Skip to content

Commit

Permalink
[Author]:jersyang@celestica.com [Jira ID]:N/A [Description]: update c…
Browse files Browse the repository at this point in the history
…ode to be compatiable BRCM PDDF update
  • Loading branch information
nicwu-cel committed Apr 25, 2022
1 parent 273d24a commit 318e5ea
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 159 deletions.
2 changes: 1 addition & 1 deletion device/celestica/x86_64-cel_belgite-r0/installer.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CONSOLE_PORT=0x3f8
CONSOLE_DEV=0
CONSOLE_SPEED=9600
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog"
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"
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None):
vendor_ext = self._eeprom.vendor_ext_str()
with open(FAN_DIRECTION_FILE_PATH, "w+") as f:
f.write(vendor_ext)
for i in range(self.platform_inventory['num_fantrays']):
fandrawer = FanDrawer(i, self.pddf_obj, self.plugin_data) #lgtm [py/call/wrong-number-class-arguments]
self._fan_drawer_list.append(fandrawer)
self._fan_list.extend(fandrawer._fan_list)

self.__initialize_components()

def __initialize_components(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,8 @@

class Eeprom(PddfEeprom):

_TLV_DISPLAY_VENDOR_EXT = True
_TLV_INFO_MAX_LEN = 256
pddf_obj = {}
plugin_data = {}

def __init__(self, pddf_data=None, pddf_plugin_data=None):
if not pddf_data or not pddf_plugin_data:
raise ValueError('PDDF JSON data error')

self.pddf_obj = pddf_data
self.plugin_data = pddf_plugin_data

# system EEPROM always has device name EEPROM1
self.eeprom_path = self.pddf_obj.get_path("EEPROM1", "eeprom")
if self.eeprom_path is None:
return

super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True)
#super().__init__(self.pddf_obj, self.plugin_data)
self.eeprom_tlv_dict = dict()
try:
self.eeprom_data = self.read_eeprom()
except Exception as e:
self.eeprom_data = "N/A"
raise RuntimeError("PddfEeprom is not Programmed - Error: {}".format(str(e)))
else:
eeprom = self.eeprom_data

if not self.is_valid_tlvinfo_header(eeprom):
return

total_length = ((eeprom[9]) << 8) | (eeprom[10])
tlv_index = self._TLV_INFO_HDR_LEN
tlv_end = self._TLV_INFO_HDR_LEN + total_length

while (tlv_index + 2) < self._TLV_INFO_MAX_LEN and tlv_index < tlv_end:
if not self.is_valid_tlv(eeprom[tlv_index:]):
break

tlv = eeprom[tlv_index:tlv_index + 2
+ (eeprom[tlv_index + 1])]
code = "0x%02X" % ((tlv[0]))

if (tlv[0]) == self._TLV_CODE_VENDOR_EXT:
name = "Vendor Extension" #lgtm [py/multiple-definition]
value = ""
if self._TLV_DISPLAY_VENDOR_EXT:
for c in tlv[2:2 + tlv[1]]:
value += "0x%02X " % c
else:
name, value = self.decoder(None, tlv)

self.eeprom_tlv_dict[code] = value
if (eeprom[tlv_index]) == self._TLV_CODE_CRC_32:
break

tlv_index += (eeprom[tlv_index+1]) + 2
PddfEeprom.__init__(self, pddf_data, pddf_plugin_data)

def vendor_ext_str(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,79 +6,10 @@
#############################################################################

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


class PddfFanDrawer(FanDrawerBase):
"""PDDF generic Fan Drawer class"""

pddf_obj = {}
plugin_data = {}

def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None):
FanDrawerBase.__init__(self)
if not pddf_data or not pddf_plugin_data:
raise ValueError('PDDF JSON data error')

self.pddf_obj = pddf_data
self.plugin_data = pddf_plugin_data
self.platform = self.pddf_obj.get_platform()

if tray_idx < 0 or tray_idx >= self.platform['num_fantrays']:
print("Invalid fantray index %d\n" % tray_idx)
return

self.fantray_index = tray_idx+1
for j in range(self.platform['num_fans_pertray']):
# Fan index is 0-based for the init call
self._fan_list.append(Fan(tray_idx, j, self.pddf_obj, self.plugin_data)) #lgtm [py/call/wrong-number-class-arguments]

def get_name(self):
"""
Retrieves the fan drawer name
Returns: String containing fan-drawer name
"""
return "Fantray{0}".format(self.fantray_index)

def get_presence(self):
status = False
# Usually if a tray is removed, all the fans inside it are absent
if self._fan_list:
status = self._fan_list[0].get_presence()

return status

def get_status(self):
status = False
# if all the fans are working fine, then tray status should be okay
if self._fan_list:
status = all(fan.get_status() == True for fan in self._fan_list)

return status

def is_replaceable(self):
"""
Indicate whether this device is replaceable.
Returns:
bool: True if it is replaceable.
"""
# Usually Fantrays are replaceable
return False

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 self.fantray_index



class FanDrawer(PddfFanDrawer):
"""PDDF Platform-Specific Fan-Drawer class"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,10 @@
#############################################################################

try:
import json
# from . import pddfapi
# from sonic_platform_base.platform_base import PlatformBase
from sonic_platform_pddf_base.pddf_platform import PddfPlatform
from sonic_platform.chassis import Chassis
except ImportError as e:
raise ImportError(str(e) + "- required module not found")


#class PddfPlatform(PlatformBase):
# """
# PDDF Generic Platform class
# """
# pddf_obj = {}
# pddf_plugin_data = {}
#
# def __init__(self):
# Initialize the JSON data

# self.pddf_data = pddfapi.PddfApi()
# with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd:
# self.pddf_plugin_data = json.load(pd)
#
# if not self.pddf_data or not self.pddf_plugin_data:
# print("Error: PDDF JSON data is not loaded properly ... Exiting")
# raise ValueError

# PlatformBase.__init__(self)
# self._chassis = Chassis(self.pddf_data, self.pddf_plugin_data)

class Platform(PddfPlatform):
"""
PDDF Platform-Specific Platform Class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
class Thermal(PddfThermal):
"""PDDF Platform-Specific Thermal class"""

def __init__(self, index, pddf_data=None, pddf_plugin_data=None):
PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data)
def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0):
PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index)
self.minimum_thermal = self.get_temperature()
self.maximum_thermal = self.get_temperature()
# Provide the functions/variables below for which implementation is to be overwritten
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_platform_and_hwsku(self):
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY],
stdout=subprocess.PIPE,
shell=False,
universal_newlines=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
Expand All @@ -58,6 +59,7 @@ def get_platform_and_hwsku(self):
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY],
stdout=subprocess.PIPE,
shell=False,
universal_newlines=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
Expand Down

0 comments on commit 318e5ea

Please sign in to comment.