Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply custom Si settings via CMIS: SONiC xcvrd platform common changes #384

Merged
merged 46 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2c4e89b
Validate and apply module SI settings
AnoopKamath Jul 6, 2023
fe4f69a
Update consts.py
AnoopKamath Jul 6, 2023
94ac72a
Update cmis.py
AnoopKamath Jul 6, 2023
e274021
Fix build failures
AnoopKamath Jul 7, 2023
0cae3ae
Merge branch 'master' into master
AnoopKamath Jul 18, 2023
a0e6036
Update test_cmis.py
AnoopKamath Jul 18, 2023
7eb1564
Address review comments
AnoopKamath Jul 19, 2023
b52254d
Update cmis.py
AnoopKamath Jul 19, 2023
deed9ef
Update consts.py
AnoopKamath Jul 19, 2023
3a0204f
Create new APIs
AnoopKamath Jul 25, 2023
d4e628d
Add get_manufacturer API
AnoopKamath Jul 25, 2023
64e5b90
Update cmis.py
AnoopKamath Jul 25, 2023
97fbabe
Update cmis.py
AnoopKamath Jul 25, 2023
e7fe3c4
Update cmis.py
AnoopKamath Jul 26, 2023
858fbb0
Apply suggestions from code review
AnoopKamath Jul 26, 2023
36b5ad7
Update cmis.py
AnoopKamath Jul 26, 2023
321d589
Update cmis.py
AnoopKamath Jul 26, 2023
ecb723b
Update cmis.py
AnoopKamath Jul 26, 2023
ea1c158
Fix failures identified with mock test
AnoopKamath Jul 26, 2023
6a35e0f
Update test_cmis.py
AnoopKamath Jul 26, 2023
90826cd
Update cmis.py
AnoopKamath Jul 26, 2023
720a018
fix whitespace errors
AnoopKamath Jul 26, 2023
1b2ccdb
Address review comments
AnoopKamath Jul 28, 2023
3d65708
Update cmis.py
AnoopKamath Jul 28, 2023
f552e27
Fix build failures
AnoopKamath Jul 28, 2023
6db613c
Update test_cmis.py
AnoopKamath Jul 28, 2023
4589203
Update test_cmis.py
AnoopKamath Jul 28, 2023
1f46952
Merge branch 'master' into master
AnoopKamath Jul 31, 2023
ddc2f7c
Address review comments
AnoopKamath Aug 2, 2023
79fde14
Address review comments
AnoopKamath Aug 4, 2023
0b4bd11
Update consts.py
AnoopKamath Aug 4, 2023
496d9d4
Update cmis.py
AnoopKamath Aug 4, 2023
22bcabd
Update test_cmis.py
AnoopKamath Aug 4, 2023
3dbfbca
Update cmis.py
AnoopKamath Aug 4, 2023
55fb685
Update cmis.py
AnoopKamath Aug 4, 2023
4917b2c
Fix nibble write api
AnoopKamath Aug 6, 2023
adf9767
Update cmis.py
AnoopKamath Aug 6, 2023
038bc8c
Update test_cmis.py
AnoopKamath Aug 6, 2023
9f372e8
Remove byte read
AnoopKamath Aug 10, 2023
51f1822
Replace RegBitField with RegBitsField
AnoopKamath Aug 10, 2023
03c57ef
Update consts.py
AnoopKamath Aug 10, 2023
b1532e7
Fix build failure
AnoopKamath Aug 10, 2023
a72fb74
Update test_cmis.py
AnoopKamath Aug 10, 2023
7d45bff
Merge branch 'master' into master
AnoopKamath Aug 10, 2023
9aea964
Merge branch 'master' into master
AnoopKamath Aug 10, 2023
e3c1962
Update cmis.py
AnoopKamath Aug 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
246 changes: 244 additions & 2 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def __init__(self, xcvr_eeprom):
self.vdm = CmisVdmApi(xcvr_eeprom) if not self.is_flat_memory() else None
self.cdb = CmisCdbApi(xcvr_eeprom) if not self.is_flat_memory() else None

def get_manufacturer(self):
'''
This function returns the manufacturer of the module
'''
return self.xcvr_eeprom.read(consts.VENDOR_NAME_FIELD)

def get_model(self):
'''
This function returns the part number of the module
Expand Down Expand Up @@ -2069,7 +2075,7 @@ def get_application(self, lane):

return (appl & 0xf)

def set_application(self, channel, appl_code):
def set_application(self, channel, appl_code, ec):
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
"""
Update the selected application code to the specified lanes on the host side

Expand All @@ -2092,11 +2098,247 @@ def set_application(self, channel, appl_code):
lane_first = lane
addr = "{}_{}_{}".format(consts.STAGED_CTRL_APSEL_FIELD, 0, lane + 1)
data = (appl_code << 4) | (lane_first << 1)
#set EC bit
data|= ec
self.xcvr_eeprom.write(addr, data)

# Apply DataPathInit
def stage_datapath_init(self, channel):
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
'''
This function applies DataPathInit
'''
return self.xcvr_eeprom.write("%s_%d" % (consts.STAGED_CTRL_APPLY_DPINIT_FIELD, 0), channel)

def get_rx_output_amp_supported_val(self):
'''
This function returns the supported RX output amp val
'''
return self.xcvr_eeprom.read(consts.RX_OUTPUT_LEVEL_SUPPORT)

def get_rx_output_eq_pre_max_val(self):
'''
This function returns the supported RX output eq pre cursor val
'''
return self.xcvr_eeprom.read(consts.RX_OUTPUT_EQ_PRE_CURSOR_MAX)

def get_rx_output_eq_post_max_val(self):
'''
This function returns the supported RX output eq post sursor val
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
'''
return self.xcvr_eeprom.read(consts.RX_OUTPUT_EQ_POST_CURSOR_MAX)

def get_tx_input_eq_max_val(self):
'''
This function returns the supported TX input eq val
'''
return self.xcvr_eeprom.read(consts.TX_INPUT_EQ_MAX)

def get_tx_cdr_supported(self):
'''
This function returns the supported TX CDR field
'''
return self.xcvr_eeprom.read(consts.TX_CDR_SUPPORT_FIELD)

def get_rx_cdr_supported(self):
'''
This function returns the supported RX CDR field
'''
return self.xcvr_eeprom.read(consts.RX_CDR_SUPPORT_FIELD)

def get_tx_input_eq_fixed_supported(self):
'''
This function returns the supported TX input eq field
'''
return self.xcvr_eeprom.read(consts.TX_INPUT_EQ_FIXED_MANUAL_CTRL_SUPPORT_FIELD)

def get_tx_input_adaptive_eq_supported(self):
'''
This function returns the supported TX input adaptive eq field
'''
return self.xcvr_eeprom.read(consts.TX_INPUT_ADAPTIVE_EQ_SUPPORT_FIELD)

def get_tx_input_recall_buf1_supported(self):
'''
This function returns the supported TX input recall buf1 field
'''
return self.xcvr_eeprom.read(consts.TX_INPUT_EQ_RECALL_BUF1_SUPPORT_FIELD)

def get_tx_input_recall_buf2_supported(self):
'''
This function returns the supported TX input recall buf2 field
'''
return self.xcvr_eeprom.read(consts.TX_INPUT_EQ_RECALL_BUF2_SUPPORT_FIELD)

def get_rx_ouput_amp_ctrl_supported(self):
'''
This function returns the supported RX output amp control field
'''
return self.xcvr_eeprom.read(consts.RX_OUTPUT_AMP_CTRL_SUPPORT_FIELD)

def get_rx_output_eq_pre_ctrl_supported(self):
'''
This function returns the supported RX output eq pre control field
'''
return self.xcvr_eeprom.read(consts.RX_OUTPUT_EQ_PRE_CTRL_SUPPORT_FIELD)

def get_rx_output_eq_post_ctrl_supported(self):
'''
This function returns the supported RX output eq post control field
'''
return self.xcvr_eeprom.read(consts.RX_OUTPUT_EQ_POST_CTRL_SUPPORT_FIELD)

def nibble_read_modify_write(self, val, si_param, lane):
if (lane%2) == 0:
pre_si_key_lane = "{}{}".format(si_param, lane-1)
pre_val = self.xcvr_eeprom.read(pre_si_key_lane)
val = (val << 4) | pre_val
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
si_key_lane = "{}{}".format(si_param, lane)
self.xcvr_eeprom.write(si_key_lane, val)

def stage_output_eq_pre_cursor_target_rx(self, host_lanes_mask, si_settings):
'''
This function applies RX output eq pre cursor settings
'''
for lane in range(self.NUM_CHANNELS):
if ((1 << lane) & host_lanes_mask) == 0:
continue
lane = lane+1
si_key_lane = "{}{}".format(consts.OUTPUT_EQ_PRE_CURSOR_TARGET_RX, lane)
val = si_settings[consts.OUTPUT_EQ_PRE_CURSOR_TARGET_RX][si_key_lane]
if val <= get_rx_output_eq_pre_max_val():
self.nibble_read_modify_write(val, consts.OUTPUT_EQ_PRE_CURSOR_TARGET_RX, lane)

def stage_output_eq_post_cursor_target_rx(self, host_lanes_mask, si_settings):
'''
This function applies RX output eq pre cursor settings
'''
for lane in range(self.NUM_CHANNELS):
if ((1 << lane) & host_lanes_mask) == 0:
continue
lane = lane+1
si_key_lane = "{}{}".format(consts.OUTPUT_EQ_POST_CURSOR_TARGET_RX, lane)
val = si_settings[consts.OUTPUT_EQ_POST_CURSOR_TARGET_RX][si_key_lane]
if val <= get_rx_output_eq_post_max_val():
self.nibble_read_modify_write(val, consts.OUTPUT_EQ_POST_CURSOR_TARGET_RX, lane)

def stage_output_amp_target_rx(self, host_lanes_mask, si_settings):
'''
This function applies RX output amp settings
'''
for lane in range(self.NUM_CHANNELS):
if ((1 << lane) & host_lanes_mask) == 0:
continue
lane = lane+1
si_key_lane = "{}{}".format(consts.OUTPUT_AMPLITUDE_TARGET_RX, lane)
val = si_settings[consts.OUTPUT_AMPLITUDE_TARGET_RX][si_key_lane]
if val <= get_rx_output_eq_post_max_val():
self.nibble_read_modify_write(val, consts.OUTPUT_AMPLITUDE_TARGET_RX, lane)

def stage_fixed_input_target_tx(self, host_lanes_mask, si_settings):
'''
This function applies fixed TX input si settings
'''
for lane in range(self.NUM_CHANNELS):
if ((1 << lane) & host_lanes_mask) == 0:
continue
lane = lane+1
si_key_lane = "{}{}".format(consts.FIXED_INPUT_EQ_TARGET_TX, lane)
val = si_settings[consts.FIXED_INPUT_EQ_TARGET_TX][si_key_lane]
if val <= get_rx_output_eq_post_max_val():
self.nibble_read_modify_write(val, consts.FIXED_INPUT_EQ_TARGET_TX, lane)

def stage_adaptive_input_recall_tx(self, host_lanes_mask, si_settings):
'''
This function applies adaptive TX input recall si settings
'''
val = 0
for lane in range(self.NUM_CHANNELS):
if ((1 << lane) & host_lanes_mask) == 0:
continue
si_key_lane = "{}{}".format(si_keys, lane+1)
si_val = si_settings[si_keys][si_key_lane]
lane %= (self.NUM_CHANNELS//2)
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
mask = ~(val << (lane*2))
l_data = si_val << (lane*2)
val = (val & mask) | l_data
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
self.xcvr_eeprom.write(si_key_lane, val)

def byte_read_modify_write(self, si_keys, host_lanes_mask, si_settings):
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
val = 0
# Read 1 byte data
for lane in range(self.NUM_CHANNELS):
si_key_lane = "{}{}".format(si_keys, lane+1)
data = self.xcvr_eeprom.read(si_key_lane)
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
val |= (data << lane)
# Write only applicable field
for lane in range(self.NUM_CHANNELS):
if ((1 << lane) & host_lanes_mask) == 0:
continue
si_key_lane = "{}{}".format(si_keys, lane+1)
si_val = si_settings[si_keys][si_key_lane]
val &= ~(1 << lane)
val |= (si_val << lane)
self.xcvr_eeprom.write(si_key_lane, val)

def stage_adaptive_input_eq_enable_tx(self, host_lanes_mask, si_settings):
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
'''
This function applies adaptive TX input enable si settings
'''
self.byte_read_modify_write(consts.ADAPTIVE_INPUT_EQ_ENABLE_TX, host_lanes_mask, si_settings)

def stage_cdr_tx(self, host_lanes_mask, si_settings):
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
'''
This function applies TX CDR si settings
'''
self.byte_read_modify_write(consts.CDR_ENABLE_TX, host_lanes_mask, si_settings)

def stage_cdr_rx(self, host_lanes_mask, si_settings):
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
'''
This function applies RX CDR si settings
'''
self.byte_read_modify_write(consts.CDR_ENABLE_RX, host_lanes_mask, si_settings)
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved

def stage_rx_si_settings(self, host_lanes_mask, si_settings):
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
for si_keys in si_settings:
if si_keys == consts.OUTPUT_EQ_PRE_CURSOR_TARGET_RX and self.get_rx_output_eq_pre_ctrl_supported():
self.stage_output_eq_pre_cursor_target_rx(host_lanes_mask, si_settings)
elif si_keys == consts.OUTPUT_EQ_POST_CURSOR_TARGET_RX and self.get_rx_output_eq_post_ctrl_supported():
self.stage_output_eq_post_cursor_target_rx(host_lanes_mask, si_settings)
elif si_keys == consts.OUTPUT_AMPLITUDE_TARGET_RX and self.get_rx_ouput_amp_ctrl_supported():
self.stage_output_amp_target_rx(host_lanes_mask, si_settings)
elif si_keys == consts.CDR_ENABLE_RX and self.get_rx_cdr_supported():
self.stage_cdr_tx(host_lanes_mask, si_settings)

def stage_tx_si_settings(self, host_lanes_mask, si_settings):
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
for si_keys in si_settings:
if si_keys == consts.FIXED_INPUT_EQ_TARGET_TX and self.get_tx_input_eq_fixed_supported():
self.stage_fixed_input_target_tx(host_lanes_mask, si_settings)
elif (si_keys == consts.ADAPTIVE_INPUT_EQ_RECALLED_TX and
(self.get_tx_input_recall_buf1_supported() or self.get_tx_input_recall_buf2_supported())):
self.stage_adaptive_input_recall_tx(host_lanes_mask, si_settings)
elif si_keys == consts.ADAPTIVE_INPUT_EQ_ENABLE_TX and self.get_tx_input_adaptive_eq_supported():
self.stage_adaptive_input_eq_enable_tx(host_lanes_mask, si_settings)
elif si_keys == consts.CDR_ENABLE_TX and self.get_tx_cdr_supported():
self.stage_cdr_rx(host_lanes_mask, si_settings)

def stage_custom_si_settings(self, host_lanes_mask, optics_si_dict):
# Read and cache the existing SCS0 TX CTRL data
si_settings = self.xcvr_eeprom.read(consts.STAGED_CTRL0_TX_CTRL_FIELD)
if si_settings is None:
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved
return None

# Replace the new values with cached SI values
for si_keys in optics_si_dict:
if si_keys in si_settings:
si_settings[si_keys] = optics_si_dict[si_keys]

# stage RX si settings
self.stage_rx_si_settings(host_lanes_mask, si_settings)
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved

#stage TX si settings
self.stage_tx_si_settings(host_lanes_mask, si_settings)
AnoopKamath marked this conversation as resolved.
Show resolved Hide resolved

return True

def get_error_description(self):
dp_state = self.get_datapath_state()
conf_state = self.get_config_datapath_hostlane_status()
Expand Down
39 changes: 39 additions & 0 deletions sonic_platform_base/sonic_xcvr/fields/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,45 @@
STAGED_CTRL_APPLY_IMMEDIATE_FIELD = "Staged Control Set Apply Immediate"
STAGED_CTRL_APSEL_FIELD = "Staged Control Set ApSel"

STAGED_CTRL0_TX_CTRL_FIELD = "Staged Control TX Control"

TX_INPUT_EQ_MAX = "TXInputEqMax"
RX_OUTPUT_LEVEL_SUPPORT = "RX Output Level Supported"
RX_OUTPUT_LEVEL_0_SUPPORTED = "RXOutputLevel0Supported"
RX_OUTPUT_LEVEL_1_SUPPORTED = "RXOutputLevel1Supported"
RX_OUTPUT_LEVEL_2_SUPPORTED = "RXOutputLevel2Supported"
RX_OUTPUT_LEVEL_3_SUPPORTED = "RXOutputLevel3Supported"
RX_OUTPUT_EQ_PRE_CURSOR_MAX = "RXOutputEqPreCursorMax"
RX_OUTPUT_EQ_POST_CURSOR_MAX = "RXOutputEqPostCursorMax"

SIGNAL_INTEGRITY_CTRL_ADVT_FIELD = "Signal Integrity Control Advertisement"
TX_SI_CTRL_ADVT = "TX SI Control Advertisement"
TX_CDR_SUPPORT_FIELD = "TXCDRSupported"
TX_CDR_BYPASS_CTRL_FIELD = "TXCDRBypassSupported"
TX_INPUT_EQ_FIXED_MANUAL_CTRL_SUPPORT_FIELD = "TXInputEqFixedManualSupported"
TX_INPUT_ADAPTIVE_EQ_SUPPORT_FIELD = "TXInputAdaptiveEqSupported"
TX_INPUT_EQ_FREEZE_SUPPORT_FIELD = "TXInputEqFreezeSupported"
TX_INPUT_EQ_RECALL_BUF1_SUPPORT_FIELD = "TXInputEqRecallBuf1Supported"
TX_INPUT_EQ_RECALL_BUF2_SUPPORT_FIELD = "TXInputEqRecallBuf2Supported"
TX_INPUT_EQ_RECALL_BUF_SUPPORT_FIELD = "TXInputEqRecallBufSupported"
RX_SI_CTRL_ADVT = "RX SI Control Advertisement"
RX_CDR_SUPPORT_FIELD = "RxCDRSupported"
RX_CDR_BYPASS_CTRL_FIELD = "RXCDRBypassSupported"
RX_OUTPUT_AMP_CTRL_SUPPORT_FIELD = "RXOutputAmpSupported"
RX_OUTPUT_EQ_PRE_CTRL_SUPPORT_FIELD = "RXOutputEQPreSupported"
RX_OUTPUT_EQ_POST_CTRL_SUPPORT_FIELD = "RXOutputEQPostSupported"
RX_OUTPUT_EQ_CTRL_SUPPORT_FIELD = "RXOutputEQSupported"

ACTIVE_CTRL_FIELD = "Active Control Set"
ADAPTIVE_INPUT_EQ_ENABLE_TX = "AdaptiveInputEqEnableTx"
ADAPTIVE_INPUT_EQ_RECALLED_TX = "AdaptiveInputEqRecalledTx"
FIXED_INPUT_EQ_TARGET_TX = "FixedInputEqTargetTx"
CDR_ENABLE_TX = "CDREnableTx"
CDR_ENABLE_RX = "CDREnableRx"
OUTPUT_EQ_PRE_CURSOR_TARGET_RX = "OutputEqPreCursorTargetRx"
OUTPUT_EQ_POST_CURSOR_TARGET_RX = "OutputEqPostCursorTargetRx"
OUTPUT_AMPLITUDE_TARGET_RX = "OutputAmplitudeTargetRx"

# C-CMIS

# Module configuration support fields
Expand Down
Loading
Loading