Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion device/celestica/x86_64-cel_e1031-r0/fancontrol-B2F
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Configuration file generated by pwmconfig, changes will be lost
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
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
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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__all__ = ["platform", "chassis"]
from sonic_platform import *
19 changes: 14 additions & 5 deletions device/celestica/x86_64-cel_e1031-r0/sonic_platform/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
NUM_THERMAL = 7
NUM_SFP = 52
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"]
HOST_CHK_CMD = "docker > /dev/null 2>&1"


class Chassis(ChassisBase):
Expand All @@ -53,17 +55,23 @@ def __init__(self):
sfp = Sfp(index)
self._sfp_list.append(sfp)
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._watchdog = Watchdog()
self._eeprom = Tlv()

def __is_host(self):
return os.system(HOST_CHK_CMD) == 0

def __read_txt_file(self, file_path):
try:
with open(file_path, 'r') as fd:
data = fd.read()
return data.strip()
except IOError:
raise IOError("Unable to open %s file !" % file_path)
pass
return None

def get_base_mac(self):
"""
Expand Down Expand Up @@ -137,14 +145,15 @@ def get_reboot_cause(self):
description = 'None'
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)
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
description = sw_reboot_cause
elif hw_reboot_cause == "0x11":
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
else:
reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER
Expand Down
1 change: 1 addition & 0 deletions device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, fan_index):
self.index = fan_index
self.config_data = {}
self.fan_speed = 0
FanBase.__init__(self)

# e1031 fan attributes
# Single emc2305 chip located at i2c-23-4d
Expand Down
48 changes: 18 additions & 30 deletions device/celestica/x86_64-cel_e1031-r0/sonic_platform/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Sfp(SfpBase, SfpUtilBase):
}
PRS_PATH = "/sys/devices/platform/e1031.smc/SFP/sfp_modabs"
PLATFORM_ROOT_PATH = '/usr/share/sonic/device'
PMON_HWSKU_PATH = '/usr/share/sonic/hwsku'
SFP_STATUS_CONTROL_OFFSET = 110
SFP_STATUS_CONTROL_WIDTH = 1

Expand All @@ -61,6 +62,9 @@ class Sfp(SfpBase, SfpUtilBase):
SFP_EEPROM_TX_PWR_KEY = "TXPower"
SFP_EEPROM_TX_BS_KEY = "TXBias"
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
def port_start(self):
Expand Down Expand Up @@ -122,40 +126,24 @@ def __init__(self, sfp_index):
self.index = sfp_index
self.port_num = self.index + 1

def __is_host(self):
return os.system(self.HOST_CHK_CMD) == 0

def __get_sysfsfile_eeprom(self):
sysfsfile_eeprom = None
sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[self.port_num]
try:
sysfsfile_eeprom = open(
sysfs_sfp_i2c_client_eeprom_path, mode="r+b", buffering=0)
except IOError:
print("Error: reading sysfs file %s" %
sysfs_sfp_i2c_client_eeprom_path)
pass
return sysfsfile_eeprom

def __get_path_to_port_config_file(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:
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
platform_path = "/".join([self.PLATFORM_ROOT_PATH, self.PLATFORM])
hwsku_path = "/".join([platform_path, self.HWSKU]
) if self.__is_host() else self.PMON_HWSKU_PATH
return "/".join([hwsku_path, "port_config.ini"])

def get_transceiver_info(self):
"""
Expand Down Expand Up @@ -405,7 +393,7 @@ def get_tx_bias(self):
"""
transceiver_dom_info_dict = self.get_transceiver_bulk_status()
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):
"""
Expand All @@ -417,7 +405,7 @@ def get_rx_power(self):
"""
transceiver_dom_info_dict = self.get_transceiver_bulk_status()
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):
"""
Expand All @@ -429,7 +417,7 @@ def get_tx_power(self):
"""
transceiver_dom_info_dict = self.get_transceiver_bulk_status()
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):
"""
Expand All @@ -452,7 +440,7 @@ def tx_disable(self, tx_disable):

sysfsfile_eeprom = self.__get_sysfsfile_eeprom()
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:
tx_disable_bit = 0x80 if tx_disable else 0x7f
status_control = int(status_control_raw[0], 16)
Expand Down Expand Up @@ -551,7 +539,7 @@ def get_model(self):
Returns:
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")

def get_serial(self):
Expand All @@ -560,5 +548,5 @@ def get_serial(self):
Returns:
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")
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class Thermal(ThermalBase):
"""Platform-specific Thermal class"""

THERMAL_NAME_LIST = []
MAINBOARD_SS_PATH = "/sys/class/i2c-adapter/i2c-11/11-001a/hwmon/"
CPUBOARD_SS_PATH = "/sys/class/i2c-adapter/i2c-3/3-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/hwmon1"
SS_CONFIG_PATH = "/usr/share/sonic/device/x86_64-cel_e1031-r0/sensors.conf"

def __init__(self, thermal_index):
Expand All @@ -41,10 +41,8 @@ def __init__(self, thermal_index):
self.THERMAL_NAME_LIST.append("CPU board temperature sensor : 2")

# 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.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):
if self.index <= 4:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__all__ = ["platform", "chassis"]
from sonic_platform import *
34 changes: 28 additions & 6 deletions device/celestica/x86_64-cel_seastone-r0/sonic_platform/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@
NUM_THERMAL = 5
NUM_SFP = 32
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"]
HOST_CHK_CMD = "docker > /dev/null 2>&1"


class Chassis(ChassisBase):
Expand All @@ -53,17 +57,22 @@ def __init__(self):
sfp = Sfp(index)
self._sfp_list.append(sfp)
ChassisBase.__init__(self)

self._component_name_list = COMPONENT_NAME_LIST
self._watchdog = Watchdog()
self._eeprom = Tlv()

def __is_host(self):
return os.system(HOST_CHK_CMD) == 0

def __read_txt_file(self, file_path):
try:
with open(file_path, 'r') as fd:
data = fd.read()
return data.strip()
except IOError:
raise IOError("Unable to open %s file !" % file_path)
pass
return None

def get_base_mac(self):
"""
Expand Down Expand Up @@ -136,14 +145,27 @@ def get_reboot_cause(self):
self.component = Component("CPLD1")
description = 'None'
reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER

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)

if sw_reboot_cause != "Unexpected reboot":
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
description = sw_reboot_cause
elif hw_reboot_cause == "0x11":
reboot_cause = self.REBOOT_CAUSE_POWER_LOSS
elif prev_reboot_cause_path != "Unknown" and hw_reboot_cause == "0x11":
reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE
description = prev_sw_reboot_cause
elif hw_reboot_cause == "0x22":
reboot_cause = self.REBOOT_CAUSE_WATCHDOG,
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

CONFIG_DB_PATH = "/etc/sonic/config_db.json"
EMC2305_PATH = "/sys/bus/i2c/drivers/emc2305/"
SYS_GPIO_DIR = "/sys/class/gpio"
EMC2305_MAX_PWM = 255
Expand Down
Loading