From patchwork Wed Aug 26 09:10:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52716 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 C53B422E9E for ; Wed, 26 Aug 2015 09:14:23 +0000 (UTC) Received: by labia3 with SMTP id ia3sf36564741lab.3 for ; Wed, 26 Aug 2015 02:14:22 -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=J0k8hUTisHijxF3GXKGVbN5QB7Q6CA+feesfDfU2DUa4Fr00mgaYv/93twE2FAKUum nKCgA31fnjwUz0lTbOYS4piUOo0qsyusidtpoLss/iRLx7cgJNRGXxnw3NBmoDsfIxzw 0p+bhyvDsQ6sZJLdz5CFTvDjDT6mVfCL7PGw6+q5LjY1UIQE2Fl8ZMO7m1FILrPv57oP whu3di7x+7TeYbz1wkhjxH7YRwqR3CaQ9iS2eo7IMVPtNnCVExXRqRHwKdYW7LhRQw47 Qy1c+VT79Oa2P5mTfl9sDtI99cm5hpe1xCDV/4P1KUOocuJZb0ASnboEgJieSi5oUABG 6rxA== X-Gm-Message-State: ALoCoQn+qk+48ya9UMBfuh/MaSGalXTlSREGzY+OHIsOz265NC8OpLa7Chc0knv3+moCKFRXSeob X-Received: by 10.112.139.137 with SMTP id qy9mr9756280lbb.17.1440580462779; Wed, 26 Aug 2015 02:14:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.67 with SMTP id q3ls749090laq.78.gmail; Wed, 26 Aug 2015 02:14:22 -0700 (PDT) X-Received: by 10.152.10.71 with SMTP id g7mr29467651lab.61.1440580462472; Wed, 26 Aug 2015 02:14:22 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id db12si17965776lad.32.2015.08.26.02.14.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 02:14:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbbsx3 with SMTP id sx3so115996974lbb.0 for ; Wed, 26 Aug 2015 02:14:22 -0700 (PDT) X-Received: by 10.112.125.34 with SMTP id mn2mr26969282lbb.76.1440580462371; Wed, 26 Aug 2015 02:14:22 -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 yc8csp3775657lbb; Wed, 26 Aug 2015 02:14:21 -0700 (PDT) X-Received: by 10.107.132.146 with SMTP id o18mr2077220ioi.134.1440580461122; Wed, 26 Aug 2015 02:14:21 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h10si4645576ioh.54.2015.08.26.02.14.20; Wed, 26 Aug 2015 02:14:21 -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 E59E962044; Wed, 26 Aug 2015 09:14:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 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 [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id D0B2D62059; Wed, 26 Aug 2015 09:11:22 +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 3B5AC61F04; Wed, 26 Aug 2015 09:11:04 +0000 (UTC) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by lists.linaro.org (Postfix) with ESMTPS id DC3566203A for ; Wed, 26 Aug 2015 09:10:49 +0000 (UTC) Received: by lbbsx3 with SMTP id sx3so115945886lbb.0 for ; Wed, 26 Aug 2015 02:10:48 -0700 (PDT) X-Received: by 10.112.119.180 with SMTP id kv20mr4298662lbb.81.1440580248808; Wed, 26 Aug 2015 02:10:48 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-161-180.pppoe.mtu-net.ru. [91.76.161.180]) by smtp.gmail.com with ESMTPSA id kc4sm6569409lbc.39.2015.08.26.02.10.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 02:10:47 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 26 Aug 2015 12:10:35 +0300 Message-Id: <1440580237-21578-6-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440580237-21578-1-git-send-email-maxim.uvarov@linaro.org> References: <1440580237-21578-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 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.172 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,