From 0bce0a7e6db9b2d492ab34641c3a43fa1f6285e6 Mon Sep 17 00:00:00 2001 From: AmitKaushik7 <52193450+AmitKaushik7@users.noreply.github.com> Date: Thu, 31 Mar 2022 22:52:03 +0530 Subject: [PATCH] =?UTF-8?q?Allow=20NULL=20Buffer=20Profile=20in=20buffer?= =?UTF-8?q?=20pg/queue=20yang=20files=20for=20Dynamic=20B=E2=80=A6=20(#103?= =?UTF-8?q?53)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why I did it To address #10342 (Yang validation fails when Buffer profiles are configured with "NULL" values) --- .../yang_model_tests/tests/buffer_pg.json | 3 ++ .../tests_config/buffer_pg.json | 52 +++++++++++++++++++ .../yang-models/sonic-buffer-pg.yang | 13 +++-- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/buffer_pg.json b/src/sonic-yang-models/tests/yang_model_tests/tests/buffer_pg.json index f92a75365c..e6e4e59a8f 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/buffer_pg.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/buffer_pg.json @@ -10,6 +10,9 @@ "desc": "BUFFER_PG_WRONG_PG_VALUE pattern failure", "eStr": "Invalid Buffer PG number" }, + "BUFFER_PG_NULL_PROFILE_VALUE": { + "desc": "BUFFER_PG_NULL_PROFILE_VALUE no failure" + }, "BUFFER_PG_WRONG_PORT_VALUE": { "desc": "BUFFER_PG_WRONG_PORT_VALUE pattern failure", "eStr": "wrong" diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/buffer_pg.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/buffer_pg.json index ec3ea73bf7..cd0a244a0e 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/buffer_pg.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/buffer_pg.json @@ -52,6 +52,58 @@ } } }, + "BUFFER_PG_NULL_PROFILE_VALUE": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet4", + "tpid": "0x8100", + "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": "300", + "pool": "egress_lossless_pool" + } + ] + } + }, + "sonic-buffer-pg:sonic-buffer-pg": { + "sonic-buffer-pg:BUFFER_PG": { + "BUFFER_PG_LIST": [ + { + "port": "Ethernet4", + "pg_num": "3", + "profile": "NULL" + } + ] + } + } + }, "BUFFER_PG_WRONG_PROFILE_VALUE": { "sonic-port:sonic-port": { "sonic-port:PORT": { diff --git a/src/sonic-yang-models/yang-models/sonic-buffer-pg.yang b/src/sonic-yang-models/yang-models/sonic-buffer-pg.yang index efe6e34ad0..60d06bf6ef 100644 --- a/src/sonic-yang-models/yang-models/sonic-buffer-pg.yang +++ b/src/sonic-yang-models/yang-models/sonic-buffer-pg.yang @@ -2,9 +2,7 @@ module sonic-buffer-pg { namespace "http://github.com/Azure/sonic-buffer-pg"; prefix bpg; - import sonic-extension { - prefix sonic-ext; - } + yang-version 1.1; import sonic-port { prefix prt; @@ -54,8 +52,13 @@ module sonic-buffer-pg { leaf profile { default 0; - type leafref { - path "/bpf:sonic-buffer-profile/bpf:BUFFER_PROFILE/bpf:BUFFER_PROFILE_LIST/bpf:name"; + type union { + type leafref { + path "/bpf:sonic-buffer-profile/bpf:BUFFER_PROFILE/bpf:BUFFER_PROFILE_LIST/bpf:name"; + } + type string { + pattern "NULL"; + } } description "Buffer Profile associated with Priority Group number for a port"; }