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

[201911] [Flex Counters] add CLI for PG drop packets counters (counterpoll, show/clear counters) #2155

Merged
merged 4 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions clear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,20 @@ def clear_wm_pg_shared():
command = 'watermarkstat -c -t pg_shared'
run_command(command)

@priority_group.group()
def drop():
"""Clear priority-group dropped packets stats"""
pass

@drop.command('counters')
def clear_pg_counters():
"""Clear priority-group dropped packets counter """

if os.geteuid() != 0 and os.environ.get("UTILITIES_UNIT_TESTING", "0") != "2":
exit("Root privileges are required for this operation")
command = 'pg-drop -c clear'
run_command(command)

@priority_group.group(name='persistent-watermark')
def persistent_watermark():
"""Clear queue persistent WM. One does not simply clear WM, root is required"""
Expand Down
5 changes: 5 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,11 @@ def reload(filename, yes, load_sysinfo, no_service_restart):
if multi_asic.is_multi_asic():
num_cfg_file += num_asic

# Remove cached PG drop counters data
dropstat_dir_prefix = '/tmp/dropstat'
command = "rm -rf {}-*".format(dropstat_dir_prefix)
run_command(command, display_cmd=True)

# If the user give the filename[s], extract the file names.
if filename is not None:
cfg_files = filename.split(',')
Expand Down
43 changes: 43 additions & 0 deletions counterpoll/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

BUFFER_POOL_WATERMARK = "BUFFER_POOL_WATERMARK"
PORT_BUFFER_DROP = "PORT_BUFFER_DROP"
PG_DROP = "PG_DROP"
DISABLE = "disable"
ENABLE = "enable"
DEFLT_60_SEC= "default (60000)"
Expand Down Expand Up @@ -124,6 +125,45 @@ def disable():
port_info['FLEX_COUNTER_STATUS'] = DISABLE
configdb.mod_entry("FLEX_COUNTER_TABLE", PORT_BUFFER_DROP, port_info)

# Ingress PG drop packet stat
@cli.group()
@click.pass_context
def pg_drop(ctx):
""" Ingress PG drop counter commands """
ctx.obj = swsssdk.ConfigDBConnector()
ctx.obj.connect()

@pg_drop.command()
@click.argument('poll_interval', type=click.IntRange(1000, 30000))
@click.pass_context
def interval(ctx, poll_interval):
"""
Set pg_drop packets counter query interval
interval is between 1s and 30s.
"""

port_info = {}
port_info['POLL_INTERVAL'] = poll_interval
ctx.obj.mod_entry("FLEX_COUNTER_TABLE", PG_DROP, port_info)

@pg_drop.command()
@click.pass_context
def enable(ctx):
""" Enable pg_drop counter query """

port_info = {}
port_info['FLEX_COUNTER_STATUS'] = ENABLE
ctx.obj.mod_entry("FLEX_COUNTER_TABLE", PG_DROP, port_info)

@pg_drop.command()
@click.pass_context
def disable(ctx):
""" Disable pg_drop counter query """

port_info = {}
port_info['FLEX_COUNTER_STATUS'] = DISABLE
ctx.obj.mod_entry("FLEX_COUNTER_TABLE", PG_DROP, port_info)

# RIF counter commands
@cli.group()
def rif():
Expand Down Expand Up @@ -213,6 +253,7 @@ def show():
rif_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'RIF')
queue_wm_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'QUEUE_WATERMARK')
pg_wm_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'PG_WATERMARK')
pg_drop_info = configdb.get_entry('FLEX_COUNTER_TABLE', PG_DROP)
buffer_pool_wm_info = configdb.get_entry('FLEX_COUNTER_TABLE', BUFFER_POOL_WATERMARK)

header = ("Type", "Interval (in ms)", "Status")
Expand All @@ -229,6 +270,8 @@ def show():
data.append(["QUEUE_WATERMARK_STAT", queue_wm_info.get("POLL_INTERVAL", DEFLT_10_SEC), queue_wm_info.get("FLEX_COUNTER_STATUS", DISABLE)])
if pg_wm_info:
data.append(["PG_WATERMARK_STAT", pg_wm_info.get("POLL_INTERVAL", DEFLT_10_SEC), pg_wm_info.get("FLEX_COUNTER_STATUS", DISABLE)])
if pg_drop_info:
data.append(['PG_DROP_STAT', pg_drop_info.get("POLL_INTERVAL", DEFLT_10_SEC), pg_drop_info.get("FLEX_COUNTER_STATUS", DISABLE)])
if buffer_pool_wm_info:
data.append(["BUFFER_POOL_WATERMARK_STAT", buffer_pool_wm_info.get("POLL_INTERVAL", DEFLT_10_SEC), buffer_pool_wm_info.get("FLEX_COUNTER_STATUS", DISABLE)])

Expand Down
19 changes: 17 additions & 2 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -4465,11 +4465,14 @@ This command displays the user watermark for the queues (Egress shared pool occu

**show priority-group**

This command displays the user watermark or persistent-watermark for the Ingress "headroom" or "shared pool occupancy" per priority-group for all ports
This command displays:
1) The user watermark or persistent-watermark for the Ingress "headroom" or "shared pool occupancy" per priority-group for all ports.
2) Dropped packets per priority-group for all ports

- Usage:
```
show priority-group (watermark | persistent-watermark) (headroom | shared)
show priority-group drop counters
```

- Example:
Expand Down Expand Up @@ -4499,6 +4502,18 @@ This command displays the user watermark or persistent-watermark for the Ingress
admin@sonic:~$ show priority-group persistent-watermark headroom
```

- Example (Ingress dropped packets per PG):
```
admin@sonic:~$ show priority-group drop counters
Ingress PG dropped packets:
Port PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7
----------- ----- ----- ----- ----- ----- ----- ----- -----
Ethernet0 0 0 0 0 0 0 0 0
Ethernet4 0 0 0 0 0 0 0 0
Ethernet8 0 0 0 0 0 0 0 0
Ethernet12 0 0 0 0 0 0 0 0
```

In addition to user watermark("show queue|priority-group watermark ..."), a persistent watermark is available.
It hold values independently of user watermark. This way user can use "user watermark" for debugging, clear it, etc, but the "persistent watermark" will not be affected.

Expand Down Expand Up @@ -4528,7 +4543,7 @@ This command displays the user persistet-watermark for the queues (Egress shared
admin@sonic:~$ show queue persistent-watermark multicast
```

- NOTE: Both "user watermark" and "persistent watermark" can be cleared by user:
- NOTE: "user watermark", "persistent watermark" and "ingress dropped packets" can be cleared by user:

```
root@sonic:~# sonic-clear queue persistent-watermark unicast
Expand Down
Loading