Re: [PATCH net-next 14/14] selftests: mlxsw: Add PCI reset test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



+ linux-kselftest ML, Shuah Khan

On Wed, Nov 15, 2023 at 01:17:23PM +0100, Petr Machata wrote:
> From: Ido Schimmel <idosch@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>
> Reviewed-by: Petr Machata <petrm@xxxxxxxxxx>
> Signed-off-by: Petr Machata <petrm@xxxxxxxxxx>

Reviewed-by: Simon Horman <horms@xxxxxxxxxx>

> ---
>  .../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
> 




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux