Skip to content

Commit 318e5ea

Browse files
committed
[Author]:[email protected] [Jira ID]:N/A [Description]: update code to be compatiable BRCM PDDF update
1 parent 273d24a commit 318e5ea

File tree

9 files changed

+10
-159
lines changed

9 files changed

+10
-159
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
CONSOLE_PORT=0x3f8
22
CONSOLE_DEV=0
33
CONSOLE_SPEED=9600
4-
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog"
4+
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off module_blacklist=gpio_ich crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog"

platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None):
3030
vendor_ext = self._eeprom.vendor_ext_str()
3131
with open(FAN_DIRECTION_FILE_PATH, "w+") as f:
3232
f.write(vendor_ext)
33-
for i in range(self.platform_inventory['num_fantrays']):
34-
fandrawer = FanDrawer(i, self.pddf_obj, self.plugin_data) #lgtm [py/call/wrong-number-class-arguments]
35-
self._fan_drawer_list.append(fandrawer)
36-
self._fan_list.extend(fandrawer._fan_list)
33+
3734
self.__initialize_components()
3835

3936
def __initialize_components(self):

platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py

+1-56
Original file line numberDiff line numberDiff line change
@@ -6,63 +6,8 @@
66

77
class Eeprom(PddfEeprom):
88

9-
_TLV_DISPLAY_VENDOR_EXT = True
10-
_TLV_INFO_MAX_LEN = 256
11-
pddf_obj = {}
12-
plugin_data = {}
13-
149
def __init__(self, pddf_data=None, pddf_plugin_data=None):
15-
if not pddf_data or not pddf_plugin_data:
16-
raise ValueError('PDDF JSON data error')
17-
18-
self.pddf_obj = pddf_data
19-
self.plugin_data = pddf_plugin_data
20-
21-
# system EEPROM always has device name EEPROM1
22-
self.eeprom_path = self.pddf_obj.get_path("EEPROM1", "eeprom")
23-
if self.eeprom_path is None:
24-
return
25-
26-
super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True)
27-
#super().__init__(self.pddf_obj, self.plugin_data)
28-
self.eeprom_tlv_dict = dict()
29-
try:
30-
self.eeprom_data = self.read_eeprom()
31-
except Exception as e:
32-
self.eeprom_data = "N/A"
33-
raise RuntimeError("PddfEeprom is not Programmed - Error: {}".format(str(e)))
34-
else:
35-
eeprom = self.eeprom_data
36-
37-
if not self.is_valid_tlvinfo_header(eeprom):
38-
return
39-
40-
total_length = ((eeprom[9]) << 8) | (eeprom[10])
41-
tlv_index = self._TLV_INFO_HDR_LEN
42-
tlv_end = self._TLV_INFO_HDR_LEN + total_length
43-
44-
while (tlv_index + 2) < self._TLV_INFO_MAX_LEN and tlv_index < tlv_end:
45-
if not self.is_valid_tlv(eeprom[tlv_index:]):
46-
break
47-
48-
tlv = eeprom[tlv_index:tlv_index + 2
49-
+ (eeprom[tlv_index + 1])]
50-
code = "0x%02X" % ((tlv[0]))
51-
52-
if (tlv[0]) == self._TLV_CODE_VENDOR_EXT:
53-
name = "Vendor Extension" #lgtm [py/multiple-definition]
54-
value = ""
55-
if self._TLV_DISPLAY_VENDOR_EXT:
56-
for c in tlv[2:2 + tlv[1]]:
57-
value += "0x%02X " % c
58-
else:
59-
name, value = self.decoder(None, tlv)
60-
61-
self.eeprom_tlv_dict[code] = value
62-
if (eeprom[tlv_index]) == self._TLV_CODE_CRC_32:
63-
break
64-
65-
tlv_index += (eeprom[tlv_index+1]) + 2
10+
PddfEeprom.__init__(self, pddf_data, pddf_plugin_data)
6611

6712
def vendor_ext_str(self):
6813
"""

platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py

+1-70
Original file line numberDiff line numberDiff line change
@@ -6,79 +6,10 @@
66
#############################################################################
77

88
try:
9-
from sonic_platform_base.fan_drawer_base import FanDrawerBase
10-
from sonic_platform.fan import Fan
9+
from sonic_platform_pddf_base.pddf_fan_drawer import PddfFanDrawer
1110
except ImportError as e:
1211
raise ImportError(str(e) + "- required module not found")
1312

14-
15-
class PddfFanDrawer(FanDrawerBase):
16-
"""PDDF generic Fan Drawer class"""
17-
18-
pddf_obj = {}
19-
plugin_data = {}
20-
21-
def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None):
22-
FanDrawerBase.__init__(self)
23-
if not pddf_data or not pddf_plugin_data:
24-
raise ValueError('PDDF JSON data error')
25-
26-
self.pddf_obj = pddf_data
27-
self.plugin_data = pddf_plugin_data
28-
self.platform = self.pddf_obj.get_platform()
29-
30-
if tray_idx < 0 or tray_idx >= self.platform['num_fantrays']:
31-
print("Invalid fantray index %d\n" % tray_idx)
32-
return
33-
34-
self.fantray_index = tray_idx+1
35-
for j in range(self.platform['num_fans_pertray']):
36-
# Fan index is 0-based for the init call
37-
self._fan_list.append(Fan(tray_idx, j, self.pddf_obj, self.plugin_data)) #lgtm [py/call/wrong-number-class-arguments]
38-
39-
def get_name(self):
40-
"""
41-
Retrieves the fan drawer name
42-
Returns: String containing fan-drawer name
43-
"""
44-
return "Fantray{0}".format(self.fantray_index)
45-
46-
def get_presence(self):
47-
status = False
48-
# Usually if a tray is removed, all the fans inside it are absent
49-
if self._fan_list:
50-
status = self._fan_list[0].get_presence()
51-
52-
return status
53-
54-
def get_status(self):
55-
status = False
56-
# if all the fans are working fine, then tray status should be okay
57-
if self._fan_list:
58-
status = all(fan.get_status() == True for fan in self._fan_list)
59-
60-
return status
61-
62-
def is_replaceable(self):
63-
"""
64-
Indicate whether this device is replaceable.
65-
Returns:
66-
bool: True if it is replaceable.
67-
"""
68-
# Usually Fantrays are replaceable
69-
return False
70-
71-
def get_position_in_parent(self):
72-
"""
73-
Retrieves 1-based relative physical position in parent device.
74-
Returns:
75-
integer: The 1-based relative physical position in parent
76-
device or -1 if cannot determine the position
77-
"""
78-
return self.fantray_index
79-
80-
81-
8213
class FanDrawer(PddfFanDrawer):
8314
"""PDDF Platform-Specific Fan-Drawer class"""
8415

platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py

-26
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,10 @@
66
#############################################################################
77

88
try:
9-
import json
10-
# from . import pddfapi
11-
# from sonic_platform_base.platform_base import PlatformBase
129
from sonic_platform_pddf_base.pddf_platform import PddfPlatform
13-
from sonic_platform.chassis import Chassis
1410
except ImportError as e:
1511
raise ImportError(str(e) + "- required module not found")
1612

17-
18-
#class PddfPlatform(PlatformBase):
19-
# """
20-
# PDDF Generic Platform class
21-
# """
22-
# pddf_obj = {}
23-
# pddf_plugin_data = {}
24-
#
25-
# def __init__(self):
26-
# Initialize the JSON data
27-
28-
# self.pddf_data = pddfapi.PddfApi()
29-
# with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd:
30-
# self.pddf_plugin_data = json.load(pd)
31-
#
32-
# if not self.pddf_data or not self.pddf_plugin_data:
33-
# print("Error: PDDF JSON data is not loaded properly ... Exiting")
34-
# raise ValueError
35-
36-
# PlatformBase.__init__(self)
37-
# self._chassis = Chassis(self.pddf_data, self.pddf_plugin_data)
38-
3913
class Platform(PddfPlatform):
4014
"""
4115
PDDF Platform-Specific Platform Class

platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
class Thermal(PddfThermal):
99
"""PDDF Platform-Specific Thermal class"""
1010

11-
def __init__(self, index, pddf_data=None, pddf_plugin_data=None):
12-
PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data)
11+
def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0):
12+
PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index)
1313
self.minimum_thermal = self.get_temperature()
1414
self.maximum_thermal = self.get_temperature()
1515
# Provide the functions/variables below for which implementation is to be overwritten

platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
try:
88
from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase
9+
import time
910
except ImportError as e:
1011
raise ImportError(str(e) + "- required module not found")
1112

platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
try:
1515
from sonic_platform_base.thermal_base import ThermalBase
16+
import time
1617
except ImportError as e:
1718
raise ImportError(str(e) + "- required module not found")
1819

platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def get_platform_and_hwsku(self):
5050
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY],
5151
stdout=subprocess.PIPE,
5252
shell=False,
53+
universal_newlines=True,
5354
stderr=subprocess.STDOUT)
5455
stdout = proc.communicate()[0]
5556
proc.wait()
@@ -58,6 +59,7 @@ def get_platform_and_hwsku(self):
5859
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY],
5960
stdout=subprocess.PIPE,
6061
shell=False,
62+
universal_newlines=True,
6163
stderr=subprocess.STDOUT)
6264
stdout = proc.communicate()[0]
6365
proc.wait()

0 commit comments

Comments
 (0)