[v2] net/mlx5: add debug support for dumping all rte ports

Message ID 20221221101001.21255-1-valex@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series [v2] net/mlx5: add debug support for dumping all rte ports |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-testing fail Testing issues
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Alex Vesker Dec. 21, 2022, 10:10 a.m. UTC
  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(-)

v2: Fix iteration function to use only mlx5 devices
  

Comments

Slava Ovsiienko Dec. 21, 2022, 10:42 a.m. UTC | #1
> -----Original Message-----
> From: Alex Vesker <valex@nvidia.com>
> Sent: Wednesday, December 21, 2022 12:10 PM
> To: dev@dpdk.org
> Cc: Slava Ovsiienko <viacheslavo@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>
> Subject: [PATCH v2] net/mlx5: add debug support for dumping all rte ports
> 
> 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>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
  
Raslan Darawsheh Jan. 4, 2023, 11:44 a.m. UTC | #2
Hi,

> -----Original Message-----
> From: Alex Vesker <valex@nvidia.com>
> Sent: Wednesday, December 21, 2022 12:10 PM
> To: dev@dpdk.org
> Cc: Slava Ovsiienko <viacheslavo@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>
> Subject: [PATCH v2] net/mlx5: add debug support for dumping all rte ports
> 
> 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(-)
> 
> v2: Fix iteration function to use only mlx5 devices
> 

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c
index 0e01aff0e7..6ce0e59643 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;
+		}
+
+		MLX5_ETH_FOREACH_DEV(port_id, NULL) {
+			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;