[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.
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.
put { in the second line as consistency as other code.
There was a problem hiding this comment.
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.
put { in the second line
There was a problem hiding this comment.
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.
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.
put { in the second line
There was a problem hiding this comment.
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.
put { in the second line
There was a problem hiding this comment.
will be change
orchagent/debugcounterorch.cpp
Outdated
| } | ||
| } | ||
|
|
||
| void DebugCounterOrch::removePortDebugCounter(sai_object_id_t port_id) |
There was a problem hiding this comment.
re-use existing function like uninstallDebugFlexCounters()?
There was a problem hiding this comment.
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.
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.
was changed to the second option for add and remove
orchagent/debugcounterorch.cpp
Outdated
| return true; | ||
| } | ||
|
|
||
| void DebugCounterOrch::addPortDebugCounter(sai_object_id_t port_id) |
There was a problem hiding this comment.
re-use installDebugFlexCounters()?
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.
why assign p.m_port_id only when failed?
There was a problem hiding this comment.
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
| } | ||
|
|
||
| /* 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.
"{" to separate line to be consistent.
Can you go through the whole PR to make sure we follow the same coding style?
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) { |
orchagent/portsorch.cpp
Outdated
| } | ||
|
|
||
| /* remove pg port counters */ | ||
| if (m_isPriorityGroupMapGenerated) { |
orchagent/portsorch.cpp
Outdated
| } | ||
|
|
||
| /* remove queue port counters */ | ||
| if (m_isQueueMapGenerated) { |
|
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]>
… 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