diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 3dfdde1cef89..4d61be960c3b 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -98,6 +98,7 @@ def run(self): './yang-models/sonic-cable-length.yang', './yang-models/sonic-copp.yang', './yang-models/sonic-crm.yang', + './yang-models/sonic-default-lossless-buffer-parameter.yang', './yang-models/sonic-device_metadata.yang', './yang-models/sonic-device_neighbor.yang', './yang-models/sonic-dhcpv6-relay.yang', @@ -107,6 +108,7 @@ def run(self): './yang-models/sonic-interface.yang', './yang-models/sonic-kdump.yang', './yang-models/sonic-loopback-interface.yang', + './yang-models/sonic-lossless-traffic-pattern.yang', './yang-models/sonic-mgmt_interface.yang', './yang-models/sonic-mgmt_port.yang', './yang-models/sonic-mgmt_vrf.yang', 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 720c3c652325..340e36cadbec 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1873,6 +1873,20 @@ "LAG" ] } + }, + + "LOSSLESS_TRAFFIC_PATTERN": { + "AZURE": { + "mtu": "1024", + "small_packet_percentage": "100" + } + }, + + "DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "AZURE": { + "default_dynamic_th": "0", + "over_subscribe_ratio": "0" + } } }, "SAMPLE_CONFIG_DB_UNKNOWN": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/default_lossless_buffer_parameter.json b/src/sonic-yang-models/tests/yang_model_tests/tests/default_lossless_buffer_parameter.json new file mode 100644 index 000000000000..058d0f021a99 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/default_lossless_buffer_parameter.json @@ -0,0 +1,33 @@ +{ + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_TEST": { + "desc": "Configure DEFAULT_LOSSLESS_BUFFER_PARAMETER table." + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_INVALID_NAME_TEST": { + "desc": "Configure DEFAULT_LOSSLESS_BUFFER_PARAMETER table with invalid character.", + "eStr": "Invalid default lossless buffer parameter list name." + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_TOO_LONG_NAME_TEST": { + "desc": "Configure DEFAULT_LOSSLESS_BUFFER_PARAMETER table with too long name.", + "eStr": "Invalid length for the default lossless buffer parameter list name." + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_TOO_SMALL_DYNAMIC_TH_TEST": { + "desc": "Configure DEFAULT_LOSSLESS_BUFFER_PARAMETER table with a dynamic_th exceeding the lowerbound.", + "eStr": "Invalid default dynamic_th which should be a number in the range [-8, 7]." + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_TOO_LARGE_DYNAMIC_TH_TEST": { + "desc": "Configure DEFAULT_LOSSLESS_BUFFER_PARAMETER table with a dynamic_th exceeding the upperbound.", + "eStr": "Invalid default dynamic_th which should be a number in the range [-8, 7]." + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_INVALID_FORMAT_DYNAMIC_TH_TEST": { + "desc": "Configure DEFAULT_LOSSLESS_BUFFER_PARAMETER table with an invalid dynamic_th", + "eStr": "Invalid" + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_LACK_DYNAMIC_TH_TEST": { + "desc": "Configure DEFAULT_LOSSLESS_BUFFER_PARAMETER table without dynamic_th", + "eStrKey" : "Mandatory" + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_INVALID_FORMAT_OVER_SUBSCRIBE_RATIO_TEST": { + "desc": "Configure DEFAULT_LOSSLESS_BUFFER_PARAMETER table with an invalid over subscribe ratio.", + "eStr": "Invalid" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/lossless_traffic_pattern.json b/src/sonic-yang-models/tests/yang_model_tests/tests/lossless_traffic_pattern.json new file mode 100644 index 000000000000..6f7fc517d361 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/lossless_traffic_pattern.json @@ -0,0 +1,41 @@ +{ + "LOSSLESS_TRAFFIC_PATTERN_TEST": { + "desc": "Configure LOSSLESS_TRAFFIC_PATTERN table." + }, + "LOSSLESS_TRAFFIC_PATTERN_INVALID_NAME_TEST": { + "desc": "Configure LOSSLESS_TRAFFIC_PATTERN table with invalid character.", + "eStr": "Invalid lossless traffic pattern list name." + }, + "LOSSLESS_TRAFFIC_PATTERN_TOO_LONG_NAME_TEST": { + "desc": "Configure LOSSLESS_TRAFFIC_PATTERN table with too long name.", + "eStr": "Invalid length for the lossless traffic pattern list name." + }, + "LOSSLESS_TRAFFIC_PATTERN_TOO_SMALL_MTU_TEST": { + "desc": "Configure LOSSLESS_TRAFFIC_PATTERN table with an MTU exceeding the lowerbound.", + "eStr": "Invaild MTU which should be in [1, 9216]." + }, + "LOSSLESS_TRAFFIC_PATTERN_TOO_LARGE_MTU_TEST": { + "desc": "Configure LOSSLESS_TRAFFIC_PATTERN table with an MTU exceeding the upperbound.", + "eStr": "Invaild MTU which should be in [1, 9216]." + }, + "LOSSLESS_TRAFFIC_PATTERN_INVALID_FORMAT_MTU_TEST": { + "desc": "Configure LOSSLESS_TRAFFIC_PATTERN table with an invalid MTU", + "eStr": "Invalid" + }, + "LOSSLESS_TRAFFIC_PATTERN_LACK_MTU_TEST": { + "desc": "Configure LOSSLESS_TRAFFIC_PATTERN table without MTU", + "eStrKey": "Mandatory" + }, + "LOSSLESS_TRAFFIC_PATTERN_TOO_LARGE_SMALL_PACKET_PERCENTAGE_TEST": { + "desc": "Configure LOSSLESS_TRAFFIC_PATTERN table with a small packet percentage exceeding the upperbound.", + "eStr": "Invalid small packets percentage which should be in [0, 100]." + }, + "LOSSLESS_TRAFFIC_PATTERN_INVALID_FORMAT_SMALL_PACKET_PERCENTAGE_TEST": { + "desc": "Configure LOSSLESS_TRAFFIC_PATTERN table with an invalid small packet percentage", + "eStr": "Invalid" + }, + "LOSSLESS_TRAFFIC_PATTERN_LACK_SMALL_PACKET_PERCENTAGE_TEST": { + "desc": "Configure LOSSLESS_TRAFFIC_PATTERN table without small packet percentage", + "eStrKey": "Mandatory" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/default_lossless_buffer_parameter.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/default_lossless_buffer_parameter.json new file mode 100644 index 000000000000..2557950df4ce --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/default_lossless_buffer_parameter.json @@ -0,0 +1,105 @@ +{ + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_TEST": { + "sonic-default-lossless-buffer-parameter:sonic-default-lossless-buffer-parameter": { + "sonic-default-lossless-buffer-parameter:DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_LIST": [ + { + "name": "AZURE", + "default_dynamic_th": "0", + "over_subscribe_ratio": "0" + } + ] + } + } + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_INVALID_NAME_TEST": { + "sonic-default-lossless-buffer-parameter:sonic-default-lossless-buffer-parameter": { + "sonic-default-lossless-buffer-parameter:DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_LIST": [ + { + "name": "Invalid$", + "default_dynamic_th": "0", + "over_subscribe_ratio": "0" + } + ] + } + } + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_TOO_LONG_NAME_TEST": { + "sonic-default-lossless-buffer-parameter:sonic-default-lossless-buffer-parameter": { + "sonic-default-lossless-buffer-parameter:DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_LIST": [ + { + "name": "Long_name_which_exceeds_the_limit", + "default_dynamic_th": "0", + "over_subscribe_ratio": "0" + } + ] + } + } + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_TOO_SMALL_DYNAMIC_TH_TEST": { + "sonic-default-lossless-buffer-parameter:sonic-default-lossless-buffer-parameter": { + "sonic-default-lossless-buffer-parameter:DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_LIST": [ + { + "name": "AZURE", + "default_dynamic_th": "-9", + "over_subscribe_ratio": "0" + } + ] + } + } + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_TOO_LARGE_DYNAMIC_TH_TEST": { + "sonic-default-lossless-buffer-parameter:sonic-default-lossless-buffer-parameter": { + "sonic-default-lossless-buffer-parameter:DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_LIST": [ + { + "name": "AZURE", + "default_dynamic_th": "8", + "over_subscribe_ratio": "0" + } + ] + } + } + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_INVALID_FORMAT_DYNAMIC_TH_TEST": { + "sonic-default-lossless-buffer-parameter:sonic-default-lossless-buffer-parameter": { + "sonic-default-lossless-buffer-parameter:DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_LIST": [ + { + "name": "AZURE", + "default_dynamic_th": "NaN", + "over_subscribe_ratio": "0" + } + ] + } + } + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_LACK_DYNAMIC_TH_TEST": { + "sonic-default-lossless-buffer-parameter:sonic-default-lossless-buffer-parameter": { + "sonic-default-lossless-buffer-parameter:DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_LIST": [ + { + "name": "AZURE", + "over_subscribe_ratio": "0" + } + ] + } + } + }, + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_INVALID_FORMAT_OVER_SUBSCRIBE_RATIO_TEST": { + "sonic-default-lossless-buffer-parameter:sonic-default-lossless-buffer-parameter": { + "sonic-default-lossless-buffer-parameter:DEFAULT_LOSSLESS_BUFFER_PARAMETER": { + "DEFAULT_LOSSLESS_BUFFER_PARAMETER_LIST": [ + { + "name": "AZURE", + "default_dynamic_th": "0", + "over_subscribe_ratio": "NaN" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/lossless_traffic_pattern.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/lossless_traffic_pattern.json new file mode 100644 index 000000000000..9f4f347aa3a6 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/lossless_traffic_pattern.json @@ -0,0 +1,130 @@ +{ + "LOSSLESS_TRAFFIC_PATTERN_TEST": { + "sonic-lossless-traffic-pattern:sonic-lossless-traffic-pattern": { + "sonic-lossless-traffic-pattern:LOSSLESS_TRAFFIC_PATTERN": { + "LOSSLESS_TRAFFIC_PATTERN_LIST": [ + { + "name": "AZURE", + "mtu": "1024", + "small_packet_percentage": "100" + } + ] + } + } + }, + "LOSSLESS_TRAFFIC_PATTERN_INVALID_NAME_TEST": { + "sonic-lossless-traffic-pattern:sonic-lossless-traffic-pattern": { + "sonic-lossless-traffic-pattern:LOSSLESS_TRAFFIC_PATTERN": { + "LOSSLESS_TRAFFIC_PATTERN_LIST": [ + { + "name": "Invalid$", + "mtu": "1024", + "small_packet_percentage": "100" + } + ] + } + } + }, + "LOSSLESS_TRAFFIC_PATTERN_TOO_LONG_NAME_TEST": { + "sonic-lossless-traffic-pattern:sonic-lossless-traffic-pattern": { + "sonic-lossless-traffic-pattern:LOSSLESS_TRAFFIC_PATTERN": { + "LOSSLESS_TRAFFIC_PATTERN_LIST": [ + { + "name": "Long_name_which_exceeds_the_limit", + "mtu": "1024", + "small_packet_percentage": "100" + } + ] + } + } + }, + "LOSSLESS_TRAFFIC_PATTERN_TOO_SMALL_MTU_TEST": { + "sonic-lossless-traffic-pattern:sonic-lossless-traffic-pattern": { + "sonic-lossless-traffic-pattern:LOSSLESS_TRAFFIC_PATTERN": { + "LOSSLESS_TRAFFIC_PATTERN_LIST": [ + { + "name": "AZURE", + "mtu": "0", + "small_packet_percentage": "100" + } + ] + } + } + }, + "LOSSLESS_TRAFFIC_PATTERN_TOO_LARGE_MTU_TEST": { + "sonic-lossless-traffic-pattern:sonic-lossless-traffic-pattern": { + "sonic-lossless-traffic-pattern:LOSSLESS_TRAFFIC_PATTERN": { + "LOSSLESS_TRAFFIC_PATTERN_LIST": [ + { + "name": "AZURE", + "mtu": "9217", + "small_packet_percentage": "100" + } + ] + } + } + }, + "LOSSLESS_TRAFFIC_PATTERN_INVALID_FORMAT_MTU_TEST": { + "sonic-lossless-traffic-pattern:sonic-lossless-traffic-pattern": { + "sonic-lossless-traffic-pattern:LOSSLESS_TRAFFIC_PATTERN": { + "LOSSLESS_TRAFFIC_PATTERN_LIST": [ + { + "name": "AZURE", + "mtu": "NaN", + "small_packet_percentage": "100" + } + ] + } + } + }, + "LOSSLESS_TRAFFIC_PATTERN_LACK_MTU_TEST": { + "sonic-lossless-traffic-pattern:sonic-lossless-traffic-pattern": { + "sonic-lossless-traffic-pattern:LOSSLESS_TRAFFIC_PATTERN": { + "LOSSLESS_TRAFFIC_PATTERN_LIST": [ + { + "name": "AZURE", + "small_packet_percentage": "100" + } + ] + } + } + }, + "LOSSLESS_TRAFFIC_PATTERN_TOO_LARGE_SMALL_PACKET_PERCENTAGE_TEST": { + "sonic-lossless-traffic-pattern:sonic-lossless-traffic-pattern": { + "sonic-lossless-traffic-pattern:LOSSLESS_TRAFFIC_PATTERN": { + "LOSSLESS_TRAFFIC_PATTERN_LIST": [ + { + "name": "AZURE", + "mtu": "1024", + "small_packet_percentage": "101" + } + ] + } + } + }, + "LOSSLESS_TRAFFIC_PATTERN_INVALID_FORMAT_SMALL_PACKET_PERCENTAGE_TEST": { + "sonic-lossless-traffic-pattern:sonic-lossless-traffic-pattern": { + "sonic-lossless-traffic-pattern:LOSSLESS_TRAFFIC_PATTERN": { + "LOSSLESS_TRAFFIC_PATTERN_LIST": [ + { + "name": "AZURE", + "mtu": "1024", + "small_packet_percentage": "NaN" + } + ] + } + } + }, + "LOSSLESS_TRAFFIC_PATTERN_LACK_SMALL_PACKET_PERCENTAGE_TEST": { + "sonic-lossless-traffic-pattern:sonic-lossless-traffic-pattern": { + "sonic-lossless-traffic-pattern:LOSSLESS_TRAFFIC_PATTERN": { + "LOSSLESS_TRAFFIC_PATTERN_LIST": [ + { + "name": "AZURE", + "mtu": "1024" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-default-lossless-buffer-parameter.yang b/src/sonic-yang-models/yang-models/sonic-default-lossless-buffer-parameter.yang new file mode 100644 index 000000000000..6f98d9a922b7 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-default-lossless-buffer-parameter.yang @@ -0,0 +1,53 @@ +module sonic-default-lossless-buffer-parameter { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-default-lossless-buffer-parameter"; + + prefix default-lossless-buffer-parameter; + + description "DEFAULT_LOSSLESS_BUFFER_PARAMETER YANG module for SONiC OS"; + + revision 2022-05-31 { + description "Initial version"; + } + + container sonic-default-lossless-buffer-parameter { + container DEFAULT_LOSSLESS_BUFFER_PARAMETER { + + description "DEFAULT_LOSSLESS_BUFFER_PARAMETER part of config_db.json"; + + list DEFAULT_LOSSLESS_BUFFER_PARAMETER_LIST { + key "name"; + + leaf name { + type string { + pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})' { + error-message "Invalid default lossless buffer parameter list name."; + error-app-tag default-lossless-buffer-parameter-invalid-list-name; + } + length 1..32 { + error-message "Invalid length for the default lossless buffer parameter list name."; + error-app-tag default-lossless-buffer-parameter-invalid-list-name-length; + } + } + } + + leaf default_dynamic_th { + type int8 { + range -8..7 { + error-message "Invalid default dynamic_th which should be a number in the range [-8, 7]."; + } + } + mandatory true; + description "The default dynamic_th used in lossless buffer profile generated dynamically"; + } + + leaf over_subscribe_ratio { + type uint16; + description "The over subscribe ratio of shared headroom pool"; + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-lossless-traffic-pattern.yang b/src/sonic-yang-models/yang-models/sonic-lossless-traffic-pattern.yang new file mode 100644 index 000000000000..6901dc01e007 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-lossless-traffic-pattern.yang @@ -0,0 +1,58 @@ +module sonic-lossless-traffic-pattern { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-lossless-traffic-pattern"; + + prefix lossless-traffic-pattern; + + description "LOSSLESS_TRAFFIC_PATTERN YANG module for SONiC OS"; + + revision 2022-05-31 { + description "Initial version"; + } + + container sonic-lossless-traffic-pattern { + container LOSSLESS_TRAFFIC_PATTERN { + + description "LOSSLESS_TRAFFIC_PATTERN part of config_db.json"; + + list LOSSLESS_TRAFFIC_PATTERN_LIST { + key "name"; + + leaf name { + type string { + pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})' { + error-message "Invalid lossless traffic pattern list name."; + error-app-tag lossless-traffic-pattern-invalid-list-name; + } + length 1..32 { + error-message "Invalid length for the lossless traffic pattern list name."; + error-app-tag lossless-traffic-pattern-invalid-list-name-length; + } + } + } + + leaf mtu { + type uint16 { + range 1..9216 { + error-message "Invaild MTU which should be in [1, 9216]."; + } + } + mandatory true; + description "The maximum packet size of a lossless packet"; + } + + leaf small_packet_percentage { + type uint8 { + range 0..100 { + error-message "Invalid small packets percentage which should be in [0, 100]."; + } + } + mandatory true; + description "The percentage of small packets which is used to calculate the headroom size"; + } + } + } + } +}