From 754fca7f3fe998b58dd4281e6653e8af7f5de1ed Mon Sep 17 00:00:00 2001 From: Ze Gan Date: Fri, 13 Sep 2024 20:27:40 +0800 Subject: [PATCH] Refactor STREAM_TELEMETRY_GROUP Signed-off-by: Ze Gan --- .../sonic-stream-telemetry.yang | 53 ++++++--- doc/stream-telemetry/stream-telemetry-hld.md | 14 +-- doc/stream-telemetry/stream_telemetry.json | 105 ++++++++++++++++++ 3 files changed, 151 insertions(+), 21 deletions(-) create mode 100644 doc/stream-telemetry/stream_telemetry.json diff --git a/doc/stream-telemetry/sonic-stream-telemetry.yang b/doc/stream-telemetry/sonic-stream-telemetry.yang index 39f4216e6fd..52134bb0906 100644 --- a/doc/stream-telemetry/sonic-stream-telemetry.yang +++ b/doc/stream-telemetry/sonic-stream-telemetry.yang @@ -5,6 +5,22 @@ module sonic-stream-telemetry { prefix sonic-stream-telemetry; + import sonic-port { + prefix port; + } + + import sonic-buffer-pool { + prefix bpl; + } + + import sonic-buffer-pg { + prefix bpg; + } + + import sonic-buffer-queue { + prefix bql; + } + container sonic-stream-telemetry { container STREAM_TELEMETRY_PROFILE { description "STREAM_TELEMETRY_PROFILE part of config_db.json"; @@ -19,19 +35,23 @@ module sonic-stream-telemetry { } leaf stream_state { + mandatory true; type string { pattern "enabled|disabled"; } } leaf poll_interval { + mandatory true; description "The interval to poll counter, unit milliseconds."; type uint32; } leaf chunk_size { - type uint32; - default 0; + type uint32 { + range "1..4294967295"; + } + default 1; } leaf cache_size { @@ -54,25 +74,30 @@ module sonic-stream-telemetry { // The table name of config db leaf group_name { - type string { - pattern "PORT|QUEUE|BUFFER_PG|BUFFER_POOL|BUFFER_QUEUE"; + type enumeration { + enum PORT; + enum BUFFER_POOL; + enum BUFFER_PG; + enum BUFFER_QUEUE; } } leaf-list object_names { - type string { - pattern "\w+(\|\d+(-\d+)?)?"; - error-message "Invalid object names"; - } - description "The object names to be monitored"; + type string; + must "( ../group_name = 'PORT' and current() = /port:sonic-port/port:PORT/port:PORT_LIST/port:name )" + + " or ( ../group_name = 'BUFFER_POOL' and current() = /bpl:sonic-buffer-pool/bpl:BUFFER_POOL/bpl:BUFFER_POOL_LIST/bpl:name )" + + " or ( ../group_name = 'BUFFER_PG' and substring-before(current(), '|') = /bpg:sonic-buffer-pg/bpg:BUFFER_PG/bpg:BUFFER_PG_LIST/bpg:port and re-match(substring-after(current(), '|'), '[0-9]+') )" + + " or ( ../group_name = 'BUFFER_QUEUE' and substring-before(current(), '|') = /bql:sonic-buffer-queue/bql:BUFFER_QUEUE/bql:BUFFER_QUEUE_LIST/bql:port and re-match(substring-after(current(), '|'), '[0-9]+') )"; } + must "count(object_names) > 0"; + leaf-list object_counters { - string { - pattern "SAI_[A-Z]+_STAT_([A-Z]+_)*[A-Z]+"; - error-message "Invalid STATS ID for SAI object"; - } - description "The SAI STATS ID"; + type string; + must "( ../group_name = 'PORT' and re-match(current(), 'IF_IN_OCTETS|IF_IN_UCAST_PKTS|IF_IN_DISCARDS|IF_IN_ERRORS|IN_CURR_OCCUPANCY_BYTES|IF_OUT_OCTETS|IF_OUT_DISCARDS|IF_OUT_ERRORS|IF_OUT_UCAST_PKTS|OUT_CURR_OCCUPANCY_BYTES') )" + + " or ( ../group_name = 'BUFFER_POOL' and re-match(current(), 'PACKETS|BYTES|DROPPED_PACKETS|CURR_OCCUPANCY_BYTES|WATERMARK_BYTES|WRED_ECN_MARKED_PACKETS') )" + + " or ( ../group_name = 'BUFFER_PG' and re-match(current(), 'PACKETS|BYTES|CURR_OCCUPANCY_BYTES|WATERMARK_BYTES|XOFF_ROOM_CURR_OCCUPANCY_BYTES|XOFF_ROOM_WATERMARK_BYTES|DROPPED_PACKETS') )" + + " or ( ../group_name = 'BUFFER_QUEUE' and re-match(current(), 'DROPPED_PACKETS|CURR_OCCUPANCY_BYTES|WATERMARK_BYTES|CURR_OCCUPANCY_BYTES|XOFF_ROOM_WATERMARK_BYTES') )"; } } diff --git a/doc/stream-telemetry/stream-telemetry-hld.md b/doc/stream-telemetry/stream-telemetry-hld.md index b580e1a8828..0926840ace9 100644 --- a/doc/stream-telemetry/stream-telemetry-hld.md +++ b/doc/stream-telemetry/stream-telemetry-hld.md @@ -1,6 +1,6 @@ # Stream telemetry high level design -## Table of Content ## +## Table of Content - [Revision](#revision) - [Scope](#scope) @@ -374,15 +374,15 @@ key = STREAM_TELEMETRY_GROUP:group_name:profile_name ; Multiple groups can be bound to a same stream telemetry profile. ; field = value object_names = A comma separated list of object name. - ; The syntax of object name is top_object_name|index_range. + ; The syntax of object name is top_object_name|index. ; The object_name is the object of the top level, like port, Ethernet0,Ethernet4. - ; The index range is the object in second level, like priority group. - ; An example is Ethernet0|0,Ethernet4|3-4. -object_counters = list of stats of object - ; The stats name in the group. like SAI_PORT_STAT_IF_IN_OCTETS,SAI_PORT_STAT_IF_IN_UCAST_PKTS. - ; comma separated list. + ; The index indicates the object in second level, like priority group. + ; An example is Ethernet0|0,Ethernet4|3. +object_counters = list of stats of object; comma separated list ``` +For the schema of `STREAM_TELEMETRY_GROUP`, please refer to its [YANG model](sonic-stream-telemetry.yang). + ### StateDb #### STREAM_TELEMETRY_SESSION diff --git a/doc/stream-telemetry/stream_telemetry.json b/doc/stream-telemetry/stream_telemetry.json new file mode 100644 index 00000000000..9c704d50116 --- /dev/null +++ b/doc/stream-telemetry/stream_telemetry.json @@ -0,0 +1,105 @@ +{ + "STREAM_TELEMETRY_VALID_CASE": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0", + "speed": 25000 + }, + { + "name": "Ethernet4", + "lanes": "4", + "speed": 25000 + } + ] + } + }, + "sonic-buffer-pool:sonic-buffer-pool": { + "sonic-buffer-pool:BUFFER_POOL": { + "BUFFER_POOL_LIST": [ + { + "name": "egress_lossless_pool", + "mode": "static", + "size": "300", + "type": "ingress" + } + ] + } + }, + "sonic-buffer-profile:sonic-buffer-profile": { + "sonic-buffer-profile:BUFFER_PROFILE": { + "BUFFER_PROFILE_LIST": [ + { + "name": "lossless_buffer_profile", + "size": "1518", + "dynamic_th": "2", + "pool": "egress_lossless_pool" + } + ] + } + }, + "sonic-buffer-pg:sonic-buffer-pg": { + "sonic-buffer-pg:BUFFER_PG": { + "BUFFER_PG_LIST": [ + { + "port": "Ethernet4", + "pg_num": "3", + "profile": "lossless_buffer_profile" + } + ] + } + }, + "sonic-buffer-queue:sonic-buffer-queue": { + "sonic-buffer-queue:BUFFER_QUEUE": { + "BUFFER_QUEUE_LIST": [ + { + "port": "Ethernet0", + "qindex": "15", + "profile": "lossless_buffer_profile" + } + ] + } + }, + "sonic-stream-telemetry:sonic-stream-telemetry": { + "sonic-stream-telemetry:STREAM_TELEMETRY_PROFILE": { + "STREAM_TELEMETRY_PROFILE_LIST": [ + { + "name": "high_frequency_counters", + "stream_state": "enabled", + "poll_interval": 100 + } + ] + }, + "sonic-stream-telemetry:STREAM_TELEMETRY_GROUP": { + "STREAM_TELEMETRY_GROUP_LIST": [ + { + "profile_name": "high_frequency_counters", + "group_name": "PORT", + "object_names": ["Ethernet0", "Ethernet4"], + "object_counters": ["IF_IN_OCTETS", "OUT_CURR_OCCUPANCY_BYTES"] + }, + { + "profile_name": "high_frequency_counters", + "group_name": "BUFFER_POOL", + "object_names": ["egress_lossless_pool"], + "object_counters": ["PACKETS", "WRED_ECN_MARKED_PACKETS"] + }, + { + "profile_name": "high_frequency_counters", + "group_name": "BUFFER_PG", + "object_names": ["Ethernet4|0", "Ethernet4|3"], + "object_counters": ["CURR_OCCUPANCY_BYTES", "XOFF_ROOM_WATERMARK_BYTES"] + }, + { + "profile_name": "high_frequency_counters", + "group_name": "BUFFER_QUEUE", + "object_names": ["Ethernet0|15", "Ethernet0|3"], + "object_counters": ["WATERMARK_BYTES", "XOFF_ROOM_WATERMARK_BYTES"] + } + ] + } + } + } + }