Skip to content

Commit 5f2c7ab

Browse files
daniellertskuba-moo
authored andcommitted
selftests: mlxsw: sharedbuffer: Ensure no extra packets are counted
The test assumes that the packet it is sending is the only packet being passed to the device. However, it is not the case and so other packets are filling the buffers as well. Therefore, the test sometimes fails because it is reading a maximum occupancy that is larger than expected. Add egress filters on $h1 and $h2 that will guarantee the above. Fixes: a865ad9 ("selftests: mlxsw: Add shared buffer traffic test") Signed-off-by: Danielle Ratson <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: Petr Machata <[email protected]> Link: https://patch.msgid.link/64c28bc9b1cc1d78c4a73feda7cedbe9526ccf8b.1733414773.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6c46ad4 commit 5f2c7ab

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tools/testing/selftests/drivers/net/mlxsw/sharedbuffer.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,34 @@ SB_ITC=0
2222
h1_create()
2323
{
2424
simple_if_init $h1 192.0.1.1/24
25+
tc qdisc add dev $h1 clsact
26+
27+
# Add egress filter on $h1 that will guarantee that the packet sent,
28+
# will be the only packet being passed to the device.
29+
tc filter add dev $h1 egress pref 2 handle 102 matchall action drop
2530
}
2631

2732
h1_destroy()
2833
{
34+
tc filter del dev $h1 egress pref 2 handle 102 matchall action drop
35+
tc qdisc del dev $h1 clsact
2936
simple_if_fini $h1 192.0.1.1/24
3037
}
3138

3239
h2_create()
3340
{
3441
simple_if_init $h2 192.0.1.2/24
42+
tc qdisc add dev $h2 clsact
43+
44+
# Add egress filter on $h2 that will guarantee that the packet sent,
45+
# will be the only packet being passed to the device.
46+
tc filter add dev $h2 egress pref 1 handle 101 matchall action drop
3547
}
3648

3749
h2_destroy()
3850
{
51+
tc filter del dev $h2 egress pref 1 handle 101 matchall action drop
52+
tc qdisc del dev $h2 clsact
3953
simple_if_fini $h2 192.0.1.2/24
4054
}
4155

@@ -101,6 +115,11 @@ port_pool_test()
101115
local exp_max_occ=$(devlink_cell_size_get)
102116
local max_occ
103117

118+
tc filter add dev $h1 egress protocol ip pref 1 handle 101 flower \
119+
src_mac $h1mac dst_mac $h2mac \
120+
src_ip 192.0.1.1 dst_ip 192.0.1.2 \
121+
action pass
122+
104123
devlink sb occupancy clearmax $DEVLINK_DEV
105124

106125
$MZ $h1 -c 1 -p 10 -a $h1mac -b $h2mac -A 192.0.1.1 -B 192.0.1.2 \
@@ -117,13 +136,23 @@ port_pool_test()
117136
max_occ=$(sb_occ_pool_check $cpu_dl_port $SB_POOL_EGR_CPU $exp_max_occ)
118137
check_err $? "Expected ePool($SB_POOL_EGR_CPU) max occupancy to be $exp_max_occ, but got $max_occ"
119138
log_test "CPU port's egress pool"
139+
140+
tc filter del dev $h1 egress protocol ip pref 1 handle 101 flower \
141+
src_mac $h1mac dst_mac $h2mac \
142+
src_ip 192.0.1.1 dst_ip 192.0.1.2 \
143+
action pass
120144
}
121145

122146
port_tc_ip_test()
123147
{
124148
local exp_max_occ=$(devlink_cell_size_get)
125149
local max_occ
126150

151+
tc filter add dev $h1 egress protocol ip pref 1 handle 101 flower \
152+
src_mac $h1mac dst_mac $h2mac \
153+
src_ip 192.0.1.1 dst_ip 192.0.1.2 \
154+
action pass
155+
127156
devlink sb occupancy clearmax $DEVLINK_DEV
128157

129158
$MZ $h1 -c 1 -p 10 -a $h1mac -b $h2mac -A 192.0.1.1 -B 192.0.1.2 \
@@ -140,13 +169,21 @@ port_tc_ip_test()
140169
max_occ=$(sb_occ_etc_check $cpu_dl_port $SB_ITC_CPU_IP $exp_max_occ)
141170
check_err $? "Expected egress TC($SB_ITC_CPU_IP) max occupancy to be $exp_max_occ, but got $max_occ"
142171
log_test "CPU port's egress TC - IP packet"
172+
173+
tc filter del dev $h1 egress protocol ip pref 1 handle 101 flower \
174+
src_mac $h1mac dst_mac $h2mac \
175+
src_ip 192.0.1.1 dst_ip 192.0.1.2 \
176+
action pass
143177
}
144178

145179
port_tc_arp_test()
146180
{
147181
local exp_max_occ=$(devlink_cell_size_get)
148182
local max_occ
149183

184+
tc filter add dev $h1 egress protocol arp pref 1 handle 101 flower \
185+
src_mac $h1mac action pass
186+
150187
devlink sb occupancy clearmax $DEVLINK_DEV
151188

152189
$MZ $h1 -c 1 -p 10 -a $h1mac -A 192.0.1.1 -t arp -q
@@ -162,6 +199,9 @@ port_tc_arp_test()
162199
max_occ=$(sb_occ_etc_check $cpu_dl_port $SB_ITC_CPU_ARP $exp_max_occ)
163200
check_err $? "Expected egress TC($SB_ITC_IP2ME) max occupancy to be $exp_max_occ, but got $max_occ"
164201
log_test "CPU port's egress TC - ARP packet"
202+
203+
tc filter del dev $h1 egress protocol arp pref 1 handle 101 flower \
204+
src_mac $h1mac action pass
165205
}
166206

167207
setup_prepare()

0 commit comments

Comments
 (0)