Skip to content

Commit afceda4

Browse files
authored
[201911] [Flex Counters] add CLI for PG drop packets counters (counterpoll, show/clear counters) (sonic-net#2155)
Signed-off-by: Andriy Yurkiv <[email protected]> Should be merged after sonic-net/sonic-swss#2263 Appropriate PR in master:sonic-net#1355, sonic-net#1461, sonic-net#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
1 parent 988d8e1 commit afceda4

File tree

12 files changed

+668
-2
lines changed

12 files changed

+668
-2
lines changed

clear/main.py

+14
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,20 @@ def clear_wm_pg_shared():
227227
command = 'watermarkstat -c -t pg_shared'
228228
run_command(command)
229229

230+
@priority_group.group()
231+
def drop():
232+
"""Clear priority-group dropped packets stats"""
233+
pass
234+
235+
@drop.command('counters')
236+
def clear_pg_counters():
237+
"""Clear priority-group dropped packets counter """
238+
239+
if os.geteuid() != 0 and os.environ.get("UTILITIES_UNIT_TESTING", "0") != "2":
240+
exit("Root privileges are required for this operation")
241+
command = 'pg-drop -c clear'
242+
run_command(command)
243+
230244
@priority_group.group(name='persistent-watermark')
231245
def persistent_watermark():
232246
"""Clear queue persistent WM. One does not simply clear WM, root is required"""

config/main.py

+5
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,11 @@ def reload(filename, yes, load_sysinfo, no_service_restart):
824824
if multi_asic.is_multi_asic():
825825
num_cfg_file += num_asic
826826

827+
# Remove cached PG drop counters data
828+
dropstat_dir_prefix = '/tmp/dropstat'
829+
command = "rm -rf {}-*".format(dropstat_dir_prefix)
830+
run_command(command, display_cmd=True)
831+
827832
# If the user give the filename[s], extract the file names.
828833
if filename is not None:
829834
cfg_files = filename.split(',')

counterpoll/main.py

+43
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
BUFFER_POOL_WATERMARK = "BUFFER_POOL_WATERMARK"
88
PORT_BUFFER_DROP = "PORT_BUFFER_DROP"
9+
PG_DROP = "PG_DROP"
910
DISABLE = "disable"
1011
ENABLE = "enable"
1112
DEFLT_60_SEC= "default (60000)"
@@ -124,6 +125,45 @@ def disable():
124125
port_info['FLEX_COUNTER_STATUS'] = DISABLE
125126
configdb.mod_entry("FLEX_COUNTER_TABLE", PORT_BUFFER_DROP, port_info)
126127

128+
# Ingress PG drop packet stat
129+
@cli.group()
130+
@click.pass_context
131+
def pg_drop(ctx):
132+
""" Ingress PG drop counter commands """
133+
ctx.obj = swsssdk.ConfigDBConnector()
134+
ctx.obj.connect()
135+
136+
@pg_drop.command()
137+
@click.argument('poll_interval', type=click.IntRange(1000, 30000))
138+
@click.pass_context
139+
def interval(ctx, poll_interval):
140+
"""
141+
Set pg_drop packets counter query interval
142+
interval is between 1s and 30s.
143+
"""
144+
145+
port_info = {}
146+
port_info['POLL_INTERVAL'] = poll_interval
147+
ctx.obj.mod_entry("FLEX_COUNTER_TABLE", PG_DROP, port_info)
148+
149+
@pg_drop.command()
150+
@click.pass_context
151+
def enable(ctx):
152+
""" Enable pg_drop counter query """
153+
154+
port_info = {}
155+
port_info['FLEX_COUNTER_STATUS'] = ENABLE
156+
ctx.obj.mod_entry("FLEX_COUNTER_TABLE", PG_DROP, port_info)
157+
158+
@pg_drop.command()
159+
@click.pass_context
160+
def disable(ctx):
161+
""" Disable pg_drop counter query """
162+
163+
port_info = {}
164+
port_info['FLEX_COUNTER_STATUS'] = DISABLE
165+
ctx.obj.mod_entry("FLEX_COUNTER_TABLE", PG_DROP, port_info)
166+
127167
# RIF counter commands
128168
@cli.group()
129169
def rif():
@@ -213,6 +253,7 @@ def show():
213253
rif_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'RIF')
214254
queue_wm_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'QUEUE_WATERMARK')
215255
pg_wm_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'PG_WATERMARK')
256+
pg_drop_info = configdb.get_entry('FLEX_COUNTER_TABLE', PG_DROP)
216257
buffer_pool_wm_info = configdb.get_entry('FLEX_COUNTER_TABLE', BUFFER_POOL_WATERMARK)
217258

218259
header = ("Type", "Interval (in ms)", "Status")
@@ -229,6 +270,8 @@ def show():
229270
data.append(["QUEUE_WATERMARK_STAT", queue_wm_info.get("POLL_INTERVAL", DEFLT_10_SEC), queue_wm_info.get("FLEX_COUNTER_STATUS", DISABLE)])
230271
if pg_wm_info:
231272
data.append(["PG_WATERMARK_STAT", pg_wm_info.get("POLL_INTERVAL", DEFLT_10_SEC), pg_wm_info.get("FLEX_COUNTER_STATUS", DISABLE)])
273+
if pg_drop_info:
274+
data.append(['PG_DROP_STAT', pg_drop_info.get("POLL_INTERVAL", DEFLT_10_SEC), pg_drop_info.get("FLEX_COUNTER_STATUS", DISABLE)])
232275
if buffer_pool_wm_info:
233276
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)])
234277

doc/Command-Reference.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -4465,11 +4465,14 @@ This command displays the user watermark for the queues (Egress shared pool occu
44654465
44664466
**show priority-group**
44674467
4468-
This command displays the user watermark or persistent-watermark for the Ingress "headroom" or "shared pool occupancy" per priority-group for all ports
4468+
This command displays:
4469+
1) The user watermark or persistent-watermark for the Ingress "headroom" or "shared pool occupancy" per priority-group for all ports.
4470+
2) Dropped packets per priority-group for all ports
44694471
44704472
- Usage:
44714473
```
44724474
show priority-group (watermark | persistent-watermark) (headroom | shared)
4475+
show priority-group drop counters
44734476
```
44744477
44754478
- Example:
@@ -4499,6 +4502,18 @@ This command displays the user watermark or persistent-watermark for the Ingress
44994502
admin@sonic:~$ show priority-group persistent-watermark headroom
45004503
```
45014504
4505+
- Example (Ingress dropped packets per PG):
4506+
```
4507+
admin@sonic:~$ show priority-group drop counters
4508+
Ingress PG dropped packets:
4509+
Port PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7
4510+
----------- ----- ----- ----- ----- ----- ----- ----- -----
4511+
Ethernet0 0 0 0 0 0 0 0 0
4512+
Ethernet4 0 0 0 0 0 0 0 0
4513+
Ethernet8 0 0 0 0 0 0 0 0
4514+
Ethernet12 0 0 0 0 0 0 0 0
4515+
```
4516+
45024517
In addition to user watermark("show queue|priority-group watermark ..."), a persistent watermark is available.
45034518
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.
45044519
@@ -4528,7 +4543,7 @@ This command displays the user persistet-watermark for the queues (Egress shared
45284543
admin@sonic:~$ show queue persistent-watermark multicast
45294544
```
45304545
4531-
- NOTE: Both "user watermark" and "persistent watermark" can be cleared by user:
4546+
- NOTE: "user watermark", "persistent watermark" and "ingress dropped packets" can be cleared by user:
45324547
45334548
```
45344549
root@sonic:~# sonic-clear queue persistent-watermark unicast

0 commit comments

Comments
 (0)