From patchwork Thu Dec 14 00:00:07 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: 121873 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6132466qgn; Wed, 13 Dec 2017 16:01:21 -0800 (PST) X-Google-Smtp-Source: ACJfBouiJukVQQQs+7BejF+FmgFBdyREDLNXKW4h9Mx9co8d9CjwLYbYrPf9iKjoWxtjZG5IN9n5 X-Received: by 10.55.49.20 with SMTP id x20mr13718487qkx.97.1513209681306; Wed, 13 Dec 2017 16:01:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513209681; cv=none; d=google.com; s=arc-20160816; b=keTrjcQCdezqYx1Q2XLqHvl19nXznVSUTJqJUwRCG9bBZRHyJ7HrZWaze3tM1aGz93 clrXMx2L/IlbBgL/Aejcfbtbc2A0Df6PesPbUbg4MIIu7NtP1N3wgVIM2RYDZbUyhDoa 6+nSWNYIt3l+svsY/n57y0jTq8Mloh7wG86mlMK+n6nwrpjWmczqKeR88NXwjeOL4sib xagDVW6NYMjKrD5QRCbq+HWMlo4il8z/YzcZuFdJVxUSJ83wRahceyeKichRfE46fgQv ctbg1VtnGCJv0/sysaCuHPN8qe4Dll69ksiCxzWVrIm91FeogMOSzz9b4RaCwN/o6Pb3 8bxg== 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=pvdE50GossgSMSbVrBG0ztLnnjhVXJviPsoUhzLqZns=; b=LX4Vz2YlZq0XOx4EBcDo6Dbs0mnyfCTmwnT+6ZCp8WbKmONUuirOoXHytSZSssrjQA vVecqOmhlNpUgFh9nyhoWgfQjpPOGcSntiP5INIT7B/WFhzXdNt+KcOhJc4CfekdC+jt igtKQPaALN/oKjBnCk9R1s76QwLA23Cyj5WP7VUbFJeNrCe8hd9cQmjqoDjtpzSjYj/m F2eYripi2mv5gXBfRfU8hdC1lkHKirFsVrwQJN39n5GuL3DeTYVl+fODb5quwPa3DlyL ilHalhST3O6+YDkXGXbK8Imsb9hWF59wXXHhHB5MRGhRQ3OcIRZ/EDRnu9Cu8nxyNau4 AABw== 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 t28si730133qte.204.2017.12.13.16.01.21; Wed, 13 Dec 2017 16:01:21 -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 E42E960927; Thu, 14 Dec 2017 00:01:20 +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 1D722608EE; Thu, 14 Dec 2017 00:00:24 +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 62DE26086F; Thu, 14 Dec 2017 00:00:16 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id D8DA86083F for ; Thu, 14 Dec 2017 00:00:14 +0000 (UTC) Received: from mxback7j.mail.yandex.net (mxback7j.mail.yandex.net [IPv6:2a02:6b8:0:1619::110]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 5532F1346242 for ; Thu, 14 Dec 2017 03:00:13 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback7j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id evPzGlG8pG-0DcurMpY; Thu, 14 Dec 2017 03:00:13 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id yIWKc0t7iQ-0Cr4hdAv; Thu, 14 Dec 2017 03:00:12 +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, 14 Dec 2017 03:00:07 +0300 Message-Id: <1513209611-8033-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513209611-8033-1-git-send-email-odpbot@yandex.ru> References: <1513209611-8033-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 340 Subject: [lng-odp] [PATCH API-NEXT v2 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: 7371c04c5dc9238b8e9f601e6650b4bc36589be9 **/ .../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; }