Skip to content

Commit 81c5930

Browse files
Update config/show to include PFC Watchdog commands (sonic-net#736)
* Add pfcwd utility to the config/show CLI Signed-off-by: Andriy Moroz <[email protected]> * Add some more commands Signed-off-by: Andriy Moroz <[email protected]> * [doc] Add start_default description Signed-off-by: Andriy Moroz <[email protected]>
1 parent 66e9dfb commit 81c5930

File tree

3 files changed

+197
-0
lines changed

3 files changed

+197
-0
lines changed

config/main.py

+85
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,91 @@ def remove(session_name):
843843
config_db.connect()
844844
config_db.set_entry("MIRROR_SESSION", session_name, None)
845845

846+
#
847+
# 'pfcwd' group ('config pfcwd ...')
848+
#
849+
@config.group()
850+
def pfcwd():
851+
"""Configure pfc watchdog """
852+
pass
853+
854+
@pfcwd.command()
855+
@click.option('--action', '-a', type=click.Choice(['drop', 'forward', 'alert']))
856+
@click.option('--restoration-time', '-r', type=click.IntRange(100, 60000))
857+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
858+
@click.argument('ports', nargs=-1)
859+
@click.argument('detection-time', type=click.IntRange(100, 5000))
860+
def start(action, restoration_time, ports, detection_time, verbose):
861+
"""
862+
Start PFC watchdog on port(s). To config all ports, use all as input.
863+
864+
Example:
865+
config pfcwd start --action drop ports all detection-time 400 --restoration-time 400
866+
"""
867+
cmd = "pfcwd start"
868+
869+
if action:
870+
cmd += " --action {}".format(action)
871+
872+
if ports:
873+
ports = set(ports) - set(['ports', 'detection-time'])
874+
cmd += " ports {}".format(' '.join(ports))
875+
876+
if detection_time:
877+
cmd += " detection-time {}".format(detection_time)
878+
879+
if restoration_time:
880+
cmd += " --restoration-time {}".format(restoration_time)
881+
882+
run_command(cmd, display_cmd=verbose)
883+
884+
@pfcwd.command()
885+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
886+
def stop(verbose):
887+
""" Stop PFC watchdog """
888+
889+
cmd = "pfcwd stop"
890+
891+
run_command(cmd, display_cmd=verbose)
892+
893+
@pfcwd.command()
894+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
895+
@click.argument('poll_interval', type=click.IntRange(100, 3000))
896+
def interval(poll_interval, verbose):
897+
""" Set PFC watchdog counter polling interval (ms) """
898+
899+
cmd = "pfcwd interval {}".format(poll_interval)
900+
901+
run_command(cmd, display_cmd=verbose)
902+
903+
@pfcwd.command()
904+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
905+
@click.argument('counter_poll', type=click.Choice(['enable', 'disable']))
906+
def counter_poll(counter_poll, verbose):
907+
""" Enable/disable counter polling """
908+
909+
cmd = "pfcwd counter_poll {}".format(counter_poll)
910+
911+
run_command(cmd, display_cmd=verbose)
912+
913+
@pfcwd.command()
914+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
915+
@click.argument('big_red_switch', type=click.Choice(['enable', 'disable']))
916+
def big_red_switch(big_red_switch, verbose):
917+
""" Enable/disable BIG_RED_SWITCH mode """
918+
919+
cmd = "pfcwd big_red_switch {}".format(big_red_switch)
920+
921+
run_command(cmd, display_cmd=verbose)
922+
923+
@pfcwd.command()
924+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
925+
def start_default(verbose):
926+
""" Start PFC WD by default configurations """
927+
928+
cmd = "pfcwd start_default"
929+
930+
run_command(cmd, display_cmd=verbose)
846931

847932
#
848933
# 'qos' group ('config qos ...')

doc/Command-Reference.md

+88
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
* [NTP](#ntp)
7474
* [NTP show commands](#ntp-show-commands)
7575
* [NTP config commands](#ntp-config-commands)
76+
* [PFC Watchdog Commands](#pfc-watchdog-commands)
7677
* [Platform Component Firmware](#platform-component-firmware)
7778
* [Platform Component Firmware show commands](#platform-component-firmware-show-commands)
7879
* [Platform Component Firmware config commands](#platform-component-firmware-config-commands)
@@ -3784,6 +3785,93 @@ This command is used to delete a configured NTP server IP address.
37843785
37853786
Go Back To [Beginning of the document](#) or [Beginning of this section](#NTP)
37863787
3788+
# PFC Watchdog Commands
3789+
Detailed description of the PFC Watchdog could be fount on the [this wiki page](https://github.com/Azure/SONiC/wiki/PFC-Watchdog)
3790+
3791+
**config pfcwd start \<arguments\>**
3792+
3793+
This command starts PFC Watchdog
3794+
3795+
- Usage:
3796+
```
3797+
config pfcwd start --action drop ports all detection-time 400 --restoration-time 400
3798+
config pfcwd start --action forward ports Ethernet0 Ethernet8 detection-time 400
3799+
```
3800+
3801+
**config pfcwd stop**
3802+
3803+
This command stops PFC Watchdog
3804+
3805+
- Usage:
3806+
```
3807+
config pfcwd stop
3808+
```
3809+
3810+
**config pfcwd interval \<interval_in_ms\>**
3811+
3812+
This command sets PFC Watchdog counter polling interval (in ms)
3813+
3814+
- Usage:
3815+
```
3816+
config pfcwd interval 200
3817+
```
3818+
3819+
**config pfcwd counter_poll \<enable/disable\>**
3820+
3821+
This command enables or disables PFCWD related counters polling
3822+
3823+
- Usage:
3824+
```
3825+
config pfcwd counter_poll disable
3826+
```
3827+
3828+
**config pfcwd big_red_switch \<enable/disable\>**
3829+
3830+
This command enables or disables PFCWD's "BIG RED SWITCH"(BRS). After enabling BRS PFC Watchdog will be activated on all ports/queues it is configured for no matter whether the storm was detected or not
3831+
3832+
- Usage:
3833+
```
3834+
config pfcwd big_red_switch enable
3835+
```
3836+
3837+
**config pfcwd start_default**
3838+
3839+
This command starts PFC Watchdog with the default settings.
3840+
3841+
- Usage:
3842+
```
3843+
config pfcwd start_default
3844+
```
3845+
3846+
Default values are the following:
3847+
3848+
- detection time - 200ms
3849+
- restoration time - 200ms
3850+
- polling interval - 200ms
3851+
- action - 'drop'
3852+
3853+
Additionally if number of ports in the system exceeds 32, all times will be multiplied by roughly <num_ports\>/32.
3854+
3855+
3856+
**show pfcwd config**
3857+
3858+
This command shows current PFC Watchdog configuration
3859+
3860+
- Usage:
3861+
```
3862+
show pfcwd config
3863+
```
3864+
3865+
**show pfcwd stats**
3866+
3867+
This command shows current PFC Watchdog statistics (storms detected, packets dropped, etc)
3868+
3869+
- Usage:
3870+
```
3871+
show pfcwd stats
3872+
```
3873+
3874+
Go Back To [Beginning of the document](#) or [Beginning of this section](#pfc-watchdog-commands)
37873875
37883876
## Platform Component Firmware
37893877

show/main.py

+24
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,30 @@ def counters(verbose):
10431043

10441044
run_command(cmd, display_cmd=verbose)
10451045

1046+
# 'pfcwd' subcommand ("show pfcwd...")
1047+
@cli.group(cls=AliasedGroup, default_if_no_args=False)
1048+
def pfcwd():
1049+
"""Show details of the pfc watchdog """
1050+
pass
1051+
1052+
@pfcwd.command()
1053+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
1054+
def config(verbose):
1055+
"""Show pfc watchdog config"""
1056+
1057+
cmd = "pfcwd show config"
1058+
1059+
run_command(cmd, display_cmd=verbose)
1060+
1061+
@pfcwd.command()
1062+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
1063+
def stats(verbose):
1064+
"""Show pfc watchdog stats"""
1065+
1066+
cmd = "pfcwd show stats"
1067+
1068+
run_command(cmd, display_cmd=verbose)
1069+
10461070
# 'naming_mode' subcommand ("show interfaces naming_mode")
10471071
@interfaces.command()
10481072
@click.option('--verbose', is_flag=True, help="Enable verbose output")

0 commit comments

Comments
 (0)