DellEMC : Platform2.0 API Implementation [S6100, S6000, Z9100] (#3740)
This commit is contained in:
parent
100d67941a
commit
343ad78931
@ -631,7 +631,7 @@ static ssize_t show_fan(struct device *dev,
|
||||
ret = smf_read_reg16(data, PSU_2_FAN_SPEED);
|
||||
break;
|
||||
case 12:
|
||||
ret = ~smf_read_reg(data, FAN_TRAY_PRESENCE);
|
||||
ret = (~smf_read_reg(data, FAN_TRAY_PRESENCE) & 0xff);
|
||||
export_hex = 1;
|
||||
break;
|
||||
|
||||
@ -682,14 +682,26 @@ static ssize_t show_fan_alarm(struct device *dev,
|
||||
struct smf_data *data = dev_get_drvdata(dev);
|
||||
int ret, psu_fan_status=0;
|
||||
|
||||
if(index < 2)
|
||||
psu_fan_status = smf_read_reg(data, FAN_STATUS_GROUP_B);
|
||||
if (data->kind == z9100smf) {
|
||||
if ((index % 2) == 0)
|
||||
index = index / 2;
|
||||
else
|
||||
index = (index / 2) + 5;
|
||||
}
|
||||
|
||||
if (data->kind == s6100smf)
|
||||
index = index / 2;
|
||||
|
||||
if (index > 7) {
|
||||
psu_fan_status = ~smf_read_reg(data, FAN_STATUS_GROUP_A);
|
||||
index = index % 8;
|
||||
} else
|
||||
psu_fan_status = ~smf_read_reg(data, FAN_STATUS_GROUP_B);
|
||||
|
||||
if (psu_fan_status & (1 << (index)))
|
||||
ret=0;
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
else
|
||||
ret=1;
|
||||
|
||||
return sprintf(buf, "%d\n", ret);
|
||||
}
|
||||
@ -726,12 +738,12 @@ static ssize_t show_psu_fan(struct device *dev,
|
||||
|
||||
if (index < FAN_601_FAULT){
|
||||
fan_status = smf_read_reg(data, PSU_1_FAN_STATUS);
|
||||
ret = fan_status & (1 << index);
|
||||
ret = (fan_status >> index) & 1;
|
||||
|
||||
}
|
||||
else{
|
||||
fan_status = smf_read_reg(data, PSU_2_FAN_STATUS);
|
||||
ret = fan_status & (1 << (index - 3));
|
||||
ret = (fan_status >> (index - 3)) & 1;
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
@ -1319,17 +1331,15 @@ static ssize_t show_current(struct device *dev,
|
||||
else
|
||||
ret = smf_read_reg16(data, SWITCH_CURRENT_Z9100 + index * 2);
|
||||
else if (index < CURR602_INPUT)
|
||||
curr = smf_read_reg16(data, PSU_1_INPUT_CURRENT + (index % 4) * 2);
|
||||
ret = smf_read_reg16(data, PSU_1_INPUT_CURRENT + (index % 2) * 2);
|
||||
else
|
||||
curr = smf_read_reg16(data, PSU_2_INPUT_CURRENT + (index % 4) * 2);
|
||||
ret = smf_read_reg16(data, PSU_2_INPUT_CURRENT + (index % 4) * 2);
|
||||
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* TODO: docs say 10mA, value look like A? */
|
||||
if(index < 2)
|
||||
curr = ret*1000;
|
||||
curr = ret*10;
|
||||
|
||||
return sprintf(buf, "%d\n", curr);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class Chassis(ChassisBase):
|
||||
# Get Transceiver status
|
||||
self.modprs_register = self._get_transceiver_status()
|
||||
|
||||
self.sys_eeprom = Eeprom()
|
||||
self._eeprom = Eeprom()
|
||||
for i in range(MAX_S6000_FAN):
|
||||
fan = Fan(i)
|
||||
self._fan_list.append(fan)
|
||||
@ -105,7 +105,7 @@ class Chassis(ChassisBase):
|
||||
Returns:
|
||||
string: The name of the chassis
|
||||
"""
|
||||
return self.sys_eeprom.modelstr()
|
||||
return self._eeprom.modelstr()
|
||||
|
||||
def get_presence(self):
|
||||
"""
|
||||
@ -121,7 +121,7 @@ class Chassis(ChassisBase):
|
||||
Returns:
|
||||
string: Model/part number of chassis
|
||||
"""
|
||||
return self.sys_eeprom.part_number_str()
|
||||
return self._eeprom.part_number_str()
|
||||
|
||||
def get_serial(self):
|
||||
"""
|
||||
@ -129,7 +129,7 @@ class Chassis(ChassisBase):
|
||||
Returns:
|
||||
string: Serial number of chassis
|
||||
"""
|
||||
return self.sys_eeprom.serial_str()
|
||||
return self._eeprom.serial_str()
|
||||
|
||||
def get_status(self):
|
||||
"""
|
||||
@ -148,7 +148,7 @@ class Chassis(ChassisBase):
|
||||
A string containing the MAC address in the format
|
||||
'XX:XX:XX:XX:XX:XX'
|
||||
"""
|
||||
return self.sys_eeprom.base_mac_addr()
|
||||
return self._eeprom.base_mac_addr()
|
||||
|
||||
def get_serial_number(self):
|
||||
"""
|
||||
@ -158,7 +158,7 @@ class Chassis(ChassisBase):
|
||||
A string containing the hardware serial number for this
|
||||
chassis.
|
||||
"""
|
||||
return self.sys_eeprom.serial_number_str()
|
||||
return self._eeprom.serial_number_str()
|
||||
|
||||
def get_system_eeprom_info(self):
|
||||
"""
|
||||
@ -170,7 +170,7 @@ class Chassis(ChassisBase):
|
||||
OCP ONIE TlvInfo EEPROM format and values are their
|
||||
corresponding values.
|
||||
"""
|
||||
return self.sys_eeprom.system_eeprom_info()
|
||||
return self._eeprom.system_eeprom_info()
|
||||
|
||||
def get_reboot_cause(self):
|
||||
"""
|
||||
|
@ -28,14 +28,15 @@ except ImportError as e:
|
||||
psu_eeprom_format = [
|
||||
('PPID', 's', 20), ('DPN Rev', 's', 3), ('Service Tag', 's', 7),
|
||||
('Part Number', 's', 10), ('Part Num Revision', 's', 3),
|
||||
('Mfg Test', 's', 2), ('PSU Type', 's', 1), ('Fab Rev', 's', 2)
|
||||
('Mfg Test', 's', 2), ('Redundant copy', 's', 83), ('PSU Type', 's', 1),
|
||||
('Fab Rev', 's', 2)
|
||||
]
|
||||
|
||||
# Fan eeprom fields in format required by EepromDecoder
|
||||
fan_eeprom_format = [
|
||||
('PPID', 's', 20), ('DPN Rev', 's', 3), ('Service Tag', 's', 7),
|
||||
('Part Number', 's', 10), ('Part Num Revision', 's', 3),
|
||||
('Mfg Test', 's', 2), ('Redundant copy', 's', 82),
|
||||
('Mfg Test', 's', 2), ('Redundant copy', 's', 83),
|
||||
('Number of Fans', 's', 1), ('Fan Type', 's', 1),
|
||||
('Fab Rev', 's', 2)
|
||||
]
|
||||
@ -168,6 +169,13 @@ class Eeprom(TlvInfoDecoder):
|
||||
else:
|
||||
self.part_number = 'NA'
|
||||
|
||||
if self.is_psu_eeprom:
|
||||
(valid, data) = self._get_eeprom_field("PSU Type")
|
||||
if valid:
|
||||
self.psu_type = data
|
||||
else:
|
||||
self.psu_type = 'NA'
|
||||
else:
|
||||
(valid, data) = self._get_eeprom_field("Fan Type")
|
||||
if valid:
|
||||
self.fan_type = data
|
||||
@ -204,6 +212,9 @@ class Eeprom(TlvInfoDecoder):
|
||||
"""
|
||||
Returns the airflow fan type.
|
||||
"""
|
||||
if self.is_psu_eeprom:
|
||||
return int(self.psu_type.encode('hex'), 16)
|
||||
else:
|
||||
return int(self.fan_type.encode('hex'), 16)
|
||||
|
||||
# System EEPROM specific methods
|
||||
|
@ -17,6 +17,7 @@ except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
MAX_S6000_PSU_FAN_SPEED = 18000
|
||||
MAX_S6000_FAN_SPEED = 19000
|
||||
|
||||
|
||||
@ -26,12 +27,12 @@ class Fan(FanBase):
|
||||
CPLD_DIR = "/sys/devices/platform/dell-s6000-cpld.0/"
|
||||
I2C_DIR = "/sys/class/i2c-adapter/"
|
||||
|
||||
def __init__(self, fan_index, psu_fan=False):
|
||||
# Fan is 1-based in DellEMC platforms
|
||||
self.index = fan_index + 1
|
||||
def __init__(self, fan_index, psu_fan=False, dependency=None):
|
||||
self.is_psu_fan = psu_fan
|
||||
|
||||
if not self.is_psu_fan:
|
||||
# Fan is 1-based in DellEMC platforms
|
||||
self.index = fan_index + 1
|
||||
self.fan_presence_reg = "fan_prs"
|
||||
self.fan_led_reg = "fan{}_led".format(fan_index)
|
||||
self.get_fan_speed_reg = self.I2C_DIR + "i2c-11/11-0029/" +\
|
||||
@ -42,8 +43,13 @@ class Fan(FanBase):
|
||||
self.max_fan_speed = MAX_S6000_FAN_SPEED
|
||||
self.supported_led_color = ['off', 'green', 'amber']
|
||||
else:
|
||||
self.get_fan_speed_reg = self.I2C_DIR + "i2c-1/1-005{}/" +\
|
||||
"fan1_input".format(10 - self.index)
|
||||
self.index = fan_index
|
||||
self.dependency = dependency
|
||||
self.get_fan_speed_reg = self.I2C_DIR +\
|
||||
"i2c-1/1-005{}/fan1_target".format(10 - self.index)
|
||||
self.set_fan_speed_reg = self.I2C_DIR +\
|
||||
"i2c-1/1-005{}/fan1_target".format(10 - self.index)
|
||||
self.max_fan_speed = MAX_S6000_PSU_FAN_SPEED
|
||||
|
||||
def _get_cpld_register(self, reg_name):
|
||||
# On successful read, returns the value read from given
|
||||
@ -136,6 +142,9 @@ class Fan(FanBase):
|
||||
bool: True if Fan is present, False if not
|
||||
"""
|
||||
status = False
|
||||
if self.is_psu_fan:
|
||||
return self.dependency.get_presence()
|
||||
|
||||
fan_presence = self._get_cpld_register(self.fan_presence_reg)
|
||||
if (fan_presence != 'ERR'):
|
||||
fan_presence = int(fan_presence,16) & self.index
|
||||
@ -151,7 +160,10 @@ class Fan(FanBase):
|
||||
Returns:
|
||||
string: Part number of Fan
|
||||
"""
|
||||
if not self.is_psu_fan:
|
||||
return self.eeprom.part_number_str()
|
||||
else:
|
||||
return 'NA'
|
||||
|
||||
def get_serial(self):
|
||||
"""
|
||||
@ -161,7 +173,10 @@ class Fan(FanBase):
|
||||
string: Serial number of Fan
|
||||
"""
|
||||
# Sample Serial number format "US-01234D-54321-25A-0123-A00"
|
||||
if not self.is_psu_fan:
|
||||
return self.eeprom.serial_number_str()
|
||||
else:
|
||||
return 'NA'
|
||||
|
||||
def get_status(self):
|
||||
"""
|
||||
@ -186,7 +201,12 @@ class Fan(FanBase):
|
||||
A string, either FAN_DIRECTION_INTAKE or
|
||||
FAN_DIRECTION_EXHAUST depending on fan direction
|
||||
"""
|
||||
direction = {1: 'FAN_DIRECTION_INTAKE', 2: 'FAN_DIRECTION_EXHAUST'}
|
||||
if self.is_psu_fan:
|
||||
direction = {1: 'FAN_DIRECTION_EXHAUST', 2: 'FAN_DIRECTION_INTAKE',
|
||||
3: 'FAN_DIRECTION_EXHAUST', 4: 'FAN_DIRECTION_INTAKE'}
|
||||
fan_direction = self.dependency.eeprom.airflow_fan_type()
|
||||
else:
|
||||
direction = {1: 'FAN_DIRECTION_EXHAUST', 2: 'FAN_DIRECTION_INTAKE'}
|
||||
fan_direction = self.eeprom.airflow_fan_type()
|
||||
|
||||
return direction.get(fan_direction,'NA')
|
||||
@ -248,7 +268,7 @@ class Fan(FanBase):
|
||||
Returns:
|
||||
bool: True if set success, False if fail.
|
||||
"""
|
||||
if color not in self.supported_led_color:
|
||||
if self.is_psu_fan or (color not in self.supported_led_color):
|
||||
return False
|
||||
if(color == self.STATUS_LED_COLOR_AMBER):
|
||||
color = 'yellow'
|
||||
@ -266,6 +286,10 @@ class Fan(FanBase):
|
||||
Returns:
|
||||
A string, one of the predefined STATUS_LED_COLOR_* strings.
|
||||
"""
|
||||
if self.is_psu_fan:
|
||||
# No LED available for PSU Fan
|
||||
return None
|
||||
|
||||
fan_led = self._get_cpld_register(self.fan_led_reg)
|
||||
if (fan_led != 'ERR'):
|
||||
if (fan_led == 'yellow'):
|
||||
|
@ -13,6 +13,7 @@ try:
|
||||
import os
|
||||
from sonic_platform_base.psu_base import PsuBase
|
||||
from sonic_platform.eeprom import Eeprom
|
||||
from sonic_platform.fan import Fan
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
@ -46,6 +47,8 @@ class Psu(PsuBase):
|
||||
# make it unique per Psu object
|
||||
self._fan_list = []
|
||||
|
||||
self._fan_list.append(Fan(self.index, psu_fan=True, dependency=self))
|
||||
|
||||
def _get_cpld_register(self, reg_name):
|
||||
# On successful read, returns the value read from given
|
||||
# reg_name and on failure returns 'ERR'
|
||||
|
@ -255,8 +255,8 @@ def print_psu(psu):
|
||||
psu_fan_present = int(get_pmc_register('fan11_fault'))
|
||||
input_voltage = float(get_pmc_register('in29_input')) / 1000
|
||||
output_voltage = float(get_pmc_register('in30_input')) / 1000
|
||||
input_current = float(get_pmc_register('curr601_input')) / 100
|
||||
output_current = float(get_pmc_register('curr602_input')) / 100
|
||||
input_current = float(get_pmc_register('curr601_input')) / 1000
|
||||
output_current = float(get_pmc_register('curr602_input')) / 1000
|
||||
input_power = float(get_pmc_register('power1_input')) / 1000000
|
||||
output_power = float(get_pmc_register('power2_input')) / 1000000
|
||||
if (input_power != 0):
|
||||
@ -268,8 +268,8 @@ def print_psu(psu):
|
||||
psu_fan_present = int(get_pmc_register('fan12_fault'))
|
||||
input_voltage = float(get_pmc_register('in31_input')) / 1000
|
||||
output_voltage = float(get_pmc_register('in32_input')) / 1000
|
||||
input_current = float(get_pmc_register('curr701_input')) / 100
|
||||
output_current = float(get_pmc_register('curr702_input')) / 100
|
||||
input_current = float(get_pmc_register('curr701_input')) / 1000
|
||||
output_current = float(get_pmc_register('curr702_input')) / 1000
|
||||
input_power = float(get_pmc_register('power3_input')) / 1000000
|
||||
output_power = float(get_pmc_register('power4_input')) / 1000000
|
||||
if (input_power != 0):
|
||||
|
@ -54,6 +54,26 @@ sys_eeprom() {
|
||||
esac
|
||||
}
|
||||
|
||||
#Attach/Detach eeprom on each IOM
|
||||
switch_board_eeprom() {
|
||||
case $1 in
|
||||
"new_device")
|
||||
for ((i=14;i<=17;i++));
|
||||
do
|
||||
i2c_config "echo 24c02 0x50 > /sys/bus/i2c/devices/i2c-$i/$1"
|
||||
done
|
||||
;;
|
||||
"delete_device")
|
||||
for ((i=14;i<=17;i++));
|
||||
do
|
||||
i2c_config "echo 0x50 > /sys/bus/i2c/devices/i2c-$i/$1"
|
||||
done
|
||||
;;
|
||||
*) echo "s6100_platform: switch_board_eeprom : invalid command !"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#Attach/Detach CPLD devices to drivers for each IOM
|
||||
switch_board_cpld() {
|
||||
case $1 in
|
||||
@ -245,7 +265,7 @@ install_python_api_package() {
|
||||
remove_python_api_package() {
|
||||
rv=$(pip show sonic-platform > /dev/null 2>/dev/null)
|
||||
if [ $? -eq 0 ]; then
|
||||
rv = $(pip uninstall -y sonic-platform > /dev/null 2>/dev/null)
|
||||
rv=$(pip uninstall -y sonic-platform > /dev/null 2>/dev/null)
|
||||
fi
|
||||
}
|
||||
|
||||
@ -267,6 +287,7 @@ if [[ "$1" == "init" ]]; then
|
||||
cpu_board_mux "new_device"
|
||||
switch_board_mux "new_device"
|
||||
sys_eeprom "new_device"
|
||||
switch_board_eeprom "new_device"
|
||||
switch_board_cpld "new_device"
|
||||
switch_board_qsfp_mux "new_device"
|
||||
switch_board_sfp "new_device"
|
||||
@ -280,6 +301,7 @@ elif [[ "$1" == "deinit" ]]; then
|
||||
xcvr_presence_interrupts "disable"
|
||||
switch_board_sfp "delete_device"
|
||||
switch_board_cpld "delete_device"
|
||||
switch_board_eeprom "delete_device"
|
||||
switch_board_mux "delete_device"
|
||||
sys_eeprom "delete_device"
|
||||
switch_board_qsfp "delete_device"
|
||||
|
@ -54,10 +54,11 @@ class Chassis(ChassisBase):
|
||||
|
||||
ChassisBase.__init__(self)
|
||||
# Initialize EEPROM
|
||||
self.sys_eeprom = Eeprom()
|
||||
self._eeprom = Eeprom()
|
||||
for i in range(MAX_S6100_MODULE):
|
||||
module = Module(i)
|
||||
self._module_list.append(module)
|
||||
self._sfp_list.extend(module._sfp_list)
|
||||
|
||||
for i in range(MAX_S6100_FAN):
|
||||
fan = Fan(i)
|
||||
@ -107,7 +108,7 @@ class Chassis(ChassisBase):
|
||||
Returns:
|
||||
string: The name of the chassis
|
||||
"""
|
||||
return self.sys_eeprom.modelstr()
|
||||
return self._eeprom.modelstr()
|
||||
|
||||
def get_presence(self):
|
||||
"""
|
||||
@ -123,7 +124,7 @@ class Chassis(ChassisBase):
|
||||
Returns:
|
||||
string: Model/part number of chassis
|
||||
"""
|
||||
return self.sys_eeprom.part_number_str()
|
||||
return self._eeprom.part_number_str()
|
||||
|
||||
def get_serial(self):
|
||||
"""
|
||||
@ -131,7 +132,7 @@ class Chassis(ChassisBase):
|
||||
Returns:
|
||||
string: Serial number of chassis
|
||||
"""
|
||||
return self.sys_eeprom.serial_str()
|
||||
return self._eeprom.serial_str()
|
||||
|
||||
def get_status(self):
|
||||
"""
|
||||
@ -150,7 +151,7 @@ class Chassis(ChassisBase):
|
||||
A string containing the MAC address in the format
|
||||
'XX:XX:XX:XX:XX:XX'
|
||||
"""
|
||||
return self.sys_eeprom.base_mac_addr()
|
||||
return self._eeprom.base_mac_addr()
|
||||
|
||||
def get_serial_number(self):
|
||||
"""
|
||||
@ -160,7 +161,7 @@ class Chassis(ChassisBase):
|
||||
A string containing the hardware serial number for this
|
||||
chassis.
|
||||
"""
|
||||
return self.sys_eeprom.serial_number_str()
|
||||
return self._eeprom.serial_number_str()
|
||||
|
||||
def get_system_eeprom_info(self):
|
||||
"""
|
||||
@ -170,7 +171,7 @@ class Chassis(ChassisBase):
|
||||
OCP ONIE TlvInfo EEPROM format and values are their corresponding
|
||||
values.
|
||||
"""
|
||||
return self.sys_eeprom.system_eeprom_info()
|
||||
return self._eeprom.system_eeprom_info()
|
||||
|
||||
def get_reboot_cause(self):
|
||||
"""
|
||||
|
@ -18,14 +18,25 @@ except ImportError, e:
|
||||
|
||||
class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, i2c_line=0, iom_eeprom=False):
|
||||
self.is_module = iom_eeprom
|
||||
if self.is_module:
|
||||
self.eeprom_path = ("/sys/class/i2c-adapter"
|
||||
"/i2c-{0}/{0}-0050/eeprom").format(i2c_line)
|
||||
else:
|
||||
self.eeprom_path = "/sys/class/i2c-adapter/i2c-2/2-0050/eeprom"
|
||||
super(Eeprom, self).__init__(self.eeprom_path, 0, '', True)
|
||||
self.eeprom_tlv_dict = dict()
|
||||
|
||||
try:
|
||||
if self.is_module:
|
||||
self.write_eeprom("\x00\x00")
|
||||
self.eeprom_data = self.read_eeprom_bytes(256)
|
||||
else:
|
||||
self.eeprom_data = self.read_eeprom()
|
||||
except:
|
||||
self.eeprom_data = "N/A"
|
||||
if not self.is_module:
|
||||
raise RuntimeError("Eeprom is not Programmed")
|
||||
else:
|
||||
eeprom = self.eeprom_data
|
||||
@ -76,6 +87,10 @@ class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
return ":".join([binascii.b2a_hex(T) for T in results[2]])
|
||||
|
||||
def modelstr(self):
|
||||
if self.is_module:
|
||||
(is_valid, results) = self.get_tlv_field(
|
||||
self.eeprom_data, self._TLV_CODE_PLATFORM_NAME)
|
||||
else:
|
||||
(is_valid, results) = self.get_tlv_field(
|
||||
self.eeprom_data, self._TLV_CODE_PRODUCT_NAME)
|
||||
if not is_valid:
|
||||
|
@ -33,6 +33,10 @@ class Fan(FanBase):
|
||||
# from 1
|
||||
self.fantrayindex = fantray_index + 1
|
||||
self.fanindex = fan_index + 1
|
||||
self.fan_presence_reg = "fan{}_fault".format(
|
||||
2 * self.fantrayindex - 1)
|
||||
self.fan_status_reg = "fan{}_alarm".format(
|
||||
2 * self.fantrayindex - 1)
|
||||
self.get_fan_speed_reg = "fan{}_input".format(
|
||||
2 * self.fantrayindex - 1)
|
||||
self.get_fan_dir_reg = "fan{}_airflow".format(
|
||||
@ -43,7 +47,9 @@ class Fan(FanBase):
|
||||
else:
|
||||
# PSU Fan index starts from 11
|
||||
self.fanindex = fan_index + 10
|
||||
self.fan_presence_reg = "fan{}_fault".format(self.fanindex)
|
||||
self.get_fan_speed_reg = "fan{}_input".format(self.fanindex)
|
||||
self.get_fan_dir_reg = "fan{}_airflow".format(self.fanindex)
|
||||
self.max_fan_speed = MAX_S6100_PSU_FAN_SPEED
|
||||
|
||||
def _get_pmc_register(self, reg_name):
|
||||
@ -84,6 +90,9 @@ class Fan(FanBase):
|
||||
"""
|
||||
# For Serial number "US-01234D-54321-25A-0123-A00", the part
|
||||
# number is "01234D"
|
||||
if self.is_psu_fan:
|
||||
return 'NA'
|
||||
|
||||
fan_serialno = self._get_pmc_register(self.fan_serialno_reg)
|
||||
if (fan_serialno != 'ERR') and self.get_presence():
|
||||
if (len(fan_serialno.split('-')) > 1):
|
||||
@ -102,6 +111,9 @@ class Fan(FanBase):
|
||||
string: Serial number of FAN
|
||||
"""
|
||||
# Sample Serial number format "US-01234D-54321-25A-0123-A00"
|
||||
if self.is_psu_fan:
|
||||
return 'NA'
|
||||
|
||||
fan_serialno = self._get_pmc_register(self.fan_serialno_reg)
|
||||
if (fan_serialno == 'ERR') or not self.get_presence():
|
||||
fan_serialno = 'NA'
|
||||
@ -115,10 +127,10 @@ class Fan(FanBase):
|
||||
bool: True if fan is present, False if not
|
||||
"""
|
||||
status = False
|
||||
fantray_presence = self._get_pmc_register(self.get_fan_speed_reg)
|
||||
fantray_presence = self._get_pmc_register(self.fan_presence_reg)
|
||||
if (fantray_presence != 'ERR'):
|
||||
fantray_presence = int(fantray_presence, 10)
|
||||
if (fantray_presence > 0):
|
||||
if (~fantray_presence & 0b1):
|
||||
status = True
|
||||
|
||||
return status
|
||||
@ -130,11 +142,18 @@ class Fan(FanBase):
|
||||
bool: True if FAN is operating properly, False if not
|
||||
"""
|
||||
status = False
|
||||
if self.is_psu_fan:
|
||||
fantray_status = self._get_pmc_register(self.get_fan_speed_reg)
|
||||
if (fantray_status != 'ERR'):
|
||||
fantray_status = int(fantray_status, 10)
|
||||
if (fantray_status > 5000):
|
||||
status = True
|
||||
else:
|
||||
fantray_status = self._get_pmc_register(self.fan_status_reg)
|
||||
if (fantray_status != 'ERR'):
|
||||
fantray_status = int(fantray_status, 10)
|
||||
if (~fantray_status & 0b1):
|
||||
status = True
|
||||
|
||||
return status
|
||||
|
||||
@ -216,8 +235,15 @@ class Fan(FanBase):
|
||||
Returns:
|
||||
A string, one of the predefined STATUS_LED_COLOR_* strings.
|
||||
"""
|
||||
if self.is_psu_fan:
|
||||
# No LED available for PSU Fan
|
||||
return None
|
||||
else:
|
||||
if self.get_presence():
|
||||
if self.get_status():
|
||||
return self.STATUS_LED_COLOR_GREEN
|
||||
else:
|
||||
return self.STATUS_LED_COLOR_AMBER
|
||||
else:
|
||||
return self.STATUS_LED_COLOR_OFF
|
||||
|
||||
|
@ -14,6 +14,7 @@ try:
|
||||
from sonic_platform_base.module_base import ModuleBase
|
||||
from sonic_platform.sfp import Sfp
|
||||
from sonic_platform.component import Component
|
||||
from sonic_platform.eeprom import Eeprom
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
@ -55,7 +56,7 @@ class Module(ModuleBase):
|
||||
self.port_start = (self.index - 1) * 16
|
||||
self.port_end = (self.index * 16) - 1
|
||||
self.port_i2c_line = self.IOM_I2C_MAPPING[self.index]
|
||||
self.eeprom_tlv_dict = dict()
|
||||
self._eeprom = Eeprom(iom_eeprom=True, i2c_line=self.port_i2c_line)
|
||||
|
||||
self.iom_status_reg = "iom_status"
|
||||
self.iom_presence_reg = "iom_presence"
|
||||
@ -108,7 +109,7 @@ class Module(ModuleBase):
|
||||
Returns:
|
||||
string: The name of the device
|
||||
"""
|
||||
return "IOM{}: 16xQSFP+".format(self.index)
|
||||
return "IOM{}: {}".format(self.index, self._eeprom.modelstr())
|
||||
|
||||
def get_presence(self):
|
||||
"""
|
||||
@ -133,7 +134,7 @@ class Module(ModuleBase):
|
||||
Returns:
|
||||
string: part number of module
|
||||
"""
|
||||
return 'NA'
|
||||
return self._eeprom.part_number_str()
|
||||
|
||||
def get_serial(self):
|
||||
"""
|
||||
@ -142,7 +143,7 @@ class Module(ModuleBase):
|
||||
Returns:
|
||||
string: Serial number of module
|
||||
"""
|
||||
return 'NA'
|
||||
return self._eeprom.serial_str()
|
||||
|
||||
def get_status(self):
|
||||
"""
|
||||
@ -178,7 +179,7 @@ class Module(ModuleBase):
|
||||
Returns:
|
||||
A string containing the hardware serial number for this module.
|
||||
"""
|
||||
return 'NA'
|
||||
return self._eeprom.serial_number_str()
|
||||
|
||||
def get_system_eeprom_info(self):
|
||||
"""
|
||||
@ -192,4 +193,4 @@ class Module(ModuleBase):
|
||||
‘0x24’:’001c0f000fcd0a’, ‘0x25’:’02/03/2018 16:22:00’,
|
||||
‘0x26’:’01’, ‘0x27’:’REV01’, ‘0x28’:’AG9064-C2358-16G’}
|
||||
"""
|
||||
return self.eeprom_tlv_dict
|
||||
return self._eeprom.system_eeprom_info()
|
||||
|
@ -262,8 +262,8 @@ def print_psu(psu):
|
||||
psu_fan_present = int(get_pmc_register('fan11_fault'))
|
||||
input_voltage = float(get_pmc_register('in29_input')) / 1000
|
||||
output_voltage = float(get_pmc_register('in30_input')) / 1000
|
||||
input_current = float(get_pmc_register('curr601_input')) / 100
|
||||
output_current = float(get_pmc_register('curr602_input')) /100
|
||||
input_current = float(get_pmc_register('curr601_input')) / 1000
|
||||
output_current = float(get_pmc_register('curr602_input')) / 1000
|
||||
input_power = float(get_pmc_register('power1_input')) / 1000000
|
||||
output_power = float(get_pmc_register('power2_input')) / 1000000
|
||||
if (input_power != 0):
|
||||
@ -275,8 +275,8 @@ def print_psu(psu):
|
||||
psu_fan_present = int(get_pmc_register('fan12_fault'))
|
||||
input_voltage = float(get_pmc_register('in31_input')) / 1000
|
||||
output_voltage = float(get_pmc_register('in32_input')) / 1000
|
||||
input_current = float(get_pmc_register('curr701_input')) / 100
|
||||
output_current = float(get_pmc_register('curr702_input')) / 100
|
||||
input_current = float(get_pmc_register('curr701_input')) / 1000
|
||||
output_current = float(get_pmc_register('curr702_input')) / 1000
|
||||
input_power = float(get_pmc_register('power3_input')) / 1000000
|
||||
output_power = float(get_pmc_register('power4_input')) / 1000000
|
||||
if (input_power != 0):
|
||||
|
@ -94,7 +94,7 @@ class Chassis(ChassisBase):
|
||||
|
||||
ChassisBase.__init__(self)
|
||||
# Initialize EEPROM
|
||||
self.sys_eeprom = Eeprom()
|
||||
self._eeprom = Eeprom()
|
||||
for i in range(MAX_Z9100_FANTRAY):
|
||||
for j in range(MAX_Z9100_FAN):
|
||||
fan = Fan(i, j)
|
||||
@ -137,7 +137,7 @@ class Chassis(ChassisBase):
|
||||
Returns:
|
||||
string: The name of the chassis
|
||||
"""
|
||||
return self.sys_eeprom.modelstr()
|
||||
return self._eeprom.modelstr()
|
||||
|
||||
def get_presence(self):
|
||||
"""
|
||||
@ -153,7 +153,7 @@ class Chassis(ChassisBase):
|
||||
Returns:
|
||||
string: Model/part number of chassis
|
||||
"""
|
||||
return self.sys_eeprom.part_number_str()
|
||||
return self._eeprom.part_number_str()
|
||||
|
||||
def get_serial(self):
|
||||
"""
|
||||
@ -161,7 +161,7 @@ class Chassis(ChassisBase):
|
||||
Returns:
|
||||
string: Serial number of chassis
|
||||
"""
|
||||
return self.sys_eeprom.serial_str()
|
||||
return self._eeprom.serial_str()
|
||||
|
||||
def get_status(self):
|
||||
"""
|
||||
@ -180,7 +180,7 @@ class Chassis(ChassisBase):
|
||||
A string containing the MAC address in the format
|
||||
'XX:XX:XX:XX:XX:XX'
|
||||
"""
|
||||
return self.sys_eeprom.base_mac_addr()
|
||||
return self._eeprom.base_mac_addr()
|
||||
|
||||
def get_serial_number(self):
|
||||
"""
|
||||
@ -189,7 +189,7 @@ class Chassis(ChassisBase):
|
||||
Returns:
|
||||
A string containing the hardware serial number for this chassis.
|
||||
"""
|
||||
return self.sys_eeprom.serial_number_str()
|
||||
return self._eeprom.serial_number_str()
|
||||
|
||||
def get_system_eeprom_info(self):
|
||||
"""
|
||||
@ -200,7 +200,7 @@ class Chassis(ChassisBase):
|
||||
OCP ONIE TlvInfo EEPROM format and values are their corresponding
|
||||
values.
|
||||
"""
|
||||
return self.sys_eeprom.system_eeprom_info()
|
||||
return self._eeprom.system_eeprom_info()
|
||||
|
||||
def get_reboot_cause(self):
|
||||
"""
|
||||
|
@ -33,6 +33,10 @@ class Fan(FanBase):
|
||||
# from 1
|
||||
self.fantrayindex = fantray_index + 1
|
||||
self.fanindex = fan_index + 1
|
||||
self.fan_presence_reg = "fan{}_fault".format(
|
||||
2 * (self.fantrayindex - 1) + (self.fanindex - 1) + 1 )
|
||||
self.fan_status_reg = "fan{}_alarm".format(
|
||||
2 * (self.fantrayindex - 1) + (self.fanindex - 1) + 1 )
|
||||
self.get_fan_speed_reg = "fan{}_input".format(
|
||||
2 * (self.fantrayindex - 1) + (self.fanindex - 1) + 1 )
|
||||
self.get_fan_dir_reg = "fan{}_airflow".format(
|
||||
@ -43,7 +47,9 @@ class Fan(FanBase):
|
||||
else:
|
||||
# PSU Fan index starts from 11
|
||||
self.fanindex = fan_index + 10
|
||||
self.fan_presence_reg = "fan{}_fault".format(self.fanindex)
|
||||
self.get_fan_speed_reg = "fan{}_input".format(self.fanindex)
|
||||
self.get_fan_dir_reg = "fan{}_airflow".format(self.fanindex)
|
||||
self.max_fan_speed = MAX_Z9100_PSU_FAN_SPEED
|
||||
|
||||
def _get_pmc_register(self, reg_name):
|
||||
@ -83,6 +89,9 @@ class Fan(FanBase):
|
||||
"""
|
||||
# For Serial number "US-01234D-54321-25A-0123-A00", the part
|
||||
# number is "01234D"
|
||||
if self.is_psu_fan:
|
||||
return 'NA'
|
||||
|
||||
fan_serialno = self._get_pmc_register(self.fan_serialno_reg)
|
||||
if (fan_serialno != 'ERR') and self.get_presence():
|
||||
if (len(fan_serialno.split('-')) > 1):
|
||||
@ -101,6 +110,9 @@ class Fan(FanBase):
|
||||
string: Serial number of FAN
|
||||
"""
|
||||
# Sample Serial number format "US-01234D-54321-25A-0123-A00"
|
||||
if self.is_psu_fan:
|
||||
return 'NA'
|
||||
|
||||
fan_serialno = self._get_pmc_register(self.fan_serialno_reg)
|
||||
if (fan_serialno == 'ERR') or not self.get_presence():
|
||||
fan_serialno = 'NA'
|
||||
@ -114,10 +126,10 @@ class Fan(FanBase):
|
||||
bool: True if fan is present, False if not
|
||||
"""
|
||||
status = False
|
||||
fantray_presence = self._get_pmc_register(self.get_fan_speed_reg)
|
||||
fantray_presence = self._get_pmc_register(self.fan_presence_reg)
|
||||
if (fantray_presence != 'ERR'):
|
||||
fantray_presence = int(fantray_presence, 10)
|
||||
if (fantray_presence > 0):
|
||||
if (~fantray_presence & 0b1):
|
||||
status = True
|
||||
|
||||
return status
|
||||
@ -129,11 +141,18 @@ class Fan(FanBase):
|
||||
bool: True if FAN is operating properly, False if not
|
||||
"""
|
||||
status = False
|
||||
if self.is_psu_fan:
|
||||
fantray_status = self._get_pmc_register(self.get_fan_speed_reg)
|
||||
if (fantray_status != 'ERR'):
|
||||
fantray_status = int(fantray_status, 10)
|
||||
if (fantray_status > 5000):
|
||||
status = True
|
||||
else:
|
||||
fantray_status = self._get_pmc_register(self.fan_status_reg)
|
||||
if (fantray_status != 'ERR'):
|
||||
fantray_status = int(fantray_status, 10)
|
||||
if (~fantray_status & 0b1):
|
||||
status = True
|
||||
|
||||
return status
|
||||
|
||||
@ -215,8 +234,15 @@ class Fan(FanBase):
|
||||
Returns:
|
||||
A string, one of the predefined STATUS_LED_COLOR_* strings.
|
||||
"""
|
||||
if self.is_psu_fan:
|
||||
# No LED available for PSU Fan
|
||||
return None
|
||||
else:
|
||||
if self.get_presence():
|
||||
if self.get_status():
|
||||
return self.STATUS_LED_COLOR_GREEN
|
||||
else:
|
||||
return self.STATUS_LED_COLOR_AMBER
|
||||
else:
|
||||
return self.STATUS_LED_COLOR_OFF
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user