net/nfp: implement the burst mode get operation

Message ID 20241218063036.1697438-1-chaoyong.he@corigine.com (mailing list archive)
State Superseded, archived
Delegated to: Stephen Hemminger
Headers
Series 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/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS

Commit Message

Chaoyong He Dec. 18, 2024, 6:30 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>
---
 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(+)
  

Comments

Stephen Hemminger Dec. 18, 2024, 4:39 p.m. UTC | #1
On Wed, 18 Dec 2024 14:30:36 +0800
Chaoyong He <chaoyong.he@corigine.com> wrote:

> +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) {
> +		snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
> +				"Scalar");
> +	} else if (pkt_burst == nfp_net_vec_avx2_recv_pkts) {
> +		snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
> +				"Vector AVX2");
> +	} else {
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +

The coccinelle script want to replace that snprintf with strlcpy

Also don't need {} for one line statement but its ok as is.
  
Chaoyong He Dec. 19, 2024, 1:25 a.m. UTC | #2
> On Wed, 18 Dec 2024 14:30:36 +0800
> Chaoyong He <chaoyong.he@corigine.com> wrote:
> 
> > +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) {
> > +		snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE,
> "%s",
> > +				"Scalar");
> > +	} else if (pkt_burst == nfp_net_vec_avx2_recv_pkts) {
> > +		snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE,
> "%s",
> > +				"Vector AVX2");
> > +	} else {
> > +		return -EINVAL;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> 
> The coccinelle script want to replace that snprintf with strlcpy
> 
> Also don't need {} for one line statement but its ok as is.

Okay, I will send a new version patch.
  

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..3435371aaa 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) {
+		snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
+				"Scalar");
+	} else if (pkt_burst == nfp_net_vec_avx2_recv_pkts) {
+		snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
+				"Vector AVX2");
+	} 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) {
+		snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
+				"NFD3 Scalar");
+	} else if (pkt_burst == nfp_net_nfdk_xmit_pkts) {
+		snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
+				"NFDk Scalar");
+	} else if (pkt_burst == nfp_net_nfdk_vec_avx2_xmit_pkts) {
+		snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
+				"NFDk Vector AVX2");
+	} 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);