Skip to content

Commit

Permalink
DellEMC: Platform2.0 API enhancements in DellEMC S6000 and other API …
Browse files Browse the repository at this point in the history
…changes (#3956)
  • Loading branch information
ArunSaravananBalachandran authored and abdosi committed Feb 3, 2020
1 parent a265641 commit c841693
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Chassis(ChassisBase):
reset_reason_dict[0x6] = ChassisBase.REBOOT_CAUSE_NON_HARDWARE

def __init__(self):
ChassisBase.__init__(self)
# Initialize SFP list
self.PORT_START = 0
self.PORT_END = 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ def _load_device_eeprom(self):
except:
self.serial_number = 'NA'
self.part_number = 'NA'
if self.is_psu_eeprom:
self.psu_type = 'NA'
else:
self.fan_type = 'NA'
else:
(valid, data) = self._get_eeprom_field("PPID")
if valid:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

try:
import os
import glob
from sonic_platform_base.fan_base import FanBase
from sonic_platform.eeprom import Eeprom
except ImportError as e:
Expand All @@ -29,6 +30,7 @@ class Fan(FanBase):

def __init__(self, fan_index, psu_fan=False, dependency=None):
self.is_psu_fan = psu_fan
self.is_driver_initialized = True

if not self.is_psu_fan:
# Fan is 1-based in DellEMC platforms
Expand All @@ -45,10 +47,18 @@ def __init__(self, fan_index, psu_fan=False, dependency=None):
else:
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)

hwmon_dir = self.I2C_DIR +\
"i2c-1/1-005{}/hwmon/".format(10 - self.index)
try:
hwmon_node = os.listdir(hwmon_dir)[0]
except OSError:
hwmon_node = "hwmon*"
self.is_driver_initialized = False

self.get_fan_speed_reg = hwmon_dir + hwmon_node + '/fan1_input'
self.max_fan_speed = MAX_S6000_PSU_FAN_SPEED

def _get_cpld_register(self, reg_name):
Expand Down Expand Up @@ -93,6 +103,14 @@ def _get_i2c_register(self, reg_file):
# reg_name and on failure returns 'ERR'
rv = 'ERR'

if not self.is_driver_initialized:
reg_file_path = glob.glob(reg_file)
if len(reg_file_path):
reg_file = reg_file_path[0]
self._get_sysfs_path()
else:
return rv

if (not os.path.isfile(reg_file)):
return rv

Expand Down Expand Up @@ -122,6 +140,13 @@ def _set_i2c_register(self, reg_file, value):

return rv

def _get_sysfs_path(self):
fan_speed_reg = glob.glob(self.get_fan_speed_reg)

if len(fan_speed_reg):
self.get_fan_speed_reg = fan_speed_reg[0]
self.is_driver_initialized = True

def get_name(self):
"""
Retrieves the name of the Fan
Expand Down Expand Up @@ -200,16 +225,21 @@ def get_direction(self):
Returns:
A string, either FAN_DIRECTION_INTAKE or
FAN_DIRECTION_EXHAUST depending on fan direction
Notes:
In DellEMC platforms,
- Forward/Exhaust : Air flows from Port side to Fan side.
- Reverse/Intake : Air flows from Fan side to Port side.
"""
if self.is_psu_fan:
direction = {1: 'FAN_DIRECTION_EXHAUST', 2: 'FAN_DIRECTION_INTAKE',
3: 'FAN_DIRECTION_EXHAUST', 4: 'FAN_DIRECTION_INTAKE'}
direction = {1: self.FAN_DIRECTION_EXHAUST, 2: self.FAN_DIRECTION_INTAKE,
3: self.FAN_DIRECTION_EXHAUST, 4: self.FAN_DIRECTION_INTAKE}
fan_direction = self.dependency.eeprom.airflow_fan_type()
else:
direction = {1: 'FAN_DIRECTION_EXHAUST', 2: 'FAN_DIRECTION_INTAKE'}
direction = {1: self.FAN_DIRECTION_EXHAUST, 2: self.FAN_DIRECTION_INTAKE}
fan_direction = self.eeprom.airflow_fan_type()

return direction.get(fan_direction,'NA')
return direction.get(fan_direction, self.FAN_DIRECTION_NOT_APPLICABLE)

def get_speed(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

try:
import os
import glob
from sonic_platform_base.psu_base import PsuBase
from sonic_platform.eeprom import Eeprom
from sonic_platform.fan import Fan
Expand All @@ -29,12 +30,20 @@ def __init__(self, psu_index):
self.index = psu_index + 1
self.psu_presence_reg = "psu{}_prs".format(psu_index)
self.psu_status_reg = "powersupply_status"
self.is_driver_initialized = False

if self.index == 1:
ltc_dir = self.I2C_DIR + "i2c-11/11-0042/hwmon/"
else:
ltc_dir = self.I2C_DIR + "i2c-11/11-0040/hwmon/"
hwmon_node = os.listdir(ltc_dir)[0]

try:
hwmon_node = os.listdir(ltc_dir)[0]
except OSError:
hwmon_node = "hwmon*"
else:
self.is_driver_initialized = True

self.HWMON_DIR = ltc_dir + hwmon_node + '/'

self.psu_voltage_reg = self.HWMON_DIR + "in1_input"
Expand Down Expand Up @@ -73,6 +82,14 @@ def _get_i2c_register(self, reg_file):
# reg_name and on failure returns 'ERR'
rv = 'ERR'

if not self.is_driver_initialized:
reg_file_path = glob.glob(reg_file)
if len(reg_file_path):
reg_file = reg_file_path[0]
self._get_sysfs_path()
else:
return rv

if (not os.path.isfile(reg_file)):
return rv

Expand All @@ -86,6 +103,17 @@ def _get_i2c_register(self, reg_file):
rv = rv.lstrip(" ")
return rv

def _get_sysfs_path(self):
voltage_reg = glob.glob(self.psu_voltage_reg)
current_reg = glob.glob(self.psu_current_reg)
power_reg = glob.glob(self.psu_power_reg)

if len(voltage_reg) and len(current_reg) and len(power_reg):
self.psu_voltage_reg = voltage_reg_path[0]
self.psu_current_reg = current_reg_path[0]
self.psu_power_reg = power_reg_path[0]
self.is_driver_initialized = True

def get_name(self):
"""
Retrieves the name of the device
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

try:
import os
import glob
from sonic_platform_base.thermal_base import ThermalBase
from sonic_platform.psu import Psu
except ImportError as e:
Expand All @@ -36,13 +37,19 @@ class Thermal(ThermalBase):
def __init__(self, thermal_index):
self.index = thermal_index + 1
self.is_psu_thermal = False
self.is_driver_initialized = True
self.dependency = None

if self.index < 9:
i2c_path = self.I2C_DIR + self.I2C_DEV_MAPPING[self.index - 1][0]
hwmon_temp_index = self.I2C_DEV_MAPPING[self.index - 1][1]
hwmon_temp_suffix = "max"
hwmon_node = os.listdir(i2c_path)[0]
try:
hwmon_node = os.listdir(i2c_path)[0]
except OSError:
hwmon_node = "hwmon*"
self.is_driver_initialized = False

self.HWMON_DIR = i2c_path + hwmon_node + '/'

if self.index == 4:
Expand All @@ -55,7 +62,12 @@ def __init__(self, thermal_index):
dev_path = "/sys/devices/platform/coretemp.0/hwmon/"
hwmon_temp_index = self.index - 7
hwmon_temp_suffix = "crit"
hwmon_node = os.listdir(dev_path)[0]
try:
hwmon_node = os.listdir(dev_path)[0]
except OSError:
hwmon_node = "hwmon*"
self.is_driver_initialized = False

self.HWMON_DIR = dev_path + hwmon_node + '/'

self.thermal_temperature_file = self.HWMON_DIR \
Expand All @@ -70,6 +82,14 @@ def _read_sysfs_file(self, sysfs_file):
# sysfs_file and on failure returns 'ERR'
rv = 'ERR'

if not self.is_driver_initialized:
sysfs_file_path = glob.glob(sysfs_file)
if len(sysfs_file_path):
sysfs_file = sysfs_file_path[0]
self._get_sysfs_path()
else:
return rv

if (not os.path.isfile(sysfs_file)):
return rv

Expand All @@ -83,6 +103,19 @@ def _read_sysfs_file(self, sysfs_file):
rv = rv.lstrip(" ")
return rv

def _get_sysfs_path(self):
temperature_path = glob.glob(self.thermal_temperature_file)
high_threshold_path = glob.glob(self.thermal_high_threshold_file)
low_threshold_path = glob.glob(self.thermal_low_threshold_file)

if len(temperature_path) and len(high_threshold_path):
self.thermal_temperature_file = temperature_path[0]
self.thermal_high_threshold_file = high_threshold_path[0]
if len(low_threshold_path):
self.thermal_low_threshold_file = low_threshold_path

self.is_driver_initialized = True

def get_name(self):
"""
Retrieves the name of the thermal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def get_status(self):
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):
if (fantray_status > 1000):
status = True
else:
fantray_status = self._get_pmc_register(self.fan_status_reg)
Expand All @@ -163,13 +163,18 @@ def get_direction(self):
Returns:
A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST
depending on fan direction
Notes:
In DellEMC platforms,
- Forward/Exhaust : Air flows from Port side to Fan side.
- Reverse/Intake : Air flows from Fan side to Port side.
"""
direction = ['FAN_DIRECTION_INTAKE', 'FAN_DIRECTION_EXHAUST']
direction = [self.FAN_DIRECTION_INTAKE, self.FAN_DIRECTION_EXHAUST]
fan_direction = self._get_pmc_register(self.get_fan_dir_reg)
if (fan_direction != 'ERR') and self.get_presence():
fan_direction = int(fan_direction, 10)
else:
return 'N/A'
return self.FAN_DIRECTION_NOT_APPLICABLE
return direction[fan_direction]

def get_speed(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Chassis(ChassisBase):
power_reason_dict[44] = ChassisBase.REBOOT_CAUSE_INSUFFICIENT_FAN_SPEED

def __init__(self):
ChassisBase.__init__(self)
PORT_START = 0
PORT_END = 31
PORTS_IN_BLOCK = (PORT_END + 1)
Expand All @@ -92,7 +93,6 @@ def __init__(self):
self.PORT_I2C_MAPPING[index][1])
self._sfp_list.append(sfp_node)

ChassisBase.__init__(self)
# Initialize EEPROM
self._eeprom = Eeprom()
for i in range(MAX_Z9100_FANTRAY):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_status(self):
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):
if (fantray_status > 1000):
status = True
else:
fantray_status = self._get_pmc_register(self.fan_status_reg)
Expand All @@ -162,13 +162,18 @@ def get_direction(self):
Returns:
A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST
depending on fan direction
Notes:
In DellEMC platforms,
- Forward/Exhaust : Air flows from Port side to Fan side.
- Reverse/Intake : Air flows from Fan side to Port side.
"""
direction = ['FAN_DIRECTION_INTAKE', 'FAN_DIRECTION_EXHAUST']
direction = [self.FAN_DIRECTION_INTAKE, self.FAN_DIRECTION_EXHAUST]
fan_direction = self._get_pmc_register(self.get_fan_dir_reg)
if (fan_direction != 'ERR') and self.get_presence():
fan_direction = int(fan_direction, 10)
else:
return 'N/A'
return self.FAN_DIRECTION_NOT_APPLICABLE
return direction[fan_direction]

def get_speed(self):
Expand Down

0 comments on commit c841693

Please sign in to comment.