From: Haifei Luo <haifeil@nvidia.com>
To: dev@dpdk.org
Cc: orika@nvidia.com, viacheslavo@nvidia.com, rasland@nvidia.com,
xuemingl@nvidia.com, haifeil@nvidia.com,
Matan Azrad <matan@nvidia.com>,
Shahaf Shuler <shahafs@nvidia.com>
Subject: [dpdk-dev] [PATCH v2 2/2] net/mlx5: add mlx5 APIs for single flow dump feature
Date: Wed, 14 Apr 2021 11:56:55 +0300 [thread overview]
Message-ID: <1618390615-193593-3-git-send-email-haifeil@nvidia.com> (raw)
In-Reply-To: <1618390615-193593-1-git-send-email-haifeil@nvidia.com>
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
next prev parent reply other threads:[~2021-04-14 8:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Haifei Luo [this message]
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
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=1618390615-193593-3-git-send-email-haifeil@nvidia.com \
--to=haifeil@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=shahafs@nvidia.com \
--cc=viacheslavo@nvidia.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).