From patchwork Wed Dec 13 20:00:06 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: 121853 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5914423qgn; Wed, 13 Dec 2017 12:02:30 -0800 (PST) X-Google-Smtp-Source: ACJfBou1nANTwHVwEA2QFG3CkS1uyv7FMP/PMEakirvsjwXNuUkGcvXf4mYpNVh0ew6+4OPZez9B X-Received: by 10.237.61.181 with SMTP id i50mr13343951qtf.29.1513195350651; Wed, 13 Dec 2017 12:02:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513195350; cv=none; d=google.com; s=arc-20160816; b=phUY5yfjy1038XBQFCFjk3g4Afp6qhhzjryZh0LODMNtxqaa/SZWbx5c+JDs9hkSNm HfMJkATQVnCOoGZZm+VqA4gcFD5DtxX640hDyZzG+IKBDHi3PkUl+Gr5qHZTi3eZeOVf 4qAIwmr03Li157Tgbp2QZ5PSnVd1Bi30DSoCoSemsS2jwRb5oMSwjwku1VFsWsfmXAbD eyeaY6IWtf6lfE+Qo9YLGkafZ7dhBTzGERcoCVjSFacIX2vCOoiPS8amIegN42rvU804 kJ1210CuqFvraASCpQCeW1eWqPEWXUaqx92aoNjtHtmeUOwsoyinPfz/nd7oQdNt7IRE adMg== 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=cWZOFLKbxzI0CTCmDi3wF67yGCSWV++VxlNPJVxt+W0=; b=ngzUBGvNVg6FPgmN7a2W0wLcF4rrq6nqkLHkaknWU8dc9WzLO6l91E44xh5v8JR53x LNaPfL5Q/B7IPOAzeiUiExBk7PF7yCOf51orRUwfm8jUJ+JOZHapnf26jBrjY+VzTDPE NgZmb6DeYV91PkZ+Qol4U87Z94eKzeq+vlo93MSvHBfIAo+9e78vRlRfrFeUlUNUpQFV 0RoOKM9FHafuAOOjw7007yeg0CPhWMkv3rpVkY8m4t2N8qybtB0o0OnhM8xEgM/j0gyx MuV/pbVXwgYImqfMn48gepf1HTujiD5G7JWdxKzQKbtp8+CNtYO8vaqnS4TcHtuE1MrB BH2A== 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 s51si1476250qtk.308.2017.12.13.12.02.30; Wed, 13 Dec 2017 12:02:30 -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 53B06608FA; Wed, 13 Dec 2017 20:02:30 +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 E8BEA60819; Wed, 13 Dec 2017 20:01:57 +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 76F9C60925; Wed, 13 Dec 2017 20:01:48 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id B7FC86088A for ; Wed, 13 Dec 2017 20:00:26 +0000 (UTC) Received: from mxback8o.mail.yandex.net (mxback8o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::22]) by forward105o.mail.yandex.net (Yandex) with ESMTP id 2B2E04445751 for ; Wed, 13 Dec 2017 23:00:25 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback8o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id jvFFZXrenT-0PLCQMib; Wed, 13 Dec 2017 23:00:25 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id bm31k7WFt4-0IUm5YTx; Wed, 13 Dec 2017 23:00:18 +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: Wed, 13 Dec 2017 23:00:06 +0300 Message-Id: <1513195210-1807-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513195210-1807-1-git-send-email-odpbot@yandex.ru> References: <1513195210-1807-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 340 Subject: [lng-odp] [PATCH API-NEXT v1 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: d96a8207591fbcaac25b79286d7d72a537354c1f ** Merge commit sha: 83316d73abd3a48692d4212732f1f7b1e8ab1911 **/ .../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 96df72724..87c837ea3 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -21,6 +21,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}; @@ -30,15 +33,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; @@ -212,6 +226,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; }