From patchwork Tue Sep 26 06:00:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 114226 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3458636qgf; Mon, 25 Sep 2017 23:10:37 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBXz12C+rVh6ppuCxRLeyZT7nMdKqJ0mo7O5HXk3WdkVNFtJpECM0EOhlnKrGOod5Woddeu X-Received: by 10.36.20.149 with SMTP id 143mr3912848itg.63.1506406237021; Mon, 25 Sep 2017 23:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506406237; cv=none; d=google.com; s=arc-20160816; b=pVsbRnGHBkJXyYwLTHaeDeN6gUREykY6Ed1yTLBGNreZFXUrSaF015YTDeSvhnnkzJ dBY89mJOsqbFinqSxv4lMPYb0DuaLwcRDH/d6b3wyIc7l5Dey4m85hrdpg7l+GTp/Ruh r59HTodwGzwRfM8HLPzpqTXGPlGyY7wSRa/KbDxhQBjlmIGkKKGXK+WgUnft9VU6NEl3 XyUTbTds6P+wa85hTPWSCOJ+uwm+Zpz0MyGTU7mAmpGSUB+sEICjY6L78sHnMvov67Cg Qi7vy3SGDkLCshrhbErjqnpaEUhkGEx70RLkudlFBf9vqLU8qDey6p50++RqJVXDzYBJ tGiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=CtauqMW7YvK7POdPhDXfLpFeamqHjGPuWoaSDzolnDs=; b=U1OkvdhUojuCLzLUJLeRm54UVcD6Nsb2Dm8UHkbCSZWrYk0XoR5AekjABJQZprZ+7n 7WbCYDJYp9vOKaaqaFeUMczKKeN4Vc+rAMliYcoD+c0aIrr80nP3wWJncLba2RwqQWnT R2DfVlFRa0WeVCnv9NqqkG5BeZ7LXTypkkjL9pY/AMPSrYMd1vCq6eeX/VHG9OckwN7w w3lxLFRKRIuA9r16VjUC2xZp70NdOTpMFkabR9myzI59dzWMrzXvWllOOQ3UwjsCfHj0 ylPacawWQn5t8QIpqFA4nLp/wxe3/FGjIKk4aFJtzCGMolDoLyG/GeL7RNbEYBvJQp2y WzLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i7si6724987iob.66.2017.09.25.23.10.36; Mon, 25 Sep 2017 23:10:36 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 5F39260D1F; Tue, 26 Sep 2017 06:10:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 452AB60D60; Tue, 26 Sep 2017 06:01:13 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 74F1160CCC; Tue, 26 Sep 2017 06:00:31 +0000 (UTC) Received: from forward101p.mail.yandex.net (forward101p.mail.yandex.net [77.88.28.101]) by lists.linaro.org (Postfix) with ESMTPS id 1F08260CA9 for ; Tue, 26 Sep 2017 06:00:18 +0000 (UTC) Received: from mxback8j.mail.yandex.net (mxback8j.mail.yandex.net [IPv6:2a02:6b8:0:1619::111]) by forward101p.mail.yandex.net (Yandex) with ESMTP id 40A846A83DD4 for ; Tue, 26 Sep 2017 09:00:16 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback8j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id vtHpI3RFTL-0G606AfE; Tue, 26 Sep 2017 09:00:16 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 72uMtCPv0h-0FmKDtL2; Tue, 26 Sep 2017 09:00:15 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 26 Sep 2017 09:00:08 +0300 Message-Id: <1506405608-3507-10-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> References: <1506405608-3507-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v1 9/9] linux-gen: pktio: dpdk: use generic pktio_ops data storage X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: e89a0ed9c4cd6d7dc947b978ad1dcabc6d5a21a2 ** Merge commit sha: 160ad8615ce66c98231aa400863c82e89045d491 **/ .../linux-dpdk/include/odp_packet_io_internal.h | 7 +- platform/linux-dpdk/pktio/dpdk.c | 55 +++++------- .../linux-generic/include/odp_packet_io_internal.h | 6 +- .../include/odp_pktio_ops_subsystem.h | 12 +-- platform/linux-generic/pktio/dpdk.c | 100 +++++++++++---------- 5 files changed, 80 insertions(+), 100 deletions(-) diff --git a/platform/linux-dpdk/include/odp_packet_io_internal.h b/platform/linux-dpdk/include/odp_packet_io_internal.h index 07db8cab0..3e4d64f3a 100644 --- a/platform/linux-dpdk/include/odp_packet_io_internal.h +++ b/platform/linux-dpdk/include/odp_packet_io_internal.h @@ -29,7 +29,6 @@ extern "C" { #define PKTIO_MAX_QUEUES 64 #include -#include /* Forward declaration */ typedef union pktio_entry_u pktio_entry_t; @@ -42,10 +41,8 @@ typedef union pktio_entry_u pktio_entry_t; struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ - union { - pktio_ops_data_t ops_data; - uint8_t _ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; - }; + uint8_t ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; /**< IO operation + specific data */ /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ diff --git a/platform/linux-dpdk/pktio/dpdk.c b/platform/linux-dpdk/pktio/dpdk.c index d7a90197a..30ccc456e 100644 --- a/platform/linux-dpdk/pktio/dpdk.c +++ b/platform/linux-dpdk/pktio/dpdk.c @@ -39,18 +39,6 @@ static pktio_ops_module_t dpdk_pktio_ops; static uint32_t mtu_get_pkt_dpdk(pktio_entry_t *pktio_entry); -static inline pktio_ops_dpdk_data_t * - __retrieve_op_data(pktio_entry_t *pktio) -{ - return (pktio_ops_dpdk_data_t *)(pktio->ops_data(dpdk)); -} - -static inline void __release_op_data(pktio_entry_t *pktio) -{ - free(pktio->ops_data(dpdk)); - pktio->ops_data(dpdk) = NULL; -} - /* Test if s has only digits or not. Dpdk pktio uses only digits.*/ static int _dpdk_netdev_is_valid(const char *s) { @@ -108,7 +96,7 @@ static int input_queues_config_pkt_dpdk(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_pktin_mode_t mode = pktio_entry->s.param.in_mode; /** @@ -138,7 +126,7 @@ static int output_queues_config_pkt_dpdk(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); if (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE) pkt_dpdk->lockless_tx = 1; @@ -155,7 +143,8 @@ static int setup_pkt_dpdk(odp_pktio_t pktio ODP_UNUSED, { uint8_t portid = 0; struct rte_eth_dev_info dev_info; - pktio_ops_dpdk_data_t *pkt_dpdk = NULL; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); int i; if (!_dpdk_netdev_is_valid(netdev)) { @@ -164,9 +153,6 @@ static int setup_pkt_dpdk(odp_pktio_t pktio ODP_UNUSED, return -1; } - pktio_entry->ops_data(dpdk) = malloc(sizeof(pktio_ops_dpdk_data_t)); - pkt_dpdk = __retrieve_op_data(pktio_entry); - if (odp_unlikely(pkt_dpdk == NULL)) { ODP_ERR("Failed to allocate pktio_ops_dpdk_data_t struct"); return -1; @@ -202,12 +188,11 @@ static int setup_pkt_dpdk(odp_pktio_t pktio ODP_UNUSED, static int close_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); if (pktio_entry->s.state == PKTIO_STATE_STOPPED) rte_eth_dev_close(pkt_dpdk->portid); - __release_op_data(pktio_entry); return 0; } @@ -215,7 +200,7 @@ static int start_pkt_dpdk(pktio_entry_t *pktio_entry) { int ret, i; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t portid = pkt_dpdk->portid; int sid = rte_eth_dev_socket_id(pkt_dpdk->portid); int socket_id = sid < 0 ? 0 : sid; @@ -324,7 +309,8 @@ static int start_pkt_dpdk(pktio_entry_t *pktio_entry) static int stop_pkt_dpdk(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + rte_eth_dev_stop(pkt_dpdk->portid); return 0; } @@ -373,7 +359,7 @@ static int recv_pkt_dpdk(pktio_entry_t *pktio_entry, int index, { uint16_t nb_rx, i; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_packet_t *saved_pkt_table; uint8_t min = pkt_dpdk->min_rx_burst; odp_time_t ts_val; @@ -490,7 +476,7 @@ static int send_pkt_dpdk(pktio_entry_t *pktio_entry, int index, { int pkts; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); if (!pkt_dpdk->lockless_tx) odp_ticketlock_lock(&pkt_dpdk->tx_lock[index]); @@ -543,7 +529,7 @@ static uint32_t _dpdk_vdev_mtu(uint8_t port_id) static uint32_t mtu_get_pkt_dpdk(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint16_t mtu = 0; int ret; @@ -604,7 +590,7 @@ static int _dpdk_vdev_promisc_mode_set(uint8_t port_id, int enable) static int promisc_mode_set_pkt_dpdk(pktio_entry_t *pktio_entry, int enable) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t portid = pkt_dpdk->portid; if (enable) @@ -648,7 +634,7 @@ static int _dpdk_vdev_promisc_mode(uint8_t port_id) static int promisc_mode_get_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t portid = pkt_dpdk->portid; if (pkt_dpdk->vdev_sysc_promisc) @@ -660,25 +646,27 @@ static int promisc_mode_get_pkt_dpdk(pktio_entry_t *pktio_entry) static int mac_get_pkt_dpdk(pktio_entry_t *pktio_entry, void *mac_addr) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + rte_eth_macaddr_get(pkt_dpdk->portid, (struct ether_addr *)mac_addr); return ETH_ALEN; } - static int capability_pkt_dpdk(pktio_entry_t *pktio_entry, odp_pktio_capability_t *capa) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + *capa = pkt_dpdk->capa; return 0; } + static int link_status_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); struct rte_eth_link link; rte_eth_link_get(pkt_dpdk->portid, &link); @@ -702,7 +690,7 @@ static void stats_convert(struct rte_eth_stats *rte_stats, static int stats_pkt_dpdk(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); int ret; struct rte_eth_stats rte_stats; @@ -721,7 +709,8 @@ static int stats_pkt_dpdk(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) static int stats_reset_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + rte_eth_stats_reset(pkt_dpdk->portid); return 0; } diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 0201a47fa..665589ce3 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -48,10 +48,8 @@ typedef union pktio_entry_u pktio_entry_t; struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ - union { - pktio_ops_data_t ops_data; /**< IO operation specific data */ - uint8_t _ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; - }; + uint8_t ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; /**< IO operation + specific data */ /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 5449eccbd..f1ff48832 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -78,21 +78,11 @@ typedef ODP_MODULE_CLASS(pktio_ops) { odp_api_proto(pktio_ops, print) print; } pktio_ops_module_t; -/* Per implementation private data - * TODO: refactory each implementation to hide it internally - */ -typedef union { - void *dpdk; -} pktio_ops_data_t; - -/* Extract pktio ops data from pktio entry structure */ -#define ops_data(mod) s.ops_data.mod - /* Maximum size of pktio specific ops data.*/ #define ODP_PKTIO_ODPS_DATA_MAX_SIZE 80000 /* Extract pktio ops data from pktio entry structure */ #define odp_ops_data(_p, _mod) \ - ((pktio_ops_ ## _mod ## _data_t *)(uintptr_t)_p->s._ops_data) + ((pktio_ops_ ## _mod ## _data_t *)(uintptr_t)_p->s.ops_data) #endif diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 21c9fb0f7..be2bbbfcb 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -33,18 +34,6 @@ #include #include -static inline pktio_ops_dpdk_data_t * - __retrieve_op_data(pktio_entry_t *pktio) -{ - return (pktio_ops_dpdk_data_t *)(pktio->ops_data(dpdk)); -} - -static inline void __release_op_data(pktio_entry_t *pktio) -{ - free(pktio->ops_data(dpdk)); - pktio->ops_data(dpdk) = NULL; -} - #if ODP_DPDK_ZERO_COPY ODP_STATIC_ASSERT(CONFIG_PACKET_HEADROOM == RTE_PKTMBUF_HEADROOM, "ODP and DPDK headroom sizes not matching!"); @@ -315,6 +304,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, struct rte_mbuf *mbuf_table[], uint16_t mbuf_num, odp_time_t *ts) { + pktio_ops_dpdk_data_t *pkt_dpdk = odp_ops_data(pktio_entry, dpdk); odp_packet_t pkt; odp_packet_hdr_t *pkt_hdr; uint16_t pkt_len; @@ -323,10 +313,10 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, int i, j; int nb_pkts = 0; int alloc_len, num; - odp_pool_t pool = __retrieve_op_data(pktio_entry)->pool; + odp_pool_t pool = pkt_dpdk->pool; /* Allocate maximum sized packets */ - alloc_len = __retrieve_op_data(pktio_entry)->data_room; + alloc_len = pkt_dpdk->data_room; num = packet_alloc_multi(pool, alloc_len, pkt_table, mbuf_num); if (num != mbuf_num) { @@ -399,7 +389,7 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, const odp_packet_t pkt_table[], uint16_t num) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); int i, j; char *data; uint16_t pkt_len; @@ -437,6 +427,8 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, struct rte_mbuf *mbuf_table[], uint16_t mbuf_num, odp_time_t *ts) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); odp_packet_t pkt; odp_packet_hdr_t *pkt_hdr; uint16_t pkt_len; @@ -444,7 +436,7 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, void *data; int i; int nb_pkts = 0; - odp_pool_t pool = __retrieve_op_data(pktio_entry)->pool; + odp_pool_t pool = pkt_dpdk->pool; for (i = 0; i < mbuf_num; i++) { odp_packet_hdr_t parsed_hdr; @@ -502,7 +494,7 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, uint16_t *seg_count) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); int i; *seg_count = 0; @@ -578,7 +570,7 @@ static uint32_t dpdk_vdev_mtu_get(uint8_t port_id) static uint32_t dpdk_mtu_get(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint32_t mtu = 0; if (rte_eth_dev_get_mtu(pkt_dpdk->port_id, (uint16_t *)&mtu)) @@ -672,7 +664,7 @@ static int dpdk_setup_port(pktio_entry_t *pktio_entry) { int ret; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); struct rte_eth_rss_conf rss_conf; /* Always set some hash functions to enable DPDK RSS hash calculation */ @@ -715,7 +707,7 @@ static int dpdk_setup_port(pktio_entry_t *pktio_entry) static int dpdk_close(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); unsigned idx; unsigned i, j; @@ -733,7 +725,6 @@ static int dpdk_close(pktio_entry_t *pktio_entry) if (!ODP_DPDK_ZERO_COPY) rte_mempool_free(pkt_dpdk->pkt_pool); - __release_op_data(pktio_entry); return 0; } @@ -866,6 +857,8 @@ static int dpdk_pktio_init_local(void) static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); odp_pktin_mode_t mode = pktio_entry->s.param.in_mode; odp_bool_t lockless; @@ -879,9 +872,9 @@ static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, lockless = 0; if (p->hash_enable && p->num_queues > 1) - __retrieve_op_data(pktio_entry)->hash = p->hash_proto; + pkt_dpdk->hash = p->hash_proto; - __retrieve_op_data(pktio_entry)->lockless_rx = lockless; + pkt_dpdk->lockless_rx = lockless; return 0; } @@ -890,7 +883,7 @@ static int dpdk_output_queues_config(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_bool_t lockless; if (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE) @@ -907,7 +900,7 @@ static void dpdk_init_capability(pktio_entry_t *pktio_entry, struct rte_eth_dev_info *dev_info) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_pktio_capability_t *capa = &pkt_dpdk->capa; memset(dev_info, 0, sizeof(struct rte_eth_dev_info)); @@ -930,7 +923,8 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, const char *netdev, odp_pool_t pool) { - pktio_ops_dpdk_data_t *pkt_dpdk = NULL; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); struct rte_eth_dev_info dev_info; struct rte_mempool *pkt_pool; char pool_name[RTE_MEMPOOL_NAMESIZE]; @@ -958,9 +952,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, dpdk_initialized = 1; } - pktio_entry->ops_data(dpdk) = malloc(sizeof(pktio_ops_dpdk_data_t)); - pkt_dpdk = __retrieve_op_data(pktio_entry); - if (odp_unlikely(pkt_dpdk == NULL)) { ODP_ERR("Failed to allocate pktio_ops_dpdk_data_t struct"); return -1; @@ -974,7 +965,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, if (rte_eth_dev_count() == 0) { ODP_ERR("No DPDK ports found\n"); - __release_op_data(pktio_entry); return -1; } @@ -983,7 +973,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, mtu = dpdk_mtu_get(pktio_entry); if (mtu == 0) { ODP_ERR("Failed to read interface MTU\n"); - __release_op_data(pktio_entry); return -1; } pkt_dpdk->mtu = mtu + _ODP_ETHHDR_LEN; @@ -1020,7 +1009,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, } if (pkt_pool == NULL) { ODP_ERR("Cannot init mbuf packet pool\n"); - __release_op_data(pktio_entry); return -1; } @@ -1046,7 +1034,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, static int dpdk_start(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t port_id = pkt_dpdk->port_id; int ret; unsigned i; @@ -1097,7 +1085,10 @@ static int dpdk_start(pktio_entry_t *pktio_entry) static int dpdk_stop(pktio_entry_t *pktio_entry) { - rte_eth_dev_stop(__retrieve_op_data(pktio_entry)->port_id); + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + rte_eth_dev_stop(pkt_dpdk->port_id); return 0; } @@ -1106,7 +1097,7 @@ static int dpdk_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt_table[], int num) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); pkt_cache_t *rx_cache = &pkt_dpdk->rx_cache[index]; odp_time_t ts_val; odp_time_t *ts = NULL; @@ -1182,7 +1173,7 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index, { struct rte_mbuf *tx_mbufs[num]; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint16_t seg_count = 0; int tx_pkts; int i; @@ -1245,16 +1236,21 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index, static int dpdk_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - rte_eth_macaddr_get(__retrieve_op_data(pktio_entry)->port_id, + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + rte_eth_macaddr_get(pkt_dpdk->port_id, (struct ether_addr *)mac_addr); return ETH_ALEN; } static int dpdk_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - uint8_t port_id = __retrieve_op_data(pktio_entry)->port_id; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + uint8_t port_id = pkt_dpdk->port_id; - if (__retrieve_op_data(pktio_entry)->vdev_sysc_promisc) + if (pkt_dpdk->vdev_sysc_promisc) return dpdk_vdev_promisc_mode_set(port_id, enable); if (enable) @@ -1267,9 +1263,11 @@ static int dpdk_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) static int dpdk_promisc_mode_get(pktio_entry_t *pktio_entry) { - uint8_t port_id = __retrieve_op_data(pktio_entry)->port_id; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + uint8_t port_id = pkt_dpdk->port_id; - if (__retrieve_op_data(pktio_entry)->vdev_sysc_promisc) + if (pkt_dpdk->vdev_sysc_promisc) return dpdk_vdev_promisc_mode_get(port_id); else return rte_eth_promiscuous_get(port_id); @@ -1278,18 +1276,22 @@ static int dpdk_promisc_mode_get(pktio_entry_t *pktio_entry) static int dpdk_capability(pktio_entry_t *pktio_entry, odp_pktio_capability_t *capa) { - *capa = __retrieve_op_data(pktio_entry)->capa; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + *capa = pkt_dpdk->capa; return 0; } static int dpdk_link_status(pktio_entry_t *pktio_entry) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); struct rte_eth_link link; memset(&link, 0, sizeof(struct rte_eth_link)); - rte_eth_link_get_nowait( - __retrieve_op_data(pktio_entry)->port_id, &link); + rte_eth_link_get_nowait(pkt_dpdk->port_id, &link); return link.link_status; } @@ -1308,11 +1310,12 @@ static void stats_convert(const struct rte_eth_stats *rte_stats, static int dpdk_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); int ret; struct rte_eth_stats rte_stats; - ret = rte_eth_stats_get( - __retrieve_op_data(pktio_entry)->port_id, &rte_stats); + ret = rte_eth_stats_get(pkt_dpdk->port_id, &rte_stats); if (ret == 0) { stats_convert(&rte_stats, stats); @@ -1323,7 +1326,10 @@ static int dpdk_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) static int dpdk_stats_reset(pktio_entry_t *pktio_entry) { - rte_eth_stats_reset(__retrieve_op_data(pktio_entry)->port_id); + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + rte_eth_stats_reset(pkt_dpdk->port_id); return 0; }