Skip to content

Commit

Permalink
[201911] [Flex Counters] add CLI for PG drop packets counters (counte…
Browse files Browse the repository at this point in the history
…rpoll, show/clear counters) (#2155)

Signed-off-by: Andriy Yurkiv <[email protected]>

Should be merged after sonic-net/sonic-swss#2263

Appropriate PR in master:#1355, #1461, #1583

What I did
Added new option for "counterpoll" utility
Added new CLI commands to view and clear PG dropped packet statistics.
Added the new CLI commands to the command reference guide.

How I did it
Need to merge PG drop functionality to 201911

How to verify it
admin@arc-switch1041:~$ counterpoll pg-drop enable  --> to enable the new counter
admin@arc-switch1041:~$ counterpoll show  --> check new INGRESS_PG_STAT_DROP counter status
Check counters

admin@arc-switch1041:~$ redis-cli -n 2
127.0.0.1:6379[2]> HGETALL COUNTERS:oid:0x1a000000000062
1) "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES"
2) "0"
3) "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES"
4) "0"
5) "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS"
6) "0"
show priority-group drop counters

Ingress PG dropped packets:
     Port    PG0    PG1    PG2    PG3    PG4    PG5    PG6    PG7
---------  -----  -----  -----  -----  -----  -----  -----  -----
Ethernet0    800    801    802    803    804    805    806    807
Ethernet4    400    401    402    403    404    405    406    407
Ethernet8    100    101    102    103    104    105    106    107
...
sonic-clear priority-group drop counters
Cleared PG drop counters
  • Loading branch information
ayurkiv-nvda authored Jun 22, 2022
1 parent 988d8e1 commit afceda4
Show file tree
Hide file tree
Showing 12 changed files with 668 additions and 2 deletions.
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

0 comments on commit afceda4

Please sign in to comment.