From patchwork Wed Aug 26 15:49:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52734 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id 6E5C122E9E for ; Wed, 26 Aug 2015 15:51:28 +0000 (UTC) Received: by labip2 with SMTP id ip2sf16111635lab.1 for ; Wed, 26 Aug 2015 08:51: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=nUgd6vsWVVxvJl5OBg9OGAW4WRk3rLQs5Fu+kUnvMa4=; b=Zp0lwBjFHQtPH+Fr23u0EX8j+IUYT4IVpy5M242XetNyfud2V/nlYwe3Dki7I6iCTm GgZp3ZBUY2QWL/ZwsPiRh6lRXHGrn0SmiKvqw9fk1KLpby2NHSMovIsQZUKboXv4Zm6P RiDpWame0xD0wblpWiOB1gSa+fTt1EaZm+2pSylqekdLRXUDbPxn1VBlDBloctUbz0tj 7W+LqSbeRJxoKqadP8JD2KUpBsCEKNgpGaDlG1+phSt8idakUFi335rlVbe7aii/cAL0 nQ/u7LxNkXzMW1DsE0Di8tbm/MsUWGMdpKTJ2tfN7JUUOELiH4nZ26CDUJ/6LL1nrZvs GZpw== X-Gm-Message-State: ALoCoQlIae7hF5MHx6ATEAVpftlbw6KM7byuo8iVHmF7mzUus8YFXdIVZ+JX8pOQqlLWp0RVB+91 X-Received: by 10.180.8.74 with SMTP id p10mr2704222wia.3.1440604287454; Wed, 26 Aug 2015 08:51:27 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.228 with SMTP id h4ls880895lam.23.gmail; Wed, 26 Aug 2015 08:51:27 -0700 (PDT) X-Received: by 10.112.160.165 with SMTP id xl5mr31557029lbb.44.1440604287268; Wed, 26 Aug 2015 08:51:27 -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 rp3si16973671lbb.147.2015.08.26.08.51.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 08:51:27 -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 lbbtg9 with SMTP id tg9so123157372lbb.1 for ; Wed, 26 Aug 2015 08:51:27 -0700 (PDT) X-Received: by 10.152.37.104 with SMTP id x8mr18471278laj.29.1440604287173; Wed, 26 Aug 2015 08:51:27 -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 yc8csp4010374lbb; Wed, 26 Aug 2015 08:51:25 -0700 (PDT) X-Received: by 10.107.14.12 with SMTP id 12mr4647138ioo.177.1440604283764; Wed, 26 Aug 2015 08:51:23 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id r62si2897089ioi.130.2015.08.26.08.51.22; Wed, 26 Aug 2015 08:51:23 -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 9F2AB62077; Wed, 26 Aug 2015 15:51:22 +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 46D0D62088; Wed, 26 Aug 2015 15:49:45 +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 6F12762077; Wed, 26 Aug 2015 15:49:22 +0000 (UTC) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com [209.85.217.174]) by lists.linaro.org (Postfix) with ESMTPS id D25AA62079 for ; Wed, 26 Aug 2015 15:49:16 +0000 (UTC) Received: by lbbtg9 with SMTP id tg9so123116192lbb.1 for ; Wed, 26 Aug 2015 08:49:15 -0700 (PDT) X-Received: by 10.152.23.38 with SMTP id j6mr30532360laf.47.1440604155787; Wed, 26 Aug 2015 08:49:15 -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 w3sm6870916lag.13.2015.08.26.08.49.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 08:49:15 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 26 Aug 2015 18:49:03 +0300 Message-Id: <1440604147-24703-4-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440604147-24703-1-git-send-email-maxim.uvarov@linaro.org> References: <1440604147-24703-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv5 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.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/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,