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

[sflowmgrd] Infer sampling rate dynamically based on oper speed #2799

Merged
merged 12 commits into from
Jun 12, 2023

Conversation

vivekrnv
Copy link
Contributor

@vivekrnv vivekrnv commented May 29, 2023

What I did

  1. Remove sflowSpeedRateInitMap and infer the default sampling rate based on speed on the interface.
  2. Make the rate inference based on oper_speed.

Why I did it

  1. With Static Map, adding a new speed would require updating the code.
  2. auotneg might change the operational speed on the port but the default sampling rate is not updated

How I verified it

  1. UT's:
[----------] 11 tests from SflowMgrTest
[ RUN      ] SflowMgrTest.test_RateConfiguration
[       OK ] SflowMgrTest.test_RateConfiguration (0 ms)
[ RUN      ] SflowMgrTest.test_RateConfigurationCfgSpeed
[       OK ] SflowMgrTest.test_RateConfigurationCfgSpeed (0 ms)
[ RUN      ] SflowMgrTest.test_OnlyStateDbNotif
[       OK ] SflowMgrTest.test_OnlyStateDbNotif (0 ms)
[ RUN      ] SflowMgrTest.test_LocalRateConfiguration
[       OK ] SflowMgrTest.test_LocalRateConfiguration (0 ms)
[ RUN      ] SflowMgrTest.test_LocalRateConfWithOperSpeed
[       OK ] SflowMgrTest.test_LocalRateConfWithOperSpeed (1 ms)
[ RUN      ] SflowMgrTest.test_newSpeed
[       OK ] SflowMgrTest.test_newSpeed (0 ms)
[ RUN      ] SflowMgrTest.test_CfgSpeedAdminCfg
[       OK ] SflowMgrTest.test_CfgSpeedAdminCfg (0 ms)
[ RUN      ] SflowMgrTest.test_OperSpeedAdminCfg
[       OK ] SflowMgrTest.test_OperSpeedAdminCfg (0 ms)
[ RUN      ] SflowMgrTest.test_SflowCfgAfterPortCfg
[       OK ] SflowMgrTest.test_SflowCfgAfterPortCfg (0 ms)
[ RUN      ] SflowMgrTest.test_SflowCfgAfterOperSpeed
[       OK ] SflowMgrTest.test_SflowCfgAfterOperSpeed (1 ms)
[ RUN      ] SflowMgrTest.test_RateConfigEgressDir
[       OK ] SflowMgrTest.test_RateConfigEgressDir (0 ms)
[----------] 11 tests from SflowMgrTest (2 ms total)
  1. Run manual tests on a DUT

Test normal speed change without autoneg

root@dut:/home/admin# show sflow interface | grep Ethernet220
| Ethernet220 | up            |          100000 |

root@dut:/home/admin# config interface speed Ethernet220 50000
root@dut:/home/admin# show sflow interface | grep Ethernet220
| Ethernet220 | up            |           50000 |

root@dut:/home/admin# config interface speed Ethernet220 25000
root@dut:/home/admin# show sflow interface | grep Ethernet220
| Ethernet220 | up            |           25000 |

Test rate change with autoneg

Ethernet205 <-> Ethernet209 Back to back connected

root@dut:/# show interfaces status 
Ethernet205              205      25G   9100    N/A   etp52b  routed      up       up    QSFP28 or later         N/A
Ethernet209              209      25G   9100    N/A   etp53b  routed      up       up    QSFP28 or later         N/A

<Check sampling rate before >
root@dut:/# show sflow interface
| Ethernet205 | up            |           25000 |
| Ethernet209 | up            |           25000 |

<Enable autoneg on 209>
root@dut:/# config interface autoneg Ethernet209 enabled
<Change speed on the peer port>
root@dut:/# config interface speed Ethernet205 10000

<Speed on 209 is updated because of autoneg>
root@dut:/# show interfaces status 
Ethernet205              205      10G   9100    N/A   etp52b  routed      up       up   QSFP28 or later         N/A
Ethernet209              209      10G   9100    N/A   etp53b  routed      up       up   QSFP28 or later         N/A

<sampling rate updated on both the ports>    
root@dut:/# show sflow interface
| Ethernet205 | up            |           10000 |
| Ethernet209 | up            |           10000 |

<disable autoneg> 
root@dut:/# config interface autoneg Ethernet209 disabled

root@dut:/# show sflow interface
| Ethernet205 | up            |           10000 |
| Ethernet209 | up            |           10000 |

vivekrnv and others added 10 commits April 14, 2023 23:30
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
@vivekrnv vivekrnv requested a review from prsunny as a code owner May 29, 2023 02:05
@vivekrnv vivekrnv marked this pull request as draft May 31, 2023 16:49
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
@vivekrnv vivekrnv marked this pull request as ready for review June 1, 2023 22:32
@dgsudharsan
Copy link
Collaborator

@venkatmahalingam @prsunny Can you please help to review the changes?

@venkatmahalingam
Copy link
Contributor

@Gokulnath-Raja Please take a look at the changes.

@Gokulnath-Raja
Copy link

Kindly test following,

  1. With MAX interface and restart various container such as sflow, SWSS etc to see at all time sampling rate is programmed properly
  2. Toggle to port oper status and ensure sampling rate is programmed properly

string alias = kfvKey(t);
string op = kfvOp(t);
auto values = kfvFieldsValues(t);
string oper_speed = "";

Choose a reason for hiding this comment

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

Do we need to default as NA_SPEED instead of empty check??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

orchagent may write NA_SPEED to oper_speed in STATE_DB, setting it as empty will let us know if oper_speed field is written to state-db

Choose a reason for hiding this comment

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

ok thanks for the clarification

m_sflowPortConfMap[alias].speed.c_str(),
oper_speed.c_str());
/* oper_speed is updated by orchagent if the vendor supports and oper status is up */
if (m_sflowPortConfMap[alias].oper_speed != oper_speed && !oper_speed.empty())

Choose a reason for hiding this comment

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

Check first oper_speed != NA_SPEED && m_sflowPortConfMap[alias].oper_speed != oper_speed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

!oper_speed.empty() check is required to understand if something is written to STATE_DB. (otherwise we'll have duplicate writes to APPL_DB). If the oper_speed happen to be NA findSamplingRate() has logic to check if the speed is NA and if so, written the sampling rate based on configured speed

Copy link

@Gokulnath-Raja Gokulnath-Raja Jun 12, 2023

Choose a reason for hiding this comment

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

ok thanks for the clarification

@vivekrnv
Copy link
Contributor Author

vivekrnv commented Jun 8, 2023

Kindly test following,

  1. With MAX interface and restart various container such as sflow, SWSS etc to see at all time sampling rate is programmed properly
  2. Toggle to port oper status and ensure sampling rate is programmed properly

Hi,

I've tested those scenarios and also ran sonic-mgmt tests to verify the functionality.

@dgsudharsan
Copy link
Collaborator

@Gokulnath-Raja Can you please re-review?

@prsunny prsunny merged commit 17c8ca6 into sonic-net:master Jun 12, 2023
theasianpianist pushed a commit to theasianpianist/sonic-swss that referenced this pull request Jul 20, 2023
…c-net#2799)

* Remove sflowSpeedRateInitMap and infer the default sampling rate based on speed on the interface.
* Make the rate inference based on oper_speed.
@skg-net
Copy link
Member

skg-net commented Feb 6, 2024

@vivekrnv Can you please update the Quality Metric (Alpha/Beta/GA) for the feature either in this PR comments or in HLD itself based on https://github.com/sonic-net/SONiC/blob/master/doc/SONiC%20feature%20quality%20definition.md
Thanks

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.

6 participants