2 # SPDX-License-Identifier: GPL-2.0
5 # The script is mostly generic, with the exception of the
6 # ethtool per-TC counter names ("rx_green_prio_${tc}")
12 lib_dir
=$
(dirname $0)/..
/..
/..
/net
/forwarding
13 source $lib_dir/tc_common.sh
14 source $lib_dir/lib.sh
25 H1_IPV6
="2001:db8:1::1"
26 H2_IPV6
="2001:db8:1::2"
30 simple_if_init
$h1 $H1_IPV4/24 $H1_IPV6/64
35 simple_if_fini
$h1 $H1_IPV4/24 $H1_IPV6/64
40 simple_if_init
$h2 $H2_IPV4/24 $H2_IPV6/64
45 simple_if_fini
$h2 $H2_IPV4/24 $H2_IPV6/64
53 simple_if_init
$h1.
$vid $H1_IPV4/24 $H1_IPV6/64
54 ip link
set $h1.
$vid type vlan \
55 egress-qos-map
0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 \
56 ingress-qos-map
0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
63 simple_if_fini
$h1.
$vid $H1_IPV4/24 $H1_IPV6/64
72 simple_if_init
$h2.
$vid $H2_IPV4/24 $H2_IPV6/64
73 ip link
set $h2.
$vid type vlan \
74 egress-qos-map
0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 \
75 ingress-qos-map
0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
82 simple_if_fini
$h2.
$vid $H2_IPV4/24 $H2_IPV6/64
91 tc qdisc add dev
${h1}.100 clsact
92 tc filter add dev
${h1}.100 egress protocol ipv4 \
93 flower ip_proto icmp action skbedit priority
3
94 tc filter add dev
${h1}.100 egress protocol ipv6 \
95 flower ip_proto icmpv6 action skbedit priority
3
100 tc qdisc del dev
${h1}.100 clsact
108 ip link
set ${swp1} up
109 ip link
set ${swp2} up
111 # Ports should trust VLAN PCP even with vlan_filtering=0
112 ip link add br0
type bridge
113 ip link
set ${swp1} master br0
114 ip link
set ${swp2} master br0
147 # https://datatracker.ietf.org/doc/html/rfc2474
148 # 4.2.2.1 The Class Selector Codepoints
149 echo $
((${dscp_cs} << 5))
154 local test_name=$1; shift
155 local if_name=$1; shift
158 local counter_name="rx_green_prio_${tc}"
164 ipv4_before=$(ethtool_stats_get ${swp1} "${counter_name}")
165 ping_do ${if_name} $H2_IPV4 "-Q ${tos}"
166 ipv4_after=$(ethtool_stats_get ${swp1} "${counter_name}")
168 if [ $((${ipv4_after} - ${ipv4_before})) -lt ${PING_COUNT} ]; then
173 log_test "IPv4 ${test_name}"
175 ipv6_before=$(ethtool_stats_get ${swp1} "${counter_name}")
176 ping_do ${if_name} $H2_IPV6 "-Q ${tos}"
177 ipv6_after=$(ethtool_stats_get ${swp1} "${counter_name}")
179 if [ $((${ipv6_after} - ${ipv6_before})) -lt ${PING_COUNT} ]; then
184 log_test "IPv6 ${test_name}"
187 port_default_prio_get()
192 prio="$(dcb -j app show dev ${if_name} default-prio | \
193 jq '.default_prio[]')"
194 if [ -z "${prio}" ]; then
203 local orig=$(port_default_prio_get ${swp1})
204 local dmac=$(mac_get ${h2})
206 dcb app replace dev ${swp1} default-prio 5
208 run_test
"Port-default QoS classification" ${h1} 5 0
210 dcb app replace dev
${swp1} default-prio
${orig}
217 run_test
"Trusted VLAN PCP QoS classification" ${h1}.100 3 0
224 local port_default
=$
(port_default_prio_get
${swp1})
225 local tos
=$
(dscp_cs_to_tos
4)
227 dcb app add dev
${swp1} dscp-prio CS4
:4
228 run_test
"Trusted DSCP QoS classification" ${h1} 4 ${tos}
229 dcb app del dev
${swp1} dscp-prio CS4
:4
232 run_test
"Untrusted DSCP QoS classification follows VLAN PCP" \
236 run_test
"Untrusted DSCP QoS classification follows port default" \
237 ${h1} ${port_default} ${tos}