DPDK patches and discussions
 help / color / mirror / Atom feed
From: Haifei Luo <haifeil@nvidia.com>
To: ferruh.yigit@intel.com, viacheslavo@nvidia.com, matan@nvidia.com,
	xiaoyun.li@intel.com, thomas@monjalon.net, orika@nvidia.com
Cc: dev@dpdk.org, rasland@nvidia.com, xuemingl@nvidia.com
Subject: [dpdk-dev] [PATCH 4/4] net/mlx5: add mlx5 APIs for single flow dump feature
Date: Tue,  9 Mar 2021 10:15:16 +0200	[thread overview]
Message-ID: <1615277716-64404-5-git-send-email-haifeil@nvidia.com> (raw)
In-Reply-To: <1615277716-64404-1-git-send-email-haifeil@nvidia.com>

Add API mlx5_flow_dump_rule 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 | 27 ++++++++++++++++++-------
 drivers/net/mlx5/mlx5.h              |  3 +++
 drivers/net/mlx5/mlx5_flow.c         | 38 ++++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c
index 1938453..88ca8e1 100644
--- a/drivers/net/mlx5/linux/mlx5_socket.c
+++ b/drivers/net/mlx5/linux/mlx5_socket.c
@@ -32,12 +32,15 @@
 mlx5_pmd_socket_handle(void *cb __rte_unused)
 {
 	int conn_sock;
-	int ret;
+	int ret, j;
 	struct cmsghdr *cmsg = NULL;
-	int data;
+	#define LENGTH 9
+	/*The first byte 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 = {
@@ -50,7 +53,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) {
@@ -88,15 +93,23 @@
 	}
 	/* Dump flow. */
 	dev = &rte_eth_devices[port_id];
-	ret = mlx5_flow_dev_dump(dev, file, NULL);
+	/*The first byte 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, file, NULL);
+	else
+		ret = mlx5_flow_dump_rule(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.h b/drivers/net/mlx5/mlx5.h
index a281fd2..c5d4cee 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1222,6 +1222,9 @@ int mlx5_counter_query(struct rte_eth_dev *dev, uint32_t cnt,
 		       bool clear, uint64_t *pkts, uint64_t *bytes);
 int mlx5_flow_dev_dump(struct rte_eth_dev *dev, FILE *file,
 		       struct rte_flow_error *error);
+int mlx5_flow_dump_rule(struct rte_eth_dev *dev, struct rte_flow *flow,
+			FILE *file,
+			struct rte_flow_error *error);
 void mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev);
 int mlx5_flow_get_aged_flows(struct rte_eth_dev *dev, void **contexts,
 			uint32_t nb_contexts, struct rte_flow_error *error);
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index ab5be3d..6d031ba 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -635,6 +635,7 @@ enum mlx5_expansion {
 	.isolate = mlx5_flow_isolate,
 	.query = mlx5_flow_query,
 	.dev_dump = mlx5_flow_dev_dump,
+	.dev_single_dump = mlx5_flow_dump_rule,
 	.get_aged_flows = mlx5_flow_get_aged_flows,
 	.shared_action_create = mlx5_shared_action_create,
 	.shared_action_destroy = mlx5_shared_action_destroy,
@@ -7200,6 +7201,43 @@ struct mlx5_meter_domains_infos *
 				       sh->tx_domain, file);
 }
 
+int
+mlx5_flow_dump_rule(struct rte_eth_dev *dev, struct rte_flow *flow_idx,
+			FILE *file,
+			struct rte_flow_error *error __rte_unused)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	uint32_t handle_idx;
+	int ret;
+	struct mlx5_flow_handle *dh;
+	struct rte_flow *flow = mlx5_ipool_get(priv->sh->ipool
+			[MLX5_IPOOL_RTE_FLOW], (uintptr_t)(void *)flow_idx);
+
+	if (!priv->config.dv_flow_en) {
+		if (fputs("device dv flow disabled\n", file) <= 0)
+			return -errno;
+		return -ENOTSUP;
+	}
+
+	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;
+}
+
 /**
  * Get aged-out flows.
  *
-- 
1.8.3.1


  parent reply	other threads:[~2021-03-09 23:52 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09  8:15 [dpdk-dev] [PATCH 0/4] *** Support for one flow dump *** Haifei Luo
2021-03-09  8:15 ` [dpdk-dev] [PATCH 1/4] ethdev: add rte API for single flow dump Haifei Luo
2021-03-10  0:39   ` Stephen Hemminger
2021-03-10  7:05   ` Ori Kam
2021-03-09  8:15 ` [dpdk-dev] [PATCH 2/4] app/testpmd: add CLIs for single flow dump feature Haifei Luo
2021-03-09  8:15 ` [dpdk-dev] [PATCH 3/4] common/mlx5: add mlx5 APIs " Haifei Luo
2021-03-09  8:15 ` Haifei Luo [this message]
2021-04-07  6:09 ` [dpdk-dev] [PATCH v2 0/5] support single flow dump Haifei Luo
2021-04-07  6:09   ` [dpdk-dev] [PATCH v2 1/5] ethdev: modify rte API for " Haifei Luo
2021-04-12 19:33     ` Ori Kam
2021-04-13  4:38     ` Ajit Khaparde
2021-04-07  6:09   ` [dpdk-dev] [PATCH v2 2/5] app/testpmd: add CLIs for single flow dump feature Haifei Luo
2021-04-13 16:36     ` Ajit Khaparde
2021-04-07  6:09   ` [dpdk-dev] [PATCH v2 3/5] common/mlx5: add mlx5 APIs " Haifei Luo
2021-04-12  7:32     ` Slava Ovsiienko
2021-04-13 16:44     ` Kinsella, Ray
2021-04-14  2:40       ` Haifei Luo
2021-04-14  6:21         ` David Marchand
2021-04-14  6:23           ` Haifei Luo
2021-04-07  6:09   ` [dpdk-dev] [PATCH v2 4/5] net/mlx5: " Haifei Luo
2021-04-12  7:29     ` Slava Ovsiienko
2021-04-12  7:37     ` Slava Ovsiienko
2021-04-13  1:29       ` Haifei Luo
2021-04-13  7:22         ` Haifei Luo
2021-04-13  7:39           ` Slava Ovsiienko
2021-04-07  6:09   ` [dpdk-dev] [PATCH v2 5/5] doc: add single flow dump to guides Haifei Luo
2021-04-14  6:13 ` [dpdk-dev] [PATCH v3 0/3] support single flow dump Haifei Luo
2021-04-14  6:13   ` [dpdk-dev] [PATCH v3 1/3] ethdev: modify rte API for " Haifei Luo
2021-04-14  6:13   ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: add CLIs for single flow dump feature Haifei Luo
2021-04-14  6:13   ` [dpdk-dev] [PATCH v3 3/3] doc: add single flow dump to guides Haifei Luo
2021-04-14  8:23     ` Ferruh Yigit
2021-04-14  8:25       ` Haifei Luo
2021-04-14 10:00       ` Haifei Luo
2021-04-14  8:41 ` [dpdk-dev] [PATCH v4 0/3] support single flow dump Haifei Luo
2021-04-14  8:41   ` [dpdk-dev] [PATCH v4 1/3] ethdev: modify rte API for " Haifei Luo
2021-04-14  8:57     ` Thomas Monjalon
2021-04-14  9:10       ` Haifei Luo
2021-04-14  9:01     ` Thomas Monjalon
2021-04-14  9:07       ` Haifei Luo
2021-04-14  9:31         ` Thomas Monjalon
2021-04-14  8:41   ` [dpdk-dev] [PATCH v4 2/3] app/testpmd: add CLIs for single flow dump feature Haifei Luo
2021-04-14  8:41   ` [dpdk-dev] [PATCH v4 3/3] doc: add single flow dump to guides Haifei Luo
2021-04-14  9:15     ` Ferruh Yigit
2021-04-14  9:51 ` [dpdk-dev] [PATCH v5 0/3] support single flow dump Haifei Luo
2021-04-14  9:51   ` [dpdk-dev] [PATCH v5 1/3] ethdev: dump single flow rule Haifei Luo
2021-04-14 10:33     ` Thomas Monjalon
2021-04-14 10:37       ` Haifei Luo
2021-04-14  9:51   ` [dpdk-dev] [PATCH v5 2/3] app/testpmd: add CLIs for single flow dump feature Haifei Luo
2021-04-14  9:51   ` [dpdk-dev] [PATCH v5 3/3] doc: add single flow dump to guides Haifei Luo
2021-04-14 10:19 ` [dpdk-dev] [PATCH v6 0/2] single flow dump Haifei Luo
2021-04-14 10:19   ` [dpdk-dev] [PATCH v6 1/2] ethdev: dump single flow rule Haifei Luo
2021-04-14 10:20   ` [dpdk-dev] [PATCH v6 2/2] app/testpmd: add CLIs for single flow dump feature Haifei Luo
2021-04-14 11:26   ` [dpdk-dev] [PATCH v6 0/2] single flow dump Ferruh Yigit

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=1615277716-64404-5-git-send-email-haifeil@nvidia.com \
    --to=haifeil@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=thomas@monjalon.net \
    --cc=viacheslavo@nvidia.com \
    --cc=xiaoyun.li@intel.com \
    --cc=xuemingl@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).