Skip to content
Closed
Show file tree
Hide file tree
Changes from 15 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
75 changes: 29 additions & 46 deletions device/accton/x86_64-accton_as9726_32d-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

try:
import time
from ctypes import create_string_buffer
from sonic_sfp.sfputilbase import SfpUtilBase
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))
Expand Down Expand Up @@ -125,61 +124,45 @@ def get_presence(self, port_num):
def get_low_power_mode(self, port_num):
if port_num > self.QSFP_PORT_END: #sfp not support lpmode
return False
try:
eeprom = None

if not self.get_presence(port_num):
return False

eeprom = open(self.port_to_eeprom_mapping[port_num], "rb")
eeprom.seek(93)
lpmode = ord(eeprom.read(1))

if ((lpmode & 0x3) == 0x3):
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
else:
# High Power Mode if one of the following conditions is matched:
# 1. "Power override" bit is 0
# 2. "Power override" bit is 1 and "Power set" bit is 0
return False
if port_num <= 16:
lpmode_path = self.BASE_CPLD2_PATH + "module_lpmode_" + str(port_num)
else:
lpmode_path = self.BASE_CPLD3_PATH + "module_lpmode_" + str(port_num)
try:
val_file = open(lpmode_path)
content = val_file.readline().rstrip()
val_file.close()
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False
finally:
if eeprom is not None:
eeprom.close()
time.sleep(0.01)
if content == "0":
return True

return False


def set_low_power_mode(self, port_num, lpmode):
# Check for invalid port_num
if port_num > self.QSFP_PORT_END: #sfp not support lpmode:
return False
if not self.get_presence(port_num):
return False # Port is not present, unable to set lpmode

if port_num <= 16:
lpmode_path = self.BASE_CPLD2_PATH + "module_lpmode_" + str(port_num)
else:
lpmode_path = self.BASE_CPLD3_PATH + "module_lpmode_" + str(port_num)

self.__port_to_mod_lpmode = lpmode_path

if lpmode is True:
ret = self.__write_txt_file(self.__port_to_mod_lpmode, 0) #sysfs 1: enable lpmode
else:
ret = self.__write_txt_file(self.__port_to_mod_lpmode, 1) #sysfs 1: disable lpmode

return ret

try:
eeprom = None
if not self.get_presence(port_num):
return False # Port is not present, unable to set the eeprom

# Fill in write buffer
# 0x3:Low Power Mode. "Power override" bit is 1 and "Power set" bit is 1
# 0x9:High Power Mode. "Power override" bit is 1 ,"Power set" bit is 0 and "High Power Class Enable" bit is 1
regval = 0x3 if lpmode else 0x9

buffer = create_string_buffer(1)
buffer[0] = regval

# Write to eeprom
eeprom = open(self.port_to_eeprom_mapping[port_num], "r+b")
eeprom.seek(93)
eeprom.write(buffer[0])
return True
except IOError as e:
print("Error: unable to open file: %s" % str(e))
return False
finally:
if eeprom is not None:
eeprom.close()
time.sleep(0.01)

def reset(self, port_num):
if port_num > self.QSFP_PORT_END: #sfp not support lpmode:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"skip_ledd": true,
"skip_thermalctld": true
"skip_pcied": true
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any specific reason to skip the pcied?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no pcie devices, so we skip.

}

56 changes: 56 additions & 0 deletions device/accton/x86_64-accton_as9726_32d-r0/sensors.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# libsensors configuration file for as9726-32d
# ------------------------------------------------
#

bus "i2c-14" "i2c-1-mux (chan_id 5)"
bus "i2c-9" "i2c-1-mux (chan_id 0)"
bus "i2c-15" "i2c-1-mux (chan_id 6)"


chip "ym2401-i2c-*-58"
label in3 "PSU 1 Voltage"
label fan1 "PSU 1 Fan"
label temp1 "PSU 1 Temperature"
label power2 "PSU 1 Power"
label curr2 "PSU 1 Current"

chip "ym2401-i2c-*-59"
label in3 "PSU 2 Voltage"
label fan1 "PSU 2 Fan"
label temp1 "PSU 2 Temperature"
label power2 "PSU 2 Power"
label curr2 "PSU 2 Current"


chip "as9726_32d_fan-*"
label fan1 "Fan 1 Front"
label fan2 "Fan 2 Front"
label fan3 "Fan 3 Front"
label fan4 "Fan 4 Front"
label fan5 "Fan 5 Front"
label fan6 "Fan 6 Front"
label fan11 "Fan 1 Rear"
label fan12 "Fan 2 Rear"
label fan13 "Fan 3 Rear"
label fan14 "Fan 4 Rear"
label fan15 "Fan 5 Rear"
label fan16 "Fan 6 Rear"


chip "lm75-i2c-*-48"
label temp1 "Main Board Temperature"

chip "lm75-i2c-*-49"
label temp1 "Main Board Temperature"

chip "lm75-i2c-*-4a"
label temp1 "Main Board Temperature"

chip "lm75-i2c-*-4b"
label temp1 "CPU Board Temperature"

chip "lm75-i2c-*-4c"
label temp1 "OCXO Temperature"

chip "lm75-i2c-*-4f"
label temp1 "Main Board Temperature"
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__all__ = ['chassis', 'eeprom', 'platform', 'psu', 'sfp', 'thermal', 'fan']
__all__ = [ "platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer" ]
from . import platform
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
#############################################################################

import os
import sys

try:
from sonic_platform_base.chassis_base import ChassisBase
from .helper import APIHelper
from .event import SfpEvent
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

NUM_FAN_TRAY = 6
NUM_FAN = 2
NUM_PSU = 2
NUM_THERMAL = 3
NUM_THERMAL = 6
NUM_QSFP = 32
PORT_START = 1
PORT_END = 34
Expand Down Expand Up @@ -62,11 +64,11 @@ def __initialize_sfp(self):
self.sfp_module_initialized = True

def __initialize_fan(self):
from sonic_platform.fan import Fan
for fant_index in range(0, NUM_FAN_TRAY):
for fan_index in range(0, NUM_FAN):
fan = Fan(fant_index, fan_index)
self._fan_list.append(fan)
from sonic_platform.fan_drawer import FanDrawer
for fant_index in range(NUM_FAN_TRAY):
fandrawer = FanDrawer(fant_index)
self._fan_drawer_list.append(fandrawer)
self._fan_list.extend(fandrawer._fan_list)

def __initialize_psu(self):
from sonic_platform.psu import Psu
Expand Down Expand Up @@ -141,7 +143,15 @@ def get_base_mac(self):
"""
return self._eeprom.get_mac()

def get_serial_number(self):
def get_model(self):
"""
Retrieves the model number (or part number) of the device
Returns:
string: Model/part number of device
"""
return self._eeprom.get_pn()

def get_serial(self):
"""
Retrieves the hardware serial number for the chassis
Returns:
Expand Down Expand Up @@ -177,6 +187,15 @@ def get_reboot_cause(self):

return ('REBOOT_CAUSE_NON_HARDWARE', sw_reboot_cause)

def get_change_event(self, timeout=0):
# SFP event
if not self.sfp_module_initialized:
self.__initialize_sfp()

status, sfp_event = SfpEvent(self._sfp_list).get_sfp_event(timeout)

return status, sfp_event

def get_sfp(self, index):
"""
Retrieves sfp represented by (1-based) index <index>
Expand All @@ -199,3 +218,29 @@ def get_sfp(self, index):
sys.stderr.write("SFP index {} out of range (1-{})\n".format(
index, len(self._sfp_list)))
return sfp

def get_position_in_parent(self):
"""
Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position
for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned
Returns:
integer: The 1-based relative physical position in parent device or -1 if cannot determine the position
"""
return -1

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

def initizalize_system_led(self):
return True

def get_status_led(self):
return "ControlledByFPGA"

def set_status_led(self, color):
return True
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,55 @@ def install_firmware(self, image_path):
A boolean, True if install successfully, False if not
"""
raise NotImplementedError

def get_presence(self):
"""
Retrieves the presence of the device
Returns:
bool: True if device is present, False if not
"""
return True

def get_model(self):
"""
Retrieves the model number (or part number) of the device
Returns:
string: Model/part number of device
"""
return 'N/A'

def get_serial(self):
"""
Retrieves the serial number of the device
Returns:
string: Serial number of device
"""
return 'N/A'

def get_status(self):
"""
Retrieves the operational status of the device
Returns:
A boolean value, True if device is operating properly, False if not
"""
return True

def get_position_in_parent(self):
"""
Retrieves 1-based relative physical position in parent device.
If the agent cannot determine the parent-relative position
for some reason, or if the associated value of
entPhysicalContainedIn is'0', then the value '-1' is returned
Returns:
integer: The 1-based relative physical position in parent device
or -1 if cannot determine the position
"""
return -1

def is_replaceable(self):
"""
Indicate whether this device is replaceable.
Returns:
bool: True if it is replaceable.
"""
return False
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def _load_eeprom(self):
def get_eeprom(self):
return self._eeprom

def get_pn(self):
return self._eeprom.get('0x22', "Undefined.")

def get_serial(self):
return self._eeprom.get('0x23', "Undefined.")

Expand Down
55 changes: 55 additions & 0 deletions device/accton/x86_64-accton_as9726_32d-r0/sonic_platform/event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
try:
import time
from .helper import APIHelper
from sonic_py_common.logger import Logger
except ImportError as e:
raise ImportError(repr(e) + " - required module not found")


class SfpEvent:
''' Listen to insert/remove sfp events '''

def __init__(self, sfp_list):
self._api_helper = APIHelper()
self._sfp_list = sfp_list
self._logger = Logger()

sfp_change_event_data = {'valid': 0, 'last': 0, 'present': 0}
def get_sfp_event(self, timeout=2000):
now = time.time()
port_dict = {}
change_dict = {}
change_dict['sfp'] = port_dict

if timeout < 1000:
timeout = 1000
timeout = timeout / float(1000) # Convert to secs

if now < (self.sfp_change_event_data['last'] + timeout) and self.sfp_change_event_data['valid']:
return True, change_dict

bitmap = 0
for sfp in self._sfp_list:
modpres = sfp.get_presence()
i=sfp.port_num-1
if modpres:
bitmap = bitmap | (1 << i)

changed_ports = self.sfp_change_event_data['present'] ^ bitmap
if changed_ports:
for sfp in self._sfp_list:
i=sfp.port_num-1
if (changed_ports & (1 << i)):
if (bitmap & (1 << i)) == 0:
port_dict[i+1] = '0'
else:
port_dict[i+1] = '1'


# Update the cache dict
self.sfp_change_event_data['present'] = bitmap
self.sfp_change_event_data['last'] = now
self.sfp_change_event_data['valid'] = 1
return True, change_dict
else:
return True, change_dict
Loading