Layer2 QoS/CoS using VLAN
For Layer Three IPQoS management the ToS or DSCP filed is marked as explained in another post.
For Layer 2 with VLAN the CoS field or the Priority field is used for QoS mapping of queues.
In Ethernet-II frames For VLAN tagged packet: TPID ( Tag protocol id) is 2 byte and TCI ( tag control information ) is of two bytes.
TPID ( 2bytes) - defined value of 8100 in hex. When a frame has the EtherType equal to 8100, this frame carries the tag IEEE 802.1Q / 802.1P.
TCI - Tag Control Information field including user priority, Canonical format indicator and VLAN ID. This is 2 byte field or 16 bits field. in which :
3bits : User Priority, a 3-bit field storing the priority level for the frame. Use of this field is defined in IEEE 802.1p.
1 bit : Canonical format indicator (CFI): a 1-bit indicator that is always set to zero for Ethernet switches. CFI is used for compatibility between Ethernet and Token Ring networks. If a frame received at an Ethernet port has a CFI set to 1, then that frame should not be bridged to an untagged port.
12 bit: VLAN ID (VID): a 12-bit field specifying the VLAN to which the frame belongs. A value of 0 means that the frame doesn't belong to any VLAN; in this case the 802.1Q tag specifies only a priority and is referred to as a priority tag. A value of hex FFF is reserved for implementation use. All other values may be used as VLAN identifiers, allowing up to 4094 VLANs. On bridges, VLAN 1 is often reserved for management.
For L2 QoS the pri bit or the first three bits of TCI is used and is mapped with the QoS priority Queues. The mapping of queues depend largely on the implementation.
Generally it follows this rule:
VLAN CoS Bits QoS Priority Queues :
111---------------- 7
110---------------- 6
101---------------- 5
100---------------- 4
011---------------- 3
010---------------- 2
001---------------- 1
000---------------- 0