From patchwork Wed Aug 19 13:18:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52549 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id A8BDB22DB1 for ; Wed, 19 Aug 2015 13:22:06 +0000 (UTC) Received: by lbck9 with SMTP id k9sf1494850lbc.0 for ; Wed, 19 Aug 2015 06:22:05 -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=ZPM+9e0Ezyk6Q/2kRNIufc0ppwRBb2g9G5DnJ1X+UU0=; b=mw+QokCvogJNOSZg9M/xb5oCkU5xDaOI7EvgDPbGMs70W+GStEhLSEmSl5pm2wJYw3 SQDY4J0oP1b1Y/qmwkC0ChmEd6zLQArwOIpVVDdkuJTIEMOkG5ZdkwksoMh6Wp47Of5e ib73QhJF2c/7I1WZLWD088YawZ62m6piECVJ2RUooUybD++OJ+7XecfVHnFHvU8HbVME jBFB2PvhENveviBTcb008qbBOwKqYMzUn/I2E1ic9uDn5F2A//bCN0i58zdA9C5rFPJM QiVGFT1bATL4c0bVz5wEzxMHJW0vRqYFrPGB0dpfk/Euk0e5l/vatJ4/OK0UKfToyxLq 2B0A== X-Gm-Message-State: ALoCoQk+w3HqP2y8F/XGq/KMGg22xjdOLePnq7ilO1vkCARPEmHrw/YIkdBKaD6GpZZACeYulpiJ X-Received: by 10.194.71.39 with SMTP id r7mr3246900wju.0.1439990525293; Wed, 19 Aug 2015 06:22:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.1 with SMTP id g1ls24450lag.46.gmail; Wed, 19 Aug 2015 06:22:04 -0700 (PDT) X-Received: by 10.112.129.104 with SMTP id nv8mr11045014lbb.63.1439990524736; Wed, 19 Aug 2015 06:22:04 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id le2si488936lbc.154.2015.08.19.06.22.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2015 06:22:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbpu9 with SMTP id pu9so3052762lbb.3 for ; Wed, 19 Aug 2015 06:22:04 -0700 (PDT) X-Received: by 10.152.26.163 with SMTP id m3mr11240386lag.86.1439990524483; Wed, 19 Aug 2015 06:22:04 -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.162.200 with SMTP id yc8csp371508lbb; Wed, 19 Aug 2015 06:22:03 -0700 (PDT) X-Received: by 10.140.46.33 with SMTP id j30mr3857364qga.4.1439990522617; Wed, 19 Aug 2015 06:22:02 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 77si1051635qgb.9.2015.08.19.06.21.57; Wed, 19 Aug 2015 06:22:02 -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 DFF3B61F69; Wed, 19 Aug 2015 13:21:57 +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 18B1761F92; Wed, 19 Aug 2015 13:19:57 +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 6F38261F36; Wed, 19 Aug 2015 13:19:46 +0000 (UTC) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by lists.linaro.org (Postfix) with ESMTPS id 44CB961F6A for ; Wed, 19 Aug 2015 13:19:22 +0000 (UTC) Received: by wibhh20 with SMTP id hh20so8213648wib.0 for ; Wed, 19 Aug 2015 06:19:21 -0700 (PDT) X-Received: by 10.194.92.143 with SMTP id cm15mr24146450wjb.17.1439990361493; Wed, 19 Aug 2015 06:19:21 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id h9sm1039322wjx.20.2015.08.19.06.19.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Aug 2015 06:19:21 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 19 Aug 2015 16:18:59 +0300 Message-Id: <1439990341-12037-6-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439990341-12037-1-git-send-email-maxim.uvarov@linaro.org> References: <1439990341-12037-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 5/7] 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.169 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 | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 55c3594..7db9747 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,11 @@ 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) { + __odp_errno = EPERM; + return -1; + } + /* recvfrom: * If the address argument is not a null pointer * and the protocol does not provide the source address of @@ -355,6 +361,11 @@ static int sock_basic_send(pktio_entry_t *pktio_entry, unsigned nb_tx; int ret; + if (pktio_entry->s.state == STATE_STOP) { + __odp_errno = EPERM; + return -1; + } + sockfd = pkt_sock->sockfd; flags = MSG_DONTWAIT; i = 0; @@ -400,6 +411,11 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int recv_msgs; int i; + if (pktio_entry->s.state == STATE_STOP) { + __odp_errno = EPERM; + return -1; + } + if (odp_unlikely(len > ODP_PACKET_SOCKET_MAX_BURST_RX)) return -1; @@ -465,6 +481,11 @@ static int sock_mmsg_send(pktio_entry_t *pktio_entry, unsigned sent_msgs = 0; unsigned flags; + if (pktio_entry->s.state == STATE_STOP) { + __odp_errno = EPERM; + return -1; + } + if (odp_unlikely(len > ODP_PACKET_SOCKET_MAX_BURST_TX)) return -1; @@ -534,11 +555,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 +587,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,