tools/testing/selftests/drivers/net/microchip/ksz9477_qos.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/microchip/ksz9477_qos.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/microchip/ksz9477_qos.sh
Extension
.sh
Size
19491 bytes
Lines
669
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2024 Pengutronix, Oleksij Rempel <kernel@pengutronix.de>

# The script is adopted to work with the Microchip KSZ switch driver.

ETH_FCS_LEN=4

WAIT_TIME=1
NUM_NETIFS=4
REQUIRE_JQ="yes"
REQUIRE_MZ="yes"
STABLE_MAC_ADDRS=yes
NETIF_CREATE=no
lib_dir=$(dirname $0)/../../../net/forwarding
source $lib_dir/tc_common.sh
source $lib_dir/lib.sh

require_command dcb

h1=${NETIFS[p1]}
swp1=${NETIFS[p2]}
swp2=${NETIFS[p3]}
h2=${NETIFS[p4]}

H1_IPV4="192.0.2.1"
H2_IPV4="192.0.2.2"
H1_IPV6="2001:db8:1::1"
H2_IPV6="2001:db8:1::2"

# On h1_ and h2_create do not set IP addresses to avoid interaction with the
# system, to keep packet counters clean.
h1_create()
{
	simple_if_init $h1
	sysctl_set net.ipv6.conf.${h1}.disable_ipv6 1
	# Get the MAC address of the interface to use it with mausezahn
	h1_mac=$(ip -j link show dev ${h1} | jq -e '.[].address')
}

h1_destroy()
{
	sysctl_restore net.ipv6.conf.${h1}.disable_ipv6
	simple_if_fini $h1
}

h2_create()
{
	simple_if_init $h2
	sysctl_set net.ipv6.conf.${h2}.disable_ipv6 1
	h2_mac=$(ip -j link show dev ${h2} | jq -e '.[].address')
}

h2_destroy()
{
	sysctl_restore net.ipv6.conf.${h2}.disable_ipv6
	simple_if_fini $h2
}

switch_create()
{
	ip link set ${swp1} up
	ip link set ${swp2} up
	sysctl_set net.ipv6.conf.${swp1}.disable_ipv6 1
	sysctl_set net.ipv6.conf.${swp2}.disable_ipv6 1

	# Ports should trust VLAN PCP even with vlan_filtering=0
	ip link add br0 type bridge
	ip link set ${swp1} master br0
	ip link set ${swp2} master br0

Annotation

Implementation Notes