[v2] net/nfp: implement the burst mode get operation

Message ID 20241219014954.1763729-1-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Stephen Hemminger
Headers
Series [v2] net/nfp: implement the burst mode get operation |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-abi-testing pending Testing pending
ci/iol-compile-amd64-testing success Testing PASS

Commit Message

Chaoyong He Dec. 19, 2024, 1:49 a.m. UTC
Implement the burst mode get operation functions for both Rx and Tx.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
v2:
* Replace 'snprintf()' with 'strlcpy()'.
---
 drivers/net/nfp/nfp_ethdev.c    |  2 ++
 drivers/net/nfp/nfp_ethdev_vf.c |  2 ++
 drivers/net/nfp/nfp_rxtx.c      | 46 +++++++++++++++++++++++++++++++++
 drivers/net/nfp/nfp_rxtx.h      |  4 +++
 4 files changed, 54 insertions(+)
  

Patch

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index f54483822f..df5482f74a 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -985,6 +985,8 @@  static const struct eth_dev_ops nfp_net_eth_dev_ops = {
 	.get_module_eeprom      = nfp_net_get_module_eeprom,
 	.dev_led_on             = nfp_net_led_on,
 	.dev_led_off            = nfp_net_led_off,
+	.rx_burst_mode_get      = nfp_net_rx_burst_mode_get,
+	.tx_burst_mode_get      = nfp_net_tx_burst_mode_get,
 };
 
 static inline void
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 36b98dc0c2..23fa5b82ad 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -232,6 +232,8 @@  static const struct eth_dev_ops nfp_netvf_eth_dev_ops = {
 	.tx_queue_release       = nfp_net_tx_queue_release,
 	.rx_queue_intr_enable   = nfp_rx_queue_intr_enable,
 	.rx_queue_intr_disable  = nfp_rx_queue_intr_disable,
+	.rx_burst_mode_get      = nfp_net_rx_burst_mode_get,
+	.tx_burst_mode_get      = nfp_net_tx_burst_mode_get,
 };
 
 static inline void
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 35fb637b21..57c0b7351b 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -12,6 +12,7 @@ 
 
 #include "nfd3/nfp_nfd3.h"
 #include "nfdk/nfp_nfdk.h"
+#include "nfdk/nfp_nfdk_vec.h"
 #include "flower/nfp_flower.h"
 
 #include "nfp_ipsec.h"
@@ -893,3 +894,48 @@  nfp_net_recv_pkts_set(struct rte_eth_dev *eth_dev)
 	else
 		eth_dev->rx_pkt_burst = nfp_net_recv_pkts;
 }
+
+int
+nfp_net_rx_burst_mode_get(struct rte_eth_dev *eth_dev,
+		uint16_t queue_id __rte_unused,
+		struct rte_eth_burst_mode *mode)
+{
+	eth_rx_burst_t pkt_burst;
+
+	pkt_burst = eth_dev->rx_pkt_burst;
+	if (pkt_burst == nfp_net_recv_pkts) {
+		strlcpy(mode->info, "Scalar",
+				RTE_ETH_BURST_MODE_INFO_SIZE);
+	} else if (pkt_burst == nfp_net_vec_avx2_recv_pkts) {
+		strlcpy(mode->info, "Vector AVX2",
+				RTE_ETH_BURST_MODE_INFO_SIZE);
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+int
+nfp_net_tx_burst_mode_get(struct rte_eth_dev *eth_dev,
+		uint16_t queue_id __rte_unused,
+		struct rte_eth_burst_mode *mode)
+{
+	eth_tx_burst_t pkt_burst;
+
+	pkt_burst = eth_dev->tx_pkt_burst;
+	if (pkt_burst == nfp_net_nfd3_xmit_pkts) {
+		strlcpy(mode->info, "NFD3 Scalar",
+				RTE_ETH_BURST_MODE_INFO_SIZE);
+	} else if (pkt_burst == nfp_net_nfdk_xmit_pkts) {
+		strlcpy(mode->info, "NFDk Scalar",
+				RTE_ETH_BURST_MODE_INFO_SIZE);
+	} else if (pkt_burst == nfp_net_nfdk_vec_avx2_xmit_pkts) {
+		strlcpy(mode->info, "NFDk Vector AVX2",
+				RTE_ETH_BURST_MODE_INFO_SIZE);
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index c717d97003..48cbd83787 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -245,6 +245,10 @@  void nfp_net_tx_queue_info_get(struct rte_eth_dev *dev,
 		uint16_t queue_id,
 		struct rte_eth_txq_info *qinfo);
 void nfp_net_recv_pkts_set(struct rte_eth_dev *eth_dev);
+int nfp_net_rx_burst_mode_get(struct rte_eth_dev *eth_dev, uint16_t queue_id,
+		struct rte_eth_burst_mode *mode);
+int nfp_net_tx_burst_mode_get(struct rte_eth_dev *eth_dev, uint16_t queue_id,
+		struct rte_eth_burst_mode *mode);
 void nfp_net_parse_ptype(struct nfp_net_rxq *rxq,
 		struct nfp_net_rx_desc *rxds,
 		struct rte_mbuf *mb);