Skip to content

Commit

Permalink
Update config/show to include PFC Watchdog commands (sonic-net#736)
Browse files Browse the repository at this point in the history
* Add pfcwd utility to the config/show CLI

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>

* Add some more commands

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>

* [doc] Add start_default description

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
  • Loading branch information
andriymoroz-mlnx authored Mar 1, 2020
1 parent 66e9dfb commit 81c5930
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 0 deletions.
85 changes: 85 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,91 @@ def remove(session_name):
config_db.connect()
config_db.set_entry("MIRROR_SESSION", session_name, None)

#
# 'pfcwd' group ('config pfcwd ...')
#
@config.group()
def pfcwd():
"""Configure pfc watchdog """
pass

@pfcwd.command()
@click.option('--action', '-a', type=click.Choice(['drop', 'forward', 'alert']))
@click.option('--restoration-time', '-r', type=click.IntRange(100, 60000))
@click.option('--verbose', is_flag=True, help="Enable verbose output")
@click.argument('ports', nargs=-1)
@click.argument('detection-time', type=click.IntRange(100, 5000))
def start(action, restoration_time, ports, detection_time, verbose):
"""
Start PFC watchdog on port(s). To config all ports, use all as input.
Example:
config pfcwd start --action drop ports all detection-time 400 --restoration-time 400
"""
cmd = "pfcwd start"

if action:
cmd += " --action {}".format(action)

if ports:
ports = set(ports) - set(['ports', 'detection-time'])
cmd += " ports {}".format(' '.join(ports))

if detection_time:
cmd += " detection-time {}".format(detection_time)

if restoration_time:
cmd += " --restoration-time {}".format(restoration_time)

run_command(cmd, display_cmd=verbose)

@pfcwd.command()
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def stop(verbose):
""" Stop PFC watchdog """

cmd = "pfcwd stop"

run_command(cmd, display_cmd=verbose)

@pfcwd.command()
@click.option('--verbose', is_flag=True, help="Enable verbose output")
@click.argument('poll_interval', type=click.IntRange(100, 3000))
def interval(poll_interval, verbose):
""" Set PFC watchdog counter polling interval (ms) """

cmd = "pfcwd interval {}".format(poll_interval)

run_command(cmd, display_cmd=verbose)

@pfcwd.command()
@click.option('--verbose', is_flag=True, help="Enable verbose output")
@click.argument('counter_poll', type=click.Choice(['enable', 'disable']))
def counter_poll(counter_poll, verbose):
""" Enable/disable counter polling """

cmd = "pfcwd counter_poll {}".format(counter_poll)

run_command(cmd, display_cmd=verbose)

@pfcwd.command()
@click.option('--verbose', is_flag=True, help="Enable verbose output")
@click.argument('big_red_switch', type=click.Choice(['enable', 'disable']))
def big_red_switch(big_red_switch, verbose):
""" Enable/disable BIG_RED_SWITCH mode """

cmd = "pfcwd big_red_switch {}".format(big_red_switch)

run_command(cmd, display_cmd=verbose)

@pfcwd.command()
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def start_default(verbose):
""" Start PFC WD by default configurations """

cmd = "pfcwd start_default"

run_command(cmd, display_cmd=verbose)

#
# 'qos' group ('config qos ...')
Expand Down
88 changes: 88 additions & 0 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
* [NTP](#ntp)
* [NTP show commands](#ntp-show-commands)
* [NTP config commands](#ntp-config-commands)
* [PFC Watchdog Commands](#pfc-watchdog-commands)
* [Platform Component Firmware](#platform-component-firmware)
* [Platform Component Firmware show commands](#platform-component-firmware-show-commands)
* [Platform Component Firmware config commands](#platform-component-firmware-config-commands)
Expand Down Expand Up @@ -3784,6 +3785,93 @@ This command is used to delete a configured NTP server IP address.

Go Back To [Beginning of the document](#) or [Beginning of this section](#NTP)

# PFC Watchdog Commands
Detailed description of the PFC Watchdog could be fount on the [this wiki page](https://github.com/Azure/SONiC/wiki/PFC-Watchdog)

**config pfcwd start \<arguments\>**

This command starts PFC Watchdog

- Usage:
```
config pfcwd start --action drop ports all detection-time 400 --restoration-time 400
config pfcwd start --action forward ports Ethernet0 Ethernet8 detection-time 400
```

**config pfcwd stop**

This command stops PFC Watchdog

- Usage:
```
config pfcwd stop
```

**config pfcwd interval \<interval_in_ms\>**

This command sets PFC Watchdog counter polling interval (in ms)

- Usage:
```
config pfcwd interval 200
```

**config pfcwd counter_poll \<enable/disable\>**

This command enables or disables PFCWD related counters polling

- Usage:
```
config pfcwd counter_poll disable
```

**config pfcwd big_red_switch \<enable/disable\>**

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

- Usage:
```
config pfcwd big_red_switch enable
```

**config pfcwd start_default**

This command starts PFC Watchdog with the default settings.

- Usage:
```
config pfcwd start_default
```

Default values are the following:

- detection time - 200ms
- restoration time - 200ms
- polling interval - 200ms
- action - 'drop'

Additionally if number of ports in the system exceeds 32, all times will be multiplied by roughly <num_ports\>/32.


**show pfcwd config**

This command shows current PFC Watchdog configuration

- Usage:
```
show pfcwd config
```

**show pfcwd stats**

This command shows current PFC Watchdog statistics (storms detected, packets dropped, etc)

- Usage:
```
show pfcwd stats
```

Go Back To [Beginning of the document](#) or [Beginning of this section](#pfc-watchdog-commands)

## Platform Component Firmware

Expand Down
24 changes: 24 additions & 0 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,30 @@ def counters(verbose):

run_command(cmd, display_cmd=verbose)

# 'pfcwd' subcommand ("show pfcwd...")
@cli.group(cls=AliasedGroup, default_if_no_args=False)
def pfcwd():
"""Show details of the pfc watchdog """
pass

@pfcwd.command()
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def config(verbose):
"""Show pfc watchdog config"""

cmd = "pfcwd show config"

run_command(cmd, display_cmd=verbose)

@pfcwd.command()
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def stats(verbose):
"""Show pfc watchdog stats"""

cmd = "pfcwd show stats"

run_command(cmd, display_cmd=verbose)

# 'naming_mode' subcommand ("show interfaces naming_mode")
@interfaces.command()
@click.option('--verbose', is_flag=True, help="Enable verbose output")
Expand Down

0 comments on commit 81c5930

Please sign in to comment.