-
Notifications
You must be signed in to change notification settings - Fork 539
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
[orchagent] add & remove port counters dynamically each time port was added or removed #2019
[orchagent] add & remove port counters dynamically each time port was added or removed #2019
Conversation
This pull request fixes 2 alerts when merging a343a09 into 05c7c05 - view on LGTM.com fixed alerts:
|
@praveen-li I am unable to assign code review to you. Could you please add yourself as the reviewer? |
This pull request fixes 2 alerts when merging 550fe05 into 5f8ebfa - view on LGTM.com fixed alerts:
|
@prsunny - Can you please add @praveen-li as a reviewer ? |
This pull request fixes 2 alerts when merging 3e72fa4 into 4f6cb05 - view on LGTM.com fixed alerts:
|
/azpw run |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azpw run |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azpw run |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azpw run |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
orchagent/debugcounterorch.cpp
Outdated
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
SWSS_LOG_NOTICE("add debug counter for port 0x%" PRIu64 , 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.
INFO?
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 will change it to INFO
orchagent/debugcounterorch.cpp
Outdated
|
||
SWSS_LOG_NOTICE("add debug counter for port 0x%" PRIu64 , port_id); | ||
|
||
for (const auto& debug_counter: debug_counters) { |
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.
put {
in the second line as consistency as other code.
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.
will be changed
orchagent/debugcounterorch.cpp
Outdated
auto counter_stat = counter->getDebugCounterSAIStat(); | ||
auto flex_counter_type = getFlexCounterType(counter_type); | ||
|
||
if (flex_counter_type == CounterType::PORT_DEBUG){ |
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.
put {
in the second 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.
will be changed
orchagent/debugcounterorch.cpp
Outdated
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
SWSS_LOG_NOTICE("remove debug counter for port 0x%" PRIu64 , 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.
info
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.
will be change to INFO
orchagent/debugcounterorch.cpp
Outdated
|
||
SWSS_LOG_NOTICE("remove debug counter for port 0x%" PRIu64 , port_id); | ||
|
||
for (const auto& debug_counter: debug_counters) { |
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.
put {
in the second 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.
will be change
orchagent/debugcounterorch.cpp
Outdated
auto counter_stat = counter->getDebugCounterSAIStat(); | ||
auto flex_counter_type = getFlexCounterType(counter_type); | ||
|
||
if (flex_counter_type == CounterType::PORT_DEBUG){ |
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.
put {
in the second 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.
will be change
orchagent/debugcounterorch.cpp
Outdated
} | ||
} | ||
|
||
void DebugCounterOrch::removePortDebugCounter(sai_object_id_t 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.
re-use existing function like uninstallDebugFlexCounters()?
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.
uninstallDebugFlexCounters is removing the debug counters from all the ports, in order to fit the function uninstallDebugFlexCounters to remove only one port debug counter we need to add extra argument for indicating which ports to remove (specific port or all the ports)
do you think it's better to change uninstallDebugFlexCounters for that?
like this example:
void DebugCounterOrch::uninstallDebugFlexCounters(const string& counter_type,
const string& counter_stat,
sai_object_id_t port_id = SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ENTER();
CounterType flex_counter_type = getFlexCounterType(counter_type);
if (flex_counter_type == CounterType::SWITCH_DEBUG)
{
flex_counter_manager.removeFlexCounterStat(gSwitchId, flex_counter_type, counter_stat);
}
else if (flex_counter_type == CounterType::PORT_DEBUG)
{
if (port_id != SAI_NULL_OBJECT_ID)
{
flex_counter_manager.removeFlexCounterStat(
curr.second.m_port_id,
flex_counter_type,
counter_stat);
}
else
{
for (auto const &curr : gPortsOrch->getAllPorts())
{
if (curr.second.m_type != Port::Type::PHY)
{
continue;
}
flex_counter_manager.removeFlexCounterStat(
curr.second.m_port_id,
flex_counter_type,
counter_stat);
}
}
}
}
or this option:
void DebugCounterOrch::uninstallDebugFlexCounters(const string& counter_type,
const string& counter_stat,
sai_object_id_t port_id = SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ENTER();
CounterType flex_counter_type = getFlexCounterType(counter_type);
if (flex_counter_type == CounterType::SWITCH_DEBUG)
{
flex_counter_manager.removeFlexCounterStat(gSwitchId, flex_counter_type, counter_stat);
}
else if (flex_counter_type == CounterType::PORT_DEBUG)
{
for (auto const &curr : gPortsOrch->getAllPorts())
{
if (port_id != SAI_NULL_OBJECT_ID)
{
if (curr.second.m_port_id != port_id)
{
continue;
}
}
if (curr.second.m_type != Port::Type::PHY)
{
continue;
}
flex_counter_manager.removeFlexCounterStat(
curr.second.m_port_id,
flex_counter_type,
counter_stat);
}
}
}
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.
The point was to not introduce more functions that has similar needs. One of the option should be fine but be consistent with the Add counter function case.
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.
was changed to the second option for add and remove
orchagent/debugcounterorch.cpp
Outdated
@@ -616,3 +640,50 @@ bool DebugCounterOrch::isDropReasonValid(const string& drop_reason) const | |||
|
|||
return true; | |||
} | |||
|
|||
void DebugCounterOrch::addPortDebugCounter(sai_object_id_t 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.
re-use installDebugFlexCounters()?
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 as above
orchagent/portsorch.cpp
Outdated
if (!getPort(port_id, p)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to get port object for port id 0x%" PRIx64, port_id); | ||
p.m_port_id = 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.
why assign p.m_port_id only when failed?
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 used the way they did it in previous version but, i think it's not needed, if get_port is failing so we just need to add error message and return from this function.
I will change it
This pull request fixes 2 alerts when merging d868d8c into f6f6f86 - view on LGTM.com fixed alerts:
|
/azpw run |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azpw run |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
This pull request fixes 2 alerts when merging 904b583 into 15a3b6c - view on LGTM.com fixed alerts:
|
This pull request fixes 2 alerts when merging 3bc9fb5 into d352d5a - view on LGTM.com fixed alerts:
|
changes according to coding style
remove unused function declerations
3578197
to
e92133c
Compare
This pull request fixes 2 alerts when merging e92133c into 7350d49 - view on LGTM.com fixed alerts:
|
/azp run Azure.sonic-swss |
Azure Pipelines successfully started running 1 pipeline(s). |
orchagent/portsorch.cpp
Outdated
@@ -2378,6 +2378,16 @@ bool PortsOrch::initPort(const string &alias, const string &role, const int inde | |||
port_buffer_drop_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, port_buffer_drop_stats); | |||
} | |||
|
|||
/* when a port is added and priority group map counter is enabled --> we need to add pg counter for it */ | |||
if (m_isPriorityGroupMapGenerated) { |
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.
"{" to separate line to be consistent.
Can you go through the whole PR to make sure we follow the same coding style?
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.
Done!
orchagent/portsorch.cpp
Outdated
} | ||
|
||
/* when a port is added and queue map counter is enabled --> we need to add queue map counter for it */ | ||
if (m_isQueueMapGenerated) { |
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 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.
Done!
orchagent/portsorch.cpp
Outdated
@@ -2425,9 +2440,18 @@ void PortsOrch::deInitPort(string alias, sai_object_id_t port_id) | |||
port_buffer_drop_stat_manager.clearCounterIdList(p.m_port_id); | |||
} | |||
|
|||
/* remove pg port counters */ | |||
if (m_isPriorityGroupMapGenerated) { |
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.
{ to separate 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.
Done!
orchagent/portsorch.cpp
Outdated
} | ||
|
||
/* remove queue port counters */ | ||
if (m_isQueueMapGenerated) { |
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.
{ to separate 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.
Done!
This pull request fixes 2 alerts when merging ca47331 into 8941cc0 - view on LGTM.com fixed alerts:
|
@prsunny - Can you please approve this PR ? |
/azp run Azure.sonic-swss |
Azure Pipelines successfully started running 1 pipeline(s). |
@prsunny - can you please review ? |
@prsunny - Can you please review ? |
… added or removed (sonic-net#2019) - What I did Add support for adding & removing port counters dynamically each time port was added or removed the counters that were supported are: 1. pg watermark counters 2. pg drop counters 3. queue stat counters 4. queue watermark counters 5. debug counters 6. buffer drop counters and port stat counters are already supported to be added or removed each time port is added/removed Implemented according to the - 'HLD document on add/remove ports dynamically feature' sonic-net/SONiC#900 - Why I did it In order to support dynamically add or removed ports on sonic - How I verified it tested manually that the flex counters were added or removed correctly whenever we add or remove ports added new test cases to the following vs tests: test_flex_counters.py test_drop_counters.py test_pg_drop_counter.py Co-authored-by: dprital <[email protected]>
… added or removed (sonic-net#2019) - What I did Add support for adding & removing port counters dynamically each time port was added or removed the counters that were supported are: 1. pg watermark counters 2. pg drop counters 3. queue stat counters 4. queue watermark counters 5. debug counters 6. buffer drop counters and port stat counters are already supported to be added or removed each time port is added/removed Implemented according to the - 'HLD document on add/remove ports dynamically feature' sonic-net/SONiC#900 - Why I did it In order to support dynamically add or removed ports on sonic - How I verified it tested manually that the flex counters were added or removed correctly whenever we add or remove ports added new test cases to the following vs tests: test_flex_counters.py test_drop_counters.py test_pg_drop_counter.py Co-authored-by: dprital <[email protected]>
What I did
Add support for adding & removing port counters dynamically each time port was added or removed
the counters that were supported are:
Implemented according to the - HLD document on add/remove ports dynamically feature
Why I did it
In order to support dynamically add or removed ports on sonic
How I verified it
tested manually that the flex counters were added or removed correctly whenever we add or remove ports
added new test cases to the following vs tests:
Details if related