[PATCH v2] app/testpmd: add VLAN priority insert support
yangxingui
yangxingui at huawei.com
Wed Jun 17 10:42:20 CEST 2026
On 2026/6/16 22:23, Stephen Hemminger wrote:
> On Tue, 16 Jun 2026 21:10:01 +0800
> Xingui Yang <yangxingui at 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 at networkplumber.org>
>> Suggested-by: fengchengwen <fengchengwen at huawei.com>
>> Signed-off-by: Xingui Yang <yangxingui at 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.
Hi, Stephen,
Agreed, and I've also taken the opportunity to improve consistency by
rename vlan_id to vlan_tci. I'll update in next version.
Thanks,
Xingui
More information about the dev
mailing list