[platform/cel]: Add new API installer to pmon and base image (#3379)

* [platform/cel]: Add new api installer

* [device/celestica]: Update APIs to support both pmon and base image

* [device/e1031]: update hwmon name
This commit is contained in:
Wirut Getbamrung 2019-08-29 01:19:34 +07:00 committed by lguohan
parent 768beb79e1
commit a5b805e37a
21 changed files with 231 additions and 92 deletions

View File

@ -1,7 +1,7 @@
# Configuration file generated by pwmconfig, changes will be lost # Configuration file generated by pwmconfig, changes will be lost
INTERVAL=2 INTERVAL=2
DEVPATH=hwmon3=devices/pci0000:00/0000:00:13.0/i2c-0/i2c-8/i2c-23/23-004d hwmon2=devices/pci0000:00/0000:00:13.0/i2c-0/i2c-8/i2c-11/11-001a DEVPATH=hwmon3=devices/pci0000:00/0000:00:13.0/i2c-0/i2c-8/i2c-23/23-004d hwmon2=devices/pci0000:00/0000:00:13.0/i2c-0/i2c-8/i2c-11/11-001a
DEVNAME=hwmon3=emc2305 hwmon2=max6697 DEVNAME=hwmon3=emc2305 hwmon2=max6699
FCTEMPS=hwmon3/device/pwm1=hwmon2/temp1_input hwmon3/device/pwm2=hwmon2/temp1_input hwmon3/device/pwm4=hwmon2/temp1_input FCTEMPS=hwmon3/device/pwm1=hwmon2/temp1_input hwmon3/device/pwm2=hwmon2/temp1_input hwmon3/device/pwm4=hwmon2/temp1_input
FCFANS=hwmon3/device/pwm1=hwmon3/device/fan1_input hwmon3/device/pwm2=hwmon3/device/fan2_input hwmon3/device/pwm4=hwmon3/device/fan4_input FCFANS=hwmon3/device/pwm1=hwmon3/device/fan1_input hwmon3/device/pwm2=hwmon3/device/fan2_input hwmon3/device/pwm4=hwmon3/device/fan4_input
MINTEMP=hwmon3/device/pwm1=27 hwmon3/device/pwm2=27 hwmon3/device/pwm4=27 MINTEMP=hwmon3/device/pwm1=27 hwmon3/device/pwm2=27 hwmon3/device/pwm4=27

View File

@ -0,0 +1,2 @@
__all__ = ["platform", "chassis"]
from sonic_platform import *

View File

@ -31,8 +31,10 @@ NUM_PSU = 2
NUM_THERMAL = 7 NUM_THERMAL = 7
NUM_SFP = 52 NUM_SFP = 52
RESET_REGISTER = "0x112" RESET_REGISTER = "0x112"
REBOOT_CAUSE_PATH = "/host/reboot-cause/previous-reboot-cause.txt" HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/previous-reboot-cause.txt"
PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/previous-reboot-cause.txt"
COMPONENT_NAME_LIST = ["SMC_CPLD", "MMC_CPLD", "BIOS"] COMPONENT_NAME_LIST = ["SMC_CPLD", "MMC_CPLD", "BIOS"]
HOST_CHK_CMD = "docker > /dev/null 2>&1"
class Chassis(ChassisBase): class Chassis(ChassisBase):
@ -53,17 +55,23 @@ class Chassis(ChassisBase):
sfp = Sfp(index) sfp = Sfp(index)
self._sfp_list.append(sfp) self._sfp_list.append(sfp)
ChassisBase.__init__(self) ChassisBase.__init__(self)
self._reboot_cause_path = HOST_REBOOT_CAUSE_PATH if self.__is_host(
) else PMON_REBOOT_CAUSE_PATH
self._component_name_list = COMPONENT_NAME_LIST self._component_name_list = COMPONENT_NAME_LIST
self._watchdog = Watchdog() self._watchdog = Watchdog()
self._eeprom = Tlv() self._eeprom = Tlv()
def __is_host(self):
return os.system(HOST_CHK_CMD) == 0
def __read_txt_file(self, file_path): def __read_txt_file(self, file_path):
try: try:
with open(file_path, 'r') as fd: with open(file_path, 'r') as fd:
data = fd.read() data = fd.read()
return data.strip() return data.strip()
except IOError: except IOError:
raise IOError("Unable to open %s file !" % file_path) pass
return None
def get_base_mac(self): def get_base_mac(self):
""" """
@ -137,14 +145,15 @@ class Chassis(ChassisBase):
description = 'None' description = 'None'
reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER
hw_reboot_cause = self.component.get_register_value(RESET_REGISTER) hw_reboot_cause = self.component.get_register_value(RESET_REGISTER)
sw_reboot_cause = self.__read_txt_file(REBOOT_CAUSE_PATH) sw_reboot_cause = self.__read_txt_file(
self._reboot_cause_path) or "Unknown"
if sw_reboot_cause != "Unexpected reboot": if hw_reboot_cause == "0x55":
reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE
description = sw_reboot_cause description = sw_reboot_cause
elif hw_reboot_cause == "0x11": elif hw_reboot_cause == "0x11":
reboot_cause = self.REBOOT_CAUSE_POWER_LOSS reboot_cause = self.REBOOT_CAUSE_POWER_LOSS
elif hw_reboot_cause == "0x33" or hw_reboot_cause == "0x55": elif hw_reboot_cause == "0x33":
reboot_cause = self.REBOOT_CAUSE_WATCHDOG reboot_cause = self.REBOOT_CAUSE_WATCHDOG
else: else:
reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER

View File

@ -34,6 +34,7 @@ class Fan(FanBase):
self.index = fan_index self.index = fan_index
self.config_data = {} self.config_data = {}
self.fan_speed = 0 self.fan_speed = 0
FanBase.__init__(self)
# e1031 fan attributes # e1031 fan attributes
# Single emc2305 chip located at i2c-23-4d # Single emc2305 chip located at i2c-23-4d

View File

@ -35,6 +35,7 @@ class Sfp(SfpBase, SfpUtilBase):
} }
PRS_PATH = "/sys/devices/platform/e1031.smc/SFP/sfp_modabs" PRS_PATH = "/sys/devices/platform/e1031.smc/SFP/sfp_modabs"
PLATFORM_ROOT_PATH = '/usr/share/sonic/device' PLATFORM_ROOT_PATH = '/usr/share/sonic/device'
PMON_HWSKU_PATH = '/usr/share/sonic/hwsku'
SFP_STATUS_CONTROL_OFFSET = 110 SFP_STATUS_CONTROL_OFFSET = 110
SFP_STATUS_CONTROL_WIDTH = 1 SFP_STATUS_CONTROL_WIDTH = 1
@ -61,6 +62,9 @@ class Sfp(SfpBase, SfpUtilBase):
SFP_EEPROM_TX_PWR_KEY = "TXPower" SFP_EEPROM_TX_PWR_KEY = "TXPower"
SFP_EEPROM_TX_BS_KEY = "TXBias" SFP_EEPROM_TX_BS_KEY = "TXBias"
SFP_EEPROM_STATUS_CON_KEY = "StatusControl" SFP_EEPROM_STATUS_CON_KEY = "StatusControl"
PLATFORM = "x86_64-cel_e1031-r0"
HWSKU = "Celestica-E1031-T48S4"
HOST_CHK_CMD = "docker > /dev/null 2>&1"
@property @property
def port_start(self): def port_start(self):
@ -122,6 +126,9 @@ class Sfp(SfpBase, SfpUtilBase):
self.index = sfp_index self.index = sfp_index
self.port_num = self.index + 1 self.port_num = self.index + 1
def __is_host(self):
return os.system(self.HOST_CHK_CMD) == 0
def __get_sysfsfile_eeprom(self): def __get_sysfsfile_eeprom(self):
sysfsfile_eeprom = None sysfsfile_eeprom = None
sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[self.port_num] sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[self.port_num]
@ -129,33 +136,14 @@ class Sfp(SfpBase, SfpUtilBase):
sysfsfile_eeprom = open( sysfsfile_eeprom = open(
sysfs_sfp_i2c_client_eeprom_path, mode="r+b", buffering=0) sysfs_sfp_i2c_client_eeprom_path, mode="r+b", buffering=0)
except IOError: except IOError:
print("Error: reading sysfs file %s" % pass
sysfs_sfp_i2c_client_eeprom_path)
return sysfsfile_eeprom return sysfsfile_eeprom
def __get_path_to_port_config_file(self): def __get_path_to_port_config_file(self):
# Get platform and hwsku platform_path = "/".join([self.PLATFORM_ROOT_PATH, self.PLATFORM])
machine_info = sonic_device_util.get_machine_info() hwsku_path = "/".join([platform_path, self.HWSKU]
platform = sonic_device_util.get_platform_info(machine_info) ) if self.__is_host() else self.PMON_HWSKU_PATH
config_db = ConfigDBConnector() return "/".join([hwsku_path, "port_config.ini"])
config_db.connect()
data = config_db.get_table('DEVICE_METADATA')
try:
hwsku = data['localhost']['hwsku']
except KeyError:
hwsku = "Unknown"
# Load platform module from source
platform_path = "/".join([self.PLATFORM_ROOT_PATH, platform])
hwsku_path = "/".join([platform_path, hwsku])
# First check for the presence of the new 'port_config.ini' file
port_config_file_path = "/".join([hwsku_path, "port_config.ini"])
if not os.path.isfile(port_config_file_path):
# port_config.ini doesn't exist. Try loading the legacy 'portmap.ini' file
port_config_file_path = "/".join([hwsku_path, "portmap.ini"])
return port_config_file_path
def get_transceiver_info(self): def get_transceiver_info(self):
""" """
@ -405,7 +393,7 @@ class Sfp(SfpBase, SfpUtilBase):
""" """
transceiver_dom_info_dict = self.get_transceiver_bulk_status() transceiver_dom_info_dict = self.get_transceiver_bulk_status()
tx1_bs = transceiver_dom_info_dict.get("tx1bias", "N/A") tx1_bs = transceiver_dom_info_dict.get("tx1bias", "N/A")
return [tx1_bs, "N/A", "N/A", "N/A"] return [tx1_bs, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else []
def get_rx_power(self): def get_rx_power(self):
""" """
@ -417,7 +405,7 @@ class Sfp(SfpBase, SfpUtilBase):
""" """
transceiver_dom_info_dict = self.get_transceiver_bulk_status() transceiver_dom_info_dict = self.get_transceiver_bulk_status()
rx1_pw = transceiver_dom_info_dict.get("rx1power", "N/A") rx1_pw = transceiver_dom_info_dict.get("rx1power", "N/A")
return [rx1_pw, "N/A", "N/A", "N/A"] return [rx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else []
def get_tx_power(self): def get_tx_power(self):
""" """
@ -429,7 +417,7 @@ class Sfp(SfpBase, SfpUtilBase):
""" """
transceiver_dom_info_dict = self.get_transceiver_bulk_status() transceiver_dom_info_dict = self.get_transceiver_bulk_status()
tx1_pw = transceiver_dom_info_dict.get("tx1power", "N/A") tx1_pw = transceiver_dom_info_dict.get("tx1power", "N/A")
return [tx1_pw, "N/A", "N/A", "N/A"] return [tx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else []
def reset(self): def reset(self):
""" """
@ -452,7 +440,7 @@ class Sfp(SfpBase, SfpUtilBase):
sysfsfile_eeprom = self.__get_sysfsfile_eeprom() sysfsfile_eeprom = self.__get_sysfsfile_eeprom()
status_control_raw = self._read_eeprom_specific_bytes( status_control_raw = self._read_eeprom_specific_bytes(
sysfsfile_eeprom, self.SFP_STATUS_CONTROL_OFFSET, self.SFP_STATUS_CONTROL_WIDTH) sysfsfile_eeprom, self.SFP_STATUS_CONTROL_OFFSET, self.SFP_STATUS_CONTROL_WIDTH) if sysfsfile_eeprom else None
if status_control_raw is not None: if status_control_raw is not None:
tx_disable_bit = 0x80 if tx_disable else 0x7f tx_disable_bit = 0x80 if tx_disable else 0x7f
status_control = int(status_control_raw[0], 16) status_control = int(status_control_raw[0], 16)
@ -551,7 +539,7 @@ class Sfp(SfpBase, SfpUtilBase):
Returns: Returns:
string: Model/part number of device string: Model/part number of device
""" """
transceiver_dom_info_dict = self.get_transceiver_bulk_status() transceiver_dom_info_dict = self.get_transceiver_info()
return transceiver_dom_info_dict.get("modelname", "N/A") return transceiver_dom_info_dict.get("modelname", "N/A")
def get_serial(self): def get_serial(self):
@ -560,5 +548,5 @@ class Sfp(SfpBase, SfpUtilBase):
Returns: Returns:
string: Serial number of device string: Serial number of device
""" """
transceiver_dom_info_dict = self.get_transceiver_bulk_status() transceiver_dom_info_dict = self.get_transceiver_info()
return transceiver_dom_info_dict.get("serialnum", "N/A") return transceiver_dom_info_dict.get("serialnum", "N/A")

View File

@ -22,8 +22,8 @@ class Thermal(ThermalBase):
"""Platform-specific Thermal class""" """Platform-specific Thermal class"""
THERMAL_NAME_LIST = [] THERMAL_NAME_LIST = []
MAINBOARD_SS_PATH = "/sys/class/i2c-adapter/i2c-11/11-001a/hwmon/" MAINBOARD_SS_PATH = "/sys/class/i2c-adapter/i2c-11/11-001a/hwmon/hwmon2"
CPUBOARD_SS_PATH = "/sys/class/i2c-adapter/i2c-3/3-001a/hwmon/" CPUBOARD_SS_PATH = "/sys/class/i2c-adapter/i2c-3/3-001a/hwmon/hwmon1"
SS_CONFIG_PATH = "/usr/share/sonic/device/x86_64-cel_e1031-r0/sensors.conf" SS_CONFIG_PATH = "/usr/share/sonic/device/x86_64-cel_e1031-r0/sensors.conf"
def __init__(self, thermal_index): def __init__(self, thermal_index):
@ -41,10 +41,8 @@ class Thermal(ThermalBase):
self.THERMAL_NAME_LIST.append("CPU board temperature sensor : 2") self.THERMAL_NAME_LIST.append("CPU board temperature sensor : 2")
# Set hwmon path # Set hwmon path
self.ss_index, self.ss_path = self.__get_ss_info(self.index) self.ss_index, self.hwmon_path = self.__get_ss_info(self.index)
self.ss_key = self.THERMAL_NAME_LIST[self.index] self.ss_key = self.THERMAL_NAME_LIST[self.index]
self.hwmon_name = os.listdir(self.ss_path)[0]
self.hwmon_path = os.path.join(self.ss_path, self.hwmon_name)
def __get_ss_info(self, index): def __get_ss_info(self, index):
if self.index <= 4: if self.index <= 4:

View File

@ -0,0 +1,2 @@
__all__ = ["platform", "chassis"]
from sonic_platform import *

View File

@ -31,8 +31,12 @@ NUM_PSU = 2
NUM_THERMAL = 5 NUM_THERMAL = 5
NUM_SFP = 32 NUM_SFP = 32
RESET_REGISTER = "0x103" RESET_REGISTER = "0x103"
REBOOT_CAUSE_PATH = "/host/reboot-cause/previous-reboot-cause.txt" HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/"
PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/"
REBOOT_CAUSE_FILE = "reboot-cause.txt"
PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt"
COMPONENT_NAME_LIST = ["CPLD1", "CPLD2", "CPLD3", "CPLD4", "BIOS"] COMPONENT_NAME_LIST = ["CPLD1", "CPLD2", "CPLD3", "CPLD4", "BIOS"]
HOST_CHK_CMD = "docker > /dev/null 2>&1"
class Chassis(ChassisBase): class Chassis(ChassisBase):
@ -53,17 +57,22 @@ class Chassis(ChassisBase):
sfp = Sfp(index) sfp = Sfp(index)
self._sfp_list.append(sfp) self._sfp_list.append(sfp)
ChassisBase.__init__(self) ChassisBase.__init__(self)
self._component_name_list = COMPONENT_NAME_LIST self._component_name_list = COMPONENT_NAME_LIST
self._watchdog = Watchdog() self._watchdog = Watchdog()
self._eeprom = Tlv() self._eeprom = Tlv()
def __is_host(self):
return os.system(HOST_CHK_CMD) == 0
def __read_txt_file(self, file_path): def __read_txt_file(self, file_path):
try: try:
with open(file_path, 'r') as fd: with open(file_path, 'r') as fd:
data = fd.read() data = fd.read()
return data.strip() return data.strip()
except IOError: except IOError:
raise IOError("Unable to open %s file !" % file_path) pass
return None
def get_base_mac(self): def get_base_mac(self):
""" """
@ -136,14 +145,27 @@ class Chassis(ChassisBase):
self.component = Component("CPLD1") self.component = Component("CPLD1")
description = 'None' description = 'None'
reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER
hw_reboot_cause = self.component.get_register_value(RESET_REGISTER)
sw_reboot_cause = self.__read_txt_file(REBOOT_CAUSE_PATH)
if sw_reboot_cause != "Unexpected reboot": reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) if self.__is_host(
) else PMON_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE
prev_reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE) if self.__is_host(
) else PMON_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE
hw_reboot_cause = self.component.get_register_value(RESET_REGISTER)
sw_reboot_cause = self.__read_txt_file(
reboot_cause_path) or "Unknown"
prev_sw_reboot_cause = self.__read_txt_file(
prev_reboot_cause_path) or "Unknown"
if sw_reboot_cause == "Unknown" and (prev_sw_reboot_cause == "Unknown" or prev_sw_reboot_cause == self.REBOOT_CAUSE_POWER_LOSS) and hw_reboot_cause == "0x11":
reboot_cause = self.REBOOT_CAUSE_POWER_LOSS
elif sw_reboot_cause != "Unknown" and hw_reboot_cause == "0x11":
reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE
description = sw_reboot_cause description = sw_reboot_cause
elif hw_reboot_cause == "0x11": elif prev_reboot_cause_path != "Unknown" and hw_reboot_cause == "0x11":
reboot_cause = self.REBOOT_CAUSE_POWER_LOSS reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE
description = prev_sw_reboot_cause
elif hw_reboot_cause == "0x22": elif hw_reboot_cause == "0x22":
reboot_cause = self.REBOOT_CAUSE_WATCHDOG, reboot_cause = self.REBOOT_CAUSE_WATCHDOG,
else: else:

View File

@ -17,7 +17,6 @@ try:
except ImportError as e: except ImportError as e:
raise ImportError(str(e) + "- required module not found") raise ImportError(str(e) + "- required module not found")
CONFIG_DB_PATH = "/etc/sonic/config_db.json"
EMC2305_PATH = "/sys/bus/i2c/drivers/emc2305/" EMC2305_PATH = "/sys/bus/i2c/drivers/emc2305/"
SYS_GPIO_DIR = "/sys/class/gpio" SYS_GPIO_DIR = "/sys/class/gpio"
EMC2305_MAX_PWM = 255 EMC2305_MAX_PWM = 255

View File

@ -18,7 +18,7 @@ try:
from swsssdk import ConfigDBConnector from swsssdk import ConfigDBConnector
from sonic_platform_base.sfp_base import SfpBase from sonic_platform_base.sfp_base import SfpBase
from sonic_platform_base.sonic_sfp.sfputilbase import SfpUtilBase from sonic_platform_base.sonic_sfp.sfputilbase import SfpUtilBase
from sonic_platform_base.sonic_sfp.sfputilbase import sff8436Dom from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom
except ImportError as e: except ImportError as e:
raise ImportError(str(e) + "- required module not found") raise ImportError(str(e) + "- required module not found")
@ -61,7 +61,11 @@ class Sfp(SfpBase, SfpUtilBase):
RESET_PATH = "/sys/devices/platform/dx010_cpld/qsfp_reset" RESET_PATH = "/sys/devices/platform/dx010_cpld/qsfp_reset"
LP_PATH = "/sys/devices/platform/dx010_cpld/qsfp_lpmode" LP_PATH = "/sys/devices/platform/dx010_cpld/qsfp_lpmode"
PRS_PATH = "/sys/devices/platform/dx010_cpld/qsfp_modprs" PRS_PATH = "/sys/devices/platform/dx010_cpld/qsfp_modprs"
PLATFORM_ROOT_PATH = '/usr/share/sonic/device' PLATFORM_ROOT_PATH = "/usr/share/sonic/device"
PMON_HWSKU_PATH = "/usr/share/sonic/hwsku"
PLATFORM = "x86_64-cel_seastone-r0"
HWSKU = "Seastone-DX010"
HOST_CHK_CMD = "docker > /dev/null 2>&1"
_port_to_eeprom_mapping = {} _port_to_eeprom_mapping = {}
@ -170,37 +174,28 @@ class Sfp(SfpBase, SfpUtilBase):
(x - 1) + 26) (x - 1) + 26)
else: else:
self._port_to_eeprom_mapping[x] = eeprom_path.format(x + 26) self._port_to_eeprom_mapping[x] = eeprom_path.format(x + 26)
self.read_porttab_mappings(self.__get_path_to_port_config_file())
self.__read_porttab()
SfpUtilBase.__init__(self) SfpUtilBase.__init__(self)
# Init index # Init index
self.index = sfp_index self.index = sfp_index
self.port_num = self.index + 1 self.port_num = self.index + 1
def __get_path_to_port_config_file(self): def __read_porttab(self):
# Get platform and hwsku
machine_info = sonic_device_util.get_machine_info()
platform = sonic_device_util.get_platform_info(machine_info)
config_db = ConfigDBConnector()
config_db.connect()
data = config_db.get_table('DEVICE_METADATA')
try: try:
hwsku = data['localhost']['hwsku'] self.read_porttab_mappings(self.__get_path_to_port_config_file())
except KeyError: except:
hwsku = "Unknown" pass
# Load platform module from source def __is_host(self):
platform_path = "/".join([self.PLATFORM_ROOT_PATH, platform]) return os.system(self.HOST_CHK_CMD) == 0
hwsku_path = "/".join([platform_path, hwsku])
# First check for the presence of the new 'port_config.ini' file def __get_path_to_port_config_file(self):
port_config_file_path = "/".join([hwsku_path, "port_config.ini"]) platform_path = "/".join([self.PLATFORM_ROOT_PATH, self.PLATFORM])
if not os.path.isfile(port_config_file_path): hwsku_path = "/".join([platform_path, self.HWSKU]
# port_config.ini doesn't exist. Try loading the legacy 'portmap.ini' file ) if self.__is_host() else self.PMON_HWSKU_PATH
port_config_file_path = "/".join([hwsku_path, "portmap.ini"]) return "/".join([hwsku_path, "port_config.ini"])
return port_config_file_path
def __read_eeprom_specific_bytes(self, offset, num_bytes): def __read_eeprom_specific_bytes(self, offset, num_bytes):
sysfsfile_eeprom = None sysfsfile_eeprom = None
@ -382,7 +377,7 @@ class Sfp(SfpBase, SfpUtilBase):
""" """
rx_los_list = [] rx_los_list = []
dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
self.QSFP_CHANNL_RX_LOS_STATUS_OFFSET, self.QSFP_CHANNL_RX_LOS_STATUS_WIDTH) self.QSFP_CHANNL_RX_LOS_STATUS_OFFSET, self.QSFP_CHANNL_RX_LOS_STATUS_WIDTH) if self.get_presence() else None
if dom_channel_monitor_raw is not None: if dom_channel_monitor_raw is not None:
rx_los_data = int(dom_channel_monitor_raw[0], 16) rx_los_data = int(dom_channel_monitor_raw[0], 16)
rx_los_list.append(rx_los_data & 0x01 != 0) rx_los_list.append(rx_los_data & 0x01 != 0)
@ -400,7 +395,7 @@ class Sfp(SfpBase, SfpUtilBase):
""" """
tx_fault_list = [] tx_fault_list = []
dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
self.QSFP_CHANNL_TX_FAULT_STATUS_OFFSET, self.QSFP_CHANNL_TX_FAULT_STATUS_WIDTH) self.QSFP_CHANNL_TX_FAULT_STATUS_OFFSET, self.QSFP_CHANNL_TX_FAULT_STATUS_WIDTH) if self.get_presence() else None
if dom_channel_monitor_raw is not None: if dom_channel_monitor_raw is not None:
tx_fault_data = int(dom_channel_monitor_raw[0], 16) tx_fault_data = int(dom_channel_monitor_raw[0], 16)
tx_fault_list.append(tx_fault_data & 0x01 != 0) tx_fault_list.append(tx_fault_data & 0x01 != 0)
@ -422,7 +417,7 @@ class Sfp(SfpBase, SfpUtilBase):
return False return False
dom_control_raw = self.__read_eeprom_specific_bytes( dom_control_raw = self.__read_eeprom_specific_bytes(
self.QSFP_CONTROL_OFFSET, self.QSFP_CONTROL_WIDTH) self.QSFP_CONTROL_OFFSET, self.QSFP_CONTROL_WIDTH) if self.get_presence() else None
if dom_control_raw is not None: if dom_control_raw is not None:
dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0) dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0)
tx_disable_list.append( tx_disable_list.append(
@ -476,7 +471,7 @@ class Sfp(SfpBase, SfpUtilBase):
return False return False
dom_control_raw = self.__read_eeprom_specific_bytes( dom_control_raw = self.__read_eeprom_specific_bytes(
self.QSFP_CONTROL_OFFSET, self.QSFP_CONTROL_WIDTH) self.QSFP_CONTROL_OFFSET, self.QSFP_CONTROL_WIDTH) if self.get_presence() else None
if dom_control_raw is not None: if dom_control_raw is not None:
dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0) dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0)
power_override = ( power_override = (
@ -515,7 +510,7 @@ class Sfp(SfpBase, SfpUtilBase):
tx2_bs = transceiver_dom_info_dict.get("tx2bias", "N/A") tx2_bs = transceiver_dom_info_dict.get("tx2bias", "N/A")
tx3_bs = transceiver_dom_info_dict.get("tx3bias", "N/A") tx3_bs = transceiver_dom_info_dict.get("tx3bias", "N/A")
tx4_bs = transceiver_dom_info_dict.get("tx4bias", "N/A") tx4_bs = transceiver_dom_info_dict.get("tx4bias", "N/A")
return [tx1_bs, tx2_bs, tx3_bs, tx4_bs] return [tx1_bs, tx2_bs, tx3_bs, tx4_bs] if transceiver_dom_info_dict else []
def get_rx_power(self): def get_rx_power(self):
""" """
@ -530,7 +525,7 @@ class Sfp(SfpBase, SfpUtilBase):
rx2_pw = transceiver_dom_info_dict.get("rx2power", "N/A") rx2_pw = transceiver_dom_info_dict.get("rx2power", "N/A")
rx3_pw = transceiver_dom_info_dict.get("rx3power", "N/A") rx3_pw = transceiver_dom_info_dict.get("rx3power", "N/A")
rx4_pw = transceiver_dom_info_dict.get("rx4power", "N/A") rx4_pw = transceiver_dom_info_dict.get("rx4power", "N/A")
return [rx1_pw, rx2_pw, rx3_pw, rx4_pw] return [rx1_pw, rx2_pw, rx3_pw, rx4_pw] if transceiver_dom_info_dict else []
def get_tx_power(self): def get_tx_power(self):
""" """
@ -545,7 +540,7 @@ class Sfp(SfpBase, SfpUtilBase):
tx2_pw = transceiver_dom_info_dict.get("tx2power", "N/A") tx2_pw = transceiver_dom_info_dict.get("tx2power", "N/A")
tx3_pw = transceiver_dom_info_dict.get("tx3power", "N/A") tx3_pw = transceiver_dom_info_dict.get("tx3power", "N/A")
tx4_pw = transceiver_dom_info_dict.get("tx4power", "N/A") tx4_pw = transceiver_dom_info_dict.get("tx4power", "N/A")
return [tx1_pw, tx2_pw, tx3_pw, tx4_pw] return [tx1_pw, tx2_pw, tx3_pw, tx4_pw] if transceiver_dom_info_dict else []
def reset(self): def reset(self):
""" """
@ -754,7 +749,7 @@ class Sfp(SfpBase, SfpUtilBase):
Returns: Returns:
string: Model/part number of device string: Model/part number of device
""" """
transceiver_dom_info_dict = self.get_transceiver_bulk_status() transceiver_dom_info_dict = self.get_transceiver_info()
return transceiver_dom_info_dict.get("modelname", "N/A") return transceiver_dom_info_dict.get("modelname", "N/A")
def get_serial(self): def get_serial(self):
@ -763,5 +758,5 @@ class Sfp(SfpBase, SfpUtilBase):
Returns: Returns:
string: Serial number of device string: Serial number of device
""" """
transceiver_dom_info_dict = self.get_transceiver_bulk_status() transceiver_dom_info_dict = self.get_transceiver_info()
return transceiver_dom_info_dict.get("serialnum", "N/A") return transceiver_dom_info_dict.get("serialnum", "N/A")

View File

@ -37,18 +37,16 @@ class Thermal(ThermalBase):
# Set hwmon path # Set hwmon path
i2c_path = { i2c_path = {
0: "i2c-5/5-0048", # u4 system-inlet 0: "i2c-5/5-0048/hwmon/hwmon1", # u4 system-inlet
1: "i2c-6/6-0049", # u2 system-inlet 1: "i2c-6/6-0049/hwmon/hwmon2", # u2 system-inlet
2: "i2c-7/7-004a", # u44 bmc56960-on-board 2: "i2c-7/7-004a/hwmon/hwmon3", # u44 bmc56960-on-board
3: "i2c-14/14-0048", # u9200 cpu-on-board 3: "i2c-14/14-0048/hwmon/hwmon4", # u9200 cpu-on-board
4: "i2c-15/15-004e" # u9201 system-outlet 4: "i2c-15/15-004e/hwmon/hwmon5" # u9201 system-outlet
}.get(self.index, None) }.get(self.index, None)
self.ss_path = "{}/{}/hwmon".format(self.I2C_ADAPTER_PATH, i2c_path) self.hwmon_path = "{}/{}".format(self.I2C_ADAPTER_PATH, i2c_path)
self.ss_key = self.THERMAL_NAME_LIST[self.index] self.ss_key = self.THERMAL_NAME_LIST[self.index]
self.ss_index = 1 self.ss_index = 1
self.hwmon_name = os.listdir(self.ss_path)[0]
self.hwmon_path = os.path.join(self.ss_path, self.hwmon_name)
def __read_txt_file(self, file_path): def __read_txt_file(self, file_path):
try: try:
@ -56,7 +54,7 @@ class Thermal(ThermalBase):
data = fd.read() data = fd.read()
return data.strip() return data.strip()
except IOError: except IOError:
raise IOError("Unable to open %s file !" % file_path) pass
def __get_temp(self, temp_file): def __get_temp(self, temp_file):
temp_file_path = os.path.join(self.hwmon_path, temp_file) temp_file_path = os.path.join(self.hwmon_path, temp_file)

View File

@ -141,6 +141,8 @@ start)
sleep 0.1 sleep 0.1
done done
/bin/sh /usr/local/bin/platform_api_mgnt.sh init
echo "done." echo "done."
;; ;;

View File

@ -1,3 +1,5 @@
dx010/scripts/dx010_check_qsfp.sh usr/local/bin dx010/scripts/dx010_check_qsfp.sh usr/local/bin
dx010/cfg/dx010-modules.conf etc/modules-load.d dx010/cfg/dx010-modules.conf etc/modules-load.d
dx010/systemd/platform-modules-dx010.service lib/systemd/system dx010/systemd/platform-modules-dx010.service lib/systemd/system
dx010/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-cel_seastone-r0
services/platform_api/platform_api_mgnt.sh usr/local/bin

View File

@ -1,3 +1,6 @@
depmod -a depmod -a
systemctl enable platform-modules-dx010.service systemctl enable platform-modules-dx010.service
systemctl start platform-modules-dx010.service systemctl start platform-modules-dx010.service
/usr/local/bin/platform_api_mgnt.sh install

View File

@ -69,6 +69,8 @@ start)
echo "both" > /sys/devices/platform/e1031.smc/SFP/modabs_trig echo "both" > /sys/devices/platform/e1031.smc/SFP/modabs_trig
echo 0 > /sys/devices/platform/e1031.smc/SFP/modabs_mask echo 0 > /sys/devices/platform/e1031.smc/SFP/modabs_mask
/bin/sh /usr/local/bin/platform_api_mgnt.sh init
echo "done." echo "done."
;; ;;

View File

@ -3,3 +3,5 @@ haliburton/systemd/platform-modules-haliburton.service lib/systemd/system
haliburton/script/fancontrol.sh etc/init.d haliburton/script/fancontrol.sh etc/init.d
services/fancontrol/fancontrol.service lib/systemd/system services/fancontrol/fancontrol.service lib/systemd/system
services/fancontrol/fancontrol usr/local/bin services/fancontrol/fancontrol usr/local/bin
haliburton/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-cel_e1031-r0
services/platform_api/platform_api_mgnt.sh usr/local/bin

View File

@ -3,4 +3,6 @@ systemctl enable platform-modules-haliburton.service
systemctl enable fancontrol.service systemctl enable fancontrol.service
systemctl start platform-modules-haliburton.service systemctl start platform-modules-haliburton.service
systemctl start fancontrol.service systemctl start fancontrol.service
/usr/local/bin/platform_api_mgnt.sh install

View File

@ -13,6 +13,9 @@ MODULE_DIRS:= dx010 haliburton
override_dh_auto_build: override_dh_auto_build:
(for mod in $(MODULE_DIRS); do \ (for mod in $(MODULE_DIRS); do \
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
cd $(MOD_SRC_DIR)/$${mod}; \
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
cd $(MOD_SRC_DIR); \
done) done)
override_dh_auto_install: override_dh_auto_install:

View File

@ -0,0 +1,34 @@
from setuptools import setup
DEVICE_NAME = 'celestica'
HW_SKU = 'x86_64-cel_seastone-r0'
setup(
name='sonic-platform',
version='1.0',
description='SONiC platform API implementation on Celestica Platforms',
license='Apache 2.0',
author='SONiC Team',
author_email='linuxnetdev@microsoft.com',
url='https://github.com/Azure/sonic-buildimage',
maintainer='Wirut Getbamrung',
maintainer_email='wgetbumr@celestica.com',
packages=[
'sonic_platform',
],
package_dir={
'sonic_platform': '../../../../device/{}/{}/sonic_platform'.format(DEVICE_NAME, HW_SKU)},
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Plugins',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Topic :: Utilities',
],
keywords='sonic SONiC platform PLATFORM',
)

View File

@ -0,0 +1,34 @@
from setuptools import setup
DEVICE_NAME = 'celestica'
HW_SKU = 'x86_64-cel_e1031-r0'
setup(
name='sonic-platform',
version='1.0',
description='SONiC platform API implementation on Celestica Platforms',
license='Apache 2.0',
author='SONiC Team',
author_email='linuxnetdev@microsoft.com',
url='https://github.com/Azure/sonic-buildimage',
maintainer='Wirut Getbamrung',
maintainer_email='wgetbumr@celestica.com',
packages=[
'sonic_platform',
],
package_dir={
'sonic_platform': '../../../../device/{}/{}/sonic_platform'.format(DEVICE_NAME, HW_SKU)},
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Plugins',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Topic :: Utilities',
],
keywords='sonic SONiC platform PLATFORM',
)

View File

@ -0,0 +1,41 @@
#!/bin/bash
PREV_REBOOT_CAUSE="/host/reboot-cause/"
DEVICE="/usr/share/sonic/device"
PLATFORM=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
FILES=$DEVICE/$PLATFORM/api_files
install() {
# Install sonic-platform package
if [ -e $DEVICE/$PLATFORM/sonic_platform-1.0-py2-none-any.whl ]; then
pip install $DEVICE/$PLATFORM/sonic_platform-1.0-py2-none-any.whl
fi
}
init() {
# mount needed files for sonic-platform package
mkdir -p $FILES
mkdir -p $FILES/reboot-cause
mount -B $PREV_REBOOT_CAUSE $FILES/reboot-cause
}
deinit() {
# deinit sonic-platform package
umount -f $PREV_REBOOT_CAUSE $FILES/reboot-cause >/dev/null 2>/dev/null
}
uninstall() {
# Uninstall sonic-platform package
pip uninstall -y sonic-platform >/dev/null 2>/dev/null
}
case "$1" in
install | uninstall | init | deinit)
$1
;;
*)
echo "Usage: $0 {install|uninstall|init|deinit}"
exit 1
;;
esac