2 # SPDX-License-Identifier: GPL-2.0
21 ethtool_extended_state_check
()
24 local expected_ext_state
=$1; shift
25 local expected_ext_substate
=${1:-""}; shift
27 local ext_state
=$
(ethtool
$dev |
grep "Link detected" \
28 | cut
-d "(" -f2 | cut
-d ")" -f1)
29 local ext_substate
=$
(echo $ext_state | cut
-sd "," -f2 \
30 |
sed -e 's/^[[:space:]]*//')
31 ext_state
=$
(echo $ext_state | cut
-d "," -f1)
33 [[ $ext_state == $expected_ext_state ]]
34 check_err $?
"Expected \"$expected_ext_state\", got \"$ext_state\""
36 [[ $ext_substate == $expected_ext_substate ]]
37 check_err $?
"Expected \"$expected_ext_substate\", got \"$ext_substate\""
44 ip link
set dev
$swp1 up
47 ethtool_extended_state_check
$swp1 "Autoneg" "No partner detected"
49 log_test
"Autoneg, No partner detected"
51 ip link
set dev
$swp1 down
58 ip link
set dev
$swp1 up
59 ip link
set dev
$swp2 up
61 local -a speeds_arr
=($
(different_speeds_get
$swp1 $swp2 0 0))
62 local speed1
=${speeds_arr[0]}
63 local speed2
=${speeds_arr[1]}
65 ethtool_set
$swp1 speed
$speed1 autoneg off
66 ethtool_set
$swp2 speed
$speed2 autoneg off
69 ethtool_extended_state_check
$swp1 "Autoneg" \
70 "No partner detected during force mode"
72 ethtool_extended_state_check
$swp2 "Autoneg" \
73 "No partner detected during force mode"
75 log_test
"Autoneg, No partner detected during force mode"
77 ethtool
-s $swp2 autoneg on
78 ethtool
-s $swp1 autoneg on
80 ip link
set dev
$swp2 down
81 ip link
set dev
$swp1 down
88 ip link
set dev
$swp3 up
91 ethtool_extended_state_check
$swp3 "No cable"
95 ip link
set dev
$swp3 down