Skip to contentSkip to conversation

net/mlx5: dump software steering flows in HW

RFC In review Xiaoyu Min 2 participants 9 messages Jan 14, 2020 – Jan 15, 2020

Subsystems (2)
lore
Share & tools
lore

Xiaoyu Min

author
#0 lore raw

cover net/mlx5: dump software steering flows in HW

This RFC intends to provide a way to dump all the offloaded rte flows in HW. This is very helpful for user and developer to debug flow offloading stuff, i.e, to check whether PMD offloads the rte flow in a correct way from HW perspective.

A private PMD API is provided as well as a socket server for external tool to trigger dump.
The output file is in raw format and Mellanox specific. An external vendor (Mellanox) provided tool is needed in order to get human readable format.

Please be aware the underlying rdma-core lib also needs to support this.

Xueming Li (4):
net/mlx5: support flow dump Api
app/testpmd: new flow dump CLI
net/mlx5: add socket server for external tools
doc: update mlx5 document for flow dump feature

 app/test-pmd/Makefile                     |   4 +
 app/test-pmd/cmdline_flow.c               |  91 +++++++++
 app/test-pmd/config.c                     |  33 ++++
 app/test-pmd/meson.build                  |   3 +
 app/test-pmd/testpmd.h                    |   1 +
 doc/guides/nics/mlx5.rst                  |  28 +++
 drivers/net/mlx5/Makefile                 |  12 +-
 drivers/net/mlx5/meson.build              |   5 +
 drivers/net/mlx5/mlx5.c                   |   2 +
 drivers/net/mlx5/mlx5.h                   |   7 +
 drivers/net/mlx5/mlx5_devx_cmds.c         |  35 ++++
 drivers/net/mlx5/mlx5_glue.c              |  13 ++
 drivers/net/mlx5/mlx5_glue.h              |   1 +
 drivers/net/mlx5/mlx5_socket.c            | 226 ++++++++++++++++++++++
 drivers/net/mlx5/rte_pmd_mlx5.c           |  22 +++
 drivers/net/mlx5/rte_pmd_mlx5.h           |  39 ++++
 drivers/net/mlx5/rte_pmd_mlx5_version.map |   7 +
 17 files changed, 528 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/mlx5/mlx5_socket.c
 create mode 100644 drivers/net/mlx5/rte_pmd_mlx5.c
 create mode 100644 drivers/net/mlx5/rte_pmd_mlx5.h
Signature · 1 line
2.24.1
author
#1 lore raw

RFC 1/4 net/mlx5: support flow dump Api

From: Xueming Li <[email protected]>

Dump fdb/nic_rx/nic_tx raw flow data into specified file.

---
 drivers/net/mlx5/Makefile                 | 11 ++++++-
 drivers/net/mlx5/meson.build              |  4 +++
 drivers/net/mlx5/mlx5.h                   |  2 ++
 drivers/net/mlx5/mlx5_devx_cmds.c         | 35 ++++++++++++++++++++
 drivers/net/mlx5/mlx5_glue.c              | 13 ++++++++
 drivers/net/mlx5/mlx5_glue.h              |  1 +
 drivers/net/mlx5/rte_pmd_mlx5.c           | 22 +++++++++++++
 drivers/net/mlx5/rte_pmd_mlx5.h           | 39 +++++++++++++++++++++++
 drivers/net/mlx5/rte_pmd_mlx5_version.map |  7 ++++
 9 files changed, 133 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/mlx5/rte_pmd_mlx5.c
 create mode 100644 drivers/net/mlx5/rte_pmd_mlx5.h
drivers/net/mlx5/Makefile +10 -1
index c5cf4397ac..0ff907445e 100644
@@ -8,7 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 LIB = librte_pmd_mlx5.a
 LIB_GLUE = $(LIB_GLUE_BASE).$(LIB_GLUE_VERSION)
 LIB_GLUE_BASE = librte_pmd_mlx5_glue.so
-LIB_GLUE_VERSION = 19.08.0
+LIB_GLUE_VERSION = 19.11.0
 
 # Sources.
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5.c
@@ -39,6 +39,10 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mp.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_nl.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_devx_cmds.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_utils.c
+SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += rte_pmd_mlx5.c
+
+# Export include files of private API.
+SYMLINK-$(CONFIG_RTE_LIBRTE_MLX5_PMD)-include += rte_pmd_mlx5.h
 
 ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
 INSTALL-$(CONFIG_RTE_LIBRTE_MLX5_PMD)-lib += $(LIB_GLUE)
@@ -203,6 +207,11 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
 		infiniband/mlx5dv.h \
 		func mlx5dv_dr_action_create_flow_meter \
 		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_MLX5_DR_FLOW_DUMP \
+		infiniband/mlx5dv.h \
+		func mlx5dv_dump_dr_domain \
+		$(AUTOCONF_OUTPUT)
 	$Q sh -- '$<' '$@' \
 		HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD \
 		infiniband/mlx5dv.h \
drivers/net/mlx5/meson.build +4 -0
index d6b32db794..1bdebcb6fc 100644
@@ -61,6 +61,7 @@ if build
 		'mlx5_vlan.c',
 		'mlx5_devx_cmds.c',
 		'mlx5_utils.c',
+		'rte_pmd_mlx5.c',
 	)
 	if (dpdk_conf.has('RTE_ARCH_X86_64')
 		or dpdk_conf.has('RTE_ARCH_ARM64')
@@ -186,6 +187,8 @@ if build
 		'RDMA_NLDEV_ATTR_PORT_INDEX' ],
 		[ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX', 'rdma/rdma_netlink.h',
 		'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
+		[ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
+		'mlx5dv_dump_dr_domain'],
 	]
 	config = configuration_data()
 	foreach arg:has_sym_args
@@ -225,3 +228,4 @@ if pmd_dlopen and build
 		install_dir: dlopen_install_dir,
 	)
 endif
+install_headers('rte_pmd_mlx5.h')
drivers/net/mlx5/mlx5.h +2 -0
index c3df8256ce..68b08a7f0b 100644
@@ -1049,6 +1049,8 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_tis
 	(struct ibv_context *ctx, struct mlx5_devx_tis_attr *tis_attr);
 struct mlx5_devx_obj *mlx5_devx_cmd_create_td(struct ibv_context *ctx);
 
+int mlx5_devx_cmd_flow_dump(struct mlx5_ibv_shared *sh, FILE *file);
+
 /* mlx5_flow_meter.c */
 
 int mlx5_flow_meter_ops_get(struct rte_eth_dev *dev, void *arg);
drivers/net/mlx5/mlx5_devx_cmds.c +35 -0
index 9893287ba8..d6bf15689d 100644
@@ -927,3 +927,38 @@ mlx5_devx_cmd_create_td(struct ibv_context *ctx)
 			   transport_domain);
 	return td;
 }
+
+/**
+ * Dump all flows to file.
+ *
+ * @param[in] sh
+ *   Pointer to context.
+ * @param[out] file
+ *   Pointer to file stream.
+ *
+ * @return
+ *   0 on success, a nagative value otherwise.
+ */
+int
+mlx5_devx_cmd_flow_dump(struct mlx5_ibv_shared *sh __rte_unused,
+			FILE *file __rte_unused)
+{
+	int ret = 0;
+
+#ifdef HAVE_MLX5_DR_FLOW_DUMP
+	if (sh->fdb_domain) {
+		ret = mlx5_glue->dr_dump_domain(file, sh->fdb_domain);
+		if (ret)
+			return ret;
+	}
+	assert(sh->rx_domain);
+	ret = mlx5_glue->dr_dump_domain(file, sh->rx_domain);
+	if (ret)
+		return ret;
+	assert(sh->tx_domain);
+	ret = mlx5_glue->dr_dump_domain(file, sh->tx_domain);
+#else
+	ret = ENOTSUP;
+#endif
+	return -ret;
+}
drivers/net/mlx5/mlx5_glue.c +13 -0
index 0917bf28d6..4906eebc01 100644
@@ -1037,6 +1037,18 @@ mlx5_glue_devx_port_query(struct ibv_context *ctx,
 #endif
 }
 
+static int
+mlx5_glue_dr_dump_domain(FILE *file, void *domain)
+{
+#ifdef HAVE_MLX5_DR_FLOW_DUMP
+	return mlx5dv_dump_dr_domain(file, domain);
+#else
+	RTE_SET_USED(file);
+	RTE_SET_USED(domain);
+	return -ENOTSUP;
+#endif
+}
+
 alignas(RTE_CACHE_LINE_SIZE)
 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
 	.version = MLX5_GLUE_VERSION,
@@ -1134,4 +1146,5 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
 	.devx_umem_dereg = mlx5_glue_devx_umem_dereg,
 	.devx_qp_query = mlx5_glue_devx_qp_query,
 	.devx_port_query = mlx5_glue_devx_port_query,
+	.dr_dump_domain = mlx5_glue_dr_dump_domain,
 };
drivers/net/mlx5/mlx5_glue.h +1 -0
index 6442f1eba8..6771a18c64 100644
@@ -256,6 +256,7 @@ struct mlx5_glue {
 	int (*devx_port_query)(struct ibv_context *ctx,
 			       uint32_t port_num,
 			       struct mlx5dv_devx_port *mlx5_devx_port);
+	int (*dr_dump_domain)(FILE *file, void *domain);
 };
 
 const struct mlx5_glue *mlx5_glue;
drivers/net/mlx5/rte_pmd_mlx5.c new file +22 -0
new file mode 100644
index 0000000000..18fa12161a
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright 2019 Mellanox Technologies, Ltd
+ */
+
+#include <stdint.h>
+#include <rte_ethdev.h>
+
+#include "rte_pmd_mlx5.h"
+#include "mlx5.h"
+
+int
+rte_pmd_mlx5_flow_dump(uint16_t port_id, FILE *file)
+{
+	struct rte_eth_dev *dev;
+	struct mlx5_priv *priv;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	dev = &rte_eth_devices[port_id];
+	priv = dev->data->dev_private;
+	return mlx5_devx_cmd_flow_dump(priv->sh, file);
+}
drivers/net/mlx5/rte_pmd_mlx5.h new file +39 -0
new file mode 100644
index 0000000000..f92a054541
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright 2019 Mellanox Technologies, Ltd
+ */
+
+#ifndef _RTE_PMD_MLX5_H_
+#define _RTE_PMD_MLX5_H_
+
+/**
+ * @file
+ *
+ * Mellanox private RTE level APIs.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Dump flow raw data to file
+ *
+ * @param port_id
+ *    The port identifier of the Ethernet device.
+ * @param file
+ *   The index of the transmit queue which want to query.
+ * @return
+ *   0 on success, a nagative value otherwise.
+ */
+__rte_experimental
+int
+rte_pmd_mlx5_flow_dump(uint16_t port_id, FILE *file);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _RTE_PMD_MLX5_H_ */
drivers/net/mlx5/rte_pmd_mlx5_version.map +7 -0
index f9f17e4f6e..c7b70201d8 100644
@@ -1,3 +1,10 @@
 DPDK_20.0 {
 	local: *;
 };
+
+EXPERIMENTAL {
+	global:
+
+	rte_pmd_mlx5_flow_dump;
+
+};
Signature · 1 line
2.24.1
author
#2 lore raw

RFC 2/4 app/testpmd: new flow dump CLI

In reply to Xiaoyu Min

From: Xueming Li <[email protected]>

New flow dump CLI to dump MLX5 PMD specific flows into screen.

---
 app/test-pmd/Makefile       |  4 ++
 app/test-pmd/cmdline_flow.c | 91 +++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c       | 33 ++++++++++++++
 app/test-pmd/meson.build    |  3 ++
 app/test-pmd/testpmd.h      |  1 +
 5 files changed, 132 insertions(+)
app/test-pmd/Makefile +4 -0
index d5258eae4a..e60c8ecf63 100644
@@ -70,6 +70,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC),y)
 LDLIBS += -lrte_pmd_softnic
 endif
 
+ifeq ($(CONFIG_RTE_LIBRTE_MLX5_PMD),y)
+LDLIBS += -lrte_pmd_mlx5
+endif
+
 endif
 
 include $(RTE_SDK)/mk/rte.app.mk
app/test-pmd/cmdline_flow.c +91 -0

163 lines not on this page · raw message

app/test-pmd/config.c +33 -0
index 9da1ffb034..b5a9915df9 100644
@@ -48,6 +48,9 @@
 #ifdef RTE_LIBRTE_BNXT_PMD
 #include <rte_pmd_bnxt.h>
 #endif
+#ifdef RTE_LIBRTE_MLX5_PMD
+#include <rte_pmd_mlx5.h>
+#endif
 #include <rte_gro.h>
 #include <rte_config.h>
 
@@ -1441,6 +1444,36 @@ port_flow_flush(portid_t port_id)
 	return ret;
 }
 
+/** Dump all flow rules. */
+int
+port_flow_dump(portid_t port_id __rte_unused,
+	       const char *file_name __rte_unused)
+{
+	int ret = 0;
+#ifdef RTE_LIBRTE_MLX5_PMD
+	FILE * file = stdout;
+
+	if (file_name && strlen(file_name)) {
+		file = fopen(file_name, "w");
+		if (!file) {
+			printf("Failed to create file %s: %s\n", file_name,
+			       strerror(errno));
+			return -errno;
+		}
+	}
+	ret = rte_pmd_mlx5_flow_dump(port_id, file);
+	if (ret)
+		printf("Failed to dump flow: %s\n", strerror(-ret));
+	else
+		printf("Flow dump finished\n");
+	if (file_name && strlen(file_name))
+		fclose(file);
+#else
+	printf("MLX5 PMD driver disabled\n");
+#endif
+	return ret;
+}
+
 /** Query a flow rule. */
 int
 port_flow_query(portid_t port_id, uint32_t rule,
app/test-pmd/meson.build +3 -0
index 6006c60f99..a71e0a0cd1 100644
@@ -48,3 +48,6 @@ if dpdk_conf.has('RTE_LIBRTE_BPF')
 	sources += files('bpf_cmd.c')
 	deps += 'bpf'
 endif
+if dpdk_conf.has('RTE_LIBRTE_MLX5_PMD')
+	deps += 'pmd_mlx5'
+endif
app/test-pmd/testpmd.h +1 -0
index 857a11f8de..e1b9aba360 100644
@@ -734,6 +734,7 @@ int port_flow_create(portid_t port_id,
 		     const struct rte_flow_action *actions);
 int port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule);
 int port_flow_flush(portid_t port_id);
+int port_flow_dump(portid_t port_id, const char *file_name);
 int port_flow_query(portid_t port_id, uint32_t rule,
 		    const struct rte_flow_action *action);
 void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group);
Signature · 1 line
2.24.1
author
#7 lore raw

RFC 3/4 net/mlx5: add socket server for external tools

In reply to Xiaoyu Min

From: Xueming Li <[email protected]>

Add pmd unix socket server to enable external tool applications to trigger flow dump.

Socket path:

	/var/tmp/dpdk_mlx5_<pid>

Socket format:
io_raw: port_id of uint16
file: file descriptor of int

---
 drivers/net/mlx5/Makefile      |   1 +
 drivers/net/mlx5/meson.build   |   1 +
 drivers/net/mlx5/mlx5.c        |   2 +
 drivers/net/mlx5/mlx5.h        |   5 +
 drivers/net/mlx5/mlx5_socket.c | 226 +++++++++++++++++++++++++++++++++
 5 files changed, 235 insertions(+)
 create mode 100644 drivers/net/mlx5/mlx5_socket.c
drivers/net/mlx5/Makefile +1 -0
index 0ff907445e..5f64d6ef02 100644
@@ -40,6 +40,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_nl.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_devx_cmds.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_utils.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += rte_pmd_mlx5.c
+SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_socket.c
 
 # Export include files of private API.
 SYMLINK-$(CONFIG_RTE_LIBRTE_MLX5_PMD)-include += rte_pmd_mlx5.h
drivers/net/mlx5/meson.build +1 -0
index 1bdebcb6fc..8e5aabfdd3 100644
@@ -62,6 +62,7 @@ if build
 		'mlx5_devx_cmds.c',
 		'mlx5_utils.c',
 		'rte_pmd_mlx5.c',
+		'mlx5_socket.c',
 	)
 	if (dpdk_conf.has('RTE_ARCH_X86_64')
 		or dpdk_conf.has('RTE_ARCH_ARM64')
drivers/net/mlx5/mlx5.c +2 -0
index 50960c91ce..ffee39c1a0 100644
@@ -2954,6 +2954,8 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct mlx5_dev_config dev_config;
 	int ret;
 
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+		mlx5_pmd_socket_init();
 	ret = mlx5_init_once();
 	if (ret) {
 		DRV_LOG(ERR, "unable to init PMD global data: %s",
drivers/net/mlx5/mlx5.h +5 -0
index 68b08a7f0b..92713551aa 100644
@@ -988,6 +988,11 @@ void mlx5_mp_uninit_primary(void);
 int mlx5_mp_init_secondary(void);
 void mlx5_mp_uninit_secondary(void);
 
+/* mlx5_socket.c */
+
+int mlx5_pmd_socket_init(void);
+void mlx5_pmd_socket_uninit(void);
+
 /* mlx5_nl.c */
 
 int mlx5_nl_init(int protocol);
drivers/net/mlx5/mlx5_socket.c new file +226 -0

226 lines not on this page · raw message

Signature · 1 line
2.24.1
author
#8 lore raw

RFC 4/4 doc: update mlx5 document for flow dump feature

In reply to Xiaoyu Min

From: Xueming Li <[email protected]>

Guide of mlx5 is updated on how to dump HW flows.

---
 doc/guides/nics/mlx5.rst | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
doc/guides/nics/mlx5.rst +28 -0
index 92228d3cca..4781aae0aa 100644
@@ -1316,3 +1316,31 @@ ConnectX-4/ConnectX-5/ConnectX-6/BlueField devices managed by librte_pmd_mlx5.
       Port 3 Link Up - speed 10000 Mbps - full-duplex
       Done
       testpmd>
+
+HowTo dump flows
+----------------
+
+This section demonstrates how to dump flows. Currently, it's possible to dump
+all flows with assistence of external tools.
+
+#. 2 ways to get flow raw file:
+
+   - Using testpmd CLI:
+
+   .. code-block:: console
+
+       testpmd> flow dump <port> <output_file>
+
+   - call mlx5 PMD api in rte_pmd_mlx5.h:
+
+   .. code-block:: console
+
+       rte_pmd_mlx5_flow_dump(port, file);
+
+#. Dump humanreadable flows from raw file:
+
+   Get flow parsing tool from: https://github.com/Mellanox/mlx_steering_dump
+
+   .. code-block:: console
+
+       mlx_steering_dump.py -f <output_file>
Signature · 1 line
2.24.1
#3 lore raw

Re: [dpdk-dev] [RFC 2/4] app/testpmd: new flow dump CLI

In reply to Xiaoyu Min
Quoted 17 lines · Xiaoyu Min

From: Xueming Li <[email protected]>

New flow dump CLI to dump MLX5 PMD specific flows into screen.

---
 app/test-pmd/Makefile       |  4 ++
 app/test-pmd/cmdline_flow.c | 91 +++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c       | 33 ++++++++++++++
 app/test-pmd/meson.build    |  3 ++
 app/test-pmd/testpmd.h      |  1 +
 5 files changed, 132 insertions(+)

app/test-pmd/config.c port_flow_flush(portid_t port_id) · line 1453

Quoted 7 lines
app/test-pmd/config.c +7 -0
+/** Dump all flow rules. */
+int
+port_flow_dump(portid_t port_id __rte_unused,
+              const char *file_name __rte_unused)
+{
+       int ret = 0;
+#ifdef RTE_LIBRTE_MLX5_PMD

IMO, It should be the last resort to add driver-specific symbols in testpmd. Why not introduce rte_flow_dump() and hook the MLX driver underneath?

Quoted 22 lines
app/test-pmd/config.c +22 -0
+       FILE * file = stdout;
+
+       if (file_name && strlen(file_name)) {
+               file = fopen(file_name, "w");
+               if (!file) {
+                       printf("Failed to create file %s: %s\n", file_name,
+                              strerror(errno));
+                       return -errno;
+               }
+       }
+       ret = rte_pmd_mlx5_flow_dump(port_id, file);
+       if (ret)
+               printf("Failed to dump flow: %s\n", strerror(-ret));
+       else
+               printf("Flow dump finished\n");
+       if (file_name && strlen(file_name))
+               fclose(file);
+#else
+       printf("MLX5 PMD driver disabled\n");
+#endif
+       return ret;
+}
author
#4 lore raw

Re: [dpdk-dev] [RFC 2/4] app/testpmd: new flow dump CLI

Quoted 18 lines · Jerin Jacob
Quoted 17 lines · Xiaoyu Min

From: Xueming Li <[email protected]>

New flow dump CLI to dump MLX5 PMD specific flows into screen.

---
 app/test-pmd/Makefile       |  4 ++
 app/test-pmd/cmdline_flow.c | 91 +++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c       | 33 ++++++++++++++
 app/test-pmd/meson.build    |  3 ++
 app/test-pmd/testpmd.h      |  1 +
 5 files changed, 132 insertions(+)
Quoted 11 lines

app/test-pmd/config.c port_flow_flush(portid_t port_id) · line 1453

Quoted 7 lines
app/test-pmd/config.c +7 -0
+/** Dump all flow rules. */
+int
+port_flow_dump(portid_t port_id __rte_unused,
+              const char *file_name __rte_unused)
+{
+       int ret = 0;
+#ifdef RTE_LIBRTE_MLX5_PMD

IMO, It should be the last resort to add driver-specific symbols in testpmd. Why not introduce rte_flow_dump() and hook the MLX driver underneath?

Hey Jerin,

Thanks for you comments.

What my understanding is this flow dump is very Mellanox specific, it will dump all flows in Mellanox HW using Mellanox format. They are hardware flows in short, which are different from rte flow.

I don't know whether other vendor has the similar functionality and needs so an rte flow level API could be helpful.

And basically rte flow API is based on rte_flow, a dump function probabily means dump rte_flow itself (i.e flow->attr, pattern, actions).

This is the reason a private API is choosen and driver-specific symbols added in testpmd as result.

-Jack

#5 lore raw

Re: [dpdk-dev] [RFC 2/4] app/testpmd: new flow dump CLI

Quoted 31 lines · Jack Min
Quoted 18 lines · Jerin Jacob
Quoted 17 lines · Xiaoyu Min

From: Xueming Li <[email protected]>

New flow dump CLI to dump MLX5 PMD specific flows into screen.

---
 app/test-pmd/Makefile       |  4 ++
 app/test-pmd/cmdline_flow.c | 91 +++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c       | 33 ++++++++++++++
 app/test-pmd/meson.build    |  3 ++
 app/test-pmd/testpmd.h      |  1 +
 5 files changed, 132 insertions(+)
Quoted 11 lines

app/test-pmd/config.c port_flow_flush(portid_t port_id) · line 1453

Quoted 7 lines
app/test-pmd/config.c +7 -0
+/** Dump all flow rules. */
+int
+port_flow_dump(portid_t port_id __rte_unused,
+              const char *file_name __rte_unused)
+{
+       int ret = 0;
+#ifdef RTE_LIBRTE_MLX5_PMD

IMO, It should be the last resort to add driver-specific symbols in testpmd. Why not introduce rte_flow_dump() and hook the MLX driver underneath?

Quoted 1 line

Hey Jerin,

Hi Jack.

Quoted 6 lines

Thanks for you comments.

What my understanding is this flow dump is very Mellanox specific, it will dump all flows in Mellanox HW using Mellanox format. They are hardware flows in short, which are different from rte flow.

We do have a similar API for other drivers to represent the internal info. I think, similar API[1] would suffice for your case. We should not standardize the output of dump, instead, it will provide a generic API to dump the internal representation of flow HW to file/stdout.

Octeontx2 MACM HW (rte_flow) has similar internal information, We could implement the driver API if it is a generic API.

[1]
See the below example for eventdev driver.

/**
* Dump internal information about *dev_id* to the FILE* provided in *f*. *
* @param dev_id
* The identifier of the device.
*
* @param f
* A pointer to a file for output
*
* @return
* - 0: on success
* - <0: on failure.
*/
int
rte_event_dev_dump(uint8_t dev_id, FILE *f);

Quoted 11 lines

I don't know whether other vendor has the similar functionality and needs so an rte flow level API could be helpful.

And basically rte flow API is based on rte_flow, a dump function probabily means dump rte_flow itself (i.e flow->attr, pattern, actions).

This is the reason a private API is choosen and driver-specific symbols added in testpmd as result.

-Jack

author
#6 lore raw

Re: [dpdk-dev] [RFC 2/4] app/testpmd: new flow dump CLI

Quoted 43 lines · Jerin Jacob
Quoted 31 lines · Jack Min
Quoted 18 lines · Jerin Jacob
Quoted 17 lines · Xiaoyu Min

From: Xueming Li <[email protected]>

New flow dump CLI to dump MLX5 PMD specific flows into screen.

---
 app/test-pmd/Makefile       |  4 ++
 app/test-pmd/cmdline_flow.c | 91 +++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c       | 33 ++++++++++++++
 app/test-pmd/meson.build    |  3 ++
 app/test-pmd/testpmd.h      |  1 +
 5 files changed, 132 insertions(+)
Quoted 11 lines

app/test-pmd/config.c port_flow_flush(portid_t port_id) · line 1453

Quoted 7 lines
app/test-pmd/config.c +7 -0
+/** Dump all flow rules. */
+int
+port_flow_dump(portid_t port_id __rte_unused,
+              const char *file_name __rte_unused)
+{
+       int ret = 0;
+#ifdef RTE_LIBRTE_MLX5_PMD

IMO, It should be the last resort to add driver-specific symbols in testpmd. Why not introduce rte_flow_dump() and hook the MLX driver underneath?

Quoted 1 line

Hey Jerin,

Hi Jack.

Quoted 6 lines

Thanks for you comments.

What my understanding is this flow dump is very Mellanox specific, it will dump all flows in Mellanox HW using Mellanox format. They are hardware flows in short, which are different from rte flow.

Quoted 7 lines

We do have a similar API for other drivers to represent the internal info. I think, similar API[1] would suffice for your case. We should not standardize the output of dump, instead, it will provide a generic API to dump the internal representation of flow HW to file/stdout.

Octeontx2 MACM HW (rte_flow) has similar internal information, We could implement the driver API if it is a generic API.

Yes, a generic rte_flow API (as similar as [1])can benifit both of us. :-) I'll propose a new rte_flow API for this in v2.

Thanks,
-Jack

Quoted 32 lines

[1]
See the below example for eventdev driver.

/**
* Dump internal information about *dev_id* to the FILE* provided in *f*. *
* @param dev_id
* The identifier of the device.
*
* @param f
* A pointer to a file for output
*
* @return
* - 0: on success
* - <0: on failure.
*/
int
rte_event_dev_dump(uint8_t dev_id, FILE *f);

Quoted 11 lines

I don't know whether other vendor has the similar functionality and needs so an rte flow level API could be helpful.

And basically rte flow API is based on rte_flow, a dump function probabily means dump rte_flow itself (i.e flow->attr, pattern, actions).

This is the reason a private API is choosen and driver-specific symbols added in testpmd as result.

-Jack