DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] support single flow dump on MLX5 PMD
@ 2021-04-14  7:22 Haifei Luo
  2021-04-14  7:22 ` [dpdk-dev] [PATCH 1/2] common/mlx5: add mlx5 APIs for single flow dump feature Haifei Luo
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Haifei Luo @ 2021-04-14  7:22 UTC (permalink / raw)
  To: ferruh.yigit, viacheslavo, matan, xiaoyun.li, thomas, orika
  Cc: dev, rasland, xuemingl, haifeil

Dump information for all flows are supported and it is
useful to dump one flow.
Add single flow dump support on MLX5 PMD.
Modify API mlx5_flow_dev_dump to support.
Modify mlx5_socket since one extra arg flow_ptr is added.

Depends-on: series=16355  ("support single flow dump")
http://patchwork.dpdk.org/project/dpdk/list/?series=16355

Haifei Luo (2):
  common/mlx5: add mlx5 APIs for single flow dump feature
  net/mlx5: add mlx5 APIs for single flow dump feature

 drivers/common/mlx5/linux/meson.build |  6 ++++--
 drivers/common/mlx5/linux/mlx5_glue.c | 13 +++++++++++++
 drivers/common/mlx5/linux/mlx5_glue.h |  1 +
 drivers/common/mlx5/mlx5_devx_cmds.c  | 14 ++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h  |  2 ++
 drivers/common/mlx5/version.map       |  1 +
 drivers/net/mlx5/linux/mlx5_socket.c  | 30 ++++++++++++++++++++++++------
 drivers/net/mlx5/mlx5_flow.c          | 30 ++++++++++++++++++++++++++++--
 8 files changed, 87 insertions(+), 10 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH 1/2] common/mlx5: add mlx5 APIs for single flow dump feature
  2021-04-14  7:22 [dpdk-dev] [PATCH 0/2] support single flow dump on MLX5 PMD Haifei Luo
@ 2021-04-14  7:22 ` Haifei Luo
  2021-04-14  7:22 ` [dpdk-dev] [PATCH 2/2] net/mlx5: " Haifei Luo
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Haifei Luo @ 2021-04-14  7:22 UTC (permalink / raw)
  To: ferruh.yigit, viacheslavo, matan, xiaoyun.li, thomas, orika
  Cc: dev, rasland, xuemingl, haifeil

add mlx5 APIs for single flow dump feature

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/common/mlx5/linux/meson.build |  6 ++++--
 drivers/common/mlx5/linux/mlx5_glue.c | 13 +++++++++++++
 drivers/common/mlx5/linux/mlx5_glue.h |  1 +
 drivers/common/mlx5/mlx5_devx_cmds.c  | 14 ++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h  |  2 ++
 drivers/common/mlx5/version.map       |  1 +
 6 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 5d6a861..e8fcbd9 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -186,8 +186,10 @@ has_sym_args = [
 	'mlx5dv_dr_action_create_aso' ],
 	[ 'HAVE_INFINIBAND_VERBS_H', 'infiniband/verbs.h',
 	'INFINIBAND_VERBS_H' ],
-        [ 'HAVE_MLX5_UMR_IMKEY', 'infiniband/mlx5dv.h',
-        'MLX5_WQE_UMR_CTRL_FLAG_INLINE' ],
+	[ 'HAVE_MLX5_UMR_IMKEY', 'infiniband/mlx5dv.h',
+	'MLX5_WQE_UMR_CTRL_FLAG_INLINE' ],
+	[ 'HAVE_MLX5_DR_FLOW_DUMP_RULE', 'infiniband/mlx5dv.h',
+	'mlx5dv_dump_dr_rule' ],
 ]
 config = configuration_data()
 foreach arg:has_sym_args
diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index 964f7e7..d3bd645 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c
@@ -1101,6 +1101,18 @@
 }
 
 static int
+mlx5_glue_dr_dump_single_rule(FILE *file, void *rule)
+{
+#ifdef HAVE_MLX5_DR_FLOW_DUMP_RULE
+	return mlx5dv_dump_dr_rule(file, rule);
+#else
+	RTE_SET_USED(file);
+	RTE_SET_USED(rule);
+	return -ENOTSUP;
+#endif
+}
+
+static int
 mlx5_glue_dr_dump_domain(FILE *file, void *domain)
 {
 #ifdef HAVE_MLX5_DR_FLOW_DUMP
@@ -1423,6 +1435,7 @@
 	.devx_wq_query = mlx5_glue_devx_wq_query,
 	.devx_port_query = mlx5_glue_devx_port_query,
 	.dr_dump_domain = mlx5_glue_dr_dump_domain,
+	.dr_dump_rule = mlx5_glue_dr_dump_single_rule,
 	.dr_reclaim_domain_memory = mlx5_glue_dr_reclaim_domain_memory,
 	.dr_create_flow_action_sampler =
 		mlx5_glue_dr_create_flow_action_sampler,
diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h
index 9e385be..97462e9 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.h
+++ b/drivers/common/mlx5/linux/mlx5_glue.h
@@ -313,6 +313,7 @@ struct mlx5_glue {
 			       uint32_t port_num,
 			       struct mlx5dv_devx_port *mlx5_devx_port);
 	int (*dr_dump_domain)(FILE *file, void *domain);
+	int (*dr_dump_rule)(FILE *file, void *rule);
 	int (*devx_query_eqn)(struct ibv_context *context, uint32_t cpus,
 			      uint32_t *eqn);
 	struct mlx5dv_devx_event_channel *(*devx_create_event_channel)
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c
index 268bcd0..ec6069b 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.c
+++ b/drivers/common/mlx5/mlx5_devx_cmds.c
@@ -1584,6 +1584,20 @@ struct mlx5_devx_obj *
 	return -ret;
 }
 
+int
+mlx5_devx_cmd_flow_single_dump(void *rule_info __rte_unused,
+			FILE *file __rte_unused)
+{
+	int ret = 0;
+#ifdef HAVE_MLX5_DR_FLOW_DUMP_RULE
+	if (rule_info)
+		ret = mlx5_glue->dr_dump_rule(file, rule_info);
+#else
+	ret = ENOTSUP;
+#endif
+	return -ret;
+}
+
 /*
  * Create CQ using DevX API.
  *
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h
index 67b5f77..209e7da 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.h
+++ b/drivers/common/mlx5/mlx5_devx_cmds.h
@@ -477,6 +477,8 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_tis(void *ctx,
 int mlx5_devx_cmd_flow_dump(void *fdb_domain, void *rx_domain, void *tx_domain,
 			    FILE *file);
 __rte_internal
+int mlx5_devx_cmd_flow_single_dump(void *rule, FILE *file);
+__rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_cq(void *ctx,
 					      struct mlx5_devx_cq_attr *attr);
 __rte_internal
diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map
index 8b196a4..d2037bd 100644
--- a/drivers/common/mlx5/version.map
+++ b/drivers/common/mlx5/version.map
@@ -30,6 +30,7 @@ INTERNAL {
 	mlx5_devx_cmd_flow_counter_alloc;
 	mlx5_devx_cmd_flow_counter_query;
 	mlx5_devx_cmd_flow_dump;
+	mlx5_devx_cmd_flow_single_dump;
 	mlx5_devx_cmd_mkey_create;
 	mlx5_devx_cmd_modify_qp_state;
 	mlx5_devx_cmd_modify_rq;
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH 2/2] net/mlx5: add mlx5 APIs for single flow dump feature
  2021-04-14  7:22 [dpdk-dev] [PATCH 0/2] support single flow dump on MLX5 PMD Haifei Luo
  2021-04-14  7:22 ` [dpdk-dev] [PATCH 1/2] common/mlx5: add mlx5 APIs for single flow dump feature Haifei Luo
@ 2021-04-14  7:22 ` Haifei Luo
  2021-04-14  8:56 ` [dpdk-dev] [PATCH v2 0/2] support single flow dump on MLX5 PMD Haifei Luo
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Haifei Luo @ 2021-04-14  7:22 UTC (permalink / raw)
  To: ferruh.yigit, viacheslavo, matan, xiaoyun.li, thomas, orika
  Cc: dev, rasland, xuemingl, haifeil

Modify API mlx5_flow_dev_dump to support the feature.
Modify mlx5_socket since one extra arg flow_ptr is added.

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_socket.c | 30 ++++++++++++++++++++++++------
 drivers/net/mlx5/mlx5_flow.c         | 30 ++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c
index 6e354f4..b6eff45 100644
--- a/drivers/net/mlx5/linux/mlx5_socket.c
+++ b/drivers/net/mlx5/linux/mlx5_socket.c
@@ -2,6 +2,10 @@
  * Copyright 2019 Mellanox Technologies, Ltd
  */
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -29,11 +33,15 @@
 {
 	int conn_sock;
 	int ret;
+	int j;
 	struct cmsghdr *cmsg = NULL;
-	int data;
+	#define LENGTH 9
+	/* The first int for port_id and the rest for flowptr. */
+	int data[LENGTH];
+	uint64_t flow_ptr = 0;
 	char buf[CMSG_SPACE(sizeof(int))] = { 0 };
 	struct iovec io = {
-		.iov_base = &data,
+		.iov_base = &data[0],
 		.iov_len = sizeof(data),
 	};
 	struct msghdr msg = {
@@ -46,7 +54,9 @@
 	int fd;
 	FILE *file = NULL;
 	struct rte_eth_dev *dev;
+	struct rte_flow_error err;
 
+	memset(data, 0, sizeof(data));
 	/* Accept the connection from the client. */
 	conn_sock = accept(server_socket, NULL, NULL);
 	if (conn_sock < 0) {
@@ -84,15 +94,23 @@
 	}
 	/* Dump flow. */
 	dev = &rte_eth_devices[port_id];
-	ret = mlx5_flow_dev_dump(dev, NULL, file, NULL);
+	/* The first in data for port_id and the following 8 for flowptr */
+	for (j = 1; j < LENGTH; j++)
+		flow_ptr = (flow_ptr << 8) + data[j];
+	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;
 	msg.msg_iovlen = 1;
 	msg.msg_iov = &io;
-	data = -ret;
-	io.iov_len = sizeof(data);
-	io.iov_base = &data;
+	data[0] = -ret;
+	io.iov_len = sizeof(data[0]);
+	io.iov_base = &data[0];
 	do {
 		ret = sendmsg(conn_sock, &msg, 0);
 	} while (ret < 0 && errno == EINTR);
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index a8cf674..36089d4 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -7160,6 +7160,10 @@ struct mlx5_meter_domains_infos *
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_dev_ctx_shared *sh = priv->sh;
+	uint32_t handle_idx;
+	int ret;
+	struct mlx5_flow_handle *dh;
+	struct rte_flow *flow;
 
 	if (!priv->config.dv_flow_en) {
 		if (fputs("device dv flow disabled\n", file) <= 0)
@@ -7167,10 +7171,32 @@ struct mlx5_meter_domains_infos *
 		return -ENOTSUP;
 	}
 
+	/* dump all */
 	if (!flow_idx)
 		return mlx5_devx_cmd_flow_dump(sh->fdb_domain,
-				sh->rx_domain, sh->tx_domain, file);
-	return -ENOTSUP;
+					sh->rx_domain,
+					sh->tx_domain, file);
+	/* dump one */
+	flow = mlx5_ipool_get(priv->sh->ipool
+			[MLX5_IPOOL_RTE_FLOW], (uintptr_t)(void *)flow_idx);
+	if (!flow)
+		return -ENOENT;
+
+	handle_idx = flow->dev_handles;
+	while (handle_idx) {
+		dh = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW],
+				handle_idx);
+		if (!dh)
+			return -ENOENT;
+		if (dh->drv_flow) {
+			ret = mlx5_devx_cmd_flow_single_dump(dh->drv_flow,
+					file);
+			if (ret)
+				return -ENOENT;
+		}
+		handle_idx = dh->next.next;
+	}
+	return 0;
 }
 
 /**
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH v2 0/2] support single flow dump on MLX5 PMD
  2021-04-14  7:22 [dpdk-dev] [PATCH 0/2] support single flow dump on MLX5 PMD Haifei Luo
  2021-04-14  7:22 ` [dpdk-dev] [PATCH 1/2] common/mlx5: add mlx5 APIs for single flow dump feature Haifei Luo
  2021-04-14  7:22 ` [dpdk-dev] [PATCH 2/2] net/mlx5: " Haifei Luo
@ 2021-04-14  8:56 ` Haifei Luo
  2021-04-14  8:56   ` [dpdk-dev] [PATCH v2 1/2] common/mlx5: add mlx5 APIs for single flow dump feature Haifei Luo
  2021-04-14  8:56   ` [dpdk-dev] [PATCH v2 2/2] net/mlx5: " Haifei Luo
  2021-04-15 11:19 ` [dpdk-dev] [PATCH v3 0/2] support single flow dump on MLX5 PMD Haifei Luo
  2021-04-19  9:31 ` [dpdk-dev] [PATCH 0/2] support single flow dump on MLX5 PMD Raslan Darawsheh
  4 siblings, 2 replies; 11+ messages in thread
From: Haifei Luo @ 2021-04-14  8:56 UTC (permalink / raw)
  To: dev; +Cc: orika, viacheslavo, rasland, xuemingl, haifeil

Dump information for all flows are supported and it is
useful to dump one flow.
Add single flow dump support on MLX5 PMD.
Modify API mlx5_flow_dev_dump to support.
Modify mlx5_socket since one extra arg flow_ptr is added.

Depends-on: series=16362  ("support single flow dump")
http://patchwork.dpdk.org/project/dpdk/list/?series=16362

V2: rebase to fix apply patch failure.

Haifei Luo (2):
  common/mlx5: add mlx5 APIs for single flow dump feature
  net/mlx5: add mlx5 APIs for single flow dump feature

 drivers/common/mlx5/linux/meson.build |  6 ++++--
 drivers/common/mlx5/linux/mlx5_glue.c | 13 +++++++++++++
 drivers/common/mlx5/linux/mlx5_glue.h |  1 +
 drivers/common/mlx5/mlx5_devx_cmds.c  | 14 ++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h  |  2 ++
 drivers/common/mlx5/version.map       |  1 +
 drivers/net/mlx5/linux/mlx5_socket.c  | 30 ++++++++++++++++++++++++------
 drivers/net/mlx5/mlx5_flow.c          | 30 ++++++++++++++++++++++++++++--
 8 files changed, 87 insertions(+), 10 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH v2 1/2] common/mlx5: add mlx5 APIs for single flow dump feature
  2021-04-14  8:56 ` [dpdk-dev] [PATCH v2 0/2] support single flow dump on MLX5 PMD Haifei Luo
@ 2021-04-14  8:56   ` Haifei Luo
  2021-04-14  8:56   ` [dpdk-dev] [PATCH v2 2/2] net/mlx5: " Haifei Luo
  1 sibling, 0 replies; 11+ messages in thread
From: Haifei Luo @ 2021-04-14  8:56 UTC (permalink / raw)
  To: dev
  Cc: orika, viacheslavo, rasland, xuemingl, haifeil, Matan Azrad,
	Shahaf Shuler, Ray Kinsella, Neil Horman

add mlx5 APIs for single flow dump feature

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/common/mlx5/linux/meson.build |  6 ++++--
 drivers/common/mlx5/linux/mlx5_glue.c | 13 +++++++++++++
 drivers/common/mlx5/linux/mlx5_glue.h |  1 +
 drivers/common/mlx5/mlx5_devx_cmds.c  | 14 ++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h  |  2 ++
 drivers/common/mlx5/version.map       |  1 +
 6 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 5d6a861..e8fcbd9 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -186,8 +186,10 @@ has_sym_args = [
 	'mlx5dv_dr_action_create_aso' ],
 	[ 'HAVE_INFINIBAND_VERBS_H', 'infiniband/verbs.h',
 	'INFINIBAND_VERBS_H' ],
-        [ 'HAVE_MLX5_UMR_IMKEY', 'infiniband/mlx5dv.h',
-        'MLX5_WQE_UMR_CTRL_FLAG_INLINE' ],
+	[ 'HAVE_MLX5_UMR_IMKEY', 'infiniband/mlx5dv.h',
+	'MLX5_WQE_UMR_CTRL_FLAG_INLINE' ],
+	[ 'HAVE_MLX5_DR_FLOW_DUMP_RULE', 'infiniband/mlx5dv.h',
+	'mlx5dv_dump_dr_rule' ],
 ]
 config = configuration_data()
 foreach arg:has_sym_args
diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index 964f7e7..d3bd645 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c
@@ -1101,6 +1101,18 @@
 }
 
 static int
+mlx5_glue_dr_dump_single_rule(FILE *file, void *rule)
+{
+#ifdef HAVE_MLX5_DR_FLOW_DUMP_RULE
+	return mlx5dv_dump_dr_rule(file, rule);
+#else
+	RTE_SET_USED(file);
+	RTE_SET_USED(rule);
+	return -ENOTSUP;
+#endif
+}
+
+static int
 mlx5_glue_dr_dump_domain(FILE *file, void *domain)
 {
 #ifdef HAVE_MLX5_DR_FLOW_DUMP
@@ -1423,6 +1435,7 @@
 	.devx_wq_query = mlx5_glue_devx_wq_query,
 	.devx_port_query = mlx5_glue_devx_port_query,
 	.dr_dump_domain = mlx5_glue_dr_dump_domain,
+	.dr_dump_rule = mlx5_glue_dr_dump_single_rule,
 	.dr_reclaim_domain_memory = mlx5_glue_dr_reclaim_domain_memory,
 	.dr_create_flow_action_sampler =
 		mlx5_glue_dr_create_flow_action_sampler,
diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h
index 9e385be..97462e9 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.h
+++ b/drivers/common/mlx5/linux/mlx5_glue.h
@@ -313,6 +313,7 @@ struct mlx5_glue {
 			       uint32_t port_num,
 			       struct mlx5dv_devx_port *mlx5_devx_port);
 	int (*dr_dump_domain)(FILE *file, void *domain);
+	int (*dr_dump_rule)(FILE *file, void *rule);
 	int (*devx_query_eqn)(struct ibv_context *context, uint32_t cpus,
 			      uint32_t *eqn);
 	struct mlx5dv_devx_event_channel *(*devx_create_event_channel)
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c
index 268bcd0..ec6069b 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.c
+++ b/drivers/common/mlx5/mlx5_devx_cmds.c
@@ -1584,6 +1584,20 @@ struct mlx5_devx_obj *
 	return -ret;
 }
 
+int
+mlx5_devx_cmd_flow_single_dump(void *rule_info __rte_unused,
+			FILE *file __rte_unused)
+{
+	int ret = 0;
+#ifdef HAVE_MLX5_DR_FLOW_DUMP_RULE
+	if (rule_info)
+		ret = mlx5_glue->dr_dump_rule(file, rule_info);
+#else
+	ret = ENOTSUP;
+#endif
+	return -ret;
+}
+
 /*
  * Create CQ using DevX API.
  *
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h
index 67b5f77..209e7da 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.h
+++ b/drivers/common/mlx5/mlx5_devx_cmds.h
@@ -477,6 +477,8 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_tis(void *ctx,
 int mlx5_devx_cmd_flow_dump(void *fdb_domain, void *rx_domain, void *tx_domain,
 			    FILE *file);
 __rte_internal
+int mlx5_devx_cmd_flow_single_dump(void *rule, FILE *file);
+__rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_cq(void *ctx,
 					      struct mlx5_devx_cq_attr *attr);
 __rte_internal
diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map
index 8b196a4..d2037bd 100644
--- a/drivers/common/mlx5/version.map
+++ b/drivers/common/mlx5/version.map
@@ -30,6 +30,7 @@ INTERNAL {
 	mlx5_devx_cmd_flow_counter_alloc;
 	mlx5_devx_cmd_flow_counter_query;
 	mlx5_devx_cmd_flow_dump;
+	mlx5_devx_cmd_flow_single_dump;
 	mlx5_devx_cmd_mkey_create;
 	mlx5_devx_cmd_modify_qp_state;
 	mlx5_devx_cmd_modify_rq;
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH v2 2/2] net/mlx5: add mlx5 APIs for single flow dump feature
  2021-04-14  8:56 ` [dpdk-dev] [PATCH v2 0/2] support single flow dump on MLX5 PMD Haifei Luo
  2021-04-14  8:56   ` [dpdk-dev] [PATCH v2 1/2] common/mlx5: add mlx5 APIs for single flow dump feature Haifei Luo
@ 2021-04-14  8:56   ` Haifei Luo
  1 sibling, 0 replies; 11+ messages in thread
From: Haifei Luo @ 2021-04-14  8:56 UTC (permalink / raw)
  To: dev
  Cc: orika, viacheslavo, rasland, xuemingl, haifeil, Matan Azrad,
	Shahaf Shuler

Modify API mlx5_flow_dev_dump to support the feature.
Modify mlx5_socket since one extra arg flow_ptr is added.

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_socket.c | 30 ++++++++++++++++++++++++------
 drivers/net/mlx5/mlx5_flow.c         | 30 ++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c
index 6e354f4..b6eff45 100644
--- a/drivers/net/mlx5/linux/mlx5_socket.c
+++ b/drivers/net/mlx5/linux/mlx5_socket.c
@@ -2,6 +2,10 @@
  * Copyright 2019 Mellanox Technologies, Ltd
  */
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -29,11 +33,15 @@
 {
 	int conn_sock;
 	int ret;
+	int j;
 	struct cmsghdr *cmsg = NULL;
-	int data;
+	#define LENGTH 9
+	/* The first int for port_id and the rest for flowptr. */
+	int data[LENGTH];
+	uint64_t flow_ptr = 0;
 	char buf[CMSG_SPACE(sizeof(int))] = { 0 };
 	struct iovec io = {
-		.iov_base = &data,
+		.iov_base = &data[0],
 		.iov_len = sizeof(data),
 	};
 	struct msghdr msg = {
@@ -46,7 +54,9 @@
 	int fd;
 	FILE *file = NULL;
 	struct rte_eth_dev *dev;
+	struct rte_flow_error err;
 
+	memset(data, 0, sizeof(data));
 	/* Accept the connection from the client. */
 	conn_sock = accept(server_socket, NULL, NULL);
 	if (conn_sock < 0) {
@@ -84,15 +94,23 @@
 	}
 	/* Dump flow. */
 	dev = &rte_eth_devices[port_id];
-	ret = mlx5_flow_dev_dump(dev, NULL, file, NULL);
+	/* The first in data for port_id and the following 8 for flowptr */
+	for (j = 1; j < LENGTH; j++)
+		flow_ptr = (flow_ptr << 8) + data[j];
+	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;
 	msg.msg_iovlen = 1;
 	msg.msg_iov = &io;
-	data = -ret;
-	io.iov_len = sizeof(data);
-	io.iov_base = &data;
+	data[0] = -ret;
+	io.iov_len = sizeof(data[0]);
+	io.iov_base = &data[0];
 	do {
 		ret = sendmsg(conn_sock, &msg, 0);
 	} while (ret < 0 && errno == EINTR);
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index a8cf674..36089d4 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -7160,6 +7160,10 @@ struct mlx5_meter_domains_infos *
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_dev_ctx_shared *sh = priv->sh;
+	uint32_t handle_idx;
+	int ret;
+	struct mlx5_flow_handle *dh;
+	struct rte_flow *flow;
 
 	if (!priv->config.dv_flow_en) {
 		if (fputs("device dv flow disabled\n", file) <= 0)
@@ -7167,10 +7171,32 @@ struct mlx5_meter_domains_infos *
 		return -ENOTSUP;
 	}
 
+	/* dump all */
 	if (!flow_idx)
 		return mlx5_devx_cmd_flow_dump(sh->fdb_domain,
-				sh->rx_domain, sh->tx_domain, file);
-	return -ENOTSUP;
+					sh->rx_domain,
+					sh->tx_domain, file);
+	/* dump one */
+	flow = mlx5_ipool_get(priv->sh->ipool
+			[MLX5_IPOOL_RTE_FLOW], (uintptr_t)(void *)flow_idx);
+	if (!flow)
+		return -ENOENT;
+
+	handle_idx = flow->dev_handles;
+	while (handle_idx) {
+		dh = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW],
+				handle_idx);
+		if (!dh)
+			return -ENOENT;
+		if (dh->drv_flow) {
+			ret = mlx5_devx_cmd_flow_single_dump(dh->drv_flow,
+					file);
+			if (ret)
+				return -ENOENT;
+		}
+		handle_idx = dh->next.next;
+	}
+	return 0;
 }
 
 /**
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH v3 0/2] support single flow dump on MLX5 PMD
  2021-04-14  7:22 [dpdk-dev] [PATCH 0/2] support single flow dump on MLX5 PMD Haifei Luo
                   ` (2 preceding siblings ...)
  2021-04-14  8:56 ` [dpdk-dev] [PATCH v2 0/2] support single flow dump on MLX5 PMD Haifei Luo
@ 2021-04-15 11:19 ` Haifei Luo
  2021-04-15 11:19   ` [dpdk-dev] [PATCH v3 1/2] common/mlx5: add mlx5 APIs for single flow dump feature Haifei Luo
  2021-04-15 11:19   ` [dpdk-dev] [PATCH v3 2/2] net/mlx5: " Haifei Luo
  2021-04-19  9:31 ` [dpdk-dev] [PATCH 0/2] support single flow dump on MLX5 PMD Raslan Darawsheh
  4 siblings, 2 replies; 11+ messages in thread
From: Haifei Luo @ 2021-04-15 11:19 UTC (permalink / raw)
  To: dev; +Cc: orika, viacheslavo, rasland, xuemingl, haifeil

Dump information for all flows are supported and it is
useful to dump one flow.

Add single flow dump support on MLX5 PMD.

Modify API mlx5_flow_dev_dump to support.Modify mlx5_socket 
since one extra arg flow_ptr is added.

The data structure sent to DPDK application from the utility triggering
the flow dumps should be packed and endianness must be specified.

The native host endianness can be used, all exchange happens within
the same host (we use sendmsg aux data and share the file handle,
remote approach is not applicable, no inter-host communication happens).

The message structure to dump one/all flow(s):
    struct mlx5_flow_dump_req {
        uint32_t port_id;
        uint64_t flow_ptr;
    } __rte_packed;

If flow_ptr is 0, all flows for the specified port will be dumped.

Depends-on: series=16367  ("single flow dump")
http://patchwork.dpdk.org/project/dpdk/list/?series=16367

V2: Rebase to fix apply patch failure.
V3: Fix commments. Modify data structures sent to DPDK application.

Haifei Luo (2):
  common/mlx5: add mlx5 APIs for single flow dump feature
  net/mlx5: add mlx5 APIs for single flow dump feature

 drivers/common/mlx5/linux/meson.build |  6 +++--
 drivers/common/mlx5/linux/mlx5_glue.c | 13 ++++++++++
 drivers/common/mlx5/linux/mlx5_glue.h |  1 +
 drivers/common/mlx5/mlx5_devx_cmds.c  | 14 +++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h  |  2 ++
 drivers/common/mlx5/version.map       |  1 +
 drivers/net/mlx5/linux/mlx5_os.h      |  3 +++
 drivers/net/mlx5/linux/mlx5_socket.c  | 47 +++++++++++++++++++++++++++--------
 drivers/net/mlx5/mlx5.h               | 10 ++++++++
 drivers/net/mlx5/mlx5_flow.c          | 30 ++++++++++++++++++++--
 10 files changed, 113 insertions(+), 14 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH v3 1/2] common/mlx5: add mlx5 APIs for single flow dump feature
  2021-04-15 11:19 ` [dpdk-dev] [PATCH v3 0/2] support single flow dump on MLX5 PMD Haifei Luo
@ 2021-04-15 11:19   ` Haifei Luo
  2021-04-15 11:19   ` [dpdk-dev] [PATCH v3 2/2] net/mlx5: " Haifei Luo
  1 sibling, 0 replies; 11+ messages in thread
From: Haifei Luo @ 2021-04-15 11:19 UTC (permalink / raw)
  To: dev
  Cc: orika, viacheslavo, rasland, xuemingl, haifeil, Matan Azrad,
	Shahaf Shuler, Ray Kinsella, Neil Horman

add mlx5 APIs for single flow dump feature

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/common/mlx5/linux/meson.build |  6 ++++--
 drivers/common/mlx5/linux/mlx5_glue.c | 13 +++++++++++++
 drivers/common/mlx5/linux/mlx5_glue.h |  1 +
 drivers/common/mlx5/mlx5_devx_cmds.c  | 14 ++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h  |  2 ++
 drivers/common/mlx5/version.map       |  1 +
 6 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 5d6a861..e8fcbd9 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -186,8 +186,10 @@ has_sym_args = [
 	'mlx5dv_dr_action_create_aso' ],
 	[ 'HAVE_INFINIBAND_VERBS_H', 'infiniband/verbs.h',
 	'INFINIBAND_VERBS_H' ],
-        [ 'HAVE_MLX5_UMR_IMKEY', 'infiniband/mlx5dv.h',
-        'MLX5_WQE_UMR_CTRL_FLAG_INLINE' ],
+	[ 'HAVE_MLX5_UMR_IMKEY', 'infiniband/mlx5dv.h',
+	'MLX5_WQE_UMR_CTRL_FLAG_INLINE' ],
+	[ 'HAVE_MLX5_DR_FLOW_DUMP_RULE', 'infiniband/mlx5dv.h',
+	'mlx5dv_dump_dr_rule' ],
 ]
 config = configuration_data()
 foreach arg:has_sym_args
diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index 964f7e7..d3bd645 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c
@@ -1101,6 +1101,18 @@
 }
 
 static int
+mlx5_glue_dr_dump_single_rule(FILE *file, void *rule)
+{
+#ifdef HAVE_MLX5_DR_FLOW_DUMP_RULE
+	return mlx5dv_dump_dr_rule(file, rule);
+#else
+	RTE_SET_USED(file);
+	RTE_SET_USED(rule);
+	return -ENOTSUP;
+#endif
+}
+
+static int
 mlx5_glue_dr_dump_domain(FILE *file, void *domain)
 {
 #ifdef HAVE_MLX5_DR_FLOW_DUMP
@@ -1423,6 +1435,7 @@
 	.devx_wq_query = mlx5_glue_devx_wq_query,
 	.devx_port_query = mlx5_glue_devx_port_query,
 	.dr_dump_domain = mlx5_glue_dr_dump_domain,
+	.dr_dump_rule = mlx5_glue_dr_dump_single_rule,
 	.dr_reclaim_domain_memory = mlx5_glue_dr_reclaim_domain_memory,
 	.dr_create_flow_action_sampler =
 		mlx5_glue_dr_create_flow_action_sampler,
diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h
index 9e385be..97462e9 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.h
+++ b/drivers/common/mlx5/linux/mlx5_glue.h
@@ -313,6 +313,7 @@ struct mlx5_glue {
 			       uint32_t port_num,
 			       struct mlx5dv_devx_port *mlx5_devx_port);
 	int (*dr_dump_domain)(FILE *file, void *domain);
+	int (*dr_dump_rule)(FILE *file, void *rule);
 	int (*devx_query_eqn)(struct ibv_context *context, uint32_t cpus,
 			      uint32_t *eqn);
 	struct mlx5dv_devx_event_channel *(*devx_create_event_channel)
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c
index 268bcd0..ec6069b 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.c
+++ b/drivers/common/mlx5/mlx5_devx_cmds.c
@@ -1584,6 +1584,20 @@ struct mlx5_devx_obj *
 	return -ret;
 }
 
+int
+mlx5_devx_cmd_flow_single_dump(void *rule_info __rte_unused,
+			FILE *file __rte_unused)
+{
+	int ret = 0;
+#ifdef HAVE_MLX5_DR_FLOW_DUMP_RULE
+	if (rule_info)
+		ret = mlx5_glue->dr_dump_rule(file, rule_info);
+#else
+	ret = ENOTSUP;
+#endif
+	return -ret;
+}
+
 /*
  * Create CQ using DevX API.
  *
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h
index 67b5f77..209e7da 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.h
+++ b/drivers/common/mlx5/mlx5_devx_cmds.h
@@ -477,6 +477,8 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_tis(void *ctx,
 int mlx5_devx_cmd_flow_dump(void *fdb_domain, void *rx_domain, void *tx_domain,
 			    FILE *file);
 __rte_internal
+int mlx5_devx_cmd_flow_single_dump(void *rule, FILE *file);
+__rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_cq(void *ctx,
 					      struct mlx5_devx_cq_attr *attr);
 __rte_internal
diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map
index 8b196a4..d2037bd 100644
--- a/drivers/common/mlx5/version.map
+++ b/drivers/common/mlx5/version.map
@@ -30,6 +30,7 @@ INTERNAL {
 	mlx5_devx_cmd_flow_counter_alloc;
 	mlx5_devx_cmd_flow_counter_query;
 	mlx5_devx_cmd_flow_dump;
+	mlx5_devx_cmd_flow_single_dump;
 	mlx5_devx_cmd_mkey_create;
 	mlx5_devx_cmd_modify_qp_state;
 	mlx5_devx_cmd_modify_rq;
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH v3 2/2] net/mlx5: add mlx5 APIs for single flow dump feature
  2021-04-15 11:19 ` [dpdk-dev] [PATCH v3 0/2] support single flow dump on MLX5 PMD Haifei Luo
  2021-04-15 11:19   ` [dpdk-dev] [PATCH v3 1/2] common/mlx5: add mlx5 APIs for single flow dump feature Haifei Luo
@ 2021-04-15 11:19   ` Haifei Luo
  2021-04-15 11:28     ` Slava Ovsiienko
  1 sibling, 1 reply; 11+ messages in thread
From: Haifei Luo @ 2021-04-15 11:19 UTC (permalink / raw)
  To: dev
  Cc: orika, viacheslavo, rasland, xuemingl, haifeil, Matan Azrad,
	Shahaf Shuler

Modify API mlx5_flow_dev_dump to support the feature.
Modify mlx5_socket since one extra arg flow_ptr is added.

The data structure sent to DPDK application from the utility triggering
the flow dumps should be packed and endianness must be specified.
The native host endianness can be used, all exchange happens within
the same host (we use sendmsg aux data and share the file handle,
remote approach is not applicable, no inter-host communication happens).

The message structure to dump one/all flow(s):
struct mlx5_flow_dump_req {
	uint32_t port_id;
	uint64_t flow_ptr;
} __rte_packed;

If flow_ptr is 0, all flows for the specified port will be dumped.

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_os.h     |  3 +++
 drivers/net/mlx5/linux/mlx5_socket.c | 47 ++++++++++++++++++++++++++++--------
 drivers/net/mlx5/mlx5.h              | 10 ++++++++
 drivers/net/mlx5/mlx5_flow.c         | 30 +++++++++++++++++++++--
 4 files changed, 78 insertions(+), 12 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.h b/drivers/net/mlx5/linux/mlx5_os.h
index 6100a13..4ae7d0e 100644
--- a/drivers/net/mlx5/linux/mlx5_os.h
+++ b/drivers/net/mlx5/linux/mlx5_os.h
@@ -14,6 +14,9 @@ enum {
 	MLX5_FS_PATH_MAX = IBV_SYSFS_PATH_MAX + 1
 };
 
+/* Maximal data of sendmsg message(in bytes). */
+#define MLX5_SENDMSG_MAX 64
+
 #define MLX5_NAMESIZE IF_NAMESIZE
 
 #define PCI_DRV_FLAGS  (RTE_PCI_DRV_INTR_LSC | \
diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c
index 6e354f4..6356b66 100644
--- a/drivers/net/mlx5/linux/mlx5_socket.c
+++ b/drivers/net/mlx5/linux/mlx5_socket.c
@@ -2,6 +2,10 @@
  * Copyright 2019 Mellanox Technologies, Ltd
  */
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -30,10 +34,11 @@
 	int conn_sock;
 	int ret;
 	struct cmsghdr *cmsg = NULL;
-	int data;
-	char buf[CMSG_SPACE(sizeof(int))] = { 0 };
+	uint32_t data[MLX5_SENDMSG_MAX / sizeof(uint32_t)];
+	uint64_t flow_ptr = 0;
+	uint8_t  buf[CMSG_SPACE(sizeof(int))] = { 0 };
 	struct iovec io = {
-		.iov_base = &data,
+		.iov_base = data,
 		.iov_len = sizeof(data),
 	};
 	struct msghdr msg = {
@@ -42,11 +47,16 @@
 		.msg_control = buf,
 		.msg_controllen = sizeof(buf),
 	};
-	uint16_t port_id;
+
+	uint32_t port_id;
 	int fd;
 	FILE *file = NULL;
 	struct rte_eth_dev *dev;
+	struct rte_flow_error err;
+	struct mlx5_flow_dump_req  *dump_req;
+	struct mlx5_flow_dump_ack  *dump_ack;
 
+	memset(data, 0, sizeof(data));
 	/* Accept the connection from the client. */
 	conn_sock = accept(server_socket, NULL, NULL);
 	if (conn_sock < 0) {
@@ -54,11 +64,12 @@
 		return;
 	}
 	ret = recvmsg(conn_sock, &msg, MSG_WAITALL);
-	if (ret < 0) {
+	if (ret != sizeof(struct mlx5_flow_dump_req)) {
 		DRV_LOG(WARNING, "wrong message received: %s",
 			strerror(errno));
 		goto error;
 	}
+
 	/* Receive file descriptor. */
 	cmsg = CMSG_FIRSTHDR(&msg);
 	if (cmsg == NULL || cmsg->cmsg_type != SCM_RIGHTS ||
@@ -77,22 +88,38 @@
 		DRV_LOG(WARNING, "wrong port number message");
 		goto error;
 	}
-	memcpy(&port_id, msg.msg_iov->iov_base, sizeof(port_id));
+
+	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;
+	} 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;
 	}
+
 	/* Dump flow. */
 	dev = &rte_eth_devices[port_id];
-	ret = mlx5_flow_dev_dump(dev, NULL, file, NULL);
+	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;
 	msg.msg_iovlen = 1;
 	msg.msg_iov = &io;
-	data = -ret;
-	io.iov_len = sizeof(data);
-	io.iov_base = &data;
+	dump_ack = (struct mlx5_flow_dump_ack *)data;
+	dump_ack->rc = -ret;
+	io.iov_len = sizeof(struct mlx5_flow_dump_ack);
+	io.iov_base = dump_ack;
 	do {
 		ret = sendmsg(conn_sock, &msg, 0);
 	} while (ret < 0 && errno == EINTR);
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index e0f7101..452c5de 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -118,6 +118,16 @@ struct mlx5_dev_spawn_data {
 	struct mlx5_bond_info *bond_info;
 };
 
+/** Data associated with socket messages. */
+struct mlx5_flow_dump_req  {
+	uint32_t port_id; /**< There are plans in DPDK to extend port_id. */
+	uint64_t flow_id;
+} __rte_packed;
+
+struct mlx5_flow_dump_ack {
+	int rc; /**< Return code. */
+};
+
 /** Key string for IPC. */
 #define MLX5_MP_NAME "net_mlx5_mp"
 
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 8446307..ff40406 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -7161,6 +7161,10 @@ struct mlx5_meter_domains_infos *
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_dev_ctx_shared *sh = priv->sh;
+	uint32_t handle_idx;
+	int ret;
+	struct mlx5_flow_handle *dh;
+	struct rte_flow *flow;
 
 	if (!priv->config.dv_flow_en) {
 		if (fputs("device dv flow disabled\n", file) <= 0)
@@ -7168,10 +7172,32 @@ struct mlx5_meter_domains_infos *
 		return -ENOTSUP;
 	}
 
+	/* dump all */
 	if (!flow_idx)
 		return mlx5_devx_cmd_flow_dump(sh->fdb_domain,
-				sh->rx_domain, sh->tx_domain, file);
-	return -ENOTSUP;
+					sh->rx_domain,
+					sh->tx_domain, file);
+	/* dump one */
+	flow = mlx5_ipool_get(priv->sh->ipool
+			[MLX5_IPOOL_RTE_FLOW], (uintptr_t)(void *)flow_idx);
+	if (!flow)
+		return -ENOENT;
+
+	handle_idx = flow->dev_handles;
+	while (handle_idx) {
+		dh = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW],
+				handle_idx);
+		if (!dh)
+			return -ENOENT;
+		if (dh->drv_flow) {
+			ret = mlx5_devx_cmd_flow_single_dump(dh->drv_flow,
+					file);
+			if (ret)
+				return -ENOENT;
+		}
+		handle_idx = dh->next.next;
+	}
+	return 0;
 }
 
 /**
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/2] net/mlx5: add mlx5 APIs for single flow dump feature
  2021-04-15 11:19   ` [dpdk-dev] [PATCH v3 2/2] net/mlx5: " Haifei Luo
@ 2021-04-15 11:28     ` Slava Ovsiienko
  0 siblings, 0 replies; 11+ messages in thread
From: Slava Ovsiienko @ 2021-04-15 11:28 UTC (permalink / raw)
  To: Haifei Luo, dev
  Cc: Ori Kam, Raslan Darawsheh, Xueming(Steven) Li, Haifei Luo,
	Matan Azrad, Shahaf Shuler

> -----Original Message-----
> From: Haifei Luo <haifeil@nvidia.com>
> Sent: Thursday, April 15, 2021 14:19
> To: dev@dpdk.org
> Cc: Ori Kam <orika@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>;
> Raslan Darawsheh <rasland@nvidia.com>; Xueming(Steven) Li
> <xuemingl@nvidia.com>; Haifei Luo <haifeil@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Shahaf Shuler <shahafs@nvidia.com>
> Subject: [PATCH v3 2/2] net/mlx5: add mlx5 APIs for single flow dump
> feature
> 
> Modify API mlx5_flow_dev_dump to support the feature.
> Modify mlx5_socket since one extra arg flow_ptr is added.
> 
> The data structure sent to DPDK application from the utility triggering the
> flow dumps should be packed and endianness must be specified.
> The native host endianness can be used, all exchange happens within the
> same host (we use sendmsg aux data and share the file handle, remote
> approach is not applicable, no inter-host communication happens).
> 
> The message structure to dump one/all flow(s):
> struct mlx5_flow_dump_req {
> 	uint32_t port_id;
> 	uint64_t flow_ptr;
> } __rte_packed;
> 
> If flow_ptr is 0, all flows for the specified port will be dumped.
> 
> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dpdk-dev] [PATCH 0/2] support single flow dump on MLX5 PMD
  2021-04-14  7:22 [dpdk-dev] [PATCH 0/2] support single flow dump on MLX5 PMD Haifei Luo
                   ` (3 preceding siblings ...)
  2021-04-15 11:19 ` [dpdk-dev] [PATCH v3 0/2] support single flow dump on MLX5 PMD Haifei Luo
@ 2021-04-19  9:31 ` Raslan Darawsheh
  4 siblings, 0 replies; 11+ messages in thread
From: Raslan Darawsheh @ 2021-04-19  9:31 UTC (permalink / raw)
  To: Haifei Luo, ferruh.yigit, Slava Ovsiienko, Matan Azrad,
	xiaoyun.li, NBU-Contact-Thomas Monjalon, Ori Kam
  Cc: dev, Xueming(Steven) Li, Haifei Luo

Hi,

> -----Original Message-----
> From: Haifei Luo <haifeil@nvidia.com>
> Sent: Wednesday, April 14, 2021 10:23 AM
> To: ferruh.yigit@intel.com; Slava Ovsiienko <viacheslavo@nvidia.com>;
> Matan Azrad <matan@nvidia.com>; xiaoyun.li@intel.com; NBU-Contact-
> Thomas Monjalon <thomas@monjalon.net>; Ori Kam <orika@nvidia.com>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>;
> Xueming(Steven) Li <xuemingl@nvidia.com>; Haifei Luo
> <haifeil@nvidia.com>
> Subject: [PATCH 0/2] support single flow dump on MLX5 PMD
> 
> Dump information for all flows are supported and it is
> useful to dump one flow.
> Add single flow dump support on MLX5 PMD.
> Modify API mlx5_flow_dev_dump to support.
> Modify mlx5_socket since one extra arg flow_ptr is added.
> 
> Depends-on: series=16355  ("support single flow dump")
> http://patchwork.dpdk.org/project/dpdk/list/?series=16355
> 
> Haifei Luo (2):
>   common/mlx5: add mlx5 APIs for single flow dump feature
>   net/mlx5: add mlx5 APIs for single flow dump feature
> 
>  drivers/common/mlx5/linux/meson.build |  6 ++++--
>  drivers/common/mlx5/linux/mlx5_glue.c | 13 +++++++++++++
>  drivers/common/mlx5/linux/mlx5_glue.h |  1 +
>  drivers/common/mlx5/mlx5_devx_cmds.c  | 14 ++++++++++++++
>  drivers/common/mlx5/mlx5_devx_cmds.h  |  2 ++
>  drivers/common/mlx5/version.map       |  1 +
>  drivers/net/mlx5/linux/mlx5_socket.c  | 30 ++++++++++++++++++++++++--
> ----
>  drivers/net/mlx5/mlx5_flow.c          | 30
> ++++++++++++++++++++++++++++--
>  8 files changed, 87 insertions(+), 10 deletions(-)
> 
> --
> 1.8.3.1

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-04-19  9:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14  7:22 [dpdk-dev] [PATCH 0/2] support single flow dump on MLX5 PMD Haifei Luo
2021-04-14  7:22 ` [dpdk-dev] [PATCH 1/2] common/mlx5: add mlx5 APIs for single flow dump feature Haifei Luo
2021-04-14  7:22 ` [dpdk-dev] [PATCH 2/2] net/mlx5: " Haifei Luo
2021-04-14  8:56 ` [dpdk-dev] [PATCH v2 0/2] support single flow dump on MLX5 PMD Haifei Luo
2021-04-14  8:56   ` [dpdk-dev] [PATCH v2 1/2] common/mlx5: add mlx5 APIs for single flow dump feature Haifei Luo
2021-04-14  8:56   ` [dpdk-dev] [PATCH v2 2/2] net/mlx5: " Haifei Luo
2021-04-15 11:19 ` [dpdk-dev] [PATCH v3 0/2] support single flow dump on MLX5 PMD Haifei Luo
2021-04-15 11:19   ` [dpdk-dev] [PATCH v3 1/2] common/mlx5: add mlx5 APIs for single flow dump feature Haifei Luo
2021-04-15 11:19   ` [dpdk-dev] [PATCH v3 2/2] net/mlx5: " Haifei Luo
2021-04-15 11:28     ` Slava Ovsiienko
2021-04-19  9:31 ` [dpdk-dev] [PATCH 0/2] support single flow dump on MLX5 PMD Raslan Darawsheh

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).