feat(master : nicsensor)预留扩展函数
This commit is contained in:
parent
c73dba1433
commit
d211f41f55
281
nicsensor.sh
281
nicsensor.sh
@ -234,6 +234,144 @@ reset_pca9548(){
|
||||
i2ctransfer -y $1 w1@$2 0x00
|
||||
}
|
||||
|
||||
# Get nic type and slot number
|
||||
parse_nic_slot(){
|
||||
fullname=0
|
||||
case $nic_slot in
|
||||
ocp*)
|
||||
nic_type="ocp"
|
||||
;;
|
||||
pcie*)
|
||||
nic_type="pcie"
|
||||
fullname=1
|
||||
;;
|
||||
*)
|
||||
nic_type="pcie"
|
||||
fullname=0;
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $nic_type = "ocp" ];then
|
||||
slot_number=$(echo $nic_slot | cut -c 4)
|
||||
else
|
||||
if [ $fullname -eq 1 ];then
|
||||
slot_number=$(echo $nic_slot | cut -c 5)
|
||||
else
|
||||
slot_number=$nic_slot
|
||||
fi
|
||||
fi
|
||||
format_log_print $INFO "Nic Type : $nic_type"
|
||||
format_log_print $INFO "Slot Num : $slot_number"
|
||||
}
|
||||
|
||||
init_debuglog(){
|
||||
# only save one running log
|
||||
if [ -e $log ];then
|
||||
rm $log
|
||||
fi
|
||||
|
||||
# print time header
|
||||
res_date=`date +%Y-%m-%dT%H:%M:%S`
|
||||
format_log_print $INFO "Start Time : $res_date"
|
||||
format_log_print $INFO "Script Version : $SCRIPT_VERSION"
|
||||
format_log_print $INFO "Debug Mode : $DEBUG_MODE"
|
||||
format_log_print $INFO "Disable Detect : $DISABLE_DETECT"
|
||||
|
||||
if [ "$nic_slot" = "detect" ];then
|
||||
format_log_print $INFO "Operation Type : i2c detect"
|
||||
elif [ "$nic_slot" = "version" ];then
|
||||
format_log_print $INFO "Operation Type : get version"
|
||||
elif [ $param_num -lt 2 ];then
|
||||
format_log_print $INFO "Operation Type : help info"
|
||||
else
|
||||
format_log_print $INFO "Operation Type : read sensor"
|
||||
fi
|
||||
}
|
||||
|
||||
# Before start test, record configurtion to log
|
||||
record_config_info(){
|
||||
|
||||
format_log_print $INFO "PCIE slot : $nic_slot"
|
||||
format_log_print $INFO "I2C Bus: $i2c_bus"
|
||||
if [ $is_have_pca9641 -eq 1 ];then
|
||||
format_log_print $INFO "PCA9641 slave: $pca9641_slave"
|
||||
fi
|
||||
format_log_print $INFO "PCA9548 slave: $pca9548_slave"
|
||||
format_log_print $INFO "PCA9548 channel: $pca9548_channel"
|
||||
|
||||
# Record i2c device info to log
|
||||
if [ ${DISABLE_DETECT} -eq 0 ];then
|
||||
format_log_print $INFO "At the beginning, I2C bus status:"
|
||||
i2cdetect -y $i2c_bus >> $log
|
||||
fi
|
||||
}
|
||||
|
||||
get_pca9641_control(){
|
||||
|
||||
# Request 9641 lock
|
||||
res_lock=`i2ctransfer -y $i2c_bus w2@$pca9641_slave $REG_pca9641_controll 0x81 r1`
|
||||
format_log_print $INFO "After request 9641 lock, The REG value is $res_lock"
|
||||
|
||||
# Build 9641 Connection
|
||||
res_build=`i2ctransfer -y $i2c_bus w2@$pca9641_slave $REG_pca9641_controll 0x85 r1`
|
||||
format_log_print $INFO "After Build 9641 connection, The REG value is $res_build"
|
||||
|
||||
# After get 9641 controll, Record i2c device info to log
|
||||
if [ ${DISABLE_DETECT} -eq 0 ];then
|
||||
i2cdetect -y $i2c_bus >> $log
|
||||
fi
|
||||
|
||||
if [ "$res_build" != "0x87" ];then
|
||||
format_print $ERROR "Cannot establish connection with pca9641 !!!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
switch_pca9548_channel(){
|
||||
|
||||
# set 9548 channel
|
||||
res_setchannel=`i2ctransfer -y $i2c_bus w1@$pca9548_slave $pca9548_channel`
|
||||
format_log_print $INFO "After switch channel"
|
||||
|
||||
# After set 9548 channel , record i2c device info
|
||||
if [ ${DISABLE_DETECT} -eq 0 ];then
|
||||
i2cdetect -y $i2c_bus >> $log
|
||||
fi
|
||||
}
|
||||
|
||||
# pre execute hook function
|
||||
pre_exec_hook(){
|
||||
init_debuglog
|
||||
|
||||
# is param legel?
|
||||
if [ "$sensor_type" = "chip" ];then
|
||||
if [ $param_num -le 3 ];then
|
||||
format_print $ERROR "Command Format illegal"
|
||||
print_chip_command_format
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# if the action is fru write, need pre-process fru data
|
||||
if [ "$sensor_type" = "fru" ];then
|
||||
if [ "$option_data" = "write" ];then
|
||||
format_log_print $INFO "Opreation FRU Write"
|
||||
|
||||
# is option_data(fru file name) valid?
|
||||
if [ "$option_data2" = "" ];then
|
||||
format_print $ERROR "Please provide fru file name"
|
||||
print_fru_command_format
|
||||
exit 1
|
||||
fi
|
||||
|
||||
parse_fru_write_data
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Set i2c configuration
|
||||
# ---------------------------------------------------------
|
||||
set_configuration_5280m7(){
|
||||
|
||||
# set pca9641 address && I2C BUS
|
||||
@ -477,36 +615,6 @@ set_configuration_5688m7(){
|
||||
fi
|
||||
}
|
||||
|
||||
# Get nic type and slot number
|
||||
parse_nic_slot(){
|
||||
fullname=0
|
||||
case $nic_slot in
|
||||
ocp*)
|
||||
nic_type="ocp"
|
||||
;;
|
||||
pcie*)
|
||||
nic_type="pcie"
|
||||
fullname=1
|
||||
;;
|
||||
*)
|
||||
nic_type="pcie"
|
||||
fullname=0;
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $nic_type = "ocp" ];then
|
||||
slot_number=$(echo $nic_slot | cut -c 4)
|
||||
else
|
||||
if [ $fullname -eq 1 ];then
|
||||
slot_number=$(echo $nic_slot | cut -c 5)
|
||||
else
|
||||
slot_number=$nic_slot
|
||||
fi
|
||||
fi
|
||||
format_log_print $INFO "Nic Type : $nic_type"
|
||||
format_log_print $INFO "Slot Num : $slot_number"
|
||||
}
|
||||
|
||||
# Base on the server type, set i2c conf
|
||||
set_configuration(){
|
||||
|
||||
@ -541,111 +649,6 @@ set_configuration(){
|
||||
esac
|
||||
}
|
||||
|
||||
init_debuglog(){
|
||||
# only save one running log
|
||||
if [ -e $log ];then
|
||||
rm $log
|
||||
fi
|
||||
|
||||
# print time header
|
||||
res_date=`date +%Y-%m-%dT%H:%M:%S`
|
||||
format_log_print $INFO "Start Time : $res_date"
|
||||
format_log_print $INFO "Script Version : $SCRIPT_VERSION"
|
||||
format_log_print $INFO "Debug Mode : $DEBUG_MODE"
|
||||
format_log_print $INFO "Disable Detect : $DISABLE_DETECT"
|
||||
|
||||
if [ "$nic_slot" = "detect" ];then
|
||||
format_log_print $INFO "Operation Type : i2c detect"
|
||||
elif [ "$nic_slot" = "version" ];then
|
||||
format_log_print $INFO "Operation Type : get version"
|
||||
elif [ $param_num -lt 2 ];then
|
||||
format_log_print $INFO "Operation Type : help info"
|
||||
else
|
||||
format_log_print $INFO "Operation Type : read sensor"
|
||||
fi
|
||||
}
|
||||
|
||||
# Before start test, record configurtion to log
|
||||
record_config_info(){
|
||||
|
||||
format_log_print $INFO "PCIE slot : $nic_slot"
|
||||
format_log_print $INFO "I2C Bus: $i2c_bus"
|
||||
if [ $is_have_pca9641 -eq 1 ];then
|
||||
format_log_print $INFO "PCA9641 slave: $pca9641_slave"
|
||||
fi
|
||||
format_log_print $INFO "PCA9548 slave: $pca9548_slave"
|
||||
format_log_print $INFO "PCA9548 channel: $pca9548_channel"
|
||||
|
||||
# Record i2c device info to log
|
||||
if [ ${DISABLE_DETECT} -eq 0 ];then
|
||||
format_log_print $INFO "At the beginning, I2C bus status:"
|
||||
i2cdetect -y $i2c_bus >> $log
|
||||
fi
|
||||
}
|
||||
|
||||
get_pca9641_control(){
|
||||
|
||||
# Request 9641 lock
|
||||
res_lock=`i2ctransfer -y $i2c_bus w2@$pca9641_slave $REG_pca9641_controll 0x81 r1`
|
||||
format_log_print $INFO "After request 9641 lock, The REG value is $res_lock"
|
||||
|
||||
# Build 9641 Connection
|
||||
res_build=`i2ctransfer -y $i2c_bus w2@$pca9641_slave $REG_pca9641_controll 0x85 r1`
|
||||
format_log_print $INFO "After Build 9641 connection, The REG value is $res_build"
|
||||
|
||||
# After get 9641 controll, Record i2c device info to log
|
||||
if [ ${DISABLE_DETECT} -eq 0 ];then
|
||||
i2cdetect -y $i2c_bus >> $log
|
||||
fi
|
||||
|
||||
if [ "$res_build" != "0x87" ];then
|
||||
format_print $ERROR "Cannot establish connection with pca9641 !!!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
switch_pca9548_channel(){
|
||||
|
||||
# set 9548 channel
|
||||
res_setchannel=`i2ctransfer -y $i2c_bus w1@$pca9548_slave $pca9548_channel`
|
||||
format_log_print $INFO "After switch channel"
|
||||
|
||||
# After set 9548 channel , record i2c device info
|
||||
if [ ${DISABLE_DETECT} -eq 0 ];then
|
||||
i2cdetect -y $i2c_bus >> $log
|
||||
fi
|
||||
}
|
||||
|
||||
# pre execute hook function
|
||||
pre_exec_hook(){
|
||||
init_debuglog
|
||||
|
||||
# is param legel?
|
||||
if [ "$sensor_type" = "chip" ];then
|
||||
if [ $param_num -le 3 ];then
|
||||
format_print $ERROR "Command Format illegal"
|
||||
print_chip_command_format
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# if the action is fru write, need pre-process fru data
|
||||
if [ "$sensor_type" = "fru" ];then
|
||||
if [ "$option_data" = "write" ];then
|
||||
format_log_print $INFO "Opreation FRU Write"
|
||||
|
||||
# is option_data(fru file name) valid?
|
||||
if [ "$option_data2" = "" ];then
|
||||
format_print $ERROR "Please provide fru file name"
|
||||
print_fru_command_format
|
||||
exit 1
|
||||
fi
|
||||
|
||||
parse_fru_write_data
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Chip EMC1413
|
||||
# ---------------------------------------------------------
|
||||
@ -1219,6 +1222,11 @@ process_fru(){
|
||||
read_fru
|
||||
fi
|
||||
}
|
||||
|
||||
# This function is temporarily retained for future functional expansion
|
||||
handle_reserve(){
|
||||
format_print $INFO “Waiting for defined”
|
||||
}
|
||||
# ---------------------------------------------------------
|
||||
# END of CHIP Function
|
||||
# ---------------------------------------------------------
|
||||
@ -1263,6 +1271,9 @@ start_get_sensor(){
|
||||
"fru")
|
||||
process_fru
|
||||
;;
|
||||
"reserve")
|
||||
handle_reserve
|
||||
;;
|
||||
*)
|
||||
format_print $ERROR "Unsupport Sensor Type !!! - $sensor_type"
|
||||
format_print $INFO "Support list: $Support_Sensor_List"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user