From patchwork Wed Aug 26 09:10:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52714 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id B520522E9E for ; Wed, 26 Aug 2015 09:13:05 +0000 (UTC) Received: by wicja10 with SMTP id ja10sf3757822wic.2 for ; Wed, 26 Aug 2015 02:13: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=nUgd6vsWVVxvJl5OBg9OGAW4WRk3rLQs5Fu+kUnvMa4=; b=T0xl32Njgv61NQvlk0FM2+pCTqM2Pruxc1oJcsBWn8v5cVm08hW42PtYNyAg0IvZ13 tApsRH7Ngh9kdtClR4yAigeE0dbW/H8l2eXCGlzdRs0TFb3Cjlb8+HzN1nSsgMHey9+y g9Dh1G5Cgf+K+wh0DvGNd5/h2YqZVe4BugynnM73qFtlcPCxEVg/7M8+0hvkSv7iE0xX 8dWGTXJad0lWCWz3QRJsF8S+YjBrSrCmvKtaL0Q2/mqutmRXwCz0yyMLkMogvMLaXsub WbQ9FpPYivMzIb+6uw9Udl+RelEcIsb4NG/SMzO9xA3DjnYtiXDdzCK0Yk2xtSLZX0Qc uJhw== X-Gm-Message-State: ALoCoQnR6TBjzX9rS/pKaoLKAJBn7w8v+KOIUdOWpXCEQhwdm9o7rVXsdIxCeUnApMyfNvPLYZUM X-Received: by 10.112.189.105 with SMTP id gh9mr9821777lbc.16.1440580385060; Wed, 26 Aug 2015 02:13:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.135 with SMTP id q7ls754158laj.77.gmail; Wed, 26 Aug 2015 02:13:04 -0700 (PDT) X-Received: by 10.152.6.41 with SMTP id x9mr19002595lax.120.1440580384770; Wed, 26 Aug 2015 02:13:04 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id lc8si18289678lac.151.2015.08.26.02.13.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 02:13:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbcbn3 with SMTP id bn3so115652390lbc.2 for ; Wed, 26 Aug 2015 02:13:04 -0700 (PDT) X-Received: by 10.112.146.135 with SMTP id tc7mr11859582lbb.35.1440580384668; Wed, 26 Aug 2015 02:13: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 yc8csp3774954lbb; Wed, 26 Aug 2015 02:13:03 -0700 (PDT) X-Received: by 10.107.166.13 with SMTP id p13mr2521502ioe.0.1440580383513; Wed, 26 Aug 2015 02:13:03 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id sd11si3054564igb.20.2015.08.26.02.12.59; Wed, 26 Aug 2015 02:13:03 -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 7E92B6203A; Wed, 26 Aug 2015 09:12:59 +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 439D562048; Wed, 26 Aug 2015 09:11: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 0F33262022; Wed, 26 Aug 2015 09:10:59 +0000 (UTC) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com [209.85.215.47]) by lists.linaro.org (Postfix) with ESMTPS id 75F5C62034 for ; Wed, 26 Aug 2015 09:10:47 +0000 (UTC) Received: by laba3 with SMTP id a3so115191918lab.1 for ; Wed, 26 Aug 2015 02:10:46 -0700 (PDT) X-Received: by 10.152.37.196 with SMTP id a4mr30387295lak.59.1440580246429; Wed, 26 Aug 2015 02:10:46 -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.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 02:10:45 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 26 Aug 2015 12:10:33 +0300 Message-Id: <1440580237-21578-4-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 3/7] linux-generic: loop: 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.181 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/loop.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index 188a9ee..f61ccd5 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -18,6 +18,8 @@ #include #include +#include + /* MTU to be reported for the "loop" interface */ #define PKTIO_LOOP_MTU 1500 /* MAC address for the "loop" interface */ @@ -39,6 +41,7 @@ static int loopback_open(odp_pktio_t id, pktio_entry_t *pktio_entry, if (pktio_entry->s.pkt_loop.loopq == ODP_QUEUE_INVALID) return -1; + pktio_entry->s.state = STATE_START; return 0; } @@ -54,6 +57,11 @@ static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[], odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; queue_entry_t *qentry; + if (pktio_entry->s.state == STATE_STOP) { + __odp_errno = EPERM; + return -1; + } + qentry = queue_to_qentry(pktio_entry->s.pkt_loop.loopq); nbr = queue_deq_multi(qentry, hdr_tbl, len); @@ -72,6 +80,11 @@ static int loopback_send(pktio_entry_t *pktio_entry, odp_packet_t pkt_tbl[], queue_entry_t *qentry; unsigned i; + if (pktio_entry->s.state == STATE_STOP) { + __odp_errno = EPERM; + return -1; + } + for (i = 0; i < len; ++i) hdr_tbl[i] = odp_buf_to_hdr(_odp_packet_to_buffer(pkt_tbl[i])); @@ -103,11 +116,25 @@ static int loopback_promisc_mode_get(pktio_entry_t *pktio_entry) return pktio_entry->s.pkt_loop.promisc ? 1 : 0; } +static int loopback_start(pktio_entry_t *pktio_entry) +{ + pktio_entry->s.state = STATE_START; + return 0; +} + +static int loopback_stop(pktio_entry_t *pktio_entry) +{ + pktio_entry->s.state = STATE_STOP; + return 0; +} + const pktio_if_ops_t loopback_pktio_ops = { .init = NULL, .term = NULL, .open = loopback_open, .close = loopback_close, + .start = loopback_start, + .stop = loopback_stop, .recv = loopback_recv, .send = loopback_send, .mtu_get = loopback_mtu_get,