From patchwork Thu Dec 21 13:00:49 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: 122565 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp861224qgn; Thu, 21 Dec 2017 05:07:13 -0800 (PST) X-Google-Smtp-Source: ACJfBoshiQr5EdDkoDpVGB0lkmog2CPE0qKSCgwDgiwIfIhotY0EKLfc4p15hwubAC3OAZSFjZFz X-Received: by 10.200.51.143 with SMTP id c15mr15000579qtb.46.1513861633496; Thu, 21 Dec 2017 05:07:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513861633; cv=none; d=google.com; s=arc-20160816; b=hftGoALLnFBTLFlZ4jt9OR5Cz11OVw2vH8WfxciSjtlMAD0oXzHPz8RPu79N44B9bW PVpr16HV7Nx7VZrp9dgry3gEhjQj1II9m37sVu/XlAuNqt6E6kLEYKeAxlHQvoRPJOHF oeGe8rYv+zXboRPxqQacXMzOD5ZbldyogRz2tZ06CWBKBXqttT7Reuugnif49ZXbCL9y 10dJdIqBEA4WD7RowUlP6idu6WTrCw8hN8BTml8Q8Wra2sJpvbONVDYTzpCHK3yx+TdQ pIhS0GKQ2jAyo137dgpRtzW4ct6JrXtBCFJPfjyRI+u2uxDgA0LrDgk7Q3GzOjgIC9Fg 9dOQ== 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=RZEzo8bwViSfMTK06SRS3OzrKmXoy1owdzd8VPCL/EA=; b=FZJia9DcC5OB1j/FTXDNK8iVoRbkV590OHXu9RnSPDEVG9liaHctfD+bYBx67n6QIH Z/oCoIz7c5EmJ0IeXGJ9NjbaaAmJ9KGjj0nNZcfPzkeJK/PNjts2IPAozrqdkCd85bQl 462kvLKjs9NBqML5nCoX8fmreik69qpUZ8D/4rY1+KSfDqj6sKfOyGhjw/woiylgx3Rg o6m/qIJEMH97qgQj4RjxeQwdIrh5tvVejhE9pYHTD3HeDu1E71C+cZgMAUg2H8l04BOv 4R/d4HPhen8xCV51X/TZFTNI/plzOAoGf7QbnKhKLEalEuRs+jYzS2DIZtKGBYG85AsS bP7Q== 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 t15si1152055qtg.328.2017.12.21.05.07.13; Thu, 21 Dec 2017 05:07:13 -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 193F1614E3; Thu, 21 Dec 2017 13:07:13 +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_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 9E3A26150A; Thu, 21 Dec 2017 13:01:58 +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 A9C7E60A6E; Thu, 21 Dec 2017 13:01:17 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id 9A5FE6095E for ; Thu, 21 Dec 2017 13:00:56 +0000 (UTC) Received: from mxback8g.mail.yandex.net (mxback8g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:169]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 5B84A180451C for ; Thu, 21 Dec 2017 16:00:55 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback8g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id TfHex15A8X-0ttmYnl1; Thu, 21 Dec 2017 16:00:55 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id bK5cnSlVPU-0s6KM5m9; Thu, 21 Dec 2017 16:00:54 +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 16:00:49 +0300 Message-Id: <1513861253-18953-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513861253-18953-1-git-send-email-odpbot@yandex.ru> References: <1513861253-18953-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 340 Subject: [lng-odp] [PATCH API-NEXT v3 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: f2a1a84b43642f3d0911a351d9308d5501693290 ** Merge commit sha: ec52601dbf5fe65742cf752c2bcf4c1cc927cdc1 **/ .../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; }