diff mbox series

[3/9] net/dpaa: add Tx/Rx burst mode info

Message ID 20200710162137.22973-3-hemant.agrawal@nxp.com
State New
Headers show
Series [1/9] net/dpaa2: remove Rx timestamp enable PMD API | expand

Commit Message

Hemant Agrawal July 10, 2020, 4:21 p.m. UTC
From: Apeksha Gupta <apeksha.gupta@nxp.com>


Retrieve burst mode information according to the selected Rx/Tx mode
and offloads.

Signed-off-by: Apeksha Gupta <apeksha.gupta@nxp.com>

---
 doc/guides/nics/features/dpaa.ini |  1 +
 drivers/net/dpaa/dpaa_ethdev.c    | 70 ++++++++++++++++++++++++++++++-
 2 files changed, 70 insertions(+), 1 deletion(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/doc/guides/nics/features/dpaa.ini b/doc/guides/nics/features/dpaa.ini
index 816a6e08e..e0ed3e868 100644
--- a/doc/guides/nics/features/dpaa.ini
+++ b/doc/guides/nics/features/dpaa.ini
@@ -7,6 +7,7 @@ 
 Speed capabilities   = Y
 Link status          = Y
 Link status event    = Y
+Burst mode info      = Y
 Jumbo frame          = Y
 MTU update           = Y
 Scattered Rx         = Y
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 3a5b319d4..62ecb112f 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -457,6 +457,73 @@  static int dpaa_eth_dev_info(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+dpaa_dev_rx_burst_mode_get(struct rte_eth_dev *dev,
+			__rte_unused uint16_t queue_id,
+			struct rte_eth_burst_mode *mode)
+{
+	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
+	int ret = -EINVAL;
+	unsigned int i;
+	const struct burst_info {
+		uint64_t flags;
+		const char *output;
+	} rx_offload_map[] = {
+			{DEV_RX_OFFLOAD_JUMBO_FRAME, " Jumbo frame,"},
+			{DEV_RX_OFFLOAD_SCATTER, " Scattered,"},
+			{DEV_RX_OFFLOAD_IPV4_CKSUM, " IPV4 csum,"},
+			{DEV_RX_OFFLOAD_UDP_CKSUM, " UDP csum,"},
+			{DEV_RX_OFFLOAD_TCP_CKSUM, " TCP csum,"},
+			{DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM, " Outer IPV4 csum,"},
+			{DEV_RX_OFFLOAD_RSS_HASH, " RSS,"}
+	};
+
+	/* Update Rx offload info */
+	for (i = 0; i < RTE_DIM(rx_offload_map); i++) {
+		if (eth_conf->rxmode.offloads & rx_offload_map[i].flags) {
+			snprintf(mode->info, sizeof(mode->info), "%s",
+				rx_offload_map[i].output);
+			ret = 0;
+			break;
+		}
+	}
+	return ret;
+}
+
+static int
+dpaa_dev_tx_burst_mode_get(struct rte_eth_dev *dev,
+			__rte_unused uint16_t queue_id,
+			struct rte_eth_burst_mode *mode)
+{
+	struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
+	int ret = -EINVAL;
+	unsigned int i;
+	const struct burst_info {
+		uint64_t flags;
+		const char *output;
+	} tx_offload_map[] = {
+			{DEV_TX_OFFLOAD_MT_LOCKFREE, " MT lockfree,"},
+			{DEV_TX_OFFLOAD_MBUF_FAST_FREE, " MBUF free disable,"},
+			{DEV_TX_OFFLOAD_IPV4_CKSUM, " IPV4 csum,"},
+			{DEV_TX_OFFLOAD_UDP_CKSUM, " UDP csum,"},
+			{DEV_TX_OFFLOAD_TCP_CKSUM, " TCP csum,"},
+			{DEV_TX_OFFLOAD_SCTP_CKSUM, " SCTP csum,"},
+			{DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM, " Outer IPV4 csum,"},
+			{DEV_TX_OFFLOAD_MULTI_SEGS, " Scattered,"}
+	};
+
+	/* Update Tx offload info */
+	for (i = 0; i < RTE_DIM(tx_offload_map); i++) {
+		if (eth_conf->txmode.offloads & tx_offload_map[i].flags) {
+			snprintf(mode->info, sizeof(mode->info), "%s",
+				tx_offload_map[i].output);
+			ret = 0;
+			break;
+		}
+	}
+	return ret;
+}
+
 static int dpaa_eth_link_update(struct rte_eth_dev *dev,
 				int wait_to_complete __rte_unused)
 {
@@ -1182,7 +1249,8 @@  static struct eth_dev_ops dpaa_devops = {
 	.rx_queue_release	  = dpaa_eth_rx_queue_release,
 	.tx_queue_release	  = dpaa_eth_tx_queue_release,
 	.rx_queue_count		  = dpaa_dev_rx_queue_count,
-
+	.rx_burst_mode_get	  = dpaa_dev_rx_burst_mode_get,
+	.tx_burst_mode_get	  = dpaa_dev_tx_burst_mode_get,
 	.flow_ctrl_get		  = dpaa_flow_ctrl_get,
 	.flow_ctrl_set		  = dpaa_flow_ctrl_set,