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 712AD460C2; Mon, 20 Jan 2025 13:03:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7EC5040EF0; Mon, 20 Jan 2025 13:01:26 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id D2EA440E1E for ; Mon, 20 Jan 2025 13:01:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737374485; x=1768910485; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V1TMK3naOn59Gc5k2kdK5Hx/OtKdubZIw/h1RH9ATXI=; b=TBnunZftB92gH/kihGaXJuW6e+FodGU7JZxsjaH/HRZEvRbgq1JFctEt QjdDB98hs3uw/V/kSQQpNEkzDaimmu/15pwXFtNNFSxIbSukfGrQIK1Wt gD38SV4DVFMTg1ZP4iUZBEC+6lSKPnd6bPl4ZJRMa3WP0IohKhZn9KOf5 s54tt/HaeVfE1neMxoQQhEPwczISshosicTSaq+9QqZAMVEcLnkgpBx5M f2VaTnSNQym5bHFRNsSrpYp1+tn5m3tuDHLRKk1we++/vHNW1Jbnb7VDg Gj/i561ELA0adsb9J8g18m22A5RZ071MniRXhjXDTiqE7fX75ume22Rkv w==; X-CSE-ConnectionGUID: qvEI9MKlTWu4lAB6DDAbDg== X-CSE-MsgGUID: AL6v3uMQQaKg8eUGUwjJfA== X-IronPort-AV: E=McAfee;i="6700,10204,11320"; a="36979189" X-IronPort-AV: E=Sophos;i="6.13,219,1732608000"; d="scan'208";a="36979189" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2025 04:01:24 -0800 X-CSE-ConnectionGUID: TPuEadbzTO2klLniWHHa2A== X-CSE-MsgGUID: f3TKDSzEQ52EdQAEnPV7zQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="143767162" Received: from silpixa00401197coob.ir.intel.com (HELO silpixa00401385.ir.intel.com) ([10.237.214.45]) by orviesa001.jf.intel.com with ESMTP; 20 Jan 2025 04:01:23 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Ian Stokes , Vladimir Medvedkin , Anatoly Burakov Subject: [PATCH v5 24/25] net/intel/common: create common mbuf initializer fn Date: Mon, 20 Jan 2025 12:00:06 +0000 Message-ID: <20250120120016.1530274-25-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250120120016.1530274-1-bruce.richardson@intel.com> References: <20241122125418.2857301-1-bruce.richardson@intel.com> <20250120120016.1530274-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/intel/common/rx.h | 13 +++++++++++++ .../net/intel/i40e/i40e_rxtx_vec_altivec.c | 4 +++- drivers/net/intel/i40e/i40e_rxtx_vec_common.h | 19 ------------------- drivers/net/intel/i40e/i40e_rxtx_vec_neon.c | 4 +++- drivers/net/intel/i40e/i40e_rxtx_vec_sse.c | 4 +++- drivers/net/intel/iavf/iavf_rxtx_vec_common.h | 18 ------------------ drivers/net/intel/iavf/iavf_rxtx_vec_neon.c | 3 ++- drivers/net/intel/iavf/iavf_rxtx_vec_sse.c | 3 ++- drivers/net/intel/ice/ice_rxtx_vec_common.h | 18 ------------------ drivers/net/intel/ice/ice_rxtx_vec_sse.c | 3 ++- .../net/intel/ixgbe/ixgbe_rxtx_vec_common.h | 18 ------------------ drivers/net/intel/ixgbe/ixgbe_rxtx_vec_neon.c | 3 ++- drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c | 3 ++- 13 files changed, 32 insertions(+), 81 deletions(-) diff --git a/drivers/net/intel/common/rx.h b/drivers/net/intel/common/rx.h index 5bd2fea7e3..ca0485875c 100644 --- a/drivers/net/intel/common/rx.h +++ b/drivers/net/intel/common/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/intel/i40e/i40e_rxtx_vec_altivec.c b/drivers/net/intel/i40e/i40e_rxtx_vec_altivec.c index b6900a3e15..e8046b5ce5 100644 --- a/drivers/net/intel/i40e/i40e_rxtx_vec_altivec.c +++ b/drivers/net/intel/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/intel/i40e/i40e_rxtx_vec_common.h b/drivers/net/intel/i40e/i40e_rxtx_vec_common.h index 4d9d9f669d..445aad3ca8 100644 --- a/drivers/net/intel/i40e/i40e_rxtx_vec_common.h +++ b/drivers/net/intel/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/intel/i40e/i40e_rxtx_vec_neon.c b/drivers/net/intel/i40e/i40e_rxtx_vec_neon.c index b398d66154..1c7e9bf1fa 100644 --- a/drivers/net/intel/i40e/i40e_rxtx_vec_neon.c +++ b/drivers/net/intel/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/intel/i40e/i40e_rxtx_vec_sse.c b/drivers/net/intel/i40e/i40e_rxtx_vec_sse.c index 90c57e59d0..42255a20af 100644 --- a/drivers/net/intel/i40e/i40e_rxtx_vec_sse.c +++ b/drivers/net/intel/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/intel/iavf/iavf_rxtx_vec_common.h b/drivers/net/intel/iavf/iavf_rxtx_vec_common.h index 777fb1ce14..859df52b4b 100644 --- a/drivers/net/intel/iavf/iavf_rxtx_vec_common.h +++ b/drivers/net/intel/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/intel/iavf/iavf_rxtx_vec_neon.c b/drivers/net/intel/iavf/iavf_rxtx_vec_neon.c index 04be574683..56685ac02e 100644 --- a/drivers/net/intel/iavf/iavf_rxtx_vec_neon.c +++ b/drivers/net/intel/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/intel/iavf/iavf_rxtx_vec_sse.c b/drivers/net/intel/iavf/iavf_rxtx_vec_sse.c index 21d5bfd309..210ec9e690 100644 --- a/drivers/net/intel/iavf/iavf_rxtx_vec_sse.c +++ b/drivers/net/intel/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/intel/ice/ice_rxtx_vec_common.h b/drivers/net/intel/ice/ice_rxtx_vec_common.h index 9bd7c2cbf6..2ea7ef8486 100644 --- a/drivers/net/intel/ice/ice_rxtx_vec_common.h +++ b/drivers/net/intel/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/intel/ice/ice_rxtx_vec_sse.c b/drivers/net/intel/ice/ice_rxtx_vec_sse.c index 73e3e9eb54..d723017c2c 100644 --- a/drivers/net/intel/ice/ice_rxtx_vec_sse.c +++ b/drivers/net/intel/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/intel/ixgbe/ixgbe_rxtx_vec_common.h b/drivers/net/intel/ixgbe/ixgbe_rxtx_vec_common.h index 4ac61a8d3b..d9ff7fafe5 100644 --- a/drivers/net/intel/ixgbe/ixgbe_rxtx_vec_common.h +++ b/drivers/net/intel/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/intel/ixgbe/ixgbe_rxtx_vec_neon.c b/drivers/net/intel/ixgbe/ixgbe_rxtx_vec_neon.c index f879f6fa9a..e832f66e42 100644 --- a/drivers/net/intel/ixgbe/ixgbe_rxtx_vec_neon.c +++ b/drivers/net/intel/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/intel/ixgbe/ixgbe_rxtx_vec_sse.c b/drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c index 915358e16b..f384b4b0e4 100644 --- a/drivers/net/intel/ixgbe/ixgbe_rxtx_vec_sse.c +++ b/drivers/net/intel/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