From patchwork Tue Sep 26 06:00:00 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: 114213 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3451142qgf; Mon, 25 Sep 2017 23:01:14 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBkEsZ/JO4GdZ8J5583uLIscTnTltz15duru9eovjP10r0q68rha7nzYm/HxEjUCTWsmfMD X-Received: by 10.107.183.213 with SMTP id h204mr13866150iof.61.1506405673910; Mon, 25 Sep 2017 23:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506405673; cv=none; d=google.com; s=arc-20160816; b=tRIrLtKdTBD/MP3+LmcNXRBBVMpLUsamqjhnY1FTNyUGoQywiUoBBaFUJUbvQxf/+h FzaHA/ZsZ7odXu09YwVXJ7qW2OZY+OUp4FFdNljScTkMptIEu1Jnzo6U7gvc1FW4lCtO 8qsR4+fTnFZg7vLsFVImxWY6ka2HDqdxoAGpQm9DtVV8V8+qg75WJf41tsTidpzUw2WR uuvnC9MM4UuGJic3pUtnXm9qXZSyDu2WG0B3Pp4t4oqnKWSw5hFnD5OrtLfvuEn/ALzD EnyymXrSU1X+FS1muaMVMhj11qMlapa7Ntrt6+zI7u9eHOqq88SM7o8BXBGtkPbQXvX1 qNfA== 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=+mnG0+wXMN58IhGQyr3rkvpYfs2/Mej8+YTP0Nq2H40=; b=t4Bom4fXeiWPHYxQ55l77LApf+w9b7Mz8glLHQathZ48chWG7/pMlZCYFluoGnDQc/ EgCG1rQOHVftJ4bXPHlGGnwX6hIRS8TY6dU4rsbAogww2F3hlJ5b3RJeg+tgCmNvefrw 5F5SZKMfmtZ3hpq1Fiyq6y4sgAZCoPkXnMI5vHmajWFJcCBS2Sca3FtU9oc5gox2gEr0 nY4FKSt3e+/0pgzg3wcvFv0coLk6upO1HNKs4TqRTrVlZO1v9e4ioC91zT9L8+ChbTlF RXr7idCM4S15jzkmbtA4ZMZ/ZNf7R9TAFNRCeZ7nZlM4x/maiFVurxlbwkJkVYucZYu+ GDXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 206si6605567ioc.276.2017.09.25.23.01.13; Mon, 25 Sep 2017 23:01:13 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 7758460D6A; Tue, 26 Sep 2017 06:01: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,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 92B3360BFB; Tue, 26 Sep 2017 06:00:27 +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 A612B60CD1; Tue, 26 Sep 2017 06:00:18 +0000 (UTC) Received: from forward103o.mail.yandex.net (forward103o.mail.yandex.net [37.140.190.177]) by lists.linaro.org (Postfix) with ESMTPS id 15E1260A54 for ; Tue, 26 Sep 2017 06:00:12 +0000 (UTC) Received: from mxback17j.mail.yandex.net (mxback17j.mail.yandex.net [IPv6:2a02:6b8:0:1619::93]) by forward103o.mail.yandex.net (Yandex) with ESMTP id 5FF9D5882BCD for ; Tue, 26 Sep 2017 09:00:10 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback17j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id CWU7O1uPT7-0AH0w6gE; Tue, 26 Sep 2017 09:00:10 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 72uMtCPv0h-09mmbAIt; Tue, 26 Sep 2017 09:00:09 +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: Tue, 26 Sep 2017 09:00:00 +0300 Message-Id: <1506405608-3507-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> References: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v1 1/9] linux-gen: pktio: introduce generic pktio_ops data storage 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: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: e89a0ed9c4cd6d7dc947b978ad1dcabc6d5a21a2 ** Merge commit sha: 160ad8615ce66c98231aa400863c82e89045d491 **/ platform/linux-dpdk/include/odp_packet_io_internal.h | 5 ++++- platform/linux-generic/include/odp_packet_io_internal.h | 5 ++++- platform/linux-generic/include/odp_pktio_ops_subsystem.h | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/platform/linux-dpdk/include/odp_packet_io_internal.h b/platform/linux-dpdk/include/odp_packet_io_internal.h index ec1d0c213..07db8cab0 100644 --- a/platform/linux-dpdk/include/odp_packet_io_internal.h +++ b/platform/linux-dpdk/include/odp_packet_io_internal.h @@ -42,7 +42,10 @@ typedef union pktio_entry_u pktio_entry_t; struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ - pktio_ops_data_t ops_data; + union { + pktio_ops_data_t ops_data; + uint8_t _ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; + }; /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 9fe9aeaa7..0201a47fa 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -48,7 +48,10 @@ typedef union pktio_entry_u pktio_entry_t; struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ - pktio_ops_data_t ops_data; /**< IO operation specific data */ + union { + pktio_ops_data_t ops_data; /**< IO operation specific data */ + uint8_t _ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; + }; /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 7a915b82c..a8da6197b 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -103,4 +103,11 @@ typedef union { /* Extract pktio ops data from pktio entry structure */ #define ops_data(mod) s.ops_data.mod +/* Maximum size of pktio specific ops data.*/ +#define ODP_PKTIO_ODPS_DATA_MAX_SIZE 80000 + +/* Extract pktio ops data from pktio entry structure */ +#define odp_ops_data(_p, _mod) \ + ((pktio_ops_ ## _mod ## _data_t *)(uintptr_t)_p->s._ops_data) + #endif From patchwork Tue Sep 26 06:00:01 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: 114214 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3451693qgf; Mon, 25 Sep 2017 23:01:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDbWirsY1EVdtv2bJLr70WVgaUUFBxSLQv6slIN7Nrrx28su/BWgsH1P/J6ee7g+GzkVN0Z X-Received: by 10.107.142.211 with SMTP id q202mr12477121iod.65.1506405718736; Mon, 25 Sep 2017 23:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506405718; cv=none; d=google.com; s=arc-20160816; b=RRu01JPbbk+1i3Pdc17+joQr4vV3mydii52XaOXc5TN9QN8jaLy+Udm6wE6j7UQ3vS FcNd1nPFpvsMf+YqOUQFh97J3VpFr6Xnuld5WD9PjlQQYKZZH+qxcQh3CaMwkeVc7t/G 4H/EBgCbt57vvPyD9qOaHWUFhHQM/FXm8e+TMEIPFqATUU9UpxaRSLXJv+j8mscaj4hW xRqFKlf/nIkryBZYf2hHKFKuRjFUao596McAmOqQIAygbBbvaRx+ReBgHKWAgglS6qQe LnW+zNIhh0p5rLb/u7N3MrJs+DwZCgMO11RGW0TvfXC+UbFO/W2qGrKfDmBN+48ONTZf SQUg== 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=54N3HsoGHlentaGbT9zLJCcPXIQDruc/Pba3NjBvDgE=; b=CgSfA7wu6B6SNYFYXDIqb17Muv1vXURpZfrtxbsGZ0qdCddLgG/qoLspXqcx6b2uKa 3gv3IGYyNYQtNj+8VqFeyNM+IRII8DonjAv8rfoTsbXsLzfEiKBs+zQbBpvPyTmq/Cc+ A6wal1Zb2+DjpgkFD8plSrd6LJ4VK5wViTMVG3fdXcD8fBB9zrzx0wbs7kMIsVRR2p1H iW8UWZIpCJEFaxPOKPi5dkqxflw/lWjG6BcagfZ/BSY/xbwZP717jE00Sm/r0MowK0CM z67n8+7f8ttelN4TKpMpvmyB8VBujyc4jy3klgSyq1utJ2bqikxXwySZQWARujmy6fCZ w+2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g64si6678870ioa.409.2017.09.25.23.01.58; Mon, 25 Sep 2017 23:01:58 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 3019560D87; Tue, 26 Sep 2017 06:01:58 +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,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 EE55360C4B; Tue, 26 Sep 2017 06:00:36 +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 3779860CCC; Tue, 26 Sep 2017 06:00:20 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id B91D260A59 for ; Tue, 26 Sep 2017 06:00:12 +0000 (UTC) Received: from mxback2o.mail.yandex.net (mxback2o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1c]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 1C2BB2D841CC for ; Tue, 26 Sep 2017 09:00:11 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback2o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id I0Kyiu4tXp-0BTuUA3V; Tue, 26 Sep 2017 09:00:11 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 72uMtCPv0h-0AmiCFWP; Tue, 26 Sep 2017 09:00:10 +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: Tue, 26 Sep 2017 09:00:01 +0300 Message-Id: <1506405608-3507-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> References: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v1 2/9] linux-gen: pktio: loopback: use generic pktio_ops data storage 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: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: e89a0ed9c4cd6d7dc947b978ad1dcabc6d5a21a2 ** Merge commit sha: 160ad8615ce66c98231aa400863c82e89045d491 **/ .../include/odp_pktio_ops_subsystem.h | 2 -- platform/linux-generic/pktio/loopback.c | 33 ++++++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index a8da6197b..415b8365f 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -80,7 +80,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { /* All implementations of this subsystem */ #include -#include #include #include #include @@ -92,7 +91,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { typedef union { void *dpdk; pktio_ops_ipc_data_t ipc; - pktio_ops_loopback_data_t loopback; pktio_ops_netmap_data_t netmap; pktio_ops_pcap_data_t pcap; pktio_ops_socket_data_t socket; diff --git a/platform/linux-generic/pktio/loopback.c b/platform/linux-generic/pktio/loopback.c index 3d4c764ab..ed8222a98 100644 --- a/platform/linux-generic/pktio/loopback.c +++ b/platform/linux-generic/pktio/loopback.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include /* MAC address for the "loop" interface */ static const char pktio_loop_mac[] = {0x02, 0xe9, 0x34, 0x80, 0x73, 0x01}; @@ -28,6 +30,9 @@ 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) { + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); + if (strcmp(devname, "loop")) return -1; @@ -35,10 +40,9 @@ static int loopback_open(odp_pktio_t id, pktio_entry_t *pktio_entry, snprintf(loopq_name, sizeof(loopq_name), "%" PRIu64 "-pktio_loopq", odp_pktio_to_u64(id)); - pktio_entry->ops_data(loopback).loopq = - odp_queue_create(loopq_name, NULL); + pkt_lbk->loopq = odp_queue_create(loopq_name, NULL); - if (pktio_entry->ops_data(loopback).loopq == ODP_QUEUE_INVALID) + if (pkt_lbk->loopq == ODP_QUEUE_INVALID) return -1; loopback_stats_reset(pktio_entry); @@ -48,7 +52,10 @@ static int loopback_open(odp_pktio_t id, pktio_entry_t *pktio_entry, static int loopback_close(pktio_entry_t *pktio_entry) { - return odp_queue_destroy(pktio_entry->ops_data(loopback).loopq); + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); + + return odp_queue_destroy(pkt_lbk->loopq); } static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, @@ -64,13 +71,15 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_time_t *ts = NULL; int num_rx = 0; int failed = 0; + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); if (odp_unlikely(len > QUEUE_MULTI_MAX)) len = QUEUE_MULTI_MAX; odp_ticketlock_lock(&pktio_entry->s.rxl); - queue = queue_fn->from_ext(pktio_entry->ops_data(loopback).loopq); + queue = queue_fn->from_ext(pkt_lbk->loopq); nbr = queue_fn->deq_multi(queue, hdr_tbl, len); if (pktio_entry->s.config.pktin.bit.ts_all || @@ -159,6 +168,8 @@ static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, int i; int ret; uint32_t bytes = 0; + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); if (odp_unlikely(len > QUEUE_MULTI_MAX)) len = QUEUE_MULTI_MAX; @@ -170,7 +181,7 @@ static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_ticketlock_lock(&pktio_entry->s.txl); - queue = queue_fn->from_ext(pktio_entry->ops_data(loopback).loopq); + queue = queue_fn->from_ext(pkt_lbk->loopq); ret = queue_fn->enq_multi(queue, hdr_tbl, len); if (ret > 0) { @@ -223,13 +234,19 @@ static int loopback_capability(pktio_entry_t *pktio_entry ODP_UNUSED, static int loopback_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - pktio_entry->ops_data(loopback).promisc = enable; + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); + + pkt_lbk->promisc = enable; return 0; } static int loopback_promisc_mode_get(pktio_entry_t *pktio_entry) { - return pktio_entry->ops_data(loopback).promisc ? 1 : 0; + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); + + return pkt_lbk->promisc ? 1 : 0; } static int loopback_stats(pktio_entry_t *pktio_entry, From patchwork Tue Sep 26 06:00:02 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: 114215 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3452452qgf; Mon, 25 Sep 2017 23:02:56 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCpP3wtAPTXJXPeHNNx6fksC+U8ssROAAP1NQJoNrsymKvascIgsfSiiASj1lw67ayo+PhA X-Received: by 10.107.28.129 with SMTP id c123mr12465810ioc.303.1506405776672; Mon, 25 Sep 2017 23:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506405776; cv=none; d=google.com; s=arc-20160816; b=XQ7B/Nq9+g9gzNtGTIBCt5K7lXYYl+D4tuQXg0o05UEdlX6M7d7IJM0b8Me08ofFsb I+NQg47k1eNarV/B2K2QXME0V0yxtY8CKzY8e3Crs76c8lYkCzoBsL5bvsuUTsBRxG9E ZKGtKH630DkX0B/Onev5+39D1NP6p1wry4JnmiiKPwq+/bNh6QQUQ3nc/r5ofQlzC6Vi NQ4Zt53xDt5qagB7jNxIRZkp6okGGuFM8QLlN7T16K5Lg/ud2wdSwIWvdXXFnUSnxgqZ jK95hteA0B/9JpoSDNl6eq5kPyM+llBSC7MBIT1gbxNsf77lqVf/ui9hl89yvEbyO/yJ 9eQg== 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=/erOvSgWmZnQEI36XLHep2Cq8zOxwlTmXbEZ2g4znNE=; b=fi4KKw8JfVOqG2c7iGRxmL5prZjRkFdizD2gEVOjtm2IOH5+9ONXnq9V4M4CVI5XML JXG04DvbkbGQmtAH/3Jglsb/USLt40MUFbraE75QaBi+VigUokewL6ILekBAVoI2FfW5 6mDF8DWdABylnYW6F7wk+CRkSPgGTu0KYkTj5bXdlCLy9+nlGWo++qGEsSQ39hwWU1tR 8jNBgZQTikrbzV7eNPXzlV2jmtCDNucO+5jFHKdIuTnBTcd60N1U0oV4B3rsYWauCHmt PUZiwmU8ifa4tL1aIidl9lPx3VUdUdLyI78onljk+3HRa6QEcFhhYeFxDyJr8k28XAWR lFIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n66si6731158iof.171.2017.09.25.23.02.56; Mon, 25 Sep 2017 23:02:56 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 257BE60D00; Tue, 26 Sep 2017 06:02:56 +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,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 5D2F060CDE; Tue, 26 Sep 2017 06:00:42 +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 45F8E60A59; Tue, 26 Sep 2017 06:00:21 +0000 (UTC) Received: from forward104o.mail.yandex.net (forward104o.mail.yandex.net [37.140.190.179]) by lists.linaro.org (Postfix) with ESMTPS id 0E71D60AEF for ; Tue, 26 Sep 2017 06:00:13 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward104o.mail.yandex.net (Yandex) with ESMTP id 08F3A701B73 for ; Tue, 26 Sep 2017 09:00:12 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id jkaZHW1sCh-0Bcqpgwg; Tue, 26 Sep 2017 09:00:11 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 72uMtCPv0h-0Bm8QKsb; Tue, 26 Sep 2017 09:00:11 +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: Tue, 26 Sep 2017 09:00:02 +0300 Message-Id: <1506405608-3507-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> References: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v1 3/9] linux-gen: pktio: socket: move common code away from socket pktios 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: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: e89a0ed9c4cd6d7dc947b978ad1dcabc6d5a21a2 ** Merge commit sha: 160ad8615ce66c98231aa400863c82e89045d491 **/ platform/linux-generic/Makefile.am | 2 + .../linux-generic/include/odp_pktio_ops_socket.h | 76 ----- platform/linux-generic/pktio/common.c | 368 +++++++++++++++++++++ platform/linux-generic/pktio/common.h | 81 +++++ platform/linux-generic/pktio/dpdk.c | 1 + platform/linux-generic/pktio/ethtool.c | 1 + platform/linux-generic/pktio/ethtool.h | 15 + platform/linux-generic/pktio/netmap.c | 2 + platform/linux-generic/pktio/socket.c | 354 +------------------- platform/linux-generic/pktio/socket_mmap.c | 2 + platform/linux-generic/pktio/tap.c | 1 + 11 files changed, 475 insertions(+), 428 deletions(-) create mode 100644 platform/linux-generic/pktio/common.h create mode 100644 platform/linux-generic/pktio/ethtool.h diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 7d1066f38..6ede2d55b 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -186,6 +186,8 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_internal.h \ ${srcdir}/include/odp_packet_io_internal.h \ ${srcdir}/include/odp_packet_io_ring_internal.h \ + ${srcdir}/pktio/ethtool.h \ + ${srcdir}/pktio/common.h \ ${srcdir}/pktio/dpdk.h \ ${srcdir}/include/odp_pktio_ops_ipc.h \ ${srcdir}/include/odp_pktio_ops_loopback.h \ diff --git a/platform/linux-generic/include/odp_pktio_ops_socket.h b/platform/linux-generic/include/odp_pktio_ops_socket.h index 32c49c08e..5ed444df7 100644 --- a/platform/linux-generic/include/odp_pktio_ops_socket.h +++ b/platform/linux-generic/include/odp_pktio_ops_socket.h @@ -93,80 +93,4 @@ ethaddrs_equal(unsigned char mac_a[], unsigned char mac_b[]) return !memcmp(mac_a, mac_b, ETH_ALEN); } -/** - * Read the MAC address from a packet socket - */ -int mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]); - -/** - * Read the MTU from a packet socket - */ -uint32_t mtu_get_fd(int fd, const char *name); - -/** - * Enable/Disable promisc mode for a packet socket - */ -int promisc_mode_set_fd(int fd, const char *name, int enable); - -/** - * Return promisc mode of a packet socket - */ -int promisc_mode_get_fd(int fd, const char *name); - -/** - * Return link status of a packet socket (up/down) - */ -int link_status_fd(int fd, const char *name); - -/** - * Get enabled RSS hash protocols of a packet socket - * - * @param fd Socket file descriptor - * @param name Interface name - * @param hash_proto[out] Hash protocols - * - * @returns Number enabled hash protocols - */ -int rss_conf_get_fd(int fd, const char *name, - odp_pktin_hash_proto_t *hash_proto); - -/** - * Get supported RSS hash protocols of a packet socket - * - * Can be both read and modified. - * - * @param fd Socket file descriptor - * @param name Interface name - * @param hash_proto[out] Hash protocols - * - * @returns Number of supported hash protocols - */ -int rss_conf_get_supported_fd(int fd, const char *name, - odp_pktin_hash_proto_t *hash_proto); - -/** - * Set RSS hash protocols of a packet socket - * - * @param fd Socket file descriptor - * @param name Interface name - * @param hash_proto Hash protocols - * - * @retval 0 on success - * @retval <0 on failure - */ -int rss_conf_set_fd(int fd, const char *name, - const odp_pktin_hash_proto_t *proto); - -/** - * Print enabled RSS hash protocols - * - * @param hash_proto Hash protocols - */ -void rss_conf_print(const odp_pktin_hash_proto_t *hash_proto); - -/** - * Get ethtool statistics of a packet socket - */ -int ethtool_stats_get_fd(int fd, const char *name, odp_pktio_stats_t *stats); - #endif diff --git a/platform/linux-generic/pktio/common.c b/platform/linux-generic/pktio/common.c index 611bb451a..caefdc3a1 100644 --- a/platform/linux-generic/pktio/common.c +++ b/platform/linux-generic/pktio/common.c @@ -7,7 +7,18 @@ #include #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include int sock_stats_reset_fd(pktio_entry_t *pktio_entry, int fd) { @@ -80,3 +91,360 @@ int sock_stats_fd(pktio_entry_t *pktio_entry, return ret; } + +/* + * ODP_PACKET_SOCKET_MMSG: + * ODP_PACKET_SOCKET_MMAP: + * ODP_PACKET_NETMAP: + */ +uint32_t mtu_get_fd(int fd, const char *name) +{ + struct ifreq ifr; + int ret; + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + ret = ioctl(fd, SIOCGIFMTU, &ifr); + if (ret < 0) { + __odp_errno = errno; + ODP_DBG("ioctl(SIOCGIFMTU): %s: \"%s\".\n", strerror(errno), + ifr.ifr_name); + return 0; + } + return ifr.ifr_mtu; +} + +/** + * ODP_PACKET_SOCKET_MMSG: + * ODP_PACKET_SOCKET_MMAP: + * ODP_PACKET_NETMAP: + */ +int mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]) +{ + struct ifreq ethreq; + int ret; + + memset(ðreq, 0, sizeof(ethreq)); + snprintf(ethreq.ifr_name, IF_NAMESIZE, "%s", name); + ret = ioctl(fd, SIOCGIFHWADDR, ðreq); + if (ret != 0) { + __odp_errno = errno; + ODP_ERR("ioctl(SIOCGIFHWADDR): %s: \"%s\".\n", strerror(errno), + ethreq.ifr_name); + return -1; + } + + memcpy(mac_dst, (unsigned char *)ethreq.ifr_ifru.ifru_hwaddr.sa_data, + ETH_ALEN); + return 0; +} + +/* + * ODP_PACKET_SOCKET_MMSG: + * ODP_PACKET_SOCKET_MMAP: + * ODP_PACKET_NETMAP: + */ +int promisc_mode_set_fd(int fd, const char *name, int enable) +{ + struct ifreq ifr; + int ret; + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + ret = ioctl(fd, SIOCGIFFLAGS, &ifr); + if (ret < 0) { + __odp_errno = errno; + ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), + ifr.ifr_name); + return -1; + } + + if (enable) + ifr.ifr_flags |= IFF_PROMISC; + else + ifr.ifr_flags &= ~(IFF_PROMISC); + + ret = ioctl(fd, SIOCSIFFLAGS, &ifr); + if (ret < 0) { + __odp_errno = errno; + ODP_DBG("ioctl(SIOCSIFFLAGS): %s: \"%s\".\n", strerror(errno), + ifr.ifr_name); + return -1; + } + return 0; +} + +/* + * ODP_PACKET_SOCKET_MMSG: + * ODP_PACKET_SOCKET_MMAP: + * ODP_PACKET_NETMAP: + */ +int promisc_mode_get_fd(int fd, const char *name) +{ + struct ifreq ifr; + int ret; + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + ret = ioctl(fd, SIOCGIFFLAGS, &ifr); + if (ret < 0) { + __odp_errno = errno; + ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), + ifr.ifr_name); + return -1; + } + + return !!(ifr.ifr_flags & IFF_PROMISC); +} + +/* + * ODP_PACKET_SOCKET_MMSG: + * ODP_PACKET_SOCKET_MMAP: + * ODP_PACKET_NETMAP: + */ +int link_status_fd(int fd, const char *name) +{ + struct ifreq ifr; + int ret; + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + ret = ioctl(fd, SIOCGIFFLAGS, &ifr); + if (ret < 0) { + __odp_errno = errno; + ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), + ifr.ifr_name); + return -1; + } + + return !!(ifr.ifr_flags & IFF_RUNNING); +} + +/** + * Get enabled hash options of a packet socket + * + * @param fd Socket file descriptor + * @param name Interface name + * @param flow_type Packet flow type + * @param options[out] Enabled hash options + * + * @retval 0 on success + * @retval <0 on failure + */ +static inline int get_rss_hash_options(int fd, const char *name, + uint32_t flow_type, uint64_t *options) +{ + struct ifreq ifr; + struct ethtool_rxnfc rsscmd; + + memset(&ifr, 0, sizeof(ifr)); + memset(&rsscmd, 0, sizeof(rsscmd)); + *options = 0; + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + + rsscmd.cmd = ETHTOOL_GRXFH; + rsscmd.flow_type = flow_type; + + ifr.ifr_data = &rsscmd; + + if (ioctl(fd, SIOCETHTOOL, &ifr) < 0) + return -1; + + *options = rsscmd.data; + return 0; +} + +int rss_conf_get_fd(int fd, const char *name, + odp_pktin_hash_proto_t *hash_proto) +{ + uint64_t options; + int rss_enabled = 0; + + memset(hash_proto, 0, sizeof(odp_pktin_hash_proto_t)); + + get_rss_hash_options(fd, name, IPV4_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST)) { + hash_proto->proto.ipv4 = 1; + rss_enabled++; + } + get_rss_hash_options(fd, name, TCP_V4_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && + (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { + hash_proto->proto.ipv4_tcp = 1; + rss_enabled++; + } + get_rss_hash_options(fd, name, UDP_V4_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && + (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { + hash_proto->proto.ipv4_udp = 1; + rss_enabled++; + } + get_rss_hash_options(fd, name, IPV6_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST)) { + hash_proto->proto.ipv6 = 1; + rss_enabled++; + } + get_rss_hash_options(fd, name, TCP_V6_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && + (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { + hash_proto->proto.ipv6_tcp = 1; + rss_enabled++; + } + get_rss_hash_options(fd, name, UDP_V6_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && + (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { + hash_proto->proto.ipv6_udp = 1; + rss_enabled++; + } + return rss_enabled; +} + +/** + * Set hash options of a packet socket + * + * @param fd Socket file descriptor + * @param name Interface name + * @param flow_type Packet flow type + * @param options Hash options + * + * @retval 0 on success + * @retval <0 on failure + */ +static inline int set_rss_hash(int fd, const char *name, + uint32_t flow_type, uint64_t options) +{ + struct ifreq ifr; + struct ethtool_rxnfc rsscmd; + + memset(&rsscmd, 0, sizeof(rsscmd)); + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + + rsscmd.cmd = ETHTOOL_SRXFH; + rsscmd.flow_type = flow_type; + rsscmd.data = options; + + ifr.ifr_data = &rsscmd; + + if (ioctl(fd, SIOCETHTOOL, &ifr) < 0) + return -1; + + return 0; +} + +int rss_conf_set_fd(int fd, const char *name, + const odp_pktin_hash_proto_t *hash_proto) +{ + uint64_t options; + odp_pktin_hash_proto_t cur_hash; + + /* Compare to currently set hash protocols */ + rss_conf_get_fd(fd, name, &cur_hash); + + if (hash_proto->proto.ipv4_udp && !cur_hash.proto.ipv4_udp) { + options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; + if (set_rss_hash(fd, name, UDP_V4_FLOW, options)) + return -1; + } + if (hash_proto->proto.ipv4_tcp && !cur_hash.proto.ipv4_tcp) { + options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; + if (set_rss_hash(fd, name, TCP_V4_FLOW, options)) + return -1; + } + if (hash_proto->proto.ipv6_udp && !cur_hash.proto.ipv6_udp) { + options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; + if (set_rss_hash(fd, name, UDP_V6_FLOW, options)) + return -1; + } + if (hash_proto->proto.ipv6_tcp && !cur_hash.proto.ipv6_tcp) { + options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; + if (set_rss_hash(fd, name, TCP_V6_FLOW, options)) + return -1; + } + if (hash_proto->proto.ipv4 && !cur_hash.proto.ipv4) { + options = RXH_IP_SRC | RXH_IP_DST; + if (set_rss_hash(fd, name, IPV4_FLOW, options)) + return -1; + } + if (hash_proto->proto.ipv6 && !cur_hash.proto.ipv6) { + options = RXH_IP_SRC | RXH_IP_DST; + if (set_rss_hash(fd, name, IPV6_FLOW, options)) + return -1; + } + return 0; +} + +int rss_conf_get_supported_fd(int fd, const char *name, + odp_pktin_hash_proto_t *hash_proto) +{ + uint64_t options; + int rss_supported = 0; + + memset(hash_proto, 0, sizeof(odp_pktin_hash_proto_t)); + + if (!get_rss_hash_options(fd, name, IPV4_FLOW, &options)) { + if (!set_rss_hash(fd, name, IPV4_FLOW, options)) { + hash_proto->proto.ipv4 = 1; + rss_supported++; + } + } + if (!get_rss_hash_options(fd, name, TCP_V4_FLOW, &options)) { + if (!set_rss_hash(fd, name, TCP_V4_FLOW, options)) { + hash_proto->proto.ipv4_tcp = 1; + rss_supported++; + } + } + if (!get_rss_hash_options(fd, name, UDP_V4_FLOW, &options)) { + if (!set_rss_hash(fd, name, UDP_V4_FLOW, options)) { + hash_proto->proto.ipv4_udp = 1; + rss_supported++; + } + } + if (!get_rss_hash_options(fd, name, IPV6_FLOW, &options)) { + if (!set_rss_hash(fd, name, IPV6_FLOW, options)) { + hash_proto->proto.ipv6 = 1; + rss_supported++; + } + } + if (!get_rss_hash_options(fd, name, TCP_V6_FLOW, &options)) { + if (!set_rss_hash(fd, name, TCP_V6_FLOW, options)) { + hash_proto->proto.ipv6_tcp = 1; + rss_supported++; + } + } + if (!get_rss_hash_options(fd, name, UDP_V6_FLOW, &options)) { + if (!set_rss_hash(fd, name, UDP_V6_FLOW, options)) { + hash_proto->proto.ipv6_udp = 1; + rss_supported++; + } + } + return rss_supported; +} + +void rss_conf_print(const odp_pktin_hash_proto_t *hash_proto) +{ int max_len = 512; + char str[max_len]; + int len = 0; + int n = max_len - 1; + + len += snprintf(&str[len], n - len, " rss conf\n"); + + if (hash_proto->proto.ipv4) + len += snprintf(&str[len], n - len, + " IPV4\n"); + if (hash_proto->proto.ipv4_tcp) + len += snprintf(&str[len], n - len, + " IPV4 TCP\n"); + if (hash_proto->proto.ipv4_udp) + len += snprintf(&str[len], n - len, + " IPV4 UDP\n"); + if (hash_proto->proto.ipv6) + len += snprintf(&str[len], n - len, + " IPV6\n"); + if (hash_proto->proto.ipv6_tcp) + len += snprintf(&str[len], n - len, + " IPV6 TCP\n"); + if (hash_proto->proto.ipv6_udp) + len += snprintf(&str[len], n - len, + " IPV6 UDP\n"); + str[len] = '\0'; + + ODP_PRINT("%s\n", str); +} diff --git a/platform/linux-generic/pktio/common.h b/platform/linux-generic/pktio/common.h new file mode 100644 index 000000000..2940af143 --- /dev/null +++ b/platform/linux-generic/pktio/common.h @@ -0,0 +1,81 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PKTIO_COMMON_H_ +#define ODP_PKTIO_COMMON_H_ + +/** + * Read the MTU from a packet socket + */ +uint32_t mtu_get_fd(int fd, const char *name); + +/** + * Read the MAC address from a packet socket + */ +int mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]); + +/** + * Enable/Disable promisc mode for a packet socket + */ +int promisc_mode_set_fd(int fd, const char *name, int enable); + +/** + * Return promisc mode of a packet socket + */ +int promisc_mode_get_fd(int fd, const char *name); + +/** + * Return link status of a packet socket (up/down) + */ +int link_status_fd(int fd, const char *name); + +/** + * Get enabled RSS hash protocols of a packet socket + * + * @param fd Socket file descriptor + * @param name Interface name + * @param hash_proto[out] Hash protocols + * + * @returns Number enabled hash protocols + */ +int rss_conf_get_fd(int fd, const char *name, + odp_pktin_hash_proto_t *hash_proto); + +/** + * Get supported RSS hash protocols of a packet socket + * + * Can be both read and modified. + * + * @param fd Socket file descriptor + * @param name Interface name + * @param hash_proto[out] Hash protocols + * + * @returns Number of supported hash protocols + */ +int rss_conf_get_supported_fd(int fd, const char *name, + odp_pktin_hash_proto_t *hash_proto); + +/** + * Set RSS hash protocols of a packet socket + * + * @param fd Socket file descriptor + * @param name Interface name + * @param hash_proto Hash protocols + * + * @retval 0 on success + * @retval <0 on failure + */ +int rss_conf_set_fd(int fd, const char *name, + const odp_pktin_hash_proto_t *proto); + +/** + * Print enabled RSS hash protocols + * + * @param hash_proto Hash protocols + */ +void rss_conf_print(const odp_pktin_hash_proto_t *hash_proto); + +#endif /*ODP_PKTIO_COMMON_H_*/ diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 511c77783..21c9fb0f7 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -22,6 +22,7 @@ #include #include +#include #include #include diff --git a/platform/linux-generic/pktio/ethtool.c b/platform/linux-generic/pktio/ethtool.c index ed2875c5b..3659004be 100644 --- a/platform/linux-generic/pktio/ethtool.c +++ b/platform/linux-generic/pktio/ethtool.c @@ -15,6 +15,7 @@ #include #include #include +#include static struct ethtool_gstrings *get_stringset(int fd, struct ifreq *ifr) { diff --git a/platform/linux-generic/pktio/ethtool.h b/platform/linux-generic/pktio/ethtool.h new file mode 100644 index 000000000..c5a811238 --- /dev/null +++ b/platform/linux-generic/pktio/ethtool.h @@ -0,0 +1,15 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PKTIO_ETHTOOL_H_ +#define ODP_PKTIO_ETHTOOL_H_ + +/** + * Get ethtool statistics of a packet socket + */ +int ethtool_stats_get_fd(int fd, const char *name, odp_pktio_stats_t *stats); + +#endif /*ODP_PKTIO_ETHTOOL_H_*/ diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 07d6d9e9b..bef3ae3a3 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index c7c3c5a8c..f4939ce13 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include @@ -97,358 +99,6 @@ int sendmmsg(int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) #define ETHBUF_ALIGN(buf_ptr) ((uint8_t *)ODP_ALIGN_ROUNDUP_PTR((buf_ptr), \ sizeof(uint32_t)) + ETHBUF_OFFSET) -/** - * ODP_PACKET_SOCKET_MMSG: - * ODP_PACKET_SOCKET_MMAP: - * ODP_PACKET_NETMAP: - */ -int mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]) -{ - struct ifreq ethreq; - int ret; - - memset(ðreq, 0, sizeof(ethreq)); - snprintf(ethreq.ifr_name, IF_NAMESIZE, "%s", name); - ret = ioctl(fd, SIOCGIFHWADDR, ðreq); - if (ret != 0) { - __odp_errno = errno; - ODP_ERR("ioctl(SIOCGIFHWADDR): %s: \"%s\".\n", strerror(errno), - ethreq.ifr_name); - return -1; - } - - memcpy(mac_dst, (unsigned char *)ethreq.ifr_ifru.ifru_hwaddr.sa_data, - ETH_ALEN); - return 0; -} - -/* - * ODP_PACKET_SOCKET_MMSG: - * ODP_PACKET_SOCKET_MMAP: - * ODP_PACKET_NETMAP: - */ -uint32_t mtu_get_fd(int fd, const char *name) -{ - struct ifreq ifr; - int ret; - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - ret = ioctl(fd, SIOCGIFMTU, &ifr); - if (ret < 0) { - __odp_errno = errno; - ODP_DBG("ioctl(SIOCGIFMTU): %s: \"%s\".\n", strerror(errno), - ifr.ifr_name); - return 0; - } - return ifr.ifr_mtu; -} - -/* - * ODP_PACKET_SOCKET_MMSG: - * ODP_PACKET_SOCKET_MMAP: - * ODP_PACKET_NETMAP: - */ -int promisc_mode_set_fd(int fd, const char *name, int enable) -{ - struct ifreq ifr; - int ret; - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - ret = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (ret < 0) { - __odp_errno = errno; - ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), - ifr.ifr_name); - return -1; - } - - if (enable) - ifr.ifr_flags |= IFF_PROMISC; - else - ifr.ifr_flags &= ~(IFF_PROMISC); - - ret = ioctl(fd, SIOCSIFFLAGS, &ifr); - if (ret < 0) { - __odp_errno = errno; - ODP_DBG("ioctl(SIOCSIFFLAGS): %s: \"%s\".\n", strerror(errno), - ifr.ifr_name); - return -1; - } - return 0; -} - -/* - * ODP_PACKET_SOCKET_MMSG: - * ODP_PACKET_SOCKET_MMAP: - * ODP_PACKET_NETMAP: - */ -int promisc_mode_get_fd(int fd, const char *name) -{ - struct ifreq ifr; - int ret; - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - ret = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (ret < 0) { - __odp_errno = errno; - ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), - ifr.ifr_name); - return -1; - } - - return !!(ifr.ifr_flags & IFF_PROMISC); -} - -int link_status_fd(int fd, const char *name) -{ - struct ifreq ifr; - int ret; - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - ret = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (ret < 0) { - __odp_errno = errno; - ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), - ifr.ifr_name); - return -1; - } - - return !!(ifr.ifr_flags & IFF_RUNNING); -} - -/** - * Get enabled hash options of a packet socket - * - * @param fd Socket file descriptor - * @param name Interface name - * @param flow_type Packet flow type - * @param options[out] Enabled hash options - * - * @retval 0 on success - * @retval <0 on failure - */ -static inline int get_rss_hash_options(int fd, const char *name, - uint32_t flow_type, uint64_t *options) -{ - struct ifreq ifr; - struct ethtool_rxnfc rsscmd; - - memset(&ifr, 0, sizeof(ifr)); - memset(&rsscmd, 0, sizeof(rsscmd)); - *options = 0; - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - - rsscmd.cmd = ETHTOOL_GRXFH; - rsscmd.flow_type = flow_type; - - ifr.ifr_data = (caddr_t)&rsscmd; - - if (ioctl(fd, SIOCETHTOOL, &ifr) < 0) - return -1; - - *options = rsscmd.data; - return 0; -} - -int rss_conf_get_fd(int fd, const char *name, - odp_pktin_hash_proto_t *hash_proto) -{ - uint64_t options; - int rss_enabled = 0; - - memset(hash_proto, 0, sizeof(odp_pktin_hash_proto_t)); - - get_rss_hash_options(fd, name, IPV4_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST)) { - hash_proto->proto.ipv4 = 1; - rss_enabled++; - } - get_rss_hash_options(fd, name, TCP_V4_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && - (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { - hash_proto->proto.ipv4_tcp = 1; - rss_enabled++; - } - get_rss_hash_options(fd, name, UDP_V4_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && - (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { - hash_proto->proto.ipv4_udp = 1; - rss_enabled++; - } - get_rss_hash_options(fd, name, IPV6_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST)) { - hash_proto->proto.ipv6 = 1; - rss_enabled++; - } - get_rss_hash_options(fd, name, TCP_V6_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && - (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { - hash_proto->proto.ipv6_tcp = 1; - rss_enabled++; - } - get_rss_hash_options(fd, name, UDP_V6_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && - (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { - hash_proto->proto.ipv6_udp = 1; - rss_enabled++; - } - return rss_enabled; -} - -/** - * Set hash options of a packet socket - * - * @param fd Socket file descriptor - * @param name Interface name - * @param flow_type Packet flow type - * @param options Hash options - * - * @retval 0 on success - * @retval <0 on failure - */ -static inline int set_rss_hash(int fd, const char *name, - uint32_t flow_type, uint64_t options) -{ - struct ifreq ifr; - struct ethtool_rxnfc rsscmd; - - memset(&rsscmd, 0, sizeof(rsscmd)); - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - - rsscmd.cmd = ETHTOOL_SRXFH; - rsscmd.flow_type = flow_type; - rsscmd.data = options; - - ifr.ifr_data = (caddr_t)&rsscmd; - - if (ioctl(fd, SIOCETHTOOL, &ifr) < 0) - return -1; - - return 0; -} - -int rss_conf_set_fd(int fd, const char *name, - const odp_pktin_hash_proto_t *hash_proto) -{ - uint64_t options; - odp_pktin_hash_proto_t cur_hash; - - /* Compare to currently set hash protocols */ - rss_conf_get_fd(fd, name, &cur_hash); - - if (hash_proto->proto.ipv4_udp && !cur_hash.proto.ipv4_udp) { - options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; - if (set_rss_hash(fd, name, UDP_V4_FLOW, options)) - return -1; - } - if (hash_proto->proto.ipv4_tcp && !cur_hash.proto.ipv4_tcp) { - options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; - if (set_rss_hash(fd, name, TCP_V4_FLOW, options)) - return -1; - } - if (hash_proto->proto.ipv6_udp && !cur_hash.proto.ipv6_udp) { - options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; - if (set_rss_hash(fd, name, UDP_V6_FLOW, options)) - return -1; - } - if (hash_proto->proto.ipv6_tcp && !cur_hash.proto.ipv6_tcp) { - options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; - if (set_rss_hash(fd, name, TCP_V6_FLOW, options)) - return -1; - } - if (hash_proto->proto.ipv4 && !cur_hash.proto.ipv4) { - options = RXH_IP_SRC | RXH_IP_DST; - if (set_rss_hash(fd, name, IPV4_FLOW, options)) - return -1; - } - if (hash_proto->proto.ipv6 && !cur_hash.proto.ipv6) { - options = RXH_IP_SRC | RXH_IP_DST; - if (set_rss_hash(fd, name, IPV6_FLOW, options)) - return -1; - } - return 0; -} - -int rss_conf_get_supported_fd(int fd, const char *name, - odp_pktin_hash_proto_t *hash_proto) -{ - uint64_t options; - int rss_supported = 0; - - memset(hash_proto, 0, sizeof(odp_pktin_hash_proto_t)); - - if (!get_rss_hash_options(fd, name, IPV4_FLOW, &options)) { - if (!set_rss_hash(fd, name, IPV4_FLOW, options)) { - hash_proto->proto.ipv4 = 1; - rss_supported++; - } - } - if (!get_rss_hash_options(fd, name, TCP_V4_FLOW, &options)) { - if (!set_rss_hash(fd, name, TCP_V4_FLOW, options)) { - hash_proto->proto.ipv4_tcp = 1; - rss_supported++; - } - } - if (!get_rss_hash_options(fd, name, UDP_V4_FLOW, &options)) { - if (!set_rss_hash(fd, name, UDP_V4_FLOW, options)) { - hash_proto->proto.ipv4_udp = 1; - rss_supported++; - } - } - if (!get_rss_hash_options(fd, name, IPV6_FLOW, &options)) { - if (!set_rss_hash(fd, name, IPV6_FLOW, options)) { - hash_proto->proto.ipv6 = 1; - rss_supported++; - } - } - if (!get_rss_hash_options(fd, name, TCP_V6_FLOW, &options)) { - if (!set_rss_hash(fd, name, TCP_V6_FLOW, options)) { - hash_proto->proto.ipv6_tcp = 1; - rss_supported++; - } - } - if (!get_rss_hash_options(fd, name, UDP_V6_FLOW, &options)) { - if (!set_rss_hash(fd, name, UDP_V6_FLOW, options)) { - hash_proto->proto.ipv6_udp = 1; - rss_supported++; - } - } - return rss_supported; -} - -void rss_conf_print(const odp_pktin_hash_proto_t *hash_proto) -{ int max_len = 512; - char str[max_len]; - int len = 0; - int n = max_len - 1; - - len += snprintf(&str[len], n - len, " rss conf\n"); - - if (hash_proto->proto.ipv4) - len += snprintf(&str[len], n - len, - " IPV4\n"); - if (hash_proto->proto.ipv4_tcp) - len += snprintf(&str[len], n - len, - " IPV4 TCP\n"); - if (hash_proto->proto.ipv4_udp) - len += snprintf(&str[len], n - len, - " IPV4 UDP\n"); - if (hash_proto->proto.ipv6) - len += snprintf(&str[len], n - len, - " IPV6\n"); - if (hash_proto->proto.ipv6_tcp) - len += snprintf(&str[len], n - len, - " IPV6 TCP\n"); - if (hash_proto->proto.ipv6_udp) - len += snprintf(&str[len], n - len, - " IPV6 UDP\n"); - str[len] = '\0'; - - ODP_PRINT("%s\n", str); -} - /* * ODP_PACKET_SOCKET_MMSG: */ diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 3dd03e66b..2bb51c4bb 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index 090e51b66..e8823850c 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -43,6 +43,7 @@ #include #include #include +#include #define BUF_SIZE 65536 From patchwork Tue Sep 26 06:00:03 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: 114216 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3454179qgf; Mon, 25 Sep 2017 23:04:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDUNpn2utM3h8xyuzeuSVzSUMYkgmyjZpSU21JK7wK/W18RaWNetpcrKm0PAekdIazr6jbA X-Received: by 10.36.90.205 with SMTP id v196mr3995348ita.70.1506405898544; Mon, 25 Sep 2017 23:04:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506405898; cv=none; d=google.com; s=arc-20160816; b=1IBlgU9aSePT0Q5//wu9CEM9uHjYbCtmRytcNoYTkS+T1F0ewXvPHFKfI+BiPx0nUY 0k0kYC4dn015+ku78QCchRnsfkFeskgOL3nENHDqZGt9ybeSSlaNItc5iELxMIz+qO7C jf904qUebst1eCAQhnyzHIUvqPHgWHlSqd9je5HRXVuq6M4gKBwaf1Z9dgfdTEK8NEjA E7eBqHnIFSyMC8oY+/lQHog39bz1qikJ52S/kogv15ZkpnWSwT7czCXdl7/6ycBwTq4q G8ZmPIaGLEM1esqoNBjxnXHYjpJX2oickgmgZlefni5N7mGsyNeAiH4Ho1fEPKFYX4Ju lLBw== 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=91FyrbKo+fALtgyqRI0sGVgKAPDh2bCTzH7nEg3Jb+M=; b=eJ68M/zHY8aGAf6T463JfikLQNWzriz46gKM4SkupUUdlGJ7aJ2EgZP3nrUFVRkMlY LvBqSkdffSiSrbwWKATZdvw/eTdN25V4IX6jj/RGYn+bDl/4l3g0y9nFNx5PFTFEKogv suI9KlaY+Vha4L1MCCPvA+Mmpm/M5vdlpoQCUDzUhfMavWuO7iJ2B5B3i/H8tZ9kMyRU BYuQdweg98eqYTCZgynDNgVfhYL/L3KvadiT6w0ltbv38kG7xfH2/JHLA3bR3dc5Vxej TtjEp1ZmboFxnDOaBQU0HWmy4hnJuzf6D9D99qwpOgMlYgehyDO3g/xHn8tZWLNSaC87 KPhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q130si6299058ioq.346.2017.09.25.23.04.58; Mon, 25 Sep 2017 23:04:58 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 185D060D74; Tue, 26 Sep 2017 06:04:58 +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 A82C460D25; Tue, 26 Sep 2017 06:00:45 +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 ED8B860A59; Tue, 26 Sep 2017 06:00:21 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id 4335F60BE8 for ; Tue, 26 Sep 2017 06:00:14 +0000 (UTC) Received: from mxback8g.mail.yandex.net (mxback8g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:169]) by forward100o.mail.yandex.net (Yandex) with ESMTP id 912332A233E1 for ; Tue, 26 Sep 2017 09:00:12 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback8g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id khUFBKGLWM-0CZuvH3V; Tue, 26 Sep 2017 09:00:12 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 72uMtCPv0h-0CmKWsF3; Tue, 26 Sep 2017 09: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: Tue, 26 Sep 2017 09:00:03 +0300 Message-Id: <1506405608-3507-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> References: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v1 4/9] linux-gen: pktio: socket: use generic pktio_ops data storage 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: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: e89a0ed9c4cd6d7dc947b978ad1dcabc6d5a21a2 ** Merge commit sha: 160ad8615ce66c98231aa400863c82e89045d491 **/ .../include/odp_pktio_ops_subsystem.h | 3 -- platform/linux-generic/pktio/socket.c | 47 ++++++++++++++------- platform/linux-generic/pktio/socket_mmap.c | 48 +++++++++++++++------- 3 files changed, 66 insertions(+), 32 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 415b8365f..369d722f0 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -82,7 +82,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { #include #include #include -#include #include /* Per implementation private data @@ -93,8 +92,6 @@ typedef union { pktio_ops_ipc_data_t ipc; pktio_ops_netmap_data_t netmap; pktio_ops_pcap_data_t pcap; - pktio_ops_socket_data_t socket; - pktio_ops_socket_mmap_data_t mmap; pktio_ops_tap_data_t tap; } pktio_ops_data_t; diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index f4939ce13..997156b60 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -105,7 +106,7 @@ int sendmmsg(int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) static int sock_close(pktio_entry_t *pktio_entry) { pktio_ops_socket_data_t *pkt_sock = - &pktio_entry->ops_data(socket); + odp_ops_data(pktio_entry, socket); if (pkt_sock->sockfd != -1 && close(pkt_sock->sockfd) != 0) { __odp_errno = errno; @@ -129,7 +130,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, struct sockaddr_ll sa_ll; char shm_name[ODP_SHM_NAME_LEN]; pktio_ops_socket_data_t *pkt_sock = - &pktio_entry->ops_data(socket); + odp_ops_data(pktio_entry, socket); odp_pktio_stats_t cur_stats; /* Init pktio entry */ @@ -254,7 +255,7 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_packet_t pkt_table[], int len) { pktio_ops_socket_data_t *pkt_sock = - &pktio_entry->ops_data(socket); + odp_ops_data(pktio_entry, socket); odp_pool_t pool = pkt_sock->pool; odp_time_t ts_val; odp_time_t *ts = NULL; @@ -370,7 +371,7 @@ static int sock_mmsg_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, const odp_packet_t pkt_table[], int len) { pktio_ops_socket_data_t *pkt_sock = - &pktio_entry->ops_data(socket); + odp_ops_data(pktio_entry, socket); struct mmsghdr msgvec[len]; struct iovec iovecs[len][MAX_SEGS]; int ret; @@ -416,7 +417,10 @@ static int sock_mmsg_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, */ static uint32_t sock_mtu_get(pktio_entry_t *pktio_entry) { - return pktio_entry->ops_data(socket).mtu; + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + + return pkt_sock->mtu; } /* @@ -425,7 +429,10 @@ static uint32_t sock_mtu_get(pktio_entry_t *pktio_entry) static int sock_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->ops_data(socket).if_mac, ETH_ALEN); + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + + memcpy(mac_addr, pkt_sock->if_mac, ETH_ALEN); return ETH_ALEN; } @@ -435,7 +442,10 @@ static int sock_mac_addr_get(pktio_entry_t *pktio_entry, static int sock_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - return promisc_mode_set_fd(pktio_entry->ops_data(socket).sockfd, + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + + return promisc_mode_set_fd(pkt_sock->sockfd, pktio_entry->s.name, enable); } @@ -444,13 +454,19 @@ static int sock_promisc_mode_set(pktio_entry_t *pktio_entry, */ static int sock_promisc_mode_get(pktio_entry_t *pktio_entry) { - return promisc_mode_get_fd(pktio_entry->ops_data(socket).sockfd, + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + + return promisc_mode_get_fd(pkt_sock->sockfd, pktio_entry->s.name); } static int sock_link_status(pktio_entry_t *pktio_entry) { - return link_status_fd(pktio_entry->ops_data(socket).sockfd, + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + + return link_status_fd(pkt_sock->sockfd, pktio_entry->s.name); } @@ -472,26 +488,29 @@ static int sock_capability(pktio_entry_t *pktio_entry ODP_UNUSED, static int sock_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(stats, 0, sizeof(*stats)); return 0; } - return sock_stats_fd(pktio_entry, - stats, - pktio_entry->ops_data(socket).sockfd); + return sock_stats_fd(pktio_entry, stats, pkt_sock->sockfd); } static int sock_stats_reset(pktio_entry_t *pktio_entry) { + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(&pktio_entry->s.stats, 0, sizeof(odp_pktio_stats_t)); return 0; } - return sock_stats_reset_fd(pktio_entry, - pktio_entry->ops_data(socket).sockfd); + return sock_stats_reset_fd(pktio_entry, pkt_sock->sockfd); } static int sock_init_global(void) diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 2bb51c4bb..cd6bfc41f 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -489,7 +490,7 @@ static int mmap_bind_sock(pktio_ops_socket_mmap_data_t *pkt_sock, static int sock_mmap_close(pktio_entry_t *entry) { pktio_ops_socket_mmap_data_t - *const pkt_sock = &entry->ops_data(mmap); + *const pkt_sock = odp_ops_data(entry, socket_mmap); int ret; ret = mmap_unmap_sock(pkt_sock); @@ -519,7 +520,7 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, return -1; pktio_ops_socket_mmap_data_t - *const pkt_sock = &pktio_entry->ops_data(mmap); + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); int fanout = 1; /* Init pktio entry */ @@ -605,7 +606,7 @@ static int sock_mmap_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_packet_t pkt_table[], int len) { pktio_ops_socket_mmap_data_t - *const pkt_sock = &pktio_entry->ops_data(mmap); + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); int ret; odp_ticketlock_lock(&pktio_entry->s.rxl); @@ -621,7 +622,7 @@ static int sock_mmap_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, { int ret; pktio_ops_socket_mmap_data_t - *const pkt_sock = &pktio_entry->ops_data(mmap); + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); odp_ticketlock_lock(&pktio_entry->s.txl); ret = pkt_mmap_v2_tx(pkt_sock->tx_ring.sock, &pkt_sock->tx_ring, @@ -633,33 +634,46 @@ static int sock_mmap_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, static uint32_t sock_mmap_mtu_get(pktio_entry_t *pktio_entry) { - return mtu_get_fd(pktio_entry->ops_data(mmap).sockfd, - pktio_entry->s.name); + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + + return mtu_get_fd(pkt_sock->sockfd, pktio_entry->s.name); } static int sock_mmap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->ops_data(mmap).if_mac, ETH_ALEN); + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + + memcpy(mac_addr, pkt_sock->if_mac, ETH_ALEN); return ETH_ALEN; } static int sock_mmap_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - return promisc_mode_set_fd(pktio_entry->ops_data(mmap).sockfd, + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + + return promisc_mode_set_fd(pkt_sock->sockfd, pktio_entry->s.name, enable); } static int sock_mmap_promisc_mode_get(pktio_entry_t *pktio_entry) { - return promisc_mode_get_fd(pktio_entry->ops_data(mmap).sockfd, + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + + return promisc_mode_get_fd(pkt_sock->sockfd, pktio_entry->s.name); } static int sock_mmap_link_status(pktio_entry_t *pktio_entry) { - return link_status_fd(pktio_entry->ops_data(mmap).sockfd, - pktio_entry->s.name); + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + + return link_status_fd(pkt_sock->sockfd, pktio_entry->s.name); } static int sock_mmap_capability(pktio_entry_t *pktio_entry ODP_UNUSED, @@ -680,26 +694,30 @@ static int sock_mmap_capability(pktio_entry_t *pktio_entry ODP_UNUSED, static int sock_mmap_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(stats, 0, sizeof(*stats)); return 0; } return sock_stats_fd(pktio_entry, - stats, - pktio_entry->ops_data(mmap).sockfd); + stats, pkt_sock->sockfd); } static int sock_mmap_stats_reset(pktio_entry_t *pktio_entry) { + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(&pktio_entry->s.stats, 0, sizeof(odp_pktio_stats_t)); return 0; } - return sock_stats_reset_fd(pktio_entry, - pktio_entry->ops_data(mmap).sockfd); + return sock_stats_reset_fd(pktio_entry, pkt_sock->sockfd); } static int sock_mmap_init_global(void) From patchwork Tue Sep 26 06:00:04 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: 114217 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3455160qgf; Mon, 25 Sep 2017 23:06:07 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCyd9nfMtCIgUN2W+PgAf7U7O2/H4D/uMj0hfnXYXr3fveEqBtWydravRcHDMZAqmDhnarz X-Received: by 10.107.182.139 with SMTP id g133mr12811914iof.10.1506405966928; Mon, 25 Sep 2017 23:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506405966; cv=none; d=google.com; s=arc-20160816; b=Mp8EcRxp47jn9G66hZaXTZjL+nlK9VLbO3Zx6bBtgNJxS+2q0XKa95S65ZZ14JEtAk juWcjdtPfreygnVs8DQ1AxxM5czMKzCX2+SbIuHqc1SmwL4tGgwEaRiiDsT34wNy5bRo A9pZeOiL6hsdxeB9LEu1M1DM6HqRM4EPe6pAfsENMeV7mCbARX59S4iMf5fAEfxUG7lV /3mUo0HLEO4olRViSNccuw72IA3Ag60w3oeANpK+bF2zqBxtlNkwA8dhwWb054803mqi 9L26ffmp7VA0X6nHpeIcJuzpJnu5ha25j+J/Ftdt1Uzvc/bZyVFMJIMT+f+F8KMzQhDG cAMg== 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=Nk6x7pZZ5EbcMaTB/DgD5TQxYXkubdEiqzUIw1DuNoM=; b=loCv6gqzsCST0I8HOMu/amb6bd/Rw5jeJGotm9/t/32WK3ZYqPgKQiyd58syomOWF3 w88sW6CVos9peWGH2gbxOuuJ47e20mOsNbCxjduQYKIQINXBmN0VaBBRCYvpS+60LgjC TMagHGnL+f3SBs4hhxBRwCjzEg+rgGgF/taqt1Qh9MgOkvkRaL0ZBTf9YVRKOqKUIcfJ cVkohhL7B/M2je60emCRwAqf/Ej4XOAts0WLSy+7oAUMLz4c3vWA48PovJQmzsO3ZZn0 cVzvpOmKfv68+/AnS+qUOoVck+3KJ6b1edHjH4leUZmC5GdsUrR3qs7qgk3zZGJdvFAK 2WIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h145si6744938iof.283.2017.09.25.23.06.06; Mon, 25 Sep 2017 23:06:06 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 0026760D43; Tue, 26 Sep 2017 06:06:05 +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,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 0547F60CE2; Tue, 26 Sep 2017 06:00:51 +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 2526160CCC; Tue, 26 Sep 2017 06:00:25 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id 7D7DD60BFB for ; Tue, 26 Sep 2017 06:00:14 +0000 (UTC) Received: from mxback13g.mail.yandex.net (mxback13g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:92]) by forward105o.mail.yandex.net (Yandex) with ESMTP id 1CEE14441A8D for ; Tue, 26 Sep 2017 09:00:13 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback13g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id zZUJJqHsjl-0DvGTPwl; Tue, 26 Sep 2017 09:00:13 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 72uMtCPv0h-0CmusF3x; Tue, 26 Sep 2017 09: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: Tue, 26 Sep 2017 09:00:04 +0300 Message-Id: <1506405608-3507-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> References: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v1 5/9] linux-gen: pktio: tap: use generic pktio_ops data storage 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: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: e89a0ed9c4cd6d7dc947b978ad1dcabc6d5a21a2 ** Merge commit sha: 160ad8615ce66c98231aa400863c82e89045d491 **/ .../include/odp_pktio_ops_subsystem.h | 2 -- platform/linux-generic/include/odp_pktio_ops_tap.h | 1 + platform/linux-generic/pktio/tap.c | 34 +++++++++++++--------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 369d722f0..526280a10 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -82,7 +82,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { #include #include #include -#include /* Per implementation private data * TODO: refactory each implementation to hide it internally @@ -92,7 +91,6 @@ typedef union { pktio_ops_ipc_data_t ipc; pktio_ops_netmap_data_t netmap; pktio_ops_pcap_data_t pcap; - pktio_ops_tap_data_t tap; } pktio_ops_data_t; /* Extract pktio ops data from pktio entry structure */ diff --git a/platform/linux-generic/include/odp_pktio_ops_tap.h b/platform/linux-generic/include/odp_pktio_ops_tap.h index e8e2e270e..d9ce8e71d 100644 --- a/platform/linux-generic/include/odp_pktio_ops_tap.h +++ b/platform/linux-generic/include/odp_pktio_ops_tap.h @@ -7,6 +7,7 @@ #ifndef ODP_PACKET_OPS_TAP_H_ #define ODP_PACKET_OPS_TAP_H_ +#include #include typedef struct { diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index e8823850c..064b9b6e8 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #define BUF_SIZE 65536 @@ -64,7 +65,7 @@ static int tap_pktio_open(odp_pktio_t id ODP_UNUSED, int fd, skfd, flags; uint32_t mtu; struct ifreq ifr; - pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); if (strncmp(devname, "tap:", 4) != 0) return -1; @@ -164,7 +165,7 @@ static int tap_pktio_open(odp_pktio_t id ODP_UNUSED, static int tap_pktio_close(pktio_entry_t *pktio_entry) { int ret = 0; - pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); if (tap->fd != -1 && close(tap->fd) != 0) { __odp_errno = errno; @@ -184,6 +185,7 @@ static int tap_pktio_close(pktio_entry_t *pktio_entry) static odp_packet_t pack_odp_pkt(pktio_entry_t *pktio_entry, const void *data, unsigned int len, odp_time_t *ts) { + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); odp_packet_t pkt; odp_packet_hdr_t *pkt_hdr; odp_packet_hdr_t parsed_hdr; @@ -191,13 +193,12 @@ static odp_packet_t pack_odp_pkt(pktio_entry_t *pktio_entry, const void *data, if (pktio_cls_enabled(pktio_entry)) { if (cls_classify_packet(pktio_entry, data, len, len, - &pktio_entry->ops_data(tap).pool, - &parsed_hdr)) { + &tap->pool, &parsed_hdr)) { return ODP_PACKET_INVALID; } } - num = packet_alloc_multi(pktio_entry->ops_data(tap).pool, len, &pkt, 1); + num = packet_alloc_multi(tap->pool, len, &pkt, 1); if (num != 1) return ODP_PACKET_INVALID; @@ -228,7 +229,7 @@ static int tap_pktio_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, ssize_t retval; int i; uint8_t buf[BUF_SIZE]; - pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); odp_time_t ts_val; odp_time_t *ts = NULL; @@ -268,7 +269,7 @@ static int tap_pktio_send_lockless(pktio_entry_t *pktio_entry, int i, n; uint32_t pkt_len; uint8_t buf[BUF_SIZE]; - pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); for (i = 0; i < len; i++) { pkt_len = odp_packet_len(pkts[i]); @@ -330,11 +331,11 @@ static int tap_pktio_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, static uint32_t tap_mtu_get(pktio_entry_t *pktio_entry) { uint32_t ret; + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); - ret = mtu_get_fd(pktio_entry->ops_data(tap).skfd, - pktio_entry->s.name + 4); + ret = mtu_get_fd(tap->skfd, pktio_entry->s.name + 4); if (ret > 0) - pktio_entry->ops_data(tap).mtu = ret; + tap->mtu = ret; return ret; } @@ -342,19 +343,24 @@ static uint32_t tap_mtu_get(pktio_entry_t *pktio_entry) static int tap_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - return promisc_mode_set_fd(pktio_entry->ops_data(tap).skfd, + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); + + return promisc_mode_set_fd(tap->skfd, pktio_entry->s.name + 4, enable); } static int tap_promisc_mode_get(pktio_entry_t *pktio_entry) { - return promisc_mode_get_fd(pktio_entry->ops_data(tap).skfd, - pktio_entry->s.name + 4); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); + + return promisc_mode_get_fd(tap->skfd, pktio_entry->s.name + 4); } static int tap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->ops_data(tap).if_mac, ETH_ALEN); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); + + memcpy(mac_addr, tap->if_mac, ETH_ALEN); return ETH_ALEN; } From patchwork Tue Sep 26 06:00:05 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: 114218 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3455850qgf; Mon, 25 Sep 2017 23:06:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCopjVChQ7FUdyN/SO5iszv3eY1iU/mhXdO2YuqJkb6loOrl2ePdoMe3O3yqqcVoSbeIDBI X-Received: by 10.36.190.67 with SMTP id i64mr3998011itf.114.1506406018785; Mon, 25 Sep 2017 23:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506406018; cv=none; d=google.com; s=arc-20160816; b=E0D5286jso0tea2A3DjoeKtrC8Gceh7RvFgG4U4rUaE0uA6tc+vV+1arogV/6e6APF CmNefxK1KkGDIPLRBZd/4kKh7oQ0O0chIR5rUt97zAn0Jrr4rARMSVB+PpEnn5wzt8mM eJsMVB3Q6NPIFB6m7s2RsSL/Psli74rUX0eDIfH9VkWUySTTqyFUEAaPrZ5mjfcvLYKR a2qWoXpreCkLYKeiH5T12jKkjuUIdxjYe81b19Bk4E6CQEa5AUuXHwvXl3dbg3QSdkoT rDGq9HHcZ9sTHFyufbSWs7H6PmcS8eQ+xWpINbzs8D2fLvnPREeni/Vc37V8A5fQD8Ov gxGw== 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=TFgNB7MSjeZjBEGWilTWRA0TDqbCGpF53XFJXR3gojk=; b=fpbMt7wz3SnJT8UOYpuYjEh7O9McJqPVO9ky7oQqEOVp62ANQ2ylLEsjiNsUKvhkTB retaFApaQl1rnX6bFbTOdk/r6BReb7Nx8GSo6/Uek+HS2jk6fuilRABzHO5V6a3hTKBM tO/WXDWARXTNoAJ1XqwjwZ9BNYqnhfOe2rVitduHplu1HDd3/vDfsdAHnYiyqtFzmaMz JcmcJHN/KX+cQRrmZL7XDmCgxQdZumhKGwRyOsZcH2Q+x6nap/cKx6B+8AgTMCL1vSsu AM4giVKQFVANalrpOBcs1uEJM9qmQGM8kPeiMaCJSOw73E9cCsiibagh5/WeIRerRL9u BAWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j132si1148619itj.202.2017.09.25.23.06.58; Mon, 25 Sep 2017 23:06:58 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 210E660743; Tue, 26 Sep 2017 06:06:58 +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,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 6153F60CD7; Tue, 26 Sep 2017 06:00: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 7ED2860C0A; Tue, 26 Sep 2017 06:00:25 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id 8A0BF60C48 for ; Tue, 26 Sep 2017 06:00:15 +0000 (UTC) Received: from mxback9j.mail.yandex.net (mxback9j.mail.yandex.net [IPv6:2a02:6b8:0:1619::112]) by forward105o.mail.yandex.net (Yandex) with ESMTP id 0A1654441BBD for ; Tue, 26 Sep 2017 09:00:14 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback9j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id VqsmqlZCvx-0DZOkT3A; Tue, 26 Sep 2017 09:00:13 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 72uMtCPv0h-0DmKa3um; Tue, 26 Sep 2017 09:00:13 +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: Tue, 26 Sep 2017 09:00:05 +0300 Message-Id: <1506405608-3507-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> References: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v1 6/9] linux-gen: pktio: ipc: use generic pktio_ops data storage 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: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: e89a0ed9c4cd6d7dc947b978ad1dcabc6d5a21a2 ** Merge commit sha: 160ad8615ce66c98231aa400863c82e89045d491 **/ .../include/odp_pktio_ops_subsystem.h | 2 - platform/linux-generic/pktio/ipc.c | 201 +++++++++++---------- 2 files changed, 103 insertions(+), 100 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 526280a10..6bb31516a 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -79,7 +79,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { } pktio_ops_module_t; /* All implementations of this subsystem */ -#include #include #include @@ -88,7 +87,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { */ typedef union { void *dpdk; - pktio_ops_ipc_data_t ipc; pktio_ops_netmap_data_t netmap; pktio_ops_pcap_data_t pcap; } pktio_ops_data_t; diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index 14cd86eb7..743725c2f 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -8,10 +8,12 @@ #include #include #include <_ishm_internal.h> +#include #include #include #include +#include #define IPC_ODP_DEBUG_PRINT 0 @@ -42,7 +44,8 @@ static const char *_ipc_odp_buffer_pool_shm_name(odp_pool_t pool_hdl) static int _ipc_master_start(pktio_entry_t *pktio_entry) { - struct pktio_info *pinfo = pktio_entry->ops_data(ipc).pinfo; + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); + struct pktio_info *pinfo = pkt_ipc->pinfo; odp_shm_t shm; if (pinfo->slave.init_done == 0) @@ -56,11 +59,11 @@ static int _ipc_master_start(pktio_entry_t *pktio_entry) return -1; } - pktio_entry->ops_data(ipc).remote_pool_shm = shm; - pktio_entry->ops_data(ipc).pool_base = odp_shm_addr(shm); - pktio_entry->ops_data(ipc).pool_mdata_base = (char *)odp_shm_addr(shm); + pkt_ipc->remote_pool_shm = shm; + pkt_ipc->pool_base = odp_shm_addr(shm); + pkt_ipc->pool_mdata_base = (char *)odp_shm_addr(shm); - odp_atomic_store_u32(&pktio_entry->ops_data(ipc).ready, 1); + odp_atomic_store_u32(&pkt_ipc->ready, 1); IPC_ODP_DBG("%s started.\n", pktio_entry->s.name); return 0; @@ -70,6 +73,7 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry, const char *dev, odp_pool_t pool_hdl) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); char ipc_shm_name[ODP_POOL_NAME_LEN + sizeof("_m_prod")]; pool_t *pool; struct pktio_info *pinfo; @@ -87,62 +91,62 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry, * to be processed packets ring. */ snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_prod", dev); - pktio_entry->ops_data(ipc).tx.send = _ring_create(ipc_shm_name, + pkt_ipc->tx.send = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->ops_data(ipc).tx.send) { + if (!pkt_ipc->tx.send) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); return -1; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.send), - _ring_free_count(pktio_entry->ops_data(ipc).tx.send)); + ipc_shm_name, _ring_count(pkt_ipc->tx.send), + _ring_free_count(pkt_ipc->tx.send)); /* generate name in shm like ipc_pktio_p for * already processed packets */ snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_cons", dev); - pktio_entry->ops_data(ipc).tx.free = _ring_create(ipc_shm_name, + pkt_ipc->tx.free = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->ops_data(ipc).tx.free) { + if (!pkt_ipc->tx.free) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); goto free_m_prod; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.free), - _ring_free_count(pktio_entry->ops_data(ipc).tx.free)); + ipc_shm_name, _ring_count(pkt_ipc->tx.free), + _ring_free_count(pkt_ipc->tx.free)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_prod", dev); - pktio_entry->ops_data(ipc).rx.recv = _ring_create(ipc_shm_name, + pkt_ipc->rx.recv = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->ops_data(ipc).rx.recv) { + if (!pkt_ipc->rx.recv) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); goto free_m_cons; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.recv), - _ring_free_count(pktio_entry->ops_data(ipc).rx.recv)); + ipc_shm_name, _ring_count(pkt_ipc->rx.recv), + _ring_free_count(pkt_ipc->rx.recv)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", dev); - pktio_entry->ops_data(ipc).rx.free = _ring_create(ipc_shm_name, + pkt_ipc->rx.free = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->ops_data(ipc).rx.free) { + if (!pkt_ipc->rx.free) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); goto free_s_prod; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.free), - _ring_free_count(pktio_entry->ops_data(ipc).rx.free)); + ipc_shm_name, _ring_count(pkt_ipc->rx.free), + _ring_free_count(pkt_ipc->rx.free)); /* Set up pool name for remote info */ - pinfo = pktio_entry->ops_data(ipc).pinfo; + pinfo = pkt_ipc->pinfo; pool_name = _ipc_odp_buffer_pool_shm_name(pool_hdl); if (strlen(pool_name) > ODP_POOL_NAME_LEN) { ODP_ERR("pid %d ipc pool name %s is too big %d\n", @@ -155,7 +159,7 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry, pinfo->slave.pid = 0; pinfo->slave.init_done = 0; - pktio_entry->ops_data(ipc).pool = pool_hdl; + pkt_ipc->pool = pool_hdl; ODP_DBG("Pre init... DONE.\n"); pinfo->master.init_done = 1; @@ -221,15 +225,18 @@ static int _ipc_init_slave(const char *dev, pktio_entry_t *pktio_entry, odp_pool_t pool) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); + if (strlen(dev) > (ODP_POOL_NAME_LEN - sizeof("_slave_r"))) ODP_ABORT("too big ipc name\n"); - pktio_entry->ops_data(ipc).pool = pool; + pkt_ipc->pool = pool; return 0; } static int _ipc_slave_start(pktio_entry_t *pktio_entry) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); char ipc_shm_name[ODP_POOL_NAME_LEN + sizeof("_slave_r")]; struct pktio_info *pinfo; odp_shm_t shm; @@ -245,61 +252,61 @@ static int _ipc_slave_start(pktio_entry_t *pktio_entry) sprintf(dev, "ipc:%s", tail); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_prod", dev); - pktio_entry->ops_data(ipc).rx.recv = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->ops_data(ipc).rx.recv) { + pkt_ipc->rx.recv = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_ipc->rx.recv) { ODP_DBG("pid %d unable to find ipc ring %s name\n", getpid(), dev); sleep(1); return -1; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.recv), - _ring_free_count(pktio_entry->ops_data(ipc).rx.recv)); + ipc_shm_name, _ring_count(pkt_ipc->rx.recv), + _ring_free_count(pkt_ipc->rx.recv)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_cons", dev); - pktio_entry->ops_data(ipc).rx.free = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->ops_data(ipc).rx.free) { + pkt_ipc->rx.free = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_ipc->rx.free) { ODP_ERR("pid %d unable to find ipc ring %s name\n", getpid(), dev); goto free_m_prod; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.free), - _ring_free_count(pktio_entry->ops_data(ipc).rx.free)); + ipc_shm_name, _ring_count(pkt_ipc->rx.free), + _ring_free_count(pkt_ipc->rx.free)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_prod", dev); - pktio_entry->ops_data(ipc).tx.send = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->ops_data(ipc).tx.send) { + pkt_ipc->tx.send = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_ipc->tx.send) { ODP_ERR("pid %d unable to find ipc ring %s name\n", getpid(), dev); goto free_m_cons; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.send), - _ring_free_count(pktio_entry->ops_data(ipc).tx.send)); + ipc_shm_name, _ring_count(pkt_ipc->tx.send), + _ring_free_count(pkt_ipc->tx.send)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", dev); - pktio_entry->ops_data(ipc).tx.free = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->ops_data(ipc).tx.free) { + pkt_ipc->tx.free = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_ipc->tx.free) { ODP_ERR("pid %d unable to find ipc ring %s name\n", getpid(), dev); goto free_s_prod; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.free), - _ring_free_count(pktio_entry->ops_data(ipc).tx.free)); + ipc_shm_name, _ring_count(pkt_ipc->tx.free), + _ring_free_count(pkt_ipc->tx.free)); /* Get info about remote pool */ - pinfo = pktio_entry->ops_data(ipc).pinfo; + pinfo = pkt_ipc->pinfo; shm = _ipc_map_remote_pool(pinfo->master.pool_name, pid); - pktio_entry->ops_data(ipc).remote_pool_shm = shm; - pktio_entry->ops_data(ipc).pool_mdata_base = (char *)odp_shm_addr(shm); - pktio_entry->ops_data(ipc).pkt_size = pinfo->master.block_size; + pkt_ipc->remote_pool_shm = shm; + pkt_ipc->pool_mdata_base = (char *)odp_shm_addr(shm); + pkt_ipc->pkt_size = pinfo->master.block_size; - _ipc_export_pool(pinfo, pktio_entry->ops_data(ipc).pool); + _ipc_export_pool(pinfo, pkt_ipc->pool); - odp_atomic_store_u32(&pktio_entry->ops_data(ipc).ready, 1); + odp_atomic_store_u32(&pkt_ipc->ready, 1); pinfo->slave.init_done = 1; ODP_DBG("%s started.\n", pktio_entry->s.name); @@ -331,6 +338,7 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, char name[ODP_POOL_NAME_LEN + sizeof("_info")]; char tail[ODP_POOL_NAME_LEN]; odp_shm_t shm; + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); ODP_STATIC_ASSERT(ODP_POOL_NAME_LEN == _RING_NAMESIZE, "mismatch pool and ring name arrays"); @@ -338,15 +346,15 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, if (strncmp(dev, "ipc", 3)) return -1; - odp_atomic_init_u32(&pktio_entry->ops_data(ipc).ready, 0); + odp_atomic_init_u32(&pkt_ipc->ready, 0); - pktio_entry->ops_data(ipc).rx.cache = _ring_create("ipc_rx_cache", + pkt_ipc->rx.cache = _ring_create("ipc_rx_cache", PKTIO_IPC_ENTRIES, _RING_NO_LIST); /* Shared info about remote pktio */ if (sscanf(dev, "ipc:%d:%s", &pid, tail) == 2) { - pktio_entry->ops_data(ipc).type = PKTIO_TYPE_IPC_SLAVE; + pkt_ipc->type = PKTIO_TYPE_IPC_SLAVE; snprintf(name, sizeof(name), "ipc:%s_info", tail); IPC_ODP_DBG("lookup for name %s for pid %d\n", name, pid); @@ -359,12 +367,12 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, odp_shm_free(shm); return -1; } - pktio_entry->ops_data(ipc).pinfo = pinfo; - pktio_entry->ops_data(ipc).pinfo_shm = shm; + pkt_ipc->pinfo = pinfo; + pkt_ipc->pinfo_shm = shm; ODP_DBG("process %d is slave\n", getpid()); ret = _ipc_init_slave(name, pktio_entry, pool); } else { - pktio_entry->ops_data(ipc).type = PKTIO_TYPE_IPC_MASTER; + pkt_ipc->type = PKTIO_TYPE_IPC_MASTER; snprintf(name, sizeof(name), "%s_info", dev); shm = odp_shm_reserve(name, sizeof(struct pktio_info), ODP_CACHE_LINE_SIZE, @@ -377,8 +385,8 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, pinfo = odp_shm_addr(shm); pinfo->master.init_done = 0; pinfo->master.pool_name[0] = 0; - pktio_entry->ops_data(ipc).pinfo = pinfo; - pktio_entry->ops_data(ipc).pinfo_shm = shm; + pkt_ipc->pinfo = pinfo; + pkt_ipc->pinfo_shm = shm; ODP_DBG("process %d is master\n", getpid()); ret = _ipc_init_master(pktio_entry, dev, pool); } @@ -388,6 +396,7 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, static void _ipc_free_ring_packets(pktio_entry_t *pktio_entry, _ring_t *r) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); uintptr_t offsets[PKTIO_IPC_ENTRIES]; int ret; void **rbuf_p; @@ -398,7 +407,7 @@ static void _ipc_free_ring_packets(pktio_entry_t *pktio_entry, _ring_t *r) if (!r) return; - pool = pool_entry_from_hdl(pktio_entry->ops_data(ipc).pool); + pool = pool_entry_from_hdl(pkt_ipc->pool); addr = odp_shm_addr(pool->shm); rbuf_p = (void *)&offsets; @@ -423,6 +432,7 @@ static void _ipc_free_ring_packets(pktio_entry_t *pktio_entry, _ring_t *r) static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], int len) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); int pkts = 0; int i; _ring_t *r; @@ -432,16 +442,16 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, uint32_t ready; int pkts_ring; - ready = odp_atomic_load_u32(&pktio_entry->ops_data(ipc).ready); + ready = odp_atomic_load_u32(&pkt_ipc->ready); if (odp_unlikely(!ready)) { IPC_ODP_DBG("start pktio is missing before usage?\n"); return 0; } - _ipc_free_ring_packets(pktio_entry, pktio_entry->ops_data(ipc).tx.free); + _ipc_free_ring_packets(pktio_entry, pkt_ipc->tx.free); /* rx from cache */ - r = pktio_entry->ops_data(ipc).rx.cache; + r = pkt_ipc->rx.cache; pkts = _ring_mc_dequeue_burst(r, ipcbufs_p, len); if (odp_unlikely(pkts < 0)) ODP_ABORT("internal error dequeue\n"); @@ -449,7 +459,7 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, /* rx from other app */ if (pkts == 0) { ipcbufs_p = (void *)&offsets[0]; - r = pktio_entry->ops_data(ipc).rx.recv; + r = pkt_ipc->rx.recv; pkts = _ring_mc_dequeue_burst(r, ipcbufs_p, len); if (odp_unlikely(pkts < 0)) ODP_ABORT("internal error dequeue\n"); @@ -467,10 +477,10 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, uint64_t data_pool_off; void *rmt_data_ptr; - phdr = (void *)((uint8_t *)pktio_entry-> - ops_data(ipc).pool_mdata_base + offsets[i]); + phdr = (void *)((uint8_t *)pkt_ipc->pool_mdata_base + + offsets[i]); - pool = pktio_entry->ops_data(ipc).pool; + pool = pkt_ipc->pool; if (odp_unlikely(pool == ODP_POOL_INVALID)) ODP_ABORT("invalid pool"); @@ -494,12 +504,11 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, pkt_data = odp_packet_data(pkt); if (odp_unlikely(!pkt_data)) ODP_ABORT("unable to map pkt_data ipc_slave %d\n", - (PKTIO_TYPE_IPC_SLAVE == - pktio_entry->ops_data(ipc).type)); + (PKTIO_TYPE_IPC_SLAVE == pkt_ipc->type)); /* Copy packet data from shared pool to local pool. */ - rmt_data_ptr = (uint8_t *)pktio_entry-> - ops_data(ipc).pool_mdata_base + data_pool_off; + rmt_data_ptr = (uint8_t *)pkt_ipc->pool_mdata_base + + data_pool_off; memcpy(pkt_data, rmt_data_ptr, phdr->frame_len); /* Copy packets L2, L3 parsed offsets and size */ @@ -518,7 +527,7 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, /* put back to rx ring dequed but not processed packets*/ if (pkts != i) { ipcbufs_p = (void *)&offsets[i]; - r_p = pktio_entry->ops_data(ipc).rx.cache; + r_p = pkt_ipc->rx.cache; pkts_ring = _ring_mp_enqueue_burst(r_p, ipcbufs_p, pkts - i); if (pkts_ring != (pkts - i)) @@ -526,14 +535,13 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, if (i == 0) return 0; - } /*num of actually received packets*/ pkts = i; /* Now tell other process that we no longer need that buffers.*/ - r_p = pktio_entry->ops_data(ipc).rx.free; + r_p = pkt_ipc->rx.free; repeat: @@ -577,11 +585,12 @@ static int ipc_pktio_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, const odp_packet_t pkt_table[], int len) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); _ring_t *r; void **rbuf_p; int ret; int i; - uint32_t ready = odp_atomic_load_u32(&pktio_entry->ops_data(ipc).ready); + uint32_t ready = odp_atomic_load_u32(&pkt_ipc->ready); odp_packet_t pkt_table_mapped[len]; /**< Ready to send packet has to be * in memory mapped pool. */ uintptr_t offsets[len]; @@ -589,7 +598,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, if (odp_unlikely(!ready)) return 0; - _ipc_free_ring_packets(pktio_entry, pktio_entry->ops_data(ipc).tx.free); + _ipc_free_ring_packets(pktio_entry, pkt_ipc->tx.free); /* Copy packets to shm shared pool if they are in different * pool, or if they are references (we can't share across IPC). @@ -597,7 +606,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, for (i = 0; i < len; i++) { odp_packet_t pkt = pkt_table[i]; pool_t *ipc_pool = pool_entry_from_hdl( - pktio_entry->ops_data(ipc).pool); + pkt_ipc->pool); odp_packet_hdr_t *pkt_hdr; pool_t *pool; @@ -608,8 +617,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, odp_packet_has_ref(pkt)) { odp_packet_t newpkt; - newpkt = odp_packet_copy( - pkt, pktio_entry->ops_data(ipc).pool); + newpkt = odp_packet_copy(pkt, pkt_ipc->pool); if (newpkt == ODP_PACKET_INVALID) ODP_ABORT("Unable to copy packet\n"); @@ -641,20 +649,17 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, odp_packet_to_u64(pkt), odp_pool_to_u64(pool_hdl), pkt_hdr, pkt_hdr->buf_hdr.ipc_data_offset, offsets[i], odp_shm_addr(pool->shm), - odp_shm_addr(pool_entry_from_hdl(pktio_entry-> - ops_data(ipc).pool)->shm)); + odp_shm_addr(pool_entry_from_hdl( + pkt_ipc->pool)->shm)); } /* Put packets to ring to be processed by other process. */ rbuf_p = (void *)&offsets[0]; - r = pktio_entry->ops_data(ipc).tx.send; + r = pkt_ipc->tx.send; ret = _ring_mp_enqueue_burst(r, rbuf_p, len); if (odp_unlikely(ret < 0)) { ODP_ERR("pid %d odp_ring_mp_enqueue_bulk fail, ipc_slave %d, ret %d\n", - getpid(), - (PKTIO_TYPE_IPC_SLAVE == - pktio_entry->ops_data(ipc).type), - ret); + getpid(), (PKTIO_TYPE_IPC_SLAVE == pkt_ipc->type), ret); ODP_ERR("odp_ring_full: %d, odp_ring_count %d, _ring_free_count %d\n", _ring_full(r), _ring_count(r), _ring_free_count(r)); @@ -693,15 +698,15 @@ static int ipc_mac_addr_get(pktio_entry_t *pktio_entry ODP_UNUSED, static int ipc_start(pktio_entry_t *pktio_entry) { - uint32_t ready = odp_atomic_load_u32( - &pktio_entry->ops_data(ipc).ready); + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); + uint32_t ready = odp_atomic_load_u32(&pkt_ipc->ready); if (ready) { ODP_ABORT("%s Already started\n", pktio_entry->s.name); return -1; } - if (pktio_entry->ops_data(ipc).type == PKTIO_TYPE_IPC_MASTER) + if (pkt_ipc->type == PKTIO_TYPE_IPC_MASTER) return _ipc_master_start(pktio_entry); else return _ipc_slave_start(pktio_entry); @@ -709,24 +714,23 @@ static int ipc_start(pktio_entry_t *pktio_entry) static int ipc_stop(pktio_entry_t *pktio_entry) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); unsigned tx_send = 0, tx_free = 0; - odp_atomic_store_u32(&pktio_entry->ops_data(ipc).ready, 0); + odp_atomic_store_u32(&pkt_ipc->ready, 0); - if (pktio_entry->ops_data(ipc).tx.send) - _ipc_free_ring_packets(pktio_entry, - pktio_entry->ops_data(ipc).tx.send); + if (pkt_ipc->tx.send) + _ipc_free_ring_packets(pktio_entry, pkt_ipc->tx.send); /* other process can transfer packets from one ring to * other, use delay here to free that packets. */ sleep(1); - if (pktio_entry->ops_data(ipc).tx.free) - _ipc_free_ring_packets(pktio_entry, - pktio_entry->ops_data(ipc).tx.free); - - if (pktio_entry->ops_data(ipc).tx.send) - tx_send = _ring_count(pktio_entry->ops_data(ipc).tx.send); - if (pktio_entry->ops_data(ipc).tx.free) - tx_free = _ring_count(pktio_entry->ops_data(ipc).tx.free); + if (pkt_ipc->tx.free) + _ipc_free_ring_packets(pktio_entry, pkt_ipc->tx.free); + + if (pkt_ipc->tx.send) + tx_send = _ring_count(pkt_ipc->tx.send); + if (pkt_ipc->tx.free) + tx_free = _ring_count(pkt_ipc->tx.free); if (tx_send | tx_free) { ODP_DBG("IPC rings: tx send %d tx free %d\n", tx_send, tx_free); @@ -737,6 +741,7 @@ static int ipc_stop(pktio_entry_t *pktio_entry) static int ipc_close(pktio_entry_t *pktio_entry) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); char ipc_shm_name[ODP_POOL_NAME_LEN + sizeof("_m_prod")]; char *dev = pktio_entry->s.name; char name[ODP_POOL_NAME_LEN]; @@ -745,7 +750,7 @@ static int ipc_close(pktio_entry_t *pktio_entry) ipc_stop(pktio_entry); - odp_shm_free(pktio_entry->ops_data(ipc).remote_pool_shm); + odp_shm_free(pkt_ipc->remote_pool_shm); if (sscanf(dev, "ipc:%d:%s", &pid, tail) == 2) snprintf(name, sizeof(name), "ipc:%s", tail); @@ -753,7 +758,7 @@ static int ipc_close(pktio_entry_t *pktio_entry) snprintf(name, sizeof(name), "%s", dev); /* unlink this pktio info for both master and slave */ - odp_shm_free(pktio_entry->ops_data(ipc).pinfo_shm); + odp_shm_free(pkt_ipc->pinfo_shm); /* destroy rings */ snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", name); From patchwork Tue Sep 26 06: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: 114219 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3457126qgf; Mon, 25 Sep 2017 23:08:36 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBMi2YgkHJevRDRZuk1kCaTCuf3JElnydeoK4Zjp3WthlSuuQVNztHVEhcKvAZC/rhHQc75 X-Received: by 10.107.59.67 with SMTP id i64mr13137239ioa.123.1506406116080; Mon, 25 Sep 2017 23:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506406116; cv=none; d=google.com; s=arc-20160816; b=cDZT4SZ9NeFxwAXmhE2Chg3fLybBAl1fvyCYTzFoiYk5mNS0LBQqBCNxaY/jQmnh/1 gPz3fwFMpu/u3sSiY09gWucc2gi0s9EYpsZHFmL/8lIUme/ExbONJxr7EKnjJHN3SQZ5 uSs0cuN3Ej/gHI236n/EsHo5t8ncVrzXD+uhb+XOv73hqLpJwTZZgqB/k60ej59XW/Cm jQk+GsGb0yFLZuruiGpI8Zmv/aySP6QsSTaIOaQHjTAgHZwQsJB0CEzVkgViZuplhrDQ dGXRXjY8quB8ewB/M0Gr8ykptLweBmnp1EqbxGfUkpsmeSaFtRX/Ei/xdIjolWy56q7x nQUA== 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=lLn1cSYC4tMjDl9H79Z6eRXAFObG8FSG0Q0UTybX9tE=; b=XUYaJKf38XVCyJEGpFzipwumq68HZ3Wv4mQfKfBNYMrHa3Imv9Hlfd7b5lAsM7kAx6 VXjKMWvN/sAYjdmGJIrlesNHSbSmUshM2dZ+jxw986eBcQ0VN+wcHbwPxPn0lclb7fN+ XN5u48mAT0eNl/t+/NZI5Y6hUp4tBa3LJwNMmO0lxRE4p/zI/gaprqwiIFJuvdS4A5Xf TcbSzZUsjRDM79JI/un+aqAc4pfYfNEREKuQ5rX1n9r4+efOL1kBsJGSq/uBrdiBKTiB qg7eSFGnSjaWbLAvIW/8UzWL/Jr3QXhXwY/eRbHvDZKp4qy++mwt4i8yYDZFrac382Iz Sb5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y187si1231118itg.111.2017.09.25.23.08.35; Mon, 25 Sep 2017 23:08:36 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 8161E60D00; Tue, 26 Sep 2017 06:08:35 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 A2FC960D4A; Tue, 26 Sep 2017 06:01:04 +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 C727D60BFB; Tue, 26 Sep 2017 06:00:26 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 4711060C4B for ; Tue, 26 Sep 2017 06:00:16 +0000 (UTC) Received: from mxback11j.mail.yandex.net (mxback11j.mail.yandex.net [IPv6:2a02:6b8:0:1619::84]) by forward102j.mail.yandex.net (Yandex) with ESMTP id D407E56031AD for ; Tue, 26 Sep 2017 09:00:14 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback11j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Eplhj8JoEF-0EhWWQug; Tue, 26 Sep 2017 09:00:14 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 72uMtCPv0h-0EmWkOMA; Tue, 26 Sep 2017 09:00:14 +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: Tue, 26 Sep 2017 09:00:06 +0300 Message-Id: <1506405608-3507-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> References: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v1 7/9] linux-gen: pktio: netmap: use generic pktio_ops data storage 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: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: e89a0ed9c4cd6d7dc947b978ad1dcabc6d5a21a2 ** Merge commit sha: 160ad8615ce66c98231aa400863c82e89045d491 **/ .../include/odp_pktio_ops_subsystem.h | 2 - platform/linux-generic/odp_packet_io.c | 1 + platform/linux-generic/pktio/netmap.c | 96 +++++++++++++--------- 3 files changed, 60 insertions(+), 39 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 6bb31516a..ece4d46e0 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -79,7 +79,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { } pktio_ops_module_t; /* All implementations of this subsystem */ -#include #include /* Per implementation private data @@ -87,7 +86,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { */ typedef union { void *dpdk; - pktio_ops_netmap_data_t netmap; pktio_ops_pcap_data_t pcap; } pktio_ops_data_t; diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index e023df130..ae3125f62 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -26,6 +26,7 @@ #include #include #include +#include /* Sleep this many nanoseconds between pktin receive calls */ #define SLEEP_NSEC 1000 diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index bef3ae3a3..9ad1ab134 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,7 @@ static int netmap_do_ioctl(pktio_entry_t *pktio_entry, unsigned long cmd, int subcmd) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); struct ethtool_value eval; struct ifreq ifr; int err; @@ -135,7 +136,7 @@ static int netmap_input_queues_config(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); odp_pktin_mode_t mode = pktio_entry->s.param.in_mode; unsigned num_queues = p->num_queues; odp_bool_t lockless; @@ -164,7 +165,7 @@ static int netmap_output_queues_config(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); pkt_nm->lockless_tx = (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE); @@ -182,7 +183,7 @@ static inline void netmap_close_descriptors(pktio_entry_t *pktio_entry) { int i, j; pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); for (i = 0; i < PKTIO_MAX_QUEUES; i++) { for (j = 0; j < NM_MAX_DESC; j++) { @@ -206,7 +207,7 @@ static inline void netmap_close_descriptors(pktio_entry_t *pktio_entry) static int netmap_close(pktio_entry_t *pktio_entry) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); netmap_close_descriptors(pktio_entry); @@ -220,11 +221,13 @@ static int netmap_close(pktio_entry_t *pktio_entry) static int netmap_link_status(pktio_entry_t *pktio_entry) { - if (pktio_entry->ops_data(netmap).is_virtual) + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + if (pkt_nm->is_virtual) return 1; - return link_status_fd(pktio_entry->ops_data(netmap).sockfd, - pktio_entry->ops_data(netmap).if_name); + return link_status_fd(pkt_nm->sockfd, pkt_nm->if_name); } /** @@ -240,6 +243,8 @@ static inline int netmap_wait_for_link(pktio_entry_t *pktio_entry) { int i; int ret; + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); /* Wait for the link to come up */ for (i = 0; i <= NM_WAIT_TIMEOUT; i++) { @@ -251,12 +256,12 @@ static inline int netmap_wait_for_link(pktio_entry_t *pktio_entry) * until the opposing end's interface comes back up again. In * this case without the additional sleep pktio validation * tests fail. */ - if (!pktio_entry->ops_data(netmap).is_virtual) + if (!pkt_nm->is_virtual) sleep(1); if (ret == 1) return 1; } - ODP_DBG("%s link is down\n", pktio_entry->ops_data(netmap).if_name); + ODP_DBG("%s link is down\n", pkt_nm->if_name); return 0; } @@ -268,7 +273,7 @@ static inline int netmap_wait_for_link(pktio_entry_t *pktio_entry) static void netmap_init_capability(pktio_entry_t *pktio_entry) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); odp_pktio_capability_t *capa = &pkt_nm->capa; memset(&pkt_nm->capa, 0, sizeof(odp_pktio_capability_t)); @@ -336,7 +341,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, uint32_t mtu; uint32_t buf_size; pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); struct nm_desc *desc; struct netmap_ring *ring; odp_pktin_hash_proto_t hash_proto; @@ -460,7 +465,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, static int netmap_start(pktio_entry_t *pktio_entry) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); netmap_ring_t *desc_ring; struct nm_desc *desc_ptr; unsigned i; @@ -616,8 +621,10 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, netmap_slot_t slot_tbl[], int16_t slot_num, odp_time_t *ts) { + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); odp_packet_t pkt; - odp_pool_t pool = pktio_entry->ops_data(netmap).pool; + odp_pool_t pool = pkt_nm->pool; odp_packet_hdr_t *pkt_hdr; odp_packet_hdr_t parsed_hdr; int i; @@ -625,7 +632,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, int alloc_len; /* Allocate maximum sized packets */ - alloc_len = pktio_entry->ops_data(netmap).mtu; + alloc_len = pkt_nm->mtu; num = packet_alloc_multi(pool, alloc_len, pkt_tbl, slot_num); @@ -638,10 +645,9 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, odp_prefetch(slot.buf); - if (odp_unlikely(len > pktio_entry-> - ops_data(netmap).max_frame_len)) { + if (odp_unlikely(len > pkt_nm->max_frame_len)) { ODP_ERR("RX: frame too big %" PRIu16 " %zu!\n", len, - pktio_entry->ops_data(netmap).max_frame_len); + pkt_nm->max_frame_len); goto fail; } @@ -738,7 +744,7 @@ static int netmap_recv(pktio_entry_t *pktio_entry, int index, { struct nm_desc *desc; pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); unsigned first_desc_id = pkt_nm->rx_desc_ring[index].s.first; unsigned last_desc_id = pkt_nm->rx_desc_ring[index].s.last; unsigned desc_id; @@ -792,7 +798,7 @@ static int netmap_send(pktio_entry_t *pktio_entry, int index, const odp_packet_t pkt_table[], int num) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); struct pollfd polld; struct nm_desc *desc; struct netmap_ring *ring; @@ -867,76 +873,92 @@ static int netmap_send(pktio_entry_t *pktio_entry, int index, static int netmap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->ops_data(netmap).if_mac, ETH_ALEN); + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + memcpy(mac_addr, pkt_nm->if_mac, ETH_ALEN); return ETH_ALEN; } static uint32_t netmap_mtu_get(pktio_entry_t *pktio_entry) { - return pktio_entry->ops_data(netmap).mtu; + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + return pkt_nm->mtu; } static int netmap_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - if (pktio_entry->ops_data(netmap).is_virtual) { + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + if (pkt_nm->is_virtual) { __odp_errno = ENOTSUP; return -1; } - return promisc_mode_set_fd( - pktio_entry->ops_data(netmap).sockfd, - pktio_entry->ops_data(netmap).if_name, enable); + return promisc_mode_set_fd(pkt_nm->sockfd, pkt_nm->if_name, enable); } static int netmap_promisc_mode_get(pktio_entry_t *pktio_entry) { - if (pktio_entry->ops_data(netmap).is_virtual) + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + if (pkt_nm->is_virtual) return 0; - return promisc_mode_get_fd( - pktio_entry->ops_data(netmap).sockfd, - pktio_entry->ops_data(netmap).if_name); + return promisc_mode_get_fd(pkt_nm->sockfd, pkt_nm->if_name); } static int netmap_capability(pktio_entry_t *pktio_entry, odp_pktio_capability_t *capa) { - *capa = pktio_entry->ops_data(netmap).capa; + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + *capa = pkt_nm->capa; return 0; } static int netmap_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(stats, 0, sizeof(*stats)); return 0; } return sock_stats_fd(pktio_entry, - stats, - pktio_entry->ops_data(netmap).sockfd); + stats, pkt_nm->sockfd); } static int netmap_stats_reset(pktio_entry_t *pktio_entry) { + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(&pktio_entry->s.stats, 0, sizeof(odp_pktio_stats_t)); return 0; } - return sock_stats_reset_fd(pktio_entry, - pktio_entry->ops_data(netmap).sockfd); + return sock_stats_reset_fd(pktio_entry, pkt_nm->sockfd); } static void netmap_print(pktio_entry_t *pktio_entry) { odp_pktin_hash_proto_t hash_proto; + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); - if (rss_conf_get_fd(pktio_entry->ops_data(netmap).sockfd, - pktio_entry->ops_data(netmap).if_name, &hash_proto)) + if (rss_conf_get_fd(pkt_nm->sockfd, pkt_nm->if_name, &hash_proto)) rss_conf_print(&hash_proto); } From patchwork Tue Sep 26 06: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: 114220 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3457964qgf; Mon, 25 Sep 2017 23:09:43 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCFAaazn+JGnsN86k8V1R1iFQ7PTy0ASePnO377XT6Iza+P/RlY1fxkYEWS2pBBOorkGr03 X-Received: by 10.107.130.26 with SMTP id e26mr12690828iod.119.1506406183477; Mon, 25 Sep 2017 23:09:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506406183; cv=none; d=google.com; s=arc-20160816; b=C+PT7OXiCi4+oCBLaeu1l814on5K+kYSzD/FHJCTLIp6hqulUjVux2VXv5rqd4v0wc DpGWRM6RIE2+arkN85s8NnOk34I4/VCXiRPXkGbBsRreonNl6ZPuXbT02QkHQ8Pn/6S9 0FSakK5S7DPKtd/lqhGvaGawo840sGtMI9JKGnVJH1bxxtoqaKrUfyuaO+iVacg6KMQF UKVUWGEhk/lKOR3VcsvEEjRLCj/nSVYkBR4wdx9jgK6gMoEJ7h/wCNtmUiy1ONnX/HHA IM143ea1elrBWcnLKaE4JnoPl3jKdRtha0aNEQ8zkcl55ObkTNx9i8P8AVQGH47e/kLK nk/A== 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=FgtF8QmbY4nkCeUgPRhlnZBaD39DzwEBfh9W7Q1D8uw=; b=FIEBz0fMkfNXkYZ84L5nHz7/v2BWJk4eSZoTk2+pUYueUZJFv8iguw8bfKZi7UU+uC vPDn80QcHZrD5dtvOGywH/LYLeAb6/IrecGb/KYTv7ORFrBeddGWIqgPiupGBSQpQGCa 3PQCFS8LWz3AM+mYoZHmTwyRvPt4kfnFYtRQWqwBh2e3kXXPN0UfM8+IaFA3ZrQD4vK4 EHRIeZU/Fz6DdS6fmjmjMCkqPc2utWoL5lDH8yy39hAunYHpgxQjpLYhygBJZL4uE3B/ EvXJqfVos9UU/p26pKoUs5fKO0I7Eu8c8TwDpJZgbnxyeV4ozccdUhIYq7ry/fCMTA9k nsIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h74si6720196ioi.210.2017.09.25.23.09.43; Mon, 25 Sep 2017 23:09:43 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 11FFA60D42; Tue, 26 Sep 2017 06:09:43 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 F2E7E60D50; Tue, 26 Sep 2017 06:01:06 +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 C8FD760C4B; Tue, 26 Sep 2017 06:00:27 +0000 (UTC) Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [5.45.198.241]) by lists.linaro.org (Postfix) with ESMTPS id 0252E60C71 for ; Tue, 26 Sep 2017 06:00:16 +0000 (UTC) Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward101j.mail.yandex.net (Yandex) with ESMTP id 812CD12423B0 for ; Tue, 26 Sep 2017 09:00:15 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id F1jzDw79ka-0FhGlmiC; Tue, 26 Sep 2017 09:00:15 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 72uMtCPv0h-0Em8E59b; Tue, 26 Sep 2017 09:00:14 +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: Tue, 26 Sep 2017 09:00:07 +0300 Message-Id: <1506405608-3507-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> References: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v1 8/9] linux-gen: pktio: pcap: use generic pktio_ops data storage 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: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: e89a0ed9c4cd6d7dc947b978ad1dcabc6d5a21a2 ** Merge commit sha: 160ad8615ce66c98231aa400863c82e89045d491 **/ .../linux-generic/include/odp_pktio_ops_subsystem.h | 4 ---- platform/linux-generic/pktio/pcap.c | 19 +++++++++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index ece4d46e0..5449eccbd 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -78,15 +78,11 @@ typedef ODP_MODULE_CLASS(pktio_ops) { odp_api_proto(pktio_ops, print) print; } pktio_ops_module_t; -/* All implementations of this subsystem */ -#include - /* Per implementation private data * TODO: refactory each implementation to hide it internally */ typedef union { void *dpdk; - pktio_ops_pcap_data_t pcap; } pktio_ops_data_t; /* Extract pktio ops data from pktio entry structure */ diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index 684c4e120..d885c0402 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -137,8 +138,7 @@ static int _pcapif_init_tx(pktio_ops_pcap_data_t *pcap) static int pcapif_init(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, const char *devname, odp_pool_t pool) { - pktio_ops_pcap_data_t *pcap = - &pktio_entry->ops_data(pcap); + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); int ret; memset(pcap, 0, sizeof(pktio_ops_pcap_data_t)); @@ -165,7 +165,7 @@ static int pcapif_init(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, static int pcapif_close(pktio_entry_t *pktio_entry) { - pktio_ops_pcap_data_t *pcap = &pktio_entry->ops_data(pcap); + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); if (pcap->tx_dump) pcap_dump_close(pcap->tx_dump); @@ -212,8 +212,7 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_packet_t pkt; odp_packet_hdr_t *pkt_hdr; uint32_t pkt_len; - pktio_ops_pcap_data_t *pcap = - &pktio_entry->ops_data(pcap); + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); odp_time_t ts_val; odp_time_t *ts = NULL; @@ -296,8 +295,7 @@ static int _pcapif_dump_pkt(pktio_ops_pcap_data_t *pcap, odp_packet_t pkt) static int pcapif_send_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED, const odp_packet_t pkts[], int len) { - pktio_ops_pcap_data_t *pcap = - &pktio_entry->ops_data(pcap); + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); int i; odp_ticketlock_lock(&pktio_entry->s.txl); @@ -365,8 +363,7 @@ static int pcapif_promisc_mode_set(pktio_entry_t *pktio_entry, { char filter_exp[64] = {0}; struct bpf_program bpf; - pktio_ops_pcap_data_t *pcap = - &pktio_entry->ops_data(pcap); + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); if (!pcap->rx) { pcap->promisc = enable; @@ -406,7 +403,9 @@ static int pcapif_promisc_mode_set(pktio_entry_t *pktio_entry, static int pcapif_promisc_mode_get(pktio_entry_t *pktio_entry) { - return pktio_entry->ops_data(pcap).promisc; + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); + + return pcap->promisc; } static int pcapif_stats_reset(pktio_entry_t *pktio_entry) From patchwork Tue Sep 26 06:00:08 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: 114226 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3458636qgf; Mon, 25 Sep 2017 23:10:37 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBXz12C+rVh6ppuCxRLeyZT7nMdKqJ0mo7O5HXk3WdkVNFtJpECM0EOhlnKrGOod5Woddeu X-Received: by 10.36.20.149 with SMTP id 143mr3912848itg.63.1506406237021; Mon, 25 Sep 2017 23:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506406237; cv=none; d=google.com; s=arc-20160816; b=pVsbRnGHBkJXyYwLTHaeDeN6gUREykY6Ed1yTLBGNreZFXUrSaF015YTDeSvhnnkzJ dBY89mJOsqbFinqSxv4lMPYb0DuaLwcRDH/d6b3wyIc7l5Dey4m85hrdpg7l+GTp/Ruh r59HTodwGzwRfM8HLPzpqTXGPlGyY7wSRa/KbDxhQBjlmIGkKKGXK+WgUnft9VU6NEl3 XyUTbTds6P+wa85hTPWSCOJ+uwm+Zpz0MyGTU7mAmpGSUB+sEICjY6L78sHnMvov67Cg Qi7vy3SGDkLCshrhbErjqnpaEUhkGEx70RLkudlFBf9vqLU8qDey6p50++RqJVXDzYBJ tGiQ== 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=CtauqMW7YvK7POdPhDXfLpFeamqHjGPuWoaSDzolnDs=; b=U1OkvdhUojuCLzLUJLeRm54UVcD6Nsb2Dm8UHkbCSZWrYk0XoR5AekjABJQZprZ+7n 7WbCYDJYp9vOKaaqaFeUMczKKeN4Vc+rAMliYcoD+c0aIrr80nP3wWJncLba2RwqQWnT R2DfVlFRa0WeVCnv9NqqkG5BeZ7LXTypkkjL9pY/AMPSrYMd1vCq6eeX/VHG9OckwN7w w3lxLFRKRIuA9r16VjUC2xZp70NdOTpMFkabR9myzI59dzWMrzXvWllOOQ3UwjsCfHj0 ylPacawWQn5t8QIpqFA4nLp/wxe3/FGjIKk4aFJtzCGMolDoLyG/GeL7RNbEYBvJQp2y WzLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i7si6724987iob.66.2017.09.25.23.10.36; Mon, 25 Sep 2017 23:10:36 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 5F39260D1F; Tue, 26 Sep 2017 06:10:36 +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,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 452AB60D60; Tue, 26 Sep 2017 06:01:13 +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 74F1160CCC; Tue, 26 Sep 2017 06:00:31 +0000 (UTC) Received: from forward101p.mail.yandex.net (forward101p.mail.yandex.net [77.88.28.101]) by lists.linaro.org (Postfix) with ESMTPS id 1F08260CA9 for ; Tue, 26 Sep 2017 06:00:18 +0000 (UTC) Received: from mxback8j.mail.yandex.net (mxback8j.mail.yandex.net [IPv6:2a02:6b8:0:1619::111]) by forward101p.mail.yandex.net (Yandex) with ESMTP id 40A846A83DD4 for ; Tue, 26 Sep 2017 09:00:16 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback8j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id vtHpI3RFTL-0G606AfE; Tue, 26 Sep 2017 09:00:16 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 72uMtCPv0h-0FmKDtL2; Tue, 26 Sep 2017 09:00:15 +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: Tue, 26 Sep 2017 09:00:08 +0300 Message-Id: <1506405608-3507-10-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> References: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v1 9/9] linux-gen: pktio: dpdk: use generic pktio_ops data storage 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: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: e89a0ed9c4cd6d7dc947b978ad1dcabc6d5a21a2 ** Merge commit sha: 160ad8615ce66c98231aa400863c82e89045d491 **/ .../linux-dpdk/include/odp_packet_io_internal.h | 7 +- platform/linux-dpdk/pktio/dpdk.c | 55 +++++------- .../linux-generic/include/odp_packet_io_internal.h | 6 +- .../include/odp_pktio_ops_subsystem.h | 12 +-- platform/linux-generic/pktio/dpdk.c | 100 +++++++++++---------- 5 files changed, 80 insertions(+), 100 deletions(-) diff --git a/platform/linux-dpdk/include/odp_packet_io_internal.h b/platform/linux-dpdk/include/odp_packet_io_internal.h index 07db8cab0..3e4d64f3a 100644 --- a/platform/linux-dpdk/include/odp_packet_io_internal.h +++ b/platform/linux-dpdk/include/odp_packet_io_internal.h @@ -29,7 +29,6 @@ extern "C" { #define PKTIO_MAX_QUEUES 64 #include -#include /* Forward declaration */ typedef union pktio_entry_u pktio_entry_t; @@ -42,10 +41,8 @@ typedef union pktio_entry_u pktio_entry_t; struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ - union { - pktio_ops_data_t ops_data; - uint8_t _ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; - }; + uint8_t ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; /**< IO operation + specific data */ /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ diff --git a/platform/linux-dpdk/pktio/dpdk.c b/platform/linux-dpdk/pktio/dpdk.c index d7a90197a..30ccc456e 100644 --- a/platform/linux-dpdk/pktio/dpdk.c +++ b/platform/linux-dpdk/pktio/dpdk.c @@ -39,18 +39,6 @@ static pktio_ops_module_t dpdk_pktio_ops; static uint32_t mtu_get_pkt_dpdk(pktio_entry_t *pktio_entry); -static inline pktio_ops_dpdk_data_t * - __retrieve_op_data(pktio_entry_t *pktio) -{ - return (pktio_ops_dpdk_data_t *)(pktio->ops_data(dpdk)); -} - -static inline void __release_op_data(pktio_entry_t *pktio) -{ - free(pktio->ops_data(dpdk)); - pktio->ops_data(dpdk) = NULL; -} - /* Test if s has only digits or not. Dpdk pktio uses only digits.*/ static int _dpdk_netdev_is_valid(const char *s) { @@ -108,7 +96,7 @@ static int input_queues_config_pkt_dpdk(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_pktin_mode_t mode = pktio_entry->s.param.in_mode; /** @@ -138,7 +126,7 @@ static int output_queues_config_pkt_dpdk(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); if (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE) pkt_dpdk->lockless_tx = 1; @@ -155,7 +143,8 @@ static int setup_pkt_dpdk(odp_pktio_t pktio ODP_UNUSED, { uint8_t portid = 0; struct rte_eth_dev_info dev_info; - pktio_ops_dpdk_data_t *pkt_dpdk = NULL; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); int i; if (!_dpdk_netdev_is_valid(netdev)) { @@ -164,9 +153,6 @@ static int setup_pkt_dpdk(odp_pktio_t pktio ODP_UNUSED, return -1; } - pktio_entry->ops_data(dpdk) = malloc(sizeof(pktio_ops_dpdk_data_t)); - pkt_dpdk = __retrieve_op_data(pktio_entry); - if (odp_unlikely(pkt_dpdk == NULL)) { ODP_ERR("Failed to allocate pktio_ops_dpdk_data_t struct"); return -1; @@ -202,12 +188,11 @@ static int setup_pkt_dpdk(odp_pktio_t pktio ODP_UNUSED, static int close_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); if (pktio_entry->s.state == PKTIO_STATE_STOPPED) rte_eth_dev_close(pkt_dpdk->portid); - __release_op_data(pktio_entry); return 0; } @@ -215,7 +200,7 @@ static int start_pkt_dpdk(pktio_entry_t *pktio_entry) { int ret, i; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t portid = pkt_dpdk->portid; int sid = rte_eth_dev_socket_id(pkt_dpdk->portid); int socket_id = sid < 0 ? 0 : sid; @@ -324,7 +309,8 @@ static int start_pkt_dpdk(pktio_entry_t *pktio_entry) static int stop_pkt_dpdk(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + rte_eth_dev_stop(pkt_dpdk->portid); return 0; } @@ -373,7 +359,7 @@ static int recv_pkt_dpdk(pktio_entry_t *pktio_entry, int index, { uint16_t nb_rx, i; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_packet_t *saved_pkt_table; uint8_t min = pkt_dpdk->min_rx_burst; odp_time_t ts_val; @@ -490,7 +476,7 @@ static int send_pkt_dpdk(pktio_entry_t *pktio_entry, int index, { int pkts; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); if (!pkt_dpdk->lockless_tx) odp_ticketlock_lock(&pkt_dpdk->tx_lock[index]); @@ -543,7 +529,7 @@ static uint32_t _dpdk_vdev_mtu(uint8_t port_id) static uint32_t mtu_get_pkt_dpdk(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint16_t mtu = 0; int ret; @@ -604,7 +590,7 @@ static int _dpdk_vdev_promisc_mode_set(uint8_t port_id, int enable) static int promisc_mode_set_pkt_dpdk(pktio_entry_t *pktio_entry, int enable) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t portid = pkt_dpdk->portid; if (enable) @@ -648,7 +634,7 @@ static int _dpdk_vdev_promisc_mode(uint8_t port_id) static int promisc_mode_get_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t portid = pkt_dpdk->portid; if (pkt_dpdk->vdev_sysc_promisc) @@ -660,25 +646,27 @@ static int promisc_mode_get_pkt_dpdk(pktio_entry_t *pktio_entry) static int mac_get_pkt_dpdk(pktio_entry_t *pktio_entry, void *mac_addr) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + rte_eth_macaddr_get(pkt_dpdk->portid, (struct ether_addr *)mac_addr); return ETH_ALEN; } - static int capability_pkt_dpdk(pktio_entry_t *pktio_entry, odp_pktio_capability_t *capa) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + *capa = pkt_dpdk->capa; return 0; } + static int link_status_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); struct rte_eth_link link; rte_eth_link_get(pkt_dpdk->portid, &link); @@ -702,7 +690,7 @@ static void stats_convert(struct rte_eth_stats *rte_stats, static int stats_pkt_dpdk(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); int ret; struct rte_eth_stats rte_stats; @@ -721,7 +709,8 @@ static int stats_pkt_dpdk(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) static int stats_reset_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + rte_eth_stats_reset(pkt_dpdk->portid); return 0; } diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 0201a47fa..665589ce3 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -48,10 +48,8 @@ typedef union pktio_entry_u pktio_entry_t; struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ - union { - pktio_ops_data_t ops_data; /**< IO operation specific data */ - uint8_t _ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; - }; + uint8_t ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; /**< IO operation + specific data */ /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 5449eccbd..f1ff48832 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -78,21 +78,11 @@ typedef ODP_MODULE_CLASS(pktio_ops) { odp_api_proto(pktio_ops, print) print; } pktio_ops_module_t; -/* Per implementation private data - * TODO: refactory each implementation to hide it internally - */ -typedef union { - void *dpdk; -} pktio_ops_data_t; - -/* Extract pktio ops data from pktio entry structure */ -#define ops_data(mod) s.ops_data.mod - /* Maximum size of pktio specific ops data.*/ #define ODP_PKTIO_ODPS_DATA_MAX_SIZE 80000 /* Extract pktio ops data from pktio entry structure */ #define odp_ops_data(_p, _mod) \ - ((pktio_ops_ ## _mod ## _data_t *)(uintptr_t)_p->s._ops_data) + ((pktio_ops_ ## _mod ## _data_t *)(uintptr_t)_p->s.ops_data) #endif diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 21c9fb0f7..be2bbbfcb 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -33,18 +34,6 @@ #include #include -static inline pktio_ops_dpdk_data_t * - __retrieve_op_data(pktio_entry_t *pktio) -{ - return (pktio_ops_dpdk_data_t *)(pktio->ops_data(dpdk)); -} - -static inline void __release_op_data(pktio_entry_t *pktio) -{ - free(pktio->ops_data(dpdk)); - pktio->ops_data(dpdk) = NULL; -} - #if ODP_DPDK_ZERO_COPY ODP_STATIC_ASSERT(CONFIG_PACKET_HEADROOM == RTE_PKTMBUF_HEADROOM, "ODP and DPDK headroom sizes not matching!"); @@ -315,6 +304,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, struct rte_mbuf *mbuf_table[], uint16_t mbuf_num, odp_time_t *ts) { + pktio_ops_dpdk_data_t *pkt_dpdk = odp_ops_data(pktio_entry, dpdk); odp_packet_t pkt; odp_packet_hdr_t *pkt_hdr; uint16_t pkt_len; @@ -323,10 +313,10 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, int i, j; int nb_pkts = 0; int alloc_len, num; - odp_pool_t pool = __retrieve_op_data(pktio_entry)->pool; + odp_pool_t pool = pkt_dpdk->pool; /* Allocate maximum sized packets */ - alloc_len = __retrieve_op_data(pktio_entry)->data_room; + alloc_len = pkt_dpdk->data_room; num = packet_alloc_multi(pool, alloc_len, pkt_table, mbuf_num); if (num != mbuf_num) { @@ -399,7 +389,7 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, const odp_packet_t pkt_table[], uint16_t num) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); int i, j; char *data; uint16_t pkt_len; @@ -437,6 +427,8 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, struct rte_mbuf *mbuf_table[], uint16_t mbuf_num, odp_time_t *ts) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); odp_packet_t pkt; odp_packet_hdr_t *pkt_hdr; uint16_t pkt_len; @@ -444,7 +436,7 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, void *data; int i; int nb_pkts = 0; - odp_pool_t pool = __retrieve_op_data(pktio_entry)->pool; + odp_pool_t pool = pkt_dpdk->pool; for (i = 0; i < mbuf_num; i++) { odp_packet_hdr_t parsed_hdr; @@ -502,7 +494,7 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, uint16_t *seg_count) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); int i; *seg_count = 0; @@ -578,7 +570,7 @@ static uint32_t dpdk_vdev_mtu_get(uint8_t port_id) static uint32_t dpdk_mtu_get(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint32_t mtu = 0; if (rte_eth_dev_get_mtu(pkt_dpdk->port_id, (uint16_t *)&mtu)) @@ -672,7 +664,7 @@ static int dpdk_setup_port(pktio_entry_t *pktio_entry) { int ret; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); struct rte_eth_rss_conf rss_conf; /* Always set some hash functions to enable DPDK RSS hash calculation */ @@ -715,7 +707,7 @@ static int dpdk_setup_port(pktio_entry_t *pktio_entry) static int dpdk_close(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); unsigned idx; unsigned i, j; @@ -733,7 +725,6 @@ static int dpdk_close(pktio_entry_t *pktio_entry) if (!ODP_DPDK_ZERO_COPY) rte_mempool_free(pkt_dpdk->pkt_pool); - __release_op_data(pktio_entry); return 0; } @@ -866,6 +857,8 @@ static int dpdk_pktio_init_local(void) static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); odp_pktin_mode_t mode = pktio_entry->s.param.in_mode; odp_bool_t lockless; @@ -879,9 +872,9 @@ static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, lockless = 0; if (p->hash_enable && p->num_queues > 1) - __retrieve_op_data(pktio_entry)->hash = p->hash_proto; + pkt_dpdk->hash = p->hash_proto; - __retrieve_op_data(pktio_entry)->lockless_rx = lockless; + pkt_dpdk->lockless_rx = lockless; return 0; } @@ -890,7 +883,7 @@ static int dpdk_output_queues_config(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_bool_t lockless; if (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE) @@ -907,7 +900,7 @@ static void dpdk_init_capability(pktio_entry_t *pktio_entry, struct rte_eth_dev_info *dev_info) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_pktio_capability_t *capa = &pkt_dpdk->capa; memset(dev_info, 0, sizeof(struct rte_eth_dev_info)); @@ -930,7 +923,8 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, const char *netdev, odp_pool_t pool) { - pktio_ops_dpdk_data_t *pkt_dpdk = NULL; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); struct rte_eth_dev_info dev_info; struct rte_mempool *pkt_pool; char pool_name[RTE_MEMPOOL_NAMESIZE]; @@ -958,9 +952,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, dpdk_initialized = 1; } - pktio_entry->ops_data(dpdk) = malloc(sizeof(pktio_ops_dpdk_data_t)); - pkt_dpdk = __retrieve_op_data(pktio_entry); - if (odp_unlikely(pkt_dpdk == NULL)) { ODP_ERR("Failed to allocate pktio_ops_dpdk_data_t struct"); return -1; @@ -974,7 +965,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, if (rte_eth_dev_count() == 0) { ODP_ERR("No DPDK ports found\n"); - __release_op_data(pktio_entry); return -1; } @@ -983,7 +973,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, mtu = dpdk_mtu_get(pktio_entry); if (mtu == 0) { ODP_ERR("Failed to read interface MTU\n"); - __release_op_data(pktio_entry); return -1; } pkt_dpdk->mtu = mtu + _ODP_ETHHDR_LEN; @@ -1020,7 +1009,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, } if (pkt_pool == NULL) { ODP_ERR("Cannot init mbuf packet pool\n"); - __release_op_data(pktio_entry); return -1; } @@ -1046,7 +1034,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, static int dpdk_start(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t port_id = pkt_dpdk->port_id; int ret; unsigned i; @@ -1097,7 +1085,10 @@ static int dpdk_start(pktio_entry_t *pktio_entry) static int dpdk_stop(pktio_entry_t *pktio_entry) { - rte_eth_dev_stop(__retrieve_op_data(pktio_entry)->port_id); + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + rte_eth_dev_stop(pkt_dpdk->port_id); return 0; } @@ -1106,7 +1097,7 @@ static int dpdk_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt_table[], int num) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); pkt_cache_t *rx_cache = &pkt_dpdk->rx_cache[index]; odp_time_t ts_val; odp_time_t *ts = NULL; @@ -1182,7 +1173,7 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index, { struct rte_mbuf *tx_mbufs[num]; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint16_t seg_count = 0; int tx_pkts; int i; @@ -1245,16 +1236,21 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index, static int dpdk_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - rte_eth_macaddr_get(__retrieve_op_data(pktio_entry)->port_id, + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + rte_eth_macaddr_get(pkt_dpdk->port_id, (struct ether_addr *)mac_addr); return ETH_ALEN; } static int dpdk_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - uint8_t port_id = __retrieve_op_data(pktio_entry)->port_id; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + uint8_t port_id = pkt_dpdk->port_id; - if (__retrieve_op_data(pktio_entry)->vdev_sysc_promisc) + if (pkt_dpdk->vdev_sysc_promisc) return dpdk_vdev_promisc_mode_set(port_id, enable); if (enable) @@ -1267,9 +1263,11 @@ static int dpdk_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) static int dpdk_promisc_mode_get(pktio_entry_t *pktio_entry) { - uint8_t port_id = __retrieve_op_data(pktio_entry)->port_id; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + uint8_t port_id = pkt_dpdk->port_id; - if (__retrieve_op_data(pktio_entry)->vdev_sysc_promisc) + if (pkt_dpdk->vdev_sysc_promisc) return dpdk_vdev_promisc_mode_get(port_id); else return rte_eth_promiscuous_get(port_id); @@ -1278,18 +1276,22 @@ static int dpdk_promisc_mode_get(pktio_entry_t *pktio_entry) static int dpdk_capability(pktio_entry_t *pktio_entry, odp_pktio_capability_t *capa) { - *capa = __retrieve_op_data(pktio_entry)->capa; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + *capa = pkt_dpdk->capa; return 0; } static int dpdk_link_status(pktio_entry_t *pktio_entry) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); struct rte_eth_link link; memset(&link, 0, sizeof(struct rte_eth_link)); - rte_eth_link_get_nowait( - __retrieve_op_data(pktio_entry)->port_id, &link); + rte_eth_link_get_nowait(pkt_dpdk->port_id, &link); return link.link_status; } @@ -1308,11 +1310,12 @@ static void stats_convert(const struct rte_eth_stats *rte_stats, static int dpdk_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); int ret; struct rte_eth_stats rte_stats; - ret = rte_eth_stats_get( - __retrieve_op_data(pktio_entry)->port_id, &rte_stats); + ret = rte_eth_stats_get(pkt_dpdk->port_id, &rte_stats); if (ret == 0) { stats_convert(&rte_stats, stats); @@ -1323,7 +1326,10 @@ static int dpdk_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) static int dpdk_stats_reset(pktio_entry_t *pktio_entry) { - rte_eth_stats_reset(__retrieve_op_data(pktio_entry)->port_id); + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + rte_eth_stats_reset(pkt_dpdk->port_id); return 0; }