-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests: mlxsw: Add a scale test for physical ports
Query the maximum number of supported physical ports using devlink-resource and test that this number can be reached by splitting each of the splittable ports to its width. Test that an error is returned in case the maximum number is exceeded. Signed-off-by: Danielle Ratson <danieller@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
- Loading branch information
Danielle Ratson
authored and
Jakub Kicinski
committed
Jan 23, 2021
1 parent
321f7ab
commit 5154b1b
Showing
5 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
# Test for physical ports resource. The test splits each splittable port | ||
# to its width and checks that eventually the number of physical ports equals | ||
# the maximum number of physical ports. | ||
|
||
PORT_NUM_NETIFS=0 | ||
|
||
port_setup_prepare() | ||
{ | ||
: | ||
} | ||
|
||
port_cleanup() | ||
{ | ||
pre_cleanup | ||
|
||
for port in "${unsplit[@]}"; do | ||
devlink port unsplit $port | ||
check_err $? "Did not unsplit $netdev" | ||
done | ||
} | ||
|
||
split_all_ports() | ||
{ | ||
local should_fail=$1; shift | ||
local -a unsplit | ||
|
||
# Loop over the splittable netdevs and create tuples of netdev along | ||
# with its width. For example: | ||
# '$netdev1 $count1 $netdev2 $count2...', when: | ||
# $netdev1-2 are splittable netdevs in the device, and | ||
# $count1-2 are the netdevs width respectively. | ||
while read netdev count <<<$( | ||
devlink -j port show | | ||
jq -r '.[][] | select(.splittable==true) | "\(.netdev) \(.lanes)"' | ||
) | ||
[[ ! -z $netdev ]] | ||
do | ||
devlink port split $netdev count $count | ||
check_err $? "Did not split $netdev into $count" | ||
unsplit+=( "${netdev}s0" ) | ||
done | ||
} | ||
|
||
port_test() | ||
{ | ||
local max_ports=$1; shift | ||
local should_fail=$1; shift | ||
|
||
split_all_ports $should_fail | ||
|
||
occ=$(devlink -j resource show $DEVLINK_DEV \ | ||
| jq '.[][][] | select(.name=="physical_ports") |.["occ"]') | ||
|
||
[[ $occ -eq $max_ports ]] | ||
if [[ $should_fail -eq 0 ]]; then | ||
check_err $? "Mismatch ports number: Expected $max_ports, got $occ." | ||
else | ||
check_err_fail $should_fail $? "Reached more ports than expected" | ||
fi | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
tools/testing/selftests/drivers/net/mlxsw/spectrum-2/port_scale.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
source ../port_scale.sh | ||
|
||
port_get_target() | ||
{ | ||
local should_fail=$1 | ||
local target | ||
|
||
target=$(devlink_resource_size_get physical_ports) | ||
|
||
if ((! should_fail)); then | ||
echo $target | ||
else | ||
echo $((target + 1)) | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
tools/testing/selftests/drivers/net/mlxsw/spectrum/port_scale.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
source ../port_scale.sh | ||
|
||
port_get_target() | ||
{ | ||
local should_fail=$1 | ||
local target | ||
|
||
target=$(devlink_resource_size_get physical_ports) | ||
|
||
if ((! should_fail)); then | ||
echo $target | ||
else | ||
echo $((target + 1)) | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters