Debian Codegraph @

tests/lib/igc.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 # igc_start($interface)
13 #
14 igc_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
21
22 #
23 # Reduce link speed, because igc is capable of 2.5G, too.
24 #
25 ethtool -s "${interface}" speed 1000 autoneg on duplex full
26
27 #
28 # Increase the number of Rx and Tx queues in case of $num_cpus < 4.
29 #
30 ethtool -L "${interface}" combined 4
31 }
32
33 #
34 # igc_end($interface)
35 #
36 igc_end() {
37 local interface=$1
38
39 #
40 # Increase Tx and Rx ring sizes.
41 #
42 ethtool -G "${interface}" rx 4096 tx 4096
43 }
44
45 #
46 # igc_rx_queues_assign($interface, @rx_queues)
47 #
48 # Rx queues assignment based on PCP values and EtherType.
49 #
50 igc_rx_queues_assign() {
51 local interface=$1
52 local -n rx_queues=$2
53 local len
54
55 len=${#rx_queues[@]}
56
57 if [ "$len" -ne 10 ]; then
58 echo "igc_rx_queues_assign: rx_queues array len has to be 10!"
59 return
60 fi
61
62 ethtool -K "${interface}" ntuple on
63
64 # PCP 7
65 ethtool -N "${interface}" flow-type ether vlan 0xe000 m 0x1fff action "${rx_queues[0]}"
66
67 # PCP 6
68 ethtool -N "${interface}" flow-type ether vlan 0xc000 m 0x1fff action "${rx_queues[1]}"
69
70 # PCP 5
71 ethtool -N "${interface}" flow-type ether vlan 0xa000 m 0x1fff action "${rx_queues[2]}"
72
73 # PCP 4
74 ethtool -N "${interface}" flow-type ether vlan 0x8000 m 0x1fff action "${rx_queues[3]}"
75
76 # PCP 3
77 ethtool -N "${interface}" flow-type ether vlan 0x6000 m 0x1fff action "${rx_queues[4]}"
78
79 # PCP 2
80 ethtool -N "${interface}" flow-type ether vlan 0x4000 m 0x1fff action "${rx_queues[5]}"
81
82 # PCP 1
83 ethtool -N "${interface}" flow-type ether vlan 0x2000 m 0x1fff action "${rx_queues[6]}"
84
85 # PCP 0
86 ethtool -N "${interface}" flow-type ether vlan 0x0000 m 0x1fff action "${rx_queues[7]}"
87
88 #
89 # PTP and LLDP are transmitted untagged. Steer them via EtherType.
90 #
91 ethtool -N "${interface}" flow-type ether proto 0x88f7 action "${rx_queues[8]}"
92 ethtool -N "${interface}" flow-type ether proto 0x88cc action "${rx_queues[9]}"
93 }