802.1Qch Cyclic Queueing and Forwarding

This feature (CQF) allows you to build a network where different TSN streams will not interfere with each other, and there is a predictable latency between two nodes that can be calculated easily.

CQF was originally defined in 802.1Qch-2017 but is now part of 802.1Q-2022.

In the standard the network is using a number of timeslots in a round-robin fashion, so that different streams each get a timeslot to prevent them from blocking each other.

In practice the feature is combination of the two existing features: PSFP and TAS.

The first feature assigns "internal priority" to each frame based on arrival time on the ingress interface, where the second adds the frames to a egress queue on the egress interface and opens up for transmission from each queue based on the timeslot.

It is important to note that the internal priority is really internal to the Cyclic Queing and Forwarding feature: It will not be used to do any tag rewriting or prioritization of frame on egress.

It is also important that all nodes in the network use the same timeslot scheme and that size of the frames that are sent is limited to fit in a timeslot.

In the example below we just use two timeslots of 1ms each which gives a cycle-time of 2ms.

Frames ingress on lan0 and egress on lan1

The configuration uses internal priority 4 and 7 to store frames in egress queue 4 and 7. The "sched-entry" bitfield value configures all other queues to send except for either 4 or 7 in alternate timeslots.

We start by adding the two ports to the bridge. We use the default port VLAN which is VLAN 1 for the Linux Bridge.

ip link set up lan0
ip link set up lan1
ip link add name br0 type bridge vlan_filtering 1
ip link set lan0 master br0
ip link set lan1 master br0
ip link set up br0

Next all frames are directed from chain 0 (the default) to chain 1100000 (this enables the VCAP lookup).

tc qdisc add dev lan0 clsact
tc filter add dev lan0 ingress chain 0 prio 10000 handle 10000 matchall skip_sw action goto chain 1100000

The stream gate is configured to pass VLAN tagged frames and assign internal priorities 4 and 7 in the two 1ms intervals respectively.

tc filter add dev lan0 ingress chain 1100000 protocol 802.1q flower skip_sw \
  action gate \
  base-time 0 \
  cycle-time 2000000 \
  sched-entry open 1000000 4 \
  sched-entry open 1000000 7 \
  action goto chain 1200000

Frames egressing on lan1 with be stored in the queue that corresponds to the internal priority on that port.

The TAS scheduler is then used to map priorities to queues in a 1:1 fashion and then uses two 1ms timeslots to send all frames in all queues on lan1 except 4 and 7 respectively.

tc qdisc add dev lan1 parent root handle 100 taprio num_tc 8 \
  map 0 1 2 3 4 5 6 7 \
  queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \
  base-time 0 \
  cycle-time 2000000 \
  sched-entry S 0xef 1000000 \
  sched-entry S 0x7f 1000000 \
  flags 0x2

With this all incoming traffic on lan0 will now be passed in two 1ms timeslots through the switch to egress on lan1.