-
Notifications
You must be signed in to change notification settings - Fork 531
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
Add support for configuring loopback mode (PHY and MAC) #3095
base: master
Are you sure you want to change the base?
Conversation
d596a97
to
d0349c4
Compare
Is there an HLD for this PR? If so, please link it. Modify the PR description to follow the template and give details of the changes. Please mention any impact on Warmboot. |
Nit: Update the title to reflect it is phy loopback |
93a0467
to
bca089e
Compare
Hi Prince, thanks for your review. I included more details for the feature below. I have not created an HLD yet, but please let me know if you would like me to open an HLD PR. Overview: Design: CONFIG DB Schema:
_sai_port_loopback_mode_t enum:
Warmboot: Testing: |
sai_status_t status = sai_port_api->set_port_attribute(id, &attr); | ||
if (status != SAI_STATUS_SUCCESS) | ||
{ | ||
LOG_ERROR_AND_RETURN(ReturnCode(status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@royyi8 this won't crash OA right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is correct. It logs the error and returns from the current function.
https://github.com/sonic-net/sonic-swss/blob/master/orchagent/return_code.h#L50
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@royyi8 can we avoid crash. Why crash OA if one port fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prgeor To clarify, the code will not crash OA. It will simply log an error and return status failed in the setPortLoopbackMode
function. OA will proceed in the else block on line 4319.
static const std::unordered_map<std::string, sai_port_loopback_mode_t> portLoopbackModeMap = { | ||
{"none", SAI_PORT_LOOPBACK_MODE_NONE}, | ||
{"phy_local", SAI_PORT_LOOPBACK_MODE_PHY}, | ||
{"mac_local", SAI_PORT_LOOPBACK_MODE_MAC}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@royyi8 how is it different from SAI_PORT_INTERNAL_LOOPBACK_MODE_MAC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SAI_PORT_LOOPBACK_MODE_MAC
is the corresponding attribute for SAI_PORT_INTERNAL_LOOPBACK_MODE_MAC
. We are using sai_port_loopback_mode_t
enum instead of _sai_port_internal_loopback_mode_t
since the later is to be deprecated in SAI.
https://github.com/opencomputeproject/SAI/blob/master/inc/saiport.h#L114
@@ -118,6 +118,14 @@ static const std::unordered_map<std::string, Port::Role> portRoleMap = | |||
{ PORT_ROLE_DPC, Port::Role::Dpc } | |||
}; | |||
|
|||
static const std::unordered_map<std::string, sai_port_loopback_mode_t> portLoopbackModeMap = { | |||
{"none", SAI_PORT_LOOPBACK_MODE_NONE}, | |||
{"phy_local", SAI_PORT_LOOPBACK_MODE_PHY}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@royyi8 How is it different from SAI_PORT_INTERNAL_LOOPBACK_MODE_PHY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same reason as above. SAI_PORT_LOOPBACK_MODE_PHY
is the corresponding attribute for SAI_PORT_INTERNAL_LOOPBACK_MODE_PHY
in the sai_port_loopback_mode_t
enum.
1 similar comment
@royyi8 , can you please resolve conflict and rebase? |
4193ab3
to
b703499
Compare
Added SWSS support for configuring loopback modes through CONFIG DB.
@royyi8 , @prgeor , can you confirm there is a yang model defined for this new attribute? @dgsudharsan for viz |
@prsunny, I have not made changes to the sonic yang model. Could you please let me know if the new attribute needs to be added in sonic-buildimage sonic-port.yang? |
Yes, also we need for the link-damping feature. |
What I did:
Add a new port attribute loopback_mode to PORT_TABLE in CONFIG_DB. Portsorch will use the enum value to set the sai attribute SAI_PORT_ATTR_LOOPBACK_MODE.
Why I did it:
This PR adds support for setting loopback mode for an interface in CONFIG DB. It can be set at runtime or during initialization in config_db.json.
How I verified it:
Run component tests to set loopback mode in CONFIG DB PORT TABLE and check the corresponding loopback attribute is set in ASIC DB.
Details if related:
There is no impact to warmboot since the PR adds support for new port loopback config.