Skip to contentSkip to conversation

net/hns3: support SVE Tx/Rx

PATCH In review Wei Hu (Xavier) 4 participants 7 messages Oct 14, 2020 – Oct 27, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover net/hns3: support SVE Tx/Rx

This series add support SVE Tx/Rx operation.

Chengwen Feng (1):
net/hns3: support SVE Tx

Wei Hu (Xavier) (1):
net/hns3: support SVE Rx

 drivers/net/hns3/hns3_rxtx.c         |  43 +++-
 drivers/net/hns3/hns3_rxtx.h         |   4 +
 drivers/net/hns3/hns3_rxtx_vec.h     |  34 ++-
 drivers/net/hns3/hns3_rxtx_vec_sve.c | 472 +++++++++++++++++++++++++++++++++++
 drivers/net/hns3/meson.build         |   5 +
 5 files changed, 541 insertions(+), 17 deletions(-)
 create mode 100644 drivers/net/hns3/hns3_rxtx_vec_sve.c
Signature · 1 line
2.9.5
#1 lore raw

PATCH 1/2 net/hns3: support SVE Rx

From: "Wei Hu (Xavier)" <[email protected]>

This patch adds SVE vector instructions to optimize Rx burst process.

---
 drivers/net/hns3/hns3_rxtx.c         |  28 +++-
 drivers/net/hns3/hns3_rxtx.h         |   2 +
 drivers/net/hns3/hns3_rxtx_vec_sve.c | 313 +++++++++++++++++++++++++++++++++++
 drivers/net/hns3/meson.build         |   5 +
 4 files changed, 346 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/hns3/hns3_rxtx_vec_sve.c
drivers/net/hns3/hns3_rxtx.c +26 -2
index 60f110c..e1ff173 100644
@@ -23,6 +23,9 @@
 #include <rte_net.h>
 #include <rte_malloc.h>
 #include <rte_pci.h>
+#if defined(RTE_ARCH_ARM64) && defined(CC_SVE_SUPPORT)
+#include <rte_cpuflags.h>
+#endif
 
 #include "hns3_ethdev.h"
 #include "hns3_rxtx.h"
@@ -1841,7 +1844,8 @@ hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev)
 
 	if (dev->rx_pkt_burst == hns3_recv_pkts ||
 	    dev->rx_pkt_burst == hns3_recv_scattered_pkts ||
-	    dev->rx_pkt_burst == hns3_recv_pkts_vec)
+	    dev->rx_pkt_burst == hns3_recv_pkts_vec ||
+	    dev->rx_pkt_burst == hns3_recv_pkts_vec_sve)
 		return ptypes;
 
 	return NULL;
@@ -2347,6 +2351,14 @@ hns3_recv_pkts_vec(__rte_unused void *tx_queue,
 	return 0;
 }
 
+uint16_t __rte_weak
+hns3_recv_pkts_vec_sve(__rte_unused void *tx_queue,
+		       __rte_unused struct rte_mbuf **tx_pkts,
+		       __rte_unused uint16_t nb_pkts)
+{
+	return 0;
+}
+
 int
 hns3_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 		       struct rte_eth_burst_mode *mode)
@@ -2358,6 +2370,7 @@ hns3_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 		{ hns3_recv_pkts,		"Scalar" },
 		{ hns3_recv_scattered_pkts,	"Scalar Scattered" },
 		{ hns3_recv_pkts_vec,		"Vector Neon" },
+		{ hns3_recv_pkts_vec_sve,	"Vector Sve" },
 	};
 
 	eth_rx_burst_t pkt_burst = dev->rx_pkt_burst;
@@ -2376,6 +2389,16 @@ hns3_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 	return ret;
 }
 
+static bool
+hns3_check_sve_support(void)
+{
+#if defined(RTE_ARCH_ARM64) && defined(CC_SVE_SUPPORT)
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SVE))
+		return true;
+#endif
+	return false;
+}
+
 static eth_rx_burst_t
 hns3_get_rx_function(struct rte_eth_dev *dev)
 {
@@ -2383,7 +2406,8 @@ hns3_get_rx_function(struct rte_eth_dev *dev)
 	uint64_t offloads = dev->data->dev_conf.rxmode.offloads;
 
 	if (hns->rx_vec_allowed && hns3_rx_check_vec_support(dev) == 0)
-		return hns3_recv_pkts_vec;
+		return hns3_check_sve_support() ? hns3_recv_pkts_vec_sve :
+		       hns3_recv_pkts_vec;
 
 	if (hns->rx_simple_allowed && !dev->data->scattered_rx &&
 	    (offloads & DEV_RX_OFFLOAD_TCP_LRO) == 0)
drivers/net/hns3/hns3_rxtx.h +2 -0
index abc7c54..ba1b017 100644
@@ -630,6 +630,8 @@ uint16_t hns3_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 				  uint16_t nb_pkts);
 uint16_t hns3_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			    uint16_t nb_pkts);
+uint16_t hns3_recv_pkts_vec_sve(void *rx_queue, struct rte_mbuf **rx_pkts,
+				uint16_t nb_pkts);
 int hns3_rx_burst_mode_get(struct rte_eth_dev *dev,
 			   __rte_unused uint16_t queue_id,
 			   struct rte_eth_burst_mode *mode);
drivers/net/hns3/hns3_rxtx_vec_sve.c new file +313 -0

313 lines not on this page · raw message

drivers/net/hns3/meson.build +5 -0
index bf69ad4..ca0f21a 100644
@@ -31,4 +31,9 @@ deps += ['hash']
 
 if arch_subdir == 'arm' and dpdk_conf.get('RTE_ARCH_64')
 	sources += files('hns3_rxtx_vec.c')
+	if (dpdk_conf.has('RTE_MACHINE_CPUFLAG_SVE'))
+		dpdk_conf.set('RTE_LIBRTE_HNS3_INC_VECTOR_SVE', 1)
+		cflags = ['-DCC_SVE_SUPPORT']
+		sources += files('hns3_rxtx_vec_sve.c')
+	endif
 endif
Signature · 1 line
2.9.5
#5 lore raw

PATCH 2/2 net/hns3: support SVE Tx

In reply to Wei Hu (Xavier)

From: Chengwen Feng <[email protected]>

This patch adds SVE vector instructions to optimize Tx burst process.

---
 drivers/net/hns3/hns3_rxtx.c         |  17 +++-
 drivers/net/hns3/hns3_rxtx.h         |   2 +
 drivers/net/hns3/hns3_rxtx_vec.h     |  34 +++++---
 drivers/net/hns3/hns3_rxtx_vec_sve.c | 159 +++++++++++++++++++++++++++++++++++
 4 files changed, 196 insertions(+), 16 deletions(-)
drivers/net/hns3/hns3_rxtx.c +14 -3
index e1ff173..d511908 100644
@@ -2345,7 +2345,7 @@ hns3_rx_check_vec_support(__rte_unused struct rte_eth_dev *dev)
 
 uint16_t __rte_weak
 hns3_recv_pkts_vec(__rte_unused void *tx_queue,
-		   __rte_unused struct rte_mbuf **tx_pkts,
+		   __rte_unused struct rte_mbuf **rx_pkts,
 		   __rte_unused uint16_t nb_pkts)
 {
 	return 0;
@@ -2353,7 +2353,7 @@ hns3_recv_pkts_vec(__rte_unused void *tx_queue,
 
 uint16_t __rte_weak
 hns3_recv_pkts_vec_sve(__rte_unused void *tx_queue,
-		       __rte_unused struct rte_mbuf **tx_pkts,
+		       __rte_unused struct rte_mbuf **rx_pkts,
 		       __rte_unused uint16_t nb_pkts)
 {
 	return 0;
@@ -3615,6 +3615,14 @@ hns3_xmit_pkts_vec(__rte_unused void *tx_queue,
 	return 0;
 }
 
+uint16_t __rte_weak
+hns3_xmit_pkts_vec_sve(void __rte_unused * tx_queue,
+		       struct rte_mbuf __rte_unused **tx_pkts,
+		       uint16_t __rte_unused nb_pkts)
+{
+	return 0;
+}
+
 int
 hns3_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 		       struct rte_eth_burst_mode *mode)
@@ -3628,6 +3636,8 @@ hns3_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 		info = "Scalar";
 	else if (pkt_burst == hns3_xmit_pkts_vec)
 		info = "Vector Neon";
+	else if (pkt_burst == hns3_xmit_pkts_vec_sve)
+		info = "Vector Sve";
 
 	if (info == NULL)
 		return -EINVAL;
@@ -3645,7 +3655,8 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep)
 
 	if (hns->tx_vec_allowed && hns3_tx_check_vec_support(dev) == 0) {
 		*prep = NULL;
-		return hns3_xmit_pkts_vec;
+		return hns3_check_sve_support() ? hns3_xmit_pkts_vec_sve :
+			hns3_xmit_pkts_vec;
 	}
 
 	if (hns->tx_simple_allowed &&
drivers/net/hns3/hns3_rxtx.h +2 -0
index ba1b017..4be9c4a 100644
@@ -644,6 +644,8 @@ uint16_t hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
 uint16_t hns3_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 							uint16_t nb_pkts);
+uint16_t hns3_xmit_pkts_vec_sve(void *tx_queue, struct rte_mbuf **tx_pkts,
+				uint16_t nb_pkts);
 int hns3_tx_burst_mode_get(struct rte_eth_dev *dev,
 			   __rte_unused uint16_t queue_id,
 			   struct rte_eth_burst_mode *mode);
drivers/net/hns3/hns3_rxtx_vec.h +21 -13
index c6df36d..35d9903 100644
@@ -9,26 +9,14 @@
 #include "hns3_ethdev.h"
 
 static inline void
-hns3_tx_free_buffers(struct hns3_tx_queue *txq)
+hns3_tx_bulk_free_buffers(struct hns3_tx_queue *txq)
 {
 	struct rte_mbuf **free = txq->free;
 	struct hns3_entry *tx_entry;
-	struct hns3_desc *tx_desc;
 	struct rte_mbuf *m;
 	int nb_free = 0;
 	int i;
 
-	/*
-	 * All mbufs can be released only when the VLD bits of all
-	 * descriptors in a batch are cleared.
-	 */
-	tx_desc = &txq->tx_ring[txq->next_to_clean];
-	for (i = 0; i < txq->tx_rs_thresh; i++, tx_desc++) {
-		if (tx_desc->tx.tp_fe_sc_vld_ra_ri &
-				rte_le_to_cpu_16(BIT(HNS3_TXD_VLD_B)))
-			return;
-	}
-
 	tx_entry = &txq->sw_ring[txq->next_to_clean];
 	for (i = 0; i < txq->tx_rs_thresh; i++, tx_entry++) {
 		m = rte_pktmbuf_prefree_seg(tx_entry->mbuf);
@@ -55,6 +43,26 @@ hns3_tx_free_buffers(struct hns3_tx_queue *txq)
 		txq->next_to_clean = 0;
 }
 
+static inline void
+hns3_tx_free_buffers(struct hns3_tx_queue *txq)
+{
+	struct hns3_desc *tx_desc;
+	int i;
+
+	/*
+	 * All mbufs can be released only when the VLD bits of all
+	 * descriptors in a batch are cleared.
+	 */
+	tx_desc = &txq->tx_ring[txq->next_to_clean];
+	for (i = 0; i < txq->tx_rs_thresh; i++, tx_desc++) {
+		if (tx_desc->tx.tp_fe_sc_vld_ra_ri &
+				rte_le_to_cpu_16(BIT(HNS3_TXD_VLD_B)))
+			return;
+	}
+
+	hns3_tx_bulk_free_buffers(txq);
+}
+
 static inline uint16_t
 hns3_rx_reassemble_pkts(struct rte_mbuf **rx_pkts,
 			uint16_t nb_pkts,
drivers/net/hns3/hns3_rxtx_vec_sve.c +159 -0

162 lines not on this page · raw message

Signature · 1 line
2.9.5
#6 lore raw
In reply to Wei Hu (Xavier)
Quoted 8 lines · Wei Hu (Xavier)

This series add support SVE Tx/Rx operation.

Chengwen Feng (1):
net/hns3: support SVE Tx

Wei Hu (Xavier) (1):
net/hns3: support SVE Rx

Series applied to dpdk-next-net/main, thanks.

#2 lore raw

Re: [dpdk-dev] [PATCH 1/2] net/hns3: support SVE Rx

In reply to Wei Hu (Xavier)

Hello Wei Hu,

Quoted 5 lines
drivers/net/hns3/meson.build +0 -0
index bf69ad4..ca0f21a 100644

drivers/net/hns3/meson.build deps += ['hash'] · line 39

Quoted 9 lines
drivers/net/hns3/meson.build +5 -0
@@ -31,4 +31,9 @@ deps += ['hash']
 
 if arch_subdir == 'arm' and dpdk_conf.get('RTE_ARCH_64')
        sources += files('hns3_rxtx_vec.c')
+       if (dpdk_conf.has('RTE_MACHINE_CPUFLAG_SVE'))
+               dpdk_conf.set('RTE_LIBRTE_HNS3_INC_VECTOR_SVE', 1)
+               cflags = ['-DCC_SVE_SUPPORT']
+               sources += files('hns3_rxtx_vec_sve.c')
+       endif
 endif

This patch is already merged in main, but RTE_MACHINE_CPUFLAG_* have been removed, see https://git.dpdk.org/dpdk/commit/?id=84fb33fec1
I guess SVE support is not working because of this.

Please use compiler flags to check for support.
If you need an example on how to do this, you can probably look at what has been done for Intel vector stuff.

Besides, RTE_LIBRTE_HNS3_INC_VECTOR_SVE is not used anywhere and can be removed.

Signature · 1 line
David Marchand
#3 lore raw

Re: [dpdk-dev] [PATCH 1/2] net/hns3: support SVE Rx

Quoted 21 lines · David Marchand

Hello Wei Hu,

Quoted 5 lines
drivers/net/hns3/meson.build +0 -0
index bf69ad4..ca0f21a 100644

drivers/net/hns3/meson.build deps += ['hash'] · line 39

Quoted 9 lines
drivers/net/hns3/meson.build +5 -0
@@ -31,4 +31,9 @@ deps += ['hash']
 
  if arch_subdir == 'arm' and dpdk_conf.get('RTE_ARCH_64')
         sources += files('hns3_rxtx_vec.c')
+       if (dpdk_conf.has('RTE_MACHINE_CPUFLAG_SVE'))
+               dpdk_conf.set('RTE_LIBRTE_HNS3_INC_VECTOR_SVE', 1)
+               cflags = ['-DCC_SVE_SUPPORT']
+               sources += files('hns3_rxtx_vec_sve.c')
+       endif
  endif

This patch is already merged in main, but RTE_MACHINE_CPUFLAG_* have been removed, see https://git.dpdk.org/dpdk/commit/?id=84fb33fec1
I guess SVE support is not working because of this.

Quoted 6 lines

Please use compiler flags to check for support.
If you need an example on how to do this, you can probably look at what has been done for Intel vector stuff.

Besides, RTE_LIBRTE_HNS3_INC_VECTOR_SVE is not used anywhere and can be removed.

Hi, David
Thank your reviews. Wei Hu has left and adjust the work. I will
review and upstream his work as a new developer. I will get your comments first and handle it latter.

Thanks
Lijun Ou

Quoted 1 line
#4 lore raw

Re: [dpdk-dev] [PATCH 1/2] net/hns3: support SVE Rx

In reply to David Marchand
Quoted 21 lines · David Marchand

Hello Wei Hu,

Quoted 5 lines
drivers/net/hns3/meson.build +0 -0
index bf69ad4..ca0f21a 100644

drivers/net/hns3/meson.build deps += ['hash'] · line 39

Quoted 9 lines
drivers/net/hns3/meson.build +5 -0
@@ -31,4 +31,9 @@ deps += ['hash']
 
  if arch_subdir == 'arm' and dpdk_conf.get('RTE_ARCH_64')
         sources += files('hns3_rxtx_vec.c')
+       if (dpdk_conf.has('RTE_MACHINE_CPUFLAG_SVE'))
+               dpdk_conf.set('RTE_LIBRTE_HNS3_INC_VECTOR_SVE', 1)
+               cflags = ['-DCC_SVE_SUPPORT']
+               sources += files('hns3_rxtx_vec_sve.c')
+       endif
  endif

This patch is already merged in main, but RTE_MACHINE_CPUFLAG_* have been removed, see https://git.dpdk.org/dpdk/commit/?id=84fb33fec1
I guess SVE support is not working because of this.

Quoted 6 lines

Please use compiler flags to check for support.
If you need an example on how to do this, you can probably look at what has been done for Intel vector stuff.

Besides, RTE_LIBRTE_HNS3_INC_VECTOR_SVE is not used anywhere and can be removed.

Hi,David Marchand
I have checked. I will send a fix patch for enabling.

Thanks
Lijun Ou

Quoted 1 line