From e55403ac8367f384753ef2a418ee88dc0e5a767e Mon Sep 17 00:00:00 2001 From: Vadym Hlushko <62022266+vadymhlushko-mlnx@users.noreply.github.com> Date: Thu, 22 Apr 2021 10:00:36 +0300 Subject: [PATCH] [DPB][YANG] extended yang-model - added 'buffer_model' field, added test cases (#6464) - Why I did it The fix for the issue [DPB][YANG] sonic-device_metadata.yang is not aligned with newest changes in CONFIG_DB - How I did it CONFIG_DB was extended with the field buffer_model - added representation of this field inside the sonic-device_metadata.yang - How to verify it Run the command config interface breakout Signed-off-by: Vadym Hlushko --- .../tests/files/sample_config_db.json | 3 ++- .../tests/device_metadata.json | 10 +++++++ .../tests_config/device_metadata.json | 27 +++++++++++++++++++ .../yang-models/sonic-device_metadata.yang | 12 +++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index e4bcb564029e..699ce6ad10b3 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -202,7 +202,8 @@ "mac": "00:11:22:33:dd:5a", "hostname": "asw.dc", "bgp_asn": "64850", - "hwsku": "Stone" + "hwsku": "Stone", + "buffer_model": "dynamic" } }, "VLAN": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json index 1e560257ad71..9b58c2fde139 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json @@ -32,5 +32,15 @@ "DEVICE_METADATA_TYPE_INCORRECT_PATTERN": { "desc": "DEVICE_METADATA_TYPE_INCORRECT_PATTERN pattern failure.", "eStrKey" : "Pattern" + }, + "DEVICE_METADATA_CORRECT_BUFFER_MODEL_PATTERN": { + "desc": "DEVICE_METADATA correct value for BUFFER_MODEL field" + }, + "DEVICE_METADATA_CORRECT_BUFFER_MODEL_PATTERN2": { + "desc": "DEVICE_METADATA correct value for BUFFER_MODEL field" + }, + "DEVICE_METADATA_INCORRECT_BUFFER_MODEL_PATTERN": { + "desc": "DEVICE_METADATA wrong value for BUFFER_MODEL field.", + "eStr": ["pattern", "does not satisfy"] } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json index 7a3bf81e1991..0f0bdc8506a7 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json @@ -90,5 +90,32 @@ } } } + }, + "DEVICE_METADATA_CORRECT_BUFFER_MODEL_PATTERN": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "buffer_model": "dynamic" + } + } + } + }, + "DEVICE_METADATA_CORRECT_BUFFER_MODEL_PATTERN2": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "buffer_model": "traditional" + } + } + } + }, + "DEVICE_METADATA_INCORRECT_BUFFER_MODEL_PATTERN": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "buffer_model": "incorrect_pattern" + } + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang index 054b436f2470..e563dc0d93cc 100644 --- a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang +++ b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang @@ -89,6 +89,18 @@ module sonic-device_metadata { pattern "ToRRouter|LeafRouter|SpineChassisFrontendRouter|ChassisBackendRouter|ASIC"; } } + + leaf buffer_model { + description "This leaf is added for dynamic buffer calculation. + The dynamic model represents the model in which the buffer configurations, + like the headroom sizes and buffer pool sizes, are dynamically calculated based + on the ports' speed, cable length, and MTU. This model is used by Mellanox so far. + The traditional model represents the model in which all the buffer configurations + are statically configured in CONFIG_DB tables. This is the default model used by all other vendors"; + type string { + pattern "dynamic|traditional"; + } + } } /* end of container localhost */ }