Skip to content

Commit d746755

Browse files
authored
Update xcvrd.py
Added change to call validation routine for laser frequency grid check.
1 parent afa88e5 commit d746755

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

sonic-xcvrd/xcvrd/xcvrd.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,18 +1189,31 @@ def configure_tx_output_power(self, api, lport, tx_power):
11891189
self.log_error("{} configured tx power {} > maximum power {} supported".format(lport, tx_power, max_p))
11901190
return api.set_tx_power(tx_power)
11911191

1192-
def configure_laser_frequency(self, api, lport, freq, grid=75):
1193-
_, _, _, lowf, highf = api.get_supported_freq_config()
1192+
def config_laser_frequency_validate(self, api, lport, freq, grid=75):
1193+
supported_grid, _, _, lowf, highf = api.get_supported_freq_config()
11941194
if freq < lowf:
11951195
self.log_error("{} configured freq:{} GHz is lower than the supported freq:{} GHz".format(lport, freq, lowf))
1196+
return false
11961197
if freq > highf:
11971198
self.log_error("{} configured freq:{} GHz is higher than the supported freq:{} GHz".format(lport, freq, highf))
1198-
chan = int(round((freq - 193100)/25))
1199-
if chan % 3 != 0:
1200-
self.log_error("{} configured freq:{} GHz is NOT in 75GHz grid".format(lport, freq))
1199+
return false
1200+
if grid == 75:
1201+
if (supported_grid >> 7) & 0x1 != 1:
1202+
self.log_error("{} 75GHz is not supported".format(lport))
1203+
return False
1204+
chan = int(round((freq - 193100)/25))
1205+
if chan % 3 != 0:
1206+
self.log_error("{} configured freq:{} GHz is NOT in 75GHz grid".format(lport, freq))
1207+
return False
1208+
return True
1209+
1210+
def configure_laser_frequency(self, api, lport, freq, grid=75):
12011211
if api.get_tuning_in_progress():
12021212
self.log_error("{} Tuning in progress, subport selection may fail!".format(lport))
1203-
return api.set_laser_freq(freq, grid)
1213+
try:
1214+
return api.set_laser_freq(freq, grid)
1215+
except:
1216+
return False
12041217

12051218
def post_port_active_apsel_to_db(self, api, lport, host_lanes_mask):
12061219
try:
@@ -1424,11 +1437,15 @@ def task_worker(self):
14241437

14251438
# For ZR module, Datapath needes to be re-initlialized on new channel selection
14261439
if api.is_coherent_module():
1427-
freq = self.port_dict[lport]['laser_freq']
1428-
# If user requested frequency is NOT the same as configured on the module
1429-
# force datapath re-initialization
1430-
if 0 != freq and freq != api.get_laser_config_freq():
1431-
need_update = True
1440+
freq = self.port_dict[lport]['laser_freq']
1441+
# If user requested frequency is NOT the same as configured on the module
1442+
# force datapath re-initialization
1443+
if 0 != freq and freq != api.get_laser_config_freq():
1444+
if self.config_laser_frequency_validate(api, lport, freq) == True:
1445+
need_update = True
1446+
else:
1447+
# clear setting of invalid frequency config
1448+
self.port_dict[lport]['laser_freq'] = 0
14321449

14331450
if not need_update:
14341451
# No application updates

0 commit comments

Comments
 (0)