]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
selftests: mlxsw: Add a test case for MAC profiles consolidation
authorDanielle Ratson <danieller@nvidia.com>
Tue, 14 Dec 2021 10:21:37 +0000 (12:21 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Dec 2021 12:56:10 +0000 (12:56 +0000)
Add a test case to cover the bug fixed by the previous patch.

Edit the MAC address of one netdev so that it matches the MAC address of
the second netdev. Verify that the two MAC profiles were consolidated by
testing that the MAC profiles occupancy decreased by one.

Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/drivers/net/mlxsw/rif_mac_profiles_occ.sh

index b513f64d9092d1a35e7f33aba79580f7bbdcfb4f..026a126f584d76f01adef295a1449516fcbf6efb 100755 (executable)
@@ -72,6 +72,35 @@ rif_mac_profile_replacement_test()
        ip link set $h1.10 address $h1_10_mac
 }
 
+rif_mac_profile_consolidation_test()
+{
+       local count=$1; shift
+       local h1_20_mac
+
+       RET=0
+
+       if [[ $count -eq 1 ]]; then
+               return
+       fi
+
+       h1_20_mac=$(mac_get $h1.20)
+
+       # Set the MAC of $h1.20 to that of $h1.10 and confirm that they are
+       # using the same MAC profile.
+       ip link set $h1.20 address 00:11:11:11:11:11
+       check_err $?
+
+       occ=$(devlink -j resource show $DEVLINK_DEV \
+             | jq '.[][][] | select(.name=="rif_mac_profiles") |.["occ"]')
+
+       [[ $occ -eq $((count - 1)) ]]
+       check_err $? "MAC profile occupancy did not decrease"
+
+       log_test "RIF MAC profile consolidation"
+
+       ip link set $h1.20 address $h1_20_mac
+}
+
 rif_mac_profile_shared_replacement_test()
 {
        local count=$1; shift
@@ -104,6 +133,7 @@ rif_mac_profile_edit_test()
        create_max_rif_mac_profiles $count
 
        rif_mac_profile_replacement_test
+       rif_mac_profile_consolidation_test $count
        rif_mac_profile_shared_replacement_test $count
 }