-
Notifications
You must be signed in to change notification settings - Fork 547
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 SWSS support for link event damping feature #2933
Conversation
struct { | ||
|
||
struct { | ||
uint32_t value; |
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.
is it possible to use std::optional or boost::optional here?
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.
Hi @Junchao-Mellanox, thanks for your review. There was a refactor change in portsorch.cpp, and my change follows the existing port config. Maybe there can be a cleanup task in the future to update the port config to use std::optional.
orchagent/portsorch.cpp
Outdated
CHECK_ERROR_AND_LOG_AND_RETURN( | ||
sai_port_api->set_port_attribute(port.m_port_id, &attr), | ||
"Failed to set link event damping algorithm (" << link_event_damping_algorithm << ") for port 0x" | ||
<< std::hex << port.m_port_id); |
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.
would it better to print port alias?
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.
I updated the log message to print port alias.
p.m_flap_penalty = aied_config.flap_penalty; | ||
m_portList[p.m_alias] = p; | ||
|
||
SWSS_LOG_NOTICE("Set port %s link event damping config successfully", p.m_alias.c_str()); |
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.
there is already a log in setPortLinkEventDampingAiedConfig, how about changing that to NOTICE and remove all logs here?
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.
I removed some log messages that were also in setPortLinkEventDampingAiedConfig.
@royyi8 , could you please rebase and fix the build failure? |
22e3b06
to
facf1b0
Compare
@royyi8 , still a build failure. Can you check so that we can try to get this before branch cutoff this month |
274c7ac
to
e3e16dd
Compare
@royyi8 , thank you for actively working on this. Could you also please check the coverage issue and add some coverage? |
3f47f16
to
7dd5a28
Compare
@prsunny, I fixed the code coverage issue. By the way, all PRs will need to be merged for the link event damping feature to be complete. The full list of PRs is in the HLD: sonic-net/SONiC#1071. cc: @mint570 |
@royyi8 , could you please plan to provide a sonic-mgmt test for this feature as thats the only one missing for this. @Ashish1805 , @royyi8, @mint570 , could you please add the following to complete the feature?
|
orchagent/port/porthlpr.cpp
Outdated
@@ -118,6 +119,12 @@ static const std::unordered_map<std::string, Port::Role> portRoleMap = | |||
{ PORT_ROLE_DPC, Port::Role::Dpc } | |||
}; | |||
|
|||
static const std::unordered_map<std::string, sai_redis_link_event_damping_algorithm_t> linkEventDampingAlgorithmMap = |
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.
should global names be prefixed with g_ ?
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.
Sure, I changed the name to g_linkEventDampingAlgorithmMap.
orchagent/port/porthlpr.cpp
Outdated
@@ -233,6 +240,11 @@ std::string PortHelper::getAdminStatusStr(const PortConfig &port) const | |||
return this->getFieldValueStr(port, PORT_ADMIN_STATUS); | |||
} | |||
|
|||
std::string PortHelper::getDampingAlgoStr(const PortConfig &port) const |
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.
not sure if Str is reqired in function naming, you already knw what type is returned
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.
I removed Str from the function name, now it is getDampingAlgorithm
.
else if (field == PORT_DAMPING_ALGO) | ||
{ | ||
if (!this->parsePortLinkEventDampingAlgorithm(port, field, value)) | ||
{ | ||
return false; | ||
} | ||
} | ||
else if (field == PORT_MAX_SUPPRESS_TIME) | ||
{ | ||
if (!this->parsePortLinkEventDampingConfig(port.link_event_damping_config.max_suppress_time, field, value)) | ||
{ | ||
return false; | ||
} | ||
} | ||
else if (field == PORT_DECAY_HALF_LIFE) | ||
{ | ||
if (!this->parsePortLinkEventDampingConfig(port.link_event_damping_config.decay_half_life, field, value)) | ||
{ | ||
return false; | ||
} | ||
} | ||
else if (field == PORT_SUPPRESS_THRESHOLD) | ||
{ | ||
if (!this->parsePortLinkEventDampingConfig(port.link_event_damping_config.suppress_threshold, field, value)) | ||
{ | ||
return false; | ||
} | ||
} | ||
else if (field == PORT_REUSE_THRESHOLD) | ||
{ | ||
if (!this->parsePortLinkEventDampingConfig(port.link_event_damping_config.reuse_threshold, field, value)) | ||
{ | ||
return false; | ||
} | ||
} | ||
else if (field == PORT_FLAP_PENALTY) | ||
{ | ||
if (!this->parsePortLinkEventDampingConfig(port.link_event_damping_config.flap_penalty, field, value)) | ||
{ | ||
return false; |
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.
all this and entire function could be refactored to have a stdL::map<string,function> to execute if string is compared and seems all the functions take teh same 3 parameters
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.
Hi @kcudnik, thanks for reviewing the PR. I prefer to hold off refactoring the parsePortConfig function for now, since the first parameter is different between some of the functions. If you have more suggestions, please feel free to let me know.
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.
you have opportunity right now to do refactoring, because you understand surrounding code that you are adding, and leaving this now as is, will result to add more and more code like you are adding that instead of refactoring, take this from my experience.
orchagent/portsorch.cpp
Outdated
@@ -3002,6 +3002,48 @@ task_process_status PortsOrch::setPortLinkTraining(const Port &port, bool state) | |||
return task_success; | |||
} | |||
|
|||
ReturnCode PortsOrch::setPortLinkEventDampingAlgorithm(Port &port, | |||
sai_redis_link_event_damping_algorithm_t &link_event_damping_algorithm) { |
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.
keep { on new line
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.
It's fixed now.
208cf4e
to
a701460
Compare
@prsunny, could we please continue the discussion in the HLD PR? @Ashish1805 is keeping track of the PRs needed for the link event damping feature. |
@@ -749,6 +761,60 @@ bool PortHelper::parsePortDescription(PortConfig &port, const std::string &field | |||
return true; | |||
} | |||
|
|||
bool PortHelper::parsePortLinkEventDampingAlgorithm(PortConfig &port, const std::string &field, const std::string &value) const |
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.
Can you please confirm that this is applied when user dynamically changes the link damping configs and not just during initialization?
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. Link event damping algorithm and config can be applied at runtime by changing the entries in CONFIG DB.
@royyi8 , can you please resolve conflict and rebase? |
@royyi8 , please rebase |
b60f4a4
to
b881eac
Compare
What I did
Added support for link event damping in SWSS.
Required Syncd PR: sonic-net/sonic-sairedis#1297
CLI PR: sonic-net/sonic-utilities#3001
HLD: https://github.com/sonic-net/SONiC/blob/master/doc/link_event_damping/Link-event-damping-HLD.md
Why I did it
How I verified it
Use the
config interface damping
CLI to set the port attributes on the switch and observe that Syncd processes link event damping parameters.Details if related