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

[CLI][PFCWD][Multi-ASIC] Added multi ASIC support to 'pfcwd' CLI command #1080

Merged
merged 13 commits into from
Sep 3, 2020

Conversation

smaheshm
Copy link
Contributor

- What I did

Added multi ASIC support to the following CLI command:

show pfcwd config
show pfcwd stats.

Added multi ASIC support to following script:

pfcwd

Commands:
big_red_switch Enable/disable BIG_RED_SWITCH mode
counter_poll Enable/disable counter polling
interval Set PFC watchdog counter polling interval
show Show PFC Watchdog information
start Start PFC watchdog on port(s).
start_default Start PFC WD by default configurations
stop Stop PFC watchdog on port(s)

- How I did it

Multi ASIC decorator is used to run on multi ASIC and single ASIC. Multi ASIC requires the CLI to be a class instance.

Converted CLIs to classes to that multi ASIC decorator can be used.

Main logic change in 'show' command is:

  • collect the stats from all ASICs.
  • display the output

'show' commands have the option of passing asic instance and display filter, applicable to multi ASIC platforms.

For config changes,

  • run the config change on each asic instance on multi ASIC platforms, or the only ASIC on single ASIC platforms.

Config commands don't have the option to pass the asic instance or the display filter. By default its all instances and all ports.

- How to verify it

Ran the commands CLI commands on both multi ASIC and single ASIC platforms, and unit tests.

admin@str-n3164-acs-2:~$ pfcwd show stats --help
Usage: pfcwd show stats [OPTIONS] [QUEUES]...

  Show PFC Watchdog stats per queue

Options:
  -d, --display [all|frontend]    Show internal interfaces  [default:
                                  frontend]
  -n, --namespace [asic0|asic1|asic2|asic3|asic4|asic5]
                                  Namespace name or all
  -e, --empty
  --help                          Show this message and exit.
admin@str-n3164-acs-2:~$ pfcwd show config --help
Usage: pfcwd show config [OPTIONS] [PORTS]...

  Show PFC Watchdog configuration

Options:
  -d, --display [all|frontend]    Show internal interfaces  [default:
                                  frontend]
  -n, --namespace [asic0|asic1|asic2|asic3|asic4|asic5]
                                  Namespace name or all
  --help                          Show this message and exit.
admin@str-n3164-acs-2:~$ 

admin@str-n3164-acs-2:~$ pfcwd show config -n asic1 
Changed polling interval to 200 ms on asic1
BIG_RED_SWITCH status is disable on asic1
      PORT    ACTION    DETECTION TIME    RESTORATION TIME
----------  --------  ----------------  ------------------
Ethernet64      drop               200                 200
Ethernet68      drop               200                 200
Ethernet80      drop               200                 200
Ethernet84      drop               200                 200

admin@str-n3164-acs-2:~$ pfcwd show config -n asic1 -d all
Changed polling interval to 200 ms on asic1
BIG_RED_SWITCH status is disable on asic1
          PORT    ACTION    DETECTION TIME    RESTORATION TIME
--------------  --------  ----------------  ------------------
    Ethernet64      drop               200                 200
    Ethernet68      drop               200                 200
    .
    .
    .
Ethernet-BP112      drop               200                 200
Ethernet-BP116      drop               200                 200
Ethernet-BP120      drop               200                 200
Ethernet-BP124      drop               200                 200

admin@str-n3164-acs-2:~$ pfcwd show config 
Changed polling interval to 200 ms on asic0
BIG_RED_SWITCH status is disable on asic0
Changed polling interval to 200 ms on asic1
BIG_RED_SWITCH status is disable on asic1
Changed polling interval to 200 ms on asic2
BIG_RED_SWITCH status is disable on asic2
Changed polling interval to 200 ms on asic3
BIG_RED_SWITCH status is disable on asic3
       PORT    ACTION    DETECTION TIME    RESTORATION TIME
-----------  --------  ----------------  ------------------
Ethernet0      drop               200                 200
Ethernet4      drop               200                 200
Ethernet20      drop               200                 200
 .
 .
Ethernet64      drop               200                 200
Ethernet84      drop               200                 200
.
.
Ethernet136      drop               200                 200
Ethernet168      drop               200                 200
.
.
Ethernet180      drop               200                 200
Ethernet220      drop               200                 200
.
.
Ethernet244      drop               200                 200
Ethernet248      drop               200                 200
Ethernet252      drop               200                 200

pfcstat command


admin@str-n3164-acs-2:~$ sudo pfcwd interval 197
admin@str-n3164-acs-2:~$ sudo pfcwd start --action drop ports all detection-time 199 --restoration-time 199
admin@str-n3164-acs-2:~$ pfcwd show 
config  stats   
admin@str-n3164-acs-2:~$ pfcwd show config
Changed polling interval to 197 ms on asic0
BIG_RED_SWITCH status is enable on asic0
Changed polling interval to 197 ms on asic1
BIG_RED_SWITCH status is enable on asic1
Changed polling interval to 197 ms on asic2
BIG_RED_SWITCH status is enable on asic2
Changed polling interval to 197 ms on asic3
BIG_RED_SWITCH status is enable on asic3
       PORT    ACTION    DETECTION TIME    RESTORATION TIME
-----------  --------  ----------------  ------------------
  Ethernet0      drop               199                 199
  Ethernet4      drop               199                 199
  Ethernet8      drop               199                 199
 Ethernet12      drop               199                 199
 Ethernet16      drop               199                 199
 Ethernet20      drop               199                 199
 Ethernet24      drop               199                 199
 Ethernet28      drop               199                 199
 Ethernet32      drop               199                 199
 .
 .
 .
 .
Ethernet228      drop               199                 199
Ethernet232      drop               199                 199
Ethernet236      drop               199                 199
Ethernet240      drop               199                 199
Ethernet244      drop               199                 199
Ethernet248      drop               199                 199
Ethernet252      drop               199                 199
admin@str-n3164-acs-2:~$ 


@smaheshm
Copy link
Contributor Author

Working on unit test code, raised the PR so review can start.

Copy link
Contributor

@jleveque jleveque left a comment

Choose a reason for hiding this comment

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

Please add more detail to the PR title

@smaheshm smaheshm changed the title Pfcwd [CLI][PFCWD][Multi-ASIC] Added multi ASIC support to 'pfcwd' CLI command Aug 28, 2020
show/main.py Show resolved Hide resolved
show/main.py Outdated
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def config(verbose):
"""Show pfc watchdog config"""

cmd = "pfcwd show config"
cmd = "pfcwd show config -n {} -d {}".format(namespace, display)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will add check for namespace 'None'

show/main.py Outdated
"""Show pfc watchdog stats"""

cmd = "pfcwd show stats"
cmd = "pfcwd show stats -n {} -d {}".format(namespace, display)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will add check for namespace 'None'

@smaheshm
Copy link
Contributor Author

Unit tests are written only for 'show' commands. Unit tests for config commands is pending on mock config set implementation for multi ASIC environment.

pfcwd/main.py Outdated Show resolved Hide resolved
pfcwd/main.py Outdated Show resolved Hide resolved
@smaheshm smaheshm requested a review from jleveque August 31, 2020 18:16
pfcwd/main.py Outdated Show resolved Hide resolved
pfcwd/main.py Outdated Show resolved Hide resolved
pfcwd/main.py Show resolved Hide resolved
pfcwd/main.py Outdated Show resolved Hide resolved
@smaheshm
Copy link
Contributor Author

will wait for reviews from @arlakshm and @neethajohn and make suggested changes.

tests/pfcstat_test.py Show resolved Hide resolved
pfcwd/main.py Outdated Show resolved Hide resolved
pfcwd/main.py Show resolved Hide resolved
pfcwd/main.py Show resolved Hide resolved
pfcwd/main.py Outdated Show resolved Hide resolved
pfcwd/main.py Outdated Show resolved Hide resolved
pfcwd/main.py Outdated Show resolved Hide resolved
pfcwd/main.py Show resolved Hide resolved
tests/pfcwd_masic_test.py Outdated Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Sep 1, 2020

This pull request introduces 1 alert when merging 22bfe46 into 8d6d871 - view on LGTM.com

new alerts:

  • 1 for Unused import

@smaheshm
Copy link
Contributor Author

smaheshm commented Sep 1, 2020

retest this please

@smaheshm
Copy link
Contributor Author

smaheshm commented Sep 1, 2020

Just realized pytest needs file names to start or end with “test”. Will rename file.

…sues with mock DB connection when running separatly
@smaheshm
Copy link
Contributor Author

smaheshm commented Sep 3, 2020

This passes @neethajohn recently added unit tests on single ASIC platform.

Copy link
Contributor

@jleveque jleveque left a comment

Choose a reason for hiding this comment

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

Looks good from my perspective. Please wait for other reviewers.

@smaheshm smaheshm merged commit 8152cec into sonic-net:master Sep 3, 2020
@abdosi
Copy link
Contributor

abdosi commented Sep 3, 2020

@smaheshm Create PR for 201911

@smaheshm
Copy link
Contributor Author

smaheshm commented Sep 8, 2020

@smaheshm Create PR for 201911

#1102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants