in meta-facebook/meta-fby3/recipes-fby3/fscd/fscd/fsc_board.py [0:0]
def sensor_valid_check(board, sname, check_name, attribute):
if str(board) == "all":
sdata = sname.split("_")
board = sdata[0]
sname = sname.replace(board + "_", "")
status = c_uint8(0)
is_valid_check = False
try:
file = "/var/run/power-util_%d.lock" % int(fru_map[board]["slot_num"])
if os.path.exists(file):
return 0
if attribute["type"] == "power_status":
lpal_hndl.pal_get_server_power(
int(fru_map[board]["slot_num"]), byref(status)
)
if status.value == 6: # 12V-off
return 0
# if it's cwc system and fw update is ongoing will not check sensor to avoid bic being busy
if lpal_hndl.pal_is_cwc() == 0 and lpal_hndl.pal_is_fw_update_ongoing(int(fru_map[board]["slot_num"])) == 1:
return 0
if (search(r"front_io_temp", sname) is not None) and (
status.value == 0 or status.value == 1
):
return 1
# If sensor fail, dp will boost without checking host ready
if (search(r"Type_DP", sled_system_conf) is None) or (
search(r"Type_DPB", sled_system_conf) is not None
):
try:
flag_status = kv_get(host_ready_map[board])
except kv.KeyOperationFailure:
return 0
if flag_status != "1":
return 0
if status.value == 1: # power on
if search(r"soc_cpu|soc_therm", sname) is not None:
is_valid_check = True
elif search(r"spe_ssd", sname) is not None:
# get SSD present status
cmd = "/usr/bin/bic-util slot1 0xe0 0x2 0x9c 0x9c 0x0 0x15 0xe0 0x34 0x9c 0x9c 0x0 0x0 0x3"
response = Popen(
cmd, shell=True, stdout=PIPE).stdout.read()
response = response.decode()
# check the completion code
if response.split(" ")[6] != "00":
return 0
prsnt_bits = response.split(" ")[-3]
int_val = int("0x" + prsnt_bits, 16)
ssd_id = int(sname[7])
if int_val & (1 << ssd_id):
return 1
else:
return 0
elif search(r"dp_marvell_hsm_t", sname) is not None:
pcie_info_key = (
"sys_config/" +
fru_map[board]["name"] +
"_pcie_i04_s40_info")
return is_valid_dp_pcie(pcie_info_key)
elif search(r"gp3_m2", sname) is not None:
# get GPv3 M.2 device status
nvme_ready = c_uint8(0)
dev_status = c_uint8(0)
dev_type = c_uint8(0)
if board == "slot1_2U_top" or board == "slot1_2U_bot":
if sname[8] != "_":
# gp3_m2_10_temp
dev_id = int(sname[7]) * 10 + int(sname[8]) + 1
else:
dev_id = int(sname[7]) + 1 # gp3_m2_0_temp
response = lpal_hndl.pal_get_dev_info(
int(cwc_fru_map[board]["fru"]),
dev_id,
byref(nvme_ready),
byref(dev_status),
byref(dev_type),
)
if response == 0: # bic can get device power status
if dev_status.value == 1 and nvme_ready.value == 1: # nvme is ready
return 1
else:
return 0
else:
return 0
else:
dev_id = int(sdata[3]) + 1
response = lpal_hndl.pal_get_dev_info(
int(fru_map[board]["slot_num"]),
dev_id,
byref(nvme_ready),
byref(dev_status),
byref(dev_type),
)
if response == 0: # bic can get device power status
if dev_status.value == 1: # device power on
return 1
else:
return 0
else:
return 0
elif search(r"gp3_e1s", sname) is not None:
# get GPv3 E1.S device status
nvme_ready = c_uint8(0)
dev_status = c_uint8(0)
dev_type = c_uint8(0)
dev_id = int(sname[7]) + 13
if board == "slot1_2U_top" or board == "slot1_2U_bot":
response = lpal_hndl.pal_get_dev_info(
int(cwc_fru_map[board]["fru"]),
dev_id,
byref(nvme_ready),
byref(dev_status),
byref(dev_type),
)
else:
response = lpal_hndl.pal_get_dev_info(
int(fru_map[board]["slot_num"]),
dev_id,
byref(nvme_ready),
byref(dev_status),
byref(dev_type),
)
if response == 0: # bic can get device power status
if dev_status.value == 1: # device power on
return 1
else:
return 0
else:
return 0
elif search(r"(.*)pesw_temp", sname) is not None:
exp_board_prsnt = c_uint8(0)
pesw_power = c_uint8(0)
response = lpal_hndl.pal_is_fru_prsnt( #check if CWC board, top/bot GPv3 board is present
int(cwc_fru_map[board]["fru"]),
byref(exp_board_prsnt),
)
if response < 0 or exp_board_prsnt.value == 0: # exp board not present
return 0
response = lpal_hndl.pal_is_pesw_power_on(
int(cwc_fru_map[board]["fru"]),
byref(pesw_power),
)
if response < 0 or pesw_power.value == 0: # PESW not power ready
return 0
else:
return 1
# check if boot driver supports sensor reading
elif search(r"ssd", sname) is not None:
response = lpal_hndl.pal_is_sensor_valid(
int(fru_map[board]["slot_num"]),
boot_drive_map[board]["sensor_num"],
)
if response == 1: # boot drive unsupports sensor reading
return 0
else:
return 1
else:
suffix = ""
if search(r"1ou_m2", sname) is not None:
# 1ou_m2_a_temp. key is at 7
suffix = m2_1ou_name_map[sname[7]]
elif search(r"soc_dimm", sname) is not None:
# soc_dimmf_temp. key is at 8
suffix = dimm_location_name_map[sname[8]]
file = (
"/mnt/data/kv_store/sys_config/"
+ fru_map[board]["name"]
+ suffix
)
if is_dev_prsnt(file) == True:
is_valid_check = True
if is_valid_check == True:
# Check power status again
lpal_hndl.pal_get_server_power(
int(fru_map[board]["slot_num"]), byref(status)
)
if status.value == 1: # power on
if (search(r"Type_DP", sled_system_conf) is None) or (
search(r"Type_DPB", sled_system_conf) is not None
):
try:
flag_status = kv_get(host_ready_map[board])
except kv.KeyOperationFailure:
return 0
if flag_status == "1":
return 1
else:
# Type DP or DPB
return 1
else:
return 0
return 0
except SystemExit:
Logger.debug("SystemExit from sensor read")
raise
except Exception:
Logger.warn("Exception with board=%s, sensor_name=%s" % (board, sname))
return 0