DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/3] enhance the vlan filter feature
@ 2025-04-11  8:10 Chaoyong He
  2025-04-11  8:10 ` [PATCH 1/3] app/testpmd: add/remove multiple VLAN filter IDs at once Chaoyong He
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Chaoyong He @ 2025-04-11  8:10 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series aims to enhance the vlan filter feature:
- Support add/remove multiple vlan IDs just in one comment.
- Support show the already configured vlan IDs.

Long Wu (3):
  app/testpmd: add/remove multiple VLAN filter IDs at once
  ethdev: retrieve VLAN filter configuration
  app/testpmd: add a command to show VLAN filter IDs

 app/test-pmd/cmdline.c                      |  92 +++++++++++---
 app/test-pmd/config.c                       | 128 ++++++++++++++++++++
 app/test-pmd/testpmd.h                      |   2 +
 doc/guides/rel_notes/release_25_07.rst      |   5 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  27 ++++-
 lib/ethdev/ethdev_trace.h                   |   8 ++
 lib/ethdev/ethdev_trace_points.c            |   3 +
 lib/ethdev/rte_ethdev.c                     |  24 ++++
 lib/ethdev/rte_ethdev.h                     |  19 +++
 9 files changed, 289 insertions(+), 19 deletions(-)

-- 
2.43.5


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

* [PATCH 1/3] app/testpmd: add/remove multiple VLAN filter IDs at once
  2025-04-11  8:10 [PATCH 0/3] enhance the vlan filter feature Chaoyong He
@ 2025-04-11  8:10 ` Chaoyong He
  2025-04-11 16:27   ` Stephen Hemminger
  2025-04-11  8:10 ` [PATCH 2/3] ethdev: retrieve VLAN filter configuration Chaoyong He
  2025-04-11  8:10 ` [PATCH 3/3] app/testpmd: add a command to show VLAN filter IDs Chaoyong He
  2 siblings, 1 reply; 6+ messages in thread
From: Chaoyong He @ 2025-04-11  8:10 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He

From: Long Wu <long.wu@corigine.com>

The command of setting VLAN filter IDs can only set one VLAN filter
ID at once. For example:
testpmd> rx_vlan add 100 0

This is very inefficient in some case because it forces the
user type this command as many times as the VLAN filter IDs
they want to set.

This patch supports the user set any number valid VLAN filter
IDs just through one command and it is also backwards compatible.
For example:
testpmd> rx_vlan add 100,102-103,200 0
The VLAN filter IDs 100, 102, 103, 200 will be added to port 0.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 app/test-pmd/cmdline.c                      | 46 ++++++++++-----
 app/test-pmd/config.c                       | 64 +++++++++++++++++++++
 app/test-pmd/testpmd.h                      |  1 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 20 +++++--
 4 files changed, 112 insertions(+), 19 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index d4bb3ec998..5a627a9bc6 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -411,12 +411,12 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Set the VLAN TPID for Packet Filtering on"
 			" a port\n\n"
 
-			"rx_vlan add (vlan_id|all) (port_id)\n"
-			"    Add a vlan_id, or all identifiers, to the set"
+			"rx_vlan add (vlan_id_list|all) (port_id)\n"
+			"    Add a list of vlan_id, or all identifiers, to the set"
 			" of VLAN identifiers filtered by port_id.\n\n"
 
-			"rx_vlan rm (vlan_id|all) (port_id)\n"
-			"    Remove a vlan_id, or all identifiers, from the set"
+			"rx_vlan rm (vlan_id_list|all) (port_id)\n"
+			"    Remove a list of vlan_id, or all identifiers, from the set"
 			" of VLAN identifiers filtered by port_id.\n\n"
 
 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
@@ -4653,11 +4653,11 @@ static cmdline_parse_inst_t cmd_vlan_tpid = {
 	},
 };
 
-/* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
+/* *** ADD/REMOVE A LIST OF VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
 struct cmd_rx_vlan_filter_result {
 	cmdline_fixed_string_t rx_vlan;
 	cmdline_fixed_string_t what;
-	uint16_t vlan_id;
+	cmdline_fixed_string_t vlan_id_list;
 	portid_t port_id;
 };
 
@@ -4666,12 +4666,28 @@ cmd_rx_vlan_filter_parsed(void *parsed_result,
 			  __rte_unused struct cmdline *cl,
 			  __rte_unused void *data)
 {
+	int i;
+	int on = 0;
+	int vlan_id_count;
+	uint16_t vlan_id[4096];
 	struct cmd_rx_vlan_filter_result *res = parsed_result;
 
-	if (!strcmp(res->what, "add"))
-		rx_vft_set(res->port_id, res->vlan_id, 1);
-	else
-		rx_vft_set(res->port_id, res->vlan_id, 0);
+	vlan_id_count = rx_vft_list_parse(vlan_id, res->vlan_id_list);
+	if (vlan_id_count <= 0) {
+		fprintf(stderr, "Please input correct vlan id list\n");
+		return;
+	}
+
+	if (strcmp(res->what, "add") == 0)
+		on = 1;
+
+	for (i = 0; i < vlan_id_count; i++) {
+		if (rx_vft_set(res->port_id, vlan_id[i], on) != 0) {
+			fprintf(stderr, "Failed to %s vlan id %d\n",
+					res->what, vlan_id[i]);
+			break;
+		}
+	}
 }
 
 static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
@@ -4680,9 +4696,9 @@ static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
 static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
 				 what, "add#rm");
-static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
-	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
-			      vlan_id, RTE_UINT16);
+static cmdline_parse_token_string_t cmd_rx_vlan_filter_vlanid =
+	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
+				 vlan_id_list, NULL);
 static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
 			      port_id, RTE_UINT16);
@@ -4690,8 +4706,8 @@ static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
 static cmdline_parse_inst_t cmd_rx_vlan_filter = {
 	.f = cmd_rx_vlan_filter_parsed,
 	.data = NULL,
-	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
-		"Add/Remove a VLAN identifier to/from the set of VLAN "
+	.help_str = "rx_vlan add|rm <vlan_id_list0[,vlan_id_list1]*> <port_id>: "
+		"Add/Remove a list of VLAN identifiers to/from the set of VLAN "
 		"identifiers filtered by a port",
 	.tokens = {
 		(void *)&cmd_rx_vlan_filter_rx_vlan,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index e89af21cec..61f93a9ca5 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -6612,6 +6612,70 @@ rx_vlan_all_filter_set(portid_t port_id, int on)
 	}
 }
 
+int
+rx_vft_list_parse(uint16_t *vlan_id, char *vlan_id_list)
+{
+	int i;
+	int min;
+	int max;
+	bool dup;
+	int index;
+	int count = 0;
+	char *end = NULL;
+
+	/*
+	 * The acceptable VLAN ID list format should be like: 1,3-4,7.
+	 * Use `,` to separate VLAN ID list.
+	 * Use `-` to represent range.
+	 */
+	min = -1;
+	do {
+		while (isblank(*vlan_id_list))
+			vlan_id_list++;
+		if (*vlan_id_list == '\0')
+			return -1;
+
+		errno = 0;
+		index = strtol(vlan_id_list, &end, 10);
+		if (errno || end == NULL)
+			return -1;
+		if (index < 0)
+			return -1;
+
+		while (isblank(*end))
+			end++;
+
+		if ((*end == ',') || (*end == '\0')) {
+			max = index;
+			if (min == -1)
+				min = index;
+			for (index = min; index <= max; index++) {
+				dup = false;
+
+				for (i = 0; i < count; i++) {
+					if (vlan_id[i] == index)
+						dup = true;
+				}
+				if (dup)
+					continue;
+				if (count >= 4096)
+					return -1;
+
+				vlan_id[count++] = index;
+			}
+			min = -1;
+		} else if (*end == '-') {
+			min = index;
+		} else {
+			return -1;
+		}
+
+		vlan_id_list = end + 1;
+	} while (*end != '\0');
+
+	return count;
+}
+
 void
 vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type, uint16_t tp_id)
 {
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 05ccdec8d2..ac4f716408 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -1103,6 +1103,7 @@ void rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t queue_id, int on);
 void rx_vlan_filter_set(portid_t port_id, int on);
 void rx_vlan_all_filter_set(portid_t port_id, int on);
 void rx_vlan_qinq_strip_set(portid_t port_id, int on);
+int rx_vft_list_parse(uint16_t *vlan_id, char *vlan_id_list);
 int rx_vft_set(portid_t port_id, uint16_t vlan_id, int on);
 void vlan_extend_set(portid_t port_id, int on);
 void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index eeef49500f..b35722d2f5 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1035,9 +1035,15 @@ Set the inner or outer VLAN TPID for packet filtering on a port::
 rx_vlan add
 ~~~~~~~~~~~
 
-Add a VLAN ID, or all identifiers, to the set of VLAN identifiers filtered by port ID::
+Add a list of VLAN IDs, or all identifiers, to the set of VLAN identifiers filtered by port ID::
 
-   testpmd> rx_vlan add (vlan_id|all) (port_id)
+   testpmd> rx_vlan add (<vlan_id_list0[,vlan_id_list1]*>|all) (port_id)
+
+For example, to add some VLAN identifiers filtered by port:
+
+.. code-block:: console
+
+   testpmd> rx_vlan add 1,3-4,7 0
 
 .. note::
 
@@ -1048,9 +1054,15 @@ Add a VLAN ID, or all identifiers, to the set of VLAN identifiers filtered by po
 rx_vlan rm
 ~~~~~~~~~~
 
-Remove a VLAN ID, or all identifiers, from the set of VLAN identifiers filtered by port ID::
+Remove a list of VLAN IDs, or all identifiers, from the set of VLAN identifiers filtered by port ID::
+
+   testpmd> rx_vlan rm (<vlan_id_list0[,vlan_id_list1]*>|all) (port_id)
+
+For example, to remove some VLAN identifiers filtered by port:
+
+.. code-block:: console
 
-   testpmd> rx_vlan rm (vlan_id|all) (port_id)
+   testpmd> rx_vlan rm 1,3-4,7 0
 
 rx_vlan add (for VF)
 ~~~~~~~~~~~~~~~~~~~~
-- 
2.43.5


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

* [PATCH 2/3] ethdev: retrieve VLAN filter configuration
  2025-04-11  8:10 [PATCH 0/3] enhance the vlan filter feature Chaoyong He
  2025-04-11  8:10 ` [PATCH 1/3] app/testpmd: add/remove multiple VLAN filter IDs at once Chaoyong He
@ 2025-04-11  8:10 ` Chaoyong He
  2025-04-11  8:10 ` [PATCH 3/3] app/testpmd: add a command to show VLAN filter IDs Chaoyong He
  2 siblings, 0 replies; 6+ messages in thread
From: Chaoyong He @ 2025-04-11  8:10 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He

From: Long Wu <long.wu@corigine.com>

Added an API `rte_eth_dev_get_vlan_filter_conf()` to retrieve
the VLAN filter configuration of an Ethernet device.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 doc/guides/rel_notes/release_25_07.rst |  5 +++++
 lib/ethdev/ethdev_trace.h              |  8 ++++++++
 lib/ethdev/ethdev_trace_points.c       |  3 +++
 lib/ethdev/rte_ethdev.c                | 24 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 19 +++++++++++++++++++
 5 files changed, 59 insertions(+)

diff --git a/doc/guides/rel_notes/release_25_07.rst b/doc/guides/rel_notes/release_25_07.rst
index 093b85d206..81d4c36f77 100644
--- a/doc/guides/rel_notes/release_25_07.rst
+++ b/doc/guides/rel_notes/release_25_07.rst
@@ -55,6 +55,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added an API to retrieve VLAN filter configuration.**
+
+  Added an API ``rte_eth_dev_get_vlan_filter_conf`` to retrieve the VLAN filter
+  configuration of an Ethernet device.
+
 
 Removed Items
 -------------
diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h
index c65b78590a..ecea305c66 100644
--- a/lib/ethdev/ethdev_trace.h
+++ b/lib/ethdev/ethdev_trace.h
@@ -639,6 +639,14 @@ RTE_TRACE_POINT(
 	rte_trace_point_emit_int(ret);
 )
 
+RTE_TRACE_POINT(
+	rte_ethdev_trace_vlan_filter_conf_get,
+	RTE_TRACE_POINT_ARGS(uint16_t port_id,
+			struct rte_vlan_filter_conf *vf_conf),
+	rte_trace_point_emit_u16(port_id);
+	rte_trace_point_emit_ptr(vf_conf);
+)
+
 RTE_TRACE_POINT(
 	rte_ethdev_trace_set_vlan_strip_on_queue,
 	RTE_TRACE_POINT_ARGS(uint16_t port_id, uint16_t rx_queue_id, int on),
diff --git a/lib/ethdev/ethdev_trace_points.c b/lib/ethdev/ethdev_trace_points.c
index 071c508327..913a99f8c0 100644
--- a/lib/ethdev/ethdev_trace_points.c
+++ b/lib/ethdev/ethdev_trace_points.c
@@ -266,6 +266,9 @@ RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_set_mtu,
 RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_vlan_filter,
 	lib.ethdev.vlan_filter)
 
+RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_vlan_filter_conf_get,
+	lib.ethdev.vlan_filter_conf_get)
+
 RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_set_vlan_strip_on_queue,
 	lib.ethdev.set_vlan_strip_on_queue)
 
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index d4197322a0..a2c05594ff 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -4433,6 +4433,30 @@ rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on)
 	return ret;
 }
 
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_dev_get_vlan_filter_conf, 25.07)
+int
+rte_eth_dev_get_vlan_filter_conf(uint16_t port_id,
+		struct rte_vlan_filter_conf *vf_conf)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (vf_conf == NULL) {
+		RTE_ETHDEV_LOG_LINE(ERR,
+			"Cannot get ethdev port %u vlan filter configuration to NULL",
+			port_id);
+		return -EINVAL;
+	}
+
+	memcpy(vf_conf, &dev->data->vlan_filter_conf, sizeof(struct rte_vlan_filter_conf));
+
+	rte_ethdev_trace_vlan_filter_conf_get(port_id, vf_conf);
+
+	return 0;
+}
+
 RTE_EXPORT_SYMBOL(rte_eth_dev_set_vlan_strip_on_queue)
 int
 rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index ea7f8c4a1a..190fd4d3a7 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -3709,6 +3709,25 @@ int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
  */
 int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Retrieve the VLAN filter configuration of an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param vf_conf
+ *   Location for Ethernet device VLAN filter configuration to be filled in.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EINVAL) if bad parameter.
+ */
+__rte_experimental
+int rte_eth_dev_get_vlan_filter_conf(uint16_t port_id,
+		struct rte_vlan_filter_conf *vf_conf);
+
 /**
  * Enable/Disable hardware VLAN Strip by a Rx queue of an Ethernet device.
  *
-- 
2.43.5


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

* [PATCH 3/3] app/testpmd: add a command to show VLAN filter IDs
  2025-04-11  8:10 [PATCH 0/3] enhance the vlan filter feature Chaoyong He
  2025-04-11  8:10 ` [PATCH 1/3] app/testpmd: add/remove multiple VLAN filter IDs at once Chaoyong He
  2025-04-11  8:10 ` [PATCH 2/3] ethdev: retrieve VLAN filter configuration Chaoyong He
@ 2025-04-11  8:10 ` Chaoyong He
  2 siblings, 0 replies; 6+ messages in thread
From: Chaoyong He @ 2025-04-11  8:10 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He

From: Long Wu <long.wu@corigine.com>

Introduce a new command to show the VLAN identifiers
filtered by a port.
Usage example:
testpmd> rx_vlan show port 0
VLAN filter IDs:
1,4-5,9,12,14,18,3864-3865,3869,3874,3878,4076-4091,4093,4095,
testpmd>

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 app/test-pmd/cmdline.c                      | 46 +++++++++++++++
 app/test-pmd/config.c                       | 64 +++++++++++++++++++++
 app/test-pmd/testpmd.h                      |  1 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  7 +++
 4 files changed, 118 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 5a627a9bc6..0ac50545b0 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4718,6 +4718,51 @@ static cmdline_parse_inst_t cmd_rx_vlan_filter = {
 	},
 };
 
+/* *** SHOW VLAN IDENTIFIERS FROM A PORT VLAN RX FILTER *** */
+struct cmd_rx_vlan_filter_show_result {
+	cmdline_fixed_string_t rx_vlan;
+	cmdline_fixed_string_t show;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+};
+
+static void
+cmd_rx_vlan_filter_show_parsed(void *parsed_result,
+			       __rte_unused struct cmdline *cl,
+			       __rte_unused void *data)
+{
+	struct cmd_rx_vlan_filter_show_result *res = parsed_result;
+
+	rx_vft_dump(res->port_id);
+}
+
+static cmdline_parse_token_string_t cmd_rx_vlan_filter_show_rx_vlan =
+	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_show_result,
+				rx_vlan, "rx_vlan");
+static cmdline_parse_token_string_t cmd_rx_vlan_filter_show_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_show_result,
+				show, "show");
+static cmdline_parse_token_string_t cmd_rx_vlan_filter_show_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_show_result,
+				port, "port");
+static cmdline_parse_token_num_t cmd_rx_vlan_filter_show_portid =
+	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_show_result,
+				port_id, RTE_UINT16);
+static cmdline_parse_inst_t cmd_rx_vlan_filter_show = {
+	.f = cmd_rx_vlan_filter_show_parsed,
+	.data = NULL,
+	.help_str = "rx_vlan show port <port_id>: "
+		"Show VLAN identifiers from the set of VLAN identifiers "
+		"filtered by a port",
+	.tokens = {
+		(void *)&cmd_rx_vlan_filter_show_rx_vlan,
+		(void *)&cmd_rx_vlan_filter_show_show,
+		(void *)&cmd_rx_vlan_filter_show_port,
+		(void *)&cmd_rx_vlan_filter_show_portid,
+		NULL,
+	},
+};
+
 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
 struct cmd_tx_vlan_set_result {
 	cmdline_fixed_string_t tx_vlan;
@@ -13756,6 +13801,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
 	&cmd_vlan_tpid,
 	&cmd_rx_vlan_filter_all,
 	&cmd_rx_vlan_filter,
+	&cmd_rx_vlan_filter_show,
 	&cmd_tx_vlan_set,
 	&cmd_tx_vlan_set_qinq,
 	&cmd_tx_vlan_reset,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 61f93a9ca5..313d49812d 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -6676,6 +6676,70 @@ rx_vft_list_parse(uint16_t *vlan_id, char *vlan_id_list)
 	return count;
 }
 
+static void
+rx_vft_dump_printf(int left, int right, int *c_count)
+{
+	if (left == right)
+		*c_count += printf("%d,", left);
+	else
+		*c_count += printf("%d-%d,", left, right);
+
+	if (*c_count >= 120) {
+		*c_count = 0;
+		printf("\n");
+	}
+}
+
+void
+rx_vft_dump(uint16_t port_id)
+{
+	int ret;
+	uint16_t vidx;
+	uint16_t vbit;
+	uint64_t vmap;
+	int left, right, c_count;
+	struct rte_vlan_filter_conf vfc;
+
+	ret = rte_eth_dev_get_vlan_filter_conf(port_id, &vfc);
+	if (ret != 0) {
+		fprintf(stderr,
+			"Get VLAN filter configuration from port %u failed, ret = %d\n",
+			port_id, ret);
+		return;
+	}
+
+	printf("VLAN filter IDs:\n");
+
+	left = -1;
+	right = -1;
+	c_count = 0;
+	for (vidx = 0; vidx < 64; vidx++) {
+		vmap = vfc.ids[vidx];
+		for (vbit = 0; vbit < 64; vbit++) {
+			if ((vmap & RTE_BIT64(vbit)) != 0) {
+				if (left == -1)
+					left = vidx * 64 + vbit;
+
+				continue;
+			}
+
+			if (left != -1) {
+				right = vidx * 64 + vbit - 1;
+				rx_vft_dump_printf(left, right, &c_count);
+				left = -1;
+				right = -1;
+			}
+		}
+	}
+
+	if (left != -1 && right == -1) {
+		right = 4095;
+		rx_vft_dump_printf(left, right, &c_count);
+	}
+
+	printf("\n");
+}
+
 void
 vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type, uint16_t tp_id)
 {
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index ac4f716408..610e130c56 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -1104,6 +1104,7 @@ void rx_vlan_filter_set(portid_t port_id, int on);
 void rx_vlan_all_filter_set(portid_t port_id, int on);
 void rx_vlan_qinq_strip_set(portid_t port_id, int on);
 int rx_vft_list_parse(uint16_t *vlan_id, char *vlan_id_list);
+void rx_vft_dump(uint16_t port_id);
 int rx_vft_set(portid_t port_id, uint16_t vlan_id, int on);
 void vlan_extend_set(portid_t port_id, int on);
 void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index b35722d2f5..0eb326e1d2 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1064,6 +1064,13 @@ For example, to remove some VLAN identifiers filtered by port:
 
    testpmd> rx_vlan rm 1,3-4,7 0
 
+rx_vlan show
+~~~~~~~~~~~~
+
+Show VLAN identifiers from the set of VLAN identifiers filtered by a port::
+
+   testpmd> rx_vlan show port (port_id)
+
 rx_vlan add (for VF)
 ~~~~~~~~~~~~~~~~~~~~
 
-- 
2.43.5


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

* Re: [PATCH 1/3] app/testpmd: add/remove multiple VLAN filter IDs at once
  2025-04-11  8:10 ` [PATCH 1/3] app/testpmd: add/remove multiple VLAN filter IDs at once Chaoyong He
@ 2025-04-11 16:27   ` Stephen Hemminger
  2025-04-14  6:26     ` Chaoyong He
  0 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2025-04-11 16:27 UTC (permalink / raw)
  To: Chaoyong He; +Cc: dev, oss-drivers, Long Wu

On Fri, 11 Apr 2025 16:10:03 +0800
Chaoyong He <chaoyong.he@corigine.com> wrote:

> From: Long Wu <long.wu@corigine.com>
> 
> The command of setting VLAN filter IDs can only set one VLAN filter
> ID at once. For example:
> testpmd> rx_vlan add 100 0  
> 
> This is very inefficient in some case because it forces the
> user type this command as many times as the VLAN filter IDs
> they want to set.
> 
> This patch supports the user set any number valid VLAN filter
> IDs just through one command and it is also backwards compatible.
> For example:
> testpmd> rx_vlan add 100,102-103,200 0  
> The VLAN filter IDs 100, 102, 103, 200 will be added to port 0.
> 
> Signed-off-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>

Not sure if this is really worth the effort.
Testpmd is intended to exercise drivers, not as a production forwarding application
though users have tendency to be lazy and use it for that.

If consensus is to implement this, then DPDK should really have a way to parse
a range of values (already needed for cores). Then the library code could be used
here, rather than special parsing code only for VLAN's in testpmd.

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

* RE: [PATCH 1/3] app/testpmd: add/remove multiple VLAN filter IDs at once
  2025-04-11 16:27   ` Stephen Hemminger
@ 2025-04-14  6:26     ` Chaoyong He
  0 siblings, 0 replies; 6+ messages in thread
From: Chaoyong He @ 2025-04-14  6:26 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, oss-drivers, Long Wu

> On Fri, 11 Apr 2025 16:10:03 +0800
> Chaoyong He <chaoyong.he@corigine.com> wrote:
> 
> > From: Long Wu <long.wu@corigine.com>
> >
> > The command of setting VLAN filter IDs can only set one VLAN filter ID
> > at once. For example:
> > testpmd> rx_vlan add 100 0
> >
> > This is very inefficient in some case because it forces the user type
> > this command as many times as the VLAN filter IDs they want to set.
> >
> > This patch supports the user set any number valid VLAN filter IDs just
> > through one command and it is also backwards compatible.
> > For example:
> > testpmd> rx_vlan add 100,102-103,200 0
> > The VLAN filter IDs 100, 102, 103, 200 will be added to port 0.
> >
> > Signed-off-by: Long Wu <long.wu@corigine.com>
> > Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> 
> Not sure if this is really worth the effort.
> Testpmd is intended to exercise drivers, not as a production forwarding
> application though users have tendency to be lazy and use it for that.
> 
> If consensus is to implement this, then DPDK should really have a way to parse
> a range of values (already needed for cores). Then the library code could be
> used here, rather than special parsing code only for VLAN's in testpmd.

Okay, we can wait for this one.

Then how about the 2/3 and 3/3 patch?
Which are add a 'show' command for the VLAN filter IDs and I think they can split from this one.

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

end of thread, other threads:[~2025-04-14  6:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-11  8:10 [PATCH 0/3] enhance the vlan filter feature Chaoyong He
2025-04-11  8:10 ` [PATCH 1/3] app/testpmd: add/remove multiple VLAN filter IDs at once Chaoyong He
2025-04-11 16:27   ` Stephen Hemminger
2025-04-14  6:26     ` Chaoyong He
2025-04-11  8:10 ` [PATCH 2/3] ethdev: retrieve VLAN filter configuration Chaoyong He
2025-04-11  8:10 ` [PATCH 3/3] app/testpmd: add a command to show VLAN filter IDs Chaoyong He

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