Path: blob/master/tools/testing/selftests/drivers/net/mlxsw/pci_reset.sh
26292 views
#!/bin/bash1# SPDX-License-Identifier: GPL-2.02#3# Test that PCI reset works correctly by verifying that only the expected reset4# methods are supported and that after issuing the reset the ifindex of the5# port changes.67lib_dir=$(dirname $0)/../../../net/forwarding89ALL_TESTS="10pci_reset_test11"12NUM_NETIFS=113source $lib_dir/lib.sh14source $lib_dir/devlink_lib.sh1516pci_reset_test()17{18RET=01920local bus=$(echo $DEVLINK_DEV | cut -d '/' -f 1)21local bdf=$(echo $DEVLINK_DEV | cut -d '/' -f 2)2223if [ $bus != "pci" ]; then24check_err 1 "devlink device is not a PCI device"25log_test "pci reset"26return27fi2829if [ ! -f /sys/bus/pci/devices/$bdf/reset_method ]; then30check_err 1 "reset is not supported"31log_test "pci reset"32return33fi3435[[ $(cat /sys/bus/pci/devices/$bdf/reset_method) == "bus" ]]36check_err $? "only \"bus\" reset method should be supported"3738local ifindex_pre=$(ip -j link show dev $swp1 | jq '.[]["ifindex"]')3940echo 1 > /sys/bus/pci/devices/$bdf/reset41check_err $? "reset failed"4243# Wait for udev to rename newly created netdev.44udevadm settle4546local ifindex_post=$(ip -j link show dev $swp1 | jq '.[]["ifindex"]')4748[[ $ifindex_pre != $ifindex_post ]]49check_err $? "reset not performed"5051log_test "pci reset"52}5354swp1=${NETIFS[p1]}55tests_run5657exit $EXIT_STATUS585960