[v4,1/1] net/octeontx2: add Rx/Tx burst mode get callbacks

Message ID 20191111081615.21113-1-skori@marvell.com (mailing list archive)
State Superseded, archived
Headers
Series [v4,1/1] net/octeontx2: add Rx/Tx burst mode get callbacks |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Performance-Testing fail build patch failure
ci/travis-robot success Travis build: passed
ci/Intel-compilation fail Compilation issues

Commit Message

Sunil Kumar Kori Nov. 11, 2019, 8:16 a.m. UTC
  Retrieve burst mode information according to the selected Rx/Tx mode and
offloads.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v4:
 - Review comments incorporated.
v3:
 - Rebased the patch over patches.dpdk.org/patch/62368/
v2:
 - Rebased the patch on latest commit.
 - Update feature matrix for the support.

 doc/guides/nics/features/octeontx2.ini  |   1 +
 drivers/net/octeontx2/otx2_ethdev.c     |   2 +
 drivers/net/octeontx2/otx2_ethdev.h     |   4 +
 drivers/net/octeontx2/otx2_ethdev_ops.c | 195 ++++++++++++++++++++++++
 4 files changed, 202 insertions(+)
  

Patch

diff --git a/doc/guides/nics/features/octeontx2.ini b/doc/guides/nics/features/octeontx2.ini
index 7c59b4383..c2a3f47b0 100644
--- a/doc/guides/nics/features/octeontx2.ini
+++ b/doc/guides/nics/features/octeontx2.ini
@@ -13,6 +13,7 @@  Link status          = Y
 Link status event    = Y
 Runtime Rx queue setup = Y
 Runtime Tx queue setup = Y
+Burst mode info      = Y
 Fast mbuf free       = Y
 Free Tx mbuf on demand = Y
 Queue start/stop     = Y
diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c
index 62291c698..37b674bcb 100644
--- a/drivers/net/octeontx2/otx2_ethdev.c
+++ b/drivers/net/octeontx2/otx2_ethdev.c
@@ -1978,6 +1978,8 @@  static const struct eth_dev_ops otx2_eth_dev_ops = {
 	.xstats_get_names_by_id   = otx2_nix_xstats_get_names_by_id,
 	.rxq_info_get             = otx2_nix_rxq_info_get,
 	.txq_info_get             = otx2_nix_txq_info_get,
+	.rx_burst_mode_get        = otx2_rx_burst_mode_get,
+	.tx_burst_mode_get        = otx2_tx_burst_mode_get,
 	.rx_queue_count           = otx2_nix_rx_queue_count,
 	.rx_descriptor_done       = otx2_nix_rx_descriptor_done,
 	.rx_descriptor_status     = otx2_nix_rx_descriptor_status,
diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h
index 4d9ed4870..fd43789fe 100644
--- a/drivers/net/octeontx2/otx2_ethdev.h
+++ b/drivers/net/octeontx2/otx2_ethdev.h
@@ -388,6 +388,10 @@  void otx2_nix_rxq_info_get(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 			   struct rte_eth_rxq_info *qinfo);
 void otx2_nix_txq_info_get(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 			   struct rte_eth_txq_info *qinfo);
+int otx2_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
+			   struct rte_eth_burst_mode *mode);
+int otx2_tx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
+			   struct rte_eth_burst_mode *mode);
 uint32_t otx2_nix_rx_queue_count(struct rte_eth_dev *eth_dev, uint16_t qidx);
 int otx2_nix_tx_done_cleanup(void *txq, uint32_t free_cnt);
 int otx2_nix_rx_descriptor_done(void *rxq, uint16_t offset);
diff --git a/drivers/net/octeontx2/otx2_ethdev_ops.c b/drivers/net/octeontx2/otx2_ethdev_ops.c
index fc0fbd9f2..5db7a21b1 100644
--- a/drivers/net/octeontx2/otx2_ethdev_ops.c
+++ b/drivers/net/octeontx2/otx2_ethdev_ops.c
@@ -2,6 +2,7 @@ 
  * Copyright(C) 2019 Marvell International Ltd.
  */
 
+#include <rte_ethdev.h>
 #include <rte_mbuf_pool_ops.h>
 
 #include "otx2_ethdev.h"
@@ -221,6 +222,200 @@  otx2_nix_txq_info_get(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 	qinfo->conf.tx_deferred_start = 0;
 }
 
+int
+otx2_rx_burst_mode_get(struct rte_eth_dev *eth_dev,
+		       __rte_unused uint16_t queue_id,
+		       struct rte_eth_burst_mode *mode)
+{
+	ssize_t bytes = 0, str_size = RTE_ETH_BURST_MODE_INFO_SIZE, rc;
+	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+
+	if (dev->scalar_ena) {
+		rc = rte_strscpy(mode->info, "Scalar", str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	} else {
+		rc = rte_strscpy(mode->info, "Vector Neon", str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	rc = rte_strscpy(mode->info + bytes, ", Rx Offloads:",
+			 str_size - bytes);
+	if (rc < 0)
+		goto error;
+
+	bytes += rc;
+
+	if (dev->rx_offload_flags & NIX_RX_OFFLOAD_RSS_F) {
+		rc = rte_strscpy(mode->info + bytes, " RSS,", str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->rx_offload_flags & NIX_RX_OFFLOAD_PTYPE_F) {
+		rc = rte_strscpy(mode->info + bytes, " Ptype,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->rx_offload_flags & NIX_RX_OFFLOAD_CHECKSUM_F) {
+		rc = rte_strscpy(mode->info + bytes, " Checksum,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->rx_offload_flags & NIX_RX_OFFLOAD_VLAN_STRIP_F) {
+		rc = rte_strscpy(mode->info + bytes, " VLAN Strip,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->rx_offload_flags & NIX_RX_OFFLOAD_MARK_UPDATE_F) {
+		rc = rte_strscpy(mode->info + bytes, " Mark Update,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->rx_offload_flags & NIX_RX_OFFLOAD_TSTAMP_F) {
+		rc = rte_strscpy(mode->info + bytes, " Timestamp,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->rx_offload_flags & NIX_RX_MULTI_SEG_F) {
+		rc = rte_strscpy(mode->info + bytes, " Scattered,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	return 0;
+
+error:
+	return rc;
+}
+
+int
+otx2_tx_burst_mode_get(struct rte_eth_dev *eth_dev,
+		       __rte_unused uint16_t queue_id,
+		       struct rte_eth_burst_mode *mode)
+{
+	ssize_t bytes = 0, str_size = RTE_ETH_BURST_MODE_INFO_SIZE, rc;
+	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+
+	if (dev->scalar_ena) {
+		rc = rte_strscpy(mode->info, "Scalar", str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	} else {
+		rc = rte_strscpy(mode->info, "Vector Neon", str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	rc = rte_strscpy(mode->info + bytes, ", Tx Offloads:",
+			 str_size - bytes);
+	if (rc < 0)
+		goto error;
+
+	bytes += rc;
+
+	if (dev->tx_offload_flags & NIX_TX_OFFLOAD_L3_L4_CSUM_F) {
+		rc = rte_strscpy(mode->info + bytes, " Inner L3/L4 csum,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->tx_offload_flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F) {
+		rc = rte_strscpy(mode->info + bytes, " Outer L3/L4 csum,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->tx_offload_flags & NIX_TX_OFFLOAD_VLAN_QINQ_F) {
+		rc = rte_strscpy(mode->info + bytes, " VLAN Insertion,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->tx_offload_flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) {
+		rc = rte_strscpy(mode->info + bytes, " MBUF free disable,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->tx_offload_flags & NIX_TX_OFFLOAD_TSTAMP_F) {
+		rc = rte_strscpy(mode->info + bytes, " Timestamp,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->tx_offload_flags & NIX_TX_OFFLOAD_TSO_F) {
+		rc = rte_strscpy(mode->info + bytes, " TSO,", str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	if (dev->tx_offload_flags & NIX_RX_MULTI_SEG_F) {
+		rc = rte_strscpy(mode->info + bytes, " Scattered,",
+				 str_size - bytes);
+		if (rc < 0)
+			goto error;
+
+		bytes += rc;
+	}
+
+	return 0;
+
+error:
+	return rc;
+}
+
 static void
 nix_rx_head_tail_get(struct otx2_eth_dev *dev,
 		     uint32_t *head, uint32_t *tail, uint16_t queue_idx)