Skip to content

Commit 939de3d

Browse files
ArunSaravananBalachandranabdosi
authored andcommitted
DellEMC : Platform2.0 API Implementation [S6100, S6000, Z9100] (#3740)
1 parent a943e6c commit 939de3d

File tree

14 files changed

+233
-94
lines changed

14 files changed

+233
-94
lines changed

platform/broadcom/sonic-platform-modules-dell/common/dell_pmc.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static ssize_t show_fan(struct device *dev,
631631
ret = smf_read_reg16(data, PSU_2_FAN_SPEED);
632632
break;
633633
case 12:
634-
ret = ~smf_read_reg(data, FAN_TRAY_PRESENCE);
634+
ret = (~smf_read_reg(data, FAN_TRAY_PRESENCE) & 0xff);
635635
export_hex = 1;
636636
break;
637637

@@ -682,14 +682,26 @@ static ssize_t show_fan_alarm(struct device *dev,
682682
struct smf_data *data = dev_get_drvdata(dev);
683683
int ret, psu_fan_status=0;
684684

685-
if(index < 2)
686-
psu_fan_status = smf_read_reg(data, FAN_STATUS_GROUP_B);
685+
if (data->kind == z9100smf) {
686+
if ((index % 2) == 0)
687+
index = index / 2;
688+
else
689+
index = (index / 2) + 5;
690+
}
691+
692+
if (data->kind == s6100smf)
693+
index = index / 2;
694+
695+
if (index > 7) {
696+
psu_fan_status = ~smf_read_reg(data, FAN_STATUS_GROUP_A);
697+
index = index % 8;
698+
} else
699+
psu_fan_status = ~smf_read_reg(data, FAN_STATUS_GROUP_B);
687700

688701
if (psu_fan_status & (1 << (index)))
689702
ret=0;
690-
691-
if (ret < 0)
692-
return ret;
703+
else
704+
ret=1;
693705

694706
return sprintf(buf, "%d\n", ret);
695707
}
@@ -726,12 +738,12 @@ static ssize_t show_psu_fan(struct device *dev,
726738

727739
if (index < FAN_601_FAULT){
728740
fan_status = smf_read_reg(data, PSU_1_FAN_STATUS);
729-
ret = fan_status & (1 << index);
741+
ret = (fan_status >> index) & 1;
730742

731743
}
732744
else{
733745
fan_status = smf_read_reg(data, PSU_2_FAN_STATUS);
734-
ret = fan_status & (1 << (index - 3));
746+
ret = (fan_status >> (index - 3)) & 1;
735747
}
736748

737749
if (ret < 0)
@@ -1319,17 +1331,15 @@ static ssize_t show_current(struct device *dev,
13191331
else
13201332
ret = smf_read_reg16(data, SWITCH_CURRENT_Z9100 + index * 2);
13211333
else if (index < CURR602_INPUT)
1322-
curr = smf_read_reg16(data, PSU_1_INPUT_CURRENT + (index % 4) * 2);
1334+
ret = smf_read_reg16(data, PSU_1_INPUT_CURRENT + (index % 2) * 2);
13231335
else
1324-
curr = smf_read_reg16(data, PSU_2_INPUT_CURRENT + (index % 4) * 2);
1336+
ret = smf_read_reg16(data, PSU_2_INPUT_CURRENT + (index % 4) * 2);
13251337

13261338

13271339
if (ret < 0)
13281340
return ret;
13291341

1330-
/* TODO: docs say 10mA, value look like A? */
1331-
if(index < 2)
1332-
curr = ret*1000;
1342+
curr = ret*10;
13331343

13341344
return sprintf(buf, "%d\n", curr);
13351345
}

platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self):
6565
# Get Transceiver status
6666
self.modprs_register = self._get_transceiver_status()
6767

68-
self.sys_eeprom = Eeprom()
68+
self._eeprom = Eeprom()
6969
for i in range(MAX_S6000_FAN):
7070
fan = Fan(i)
7171
self._fan_list.append(fan)
@@ -105,7 +105,7 @@ def get_name(self):
105105
Returns:
106106
string: The name of the chassis
107107
"""
108-
return self.sys_eeprom.modelstr()
108+
return self._eeprom.modelstr()
109109

110110
def get_presence(self):
111111
"""
@@ -121,15 +121,15 @@ def get_model(self):
121121
Returns:
122122
string: Model/part number of chassis
123123
"""
124-
return self.sys_eeprom.part_number_str()
124+
return self._eeprom.part_number_str()
125125

126126
def get_serial(self):
127127
"""
128128
Retrieves the serial number of the chassis (Service tag)
129129
Returns:
130130
string: Serial number of chassis
131131
"""
132-
return self.sys_eeprom.serial_str()
132+
return self._eeprom.serial_str()
133133

134134
def get_status(self):
135135
"""
@@ -148,7 +148,7 @@ def get_base_mac(self):
148148
A string containing the MAC address in the format
149149
'XX:XX:XX:XX:XX:XX'
150150
"""
151-
return self.sys_eeprom.base_mac_addr()
151+
return self._eeprom.base_mac_addr()
152152

153153
def get_serial_number(self):
154154
"""
@@ -158,7 +158,7 @@ def get_serial_number(self):
158158
A string containing the hardware serial number for this
159159
chassis.
160160
"""
161-
return self.sys_eeprom.serial_number_str()
161+
return self._eeprom.serial_number_str()
162162

163163
def get_system_eeprom_info(self):
164164
"""
@@ -170,7 +170,7 @@ def get_system_eeprom_info(self):
170170
OCP ONIE TlvInfo EEPROM format and values are their
171171
corresponding values.
172172
"""
173-
return self.sys_eeprom.system_eeprom_info()
173+
return self._eeprom.system_eeprom_info()
174174

175175
def get_reboot_cause(self):
176176
"""

platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/eeprom.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@
2828
psu_eeprom_format = [
2929
('PPID', 's', 20), ('DPN Rev', 's', 3), ('Service Tag', 's', 7),
3030
('Part Number', 's', 10), ('Part Num Revision', 's', 3),
31-
('Mfg Test', 's', 2), ('PSU Type', 's', 1), ('Fab Rev', 's', 2)
31+
('Mfg Test', 's', 2), ('Redundant copy', 's', 83), ('PSU Type', 's', 1),
32+
('Fab Rev', 's', 2)
3233
]
3334

3435
# Fan eeprom fields in format required by EepromDecoder
3536
fan_eeprom_format = [
3637
('PPID', 's', 20), ('DPN Rev', 's', 3), ('Service Tag', 's', 7),
3738
('Part Number', 's', 10), ('Part Num Revision', 's', 3),
38-
('Mfg Test', 's', 2), ('Redundant copy', 's', 82),
39+
('Mfg Test', 's', 2), ('Redundant copy', 's', 83),
3940
('Number of Fans', 's', 1), ('Fan Type', 's', 1),
4041
('Fab Rev', 's', 2)
4142
]
@@ -168,11 +169,18 @@ def _load_device_eeprom(self):
168169
else:
169170
self.part_number = 'NA'
170171

171-
(valid, data) = self._get_eeprom_field("Fan Type")
172-
if valid:
173-
self.fan_type = data
172+
if self.is_psu_eeprom:
173+
(valid, data) = self._get_eeprom_field("PSU Type")
174+
if valid:
175+
self.psu_type = data
176+
else:
177+
self.psu_type = 'NA'
174178
else:
175-
self.fan_type = 'NA'
179+
(valid, data) = self._get_eeprom_field("Fan Type")
180+
if valid:
181+
self.fan_type = data
182+
else:
183+
self.fan_type = 'NA'
176184

177185
def _get_eeprom_field(self, field_name):
178186
"""
@@ -204,7 +212,10 @@ def airflow_fan_type(self):
204212
"""
205213
Returns the airflow fan type.
206214
"""
207-
return int(self.fan_type.encode('hex'), 16)
215+
if self.is_psu_eeprom:
216+
return int(self.psu_type.encode('hex'), 16)
217+
else:
218+
return int(self.fan_type.encode('hex'), 16)
208219

209220
# System EEPROM specific methods
210221
def base_mac_addr(self):

platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan.py

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
raise ImportError(str(e) + "- required module not found")
1818

1919

20+
MAX_S6000_PSU_FAN_SPEED = 18000
2021
MAX_S6000_FAN_SPEED = 19000
2122

2223

@@ -26,12 +27,12 @@ class Fan(FanBase):
2627
CPLD_DIR = "/sys/devices/platform/dell-s6000-cpld.0/"
2728
I2C_DIR = "/sys/class/i2c-adapter/"
2829

29-
def __init__(self, fan_index, psu_fan=False):
30-
# Fan is 1-based in DellEMC platforms
31-
self.index = fan_index + 1
30+
def __init__(self, fan_index, psu_fan=False, dependency=None):
3231
self.is_psu_fan = psu_fan
3332

3433
if not self.is_psu_fan:
34+
# Fan is 1-based in DellEMC platforms
35+
self.index = fan_index + 1
3536
self.fan_presence_reg = "fan_prs"
3637
self.fan_led_reg = "fan{}_led".format(fan_index)
3738
self.get_fan_speed_reg = self.I2C_DIR + "i2c-11/11-0029/" +\
@@ -42,8 +43,13 @@ def __init__(self, fan_index, psu_fan=False):
4243
self.max_fan_speed = MAX_S6000_FAN_SPEED
4344
self.supported_led_color = ['off', 'green', 'amber']
4445
else:
45-
self.get_fan_speed_reg = self.I2C_DIR + "i2c-1/1-005{}/" +\
46-
"fan1_input".format(10 - self.index)
46+
self.index = fan_index
47+
self.dependency = dependency
48+
self.get_fan_speed_reg = self.I2C_DIR +\
49+
"i2c-1/1-005{}/fan1_target".format(10 - self.index)
50+
self.set_fan_speed_reg = self.I2C_DIR +\
51+
"i2c-1/1-005{}/fan1_target".format(10 - self.index)
52+
self.max_fan_speed = MAX_S6000_PSU_FAN_SPEED
4753

4854
def _get_cpld_register(self, reg_name):
4955
# On successful read, returns the value read from given
@@ -136,6 +142,9 @@ def get_presence(self):
136142
bool: True if Fan is present, False if not
137143
"""
138144
status = False
145+
if self.is_psu_fan:
146+
return self.dependency.get_presence()
147+
139148
fan_presence = self._get_cpld_register(self.fan_presence_reg)
140149
if (fan_presence != 'ERR'):
141150
fan_presence = int(fan_presence,16) & self.index
@@ -151,7 +160,10 @@ def get_model(self):
151160
Returns:
152161
string: Part number of Fan
153162
"""
154-
return self.eeprom.part_number_str()
163+
if not self.is_psu_fan:
164+
return self.eeprom.part_number_str()
165+
else:
166+
return 'NA'
155167

156168
def get_serial(self):
157169
"""
@@ -161,7 +173,10 @@ def get_serial(self):
161173
string: Serial number of Fan
162174
"""
163175
# Sample Serial number format "US-01234D-54321-25A-0123-A00"
164-
return self.eeprom.serial_number_str()
176+
if not self.is_psu_fan:
177+
return self.eeprom.serial_number_str()
178+
else:
179+
return 'NA'
165180

166181
def get_status(self):
167182
"""
@@ -186,8 +201,13 @@ def get_direction(self):
186201
A string, either FAN_DIRECTION_INTAKE or
187202
FAN_DIRECTION_EXHAUST depending on fan direction
188203
"""
189-
direction = {1: 'FAN_DIRECTION_INTAKE', 2: 'FAN_DIRECTION_EXHAUST'}
190-
fan_direction = self.eeprom.airflow_fan_type()
204+
if self.is_psu_fan:
205+
direction = {1: 'FAN_DIRECTION_EXHAUST', 2: 'FAN_DIRECTION_INTAKE',
206+
3: 'FAN_DIRECTION_EXHAUST', 4: 'FAN_DIRECTION_INTAKE'}
207+
fan_direction = self.dependency.eeprom.airflow_fan_type()
208+
else:
209+
direction = {1: 'FAN_DIRECTION_EXHAUST', 2: 'FAN_DIRECTION_INTAKE'}
210+
fan_direction = self.eeprom.airflow_fan_type()
191211

192212
return direction.get(fan_direction,'NA')
193213

@@ -248,7 +268,7 @@ def set_status_led(self, color):
248268
Returns:
249269
bool: True if set success, False if fail.
250270
"""
251-
if color not in self.supported_led_color:
271+
if self.is_psu_fan or (color not in self.supported_led_color):
252272
return False
253273
if(color == self.STATUS_LED_COLOR_AMBER):
254274
color = 'yellow'
@@ -266,6 +286,10 @@ def get_status_led(self):
266286
Returns:
267287
A string, one of the predefined STATUS_LED_COLOR_* strings.
268288
"""
289+
if self.is_psu_fan:
290+
# No LED available for PSU Fan
291+
return None
292+
269293
fan_led = self._get_cpld_register(self.fan_led_reg)
270294
if (fan_led != 'ERR'):
271295
if (fan_led == 'yellow'):

platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/psu.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import os
1414
from sonic_platform_base.psu_base import PsuBase
1515
from sonic_platform.eeprom import Eeprom
16+
from sonic_platform.fan import Fan
1617
except ImportError as e:
1718
raise ImportError(str(e) + "- required module not found")
1819

@@ -46,6 +47,8 @@ def __init__(self, psu_index):
4647
# make it unique per Psu object
4748
self._fan_list = []
4849

50+
self._fan_list.append(Fan(self.index, psu_fan=True, dependency=self))
51+
4952
def _get_cpld_register(self, reg_name):
5053
# On successful read, returns the value read from given
5154
# reg_name and on failure returns 'ERR'

platform/broadcom/sonic-platform-modules-dell/s6100/scripts/platform_sensors.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ def print_psu(psu):
255255
psu_fan_present = int(get_pmc_register('fan11_fault'))
256256
input_voltage = float(get_pmc_register('in29_input')) / 1000
257257
output_voltage = float(get_pmc_register('in30_input')) / 1000
258-
input_current = float(get_pmc_register('curr601_input')) / 100
259-
output_current = float(get_pmc_register('curr602_input')) / 100
258+
input_current = float(get_pmc_register('curr601_input')) / 1000
259+
output_current = float(get_pmc_register('curr602_input')) / 1000
260260
input_power = float(get_pmc_register('power1_input')) / 1000000
261261
output_power = float(get_pmc_register('power2_input')) / 1000000
262262
if (input_power != 0):
@@ -268,8 +268,8 @@ def print_psu(psu):
268268
psu_fan_present = int(get_pmc_register('fan12_fault'))
269269
input_voltage = float(get_pmc_register('in31_input')) / 1000
270270
output_voltage = float(get_pmc_register('in32_input')) / 1000
271-
input_current = float(get_pmc_register('curr701_input')) / 100
272-
output_current = float(get_pmc_register('curr702_input')) / 100
271+
input_current = float(get_pmc_register('curr701_input')) / 1000
272+
output_current = float(get_pmc_register('curr702_input')) / 1000
273273
input_power = float(get_pmc_register('power3_input')) / 1000000
274274
output_power = float(get_pmc_register('power4_input')) / 1000000
275275
if (input_power != 0):

platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,26 @@ sys_eeprom() {
5454
esac
5555
}
5656

57+
#Attach/Detach eeprom on each IOM
58+
switch_board_eeprom() {
59+
case $1 in
60+
"new_device")
61+
for ((i=14;i<=17;i++));
62+
do
63+
i2c_config "echo 24c02 0x50 > /sys/bus/i2c/devices/i2c-$i/$1"
64+
done
65+
;;
66+
"delete_device")
67+
for ((i=14;i<=17;i++));
68+
do
69+
i2c_config "echo 0x50 > /sys/bus/i2c/devices/i2c-$i/$1"
70+
done
71+
;;
72+
*) echo "s6100_platform: switch_board_eeprom : invalid command !"
73+
;;
74+
esac
75+
}
76+
5777
#Attach/Detach CPLD devices to drivers for each IOM
5878
switch_board_cpld() {
5979
case $1 in
@@ -245,7 +265,7 @@ install_python_api_package() {
245265
remove_python_api_package() {
246266
rv=$(pip show sonic-platform > /dev/null 2>/dev/null)
247267
if [ $? -eq 0 ]; then
248-
rv = $(pip uninstall -y sonic-platform > /dev/null 2>/dev/null)
268+
rv=$(pip uninstall -y sonic-platform > /dev/null 2>/dev/null)
249269
fi
250270
}
251271

@@ -267,6 +287,7 @@ if [[ "$1" == "init" ]]; then
267287
cpu_board_mux "new_device"
268288
switch_board_mux "new_device"
269289
sys_eeprom "new_device"
290+
switch_board_eeprom "new_device"
270291
switch_board_cpld "new_device"
271292
switch_board_qsfp_mux "new_device"
272293
switch_board_sfp "new_device"
@@ -280,6 +301,7 @@ elif [[ "$1" == "deinit" ]]; then
280301
xcvr_presence_interrupts "disable"
281302
switch_board_sfp "delete_device"
282303
switch_board_cpld "delete_device"
304+
switch_board_eeprom "delete_device"
283305
switch_board_mux "delete_device"
284306
sys_eeprom "delete_device"
285307
switch_board_qsfp "delete_device"

0 commit comments

Comments
 (0)