* [PATCH] app/testpmd: add VLAN priority insert support
@ 2026-06-12 8:14 Xingui Yang
2026-06-15 9:46 ` fengchengwen
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Xingui Yang @ 2026-06-12 8:14 UTC (permalink / raw)
To: dev
Cc: stephen, david.marchand, aman.deep.singh, fengchengwen,
yangshuaisong, lihuisong, liuyonglong, kangfenglong
The tx_vlan set command currently only accepts a VLAN ID in range
[0, 4095]. This patch adds support for an extended format that includes
802.1p priority and CFI bits, allowing users to set the VLAN priority
tag when inserting VLAN headers in TX packets.
The extended format is:
bit 0-11: VLAN ID (0-4095)
bit 12: CFI (Canonical Format Indicator)
bit 13-15: Priority (0-7, 802.1p CoS)
This is consistent with the VLAN tag structure used by
rte_eth_dev_set_vlan_pvid() where the PVID field encodes VLAN ID, CFI
and priority in the same format.
A new command line option --enable-vlan-priority is added to enable this
feature. By default, the feature is disabled to maintain backward
compatibility with existing users. When enabled, the
vlan_id_is_invalid() function allows any 16-bit value to pass, while the
full 16-bit value (including CFI and priority bits) is passed to the
driver for hardware VLAN insertion.
Signed-off-by: Xingui Yang <yangxingui@huawei.com>
---
app/test-pmd/config.c | 24 +++++++++++++++---------
app/test-pmd/parameters.c | 6 ++++++
app/test-pmd/testpmd.c | 5 +++++
app/test-pmd/testpmd.h | 2 ++
4 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 36b9b023e2..80cde109e6 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1241,12 +1241,18 @@ void print_valid_ports(void)
}
static int
-vlan_id_is_invalid(uint16_t vlan_id)
+vlan_id_is_invalid(uint16_t vlan_id, int vlan_priority_ena)
{
- if (vlan_id < 4096)
- return 0;
- fprintf(stderr, "Invalid vlan_id %d (must be < 4096)\n", vlan_id);
- return 1;
+ if (!vlan_priority_ena && vlan_id >= 4096) {
+ fprintf(stderr, "Invalid vlan_id %d (must be < 4096)\n", vlan_id);
+ return 1;
+ }
+
+ /*
+ * When vlan_priority_ena is enabled, allow any 16-bit value
+ * to pass priority and CFI bits to the driver.
+ */
+ return 0;
}
static uint32_t
@@ -6876,7 +6882,7 @@ rx_vft_set(portid_t port_id, uint16_t vlan_id, int on)
if (port_id_is_invalid(port_id, ENABLED_WARN))
return 1;
- if (vlan_id_is_invalid(vlan_id))
+ if (vlan_id_is_invalid(vlan_id, vlan_priority_insert_ena))
return 1;
diag = rte_eth_dev_vlan_filter(port_id, vlan_id, on);
if (diag == 0)
@@ -6923,7 +6929,7 @@ tx_vlan_set(portid_t port_id, uint16_t vlan_id)
struct rte_eth_dev_info dev_info;
int ret;
- if (vlan_id_is_invalid(vlan_id))
+ if (vlan_id_is_invalid(vlan_id, vlan_priority_insert_ena))
return;
if (ports[port_id].dev_conf.txmode.offloads &
@@ -6954,9 +6960,9 @@ tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer)
struct rte_eth_dev_info dev_info;
int ret;
- if (vlan_id_is_invalid(vlan_id))
+ if (vlan_id_is_invalid(vlan_id, vlan_priority_insert_ena))
return;
- if (vlan_id_is_invalid(vlan_id_outer))
+ if (vlan_id_is_invalid(vlan_id_outer, vlan_priority_insert_ena))
return;
ret = eth_dev_info_get_print_err(port_id, &dev_info);
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 8c3b1244e7..3f37498d3b 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -117,6 +117,8 @@ enum {
TESTPMD_OPT_ENABLE_HW_VLAN_EXTEND_NUM,
#define TESTPMD_OPT_ENABLE_HW_QINQ_STRIP "enable-hw-qinq-strip"
TESTPMD_OPT_ENABLE_HW_QINQ_STRIP_NUM,
+#define TESTPMD_OPT_ENABLE_VLAN_PRIORITY "enable-vlan-priority"
+ TESTPMD_OPT_ENABLE_VLAN_PRIORITY_NUM,
#define TESTPMD_OPT_ENABLE_DROP_EN "enable-drop-en"
TESTPMD_OPT_ENABLE_DROP_EN_NUM,
#define TESTPMD_OPT_DISABLE_RSS "disable-rss"
@@ -461,6 +463,7 @@ usage(char* progname)
printf(" --enable-hw-vlan-strip: enable hardware vlan strip.\n");
printf(" --enable-hw-vlan-extend: enable hardware vlan extend.\n");
printf(" --enable-hw-qinq-strip: enable hardware qinq strip.\n");
+ printf(" --enable-vlan-priority: enable vlan priority insert.\n");
printf(" --enable-drop-en: enable per queue packet drop.\n");
printf(" --disable-rss: disable rss.\n");
printf(" --enable-rss: Force rss even for single-queue operation.\n");
@@ -1259,6 +1262,9 @@ launch_args_parse(int argc, char** argv)
case TESTPMD_OPT_ENABLE_HW_QINQ_STRIP_NUM:
rx_offloads |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
break;
+ case TESTPMD_OPT_ENABLE_VLAN_PRIORITY_NUM:
+ vlan_priority_insert_ena = 1;
+ break;
case TESTPMD_OPT_ENABLE_DROP_EN_NUM:
rx_drop_en = 1;
break;
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 457bb6d3fe..0239ec59de 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -307,6 +307,11 @@ uint16_t mb_mempool_cache = DEF_MBUF_CACHE; /**< Size of mbuf mempool cache. */
/* current configuration is in DCB or not,0 means it is not in DCB mode */
uint8_t dcb_config = 0;
+/*
+ * Configurable value of vlan priority insert enable.
+ */
+uint8_t vlan_priority_insert_ena;
+
/*
* Configurable number of RX/TX queues.
*/
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 04fdc2db42..104a6e73be 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -618,6 +618,8 @@ extern uint64_t noisy_lkup_num_reads_writes;
extern uint8_t dcb_config;
+extern uint8_t vlan_priority_insert_ena;
+
extern uint32_t mbuf_data_size_n;
extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT];
/**< Mbuf data space size. */
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] app/testpmd: add VLAN priority insert support
2026-06-12 8:14 [PATCH] app/testpmd: add VLAN priority insert support Xingui Yang
@ 2026-06-15 9:46 ` fengchengwen
2026-06-16 13:17 ` yangxingui
2026-06-15 19:12 ` Stephen Hemminger
2026-06-16 13:10 ` [PATCH v2] " Xingui Yang
2 siblings, 1 reply; 7+ messages in thread
From: fengchengwen @ 2026-06-15 9:46 UTC (permalink / raw)
To: Xingui Yang, dev
Cc: stephen, david.marchand, aman.deep.singh, yangshuaisong,
lihuisong, liuyonglong, kangfenglong
On 6/12/2026 4:14 PM, Xingui Yang wrote:
> The tx_vlan set command currently only accepts a VLAN ID in range
> [0, 4095]. This patch adds support for an extended format that includes
> 802.1p priority and CFI bits, allowing users to set the VLAN priority
> tag when inserting VLAN headers in TX packets.
>
> The extended format is:
> bit 0-11: VLAN ID (0-4095)
> bit 12: CFI (Canonical Format Indicator)
> bit 13-15: Priority (0-7, 802.1p CoS)
>
> This is consistent with the VLAN tag structure used by
> rte_eth_dev_set_vlan_pvid() where the PVID field encodes VLAN ID, CFI
> and priority in the same format.
>
> A new command line option --enable-vlan-priority is added to enable this
> feature. By default, the feature is disabled to maintain backward
> compatibility with existing users. When enabled, the
> vlan_id_is_invalid() function allows any 16-bit value to pass, while the
> full 16-bit value (including CFI and priority bits) is passed to the
> driver for hardware VLAN insertion.
>
> Signed-off-by: Xingui Yang <yangxingui@huawei.com>
> ---
> app/test-pmd/config.c | 24 +++++++++++++++---------
> app/test-pmd/parameters.c | 6 ++++++
> app/test-pmd/testpmd.c | 5 +++++
> app/test-pmd/testpmd.h | 2 ++
> 4 files changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index 36b9b023e2..80cde109e6 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -1241,12 +1241,18 @@ void print_valid_ports(void)
> }
>
> static int
> -vlan_id_is_invalid(uint16_t vlan_id)
> +vlan_id_is_invalid(uint16_t vlan_id, int vlan_priority_ena)
> {
> - if (vlan_id < 4096)
> - return 0;
> - fprintf(stderr, "Invalid vlan_id %d (must be < 4096)\n", vlan_id);
> - return 1;
> + if (!vlan_priority_ena && vlan_id >= 4096) {
> + fprintf(stderr, "Invalid vlan_id %d (must be < 4096)\n", vlan_id);
> + return 1;
> + }
> +
> + /*
> + * When vlan_priority_ena is enabled, allow any 16-bit value
> + * to pass priority and CFI bits to the driver.
> + */
> + return 0;
> }
>
> static uint32_t
> @@ -6876,7 +6882,7 @@ rx_vft_set(portid_t port_id, uint16_t vlan_id, int on)
>
> if (port_id_is_invalid(port_id, ENABLED_WARN))
> return 1;
> - if (vlan_id_is_invalid(vlan_id))
> + if (vlan_id_is_invalid(vlan_id, vlan_priority_insert_ena))
Just vlan_id_is_invalid(vlan_id, false) because Rx is no need to impl this.
> return 1;
> diag = rte_eth_dev_vlan_filter(port_id, vlan_id, on);
> if (diag == 0)
> @@ -6923,7 +6929,7 @@ tx_vlan_set(portid_t port_id, uint16_t vlan_id)
> struct rte_eth_dev_info dev_info;
> int ret;
>
> - if (vlan_id_is_invalid(vlan_id))
> + if (vlan_id_is_invalid(vlan_id, vlan_priority_insert_ena))
> return;
>
> if (ports[port_id].dev_conf.txmode.offloads &
> @@ -6954,9 +6960,9 @@ tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer)
> struct rte_eth_dev_info dev_info;
> int ret;
>
> - if (vlan_id_is_invalid(vlan_id))
> + if (vlan_id_is_invalid(vlan_id, vlan_priority_insert_ena))
> return;
> - if (vlan_id_is_invalid(vlan_id_outer))
> + if (vlan_id_is_invalid(vlan_id_outer, vlan_priority_insert_ena))
> return;
>
> ret = eth_dev_info_get_print_err(port_id, &dev_info);
> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
> index 8c3b1244e7..3f37498d3b 100644
> --- a/app/test-pmd/parameters.c
> +++ b/app/test-pmd/parameters.c
> @@ -117,6 +117,8 @@ enum {
> TESTPMD_OPT_ENABLE_HW_VLAN_EXTEND_NUM,
> #define TESTPMD_OPT_ENABLE_HW_QINQ_STRIP "enable-hw-qinq-strip"
> TESTPMD_OPT_ENABLE_HW_QINQ_STRIP_NUM,
> +#define TESTPMD_OPT_ENABLE_VLAN_PRIORITY "enable-vlan-priority"
> + TESTPMD_OPT_ENABLE_VLAN_PRIORITY_NUM,
How about TESTPMD_OPT_ENABLE_VLAN_INSERT_PRI "enable-vlan-insert-pri"
> #define TESTPMD_OPT_ENABLE_DROP_EN "enable-drop-en"
> TESTPMD_OPT_ENABLE_DROP_EN_NUM,
> #define TESTPMD_OPT_DISABLE_RSS "disable-rss"
> @@ -461,6 +463,7 @@ usage(char* progname)
> printf(" --enable-hw-vlan-strip: enable hardware vlan strip.\n");
> printf(" --enable-hw-vlan-extend: enable hardware vlan extend.\n");
> printf(" --enable-hw-qinq-strip: enable hardware qinq strip.\n");
> + printf(" --enable-vlan-priority: enable vlan priority insert.\n");
> printf(" --enable-drop-en: enable per queue packet drop.\n");
> printf(" --disable-rss: disable rss.\n");
> printf(" --enable-rss: Force rss even for single-queue operation.\n");
> @@ -1259,6 +1262,9 @@ launch_args_parse(int argc, char** argv)
> case TESTPMD_OPT_ENABLE_HW_QINQ_STRIP_NUM:
> rx_offloads |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
> break;
> + case TESTPMD_OPT_ENABLE_VLAN_PRIORITY_NUM:
> + vlan_priority_insert_ena = 1;
How about tx_insert_vlan_pri_en
> + break;
> case TESTPMD_OPT_ENABLE_DROP_EN_NUM:
> rx_drop_en = 1;
> break;
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index 457bb6d3fe..0239ec59de 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -307,6 +307,11 @@ uint16_t mb_mempool_cache = DEF_MBUF_CACHE; /**< Size of mbuf mempool cache. */
> /* current configuration is in DCB or not,0 means it is not in DCB mode */
> uint8_t dcb_config = 0;
>
> +/*
> + * Configurable value of vlan priority insert enable.
> + */
> +uint8_t vlan_priority_insert_ena;
> +
> /*
> * Configurable number of RX/TX queues.
> */
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
> index 04fdc2db42..104a6e73be 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -618,6 +618,8 @@ extern uint64_t noisy_lkup_num_reads_writes;
>
> extern uint8_t dcb_config;
>
> +extern uint8_t vlan_priority_insert_ena;
> +
> extern uint32_t mbuf_data_size_n;
> extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT];
> /**< Mbuf data space size. */
We need also update the testpmd document
Thanks
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] app/testpmd: add VLAN priority insert support
2026-06-15 9:46 ` fengchengwen
@ 2026-06-16 13:17 ` yangxingui
0 siblings, 0 replies; 7+ messages in thread
From: yangxingui @ 2026-06-16 13:17 UTC (permalink / raw)
To: fengchengwen, dev
Cc: stephen, david.marchand, aman.deep.singh, yangshuaisong,
lihuisong, liuyonglong, kangfenglong
On 2026/6/15 17:46, fengchengwen wrote:
> On 6/12/2026 4:14 PM, Xingui Yang wrote:
>> The tx_vlan set command currently only accepts a VLAN ID in range
>> [0, 4095]. This patch adds support for an extended format that includes
>> 802.1p priority and CFI bits, allowing users to set the VLAN priority
>> tag when inserting VLAN headers in TX packets.
>>
>> The extended format is:
>> bit 0-11: VLAN ID (0-4095)
>> bit 12: CFI (Canonical Format Indicator)
>> bit 13-15: Priority (0-7, 802.1p CoS)
>>
>> This is consistent with the VLAN tag structure used by
>> rte_eth_dev_set_vlan_pvid() where the PVID field encodes VLAN ID, CFI
>> and priority in the same format.
>>
>> A new command line option --enable-vlan-priority is added to enable this
>> feature. By default, the feature is disabled to maintain backward
>> compatibility with existing users. When enabled, the
>> vlan_id_is_invalid() function allows any 16-bit value to pass, while the
>> full 16-bit value (including CFI and priority bits) is passed to the
>> driver for hardware VLAN insertion.
>>
>> Signed-off-by: Xingui Yang <yangxingui@huawei.com>
>> ---
>> app/test-pmd/config.c | 24 +++++++++++++++---------
>> app/test-pmd/parameters.c | 6 ++++++
>> app/test-pmd/testpmd.c | 5 +++++
>> app/test-pmd/testpmd.h | 2 ++
>> 4 files changed, 28 insertions(+), 9 deletions(-)
>>
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
>> index 36b9b023e2..80cde109e6 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -1241,12 +1241,18 @@ void print_valid_ports(void)
>> }
>>
>> static int
>> -vlan_id_is_invalid(uint16_t vlan_id)
>> +vlan_id_is_invalid(uint16_t vlan_id, int vlan_priority_ena)
>> {
>> - if (vlan_id < 4096)
>> - return 0;
>> - fprintf(stderr, "Invalid vlan_id %d (must be < 4096)\n", vlan_id);
>> - return 1;
>> + if (!vlan_priority_ena && vlan_id >= 4096) {
>> + fprintf(stderr, "Invalid vlan_id %d (must be < 4096)\n", vlan_id);
>> + return 1;
>> + }
>> +
>> + /*
>> + * When vlan_priority_ena is enabled, allow any 16-bit value
>> + * to pass priority and CFI bits to the driver.
>> + */
>> + return 0;
>> }
>>
>> static uint32_t
>> @@ -6876,7 +6882,7 @@ rx_vft_set(portid_t port_id, uint16_t vlan_id, int on)
>>
>> if (port_id_is_invalid(port_id, ENABLED_WARN))
>> return 1;
>> - if (vlan_id_is_invalid(vlan_id))
>> + if (vlan_id_is_invalid(vlan_id, vlan_priority_insert_ena))
>
> Just vlan_id_is_invalid(vlan_id, false) because Rx is no need to impl this.
>
>> return 1;
>> diag = rte_eth_dev_vlan_filter(port_id, vlan_id, on);
>> if (diag == 0)
>> @@ -6923,7 +6929,7 @@ tx_vlan_set(portid_t port_id, uint16_t vlan_id)
>> struct rte_eth_dev_info dev_info;
>> int ret;
>>
>> - if (vlan_id_is_invalid(vlan_id))
>> + if (vlan_id_is_invalid(vlan_id, vlan_priority_insert_ena))
>> return;
>>
>> if (ports[port_id].dev_conf.txmode.offloads &
>> @@ -6954,9 +6960,9 @@ tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer)
>> struct rte_eth_dev_info dev_info;
>> int ret;
>>
>> - if (vlan_id_is_invalid(vlan_id))
>> + if (vlan_id_is_invalid(vlan_id, vlan_priority_insert_ena))
>> return;
>> - if (vlan_id_is_invalid(vlan_id_outer))
>> + if (vlan_id_is_invalid(vlan_id_outer, vlan_priority_insert_ena))
>> return;
>>
>> ret = eth_dev_info_get_print_err(port_id, &dev_info);
>> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
>> index 8c3b1244e7..3f37498d3b 100644
>> --- a/app/test-pmd/parameters.c
>> +++ b/app/test-pmd/parameters.c
>> @@ -117,6 +117,8 @@ enum {
>> TESTPMD_OPT_ENABLE_HW_VLAN_EXTEND_NUM,
>> #define TESTPMD_OPT_ENABLE_HW_QINQ_STRIP "enable-hw-qinq-strip"
>> TESTPMD_OPT_ENABLE_HW_QINQ_STRIP_NUM,
>> +#define TESTPMD_OPT_ENABLE_VLAN_PRIORITY "enable-vlan-priority"
>> + TESTPMD_OPT_ENABLE_VLAN_PRIORITY_NUM,
>
> How about TESTPMD_OPT_ENABLE_VLAN_INSERT_PRI "enable-vlan-insert-pri"
I have adopted the simpler approach as suggested by Stephen.
>> #define TESTPMD_OPT_ENABLE_DROP_EN "enable-drop-en"
>> TESTPMD_OPT_ENABLE_DROP_EN_NUM,
>> #define TESTPMD_OPT_DISABLE_RSS "disable-rss"
>> @@ -461,6 +463,7 @@ usage(char* progname)
>> printf(" --enable-hw-vlan-strip: enable hardware vlan strip.\n");
>> printf(" --enable-hw-vlan-extend: enable hardware vlan extend.\n");
>> printf(" --enable-hw-qinq-strip: enable hardware qinq strip.\n");
>> + printf(" --enable-vlan-priority: enable vlan priority insert.\n");
>> printf(" --enable-drop-en: enable per queue packet drop.\n");
>> printf(" --disable-rss: disable rss.\n");
>> printf(" --enable-rss: Force rss even for single-queue operation.\n");
>> @@ -1259,6 +1262,9 @@ launch_args_parse(int argc, char** argv)
>> case TESTPMD_OPT_ENABLE_HW_QINQ_STRIP_NUM:
>> rx_offloads |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
>> break;
>> + case TESTPMD_OPT_ENABLE_VLAN_PRIORITY_NUM:
>> + vlan_priority_insert_ena = 1;
>
> How about tx_insert_vlan_pri_en
>
>> + break;
I have adopted the simpler approach as suggested by Stephen, which
eliminates the need for a new command-line option and global variable.
>
> We need also update the testpmd document
OK.
Thanks,
Xingui
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] app/testpmd: add VLAN priority insert support
2026-06-12 8:14 [PATCH] app/testpmd: add VLAN priority insert support Xingui Yang
2026-06-15 9:46 ` fengchengwen
@ 2026-06-15 19:12 ` Stephen Hemminger
2026-06-16 13:19 ` yangxingui
2026-06-16 13:10 ` [PATCH v2] " Xingui Yang
2 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2026-06-15 19:12 UTC (permalink / raw)
To: Xingui Yang
Cc: dev, david.marchand, aman.deep.singh, fengchengwen, yangshuaisong,
lihuisong, liuyonglong, kangfenglong
On Fri, 12 Jun 2026 16:14:11 +0800
Xingui Yang <yangxingui@huawei.com> wrote:
> The tx_vlan set command currently only accepts a VLAN ID in range
> [0, 4095]. This patch adds support for an extended format that includes
> 802.1p priority and CFI bits, allowing users to set the VLAN priority
> tag when inserting VLAN headers in TX packets.
>
> The extended format is:
> bit 0-11: VLAN ID (0-4095)
> bit 12: CFI (Canonical Format Indicator)
> bit 13-15: Priority (0-7, 802.1p CoS)
>
> This is consistent with the VLAN tag structure used by
> rte_eth_dev_set_vlan_pvid() where the PVID field encodes VLAN ID, CFI
> and priority in the same format.
>
> A new command line option --enable-vlan-priority is added to enable this
> feature. By default, the feature is disabled to maintain backward
> compatibility with existing users. When enabled, the
> vlan_id_is_invalid() function allows any 16-bit value to pass, while the
> full 16-bit value (including CFI and priority bits) is passed to the
> driver for hardware VLAN insertion.
>
> Signed-off-by: Xingui Yang <yangxingui@huawei.com>
> ---
Having ability to set priority bits is good, and testpmd should allow it.
The mbuf vlan_tci is already a full 16-bit TCI (priority/CFI/VID), and
the TX insert path copies tx_vlan_id straight into it. So priority
insert already works; the only thing in the way is the < 4096 check.
Do you actually need a new option for this? Both of_push_vlan +
of_set_vlan_pcp (rte_flow) and "tx_vlan set pvid" already let you set
the priority bits today, with no new code.
If you still want "tx_vlan set" itself to carry priority, I'd suggest
a smaller change: relax only the TX insert validators and drop the
option and the global. Don't touch rx_vft_set -- it feeds the VLAN
filter, which only takes a VLAN ID and rejects > 4095 anyway, so the
flag just turns a clear error into a confusing one.
Either way, if the option stays, please document it, and add a release note.
The commit message why the existing paths aren't enough.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] app/testpmd: add VLAN priority insert support
2026-06-15 19:12 ` Stephen Hemminger
@ 2026-06-16 13:19 ` yangxingui
0 siblings, 0 replies; 7+ messages in thread
From: yangxingui @ 2026-06-16 13:19 UTC (permalink / raw)
To: Stephen Hemminger
Cc: dev, david.marchand, aman.deep.singh, fengchengwen, yangshuaisong,
lihuisong, liuyonglong, kangfenglong
On 2026/6/16 3:12, Stephen Hemminger wrote:
> On Fri, 12 Jun 2026 16:14:11 +0800
> Xingui Yang <yangxingui@huawei.com> wrote:
>
>> The tx_vlan set command currently only accepts a VLAN ID in range
>> [0, 4095]. This patch adds support for an extended format that includes
>> 802.1p priority and CFI bits, allowing users to set the VLAN priority
>> tag when inserting VLAN headers in TX packets.
>>
>> The extended format is:
>> bit 0-11: VLAN ID (0-4095)
>> bit 12: CFI (Canonical Format Indicator)
>> bit 13-15: Priority (0-7, 802.1p CoS)
>>
>> This is consistent with the VLAN tag structure used by
>> rte_eth_dev_set_vlan_pvid() where the PVID field encodes VLAN ID, CFI
>> and priority in the same format.
>>
>> A new command line option --enable-vlan-priority is added to enable this
>> feature. By default, the feature is disabled to maintain backward
>> compatibility with existing users. When enabled, the
>> vlan_id_is_invalid() function allows any 16-bit value to pass, while the
>> full 16-bit value (including CFI and priority bits) is passed to the
>> driver for hardware VLAN insertion.
>>
>> Signed-off-by: Xingui Yang <yangxingui@huawei.com>
>> ---
>
>
> Having ability to set priority bits is good, and testpmd should allow it.
> The mbuf vlan_tci is already a full 16-bit TCI (priority/CFI/VID), and
> the TX insert path copies tx_vlan_id straight into it. So priority
> insert already works; the only thing in the way is the < 4096 check.
>
> Do you actually need a new option for this? Both of_push_vlan +
> of_set_vlan_pcp (rte_flow) and "tx_vlan set pvid" already let you set
> the priority bits today, with no new code.
>
> If you still want "tx_vlan set" itself to carry priority, I'd suggest
> a smaller change: relax only the TX insert validators and drop the
> option and the global. Don't touch rx_vft_set -- it feeds the VLAN
> filter, which only takes a VLAN ID and rejects > 4095 anyway, so the
> flag just turns a clear error into a confusing one.
>
> Either way, if the option stays, please document it, and add a release note.
> The commit message why the existing paths aren't enough.
Thank you for the suggestion. I have implemented the simpler approach in v2.
Thanks,
Xingui
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] app/testpmd: add VLAN priority insert support
2026-06-12 8:14 [PATCH] app/testpmd: add VLAN priority insert support Xingui Yang
2026-06-15 9:46 ` fengchengwen
2026-06-15 19:12 ` Stephen Hemminger
@ 2026-06-16 13:10 ` Xingui Yang
2026-06-16 14:23 ` Stephen Hemminger
2 siblings, 1 reply; 7+ messages in thread
From: Xingui Yang @ 2026-06-16 13:10 UTC (permalink / raw)
To: dev
Cc: stephen, david.marchand, aman.deep.singh, fengchengwen,
yangshuaisong, lihuisong, liuyonglong, kangfenglong
The tx_vlan set and tx_qinq set commands only accepted VLAN ID in range
[0, 4095]. This prevented users from setting 802.1p priority and CFI
bits when using hardware VLAN insertion.
Since mbuf vlan_tci field already supports full 16-bit VLAN Tag Control
Information (TCI), relax the validation for TX paths to allow priority
and CFI bits. The vlan_id parameter now accepts:
- Bits 0-11: VLAN ID (0-4095)
- Bit 12: CFI (Canonical Format Indicator)
- Bits 13-15: Priority (0-7, 802.1p CoS)
Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
Suggested-by: fengchengwen <fengchengwen@huawei.com>
Signed-off-by: Xingui Yang <yangxingui@huawei.com>
---
v2:
- Removed --enable-vlan-priority option and global variable as suggested
by Stephen Hemminger. The feature is now always enabled for TX paths
- RX VLAN filter continues to enforce strict VLAN ID validation as
suggested by fengchengwen
- Added documentation updates for testpmd_funcs.rst and release notes
app/test-pmd/config.c | 13 ++++++++-----
doc/guides/rel_notes/release_26_07.rst | 7 +++++++
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 17 ++++++++++++++---
3 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 9d457ca88e..38758f9c05 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1241,8 +1241,11 @@ void print_valid_ports(void)
}
static int
-vlan_id_is_invalid(uint16_t vlan_id)
+vlan_id_is_invalid(uint16_t vlan_id, bool is_tx)
{
+ if (is_tx)
+ return 0;
+
if (vlan_id < 4096)
return 0;
fprintf(stderr, "Invalid vlan_id %d (must be < 4096)\n", vlan_id);
@@ -6876,7 +6879,7 @@ rx_vft_set(portid_t port_id, uint16_t vlan_id, int on)
if (port_id_is_invalid(port_id, ENABLED_WARN))
return 1;
- if (vlan_id_is_invalid(vlan_id))
+ if (vlan_id_is_invalid(vlan_id, false))
return 1;
diag = rte_eth_dev_vlan_filter(port_id, vlan_id, on);
if (diag == 0)
@@ -6923,7 +6926,7 @@ tx_vlan_set(portid_t port_id, uint16_t vlan_id)
struct rte_eth_dev_info dev_info;
int ret;
- if (vlan_id_is_invalid(vlan_id))
+ if (vlan_id_is_invalid(vlan_id, true))
return;
if (ports[port_id].dev_conf.txmode.offloads &
@@ -6954,9 +6957,9 @@ tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer)
struct rte_eth_dev_info dev_info;
int ret;
- if (vlan_id_is_invalid(vlan_id))
+ if (vlan_id_is_invalid(vlan_id, true))
return;
- if (vlan_id_is_invalid(vlan_id_outer))
+ if (vlan_id_is_invalid(vlan_id_outer, true))
return;
ret = eth_dev_info_get_print_err(port_id, &dev_info);
diff --git a/doc/guides/rel_notes/release_26_07.rst b/doc/guides/rel_notes/release_26_07.rst
index 5d7aa8d1bf..e382c7f407 100644
--- a/doc/guides/rel_notes/release_26_07.rst
+++ b/doc/guides/rel_notes/release_26_07.rst
@@ -150,6 +150,13 @@ New Features
* Added ``eof`` devarg to use link state to signal end of receive file input.
* Added unit test suite.
+* **Added VLAN priority support in testpmd.**
+
+ Added support for setting VLAN priority and CFI bits in ``tx_vlan set``
+ and ``tx_qinq set`` commands. The ``vlan_tci`` parameter now accepts the
+ full 16-bit VLAN Tag Control Information (TCI) format, which includes
+ priority (bits 13-15), CFI (bit 12), and VLAN ID (bits 0-11).
+
* **Added AI review helpers.**
Added AGENTS.md file for AI review
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index f0f2b0758b..b967810b10 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1120,15 +1120,26 @@ tx_vlan set
Set hardware insertion of VLAN IDs in packets sent on a port::
- testpmd> tx_vlan set (port_id) vlan_id[, vlan_id_outer]
+ testpmd> tx_vlan set (port_id) vlan_tci[, vlan_tci_outer]
+
+The ``vlan_tci`` parameter accepts the full 16-bit VLAN Tag Control Information (TCI)
+format, which includes:
+
+* Bits 0-11: VLAN ID (0-4095)
+* Bit 12: CFI (Canonical Format Indicator)
+* Bits 13-15: Priority (0-7, 802.1p CoS)
For example, set a single VLAN ID (5) insertion on port 0::
- tx_vlan set 0 5
+ testpmd> tx_vlan set 0 5
+
+Or, set a VLAN ID with priority (priority=3, VLAN ID=6) insertion on port 0::
+
+ testpmd> tx_vlan set 0 0x6006
Or, set double VLAN ID (inner: 2, outer: 3) insertion on port 1::
- tx_vlan set 1 2 3
+ testpmd> tx_vlan set 1 2 3
tx_vlan set pvid
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v2] app/testpmd: add VLAN priority insert support
2026-06-16 13:10 ` [PATCH v2] " Xingui Yang
@ 2026-06-16 14:23 ` Stephen Hemminger
0 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2026-06-16 14:23 UTC (permalink / raw)
To: Xingui Yang
Cc: dev, david.marchand, aman.deep.singh, fengchengwen, yangshuaisong,
lihuisong, liuyonglong, kangfenglong
On Tue, 16 Jun 2026 21:10:01 +0800
Xingui Yang <yangxingui@huawei.com> wrote:
> The tx_vlan set and tx_qinq set commands only accepted VLAN ID in range
> [0, 4095]. This prevented users from setting 802.1p priority and CFI
> bits when using hardware VLAN insertion.
>
> Since mbuf vlan_tci field already supports full 16-bit VLAN Tag Control
> Information (TCI), relax the validation for TX paths to allow priority
> and CFI bits. The vlan_id parameter now accepts:
> - Bits 0-11: VLAN ID (0-4095)
> - Bit 12: CFI (Canonical Format Indicator)
> - Bits 13-15: Priority (0-7, 802.1p CoS)
>
> Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
> Suggested-by: fengchengwen <fengchengwen@huawei.com>
> Signed-off-by: Xingui Yang <yangxingui@huawei.com>
> ---
> v2:
> - Removed --enable-vlan-priority option and global variable as suggested
> by Stephen Hemminger. The feature is now always enabled for TX paths
> - RX VLAN filter continues to enforce strict VLAN ID validation as
> suggested by fengchengwen
> - Added documentation updates for testpmd_funcs.rst and release notes
>
> app/test-pmd/config.c | 13 ++++++++-----
> doc/guides/rel_notes/release_26_07.rst | 7 +++++++
> doc/guides/testpmd_app_ug/testpmd_funcs.rst | 17 ++++++++++++++---
> 3 files changed, 29 insertions(+), 8 deletions(-)
>
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index 9d457ca88e..38758f9c05 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -1241,8 +1241,11 @@ void print_valid_ports(void)
> }
>
> static int
> -vlan_id_is_invalid(uint16_t vlan_id)
> +vlan_id_is_invalid(uint16_t vlan_id, bool is_tx)
> {
> + if (is_tx)
> + return 0;
> +
> if (vlan_id < 4096)
> return 0;
> fprintf(stderr, "Invalid vlan_id %d (must be < 4096)\n", vlan_id);
> @@ -6876,7 +6879,7 @@ rx_vft_set(portid_t port_id, uint16_t vlan_id, int on)
>
> if (port_id_is_invalid(port_id, ENABLED_WARN))
> return 1;
> - if (vlan_id_is_invalid(vlan_id))
> + if (vlan_id_is_invalid(vlan_id, false))
> return 1;
> diag = rte_eth_dev_vlan_filter(port_id, vlan_id, on);
> if (diag == 0)
> @@ -6923,7 +6926,7 @@ tx_vlan_set(portid_t port_id, uint16_t vlan_id)
> struct rte_eth_dev_info dev_info;
> int ret;
>
> - if (vlan_id_is_invalid(vlan_id))
> + if (vlan_id_is_invalid(vlan_id, true))
> return;
Why have the is_tx flag if it is always used as constant?
Just remove the whole vlan_id_is_invalid() branch test in the transmit path.
Maybe add a comment that any VLAN is allowed on transmit?
Or make a new function. Since VLAN of 0xffff is reserved. Though you might want
to allow it since testpmd is for testing even invalid packets.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-06-16 14:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-12 8:14 [PATCH] app/testpmd: add VLAN priority insert support Xingui Yang
2026-06-15 9:46 ` fengchengwen
2026-06-16 13:17 ` yangxingui
2026-06-15 19:12 ` Stephen Hemminger
2026-06-16 13:19 ` yangxingui
2026-06-16 13:10 ` [PATCH v2] " Xingui Yang
2026-06-16 14:23 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox