Skip to content

Commit

Permalink
[DellEMC]: EEPROM decoder for S6000, S6000-ON (#4718)
Browse files Browse the repository at this point in the history
**- Why I did it**

For decoding system EEPROM of S6000 based on Dell offset format and S6000-ON’s system EEPROM in ONIE TLV format.

**- How I did it**

- Differentiate between S6000 and S6000-ON using the product name available in ‘dmi’  ( “/sys/class/dmi/id/product_name” )
- For decoding S6000 system EEPROM in Dell offset format and updating the redis DB with the EEPROM contents, added a new class ‘EepromS6000’ in eeprom.py, 
- Renamed certain methods in both Eeprom, EepromS6000 classes to accommodate the plugin-specific methods.

**- How to verify it**

- Use 'decode-syseeprom' command to list the system EEPROM details.
- Wrote a python script to load chassis class and call the appropriate methods.

UT Logs: [S6000_eeprom_logs.txt](https://github.com/Azure/sonic-buildimage/files/4735515/S6000_eeprom_logs.txt), [S6000-ON_eeprom_logs.txt](https://github.com/Azure/sonic-buildimage/files/4735461/S6000-ON_eeprom_logs.txt)
Test script: [eeprom_test_py.txt](https://github.com/Azure/sonic-buildimage/files/4735509/eeprom_test_py.txt)
  • Loading branch information
ArunSaravananBalachandran authored Jun 9, 2020
1 parent 9505bdb commit 54b284f
Show file tree
Hide file tree
Showing 5 changed files with 292 additions and 23 deletions.
22 changes: 15 additions & 7 deletions device/dell/x86_64-dell_s6000_s1220-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@
#############################################################################

try:
from sonic_eeprom import eeprom_tlvinfo
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
from sonic_eeprom.eeprom_tlvinfo import TlvInfoDecoder
from sonic_platform.eeprom import EepromS6000
except ImportError as e:
raise ImportError(str(e) + "- required module not found")


class board(eeprom_tlvinfo.TlvInfoDecoder):
class board(object):

def __init__(self, name, path, cpld_root, ro):
self.eeprom_path = "/sys/class/i2c-adapter/i2c-10/10-0053/eeprom"
super(board, self).__init__(self.eeprom_path, 0, '', True)
def __new__(cls, name, path, cpld_root, ro):
eeprom_path = "/sys/class/i2c-adapter/i2c-10/10-0053/eeprom"

with open("/sys/class/dmi/id/product_name", "r") as fd:
board_type = fd.read()

if 'S6000-ON' in board_type:
return TlvInfoDecoder(eeprom_path, 0, '', True)
else:
return EepromS6000(is_plugin=True)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import subprocess
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp
from sonic_platform.eeprom import Eeprom
from sonic_platform.eeprom import Eeprom, EepromS6000
from sonic_platform.fan import Fan
from sonic_platform.psu import Psu
from sonic_platform.thermal import Thermal
Expand Down Expand Up @@ -68,7 +68,14 @@ def __init__(self):
# Get Transceiver status
self.modprs_register = self._get_transceiver_status()

self._eeprom = Eeprom()
with open("/sys/class/dmi/id/product_name", "r") as fd:
board_type = fd.read()

if 'S6000-ON' in board_type:
self._eeprom = Eeprom()
else:
self._eeprom = EepromS6000()

for i in range(MAX_S6000_FAN):
fan = Fan(i)
self._fan_list.append(fan)
Expand Down Expand Up @@ -138,7 +145,7 @@ def get_name(self):
Returns:
string: The name of the chassis
"""
return self._eeprom.modelstr()
return self._eeprom.get_model()

def get_presence(self):
"""
Expand All @@ -154,15 +161,15 @@ def get_model(self):
Returns:
string: Model/part number of chassis
"""
return self._eeprom.part_number_str()
return self._eeprom.get_part_number()

def get_serial(self):
"""
Retrieves the serial number of the chassis (Service tag)
Returns:
string: Serial number of chassis
"""
return self._eeprom.serial_str()
return self._eeprom.get_serial()

def get_status(self):
"""
Expand All @@ -181,7 +188,7 @@ def get_base_mac(self):
A string containing the MAC address in the format
'XX:XX:XX:XX:XX:XX'
"""
return self._eeprom.base_mac_addr()
return self._eeprom.get_base_mac()

def get_serial_number(self):
"""
Expand All @@ -191,7 +198,7 @@ def get_serial_number(self):
A string containing the hardware serial number for this
chassis.
"""
return self._eeprom.serial_number_str()
return self._eeprom.get_serial_number()

def get_system_eeprom_info(self):
"""
Expand Down
Loading

0 comments on commit 54b284f

Please sign in to comment.