tools/testing/selftests/drivers/net/hw/ethtool_lib.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/hw/ethtool_lib.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/hw/ethtool_lib.sh- Extension
.sh- Size
- 2815 bytes
- Lines
- 121
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
speeds_arr_get()
{
cmd='/ETHTOOL_LINK_MODE_[^[:space:]]*_BIT[[:space:]]+=[[:space:]]+/ \
{sub(/,$/, "") \
sub(/ETHTOOL_LINK_MODE_/,"") \
sub(/_BIT/,"") \
sub(/_Full/,"/Full") \
sub(/_Half/,"/Half");\
print "["$1"]="$3}'
awk "${cmd}" /usr/include/linux/ethtool.h
}
ethtool_set()
{
local cmd="$@"
local out=$(ethtool -s $cmd 2>&1 | wc -l)
check_err $out "error in configuration. $cmd"
}
dev_linkmodes_params_get()
{
local dev=$1; shift
local adver=$1; shift
local -a linkmodes_params
local param_count
local arr
if (($adver)); then
mode="Advertised link modes"
else
mode="Supported link modes"
fi
local -a dev_linkmodes=($(dev_speeds_get $dev 1 $adver))
for ((i=0; i<${#dev_linkmodes[@]}; i++)); do
linkmodes_params[$i]=$(echo -e "${dev_linkmodes[$i]}" | \
# Replaces all non numbers with spaces
sed -e 's/[^0-9]/ /g' | \
# Squeeze spaces in sequence to 1 space
tr -s ' ')
# Count how many numbers were found in the linkmode
param_count=$(echo "${linkmodes_params[$i]}" | wc -w)
if [[ $param_count -eq 1 ]]; then
linkmodes_params[$i]="${linkmodes_params[$i]} 1"
elif [[ $param_count -ge 3 ]]; then
arr=(${linkmodes_params[$i]})
# Take only first two params
linkmodes_params[$i]=$(echo "${arr[@]:0:2}")
fi
done
echo ${linkmodes_params[@]}
}
dev_speeds_get()
{
local dev=$1; shift
local with_mode=$1; shift
local adver=$1; shift
local speeds_str
if (($adver)); then
mode="Advertised link modes"
else
mode="Supported link modes"
fi
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.