2 # SPDX-License-Identifier: GPL-2.0
6 cmd
='/ETHTOOL_LINK_MODE_[^[:space:]]*_BIT[[:space:]]+=[[:space:]]+/ \
8 sub(/ETHTOOL_LINK_MODE_/,"") \
10 sub(/_Full/,"/Full") \
11 sub(/_Half/,"/Half");\
14 awk "${cmd}" /usr
/include
/linux
/ethtool.h
20 local out
=$
(ethtool
-s $cmd 2>&1 |
wc -l)
22 check_err
$out "error in configuration. $cmd"
28 local with_mode
=$1; shift
33 mode
="Advertised link modes"
35 mode
="Supported link modes"
38 speeds_str
=$
(ethtool
"$dev" | \
39 # Snip everything before the link modes section.
40 sed -n '/'"$mode"':/,$p' | \
41 # Quit processing the rest at the start of the next section.
42 # When checking, skip the header of this section (hence the 2,).
43 sed -n '2,${/^[\t][^ \t]/q};p' | \
44 # Drop the section header of the current section.
47 local -a speeds_arr
=($speeds_str)
48 if [[ $with_mode -eq 0 ]]; then
49 for ((i
=0; i
<${#speeds_arr[@]}; i
++)); do
50 speeds_arr
[$i]=${speeds_arr[$i]%base*}
63 local -a dev1_speeds
=($
(dev_speeds_get
$dev1 $with_mode $adver))
64 local -a dev2_speeds
=($
(dev_speeds_get
$dev2 $with_mode $adver))
67 <(printf '%s\n' "${dev1_speeds[@]}" |
sort -u) \
68 <(printf '%s\n' "${dev2_speeds[@]}" |
sort -u)
71 different_speeds_get
()
75 local with_mode
=$1; shift
80 speeds_arr
=($
(common_speeds_get
$dev1 $dev2 $with_mode $adver))
81 if [[ ${#speeds_arr[@]} < 2 ]]; then
82 check_err
1 "cannot check different speeds. There are not enough speeds"
85 echo ${speeds_arr[0]} ${speeds_arr[1]}