Skip to content

Commit

Permalink
Applying network device admin state according it device's flags inste…
Browse files Browse the repository at this point in the history
…ad of using operstate

since operstate is not reflecting device's desired state

Signed-off-by: Ido Heyvi <[email protected]>
  • Loading branch information
heyvister1 committed Nov 7, 2024
1 parent f7f0c92 commit c4297ff
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ function find_mlx_devs() {

pci_addr=$(basename $(readlink ${netdev_path}/device)) && [[ -n $pci_addr ]] || return 1
dev_name=$(basename "$netdev_path") && [[ -n $dev_name ]] || return 1
dev_operstate=$(cat "$netdev_path"/operstate) && [[ -n $dev_operstate ]] || return 1
dev_adminstate_flags=$(( $(cat "$netdev_path"/flags) & 1 )) && [[ -n $dev_adminstate_flags ]] || return 1
dev_adminstate=$([[ $dev_adminstate_flags -eq 1 ]] && echo "up" || echo "down")
dev_mtu=$(cat "$netdev_path"/mtu) && [[ -n $dev_mtu ]] || return 1
dev_type=""
dev_guid=""
Expand Down Expand Up @@ -563,11 +564,11 @@ function find_mlx_devs() {
fi
fi

dev_record="$pci_addr $dev_type $dev_name $dev_operstate $dev_mtu $pf_numvfs $dev_guid $eswitch_mode"
dev_record="$pci_addr $dev_type $dev_name $dev_adminstate $dev_mtu $pf_numvfs $dev_guid $eswitch_mode"
debug_print "Storing device record [${mlx_dev_record_idx}] $dev_record"
mlx_devs_arr[${mlx_dev_record_idx}]=$dev_record
# Example:
# pci_addr dev_type dev_name dev_operstate dev_mtu pf_numvfs dev_guid (For IB only) eswitch_mode
# pci_addr dev_type dev_name dev_adminstate dev_mtu pf_numvfs dev_guid (For IB only) eswitch_mode
# 0000:08:00.0 eth eth2 up 1500 4 0c42:a103:0016:054c legacy
# 0000:08:00.1 eth eth3 up 1500 0 0c42:a103:0016:054d switchdev

Expand Down Expand Up @@ -600,7 +601,7 @@ function find_mlx_vfs() {
while [ ${num_mlx_devices} -gt 0 ]; do
declare -a mlx_dev_info=(${mlx_devs_arr[$((num_mlx_devices-1))]})

# pci_addr dev_type dev_name dev_operstate dev_mtu pf_numvfs dev_guid eswitch_mode
# pci_addr dev_type dev_name dev_adminstate dev_mtu pf_numvfs dev_guid eswitch_mode
# [0] [1] [2] [3] [4] [5] [6] [7]
mlnx_dev_pci=${mlx_dev_info[0]}
mlnx_dev_type=${mlx_dev_info[1]}
Expand Down Expand Up @@ -661,7 +662,7 @@ function find_switchdev_representors() {
while [ ${num_mlx_devices} -gt 0 ]; do
declare -a mlx_dev_info=(${mlx_devs_arr[$((num_mlx_devices-1))]})

# pci_addr dev_type dev_name dev_operstate dev_mtu pf_numvfs dev_guid eswitch_mode
# pci_addr dev_type dev_name dev_adminstate dev_mtu pf_numvfs dev_guid eswitch_mode
# [0] [1] [2] [3] [4] [5] [6] [7]
mlnx_dev_pci=${mlx_dev_info[0]}
mlnx_dev_name=${mlx_dev_info[2]}
Expand Down Expand Up @@ -756,7 +757,7 @@ function restore_sriov_config() {
while [ ${num_mlx_devices} -gt 0 ]; do
declare -a mlx_dev_info=(${mlx_devs_arr[$((num_mlx_devices-1))]})

# pci_addr dev_type dev_name dev_operstate dev_mtu pf_numvfs dev_guid (For IB only) eswitch_mode
# pci_addr dev_type dev_name dev_adminstate dev_mtu pf_numvfs dev_guid (For IB only) eswitch_mode
# [0] [1] [2] [3] [4] [5] [6] [7]

pf_pci_addr=${mlx_dev_info[0]}
Expand Down

0 comments on commit c4297ff

Please sign in to comment.