DellEMC: Platform 2.0 Api - Component for z9264f (#4091)

This commit is contained in:
Joe LeVeque 2020-03-04 19:17:09 -08:00 committed by GitHub
parent f6ec95cf2b
commit ab4861deb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 146 additions and 3 deletions

View File

@ -139,6 +139,51 @@ remove_python_api_package() {
fi
}
# Readout firmware version of the system and
# store in /var/log/firmware_versions
platform_firmware_versions()
{
FIRMWARE_VERSION_FILE=/var/log/firmware_versions
rm -rf ${FIRMWARE_VERSION_FILE}
echo "BIOS: `dmidecode -s system-version `" > $FIRMWARE_VERSION_FILE
## Get FPGA version
r=`/usr/bin/pcisysfs.py --get --offset 0x00 --res /sys/bus/pci/devices/0000\:04\:00.0/resource0 | sed '1d; s/.*\(....\)$/\1/; s/\(..\{1\}\)/\1./'`
r_min=$(echo $r | sed 's/.*\(..\)$/0x\1/')
r_maj=$(echo $r | sed 's/^\(..\).*/0x\1/')
echo "FPGA: $((r_maj)).$((r_min))" >> $FIRMWARE_VERSION_FILE
## Get BMC Firmware Revision
r=`cat /sys/class/ipmi/ipmi0/device/bmc/firmware_revision`
echo "BMC: $r" >> $FIRMWARE_VERSION_FILE
#System CPLD 0x31 on i2c bus 601 ( physical FPGA I2C-2)
r_min=`/usr/sbin/i2cget -y 601 0x31 0x0 | sed ' s/.*\(0x..\)$/\1/'`
r_maj=`/usr/sbin/i2cget -y 601 0x31 0x1 | sed ' s/.*\(0x..\)$/\1/'`
echo "System CPLD: $((r_maj)).$((r_min))" >> $FIRMWARE_VERSION_FILE
#Slave CPLD 1 0x30 on i2c bus 600 ( physical FPGA I2C-1)
r_min=`/usr/sbin/i2cget -y 600 0x30 0x0 | sed ' s/.*\(0x..\)$/\1/'`
r_maj=`/usr/sbin/i2cget -y 600 0x30 0x1 | sed ' s/.*\(0x..\)$/\1/'`
echo "Slave CPLD 1: $((r_maj)).$((r_min))" >> $FIRMWARE_VERSION_FILE
#Slave CPLD 2 0x31 on i2c bus 600 ( physical FPGA I2C-1)
r_min=`/usr/sbin/i2cget -y 600 0x31 0x0 | sed ' s/.*\(0x..\)$/\1/'`
r_maj=`/usr/sbin/i2cget -y 600 0x31 0x1 | sed ' s/.*\(0x..\)$/\1/'`
echo "Slave CPLD 2: $((r_maj)).$((r_min))" >> $FIRMWARE_VERSION_FILE
#Slave CPLD 3 0x32 on i2c bus 600 ( physical FPGA I2C-1)
r_min=`/usr/sbin/i2cget -y 600 0x32 0x0 | sed ' s/.*\(0x..\)$/\1/'`
r_maj=`/usr/sbin/i2cget -y 600 0x32 0x1 | sed ' s/.*\(0x..\)$/\1/'`
echo "Slave CPLD 3: $((r_maj)).$((r_min))" >> $FIRMWARE_VERSION_FILE
#Slave CPLD 4 0x33 on i2c bus 600 ( physical FPGA I2C-1)
r_min=`/usr/sbin/i2cget -y 600 0x33 0x0 | sed ' s/.*\(0x..\)$/\1/'`
r_maj=`/usr/sbin/i2cget -y 600 0x33 0x1 | sed ' s/.*\(0x..\)$/\1/'`
echo "Slave CPLD 4: $((r_maj)).$((r_min))" >> $FIRMWARE_VERSION_FILE
}
init_devnum
if [ "$1" == "init" ]; then
@ -156,6 +201,7 @@ if [ "$1" == "init" ]; then
init_switch_port_led
install_python_api_package
python /usr/bin/qsfp_irq_enable.py
platform_firmware_versions
elif [ "$1" == "deinit" ]; then
sys_eeprom "delete_device"

View File

@ -14,11 +14,13 @@ try:
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp
from sonic_platform.eeprom import Eeprom
from sonic_platform.component import Component
from sonic_platform.psu import Psu
from sonic_platform.thermal import Thermal
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
MAX_Z9264F_COMPONENT = 8 # BIOS,BMC,FPGA,SYSTEM CPLD,4 SLAVE CPLDs
MAX_Z9264F_PSU = 2
MAX_Z9264F_THERMAL = 8
@ -55,15 +57,19 @@ class Chassis(ChassisBase):
self._sfp_list.append(sfp_node)
self._eeprom = Eeprom()
for i in range(MAX_Z9264F_COMPONENT):
component = Component(i)
self._component_list.append(component)
for i in range(MAX_Z9264F_PSU):
psu = Psu(i)
self._psu_list.append(psu)
for i in range(MAX_Z9264F_THERMAL):
thermal = Thermal(i)
self._thermal_list.append(thermal)
for port_num in range(self.PORT_START, (self.PORT_END + 1)):
presence = self.get_sfp(port_num).get_presence()
if presence:

View File

@ -0,0 +1,91 @@
#!/usr/bin/env python
########################################################################
# DELLEMC Z9264F
#
# Module contains an implementation of SONiC Platform Base API and
# provides the Components' (e.g., BIOS, CPLD, FPGA, BMC etc.) available in
# the platform
#
########################################################################
try:
import os
import re
from sonic_platform_base.component_base import ComponentBase
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
FIRMWARE_VERSION_FILE="/var/log/firmware_versions"
class Component(ComponentBase):
"""DellEMC Platform-specific Component class"""
CHASSIS_COMPONENTS = [
["BIOS", ("Performs initialization of hardware components during "
"booting")],
["FPGA", ("Used for managing the system LEDs")],
["BMC", ("Platform management controller for on-board temperature "
"monitoring, in-chassis power, Fan and LED control")],
["System CPLD", ("Used for managing the CPU power sequence and CPU states")],
["Slave CPLD 1", ("Used for managing QSFP/QSFP28 port transceivers (1-16)")],
["Slave CPLD 2", ("Used for managing QSFP/QSFP28 port transceivers (17-32)")],
["Slave CPLD 3", ("Used for managing QSFP/QSFP28 port transceivers (33-48)")],
["Slave CPLD 4", ("Used for managing QSFP/QSFP28 port transceivers (49-64) and SFP/SFP28 "
"port transceivers (65 and 66)")],
]
def __init__(self, component_index=0):
self.index = component_index
self.name = self.CHASSIS_COMPONENTS[self.index][0]
self.description = self.CHASSIS_COMPONENTS[self.index][1]
def get_name(self):
"""
Retrieves the name of the component
Returns:
A string containing the name of the component
"""
return self.name
def get_description(self):
"""
Retrieves the description of the component
Returns:
A string containing the description of the component
"""
return self.description
def get_firmware_version(self):
"""
Retrieves the firmware version of the component
Returns:
A string containing the firmware version of the component
"""
rv = ""
try:
fd = open(FIRMWARE_VERSION_FILE,"r")
except IOError:
return rv
version_contents = fd.read()
fd.close()
if not version_contents:
return rv
if self.index < 8:
version = re.search(r''+self.CHASSIS_COMPONENTS[self.index][0]+':(.*)',version_contents)
if version:
rv = version.group(1).strip()
return rv
def install_firmware(self, image_path):
"""
Installs firmware to the component
Args:
image_path: A string, path to firmware image
Returns:
A boolean, True if install was successful, False if not
"""
return False