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

Add SWSS support for link event damping feature #2933

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

royyi8
Copy link
Contributor

@royyi8 royyi8 commented Oct 13, 2023

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

struct {

struct {
uint32_t value;
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

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);
Copy link
Collaborator

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?

Copy link
Contributor Author

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());
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@prsunny prsunny requested review from prgeor and dgsudharsan May 7, 2024 23:48
@prsunny
Copy link
Collaborator

prsunny commented May 8, 2024

@royyi8 , could you please rebase and fix the build failure?

@royyi8 royyi8 force-pushed the link_event_damping_feature branch 2 times, most recently from 22e3b06 to facf1b0 Compare May 9, 2024 17:58
@prsunny
Copy link
Collaborator

prsunny commented May 10, 2024

@royyi8 , still a build failure. Can you check so that we can try to get this before branch cutoff this month

@royyi8 royyi8 force-pushed the link_event_damping_feature branch 7 times, most recently from 274c7ac to e3e16dd Compare May 13, 2024 18:30
@prsunny
Copy link
Collaborator

prsunny commented May 13, 2024

@royyi8 , thank you for actively working on this. Could you also please check the coverage issue and add some coverage?

@royyi8 royyi8 force-pushed the link_event_damping_feature branch 3 times, most recently from 3f47f16 to 7dd5a28 Compare May 15, 2024 17:23
@royyi8
Copy link
Contributor Author

royyi8 commented May 15, 2024

@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

@prsunny
Copy link
Collaborator

prsunny commented May 15, 2024

@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?

  1. sonic-mgmt tests
  2. yang-model support for the config_db changes

@@ -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 =
Copy link
Contributor

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_ ?

Copy link
Contributor Author

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.

@@ -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
Copy link
Contributor

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

Copy link
Contributor Author

@royyi8 royyi8 May 15, 2024

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.

Comment on lines +1065 to +1229
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;
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

keep { on new line

Copy link
Contributor Author

@royyi8 royyi8 May 15, 2024

Choose a reason for hiding this comment

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

It's fixed now.

@royyi8 royyi8 force-pushed the link_event_damping_feature branch 2 times, most recently from 208cf4e to a701460 Compare May 15, 2024 23:45
@royyi8
Copy link
Contributor Author

royyi8 commented May 16, 2024

@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?

  1. sonic-mgmt tests
  2. yang-model support for the config_db changes

@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
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

prgeor
prgeor previously approved these changes May 20, 2024
@prsunny
Copy link
Collaborator

prsunny commented May 23, 2024

@royyi8 , can you please resolve conflict and rebase?

@prsunny
Copy link
Collaborator

prsunny commented May 28, 2024

@royyi8 , please rebase

@royyi8 royyi8 force-pushed the link_event_damping_feature branch from b60f4a4 to b881eac Compare June 4, 2024 01:29
@prsunny prsunny merged commit 80f5207 into sonic-net:master Jun 4, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants