Skip to content

Commit

Permalink
net/ice: add AVX512 vector path
Browse files Browse the repository at this point in the history
Add AVX512 support for ice PMD. This patch adds ice_rxtx_vec_avx512.c
to support ice AVX512 vPMD.

This patch aims to enable AVX512 on ice vPMD. Main changes are focus
on Rx path compared with AVX2 vPMD.

Signed-off-by: Leyi Rong <[email protected]>
Signed-off-by: Bruce Richardson <[email protected]>
Acked-by: Qi Zhang <[email protected]>
  • Loading branch information
Ninja-Mobius authored and Ferruh Yigit committed Nov 3, 2020
1 parent 7966fcd commit 7f85d5e
Show file tree
Hide file tree
Showing 4 changed files with 935 additions and 18 deletions.
98 changes: 80 additions & 18 deletions drivers/net/ice/ice_rxtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1930,6 +1930,10 @@ ice_dev_supported_ptypes_get(struct rte_eth_dev *dev)
#ifdef RTE_ARCH_X86
if (dev->rx_pkt_burst == ice_recv_pkts_vec ||
dev->rx_pkt_burst == ice_recv_scattered_pkts_vec ||
#ifdef CC_AVX512_SUPPORT
dev->rx_pkt_burst == ice_recv_pkts_vec_avx512 ||
dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx512 ||
#endif
dev->rx_pkt_burst == ice_recv_pkts_vec_avx2 ||
dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2)
return ptypes;
Expand Down Expand Up @@ -2987,6 +2991,7 @@ ice_set_rx_function(struct rte_eth_dev *dev)
#ifdef RTE_ARCH_X86
struct ice_rx_queue *rxq;
int i;
bool use_avx512 = false;
bool use_avx2 = false;

if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
Expand All @@ -3001,9 +3006,19 @@ ice_set_rx_function(struct rte_eth_dev *dev)
}
}

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)
if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512 &&
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;
#else
PMD_DRV_LOG(NOTICE,
"AVX512 is not supported in build env");
#endif
if (!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)
use_avx2 = true;

} else {
Expand All @@ -3013,20 +3028,41 @@ ice_set_rx_function(struct rte_eth_dev *dev)

if (ad->rx_vec_allowed) {
if (dev->data->scattered_rx) {
PMD_DRV_LOG(DEBUG,
if (use_avx512) {
#ifdef CC_AVX512_SUPPORT
PMD_DRV_LOG(NOTICE,
"Using AVX512 Vector Scattered Rx (port %d).",
dev->data->port_id);
dev->rx_pkt_burst =
ice_recv_scattered_pkts_vec_avx512;
#endif
} else {
PMD_DRV_LOG(DEBUG,
"Using %sVector Scattered Rx (port %d).",
use_avx2 ? "avx2 " : "",
dev->data->port_id);
dev->rx_pkt_burst = use_avx2 ?
dev->rx_pkt_burst = use_avx2 ?
ice_recv_scattered_pkts_vec_avx2 :
ice_recv_scattered_pkts_vec;
}
} else {
PMD_DRV_LOG(DEBUG, "Using %sVector Rx (port %d).",
if (use_avx512) {
#ifdef CC_AVX512_SUPPORT
PMD_DRV_LOG(NOTICE,
"Using AVX512 Vector Rx (port %d).",
dev->data->port_id);
dev->rx_pkt_burst =
ice_recv_pkts_vec_avx512;
#endif
} else {
PMD_DRV_LOG(DEBUG,
"Using %sVector Rx (port %d).",
use_avx2 ? "avx2 " : "",
dev->data->port_id);
dev->rx_pkt_burst = use_avx2 ?
ice_recv_pkts_vec_avx2 :
ice_recv_pkts_vec;
dev->rx_pkt_burst = use_avx2 ?
ice_recv_pkts_vec_avx2 :
ice_recv_pkts_vec;
}
}
return;
}
Expand Down Expand Up @@ -3063,6 +3099,10 @@ static const struct {
{ ice_recv_pkts_bulk_alloc, "Scalar Bulk Alloc" },
{ ice_recv_pkts, "Scalar" },
#ifdef RTE_ARCH_X86
#ifdef CC_AVX512_SUPPORT
{ ice_recv_scattered_pkts_vec_avx512, "Vector AVX512 Scattered" },
{ ice_recv_pkts_vec_avx512, "Vector AVX512" },
#endif
{ ice_recv_scattered_pkts_vec_avx2, "Vector AVX2 Scattered" },
{ ice_recv_pkts_vec_avx2, "Vector AVX2" },
{ ice_recv_scattered_pkts_vec, "Vector SSE Scattered" },
Expand Down Expand Up @@ -3167,6 +3207,7 @@ ice_set_tx_function(struct rte_eth_dev *dev)
#ifdef RTE_ARCH_X86
struct ice_tx_queue *txq;
int i;
bool use_avx512 = false;
bool use_avx2 = false;

if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
Expand All @@ -3181,9 +3222,19 @@ ice_set_tx_function(struct rte_eth_dev *dev)
}
}

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)
if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512 &&
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;
#else
PMD_DRV_LOG(NOTICE,
"AVX512 is not supported in build env");
#endif
if (!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)
use_avx2 = true;

} else {
Expand All @@ -3192,12 +3243,20 @@ ice_set_tx_function(struct rte_eth_dev *dev)
}

if (ad->tx_vec_allowed) {
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 (use_avx512) {
#ifdef CC_AVX512_SUPPORT
PMD_DRV_LOG(NOTICE, "Using AVX512 Vector Tx (port %d).",
dev->data->port_id);
dev->tx_pkt_burst = ice_xmit_pkts_vec_avx512;
#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;
}
dev->tx_pkt_prepare = NULL;

return;
Expand All @@ -3222,6 +3281,9 @@ static const struct {
{ ice_xmit_pkts_simple, "Scalar Simple" },
{ ice_xmit_pkts, "Scalar" },
#ifdef RTE_ARCH_X86
#ifdef CC_AVX512_SUPPORT
{ ice_xmit_pkts_vec_avx512, "Vector AVX512" },
#endif
{ ice_xmit_pkts_vec_avx2, "Vector AVX2" },
{ ice_xmit_pkts_vec, "Vector SSE" },
#endif
Expand Down
7 changes: 7 additions & 0 deletions drivers/net/ice/ice_rxtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ 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_recv_pkts_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
uint16_t ice_recv_scattered_pkts_vec_avx512(void *rx_queue,
struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
uint16_t ice_xmit_pkts_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);
int ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc);
int ice_tx_done_cleanup(void *txq, uint32_t free_cnt);

Expand Down
Loading

0 comments on commit 7f85d5e

Please sign in to comment.