* [dpdk-dev] [PATCH 0/2] add Rx/Tx offload paths for ICE AVX2 @ 2021-06-02 2:21 Wenzhuo Lu 2021-06-02 2:21 ` [dpdk-dev] [PATCH 1/2] net/ice: add Tx AVX2 offload path Wenzhuo Lu ` (3 more replies) 0 siblings, 4 replies; 12+ messages in thread From: Wenzhuo Lu @ 2021-06-02 2:21 UTC (permalink / raw) To: dev; +Cc: Wenzhuo Lu Add specific paths for RX/TX AVX2, called offload paths. In these paths, support the HW offload features, like, checksum, VLAN, RSS offload. These paths are chosen automatically according to the configuration. Wenzhuo Lu (2): net/ice: add Tx AVX2 offload path net/ice: add Rx AVX2 offload path doc/guides/rel_notes/release_21_08.rst | 6 + drivers/net/ice/ice_rxtx.c | 86 +++++-- drivers/net/ice/ice_rxtx.h | 7 + drivers/net/ice/ice_rxtx_vec_avx2.c | 402 +++++++++++++++++++-------------- 4 files changed, 307 insertions(+), 194 deletions(-) -- 1.9.3 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH 1/2] net/ice: add Tx AVX2 offload path 2021-06-02 2:21 [dpdk-dev] [PATCH 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu @ 2021-06-02 2:21 ` Wenzhuo Lu 2021-06-02 2:21 ` [dpdk-dev] [PATCH 2/2] net/ice: add Rx " Wenzhuo Lu ` (2 subsequent siblings) 3 siblings, 0 replies; 12+ messages in thread From: Wenzhuo Lu @ 2021-06-02 2:21 UTC (permalink / raw) To: dev; +Cc: Wenzhuo Lu Add a specific path for TX AVX2. In this path, support the HW offload features, like, checksum insertion, VLAN insertion. This path is chosen automatically according to the configuration. 'inline' is used, then the duplicate code is generated by the compiler. Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com> --- drivers/net/ice/ice_rxtx.c | 36 ++++++++++++++++--------- drivers/net/ice/ice_rxtx.h | 2 ++ drivers/net/ice/ice_rxtx_vec_avx2.c | 54 ++++++++++++++++++++++++++----------- 3 files changed, 64 insertions(+), 28 deletions(-) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 49abcb2..7c9474e 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -3294,7 +3294,7 @@ #ifdef RTE_ARCH_X86 struct ice_tx_queue *txq; int i; - int tx_check_ret; + int tx_check_ret = -1; bool use_avx512 = false; bool use_avx2 = false; @@ -3313,13 +3313,13 @@ PMD_DRV_LOG(NOTICE, "AVX512 is not supported in build env"); #endif - if (!use_avx512 && tx_check_ret == ICE_VECTOR_PATH && - (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 || - rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) && - rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256) + if ((rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 || + rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) && + rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256) use_avx2 = true; - if (!use_avx512 && tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) + if (!use_avx2 && !use_avx512 && + tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) ad->tx_vec_allowed = false; if (ad->tx_vec_allowed) { @@ -3337,6 +3337,7 @@ } if (ad->tx_vec_allowed) { + dev->tx_pkt_prepare = NULL; if (use_avx512) { #ifdef CC_AVX512_SUPPORT if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { @@ -3345,6 +3346,7 @@ dev->data->port_id); dev->tx_pkt_burst = ice_xmit_pkts_vec_avx512_offload; + dev->tx_pkt_prepare = ice_prep_pkts; } else { PMD_DRV_LOG(NOTICE, "Using AVX512 Vector Tx (port %d).", @@ -3353,14 +3355,22 @@ } #endif } else { - PMD_DRV_LOG(DEBUG, "Using %sVector Tx (port %d).", - use_avx2 ? "avx2 " : "", - dev->data->port_id); - dev->tx_pkt_burst = use_avx2 ? - ice_xmit_pkts_vec_avx2 : - ice_xmit_pkts_vec; + if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { + PMD_DRV_LOG(NOTICE, + "Using AVX2 OFFLOAD Vector Tx (port %d).", + dev->data->port_id); + dev->tx_pkt_burst = + ice_xmit_pkts_vec_avx2_offload; + dev->tx_pkt_prepare = ice_prep_pkts; + } else { + PMD_DRV_LOG(DEBUG, "Using %sVector Tx (port %d).", + use_avx2 ? "avx2 " : "", + dev->data->port_id); + dev->tx_pkt_burst = use_avx2 ? + ice_xmit_pkts_vec_avx2 : + ice_xmit_pkts_vec; + } } - dev->tx_pkt_prepare = NULL; return; } diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index b29387c..595dc66 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -255,6 +255,8 @@ uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue, uint16_t nb_pkts); uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); +uint16_t ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); uint16_t ice_recv_pkts_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); uint16_t ice_recv_pkts_vec_avx512_offload(void *rx_queue, diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c b/drivers/net/ice/ice_rxtx_vec_avx2.c index 8d4bd6d..b83c1ac 100644 --- a/drivers/net/ice/ice_rxtx_vec_avx2.c +++ b/drivers/net/ice/ice_rxtx_vec_avx2.c @@ -769,30 +769,32 @@ rx_pkts + retval, nb_pkts); } -static inline void +static __rte_always_inline void ice_vtx1(volatile struct ice_tx_desc *txdp, - struct rte_mbuf *pkt, uint64_t flags) + struct rte_mbuf *pkt, uint64_t flags, bool offload) { uint64_t high_qw = (ICE_TX_DESC_DTYPE_DATA | ((uint64_t)flags << ICE_TXD_QW1_CMD_S) | ((uint64_t)pkt->data_len << ICE_TXD_QW1_TX_BUF_SZ_S)); + if (offload) + ice_txd_enable_offload(pkt, &high_qw); __m128i descriptor = _mm_set_epi64x(high_qw, pkt->buf_iova + pkt->data_off); _mm_store_si128((__m128i *)txdp, descriptor); } -static inline void +static __rte_always_inline void ice_vtx(volatile struct ice_tx_desc *txdp, - struct rte_mbuf **pkt, uint16_t nb_pkts, uint64_t flags) + struct rte_mbuf **pkt, uint16_t nb_pkts, uint64_t flags, bool offload) { const uint64_t hi_qw_tmpl = (ICE_TX_DESC_DTYPE_DATA | ((uint64_t)flags << ICE_TXD_QW1_CMD_S)); /* if unaligned on 32-bit boundary, do one to align */ if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) { - ice_vtx1(txdp, *pkt, flags); + ice_vtx1(txdp, *pkt, flags, offload); nb_pkts--, txdp++, pkt++; } @@ -802,18 +804,26 @@ hi_qw_tmpl | ((uint64_t)pkt[3]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[3], &hi_qw3); uint64_t hi_qw2 = hi_qw_tmpl | ((uint64_t)pkt[2]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[2], &hi_qw2); uint64_t hi_qw1 = hi_qw_tmpl | ((uint64_t)pkt[1]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[1], &hi_qw1); uint64_t hi_qw0 = hi_qw_tmpl | ((uint64_t)pkt[0]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[0], &hi_qw0); __m256i desc2_3 = _mm256_set_epi64x @@ -833,14 +843,14 @@ /* do any last ones */ while (nb_pkts) { - ice_vtx1(txdp, *pkt, flags); + ice_vtx1(txdp, *pkt, flags, offload); txdp++, pkt++, nb_pkts--; } } -static inline uint16_t +static __rte_always_inline uint16_t ice_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, - uint16_t nb_pkts) + uint16_t nb_pkts, bool offload) { struct ice_tx_queue *txq = (struct ice_tx_queue *)tx_queue; volatile struct ice_tx_desc *txdp; @@ -869,11 +879,11 @@ if (nb_commit >= n) { ice_tx_backlog_entry(txep, tx_pkts, n); - ice_vtx(txdp, tx_pkts, n - 1, flags); + ice_vtx(txdp, tx_pkts, n - 1, flags, offload); tx_pkts += (n - 1); txdp += (n - 1); - ice_vtx1(txdp, *tx_pkts++, rs); + ice_vtx1(txdp, *tx_pkts++, rs, offload); nb_commit = (uint16_t)(nb_commit - n); @@ -887,7 +897,7 @@ ice_tx_backlog_entry(txep, tx_pkts, nb_commit); - ice_vtx(txdp, tx_pkts, nb_commit, flags); + ice_vtx(txdp, tx_pkts, nb_commit, flags, offload); tx_id = (uint16_t)(tx_id + nb_commit); if (tx_id > txq->tx_next_rs) { @@ -905,9 +915,9 @@ return nb_pkts; } -uint16_t -ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, - uint16_t nb_pkts) +static __rte_always_inline uint16_t +ice_xmit_pkts_vec_avx2_common(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts, bool offload) { uint16_t nb_tx = 0; struct ice_tx_queue *txq = (struct ice_tx_queue *)tx_queue; @@ -917,7 +927,7 @@ num = (uint16_t)RTE_MIN(nb_pkts, txq->tx_rs_thresh); ret = ice_xmit_fixed_burst_vec_avx2(tx_queue, &tx_pkts[nb_tx], - num); + num, offload); nb_tx += ret; nb_pkts -= ret; if (ret < num) @@ -926,3 +936,17 @@ return nb_tx; } + +uint16_t +ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + return ice_xmit_pkts_vec_avx2_common(tx_queue, tx_pkts, nb_pkts, false); +} + +uint16_t +ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + return ice_xmit_pkts_vec_avx2_common(tx_queue, tx_pkts, nb_pkts, true); +} -- 1.9.3 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH 2/2] net/ice: add Rx AVX2 offload path 2021-06-02 2:21 [dpdk-dev] [PATCH 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu 2021-06-02 2:21 ` [dpdk-dev] [PATCH 1/2] net/ice: add Tx AVX2 offload path Wenzhuo Lu @ 2021-06-02 2:21 ` Wenzhuo Lu 2021-06-28 7:53 ` [dpdk-dev] [PATCH v2 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu 3 siblings, 0 replies; 12+ messages in thread From: Wenzhuo Lu @ 2021-06-02 2:21 UTC (permalink / raw) To: dev; +Cc: Wenzhuo Lu Add a specific path for RX AVX2. In this path, support the HW offload features, like, checksum, VLAN stripping, RSS hash. This path is chosen automatically according to the configuration. 'inline' is used, then the duplicate code is generated by the compiler. Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com> --- doc/guides/rel_notes/release_21_08.rst | 6 + drivers/net/ice/ice_rxtx.c | 50 +++-- drivers/net/ice/ice_rxtx.h | 5 + drivers/net/ice/ice_rxtx_vec_avx2.c | 348 ++++++++++++++++++--------------- 4 files changed, 243 insertions(+), 166 deletions(-) diff --git a/doc/guides/rel_notes/release_21_08.rst b/doc/guides/rel_notes/release_21_08.rst index a6ecfdf..203b772 100644 --- a/doc/guides/rel_notes/release_21_08.rst +++ b/doc/guides/rel_notes/release_21_08.rst @@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated Intel ice driver.** + + * In AVX2 code, added the new RX and TX paths to use the HW offload + features. When the HW offload features are configured to be used, the + offload paths are chosen automatically. In parallel the support for HW + offload features was removed from the legacy AVX2 paths. Removed Items ------------- diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 7c9474e..4e51fd6 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -1999,7 +1999,9 @@ dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx512_offload || #endif dev->rx_pkt_burst == ice_recv_pkts_vec_avx2 || - dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2) + dev->rx_pkt_burst == ice_recv_pkts_vec_avx2_offload || + dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2 || + dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2_offload) return ptypes; #endif @@ -3058,7 +3060,7 @@ #ifdef RTE_ARCH_X86 struct ice_rx_queue *rxq; int i; - int rx_check_ret; + int rx_check_ret = -1; bool use_avx512 = false; bool use_avx2 = false; @@ -3113,14 +3115,25 @@ ice_recv_scattered_pkts_vec_avx512; } #endif + } else if (use_avx2) { + if (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { + PMD_DRV_LOG(NOTICE, + "Using AVX2 OFFLOAD Vector Scattered Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_scattered_pkts_vec_avx2_offload; + } else { + PMD_DRV_LOG(NOTICE, + "Using AVX2 Vector Scattered Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_scattered_pkts_vec_avx2; + } } else { PMD_DRV_LOG(DEBUG, - "Using %sVector Scattered Rx (port %d).", - use_avx2 ? "avx2 " : "", + "Using Vector Scattered Rx (port %d).", dev->data->port_id); - dev->rx_pkt_burst = use_avx2 ? - ice_recv_scattered_pkts_vec_avx2 : - ice_recv_scattered_pkts_vec; + dev->rx_pkt_burst = ice_recv_scattered_pkts_vec; } } else { if (use_avx512) { @@ -3139,14 +3152,25 @@ ice_recv_pkts_vec_avx512; } #endif + } else if (use_avx2) { + if (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { + PMD_DRV_LOG(NOTICE, + "Using AVX2 OFFLOAD Vector Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_pkts_vec_avx2_offload; + } else { + PMD_DRV_LOG(NOTICE, + "Using AVX2 Vector Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_pkts_vec_avx2; + } } else { PMD_DRV_LOG(DEBUG, - "Using %sVector Rx (port %d).", - use_avx2 ? "avx2 " : "", + "Using Vector Rx (port %d).", dev->data->port_id); - dev->rx_pkt_burst = use_avx2 ? - ice_recv_pkts_vec_avx2 : - ice_recv_pkts_vec; + dev->rx_pkt_burst = ice_recv_pkts_vec; } } return; @@ -3191,7 +3215,9 @@ { ice_recv_pkts_vec_avx512_offload, "Offload Vector AVX512" }, #endif { ice_recv_scattered_pkts_vec_avx2, "Vector AVX2 Scattered" }, + { ice_recv_scattered_pkts_vec_avx2_offload, "Offload Vector AVX2 Scattered" }, { ice_recv_pkts_vec_avx2, "Vector AVX2" }, + { ice_recv_pkts_vec_avx2_offload, "Offload Vector AVX2" }, { ice_recv_scattered_pkts_vec, "Vector SSE Scattered" }, { ice_recv_pkts_vec, "Vector SSE" }, #endif diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index 595dc66..bd28a68 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -250,9 +250,14 @@ uint16_t ice_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); uint16_t ice_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); +uint16_t ice_recv_pkts_vec_avx2_offload(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts); uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); +uint16_t ice_recv_scattered_pkts_vec_avx2_offload(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts); uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); uint16_t ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts, diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c b/drivers/net/ice/ice_rxtx_vec_avx2.c index b83c1ac..0be9858 100644 --- a/drivers/net/ice/ice_rxtx_vec_avx2.c +++ b/drivers/net/ice/ice_rxtx_vec_avx2.c @@ -16,7 +16,7 @@ return ice_rxq_rearm_common(rxq, false); } -static inline __m256i +static __rte_always_inline __m256i ice_flex_rxd_to_fdir_flags_vec_avx2(const __m256i fdir_id0_7) { #define FDID_MIS_MAGIC 0xFFFFFFFF @@ -35,9 +35,10 @@ return fdir_flags; } -static inline uint16_t +static __rte_always_inline uint16_t _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts, uint8_t *split_packet) + uint16_t nb_pkts, uint8_t *split_packet, + bool offload) { #define ICE_DESCS_PER_LOOP_AVX 8 @@ -385,171 +386,177 @@ */ __m256i status0_7 = _mm256_unpacklo_epi64(status4_7, status0_3); + __m256i mbuf_flags = _mm256_set1_epi32(0); - /* now do flag manipulation */ + if (offload) { + /* now do flag manipulation */ - /* get only flag/error bits we want */ - const __m256i flag_bits = - _mm256_and_si256(status0_7, flags_mask); - /** - * l3_l4_error flags, shuffle, then shift to correct adjustment - * of flags in flags_shuf, and finally mask out extra bits - */ - __m256i l3_l4_flags = _mm256_shuffle_epi8(l3_l4_flags_shuf, - _mm256_srli_epi32(flag_bits, 4)); - l3_l4_flags = _mm256_slli_epi32(l3_l4_flags, 1); + /* get only flag/error bits we want */ + const __m256i flag_bits = + _mm256_and_si256(status0_7, flags_mask); + /** + * l3_l4_error flags, shuffle, then shift to correct adjustment + * of flags in flags_shuf, and finally mask out extra bits + */ + __m256i l3_l4_flags = _mm256_shuffle_epi8(l3_l4_flags_shuf, + _mm256_srli_epi32(flag_bits, 4)); + l3_l4_flags = _mm256_slli_epi32(l3_l4_flags, 1); - __m256i l4_outer_mask = _mm256_set1_epi32(0x6); - __m256i l4_outer_flags = - _mm256_and_si256(l3_l4_flags, l4_outer_mask); - l4_outer_flags = _mm256_slli_epi32(l4_outer_flags, 20); + __m256i l4_outer_mask = _mm256_set1_epi32(0x6); + __m256i l4_outer_flags = + _mm256_and_si256(l3_l4_flags, l4_outer_mask); + l4_outer_flags = _mm256_slli_epi32(l4_outer_flags, 20); - __m256i l3_l4_mask = _mm256_set1_epi32(~0x6); - l3_l4_flags = _mm256_and_si256(l3_l4_flags, l3_l4_mask); - l3_l4_flags = _mm256_or_si256(l3_l4_flags, l4_outer_flags); - l3_l4_flags = _mm256_and_si256(l3_l4_flags, cksum_mask); - /* set rss and vlan flags */ - const __m256i rss_vlan_flag_bits = - _mm256_srli_epi32(flag_bits, 12); - const __m256i rss_vlan_flags = - _mm256_shuffle_epi8(rss_vlan_flags_shuf, - rss_vlan_flag_bits); + __m256i l3_l4_mask = _mm256_set1_epi32(~0x6); - /* merge flags */ - __m256i mbuf_flags = _mm256_or_si256(l3_l4_flags, - rss_vlan_flags); + l3_l4_flags = _mm256_and_si256(l3_l4_flags, l3_l4_mask); + l3_l4_flags = _mm256_or_si256(l3_l4_flags, l4_outer_flags); + l3_l4_flags = _mm256_and_si256(l3_l4_flags, cksum_mask); + /* set rss and vlan flags */ + const __m256i rss_vlan_flag_bits = + _mm256_srli_epi32(flag_bits, 12); + const __m256i rss_vlan_flags = + _mm256_shuffle_epi8(rss_vlan_flags_shuf, + rss_vlan_flag_bits); - if (rxq->fdir_enabled) { - const __m256i fdir_id4_7 = - _mm256_unpackhi_epi32(raw_desc6_7, raw_desc4_5); + /* merge flags */ + mbuf_flags = _mm256_or_si256(l3_l4_flags, + rss_vlan_flags); - const __m256i fdir_id0_3 = - _mm256_unpackhi_epi32(raw_desc2_3, raw_desc0_1); + if (rxq->fdir_enabled) { + const __m256i fdir_id4_7 = + _mm256_unpackhi_epi32(raw_desc6_7, raw_desc4_5); - const __m256i fdir_id0_7 = - _mm256_unpackhi_epi64(fdir_id4_7, fdir_id0_3); + const __m256i fdir_id0_3 = + _mm256_unpackhi_epi32(raw_desc2_3, raw_desc0_1); - const __m256i fdir_flags = - ice_flex_rxd_to_fdir_flags_vec_avx2(fdir_id0_7); + const __m256i fdir_id0_7 = + _mm256_unpackhi_epi64(fdir_id4_7, fdir_id0_3); - /* merge with fdir_flags */ - mbuf_flags = _mm256_or_si256(mbuf_flags, fdir_flags); + const __m256i fdir_flags = + ice_flex_rxd_to_fdir_flags_vec_avx2(fdir_id0_7); - /* write to mbuf: have to use scalar store here */ - rx_pkts[i + 0]->hash.fdir.hi = - _mm256_extract_epi32(fdir_id0_7, 3); + /* merge with fdir_flags */ + mbuf_flags = _mm256_or_si256(mbuf_flags, fdir_flags); - rx_pkts[i + 1]->hash.fdir.hi = - _mm256_extract_epi32(fdir_id0_7, 7); + /* write to mbuf: have to use scalar store here */ + rx_pkts[i + 0]->hash.fdir.hi = + _mm256_extract_epi32(fdir_id0_7, 3); - rx_pkts[i + 2]->hash.fdir.hi = - _mm256_extract_epi32(fdir_id0_7, 2); + rx_pkts[i + 1]->hash.fdir.hi = + _mm256_extract_epi32(fdir_id0_7, 7); - rx_pkts[i + 3]->hash.fdir.hi = - _mm256_extract_epi32(fdir_id0_7, 6); + rx_pkts[i + 2]->hash.fdir.hi = + _mm256_extract_epi32(fdir_id0_7, 2); - rx_pkts[i + 4]->hash.fdir.hi = - _mm256_extract_epi32(fdir_id0_7, 1); + rx_pkts[i + 3]->hash.fdir.hi = + _mm256_extract_epi32(fdir_id0_7, 6); - rx_pkts[i + 5]->hash.fdir.hi = - _mm256_extract_epi32(fdir_id0_7, 5); + rx_pkts[i + 4]->hash.fdir.hi = + _mm256_extract_epi32(fdir_id0_7, 1); - rx_pkts[i + 6]->hash.fdir.hi = - _mm256_extract_epi32(fdir_id0_7, 0); + rx_pkts[i + 5]->hash.fdir.hi = + _mm256_extract_epi32(fdir_id0_7, 5); - rx_pkts[i + 7]->hash.fdir.hi = - _mm256_extract_epi32(fdir_id0_7, 4); - } /* if() on fdir_enabled */ + rx_pkts[i + 6]->hash.fdir.hi = + _mm256_extract_epi32(fdir_id0_7, 0); -#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC - /** - * needs to load 2nd 16B of each desc for RSS hash parsing, - * will cause performance drop to get into this context. - */ - if (rxq->vsi->adapter->eth_dev->data->dev_conf.rxmode.offloads & - DEV_RX_OFFLOAD_RSS_HASH) { - /* load bottom half of every 32B desc */ - const __m128i raw_desc_bh7 = - _mm_load_si128 - ((void *)(&rxdp[7].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh6 = - _mm_load_si128 - ((void *)(&rxdp[6].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh5 = - _mm_load_si128 - ((void *)(&rxdp[5].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh4 = - _mm_load_si128 - ((void *)(&rxdp[4].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh3 = - _mm_load_si128 - ((void *)(&rxdp[3].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh2 = - _mm_load_si128 - ((void *)(&rxdp[2].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh1 = - _mm_load_si128 - ((void *)(&rxdp[1].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh0 = - _mm_load_si128 - ((void *)(&rxdp[0].wb.status_error1)); - - __m256i raw_desc_bh6_7 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh6), - raw_desc_bh7, 1); - __m256i raw_desc_bh4_5 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh4), - raw_desc_bh5, 1); - __m256i raw_desc_bh2_3 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh2), - raw_desc_bh3, 1); - __m256i raw_desc_bh0_1 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh0), - raw_desc_bh1, 1); + rx_pkts[i + 7]->hash.fdir.hi = + _mm256_extract_epi32(fdir_id0_7, 4); + } /* if() on fdir_enabled */ + } + if (offload) { +#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC /** - * to shift the 32b RSS hash value to the - * highest 32b of each 128b before mask + * needs to load 2nd 16B of each desc for RSS hash parsing, + * will cause performance drop to get into this context. */ - __m256i rss_hash6_7 = - _mm256_slli_epi64(raw_desc_bh6_7, 32); - __m256i rss_hash4_5 = - _mm256_slli_epi64(raw_desc_bh4_5, 32); - __m256i rss_hash2_3 = - _mm256_slli_epi64(raw_desc_bh2_3, 32); - __m256i rss_hash0_1 = - _mm256_slli_epi64(raw_desc_bh0_1, 32); - - __m256i rss_hash_msk = - _mm256_set_epi32(0xFFFFFFFF, 0, 0, 0, - 0xFFFFFFFF, 0, 0, 0); - - rss_hash6_7 = _mm256_and_si256 - (rss_hash6_7, rss_hash_msk); - rss_hash4_5 = _mm256_and_si256 - (rss_hash4_5, rss_hash_msk); - rss_hash2_3 = _mm256_and_si256 - (rss_hash2_3, rss_hash_msk); - rss_hash0_1 = _mm256_and_si256 - (rss_hash0_1, rss_hash_msk); - - mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7); - mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5); - mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3); - mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1); - } /* if() on RSS hash parsing */ + if (rxq->vsi->adapter->eth_dev->data->dev_conf.rxmode.offloads & + DEV_RX_OFFLOAD_RSS_HASH) { + /* load bottom half of every 32B desc */ + const __m128i raw_desc_bh7 = + _mm_load_si128 + ((void *)(&rxdp[7].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh6 = + _mm_load_si128 + ((void *)(&rxdp[6].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh5 = + _mm_load_si128 + ((void *)(&rxdp[5].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh4 = + _mm_load_si128 + ((void *)(&rxdp[4].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh3 = + _mm_load_si128 + ((void *)(&rxdp[3].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh2 = + _mm_load_si128 + ((void *)(&rxdp[2].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh1 = + _mm_load_si128 + ((void *)(&rxdp[1].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh0 = + _mm_load_si128 + ((void *)(&rxdp[0].wb.status_error1)); + + __m256i raw_desc_bh6_7 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh6), + raw_desc_bh7, 1); + __m256i raw_desc_bh4_5 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh4), + raw_desc_bh5, 1); + __m256i raw_desc_bh2_3 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh2), + raw_desc_bh3, 1); + __m256i raw_desc_bh0_1 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh0), + raw_desc_bh1, 1); + + /** + * to shift the 32b RSS hash value to the + * highest 32b of each 128b before mask + */ + __m256i rss_hash6_7 = + _mm256_slli_epi64(raw_desc_bh6_7, 32); + __m256i rss_hash4_5 = + _mm256_slli_epi64(raw_desc_bh4_5, 32); + __m256i rss_hash2_3 = + _mm256_slli_epi64(raw_desc_bh2_3, 32); + __m256i rss_hash0_1 = + _mm256_slli_epi64(raw_desc_bh0_1, 32); + + __m256i rss_hash_msk = + _mm256_set_epi32(0xFFFFFFFF, 0, 0, 0, + 0xFFFFFFFF, 0, 0, 0); + + rss_hash6_7 = _mm256_and_si256 + (rss_hash6_7, rss_hash_msk); + rss_hash4_5 = _mm256_and_si256 + (rss_hash4_5, rss_hash_msk); + rss_hash2_3 = _mm256_and_si256 + (rss_hash2_3, rss_hash_msk); + rss_hash0_1 = _mm256_and_si256 + (rss_hash0_1, rss_hash_msk); + + mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7); + mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5); + mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3); + mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1); + } /* if() on RSS hash parsing */ #endif + } /** * At this point, we have the 8 sets of flags in the low 16-bits @@ -701,7 +708,16 @@ ice_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { - return _ice_recv_raw_pkts_vec_avx2(rx_queue, rx_pkts, nb_pkts, NULL); + return _ice_recv_raw_pkts_vec_avx2(rx_queue, rx_pkts, + nb_pkts, NULL, false); +} + +uint16_t +ice_recv_pkts_vec_avx2_offload(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return _ice_recv_raw_pkts_vec_avx2(rx_queue, rx_pkts, + nb_pkts, NULL, true); } /** @@ -709,16 +725,16 @@ * Notice: * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet */ -static uint16_t +static __rte_always_inline uint16_t ice_recv_scattered_burst_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts) + uint16_t nb_pkts, bool offload) { struct ice_rx_queue *rxq = rx_queue; uint8_t split_flags[ICE_VPMD_RX_BURST] = {0}; /* get some new buffers */ uint16_t nb_bufs = _ice_recv_raw_pkts_vec_avx2(rxq, rx_pkts, nb_pkts, - split_flags); + split_flags, offload); if (nb_bufs == 0) return 0; @@ -751,22 +767,46 @@ * Notice: * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet */ -uint16_t -ice_recv_scattered_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts) +static __rte_always_inline uint16_t +ice_recv_scattered_pkts_vec_avx2_common(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts, + bool offload) { uint16_t retval = 0; while (nb_pkts > ICE_VPMD_RX_BURST) { uint16_t burst = ice_recv_scattered_burst_vec_avx2(rx_queue, - rx_pkts + retval, ICE_VPMD_RX_BURST); + rx_pkts + retval, ICE_VPMD_RX_BURST, offload); retval += burst; nb_pkts -= burst; if (burst < ICE_VPMD_RX_BURST) return retval; } return retval + ice_recv_scattered_burst_vec_avx2(rx_queue, - rx_pkts + retval, nb_pkts); + rx_pkts + retval, nb_pkts, offload); +} + +uint16_t +ice_recv_scattered_pkts_vec_avx2(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return ice_recv_scattered_pkts_vec_avx2_common(rx_queue, + rx_pkts, + nb_pkts, + false); +} + +uint16_t +ice_recv_scattered_pkts_vec_avx2_offload(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return ice_recv_scattered_pkts_vec_avx2_common(rx_queue, + rx_pkts, + nb_pkts, + true); } static __rte_always_inline void -- 1.9.3 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v2 0/2] add Rx/Tx offload paths for ICE AVX2 2021-06-02 2:21 [dpdk-dev] [PATCH 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu 2021-06-02 2:21 ` [dpdk-dev] [PATCH 1/2] net/ice: add Tx AVX2 offload path Wenzhuo Lu 2021-06-02 2:21 ` [dpdk-dev] [PATCH 2/2] net/ice: add Rx " Wenzhuo Lu @ 2021-06-28 7:53 ` Wenzhuo Lu 2021-06-28 7:53 ` [dpdk-dev] [PATCH v2 1/2] net/ice: add Tx AVX2 offload path Wenzhuo Lu 2021-06-28 7:53 ` [dpdk-dev] [PATCH v2 2/2] net/ice: add Rx " Wenzhuo Lu 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu 3 siblings, 2 replies; 12+ messages in thread From: Wenzhuo Lu @ 2021-06-28 7:53 UTC (permalink / raw) To: dev; +Cc: Wenzhuo Lu Add specific paths for RX/TX AVX2, called offload paths. In these paths, support the HW offload features, like, checksum, VLAN, RSS offload. These paths are chosen automatically according to the configuration. v2: - fdir should be supported by offload and normal path. Wenzhuo Lu (2): net/ice: add Tx AVX2 offload path net/ice: add Rx AVX2 offload path doc/guides/rel_notes/release_21_08.rst | 6 + drivers/net/ice/ice_rxtx.c | 96 ++++++--- drivers/net/ice/ice_rxtx.h | 7 + drivers/net/ice/ice_rxtx_vec_avx2.c | 350 +++++++++++++++++++-------------- 4 files changed, 286 insertions(+), 173 deletions(-) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v2 1/2] net/ice: add Tx AVX2 offload path 2021-06-28 7:53 ` [dpdk-dev] [PATCH v2 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu @ 2021-06-28 7:53 ` Wenzhuo Lu 2021-06-28 7:53 ` [dpdk-dev] [PATCH v2 2/2] net/ice: add Rx " Wenzhuo Lu 1 sibling, 0 replies; 12+ messages in thread From: Wenzhuo Lu @ 2021-06-28 7:53 UTC (permalink / raw) To: dev; +Cc: Wenzhuo Lu Add a specific path for TX AVX2. In this path, support the HW offload features, like, checksum insertion, VLAN insertion. This path is chosen automatically according to the configuration. 'inline' is used, then the duplicate code is generated by the compiler. Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com> --- drivers/net/ice/ice_rxtx.c | 46 ++++++++++++++++++------------- drivers/net/ice/ice_rxtx.h | 2 ++ drivers/net/ice/ice_rxtx_vec_avx2.c | 54 ++++++++++++++++++++++++++----------- 3 files changed, 69 insertions(+), 33 deletions(-) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 49abcb2..5d7ca60 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -3294,9 +3294,9 @@ #ifdef RTE_ARCH_X86 struct ice_tx_queue *txq; int i; - int tx_check_ret; - bool use_avx512 = false; - bool use_avx2 = false; + int tx_check_ret = -1; + bool cap_avx512 = false; + bool cap_avx2 = false; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { tx_check_ret = ice_tx_vec_dev_check(dev); @@ -3308,18 +3308,18 @@ rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 && rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1) #ifdef CC_AVX512_SUPPORT - use_avx512 = true; + cap_avx512 = true; #else PMD_DRV_LOG(NOTICE, "AVX512 is not supported in build env"); #endif - if (!use_avx512 && tx_check_ret == ICE_VECTOR_PATH && - (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 || - rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) && - rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256) - use_avx2 = true; + if ((rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 || + rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) && + rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256) + cap_avx2 = true; - if (!use_avx512 && tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) + if (!cap_avx2 && !cap_avx512 && + tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) ad->tx_vec_allowed = false; if (ad->tx_vec_allowed) { @@ -3337,7 +3337,8 @@ } if (ad->tx_vec_allowed) { - if (use_avx512) { + dev->tx_pkt_prepare = NULL; + if (cap_avx512) { #ifdef CC_AVX512_SUPPORT if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { PMD_DRV_LOG(NOTICE, @@ -3345,6 +3346,7 @@ dev->data->port_id); dev->tx_pkt_burst = ice_xmit_pkts_vec_avx512_offload; + dev->tx_pkt_prepare = ice_prep_pkts; } else { PMD_DRV_LOG(NOTICE, "Using AVX512 Vector Tx (port %d).", @@ -3353,14 +3355,22 @@ } #endif } else { - PMD_DRV_LOG(DEBUG, "Using %sVector Tx (port %d).", - use_avx2 ? "avx2 " : "", - dev->data->port_id); - dev->tx_pkt_burst = use_avx2 ? - ice_xmit_pkts_vec_avx2 : - ice_xmit_pkts_vec; + if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { + PMD_DRV_LOG(NOTICE, + "Using AVX2 OFFLOAD Vector Tx (port %d).", + dev->data->port_id); + dev->tx_pkt_burst = + ice_xmit_pkts_vec_avx2_offload; + dev->tx_pkt_prepare = ice_prep_pkts; + } else { + PMD_DRV_LOG(DEBUG, "Using %sVector Tx (port %d).", + cap_avx2 ? "avx2 " : "", + dev->data->port_id); + dev->tx_pkt_burst = cap_avx2 ? + ice_xmit_pkts_vec_avx2 : + ice_xmit_pkts_vec; + } } - dev->tx_pkt_prepare = NULL; return; } diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index b29387c..595dc66 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -255,6 +255,8 @@ uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue, uint16_t nb_pkts); uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); +uint16_t ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); uint16_t ice_recv_pkts_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); uint16_t ice_recv_pkts_vec_avx512_offload(void *rx_queue, diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c b/drivers/net/ice/ice_rxtx_vec_avx2.c index 8d4bd6d..b83c1ac 100644 --- a/drivers/net/ice/ice_rxtx_vec_avx2.c +++ b/drivers/net/ice/ice_rxtx_vec_avx2.c @@ -769,30 +769,32 @@ rx_pkts + retval, nb_pkts); } -static inline void +static __rte_always_inline void ice_vtx1(volatile struct ice_tx_desc *txdp, - struct rte_mbuf *pkt, uint64_t flags) + struct rte_mbuf *pkt, uint64_t flags, bool offload) { uint64_t high_qw = (ICE_TX_DESC_DTYPE_DATA | ((uint64_t)flags << ICE_TXD_QW1_CMD_S) | ((uint64_t)pkt->data_len << ICE_TXD_QW1_TX_BUF_SZ_S)); + if (offload) + ice_txd_enable_offload(pkt, &high_qw); __m128i descriptor = _mm_set_epi64x(high_qw, pkt->buf_iova + pkt->data_off); _mm_store_si128((__m128i *)txdp, descriptor); } -static inline void +static __rte_always_inline void ice_vtx(volatile struct ice_tx_desc *txdp, - struct rte_mbuf **pkt, uint16_t nb_pkts, uint64_t flags) + struct rte_mbuf **pkt, uint16_t nb_pkts, uint64_t flags, bool offload) { const uint64_t hi_qw_tmpl = (ICE_TX_DESC_DTYPE_DATA | ((uint64_t)flags << ICE_TXD_QW1_CMD_S)); /* if unaligned on 32-bit boundary, do one to align */ if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) { - ice_vtx1(txdp, *pkt, flags); + ice_vtx1(txdp, *pkt, flags, offload); nb_pkts--, txdp++, pkt++; } @@ -802,18 +804,26 @@ hi_qw_tmpl | ((uint64_t)pkt[3]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[3], &hi_qw3); uint64_t hi_qw2 = hi_qw_tmpl | ((uint64_t)pkt[2]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[2], &hi_qw2); uint64_t hi_qw1 = hi_qw_tmpl | ((uint64_t)pkt[1]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[1], &hi_qw1); uint64_t hi_qw0 = hi_qw_tmpl | ((uint64_t)pkt[0]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[0], &hi_qw0); __m256i desc2_3 = _mm256_set_epi64x @@ -833,14 +843,14 @@ /* do any last ones */ while (nb_pkts) { - ice_vtx1(txdp, *pkt, flags); + ice_vtx1(txdp, *pkt, flags, offload); txdp++, pkt++, nb_pkts--; } } -static inline uint16_t +static __rte_always_inline uint16_t ice_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, - uint16_t nb_pkts) + uint16_t nb_pkts, bool offload) { struct ice_tx_queue *txq = (struct ice_tx_queue *)tx_queue; volatile struct ice_tx_desc *txdp; @@ -869,11 +879,11 @@ if (nb_commit >= n) { ice_tx_backlog_entry(txep, tx_pkts, n); - ice_vtx(txdp, tx_pkts, n - 1, flags); + ice_vtx(txdp, tx_pkts, n - 1, flags, offload); tx_pkts += (n - 1); txdp += (n - 1); - ice_vtx1(txdp, *tx_pkts++, rs); + ice_vtx1(txdp, *tx_pkts++, rs, offload); nb_commit = (uint16_t)(nb_commit - n); @@ -887,7 +897,7 @@ ice_tx_backlog_entry(txep, tx_pkts, nb_commit); - ice_vtx(txdp, tx_pkts, nb_commit, flags); + ice_vtx(txdp, tx_pkts, nb_commit, flags, offload); tx_id = (uint16_t)(tx_id + nb_commit); if (tx_id > txq->tx_next_rs) { @@ -905,9 +915,9 @@ return nb_pkts; } -uint16_t -ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, - uint16_t nb_pkts) +static __rte_always_inline uint16_t +ice_xmit_pkts_vec_avx2_common(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts, bool offload) { uint16_t nb_tx = 0; struct ice_tx_queue *txq = (struct ice_tx_queue *)tx_queue; @@ -917,7 +927,7 @@ num = (uint16_t)RTE_MIN(nb_pkts, txq->tx_rs_thresh); ret = ice_xmit_fixed_burst_vec_avx2(tx_queue, &tx_pkts[nb_tx], - num); + num, offload); nb_tx += ret; nb_pkts -= ret; if (ret < num) @@ -926,3 +936,17 @@ return nb_tx; } + +uint16_t +ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + return ice_xmit_pkts_vec_avx2_common(tx_queue, tx_pkts, nb_pkts, false); +} + +uint16_t +ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + return ice_xmit_pkts_vec_avx2_common(tx_queue, tx_pkts, nb_pkts, true); +} -- 1.8.3.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v2 2/2] net/ice: add Rx AVX2 offload path 2021-06-28 7:53 ` [dpdk-dev] [PATCH v2 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu 2021-06-28 7:53 ` [dpdk-dev] [PATCH v2 1/2] net/ice: add Tx AVX2 offload path Wenzhuo Lu @ 2021-06-28 7:53 ` Wenzhuo Lu 1 sibling, 0 replies; 12+ messages in thread From: Wenzhuo Lu @ 2021-06-28 7:53 UTC (permalink / raw) To: dev; +Cc: Wenzhuo Lu Add a specific path for RX AVX2. In this path, support the HW offload features, like, checksum, VLAN stripping, RSS hash. This path is chosen automatically according to the configuration. 'inline' is used, then the duplicate code is generated by the compiler. Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com> --- doc/guides/rel_notes/release_21_08.rst | 6 + drivers/net/ice/ice_rxtx.c | 50 ++++-- drivers/net/ice/ice_rxtx.h | 5 + drivers/net/ice/ice_rxtx_vec_avx2.c | 296 +++++++++++++++++++-------------- 4 files changed, 217 insertions(+), 140 deletions(-) diff --git a/doc/guides/rel_notes/release_21_08.rst b/doc/guides/rel_notes/release_21_08.rst index a6ecfdf..203b772 100644 --- a/doc/guides/rel_notes/release_21_08.rst +++ b/doc/guides/rel_notes/release_21_08.rst @@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated Intel ice driver.** + + * In AVX2 code, added the new RX and TX paths to use the HW offload + features. When the HW offload features are configured to be used, the + offload paths are chosen automatically. In parallel the support for HW + offload features was removed from the legacy AVX2 paths. Removed Items ------------- diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 5d7ca60..27fd248 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -1999,7 +1999,9 @@ dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx512_offload || #endif dev->rx_pkt_burst == ice_recv_pkts_vec_avx2 || - dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2) + dev->rx_pkt_burst == ice_recv_pkts_vec_avx2_offload || + dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2 || + dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2_offload) return ptypes; #endif @@ -3058,7 +3060,7 @@ #ifdef RTE_ARCH_X86 struct ice_rx_queue *rxq; int i; - int rx_check_ret; + int rx_check_ret = -1; bool use_avx512 = false; bool use_avx2 = false; @@ -3113,14 +3115,25 @@ ice_recv_scattered_pkts_vec_avx512; } #endif + } else if (use_avx2) { + if (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { + PMD_DRV_LOG(NOTICE, + "Using AVX2 OFFLOAD Vector Scattered Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_scattered_pkts_vec_avx2_offload; + } else { + PMD_DRV_LOG(NOTICE, + "Using AVX2 Vector Scattered Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_scattered_pkts_vec_avx2; + } } else { PMD_DRV_LOG(DEBUG, - "Using %sVector Scattered Rx (port %d).", - use_avx2 ? "avx2 " : "", + "Using Vector Scattered Rx (port %d).", dev->data->port_id); - dev->rx_pkt_burst = use_avx2 ? - ice_recv_scattered_pkts_vec_avx2 : - ice_recv_scattered_pkts_vec; + dev->rx_pkt_burst = ice_recv_scattered_pkts_vec; } } else { if (use_avx512) { @@ -3139,14 +3152,25 @@ ice_recv_pkts_vec_avx512; } #endif + } else if (use_avx2) { + if (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { + PMD_DRV_LOG(NOTICE, + "Using AVX2 OFFLOAD Vector Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_pkts_vec_avx2_offload; + } else { + PMD_DRV_LOG(NOTICE, + "Using AVX2 Vector Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_pkts_vec_avx2; + } } else { PMD_DRV_LOG(DEBUG, - "Using %sVector Rx (port %d).", - use_avx2 ? "avx2 " : "", + "Using Vector Rx (port %d).", dev->data->port_id); - dev->rx_pkt_burst = use_avx2 ? - ice_recv_pkts_vec_avx2 : - ice_recv_pkts_vec; + dev->rx_pkt_burst = ice_recv_pkts_vec; } } return; @@ -3191,7 +3215,9 @@ { ice_recv_pkts_vec_avx512_offload, "Offload Vector AVX512" }, #endif { ice_recv_scattered_pkts_vec_avx2, "Vector AVX2 Scattered" }, + { ice_recv_scattered_pkts_vec_avx2_offload, "Offload Vector AVX2 Scattered" }, { ice_recv_pkts_vec_avx2, "Vector AVX2" }, + { ice_recv_pkts_vec_avx2_offload, "Offload Vector AVX2" }, { ice_recv_scattered_pkts_vec, "Vector SSE Scattered" }, { ice_recv_pkts_vec, "Vector SSE" }, #endif diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index 595dc66..bd28a68 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -250,9 +250,14 @@ uint16_t ice_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); uint16_t ice_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); +uint16_t ice_recv_pkts_vec_avx2_offload(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts); uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); +uint16_t ice_recv_scattered_pkts_vec_avx2_offload(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts); uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); uint16_t ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts, diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c b/drivers/net/ice/ice_rxtx_vec_avx2.c index b83c1ac..2841597 100644 --- a/drivers/net/ice/ice_rxtx_vec_avx2.c +++ b/drivers/net/ice/ice_rxtx_vec_avx2.c @@ -16,7 +16,7 @@ return ice_rxq_rearm_common(rxq, false); } -static inline __m256i +static __rte_always_inline __m256i ice_flex_rxd_to_fdir_flags_vec_avx2(const __m256i fdir_id0_7) { #define FDID_MIS_MAGIC 0xFFFFFFFF @@ -35,9 +35,10 @@ return fdir_flags; } -static inline uint16_t +static __rte_always_inline uint16_t _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts, uint8_t *split_packet) + uint16_t nb_pkts, uint8_t *split_packet, + bool offload) { #define ICE_DESCS_PER_LOOP_AVX 8 @@ -385,39 +386,43 @@ */ __m256i status0_7 = _mm256_unpacklo_epi64(status4_7, status0_3); + __m256i mbuf_flags = _mm256_set1_epi32(0); - /* now do flag manipulation */ + if (offload) { + /* now do flag manipulation */ - /* get only flag/error bits we want */ - const __m256i flag_bits = - _mm256_and_si256(status0_7, flags_mask); - /** - * l3_l4_error flags, shuffle, then shift to correct adjustment - * of flags in flags_shuf, and finally mask out extra bits - */ - __m256i l3_l4_flags = _mm256_shuffle_epi8(l3_l4_flags_shuf, - _mm256_srli_epi32(flag_bits, 4)); - l3_l4_flags = _mm256_slli_epi32(l3_l4_flags, 1); - - __m256i l4_outer_mask = _mm256_set1_epi32(0x6); - __m256i l4_outer_flags = - _mm256_and_si256(l3_l4_flags, l4_outer_mask); - l4_outer_flags = _mm256_slli_epi32(l4_outer_flags, 20); - - __m256i l3_l4_mask = _mm256_set1_epi32(~0x6); - l3_l4_flags = _mm256_and_si256(l3_l4_flags, l3_l4_mask); - l3_l4_flags = _mm256_or_si256(l3_l4_flags, l4_outer_flags); - l3_l4_flags = _mm256_and_si256(l3_l4_flags, cksum_mask); - /* set rss and vlan flags */ - const __m256i rss_vlan_flag_bits = - _mm256_srli_epi32(flag_bits, 12); - const __m256i rss_vlan_flags = - _mm256_shuffle_epi8(rss_vlan_flags_shuf, - rss_vlan_flag_bits); - - /* merge flags */ - __m256i mbuf_flags = _mm256_or_si256(l3_l4_flags, - rss_vlan_flags); + /* get only flag/error bits we want */ + const __m256i flag_bits = + _mm256_and_si256(status0_7, flags_mask); + /** + * l3_l4_error flags, shuffle, then shift to correct adjustment + * of flags in flags_shuf, and finally mask out extra bits + */ + __m256i l3_l4_flags = _mm256_shuffle_epi8(l3_l4_flags_shuf, + _mm256_srli_epi32(flag_bits, 4)); + l3_l4_flags = _mm256_slli_epi32(l3_l4_flags, 1); + + __m256i l4_outer_mask = _mm256_set1_epi32(0x6); + __m256i l4_outer_flags = + _mm256_and_si256(l3_l4_flags, l4_outer_mask); + l4_outer_flags = _mm256_slli_epi32(l4_outer_flags, 20); + + __m256i l3_l4_mask = _mm256_set1_epi32(~0x6); + + l3_l4_flags = _mm256_and_si256(l3_l4_flags, l3_l4_mask); + l3_l4_flags = _mm256_or_si256(l3_l4_flags, l4_outer_flags); + l3_l4_flags = _mm256_and_si256(l3_l4_flags, cksum_mask); + /* set rss and vlan flags */ + const __m256i rss_vlan_flag_bits = + _mm256_srli_epi32(flag_bits, 12); + const __m256i rss_vlan_flags = + _mm256_shuffle_epi8(rss_vlan_flags_shuf, + rss_vlan_flag_bits); + + /* merge flags */ + mbuf_flags = _mm256_or_si256(l3_l4_flags, + rss_vlan_flags); + } if (rxq->fdir_enabled) { const __m256i fdir_id4_7 = @@ -461,95 +466,97 @@ _mm256_extract_epi32(fdir_id0_7, 4); } /* if() on fdir_enabled */ + if (offload) { #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC - /** - * needs to load 2nd 16B of each desc for RSS hash parsing, - * will cause performance drop to get into this context. - */ - if (rxq->vsi->adapter->eth_dev->data->dev_conf.rxmode.offloads & - DEV_RX_OFFLOAD_RSS_HASH) { - /* load bottom half of every 32B desc */ - const __m128i raw_desc_bh7 = - _mm_load_si128 - ((void *)(&rxdp[7].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh6 = - _mm_load_si128 - ((void *)(&rxdp[6].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh5 = - _mm_load_si128 - ((void *)(&rxdp[5].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh4 = - _mm_load_si128 - ((void *)(&rxdp[4].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh3 = - _mm_load_si128 - ((void *)(&rxdp[3].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh2 = - _mm_load_si128 - ((void *)(&rxdp[2].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh1 = - _mm_load_si128 - ((void *)(&rxdp[1].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh0 = - _mm_load_si128 - ((void *)(&rxdp[0].wb.status_error1)); - - __m256i raw_desc_bh6_7 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh6), - raw_desc_bh7, 1); - __m256i raw_desc_bh4_5 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh4), - raw_desc_bh5, 1); - __m256i raw_desc_bh2_3 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh2), - raw_desc_bh3, 1); - __m256i raw_desc_bh0_1 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh0), - raw_desc_bh1, 1); - /** - * to shift the 32b RSS hash value to the - * highest 32b of each 128b before mask + * needs to load 2nd 16B of each desc for RSS hash parsing, + * will cause performance drop to get into this context. */ - __m256i rss_hash6_7 = - _mm256_slli_epi64(raw_desc_bh6_7, 32); - __m256i rss_hash4_5 = - _mm256_slli_epi64(raw_desc_bh4_5, 32); - __m256i rss_hash2_3 = - _mm256_slli_epi64(raw_desc_bh2_3, 32); - __m256i rss_hash0_1 = - _mm256_slli_epi64(raw_desc_bh0_1, 32); - - __m256i rss_hash_msk = - _mm256_set_epi32(0xFFFFFFFF, 0, 0, 0, - 0xFFFFFFFF, 0, 0, 0); - - rss_hash6_7 = _mm256_and_si256 - (rss_hash6_7, rss_hash_msk); - rss_hash4_5 = _mm256_and_si256 - (rss_hash4_5, rss_hash_msk); - rss_hash2_3 = _mm256_and_si256 - (rss_hash2_3, rss_hash_msk); - rss_hash0_1 = _mm256_and_si256 - (rss_hash0_1, rss_hash_msk); - - mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7); - mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5); - mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3); - mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1); - } /* if() on RSS hash parsing */ + if (rxq->vsi->adapter->eth_dev->data->dev_conf.rxmode.offloads & + DEV_RX_OFFLOAD_RSS_HASH) { + /* load bottom half of every 32B desc */ + const __m128i raw_desc_bh7 = + _mm_load_si128 + ((void *)(&rxdp[7].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh6 = + _mm_load_si128 + ((void *)(&rxdp[6].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh5 = + _mm_load_si128 + ((void *)(&rxdp[5].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh4 = + _mm_load_si128 + ((void *)(&rxdp[4].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh3 = + _mm_load_si128 + ((void *)(&rxdp[3].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh2 = + _mm_load_si128 + ((void *)(&rxdp[2].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh1 = + _mm_load_si128 + ((void *)(&rxdp[1].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh0 = + _mm_load_si128 + ((void *)(&rxdp[0].wb.status_error1)); + + __m256i raw_desc_bh6_7 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh6), + raw_desc_bh7, 1); + __m256i raw_desc_bh4_5 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh4), + raw_desc_bh5, 1); + __m256i raw_desc_bh2_3 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh2), + raw_desc_bh3, 1); + __m256i raw_desc_bh0_1 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh0), + raw_desc_bh1, 1); + + /** + * to shift the 32b RSS hash value to the + * highest 32b of each 128b before mask + */ + __m256i rss_hash6_7 = + _mm256_slli_epi64(raw_desc_bh6_7, 32); + __m256i rss_hash4_5 = + _mm256_slli_epi64(raw_desc_bh4_5, 32); + __m256i rss_hash2_3 = + _mm256_slli_epi64(raw_desc_bh2_3, 32); + __m256i rss_hash0_1 = + _mm256_slli_epi64(raw_desc_bh0_1, 32); + + __m256i rss_hash_msk = + _mm256_set_epi32(0xFFFFFFFF, 0, 0, 0, + 0xFFFFFFFF, 0, 0, 0); + + rss_hash6_7 = _mm256_and_si256 + (rss_hash6_7, rss_hash_msk); + rss_hash4_5 = _mm256_and_si256 + (rss_hash4_5, rss_hash_msk); + rss_hash2_3 = _mm256_and_si256 + (rss_hash2_3, rss_hash_msk); + rss_hash0_1 = _mm256_and_si256 + (rss_hash0_1, rss_hash_msk); + + mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7); + mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5); + mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3); + mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1); + } /* if() on RSS hash parsing */ #endif + } /** * At this point, we have the 8 sets of flags in the low 16-bits @@ -701,7 +708,16 @@ ice_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { - return _ice_recv_raw_pkts_vec_avx2(rx_queue, rx_pkts, nb_pkts, NULL); + return _ice_recv_raw_pkts_vec_avx2(rx_queue, rx_pkts, + nb_pkts, NULL, false); +} + +uint16_t +ice_recv_pkts_vec_avx2_offload(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return _ice_recv_raw_pkts_vec_avx2(rx_queue, rx_pkts, + nb_pkts, NULL, true); } /** @@ -709,16 +725,16 @@ * Notice: * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet */ -static uint16_t +static __rte_always_inline uint16_t ice_recv_scattered_burst_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts) + uint16_t nb_pkts, bool offload) { struct ice_rx_queue *rxq = rx_queue; uint8_t split_flags[ICE_VPMD_RX_BURST] = {0}; /* get some new buffers */ uint16_t nb_bufs = _ice_recv_raw_pkts_vec_avx2(rxq, rx_pkts, nb_pkts, - split_flags); + split_flags, offload); if (nb_bufs == 0) return 0; @@ -751,22 +767,46 @@ * Notice: * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet */ -uint16_t -ice_recv_scattered_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts) +static __rte_always_inline uint16_t +ice_recv_scattered_pkts_vec_avx2_common(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts, + bool offload) { uint16_t retval = 0; while (nb_pkts > ICE_VPMD_RX_BURST) { uint16_t burst = ice_recv_scattered_burst_vec_avx2(rx_queue, - rx_pkts + retval, ICE_VPMD_RX_BURST); + rx_pkts + retval, ICE_VPMD_RX_BURST, offload); retval += burst; nb_pkts -= burst; if (burst < ICE_VPMD_RX_BURST) return retval; } return retval + ice_recv_scattered_burst_vec_avx2(rx_queue, - rx_pkts + retval, nb_pkts); + rx_pkts + retval, nb_pkts, offload); +} + +uint16_t +ice_recv_scattered_pkts_vec_avx2(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return ice_recv_scattered_pkts_vec_avx2_common(rx_queue, + rx_pkts, + nb_pkts, + false); +} + +uint16_t +ice_recv_scattered_pkts_vec_avx2_offload(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return ice_recv_scattered_pkts_vec_avx2_common(rx_queue, + rx_pkts, + nb_pkts, + true); } static __rte_always_inline void -- 1.8.3.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 2021-06-02 2:21 [dpdk-dev] [PATCH 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu ` (2 preceding siblings ...) 2021-06-28 7:53 ` [dpdk-dev] [PATCH v2 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu @ 2021-06-29 2:29 ` Wenzhuo Lu 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 1/2] net/ice: add Tx AVX2 offload path Wenzhuo Lu ` (2 more replies) 3 siblings, 3 replies; 12+ messages in thread From: Wenzhuo Lu @ 2021-06-29 2:29 UTC (permalink / raw) To: dev; +Cc: Wenzhuo Lu Add specific paths for RX/TX AVX2, called offload paths. In these paths, support the HW offload features, like, checksum, VLAN, RSS offload. These paths are chosen automatically according to the configuration. v2: - fdir should be supported by offload and normal path. v3: - rebased on the newest code. Wenzhuo Lu (2): net/ice: add Tx AVX2 offload path net/ice: add Rx AVX2 offload path doc/guides/rel_notes/release_21_08.rst | 6 + drivers/net/ice/ice_rxtx.c | 87 +++++--- drivers/net/ice/ice_rxtx.h | 7 + drivers/net/ice/ice_rxtx_vec_avx2.c | 350 +++++++++++++++++++-------------- 4 files changed, 282 insertions(+), 168 deletions(-) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v3 1/2] net/ice: add Tx AVX2 offload path 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu @ 2021-06-29 2:29 ` Wenzhuo Lu 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 2/2] net/ice: add Rx " Wenzhuo Lu 2021-07-02 8:03 ` [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 Rong, Leyi 2 siblings, 0 replies; 12+ messages in thread From: Wenzhuo Lu @ 2021-06-29 2:29 UTC (permalink / raw) To: dev; +Cc: Wenzhuo Lu Add a specific path for TX AVX2. In this path, support the HW offload features, like, checksum insertion, VLAN insertion. This path is chosen automatically according to the configuration. 'inline' is used, then the duplicate code is generated by the compiler. Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com> --- drivers/net/ice/ice_rxtx.c | 37 ++++++++++++++++--------- drivers/net/ice/ice_rxtx.h | 2 ++ drivers/net/ice/ice_rxtx_vec_avx2.c | 54 ++++++++++++++++++++++++++----------- 3 files changed, 65 insertions(+), 28 deletions(-) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index fc9bb5a..5419047 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -3288,7 +3288,7 @@ #ifdef RTE_ARCH_X86 struct ice_tx_queue *txq; int i; - int tx_check_ret = 0; + int tx_check_ret = -1; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { ad->tx_use_avx2 = false; @@ -3307,13 +3307,14 @@ PMD_DRV_LOG(NOTICE, "AVX512 is not supported in build env"); #endif - if (!ad->tx_use_avx512 && tx_check_ret == ICE_VECTOR_PATH && - (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 || - rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) && - rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256) + if (!ad->tx_use_avx512 && + (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 || + rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) && + rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256) ad->tx_use_avx2 = true; - if (!ad->tx_use_avx512 && tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) + if (!ad->tx_use_avx2 && !ad->tx_use_avx512 && + tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) ad->tx_vec_allowed = false; if (ad->tx_vec_allowed) { @@ -3331,6 +3332,7 @@ } if (ad->tx_vec_allowed) { + dev->tx_pkt_prepare = NULL; if (ad->tx_use_avx512) { #ifdef CC_AVX512_SUPPORT if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { @@ -3339,6 +3341,7 @@ dev->data->port_id); dev->tx_pkt_burst = ice_xmit_pkts_vec_avx512_offload; + dev->tx_pkt_prepare = ice_prep_pkts; } else { PMD_DRV_LOG(NOTICE, "Using AVX512 Vector Tx (port %d).", @@ -3347,14 +3350,22 @@ } #endif } else { - PMD_DRV_LOG(DEBUG, "Using %sVector Tx (port %d).", - ad->tx_use_avx2 ? "avx2 " : "", - dev->data->port_id); - dev->tx_pkt_burst = ad->tx_use_avx2 ? - ice_xmit_pkts_vec_avx2 : - ice_xmit_pkts_vec; + if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { + PMD_DRV_LOG(NOTICE, + "Using AVX2 OFFLOAD Vector Tx (port %d).", + dev->data->port_id); + dev->tx_pkt_burst = + ice_xmit_pkts_vec_avx2_offload; + dev->tx_pkt_prepare = ice_prep_pkts; + } else { + PMD_DRV_LOG(DEBUG, "Using %sVector Tx (port %d).", + ad->tx_use_avx2 ? "avx2 " : "", + dev->data->port_id); + dev->tx_pkt_burst = ad->tx_use_avx2 ? + ice_xmit_pkts_vec_avx2 : + ice_xmit_pkts_vec; + } } - dev->tx_pkt_prepare = NULL; return; } diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index 86b6f3d..f0536f7 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -255,6 +255,8 @@ uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue, uint16_t nb_pkts); uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); +uint16_t ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); uint16_t ice_recv_pkts_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); uint16_t ice_recv_pkts_vec_avx512_offload(void *rx_queue, diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c b/drivers/net/ice/ice_rxtx_vec_avx2.c index 165bc1b..b72946b 100644 --- a/drivers/net/ice/ice_rxtx_vec_avx2.c +++ b/drivers/net/ice/ice_rxtx_vec_avx2.c @@ -769,30 +769,32 @@ rx_pkts + retval, nb_pkts); } -static inline void +static __rte_always_inline void ice_vtx1(volatile struct ice_tx_desc *txdp, - struct rte_mbuf *pkt, uint64_t flags) + struct rte_mbuf *pkt, uint64_t flags, bool offload) { uint64_t high_qw = (ICE_TX_DESC_DTYPE_DATA | ((uint64_t)flags << ICE_TXD_QW1_CMD_S) | ((uint64_t)pkt->data_len << ICE_TXD_QW1_TX_BUF_SZ_S)); + if (offload) + ice_txd_enable_offload(pkt, &high_qw); __m128i descriptor = _mm_set_epi64x(high_qw, pkt->buf_iova + pkt->data_off); _mm_store_si128((__m128i *)txdp, descriptor); } -static inline void +static __rte_always_inline void ice_vtx(volatile struct ice_tx_desc *txdp, - struct rte_mbuf **pkt, uint16_t nb_pkts, uint64_t flags) + struct rte_mbuf **pkt, uint16_t nb_pkts, uint64_t flags, bool offload) { const uint64_t hi_qw_tmpl = (ICE_TX_DESC_DTYPE_DATA | ((uint64_t)flags << ICE_TXD_QW1_CMD_S)); /* if unaligned on 32-bit boundary, do one to align */ if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) { - ice_vtx1(txdp, *pkt, flags); + ice_vtx1(txdp, *pkt, flags, offload); nb_pkts--, txdp++, pkt++; } @@ -802,18 +804,26 @@ hi_qw_tmpl | ((uint64_t)pkt[3]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[3], &hi_qw3); uint64_t hi_qw2 = hi_qw_tmpl | ((uint64_t)pkt[2]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[2], &hi_qw2); uint64_t hi_qw1 = hi_qw_tmpl | ((uint64_t)pkt[1]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[1], &hi_qw1); uint64_t hi_qw0 = hi_qw_tmpl | ((uint64_t)pkt[0]->data_len << ICE_TXD_QW1_TX_BUF_SZ_S); + if (offload) + ice_txd_enable_offload(pkt[0], &hi_qw0); __m256i desc2_3 = _mm256_set_epi64x @@ -833,14 +843,14 @@ /* do any last ones */ while (nb_pkts) { - ice_vtx1(txdp, *pkt, flags); + ice_vtx1(txdp, *pkt, flags, offload); txdp++, pkt++, nb_pkts--; } } -static inline uint16_t +static __rte_always_inline uint16_t ice_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, - uint16_t nb_pkts) + uint16_t nb_pkts, bool offload) { struct ice_tx_queue *txq = (struct ice_tx_queue *)tx_queue; volatile struct ice_tx_desc *txdp; @@ -869,11 +879,11 @@ if (nb_commit >= n) { ice_tx_backlog_entry(txep, tx_pkts, n); - ice_vtx(txdp, tx_pkts, n - 1, flags); + ice_vtx(txdp, tx_pkts, n - 1, flags, offload); tx_pkts += (n - 1); txdp += (n - 1); - ice_vtx1(txdp, *tx_pkts++, rs); + ice_vtx1(txdp, *tx_pkts++, rs, offload); nb_commit = (uint16_t)(nb_commit - n); @@ -887,7 +897,7 @@ ice_tx_backlog_entry(txep, tx_pkts, nb_commit); - ice_vtx(txdp, tx_pkts, nb_commit, flags); + ice_vtx(txdp, tx_pkts, nb_commit, flags, offload); tx_id = (uint16_t)(tx_id + nb_commit); if (tx_id > txq->tx_next_rs) { @@ -905,9 +915,9 @@ return nb_pkts; } -uint16_t -ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, - uint16_t nb_pkts) +static __rte_always_inline uint16_t +ice_xmit_pkts_vec_avx2_common(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts, bool offload) { uint16_t nb_tx = 0; struct ice_tx_queue *txq = (struct ice_tx_queue *)tx_queue; @@ -917,7 +927,7 @@ num = (uint16_t)RTE_MIN(nb_pkts, txq->tx_rs_thresh); ret = ice_xmit_fixed_burst_vec_avx2(tx_queue, &tx_pkts[nb_tx], - num); + num, offload); nb_tx += ret; nb_pkts -= ret; if (ret < num) @@ -926,3 +936,17 @@ return nb_tx; } + +uint16_t +ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + return ice_xmit_pkts_vec_avx2_common(tx_queue, tx_pkts, nb_pkts, false); +} + +uint16_t +ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + return ice_xmit_pkts_vec_avx2_common(tx_queue, tx_pkts, nb_pkts, true); +} -- 1.8.3.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v3 2/2] net/ice: add Rx AVX2 offload path 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 1/2] net/ice: add Tx AVX2 offload path Wenzhuo Lu @ 2021-06-29 2:29 ` Wenzhuo Lu 2021-07-02 8:03 ` [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 Rong, Leyi 2 siblings, 0 replies; 12+ messages in thread From: Wenzhuo Lu @ 2021-06-29 2:29 UTC (permalink / raw) To: dev; +Cc: Wenzhuo Lu Add a specific path for RX AVX2. In this path, support the HW offload features, like, checksum, VLAN stripping, RSS hash. This path is chosen automatically according to the configuration. 'inline' is used, then the duplicate code is generated by the compiler. Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com> --- doc/guides/rel_notes/release_21_08.rst | 6 + drivers/net/ice/ice_rxtx.c | 50 ++++-- drivers/net/ice/ice_rxtx.h | 5 + drivers/net/ice/ice_rxtx_vec_avx2.c | 296 +++++++++++++++++++-------------- 4 files changed, 217 insertions(+), 140 deletions(-) diff --git a/doc/guides/rel_notes/release_21_08.rst b/doc/guides/rel_notes/release_21_08.rst index a6ecfdf..203b772 100644 --- a/doc/guides/rel_notes/release_21_08.rst +++ b/doc/guides/rel_notes/release_21_08.rst @@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated Intel ice driver.** + + * In AVX2 code, added the new RX and TX paths to use the HW offload + features. When the HW offload features are configured to be used, the + offload paths are chosen automatically. In parallel the support for HW + offload features was removed from the legacy AVX2 paths. Removed Items ------------- diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 5419047..97c3d80 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -1995,7 +1995,9 @@ dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx512_offload || #endif dev->rx_pkt_burst == ice_recv_pkts_vec_avx2 || - dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2) + dev->rx_pkt_burst == ice_recv_pkts_vec_avx2_offload || + dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2 || + dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2_offload) return ptypes; #endif @@ -3052,7 +3054,7 @@ #ifdef RTE_ARCH_X86 struct ice_rx_queue *rxq; int i; - int rx_check_ret = 0; + int rx_check_ret = -1; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { ad->rx_use_avx512 = false; @@ -3107,14 +3109,25 @@ ice_recv_scattered_pkts_vec_avx512; } #endif + } else if (ad->rx_use_avx2) { + if (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { + PMD_DRV_LOG(NOTICE, + "Using AVX2 OFFLOAD Vector Scattered Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_scattered_pkts_vec_avx2_offload; + } else { + PMD_DRV_LOG(NOTICE, + "Using AVX2 Vector Scattered Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_scattered_pkts_vec_avx2; + } } else { PMD_DRV_LOG(DEBUG, - "Using %sVector Scattered Rx (port %d).", - ad->rx_use_avx2 ? "avx2 " : "", + "Using Vector Scattered Rx (port %d).", dev->data->port_id); - dev->rx_pkt_burst = ad->rx_use_avx2 ? - ice_recv_scattered_pkts_vec_avx2 : - ice_recv_scattered_pkts_vec; + dev->rx_pkt_burst = ice_recv_scattered_pkts_vec; } } else { if (ad->rx_use_avx512) { @@ -3133,14 +3146,25 @@ ice_recv_pkts_vec_avx512; } #endif + } else if (ad->rx_use_avx2) { + if (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH) { + PMD_DRV_LOG(NOTICE, + "Using AVX2 OFFLOAD Vector Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_pkts_vec_avx2_offload; + } else { + PMD_DRV_LOG(NOTICE, + "Using AVX2 Vector Rx (port %d).", + dev->data->port_id); + dev->rx_pkt_burst = + ice_recv_pkts_vec_avx2; + } } else { PMD_DRV_LOG(DEBUG, - "Using %sVector Rx (port %d).", - ad->rx_use_avx2 ? "avx2 " : "", + "Using Vector Rx (port %d).", dev->data->port_id); - dev->rx_pkt_burst = ad->rx_use_avx2 ? - ice_recv_pkts_vec_avx2 : - ice_recv_pkts_vec; + dev->rx_pkt_burst = ice_recv_pkts_vec; } } return; @@ -3185,7 +3209,9 @@ { ice_recv_pkts_vec_avx512_offload, "Offload Vector AVX512" }, #endif { ice_recv_scattered_pkts_vec_avx2, "Vector AVX2 Scattered" }, + { ice_recv_scattered_pkts_vec_avx2_offload, "Offload Vector AVX2 Scattered" }, { ice_recv_pkts_vec_avx2, "Vector AVX2" }, + { ice_recv_pkts_vec_avx2_offload, "Offload Vector AVX2" }, { ice_recv_scattered_pkts_vec, "Vector SSE Scattered" }, { ice_recv_pkts_vec, "Vector SSE" }, #endif diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index f0536f7..b10db08 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -250,9 +250,14 @@ uint16_t ice_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); uint16_t ice_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); +uint16_t ice_recv_pkts_vec_avx2_offload(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts); uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); +uint16_t ice_recv_scattered_pkts_vec_avx2_offload(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts); uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); uint16_t ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts, diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c b/drivers/net/ice/ice_rxtx_vec_avx2.c index b72946b..9725ac0 100644 --- a/drivers/net/ice/ice_rxtx_vec_avx2.c +++ b/drivers/net/ice/ice_rxtx_vec_avx2.c @@ -16,7 +16,7 @@ return ice_rxq_rearm_common(rxq, false); } -static inline __m256i +static __rte_always_inline __m256i ice_flex_rxd_to_fdir_flags_vec_avx2(const __m256i fdir_id0_7) { #define FDID_MIS_MAGIC 0xFFFFFFFF @@ -35,9 +35,10 @@ return fdir_flags; } -static inline uint16_t +static __rte_always_inline uint16_t _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts, uint8_t *split_packet) + uint16_t nb_pkts, uint8_t *split_packet, + bool offload) { #define ICE_DESCS_PER_LOOP_AVX 8 @@ -385,39 +386,43 @@ */ __m256i status0_7 = _mm256_unpacklo_epi64(status4_7, status0_3); + __m256i mbuf_flags = _mm256_set1_epi32(0); - /* now do flag manipulation */ + if (offload) { + /* now do flag manipulation */ - /* get only flag/error bits we want */ - const __m256i flag_bits = - _mm256_and_si256(status0_7, flags_mask); - /** - * l3_l4_error flags, shuffle, then shift to correct adjustment - * of flags in flags_shuf, and finally mask out extra bits - */ - __m256i l3_l4_flags = _mm256_shuffle_epi8(l3_l4_flags_shuf, - _mm256_srli_epi32(flag_bits, 4)); - l3_l4_flags = _mm256_slli_epi32(l3_l4_flags, 1); - - __m256i l4_outer_mask = _mm256_set1_epi32(0x6); - __m256i l4_outer_flags = - _mm256_and_si256(l3_l4_flags, l4_outer_mask); - l4_outer_flags = _mm256_slli_epi32(l4_outer_flags, 20); - - __m256i l3_l4_mask = _mm256_set1_epi32(~0x6); - l3_l4_flags = _mm256_and_si256(l3_l4_flags, l3_l4_mask); - l3_l4_flags = _mm256_or_si256(l3_l4_flags, l4_outer_flags); - l3_l4_flags = _mm256_and_si256(l3_l4_flags, cksum_mask); - /* set rss and vlan flags */ - const __m256i rss_vlan_flag_bits = - _mm256_srli_epi32(flag_bits, 12); - const __m256i rss_vlan_flags = - _mm256_shuffle_epi8(rss_vlan_flags_shuf, - rss_vlan_flag_bits); - - /* merge flags */ - __m256i mbuf_flags = _mm256_or_si256(l3_l4_flags, - rss_vlan_flags); + /* get only flag/error bits we want */ + const __m256i flag_bits = + _mm256_and_si256(status0_7, flags_mask); + /** + * l3_l4_error flags, shuffle, then shift to correct adjustment + * of flags in flags_shuf, and finally mask out extra bits + */ + __m256i l3_l4_flags = _mm256_shuffle_epi8(l3_l4_flags_shuf, + _mm256_srli_epi32(flag_bits, 4)); + l3_l4_flags = _mm256_slli_epi32(l3_l4_flags, 1); + + __m256i l4_outer_mask = _mm256_set1_epi32(0x6); + __m256i l4_outer_flags = + _mm256_and_si256(l3_l4_flags, l4_outer_mask); + l4_outer_flags = _mm256_slli_epi32(l4_outer_flags, 20); + + __m256i l3_l4_mask = _mm256_set1_epi32(~0x6); + + l3_l4_flags = _mm256_and_si256(l3_l4_flags, l3_l4_mask); + l3_l4_flags = _mm256_or_si256(l3_l4_flags, l4_outer_flags); + l3_l4_flags = _mm256_and_si256(l3_l4_flags, cksum_mask); + /* set rss and vlan flags */ + const __m256i rss_vlan_flag_bits = + _mm256_srli_epi32(flag_bits, 12); + const __m256i rss_vlan_flags = + _mm256_shuffle_epi8(rss_vlan_flags_shuf, + rss_vlan_flag_bits); + + /* merge flags */ + mbuf_flags = _mm256_or_si256(l3_l4_flags, + rss_vlan_flags); + } if (rxq->fdir_enabled) { const __m256i fdir_id4_7 = @@ -461,95 +466,97 @@ _mm256_extract_epi32(fdir_id0_7, 4); } /* if() on fdir_enabled */ + if (offload) { #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC - /** - * needs to load 2nd 16B of each desc for RSS hash parsing, - * will cause performance drop to get into this context. - */ - if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads & - DEV_RX_OFFLOAD_RSS_HASH) { - /* load bottom half of every 32B desc */ - const __m128i raw_desc_bh7 = - _mm_load_si128 - ((void *)(&rxdp[7].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh6 = - _mm_load_si128 - ((void *)(&rxdp[6].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh5 = - _mm_load_si128 - ((void *)(&rxdp[5].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh4 = - _mm_load_si128 - ((void *)(&rxdp[4].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh3 = - _mm_load_si128 - ((void *)(&rxdp[3].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh2 = - _mm_load_si128 - ((void *)(&rxdp[2].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh1 = - _mm_load_si128 - ((void *)(&rxdp[1].wb.status_error1)); - rte_compiler_barrier(); - const __m128i raw_desc_bh0 = - _mm_load_si128 - ((void *)(&rxdp[0].wb.status_error1)); - - __m256i raw_desc_bh6_7 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh6), - raw_desc_bh7, 1); - __m256i raw_desc_bh4_5 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh4), - raw_desc_bh5, 1); - __m256i raw_desc_bh2_3 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh2), - raw_desc_bh3, 1); - __m256i raw_desc_bh0_1 = - _mm256_inserti128_si256 - (_mm256_castsi128_si256(raw_desc_bh0), - raw_desc_bh1, 1); - /** - * to shift the 32b RSS hash value to the - * highest 32b of each 128b before mask + * needs to load 2nd 16B of each desc for RSS hash parsing, + * will cause performance drop to get into this context. */ - __m256i rss_hash6_7 = - _mm256_slli_epi64(raw_desc_bh6_7, 32); - __m256i rss_hash4_5 = - _mm256_slli_epi64(raw_desc_bh4_5, 32); - __m256i rss_hash2_3 = - _mm256_slli_epi64(raw_desc_bh2_3, 32); - __m256i rss_hash0_1 = - _mm256_slli_epi64(raw_desc_bh0_1, 32); - - __m256i rss_hash_msk = - _mm256_set_epi32(0xFFFFFFFF, 0, 0, 0, - 0xFFFFFFFF, 0, 0, 0); - - rss_hash6_7 = _mm256_and_si256 - (rss_hash6_7, rss_hash_msk); - rss_hash4_5 = _mm256_and_si256 - (rss_hash4_5, rss_hash_msk); - rss_hash2_3 = _mm256_and_si256 - (rss_hash2_3, rss_hash_msk); - rss_hash0_1 = _mm256_and_si256 - (rss_hash0_1, rss_hash_msk); - - mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7); - mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5); - mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3); - mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1); - } /* if() on RSS hash parsing */ + if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads & + DEV_RX_OFFLOAD_RSS_HASH) { + /* load bottom half of every 32B desc */ + const __m128i raw_desc_bh7 = + _mm_load_si128 + ((void *)(&rxdp[7].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh6 = + _mm_load_si128 + ((void *)(&rxdp[6].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh5 = + _mm_load_si128 + ((void *)(&rxdp[5].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh4 = + _mm_load_si128 + ((void *)(&rxdp[4].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh3 = + _mm_load_si128 + ((void *)(&rxdp[3].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh2 = + _mm_load_si128 + ((void *)(&rxdp[2].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh1 = + _mm_load_si128 + ((void *)(&rxdp[1].wb.status_error1)); + rte_compiler_barrier(); + const __m128i raw_desc_bh0 = + _mm_load_si128 + ((void *)(&rxdp[0].wb.status_error1)); + + __m256i raw_desc_bh6_7 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh6), + raw_desc_bh7, 1); + __m256i raw_desc_bh4_5 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh4), + raw_desc_bh5, 1); + __m256i raw_desc_bh2_3 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh2), + raw_desc_bh3, 1); + __m256i raw_desc_bh0_1 = + _mm256_inserti128_si256 + (_mm256_castsi128_si256(raw_desc_bh0), + raw_desc_bh1, 1); + + /** + * to shift the 32b RSS hash value to the + * highest 32b of each 128b before mask + */ + __m256i rss_hash6_7 = + _mm256_slli_epi64(raw_desc_bh6_7, 32); + __m256i rss_hash4_5 = + _mm256_slli_epi64(raw_desc_bh4_5, 32); + __m256i rss_hash2_3 = + _mm256_slli_epi64(raw_desc_bh2_3, 32); + __m256i rss_hash0_1 = + _mm256_slli_epi64(raw_desc_bh0_1, 32); + + __m256i rss_hash_msk = + _mm256_set_epi32(0xFFFFFFFF, 0, 0, 0, + 0xFFFFFFFF, 0, 0, 0); + + rss_hash6_7 = _mm256_and_si256 + (rss_hash6_7, rss_hash_msk); + rss_hash4_5 = _mm256_and_si256 + (rss_hash4_5, rss_hash_msk); + rss_hash2_3 = _mm256_and_si256 + (rss_hash2_3, rss_hash_msk); + rss_hash0_1 = _mm256_and_si256 + (rss_hash0_1, rss_hash_msk); + + mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7); + mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5); + mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3); + mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1); + } /* if() on RSS hash parsing */ #endif + } /** * At this point, we have the 8 sets of flags in the low 16-bits @@ -701,7 +708,16 @@ ice_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { - return _ice_recv_raw_pkts_vec_avx2(rx_queue, rx_pkts, nb_pkts, NULL); + return _ice_recv_raw_pkts_vec_avx2(rx_queue, rx_pkts, + nb_pkts, NULL, false); +} + +uint16_t +ice_recv_pkts_vec_avx2_offload(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return _ice_recv_raw_pkts_vec_avx2(rx_queue, rx_pkts, + nb_pkts, NULL, true); } /** @@ -709,16 +725,16 @@ * Notice: * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet */ -static uint16_t +static __rte_always_inline uint16_t ice_recv_scattered_burst_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts) + uint16_t nb_pkts, bool offload) { struct ice_rx_queue *rxq = rx_queue; uint8_t split_flags[ICE_VPMD_RX_BURST] = {0}; /* get some new buffers */ uint16_t nb_bufs = _ice_recv_raw_pkts_vec_avx2(rxq, rx_pkts, nb_pkts, - split_flags); + split_flags, offload); if (nb_bufs == 0) return 0; @@ -751,22 +767,46 @@ * Notice: * - nb_pkts < ICE_DESCS_PER_LOOP, just return no packet */ -uint16_t -ice_recv_scattered_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts) +static __rte_always_inline uint16_t +ice_recv_scattered_pkts_vec_avx2_common(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts, + bool offload) { uint16_t retval = 0; while (nb_pkts > ICE_VPMD_RX_BURST) { uint16_t burst = ice_recv_scattered_burst_vec_avx2(rx_queue, - rx_pkts + retval, ICE_VPMD_RX_BURST); + rx_pkts + retval, ICE_VPMD_RX_BURST, offload); retval += burst; nb_pkts -= burst; if (burst < ICE_VPMD_RX_BURST) return retval; } return retval + ice_recv_scattered_burst_vec_avx2(rx_queue, - rx_pkts + retval, nb_pkts); + rx_pkts + retval, nb_pkts, offload); +} + +uint16_t +ice_recv_scattered_pkts_vec_avx2(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return ice_recv_scattered_pkts_vec_avx2_common(rx_queue, + rx_pkts, + nb_pkts, + false); +} + +uint16_t +ice_recv_scattered_pkts_vec_avx2_offload(void *rx_queue, + struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return ice_recv_scattered_pkts_vec_avx2_common(rx_queue, + rx_pkts, + nb_pkts, + true); } static __rte_always_inline void -- 1.8.3.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 1/2] net/ice: add Tx AVX2 offload path Wenzhuo Lu 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 2/2] net/ice: add Rx " Wenzhuo Lu @ 2021-07-02 8:03 ` Rong, Leyi 2021-07-06 2:57 ` Zhang, Qi Z 2 siblings, 1 reply; 12+ messages in thread From: Rong, Leyi @ 2021-07-02 8:03 UTC (permalink / raw) To: Lu, Wenzhuo, dev; +Cc: Lu, Wenzhuo, Zhang, Qi Z > -----Original Message----- > From: dev <dev-bounces@dpdk.org> On Behalf Of Wenzhuo Lu > Sent: Tuesday, June 29, 2021 10:29 AM > To: dev@dpdk.org > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com> > Subject: [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 > > Add specific paths for RX/TX AVX2, called offload paths. > In these paths, support the HW offload features, like, checksum, VLAN, RSS > offload. > These paths are chosen automatically according to the configuration. > > v2: > - fdir should be supported by offload and normal path. > > v3: > - rebased on the newest code. > > Wenzhuo Lu (2): > net/ice: add Tx AVX2 offload path > net/ice: add Rx AVX2 offload path > > doc/guides/rel_notes/release_21_08.rst | 6 + > drivers/net/ice/ice_rxtx.c | 87 +++++--- > drivers/net/ice/ice_rxtx.h | 7 + > drivers/net/ice/ice_rxtx_vec_avx2.c | 350 +++++++++++++++++++-------------- > 4 files changed, 282 insertions(+), 168 deletions(-) > > -- > 1.8.3.1 Acked-by: Leyi Rong <leyi.rong@intel.com> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 2021-07-02 8:03 ` [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 Rong, Leyi @ 2021-07-06 2:57 ` Zhang, Qi Z 2021-07-06 18:39 ` Thomas Monjalon 0 siblings, 1 reply; 12+ messages in thread From: Zhang, Qi Z @ 2021-07-06 2:57 UTC (permalink / raw) To: Rong, Leyi, Lu, Wenzhuo, dev; +Cc: Lu, Wenzhuo > -----Original Message----- > From: Rong, Leyi <leyi.rong@intel.com> > Sent: Friday, July 2, 2021 4:04 PM > To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; dev@dpdk.org > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com> > Subject: RE: [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 > > > > -----Original Message----- > > From: dev <dev-bounces@dpdk.org> On Behalf Of Wenzhuo Lu > > Sent: Tuesday, June 29, 2021 10:29 AM > > To: dev@dpdk.org > > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com> > > Subject: [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE > > AVX2 > > > > Add specific paths for RX/TX AVX2, called offload paths. > > In these paths, support the HW offload features, like, checksum, VLAN, > > RSS offload. > > These paths are chosen automatically according to the configuration. > > > > v2: > > - fdir should be supported by offload and normal path. > > > > v3: > > - rebased on the newest code. > > > > Wenzhuo Lu (2): > > net/ice: add Tx AVX2 offload path > > net/ice: add Rx AVX2 offload path > > > > doc/guides/rel_notes/release_21_08.rst | 6 + > > drivers/net/ice/ice_rxtx.c | 87 +++++--- > > drivers/net/ice/ice_rxtx.h | 7 + > > drivers/net/ice/ice_rxtx_vec_avx2.c | 350 > +++++++++++++++++++-------------- > > 4 files changed, 282 insertions(+), 168 deletions(-) > > > > -- > > 1.8.3.1 > > Acked-by: Leyi Rong <leyi.rong@intel.com> Applied to dpdk-next-net-intel. Thanks Qi ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 2021-07-06 2:57 ` Zhang, Qi Z @ 2021-07-06 18:39 ` Thomas Monjalon 0 siblings, 0 replies; 12+ messages in thread From: Thomas Monjalon @ 2021-07-06 18:39 UTC (permalink / raw) To: Zhang, Qi Z; +Cc: Rong, Leyi, Lu, Wenzhuo, dev, ferruh.yigit 06/07/2021 04:57, Zhang, Qi Z: > > Acked-by: Leyi Rong <leyi.rong@intel.com> > > Applied to dpdk-next-net-intel. During your copy/paste of the ack, you transformed it into Acked-by: Reyi Rong <reyi.rong@intel.com> and also Acked-by: Leyi Rong <reyi.rong@intel.com> I fix it to Acked-by: Leyi Rong <leyi.rong@intel.com> as original above. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-07-06 18:39 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-06-02 2:21 [dpdk-dev] [PATCH 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu 2021-06-02 2:21 ` [dpdk-dev] [PATCH 1/2] net/ice: add Tx AVX2 offload path Wenzhuo Lu 2021-06-02 2:21 ` [dpdk-dev] [PATCH 2/2] net/ice: add Rx " Wenzhuo Lu 2021-06-28 7:53 ` [dpdk-dev] [PATCH v2 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu 2021-06-28 7:53 ` [dpdk-dev] [PATCH v2 1/2] net/ice: add Tx AVX2 offload path Wenzhuo Lu 2021-06-28 7:53 ` [dpdk-dev] [PATCH v2 2/2] net/ice: add Rx " Wenzhuo Lu 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 Wenzhuo Lu 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 1/2] net/ice: add Tx AVX2 offload path Wenzhuo Lu 2021-06-29 2:29 ` [dpdk-dev] [PATCH v3 2/2] net/ice: add Rx " Wenzhuo Lu 2021-07-02 8:03 ` [dpdk-dev] [PATCH v3 0/2] add Rx/Tx offload paths for ICE AVX2 Rong, Leyi 2021-07-06 2:57 ` Zhang, Qi Z 2021-07-06 18:39 ` Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).