Skip to content

Commit 4be4306

Browse files
[xcvrd] Enhance Media Settings (#177)
#### 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.
1 parent 911601d commit 4be4306

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

sonic-xcvrd/tests/test_xcvrd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,5 +316,5 @@ def test_get_media_settings_key(self):
316316
# Test a bad 'specification_compliance' value
317317
xcvr_info_dict[0]['specification_compliance'] = 'N/A'
318318
result = get_media_settings_key(0, xcvr_info_dict)
319-
assert result == ['MOLEX-1064141421', 'QSFP+']
319+
assert result == ['MOLEX-1064141421', 'QSFP+-*']
320320
# TODO: Ensure that error message was logged

sonic-xcvrd/xcvrd/xcvrd.py

+21-14
Original file line numberDiff line numberDiff line change
@@ -638,29 +638,36 @@ def get_media_settings_key(physical_port, transceiver_dict):
638638
media_len = transceiver_dict[physical_port]['cable_length']
639639

640640
media_compliance_dict_str = transceiver_dict[physical_port]['specification_compliance']
641-
641+
media_compliance_code = ''
642+
media_type = ''
643+
media_key = ''
642644
media_compliance_dict = {}
645+
643646
try:
644-
media_compliance_dict = ast.literal_eval(media_compliance_dict_str)
647+
if _wrapper_get_sfp_type(physical_port) == 'QSFP_DD':
648+
media_compliance_code = media_compliance_dict_str
649+
else:
650+
media_compliance_dict = ast.literal_eval(media_compliance_dict_str)
651+
if sup_compliance_str in media_compliance_dict:
652+
media_compliance_code = media_compliance_dict[sup_compliance_str]
645653
except ValueError as e:
646654
helper_logger.log_error("Invalid value for port {} 'specification_compliance': {}".format(physical_port, media_compliance_dict_str))
647655

648-
media_compliance_code = ''
649-
media_type = ''
650-
651-
if sup_compliance_str in media_compliance_dict:
652-
media_compliance_code = media_compliance_dict[sup_compliance_str]
653-
654656
media_type = transceiver_dict[physical_port]['type_abbrv_name']
655657

656-
media_key = ''
657-
658658
if len(media_type) != 0:
659659
media_key += media_type
660660
if len(media_compliance_code) != 0:
661661
media_key += '-' + media_compliance_code
662-
if len(media_len) != 0:
663-
media_key += '-' + media_len + 'M'
662+
if _wrapper_get_sfp_type(physical_port) == 'QSFP_DD':
663+
if media_compliance_code == "passive_copper_media_interface":
664+
if len(media_len) != 0:
665+
media_key += '-' + media_len + 'M'
666+
else:
667+
if len(media_len) != 0:
668+
media_key += '-' + media_len + 'M'
669+
else:
670+
media_key += '-' + '*'
664671

665672
return [vendor_key, media_key]
666673

@@ -742,8 +749,8 @@ def notify_media_setting(logical_port_name, transceiver_dict,
742749
key = get_media_settings_key(physical_port, transceiver_dict)
743750
media_dict = get_media_settings_value(physical_port, key)
744751

745-
if(len(media_dict) == 0):
746-
helper_logger.log_error("Error in obtaining media setting")
752+
if len(media_dict) == 0:
753+
helper_logger.log_error("Error in obtaining media setting for {}".format(logical_port_name))
747754
return
748755

749756
fvs = swsscommon.FieldValuePairs(len(media_dict))

0 commit comments

Comments
 (0)