Skip to content

Commit

Permalink
hw-mgmt: topoogy: Add dynamic devices for smart switch
Browse files Browse the repository at this point in the history
Add hotplug hooks for DPU devices.

Signed-off-by: Vadim Pasternak <[email protected]>
  • Loading branch information
vadimp-nvidia committed Jan 24, 2024
1 parent 95b27bd commit 1e1e5f9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
29 changes: 16 additions & 13 deletions usr/usr/bin/hw-management-chassis-events.sh
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,22 @@ function handle_hotplug_event()
fan*)
handle_hotplug_fan_event "$attribute" "$event"
;;
dpu*)
bus=$(echo $attribute | cut -d"_" -f1 | cut -c 4-)
bus_offset=$(< $config_path/dpu_bus_off)
bus=$((bus+bus_offset-1))
if [ "$attribute" == "dpu1_ready" ] || [ "$attribute" == "dpu2_ready" ] ||
[ "$attribute" == "dpu3_ready" ] || [ "$attribute" == "dpu4_ready" ]; then
# Connect dynamic devices.
connect_underlying_devices "$bus"

fi
if [ "$attribute" == "dpu1_shtdn_ready" ] || [ "$attribute" == "dpu2_shtdn_ready" ] ||
[ "$attribute" == "dpu3_shtdn_ready" ] || [ "$attribute" == "dpu4_shtdn_ready" ]; then
# Disconnect dynamic devices.
disconnect_underlying_devices "$bus"
fi
;;
*)
;;
esac
Expand Down Expand Up @@ -1156,19 +1172,6 @@ if [ "$1" == "add" ]; then
fi
done
fi
if [ "$2" == "dpu1_ready" ] || [ "$2" == "dpu2_ready" ] ||
[ "$2" == "dpu3_read" ] || [ "$2" == "dpu4_ready" ]; then
# Connect dynamic devices.
bus=$(echo "$3$4" | xargs dirname | xargs dirname | xargs dirname | xargs basename | cut -d"-" -f1)
connect_underlying_devices "$bus"

fi
if [ "$2" == "dpu1_shtdn_ready" ] || [ "$2" == "dpu2_shtdn_ready" ] ||
[ "$2" == "dpu3_shtdn_read" ] || [ "$2" == "dpu4_shtdn_ready" ]; then
# Disconnect dynamic devices.
bus=$(echo "$3$4" | xargs dirname | xargs dirname | xargs dirname | xargs basename | cut -d"-" -f1)
disconnect_underlying_devices "$bus"
fi
# Creating lc folders hierarchy upon line card udev add event.
if [ "$2" == "linecard" ]; then
input_bus_num=$(echo "$3""$4" | xargs basename | cut -d"-" -f1)
Expand Down
8 changes: 4 additions & 4 deletions usr/usr/bin/hw-management-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ connect_underlying_devices()

declare -a card_connect_table="($(< $config_path/i2c_underlying_devices))"

for ((i=0; i<${#card_connect_table[@]}; i+=$2)); do
addr="${card_connect_table[i+1]}"
for ((i=0; i<${#card_connect_table[@]}; i+=4)); do
addr="${card_connect_table[i+2]}"
if [ ! -d /sys/bus/i2c/devices/$bus-00"$addr" ] &&
[ ! -d /sys/bus/i2c/devices/$bus-000"$addr" ]; then
echo "${card_connect_table[i]}" "$addr" > /sys/bus/i2c/devices/i2c-$bus/new_device
Expand All @@ -662,8 +662,8 @@ disconnect_underlying_devices()

declare -a card_connect_table="($(< $config_path/i2c_underlying_devices))"

for ((i=0; i<${#card_connect_table[@]}; i+=$2)); do
addr="${card_connect_table[i+1]}"
for ((i=0; i<${#card_connect_table[@]}; i+=4)); do
addr="${card_connect_table[i+2]}"
if [ -d /sys/bus/i2c/devices/$bus-00"$addr" ] &&
[ -d /sys/bus/i2c/devices/$bus-000"$addr" ]; then
echo "$addr" > /sys/bus/i2c/devices/i2c-$bus/delete_device
Expand Down
2 changes: 1 addition & 1 deletion usr/usr/bin/hw-management.sh
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ p4300_dynamic_i2c_bus_connect_table=( \
mp2975 0x23 26 voltmon2 )

smart_switch_dpu_dynamic_i2c_bus_connect_table=( \
tmp421 0x0 0x1f tmp421 dpu_cx_amb \
tmp421 0x0 0x1f dpu_cx_amb \
mp2975 0x0 0x69 dpu_voltmon1 \
mp2975 0x0 0x6a dpu_voltmon2)

Expand Down

0 comments on commit 1e1e5f9

Please sign in to comment.