Debian Codegraph @

tests/multi_middleware/stmmac/xdp/flow_ehl.sh

raw symbols SCIP
1 #!/bin/bash
2 #
3 # Copyright (C) 2021 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 on Intel Elkhart Lake.
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/stmmac.sh
18
19 #
20 # Command line arguments.
21 #
22 INTERFACE=$1
23 CYCLETIME_NS=$2
24 BASETIME=$3
25
26 [ -z $INTERFACE ] && INTERFACE="enp0s29f2" # default: enp0s29f2
27 [ -z $CYCLETIME_NS ] && CYCLETIME_NS="1000000" # default: 1ms
28 [ -z $BASETIME ] && BASETIME=$(date '+%s000000000' -d '60 sec') # default: now + 60s
29
30 load_kernel_modules
31
32 setup_threaded_napi "${INTERFACE}"
33
34 stmmac_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 * 12.5 / 100" | bc) # RT
43 ENTRY5_NS=$(echo "$CYCLETIME_NS * 50 / 100" | bc) # Non-RT
44
45 #
46 # Tx Assignment with Qbv and full hardware offload.
47 #
48 # PCP 0 - Queue 0 - UDP Low
49 # PCP 1 - Queue 1 - UDP High
50 # PCP 2 - Queue 2 - DCP
51 # PCP 3 - Queue 3 - RTA
52 # PCP 4 - Queue 5 - RTC
53 # PCP 5 - Queue 6 - TSN LOW
54 # PCP 6 - Queue 7 - TSN HIGH
55 # PCP 7 - Queue 4 - PTP/LLDP
56 #
57 tc qdisc replace dev ${INTERFACE} handle 100 parent root taprio num_tc 8 \
58 map 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 \
59 queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \
60 base-time ${BASETIME} \
61 sched-entry S 0x80 ${ENTRY1_NS} \
62 sched-entry S 0x40 ${ENTRY2_NS} \
63 sched-entry S 0x20 ${ENTRY3_NS} \
64 sched-entry S 0x10 ${ENTRY4_NS} \
65 sched-entry S 0x0f ${ENTRY5_NS} \
66 flags 0x02
67
68 #
69 # Create VLAN interfaces.
70 #
71 ip link add link ${INTERFACE} name ${INTERFACE}.100 type vlan id 100
72 ip link add link ${INTERFACE} name ${INTERFACE}.200 type vlan id 200
73 ip link add link ${INTERFACE} name ${INTERFACE}.300 type vlan id 300
74 ip link add link ${INTERFACE} name ${INTERFACE}.400 type vlan id 400
75
76 ip link set ${INTERFACE}.100 up
77 ip link set ${INTERFACE}.200 up
78 ip link set ${INTERFACE}.300 up
79 ip link set ${INTERFACE}.400 up
80
81 #
82 # Rx Assignment.
83 #
84 # PCP 0 - Queue 0 - UDP Low
85 # PCP 1 - Queue 1 - UDP High
86 # PCP 2 - Queue 2 - DCP
87 # PCP 3 - Queue 3 - RTA
88 # PCP 4 - Queue 5 - RTC
89 # PCP 5 - Queue 6 - TSN LOW
90 # PCP 6 - Queue 7 - TSN HIGH
91 # PCP 7 - Queue 4 - PTP/LLDP
92 #
93 RXQUEUES=(4 7 6 5 3 2 1 0 4 4)
94 stmmac_rx_queues_assign "${INTERFACE}" RXQUEUES
95
96 stmmac_end "${INTERFACE}"
97
98 setup_irqs "${INTERFACE}"
99
100 exit 0