From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C266645EFA; Fri, 20 Dec 2024 15:42:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73197406B6; Fri, 20 Dec 2024 15:40:49 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by mails.dpdk.org (Postfix) with ESMTP id 203D0406B8 for ; Fri, 20 Dec 2024 15:40:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734705648; x=1766241648; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=w+IRo5MfOYpR90sE2CPkN6wEc9k8GoYymSjgS8F3gAE=; b=QsUzYH9gwQeinnRr87MeEa2VNaGFf5yXpo0sF/9K6D2KM5NpvIUwyXEr HmXtizAA64rdhF86ppS7dV0OIVUblntmab1tgrDF/Ud4OaoQqiU01RGC7 g6ww1CrXVr2kANcCW9Umoggtqkdv83tTv6QcuQyomiNuWOnlXng7gse+G FO5924SjBfZiYfw2WvF54xaBwDoJiOoT8gjzDqQwSjl6ZF0pYsKkrSrsE bNZnDsXDQmIOaXf3QtBoHwHmUWw5raQaQYEL3HAmD2zWisI08Vg9PdO26 a21dQ9ztVgJbY1EBXn2T4Xb5C0Ksc+c9u8h82rQ5LHe/E/QGA5O24zLVB w==; X-CSE-ConnectionGUID: Qnrsouw2RoGDfyF432n6Zw== X-CSE-MsgGUID: tjdqJTqPR8CvvCloasvQmw== X-IronPort-AV: E=McAfee;i="6700,10204,11292"; a="39040279" X-IronPort-AV: E=Sophos;i="6.12,251,1728975600"; d="scan'208";a="39040279" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2024 06:40:47 -0800 X-CSE-ConnectionGUID: Snn7N2z2QaCj6DlS/SqXrg== X-CSE-MsgGUID: mX2coMopTRWcKNYD8V2MUg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,251,1728975600"; d="scan'208";a="98310751" Received: from silpixa00401197coob.ir.intel.com (HELO silpixa00401385.ir.intel.com) ([10.237.214.45]) by fmviesa006.fm.intel.com with ESMTP; 20 Dec 2024 06:40:44 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , David Christensen , Ian Stokes , Wathsala Vithanage , Konstantin Ananyev , Vladimir Medvedkin , Anatoly Burakov Subject: [PATCH v4 23/24] net/_common_intel: create common mbuf initializer fn Date: Fri, 20 Dec 2024 14:39:20 +0000 Message-ID: <20241220143925.609044-24-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220143925.609044-1-bruce.richardson@intel.com> References: <20241122125418.2857301-1-bruce.richardson@intel.com> <20241220143925.609044-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Across a number of drivers, the same code is used for initializing the "mbuf_initializer" value inside the rx queue structure for use with the vector drivers. Since the rx queue structures are (currently) different across the drivers, we cannot just move a single copy of the function to a common location. Instead, we create a dedicated function which just creates the mbuf initializer for a particular port. In creating this function, we can shorten it vs the original versions by initializing the mbuf fields as they are defined, rather than afterwards. We can also remove the use of the barrier and temporary uintptr_t variable, because the mbuf has been reworked so that rearm_data is a proper single-element array in a union. Across ixgbe, i40e, iavf and i40e, we can call this function to initialize the rxq data, replacing the "*_rxq_vec_setup_default" functions. Only the i40e was slightly different, having an extra assignment in it, to set the "sse" flag (even in case of neon and altivec paths). This assignment was just duplicated to the calling sites for simplicity and to keep existing behaviour. Signed-off-by: Bruce Richardson --- drivers/net/_common_intel/rx.h | 13 +++++++++++++ drivers/net/i40e/i40e_rxtx_vec_altivec.c | 4 +++- drivers/net/i40e/i40e_rxtx_vec_common.h | 19 ------------------- drivers/net/i40e/i40e_rxtx_vec_neon.c | 4 +++- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +++- drivers/net/iavf/iavf_rxtx_vec_common.h | 18 ------------------ drivers/net/iavf/iavf_rxtx_vec_neon.c | 3 ++- drivers/net/iavf/iavf_rxtx_vec_sse.c | 3 ++- drivers/net/ice/ice_rxtx_vec_common.h | 18 ------------------ drivers/net/ice/ice_rxtx_vec_sse.c | 3 ++- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 18 ------------------ drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c | 3 ++- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 3 ++- 13 files changed, 32 insertions(+), 81 deletions(-) diff --git a/drivers/net/_common_intel/rx.h b/drivers/net/_common_intel/rx.h index 5bd2fea7e3..ca0485875c 100644 --- a/drivers/net/_common_intel/rx.h +++ b/drivers/net/_common_intel/rx.h @@ -76,4 +76,17 @@ ci_rx_reassemble_packets(struct rte_mbuf **rx_bufs, uint16_t nb_bufs, uint8_t *s return pkt_idx; } +static inline uint64_t +ci_rxq_mbuf_initializer(uint16_t port_id) +{ + struct rte_mbuf mb_def = { + .nb_segs = 1, + .data_off = RTE_PKTMBUF_HEADROOM, + .port = port_id, + }; + rte_mbuf_refcnt_set(&mb_def, 1); + + return mb_def.rearm_data[0]; +} + #endif /* _COMMON_INTEL_RX_H_ */ diff --git a/drivers/net/i40e/i40e_rxtx_vec_altivec.c b/drivers/net/i40e/i40e_rxtx_vec_altivec.c index b6900a3e15..e8046b5ce5 100644 --- a/drivers/net/i40e/i40e_rxtx_vec_altivec.c +++ b/drivers/net/i40e/i40e_rxtx_vec_altivec.c @@ -621,7 +621,9 @@ i40e_rx_queue_release_mbufs_vec(struct i40e_rx_queue *rxq) int __rte_cold i40e_rxq_vec_setup(struct i40e_rx_queue *rxq) { - return i40e_rxq_vec_setup_default(rxq); + rxq->rx_using_sse = 1; + rxq->mbuf_initializer = ci_rxq_mbuf_initializer(rxq->port_id); + return 0; } int __rte_cold diff --git a/drivers/net/i40e/i40e_rxtx_vec_common.h b/drivers/net/i40e/i40e_rxtx_vec_common.h index 733dc797cd..1ccdbd3fdb 100644 --- a/drivers/net/i40e/i40e_rxtx_vec_common.h +++ b/drivers/net/i40e/i40e_rxtx_vec_common.h @@ -54,25 +54,6 @@ _i40e_rx_queue_release_mbufs_vec(struct i40e_rx_queue *rxq) memset(rxq->sw_ring, 0, sizeof(rxq->sw_ring[0]) * rxq->nb_rx_desc); } -static inline int -i40e_rxq_vec_setup_default(struct i40e_rx_queue *rxq) -{ - uintptr_t p; - struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */ - - mb_def.nb_segs = 1; - mb_def.data_off = RTE_PKTMBUF_HEADROOM; - mb_def.port = rxq->port_id; - rte_mbuf_refcnt_set(&mb_def, 1); - - /* prevent compiler reordering: rearm_data covers previous fields */ - rte_compiler_barrier(); - p = (uintptr_t)&mb_def.rearm_data; - rxq->mbuf_initializer = *(uint64_t *)p; - rxq->rx_using_sse = 1; - return 0; -} - static inline int i40e_rx_vec_dev_conf_condition_check_default(struct rte_eth_dev *dev) { diff --git a/drivers/net/i40e/i40e_rxtx_vec_neon.c b/drivers/net/i40e/i40e_rxtx_vec_neon.c index b398d66154..1c7e9bf1fa 100644 --- a/drivers/net/i40e/i40e_rxtx_vec_neon.c +++ b/drivers/net/i40e/i40e_rxtx_vec_neon.c @@ -749,7 +749,9 @@ i40e_rx_queue_release_mbufs_vec(struct i40e_rx_queue *rxq) int __rte_cold i40e_rxq_vec_setup(struct i40e_rx_queue *rxq) { - return i40e_rxq_vec_setup_default(rxq); + rxq->rx_using_sse = 1; + rxq->mbuf_initializer = ci_rxq_mbuf_initializer(rxq->port_id); + return 0; } int __rte_cold diff --git a/drivers/net/i40e/i40e_rxtx_vec_sse.c b/drivers/net/i40e/i40e_rxtx_vec_sse.c index 90c57e59d0..42255a20af 100644 --- a/drivers/net/i40e/i40e_rxtx_vec_sse.c +++ b/drivers/net/i40e/i40e_rxtx_vec_sse.c @@ -767,7 +767,9 @@ i40e_rx_queue_release_mbufs_vec(struct i40e_rx_queue *rxq) int __rte_cold i40e_rxq_vec_setup(struct i40e_rx_queue *rxq) { - return i40e_rxq_vec_setup_default(rxq); + rxq->rx_using_sse = 1; + rxq->mbuf_initializer = ci_rxq_mbuf_initializer(rxq->port_id); + return 0; } int __rte_cold diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h index c69399a173..2cea4b0fb9 100644 --- a/drivers/net/iavf/iavf_rxtx_vec_common.h +++ b/drivers/net/iavf/iavf_rxtx_vec_common.h @@ -54,24 +54,6 @@ _iavf_rx_queue_release_mbufs_vec(struct iavf_rx_queue *rxq) memset(rxq->sw_ring, 0, sizeof(rxq->sw_ring[0]) * rxq->nb_rx_desc); } -static inline int -iavf_rxq_vec_setup_default(struct iavf_rx_queue *rxq) -{ - uintptr_t p; - struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */ - - mb_def.nb_segs = 1; - mb_def.data_off = RTE_PKTMBUF_HEADROOM; - mb_def.port = rxq->port_id; - rte_mbuf_refcnt_set(&mb_def, 1); - - /* prevent compiler reordering: rearm_data covers previous fields */ - rte_compiler_barrier(); - p = (uintptr_t)&mb_def.rearm_data; - rxq->mbuf_initializer = *(uint64_t *)p; - return 0; -} - static inline int iavf_rx_vec_queue_default(struct iavf_rx_queue *rxq) { diff --git a/drivers/net/iavf/iavf_rxtx_vec_neon.c b/drivers/net/iavf/iavf_rxtx_vec_neon.c index 04be574683..56685ac02e 100644 --- a/drivers/net/iavf/iavf_rxtx_vec_neon.c +++ b/drivers/net/iavf/iavf_rxtx_vec_neon.c @@ -407,7 +407,8 @@ int __rte_cold iavf_rxq_vec_setup(struct iavf_rx_queue *rxq) { rxq->ops = &neon_vec_rxq_ops; - return iavf_rxq_vec_setup_default(rxq); + rxq->mbuf_initializer = ci_rxq_mbuf_initializer(rxq->port_id); + return 0; } int __rte_cold diff --git a/drivers/net/iavf/iavf_rxtx_vec_sse.c b/drivers/net/iavf/iavf_rxtx_vec_sse.c index 21d5bfd309..210ec9e690 100644 --- a/drivers/net/iavf/iavf_rxtx_vec_sse.c +++ b/drivers/net/iavf/iavf_rxtx_vec_sse.c @@ -1469,7 +1469,8 @@ int __rte_cold iavf_rxq_vec_setup(struct iavf_rx_queue *rxq) { rxq->rel_mbufs_type = IAVF_REL_MBUFS_SSE_VEC; - return iavf_rxq_vec_setup_default(rxq); + rxq->mbuf_initializer = ci_rxq_mbuf_initializer(rxq->port_id); + return 0; } int __rte_cold diff --git a/drivers/net/ice/ice_rxtx_vec_common.h b/drivers/net/ice/ice_rxtx_vec_common.h index aa709fb51c..d5cf0e6fca 100644 --- a/drivers/net/ice/ice_rxtx_vec_common.h +++ b/drivers/net/ice/ice_rxtx_vec_common.h @@ -55,24 +55,6 @@ _ice_rx_queue_release_mbufs_vec(struct ice_rx_queue *rxq) memset(rxq->sw_ring, 0, sizeof(rxq->sw_ring[0]) * rxq->nb_rx_desc); } -static inline int -ice_rxq_vec_setup_default(struct ice_rx_queue *rxq) -{ - uintptr_t p; - struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */ - - mb_def.nb_segs = 1; - mb_def.data_off = RTE_PKTMBUF_HEADROOM; - mb_def.port = rxq->port_id; - rte_mbuf_refcnt_set(&mb_def, 1); - - /* prevent compiler reordering: rearm_data covers previous fields */ - rte_compiler_barrier(); - p = (uintptr_t)&mb_def.rearm_data; - rxq->mbuf_initializer = *(uint64_t *)p; - return 0; -} - #define ICE_TX_NO_VECTOR_FLAGS ( \ RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \ RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM | \ diff --git a/drivers/net/ice/ice_rxtx_vec_sse.c b/drivers/net/ice/ice_rxtx_vec_sse.c index 73e3e9eb54..d723017c2c 100644 --- a/drivers/net/ice/ice_rxtx_vec_sse.c +++ b/drivers/net/ice/ice_rxtx_vec_sse.c @@ -789,7 +789,8 @@ ice_rxq_vec_setup(struct ice_rx_queue *rxq) return -1; rxq->rx_rel_mbufs = _ice_rx_queue_release_mbufs_vec; - return ice_rxq_vec_setup_default(rxq); + rxq->mbuf_initializer = ci_rxq_mbuf_initializer(rxq->port_id); + return 0; } int __rte_cold diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h index 9c3752a12a..4a4d793e20 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h @@ -143,24 +143,6 @@ _ixgbe_reset_tx_queue_vec(struct ci_tx_queue *txq) memset(txq->ctx_cache, 0, IXGBE_CTX_NUM * sizeof(struct ixgbe_advctx_info)); } -static inline int -ixgbe_rxq_vec_setup_default(struct ixgbe_rx_queue *rxq) -{ - uintptr_t p; - struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */ - - mb_def.nb_segs = 1; - mb_def.data_off = RTE_PKTMBUF_HEADROOM; - mb_def.port = rxq->port_id; - rte_mbuf_refcnt_set(&mb_def, 1); - - /* prevent compiler reordering: rearm_data covers previous fields */ - rte_compiler_barrier(); - p = (uintptr_t)&mb_def.rearm_data; - rxq->mbuf_initializer = *(uint64_t *)p; - return 0; -} - static inline int ixgbe_txq_vec_setup_default(struct ci_tx_queue *txq, const struct ixgbe_txq_ops *txq_ops) diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c b/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c index f879f6fa9a..e832f66e42 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c @@ -659,7 +659,8 @@ static const struct ixgbe_txq_ops vec_txq_ops = { int __rte_cold ixgbe_rxq_vec_setup(struct ixgbe_rx_queue *rxq) { - return ixgbe_rxq_vec_setup_default(rxq); + rxq->mbuf_initializer = ci_rxq_mbuf_initializer(rxq->port_id); + return 0; } int __rte_cold diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c index 915358e16b..f384b4b0e4 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c @@ -782,7 +782,8 @@ static const struct ixgbe_txq_ops vec_txq_ops = { int __rte_cold ixgbe_rxq_vec_setup(struct ixgbe_rx_queue *rxq) { - return ixgbe_rxq_vec_setup_default(rxq); + rxq->mbuf_initializer = ci_rxq_mbuf_initializer(rxq->port_id); + return 0; } int __rte_cold -- 2.43.0