From patchwork Wed Aug 19 13:18:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52546 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 6202A22DB1 for ; Wed, 19 Aug 2015 13:20:26 +0000 (UTC) Received: by wicul11 with SMTP id ul11sf2621343wic.1 for ; Wed, 19 Aug 2015 06:20:25 -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=KxD9R+FA2mO44RJZR7O7/s5gCBaKwuoXeDJSnWUEdSs4UDsk+lc3a4V35jkzkBK2YR k7JWEorG7wD5PZGDCYTO0+XqL3Pc9QzlnnKBxNEbB3rsCQmc0Y2Z86iNlJR3+PzZFuxu WoKcl6XvOiVAlTMzPCHwraMzXC7bSpOnQ4YkCBlMQzhBP94/vq09nuo69sY9yzGGPEEL ud56LrZBpn6gUokkyFvey5b99Ma7/uuIn2bLEVWWtJUZsfGeRqFp0Cl8PX9oTS4kRJPo U8yC1du7QKV9KwycsyiCJHyAgxML3blzwVYSas+yBjuXklpXyfTvVzAM9azrtuL74Jd5 ucQw== X-Gm-Message-State: ALoCoQnC9WI2ZFpuN2xRzmZnfJ7MBrNmD8fKj8VvypkDGHWkkyTlQ7t4L+h5ybCLixF5cR2VZ2zj X-Received: by 10.180.186.36 with SMTP id fh4mr463784wic.7.1439990425650; Wed, 19 Aug 2015 06:20:25 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.234 with SMTP id w10ls27423lag.41.gmail; Wed, 19 Aug 2015 06:20:25 -0700 (PDT) X-Received: by 10.152.7.37 with SMTP id g5mr11278504laa.101.1439990425477; Wed, 19 Aug 2015 06:20:25 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id an8si482804lbd.172.2015.08.19.06.20.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2015 06:20:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by laba3 with SMTP id a3so2854713lab.1 for ; Wed, 19 Aug 2015 06:20:25 -0700 (PDT) X-Received: by 10.152.22.133 with SMTP id d5mr11111875laf.112.1439990425309; Wed, 19 Aug 2015 06:20:25 -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 yc8csp370520lbb; Wed, 19 Aug 2015 06:20:24 -0700 (PDT) X-Received: by 10.140.131.134 with SMTP id 128mr24179123qhd.44.1439990423782; Wed, 19 Aug 2015 06:20:23 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h13si1012952qhc.101.2015.08.19.06.20.23; Wed, 19 Aug 2015 06:20: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 F264D61F58; Wed, 19 Aug 2015 13:20:22 +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 0E4AA61F75; Wed, 19 Aug 2015 13:19:50 +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 A8BF961F65; Wed, 19 Aug 2015 13:19:44 +0000 (UTC) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by lists.linaro.org (Postfix) with ESMTPS id 54C7E61F71 for ; Wed, 19 Aug 2015 13:19:20 +0000 (UTC) Received: by wibhh20 with SMTP id hh20so8212797wib.0 for ; Wed, 19 Aug 2015 06:19:19 -0700 (PDT) X-Received: by 10.194.87.4 with SMTP id t4mr24961289wjz.84.1439990359571; Wed, 19 Aug 2015 06:19:19 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id h9sm1039322wjx.20.2015.08.19.06.19.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Aug 2015 06:19:19 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 19 Aug 2015 16:18:57 +0300 Message-Id: <1439990341-12037-4-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 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.215.51 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,