From b4169ce1f5c4d41ee034745f936ac95b95ec4b42 Mon Sep 17 00:00:00 2001 From: leimingsheng Date: Wed, 4 Dec 2024 15:20:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(script=20:=20nicsensor.sh)=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9OCP=E5=8D=A1=E6=A7=BD=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02.nicsensor/change_list.txt | 4 + 02.nicsensor/nicsensor.sh | 166 +++++++++++++++++++++++------------ 2 files changed, 112 insertions(+), 58 deletions(-) diff --git a/02.nicsensor/change_list.txt b/02.nicsensor/change_list.txt index 2fde5fd..63359a2 100644 --- a/02.nicsensor/change_list.txt +++ b/02.nicsensor/change_list.txt @@ -1,3 +1,7 @@ +# Script Version 1.3 + Release Note + 1.[新增功能]支持5280m7的OCP卡的使用 + # Script Version 1.2 20241102 Release Note: 1.[新增功能]支持写入板卡FRU diff --git a/02.nicsensor/nicsensor.sh b/02.nicsensor/nicsensor.sh index 12b40cb..4729ef7 100644 --- a/02.nicsensor/nicsensor.sh +++ b/02.nicsensor/nicsensor.sh @@ -50,7 +50,7 @@ server_type="5280m7" # Common Varible (Don't Change) # --------------------------------------------------------- # Input Param -pcie_slot=$1 +nic_slot=$1 sensor_type=$2 # Introduction of chip_slave @@ -117,11 +117,13 @@ ina3221_ch2_volt="0" ina3221_ch0_current="0" ina3221_ch1_current="0" ina3221_ch2_current="0" -SCRIPT_VERSION="1.2 Standard" +SCRIPT_VERSION="1.3 Intest Rev1" fru_file_name=$option_data2 fru_write_size=0 fru_write_data="" +nic_type="" +slot_number="" # --------------------------------------------------------- # Script Function Defination @@ -198,30 +200,46 @@ conf_pre_check(){ # 根据5280m7 pcie slot 和 i2c 对对应关系调整变量 set_configuration_5280m7(){ - is_have_pca9641=1 - # set pca9641 address && I2C BUS - if [ $pcie_slot -le 2 ];then - pca9641_slave="0x41" - i2c_bus=12 + if [ $nic_type == "ocp" ];then + is_have_pca9641=0 + pca9548_slave="0x70" else - pca9641_slave="0x42" - i2c_bus=13 + 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 [ $pcie_slot -eq 0 ];then - pca9548_channel="0x02" - elif [ $pcie_slot -eq 1 ];then - pca9548_channel="0x04" - elif [ $pcie_slot -eq 2 ];then - pca9548_channel="0x08" - elif [ $pcie_slot -eq 3 ];then - pca9548_channel="0x02" - elif [ $pcie_slot -eq 4 ];then - pca9548_channel="0x04" - elif [ $pcie_slot -eq 5 ];then - pca9548_channel="0x08" + if [ $nic_type == "ocp" ];then + 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" + fi + else + if [ $slot_number -eq 0 ];then + pca9548_channel="0x02" + elif [ $slot_number -eq 1 ];then + pca9548_channel="0x04" + elif [ $slot_number -eq 2 ];then + pca9548_channel="0x08" + elif [ $slot_number -eq 3 ];then + pca9548_channel="0x02" + elif [ $slot_number -eq 4 ];then + pca9548_channel="0x04" + elif [ $slot_number -eq 5 ];then + pca9548_channel="0x08" + fi fi } @@ -231,7 +249,7 @@ set_configuration_5468m7(){ is_have_pca9641=1 # set pca9641 address && I2C BUS - if [ $pcie_slot -le 4 ];then + if [ $slot_number -le 4 ];then pca9641_slave="0x31" pca9548_slave="0x70" i2c_bus=13 @@ -242,27 +260,27 @@ set_configuration_5468m7(){ fi # set pca9548 switch channel - if [ $pcie_slot -eq 0 ];then + if [ $slot_number -eq 0 ];then pca9548_channel="0x01" - elif [ $pcie_slot -eq 1 ];then + elif [ $slot_number -eq 1 ];then pca9548_channel="0x02" - elif [ $pcie_slot -eq 2 ];then + elif [ $slot_number -eq 2 ];then pca9548_channel="0x04" - elif [ $pcie_slot -eq 3 ];then + elif [ $slot_number -eq 3 ];then pca9548_channel="0x08" - elif [ $pcie_slot -eq 4 ];then + elif [ $slot_number -eq 4 ];then pca9548_channel="0x10" - elif [ $pcie_slot -eq 5 ];then + elif [ $slot_number -eq 5 ];then pca9548_channel="0x01" - elif [ $pcie_slot -eq 6 ];then + elif [ $slot_number -eq 6 ];then pca9548_channel="0x02" - elif [ $pcie_slot -eq 7 ];then + elif [ $slot_number -eq 7 ];then pca9548_channel="0x04" - elif [ $pcie_slot -eq 8 ];then + elif [ $slot_number -eq 8 ];then pca9548_channel="0x08" - elif [ $pcie_slot -eq 9 ];then + elif [ $slot_number -eq 9 ];then pca9548_channel="0x10" - elif [ $pcie_slot -eq 10 ];then + elif [ $slot_number -eq 10 ];then pca9548_channel="0x20" fi } @@ -274,21 +292,21 @@ set_configuration_donghu(){ i2c_bus=3 pca9548_slave="0x70" # set pca9548 switch channel - if [ $pcie_slot -eq 0 ];then + if [ $slot_number -eq 0 ];then pca9548_channel="0x80" - elif [ $pcie_slot -eq 1 ];then + elif [ $slot_number -eq 1 ];then pca9548_channel="0x40" - elif [ $pcie_slot -eq 2 ];then + elif [ $slot_number -eq 2 ];then pca9548_channel="0x20" - elif [ $pcie_slot -eq 3 ];then + elif [ $slot_number -eq 3 ];then pca9548_channel="0x10" - elif [ $pcie_slot -eq 4 ];then + elif [ $slot_number -eq 4 ];then pca9548_channel="0x08" - elif [ $pcie_slot -eq 5 ];then + elif [ $slot_number -eq 5 ];then pca9548_channel="0x04" - elif [ $pcie_slot -eq 6 ];then + elif [ $slot_number -eq 6 ];then pca9548_channel="0x02" - elif [ $pcie_slot -eq 7 ];then + elif [ $slot_number -eq 7 ];then pca9548_channel="0x01" fi @@ -300,13 +318,13 @@ set_configuration_yichun(){ pca9548_slave="0x74" # set pca9548 switch channel - if [ $pcie_slot -eq 0 ];then + if [ $slot_number -eq 0 ];then i2c_bus=12 pca9548_channel="0x02" - elif [ $pcie_slot -eq 1 ];then + elif [ $slot_number -eq 1 ];then i2c_bus=13 pca9548_channel="0x02" - elif [ $pcie_slot -eq 2 ];then + elif [ $slot_number -eq 2 ];then i2c_bus=14 pca9548_channel="0x02" fi @@ -316,7 +334,7 @@ set_configuration_yichun(){ set_configuration_qiandaohu(){ is_have_pca9641=0 - if [ $pcie_slot -le 7 ];then + if [ $slot_number -le 7 ];then i2c_bus=3 pca9548_slave=0x70 else @@ -325,41 +343,73 @@ set_configuration_qiandaohu(){ fi # set pca9548 switch channel - if [ $pcie_slot -eq 0 ];then + if [ $slot_number -eq 0 ];then pca9548_channel="0x08" - elif [ $pcie_slot -eq 1 ];then + elif [ $slot_number -eq 1 ];then pca9548_channel="0x04" - elif [ $pcie_slot -eq 2 ];then + elif [ $slot_number -eq 2 ];then pca9548_channel="0x01" - elif [ $pcie_slot -eq 3 ];then + elif [ $slot_number -eq 3 ];then pca9548_channel="0x02" - elif [ $pcie_slot -eq 4 ];then + elif [ $slot_number -eq 4 ];then pca9548_channel="0x80" - elif [ $pcie_slot -eq 5 ];then + elif [ $slot_number -eq 5 ];then pca9548_channel="0x40" - elif [ $pcie_slot -eq 6 ];then + elif [ $slot_number -eq 6 ];then pca9548_channel="0x10" - elif [ $pcie_slot -eq 7 ];then + elif [ $slot_number -eq 7 ];then pca9548_channel="0x20" - elif [ $pcie_slot -eq 8 ];then + elif [ $slot_number -eq 8 ];then pca9548_channel="0x08" - elif [ $pcie_slot -eq 9 ];then + elif [ $slot_number -eq 9 ];then pca9548_channel="0x04" - elif [ $pcie_slot -eq 10 ];then + elif [ $slot_number -eq 10 ];then pca9548_channel="0x01" - elif [ $pcie_slot -eq 11 ];then + elif [ $slot_number -eq 11 ];then pca9548_channel="0x02" 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" +} + # 根据输入信息调整选通芯片的配置(PCA9641 PCA9548) set_configuration(){ format_log_print $INFO "Server Type : $server_type" + parse_nic_slot # 根据服务器型号执行对应的配置策略 case $server_type in "5280m7") + # Support PCIe and OCP configuration set_configuration_5280m7 ;; "5468m7") @@ -402,7 +452,7 @@ init_debuglog(){ prepare_start_info(){ # 记录单次配置信息到调试日志中去 - format_log_print $INFO "PCIE slot : $pcie_slot" + 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"