From patchwork Thu Dec 21 17:00:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 122590 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1157748qgn; Thu, 21 Dec 2017 09:09:03 -0800 (PST) X-Google-Smtp-Source: ACJfBotrpKcv+ipgTXzfmFaVnvsA2lPsRqWG3Uosj3CMgM1UbvpDlI4HKIrNwwq1YuYUBOCOZ4eJ X-Received: by 10.55.105.131 with SMTP id e125mr14871880qkc.214.1513876143327; Thu, 21 Dec 2017 09:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513876143; cv=none; d=google.com; s=arc-20160816; b=vW03J73t8eFBTi4J63uqT4prNqXSWLzEIUquXeXIVs3gSu9Fx9AY84SsxPdItm3S+2 8ViIvr9gH2KfcPQ88wW6cKBio1QVR96FjKq4Vdx6FzRuiU3wpI2X++SKiCPdI5820J4u mKwCPRyLR2e/XdGLVdUklsYjFV6lev5PXzPQLZsCQgcjVY0wz7hHzawJi/LCULeNhkv2 61Z5kRJ4dF0biZiU2L57Y4QOJ9YqLstcWw0LgBLwVgRKyZgwbbcwElDfVaHhw2hbrbER qMQzTwmGDR8cUbhfnVLKb/qKh+OMPyg5tDgZ7I+piLfoj3IXCJOh+8QhECmlS5zZd3Sq CcMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=+avprwR9p0ib06/h5v7VTABJLP7vKVFkMXzKQ8KHJPI=; b=G8fdf+6fA5MIE9B+rmUBjQSqKXElOEtZlrD9XCFOOi/n6i6TdISjF9Mjb7Ja4kvAo2 fMpewb2T8qSdGXF45c58lGx0lOhFg49qaKJkkFJQh/uCPVo/bmtF5X2SiyuBruXquTqX O5AopM+AxCBk0J1ZtZ6ZGvrU58Zi3F7WsvnFmkooUFLazBB7GFjmYpxdGeX2uLcAFIL+ 6w9297PDoFzuEpK+LBaRKneDCZSi5Qh4KQ233CupakEBQ4FiIcJH09pUt4/QdPhTuKUK /tSyOz98BzMYz9sQld4iVERyF7Cx2Mk43HzcIv8RHj2I8SrEmDoM+MCcnuHf76gTZR8w V6pA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id s10si7794049qki.83.2017.12.21.09.09.02; Thu, 21 Dec 2017 09:09:03 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id DEB9C61516; Thu, 21 Dec 2017 17:09:02 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 2E6916151A; Thu, 21 Dec 2017 17:02:46 +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 D49F160C31; Thu, 21 Dec 2017 17:02:05 +0000 (UTC) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [5.45.198.247]) by lists.linaro.org (Postfix) with ESMTPS id 19AD861507 for ; Thu, 21 Dec 2017 17:00:49 +0000 (UTC) Received: from mxback15g.mail.yandex.net (mxback15g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:94]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 2C42844985 for ; Thu, 21 Dec 2017 20:00:48 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback15g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id dQnVr9GNJV-0mS4hwiQ; Thu, 21 Dec 2017 20:00:48 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id l1vjHaT6xA-0lXqbPOl; Thu, 21 Dec 2017 20:00:47 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 21 Dec 2017 20:00:42 +0300 Message-Id: <1513875646-25336-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513875646-25336-1-git-send-email-odpbot@yandex.ru> References: <1513875646-25336-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 340 Subject: [lng-odp] [PATCH API-NEXT v4 1/5] linux-gen: loop: support multiple loop devices X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Add support for several loop devices "loop%d". Use "loop" instead of "loop0" for backwards compatibility. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 340 (lumag:ipsec-api-example) ** https://github.com/Linaro/odp/pull/340 ** Patch: https://github.com/Linaro/odp/pull/340.patch ** Base sha: c38fc105f0e9a88dd4ebb4d9e7ac9e1160466322 ** Merge commit sha: 82c8f20abfb7a55542ca78d82428d0c4e42670d1 **/ .../linux-generic/include/odp_packet_io_internal.h | 1 + platform/linux-generic/pktio/loop.c | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 598b1ad50..25e037182 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -53,6 +53,7 @@ struct pktio_if_ops; typedef struct { odp_queue_t loopq; /**< loopback queue for "loop" device */ odp_bool_t promisc; /**< promiscuous mode state */ + uint8_t idx; /**< index of "loop" device */ } pkt_loop_t; #ifdef HAVE_PCAP diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index f887e1a2d..698d363e4 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -22,6 +22,9 @@ #include #include #include +#include + +#define MAX_LOOP 16 /* MAC address for the "loop" interface */ static const char pktio_loop_mac[] = {0x02, 0xe9, 0x34, 0x80, 0x73, 0x01}; @@ -31,15 +34,26 @@ static int loopback_stats_reset(pktio_entry_t *pktio_entry); static int loopback_open(odp_pktio_t id, pktio_entry_t *pktio_entry, const char *devname, odp_pool_t pool ODP_UNUSED) { - if (strcmp(devname, "loop")) - return -1; - + long idx; char loopq_name[ODP_QUEUE_NAME_LEN]; + if (!strcmp(devname, "loop")) { + idx = 0; + } else if (!strncmp(devname, "loop", 4)) { + char *end; + + idx = strtol(devname + 4, &end, 10); + if (idx <= 0 || idx >= MAX_LOOP || *end) + return -1; + } else { + return -1; + } + snprintf(loopq_name, sizeof(loopq_name), "%" PRIu64 "-pktio_loopq", odp_pktio_to_u64(id)); pktio_entry->s.pkt_loop.loopq = odp_queue_create(loopq_name, NULL); + pktio_entry->s.pkt_loop.idx = idx; if (pktio_entry->s.pkt_loop.loopq == ODP_QUEUE_INVALID) return -1; @@ -213,6 +227,7 @@ static int loopback_mac_addr_get(pktio_entry_t *pktio_entry ODP_UNUSED, void *mac_addr) { memcpy(mac_addr, pktio_loop_mac, ETH_ALEN); + ((uint8_t *)mac_addr)[ETH_ALEN - 1] += pktio_entry->s.pkt_loop.idx; return ETH_ALEN; }