Skip to content

Commit d59aecd

Browse files
aditya-nexthopabhi-nexthopbgallagher-nexthop
authored
Create ELSFP memory map classes (#678)
* add elsfp pages and mem map Signed-off-by: Abhi Singh <abhi@nexthop.ai> * Refactor ELSFP memory map to use page-driven field registration Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai> * Add module function type, fix some bugs Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai> * Adding VDM and CDB pages to ELSFP memory map Signed-off-by: aditya-nexthop <aditya@nexthop.ai> * Add page parameters to ELSFP pages Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai> * Updating filename comment in new ELSFP page files Signed-off-by: aditya-nexthop <aditya@nexthop.ai> * Addressed review comments Signed-off-by: aditya-nexthop <aditya@nexthop.ai> * Adding a unit test to increase coverage Signed-off-by: aditya-nexthop <aditya@nexthop.ai> * Move all the elsfp files from cmis/ to cmis/elsfp/ and address open review comments Signed-off-by: aditya-nexthop <aditya@nexthop.ai> --------- Signed-off-by: Abhi Singh <abhi@nexthop.ai> Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai> Signed-off-by: aditya-nexthop <aditya@nexthop.ai> Co-authored-by: Abhi Singh <abhi@nexthop.ai> Co-authored-by: Brian Gallagher <bgallagher@nexthop.ai>
1 parent ef6286f commit d59aecd

15 files changed

Lines changed: 977 additions & 2 deletions

File tree

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
'sonic_platform_base.sonic_xcvr.mem_maps.public',
4848
'sonic_platform_base.sonic_xcvr.mem_maps.public.cmis',
4949
'sonic_platform_base.sonic_xcvr.mem_maps.public.cmis.pages',
50+
'sonic_platform_base.sonic_xcvr.mem_maps.public.cmis.elsfp',
51+
'sonic_platform_base.sonic_xcvr.mem_maps.public.cmis.elsfp.pages',
5052
'sonic_platform_base.sonic_xcvr.api',
5153
'sonic_platform_base.sonic_xcvr.api.public',
5254
'sonic_platform_base.sonic_xcvr.codes',

sonic_platform_base/sonic_xcvr/codes/public/cmis.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ class CmisCodes(Sff8024):
3333
17: 'L-band tunable laser',
3434
}
3535

36+
MODULE_FUNCTION_TYPE = {
37+
0: 'Transmission Module',
38+
1: 'Resource Module',
39+
}
40+
3641
MODULE_STATE = {
3742
1: 'ModuleLowPwr',
3843
2: 'ModulePwrUp',
@@ -100,6 +105,24 @@ class CmisCodes(Sff8024):
100105
22: ['Errored Frames Average Host Input', 'F16', 1, 'S'],
101106
23: ['Errored Frames Current Value Media Input', 'F16', 1, 'B'],
102107
24: ['Errored Frames Current Value Host Input', 'F16', 1, 'B'],
108+
25: ['FERC Total Accumulated Media Input', 'F16', 1, 'S'],
109+
26: ['FERC Total Accumulated Host Input', 'F16', 1, 'S'],
110+
27: ['SEWmax Minimum Sample Value Media Input', 'U16', 1, 'S'],
111+
28: ['SEWmax Minimum Sample Value Host Input', 'U16', 1, 'S'],
112+
29: ['SEWmax Maximum Sample Value Media Input', 'U16', 1, 'S'],
113+
30: ['SEWmax Maximum Sample Value Host Input', 'U16', 1, 'S'],
114+
31: ['SEWmax Sample Average Value Media Input', 'U16', 1, 'S'],
115+
32: ['SEWmax Sample Average Value Host Input', 'U16', 1, 'S'],
116+
33: ['SEWmax Current Sample Value Media Input', 'U16', 1, 'B'],
117+
34: ['SEWmax Current Sample Value Host Input', 'U16', 1, 'B'],
118+
77: ['Vcc2p6 Voltage Monitor [V]', 'U16', 100e-6, 'B'],
119+
78: ['Vcc1p8 Voltage Monitor [V]', 'U16', 100e-6, 'B'],
120+
79: ['Vcc1p2 Voltage Monitor [V]', 'U16', 100e-6, 'B'],
121+
80: ['Vcc0p9 Voltage Monitor [V]', 'U16', 100e-6, 'B'],
122+
81: ['Vcc0p7A Voltage Monitor [V]', 'U16', 100e-6, 'B'],
123+
82: ['Vcc0p7B Voltage Monitor [V]', 'U16', 100e-6, 'B'],
124+
83: ['Vcc12 Voltage Monitor [V]', 'U16', 250e-6, 'B'],
125+
84: ['ELS Input Power [dBm]', 'S16', 0.01, 'B'],
103126
128: ['Modulator Bias X/I [%]', 'U16', 100.0/65535, 'B'],
104127
129: ['Modulator Bias X/Q [%]', 'U16', 100.0/65535, 'B'],
105128
130: ['Modulator Bias Y/I [%]', 'U16', 100.0/65535, 'B'],
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""
2+
elsfp.py
3+
4+
Code definitions for ELSFP (External Laser Source Function Plug),
5+
per OIF-ELSFP-CMIS-01.0.
6+
"""
7+
8+
from .cmis import CmisCodes
9+
10+
11+
class ElsfpCodes(CmisCodes):
12+
CONTROL_MODE = {
13+
0: 'ACC', # Automatic Current Control
14+
1: 'APC', # Automatic Power Control
15+
}
16+
17+
LANE_FAULT_CODE = {
18+
0: 'No alarm detected',
19+
1: 'Automatic Power Control (APC) control loop failure',
20+
2: 'Automatic Current Control (ACC) control loop failure',
21+
3: 'Reserved',
22+
4: 'Reserved',
23+
5: 'Reserved',
24+
6: 'Reserved',
25+
7: 'Reserved',
26+
8: 'Reserved',
27+
9: 'Vendor specific fault',
28+
10: 'Vendor specific fault',
29+
11: 'Vendor specific fault',
30+
12: 'Vendor specific fault',
31+
13: 'Vendor specific fault',
32+
14: 'Vendor specific fault',
33+
15: 'Vendor specific fault',
34+
}
35+
36+
LANE_WARNING_CODE = {
37+
0: 'No warning detected',
38+
1: 'Automatic Power Control (APC) control loop warning',
39+
2: 'Automatic Current Control (ACC) control loop warning',
40+
3: 'Reserved',
41+
4: 'Reserved',
42+
5: 'Reserved',
43+
6: 'Reserved',
44+
7: 'Reserved',
45+
8: 'Reserved',
46+
9: 'Vendor specific warning',
47+
10: 'Vendor specific warning',
48+
11: 'Vendor specific warning',
49+
12: 'Vendor specific warning',
50+
13: 'Vendor specific warning',
51+
14: 'Vendor specific warning',
52+
15: 'Vendor specific warning',
53+
}
54+
55+
LANE_STATE = {
56+
0: 'Lane Output off',
57+
1: 'Lane Output ramping',
58+
2: 'Lane Output on',
59+
3: 'Reserved',
60+
}

sonic_platform_base/sonic_xcvr/fields/consts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
STATUS_IND_BITS_FIELD = "Status Indicator Bits"
88

99
FLAT_MEM_FIELD = "Flat_mem"
10+
MODULE_FUNCTION_TYPE = "ModuleFunctionType"
1011
CONNECTOR_FIELD = "Connector"
1112

1213
DIAG_MON_TYPE_FIELD = "Diagnostic Monitoring Type"
@@ -304,6 +305,7 @@
304305
MAX_POWER_FIELD = "MaxPower"
305306
MGMT_CHAR_FIELD = "Management Characteristics"
306307
MGMT_CHAR_MISC_FIELD = "Management Characteristics (Misc)"
308+
EXTENDED_MODULE_INFO_FIELD = "ExtendedModuleInfo"
307309

308310
MODULE_CHAR_ADVT_FIELD = "Module Characteristics Advertising"
309311

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# ELSFP-specific field name constants (Pages 1Ah and 1Bh)
2+
3+
# Group name constants (used as group fields)
4+
ELSFP_MODULE_ADVERTISEMENTS_FIELD = "ElsfpModuleAdvertisements"
5+
ELSFP_LANE_FAULTS_WARNINGS_FIELD = "ElsfpLaneFaultsWarnings"
6+
ELSFP_LASER_SAVE_RESTORE_FIELD = "ElsfpLaserSaveRestore"
7+
ELSFP_ALARMS_WARNINGS_MASKS_FIELD = "ElsfpAlarmsWarningsMasks"
8+
ELSFP_LANE_CONTROLS_FIELD = "ElsfpLaneControls" # Table 8: Bytes 220-222
9+
ELSFP_OUTPUT_FIBER_CHECKED_FIELD = "ElsfpOutputFiberChecked" # Table 9: Byte 223
10+
ELSFP_LANE_MAPPING_FREQ_POWER_FIELD = "ElsfpLaneMappingFreqPower" # Table 10: Bytes 224-255
11+
ELSFP_SETPOINTS_FIELD = "ElsfpSetpoints"
12+
ELSFP_MONITORS_FIELD = "ElsfpMonitors"
13+
14+
# Page 1Ah: ELSFP Advertisements, Flags, and Controls
15+
16+
# Module Advertisements (Bytes 128-164)
17+
MAX_OPTICAL_POWER = "MaxOpticalPower"
18+
MIN_OPTICAL_POWER = "MinOpticalPower"
19+
MAX_LASER_BIAS = "MaxLaserBias"
20+
MIN_LASER_BIAS = "MinLaserBias"
21+
22+
# Container byte for ControlModeAPCACC/NumberOfLanes (byte 140)
23+
CONTROL_MODE_AND_LANE_COUNT = "ElsfpControlModeAndLaneCount"
24+
25+
CONTROL_MODE_APC_ACC = "ControlModeAPCACC"
26+
NUMBER_OF_LANES = "NumberOfLanes"
27+
BIAS_HIGH_ALARM = "BiasHighAlarm"
28+
BIAS_LOW_ALARM = "BiasLowAlarm"
29+
BIAS_HIGH_WARN = "BiasHighWarn"
30+
BIAS_LOW_WARN = "BiasLowWarn"
31+
OPT_POWER_HIGH_ALARM = "OptPowerHighAlarm"
32+
OPT_POWER_LOW_ALARM = "OptPowerLowAlarm"
33+
OPT_POWER_HIGH_WARN = "OptPowerHighWarn"
34+
OPT_POWER_LOW_WARN = "OptPowerLowWarn"
35+
36+
# Lane Faults and Warnings (Bytes 165-181)
37+
LANE_SUMMARY_STATUS = "ElsfpLaneSummaryStatus"
38+
LANE_SUMMARY_FAULT = "LaneSummaryFault"
39+
LANE_SUMMARY_WARNING = "LaneSummaryWarning"
40+
FAULT_FLAG_LANE_FIELD = "FaultFlagLanes"
41+
WARN_FLAG_LANE_FIELD = "WarnFlagLanes"
42+
43+
# Laser Setting and Save/Restore (Bytes 182-185)
44+
SAVE_RESTORE_COMMAND = "SaveRestoreCommand"
45+
SAVE_RESTORE_CONFIRM = "SaveRestoreConfirm"
46+
47+
# Laser Alarms, Warnings, Faults, and Masks (Bytes 186-219)
48+
HIGH_BIAS_ALARM_INDEXED_FIELD = "HighBiasAlarmIndexed"
49+
LOW_BIAS_ALARM_INDEXED_FIELD = "LowBiasAlarmIndexed"
50+
HIGH_BIAS_WARN_INDEXED_FIELD = "HighBiasWarnIndexed"
51+
LOW_BIAS_WARN_INDEXED_FIELD = "LowBiasWarnIndexed"
52+
HIGH_POWER_ALARM_INDEXED_FIELD = "HighPowerAlarmIndexed"
53+
LOW_POWER_ALARM_INDEXED_FIELD = "LowPowerAlarmIndexed"
54+
HIGH_POWER_WARN_INDEXED_FIELD = "HighPowerWarnIndexed"
55+
LOW_POWER_WARN_INDEXED_FIELD = "LowPowerWarnIndexed"
56+
57+
HIGH_BIAS_ALARM_MASK_FIELD = "HighBiasAlarmMask"
58+
LOW_BIAS_ALARM_MASK_FIELD = "LowBiasAlarmMask"
59+
HIGH_BIAS_WARN_MASK_FIELD = "HighBiasWarnMask"
60+
LOW_BIAS_WARN_MASK_FIELD = "LowBiasWarnMask"
61+
HIGH_POWER_ALARM_MASK_FIELD = "HighPowerAlarmMask"
62+
LOW_POWER_ALARM_MASK_FIELD = "LowPowerAlarmMask"
63+
HIGH_POWER_WARN_MASK_FIELD = "HighPowerWarnMask"
64+
LOW_POWER_WARN_MASK_FIELD = "LowPowerWarnMask"
65+
66+
GLOBAL_ALARM_MASK_FIELD = "GlobalAlarmMask"
67+
GLOBAL_WARN_MASK_FIELD = "GlobalWarnMask"
68+
FAULT_CODE_FIELD = "FaultCode"
69+
WARNING_CODE_FIELD = "WarningCode"
70+
71+
# Laser Controls, State, and Additional Info (Bytes 220-255)
72+
LANE_ENABLE_FIELD = "LaneEnable"
73+
LANE_STATE_FIELD = "LaneState"
74+
OUTPUT_FIBER_CHECKED_FLAG_LANE_FIELD = "OutputFiberCheckedFlagLane"
75+
LANE_TO_FIBER_MAPPING_FIELD = "LaneToFiberMapping"
76+
LANE_FREQ_FIELD = "LaneFreq"
77+
OPT_CHECK_POWER_SETPOINT = "OptCheckPowerSetpoint"
78+
79+
# Page 1Bh: Laser Setpoints and Monitors
80+
81+
# Laser Current and Optical Power Setpoints (Bytes 128-183)
82+
BIAS_CURRENT_SETPOINT_FIELD = "BiasCurrentSetpoint"
83+
OPT_POWER_SETPOINT_FIELD = "OptPowerSetpoint"
84+
85+
# Laser Current, Optical, and Voltage Monitors (Bytes 184-255)
86+
BIAS_CURRENT_MONITOR_FIELD = "BiasCurrentMonitor"
87+
OPT_POWER_MONITOR_FIELD = "OptPowerMonitor"
88+
VOLTAGE_MONITOR_FIELD = "VoltageMonitor"
89+
ICC_MONITOR = "ICCMonitor"
90+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""
2+
cmis.elsfp package
3+
4+
Re-exports ElsfpMemMap so existing imports of the form
5+
`from sonic_platform_base.sonic_xcvr.mem_maps.public.cmis.elsfp import X`
6+
keep resolving after the elsfp.py module became the elsfp/ package.
7+
"""
8+
9+
from .elsfp import ElsfpMemMap
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""
2+
elsfp.py
3+
4+
Implementation of XcvrMemMap for ELSFP
5+
Extends CMIS Rev 5.0 with ELSFP-specific pages 1Ah and 1Bh
6+
"""
7+
8+
from ..cmis import CmisFlatMemMap
9+
10+
# Standard CMIS page classes that an ELSFP module exposes.
11+
from ..pages import (
12+
CmisAdvertisingPage,
13+
CmisThresholdsPage,
14+
CmisVdmAdvertisingCtrlPage,
15+
CmisCdbMessagePage,
16+
)
17+
18+
# ELSFP-specific page classes (pages 1Ah and 1Bh).
19+
from .pages import (
20+
ElsfpAdvertisementsFlagsCtrlPage,
21+
ElsfpSetpointsMonitorsPage,
22+
)
23+
24+
25+
class ElsfpMemMap(CmisFlatMemMap):
26+
"""
27+
Memory map for ELSFP.
28+
29+
Inherits CmisFlatMemMap (Page 00h) and adds:
30+
- Page 01h: CMIS Advertising
31+
- Page 02h: CMIS Thresholds
32+
- Page 1Ah: ELSFP Advertisements, Flags, and Controls
33+
- Page 1Bh: ELSFP Setpoints and Monitors
34+
- Page 2Fh: CMIS VDM Advertising and Control (optional on ELSFP modules)
35+
- Page 9Fh: CMIS CDB Message (optional on ELSFP modules)
36+
37+
Excludes CMIS pages 10h, 11h, 12h, 13h (lane datapath and module control pages).
38+
"""
39+
40+
def __init__(self, codes, bank=0):
41+
# Initialize base CmisFlatMemMap (Page 00h lower and upper)
42+
super(ElsfpMemMap, self).__init__(codes, bank=bank)
43+
44+
self.add_pages(
45+
CmisAdvertisingPage(codes), # 0x01
46+
CmisThresholdsPage(codes), # 0x02
47+
ElsfpAdvertisementsFlagsCtrlPage(codes, bank=bank), # 0x1A
48+
ElsfpSetpointsMonitorsPage(codes, bank=bank), # 0x1B
49+
CmisVdmAdvertisingCtrlPage(codes, bank=bank), # 0x2F
50+
CmisCdbMessagePage(codes, bank=bank), # 0x9F
51+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
cmis.elsfp.pages package
3+
4+
ELSFP-specific CMIS page classes (page 1Ah and page 1Bh).
5+
"""
6+
7+
from .consts import (
8+
ELSFP_ADVERTISEMENTS_FLAGS_CTRL_PAGE,
9+
ELSFP_SETPOINTS_MON_PAGE,
10+
)
11+
from .page1a import ElsfpAdvertisementsFlagsCtrlPage
12+
from .page1b import ElsfpSetpointsMonitorsPage
13+
14+
__all__ = [
15+
'ELSFP_ADVERTISEMENTS_FLAGS_CTRL_PAGE',
16+
'ELSFP_SETPOINTS_MON_PAGE',
17+
'ElsfpAdvertisementsFlagsCtrlPage',
18+
'ElsfpSetpointsMonitorsPage',
19+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
consts.py
3+
4+
ELSFP-specific CMIS page number constants.
5+
"""
6+
7+
ELSFP_ADVERTISEMENTS_FLAGS_CTRL_PAGE = 0x1A
8+
ELSFP_SETPOINTS_MON_PAGE = 0x1B

0 commit comments

Comments
 (0)