From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E670BA04E6; Fri, 30 Oct 2020 18:47:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6409D5946; Fri, 30 Oct 2020 18:45:19 +0100 (CET) Received: from new2-smtp.messagingengine.com (new2-smtp.messagingengine.com [66.111.4.224]) by dpdk.org (Postfix) with ESMTP id B4FEC2BDB for ; Fri, 30 Oct 2020 18:45:02 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 6B4AE580844; Fri, 30 Oct 2020 13:45:02 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 30 Oct 2020 13:45:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=mKlEZpWa+INxK OAxmqTfNHwropb/kjkJIecE0tJRT9M=; b=M1IYjFRIGwQbE4XuLeAgOlENzWnjA 3U02VzT9P74sGwUqIEIC4kfJCb7C+NE8OdMF+Eq9PfAQ5A1t/vuhdQ6Am6ZpmOGm VQ85mQ4QYHnkU1HrozVofvmZa3ZYPZmoa00OPHjm+PtwQSMjxSNK4Ka9FkFPXnn6 1p+03uWAJ9d/Vmb2djOs68PWUPxLRSjEYLG4QnBuAzRzxVVhnskKE9ztSLtu9+OQ dCtuke9bfeeKAG95wui566aGNsuZwYS+TcFkIIp0ifGmkWEos2ILU9g5SMvdXBGB sh+QErodzHt4amHAJQK0jczq29oj8xD+EDiRuJ6vQa2UGhV5mAHkcKNjw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=mKlEZpWa+INxKOAxmqTfNHwropb/kjkJIecE0tJRT9M=; b=WjS2UvIC UdcSr2AeGBWKvt+0bqC4l47fo8Ik7iuk1wQ0Q24F6Xc+jh3ybY4yhkVzcMTq9/8l x6Es9iDexqo3P5HRg4Q/TkhbhqmsuD7HoPYIX3JG4TTnXHQA8oTPPR3oiiP52i16 jG5GyR0TmM43RIqt3Ev/ZC9YBVH5pKWl3i/zTt6401Z6VU1vj4QaewlPXR0k6s2E Ygc2RZkndP56hEpzQgiIAsd7O67zhFhM3dGgccNTOjOCTe2N7Z+EjmpNxZGzLDc0 ij5Ip9Yi1BbqzNXBkv3zqQ8ckburejqC36m78oXvlhe/sfIxxG881dxPQ5ynD0aG 0XaVVm4wEP1nPw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleehgdellecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpeehjefhvdffueehieevuddvfeeigefhtddvvddtheehgfekfefhtdfh teffgeetueenucffohhmrghinheptghonhhfrdhinhenucfkphepjeejrddufeegrddvtd efrddukeegnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhho mhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 3B3813064680; Fri, 30 Oct 2020 13:45:00 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, david.marchand@redhat.com, bruce.richardson@intel.com, olivier.matz@6wind.com, andrew.rybchenko@oktetlabs.ru, akhil.goyal@nxp.com, jerinj@marvell.com, Ed Czeck , Shepard Siegel , John Miller , Ray Kinsella , Neil Horman Date: Fri, 30 Oct 2020 18:44:33 +0100 Message-Id: <20201030174441.1076264-8-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030174441.1076264-1-thomas@monjalon.net> References: <20201026052105.1561859-1-thomas@monjalon.net> <20201030174441.1076264-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 07/15] net/ark: switch user data to dynamic mbuf fields X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ed Czeck The second field of metadata is reserved for user data which was using a deprecated mbuf field. It is moved to dynamic fields in order to allow removal of udata64. The use of meta data must be enabled with a compile-time flag RTE_PMD_ARK_{TX,RX}_USERDATA_ENABLE. User data on Tx and Rx paths can be defined and used separately. Signed-off-by: Thomas Monjalon Signed-off-by: Ed Czeck --- doc/api/doxy-api-index.md | 1 + doc/api/doxy-api.conf.in | 1 + drivers/net/ark/ark_ethdev.c | 39 ++++++++++ drivers/net/ark/ark_ethdev_rx.c | 3 +- drivers/net/ark/ark_ethdev_tx.c | 3 +- drivers/net/ark/meson.build | 2 + drivers/net/ark/rte_pmd_ark.h | 125 ++++++++++++++++++++++++++++++++ drivers/net/ark/version.map | 7 ++ 8 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ark/rte_pmd_ark.h diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md index a9c12d1a2f..b865a51e8c 100644 --- a/doc/api/doxy-api-index.md +++ b/doc/api/doxy-api-index.md @@ -41,6 +41,7 @@ The public API headers are grouped by topics: [vhost] (@ref rte_vhost.h), [vdpa] (@ref rte_vdpa.h), [KNI] (@ref rte_kni.h), + [ark] (@ref rte_pmd_ark.h), [ixgbe] (@ref rte_pmd_ixgbe.h), [i40e] (@ref rte_pmd_i40e.h), [ice] (@ref rte_pmd_ice.h), diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in index e37f8c2e80..c5b01a1814 100644 --- a/doc/api/doxy-api.conf.in +++ b/doc/api/doxy-api.conf.in @@ -8,6 +8,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \ @TOPDIR@/drivers/bus/vdev \ @TOPDIR@/drivers/crypto/scheduler \ @TOPDIR@/drivers/mempool/dpaa2 \ + @TOPDIR@/drivers/net/ark \ @TOPDIR@/drivers/net/bnxt \ @TOPDIR@/drivers/net/bonding \ @TOPDIR@/drivers/net/dpaa \ diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index 168b3659d6..fa343999a1 100644 --- a/drivers/net/ark/ark_ethdev.c +++ b/drivers/net/ark/ark_ethdev.c @@ -10,6 +10,7 @@ #include #include +#include "rte_pmd_ark.h" #include "ark_global.h" #include "ark_logs.h" #include "ark_ethdev_tx.h" @@ -78,6 +79,9 @@ static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size); #define ARK_TX_MAX_QUEUE (4096 * 4) #define ARK_TX_MIN_QUEUE (256) +int rte_pmd_ark_rx_userdata_dynfield_offset = -1; +int rte_pmd_ark_tx_userdata_dynfield_offset = -1; + static const char * const valid_arguments[] = { ARK_PKTGEN_ARG, ARK_PKTCHKR_ARG, @@ -245,6 +249,16 @@ eth_ark_dev_init(struct rte_eth_dev *dev) int ret; int port_count = 1; int p; + static const struct rte_mbuf_dynfield ark_tx_userdata_dynfield_desc = { + .name = RTE_PMD_ARK_TX_USERDATA_DYNFIELD_NAME, + .size = sizeof(rte_pmd_ark_tx_userdata_t), + .align = __alignof__(rte_pmd_ark_tx_userdata_t), + }; + static const struct rte_mbuf_dynfield ark_rx_userdata_dynfield_desc = { + .name = RTE_PMD_ARK_RX_USERDATA_DYNFIELD_NAME, + .size = sizeof(rte_pmd_ark_rx_userdata_t), + .align = __alignof__(rte_pmd_ark_rx_userdata_t), + }; ark->eth_dev = dev; @@ -254,6 +268,31 @@ eth_ark_dev_init(struct rte_eth_dev *dev) ret = check_for_ext(ark); if (ret) return ret; + + /* Extra mbuf fields for user data */ + if (RTE_PMD_ARK_TX_USERDATA_ENABLE) { + rte_pmd_ark_tx_userdata_dynfield_offset = + rte_mbuf_dynfield_register(&ark_tx_userdata_dynfield_desc); + if (rte_pmd_ark_tx_userdata_dynfield_offset < 0) { + ARK_PMD_LOG(ERR, + "Failed to register mbuf field for tx userdata\n"); + return -rte_errno; + } + ARK_PMD_LOG(INFO, "Registered TX-meta dynamic field at %d\n", + rte_pmd_ark_tx_userdata_dynfield_offset); + } + if (RTE_PMD_ARK_RX_USERDATA_ENABLE) { + rte_pmd_ark_rx_userdata_dynfield_offset = + rte_mbuf_dynfield_register(&ark_rx_userdata_dynfield_desc); + if (rte_pmd_ark_rx_userdata_dynfield_offset < 0) { + ARK_PMD_LOG(ERR, + "Failed to register mbuf field for rx userdata\n"); + return -rte_errno; + } + ARK_PMD_LOG(INFO, "Registered RX-meta dynamic field at %d\n", + rte_pmd_ark_rx_userdata_dynfield_offset); + } + pci_dev = RTE_ETH_DEV_TO_PCI(dev); rte_eth_copy_pci_info(dev, pci_dev); dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; diff --git a/drivers/net/ark/ark_ethdev_rx.c b/drivers/net/ark/ark_ethdev_rx.c index 2f8d05099c..825b4791be 100644 --- a/drivers/net/ark/ark_ethdev_rx.c +++ b/drivers/net/ark/ark_ethdev_rx.c @@ -4,6 +4,7 @@ #include +#include "rte_pmd_ark.h" #include "ark_ethdev_rx.h" #include "ark_global.h" #include "ark_logs.h" @@ -272,7 +273,7 @@ eth_ark_recv_pkts(void *rx_queue, mbuf->pkt_len = meta->pkt_len; mbuf->data_len = meta->pkt_len; mbuf->timestamp = meta->timestamp; - mbuf->udata64 = meta->user_data; + rte_pmd_ark_mbuf_rx_userdata_set(mbuf, meta->user_data); if (ARK_DEBUG_CORE) { /* debug sanity checks */ if ((meta->pkt_len > (1024 * 16)) || diff --git a/drivers/net/ark/ark_ethdev_tx.c b/drivers/net/ark/ark_ethdev_tx.c index a0e35af880..612d918e33 100644 --- a/drivers/net/ark/ark_ethdev_tx.c +++ b/drivers/net/ark/ark_ethdev_tx.c @@ -4,6 +4,7 @@ #include +#include "rte_pmd_ark.h" #include "ark_ethdev_tx.h" #include "ark_global.h" #include "ark_mpu.h" @@ -70,7 +71,7 @@ eth_ark_tx_meta_from_mbuf(struct ark_tx_meta *meta, uint8_t flags) { meta->physaddr = rte_mbuf_data_iova(mbuf); - meta->user1 = (uint32_t)mbuf->udata64; + meta->user1 = rte_pmd_ark_mbuf_tx_userdata_get(mbuf); meta->data_len = rte_pktmbuf_data_len(mbuf); meta->flags = flags; } diff --git a/drivers/net/ark/meson.build b/drivers/net/ark/meson.build index 99151bba1d..80bce94e1a 100644 --- a/drivers/net/ark/meson.build +++ b/drivers/net/ark/meson.build @@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel Corporation +headers = files('rte_pmd_ark.h') + sources = files('ark_ddm.c', 'ark_ethdev.c', 'ark_ethdev_rx.c', diff --git a/drivers/net/ark/rte_pmd_ark.h b/drivers/net/ark/rte_pmd_ark.h new file mode 100644 index 0000000000..6f26d66b12 --- /dev/null +++ b/drivers/net/ark/rte_pmd_ark.h @@ -0,0 +1,125 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Atomic Rules LLC + */ + +#ifndef RTE_PMD_ARK_H +#define RTE_PMD_ARK_H + +/** + * @file + * ARK driver-specific API + */ + +#include +#include + +#ifndef RTE_PMD_ARK_TX_USERDATA_ENABLE +#define RTE_PMD_ARK_TX_USERDATA_ENABLE 0 +#endif + +#ifndef RTE_PMD_ARK_RX_USERDATA_ENABLE +#define RTE_PMD_ARK_RX_USERDATA_ENABLE 0 +#endif + +typedef uint32_t rte_pmd_ark_tx_userdata_t; +typedef uint64_t rte_pmd_ark_rx_userdata_t; + +extern int rte_pmd_ark_tx_userdata_dynfield_offset; +extern int rte_pmd_ark_rx_userdata_dynfield_offset; + +/** mbuf dynamic field for custom Tx ARK data */ +#define RTE_PMD_ARK_TX_USERDATA_DYNFIELD_NAME "rte_net_ark_dynfield_tx_userdata" +/** mbuf dynamic field for custom Rx ARK data */ +#define RTE_PMD_ARK_RX_USERDATA_DYNFIELD_NAME "rte_net_ark_dynfield_rx_userdata" + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Read Tx user data from mbuf. + * + * @param mbuf Structure to read from. + * @return user data + */ +__rte_experimental +static inline rte_pmd_ark_tx_userdata_t +rte_pmd_ark_mbuf_tx_userdata_get(const struct rte_mbuf *mbuf) +{ +#if RTE_PMD_ARK_TX_USERDATA_ENABLE + return *RTE_MBUF_DYNFIELD(mbuf, rte_pmd_ark_tx_userdata_dynfield_offset, + rte_pmd_ark_tx_userdata_t *); +#else + RTE_SET_USED(mbuf); + return 0; +#endif +} + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Write Tx user data to mbuf. + * + * @param mbuf Structure to write into. + * @param data User data. + */ +__rte_experimental +static inline void +rte_pmd_ark_mbuf_tx_userdata_set(struct rte_mbuf *mbuf, + rte_pmd_ark_tx_userdata_t data) +{ +#if RTE_PMD_ARK_TX_USERDATA_ENABLE + *RTE_MBUF_DYNFIELD(mbuf, rte_pmd_ark_tx_userdata_dynfield_offset, + rte_pmd_ark_tx_userdata_t *) = data; +#else + RTE_SET_USED(mbuf); + RTE_SET_USED(data); +#endif +} + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Read Rx user data from mbuf. + * + * @param mbuf Structure to read from. + * @return user data + */ +__rte_experimental +static inline rte_pmd_ark_rx_userdata_t +rte_pmd_ark_mbuf_rx_userdata_get(const struct rte_mbuf *mbuf) +{ +#if RTE_PMD_ARK_RX_USERDATA_ENABLE + return *RTE_MBUF_DYNFIELD(mbuf, rte_pmd_ark_rx_userdata_dynfield_offset, + rte_pmd_ark_rx_userdata_t *); +#else + RTE_SET_USED(mbuf); + return 0; +#endif +} + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Write Rx user data to mbuf. + * + * @param mbuf Structure to write into. + * @param data User data. + */ +__rte_experimental +static inline void +rte_pmd_ark_mbuf_rx_userdata_set(struct rte_mbuf *mbuf, + rte_pmd_ark_rx_userdata_t data) +{ +#if RTE_PMD_ARK_RX_USERDATA_ENABLE + *RTE_MBUF_DYNFIELD(mbuf, rte_pmd_ark_rx_userdata_dynfield_offset, + rte_pmd_ark_rx_userdata_t *) = data; +#else + RTE_SET_USED(mbuf); + RTE_SET_USED(data); +#endif +} + +#endif /* RTE_PMD_ARK_H */ diff --git a/drivers/net/ark/version.map b/drivers/net/ark/version.map index 4a76d1d52d..954bea6796 100644 --- a/drivers/net/ark/version.map +++ b/drivers/net/ark/version.map @@ -1,3 +1,10 @@ DPDK_21 { local: *; }; + +EXPERIMENTAL { + global: + + rte_pmd_ark_tx_userdata_dynfield_offset; + rte_pmd_ark_rx_userdata_dynfield_offset; +}; -- 2.28.0