Rewriter VLAN Tagging (ES0)
Before a frame is transmitted on a port it is subject to one ES0 lookup.
ES0 is intended for VLAN tag manipulations and is controlled by the tc flower filter command.
ES0 supports only one keyset on each switch:
Switch | Keyset |
---|---|
Sparx5 |
ISDX |
LAN966x |
VID |
A keyset is an internal value used by the hardware. A flower key is what the user specifies in the tc flower filter command. |
1. ISDX
The ISDX keyset is used for all lookups and matches on the following flower keys:
Flower key | Value | Example | Description |
---|---|---|---|
vlan_id |
<VID> or <VID>/<VID_MASK> |
vlan_id 1234 or vlan_id 0x100/0xff0 |
The classified VID to match. |
vlan_ethtype |
<PROTO> |
vlan_ethtype all |
Only 'all' is allowed here as ES0 cannot match on a specific protocol. |
2. VID
The VID keyset is used for all lookups and matches on the following flower keys:
Flower key | Value | Example | Description |
---|---|---|---|
vlan_id |
<VID> or <VID>/<VID_MASK> |
vlan_id 1234 or vlan_id 0x100/0xff0 |
The classified VID to match. |
vlan_prio |
<PCP> or <PCP>/<PCP_MASK> |
vlan_prio 3 or vlan_id 0x0/0x1 |
The classified PCP to match. |
vlan_ethtype |
<PROTO> |
vlan_ethtype all |
Only 'all' is allowed here as ES0 cannot match on a specific protocol. |
3. Filter examples
This filter matches on the classified VID and PCP and pops the VLAN tag:
# tc qdisc add dev eth0 clsact # tc filter add dev eth0 egress chain 30000 prio 10 handle 42 protocol 802.1q flower skip_sw \ vlan_id 100 \ vlan_prio 1 \ vlan_ethtype all \ action vlan pop \ action goto chain 30001
Sparx5: Does not support vlan_prio, the vlan actions (will be added in a future release). |
This filter matches on the classified VID and PCP and modifies the VLAN tag:
# tc qdisc add dev eth0 clsact # tc filter add dev eth0 egress chain 30000 prio 10 handle 42 protocol 802.1q flower skip_sw \ vlan_id 100 \ vlan_prio 1 \ vlan_ethtype all \ action vlan modify id 200 priority 2 \ action goto chain 30001
This filter matches on the classified VID and PCP and adds an outermost VLAN service tag:
# tc qdisc add dev eth0 clsact # tc filter add dev eth0 egress chain 30000 prio 10 handle 42 protocol 802.1q flower skip_sw \ vlan_id 100 \ vlan_prio 1 \ vlan_ethtype all \ action vlan push protocol 802.1ad id 200 priority 2 \ action goto chain 30001
3.1. ES0 Actions
The ES0 lookup supports the actions shown in this table:
Flower action | Example | Description | Sparx5 | LAN966x |
---|---|---|---|---|
pass |
action pass |
This is a no-op action. |
✔ |
✔ |
vlan pop |
action vlan pop |
Pops the outermost VLAN tag. |
· |
✔ |
vlan modify [protocol <PROTO>] id <VID> priority <PCP> |
action vlan modify id 100 priority 3 |
Modifies the frame to a specific VID, PCP, and optionally VLAN protocol of 802.1Q or 802.1ad. Default is 802.1Q. |
· |
✔ |
vlan push [protocol <PROTO>] id <VID> priority <PCP> |
action vlan push protocol 802.1ad id 100 priority 3 |
Add an outermost VLAN tag with specific VID, PCP, and optionally VLAN protocol of 802.1Q or 802.1ad. Default is 802.1Q. |
· |
✔ |
goto chain <CHAIN> |
action goto chain 30001 |
Which chain to go to after this match. A required no-op action where the chain number must be higher than the ES0 chain number (30000). |
✔ |
✔ |
4. ES0 Status
Use the tc filter show
command to see the filter configuration for a specific port.
Add -s
to also see the statistics:
# tc -s filter show dev eth3 egress filter protocol 802.1Q pref 100 flower chain 30000 filter protocol 802.1Q pref 100 flower chain 30000 handle 0xc8 vlan_id 3857 vlan_prio 1 vlan_ethtype all eth_type 0003 skip_sw in_hw in_hw_count 1 action order 1: vlan push id 3874 protocol 802.1ad priority 2 pipe index 1 ref 1 bind 1 installed 0 sec used 0 sec Action statistics: Sent 0 bytes 1 pkt (dropped 0, overlimits 0 requeues 0) Sent software 0 bytes 0 pkt Sent hardware 0 bytes 1 pkt backlog 0b 0p requeues 0 used_hw_stats immediate action order 2: gact action goto chain 30001 random type none pass val 0 index 1 ref 1 bind 1 installed 0 sec used 0 sec Action statistics: Sent 0 bytes 1 pkt (dropped 0, overlimits 0 requeues 0) Sent software 0 bytes 0 pkt Sent hardware 0 bytes 1 pkt backlog 0b 0p requeues 0 used_hw_stats immediate
First comes information about the filter, then the match and finally the actions including statistics.
The number of frames that has his the filter is shown as Sent hardware 0 bytes 1 pkt
.
Note that the hardware does not support counting the number of bytes and that the counter in ES0 is only 1 bit wide.
This means that the pkt
counter shown here will only increment by one each time the tc -s filter show
command is executed.
In the current kernel the same statistics are shown for all actions in a filter. This might change in the future.