Skip to content

Commit ce9aacb

Browse files
authored
EEPROM/DOM Info: The Compliance Code will show "unknown" by using FINISAR 10G LR XCVR (sonic-net#319)
* JIRA-SONIC-5341: [eBay_ec202111_214] EEPROM/DOM Info: The Compliance Code will show "unknown" by using FINISAR 10G LR XCVR correct the code mapping * Fix others error code mapping and add unit test
1 parent 7c48be2 commit ce9aacb

File tree

8 files changed

+129
-48
lines changed

8 files changed

+129
-48
lines changed

sonic_platform_base/sonic_xcvr/codes/public/sff8436.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ class Sff8436Codes(Sff8024):
1515

1616
POWER_CLASSES = {
1717
0: "Power Class 1 Module (1.5W max. Power consumption)",
18-
64: "Power Class 2 Module (2.0W max. Power consumption)",
19-
128: "Power Class 3 Module (2.5W max. Power consumption)",
20-
192: "Power Class 4 Module (3.5W max. Power consumption)",
18+
1: "Power Class 2 Module (2.0W max. Power consumption)",
19+
2: "Power Class 3 Module (2.5W max. Power consumption)",
20+
3: "Power Class 4 Module (3.5W max. Power consumption)",
2121
}
2222

2323
CLEI_CODE = {
2424
0: "No CLEI code present in Page 02h",
25-
16: "CLEI code present in Page 02h"
25+
1: "CLEI code present in Page 02h"
2626
}
2727

2828
CDR_TX = {
2929
0: "No CDR in TX",
30-
8: "CDR present in TX"
30+
1: "CDR present in TX"
3131
}
3232

3333
CDR_RX = {
3434
0: "No CDR in RX",
35-
4: "CDR present in RX"
35+
1: "CDR present in RX"
3636
}
3737

3838
ETHERNET_10_40G_COMPLIANCE = {
@@ -65,20 +65,20 @@ class Sff8436Codes(Sff8024):
6565
}
6666

6767
FIBRE_CHANNEL_LINK_LENGTH = {
68-
8: "Medium (M)",
69-
16: "Long distance (L)",
70-
32: "Intermediate distance (I)",
71-
64: "Short distance (S)",
72-
128: "Very long distance (V)"
68+
1: "Medium (M)",
69+
2: "Long distance (L)",
70+
4: "Intermediate distance (I)",
71+
8: "Short distance (S)",
72+
16: "Very long distance (V)"
7373
}
7474

7575
FIBRE_CHANNEL_TRANSMITTER_TECH = {
76-
16: "Longwave Laser (LL)",
77-
32: "Shortwave laser w OFC (SL)",
78-
64: "Shortwave laser w/o OFC (SN)",
79-
128: "Electrical intra-enclosure",
80-
256: "Electrical inter-enclosure (EN)",
81-
512: "Longwave laser (LC)"
76+
1: "Longwave Laser (LL)",
77+
2: "Shortwave laser w OFC (SL)",
78+
4: "Shortwave laser w/o OFC (SN)",
79+
8: "Electrical intra-enclosure",
80+
16: "Electrical inter-enclosure (EN)",
81+
32: "Longwave laser (LC)"
8282
}
8383

8484
FIBRE_CHANNEL_TRANSMISSION_MEDIA = {

sonic_platform_base/sonic_xcvr/codes/public/sff8472.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ class Sff8472Codes(Sff8024):
3737
192: "Power Class 4 Module (3.5W max.)",
3838
193: "Power Class 5 Module (4.0W max.)",
3939
194: "Power Class 6 Module (4.5W max.)",
40-
197: "Power Class 7 Module (5.0W max.)",
40+
195: "Power Class 7 Module (5.0W max.)",
4141
32: "Power Class 8 Module",
4242
}
4343

4444
ETHERNET_10G_COMPLIANCE = {
45-
16: "10GBASE-SR",
46-
32: "10GBASE-LR",
47-
64: "10GBASE-LRM",
48-
128: "10GBASE-ER",
45+
1: "10GBASE-SR",
46+
2: "10GBASE-LR",
47+
4: "10GBASE-LRM",
48+
8: "10GBASE-ER",
4949
}
5050

5151
INFINIBAND_COMPLIANCE = {
@@ -56,8 +56,8 @@ class Sff8472Codes(Sff8024):
5656
}
5757

5858
ESCON_COMPLIANCE = {
59-
128: "ESCON MMF, 1310nm LED",
60-
64: "ESCON SMF, 1310nm Laser"
59+
2: "ESCON MMF, 1310nm LED",
60+
1: "ESCON SMF, 1310nm Laser"
6161
}
6262

6363
SONET_COMPLIANCE = {
@@ -87,21 +87,21 @@ class Sff8472Codes(Sff8024):
8787
}
8888

8989
FIBRE_CHANNEL_LINK_LENGTH = {
90-
8: "Medium (M)",
91-
16: "Long distance (L)",
92-
32: "Intermediate distance (I)",
93-
64: "Short distance (S)",
94-
128: "Very long distance (V)"
90+
1: "Medium (M)",
91+
2: "Long distance (L)",
92+
4: "Intermediate distance (I)",
93+
8: "Short distance (S)",
94+
16: "Very long distance (V)"
9595
}
9696

9797
FIBRE_CHANNEL_TRANSMITTER_TECH = {
98-
16: "Longwave Laser (LL)",
99-
32: "Shortwave laser w OFC (SL)",
100-
64: "Shortwave laser w/o OFC (SN)",
101-
128: "Electrical intra-enclosure (EL)",
102-
256: "Electrical inter-enclosure (EL)",
103-
512: "Longwave laser (LC)",
104-
1024: "Shortwave laser, linear RX (SA)"
98+
1: "Longwave Laser (LL)",
99+
2: "Shortwave laser w OFC (SL)",
100+
4: "Shortwave laser w/o OFC (SN)",
101+
8: "Electrical intra-enclosure (EL)",
102+
16: "Electrical inter-enclosure (EL)",
103+
32: "Longwave laser (LC)",
104+
64: "Shortwave laser, linear RX (SA)"
105105
}
106106

107107
SFP_CABLE_TECH = {

sonic_platform_base/sonic_xcvr/codes/public/sff8636.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Sff8636Codes(Sff8024):
3232
192: "Power Class 4 Module (3.5W max.)",
3333
193: "Power Class 5 Module (4.0W max.)",
3434
194: "Power Class 6 Module (4.5W max.)",
35-
197: "Power Class 7 Module (5.0W max.)",
35+
195: "Power Class 7 Module (5.0W max.)",
3636
32: "Power Class 8 Module",
3737
}
3838

@@ -91,12 +91,12 @@ class Sff8636Codes(Sff8024):
9191
}
9292

9393
FIBRE_CHANNEL_TRANSMITTER_TECH = {
94-
16: "Longwave Laser (LL)",
95-
32: "Shortwave laser w OFC (SL)",
96-
64: "Shortwave laser w/o OFC (SN)",
97-
128: "Electrical intra-enclosure",
98-
256: "Electrical inter-enclosure (EN)",
99-
512: "Longwave laser (LC)"
94+
1: "Longwave Laser (LL)",
95+
2: "Shortwave laser w OFC (SL)",
96+
4: "Shortwave laser w/o OFC (SN)",
97+
8: "Electrical intra-enclosure",
98+
16: "Electrical inter-enclosure (EN)",
99+
32: "Longwave laser (LC)"
100100
}
101101

102102
FIBRE_CHANNEL_TRANSMISSION_MEDIA = {

sonic_platform_base/sonic_xcvr/mem_maps/public/sff8436.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def __init__(self, codes):
4848
*(RegBitField("%s_%d" % (consts.FIBRE_CHANNEL_LINK_LENGTH_FIELD, bit), bit) for bit in range(3, 8))
4949
),
5050
CodeRegField(consts.FIBRE_CHANNEL_TRANSMITTER_TECH_FIELD, self.get_addr(0, 135), self.codes.FIBRE_CHANNEL_TRANSMITTER_TECH,
51-
*(RegBitField("%s_%d" % (consts.FIBRE_CHANNEL_TRANSMITTER_TECH_FIELD, bit), bit) for bit in list(range(0,3)) + list(range(8, 16))),
52-
size=2, format="<H"
51+
*(RegBitField("%s_%d" % (consts.FIBRE_CHANNEL_TRANSMITTER_TECH_FIELD, bit), bit) for bit in range(4, 11)),
52+
size=2, format=">H"
5353
),
5454
CodeRegField(consts.FIBRE_CHANNEL_TRANSMISSION_MEDIA_FIELD, self.get_addr(0, 137), self.codes.FIBRE_CHANNEL_TRANSMISSION_MEDIA),
5555
CodeRegField(consts.FIBRE_CHANNEL_SPEED_FIELD, self.get_addr(0, 138), self.codes.FIBRE_CHANNEL_SPEED),
@@ -139,4 +139,4 @@ def __init__(self, codes):
139139
)
140140

141141
def get_addr(self, page, offset, page_size=128):
142-
return page * page_size + offset
142+
return page * page_size + offset

sonic_platform_base/sonic_xcvr/mem_maps/public/sff8636.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def __init__(self, codes):
5858
*(RegBitField("%s_%d" % (consts.FIBRE_CHANNEL_LINK_LENGTH_FIELD, bit), bit) for bit in range(3, 8))
5959
),
6060
CodeRegField(consts.FIBRE_CHANNEL_TRANSMITTER_TECH_FIELD, self.get_addr(0, 135), self.codes.FIBRE_CHANNEL_TRANSMITTER_TECH,
61-
*(RegBitField("%s_%d" % (consts.FIBRE_CHANNEL_TRANSMITTER_TECH_FIELD, bit), bit) for bit in list(range(0,3)) + list(range(8, 16))),
62-
size=2, format="<H"
61+
*(RegBitField("%s_%d" % (consts.FIBRE_CHANNEL_TRANSMITTER_TECH_FIELD, bit), bit) for bit in range(4, 11)),
62+
size=2, format=">H"
6363
),
6464
CodeRegField(consts.FIBRE_CHANNEL_TRANSMISSION_MEDIA_FIELD, self.get_addr(0, 137), self.codes.FIBRE_CHANNEL_TRANSMISSION_MEDIA),
6565
CodeRegField(consts.FIBRE_CHANNEL_SPEED_FIELD, self.get_addr(0, 138), self.codes.FIBRE_CHANNEL_SPEED),

tests/sonic_xcvr/test_sff8436.py

+31
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from mock import MagicMock, patch
2+
import pytest
3+
24

35
from sonic_platform_base.sonic_xcvr.api.public.sff8436 import Sff8436Api
46
from sonic_platform_base.sonic_xcvr.codes.public.sff8436 import Sff8436Codes
57
from sonic_platform_base.sonic_xcvr.mem_maps.public.sff8436 import Sff8436MemMap
68
from sonic_platform_base.sonic_xcvr.xcvr_eeprom import XcvrEeprom
9+
from sonic_platform_base.sonic_xcvr.fields import consts
710

811
class TestSff8436(object):
912
codes = Sff8436Codes
@@ -52,6 +55,33 @@ def test_api(self):
5255
self.api.get_lpmode_support()
5356
self.api.get_power_override_support()
5457

58+
@pytest.mark.parametrize("mock_response, expected", [
59+
(bytearray([0x0]), "Power Class 1 Module (1.5W max. Power consumption)"),
60+
(bytearray([0x40]), "Power Class 2 Module (2.0W max. Power consumption)"),
61+
(bytearray([0x80]), "Power Class 3 Module (2.5W max. Power consumption)"),
62+
(bytearray([0xC0]), "Power Class 4 Module (3.5W max. Power consumption)")
63+
])
64+
def test_power_class(self, mock_response, expected):
65+
self.api.xcvr_eeprom.reader = MagicMock()
66+
self.api.xcvr_eeprom.reader.return_value = mock_response
67+
result = self.api.xcvr_eeprom.read(consts.POWER_CLASS_FIELD)
68+
assert result == expected
69+
70+
71+
@pytest.mark.parametrize("mock_response, expected", [
72+
(bytearray([0x02, 0x0]), "Longwave laser (LC)"),
73+
(bytearray([0x01, 0x0]), "Electrical inter-enclosure (EN)"),
74+
(bytearray([0x0, 0x80]), "Electrical intra-enclosure"),
75+
(bytearray([0x0, 0x40]), "Shortwave laser w/o OFC (SN)"),
76+
(bytearray([0x0, 0x20]), "Shortwave laser w OFC (SL)"),
77+
(bytearray([0x0, 0x10]), "Longwave Laser (LL)")
78+
])
79+
def test_fiber_channel_transmitter_tech(self, mock_response, expected):
80+
self.api.xcvr_eeprom.reader = MagicMock()
81+
self.api.xcvr_eeprom.reader.return_value = mock_response
82+
result = self.api.xcvr_eeprom.read(consts.FIBRE_CHANNEL_TRANSMITTER_TECH_FIELD)
83+
assert result == expected
84+
5585
def test_is_copper(self):
5686
with patch.object(self.api, 'xcvr_eeprom') as mock_eeprom:
5787
mock_eeprom.read = MagicMock()
@@ -73,3 +103,4 @@ def test_simulate_copper(self):
73103
assert not self.api.get_rx_power_support()
74104
assert not self.api.get_temperature_support()
75105
assert not self.api.get_voltage_support()
106+

tests/sonic_xcvr/test_sff8472.py

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from mock import MagicMock
22
import sys
3+
import pytest
34

45
from sonic_platform_base.sonic_xcvr.api.public.sff8472 import Sff8472Api
56
from sonic_platform_base.sonic_xcvr.codes.public.sff8472 import Sff8472Codes
@@ -170,3 +171,18 @@ def test_rx_power(self):
170171
}
171172
decoded = rx_power_field.decode(data, **deps)
172173
assert decoded == 209.713
174+
175+
@pytest.mark.parametrize("mock_response, expected", [
176+
(bytearray([0x04, 0x0]), "Shortwave laser, linear RX (SA)"),
177+
(bytearray([0x02, 0x0]), "Longwave laser (LC)"),
178+
(bytearray([0x01, 0x0]), "Electrical inter-enclosure (EL)"),
179+
(bytearray([0x0, 0x80]), "Electrical intra-enclosure (EL)"),
180+
(bytearray([0x0, 0x40]), "Shortwave laser w/o OFC (SN)"),
181+
(bytearray([0x0, 0x20]), "Shortwave laser w OFC (SL)"),
182+
(bytearray([0x0, 0x10]), "Longwave Laser (LL)")
183+
])
184+
def test_fiber_channel_transmitter_tech(self, mock_response, expected):
185+
self.api.xcvr_eeprom.reader = MagicMock()
186+
self.api.xcvr_eeprom.reader.return_value = mock_response
187+
result = self.api.xcvr_eeprom.read(consts.FIBRE_CHANNEL_TRANSMITTER_TECH_FIELD)
188+
assert result == expected

tests/sonic_xcvr/test_sff8636.py

+34
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from mock import MagicMock, patch
2+
import pytest
3+
24

35
from sonic_platform_base.sonic_xcvr.api.public.sff8636 import Sff8636Api
46
from sonic_platform_base.sonic_xcvr.codes.public.sff8636 import Sff8636Codes
57
from sonic_platform_base.sonic_xcvr.mem_maps.public.sff8636 import Sff8636MemMap
68
from sonic_platform_base.sonic_xcvr.xcvr_eeprom import XcvrEeprom
9+
from sonic_platform_base.sonic_xcvr.fields import consts
710

811
class TestSff8636(object):
912
codes = Sff8636Codes
@@ -52,6 +55,36 @@ def test_api(self):
5255
self.api.get_lpmode_support()
5356
self.api.get_power_override_support()
5457

58+
@pytest.mark.parametrize("mock_response, expected", [
59+
(bytearray([0x0]), "Power Class 1 Module (1.5W max.)"),
60+
(bytearray([0x40]), "Power Class 2 Module (2.0W max.)"),
61+
(bytearray([0x80]), "Power Class 3 Module (2.5W max.)"),
62+
(bytearray([0xC0]), "Power Class 4 Module (3.5W max.)"),
63+
(bytearray([0xC1]), "Power Class 5 Module (4.0W max.)"),
64+
(bytearray([0xC2]), "Power Class 6 Module (4.5W max.)"),
65+
(bytearray([0xC3]), "Power Class 7 Module (5.0W max.)"),
66+
(bytearray([0x20]), "Power Class 8 Module")
67+
])
68+
def test_power_class(self, mock_response, expected):
69+
self.api.xcvr_eeprom.reader = MagicMock()
70+
self.api.xcvr_eeprom.reader.return_value = mock_response
71+
result = self.api.xcvr_eeprom.read(consts.POWER_CLASS_FIELD)
72+
assert result == expected
73+
74+
@pytest.mark.parametrize("mock_response, expected", [
75+
(bytearray([0x02, 0x0]), "Longwave laser (LC)"),
76+
(bytearray([0x01, 0x0]), "Electrical inter-enclosure (EN)"),
77+
(bytearray([0x0, 0x80]), "Electrical intra-enclosure"),
78+
(bytearray([0x0, 0x40]), "Shortwave laser w/o OFC (SN)"),
79+
(bytearray([0x0, 0x20]), "Shortwave laser w OFC (SL)"),
80+
(bytearray([0x0, 0x10]), "Longwave Laser (LL)")
81+
])
82+
def test_fiber_channel_transmitter_tech(self, mock_response, expected):
83+
self.api.xcvr_eeprom.reader = MagicMock()
84+
self.api.xcvr_eeprom.reader.return_value = mock_response
85+
result = self.api.xcvr_eeprom.read(consts.FIBRE_CHANNEL_TRANSMITTER_TECH_FIELD)
86+
assert result == expected
87+
5588
def test_is_copper(self):
5689
with patch.object(self.api, 'xcvr_eeprom') as mock_eeprom:
5790
mock_eeprom.read = MagicMock()
@@ -71,3 +104,4 @@ def test_simulate_copper(self):
71104
assert not self.api.get_rx_power_support()
72105
assert not self.api.get_temperature_support()
73106
assert not self.api.get_voltage_support()
107+

0 commit comments

Comments
 (0)