From 81c59309085904403ba751ffdb59b7cf6aaf2e30 Mon Sep 17 00:00:00 2001 From: Andriy Moroz <22394886+andriymoroz-mlnx@users.noreply.github.com> Date: Sun, 1 Mar 2020 14:39:56 +0200 Subject: [PATCH] Update config/show to include PFC Watchdog commands (#736) * Add pfcwd utility to the config/show CLI Signed-off-by: Andriy Moroz * Add some more commands Signed-off-by: Andriy Moroz * [doc] Add start_default description Signed-off-by: Andriy Moroz --- config/main.py | 85 ++++++++++++++++++++++++++++++++++++++ doc/Command-Reference.md | 88 ++++++++++++++++++++++++++++++++++++++++ show/main.py | 24 +++++++++++ 3 files changed, 197 insertions(+) diff --git a/config/main.py b/config/main.py index cf18fc7e995f..a525415af521 100755 --- a/config/main.py +++ b/config/main.py @@ -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 ...') diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 8fb8b23eb0ea..c10d5095e235 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -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) @@ -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 \** + +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 \** + +This command sets PFC Watchdog counter polling interval (in ms) + +- Usage: + ``` + config pfcwd interval 200 + ``` + +**config pfcwd counter_poll \** + +This command enables or disables PFCWD related counters polling + +- Usage: + ``` + config pfcwd counter_poll disable + ``` + +**config pfcwd big_red_switch \** + +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 /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 diff --git a/show/main.py b/show/main.py index 4a5230604456..c5add8729e3b 100755 --- a/show/main.py +++ b/show/main.py @@ -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")