Skip to content

Commit 50a75a5

Browse files
authored
Aligning SONiC code with sff8024 spec (#457)
* Updated sff8024.py to align with sff8024 spec (fixes and additions) * A fix for the method of retrieving the application advertisement list from the EEPROM of CMIS modules * Added a unit test to validate the result of get_application_advertisement() for applications with missing data
1 parent 655a5ff commit 50a75a5

File tree

3 files changed

+144
-14
lines changed

3 files changed

+144
-14
lines changed

sonic_platform_base/sonic_xcvr/api/public/cmis.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,34 +2034,34 @@ def get_application_advertisement(self):
20342034
key = "{}_{}".format(consts.HOST_ELECTRICAL_INTERFACE, app)
20352035
val = dic.get(key)
20362036
if val in [None, 'Unknown', 'Undefined']:
2037-
break
2037+
continue
20382038
buf['host_electrical_interface_id'] = val
20392039

20402040
prefix = map.get(self.xcvr_eeprom.read(consts.MEDIA_TYPE_FIELD))
20412041
if prefix is None:
2042-
break
2042+
continue
20432043
key = "{}_{}".format(prefix, app)
20442044
val = dic.get(key)
20452045
if val in [None, 'Unknown']:
2046-
break
2046+
continue
20472047
buf['module_media_interface_id'] = val
20482048

20492049
key = "{}_{}".format(consts.MEDIA_LANE_COUNT, app)
20502050
val = dic.get(key)
20512051
if val is None:
2052-
break
2052+
continue
20532053
buf['media_lane_count'] = val
20542054

20552055
key = "{}_{}".format(consts.HOST_LANE_COUNT, app)
20562056
val = dic.get(key)
20572057
if val is None:
2058-
break
2058+
continue
20592059
buf['host_lane_count'] = val
20602060

20612061
key = "{}_{}".format(consts.HOST_LANE_ASSIGNMENT_OPTION, app)
20622062
val = dic.get(key)
20632063
if val is None:
2064-
break
2064+
continue
20652065
buf['host_lane_assignment_options'] = val
20662066

20672067
key = "{}_{}".format(consts.MEDIA_LANE_ASSIGNMENT_OPTION, app)

sonic_platform_base/sonic_xcvr/codes/public/sff8024.py

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class Sff8024(XcvrCodes):
183183
5: 'base_t_media_interface'
184184
}
185185

186+
# Host Electrical Interface IDs
186187
HOST_ELECTRICAL_INTERFACE = {
187188
0: 'Undefined',
188189
1: '1000BASE -CX(Clause 39)',
@@ -250,14 +251,26 @@ class Sff8024(XcvrCodes):
250251
64: 'FOIC4.8 (ITU-T G.709.1 G.Sup58)',
251252
65: 'CAUI-4 C2M (Annex 83E) without FEC',
252253
66: 'CAUI-4 C2M (Annex 83E) with RS(528,514) FEC',
254+
67: '50GBASE-CR2 (Ethernet Technology Consortium) with RS(528,514) (Clause 91) FEC',
255+
68: '50GBASE-CR2 (Ethernet Technology Consortium) with BASE-R (Clause 74), Fire code FEC',
256+
69: '50GBASE-CR2 (Ethernet Technology Consortium) with no FEC',
257+
70: '100GBASE-CR1 (Clause 162)',
258+
71: '200GBASE-CR2 (Clause 162)',
259+
72: '400GBASE-CR4 (Clause 162)',
260+
73: '800G-ETC-CR8',
261+
74: '128GFC (FC-PI-8)',
253262
75: '100GAUI-1-S C2M (Annex 120G)',
254263
76: '100GAUI-1-L C2M (Annex 120G)',
264+
77: '200GAUI-2-S C2M (Annex 120G)',
265+
78: '200GAUI-2-L C2M (Annex 120G)',
255266
79: '400GAUI-4-S C2M (Annex 120G)',
256267
80: '400GAUI-4-L C2M (Annex 120G)',
257268
81: '800G S C2M (placeholder)',
258-
82: '800G L C2M (placeholder)'
269+
82: '800G L C2M (placeholder)',
270+
83: 'OTL4.2'
259271
}
260272

273+
# MMF media interface IDs
261274
NM_850_MEDIA_INTERFACE = {
262275
0: 'Undefined',
263276
1: '10GBASE-SW (Clause 52)',
@@ -278,16 +291,23 @@ class Sff8024(XcvrCodes):
278291
16: '400GBASE-SR8 (Clause 138)',
279292
17: '400G-SR4 (Placeholder)',
280293
18: '800G-SR8 (Placeholder)',
281-
26: '400GBASE-SR4.2 (Clause 150) (400GE BiDi)',
282294
19: '8GFC-MM (FC-PI-4)',
283295
20: '10GFC-MM (10GFC)',
284296
21: '16GFC-MM (FC-PI-5)',
285297
22: '32GFC-MM (FC-PI-6)',
286298
23: '64GFC-MM (FC-PI 7)',
287299
24: '128GFC-MM4 (FC-PI-6P)',
288-
25: '256GFC-MM4 (FC-PI-7P)'
300+
25: '256GFC-MM4 (FC-PI-7P)',
301+
26: '400GBASE-SR4.2 (Clause 150) (400GE BiDi)',
302+
27: '200G-SR2 (Clause 167)',
303+
28: '128GFC-MM (FC-PI-8)',
304+
29: '100G-VR1 (Clause 167)',
305+
30: '200G-VR2 (Clause 167)',
306+
31: '400G-VR4 (Clause 167)',
307+
32: '800G-VR8 (Placeholder)'
289308
}
290309

310+
# SMF media interface IDs
291311
SM_MEDIA_INTERFACE = {
292312
0: 'Undefined',
293313
1: '10GBASE-LW (Cl 52)',
@@ -326,9 +346,7 @@ class Sff8024(XcvrCodes):
326346
34: '32GFC-SM (FC-PI-6)',
327347
35: '64GFC-SM (FC-PI-7)',
328348
36: '128GFC-PSM4 (FC-PI-6P)',
329-
37: '256GFC-PSM4 (FC-PI-7P)',
330349
38: '128GFC-CWDM4 (FC-PI-6P)',
331-
39: '256GFC-CWDM4 (FC-PI-7P)',
332350
44: '4I1-9D1F (G.959.1)',
333351
45: '4L1-9C1F (G.959.1)',
334352
46: '4L1-9D1F (G.959.1)',
@@ -337,6 +355,7 @@ class Sff8024(XcvrCodes):
337355
49: '4I1-4D1F (G.959.1)',
338356
50: '8R1-4D1F (G.959.1)',
339357
51: '8I1-4D1F (G.959.1)',
358+
52: '100G CWDM4-OCP',
340359
56: '10G-SR',
341360
57: '10G-LR',
342361
58: '25G-SR',
@@ -345,18 +364,40 @@ class Sff8024(XcvrCodes):
345364
61: '25G-LR-BiDi',
346365
62: '400ZR, DWDM, amplified',
347366
63: '400ZR, Single Wavelength, Unamplified',
367+
64: '50GBASE-ER (Cl 139)',
368+
65: '200GBASE-ER4 (Cl 122)',
369+
66: '400GBASE-ER8 (Cl 122)',
370+
67: '400GBASE-LR4-6 (Cl 151)',
371+
68: '100GBASE-ZR (Cl 154)',
372+
69: '128GFC-SM (FC-PI-8)',
348373
70: 'ZR400-OFEC-16QAM',
349374
71: 'ZR300-OFEC-8QAM',
350375
72: 'ZR200-OFEC-QPSK',
351-
73: 'ZR100-OFEC-QPSK'
376+
73: 'ZR100-OFEC-QPSK',
377+
74: '100G-LR1-20',
378+
75: '100G-ER1-30',
379+
76: '100G-ER1-40',
380+
77: '400GBASE-ZR (Cl 156)',
381+
78: '10GBASE-BR (Cl 158)',
382+
79: '25GBASE-BR (Cl 159)',
383+
80: '50GBASE-BR (Cl 160)',
384+
81: 'FOIC1.4-DO (G.709.3/Y.1331.3)',
385+
82: 'FOIC2.8-DO (G.709.3/Y.1331.3)',
386+
83: 'FOIC4.8-DO (G.709.3/Y.1331.3)',
387+
84: 'FOIC2.4-DO (G.709.3/Y.1331.3)',
388+
85: '400GBASE-DR4-2 (placeholder)',
389+
86: '800GBASE-DR8 (placeholder)',
390+
87: '800GBASE-DR8-2 (placeholder)'
352391
}
353392

393+
# Passive and Linear Active Copper Cable and Passive Loopback media interface codes
354394
PASSIVE_COPPER_MEDIA_INTERFACE = {
355395
0: 'Undefined',
356396
1: 'Copper cable',
357-
2: 'Passive Loopback module'
397+
191: 'Passive Loopback module'
358398
}
359399

400+
# Limiting and Retimed Active Cable assembly and Active Loopback media interface codes
360401
ACTIVE_CABLE_MEDIA_INTERFACE = {
361402
0: 'Undefined',
362403
1: 'Active Cable assembly with BER < 10^-12',
@@ -366,12 +407,16 @@ class Sff8024(XcvrCodes):
366407
191: 'Active Loopback module'
367408
}
368409

410+
# BASE-T media interface codes
369411
BASE_T_MEDIA_INTERFACE = {
370412
0: 'Undefined',
371413
1: '1000BASE-T (Clause 40)',
372414
2: '2.5GBASE-T (Clause 126)',
373415
3: '5GBASE-T (Clause 126)',
374-
4: '10GBASE-T (Clause 55)'
416+
4: '10GBASE-T (Clause 55)',
417+
5: '25GBASE-T (Clause 113)',
418+
6: '40GBASE-T (Clause 113)',
419+
7: '50GBASE-T (Placeholder)'
375420
}
376421

377422
# TODO: Add other codes

tests/sonic_xcvr/test_cmis.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,91 @@ def test_get_application_advertisement(self):
21722172
assert result[1]['host_lane_assignment_options'] == 0x01
21732173
assert result[1]['media_lane_assignment_options'] == 0x02
21742174

2175+
def test_get_application_advertisement_apps_with_missing_data(self):
2176+
self.api.xcvr_eeprom.read = MagicMock()
2177+
self.api.xcvr_eeprom.read.side_effect = [
2178+
{
2179+
consts.HOST_ELECTRICAL_INTERFACE + "_1": "400GAUI-8 C2M (Annex 120E)",
2180+
consts.HOST_ELECTRICAL_INTERFACE + "_2": None,
2181+
consts.HOST_ELECTRICAL_INTERFACE + "_3": "200GAUI-8 C2M (Annex 120C)",
2182+
consts.HOST_ELECTRICAL_INTERFACE + "_4": "40GBASE-CR4 (Clause 85)",
2183+
consts.HOST_ELECTRICAL_INTERFACE + "_5": "50GBASE-CR (Clause 126)",
2184+
consts.HOST_ELECTRICAL_INTERFACE + "_6": "200GBASE-CR4 (Clause 136)",
2185+
consts.HOST_ELECTRICAL_INTERFACE + "_7": "200GAUI-2-S C2M (Annex 120G)",
2186+
consts.HOST_ELECTRICAL_INTERFACE + "_8": "800G S C2M (placeholder)",
2187+
2188+
consts.MODULE_MEDIA_INTERFACE_SM + "_1": "400GBASE-DR4 (Cl 124)",
2189+
consts.MODULE_MEDIA_INTERFACE_SM + "_2": "25GBASE-LR (Cl 114)",
2190+
consts.MODULE_MEDIA_INTERFACE_SM + "_3": "40GBASE-LR4 (Cl 87)",
2191+
consts.MODULE_MEDIA_INTERFACE_SM + "_4": None,
2192+
consts.MODULE_MEDIA_INTERFACE_SM + "_5": "10GBASE-LR (Cl 52)",
2193+
consts.MODULE_MEDIA_INTERFACE_SM + "_6": "50GBASE-FR (Cl 139)",
2194+
consts.MODULE_MEDIA_INTERFACE_SM + "_7": "100GBASE-DR (Cl 140)",
2195+
consts.MODULE_MEDIA_INTERFACE_SM + "_8": "800GBASE-DR8 (placeholder)",
2196+
2197+
consts.MEDIA_LANE_COUNT + "_1": 4,
2198+
consts.MEDIA_LANE_COUNT + "_2": 4,
2199+
consts.MEDIA_LANE_COUNT + "_3": 4,
2200+
consts.MEDIA_LANE_COUNT + "_4": 4,
2201+
consts.MEDIA_LANE_COUNT + "_5": None,
2202+
consts.MEDIA_LANE_COUNT + "_6": 4,
2203+
consts.MEDIA_LANE_COUNT + "_7": 4,
2204+
consts.MEDIA_LANE_COUNT + "_8": 4,
2205+
2206+
consts.HOST_LANE_COUNT + "_1": 8,
2207+
consts.HOST_LANE_COUNT + "_2": 8,
2208+
consts.HOST_LANE_COUNT + "_3": 8,
2209+
consts.HOST_LANE_COUNT + "_4": 8,
2210+
consts.HOST_LANE_COUNT + "_5": 8,
2211+
consts.HOST_LANE_COUNT + "_6": 8,
2212+
consts.HOST_LANE_COUNT + "_7": 8,
2213+
consts.HOST_LANE_COUNT + "_8": None,
2214+
2215+
consts.HOST_LANE_ASSIGNMENT_OPTION + "_1": 0x01,
2216+
consts.HOST_LANE_ASSIGNMENT_OPTION + "_2": 0x01,
2217+
consts.HOST_LANE_ASSIGNMENT_OPTION + "_3": 0x01,
2218+
consts.HOST_LANE_ASSIGNMENT_OPTION + "_4": 0x01,
2219+
consts.HOST_LANE_ASSIGNMENT_OPTION + "_5": 0x01,
2220+
consts.HOST_LANE_ASSIGNMENT_OPTION + "_6": 0x01,
2221+
consts.HOST_LANE_ASSIGNMENT_OPTION + "_7": None,
2222+
consts.HOST_LANE_ASSIGNMENT_OPTION + "_8": 0x01,
2223+
2224+
consts.MEDIA_LANE_ASSIGNMENT_OPTION + "_1": 0x02,
2225+
consts.MEDIA_LANE_ASSIGNMENT_OPTION + "_2": 0x02,
2226+
consts.MEDIA_LANE_ASSIGNMENT_OPTION + "_3": 0x02,
2227+
consts.MEDIA_LANE_ASSIGNMENT_OPTION + "_4": 0x02,
2228+
consts.MEDIA_LANE_ASSIGNMENT_OPTION + "_5": 0x02,
2229+
consts.MEDIA_LANE_ASSIGNMENT_OPTION + "_6": 0x02,
2230+
consts.MEDIA_LANE_ASSIGNMENT_OPTION + "_7": 0x02,
2231+
consts.MEDIA_LANE_ASSIGNMENT_OPTION + "_8": 0x02
2232+
},
2233+
Sff8024.MODULE_MEDIA_TYPE[2],
2234+
None,
2235+
Sff8024.MODULE_MEDIA_TYPE[2],
2236+
Sff8024.MODULE_MEDIA_TYPE[2],
2237+
Sff8024.MODULE_MEDIA_TYPE[2],
2238+
Sff8024.MODULE_MEDIA_TYPE[2],
2239+
Sff8024.MODULE_MEDIA_TYPE[2],
2240+
Sff8024.MODULE_MEDIA_TYPE[2]
2241+
]
2242+
result = self.api.get_application_advertisement()
2243+
2244+
assert len(result) == 2
2245+
2246+
assert result[1]['host_electrical_interface_id'] == '400GAUI-8 C2M (Annex 120E)'
2247+
assert result[1]['module_media_interface_id'] == '400GBASE-DR4 (Cl 124)'
2248+
assert result[1]['host_lane_count'] == 8
2249+
assert result[1]['media_lane_count'] == 4
2250+
assert result[1]['host_lane_assignment_options'] == 0x01
2251+
assert result[1]['media_lane_assignment_options'] == 0x02
2252+
2253+
assert result[6]['host_electrical_interface_id'] == '200GBASE-CR4 (Clause 136)'
2254+
assert result[6]['module_media_interface_id'] == '50GBASE-FR (Cl 139)'
2255+
assert result[6]['host_lane_count'] == 8
2256+
assert result[6]['media_lane_count'] == 4
2257+
assert result[6]['host_lane_assignment_options'] == 0x01
2258+
assert result[6]['media_lane_assignment_options'] == 0x02
2259+
21752260
def test_get_application_advertisement_non_support(self):
21762261
self.api.xcvr_eeprom.read = MagicMock(return_value = None)
21772262
self.api.is_flat_memory = MagicMock(return_value = False)

0 commit comments

Comments
 (0)