[RFC,v2,3/3] net/ice: support the Rx/Tx burst description trace
diff mbox series

Message ID 1565665572-65495-4-git-send-email-haiyue.wang@intel.com
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • show the Rx/Tx burst description field
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Haiyue Wang Aug. 13, 2019, 3:06 a.m. UTC
According to the Rx/Tx burst function that's selected currently, format
the distinct burst description information for apps to query.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 26 ++++++++++++++++++++++
 drivers/net/ice/ice_rxtx.c   | 52 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/ice_rxtx.h   |  4 ++++
 3 files changed, 82 insertions(+)

Patch
diff mbox series

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 44a14cb..bad5c23 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -99,6 +99,8 @@  static int ice_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
 			struct rte_eth_udp_tunnel *udp_tunnel);
 static int ice_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
 			struct rte_eth_udp_tunnel *udp_tunnel);
+static int ice_trace_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+			      enum rte_eth_trace type, char *buf, int sz);
 
 static const struct rte_pci_id pci_id_ice_map[] = {
 	{ RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E810C_BACKPLANE) },
@@ -147,6 +149,7 @@  static const struct eth_dev_ops ice_eth_dev_ops = {
 	.vlan_pvid_set                = ice_vlan_pvid_set,
 	.rxq_info_get                 = ice_rxq_info_get,
 	.txq_info_get                 = ice_txq_info_get,
+	.trace_info_get               = ice_trace_info_get,
 	.get_eeprom_length            = ice_get_eeprom_length,
 	.get_eeprom                   = ice_get_eeprom,
 	.rx_queue_count               = ice_rx_queue_count,
@@ -3765,6 +3768,29 @@  ice_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
 }
 
 static int
+ice_trace_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		   enum rte_eth_trace type, char *buf, int sz)
+{
+	int ret;
+
+	switch (type) {
+	case ETH_TRACE_RX_BURST:
+		ret = ice_rx_burst_info_get(dev, queue_id, buf, sz);
+		break;
+
+	case ETH_TRACE_TX_BURST:
+		ret = ice_tx_burst_info_get(dev, queue_id, buf, sz);
+		break;
+
+	default:
+		ret = -ENOTSUP;
+		break;
+	}
+
+	return ret;
+}
+
+static int
 ice_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	      struct rte_pci_device *pci_dev)
 {
diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 0282b53..43d52c2 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -2385,6 +2385,35 @@  ice_set_rx_function(struct rte_eth_dev *dev)
 	}
 }
 
+int
+ice_rx_burst_info_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
+		      char *buf, int sz)
+{
+	int len = 0;
+
+	if (dev->rx_pkt_burst == ice_recv_scattered_pkts)
+		len = snprintf(buf, sz, "Scattered Rx");
+	else if (dev->rx_pkt_burst == ice_recv_pkts_bulk_alloc)
+		len = snprintf(buf, sz, "Bulk Rx");
+	else if (dev->rx_pkt_burst == ice_recv_pkts)
+		len = snprintf(buf, sz, "Normal Rx");
+#ifdef RTE_ARCH_X86
+	else if (dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2)
+		len = snprintf(buf, sz, "AVX2 Vector Scattered Rx");
+	else if (dev->rx_pkt_burst == ice_recv_scattered_pkts_vec)
+		len = snprintf(buf, sz, "Vector Scattered Rx");
+	else if (dev->rx_pkt_burst == ice_recv_pkts_vec_avx2)
+		len = snprintf(buf, sz, "AVX2 Vector Rx");
+	else if (dev->rx_pkt_burst == ice_recv_pkts_vec)
+		len = snprintf(buf, sz, "Vector Rx");
+#endif
+
+	if (len >= sz)
+		len = -ENOSPC; /* The output was truncated */
+
+	return len;
+}
+
 void __attribute__((cold))
 ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq)
 {
@@ -2454,6 +2483,29 @@  ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	return i;
 }
 
+int
+ice_tx_burst_info_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
+		      char *buf, int sz)
+{
+	int len = 0;
+
+	if (dev->tx_pkt_burst == ice_xmit_pkts_simple)
+		len = snprintf(buf, sz, "Simple Tx");
+	else if (dev->tx_pkt_burst == ice_xmit_pkts)
+		len = snprintf(buf, sz, "Normal Tx");
+#ifdef RTE_ARCH_X86
+	else if (dev->tx_pkt_burst == ice_xmit_pkts_vec_avx2)
+		len = snprintf(buf, sz, "AVX2 Vector Tx");
+	else if (dev->tx_pkt_burst == ice_xmit_pkts_vec)
+		len = snprintf(buf, sz, "Vector Tx");
+#endif
+
+	if (len >= sz)
+		len = -ENOSPC; /* The output was truncated */
+
+	return len;
+}
+
 void __attribute__((cold))
 ice_set_tx_function(struct rte_eth_dev *dev)
 {
diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h
index e921411..f951088 100644
--- a/drivers/net/ice/ice_rxtx.h
+++ b/drivers/net/ice/ice_rxtx.h
@@ -188,4 +188,8 @@  uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue,
 					  uint16_t nb_pkts);
 uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
+int ice_rx_burst_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+			  char *buf, int sz);
+int ice_tx_burst_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+			  char *buf, int sz);
 #endif /* _ICE_RXTX_H_ */