@@ -230,6 +230,122 @@ simultaneously on two ports. The driver checks the consistency of the schedules
230230against this restriction and errors out when appropriate. Schedule analysis is
231231needed to avoid this, which is outside the scope of the document.
232232
233+ Routing actions (redirect, trap, drop)
234+ --------------------------------------
235+
236+ The switch is able to offload flow-based redirection of packets to a set of
237+ destination ports specified by the user. Internally, this is implemented by
238+ making use of Virtual Links, a TTEthernet concept.
239+
240+ The driver supports 2 types of keys for Virtual Links:
241+
242+ - VLAN-aware virtual links: these match on destination MAC address, VLAN ID and
243+ VLAN PCP.
244+ - VLAN-unaware virtual links: these match on destination MAC address only.
245+
246+ The VLAN awareness state of the bridge (vlan_filtering) cannot be changed while
247+ there are virtual link rules installed.
248+
249+ Composing multiple actions inside the same rule is supported. When only routing
250+ actions are requested, the driver creates a "non-critical" virtual link. When
251+ the action list also contains tc-gate (more details below), the virtual link
252+ becomes "time-critical" (draws frame buffers from a reserved memory partition,
253+ etc).
254+
255+ The 3 routing actions that are supported are "trap", "drop" and "redirect".
256+
257+ Example 1: send frames received on swp2 with a DA of 42:be: 24:9b:76:20 to the
258+ CPU and to swp3. This type of key (DA only) when the port's VLAN awareness
259+ state is off::
260+
261+ tc qdisc add dev swp2 clsact
262+ tc filter add dev swp2 ingress flower skip_sw dst_mac 42:be:24:9b:76:20 \
263+ action mirred egress redirect dev swp3 \
264+ action trap
265+
266+ Example 2: drop frames received on swp2 with a DA of 42:be: 24:9b:76:20, a VID
267+ of 100 and a PCP of 0::
268+
269+ tc filter add dev swp2 ingress protocol 802.1Q flower skip_sw \
270+ dst_mac 42:be:24:9b:76:20 vlan_id 100 vlan_prio 0 action drop
271+
272+ Time-based ingress policing
273+ ---------------------------
274+
275+ The TTEthernet hardware abilities of the switch can be constrained to act
276+ similarly to the Per-Stream Filtering and Policing (PSFP) clause specified in
277+ IEEE 802.1Q-2018 (formerly 802.1Qci). This means it can be used to perform
278+ tight timing-based admission control for up to 1024 flows (identified by a
279+ tuple composed of destination MAC address, VLAN ID and VLAN PCP). Packets which
280+ are received outside their expected reception window are dropped.
281+
282+ This capability can be managed through the offload of the tc-gate action. As
283+ routing actions are intrinsic to virtual links in TTEthernet (which performs
284+ explicit routing of time-critical traffic and does not leave that in the hands
285+ of the FDB, flooding etc), the tc-gate action may never appear alone when
286+ asking sja1105 to offload it. One (or more) redirect or trap actions must also
287+ follow along.
288+
289+ Example: create a tc-taprio schedule that is phase-aligned with a tc-gate
290+ schedule (the clocks must be synchronized by a 1588 application stack, which is
291+ outside the scope of this document). No packet delivered by the sender will be
292+ dropped. Note that the reception window is larger than the transmission window
293+ (and much more so, in this example) to compensate for the packet propagation
294+ delay of the link (which can be determined by the 1588 application stack).
295+
296+ Receiver (sja1105)::
297+
298+ tc qdisc add dev swp2 clsact
299+ now=$(phc_ctl /dev/ptp1 get | awk '/clock time is/ {print $5}') && \
300+ sec=$(echo $now | awk -F. '{print $1}') && \
301+ base_time="$(((sec + 2) * 1000000000))" && \
302+ echo "base time ${base_time}"
303+ tc filter add dev swp2 ingress flower skip_sw \
304+ dst_mac 42:be:24:9b:76:20 \
305+ action gate base-time ${base_time} \
306+ sched-entry OPEN 60000 -1 -1 \
307+ sched-entry CLOSE 40000 -1 -1 \
308+ action trap
309+
310+ Sender::
311+
312+ now=$(phc_ctl /dev/ptp0 get | awk '/clock time is/ {print $5}') && \
313+ sec=$(echo $now | awk -F. '{print $1}') && \
314+ base_time="$(((sec + 2) * 1000000000))" && \
315+ echo "base time ${base_time}"
316+ tc qdisc add dev eno0 parent root taprio \
317+ num_tc 8 \
318+ map 0 1 2 3 4 5 6 7 \
319+ queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \
320+ base-time ${base_time} \
321+ sched-entry S 01 50000 \
322+ sched-entry S 00 50000 \
323+ flags 2
324+
325+ The engine used to schedule the ingress gate operations is the same that the
326+ one used for the tc-taprio offload. Therefore, the restrictions regarding the
327+ fact that no two gate actions (either tc-gate or tc-taprio gates) may fire at
328+ the same time (during the same 200 ns slot) still apply.
329+
330+ To come in handy, it is possible to share time-triggered virtual links across
331+ more than 1 ingress port, via flow blocks. In this case, the restriction of
332+ firing at the same time does not apply because there is a single schedule in
333+ the system, that of the shared virtual link::
334+
335+ tc qdisc add dev swp2 ingress_block 1 clsact
336+ tc qdisc add dev swp3 ingress_block 1 clsact
337+ tc filter add block 1 flower skip_sw dst_mac 42:be:24:9b:76:20 \
338+ action gate index 2 \
339+ base-time 0 \
340+ sched-entry OPEN 50000000 -1 -1 \
341+ sched-entry CLOSE 50000000 -1 -1 \
342+ action trap
343+
344+ Hardware statistics for each flow are also available ("pkts" counts the number
345+ of dropped frames, which is a sum of frames dropped due to timing violations,
346+ lack of destination ports and MTU enforcement checks). Byte-level counters are
347+ not available.
348+
233349Device Tree bindings and board design
234350=====================================
235351
0 commit comments