From 423959cfe25c9dc231b80f3df59318585df3a023 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Thu, 19 Jan 2023 12:30:56 +0000
Subject: net/vhost: support private dump

[ upstream commit 47b9fb64c15d60e1c8c2c8f6e63824fd2cada428 ]

This patch implements eth_dev_priv_dump callback which could use for
debugging.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 drivers/net/vhost/rte_eth_vhost.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 070f0e6dfd..b120341d0c 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -1429,6 +1429,23 @@ vhost_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
 	return 0;
 }
 
+static int
+vhost_dev_priv_dump(struct rte_eth_dev *dev, FILE *f)
+{
+	struct pmd_internal *internal = dev->data->dev_private;
+
+	fprintf(f, "iface_name: %s\n", internal->iface_name);
+	fprintf(f, "flags: 0x%" PRIx64 "\n", internal->flags);
+	fprintf(f, "disable_flags: 0x%" PRIx64 "\n", internal->disable_flags);
+	fprintf(f, "max_queues: %u\n", internal->max_queues);
+	fprintf(f, "vid: %d\n", internal->vid);
+	fprintf(f, "started: %d\n", rte_atomic32_read(&internal->started));
+	fprintf(f, "dev_attached: %d\n", rte_atomic32_read(&internal->dev_attached));
+	fprintf(f, "vlan_strip: %d\n", internal->vlan_strip);
+
+	return 0;
+}
+
 static const struct eth_dev_ops ops = {
 	.dev_start = eth_dev_start,
 	.dev_stop = eth_dev_stop,
@@ -1449,6 +1466,7 @@ static const struct eth_dev_ops ops = {
 	.rx_queue_intr_enable = eth_rxq_intr_enable,
 	.rx_queue_intr_disable = eth_rxq_intr_disable,
 	.get_monitor_addr = vhost_get_monitor_addr,
+	.eth_dev_priv_dump = vhost_dev_priv_dump,
 };
 
 static int
-- 
2.23.0

