diff --git a/nicsensor.sh b/nicsensor.sh index 3dbbfc4..875744a 100755 --- a/nicsensor.sh +++ b/nicsensor.sh @@ -133,7 +133,6 @@ INFO="Info" WARNING="Warning" ERROR="Error" log="/tmp/nicsensor_debug.log" - # --------------------------------------------------------- # Script Function Defination # --------------------------------------------------------- @@ -395,24 +394,11 @@ set_configuration_5280m7(){ # set pca9641 address && I2C BUS if [ $nic_type = "ocp" ];then + # Case - OCP is_have_pca9641=0 pca9548_slave="0x70" i2c_bus=3 - else - is_have_pca9641=1 - if [ $slot_number -le 2 ];then - pca9641_slave="0x41" - pca9548_slave="0x72" - i2c_bus=12 - else - pca9641_slave="0x42" - pca9548_slave="0x72" - i2c_bus=13 - fi - fi - # set pca9548 switch channel - if [ $nic_type = "ocp" ];then if [ $slot_number -eq 0 ];then pca9548_channel="0x01" elif [ $slot_number -eq 1 ];then @@ -423,6 +409,18 @@ set_configuration_5280m7(){ format_print $WARNING "Unspecified card slot!" fi else + # Case - PCIe + is_have_pca9641=1 + if [ $slot_number -le 2 ];then + pca9641_slave="0x41" + pca9548_slave="0x72" + i2c_bus=12 + else + pca9641_slave="0x42" + pca9548_slave="0x72" + i2c_bus=13 + fi + if [ $slot_number -eq 0 ];then pca9548_channel="0x02" elif [ $slot_number -eq 1 ];then @@ -443,194 +441,190 @@ set_configuration_5280m7(){ set_configuration_5468m7(){ if [ $nic_type = "ocp" ];then + # Case - OCP format_print $ERROR "Unsupport OCP Nic on $server_type" format_print $INFO "Please check if script has update version" exit 1 - fi - - is_have_pca9641=1 - - # set pca9641 address && I2C BUS - if [ $slot_number -le 4 ];then - pca9641_slave="0x31" - pca9548_slave="0x70" - i2c_bus=13 else - pca9641_slave="0x42" - pca9548_slave="0x71" - i2c_bus=14 - fi + # Case - PCIe + is_have_pca9641=1 + if [ $slot_number -le 4 ];then + pca9641_slave="0x31" + pca9548_slave="0x70" + i2c_bus=13 + else + pca9641_slave="0x42" + pca9548_slave="0x71" + i2c_bus=14 + fi - # set pca9548 switch channel - if [ $slot_number -eq 0 ];then - pca9548_channel="0x01" - elif [ $slot_number -eq 1 ];then - pca9548_channel="0x02" - elif [ $slot_number -eq 2 ];then - pca9548_channel="0x04" - elif [ $slot_number -eq 3 ];then - pca9548_channel="0x08" - elif [ $slot_number -eq 4 ];then - pca9548_channel="0x10" - elif [ $slot_number -eq 5 ];then - pca9548_channel="0x01" - elif [ $slot_number -eq 6 ];then - pca9548_channel="0x02" - elif [ $slot_number -eq 7 ];then - pca9548_channel="0x04" - elif [ $slot_number -eq 8 ];then - pca9548_channel="0x08" - elif [ $slot_number -eq 9 ];then - pca9548_channel="0x10" - elif [ $slot_number -eq 10 ];then - pca9548_channel="0x20" - else - format_print $WARNING "Unspecified card slot!" + if [ $slot_number -eq 0 ];then + pca9548_channel="0x01" + elif [ $slot_number -eq 1 ];then + pca9548_channel="0x02" + elif [ $slot_number -eq 2 ];then + pca9548_channel="0x04" + elif [ $slot_number -eq 3 ];then + pca9548_channel="0x08" + elif [ $slot_number -eq 4 ];then + pca9548_channel="0x10" + elif [ $slot_number -eq 5 ];then + pca9548_channel="0x01" + elif [ $slot_number -eq 6 ];then + pca9548_channel="0x02" + elif [ $slot_number -eq 7 ];then + pca9548_channel="0x04" + elif [ $slot_number -eq 8 ];then + pca9548_channel="0x08" + elif [ $slot_number -eq 9 ];then + pca9548_channel="0x10" + elif [ $slot_number -eq 10 ];then + pca9548_channel="0x20" + else + format_print $WARNING "Unspecified card slot!" + fi fi } set_configuration_donghu(){ if [ $nic_type = "ocp" ];then + # Case - OCP format_print $ERROR "Unsupport OCP Nic on $server_type" format_print $INFO "Please check if script has update version" exit 1 - fi - - is_have_pca9641=0 - - i2c_bus=3 - pca9548_slave="0x70" - # set pca9548 switch channel - if [ $slot_number -eq 0 ];then - pca9548_channel="0x80" - elif [ $slot_number -eq 1 ];then - pca9548_channel="0x40" - elif [ $slot_number -eq 2 ];then - pca9548_channel="0x20" - elif [ $slot_number -eq 3 ];then - pca9548_channel="0x10" - elif [ $slot_number -eq 4 ];then - pca9548_channel="0x08" - elif [ $slot_number -eq 5 ];then - pca9548_channel="0x04" - elif [ $slot_number -eq 6 ];then - pca9548_channel="0x02" - elif [ $slot_number -eq 7 ];then - pca9548_channel="0x01" else - format_print $WARNING "Unspecified card slot!" + # Case - PCIe + is_have_pca9641=0 + i2c_bus=3 + pca9548_slave="0x70" + if [ $slot_number -eq 0 ];then + pca9548_channel="0x80" + elif [ $slot_number -eq 1 ];then + pca9548_channel="0x40" + elif [ $slot_number -eq 2 ];then + pca9548_channel="0x20" + elif [ $slot_number -eq 3 ];then + pca9548_channel="0x10" + elif [ $slot_number -eq 4 ];then + pca9548_channel="0x08" + elif [ $slot_number -eq 5 ];then + pca9548_channel="0x04" + elif [ $slot_number -eq 6 ];then + pca9548_channel="0x02" + elif [ $slot_number -eq 7 ];then + pca9548_channel="0x01" + else + format_print $WARNING "Unspecified card slot!" + fi fi - } set_configuration_yichun(){ if [ $nic_type = "ocp" ];then + # Case - OCP format_print $ERROR "Unsupport OCP Nic on $server_type" format_print $INFO "Please check if script has update version" exit 1 - fi - - is_have_pca9641=0 - pca9548_slave="0x74" - - # set pca9548 switch channel - if [ $slot_number -eq 0 ];then - i2c_bus=12 - pca9548_channel="0x02" - elif [ $slot_number -eq 1 ];then - i2c_bus=13 - pca9548_channel="0x02" - elif [ $slot_number -eq 2 ];then - i2c_bus=14 - pca9548_channel="0x02" else - format_print $WARNING "Unspecified card slot!" + # Case - PCIe + is_have_pca9641=0 + pca9548_slave="0x74" + if [ $slot_number -eq 0 ];then + i2c_bus=12 + pca9548_channel="0x02" + elif [ $slot_number -eq 1 ];then + i2c_bus=13 + pca9548_channel="0x02" + elif [ $slot_number -eq 2 ];then + i2c_bus=14 + pca9548_channel="0x02" + else + format_print $WARNING "Unspecified card slot!" + fi fi } set_configuration_qiandaohu(){ if [ $nic_type = "ocp" ];then + # Case - OCP format_print $ERROR "Unsupport OCP Nic on $server_type" format_print $INFO "Please check if script has update version" exit 1 - fi - - is_have_pca9641=0 - - if [ $slot_number -le 7 ];then - i2c_bus=3 - pca9548_slave=0x70 else - i2c_bus=6 - pca9548_slave=0x71 - fi - - # set pca9548 switch channel - if [ $slot_number -eq 0 ];then - pca9548_channel="0x08" - elif [ $slot_number -eq 1 ];then - pca9548_channel="0x04" - elif [ $slot_number -eq 2 ];then - pca9548_channel="0x01" - elif [ $slot_number -eq 3 ];then - pca9548_channel="0x02" - elif [ $slot_number -eq 4 ];then - pca9548_channel="0x80" - elif [ $slot_number -eq 5 ];then - pca9548_channel="0x40" - elif [ $slot_number -eq 6 ];then - pca9548_channel="0x10" - elif [ $slot_number -eq 7 ];then - pca9548_channel="0x20" - elif [ $slot_number -eq 8 ];then - pca9548_channel="0x08" - elif [ $slot_number -eq 9 ];then - pca9548_channel="0x04" - elif [ $slot_number -eq 10 ];then - pca9548_channel="0x01" - elif [ $slot_number -eq 11 ];then - pca9548_channel="0x02" - else - format_print $WARNING "Unspecified card slot!" + # Case - PCIe + is_have_pca9641=0 + if [ $slot_number -le 7 ];then + i2c_bus=3 + pca9548_slave=0x70 + else + i2c_bus=6 + pca9548_slave=0x71 + fi + if [ $slot_number -eq 0 ];then + pca9548_channel="0x08" + elif [ $slot_number -eq 1 ];then + pca9548_channel="0x04" + elif [ $slot_number -eq 2 ];then + pca9548_channel="0x01" + elif [ $slot_number -eq 3 ];then + pca9548_channel="0x02" + elif [ $slot_number -eq 4 ];then + pca9548_channel="0x80" + elif [ $slot_number -eq 5 ];then + pca9548_channel="0x40" + elif [ $slot_number -eq 6 ];then + pca9548_channel="0x10" + elif [ $slot_number -eq 7 ];then + pca9548_channel="0x20" + elif [ $slot_number -eq 8 ];then + pca9548_channel="0x08" + elif [ $slot_number -eq 9 ];then + pca9548_channel="0x04" + elif [ $slot_number -eq 10 ];then + pca9548_channel="0x01" + elif [ $slot_number -eq 11 ];then + pca9548_channel="0x02" + else + format_print $WARNING "Unspecified card slot!" + fi fi } set_configuration_5688m7(){ if [ $nic_type = "ocp" ];then + # Case - OCP format_print $ERROR "Unsupport OCP Nic on $server_type" format_print $INFO "Please check if script has update version" exit 1 - fi - - is_have_pca9641=1 - pca9641_slave="0x31" - i2c_bus=12 - - if [ $slot_number -le 3 ];then - pca9548_slave=0x71 else - pca9548_slave=0x72 - fi - - # set pca9548 switch channel - if [ $slot_number -eq 0 ];then - pca9548_channel="0x01" - elif [ $slot_number -eq 1 ];then - pca9548_channel="0x02" - elif [ $slot_number -eq 2 ];then - pca9548_channel="0x04" - elif [ $slot_number -eq 3 ];then - pca9548_channel="0x08" - elif [ $slot_number -eq 4 ];then - pca9548_channel="0x01" - elif [ $slot_number -eq 5 ];then - pca9548_channel="0x02" - elif [ $slot_number -eq 6 ];then - pca9548_channel="0x04" - elif [ $slot_number -eq 7 ];then - pca9548_channel="0x08" - else - format_print $WARNING "Unspecified card slot!" + # Case - PCIe + is_have_pca9641=1 + pca9641_slave="0x31" + i2c_bus=12 + if [ $slot_number -le 3 ];then + pca9548_slave=0x71 + else + pca9548_slave=0x72 + fi + if [ $slot_number -eq 0 ];then + pca9548_channel="0x01" + elif [ $slot_number -eq 1 ];then + pca9548_channel="0x02" + elif [ $slot_number -eq 2 ];then + pca9548_channel="0x04" + elif [ $slot_number -eq 3 ];then + pca9548_channel="0x08" + elif [ $slot_number -eq 4 ];then + pca9548_channel="0x01" + elif [ $slot_number -eq 5 ];then + pca9548_channel="0x02" + elif [ $slot_number -eq 6 ];then + pca9548_channel="0x04" + elif [ $slot_number -eq 7 ];then + pca9548_channel="0x08" + else + format_print $WARNING "Unspecified card slot!" + fi fi } @@ -745,9 +739,6 @@ read_emc1413_channel_value(){ } process_emc1413(){ - # emc1413 no need to init - - # get chip emc1413 value read_emc1413_channel_value } @@ -845,8 +836,6 @@ read_adc128_channel_value(){ process_adc128(){ # check if chip adc128 need init check_adc128_init - - # get chip adc128 value read_adc128_channel_value } @@ -971,10 +960,6 @@ read_ina3221_channel_value(){ } process_ina3221(){ - - # ina3221 no need to init first - - # get chip ina3221 value read_ina3221_channel_value } # --------------------------------------------------------- @@ -1050,9 +1035,6 @@ read_tmp468_value(){ } process_tmp468(){ - # tmp112 no need to init firsts - - # get chip tmp112 value read_tmp468_value } @@ -1112,9 +1094,6 @@ read_tmp112_value(){ } process_tmp112(){ - # tmp112 no need to init firsts - - # get chip tmp112 value read_tmp112_value } # --------------------------------------------------------- @@ -1122,7 +1101,6 @@ process_tmp112(){ # --------------------------------------------------------- # do a customization command write_read_chip(){ - # Modify i2c cmd which write to cpld if need cmd_wr=$option_data res_wr=`$cmd_wr` @@ -1133,9 +1111,6 @@ write_read_chip(){ } process_chip(){ - - # cpld no need to init first - # write and read cpld write_read_chip } @@ -1250,8 +1225,6 @@ write_fru(){ } process_fru(){ - # fru no need to init first - # write and read fru if [ "$option_data" = "write" ];then write_fru @@ -1472,7 +1445,7 @@ debug_user_defined_detect(){ format_print $INFO "Detect by user-defined" # default execute - format_print $INFO "Default detect on the current i2c" + format_print $INFO "Default detect on the default i2c: $i2c_bus" i2cdetect -y $i2c_bus } @@ -1513,7 +1486,7 @@ start_detect_device(){ } # --------------------------------------------------------- -# Start Execute Script +# Start Execute Script(main) # --------------------------------------------------------- pre_exec_hook