From patchwork Thu Aug 13 11:45:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52385 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id BA03B2031F for ; Thu, 13 Aug 2015 11:48:28 +0000 (UTC) Received: by labd1 with SMTP id d1sf15958327lab.0 for ; Thu, 13 Aug 2015 04:48:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=k/6NsaS6uPl48lhdoAbNxAdfhU865HA4eLWA/mpp2Ss=; b=GFkk9smAgyMgW6j1lWnyGpX1nKI18HuFwaD/zrBIeFMmmekxmZOxCCv22S0HOZcOSM VjpYkJR1iufrC07Gb64QcwnQ89XFs5pGZxDRGbslXELiMlhxCXct8RVilyS11sdcvel5 y2O4VTfZ8No9pe4cocs7A62b4d3Ko5EtuaPzTTJuyluYIf5T2Dq0ueDDmbnP3+8Ao+oF xaz9JPvVXOT7u33ddXJ7Pmiu4gFas2oQ+6rT47JmQzUzRqad5+t7hCYyqnZEeIf0NkVD u5c6AMnBtyeT2Gn/LbjGMILN5ilcm3gld72n7QmRsA6Oc5VyEYDmcJL+eTq9JpqQU4uW Drlw== X-Gm-Message-State: ALoCoQndBozeu1Ywt4PAJ01xZLbzmD9uV3/XYuWOBku/ChAhZMdThW6nOPNG7YpKRUYxbA7e3Qb0 X-Received: by 10.180.75.49 with SMTP id z17mr8455668wiv.7.1439466507325; Thu, 13 Aug 2015 04:48:27 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.103 with SMTP id l7ls166525laf.35.gmail; Thu, 13 Aug 2015 04:48:27 -0700 (PDT) X-Received: by 10.112.166.106 with SMTP id zf10mr35585269lbb.36.1439466507155; Thu, 13 Aug 2015 04:48:27 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id r11si2020385lby.31.2015.08.13.04.48.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Aug 2015 04:48:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbbtg9 with SMTP id tg9so25670606lbb.1 for ; Thu, 13 Aug 2015 04:48:27 -0700 (PDT) X-Received: by 10.112.166.2 with SMTP id zc2mr35531667lbb.29.1439466506904; Thu, 13 Aug 2015 04:48:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp888150lba; Thu, 13 Aug 2015 04:48:25 -0700 (PDT) X-Received: by 10.55.19.97 with SMTP id d94mr64291577qkh.55.1439466505310; Thu, 13 Aug 2015 04:48:25 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 19si3269131qgf.106.2015.08.13.04.48.22; Thu, 13 Aug 2015 04:48:25 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id AC30F61D65; Thu, 13 Aug 2015 11:48:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id AD77461D5B; Thu, 13 Aug 2015 11:46:19 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 16F1061FCB; Thu, 13 Aug 2015 11:46:15 +0000 (UTC) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by lists.linaro.org (Postfix) with ESMTPS id 9D10261CD8 for ; Thu, 13 Aug 2015 11:45:47 +0000 (UTC) Received: by wicne3 with SMTP id ne3so136023068wic.0 for ; Thu, 13 Aug 2015 04:45:46 -0700 (PDT) X-Received: by 10.180.84.136 with SMTP id z8mr58397885wiy.63.1439466346889; Thu, 13 Aug 2015 04:45:46 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id ma4sm2972054wjb.38.2015.08.13.04.45.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Aug 2015 04:45:46 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 13 Aug 2015 14:45:32 +0300 Message-Id: <1439466334-16497-5-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439466334-16497-1-git-send-email-maxim.uvarov@linaro.org> References: <1439466334-16497-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 4/6] linux-generic: socket: implement pktio_start and pktio_stop X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Maxim Uvarov --- platform/linux-generic/pktio/socket.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 55c3594..0c56d70 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -248,6 +248,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, goto error; } + pktio_entry->s.state = STATE_START; return 0; error: @@ -296,6 +297,9 @@ static int sock_basic_recv(pktio_entry_t *pktio_entry, uint8_t *pkt_buf; int nb_rx = 0; + if (pktio_entry->s.state == STATE_STOP) + return 0; + /* recvfrom: * If the address argument is not a null pointer * and the protocol does not provide the source address of @@ -355,6 +359,9 @@ static int sock_basic_send(pktio_entry_t *pktio_entry, unsigned nb_tx; int ret; + if (pktio_entry->s.state == STATE_STOP) + return 0; + sockfd = pkt_sock->sockfd; flags = MSG_DONTWAIT; i = 0; @@ -400,6 +407,9 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int recv_msgs; int i; + if (pktio_entry->s.state == STATE_STOP) + return 0; + if (odp_unlikely(len > ODP_PACKET_SOCKET_MAX_BURST_RX)) return -1; @@ -465,6 +475,9 @@ static int sock_mmsg_send(pktio_entry_t *pktio_entry, unsigned sent_msgs = 0; unsigned flags; + if (pktio_entry->s.state == STATE_STOP) + return 0; + if (odp_unlikely(len > ODP_PACKET_SOCKET_MAX_BURST_TX)) return -1; @@ -534,11 +547,25 @@ static int sock_promisc_mode_get(pktio_entry_t *pktio_entry) pktio_entry->s.name); } +static int sock_start(pktio_entry_t *pktio_entry) +{ + pktio_entry->s.state = STATE_START; + return 0; +} + +static int sock_stop(pktio_entry_t *pktio_entry) +{ + pktio_entry->s.state = STATE_STOP; + return 0; +} + const pktio_if_ops_t sock_basic_pktio_ops = { .init = NULL, .term = NULL, .open = sock_basic_open, .close = sock_close, + .start = sock_start, + .stop = sock_stop, .recv = sock_basic_recv, .send = sock_basic_send, .mtu_get = sock_mtu_get, @@ -552,6 +579,8 @@ const pktio_if_ops_t sock_mmsg_pktio_ops = { .term = NULL, .open = sock_mmsg_open, .close = sock_close, + .start = sock_start, + .stop = sock_stop, .recv = sock_mmsg_recv, .send = sock_mmsg_send, .mtu_get = sock_mtu_get,