idpf and cpfl rx path selection simplification
cover idpf and cpfl rx path selection simplification
This series refactors the vector capability detection and Rx path selection code in the idpf and cpfl PMDs to use the common functions provided in drivers/net/intel/common/rx.h.
Ciara Loftus (4):
net/idpf: use the new common vector capability function net/idpf: use the common Rx path selection infrastructure net/cpfl: use the new common vector capability function net/cpfl: use the common Rx path selection infrastructure
drivers/net/intel/common/rx.h | 5 + drivers/net/intel/cpfl/cpfl_rxtx.c | 143 +++++------------- drivers/net/intel/cpfl/cpfl_rxtx_vec_common.h | 20 +++ drivers/net/intel/idpf/idpf_common_device.h | 17 ++- drivers/net/intel/idpf/idpf_common_rxtx.c | 24 +++ drivers/net/intel/idpf/idpf_common_rxtx.h | 12 ++ drivers/net/intel/idpf/idpf_ethdev.c | 2 + drivers/net/intel/idpf/idpf_rxtx.c | 141 +++++------------ drivers/net/intel/idpf/idpf_rxtx_vec_common.h | 19 +++ 9 files changed, 167 insertions(+), 216 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/4 net/idpf: use the new common vector capability function
Use the new function for determining the maximum simd bitwidth in the idpf driver. An additional check is required for the AVX512DQ flag which is not performed in the common function. Since no other drivers require this flag, the check will remain outside of the common function.
--- drivers/net/intel/idpf/idpf_rxtx.c | 50 ++++++------------- drivers/net/intel/idpf/idpf_rxtx_vec_common.h | 19 +++++++ 2 files changed, 33 insertions(+), 36 deletions(-)
drivers/net/intel/idpf/idpf_rxtx.c +14 -36
@@ -762,26 +762,13 @@ idpf_set_rx_function(struct rte_eth_dev *dev)struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 struct idpf_rx_queue *rxq; +enum rte_vect_max_simd rx_simd_width =RTE_VECT_SIMD_DISABLED ;int i;if (idpf_rx_vec_dev_check_default (dev) ==IDPF_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { vport->rx_vec_allowed = true; - -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 && -rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) - vport->rx_use_avx2 = true; - - if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) -#ifdef CC_AVX512_SUPPORT -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512DQ )) - vport->rx_use_avx512 = true; -#else -PMD_DRV_LOG (NOTICE , -"AVX512 is not supported in build env" ); -#endif /* CC_AVX512_SUPPORT */ + rx_simd_width =idpf_get_max_simd_bitwidth (); }else { vport->rx_vec_allowed = false; }
@@ -795,7 +782,7 @@ idpf_set_rx_function(struct rte_eth_dev *dev) (void )idpf_qc_splitq_rx_vec_setup (rxq); }#ifdef CC_AVX512_SUPPORT -if (vport->rx_use_avx512) { +if (rx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Split AVX512 Vector Rx (port %d)." , dev->data->port_id);
@@ -815,7 +802,7 @@ idpf_set_rx_function(struct rte_eth_dev *dev) (void )idpf_qc_singleq_rx_vec_setup (rxq); }#ifdef CC_AVX512_SUPPORT -if (vport->rx_use_avx512) { +if (rx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX512 Vector Rx (port %d)." , dev->data->port_id);
@@ -823,7 +810,7 @@ idpf_set_rx_function(struct rte_eth_dev *dev) return; }#endif /* CC_AVX512_SUPPORT */ -if (vport->rx_use_avx2) { +if (rx_simd_width ==RTE_VECT_SIMD_256 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX2 Vector Rx (port %d)." , dev->data->port_id);
@@ -871,6 +858,7 @@ idpf_set_tx_function(struct rte_eth_dev *dev) {struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 +enum rte_vect_max_simd tx_simd_width =RTE_VECT_SIMD_DISABLED ;#ifdef CC_AVX512_SUPPORT struct ci_tx_queue *txq;int i;
@@ -879,22 +867,12 @@ idpf_set_tx_function(struct rte_eth_dev *dev)if (idpf_tx_vec_dev_check_default (dev) ==IDPF_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { vport->tx_vec_allowed = true; - -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 && -rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) - vport->tx_use_avx2 = true; - - if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) + tx_simd_width =idpf_get_max_simd_bitwidth ();#ifdef CC_AVX512_SUPPORT - { -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 ) - vport->tx_use_avx512 = true; -if (vport->tx_use_avx512) { -for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; -idpf_qc_tx_vec_avx512_setup (txq); - } +if (tx_simd_width ==RTE_VECT_SIMD_512 ) { +for (i =0 ; i < dev->data->nb_tx_queues; i++) { + txq = dev->data->tx_queues[i]; +idpf_qc_tx_vec_avx512_setup (txq); } }#else
@@ -910,7 +888,7 @@ idpf_set_tx_function(struct rte_eth_dev *dev)if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) {if (vport->tx_vec_allowed) {#ifdef CC_AVX512_SUPPORT -if (vport->tx_use_avx512) { +if (tx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Split AVX512 Vector Tx (port %d)." , dev->data->port_id);
@@ -928,7 +906,7 @@ idpf_set_tx_function(struct rte_eth_dev *dev) }else {if (vport->tx_vec_allowed) {#ifdef CC_AVX512_SUPPORT -if (vport->tx_use_avx512) { +if (tx_simd_width ==RTE_VECT_SIMD_512 ) {for (i =0 ; i < dev->data->nb_tx_queues; i++) { txq = dev->data->tx_queues[i];if (txq ==NULL )
@@ -943,7 +921,7 @@ idpf_set_tx_function(struct rte_eth_dev *dev) return; }#endif /* CC_AVX512_SUPPORT */ -if (vport->tx_use_avx2) { +if (tx_simd_width ==RTE_VECT_SIMD_256 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX2 Vector Tx (port %d)." , dev->data->port_id);
drivers/net/intel/idpf/idpf_rxtx_vec_common.h +19 -0
@@ -11,6 +11,9 @@#include "idpf_ethdev.h" #include "idpf_rxtx.h" #include "../common/rx.h" +#ifdef RTE_ARCH_X86 +#include "../common/rx_vec_x86.h" +#endif #define IDPF_SCALAR_PATH 0#define IDPF_VECTOR_PATH 1
@@ -129,4 +132,20 @@ idpf_tx_vec_dev_check_default(struct rte_eth_dev *dev) return IDPF_VECTOR_PATH; } +#ifdef RTE_ARCH_X86 +static inline enum rte_vect_max_simd +idpf_get_max_simd_bitwidth (void ) +{ +if (rte_vect_get_max_simd_bitwidth () ==512 && +rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512DQ ) ==0 ) { +if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 )) +return RTE_VECT_SIMD_256 ; +else +return RTE_VECT_SIMD_DISABLED ; + } + +return ci_get_x86_max_simd_bitwidth (); +} +#endif +#endif /*_IDPF_RXTX_VEC_COMMON_H_*/
Signature · 1 line
2.34.1
Re: [PATCH 1/4] net/idpf: use the new common vector capability function
Quoted 5 lines · Ciara Loftus
Use the new function for determining the maximum simd bitwidth in the idpf driver. An additional check is required for the AVX512DQ flag which is not performed in the common function. Since no other drivers require this flag, the check will remain outside of the common function.
DQ can just be checked in the common function too. It was introduced the same time as AVX-512VL and BW (see [1]). There is no need for special-case handling of it.
/Bruce
PATCH 2/4 net/idpf: use the common Rx path selection infrastructure
In reply to Ciara LoftusUpdate the common rx path selection infrastructure to include the feature "single queue" which is relevant for the idpf and cpfl drivers. Replace the existing complicated logic in the idpf driver with the use of the common function.
--- drivers/net/intel/common/rx.h | 5 + drivers/net/intel/idpf/idpf_common_device.h | 12 +++ drivers/net/intel/idpf/idpf_common_rxtx.c | 24 +++++ drivers/net/intel/idpf/idpf_common_rxtx.h | 12 +++ drivers/net/intel/idpf/idpf_ethdev.c | 2 + drivers/net/intel/idpf/idpf_rxtx.c | 103 ++++++-------------- 6 files changed, 83 insertions(+), 75 deletions(-)
drivers/net/intel/common/rx.h +5 -0
@@ -131,6 +131,7 @@ struct ci_rx_path_features_extra {bool flex_desc;bool bulk_alloc;bool disabled; +bool single_queue; };struct ci_rx_path_features {
@@ -278,6 +279,10 @@ ci_rx_path_select(struct ci_rx_path_features req_features,if (path_features->extra.flex_desc != req_features.extra.flex_desc)continue ; +/* If requested, ensure the path supports single queue RX. */ +if (path_features->extra.single_queue != req_features.extra.single_queue) +continue ; +/* If requested, ensure the path supports scattered RX. */ if (path_features->extra.scattered != req_features.extra.scattered)continue ;
drivers/net/intel/idpf/idpf_common_device.h +12 -0
@@ -44,6 +44,16 @@ (sizeof (struct virtchnl2_ptype ) + \ (((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0]))) +enum idpf_rx_func_type { +IDPF_RX_DEFAULT , +IDPF_RX_SINGLEQ , +IDPF_RX_SINGLEQ_SCATTERED , +IDPF_RX_SINGLEQ_AVX2 , +IDPF_RX_AVX512 , +IDPF_RX_SINGLQ_AVX512 , +IDPF_RX_MAX +}; +struct idpf_adapter {struct idpf_hw hw;struct virtchnl2_version_info virtchnl_version;
@@ -59,6 +69,8 @@ struct idpf_adapter {/* For timestamp */ uint64_t time_hw; + +enum idpf_rx_func_type rx_func_type; };struct idpf_chunks_info {
drivers/net/intel/idpf/idpf_common_rxtx.c +24 -0
@@ -7,6 +7,8 @@#include <rte_errno.h> #include "idpf_common_rxtx.h" +#include "idpf_common_device.h" +#include "../common/rx.h" int idpf_timestamp_dynfield_offset =-1 ;uint64_t idpf_timestamp_dynflag;
@@ -1622,3 +1624,25 @@ idpf_qc_splitq_rx_vec_setup(struct idpf_rx_queue *rxq) rxq->bufq2->idpf_ops = &def_rx_ops_vec;return idpf_rxq_vec_setup_default (rxq->bufq2); } + +RTE_EXPORT_INTERNAL_SYMBOL (idpf_rx_path_infos) +const struct ci_rx_path_info idpf_rx_path_infos[] = { + [IDPF_RX_DEFAULT ] = {idpf_dp_splitq_recv_pkts,"Scalar Split" , + {IDPF_RX_SCALAR_OFFLOADS ,RTE_VECT_SIMD_DISABLED }}, + [IDPF_RX_SINGLEQ ] = {idpf_dp_singleq_recv_pkts,"Scalar Single Queue" , + {IDPF_RX_SCALAR_OFFLOADS ,RTE_VECT_SIMD_DISABLED , {.single_queue = true}}}, + [IDPF_RX_SINGLEQ_SCATTERED ] = { + idpf_dp_singleq_recv_scatter_pkts,"Scalar Single Queue Scattered" , + {IDPF_RX_SCALAR_OFFLOADS ,RTE_VECT_SIMD_DISABLED , + {.scattered = true, .single_queue = true}}}, +#ifdef RTE_ARCH_X86 + [IDPF_RX_SINGLEQ_AVX2] = {idpf_dp_singleq_recv_pkts_avx2, "AVX2 Single Queue", + {IDPF_RX_VECTOR_OFFLOADS ,RTE_VECT_SIMD_256 , {.single_queue = true}}}, +#ifdef CC_AVX512_SUPPORT + [IDPF_RX_AVX512] = {idpf_dp_splitq_recv_pkts_avx512, "AVX-512 Split", + {IDPF_RX_VECTOR_OFFLOADS ,RTE_VECT_SIMD_512 }}, + [IDPF_RX_SINGLQ_AVX512 ] = {idpf_dp_singleq_recv_pkts_avx512,"AVX-512 Single Queue" , + {IDPF_RX_VECTOR_OFFLOADS ,RTE_VECT_SIMD_512 , {.single_queue = true}}}, +#endif /* CC_AVX512_SUPPORT */ +#endif /* RTE_ARCH_X86 */ +};
drivers/net/intel/idpf/idpf_common_rxtx.h +12 -0
@@ -11,6 +11,7 @@#include "idpf_common_device.h" #include "../common/tx.h" +#include "../common/rx.h" #define IDPF_RX_MAX_BURST 32
@@ -96,6 +97,15 @@#define IDPF_RX_SPLIT_BUFQ1_ID 1#define IDPF_RX_SPLIT_BUFQ2_ID 2 +#define IDPF_RX_SCALAR_OFFLOADS ( \ + RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \ + RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \ + RTE_ETH_RX_OFFLOAD_TCP_CKSUM | \ + RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | \ + RTE_ETH_RX_OFFLOAD_TIMESTAMP | \ + RTE_ETH_RX_OFFLOAD_SCATTER) +#define IDPF_RX_VECTOR_OFFLOADS 0 +struct idpf_rx_stats {RTE_ATOMIC (uint64_t ) mbuf_alloc_failed; };
@@ -253,4 +263,6 @@ uint16_t idpf_dp_singleq_xmit_pkts_avx2(void *tx_queue,struct rte_mbuf **tx_pkts, uint16_t nb_pkts); +extern const struct ci_rx_path_info idpf_rx_path_infos[IDPF_RX_MAX ]; +#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/net/intel/idpf/idpf_ethdev.c +2 -0
@@ -694,6 +694,8 @@ idpf_dev_configure(struct rte_eth_dev *dev) (dev->data->mtu ==0 ) ?IDPF_DEFAULT_MTU : dev->data->mtu +IDPF_ETH_OVERHEAD ; + vport->adapter->rx_func_type =IDPF_RX_DEFAULT ; +return 0 ; }
drivers/net/intel/idpf/idpf_rxtx.c +28 -75
125 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 2/4] net/idpf: use the common Rx path selection infrastructure
Quoted 96 lines · Ciara Loftus
Update the common rx path selection infrastructure to include the feature "single queue" which is relevant for the idpf and cpfl drivers. Replace the existing complicated logic in the idpf driver with the use of the common function.
Signed-off-by Ciara Loftus <[email protected]>--- drivers/net/intel/common/rx.h | 5 + drivers/net/intel/idpf/idpf_common_device.h | 12 +++ drivers/net/intel/idpf/idpf_common_rxtx.c | 24 +++++ drivers/net/intel/idpf/idpf_common_rxtx.h | 12 +++ drivers/net/intel/idpf/idpf_ethdev.c | 2 + drivers/net/intel/idpf/idpf_rxtx.c | 103 ++++++-------------- 6 files changed, 83 insertions(+), 75 deletions(-)drivers/net/intel/common/rx.h +5
-0@@ -131,6 +131,7 @@ struct ci_rx_path_features_extra {bool flex_desc;bool bulk_alloc;bool disabled; +bool single_queue; };struct ci_rx_path_features {@@ -278,6 +279,10 @@ ci_rx_path_select(struct ci_rx_path_features req_features,if (path_features->extra.flex_desc != req_features.extra.flex_desc)continue ; +/* If requested, ensure the path supports single queue RX. */ +if (path_features->extra.single_queue != req_features.extra.single_queue) +continue ; +/* If requested, ensure the path supports scattered RX. */ if (path_features->extra.scattered != req_features.extra.scattered)continue ;drivers/net/intel/idpf/idpf_common_device.h +12
-0@@ -44,6 +44,16 @@ (sizeof (struct virtchnl2_ptype ) + \ (((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0]))) +enum idpf_rx_func_type { +IDPF_RX_DEFAULT , +IDPF_RX_SINGLEQ , +IDPF_RX_SINGLEQ_SCATTERED , +IDPF_RX_SINGLEQ_AVX2 , +IDPF_RX_AVX512 , +IDPF_RX_SINGLQ_AVX512 , +IDPF_RX_MAX +}; +struct idpf_adapter {struct idpf_hw hw;struct virtchnl2_version_info virtchnl_version;@@ -59,6 +69,8 @@ struct idpf_adapter {/* For timestamp */ uint64_t time_hw; + +enum idpf_rx_func_type rx_func_type; };struct idpf_chunks_info {drivers/net/intel/idpf/idpf_common_rxtx.c +13
-0@@ -7,6 +7,8 @@#include <rte_errno.h> #include "idpf_common_rxtx.h" +#include "idpf_common_device.h" +#include "../common/rx.h" int idpf_timestamp_dynfield_offset =-1 ;uint64_t idpf_timestamp_dynflag;@@ -1622,3 +1624,25 @@ idpf_qc_splitq_rx_vec_setup(struct idpf_rx_queue *rxq) rxq->bufq2->idpf_ops = &def_rx_ops_vec;return idpf_rxq_vec_setup_default (rxq->bufq2); } + +RTE_EXPORT_INTERNAL_SYMBOL (idpf_rx_path_infos) +const struct ci_rx_path_info idpf_rx_path_infos[] = { + [IDPF_RX_DEFAULT ] = {idpf_dp_splitq_recv_pkts,"Scalar Split" , + {IDPF_RX_SCALAR_OFFLOADS ,RTE_VECT_SIMD_DISABLED }}, + [IDPF_RX_SINGLEQ ] = {idpf_dp_singleq_recv_pkts,"Scalar Single Queue" , + {IDPF_RX_SCALAR_OFFLOADS ,RTE_VECT_SIMD_DISABLED , {.single_queue = true}}}, + [IDPF_RX_SINGLEQ_SCATTERED ] = { + idpf_dp_singleq_recv_scatter_pkts,"Scalar Single Queue Scattered" , + {IDPF_RX_SCALAR_OFFLOADS ,RTE_VECT_SIMD_DISABLED , + {.scattered = true, .single_queue = true}}},
drivers/net/intel/idpf/idpf_common_rxtx.c idpf_qc_splitq_rx_vec_setup(struct idpf_rx_queue *rxq) · line 1647
Quoted 10 lines
drivers/net/intel/idpf/idpf_common_rxtx.c +10
-0+#ifdef RTE_ARCH_X86 + [IDPF_RX_SINGLEQ_AVX2 ] = {idpf_dp_singleq_recv_pkts_avx2,"AVX2 Single Queue" , + {IDPF_RX_VECTOR_OFFLOADS ,RTE_VECT_SIMD_256 , {.single_queue = true}}}, +#ifdef CC_AVX512_SUPPORT + [IDPF_RX_AVX512 ] = {idpf_dp_splitq_recv_pkts_avx512,"AVX-512 Split" , + {IDPF_RX_VECTOR_OFFLOADS, RTE_VECT_SIMD_512}}, + [IDPF_RX_SINGLQ_AVX512 ] = {idpf_dp_singleq_recv_pkts_avx512,"AVX-512 Single Queue" , + {IDPF_RX_VECTOR_OFFLOADS, RTE_VECT_SIMD_512, {.single_queue = true}}}, +#endif /* CC_AVX512_SUPPORT */ +#endif /* RTE_ARCH_X86 */
A minor point, but I don't particularly like this form of init for the array. If it was all in table form, with each entry on a single line, then it would be ok, since we could have neat columns. However, since we are word-wrapping the lines, I'd tend towards having one element per line and using named initializers.
PATCH 3/4 net/cpfl: use the new common vector capability function
In reply to Ciara LoftusUse the new function for determining the maximum simd bitwidth in the cpfl driver. An additional check is added for the AVX512DQ CPU flag as it is not present in the common function since it is not a common requirement for all drivers. Also, remove unused elements related to AVX capability from the idpf_vport structure, now that neither the idpf or cpfl drivers use them.
--- drivers/net/intel/cpfl/cpfl_rxtx.c | 50 ++++++------------- drivers/net/intel/cpfl/cpfl_rxtx_vec_common.h | 20 ++++++++ drivers/net/intel/idpf/idpf_common_device.h | 4 -- 3 files changed, 34 insertions(+), 40 deletions(-)
drivers/net/intel/cpfl/cpfl_rxtx.c +14 -36
@@ -1411,26 +1411,13 @@ cpfl_set_rx_function(struct rte_eth_dev *dev)struct idpf_vport *vport = &cpfl_vport->base;#ifdef RTE_ARCH_X86 struct cpfl_rx_queue *cpfl_rxq; +enum rte_vect_max_simd rx_simd_width =RTE_VECT_SIMD_DISABLED ;int i;if (cpfl_rx_vec_dev_check_default (dev) ==CPFL_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { vport->rx_vec_allowed = true; - -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 && -rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) - vport->rx_use_avx2 = true; - - if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) -#ifdef CC_AVX512_SUPPORT -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512DQ )) - vport->rx_use_avx512 = true; -#else -PMD_DRV_LOG (NOTICE , -"AVX512 is not supported in build env" ); -#endif /* CC_AVX512_SUPPORT */ + rx_simd_width =cpfl_get_max_simd_bitwidth (); }else { vport->rx_vec_allowed = false; }
@@ -1446,7 +1433,7 @@ cpfl_set_rx_function(struct rte_eth_dev *dev) (void )idpf_qc_splitq_rx_vec_setup (&cpfl_rxq->base); }#ifdef CC_AVX512_SUPPORT -if (vport->rx_use_avx512) { +if (rx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Split AVX512 Vector Rx (port %d)." , dev->data->port_id);
@@ -1466,7 +1453,7 @@ cpfl_set_rx_function(struct rte_eth_dev *dev) (void )idpf_qc_singleq_rx_vec_setup (&cpfl_rxq->base); }#ifdef CC_AVX512_SUPPORT -if (vport->rx_use_avx512) { +if (rx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX512 Vector Rx (port %d)." , dev->data->port_id);
@@ -1474,7 +1461,7 @@ cpfl_set_rx_function(struct rte_eth_dev *dev) return; }#endif /* CC_AVX512_SUPPORT */ -if (vport->rx_use_avx2) { +if (rx_simd_width ==RTE_VECT_SIMD_256 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX2 Vector Rx (port %d)." , dev->data->port_id);
@@ -1522,6 +1509,7 @@ cpfl_set_tx_function(struct rte_eth_dev *dev)struct cpfl_vport *cpfl_vport = dev->data->dev_private;struct idpf_vport *vport = &cpfl_vport->base;#ifdef RTE_ARCH_X86 +enum rte_vect_max_simd tx_simd_width =RTE_VECT_SIMD_DISABLED ;#ifdef CC_AVX512_SUPPORT struct cpfl_tx_queue *cpfl_txq;int i;
@@ -1530,22 +1518,12 @@ cpfl_set_tx_function(struct rte_eth_dev *dev)if (cpfl_tx_vec_dev_check_default (dev) ==CPFL_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { vport->tx_vec_allowed = true; - -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 && -rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) - vport->tx_use_avx2 = true; - - if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) + tx_simd_width =cpfl_get_max_simd_bitwidth ();#ifdef CC_AVX512_SUPPORT - { -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 ) - vport->tx_use_avx512 = true; -if (vport->tx_use_avx512) { -for (i =0 ; i < dev->data->nb_tx_queues; i++) { - cpfl_txq = dev->data->tx_queues[i]; -idpf_qc_tx_vec_avx512_setup (&cpfl_txq->base); - } +if (tx_simd_width ==RTE_VECT_SIMD_512 ) { +for (i =0 ; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; +idpf_qc_tx_vec_avx512_setup (&cpfl_txq->base); } }#else
@@ -1561,7 +1539,7 @@ cpfl_set_tx_function(struct rte_eth_dev *dev)if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) {if (vport->tx_vec_allowed) {#ifdef CC_AVX512_SUPPORT -if (vport->tx_use_avx512) { +if (tx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Split AVX512 Vector Tx (port %d)." , dev->data->port_id);
@@ -1579,7 +1557,7 @@ cpfl_set_tx_function(struct rte_eth_dev *dev) }else {if (vport->tx_vec_allowed) {#ifdef CC_AVX512_SUPPORT -if (vport->tx_use_avx512) { +if (tx_simd_width ==RTE_VECT_SIMD_512 ) {for (i =0 ; i < dev->data->nb_tx_queues; i++) { cpfl_txq = dev->data->tx_queues[i];if (cpfl_txq ==NULL )
@@ -1594,7 +1572,7 @@ cpfl_set_tx_function(struct rte_eth_dev *dev) return; }#endif /* CC_AVX512_SUPPORT */ -if (vport->tx_use_avx2) { +if (tx_simd_width ==RTE_VECT_SIMD_256 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX2 Vector Tx (port %d)." , dev->data->port_id);
drivers/net/intel/cpfl/cpfl_rxtx_vec_common.h +20 -0
@@ -11,6 +11,10 @@#include "cpfl_ethdev.h" #include "cpfl_rxtx.h" +#ifdef RTE_ARCH_X86 +#include "../common/rx_vec_x86.h" +#endif +#define CPFL_SCALAR_PATH 0#define CPFL_VECTOR_PATH 1#define CPFL_RX_NO_VECTOR_FLAGS ( \
@@ -121,4 +125,20 @@ cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev) return CPFL_VECTOR_PATH; } +#ifdef RTE_ARCH_X86 +static inline enum rte_vect_max_simd +cpfl_get_max_simd_bitwidth (void ) +{ +if (rte_vect_get_max_simd_bitwidth () ==512 && +rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512DQ ) ==0 ) { +if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 )) +return RTE_VECT_SIMD_256 ; +else +return RTE_VECT_SIMD_DISABLED ; + } + +return ci_get_x86_max_simd_bitwidth (); +} +#endif +#endif /*_CPFL_RXTX_VEC_COMMON_H_*/
drivers/net/intel/idpf/idpf_common_device.h +0 -4
@@ -135,10 +135,6 @@ struct idpf_vport {bool rx_vec_allowed;bool tx_vec_allowed; -bool rx_use_avx2; -bool tx_use_avx2; -bool rx_use_avx512; -bool tx_use_avx512;struct virtchnl2_vport_stats eth_stats_offset;
Signature · 1 line
2.34.1
PATCH 4/4 net/cpfl: use the common Rx path selection infrastructure
In reply to Ciara LoftusReplace the existing complicated logic with the use of the common function.
--- drivers/net/intel/cpfl/cpfl_rxtx.c | 105 ++++++-------------- drivers/net/intel/idpf/idpf_common_device.h | 1 - 2 files changed, 29 insertions(+), 77 deletions(-)
drivers/net/intel/cpfl/cpfl_rxtx.c +29 -76
@@ -1409,98 +1409,51 @@ cpfl_set_rx_function(struct rte_eth_dev *dev) {struct cpfl_vport *cpfl_vport = dev->data->dev_private;struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *ad = vport->adapter; +struct ci_rx_path_features req_features = { + .rx_offloads = dev->data->dev_conf.rxmode.offloads, + .simd_width =RTE_VECT_SIMD_DISABLED , + };#ifdef RTE_ARCH_X86 struct cpfl_rx_queue *cpfl_rxq; -enum rte_vect_max_simd rx_simd_width =RTE_VECT_SIMD_DISABLED ;int i;if (cpfl_rx_vec_dev_check_default (dev) ==CPFL_VECTOR_PATH && -rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { - vport->rx_vec_allowed = true; - rx_simd_width =cpfl_get_max_simd_bitwidth (); - }else { - vport->rx_vec_allowed = false; - } +rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) + req_features.simd_width =cpfl_get_max_simd_bitwidth ();#endif /* RTE_ARCH_X86 */ + req_features.extra.single_queue = (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ); + req_features.extra.scattered = dev->data->scattered_rx; + + ad->rx_func_type =ci_rx_path_select (req_features, + &idpf_rx_path_infos[0 ], +IDPF_RX_MAX , +IDPF_RX_DEFAULT ); +#ifdef RTE_ARCH_X86 -if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { -if (vport->rx_vec_allowed) { +if (idpf_rx_path_infos[ad->rx_func_type].features.simd_width >=RTE_VECT_SIMD_256 ) { +/* Vector function selected. Prepare the rxq accordingly. */ +if (idpf_rx_path_infos[ad->rx_func_type].features.extra.single_queue) {for (i =0 ; i < dev->data->nb_rx_queues; i++) { cpfl_rxq = dev->data->rx_queues[i]; -if (cpfl_rxq->hairpin_info.hairpin_q) -continue ; - (void )idpf_qc_splitq_rx_vec_setup (&cpfl_rxq->base); - } -#ifdef CC_AVX512_SUPPORT -if (rx_simd_width ==RTE_VECT_SIMD_512 ) { -PMD_DRV_LOG (NOTICE , -"Using Split AVX512 Vector Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts_avx512; -return ; + (void )idpf_qc_singleq_rx_vec_setup (&cpfl_rxq->base); } -#endif /* CC_AVX512_SUPPORT */ - } -PMD_DRV_LOG (NOTICE , -"Using Split Scalar Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts; - }else { -if (vport->rx_vec_allowed) { + }else {for (i =0 ; i < dev->data->nb_rx_queues; i++) { cpfl_rxq = dev->data->rx_queues[i]; - (void )idpf_qc_singleq_rx_vec_setup (&cpfl_rxq->base); - } -#ifdef CC_AVX512_SUPPORT -if (rx_simd_width ==RTE_VECT_SIMD_512 ) { -PMD_DRV_LOG (NOTICE , -"Using Single AVX512 Vector Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts_avx512; -return ; - } -#endif /* CC_AVX512_SUPPORT */ -if (rx_simd_width ==RTE_VECT_SIMD_256 ) { -PMD_DRV_LOG (NOTICE , -"Using Single AVX2 Vector Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts_avx2; -return ; +if (cpfl_rxq->hairpin_info.hairpin_q) +continue ; + (void )idpf_qc_splitq_rx_vec_setup (&cpfl_rxq->base); } } -if (dev->data->scattered_rx) { -PMD_DRV_LOG (NOTICE , -"Using Single Scalar Scatterd Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; -return ; - } -PMD_DRV_LOG (NOTICE , -"Using Single Scalar Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts; - } -#else -if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { -PMD_DRV_LOG (NOTICE , -"Using Split Scalar Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts; - }else { -if (dev->data->scattered_rx) { -PMD_DRV_LOG (NOTICE , -"Using Single Scalar Scatterd Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; -return ; - } -PMD_DRV_LOG (NOTICE , -"Using Single Scalar Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts; } -#endif /* RTE_ARCH_X86 */ +#endif + + dev->rx_pkt_burst = idpf_rx_path_infos[ad->rx_func_type].pkt_burst; +PMD_DRV_LOG (NOTICE ,"Using %s (port %d)." , + idpf_rx_path_infos[ad->rx_func_type].info, dev->data->port_id); + }void
drivers/net/intel/idpf/idpf_common_device.h +0 -1
@@ -133,7 +133,6 @@ struct idpf_vport {uint16_t devarg_id; -bool rx_vec_allowed;bool tx_vec_allowed;struct virtchnl2_vport_stats eth_stats_offset;
Signature · 1 line
2.34.1
v2 cover idpf and cpfl rx path selection simplification
In reply to Ciara LoftusThis series refactors the vector capability detection and Rx path selection code in the idpf and cpfl PMDs to use the common functions provided in drivers/net/intel/common/rx.h.
v2:
* Moved AVX512DQ check to common code.
* Refactored rx function array definition for better readability.
* Restored Rx functions back to their original names.
Ciara Loftus (5):
net/intel: add AVX512DQ flag to AVX-512 checks net/idpf: use the new common vector capability function net/idpf: use the common Rx path selection infrastructure net/cpfl: use the new common vector capability function net/cpfl: use the common Rx path selection infrastructure
drivers/net/intel/common/rx.h | 5 + drivers/net/intel/common/rx_vec_x86.h | 3 +- drivers/net/intel/cpfl/cpfl_rxtx.c | 143 +++++------------- drivers/net/intel/cpfl/cpfl_rxtx_vec_common.h | 12 ++ drivers/net/intel/idpf/idpf_common_device.h | 17 ++- drivers/net/intel/idpf/idpf_common_rxtx.c | 51 +++++++ drivers/net/intel/idpf/idpf_common_rxtx.h | 12 ++ drivers/net/intel/idpf/idpf_ethdev.c | 2 + drivers/net/intel/idpf/idpf_rxtx.c | 141 +++++------------ drivers/net/intel/idpf/idpf_rxtx_vec_common.h | 11 ++ 10 files changed, 180 insertions(+), 217 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/5 net/intel: add AVX512DQ flag to AVX-512 checks
Add a check for the AVX512DQ cpu flag to the x86 vector capability function. This flag is required by the idpf and cpfl drivers which will soon use this function during their rx path selection process.
--- drivers/net/intel/common/rx_vec_x86.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/intel/common/rx_vec_x86.h +2 -1
@@ -359,7 +359,8 @@ ci_get_x86_max_simd_bitwidth(void)int simd =X86_MAX_SIMD_BITWIDTH ;if (simd >=512 &&rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 ) +rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 && +rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512DQ ) ==1 ) ret =RTE_VECT_SIMD_512 ;else if (simd >=256 && (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 )) ret =RTE_VECT_SIMD_256 ;
Signature · 1 line
2.34.1
Re: [PATCH v2 1/5] net/intel: add AVX512DQ flag to AVX-512 checks
Quoted 6 lines · Ciara Loftus
Add a check for the AVX512DQ cpu flag to the x86 vector capability function. This flag is required by the idpf and cpfl drivers which will soon use this function during their rx path selection process.
Signed-off-by Ciara Loftus <[email protected]>---
PATCH v2 2/5 net/idpf: use the new common vector capability function
In reply to Ciara LoftusUse the new function for determining the maximum simd bitwidth in the idpf driver.
---
v2:
* Removed check for AVX512DQ in the driver code as it's in the common code now.
--- drivers/net/intel/idpf/idpf_rxtx.c | 50 ++++++------------- drivers/net/intel/idpf/idpf_rxtx_vec_common.h | 11 ++++ 2 files changed, 25 insertions(+), 36 deletions(-)
drivers/net/intel/idpf/idpf_rxtx.c +14 -36
@@ -762,26 +762,13 @@ idpf_set_rx_function(struct rte_eth_dev *dev)struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 struct idpf_rx_queue *rxq; +enum rte_vect_max_simd rx_simd_width =RTE_VECT_SIMD_DISABLED ;int i;if (idpf_rx_vec_dev_check_default (dev) ==IDPF_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { vport->rx_vec_allowed = true; - -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 && -rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) - vport->rx_use_avx2 = true; - - if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) -#ifdef CC_AVX512_SUPPORT -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512DQ )) - vport->rx_use_avx512 = true; -#else -PMD_DRV_LOG (NOTICE , -"AVX512 is not supported in build env" ); -#endif /* CC_AVX512_SUPPORT */ + rx_simd_width =idpf_get_max_simd_bitwidth (); }else { vport->rx_vec_allowed = false; }
@@ -795,7 +782,7 @@ idpf_set_rx_function(struct rte_eth_dev *dev) (void )idpf_qc_splitq_rx_vec_setup (rxq); }#ifdef CC_AVX512_SUPPORT -if (vport->rx_use_avx512) { +if (rx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Split AVX512 Vector Rx (port %d)." , dev->data->port_id);
@@ -815,7 +802,7 @@ idpf_set_rx_function(struct rte_eth_dev *dev) (void )idpf_qc_singleq_rx_vec_setup (rxq); }#ifdef CC_AVX512_SUPPORT -if (vport->rx_use_avx512) { +if (rx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX512 Vector Rx (port %d)." , dev->data->port_id);
@@ -823,7 +810,7 @@ idpf_set_rx_function(struct rte_eth_dev *dev) return; }#endif /* CC_AVX512_SUPPORT */ -if (vport->rx_use_avx2) { +if (rx_simd_width ==RTE_VECT_SIMD_256 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX2 Vector Rx (port %d)." , dev->data->port_id);
@@ -871,6 +858,7 @@ idpf_set_tx_function(struct rte_eth_dev *dev) {struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 +enum rte_vect_max_simd tx_simd_width =RTE_VECT_SIMD_DISABLED ;#ifdef CC_AVX512_SUPPORT struct ci_tx_queue *txq;int i;
@@ -879,22 +867,12 @@ idpf_set_tx_function(struct rte_eth_dev *dev)if (idpf_tx_vec_dev_check_default (dev) ==IDPF_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { vport->tx_vec_allowed = true; - -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 && -rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) - vport->tx_use_avx2 = true; - - if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) + tx_simd_width =idpf_get_max_simd_bitwidth ();#ifdef CC_AVX512_SUPPORT - { -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 ) - vport->tx_use_avx512 = true; -if (vport->tx_use_avx512) { -for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; -idpf_qc_tx_vec_avx512_setup (txq); - } +if (tx_simd_width ==RTE_VECT_SIMD_512 ) { +for (i =0 ; i < dev->data->nb_tx_queues; i++) { + txq = dev->data->tx_queues[i]; +idpf_qc_tx_vec_avx512_setup (txq); } }#else
@@ -910,7 +888,7 @@ idpf_set_tx_function(struct rte_eth_dev *dev)if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) {if (vport->tx_vec_allowed) {#ifdef CC_AVX512_SUPPORT -if (vport->tx_use_avx512) { +if (tx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Split AVX512 Vector Tx (port %d)." , dev->data->port_id);
@@ -928,7 +906,7 @@ idpf_set_tx_function(struct rte_eth_dev *dev) }else {if (vport->tx_vec_allowed) {#ifdef CC_AVX512_SUPPORT -if (vport->tx_use_avx512) { +if (tx_simd_width ==RTE_VECT_SIMD_512 ) {for (i =0 ; i < dev->data->nb_tx_queues; i++) { txq = dev->data->tx_queues[i];if (txq ==NULL )
@@ -943,7 +921,7 @@ idpf_set_tx_function(struct rte_eth_dev *dev) return; }#endif /* CC_AVX512_SUPPORT */ -if (vport->tx_use_avx2) { +if (tx_simd_width ==RTE_VECT_SIMD_256 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX2 Vector Tx (port %d)." , dev->data->port_id);
drivers/net/intel/idpf/idpf_rxtx_vec_common.h +11 -0
@@ -11,6 +11,9 @@#include "idpf_ethdev.h" #include "idpf_rxtx.h" #include "../common/rx.h" +#ifdef RTE_ARCH_X86 +#include "../common/rx_vec_x86.h" +#endif #define IDPF_SCALAR_PATH 0#define IDPF_VECTOR_PATH 1
@@ -129,4 +132,12 @@ idpf_tx_vec_dev_check_default(struct rte_eth_dev *dev) return IDPF_VECTOR_PATH; } +#ifdef RTE_ARCH_X86 +static inline enum rte_vect_max_simd +idpf_get_max_simd_bitwidth (void ) +{ +return ci_get_x86_max_simd_bitwidth (); +} +#endif +#endif /*_IDPF_RXTX_VEC_COMMON_H_*/
Signature · 1 line
2.34.1
PATCH v2 3/5 net/idpf: use the common Rx path selection infrastructure
In reply to Ciara LoftusUpdate the common rx path selection infrastructure to include the feature "single queue" which is relevant for the idpf and cpfl drivers. Replace the existing complicated logic in the idpf driver with the use of the common function.
---
v2:
* Restored rx function names to match their original names
* Refactored the rx function infos array for better readability
--- drivers/net/intel/common/rx.h | 5 + drivers/net/intel/idpf/idpf_common_device.h | 12 +++ drivers/net/intel/idpf/idpf_common_rxtx.c | 51 ++++++++++ drivers/net/intel/idpf/idpf_common_rxtx.h | 12 +++ drivers/net/intel/idpf/idpf_ethdev.c | 2 + drivers/net/intel/idpf/idpf_rxtx.c | 103 ++++++-------------- 6 files changed, 110 insertions(+), 75 deletions(-)
drivers/net/intel/common/rx.h +5 -0
@@ -131,6 +131,7 @@ struct ci_rx_path_features_extra {bool flex_desc;bool bulk_alloc;bool disabled; +bool single_queue; };struct ci_rx_path_features {
@@ -278,6 +279,10 @@ ci_rx_path_select(struct ci_rx_path_features req_features,if (path_features->extra.flex_desc != req_features.extra.flex_desc)continue ; +/* If requested, ensure the path supports single queue RX. */ +if (path_features->extra.single_queue != req_features.extra.single_queue) +continue ; +/* If requested, ensure the path supports scattered RX. */ if (path_features->extra.scattered != req_features.extra.scattered)continue ;
drivers/net/intel/idpf/idpf_common_device.h +12 -0
@@ -44,6 +44,16 @@ (sizeof (struct virtchnl2_ptype ) + \ (((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0]))) +enum idpf_rx_func_type { +IDPF_RX_DEFAULT , +IDPF_RX_SINGLEQ , +IDPF_RX_SINGLEQ_SCATTERED , +IDPF_RX_SINGLEQ_AVX2 , +IDPF_RX_AVX512 , +IDPF_RX_SINGLQ_AVX512 , +IDPF_RX_MAX +}; +struct idpf_adapter {struct idpf_hw hw;struct virtchnl2_version_info virtchnl_version;
@@ -59,6 +69,8 @@ struct idpf_adapter {/* For timestamp */ uint64_t time_hw; + +enum idpf_rx_func_type rx_func_type; };struct idpf_chunks_info {
drivers/net/intel/idpf/idpf_common_rxtx.c +51 -0
60 lines not on this page · raw message
drivers/net/intel/idpf/idpf_common_rxtx.h +12 -0
@@ -11,6 +11,7 @@#include "idpf_common_device.h" #include "../common/tx.h" +#include "../common/rx.h" #define IDPF_RX_MAX_BURST 32
@@ -96,6 +97,15 @@#define IDPF_RX_SPLIT_BUFQ1_ID 1#define IDPF_RX_SPLIT_BUFQ2_ID 2 +#define IDPF_RX_SCALAR_OFFLOADS ( \ + RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \ + RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \ + RTE_ETH_RX_OFFLOAD_TCP_CKSUM | \ + RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | \ + RTE_ETH_RX_OFFLOAD_TIMESTAMP | \ + RTE_ETH_RX_OFFLOAD_SCATTER) +#define IDPF_RX_VECTOR_OFFLOADS 0 +struct idpf_rx_stats {RTE_ATOMIC (uint64_t ) mbuf_alloc_failed; };
@@ -253,4 +263,6 @@ uint16_t idpf_dp_singleq_xmit_pkts_avx2(void *tx_queue,struct rte_mbuf **tx_pkts, uint16_t nb_pkts); +extern const struct ci_rx_path_info idpf_rx_path_infos[IDPF_RX_MAX ]; +#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/net/intel/idpf/idpf_ethdev.c +2 -0
@@ -694,6 +694,8 @@ idpf_dev_configure(struct rte_eth_dev *dev) (dev->data->mtu ==0 ) ?IDPF_DEFAULT_MTU : dev->data->mtu +IDPF_ETH_OVERHEAD ; + vport->adapter->rx_func_type =IDPF_RX_DEFAULT ; +return 0 ; }
drivers/net/intel/idpf/idpf_rxtx.c +28 -75
125 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v2 4/5 net/cpfl: use the new common vector capability function
In reply to Ciara LoftusUse the new function for determining the maximum simd bitwidth in the cpfl driver. Also, remove unused elements related to AVX capability from the idpf_vport structure, now that neither the idpf or cpfl drivers use them.
---
v2:
* Removed check for AVX512DQ in the driver code as it's in the common code now.
--- drivers/net/intel/cpfl/cpfl_rxtx.c | 50 ++++++------------- drivers/net/intel/cpfl/cpfl_rxtx_vec_common.h | 12 +++++ drivers/net/intel/idpf/idpf_common_device.h | 4 -- 3 files changed, 26 insertions(+), 40 deletions(-)
drivers/net/intel/cpfl/cpfl_rxtx.c +14 -36
@@ -1411,26 +1411,13 @@ cpfl_set_rx_function(struct rte_eth_dev *dev)struct idpf_vport *vport = &cpfl_vport->base;#ifdef RTE_ARCH_X86 struct cpfl_rx_queue *cpfl_rxq; +enum rte_vect_max_simd rx_simd_width =RTE_VECT_SIMD_DISABLED ;int i;if (cpfl_rx_vec_dev_check_default (dev) ==CPFL_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { vport->rx_vec_allowed = true; - -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 && -rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) - vport->rx_use_avx2 = true; - - if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) -#ifdef CC_AVX512_SUPPORT -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512DQ )) - vport->rx_use_avx512 = true; -#else -PMD_DRV_LOG (NOTICE , -"AVX512 is not supported in build env" ); -#endif /* CC_AVX512_SUPPORT */ + rx_simd_width =cpfl_get_max_simd_bitwidth (); }else { vport->rx_vec_allowed = false; }
@@ -1446,7 +1433,7 @@ cpfl_set_rx_function(struct rte_eth_dev *dev) (void )idpf_qc_splitq_rx_vec_setup (&cpfl_rxq->base); }#ifdef CC_AVX512_SUPPORT -if (vport->rx_use_avx512) { +if (rx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Split AVX512 Vector Rx (port %d)." , dev->data->port_id);
@@ -1466,7 +1453,7 @@ cpfl_set_rx_function(struct rte_eth_dev *dev) (void )idpf_qc_singleq_rx_vec_setup (&cpfl_rxq->base); }#ifdef CC_AVX512_SUPPORT -if (vport->rx_use_avx512) { +if (rx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX512 Vector Rx (port %d)." , dev->data->port_id);
@@ -1474,7 +1461,7 @@ cpfl_set_rx_function(struct rte_eth_dev *dev) return; }#endif /* CC_AVX512_SUPPORT */ -if (vport->rx_use_avx2) { +if (rx_simd_width ==RTE_VECT_SIMD_256 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX2 Vector Rx (port %d)." , dev->data->port_id);
@@ -1522,6 +1509,7 @@ cpfl_set_tx_function(struct rte_eth_dev *dev)struct cpfl_vport *cpfl_vport = dev->data->dev_private;struct idpf_vport *vport = &cpfl_vport->base;#ifdef RTE_ARCH_X86 +enum rte_vect_max_simd tx_simd_width =RTE_VECT_SIMD_DISABLED ;#ifdef CC_AVX512_SUPPORT struct cpfl_tx_queue *cpfl_txq;int i;
@@ -1530,22 +1518,12 @@ cpfl_set_tx_function(struct rte_eth_dev *dev)if (cpfl_tx_vec_dev_check_default (dev) ==CPFL_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { vport->tx_vec_allowed = true; - -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 && -rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) - vport->tx_use_avx2 = true; - - if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) + tx_simd_width =cpfl_get_max_simd_bitwidth ();#ifdef CC_AVX512_SUPPORT - { -if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 && -rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 ) - vport->tx_use_avx512 = true; -if (vport->tx_use_avx512) { -for (i =0 ; i < dev->data->nb_tx_queues; i++) { - cpfl_txq = dev->data->tx_queues[i]; -idpf_qc_tx_vec_avx512_setup (&cpfl_txq->base); - } +if (tx_simd_width ==RTE_VECT_SIMD_512 ) { +for (i =0 ; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; +idpf_qc_tx_vec_avx512_setup (&cpfl_txq->base); } }#else
@@ -1561,7 +1539,7 @@ cpfl_set_tx_function(struct rte_eth_dev *dev)if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) {if (vport->tx_vec_allowed) {#ifdef CC_AVX512_SUPPORT -if (vport->tx_use_avx512) { +if (tx_simd_width ==RTE_VECT_SIMD_512 ) {PMD_DRV_LOG (NOTICE ,"Using Split AVX512 Vector Tx (port %d)." , dev->data->port_id);
@@ -1579,7 +1557,7 @@ cpfl_set_tx_function(struct rte_eth_dev *dev) }else {if (vport->tx_vec_allowed) {#ifdef CC_AVX512_SUPPORT -if (vport->tx_use_avx512) { +if (tx_simd_width ==RTE_VECT_SIMD_512 ) {for (i =0 ; i < dev->data->nb_tx_queues; i++) { cpfl_txq = dev->data->tx_queues[i];if (cpfl_txq ==NULL )
@@ -1594,7 +1572,7 @@ cpfl_set_tx_function(struct rte_eth_dev *dev) return; }#endif /* CC_AVX512_SUPPORT */ -if (vport->tx_use_avx2) { +if (tx_simd_width ==RTE_VECT_SIMD_256 ) {PMD_DRV_LOG (NOTICE ,"Using Single AVX2 Vector Tx (port %d)." , dev->data->port_id);
drivers/net/intel/cpfl/cpfl_rxtx_vec_common.h +12 -0
@@ -11,6 +11,10 @@#include "cpfl_ethdev.h" #include "cpfl_rxtx.h" +#ifdef RTE_ARCH_X86 +#include "../common/rx_vec_x86.h" +#endif +#define CPFL_SCALAR_PATH 0#define CPFL_VECTOR_PATH 1#define CPFL_RX_NO_VECTOR_FLAGS ( \
@@ -121,4 +125,12 @@ cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev) return CPFL_VECTOR_PATH; } +#ifdef RTE_ARCH_X86 +static inline enum rte_vect_max_simd +cpfl_get_max_simd_bitwidth (void ) +{ +return ci_get_x86_max_simd_bitwidth (); +} +#endif +#endif /*_CPFL_RXTX_VEC_COMMON_H_*/
drivers/net/intel/idpf/idpf_common_device.h +0 -4
@@ -135,10 +135,6 @@ struct idpf_vport {bool rx_vec_allowed;bool tx_vec_allowed; -bool rx_use_avx2; -bool tx_use_avx2; -bool rx_use_avx512; -bool tx_use_avx512;struct virtchnl2_vport_stats eth_stats_offset;
Signature · 1 line
2.34.1
PATCH v2 5/5 net/cpfl: use the common Rx path selection infrastructure
In reply to Ciara LoftusReplace the existing complicated logic with the use of the common function.
--- drivers/net/intel/cpfl/cpfl_rxtx.c | 105 ++++++-------------- drivers/net/intel/idpf/idpf_common_device.h | 1 - 2 files changed, 29 insertions(+), 77 deletions(-)
drivers/net/intel/cpfl/cpfl_rxtx.c +29 -76
@@ -1409,98 +1409,51 @@ cpfl_set_rx_function(struct rte_eth_dev *dev) {struct cpfl_vport *cpfl_vport = dev->data->dev_private;struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *ad = vport->adapter; +struct ci_rx_path_features req_features = { + .rx_offloads = dev->data->dev_conf.rxmode.offloads, + .simd_width =RTE_VECT_SIMD_DISABLED , + };#ifdef RTE_ARCH_X86 struct cpfl_rx_queue *cpfl_rxq; -enum rte_vect_max_simd rx_simd_width =RTE_VECT_SIMD_DISABLED ;int i;if (cpfl_rx_vec_dev_check_default (dev) ==CPFL_VECTOR_PATH && -rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { - vport->rx_vec_allowed = true; - rx_simd_width =cpfl_get_max_simd_bitwidth (); - }else { - vport->rx_vec_allowed = false; - } +rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) + req_features.simd_width =cpfl_get_max_simd_bitwidth ();#endif /* RTE_ARCH_X86 */ + req_features.extra.single_queue = (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ); + req_features.extra.scattered = dev->data->scattered_rx; + + ad->rx_func_type =ci_rx_path_select (req_features, + &idpf_rx_path_infos[0 ], +IDPF_RX_MAX , +IDPF_RX_DEFAULT ); +#ifdef RTE_ARCH_X86 -if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { -if (vport->rx_vec_allowed) { +if (idpf_rx_path_infos[ad->rx_func_type].features.simd_width >=RTE_VECT_SIMD_256 ) { +/* Vector function selected. Prepare the rxq accordingly. */ +if (idpf_rx_path_infos[ad->rx_func_type].features.extra.single_queue) {for (i =0 ; i < dev->data->nb_rx_queues; i++) { cpfl_rxq = dev->data->rx_queues[i]; -if (cpfl_rxq->hairpin_info.hairpin_q) -continue ; - (void )idpf_qc_splitq_rx_vec_setup (&cpfl_rxq->base); - } -#ifdef CC_AVX512_SUPPORT -if (rx_simd_width ==RTE_VECT_SIMD_512 ) { -PMD_DRV_LOG (NOTICE , -"Using Split AVX512 Vector Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts_avx512; -return ; + (void )idpf_qc_singleq_rx_vec_setup (&cpfl_rxq->base); } -#endif /* CC_AVX512_SUPPORT */ - } -PMD_DRV_LOG (NOTICE , -"Using Split Scalar Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts; - }else { -if (vport->rx_vec_allowed) { + }else {for (i =0 ; i < dev->data->nb_rx_queues; i++) { cpfl_rxq = dev->data->rx_queues[i]; - (void )idpf_qc_singleq_rx_vec_setup (&cpfl_rxq->base); - } -#ifdef CC_AVX512_SUPPORT -if (rx_simd_width ==RTE_VECT_SIMD_512 ) { -PMD_DRV_LOG (NOTICE , -"Using Single AVX512 Vector Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts_avx512; -return ; - } -#endif /* CC_AVX512_SUPPORT */ -if (rx_simd_width ==RTE_VECT_SIMD_256 ) { -PMD_DRV_LOG (NOTICE , -"Using Single AVX2 Vector Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts_avx2; -return ; +if (cpfl_rxq->hairpin_info.hairpin_q) +continue ; + (void )idpf_qc_splitq_rx_vec_setup (&cpfl_rxq->base); } } -if (dev->data->scattered_rx) { -PMD_DRV_LOG (NOTICE , -"Using Single Scalar Scatterd Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; -return ; - } -PMD_DRV_LOG (NOTICE , -"Using Single Scalar Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts; - } -#else -if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { -PMD_DRV_LOG (NOTICE , -"Using Split Scalar Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts; - }else { -if (dev->data->scattered_rx) { -PMD_DRV_LOG (NOTICE , -"Using Single Scalar Scatterd Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts; -return ; - } -PMD_DRV_LOG (NOTICE , -"Using Single Scalar Rx (port %d)." , - dev->data->port_id); - dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts; } -#endif /* RTE_ARCH_X86 */ +#endif + + dev->rx_pkt_burst = idpf_rx_path_infos[ad->rx_func_type].pkt_burst; +PMD_DRV_LOG (NOTICE ,"Using %s Rx (port %d)." , + idpf_rx_path_infos[ad->rx_func_type].info, dev->data->port_id); + }void
drivers/net/intel/idpf/idpf_common_device.h +0 -1
@@ -133,7 +133,6 @@ struct idpf_vport {uint16_t devarg_id; -bool rx_vec_allowed;bool tx_vec_allowed;struct virtchnl2_vport_stats eth_stats_offset;
Signature · 1 line
2.34.1
Quoted 18 lines
-----Original Message-----
From: Ciara Loftus <[email protected]>
Sent: Wednesday, September 17, 2025 2:47 PM
To: [email protected]
Cc: Loftus, Ciara <[email protected]>
Subject: [PATCH v2 0/5] idpf and cpfl rx path selection simplificationThis series refactors the vector capability detection and Rx path selection code in the idpf and cpfl PMDs to use the common functions provided in
drivers/net/intel/common/rx.h.v2:
* Moved AVX512DQ check to common code.
* Refactored rx function array definition for better readability.
* Restored Rx functions back to their original names.
Quoted 7 lines
Ciara Loftus (5):
net/intel: add AVX512DQ flag to AVX-512 checks net/idpf: use the new common vector capability function net/idpf: use the common Rx path selection infrastructure net/cpfl: use the new common vector capability function net/cpfl: use the common Rx path selection infrastructure
Quoted 14 lines
drivers/net/intel/common/rx.h | 5 + drivers/net/intel/common/rx_vec_x86.h | 3 +- drivers/net/intel/cpfl/cpfl_rxtx.c | 143 +++++------------- drivers/net/intel/cpfl/cpfl_rxtx_vec_common.h | 12 ++ drivers/net/intel/idpf/idpf_common_device.h | 17 ++- drivers/net/intel/idpf/idpf_common_rxtx.c | 51 +++++++ drivers/net/intel/idpf/idpf_common_rxtx.h | 12 ++ drivers/net/intel/idpf/idpf_ethdev.c | 2 + drivers/net/intel/idpf/idpf_rxtx.c | 141 +++++------------ drivers/net/intel/idpf/idpf_rxtx_vec_common.h | 11 ++ 10 files changed, 180 insertions(+), 217 deletions(-)--
2.34.1
Quoted 18 lines · Shaiq
Quoted 18 lines
-----Original Message-----
From: Ciara Loftus <[email protected]>
Sent: Wednesday, September 17, 2025 2:47 PM
To: [email protected]
Cc: Loftus, Ciara <[email protected]>
Subject: [PATCH v2 0/5] idpf and cpfl rx path selection simplificationThis series refactors the vector capability detection and Rx path selection code in the idpf and cpfl PMDs to use the common functions provided in
drivers/net/intel/common/rx.h.v2:
* Moved AVX512DQ check to common code.
* Refactored rx function array definition for better readability.
* Restored Rx functions back to their original names.
Quoted 9 lines
Quoted 7 lines
Ciara Loftus (5):
net/intel: add AVX512DQ flag to AVX-512 checks net/idpf: use the new common vector capability function net/idpf: use the common Rx path selection infrastructure net/cpfl: use the new common vector capability function net/cpfl: use the common Rx path selection infrastructureTested-by <[email protected]>
Series applied to dpdk-next-net-intel.
Thanks,
/Bruce