Skip to content

Commit bf4f593

Browse files
committed
hw-mgmt: system events: ASIC init complition done
Add two new attributes: /var/run/hw-management/config/asic_chipup_completed /var/run/hw-management/config/asics_init_done 'asic_chipup_completed' carries counter of completed ASIC devices probing. 'asics_init_done' is to be set to one, when 'asic_chipup_completed' attribute matches 'asic_num' attribute. Motivation is to use 'asics_init_done' as criteria of system infrastructure readiness. Signed-off-by: Vadim Pasternak <[email protected]> Reviwed-by: Felix Radensky <[email protected]> Reviwed-by: Michael Shych <[email protected]>
1 parent 32735b0 commit bf4f593

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

usr/usr/bin/hw-management-helpers.sh

+27
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,33 @@ change_file_counter()
242242
echo $counter > $file_name
243243
}
244244

245+
# Update counter, match attribute, unlock.
246+
# $1 - file with counter
247+
# $2 - value to update counter ( 1 increase, -1 decrease)
248+
# $3 - file to match with the counter
249+
# $4 - file to set according to the match ( 0 not matched, 1 matched)
250+
unlock_service_state_change_update_and_match()
251+
{
252+
update_file_name=$1
253+
val=$2
254+
match_file_name=$3
255+
set_file_name=$4
256+
local counter
257+
local match
258+
259+
change_file_counter "$update_file_name" "$val"
260+
if [ ! -z "$3" ] && [ ! -z "$4" ]; then
261+
counter=$(< $update_file_name)
262+
match=$(< $match_file_name)
263+
if [ $counter -eq $match ]; then
264+
echo 1 > $set_file_name
265+
else
266+
echo 0 > $set_file_name
267+
fi
268+
fi
269+
/usr/bin/flock -u ${LOCKFD}
270+
}
271+
245272
connect_device()
246273
{
247274
find_i2c_bus

usr/usr/bin/hw-management.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -2523,9 +2523,12 @@ do_chip_up_down()
25232523
set_i2c_bus_frequency_400KHz
25242524
echo $i2c_asic_addr > /sys/bus/i2c/devices/i2c-"$bus"/delete_device
25252525
restore_i2c_bus_frequency_default
2526+
else
2527+
unlock_service_state_change
2528+
return 0
25262529
fi
25272530
echo 0 > $config_path/sfp_counter
2528-
unlock_service_state_change
2531+
unlock_service_state_change_update_and_match $config_path/asic_chipup_completed -1 $config_path/asic_num $config_path/asics_init_done
25292532
;;
25302533
1)
25312534
lock_service_state_change
@@ -2561,7 +2564,13 @@ do_chip_up_down()
25612564
unlock_service_state_change
25622565
return 0
25632566
fi
2564-
unlock_service_state_change
2567+
if [ ! -f "$config_path/asic_chipup_completed" ]; then
2568+
echo 0 > "$config_path/asic_chipup_completed"
2569+
fi
2570+
if [ ! -f "$config_path/asics_init_done" ]; then
2571+
echo 0 > "$config_path/asics_init_done"
2572+
fi
2573+
unlock_service_state_change_update_and_match "$config_path/asic_chipup_completed" 1 "$config_path/asic_num" "$config_path/asics_init_done"
25652574
return 0
25662575
;;
25672576
*)

0 commit comments

Comments
 (0)