Skip to content

Commit

Permalink
[sfp] Add media assignment options to Application Advertisement (#324)
Browse files Browse the repository at this point in the history
* [sfp] Add media assignment options to Application Advertisement

* Increase UT coverage
  • Loading branch information
Junchao-Mellanox committed Nov 16, 2022
1 parent 644f8c2 commit d739102
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,11 @@ def get_application_advertisement(self):
break
buf['host_lane_assignment_options'] = val

key = "{}_{}".format(consts.MEDIA_LANE_ASSIGNMENT_OPTION, app)
val = dic.get(key)
if val is not None:
buf['media_lane_assignment_options'] = val

ret[app] = buf
return ret

Expand Down
6 changes: 4 additions & 2 deletions tests/sonic_xcvr/test_cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ def test_get_module_fw_info(self, mock_response, expected):
if result['status'] == False: # Check 'result' when 'status' == False for distinguishing error type.
assert result['result'] == expected['result']
assert result['status'] == expected['status']

@pytest.mark.parametrize("input_param, mock_response, expected", [
(1, 1, (True, 'Module FW run: Success\n')),
(1, 64, (False, 'Module FW run: Fail\nFW_run_status 64\n')),
Expand Down Expand Up @@ -2006,7 +2006,8 @@ def test_get_application_advertisement(self):
consts.MODULE_MEDIA_INTERFACE_SM + "_1": "400GBASE-DR4 (Cl 124)",
consts.MEDIA_LANE_COUNT + "_1": 4,
consts.HOST_LANE_COUNT + "_1": 8,
consts.HOST_LANE_ASSIGNMENT_OPTION + "_1": 0x01
consts.HOST_LANE_ASSIGNMENT_OPTION + "_1": 0x01,
consts.MEDIA_LANE_ASSIGNMENT_OPTION + "_1": 0x02
},
Sff8024.MODULE_MEDIA_TYPE[2]
]
Expand All @@ -2018,6 +2019,7 @@ def test_get_application_advertisement(self):
assert result[1]['host_lane_count'] == 8
assert result[1]['media_lane_count'] == 4
assert result[1]['host_lane_assignment_options'] == 0x01
assert result[1]['media_lane_assignment_options'] == 0x02

def test_get_application_advertisement_non_support(self):
self.api.xcvr_eeprom.read = MagicMock(return_value = None)
Expand Down

0 comments on commit d739102

Please sign in to comment.