Skip to content

Commit 02dd597

Browse files
authored
implement CMIS set_laser_freq to support 100GHz grid space (#294)
Signed-off-by: chiourung_huang <[email protected]> Signed-off-by: chiourung_huang <[email protected]>
1 parent d739102 commit 02dd597

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

sonic_platform_base/sonic_xcvr/api/public/c_cmis.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ def get_laser_tuning_summary(self):
9494

9595
def get_supported_freq_config(self):
9696
'''
97-
This function returns the supported freq grid, low and high supported channel in 75GHz grid,
97+
This function returns the supported freq grid, low and high supported channel in 75/100GHz grid,
9898
and low and high frequency supported in GHz.
99-
allowed channel number bound in 75 GHz grid
100-
allowed frequency bound in 75 GHz grid
99+
allowed channel number bound in 75/100 GHz grid
100+
allowed frequency bound in 75/100 GHz grid
101101
'''
102102
grid_supported = self.xcvr_eeprom.read(consts.SUPPORT_GRID)
103103
low_ch_num = self.xcvr_eeprom.read(consts.LOW_CHANNEL)
@@ -106,20 +106,28 @@ def get_supported_freq_config(self):
106106
high_freq_supported = 193100 + hi_ch_num * 25
107107
return grid_supported, low_ch_num, hi_ch_num, low_freq_supported, high_freq_supported
108108

109-
def set_laser_freq(self, freq):
109+
def set_laser_freq(self, freq, grid):
110110
'''
111111
This function sets the laser frequency. Unit in GHz
112112
ZR application will not support fine tuning of the laser
113-
SONiC will only support 75 GHz frequency grid
113+
SONiC will only support 75 GHz and 100GHz frequency grids
114114
Return True if the provision succeeds, False if it fails
115115
'''
116116
grid_supported, low_ch_num, hi_ch_num, _, _ = self.get_supported_freq_config()
117117
grid_supported_75GHz = (grid_supported >> 7) & 0x1
118-
assert grid_supported_75GHz
119-
freq_grid = 0x70
118+
grid_supported_100GHz = (grid_supported >> 5) & 0x1
119+
if grid == 75:
120+
assert grid_supported_75GHz
121+
freq_grid = 0x70
122+
channel_number = int(round((freq - 193100)/25))
123+
assert channel_number % 3 == 0
124+
elif grid == 100:
125+
assert grid_supported_100GHz
126+
freq_grid = 0x50
127+
channel_number = int(round((freq - 193100)/100))
128+
else:
129+
return False
120130
self.xcvr_eeprom.write(consts.GRID_SPACING, freq_grid)
121-
channel_number = int(round((freq - 193100)/25))
122-
assert channel_number % 3 == 0
123131
if channel_number > hi_ch_num or channel_number < low_ch_num:
124132
raise ValueError('Provisioned frequency out of range. Max Freq: 196100; Min Freq: 191300 GHz.')
125133
status = self.xcvr_eeprom.write(consts.LASER_CONFIG_CHANNEL, channel_number)

tests/sonic_xcvr/test_ccmis.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def test_get_supported_freq_config(self, mock_response, expected):
9393
assert result == expected
9494

9595
@pytest.mark.parametrize("input_param, mock_response",[
96-
(193100, (0xff, -72, 120, 191300, 196100)),
97-
(195950, (0xff, -72, 120, 191300, 196100)),
96+
((193100,75), (0xff, -72, 120, 191300, 196100)),
97+
((195950,100), (0xff, -72, 120, 191300, 196100)),
9898
])
9999
def test_set_laser_freq(self, input_param, mock_response):
100100
self.api.is_flat_memory = MagicMock()
@@ -103,7 +103,7 @@ def test_set_laser_freq(self, input_param, mock_response):
103103
self.api.get_lpmode_support.return_value = False
104104
self.api.get_supported_freq_config = MagicMock()
105105
self.api.get_supported_freq_config.return_value = mock_response
106-
self.api.set_laser_freq(input_param)
106+
self.api.set_laser_freq(input_param[0], input_param[1])
107107

108108
@pytest.mark.parametrize("input_param, mock_response",[
109109
(-10, (-14, -9)),

0 commit comments

Comments
 (0)