Skip to content

Commit

Permalink
Add all parameter to show/clear queue watermark command (sonic-ne…
Browse files Browse the repository at this point in the history
…t#1149)

Signed-off-by: Petro Bratash petrox.bratash@intel.com
Depends on sonic-net/sonic-swss#1653

- What I did
Add new commands :
show queue persistent-watermark all
show queue watermark all
sonic-clear queue watermark all
sonic-clear queue persistent-watermark all

- How I did it
Add q_shared_all type to watermarkstat file

- How to verify it
Execute:
show queue persistent-watermark all
show queue watermark all
sonic-clear queue watermark all
sonic-clear queue persistent-watermark all
  • Loading branch information
bratashX authored Mar 25, 2021
1 parent 1ee04fb commit 1f1696a
Show file tree
Hide file tree
Showing 6 changed files with 288 additions and 9 deletions.
11 changes: 11 additions & 0 deletions clear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ def clear_wm_q_multi():
command = 'watermarkstat -c -t q_shared_multi'
run_command(command)

@watermark.command('all')
def clear_wm_q_all():
"""Clear user WM for all queues"""
command = 'watermarkstat -c -t q_shared_all'
run_command(command)

@queue.group(name='persistent-watermark')
def persistent_watermark():
"""Clear queue persistent WM. One does not simply clear WM, root is required"""
Expand All @@ -290,6 +296,11 @@ def clear_pwm_q_multi():
command = 'watermarkstat -c -p -t q_shared_multi'
run_command(command)

@persistent_watermark.command('all')
def clear_pwm_q_all():
"""Clear persistent WM for all queues"""
command = 'watermarkstat -c -p -t q_shared_all'
run_command(command)

@cli.group(name='headroom-pool')
def headroom_pool():
Expand Down
23 changes: 18 additions & 5 deletions scripts/watermarkstat
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Watermarkstat(object):
def __init__(self):
self.counters_db = SonicV2Connector(use_unix_socket_path=False)
self.counters_db.connect(self.counters_db.COUNTERS_DB)

# connect APP DB for clear notifications
self.app_db = SonicV2Connector(use_unix_socket_path=False)
self.app_db.connect(self.counters_db.APPL_DB)
Expand Down Expand Up @@ -107,12 +107,14 @@ class Watermarkstat(object):

self.port_uc_queues_map = {}
self.port_mc_queues_map = {}
self.port_all_queues_map = {}
self.port_pg_map = {}
self.port_name_map = {}

for port in self.counter_port_name_map:
self.port_uc_queues_map[port] = {}
self.port_mc_queues_map[port] = {}
self.port_all_queues_map[port] = {}
self.port_pg_map[port] = {}
self.port_name_map[self.counter_port_name_map[port]] = port

Expand All @@ -130,6 +132,9 @@ class Watermarkstat(object):
elif get_queue_type(counter_queue_name_map[queue]) == QUEUE_TYPE_MC:
self.port_mc_queues_map[port][queue] = counter_queue_name_map[queue]

elif get_queue_type(counter_queue_name_map[queue]) == QUEUE_TYPE_ALL:
self.port_all_queues_map[port][queue] = counter_queue_name_map[queue]

# Get PGs for each port
counter_pg_name_map = self.counters_db.get_all(self.counters_db.COUNTERS_DB, COUNTERS_PG_NAME_MAP)
if counter_pg_name_map is None:
Expand Down Expand Up @@ -167,6 +172,11 @@ class Watermarkstat(object):
"idx_func": self.get_queue_index,
"wm_name" : "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES",
"header_prefix": "MC"},
"q_shared_all": {"message" : "Egress shared pool occupancy per all queues:",
"obj_map" : self.port_all_queues_map,
"idx_func": self.get_queue_index,
"wm_name" : "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES",
"header_prefix": "ALL"},
"buffer_pool" : {"message": "Shared pool maximum occupancy:",
"wm_name": "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES",
"header" : headerBufferPool},
Expand Down Expand Up @@ -271,6 +281,9 @@ def main():
Examples:
watermarkstat -t pg_headroom
watermarkstat -t pg_shared
watermarkstat -t q_shared_all
watermarkstat -p -t q_shared_all
watermarkstat -t q_shared_all -c
watermarkstat -t q_shared_uni -c
watermarkstat -t q_shared_multi -c
watermarkstat -p -t pg_shared
Expand All @@ -283,17 +296,17 @@ Examples:
parser.add_argument('-c', '--clear', action='store_true', help='Clear watermarks request')
parser.add_argument('-p', '--persistent', action='store_true', help='Do the operations on the persistent watermark')
parser.add_argument('-t', '--type', required=True, action='store',
choices=['pg_headroom', 'pg_shared', 'q_shared_uni', 'q_shared_multi', 'buffer_pool', 'headroom_pool'],
choices=['pg_headroom', 'pg_shared', 'q_shared_uni', 'q_shared_multi', 'buffer_pool', 'headroom_pool', 'q_shared_all'],
help='The type of watermark')
parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0')
args = parser.parse_args()
watermarkstat = Watermarkstat()

if args.clear:
watermarkstat.send_clear_notification(("PERSISTENT" if args.persistent else "USER", args.type.upper()))
sys.exit(0)
table_prefix = PERSISTENT_TABLE_PREFIX if args.persistent else USER_TABLE_PREFIX

table_prefix = PERSISTENT_TABLE_PREFIX if args.persistent else USER_TABLE_PREFIX
watermarkstat.print_all_stat(table_prefix, args.type)
sys.exit(0)

Expand Down
13 changes: 13 additions & 0 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,13 @@ def wm_q_multi():
command = 'watermarkstat -t q_shared_multi'
run_command(command)

# 'all' subcommand ("show queue watermarks all")
@watermark.command('all')
def wm_q_all():
"""Show user WM for all queues"""
command = 'watermarkstat -t q_shared_all'
run_command(command)

#
# 'persistent-watermarks' subgroup ("show queue persistent-watermarks ...")
#
Expand All @@ -579,6 +586,12 @@ def pwm_q_multi():
command = 'watermarkstat -p -t q_shared_multi'
run_command(command)

# 'all' subcommand ("show queue persistent-watermarks all")
@persistent_watermark.command('all')
def pwm_q_all():
"""Show persistent WM for all queues"""
command = 'watermarkstat -p -t q_shared_all'
run_command(command)

#
# 'priority-group' group ("show priority-group ...")
Expand Down
Loading

0 comments on commit 1f1696a

Please sign in to comment.