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

[DELL][Z9100,S6100,S6000] Platform 2.0 SFP Changes #3229

Merged
merged 3 commits into from
Aug 13, 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
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__all__ = ["platform", "chassis"]
__all__ = ["platform", "chassis", "sfp"]
from sonic_platform import *
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
try:
import os
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

Expand All @@ -26,7 +27,23 @@ class Chassis(ChassisBase):
reset_reason_dict[0x6] = ChassisBase.REBOOT_CAUSE_NON_HARDWARE

def __init__(self):
ChassisBase.__init__(self)
# Initialize SFP list
PORT_START = 0
PORT_END = 31
EEPROM_OFFSET = 20
PORTS_IN_BLOCK = (PORT_END + 1)

# sfp.py will read eeprom contents and retrive the eeprom data.
# It will also provide support sfp controls like reset and setting
# low power mode.
# We pass the eeprom path and sfp control path from chassis.py
# So that sfp.py implementation can be generic to all platforms
eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
sfp_control = "/sys/devices/platform/dell-s6000-cpld.0/"
for index in range(0, PORTS_IN_BLOCK):
eeprom_path = eeprom_base.format(index + EEPROM_OFFSET)
sfp_node = Sfp(index, 'QSFP', eeprom_path, sfp_control, index)
self._sfp_list.append(sfp_node)

def get_register(self, reg_name):
rv = 'ERR'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__all__ = ["platform", "chassis", "fan", "psu"]
__all__ = ["platform", "chassis", "fan", "psu", "sfp"]
from sonic_platform import *

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
try:
import os
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp
from sonic_platform.psu import Psu
from sonic_platform.fan import Fan
from eeprom import Eeprom
Expand All @@ -30,6 +31,39 @@ class Chassis(ChassisBase):
HWMON_NODE = os.listdir(HWMON_DIR)[0]
MAILBOX_DIR = HWMON_DIR + HWMON_NODE

PORT_START = 0
PORT_END = 63
PORTS_IN_BLOCK = (PORT_END + 1)
IOM1_PORT_START = 0
IOM2_PORT_START = 16
IOM3_PORT_START = 32
IOM4_PORT_START = 48

PORT_I2C_MAPPING = {}
# 0th Index = i2cLine, 1st Index = EepromIdx in i2cLine
EEPROM_I2C_MAPPING = {
# IOM 1
0: [6, 66], 1: [6, 67], 2: [6, 68], 3: [6, 69],
4: [6, 70], 5: [6, 71], 6: [6, 72], 7: [6, 73],
8: [6, 74], 9: [6, 75], 10: [6, 76], 11: [6, 77],
12: [6, 78], 13: [6, 79], 14: [6, 80], 15: [6, 81],
# IOM 2
16: [8, 50], 17: [8, 51], 18: [8, 52], 19: [8, 53],
20: [8, 54], 21: [8, 55], 22: [8, 56], 23: [8, 57],
24: [8, 58], 25: [8, 59], 26: [8, 60], 27: [8, 61],
28: [8, 62], 29: [8, 63], 30: [8, 64], 31: [8, 65],
# IOM 3
32: [7, 34], 33: [7, 35], 34: [7, 36], 35: [7, 37],
36: [7, 38], 37: [7, 39], 38: [7, 40], 39: [7, 41],
40: [7, 42], 41: [7, 43], 42: [7, 44], 43: [7, 45],
44: [7, 46], 45: [7, 47], 46: [7, 48], 47: [7, 49],
# IOM 4
48: [9, 18], 49: [9, 19], 50: [9, 20], 51: [9, 21],
52: [9, 22], 53: [9, 23], 54: [9, 24], 55: [9, 25],
56: [9, 26], 57: [9, 27], 58: [9, 28], 59: [9, 29],
60: [9, 30], 61: [9, 31], 62: [9, 32], 63: [9, 33]
}

reset_reason_dict = {}
reset_reason_dict[11] = ChassisBase.REBOOT_CAUSE_POWER_LOSS
reset_reason_dict[33] = ChassisBase.REBOOT_CAUSE_WATCHDOG
Expand All @@ -55,6 +89,39 @@ def __init__(self):
psu = Psu(i)
self._psu_list.append(psu)

self._populate_port_i2c_mapping()

# sfp.py will read eeprom contents and retrive the eeprom data.
# It will also provide support sfp controls like reset and setting
# low power mode.
# We pass the eeprom path and sfp control path from chassis.py
# So that sfp.py implementation can be generic to all platforms
eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/i2c-{1}/{1}-0050/eeprom"
sfp_ctrl_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-003e/"
for index in range(0, self.PORTS_IN_BLOCK):
eeprom_path = eeprom_base.format(self.EEPROM_I2C_MAPPING[index][0],
self.EEPROM_I2C_MAPPING[index][1])
sfp_control = sfp_ctrl_base.format(self.PORT_I2C_MAPPING[index])
sfp_node = Sfp(index, 'QSFP', eeprom_path, sfp_control, index)
self._sfp_list.append(sfp_node)

def _populate_port_i2c_mapping(self):
# port_num and i2c match
for port_num in range(0, self.PORTS_IN_BLOCK):
if((port_num >= self.IOM1_PORT_START) and
(port_num < self.IOM2_PORT_START)):
i2c_line = 14
elif((port_num >= self.IOM2_PORT_START) and
(port_num < self.IOM3_PORT_START)):
i2c_line = 16
elif((port_num >= self.IOM3_PORT_START) and
(port_num <self.IOM4_PORT_START)):
i2c_line = 15
elif((port_num >= self.IOM4_PORT_START) and
(port_num < self.PORTS_IN_BLOCK)):
i2c_line = 17
self.PORT_I2C_MAPPING[port_num] = i2c_line

def _get_pmc_register(self, reg_name):
# On successful read, returns the value read from given
# reg_name and on failure returns 'ERR'
Expand Down
Loading