Skip to content

Commit 3c9a7ec

Browse files
authored
[DellEMC Z9332f] Platform API 2.0 Support and bug fixing (#5958)
- Add platform infra to support 2.0 API - Bug fixing for 9332 known issues
1 parent 6d9ecbc commit 3c9a7ec

File tree

20 files changed

+2630
-33
lines changed

20 files changed

+2630
-33
lines changed

platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,29 @@
2323
# IPMI FRU Device Commands
2424
Cmd_ReadFRUData = 0x11
2525

26+
def get_ipmitool_raw_output(args):
27+
"""
28+
Returns a list the elements of which are the individual bytes of
29+
ipmitool raw <cmd> command output.
30+
"""
31+
result_bytes = list()
32+
result = ""
33+
command = "ipmitool raw {}".format(args)
34+
try:
35+
proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE,
36+
stderr=subprocess.STDOUT)
37+
stdout = proc.communicate()[0]
38+
proc.wait()
39+
if not proc.returncode:
40+
result = stdout.rstrip('\n')
41+
except:
42+
pass
43+
44+
for i in result.split():
45+
result_bytes.append(int(i, 16))
46+
47+
return result_bytes
48+
2649
class IpmiSensor(object):
2750

2851
# Sensor Threshold types and their respective bit masks
@@ -39,29 +62,6 @@ def __init__(self, sensor_id, is_discrete=False):
3962
self.id = sensor_id
4063
self.is_discrete = is_discrete
4164

42-
def _get_ipmitool_raw_output(self, args):
43-
"""
44-
Returns a list the elements of which are the individual bytes of
45-
ipmitool raw <cmd> command output.
46-
"""
47-
result_bytes = list()
48-
result = ""
49-
command = "ipmitool raw {}".format(args)
50-
try:
51-
proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE,
52-
stderr=subprocess.STDOUT)
53-
stdout = proc.communicate()[0]
54-
proc.wait()
55-
if not proc.returncode:
56-
result = stdout.decode('utf-8').rstrip('\n')
57-
except:
58-
pass
59-
60-
for i in result.split():
61-
result_bytes.append(int(i, 16))
62-
63-
return result_bytes
64-
6565
def _get_converted_sensor_reading(self, raw_value):
6666
"""
6767
Returns a 2 element tuple(bool, int) in which first element
@@ -72,7 +72,7 @@ def _get_converted_sensor_reading(self, raw_value):
7272
cmd_args = "{} {} {} {}".format(NetFn_SensorEvent,
7373
Cmd_GetSensorReadingFactors,
7474
self.id, raw_value)
75-
factors = self._get_ipmitool_raw_output(cmd_args)
75+
factors = get_ipmitool_raw_output(cmd_args)
7676

7777
if len(factors) != 7:
7878
return False, 0
@@ -107,7 +107,7 @@ def get_reading(self):
107107
# Get Sensor Reading
108108
cmd_args = "{} {} {}".format(NetFn_SensorEvent, Cmd_GetSensorReading,
109109
self.id)
110-
output = self._get_ipmitool_raw_output(cmd_args)
110+
output = get_ipmitool_raw_output(cmd_args)
111111
if len(output) != 4:
112112
return False, 0
113113

@@ -154,7 +154,7 @@ def get_threshold(self, threshold_type):
154154
# Get Sensor Threshold
155155
cmd_args = "{} {} {}".format(NetFn_SensorEvent, Cmd_GetSensorThreshold,
156156
self.id)
157-
thresholds = self._get_ipmitool_raw_output(cmd_args)
157+
thresholds = get_ipmitool_raw_output(cmd_args)
158158
if len(thresholds) != 7:
159159
return False, 0
160160

platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-z9332f.install

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ z9332f/scripts/platform_sensors.py usr/local/bin
33
z9332f/scripts/sensors usr/bin
44
z9332f/cfg/z9332f-modules.conf etc/modules-load.d
55
z9332f/systemd/platform-modules-z9332f.service etc/systemd/system
6+
z9332f/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dellemc_z9332f_d1508-r0
7+
z9332f/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-dellemc_z9332f_d1508-r0
68
common/platform_reboot usr/share/sonic/device/x86_64-dellemc_z9332f_d1508-r0
79
common/pcisysfs.py usr/bin
10+
common/fw-updater usr/local/bin
11+
common/onie_mode_set usr/local/bin

platform/broadcom/sonic-platform-modules-dell/debian/rules

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ override_dh_auto_build:
4545
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
4646
python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
4747
cd $(MOD_SRC_DIR); \
48+
elif [ $$mod = "z9332f" ]; then \
49+
cp $(COMMON_DIR)/ipmihelper.py $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
50+
cd $(MOD_SRC_DIR)/$${mod}; \
51+
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
52+
python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
53+
cd $(MOD_SRC_DIR); \
4854
fi; \
4955
echo "making man page alias $$mod -> $$mod APIs";\
5056
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
@@ -97,6 +103,11 @@ override_dh_clean:
97103
rm -f $(MOD_SRC_DIR)/$${mod}/modules/*.whl; \
98104
rm -rf $(MOD_SRC_DIR)/$${mod}/build; \
99105
rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \
106+
elif [ $$mod = "z9332f" ]; then \
107+
rm -f $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
108+
rm -f $(MOD_SRC_DIR)/$${mod}/modules/*.whl; \
109+
rm -rf $(MOD_SRC_DIR)/$${mod}/build; \
110+
rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \
100111
fi; \
101112
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \
102113
done); \

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self):
7575

7676
for port_num in range(self.PORT_START, self.PORTS_IN_BLOCK):
7777
# sfp get uses zero-indexing, but port numbers start from 1
78-
presence = self.get_sfp(port_num-1).get_presence()
78+
presence = self.get_sfp(port_num).get_presence()
7979
self._global_port_pres_dict[port_num] = '1' if presence else '0'
8080

8181
def __del__(self):
@@ -99,7 +99,7 @@ def get_change_event(self, timeout=0):
9999
while True:
100100
time.sleep(0.5)
101101
for port_num in range(self.PORT_START, (self.PORT_END + 1)):
102-
presence = self.get_sfp(port_num-1).get_presence()
102+
presence = self.get_sfp(port_num).get_presence()
103103
if(presence and self._global_port_pres_dict[port_num] == '0'):
104104
self._global_port_pres_dict[port_num] = '1'
105105
port_dict[port_num] = '1'
@@ -134,10 +134,10 @@ def get_sfp(self, index):
134134

135135
try:
136136
# The index will start from 0
137-
sfp = self._sfp_list[index]
137+
sfp = self._sfp_list[index-1]
138138
except IndexError:
139139
sys.stderr.write("SFP index {} out of range (0-{})\n".format(
140-
index, len(self._sfp_list)-1))
140+
index, len(self._sfp_list)))
141141
return sfp
142142

143143
def get_name(self):

platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/fan_drawer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22

33
########################################################################
4-
# DellEMC S5232F
4+
# DellEMC Z9332F
55
#
66
# Module contains an implementation of SONiC Platform Base API and
77
# provides the Fan-Drawers' information available in the platform.
@@ -14,7 +14,7 @@
1414
except ImportError as e:
1515
raise ImportError(str(e) + "- required module not found")
1616

17-
S5232F_FANS_PER_FANTRAY = 2
17+
Z9332F_FANS_PER_FANTRAY = 2
1818

1919

2020
class FanDrawer(FanDrawerBase):
@@ -25,7 +25,7 @@ def __init__(self, fantray_index):
2525
FanDrawerBase.__init__(self)
2626
# FanTray is 1-based in DellEMC platforms
2727
self.fantrayindex = fantray_index + 1
28-
for i in range(S5232F_FANS_PER_FANTRAY):
28+
for i in range(Z9332F_FANS_PER_FANTRAY):
2929
self._fan_list.append(Fan(fantray_index, i))
3030

3131
def get_name(self):

platform/broadcom/sonic-platform-modules-dell/z9332f/scripts/z9332f_platform.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,29 @@ platform_firmware_versions() {
145145
ver=`/usr/sbin/i2cget -y 4 0x31 0x0`
146146
echo "Switch CPLD 2: $((ver))" >> $FIRMWARE_VERSION_FILE
147147
}
148+
149+
install_python_api_package() {
150+
device="/usr/share/sonic/device"
151+
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
152+
153+
rv=$(pip install $device/$platform/sonic_platform-1.0-py2-none-any.whl)
154+
rv=$(pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl)
155+
}
156+
157+
remove_python_api_package() {
158+
rv=$(pip show sonic-platform > /dev/null 2>/dev/null)
159+
if [ $? -eq 0 ]; then
160+
rv=$(pip uninstall -y sonic-platform > /dev/null 2>/dev/null)
161+
fi
162+
163+
rv=$(pip3 show sonic-platform > /dev/null 2>/dev/null)
164+
if [ $? -eq 0 ]; then
165+
rv=$(pip3 uninstall -y sonic-platform > /dev/null 2>/dev/null)
166+
fi
167+
}
168+
169+
170+
148171
init_devnum
149172

150173
if [ "$1" == "init" ]; then
@@ -160,6 +183,7 @@ if [ "$1" == "init" ]; then
160183
switch_board_qsfp "new_device"
161184
switch_board_sfp "new_device"
162185
switch_board_led_default
186+
install_python_api_package
163187
# /usr/bin/qsfp_irq_enable.py
164188
platform_firmware_versions
165189

@@ -174,6 +198,7 @@ elif [ "$1" == "deinit" ]; then
174198
modprobe -r cls-i2c-ocore
175199
modprobe -r cls-switchboard
176200
modprobe -r mc24lc64t
201+
remove_python_api_package
177202
else
178203
echo "z9332f_platform : Invalid option !"
179204
fi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../s6100/setup.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__all__ = ["platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer"]

0 commit comments

Comments
 (0)