Debian Codegraph @

tests/multi_middleware/i226/xdp/flow.sh

raw symbols SCIP
1 #!/bin/bash
2 #
3 # Copyright (C) 2021-2024 Linutronix GmbH
4 # Author Kurt Kanzenbach <[email protected]>
5 #
6 # SPDX-License-Identifier: BSD-2-Clause
7 #
8 # Setup the Rx and Tx traffic flows for Intel i226.
9 #
10 # Rx steering is based on PCP values. Tx steering is based on socket priorities
11 # which are mapped to traffic classes and to timeslots accordingly.
12 #
13
14 set -e
15
16 source ../../../lib/common.sh
17 source ../../../lib/igc.sh
18
19 #
20 # Command line arguments.
21 #
22 INTERFACE=$1
23 CYCLETIME_NS=$2
24 BASETIME=$3
25
26 [ -z $INTERFACE ] && INTERFACE="enp3s0" # default: enp3s0
27 [ -z $CYCLETIME_NS ] && CYCLETIME_NS="1000000" # default: 1ms
28 [ -z $BASETIME ] && BASETIME=$(date '+%s000000000' -d '-30 sec') # default: now - 30s
29
30 load_kernel_modules
31
32 setup_threaded_napi "${INTERFACE}"
33
34 igc_start "${INTERFACE}"
35
36 #
37 # Qbv configuration.
38 #
39 ENTRY1_NS=$(echo "$CYCLETIME_NS * 12.5 / 100" | bc) # TSN High
40 ENTRY2_NS=$(echo "$CYCLETIME_NS * 12.5 / 100" | bc) # TSN Low
41 ENTRY3_NS=$(echo "$CYCLETIME_NS * 12.5 / 100" | bc) # RT
42 ENTRY4_NS=$(echo "$CYCLETIME_NS * 62.5 / 100" | bc) # RT / Non-RT
43
44 #
45 # Tx Assignment with Qbv and full hardware offload.
46 #
47 # PCP 6 - Queue 0 - TSN High
48 # PCP 5 - Queue 1 - OPC/UA #1
49 # PCP 4 - Queue 2 - OPC/UA #2
50 # PCP 3 - Queue 3 - AVTP / All other traffic
51 #
52 tc qdisc replace dev ${INTERFACE} handle 100 parent root taprio num_tc 4 \
53 map 3 3 3 3 3 2 1 0 3 3 3 3 3 3 3 3 \
54 queues 1@0 1@1 1@2 1@3 \
55 base-time ${BASETIME} \
56 sched-entry S 0x01 ${ENTRY1_NS} \
57 sched-entry S 0x02 ${ENTRY2_NS} \
58 sched-entry S 0x04 ${ENTRY3_NS} \
59 sched-entry S 0xf8 ${ENTRY4_NS} \
60 flags 0x02
61
62 #
63 # Rx Queues Assignment.
64 #
65 # Rx Q 3 - AVTP / All other traffic
66 # Rx Q 2 - OPC/UA #2
67 # Rx Q 1 - OPC/UA #1
68 # Rx Q 0 - TSN High
69 #
70 RXQUEUES=(3 0 1 2 3 3 3 3 3 3)
71 igc_rx_queues_assign "${INTERFACE}" RXQUEUES
72
73 igc_end "${INTERFACE}"
74
75 setup_irqs "${INTERFACE}"
76
77 exit 0