blob: e435831ab64bfd8c83f36d9cb3df2148adcc383a [file] [log] [blame]
Andrew Geissler3da13b32023-01-11 11:51:58 -07001#!/bin/bash
2set -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
12if [ $# -ne 1 ]; then
13 echo "Required network interface not provided"
14 exit 1
15fi
16
17netIface=$1
18
19# 60s total: 12 tries with 5s sleeps
20for i in {1..12}
21do
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
34done
35
36echo "ERROR: all retry attempts exhausted, unable to configure $netIface to 1 gigabit"
37exit 1