Message ID | f0dea3a59ae1e8eb73be5cb1269383bf1bcc922c.1700047319.git.petrm@nvidia.com (mailing list archive) |
---|---|
State | Accepted |
Commit | af51d6bd0b130b06fc58b35fee8f93b0a5c77f21 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | mlxsw: Add support for new reset flow | expand |
+ linux-kselftest ML, Shuah Khan On Wed, Nov 15, 2023 at 01:17:23PM +0100, Petr Machata wrote: > From: Ido Schimmel <idosch@nvidia.com> > > Test that PCI reset works correctly by verifying that only the expected > reset methods are supported and that after issuing the reset the ifindex > of the port changes. > > Signed-off-by: Ido Schimmel <idosch@nvidia.com> > Reviewed-by: Petr Machata <petrm@nvidia.com> > Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Simon Horman <horms@kernel.org> > --- > .../selftests/drivers/net/mlxsw/pci_reset.sh | 58 +++++++++++++++++++ > 1 file changed, 58 insertions(+) > create mode 100755 tools/testing/selftests/drivers/net/mlxsw/pci_reset.sh > > diff --git a/tools/testing/selftests/drivers/net/mlxsw/pci_reset.sh b/tools/testing/selftests/drivers/net/mlxsw/pci_reset.sh > new file mode 100755 > index 000000000000..fe0343b95e6c > --- /dev/null > +++ b/tools/testing/selftests/drivers/net/mlxsw/pci_reset.sh > @@ -0,0 +1,58 @@ > +#!/bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# > +# Test that PCI reset works correctly by verifying that only the expected reset > +# methods are supported and that after issuing the reset the ifindex of the > +# port changes. > + > +lib_dir=$(dirname $0)/../../../net/forwarding > + > +ALL_TESTS=" > + pci_reset_test > +" > +NUM_NETIFS=1 > +source $lib_dir/lib.sh > +source $lib_dir/devlink_lib.sh > + > +pci_reset_test() > +{ > + RET=0 > + > + local bus=$(echo $DEVLINK_DEV | cut -d '/' -f 1) > + local bdf=$(echo $DEVLINK_DEV | cut -d '/' -f 2) > + > + if [ $bus != "pci" ]; then > + check_err 1 "devlink device is not a PCI device" > + log_test "pci reset" > + return > + fi > + > + if [ ! -f /sys/bus/pci/devices/$bdf/reset_method ]; then > + check_err 1 "reset is not supported" > + log_test "pci reset" > + return > + fi > + > + [[ $(cat /sys/bus/pci/devices/$bdf/reset_method) == "bus" ]] > + check_err $? "only \"bus\" reset method should be supported" > + > + local ifindex_pre=$(ip -j link show dev $swp1 | jq '.[]["ifindex"]') > + > + echo 1 > /sys/bus/pci/devices/$bdf/reset > + check_err $? "reset failed" > + > + # Wait for udev to rename newly created netdev. > + udevadm settle > + > + local ifindex_post=$(ip -j link show dev $swp1 | jq '.[]["ifindex"]') > + > + [[ $ifindex_pre != $ifindex_post ]] > + check_err $? "reset not performed" > + > + log_test "pci reset" > +} > + > +swp1=${NETIFS[p1]} > +tests_run > + > +exit $EXIT_STATUS > -- > 2.41.0 >
diff --git a/tools/testing/selftests/drivers/net/mlxsw/pci_reset.sh b/tools/testing/selftests/drivers/net/mlxsw/pci_reset.sh new file mode 100755 index 000000000000..fe0343b95e6c --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/pci_reset.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Test that PCI reset works correctly by verifying that only the expected reset +# methods are supported and that after issuing the reset the ifindex of the +# port changes. + +lib_dir=$(dirname $0)/../../../net/forwarding + +ALL_TESTS=" + pci_reset_test +" +NUM_NETIFS=1 +source $lib_dir/lib.sh +source $lib_dir/devlink_lib.sh + +pci_reset_test() +{ + RET=0 + + local bus=$(echo $DEVLINK_DEV | cut -d '/' -f 1) + local bdf=$(echo $DEVLINK_DEV | cut -d '/' -f 2) + + if [ $bus != "pci" ]; then + check_err 1 "devlink device is not a PCI device" + log_test "pci reset" + return + fi + + if [ ! -f /sys/bus/pci/devices/$bdf/reset_method ]; then + check_err 1 "reset is not supported" + log_test "pci reset" + return + fi + + [[ $(cat /sys/bus/pci/devices/$bdf/reset_method) == "bus" ]] + check_err $? "only \"bus\" reset method should be supported" + + local ifindex_pre=$(ip -j link show dev $swp1 | jq '.[]["ifindex"]') + + echo 1 > /sys/bus/pci/devices/$bdf/reset + check_err $? "reset failed" + + # Wait for udev to rename newly created netdev. + udevadm settle + + local ifindex_post=$(ip -j link show dev $swp1 | jq '.[]["ifindex"]') + + [[ $ifindex_pre != $ifindex_post ]] + check_err $? "reset not performed" + + log_test "pci reset" +} + +swp1=${NETIFS[p1]} +tests_run + +exit $EXIT_STATUS