Skip to contentSkip to conversation

AVX2 Vectorized Rx/Tx functions for i40e

PATCH Superseded Bruce Richardson 7 participants 17 messages Nov 23, 2017 – Jan 10, 2018 Network drivers

lore
Share & tools
lore
#0 lore raw

cover AVX2 Vectorized Rx/Tx functions for i40e

This patch adds an AVX2 vectorized path to the i40e driver, based on the existing SSE4.2 version. Using AVX2 instructions gives better performance than the SSE version, though the percentage increase depends on the exact settings used. For example:

* Using 16B rather than 32B descriptors gives the biggest benefit since 2 descriptors at a time can be read, rather than just 1 when 32B ones are used.
* Bigger burst sizes for RX gives improved performance - while we see an improvement with testpmd with the default burst size of 32, burst sizes of up to 128 give further improvements
* In my testing, most of the improvement comes from faster processing on the RX path, though the improved TX also gives benefit.

This has been tested on a system with CPU: "Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz", and I've focused on testing with Rx ring sizes of approx 1k - generally --rxd=1024 and --txd=512, rather than the defaults which tend to give poorer zero-loss performance due to the smaller amount of buffering.

Bruce Richardson (2):
net/i40e: add AVX2 Tx function
net/i40e: add AVX2 Rx function

 drivers/net/i40e/Makefile             |  19 +
 drivers/net/i40e/i40e_rxtx.c          |  31 ++
 drivers/net/i40e/i40e_rxtx.h          |   6 +
 drivers/net/i40e/i40e_rxtx_vec_avx2.c | 792 ++++++++++++++++++++++++++++++++++
 4 files changed, 848 insertions(+)
 create mode 100644 drivers/net/i40e/i40e_rxtx_vec_avx2.c
Signature · 1 line
2.13.6
#1 lore raw

PATCH 1/2 net/i40e: add AVX2 Tx function

Add a new Tx function using AVX2 instructions for higher performance. For now, this functionality is limited to platforms with Intel Xeon Scalable Processor(SP), Skylake uarch. The function to be used is selected at runtime, not just at compile-time.

---
 drivers/net/i40e/Makefile             |  19 ++++
 drivers/net/i40e/i40e_rxtx.c          |  10 ++
 drivers/net/i40e/i40e_rxtx.h          |   2 +
 drivers/net/i40e/i40e_rxtx_vec_avx2.c | 191 ++++++++++++++++++++++++++++++++++
 4 files changed, 222 insertions(+)
 create mode 100644 drivers/net/i40e/i40e_rxtx_vec_avx2.c
drivers/net/i40e/Makefile +19 -0
index 9ab8c84df..313a84e3f 100644
@@ -114,6 +114,25 @@ SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_flow.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += rte_pmd_i40e.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_tm.c
 
+ifeq ($(findstring RTE_MACHINE_CPUFLAG_AVX2,$(CFLAGS)),RTE_MACHINE_CPUFLAG_AVX2)
+	CC_AVX2_SUPPORT=1
+else
+	CC_AVX2_SUPPORT=\
+	$(shell $(CC) -march=core-avx2 -dM -E - </dev/null 2>&1 | \
+	grep -q AVX2 && echo 1)
+	ifeq ($(CC_AVX2_SUPPORT), 1)
+		ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
+			CFLAGS_i40e_rxtx_vec_avx2.o += -march=core-avx2
+		else
+			CFLAGS_i40e_rxtx_vec_avx2.o += -mavx2
+		endif
+	endif
+endif
+
+ifeq ($(CC_AVX2_SUPPORT), 1)
+	SRCS-$(CONFIG_RTE_LIBRTE_ACL) += i40e_rxtx_vec_avx2.c
+endif
+
 # install this header file
 SYMLINK-$(CONFIG_RTE_LIBRTE_I40E_PMD)-include := rte_pmd_i40e.h
 
drivers/net/i40e/i40e_rxtx.c +10 -0
index 904d37f08..b32fe4241 100644
@@ -2938,6 +2938,16 @@ i40e_set_tx_function(struct rte_eth_dev *dev)
 		if (ad->tx_vec_allowed) {
 			PMD_INIT_LOG(DEBUG, "Vector tx finally be used.");
 			dev->tx_pkt_burst = i40e_xmit_pkts_vec;
+#ifdef RTE_ARCH_X86
+			/*
+			 * since AVX frequency can be different to base
+			 * frequency, limit use of AVX2 version to later
+			 * plaforms, not all those that could theoretically
+			 * run it.
+			 */
+			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+				dev->tx_pkt_burst = i40e_xmit_pkts_vec_avx2;
+#endif
 		} else {
 			PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
 			dev->tx_pkt_burst = i40e_xmit_pkts_simple;
drivers/net/i40e/i40e_rxtx.h +2 -0
index 06c6a6592..5d76ae15a 100644
@@ -256,6 +256,8 @@ void i40e_set_tx_function_flag(struct rte_eth_dev *dev,
 void i40e_set_tx_function(struct rte_eth_dev *dev);
 void i40e_set_default_ptype_table(struct rte_eth_dev *dev);
 void i40e_set_default_pctype_table(struct rte_eth_dev *dev);
+uint16_t i40e_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
+	uint16_t nb_pkts);
 
 /* For each value it means, datasheet of hardware can tell more details
  *
drivers/net/i40e/i40e_rxtx_vec_avx2.c new file +191 -0

191 lines not on this page · raw message

Signature · 1 line
2.13.6
#2 lore raw

Re: [PATCH 1/2] net/i40e: add AVX2 Tx function

Review

Quoted 2 lines · Bruce Richardson
(quoted diff) +2 -0
+ifeq ($(CC_AVX2_SUPPORT), 1)
+	SRCS-$(CONFIG_RTE_LIBRTE_ACL) += i40e_rxtx_vec_avx2.c

Minor issue:
s/CONFIG_RTE_LIBRTE_ACL/CONFIG_RTE_LIBRTE_I40E_INC_VECTOR/

Quoted 1 line

+endif

#3 lore raw

Re: [PATCH 1/2] net/i40e: add AVX2 Tx function

Quoted 7 lines · Ferruh Yigit

Review

Quoted 2 lines · Bruce Richardson
(quoted diff) +2 -0
+ifeq ($(CC_AVX2_SUPPORT), 1)
+	SRCS-$(CONFIG_RTE_LIBRTE_ACL) += i40e_rxtx_vec_avx2.c

Minor issue:
s/CONFIG_RTE_LIBRTE_ACL/CONFIG_RTE_LIBRTE_I40E_INC_VECTOR/

Ooops. Good catch Ferruh. Hopefully this can be fixed on apply, if not, or if there are other issues I'll do a V2.

/Bruce

#4 lore raw

PATCH 2/2 net/i40e: add AVX2 Rx function

In reply to Bruce Richardson

Add a new Rx function using AVX2 instructions for higher performance. For now, this functionality is limited to platforms with Intel Xeon Scalable Processor(SP), Skylake uarch. The function to be used is selected at runtime, not just at compile-time.

---
 drivers/net/i40e/i40e_rxtx.c          |  21 ++
 drivers/net/i40e/i40e_rxtx.h          |   4 +
 drivers/net/i40e/i40e_rxtx_vec_avx2.c | 601 ++++++++++++++++++++++++++++++++++
 3 files changed, 626 insertions(+)
drivers/net/i40e/i40e_rxtx.c +21 -0
index b32fe4241..32dad4c5c 100644
@@ -2842,6 +2842,17 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
 				     dev->data->port_id);
 
 			dev->rx_pkt_burst = i40e_recv_scattered_pkts_vec;
+#ifdef RTE_ARCH_X86
+			/*
+			 * since AVX frequency can be different to base
+			 * frequency, limit use of AVX2 version to later
+			 * plaforms, not all those that could theoretically
+			 * run it.
+			 */
+			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+				dev->rx_pkt_burst =
+					i40e_recv_scattered_pkts_vec_avx2;
+#endif
 		} else {
 			PMD_INIT_LOG(DEBUG, "Using a Scattered with bulk "
 					   "allocation callback (port=%d).",
@@ -2861,6 +2872,16 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
 			     dev->data->port_id);
 
 		dev->rx_pkt_burst = i40e_recv_pkts_vec;
+#ifdef RTE_ARCH_X86
+		/*
+		 * since AVX frequency can be different to base
+		 * frequency, limit use of AVX2 version to later
+		 * plaforms, not all those that could theoretically
+		 * run it.
+		 */
+		if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+			dev->rx_pkt_burst = i40e_recv_pkts_vec_avx2;
+#endif
 	} else if (ad->rx_bulk_alloc_allowed) {
 		PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
 				    "satisfied. Rx Burst Bulk Alloc function "
drivers/net/i40e/i40e_rxtx.h +4 -0
index 5d76ae15a..b014a534e 100644
@@ -256,6 +256,10 @@ void i40e_set_tx_function_flag(struct rte_eth_dev *dev,
 void i40e_set_tx_function(struct rte_eth_dev *dev);
 void i40e_set_default_ptype_table(struct rte_eth_dev *dev);
 void i40e_set_default_pctype_table(struct rte_eth_dev *dev);
+uint16_t i40e_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts,
+	uint16_t nb_pkts);
+uint16_t i40e_recv_scattered_pkts_vec_avx2(void *rx_queue,
+	struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
 uint16_t i40e_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 	uint16_t nb_pkts);
 
drivers/net/i40e/i40e_rxtx_vec_avx2.c +601 -0

607 lines not on this page · raw message

Signature · 1 line
2.13.6
#5 lore raw
In reply to Bruce Richardson
Quoted 14 lines · Bruce Richardson

This patch adds an AVX2 vectorized path to the i40e driver, based on the existing SSE4.2 version. Using AVX2 instructions gives better performance than the SSE version, though the percentage increase depends on the exact settings used. For example:

* Using 16B rather than 32B descriptors gives the biggest benefit since 2 descriptors at a time can be read, rather than just 1 when 32B ones are used.
* Bigger burst sizes for RX gives improved performance - while we see an improvement with testpmd with the default burst size of 32, burst sizes of up to 128 give further improvements
* In my testing, most of the improvement comes from faster processing on the RX path, though the improved TX also gives benefit.

Quoted 9 lines

This has been tested on a system with CPU: "Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz", and I've focused on testing with Rx ring sizes of approx 1k - generally --rxd=1024 and --txd=512, rather than the defaults which tend to give poorer zero-loss performance due to the smaller amount of buffering.

Bruce Richardson (2):
net/i40e: add AVX2 Tx function
net/i40e: add AVX2 Rx function

Just also to note that this set has quite a number of checkpatch warnings about long lines. These were deliberately left in, as the lines are not significantly over 80 characters, and I felt that splitting them would have hurt readability.

/Bruce

Reviewed-by on the v1 series
#6 lore raw
In reply to Bruce Richardson
Quoted 23 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Friday, November 24, 2017 12:53 AM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Richardson, Bruce <[email protected]>
Subject: [dpdk-dev] [PATCH 0/2] AVX2 Vectorized Rx/Tx functions for i40e

This patch adds an AVX2 vectorized path to the i40e driver, based on the existing SSE4.2 version. Using AVX2 instructions gives better performance than the SSE version, though the percentage increase depends on the exact settings used. For example:

* Using 16B rather than 32B descriptors gives the biggest benefit since 2 descriptors at a time can be read, rather than just 1 when 32B ones are used.
* Bigger burst sizes for RX gives improved performance - while we see an improvement with testpmd with the default burst size of 32, burst sizes of up to 128 give further improvements
* In my testing, most of the improvement comes from faster processing on the RX path, though the improved TX also gives benefit.

Quoted 4 lines

This has been tested on a system with CPU: "Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz", and I've focused on testing with Rx ring sizes of approx 1k - generally --rxd=1024 and --txd=512, rather than the defaults which tend to give poorer zero-loss performance due to the smaller amount of buffering.

Manipulated the instructions, no issue be found.
The patch is wonderful!.

Thanks
Qi

Quoted 15 lines

Bruce Richardson (2):
net/i40e: add AVX2 Tx function
net/i40e: add AVX2 Rx function

 drivers/net/i40e/Makefile             |  19 +
 drivers/net/i40e/i40e_rxtx.c          |  31 ++
 drivers/net/i40e/i40e_rxtx.h          |   6 +
 drivers/net/i40e/i40e_rxtx_vec_avx2.c | 792
++++++++++++++++++++++++++++++++++
 4 files changed, 848 insertions(+)
 create mode 100644 drivers/net/i40e/i40e_rxtx_vec_avx2.c

--
2.13.6

#7 lore raw

v2 cover AVX2 Vectorized Rx/Tx functions for i40e

In reply to Bruce Richardson

This patch adds an AVX2 vectorized path to the i40e driver, based on the existing SSE4.2 version. Using AVX2 instructions gives better performance than the SSE version, though the percentage increase depends on the exact settings used. For example:

* Using 16B rather than 32B descriptors gives the biggest benefit since 2 descriptors at a time can be read, rather than just 1 when 32B ones are used.
* Bigger burst sizes for RX gives improved performance - while we see an improvement with testpmd with the default burst size of 32, burst sizes of up to 128 give further improvements
* In my testing, most of the improvement comes from faster processing on the RX path, though the improved TX also gives benefit.

This has been tested on a system with CPU: "Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz", and I've focused on testing with Rx ring sizes of approx 1k - generally --rxd=1024 and --txd=512, rather than the defaults which tend to give poorer zero-loss performance due to the smaller amount of buffering.

V2:
* Fixed incorrect config variable reference in makefile
* Added missing stub function for when vector drivers are disabled
* Added missing references to the new functions when checking for vector code paths, e.g. for ring tear-down

Bruce Richardson (2):
net/i40e: add AVX2 Tx function
net/i40e: add AVX2 Rx function

 drivers/net/i40e/Makefile             |  19 +
 drivers/net/i40e/i40e_rxtx.c          |  66 ++-
 drivers/net/i40e/i40e_rxtx.h          |   6 +
 drivers/net/i40e/i40e_rxtx_vec_avx2.c | 792 ++++++++++++++++++++++++++++++++++
 4 files changed, 880 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/i40e/i40e_rxtx_vec_avx2.c
Signature · 1 line
2.14.3
#8 lore raw

PATCH v2 1/2 net/i40e: add AVX2 Tx function

Add a new Tx function using AVX2 instructions for higher performance. For now, this functionality is limited to platforms with Intel Xeon Scalable Processor(SP), Skylake uarch. The function to be used is selected at runtime, not just at compile-time.

---
V2:
* fix incorrect config parameter in makefile (ACL -> I40E_INC_VECTOR)
* add in checks for AVX2 vector functions when checking for vector code in use.
* add in stub functions for new AVX2 functions to allow compile when vector paths disabled, or AVX2 not available on compile

---
 drivers/net/i40e/Makefile             |  19 ++++
 drivers/net/i40e/i40e_rxtx.c          |  21 +++-
 drivers/net/i40e/i40e_rxtx.h          |   2 +
 drivers/net/i40e/i40e_rxtx_vec_avx2.c | 191 ++++++++++++++++++++++++++++++++++
 4 files changed, 232 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/i40e/i40e_rxtx_vec_avx2.c
drivers/net/i40e/Makefile +19 -0
index 4b9634d44..5663f5b1c 100644
@@ -86,6 +86,25 @@ SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_flow.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += rte_pmd_i40e.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_tm.c
 
+ifeq ($(findstring RTE_MACHINE_CPUFLAG_AVX2,$(CFLAGS)),RTE_MACHINE_CPUFLAG_AVX2)
+	CC_AVX2_SUPPORT=1
+else
+	CC_AVX2_SUPPORT=\
+	$(shell $(CC) -march=core-avx2 -dM -E - </dev/null 2>&1 | \
+	grep -q AVX2 && echo 1)
+	ifeq ($(CC_AVX2_SUPPORT), 1)
+		ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
+			CFLAGS_i40e_rxtx_vec_avx2.o += -march=core-avx2
+		else
+			CFLAGS_i40e_rxtx_vec_avx2.o += -mavx2
+		endif
+	endif
+endif
+
+ifeq ($(CC_AVX2_SUPPORT), 1)
+	SRCS-$(CONFIG_RTE_LIBRTE_I40E_INC_VECTOR) += i40e_rxtx_vec_avx2.c
+endif
+
 # install this header file
 SYMLINK-$(CONFIG_RTE_LIBRTE_I40E_PMD)-include := rte_pmd_i40e.h
 
drivers/net/i40e/i40e_rxtx.c +20 -1
index f359a0d17..79e66c2e3 100644
@@ -2287,7 +2287,8 @@ i40e_tx_queue_release_mbufs(struct i40e_tx_queue *txq)
 	 *  vPMD tx will not set sw_ring's mbuf to NULL after free,
 	 *  so need to free remains more carefully.
 	 */
-	if (dev->tx_pkt_burst == i40e_xmit_pkts_vec) {
+	if (dev->tx_pkt_burst == i40e_xmit_pkts_vec_avx2 ||
+			dev->tx_pkt_burst == i40e_xmit_pkts_vec) {
 		i = txq->tx_next_dd - txq->tx_rs_thresh + 1;
 		if (txq->tx_tail < i) {
 			for (; i < txq->nb_tx_desc; i++) {
@@ -2906,6 +2907,16 @@ i40e_set_tx_function(struct rte_eth_dev *dev)
 		if (ad->tx_vec_allowed) {
 			PMD_INIT_LOG(DEBUG, "Vector tx finally be used.");
 			dev->tx_pkt_burst = i40e_xmit_pkts_vec;
+#ifdef RTE_ARCH_X86
+			/*
+			 * since AVX frequency can be different to base
+			 * frequency, limit use of AVX2 version to later
+			 * plaforms, not all those that could theoretically
+			 * run it.
+			 */
+			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+				dev->tx_pkt_burst = i40e_xmit_pkts_vec_avx2;
+#endif
 		} else {
 			PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
 			dev->tx_pkt_burst = i40e_xmit_pkts_simple;
@@ -3037,3 +3048,11 @@ i40e_xmit_fixed_burst_vec(void __rte_unused * tx_queue,
 {
 	return 0;
 }
+
+uint16_t __attribute__((weak))
+i40e_xmit_pkts_vec_avx2(void __rte_unused * tx_queue,
+			  struct rte_mbuf __rte_unused **tx_pkts,
+			  uint16_t __rte_unused nb_pkts)
+{
+	return 0;
+}
drivers/net/i40e/i40e_rxtx.h +2 -0
index 63f33cb5e..49114cfeb 100644
@@ -227,6 +227,8 @@ void i40e_set_tx_function_flag(struct rte_eth_dev *dev,
 void i40e_set_tx_function(struct rte_eth_dev *dev);
 void i40e_set_default_ptype_table(struct rte_eth_dev *dev);
 void i40e_set_default_pctype_table(struct rte_eth_dev *dev);
+uint16_t i40e_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
+	uint16_t nb_pkts);
 
 /* For each value it means, datasheet of hardware can tell more details
  *
drivers/net/i40e/i40e_rxtx_vec_avx2.c new file +191 -0

191 lines not on this page · raw message

Signature · 1 line
2.14.3
#9 lore raw

PATCH v2 2/2 net/i40e: add AVX2 Rx function

In reply to Bruce Richardson

Add a new Rx function using AVX2 instructions for higher performance. For now, this functionality is limited to platforms with Intel Xeon Scalable Processor(SP), Skylake uarch. The function to be used is selected at runtime, not just at compile-time.

---
V2:
* when checking for vector functions in use, add in checks for the new AVX2 functions
* add stub functions for the new AVX2 functions to allow compile when vector is disabled or when AVX2 unavailable

---
 drivers/net/i40e/i40e_rxtx.c          |  45 ++-
 drivers/net/i40e/i40e_rxtx.h          |   4 +
 drivers/net/i40e/i40e_rxtx_vec_avx2.c | 601 ++++++++++++++++++++++++++++++++++
 3 files changed, 648 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_rxtx.c +43 -2
index 79e66c2e3..ea8301beb 100644
@@ -1689,7 +1689,9 @@ i40e_dev_supported_ptypes_get(struct rte_eth_dev *dev)
 #endif
 	    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)
+	    dev->rx_pkt_burst == i40e_recv_pkts_vec ||
+	    dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec_avx2 ||
+	    dev->rx_pkt_burst == i40e_recv_pkts_vec_avx2)
 		return ptypes;
 	return NULL;
 }
@@ -2811,6 +2813,17 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
 				     dev->data->port_id);
 
 			dev->rx_pkt_burst = i40e_recv_scattered_pkts_vec;
+#ifdef RTE_ARCH_X86
+			/*
+			 * since AVX frequency can be different to base
+			 * frequency, limit use of AVX2 version to later
+			 * plaforms, not all those that could theoretically
+			 * run it.
+			 */
+			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+				dev->rx_pkt_burst =
+					i40e_recv_scattered_pkts_vec_avx2;
+#endif
 		} else {
 			PMD_INIT_LOG(DEBUG, "Using a Scattered with bulk "
 					   "allocation callback (port=%d).",
@@ -2830,6 +2843,16 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
 			     dev->data->port_id);
 
 		dev->rx_pkt_burst = i40e_recv_pkts_vec;
+#ifdef RTE_ARCH_X86
+		/*
+		 * since AVX frequency can be different to base
+		 * frequency, limit use of AVX2 version to later
+		 * plaforms, not all those that could theoretically
+		 * run it.
+		 */
+		if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+			dev->rx_pkt_burst = i40e_recv_pkts_vec_avx2;
+#endif
 	} else if (ad->rx_bulk_alloc_allowed) {
 		PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
 				    "satisfied. Rx Burst Bulk Alloc function "
@@ -2850,7 +2873,9 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		rx_using_sse =
 			(dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec ||
-			 dev->rx_pkt_burst == i40e_recv_pkts_vec);
+			 dev->rx_pkt_burst == i40e_recv_pkts_vec ||
+			 dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec_avx2 ||
+			 dev->rx_pkt_burst == i40e_recv_pkts_vec_avx2);
 
 		for (i = 0; i < dev->data->nb_rx_queues; i++) {
 			struct i40e_rx_queue *rxq = dev->data->rx_queues[i];
@@ -3023,6 +3048,22 @@ i40e_recv_scattered_pkts_vec(
 	return 0;
 }
 
+uint16_t __attribute__((weak))
+i40e_recv_pkts_vec_avx2(void __rte_unused *rx_queue,
+			struct rte_mbuf __rte_unused **rx_pkts,
+			uint16_t __rte_unused nb_pkts)
+{
+	return 0;
+}
+
+uint16_t __attribute__((weak))
+i40e_recv_scattered_pkts_vec_avx2(void __rte_unused *rx_queue,
+			struct rte_mbuf __rte_unused **rx_pkts,
+			uint16_t __rte_unused nb_pkts)
+{
+	return 0;
+}
+
 int __attribute__((weak))
 i40e_rxq_vec_setup(struct i40e_rx_queue __rte_unused *rxq)
 {
drivers/net/i40e/i40e_rxtx.h +4 -0
index 49114cfeb..34cd79233 100644
@@ -227,6 +227,10 @@ void i40e_set_tx_function_flag(struct rte_eth_dev *dev,
 void i40e_set_tx_function(struct rte_eth_dev *dev);
 void i40e_set_default_ptype_table(struct rte_eth_dev *dev);
 void i40e_set_default_pctype_table(struct rte_eth_dev *dev);
+uint16_t i40e_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts,
+	uint16_t nb_pkts);
+uint16_t i40e_recv_scattered_pkts_vec_avx2(void *rx_queue,
+	struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
 uint16_t i40e_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 	uint16_t nb_pkts);
 
drivers/net/i40e/i40e_rxtx_vec_avx2.c +601 -0

607 lines not on this page · raw message

Signature · 1 line
2.14.3
#10 lore raw
In reply to Bruce Richardson
Quoted 5 lines · Bruce Richardson

This patch adds an AVX2 vectorized path to the i40e driver, based on the existing SSE4.2 version. Using AVX2 instructions gives better performance than the SSE version, though the percentage increase depends on the exact settings used. For example:

Hi Bruce,

Just curious, can you provide some hints on percent increase in at least some representative cases? I'm just trying to get a sense of if this is %5, 10%, 20%, more... I know mileage will vary depending on system, setup, configuration, etc.

Thanks,
John

Quoted 31 lines

* Using 16B rather than 32B descriptors gives the biggest benefit since 2 descriptors at a time can be read, rather than just 1 when 32B ones are used.
* Bigger burst sizes for RX gives improved performance - while we see an improvement with testpmd with the default burst size of 32, burst sizes of up to 128 give further improvements
* In my testing, most of the improvement comes from faster processing on the RX path, though the improved TX also gives benefit.

This has been tested on a system with CPU: "Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz", and I've focused on testing with Rx ring sizes of approx 1k - generally --rxd=1024 and --txd=512, rather than the defaults which tend to give poorer zero-loss performance due to the smaller amount of buffering.

V2:
* Fixed incorrect config variable reference in makefile
* Added missing stub function for when vector drivers are disabled
* Added missing references to the new functions when checking for vector code paths, e.g. for ring tear-down

Bruce Richardson (2):
net/i40e: add AVX2 Tx function
net/i40e: add AVX2 Rx function

 drivers/net/i40e/Makefile             |  19 +
 drivers/net/i40e/i40e_rxtx.c          |  66 ++-
 drivers/net/i40e/i40e_rxtx.h          |   6 +
 drivers/net/i40e/i40e_rxtx_vec_avx2.c | 792 ++++++++++++++++++++++++++++++++++
 4 files changed, 880 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/i40e/i40e_rxtx_vec_avx2.c
#11 lore raw
Quoted 17 lines

-----Original Message-----
From: John Fastabend [mailto:[email protected]]
Sent: Tuesday, January 9, 2018 4:31 PM
To: Richardson, Bruce; Zhang, Qi Z; Xing, Beilei
Cc: [email protected]; Zhang, Helin; Yigit, Ferruh
Subject: Re: [dpdk-dev] [PATCH v2 0/2] AVX2 Vectorized Rx/Tx functions for i40e

Quoted 5 lines · Bruce Richardson

This patch adds an AVX2 vectorized path to the i40e driver, based on the existing SSE4.2 version. Using AVX2 instructions gives better performance than the SSE version, though the percentage increase depends on the exact settings used. For example:

Quoted 7 lines

Hi Bruce,

Just curious, can you provide some hints on percent increase in at least some representative cases? I'm just trying to get a sense of if this is %5, 10%, 20%, more... I know mileage will vary depending on system, setup, configuration, etc.

Best case conditions to test under are using testpmd as that is where any IO improvement will be most seen. As a ballpark figure though, on my system while testing testpmd with both 16B and 32B descriptors, (RX/TX ring sizes 1024/512) I saw ~15% performance increase, and sometimes quite a bit higher, e.g. when testing with 16B descriptors with larger burst sizes. As you say system, setup, config all has an impact, so YMMV... :-).

/Bruce

#12 lore raw

Le 10/01/2018 à 10:27, Richardson, Bruce a écrit :

Quoted 8 lines
Quoted 7 lines

Hi Bruce,

Just curious, can you provide some hints on percent increase in at least some representative cases? I'm just trying to get a sense of if this is %5, 10%, 20%, more... I know mileage will vary depending on system, setup, configuration, etc.

Best case conditions to test under are using testpmd as that is where any IO improvement will be most seen. As a ballpark figure though, on my system while testing testpmd with both 16B and 32B descriptors, (RX/TX ring sizes 1024/512) I saw ~15% performance increase, and sometimes quite a bit higher, e.g. when testing with 16B descriptors with larger burst sizes.

Hi Bruce,

Then, about the next limit after this performance increase: is it the board/Mpps capacity/PCI bus? If so, you should see that CPU usage on testpmd's cores to be decreased. Can you be more explicit about it?

What's about other packet size like 66 bytes? 122 bytes? which are not aligned on 64 bytes.

Thank you,
Vincent

#13 lore raw
Quoted 8 lines · Vincent JARDIN

Le 10/01/2018 à 10:27, Richardson, Bruce a écrit :

Quoted 7 lines
Quoted 7 lines

Hi Bruce,

Just curious, can you provide some hints on percent increase in at least some representative cases? I'm just trying to get a sense of if this is %5, 10%, 20%, more... I know mileage will vary depending on system, setup, configuration, etc.

Quoted 8 lines
Quoted 1 line

Best case conditions to test under are using testpmd as that is where any IO improvement will be most seen. As a ballpark figure though, on my system while testing testpmd with both 16B and 32B descriptors, (RX/TX ring sizes 1024/512) I saw ~15% performance increase, and sometimes quite a bit higher, e.g. when testing with 16B descriptors with larger burst sizes.

Hi Bruce,

Then, about the next limit after this performance increase: is it the board/Mpps capacity/PCI bus? If so, you should see that CPU usage on testpmd's cores to be decreased. Can you be more explicit about it?

Hi Vincent,

again it really depends on your setup. In my case I was using 2 NICs with 1x40G ports each, and each one using a PCI Gen3 x8 connection to CPU. I chose this particular setup because there is sufficient NIC capacity and PCI bandwidth available that for 64-byte packet sizes, there will be more IO available than a single core can handle. This patchset basically reduces the cycles needed for a core to process each packet, so in cases where the core is the bottleneck you will get improved performance. For other cases where PCI or NIC capability is the issue this patch almost certainly won't help, as there are no changes to the way in which the NIC descriptor ring is used, e.g. no changes to descriptor write-back over PCI etc.

Quoted 3 lines

What's about other packet size like 66 bytes? 122 bytes? which are not aligned on 64 bytes.

Sorry, I don't have comparison data for that to share.

/Bruce

Acked-by on the v2 series
#14 lore raw
In reply to Bruce Richardson

Hi

After perf test, with right setting, the perf can improve about 20%.

Quoted 43 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Tuesday, January 9, 2018 22:33
To: Zhang, Qi Z <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Zhang, Helin <[email protected]>; Yigit, Ferruh <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/2] AVX2 Vectorized Rx/Tx functions for i40e

This patch adds an AVX2 vectorized path to the i40e driver, based on the existing SSE4.2 version. Using AVX2 instructions gives better performance than the SSE version, though the percentage increase depends on the exact settings used. For example:

* Using 16B rather than 32B descriptors gives the biggest benefit since 2 descriptors at a time can be read, rather than just 1 when 32B ones are used.
* Bigger burst sizes for RX gives improved performance - while we see an improvement with testpmd with the default burst size of 32, burst sizes of up to 128 give further improvements
* In my testing, most of the improvement comes from faster processing on the RX path, though the improved TX also gives benefit.

This has been tested on a system with CPU: "Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz", and I've focused on testing with Rx ring sizes of approx 1k - generally --rxd=1024 and --txd=512, rather than the defaults which tend to give poorer zero-loss performance due to the smaller amount of buffering.

V2:
* Fixed incorrect config variable reference in makefile
* Added missing stub function for when vector drivers are disabled
* Added missing references to the new functions when checking for vector code paths, e.g. for ring tear-down

Bruce Richardson (2):
net/i40e: add AVX2 Tx function
net/i40e: add AVX2 Rx function

 drivers/net/i40e/Makefile             |  19 +
 drivers/net/i40e/i40e_rxtx.c          |  66 ++-
 drivers/net/i40e/i40e_rxtx.h          |   6 +
 drivers/net/i40e/i40e_rxtx_vec_avx2.c | 792
++++++++++++++++++++++++++++++++++
 4 files changed, 880 insertions(+), 3 deletions(-)  create mode 100644
Quoted 4 lines

drivers/net/i40e/i40e_rxtx_vec_avx2.c

--
2.14.3

Acked-by on the v2 series
#15 lore raw
In reply to Bruce Richardson
Quoted 45 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Tuesday, January 9, 2018 10:33 PM
To: Zhang, Qi Z <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Zhang, Helin <[email protected]>; Yigit, Ferruh <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH v2 0/2] AVX2 Vectorized Rx/Tx functions for i40e

This patch adds an AVX2 vectorized path to the i40e driver, based on the existing SSE4.2 version. Using AVX2 instructions gives better performance than the SSE version, though the percentage increase depends on the exact settings used. For example:

* Using 16B rather than 32B descriptors gives the biggest benefit since 2 descriptors at a time can be read, rather than just 1 when 32B ones are used.
* Bigger burst sizes for RX gives improved performance - while we see an improvement with testpmd with the default burst size of 32, burst sizes of up to 128 give further improvements
* In my testing, most of the improvement comes from faster processing on the RX path, though the improved TX also gives benefit.

This has been tested on a system with CPU: "Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz", and I've focused on testing with Rx ring sizes of approx 1k - generally --rxd=1024 and --txd=512, rather than the defaults which tend to give poorer zero-loss performance due to the smaller amount of buffering.

V2:
* Fixed incorrect config variable reference in makefile
* Added missing stub function for when vector drivers are disabled
* Added missing references to the new functions when checking for vector code paths, e.g. for ring tear-down

Bruce Richardson (2):
net/i40e: add AVX2 Tx function
net/i40e: add AVX2 Rx function

 drivers/net/i40e/Makefile             |  19 +
 drivers/net/i40e/i40e_rxtx.c          |  66 ++-
 drivers/net/i40e/i40e_rxtx.h          |   6 +
 drivers/net/i40e/i40e_rxtx_vec_avx2.c | 792
++++++++++++++++++++++++++++++++++
 4 files changed, 880 insertions(+), 3 deletions(-)  create mode 100644
Quoted 4 lines

drivers/net/i40e/i40e_rxtx_vec_avx2.c

--
2.14.3

Applied
#16 lore raw
Quoted 59 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Wednesday, January 10, 2018 3:15 PM
To: Richardson, Bruce; Xing, Beilei
Cc: [email protected]; Zhang, Helin; Yigit, Ferruh
Subject: RE: [PATCH v2 0/2] AVX2 Vectorized Rx/Tx functions for i40e

Quoted 48 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Tuesday, January 9, 2018 10:33 PM
To: Zhang, Qi Z <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Zhang, Helin <[email protected]>; Yigit, Ferruh <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH v2 0/2] AVX2 Vectorized Rx/Tx functions for i40e

This patch adds an AVX2 vectorized path to the i40e driver, based on the existing SSE4.2 version. Using AVX2 instructions gives better performance than the SSE version, though the percentage increase depends on the exact settings used. For example:

* Using 16B rather than 32B descriptors gives the biggest benefit since 2 descriptors at a time can be read, rather than just 1 when 32B ones are used.
* Bigger burst sizes for RX gives improved performance - while we see an improvement with testpmd with the default burst size of 32, burst sizes of up to 128 give further improvements
* In my testing, most of the improvement comes from faster processing on the RX path, though the improved TX also gives benefit.

This has been tested on a system with CPU: "Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz", and I've focused on testing with Rx ring sizes of approx 1k - generally
--rxd=1024 and --txd=512, rather than the defaults which tend to give poorer zero-loss performance due to the smaller amount of buffering.

V2:
* Fixed incorrect config variable reference in makefile
* Added missing stub function for when vector drivers are disabled
* Added missing references to the new functions when checking for vector code paths, e.g. for ring tear-down

Bruce Richardson (2):
net/i40e: add AVX2 Tx function
net/i40e: add AVX2 Rx function

 drivers/net/i40e/Makefile             |  19 +
 drivers/net/i40e/i40e_rxtx.c          |  66 ++-
 drivers/net/i40e/i40e_rxtx.h          |   6 +
 drivers/net/i40e/i40e_rxtx_vec_avx2.c | 792
++++++++++++++++++++++++++++++++++
 4 files changed, 880 insertions(+), 3 deletions(-)  create mode

100644 drivers/net/i40e/i40e_rxtx_vec_avx2.c

Quoted 4 lines
Quoted 2 lines

--
2.14.3

Applied to dpdk-next-net-intel, with minor commit log changes. Thanks!

/Helin