Andrew Geissler | 3da13b3 | 2023-01-11 11:51:58 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
| 4 | # This script tries to periodically set the passed in network interface to |
| 5 | # 1 gigabit. It will run until it is successful or it hits its max retries. |
| 6 | # This script is necessary because there is no clear indication from the kernel |
| 7 | # NCSI stack when it is in a proper state for this speed setting to succeed |
| 8 | |
| 9 | # This script expects 1 parameter |
| 10 | # - Network interface to configure (i.e. eth0, eth1, ...) |
| 11 | |
| 12 | if [ $# -ne 1 ]; then |
| 13 | echo "Required network interface not provided" |
| 14 | exit 1 |
| 15 | fi |
| 16 | |
| 17 | netIface=$1 |
| 18 | |
| 19 | # 60s total: 12 tries with 5s sleeps |
| 20 | for i in {1..12} |
| 21 | do |
| 22 | echo "attempt number $i: setting $netIface to 1 gigabit" |
| 23 | rc=0 |
| 24 | # package 0, channel 0, oem command, see Intel I210 datasheet section 10.6.3.10.1 |
| 25 | /usr/libexec/ncsi-netlink-ifindex "$netIface" -p 0 -c 0 -o 00000157200001 || rc=$? |
| 26 | if [ $rc -ne 0 ]; then |
| 27 | echo "error code is $rc setting $netIface to 1 gigabit, sleep and retry" |
| 28 | sleep 5 |
| 29 | else |
| 30 | echo "success setting $netIface to 1 gigabit" |
| 31 | exit 0 |
| 32 | fi |
| 33 | |
| 34 | done |
| 35 | |
| 36 | echo "ERROR: all retry attempts exhausted, unable to configure $netIface to 1 gigabit" |
| 37 | exit 1 |