Skip to content

Commit

Permalink
[xcvrd] Enhance Media Settings (sonic-net#177)
Browse files Browse the repository at this point in the history
#### Description
1. Currently in sonic, for 400G pre-emphasis settings is not programmed via common methodology. 
We use Vendor Name + PN to program which would consume memory and never ending process as we need to add Vendor name + PN for every optic.
2.  For 100G/40G optics, specification compliance is not displayed. Only for DAC, the specification compliance was displayed.

#### Motivation and Context
1. With this PR, we can program the pre-emphasis settings for both DAC,AOC and optics.
QSFP_DD parser doesn't have specification compliance which was need to program pre-emphasis settings.
The platform API code can be changed to return the type_of_media_interface for 400G media specification compliance, so that the type of media can be determined.
     https://github.com/Azure/sonic-platform-common/blob/a95834b65a9f3b17ab1ce4e1ba5d1a60102e4507/sonic_platform_base/sonic_sfp/sff8024.py#L104
2. To address 100G/40G optic, introduced a new key "QSFP28 - *" / "QSFP+ - *" (type_abbrv_name followed by a hyphen) .
The same key can be defined in vendor specific media_settings.json. 
These changes doesn't modify the existing behavior but additionally addresses the above mentioned issues.
Vendors can still add "Vendor_name + PN" in media_settings.json to program media settings if needed.
  • Loading branch information
aravindmani-1 authored Apr 28, 2021
1 parent 911601d commit 4be4306
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,5 @@ def test_get_media_settings_key(self):
# Test a bad 'specification_compliance' value
xcvr_info_dict[0]['specification_compliance'] = 'N/A'
result = get_media_settings_key(0, xcvr_info_dict)
assert result == ['MOLEX-1064141421', 'QSFP+']
assert result == ['MOLEX-1064141421', 'QSFP+-*']
# TODO: Ensure that error message was logged
35 changes: 21 additions & 14 deletions sonic-xcvrd/xcvrd/xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,29 +638,36 @@ def get_media_settings_key(physical_port, transceiver_dict):
media_len = transceiver_dict[physical_port]['cable_length']

media_compliance_dict_str = transceiver_dict[physical_port]['specification_compliance']

media_compliance_code = ''
media_type = ''
media_key = ''
media_compliance_dict = {}

try:
media_compliance_dict = ast.literal_eval(media_compliance_dict_str)
if _wrapper_get_sfp_type(physical_port) == 'QSFP_DD':
media_compliance_code = media_compliance_dict_str
else:
media_compliance_dict = ast.literal_eval(media_compliance_dict_str)
if sup_compliance_str in media_compliance_dict:
media_compliance_code = media_compliance_dict[sup_compliance_str]
except ValueError as e:
helper_logger.log_error("Invalid value for port {} 'specification_compliance': {}".format(physical_port, media_compliance_dict_str))

media_compliance_code = ''
media_type = ''

if sup_compliance_str in media_compliance_dict:
media_compliance_code = media_compliance_dict[sup_compliance_str]

media_type = transceiver_dict[physical_port]['type_abbrv_name']

media_key = ''

if len(media_type) != 0:
media_key += media_type
if len(media_compliance_code) != 0:
media_key += '-' + media_compliance_code
if len(media_len) != 0:
media_key += '-' + media_len + 'M'
if _wrapper_get_sfp_type(physical_port) == 'QSFP_DD':
if media_compliance_code == "passive_copper_media_interface":
if len(media_len) != 0:
media_key += '-' + media_len + 'M'
else:
if len(media_len) != 0:
media_key += '-' + media_len + 'M'
else:
media_key += '-' + '*'

return [vendor_key, media_key]

Expand Down Expand Up @@ -742,8 +749,8 @@ def notify_media_setting(logical_port_name, transceiver_dict,
key = get_media_settings_key(physical_port, transceiver_dict)
media_dict = get_media_settings_value(physical_port, key)

if(len(media_dict) == 0):
helper_logger.log_error("Error in obtaining media setting")
if len(media_dict) == 0:
helper_logger.log_error("Error in obtaining media setting for {}".format(logical_port_name))
return

fvs = swsscommon.FieldValuePairs(len(media_dict))
Expand Down

0 comments on commit 4be4306

Please sign in to comment.