Compare commits
No commits in common. "8a08250df714c90e9536111c8f5b11f2bac3431a" and "c73dba14333fcf8741d7e68d6b9067e43aab7f12" have entirely different histories.
8a08250df7
...
c73dba1433
283
nicsensor.sh
283
nicsensor.sh
@ -140,7 +140,7 @@ ina3221_ch2_volt="0"
|
|||||||
ina3221_ch0_current="0"
|
ina3221_ch0_current="0"
|
||||||
ina3221_ch1_current="0"
|
ina3221_ch1_current="0"
|
||||||
ina3221_ch2_current="0"
|
ina3221_ch2_current="0"
|
||||||
SCRIPT_VERSION="1.6.4"
|
SCRIPT_VERSION="1.6.3"
|
||||||
|
|
||||||
fru_file_name=$option_data2
|
fru_file_name=$option_data2
|
||||||
fru_write_size=0
|
fru_write_size=0
|
||||||
@ -234,144 +234,6 @@ reset_pca9548(){
|
|||||||
i2ctransfer -y $1 w1@$2 0x00
|
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_configuration_5280m7(){
|
||||||
|
|
||||||
# set pca9641 address && I2C BUS
|
# set pca9641 address && I2C BUS
|
||||||
@ -615,6 +477,36 @@ set_configuration_5688m7(){
|
|||||||
fi
|
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
|
# Base on the server type, set i2c conf
|
||||||
set_configuration(){
|
set_configuration(){
|
||||||
|
|
||||||
@ -649,6 +541,111 @@ set_configuration(){
|
|||||||
esac
|
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
|
# Chip EMC1413
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
@ -1222,11 +1219,6 @@ process_fru(){
|
|||||||
read_fru
|
read_fru
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function is temporarily retained for future functional expansion
|
|
||||||
handle_reserve(){
|
|
||||||
format_print $INFO “Waiting for defined”
|
|
||||||
}
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# END of CHIP Function
|
# END of CHIP Function
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
@ -1271,9 +1263,6 @@ start_get_sensor(){
|
|||||||
"fru")
|
"fru")
|
||||||
process_fru
|
process_fru
|
||||||
;;
|
;;
|
||||||
"reserve")
|
|
||||||
handle_reserve
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
format_print $ERROR "Unsupport Sensor Type !!! - $sensor_type"
|
format_print $ERROR "Unsupport Sensor Type !!! - $sensor_type"
|
||||||
format_print $INFO "Support list: $Support_Sensor_List"
|
format_print $INFO "Support list: $Support_Sensor_List"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user