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

[CMIS] Add lane_mask parameter to set_loopback_mode() to enable setti… #490

Merged
merged 6 commits into from
Sep 8, 2024
15 changes: 9 additions & 6 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,15 +1115,18 @@ def get_loopback_capability(self):
loopback_capability['media_side_output_loopback_supported'] = bool((allowed_loopback_result >> 0) & 0x1)
return loopback_capability

def set_loopback_mode(self, loopback_mode):
def set_loopback_mode(self, loopback_mode, lane_mask = 0xff):
'''
This function sets the module loopback mode.
Loopback mode has to be one of the five:
loopback_mode: Loopback mode has to be one of the five:
1. "none" (default)
2. "host-side-input"
3. "host-side-output"
4. "media-side-input"
5. "media-side-output"
lane_mask: A bitmask representing which lanes to apply the loopback mode to.
The default value of 0xFF indicates that the mode should be applied to all lanes.

The function will look at 13h:128 to check advertized loopback capabilities.
Return True if the provision succeeds, False if it fails
'''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xinyulin As part of clearing the loopback (line 1136-1140), can we make sure that the loopback is cleared only for the lane_mask lanes rather than all lanes?
Also, should we check if the module advertises per lane loopback support and then use lane_mask accordingly. This will be helpful to clear loopback on all lanes if per lane loopback is not supported.

Copy link
Contributor Author

@xinyulin xinyulin Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Sure! we'd better to reject the request if simultaneous host media loopback mode is not supported.
  2. To clear specific lanes corresponding to the logical port for the none mode, we will need to have two lane masks (host_lane_mask and media_lane_mask for host and media individually) because the host and media lane masks might not be identical (e.g., host_lane_mask = 0x3, media_lane_mask = 0x1).
  3. If per-lane loopback mode is not supported, should we reject the request or configure the entire physical port instead?
  4. Do you think it is useful to log some messages for the reject cases?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xinyulin
For 2., we can expect loopback_mode to include the type of loopback to be cleared i.e. have host-side-input-none, host-side-output-none etc. In this case, the caller can pass the lane_mask accordingly.
For 3., I think we should configure entire physical port and display a message. @prgeor Can you please confirm the expected behavior in this case?
For 4., Yes, I think it is helpful to log messages in reject cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mihirpat1 Thanks for the comments. I've updated it accordingly. Let's check if Prince has any comments on the changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xinyulin I discussed with @prgeor regarding 3. and concluded to reject the config if per lane loopback is not supported (i.e. we should not configure unrelated lanes when loopback is intended to configure specific lanes).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mihirpat1 Thanks for the confirmation. It has been updated!

Expand All @@ -1138,22 +1141,22 @@ def set_loopback_mode(self, loopback_mode):
return all([status_host_input, status_host_output, status_media_input, status_media_output])
elif loopback_mode == 'host-side-input':
if loopback_capability['host_side_input_loopback_supported']:
return self.xcvr_eeprom.write(consts.HOST_INPUT_LOOPBACK, 0xff)
return self.xcvr_eeprom.write(consts.HOST_INPUT_LOOPBACK, lane_mask)
else:
return False
elif loopback_mode == 'host-side-output':
if loopback_capability['host_side_output_loopback_supported']:
return self.xcvr_eeprom.write(consts.HOST_OUTPUT_LOOPBACK, 0xff)
return self.xcvr_eeprom.write(consts.HOST_OUTPUT_LOOPBACK, lane_mask)
else:
return False
elif loopback_mode == 'media-side-input':
if loopback_capability['media_side_input_loopback_supported']:
return self.xcvr_eeprom.write(consts.MEDIA_INPUT_LOOPBACK, 0xff)
return self.xcvr_eeprom.write(consts.MEDIA_INPUT_LOOPBACK, lane_mask)
else:
return False
elif loopback_mode == 'media-side-output':
if loopback_capability['media_side_output_loopback_supported']:
return self.xcvr_eeprom.write(consts.MEDIA_OUTPUT_LOOPBACK, 0xff)
return self.xcvr_eeprom.write(consts.MEDIA_OUTPUT_LOOPBACK, lane_mask)
else:
return False
else:
Expand Down
Loading