Skip to content

Commit

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

This patch aims to enable AVX512 on i40e 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: Wenzhuo Lu <[email protected]>
  • Loading branch information
Ninja-Mobius authored and Ferruh Yigit committed Jan 19, 2021
1 parent 6ada10d commit e6a6a13
Show file tree
Hide file tree
Showing 4 changed files with 1,130 additions and 22 deletions.
95 changes: 73 additions & 22 deletions drivers/net/i40e/i40e_rxtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,10 @@ i40e_dev_supported_ptypes_get(struct rte_eth_dev *dev)
dev->rx_pkt_burst == i40e_recv_scattered_pkts ||
dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec ||
dev->rx_pkt_burst == i40e_recv_pkts_vec ||
#ifdef CC_AVX512_SUPPORT
dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec_avx512 ||
dev->rx_pkt_burst == i40e_recv_pkts_vec_avx512 ||
#endif
dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec_avx2 ||
dev->rx_pkt_burst == i40e_recv_pkts_vec_avx2)
return ptypes;
Expand Down Expand Up @@ -3162,6 +3166,7 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
uint16_t rx_using_sse, i;
bool use_avx2 = false;
bool use_avx512 = false;
/* In order to allow Vector Rx there are a few configuration
* conditions to be met and Rx Bulk Allocation should be allowed.
*/
Expand All @@ -3185,28 +3190,51 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
}
}

use_avx2 = get_avx_supported(0);
use_avx512 = get_avx_supported(1);

if (!use_avx512)
use_avx2 = get_avx_supported(0);
}
}

if (ad->rx_vec_allowed &&
rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
if (dev->data->scattered_rx) {
PMD_INIT_LOG(DEBUG,
"Using %sVector Scattered Rx (port %d).",
use_avx2 ? "avx2 " : "",
dev->data->port_id);
dev->rx_pkt_burst = use_avx2 ?
i40e_recv_scattered_pkts_vec_avx2 :
i40e_recv_scattered_pkts_vec;
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 =
i40e_recv_scattered_pkts_vec_avx512;
#endif
} else {
PMD_INIT_LOG(DEBUG,
"Using %sVector Scattered Rx (port %d).",
use_avx2 ? "avx2 " : "",
dev->data->port_id);
dev->rx_pkt_burst = use_avx2 ?
i40e_recv_scattered_pkts_vec_avx2 :
i40e_recv_scattered_pkts_vec;
}
} else {
PMD_INIT_LOG(DEBUG,
"Using %sVector Rx (port %d).",
use_avx2 ? "avx2 " : "",
dev->data->port_id);
dev->rx_pkt_burst = use_avx2 ?
i40e_recv_pkts_vec_avx2 :
i40e_recv_pkts_vec;
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 =
i40e_recv_pkts_vec_avx512;
#endif
} else {
PMD_INIT_LOG(DEBUG,
"Using %sVector Rx (port %d).",
use_avx2 ? "avx2 " : "",
dev->data->port_id);
dev->rx_pkt_burst = use_avx2 ?
i40e_recv_pkts_vec_avx2 :
i40e_recv_pkts_vec;
}
}
} else if (!dev->data->scattered_rx && ad->rx_bulk_alloc_allowed) {
PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
Expand All @@ -3229,6 +3257,10 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
rx_using_sse =
(dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec ||
dev->rx_pkt_burst == i40e_recv_pkts_vec ||
#ifdef CC_AVX512_SUPPORT
dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec_avx512 ||
dev->rx_pkt_burst == i40e_recv_pkts_vec_avx512 ||
#endif
dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec_avx2 ||
dev->rx_pkt_burst == i40e_recv_pkts_vec_avx2);

Expand All @@ -3249,6 +3281,10 @@ static const struct {
{ i40e_recv_pkts_bulk_alloc, "Scalar Bulk Alloc" },
{ i40e_recv_pkts, "Scalar" },
#ifdef RTE_ARCH_X86
#ifdef CC_AVX512_SUPPORT
{ i40e_recv_scattered_pkts_vec_avx512, "Vector AVX512 Scattered" },
{ i40e_recv_pkts_vec_avx512, "Vector AVX512" },
#endif
{ i40e_recv_scattered_pkts_vec_avx2, "Vector AVX2 Scattered" },
{ i40e_recv_pkts_vec_avx2, "Vector AVX2" },
{ i40e_recv_scattered_pkts_vec, "Vector SSE Scattered" },
Expand Down Expand Up @@ -3315,6 +3351,7 @@ i40e_set_tx_function(struct rte_eth_dev *dev)
I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
int i;
bool use_avx2 = false;
bool use_avx512 = false;

if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
if (ad->tx_vec_allowed) {
Expand All @@ -3328,19 +3365,30 @@ i40e_set_tx_function(struct rte_eth_dev *dev)
}
}

use_avx2 = get_avx_supported(0);
use_avx512 = get_avx_supported(1);

if (!use_avx512)
use_avx2 = get_avx_supported(0);
}
}

if (ad->tx_simple_allowed) {
if (ad->tx_vec_allowed &&
rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
PMD_INIT_LOG(DEBUG, "Using %sVector Tx (port %d).",
use_avx2 ? "avx2 " : "",
dev->data->port_id);
dev->tx_pkt_burst = use_avx2 ?
i40e_xmit_pkts_vec_avx2 :
i40e_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 = i40e_xmit_pkts_vec_avx512;
#endif
} else {
PMD_INIT_LOG(DEBUG, "Using %sVector Tx (port %d).",
use_avx2 ? "avx2 " : "",
dev->data->port_id);
dev->tx_pkt_burst = use_avx2 ?
i40e_xmit_pkts_vec_avx2 :
i40e_xmit_pkts_vec;
}
} else {
PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
dev->tx_pkt_burst = i40e_xmit_pkts_simple;
Expand All @@ -3360,6 +3408,9 @@ static const struct {
{ i40e_xmit_pkts_simple, "Scalar Simple" },
{ i40e_xmit_pkts, "Scalar" },
#ifdef RTE_ARCH_X86
#ifdef CC_AVX512_SUPPORT
{ i40e_xmit_pkts_vec_avx512, "Vector AVX512" },
#endif
{ i40e_xmit_pkts_vec_avx2, "Vector AVX2" },
{ i40e_xmit_pkts_vec, "Vector SSE" },
#elif defined(RTE_ARCH_ARM64)
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/i40e/i40e_rxtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ uint16_t i40e_recv_scattered_pkts_vec_avx2(void *rx_queue,
uint16_t i40e_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);
int i40e_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc);
uint16_t i40e_recv_pkts_vec_avx512(void *rx_queue,
struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
uint16_t i40e_recv_scattered_pkts_vec_avx512(void *rx_queue,
struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
uint16_t i40e_xmit_pkts_vec_avx512(void *tx_queue,
struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);

/* For each value it means, datasheet of hardware can tell more details
*
Expand Down
Loading

0 comments on commit e6a6a13

Please sign in to comment.