From 7afca09f0241b60bfc25d67b6c5877d400a70b32 Mon Sep 17 00:00:00 2001 From: Neetha John Date: Wed, 2 Sep 2020 16:06:48 -0700 Subject: [PATCH 1/4] Retrieve headroom pool WM counters Signed-off-by: Neetha John --- scripts/watermarkstat | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/watermarkstat b/scripts/watermarkstat index b818411608..1b5e8fdec2 100755 --- a/scripts/watermarkstat +++ b/scripts/watermarkstat @@ -169,6 +169,9 @@ class Watermarkstat(object): "header_prefix": "MC"}, "buffer_pool" : {"message": "Shared pool maximum occupancy:", "wm_name": "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES", + "header" : headerBufferPool}, + "headroom_pool" : {"message": "Headroom pool maximum occupancy:", + "wm_name": "SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES", "header" : headerBufferPool} } @@ -228,12 +231,15 @@ class Watermarkstat(object): def print_all_stat(self, table_prefix, key): table = [] type = self.watermark_types[key] - if key == 'buffer_pool': + if key in ['buffer_pool', 'headroom_pool']: self.header_list = type['header'] # Get stats for each buffer pool for buf_pool, bp_oid in natsorted(self.buffer_pool_name_to_oid_map.items()): - key = table_prefix + bp_oid - data = self.counters_db.get(self.counters_db.COUNTERS_DB, key, type["wm_name"]) + if key == 'headroom_pool' and 'ingress_lossless' not in buf_pool: + continue + + db_key = table_prefix + bp_oid + data = self.counters_db.get(self.counters_db.COUNTERS_DB, db_key, type["wm_name"]) if data is None: data = STATUS_NA table.append((buf_pool, data)) @@ -278,7 +284,7 @@ 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'], + choices=['pg_headroom', 'pg_shared', 'q_shared_uni', 'q_shared_multi', 'buffer_pool', 'headroom_pool'], help='The type of watermark') args = parser.parse_args() watermarkstat = Watermarkstat() From 9114e2e84e3954d6ad2d8ba97ffd62a5d15cfa55 Mon Sep 17 00:00:00 2001 From: Neetha John Date: Wed, 2 Sep 2020 16:07:28 -0700 Subject: [PATCH 2/4] Add show command for headroom pool WM Signed-off-by: Neetha John --- show/main.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/show/main.py b/show/main.py index e472292797..4cb9e0e16c 100755 --- a/show/main.py +++ b/show/main.py @@ -603,6 +603,27 @@ def pwm_buffer_pool(): run_command(command) +# +# 'headroom-pool' group ("show headroom-pool ...") +# + +@cli.group(name='headroom-pool', cls=clicommon.AliasedGroup) +def headroom_pool(): + """Show details of headroom pool""" + +@headroom_pool.command('watermark') +def wm_headroom_pool(): + """Show user WM for headroom pool""" + command = 'watermarkstat -t headroom_pool' + run_command(command) + +@headroom_pool.command('persistent-watermark') +def pwm_headroom_pool(): + """Show persistent WM for headroom pool""" + command = 'watermarkstat -p -t headroom_pool' + run_command(command) + + # # 'mac' command ("show mac ...") # From a6e7c96278aa18c7eaab3c6c75d7efbc9fe39c2a Mon Sep 17 00:00:00 2001 From: Neetha John Date: Wed, 16 Sep 2020 15:56:49 -0700 Subject: [PATCH 3/4] Add clear commands for headroom pool WM Signed-off-by: Neetha John --- clear/main.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/clear/main.py b/clear/main.py index 23cbeb7e7d..bebe052214 100755 --- a/clear/main.py +++ b/clear/main.py @@ -281,6 +281,30 @@ def clear_pwm_q_multi(): command = 'watermarkstat -c -p -t q_shared_multi' run_command(command) + +@cli.group(name='headroom-pool') +def headroom_pool(): + """Clear headroom pool WM""" + pass + +@headroom_pool.command('watermark') +def watermark(): + """Clear headroom pool user WM. One does not simply clear WM, root is required""" + if os.geteuid() != 0: + exit("Root privileges are required for this operation") + + command = 'watermarkstat -c -t headroom_pool' + run_command(command) + +@headroom_pool.command('persistent-watermark') +def persistent_watermark(): + """Clear headroom pool persistent WM. One does not simply clear WM, root is required""" + if os.geteuid() != 0: + exit("Root privileges are required for this operation") + + command = 'watermarkstat -c -p -t headroom_pool' + run_command(command) + # # 'arp' command #### # From 250673af6d8724f9ce9f4592560e118d047d21c7 Mon Sep 17 00:00:00 2001 From: Neetha John Date: Tue, 17 Nov 2020 12:10:37 -0800 Subject: [PATCH 4/4] Add tests for headroom pool wm Signed-off-by: Neetha John --- tests/mock_tables/counters_db.json | 6 ++++-- tests/watermarkstat_test.py | 6 ++++++ tests/wm_input/wm_test_vectors.py | 24 +++++++++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/tests/mock_tables/counters_db.json b/tests/mock_tables/counters_db.json index 96be3b5fc5..dfc344672b 100644 --- a/tests/mock_tables/counters_db.json +++ b/tests/mock_tables/counters_db.json @@ -990,7 +990,8 @@ "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "2000" }, "USER_WATERMARKS:oid:0x18000000000b66": { - "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "3000" + "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "3000", + "SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES": "432640" }, "PERSISTENT_WATERMARKS:oid:0x18000000000b64": { "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "2000" @@ -999,7 +1000,8 @@ "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "3000" }, "PERSISTENT_WATERMARKS:oid:0x18000000000b66": { - "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "4000" + "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "4000", + "SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES": "863616" }, "CRM:ACL_STATS:INGRESS:VLAN":{ "crm_stats_acl_table_used":"0", diff --git a/tests/watermarkstat_test.py b/tests/watermarkstat_test.py index 21ec3ad148..0cc9dd624b 100644 --- a/tests/watermarkstat_test.py +++ b/tests/watermarkstat_test.py @@ -36,6 +36,9 @@ def test_show_queue_multicast_wm(self): def test_show_buffer_pool_wm(self): self.executor(testData['show_buffer_pool_wm']) + def test_show_headroom_pool_wm(self): + self.executor(testData['show_hdrm_pool_wm']) + def test_show_pg_shared_peristent_wm(self): self.executor(testData['show_pg_pwm_shared']) @@ -51,6 +54,9 @@ def test_show_queue_multicast_persistent_wm(self): def test_show_buffer_pool_persistent_wm(self): self.executor(testData['show_buffer_pool_pwm']) + def test_show_headroom_pool_persistent_wm(self): + self.executor(testData['show_hdrm_pool_pwm']) + def executor(self, testcase): runner = CliRunner() diff --git a/tests/wm_input/wm_test_vectors.py b/tests/wm_input/wm_test_vectors.py index 98ccb2eaa3..a5314b1fe6 100644 --- a/tests/wm_input/wm_test_vectors.py +++ b/tests/wm_input/wm_test_vectors.py @@ -79,6 +79,20 @@ ingress_lossless_pool 4000 """ +show_hdrm_pool_wm_output="""\ +Headroom pool maximum occupancy: + Pool Bytes +--------------------- ------- +ingress_lossless_pool 432640 +""" + +show_hdrm_pool_persistent_wm_output="""\ +Headroom pool maximum occupancy: + Pool Bytes +--------------------- ------- +ingress_lossless_pool 863616 +""" + testData = { 'show_pg_wm_shared' : [ {'cmd' : ['priority-group', 'watermark', 'shared'], 'rc_output': show_pg_wm_shared_output @@ -119,5 +133,13 @@ 'show_buffer_pool_pwm' : [ {'cmd' : ['buffer_pool', 'persistent-watermark'], 'rc_output': show_buffer_pool_persistent_wm_output } - ] + ], + 'show_hdrm_pool_wm' : [ {'cmd' : ['headroom-pool', 'watermark'], + 'rc_output': show_hdrm_pool_wm_output + } + ], + 'show_hdrm_pool_pwm' : [ {'cmd' : ['headroom-pool', 'persistent-watermark'], + 'rc_output': show_hdrm_pool_persistent_wm_output + } + ] }