Debian Codegraph @

tests/lib/stmmac.sh

raw symbols SCIP
1 # -*- mode: shell-script; sh-shell: bash -*-
2 #
3 # Copyright (C) 2020-2025 Linutronix GmbH
4 # Author Kurt Kanzenbach <[email protected]>
5 #
6 # SPDX-License-Identifier: BSD-2-Clause
7 #
8 # Test setup library.
9 #
10
11 #
12 # stmmac_start($interface)
13 #
14 stmmac_start() {
15 local interface=$1
16
17 #
18 # Disable VLAN Rx offload for eBPF XDP programs.
19 #
20 ethtool -K "${interface}" rx-vlan-offload off || true
21 }
22
23 #
24 # stmmac_end($interface)
25 #
26 stmmac_end() {
27 local interface=$1
28 }
29
30 #
31 # stmmac_rx_queues_assign($interface, @rx_queues)
32 #
33 # Rx queues assignment based on PCP values and EtherType.
34 #
35 stmmac_rx_queues_assign() {
36 local interface=$1
37 local -n rx_queues=$2
38 local len
39
40 len=${#rx_queues[@]}
41
42 if [ "$len" -ne 10 ]; then
43 echo "stmmac_rx_queues_assign: rx_queues array len has to be 10!"
44 return
45 fi
46
47 #
48 # Steering based on PCP value.
49 #
50 tc qdisc add dev "${interface}" ingress
51 tc filter add dev "${interface}" parent ffff: protocol 802.1Q flower vlan_prio 7 hw_tc "${rx_queues[0]}"
52 tc filter add dev "${interface}" parent ffff: protocol 802.1Q flower vlan_prio 6 hw_tc "${rx_queues[1]}"
53 tc filter add dev "${interface}" parent ffff: protocol 802.1Q flower vlan_prio 5 hw_tc "${rx_queues[2]}"
54 tc filter add dev "${interface}" parent ffff: protocol 802.1Q flower vlan_prio 4 hw_tc "${rx_queues[3]}"
55 tc filter add dev "${interface}" parent ffff: protocol 802.1Q flower vlan_prio 3 hw_tc "${rx_queues[4]}"
56 tc filter add dev "${interface}" parent ffff: protocol 802.1Q flower vlan_prio 2 hw_tc "${rx_queues[5]}"
57 tc filter add dev "${interface}" parent ffff: protocol 802.1Q flower vlan_prio 1 hw_tc "${rx_queues[6]}"
58 tc filter add dev "${interface}" parent ffff: protocol 802.1Q flower vlan_prio 0 hw_tc "${rx_queues[7]}"
59
60 #
61 # PTP and LLDP are transmitted untagged. Steer them via EtherType.
62 #
63 tc filter add dev "${interface}" parent ffff: protocol 0x88f7 flower hw_tc "${rx_queues[8]}"
64 tc filter add dev "${interface}" parent ffff: protocol 0x88cc flower hw_tc "${rx_queues[9]}"
65 }