Skip to content

Commit

Permalink
DellEMC : Platform2.0 API Implementation [S6100, S6000, Z9100] (#3740)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArunSaravananBalachandran authored and sujinmkang committed Dec 3, 2019
1 parent 100d679 commit 343ad78
Show file tree
Hide file tree
Showing 14 changed files with 233 additions and 94 deletions.
36 changes: 23 additions & 13 deletions platform/broadcom/sonic-platform-modules-dell/common/dell_pmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self):
# 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)
Expand Down Expand Up @@ -105,7 +105,7 @@ def get_name(self):
Returns:
string: The name of the chassis
"""
return self.sys_eeprom.modelstr()
return self._eeprom.modelstr()

def get_presence(self):
"""
Expand All @@ -121,15 +121,15 @@ def get_model(self):
Returns:
string: Model/part number of chassis
"""
return self.sys_eeprom.part_number_str()
return self._eeprom.part_number_str()

def get_serial(self):
"""
Retrieves the serial number of the chassis (Service tag)
Returns:
string: Serial number of chassis
"""
return self.sys_eeprom.serial_str()
return self._eeprom.serial_str()

def get_status(self):
"""
Expand All @@ -148,7 +148,7 @@ def get_base_mac(self):
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):
"""
Expand All @@ -158,7 +158,7 @@ def get_serial_number(self):
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):
"""
Expand All @@ -170,7 +170,7 @@ def get_system_eeprom_info(self):
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):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
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)
]
Expand Down Expand Up @@ -168,11 +169,18 @@ def _load_device_eeprom(self):
else:
self.part_number = 'NA'

(valid, data) = self._get_eeprom_field("Fan Type")
if valid:
self.fan_type = data
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:
self.fan_type = 'NA'
(valid, data) = self._get_eeprom_field("Fan Type")
if valid:
self.fan_type = data
else:
self.fan_type = 'NA'

def _get_eeprom_field(self, field_name):
"""
Expand Down Expand Up @@ -204,7 +212,10 @@ def airflow_fan_type(self):
"""
Returns the airflow fan type.
"""
return int(self.fan_type.encode('hex'), 16)
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
def base_mac_addr(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
raise ImportError(str(e) + "- required module not found")


MAX_S6000_PSU_FAN_SPEED = 18000
MAX_S6000_FAN_SPEED = 19000


Expand All @@ -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/" +\
Expand All @@ -42,8 +43,13 @@ def __init__(self, fan_index, psu_fan=False):
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
Expand Down Expand Up @@ -136,6 +142,9 @@ def get_presence(self):
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
Expand All @@ -151,7 +160,10 @@ def get_model(self):
Returns:
string: Part number of Fan
"""
return self.eeprom.part_number_str()
if not self.is_psu_fan:
return self.eeprom.part_number_str()
else:
return 'NA'

def get_serial(self):
"""
Expand All @@ -161,7 +173,10 @@ def get_serial(self):
string: Serial number of Fan
"""
# Sample Serial number format "US-01234D-54321-25A-0123-A00"
return self.eeprom.serial_number_str()
if not self.is_psu_fan:
return self.eeprom.serial_number_str()
else:
return 'NA'

def get_status(self):
"""
Expand All @@ -186,8 +201,13 @@ def get_direction(self):
A string, either FAN_DIRECTION_INTAKE or
FAN_DIRECTION_EXHAUST depending on fan direction
"""
direction = {1: 'FAN_DIRECTION_INTAKE', 2: 'FAN_DIRECTION_EXHAUST'}
fan_direction = self.eeprom.airflow_fan_type()
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')

Expand Down Expand Up @@ -248,7 +268,7 @@ def set_status_led(self, color):
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'
Expand All @@ -266,6 +286,10 @@ def get_status_led(self):
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'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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")

Expand Down Expand Up @@ -46,6 +47,8 @@ def __init__(self, psu_index):
# 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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand All @@ -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"
Expand All @@ -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"
Expand Down
Loading

0 comments on commit 343ad78

Please sign in to comment.