From patchwork Fri Aug 14 11:03:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52428 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by patches.linaro.org (Postfix) with ESMTPS id A43842031F for ; Fri, 14 Aug 2015 11:05:05 +0000 (UTC) Received: by lbcli1 with SMTP id li1sf25705685lbc.2 for ; Fri, 14 Aug 2015 04:05:04 -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=FdMgazmUeExzgXQjXcOSAmvaymismfg2pFBnxhKvtHVeHv8KykMel1fr+/eIIj+2AY nNMuIK1UI6G1SKc00CQ6q65qCVZHjiNTYWsw5n0+XKI89JjCvyTCJYCZ58dQA4AAZkDT PvRX8GyGUI+kM93DaQ+UHTE253iuP5T4vQCocRBau+kUDF7r4U2wXROgxSJgZKHyWUcH vy2IYwh1OxbiQW3B7NjRJsJjsY8y/BoiWEbP6ddYhloNG3tMdbcBDDMh1K/tMmWOhODP klzlpTIw7z51sDMszk571HxzuzvH497mqhbG7PuJqgXY1nZJeNwnBIVkA80att8qfl+7 D4Qw== X-Gm-Message-State: ALoCoQmv8Sd2owNJgto5YIbmuqQduNJoUvelrGy5m0b/N/prZfbd7x2FXsg5wU2uw6V4GDswjtRv X-Received: by 10.112.13.200 with SMTP id j8mr12871490lbc.14.1439550304627; Fri, 14 Aug 2015 04:05:04 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.219.34 with SMTP id pl2ls349285lac.84.gmail; Fri, 14 Aug 2015 04:05:04 -0700 (PDT) X-Received: by 10.152.20.4 with SMTP id j4mr20762390lae.7.1439550304359; Fri, 14 Aug 2015 04:05:04 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id jo12si5751633lab.37.2015.08.14.04.05.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Aug 2015 04:05:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbcbn3 with SMTP id bn3so43035377lbc.2 for ; Fri, 14 Aug 2015 04:05:04 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr42496058lbc.41.1439550304250; Fri, 14 Aug 2015 04:05: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.7.198 with SMTP id l6csp1531864lba; Fri, 14 Aug 2015 04:05:03 -0700 (PDT) X-Received: by 10.55.22.16 with SMTP id g16mr70643815qkh.87.1439550301331; Fri, 14 Aug 2015 04:05:01 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id r123si8899573qha.22.2015.08.14.04.05.00; Fri, 14 Aug 2015 04:05:01 -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 48C8761EC4; Fri, 14 Aug 2015 11:05:00 +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 5B7BC61E95; Fri, 14 Aug 2015 11:03:31 +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 6E91D61DE1; Fri, 14 Aug 2015 11:03:28 +0000 (UTC) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by lists.linaro.org (Postfix) with ESMTPS id E70A361DE1 for ; Fri, 14 Aug 2015 11:03:21 +0000 (UTC) Received: by wicne3 with SMTP id ne3so15618495wic.1 for ; Fri, 14 Aug 2015 04:03:21 -0700 (PDT) X-Received: by 10.180.75.9 with SMTP id y9mr5829286wiv.67.1439550200966; Fri, 14 Aug 2015 04:03:20 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id c11sm2538630wib.1.2015.08.14.04.03.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Aug 2015 04:03:20 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 14 Aug 2015 14:03:00 +0300 Message-Id: <1439550184-28383-4-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439550184-28383-1-git-send-email-maxim.uvarov@linaro.org> References: <1439550184-28383-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 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.170 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,