From patchwork Thu Oct 19 12: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: 116383 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp410575qgn; Thu, 19 Oct 2017 05:04:01 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RZX68xoAkVXDo0KRxzsTO7eMZ825wtSoQ+CNbafQSeBzY9K3UfJgIrSZct8LpKBZivCDbh X-Received: by 10.55.18.223 with SMTP id 92mr1445954qks.303.1508414641215; Thu, 19 Oct 2017 05:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508414641; cv=none; d=google.com; s=arc-20160816; b=IdhyBJCbq1swB9KEPRBdkN4eLA5Vtcb7t9Sfodl42i7VDDRyBuBegLyx1zLHjDPNhZ Y4PVozJAjFDMzCCg38DxAHHIluUax38sWAfrCP9keStpstQk09BV6JRXK8cv9nc4IlOA +rOENYpCt2kehQnMXQIXTKil8XUvBN2Q3V86NUbVDoVRU5c+ubV9wCF6imn9dUGfgdxi nx5FdU8NahlHDMl4FJlKWHgVdEOUl8+UTLTzBpHlZLR/CBcGl4xoXuEwtUS7Km3raaXT FBDQbXmPPBcgtPQXB5/fCDTZJmyy7b8O3Exa9WHAP5Xcyfj+DGiu4AlqCHg0/IwoYKLg VH/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=9+jgliH+1hf8tpnOt8zPXwl3yHX+LcyqIAAiot00BDU=; b=sCvHPazjiYz2Ktl2OuTBkzHVTTtC3GEDbvDg5nZEBTyPS6mhx1flAbdgRIjJ6NbIAz iAfoglrvy5xLsItueyJ1nvgPt5+NF4qbHCeWhtYkSuYvPYaOUr0gbPDW4Ao+EN2bpLIG 7PL128l2QSimv5qpip6CIEitVnPU9iJ3Ux2/e57e9exQ3Jj+bWqT65SPOy6efoP9BzfV QlGsjJclYYg2FgyAeO/xewtbGRYL06n1yA+PzUMYn6bEikEGIB4OU5+o49HK/2LderSB SWGO4Ut0cSPSrW4fPEluG6ESy0NG7RDRogkVy78+h/HbipGBXVf+U4xp/fcFxZxLcW60 KzNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id n198si2175634qke.115.2017.10.19.05.04.00; Thu, 19 Oct 2017 05:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id DAD8562ADC; Thu, 19 Oct 2017 12:04:00 +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 547B662A96; Thu, 19 Oct 2017 12:02:32 +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 98C4D62A74; Thu, 19 Oct 2017 12:02:20 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id 081DF62A9E for ; Thu, 19 Oct 2017 12:00:15 +0000 (UTC) Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 75834408502F for ; Thu, 19 Oct 2017 15:00:13 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id hKC742O8St-0DhG2YHX; Thu, 19 Oct 2017 15:00:13 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lZE2bfHgVf-0CIGrQBW; Thu, 19 Oct 2017 15:00:12 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 19 Oct 2017 15:00:00 +0300 Message-Id: <1508414408-10456-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> References: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 241 Subject: [lng-odp] [PATCH 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 241 (bogdanPricope:2_0_pktio_ops_pr) ** https://github.com/Linaro/odp/pull/241 ** Patch: https://github.com/Linaro/odp/pull/241.patch ** Base sha: 76f82972ecb51aa64215c97cb3d7f94e5de980f9 ** Merge commit sha: 24c411a2875cbcd686833666d481a0197cc82e90 **/ 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 10760ca47..d31c449e2 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 dacea47c9..79f5b1082 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -50,7 +50,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 3843ac709..07c5dbee7 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -105,4 +105,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 Thu Oct 19 12: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: 116384 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp411803qgn; Thu, 19 Oct 2017 05:04:55 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TpEmyxfC2W+xGcViE2KNxuEprXBrDeIh3gOFl00ciiKcjcpVcgVnEMQUU+0qKJ4QLNNwc9 X-Received: by 10.36.73.14 with SMTP id z14mr2018838ita.60.1508414695386; Thu, 19 Oct 2017 05:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508414695; cv=none; d=google.com; s=arc-20160816; b=CUVEMYdbY7jQntXWJgARsqXeaWJ5H4+Ia/Ka1CxrE3bjWfEL2XSdxABIv3uQ1t0eoF 9FCQZfdQdFxYk2JslNd/THQfABNicARCNZLd4/kdkbOvjvV3b6UMm9r19TZsbpKdGRYz 5w52X0yqDKp8qf0mlS/ZOIx/zhMIOk507MrTb+Ylc/PyTKXKuX2esDwpYBsQNLw27Bzm 8CKzEDI/IoqMqmHYeB4z5DlELTGFNMAwM1uKtG3SiqFpHCixfawDoc3o0+Z9g93pkbOy r/mNxT5YE58v3frksRt9D3v8IFzWywP9TzXyIFCetPnL09tcBjMRR17809JqCov/xSEE 9j1g== 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=ItPuy41aZ2/TVWdNRbgkumcZpEsLd/FLZArL8J/g96w=; b=J7ppyO7PyagvqIQn2DfJ9sL4Sjlh8wOT5KrhzZ9W8JDtMNhjt1A0h0sb/fxvEmFJHj +eVjnmDz84tCL9zZ7Et923WvNrUx66wMU4vQ8RYsKEQWTgxQ9bz6URhta7fzxVri99U+ JHgvyijVJbFK5Aa/vEYPtS0mg+DOg7dLcPH38v5KCvNnd9gCPun5VHv74MatqvLaVz6h X3YHoAWPD9cNv+FOCFeR8Z1DGxWWVpO0ucFwvupsdGLIx9cTLAUIZmtEg1/7e1S0nkDv Pme8q3y6epevdCHAs2vCbB67r4HPdJY6jmkNJBSc5pCUTxNqgBoHDW02ZV38ef5aGHYY IGLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id z126si1213866itg.60.2017.10.19.05.04.55; Thu, 19 Oct 2017 05:04:55 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id E13F260C1D; Thu, 19 Oct 2017 12:04:54 +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 A297262A9E; Thu, 19 Oct 2017 12:02:41 +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 1054B62B34; Thu, 19 Oct 2017 12:02:27 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id 187CF61D4C for ; Thu, 19 Oct 2017 12:00:17 +0000 (UTC) Received: from mxback17j.mail.yandex.net (mxback17j.mail.yandex.net [IPv6:2a02:6b8:0:1619::93]) by forward100o.mail.yandex.net (Yandex) with ESMTP id E8E532A22193 for ; Thu, 19 Oct 2017 15:00:14 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback17j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id yH6ge1nmZM-0EZWVHgY; Thu, 19 Oct 2017 15:00:14 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lZE2bfHgVf-0DIWN7Pd; Thu, 19 Oct 2017 15: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: Thu, 19 Oct 2017 15:00:01 +0300 Message-Id: <1508414408-10456-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> References: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 241 Subject: [lng-odp] [PATCH 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 241 (bogdanPricope:2_0_pktio_ops_pr) ** https://github.com/Linaro/odp/pull/241 ** Patch: https://github.com/Linaro/odp/pull/241.patch ** Base sha: 76f82972ecb51aa64215c97cb3d7f94e5de980f9 ** Merge commit sha: 24c411a2875cbcd686833666d481a0197cc82e90 **/ .../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 07c5dbee7..241ce4673 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) { /* All implementations of this subsystem */ #include -#include #include #include #include @@ -94,7 +93,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 b17868a39..01bbc8bc6 100644 --- a/platform/linux-generic/pktio/loopback.c +++ b/platform/linux-generic/pktio/loopback.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -21,6 +22,7 @@ #include #include #include +#include /* MAC address for the "loop" interface */ static const char pktio_loop_mac[] = {0x02, 0xe9, 0x34, 0x80, 0x73, 0x01}; @@ -30,6 +32,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; @@ -37,10 +42,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); @@ -50,7 +54,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, @@ -65,13 +72,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 || @@ -155,6 +164,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; @@ -166,7 +177,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) { @@ -219,13 +230,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 Thu Oct 19 12: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: 116385 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp413281qgn; Thu, 19 Oct 2017 05:06:08 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TeRlYbhB7d0rwG6WFHUa1Q/9jSvrpd7lZ1j7p1QE8rAkGfkZ6OtnKZmk+/ctO02WQ32sVg X-Received: by 10.36.181.27 with SMTP id v27mr1947246ite.137.1508414767882; Thu, 19 Oct 2017 05:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508414767; cv=none; d=google.com; s=arc-20160816; b=LMWqfQ9AcsEO44bnTdMKVVIKqOip+2lIVyJo4h8ZhWzr15OXmco41iSt6AYJclaVOX jek8/Rh2I7wUCXc/KTGSg6FStkWbqGV3mYfXgeW9oum0HPuAPK3P10HF6YZYfcitXjU2 uOkV7phjFs3PiDt/gcvKmaZixd8BDNmmR2ilo3p0j7gOB+9RQRYxfdGExdirJX5vynuq ua2A0IWWVmHwb1JmwbZrvlOzvzMBO68PP0RuRb1VvoL1Yd+zngPRq5LdpcBJNaz3+b+P BbRNxsyqMAXXKPCmTWTJjasaqx9wMF8cg9NFCdHkp99jZQn4085RBQ9iOlBsomDwzXZT PPYA== 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=8g9mzYjO0hYMBJluZtQ3GKEDEo0Sea7hC3+rxAh+Kfw=; b=bD5kmQqa2GV3ji3pJxId2VJKz5d1kSr6fCPzD0ZxnPm08xQaiHUJejV0UqITxjZ1S1 gdkUUpJWLE6Kx83o/cBYeKeO52V13GCHcQ+G59mFl8C0eSXo1Lp70z4qbee6cOvbxANu eN4epgFZss2VMhBgWs97zvcFkT6Cs6g8hPJTjGqaJW59ufkyywj6mB7rKNm3aOsxmF3r LMrSlUvLpTg5keIfQsfDHBVfPCuzIRgXFjWfKgDmKnQtKRchd6iL+BHxwqryqn7byQsq MG5fO4ROYIyJuaNauHXqkTogjMJoMCMk3blsd5vBvznNthrzsc/ukBtJ7EhNkK3/ihqd av2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id w62si1224279itb.6.2017.10.19.05.06.07; Thu, 19 Oct 2017 05:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 5CC5062B38; Thu, 19 Oct 2017 12:06:07 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 1E9E562A9F; Thu, 19 Oct 2017 12:03:03 +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 D169762C64; Thu, 19 Oct 2017 12:02:52 +0000 (UTC) Received: from forward104p.mail.yandex.net (forward104p.mail.yandex.net [77.88.28.107]) by lists.linaro.org (Postfix) with ESMTPS id 7F90762A9F for ; Thu, 19 Oct 2017 12:00:17 +0000 (UTC) Received: from mxback2o.mail.yandex.net (mxback2o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1c]) by forward104p.mail.yandex.net (Yandex) with ESMTP id 3882C18361D for ; Thu, 19 Oct 2017 15:00:16 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback2o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 8JeQAuBjmW-0GaWBWNR; Thu, 19 Oct 2017 15:00:16 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lZE2bfHgVf-0FIemgSJ; Thu, 19 Oct 2017 15: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: Thu, 19 Oct 2017 15:00:02 +0300 Message-Id: <1508414408-10456-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> References: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 241 Subject: [lng-odp] [PATCH 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 241 (bogdanPricope:2_0_pktio_ops_pr) ** https://github.com/Linaro/odp/pull/241 ** Patch: https://github.com/Linaro/odp/pull/241.patch ** Base sha: 76f82972ecb51aa64215c97cb3d7f94e5de980f9 ** Merge commit sha: 24c411a2875cbcd686833666d481a0197cc82e90 **/ platform/linux-generic/Makefile.am | 2 + .../linux-generic/include/odp_pktio_ops_socket.h | 76 ----- platform/linux-generic/pktio/common.c | 367 +++++++++++++++++++++ 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, 474 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 d5ddb4db4..277418142 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -175,6 +175,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 94add0615..4c952e467 100644 --- a/platform/linux-generic/pktio/common.c +++ b/platform/linux-generic/pktio/common.c @@ -9,7 +9,17 @@ #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) { @@ -82,3 +92,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 = (void *)&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 = (void *)&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 c32615229..9337ea33d 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -24,6 +24,7 @@ #include #include +#include #include #include diff --git a/platform/linux-generic/pktio/ethtool.c b/platform/linux-generic/pktio/ethtool.c index b41ce4440..b71666a32 100644 --- a/platform/linux-generic/pktio/ethtool.c +++ b/platform/linux-generic/pktio/ethtool.c @@ -19,6 +19,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 d4b5636ba..215e6454e 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index df277e67c..0a2e268c5 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -99,358 +101,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 3930ade21..1605b7fff 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -32,6 +32,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 bb7efe051..6cef64f18 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -45,6 +45,7 @@ #include #include #include +#include #define BUF_SIZE 65536 From patchwork Thu Oct 19 12: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: 116387 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp416699qgn; Thu, 19 Oct 2017 05:09:12 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RRm3jU/e03KWW/gwToWvI3sBCZoTLoB2EBklCHcCvex5tSQ/OIXOlzLHCSNaardeyPBQc9 X-Received: by 10.107.201.69 with SMTP id z66mr1424035iof.118.1508414952493; Thu, 19 Oct 2017 05:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508414952; cv=none; d=google.com; s=arc-20160816; b=A2wqPz16qvWnXUvk7w17A02Y6uWvxQZJkPh4TXIvyfIKRmmHjfpcNc4TjK8pzlPxFX z3tzJQd3wtmiQVuYL9/ar3K63Yk2rBIkoMaKT9GSGO3/ADXADLYgQxKb4pGS+jeA76UH wSIsipbyswpFAzIlc78AZu3sKm/SqgvPvIHOAXNm5Gd/TKTrAl1bpkn6S+B+dF1JvE7q wURZJ73OBU6YWlNwqRiswU8yGgfv/kVH4z0+YeVNZcMigbTT0VeXc0YIPaLNYannSL8D ybJtR8hW7tHM+K/6djRnqGfxBd28OMrtgQsEahXGkicSKU/zyslgd2bF6K/+AQ4Lb6Il 3aYA== 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=vV5VKTHiUtc0tBKAeDxaQPvEIZ4TOBz7/lg3YklHBno=; b=JByc3deUdC05AyAmB2qtg1S40EwsTLxEuZqz2ocH9HBY+PcZWVj6AztjhxNAqB3xNk 9xOKyFGx4mzMfpbKVM9vSv5uFqpTe/qUfM1QtMHTCnAykiGVAOO/joAS+FUYlMSNEcSA rpoDGGi4hgawM3eyLnsTY/vXUT4ydM1ijS+7l9z4VZJTRO2n3+ADwsoy6c7piE4zALD6 4ilWKo7vHFGNOz9sGULMGGvjFGJ28TrDdr4JUVgDLfMrv3WExtRdtr8LiAv1BJJuQveU RNkLi2m0bLOGWHhAYFeYikh2ut9FkhWDsrFOAfaFD93raJEIyf8gkDWBx6cspBy+lhL7 uXlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id a30si10903661ioj.96.2017.10.19.05.09.12; Thu, 19 Oct 2017 05:09:12 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 1851D62EDB; Thu, 19 Oct 2017 12:09:12 +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 A8FD962CB5; Thu, 19 Oct 2017 12:03:14 +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 66516629F2; Thu, 19 Oct 2017 12:03:06 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id 708E6629F2 for ; Thu, 19 Oct 2017 12:00:18 +0000 (UTC) Received: from mxback6g.mail.yandex.net (mxback6g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:167]) by forward100o.mail.yandex.net (Yandex) with ESMTP id 4D2412A244FE for ; Thu, 19 Oct 2017 15:00:17 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback6g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 1cPrIImQrz-0HiGC5x0; Thu, 19 Oct 2017 15:00:17 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lZE2bfHgVf-0GIiU5mW; Thu, 19 Oct 2017 15:00:16 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 19 Oct 2017 15:00:03 +0300 Message-Id: <1508414408-10456-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> References: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 241 Subject: [lng-odp] [PATCH 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 241 (bogdanPricope:2_0_pktio_ops_pr) ** https://github.com/Linaro/odp/pull/241 ** Patch: https://github.com/Linaro/odp/pull/241.patch ** Base sha: 76f82972ecb51aa64215c97cb3d7f94e5de980f9 ** Merge commit sha: 24c411a2875cbcd686833666d481a0197cc82e90 **/ .../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 241ce4673..d945a5cc1 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -84,7 +84,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { #include #include #include -#include #include /* Per implementation private data @@ -95,8 +94,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 0a2e268c5..238cd67f9 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -107,7 +108,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; @@ -131,7 +132,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 */ @@ -256,7 +257,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; @@ -372,7 +373,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; @@ -418,7 +419,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; } /* @@ -427,7 +431,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; } @@ -437,7 +444,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); } @@ -446,13 +456,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); } @@ -474,26 +490,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 1605b7fff..3b62979d8 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -491,7 +492,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); @@ -521,7 +522,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 */ @@ -607,7 +608,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); @@ -623,7 +624,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, @@ -635,33 +636,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, @@ -682,26 +696,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 Thu Oct 19 12: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: 116386 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp415547qgn; Thu, 19 Oct 2017 05:08:10 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SZGBrvZ4eb+hlO6U+iLsvEAi20ItCBVhqXPgSgfYtQEhwjryigz2sECm/RWkd+rWiUvLmQ X-Received: by 10.36.73.164 with SMTP id e36mr1820713itd.129.1508414890811; Thu, 19 Oct 2017 05:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508414890; cv=none; d=google.com; s=arc-20160816; b=dTAr+zs/c3vibdSUc3HGnpqqCICWMrjG1Z/GqHdmfy05hMpyU1UbPjaILZwUYcLQio biB7u7xwJZQZ90mRgWgu3aWZ6z5UG1bK8bItexw7Nves0C/LZIw9bAk65bTd8BMVJnv6 BGQiRLjQOashWr2yWRey/wp9WjNvU2S2VRjCjHRx5szsLq4kG834V3e+QX8PMSI6TDKB LExgixEoW8oimtMIFDjKZnYAaMEYNlA2vS5Q5Wzogp/FOaoZcAy9uWNrEP3fou9zNLBD 9iu2ak7BqGSxfcAC0cn5DoewtB1Hw378JekeGuEVPU7GvagVrDtMCJbu3u2ogkdqex6f 4C8Q== 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=2+NpCMt0ANao8yN/oxfeRNpBYOayHs+8T4HY8J0z4QA=; b=zdRtYipMRRH2pdS2uUVW6u6nI6mR6z4nX+EdF4s9YIMrypGZhBzn0GTH4pYy3omu7r DQwnDXBwxY8zemkd479tdhbjGVGQgC+3pzi6jpbS6OOcE0Wf49mXWz+/RY+XGkco+797 Q2ZgP6D7UWWDhWSXK3NVSM/zkq5CqZaCc8OET9tfXGX4K80MbaPO3otQ81q+ePG+NtFB QYTQz0qbhr3gYuMqeVn7LsT+opLasuOK4z+8pvC9IKZSV7WPEsOVos2E6JF4rvUN10L9 /cO10lFdL8md/usxJnYKzzZ9hdbtjjga5Nsv4wyLMJJT6t+m6Yq+p2imSbwT5vXQpsv+ bOfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id 6si1153759itv.66.2017.10.19.05.08.10; Thu, 19 Oct 2017 05:08:10 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 4A15462E4A; Thu, 19 Oct 2017 12:08:10 +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 51FF962C64; Thu, 19 Oct 2017 12:03:09 +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 0B84C62A88; Thu, 19 Oct 2017 12:03:02 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 3D5D562ABF for ; Thu, 19 Oct 2017 12:00:25 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 063232D8524C for ; Thu, 19 Oct 2017 15:00:24 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id FBQ83Ecopb-0Hk85IeK; Thu, 19 Oct 2017 15:00:17 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lZE2bfHgVf-0HIe9NHw; Thu, 19 Oct 2017 15:00:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 19 Oct 2017 15:00:04 +0300 Message-Id: <1508414408-10456-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> References: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 241 Subject: [lng-odp] [PATCH 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 241 (bogdanPricope:2_0_pktio_ops_pr) ** https://github.com/Linaro/odp/pull/241 ** Patch: https://github.com/Linaro/odp/pull/241.patch ** Base sha: 76f82972ecb51aa64215c97cb3d7f94e5de980f9 ** Merge commit sha: 24c411a2875cbcd686833666d481a0197cc82e90 **/ .../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 d945a5cc1..56b7a5fcd 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -84,7 +84,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { #include #include #include -#include /* Per implementation private data * TODO: refactory each implementation to hide it internally @@ -94,7 +93,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 6cef64f18..e256eec3e 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #define BUF_SIZE 65536 @@ -66,7 +67,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; @@ -166,7 +167,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; @@ -186,6 +187,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; @@ -193,13 +195,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; @@ -230,7 +231,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; @@ -270,7 +271,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]); @@ -332,11 +333,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; } @@ -344,19 +345,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 Thu Oct 19 12: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: 116389 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp420351qgn; Thu, 19 Oct 2017 05:12:28 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QSYNIAMbspm7x47W+JyrOpr6SXiN7a2u1pOrRMNzt5ni2/wYHMTgn4WFz3s3k4smTpIl90 X-Received: by 10.36.144.4 with SMTP id x4mr1971133itd.103.1508415148057; Thu, 19 Oct 2017 05:12:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508415148; cv=none; d=google.com; s=arc-20160816; b=AJV4pe9N2HwOui7urf7W+ooSjad5ZK65C9lpw/BBGf0ZnY5OG/PHVHWaW/55qrGXnk Oxg3QlnraTHgH+1JUYsA2ZR9FzJsslJQX21deoh0lNb3SsorHLx0bs+eSvJqKfLZK09o N9jnjlMDb6JrNXuo95+exWcTxbZvondUraHsr6XjBZ90ggJiIP1S/rtNeFNAeqMbMuln A21gCMMcRP+TKFoCgE+0sOVLYqXLnJy3nSxlDOPpUKsrtMaMj+JZlm8l/zifEHcVQHuy ZVHlMWQzk94xoAnxfIscuPGQGLMPj29Hlm6RAp8Cfuwi6hBCFbKIPT0ggfFGSyrjc4fW UtQA== 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=DNGmNViC+cd53+KN7N6K1VnOuYUSMpV28Z/mRiNAJbU=; b=WyhKROuCpo4ZC0r8q15XtprVpMKBbTk3Zk3GI58K8vH18k4LHLH5E5ipjVXo/kEObP N2rGh75yBPCSzaHfvo0/9pqa0yYd4hMsefWqQf9THdMC+vHiu9pnYpaXHywWh3oSv8J4 bxnGjlEunxHQ0yFyxOQKYVoA/SBpjdhUT1Q+jZhFG5ZDvDqxLd3lPLVijMfPEddI0zG5 ytJol60jKgToLrIqsITgktbflqbTF6vIOAGyEqoyz2s4VipK+7/vox1iPh9NOupVoohF +/OBmTPl2gaWYhgRUCpueiYyQkYfBAdN8pDcWxqiuAljAvfNbWCcrY+ct+wX5xciDM7E A/jQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id i6si10787925iob.15.2017.10.19.05.12.27; Thu, 19 Oct 2017 05:12:28 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 89D9A62F07; Thu, 19 Oct 2017 12:12:27 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id D7E5F62D83; Thu, 19 Oct 2017 12:04:16 +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 73BC562AC9; Thu, 19 Oct 2017 12:03:56 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 5957962AC9 for ; Thu, 19 Oct 2017 12:00:26 +0000 (UTC) Received: from mxback10j.mail.yandex.net (mxback10j.mail.yandex.net [IPv6:2a02:6b8:0:1619::113]) by forward100p.mail.yandex.net (Yandex) with ESMTP id EF4D451017FE for ; Thu, 19 Oct 2017 15:00:24 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback10j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id idRLRiohuB-0O0aQnRr; Thu, 19 Oct 2017 15:00:24 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lZE2bfHgVf-0OISYRjB; Thu, 19 Oct 2017 15:00:24 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 19 Oct 2017 15:00:05 +0300 Message-Id: <1508414408-10456-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> References: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 241 Subject: [lng-odp] [PATCH 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 241 (bogdanPricope:2_0_pktio_ops_pr) ** https://github.com/Linaro/odp/pull/241 ** Patch: https://github.com/Linaro/odp/pull/241.patch ** Base sha: 76f82972ecb51aa64215c97cb3d7f94e5de980f9 ** Merge commit sha: 24c411a2875cbcd686833666d481a0197cc82e90 **/ .../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 56b7a5fcd..411d961a1 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -81,7 +81,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { } pktio_ops_module_t; /* All implementations of this subsystem */ -#include #include #include @@ -90,7 +89,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 6e3fdfdb5..6505d7878 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -11,10 +11,12 @@ #include #include #include <_ishm_internal.h> +#include #include #include #include +#include #define IPC_ODP_DEBUG_PRINT 0 @@ -45,7 +47,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) @@ -59,11 +62,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; @@ -73,6 +76,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; @@ -90,62 +94,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", @@ -158,7 +162,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; @@ -224,15 +228,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; @@ -248,61 +255,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); @@ -334,6 +341,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"); @@ -341,15 +349,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); @@ -362,12 +370,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, @@ -380,8 +388,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); } @@ -391,6 +399,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; @@ -401,7 +410,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; @@ -426,6 +435,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; @@ -435,16 +445,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"); @@ -452,7 +462,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"); @@ -470,10 +480,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"); @@ -497,12 +507,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 */ @@ -521,7 +530,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)) @@ -529,14 +538,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: @@ -580,11 +588,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]; @@ -592,7 +601,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). @@ -600,7 +609,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; @@ -611,8 +620,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"); @@ -644,20 +652,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)); @@ -696,15 +701,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); @@ -712,24 +717,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); @@ -740,6 +744,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]; @@ -748,7 +753,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); @@ -756,7 +761,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 Thu Oct 19 12: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: 116388 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp419195qgn; Thu, 19 Oct 2017 05:11:22 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RaX/oTgGICPag8Z6UWAhLUHFkeZ/a8RJy4uk2ZI+kR6tdsEPLbl6yYlXstjraRoRWaKT4O X-Received: by 10.36.91.138 with SMTP id g132mr1888575itb.33.1508415082574; Thu, 19 Oct 2017 05:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508415082; cv=none; d=google.com; s=arc-20160816; b=hn81VO8QBdqbReU1OmXXZgDjjpuZzTYUgoeb3JYbXULe2CrN/fkR+VzXojwfKxgEaE TeaIjTHRGZ4ImCSEEaVg/PgQq4Ke6fZ8CO8q6wJzhRP9AEQ4TOFDRvpBjlLZvY8f+aps yYKWhJtJHv/g6gVP98A6zF6ygryGXMV6V3J1noBW+OdxG+f2M1YhTEZtmGxf9fd1u5HB LSn+HRz5O1h5aRrH/9OnFx7NSAMeFDum/oCYx/93MAX8EroOiu7uCViYo5ibB1DpRbDn p9jhkECGv8h88qO9xW4AtFvmcIGdPMLYsX6BM8dukUIFEdl7w9jsG2AOnMbRZAEYVlvc oqeA== 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=jcz0oczs3GYnxYfpu/lK65Q6o7cK3DHHm8vD+PJcSe8=; b=eiAw4hy3UHiCAARLyRG996Jxa7ze7hrsPRyPjI4u/9P3aVxWUZ1Sds04KJ0YAfKHLq TIxPedkLhm56OdjO1bf1zG0zB6wSxEJtAghC7lyMQRLKLmPIdGfq3naQMOFqELeZQRrI Zmbw8+gP5PGSDLt5tbf5LeTKr0wLSipRLgDfdFRGOMOtox9F9fGh/wK8PHuMkI2DH8S3 wxMyfqo3OyycNVuiYeWzo6qOswqJmo/sLCdud89mj9kPZ3n+Qf42U5jOWA1uKL1tl+WP nT/37kU88lO5QCCFmrMxpgkj+9F/ftjVXSjAOO9EcBaZ91nZaCl41oLJ5OHARabuejL1 HRHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id s2si9511265ioa.280.2017.10.19.05.11.22; Thu, 19 Oct 2017 05:11:22 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 2433F62D31; Thu, 19 Oct 2017 12:11:22 +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, RCVD_IN_MSPIKE_H4, 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 8E11562CA7; Thu, 19 Oct 2017 12:04: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 1597062ADC; Thu, 19 Oct 2017 12:03:50 +0000 (UTC) Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by lists.linaro.org (Postfix) with ESMTPS id CB30362AEA for ; Thu, 19 Oct 2017 12:00:26 +0000 (UTC) Received: from mxback10j.mail.yandex.net (mxback10j.mail.yandex.net [IPv6:2a02:6b8:0:1619::113]) by forward105j.mail.yandex.net (Yandex) with ESMTP id ABC4A18386C for ; Thu, 19 Oct 2017 15:00:25 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback10j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id zqi9cWIt2N-0P04lS6f; Thu, 19 Oct 2017 15:00:25 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lZE2bfHgVf-0PIiPKku; Thu, 19 Oct 2017 15:00:25 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 19 Oct 2017 15:00:06 +0300 Message-Id: <1508414408-10456-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> References: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 241 Subject: [lng-odp] [PATCH 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 241 (bogdanPricope:2_0_pktio_ops_pr) ** https://github.com/Linaro/odp/pull/241 ** Patch: https://github.com/Linaro/odp/pull/241.patch ** Base sha: 76f82972ecb51aa64215c97cb3d7f94e5de980f9 ** Merge commit sha: 24c411a2875cbcd686833666d481a0197cc82e90 **/ .../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 411d961a1..edc5ab8a6 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -81,7 +81,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { } pktio_ops_module_t; /* All implementations of this subsystem */ -#include #include /* Per implementation private data @@ -89,7 +88,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 e2239bcdb..beeb9c6b3 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -29,6 +29,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 215e6454e..84e2144f4 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -49,7 +50,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; @@ -137,7 +138,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; @@ -166,7 +167,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); @@ -184,7 +185,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++) { @@ -208,7 +209,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); @@ -222,11 +223,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); } /** @@ -242,6 +245,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++) { @@ -253,12 +258,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; } @@ -270,7 +275,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)); @@ -338,7 +343,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; @@ -462,7 +467,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; @@ -618,8 +623,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; @@ -627,7 +634,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); @@ -640,10 +647,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; } @@ -740,7 +746,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; @@ -794,7 +800,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; @@ -869,76 +875,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 Thu Oct 19 12: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: 116390 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp421916qgn; Thu, 19 Oct 2017 05:14:02 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RRVJJHEhSBYORzlvYlBgjHjdnuqfrCqGO6Xt3Sk9mBFkY5AZrpU+S3swKqAJhhpBfNVYj6 X-Received: by 10.55.1.8 with SMTP id 8mr54033qkb.80.1508415242342; Thu, 19 Oct 2017 05:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508415242; cv=none; d=google.com; s=arc-20160816; b=V1+s8G24XUEtnPgS2Qj070dI4QifPHET1fQmznhomnJ0jDOLM7t9ynQsNhkmFKatIF yPdsl1cSce5ez3rfMIslZLFfxKGfKFCUlVmvPiGNofd07gONCf5jkfKnZsMaY7ZfVf+L 3Iq8xl/Vkmjo4Ku6kMD8LRfcXRhfsQ2pKkTmEAm33kijQI6jCBdnm27rg6TGUAbk/URy ZGZQo8NSTTxN5y4cNWHuUttDPrxS0IPy2U6hbd6CuWEAQ133TPwfWckQDWcvo7NxLAKg Rbe9wnPBAo51HSg85ifBcfw5m7m2oq0pz8mcqh/6sBO+uA0I75kY/unUwWTYZcD0Rn76 1+lg== 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=lxfUIwc/flhNOTQJ8+toB5/iYZ59MELW++eoS0kZ06o=; b=y2Vn+F3FZWbcLR2wPBKqS6OhHQRHgj/3ydwLg7L9X57yMcL7f99OBxSYqTvbV6sE0k cy+A0o6MWk4F2f5PAQPIgPhVa3lTT9BSVFrD7gAdG5bDB1eDKFnf8WfVtUaqDm+8KyZd UsMVwlr2aE81kcYtwSA6AXo2jQbF0bXmP6qGUiFdd5O5B3vQzcF05Y4cpg1Ha6gt+Sdp 5nYfLeCuN/e6+Y2GVbUfDOWptHA8XXZmkyAUm1FSd+xtovIfVf2U4pMilXa0e3Q+K6fb CVJ1ZT9gamdIhp+OfebZZJZpm8R6ZNNXvqQ9xCjZ7eb9uIZP2Nx9HHAeY3gfZAIHMYUS Asgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id o39si2542918qta.471.2017.10.19.05.14.02; Thu, 19 Oct 2017 05:14:02 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 0892862F45; Thu, 19 Oct 2017 12:14:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, 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 3D3FB62AEA; Thu, 19 Oct 2017 12:04:24 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C4B6262ADC; Thu, 19 Oct 2017 12:03:58 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id DBA8462AC2 for ; Thu, 19 Oct 2017 12:00:28 +0000 (UTC) Received: from mxback5g.mail.yandex.net (mxback5g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:166]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 601C434C2EE8 for ; Thu, 19 Oct 2017 15:00:26 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback5g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Stj1y1q1wm-0QnSnbVt; Thu, 19 Oct 2017 15:00:26 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lZE2bfHgVf-0PIePA4D; Thu, 19 Oct 2017 15:00:25 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 19 Oct 2017 15:00:07 +0300 Message-Id: <1508414408-10456-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> References: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 241 Subject: [lng-odp] [PATCH 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 241 (bogdanPricope:2_0_pktio_ops_pr) ** https://github.com/Linaro/odp/pull/241 ** Patch: https://github.com/Linaro/odp/pull/241.patch ** Base sha: 76f82972ecb51aa64215c97cb3d7f94e5de980f9 ** Merge commit sha: 24c411a2875cbcd686833666d481a0197cc82e90 **/ .../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 edc5ab8a6..64940d514 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -80,15 +80,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 252a9048f..5bfaeef0e 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -41,6 +41,7 @@ #include #include #include +#include #include @@ -139,8 +140,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)); @@ -167,7 +167,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); @@ -214,8 +214,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; @@ -298,8 +297,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); @@ -367,8 +365,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; @@ -408,7 +405,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 Thu Oct 19 12: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: 116391 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp422798qgn; Thu, 19 Oct 2017 05:14:53 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T38cqm3WVNGH2QLmCIK5zCRUOwRR2ZPDzR+YQFHXzRmaJ6+orwoVjrLvbb6Kz7Cl00AkoD X-Received: by 10.107.158.75 with SMTP id h72mr1510509ioe.256.1508415292899; Thu, 19 Oct 2017 05:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508415292; cv=none; d=google.com; s=arc-20160816; b=xGi45Bq02eF0XI2orXHVIDYtfjArmIaQFLaJKUktAkiiuUP4f6A3JfjyyvHEGkHRpd gFyqAcyHYa6H8qTtArdFTO3US9Nxr1QLsJXQWkIdahzgznsB/gJKQY4LjLAC7R+WFQ0B Emr6SsfjcCpVFuwPIwLZwxid0S/TR9y1MpDWwb/Nq6fJfZSdxGtWn2LquCbVtkSbyQuU 8dalBsxqHOO8NwOvxF91Bav/Vmv+ugWUK3B/K9+E1SVfrg8g+N5yXGLjaBP8Px55oTSG 0rNaKFba0YpIu/yBWbJc3nUFUUQvYrN9W8D9AWnHm2UHadgrb7N8LOhJUG6eJlUOwjb3 Iexg== 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=qBiR8kM+/lpaeThlksOYsskIdSqJycSA7amEhgBn9aU=; b=n8oSvyqXLEsItdkPiLCDmMPHDgvNL9WBg8+/pirwV94A0IiAA5G4rbDNo1We0SynJZ fru1/SCEBjD787Vl7Y4M9boR1KbwnhIRDoE37zeyfrGT1Kr7W8B7U8R8WBLQdD0xjNwR RQmiWzua0Iw5qsWJseXPeCkF6ZGFAZ69/e0D0W+iLmrFQjasofirBuAfjXyxqwJsJEPJ 5uxPZV3ksUfLU/KngbcQYN6ObLodHLaYs9/41IoDvmBsEI88svNbMo6QCLOwThxvZOKD AofxUVjfonH4EjOzG4xRj0+0g+uKyLeh6gsJb5gSWexWImFpWjxgUjSiDA+MM5LGd2DF DMsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id u65si1223930itg.111.2017.10.19.05.14.50; Thu, 19 Oct 2017 05:14:52 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 7098862DAD; Thu, 19 Oct 2017 12:14:50 +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 86EFA62DC8; Thu, 19 Oct 2017 12:04:30 +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 96E6162AE7; Thu, 19 Oct 2017 12:04:12 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 88AF162AE7 for ; Thu, 19 Oct 2017 12:00:29 +0000 (UTC) Received: from mxback13j.mail.yandex.net (mxback13j.mail.yandex.net [IPv6:2a02:6b8:0:1619::88]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 05058430313A for ; Thu, 19 Oct 2017 15:00:28 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback13j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 177Bf4Q3FR-0Rq4w7d3; Thu, 19 Oct 2017 15:00:27 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lZE2bfHgVf-0QI4GTp9; Thu, 19 Oct 2017 15:00:26 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 19 Oct 2017 15:00:08 +0300 Message-Id: <1508414408-10456-10-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> References: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 241 Subject: [lng-odp] [PATCH 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 241 (bogdanPricope:2_0_pktio_ops_pr) ** https://github.com/Linaro/odp/pull/241 ** Patch: https://github.com/Linaro/odp/pull/241.patch ** Base sha: 76f82972ecb51aa64215c97cb3d7f94e5de980f9 ** Merge commit sha: 24c411a2875cbcd686833666d481a0197cc82e90 **/ .../linux-dpdk/include/odp_packet_io_internal.h | 7 +- platform/linux-dpdk/pktio/dpdk.c | 57 +++++------- .../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, 82 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 d31c449e2..089ad38c5 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 e64f02d5e..1248c130e 100644 --- a/platform/linux-dpdk/pktio/dpdk.c +++ b/platform/linux-dpdk/pktio/dpdk.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include + #include #include #include @@ -39,18 +41,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 +98,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 +128,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 +145,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 +155,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 +190,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 +202,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 +311,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 +361,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 +478,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 +531,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 +592,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 +636,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 +648,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 +692,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 +711,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 79f5b1082..b26a35d25 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -50,10 +50,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 64940d514..34bc5a24e 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -80,21 +80,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 9337ea33d..563d70a38 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -39,18 +40,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!"); @@ -363,6 +352,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; @@ -371,11 +361,11 @@ 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_pktin_config_opt_t *pktin_cfg = &pktio_entry->s.config.pktin; + 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) { @@ -545,7 +535,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; @@ -589,6 +579,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; @@ -596,8 +588,8 @@ 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_pktin_config_opt_t *pktin_cfg = &pktio_entry->s.config.pktin; + odp_pool_t pool = pkt_dpdk->pool; for (i = 0; i < mbuf_num; i++) { odp_packet_hdr_t parsed_hdr; @@ -662,7 +654,7 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, uint16_t *copy_count) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_pktout_config_opt_t *pktout_cfg = &pktio_entry->s.config.pktout; int i; *copy_count = 0; @@ -752,7 +744,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)) @@ -846,7 +838,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; uint16_t hw_ip_checksum = 0; @@ -895,7 +887,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; @@ -913,7 +905,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; } @@ -1046,6 +1037,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; @@ -1059,9 +1052,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; } @@ -1070,7 +1063,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) @@ -1087,7 +1080,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; int ptype_cnt; int ptype_l3_ipv4 = 0; @@ -1164,7 +1157,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]; @@ -1192,9 +1186,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; @@ -1208,7 +1199,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; } @@ -1217,7 +1207,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; @@ -1254,7 +1243,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; } @@ -1280,7 +1268,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; @@ -1331,7 +1319,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; } @@ -1340,7 +1331,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; @@ -1416,7 +1407,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 copy_count = 0; int tx_pkts; int i; @@ -1479,16 +1470,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) @@ -1501,9 +1497,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); @@ -1512,18 +1510,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; } @@ -1542,11 +1544,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); @@ -1557,7 +1560,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; }