Skip to content

Commit

Permalink
selftests: mlxsw: sharedbuffer: Ensure no extra packets are counted
Browse files Browse the repository at this point in the history
[ Upstream commit 5f2c7ab ]

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 <danieller@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Link: https://patch.msgid.link/64c28bc9b1cc1d78c4a73feda7cedbe9526ccf8b.1733414773.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
daniellerts authored and gregkh committed Dec 19, 2024
1 parent c9776bd commit 03528ff
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tools/testing/selftests/drivers/net/mlxsw/sharedbuffer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,34 @@ SB_ITC=0
h1_create()
{
simple_if_init $h1 192.0.1.1/24
tc qdisc add dev $h1 clsact

# Add egress filter on $h1 that will guarantee that the packet sent,
# will be the only packet being passed to the device.
tc filter add dev $h1 egress pref 2 handle 102 matchall action drop
}

h1_destroy()
{
tc filter del dev $h1 egress pref 2 handle 102 matchall action drop
tc qdisc del dev $h1 clsact
simple_if_fini $h1 192.0.1.1/24
}

h2_create()
{
simple_if_init $h2 192.0.1.2/24
tc qdisc add dev $h2 clsact

# Add egress filter on $h2 that will guarantee that the packet sent,
# will be the only packet being passed to the device.
tc filter add dev $h2 egress pref 1 handle 101 matchall action drop
}

h2_destroy()
{
tc filter del dev $h2 egress pref 1 handle 101 matchall action drop
tc qdisc del dev $h2 clsact
simple_if_fini $h2 192.0.1.2/24
}

Expand Down Expand Up @@ -101,6 +115,11 @@ port_pool_test()
local exp_max_occ=$(devlink_cell_size_get)
local max_occ

tc filter add dev $h1 egress protocol ip pref 1 handle 101 flower \
src_mac $h1mac dst_mac $h2mac \
src_ip 192.0.1.1 dst_ip 192.0.1.2 \
action pass

devlink sb occupancy clearmax $DEVLINK_DEV

$MZ $h1 -c 1 -p 10 -a $h1mac -b $h2mac -A 192.0.1.1 -B 192.0.1.2 \
Expand All @@ -117,13 +136,23 @@ port_pool_test()
max_occ=$(sb_occ_pool_check $cpu_dl_port $SB_POOL_EGR_CPU $exp_max_occ)
check_err $? "Expected ePool($SB_POOL_EGR_CPU) max occupancy to be $exp_max_occ, but got $max_occ"
log_test "CPU port's egress pool"

tc filter del dev $h1 egress protocol ip pref 1 handle 101 flower \
src_mac $h1mac dst_mac $h2mac \
src_ip 192.0.1.1 dst_ip 192.0.1.2 \
action pass
}

port_tc_ip_test()
{
local exp_max_occ=$(devlink_cell_size_get)
local max_occ

tc filter add dev $h1 egress protocol ip pref 1 handle 101 flower \
src_mac $h1mac dst_mac $h2mac \
src_ip 192.0.1.1 dst_ip 192.0.1.2 \
action pass

devlink sb occupancy clearmax $DEVLINK_DEV

$MZ $h1 -c 1 -p 10 -a $h1mac -b $h2mac -A 192.0.1.1 -B 192.0.1.2 \
Expand All @@ -140,13 +169,21 @@ port_tc_ip_test()
max_occ=$(sb_occ_etc_check $cpu_dl_port $SB_ITC_CPU_IP $exp_max_occ)
check_err $? "Expected egress TC($SB_ITC_CPU_IP) max occupancy to be $exp_max_occ, but got $max_occ"
log_test "CPU port's egress TC - IP packet"

tc filter del dev $h1 egress protocol ip pref 1 handle 101 flower \
src_mac $h1mac dst_mac $h2mac \
src_ip 192.0.1.1 dst_ip 192.0.1.2 \
action pass
}

port_tc_arp_test()
{
local exp_max_occ=$(devlink_cell_size_get)
local max_occ

tc filter add dev $h1 egress protocol arp pref 1 handle 101 flower \
src_mac $h1mac action pass

devlink sb occupancy clearmax $DEVLINK_DEV

$MZ $h1 -c 1 -p 10 -a $h1mac -A 192.0.1.1 -t arp -q
Expand All @@ -162,6 +199,9 @@ port_tc_arp_test()
max_occ=$(sb_occ_etc_check $cpu_dl_port $SB_ITC_CPU_ARP $exp_max_occ)
check_err $? "Expected egress TC($SB_ITC_IP2ME) max occupancy to be $exp_max_occ, but got $max_occ"
log_test "CPU port's egress TC - ARP packet"

tc filter del dev $h1 egress protocol arp pref 1 handle 101 flower \
src_mac $h1mac action pass
}

setup_prepare()
Expand Down

0 comments on commit 03528ff

Please sign in to comment.