Skip to content

Commit

Permalink
DellEMC: S6100, S6000 - Enable thermalctld, Platform API implementati…
Browse files Browse the repository at this point in the history
…on and fixes (#6438)

**- Why I did it**

To incorporate the below changes in DellEMC S6100, S6000 platforms.

- S6100, S6000:
    - Enable 'thermalctld'
    - Implement DeviceBase methods (presence, status, model, serial) for Fantray and Component
    - Implement ‘get_position_in_parent’, ‘is_replaceable’ methods for all device types
    - Implement ‘get_status’ method for Fantray
    - Implement ‘get_temperature’, ‘get_temperature_high_threshold’, ‘get_voltage_high_threshold’, ‘get_voltage_low_threshold’ methods for PSU
    - Implement ‘get_status_led’, ‘set_status_led’ methods for Chassis
    - SFP:
        - Make EEPROM read both Python2 and Python3 compatible
        - Fix ‘get_tx_disable_channel’ method’s return type
        - Implement ‘tx_disable’, ‘tx_disable_channel’ and ‘set_power_override’ methods
- S6000:
    - Move PSU thermal sensors from Chassis to respective PSU
    - Make available the data of both Fans present in each Fantray


**- How I did it**

- Remove 'skip_thermalctld:true' in pmon_daemon_control.json
- Implement the platform API methods in the respective device files
- Use `bytearray` for data read from transceiver EEPROM 
- Change return type of 'get_tx_disable_channel' to match specification in sonic_platform_common/sfp_base.py
  • Loading branch information
ArunSaravananBalachandran authored Feb 5, 2021
1 parent 85a6314 commit fa89c6d
Show file tree
Hide file tree
Showing 19 changed files with 1,084 additions and 280 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"skip_ledd": true,
"skip_thermalctld": true
"skip_ledd": true
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"skip_ledd": true,
"skip_thermalctld": true
"skip_ledd": true
}
46 changes: 46 additions & 0 deletions platform/broadcom/sonic-platform-modules-dell/common/dell_pmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@
/* Mailbox PowerOn Reason */
#define TRACK_POWERON_REASON 0x05FF

/* System Status LED */
#define SYSTEM_STATUS_LED 0x04DF

/* CPU Set IO Modules */
#define CPU_IOM1_CTRL_FLAG 0x04D9
#define CPU_IOM2_CTRL_FLAG 0x04DA
Expand Down Expand Up @@ -607,6 +610,44 @@ static ssize_t show_mb_poweron_reason(struct device *dev,
return sprintf(buf, "0x%x\n", ret);
}

/* System Status LED */
static ssize_t set_sys_status_led(struct device *dev,
struct device_attribute *devattr, const char *buf, size_t count)
{
int err = 0;
unsigned int dev_data = 0;
struct smf_data *data = dev_get_drvdata(dev);

if (data->kind == z9100smf)
return -1;

err = kstrtouint(buf, 16, &dev_data);
if (err)
return err;

err = smf_write_reg(data, SYSTEM_STATUS_LED, dev_data);
if(err < 0)
return err;

return count;
}

static ssize_t show_sys_status_led(struct device *dev,
struct device_attribute *devattr, char *buf)
{
unsigned int ret = 0;
struct smf_data *data = dev_get_drvdata(dev);

if (data->kind == z9100smf)
return 0;

ret = smf_read_reg(data, SYSTEM_STATUS_LED);
if(ret < 0)
return ret;

return sprintf(buf, "0x%x\n", ret);
}

/* FANIN ATTR */
static ssize_t
show_fan_label(struct device *dev, struct device_attribute *attr, char *buf)
Expand Down Expand Up @@ -2081,12 +2122,17 @@ static SENSOR_DEVICE_ATTR(smf_poweron_reason, S_IRUGO,
static SENSOR_DEVICE_ATTR(mb_poweron_reason, S_IRUGO|S_IWUSR,
show_mb_poweron_reason, set_mb_poweron_reason, 0);

/* System Status LED */
static SENSOR_DEVICE_ATTR(sys_status_led, S_IRUGO|S_IWUSR,
show_sys_status_led, set_sys_status_led, 0);

static struct attribute *smf_dell_attrs[] = {
&sensor_dev_attr_smf_version.dev_attr.attr,
&sensor_dev_attr_smf_firmware_ver.dev_attr.attr,
&sensor_dev_attr_smf_reset_reason.dev_attr.attr,
&sensor_dev_attr_smf_poweron_reason.dev_attr.attr,
&sensor_dev_attr_mb_poweron_reason.dev_attr.attr,
&sensor_dev_attr_sys_status_led.dev_attr.attr,
&sensor_dev_attr_fan_tray_presence.dev_attr.attr,
&sensor_dev_attr_fan1_airflow.dev_attr.attr,
&sensor_dev_attr_fan3_airflow.dev_attr.attr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

MAX_S6000_FANTRAY = 3
MAX_S6000_PSU = 2
MAX_S6000_THERMAL = 10
MAX_S6000_THERMAL = 6
MAX_S6000_COMPONENT = 4


Expand All @@ -44,6 +44,8 @@ class Chassis(ChassisBase):

def __init__(self):
ChassisBase.__init__(self)
self.status_led_reg = "system_led"
self.supported_led_color = ['green', 'blinking green', 'amber', 'blinking amber']
# Initialize SFP list
self.PORT_START = 0
self.PORT_END = 31
Expand Down Expand Up @@ -101,13 +103,30 @@ def _get_cpld_register(self, reg_name):
try:
with open(mb_reg_file, 'r') as fd:
rv = fd.read()
except Exception as error:
except IOError:
rv = 'ERR'

rv = rv.rstrip('\r\n')
rv = rv.lstrip(" ")
return rv

def _set_cpld_register(self, reg_name, value):
# On successful write, returns the value will be written on
# reg_name and on failure returns 'ERR'
rv = 'ERR'
cpld_reg_file = self.CPLD_DIR+'/'+reg_name

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

try:
with open(cpld_reg_file, 'w') as fd:
rv = fd.write(str(value))
except IOError:
rv = 'ERR'

return rv

def _nvram_write(self, offset, val):
resource = "/dev/nvram"
fd = os.open(resource, os.O_RDWR)
Expand Down Expand Up @@ -179,6 +198,23 @@ def get_status(self):
"""
return True

def get_position_in_parent(self):
"""
Retrieves 1-based relative physical position in parent device.
Returns:
integer: The 1-based relative physical position in parent
device or -1 if cannot determine the position
"""
return -1

def is_replaceable(self):
"""
Indicate whether Chassis is replaceable.
Returns:
bool: True if it is replaceable.
"""
return False

def get_base_mac(self):
"""
Retrieves the base MAC address for the chassis
Expand Down Expand Up @@ -305,4 +341,41 @@ def get_change_event(self, timeout=0):
return True, ret_dict
return False, ret_dict

def set_status_led(self, color):
"""
Sets the state of the system LED
Args:
color: A string representing the color with which to set the
system LED
Returns:
bool: True if system LED state is set successfully, False if not
"""
if color not in self.supported_led_color:
return False

# Change color string format to the one used by driver
color = color.replace('amber', 'yellow')
color = color.replace('blinking ', 'blink_')
rv = self._set_cpld_register(self.status_led_reg, color)
if (rv != 'ERR'):
return True
else:
return False

def get_status_led(self):
"""
Gets the state of the system LED
Returns:
A string, one of the valid LED color strings which could be vendor
specified.
"""
status_led = self._get_cpld_register(self.status_led_reg)
if (status_led != 'ERR'):
status_led = status_led.replace('yellow', 'amber')
status_led = status_led.replace('blink_', 'blinking ')
return status_led
else:
return None
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class Component(ComponentBase):
"booting")],
["System-CPLD", "Used for managing CPU board devices and power"],
["Master-CPLD", ("Used for managing Fan, PSU, system LEDs, QSFP "
"modules (1-16)")],
["Slave-CPLD", "Used for managing QSFP modules (17-32)"]
"modules (17-32)")],
["Slave-CPLD", "Used for managing QSFP modules (1-16)"]
]

def __init__(self, component_index):
Expand Down Expand Up @@ -90,6 +90,55 @@ def get_name(self):
"""
return self.name

def get_model(self):
"""
Retrieves the part number of the component
Returns:
string: Part number of component
"""
return 'NA'

def get_serial(self):
"""
Retrieves the serial number of the component
Returns:
string: Serial number of component
"""
return 'NA'

def get_presence(self):
"""
Retrieves the presence of the component
Returns:
bool: True if present, False if not
"""
return True

def get_status(self):
"""
Retrieves the operational status of the component
Returns:
bool: True if component is operating properly, False if not
"""
return True

def get_position_in_parent(self):
"""
Retrieves 1-based relative physical position in parent device.
Returns:
integer: The 1-based relative physical position in parent
device or -1 if cannot determine the position
"""
return -1

def is_replaceable(self):
"""
Indicate whether component is replaceable.
Returns:
bool: True if it is replaceable.
"""
return False

def get_description(self):
"""
Retrieves the description of the component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
('Fab Rev', 's', 2)
]

# Fan eeprom fields in format required by EepromDecoder
fan_eeprom_format = [
# FanTray eeprom fields in format required by EepromDecoder
fantray_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', 83),
Expand All @@ -51,10 +51,10 @@ class Eeprom(TlvInfoDecoder):

I2C_DIR = "/sys/class/i2c-adapter/"

def __init__(self, is_psu=False, psu_index=0, is_fan=False, fan_index=0):
def __init__(self, is_psu=False, psu_index=0, is_fantray=False, fantray_index=0):
self.is_psu_eeprom = is_psu
self.is_fan_eeprom = is_fan
self.is_sys_eeprom = not (is_psu | is_fan)
self.is_fantray_eeprom = is_fantray
self.is_sys_eeprom = not (is_psu | is_fantray)

if self.is_sys_eeprom:
self.start_offset = 0
Expand All @@ -71,10 +71,10 @@ def __init__(self, is_psu=False, psu_index=0, is_fan=False, fan_index=0):
+ "i2c-1/1-005{}/eeprom".format(2 - self.index)
self.format = psu_eeprom_format
else:
self.index = fan_index
self.index = fantray_index
self.eeprom_path = self.I2C_DIR \
+ "i2c-11/11-005{}/eeprom".format(4 - self.index)
self.format = fan_eeprom_format
self.format = fantray_eeprom_format
EepromDecoder.__init__(self, self.eeprom_path, self.format,
self.start_offset, '', True)
self._load_device_eeprom()
Expand Down
Loading

0 comments on commit fa89c6d

Please sign in to comment.