Debian Codegraph @

tests/multi_middleware/stmmac/packet/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 * 50 / 100" | bc) # TSN High
40 ENTRY2_NS=$(echo "$CYCLETIME_NS * 50 / 100" | bc) # Everything else
41
42 #
43 # Tx Assignment with Qbv and full hardware offload.
44 #
45 # PCP 0 - Queue 0 - UDP Low
46 # PCP 1 - Queue 1 - UDP High
47 # PCP 2 - Queue 2 - DCP
48 # PCP 3 - Queue 3 - RTA
49 # PCP 4 - Queue 5 - RTC
50 # PCP 5 - Queue 6 - TSN LOW
51 # PCP 6 - Queue 7 - TSN HIGH
52 # PCP 7 - Queue 4 - PTP/LLDP
53 #
54 tc qdisc replace dev ${INTERFACE} handle 100 parent root taprio num_tc 8 \
55 map 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 \
56 queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \
57 base-time ${BASETIME} \
58 sched-entry S 0x80 ${ENTRY1_NS} \
59 sched-entry S 0x7f ${ENTRY2_NS} \
60 flags 0x02
61
62 #
63 # Enable Tx launch time support for PCP 6 / TC 7.
64 #
65 tc qdisc replace dev ${INTERFACE} parent 100:8 etf \
66 clockid CLOCK_TAI \
67 delta 500000 \
68 offload
69
70 #
71 # Create VLAN interfaces.
72 #
73 ip link add link ${INTERFACE} name ${INTERFACE}.100 type vlan id 100
74 ip link add link ${INTERFACE} name ${INTERFACE}.200 type vlan id 200
75 ip link add link ${INTERFACE} name ${INTERFACE}.300 type vlan id 300
76 ip link add link ${INTERFACE} name ${INTERFACE}.400 type vlan id 400
77
78 ip link set ${INTERFACE}.100 up
79 ip link set ${INTERFACE}.200 up
80 ip link set ${INTERFACE}.300 up
81 ip link set ${INTERFACE}.400 up
82
83 #
84 # Rx Assignment.
85 #
86 # PCP 0 - Queue 0 - UDP Low
87 # PCP 1 - Queue 1 - UDP High
88 # PCP 2 - Queue 2 - DCP
89 # PCP 3 - Queue 3 - RTA
90 # PCP 4 - Queue 5 - RTC
91 # PCP 5 - Queue 6 - TSN LOW
92 # PCP 6 - Queue 7 - TSN HIGH
93 # PCP 7 - Queue 4 - PTP/LLDP
94 #
95 RXQUEUES=(4 7 6 5 3 2 1 0 4 4)
96 stmmac_rx_queues_assign "${INTERFACE}" RXQUEUES
97
98 stmmac_end "${INTERFACE}"
99
100 setup_irqs "${INTERFACE}"
101
102 exit 0