DPDK patches and discussions
 help / color / mirror / Atom feed
From: Alex Vesker <valex@nvidia.com>
To: <valex@nvidia.com>, <viacheslavo@nvidia.com>,
	<thomas@monjalon.net>, <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>
Cc: <dev@dpdk.org>, <orika@nvidia.com>
Subject: [PATCH] net/mlx5: add debug support for dumping all rte ports
Date: Tue, 13 Dec 2022 11:28:49 +0200	[thread overview]
Message-ID: <20221213092849.7889-1-valex@nvidia.com> (raw)

Add a special value max_uint16 to request dump of all
rte ethernet ports. This is useful for collecting the
full info from all the ports in a single dump.

Signed-off-by: Alex Vesker <valex@nvidia.com>
Reviewed-by: Ori Kam <orika@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_socket.c | 39 ++++++++++++++++++----------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c
index 0e01aff0e7..ab1a8075f3 100644
--- a/drivers/net/mlx5/linux/mlx5_socket.c
+++ b/drivers/net/mlx5/linux/mlx5_socket.c
@@ -21,6 +21,7 @@
 /* PMD socket service for tools. */
 
 #define MLX5_SOCKET_PATH "/var/tmp/dpdk_net_mlx5_%d"
+#define MLX5_ALL_PORT_IDS 0xffff
 
 int server_socket = -1; /* Unix socket for primary process. */
 struct rte_intr_handle *server_intr_handle; /* Interrupt handler. */
@@ -35,7 +36,7 @@ mlx5_pmd_socket_handle(void *cb __rte_unused)
 	int ret;
 	struct cmsghdr *cmsg = NULL;
 	uint32_t data[MLX5_SENDMSG_MAX / sizeof(uint32_t)];
-	uint64_t flow_ptr = 0;
+	struct rte_flow *flow_ptr = NULL;
 	uint8_t  buf[CMSG_SPACE(sizeof(int))] = { 0 };
 	struct iovec io = {
 		.iov_base = data,
@@ -92,25 +93,37 @@ mlx5_pmd_socket_handle(void *cb __rte_unused)
 	dump_req = (struct mlx5_flow_dump_req *)msg.msg_iov->iov_base;
 	if (dump_req) {
 		port_id = dump_req->port_id;
-		flow_ptr = dump_req->flow_id;
+		flow_ptr = (struct rte_flow *)((uintptr_t)dump_req->flow_id);
 	} else {
 		DRV_LOG(WARNING, "Invalid message");
 		goto error;
 	}
 
-	if (!rte_eth_dev_is_valid_port(port_id)) {
-		DRV_LOG(WARNING, "Invalid port %u", port_id);
-		goto error;
+	if (port_id == MLX5_ALL_PORT_IDS) {
+		/* Dump all port ids */
+		if (flow_ptr) {
+			DRV_LOG(WARNING, "Flow ptr unsupported with given port id");
+			goto error;
+		}
+
+		RTE_ETH_FOREACH_DEV(port_id) {
+			dev = &rte_eth_devices[port_id];
+			ret = mlx5_flow_dev_dump(dev, NULL, file, &err);
+			if (ret)
+				break;
+		}
+	} else {
+		/* Dump single port id */
+		if (!rte_eth_dev_is_valid_port(port_id)) {
+			DRV_LOG(WARNING, "Invalid port %u", port_id);
+			goto error;
+		}
+
+		/* Dump flow */
+		dev = &rte_eth_devices[port_id];
+		ret = mlx5_flow_dev_dump(dev, flow_ptr, file, &err);
 	}
 
-	/* Dump flow. */
-	dev = &rte_eth_devices[port_id];
-	if (flow_ptr == 0)
-		ret = mlx5_flow_dev_dump(dev, NULL, file, NULL);
-	else
-		ret = mlx5_flow_dev_dump(dev,
-			(struct rte_flow *)((uintptr_t)flow_ptr), file, &err);
-
 	/* Set-up the ancillary data and reply. */
 	msg.msg_controllen = 0;
 	msg.msg_control = NULL;
-- 
2.18.1


             reply	other threads:[~2022-12-13  9:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13  9:28 Alex Vesker [this message]
2022-12-21 10:10 ` [PATCH v2] " Alex Vesker
2022-12-21 10:42   ` Slava Ovsiienko
2023-01-04 11:44   ` Raslan Darawsheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221213092849.7889-1-valex@nvidia.com \
    --to=valex@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=thomas@monjalon.net \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).