From a99d78dedb838644d13150f5946a962a80ebacab Mon Sep 17 00:00:00 2001 From: Ashok Daparthi-Dell Date: Mon, 18 Oct 2021 10:01:08 -0700 Subject: [PATCH] [Yang model] SONiC QOS Scheduler, WRED, Queue Yangs (#7281) --- src/sonic-yang-models/setup.py | 3 + .../tests/files/sample_config_db.json | 51 +- .../tests/yang_model_tests/tests/qos.json | 85 ++++ .../yang_model_tests/tests_config/qos.json | 477 ++++++++++++++++++ .../yang-models/sonic-queue.yang | 88 ++++ .../yang-models/sonic-scheduler.yang | 148 ++++++ .../yang-models/sonic-wred-profile.yang | 177 +++++++ 7 files changed, 1028 insertions(+), 1 deletion(-) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/qos.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/qos.json create mode 100644 src/sonic-yang-models/yang-models/sonic-queue.yang create mode 100644 src/sonic-yang-models/yang-models/sonic-scheduler.yang create mode 100644 src/sonic-yang-models/yang-models/sonic-wred-profile.yang diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 51c190e495..0ffc2dfd3a 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -76,6 +76,9 @@ setup( './yang-models/sonic-vrf.yang', './yang-models/sonic-warm-restart.yang', './yang-models/sonic-lldp.yang', + './yang-models/sonic-scheduler.yang', + './yang-models/sonic-wred-profile.yang', + './yang-models/sonic-queue.yang', './yang-models/sonic_yang_tree']), ], zip_safe=False, 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 bd7aff24b5..a53c58eae7 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1138,6 +1138,56 @@ "high_mem_alert": "disabled", "state": "enabled" } + }, + + "SCHEDULER": { + "TEST@0": { + "cbs": "256", + "cir": "1250000", + "meter_type": "bytes", + "pbs": "1024", + "pir": "25000000", + "type": "DWRR", + "weight": "20" + }, + + "TEST@1": { + "cbs": "1024", + "cir": "1280000", + "meter_type": "bytes", + "pbs": "2048", + "pir": "2560000", + "type": "STRICT" + } + }, + + "WRED_PROFILE": { + "Wred1": { + "ecn": "ecn_all", + "green_drop_probability": "50", + "green_max_threshold": "2048000", + "green_min_threshold": "1024000", + "wred_green_enable": "true", + "yellow_drop_probability": "50", + "yellow_max_threshold": "2048000", + "yellow_min_threshold": "1024000", + "wred_yellow_enable": "true", + "red_drop_probability": "50", + "red_max_threshold": "2048000", + "red_min_threshold": "1024000", + "wred_red_enable": "true" + } + }, + + "QUEUE": { + "Ethernet0|0": { + "scheduler": "TEST@0", + "wred_profile": "Wred1" + }, + "Ethernet0|1": { + "scheduler": "TEST@1", + "wred_profile": "Wred1" + } } }, @@ -1146,5 +1196,4 @@ "Error": "This Table is for testing, This Table does not have YANG models." } } - } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/qos.json b/src/sonic-yang-models/tests/yang_model_tests/tests/qos.json new file mode 100644 index 0000000000..96b7b4b8d9 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/qos.json @@ -0,0 +1,85 @@ +{ + "SCHEDULER_VALID": { + "desc": "Configure SCHEDULER table." + }, + + "SCHEDULER_UNDEFINED_TYPE": { + "desc": "Configure undefined type in SCHEDULER table.", + "eStrKey" : "InvalidValue", + "eStr": ["type"] + }, + + "SCHEDULER_INVALID_WEIGHT": { + "desc": "Configure outof range weight in SCHEDULER table.", + "eStrKey" : "Pattern" + }, + + "SCHEDULER_INVALID_METER_TYPE": { + "desc": "Configure unsuported meter type in SCHEDULER table.", + "eStrKey": "InvalidValue", + "eStr": ["meter_type"] + }, + + "SCHEDULER_CBS_NO_CIR": { + "desc": "Configure CBS without CIR.", + "eStr": ["cbs can't be configured without cir"] + }, + + "SCHEDULER_PIR_NO_CIR": { + "desc": "Configure PIR without CIR.", + "eStr": ["pir can't be configured without cir"] + }, + + "SCHEDULER_PIR_VS_CIR": { + "desc": "Configure PIR vs CIR.", + "eStr": ["pir must be greater than or equal to cir"] + }, + + "WRED_PROFILE_EMPTY": { + "desc": "Configure Empty WRED profile." + }, + + "WRED_PROFILE_VALID": { + "desc": "Configure WRED profile." + }, + + "WRED_PROFILE_INVALID_DROP_PROBABILITY": { + "desc": "Configure invalid drop probability in WRED profile.", + "eStrKey" : "Pattern" + }, + + "WRED_PROFILE_INVALID_GREEN_THRESHOLD": { + "desc": "Configure green maximum threshold less than min threshold in WRED profile.", + "eStr": ["Green max threshold must be greater than or equal to min threshold"] + }, + + "WRED_PROFILE_INVALID_YELLOW_THRESHOLD": { + "desc": "Configure yellow maximum threshold less than min threshold in WRED profile.", + "eStr": ["Yellow max threshold must be greater than or equal to min threshold"] + }, + + "WRED_PROFILE_INVALID_RED_THRESHOLD": { + "desc": "Configure red maximum threshold less than min threshold in WRED profile.", + "eStr": ["Red max threshold must be greater than or equal to min threshold"] + }, + + + "QUEUE_VALID": { + "desc": "Attach scheduler and wred profiles to QUEUE." + }, + + "QUEUE_PORT_NOT_EXIST": { + "desc": "Referring non-existing PORT table.", + "eStrKey": "InvalidValue" + }, + + "QUEUE_SCHEDULER_NOT_EXIST": { + "desc": "Referring non-existing SCHEDULER table.", + "eStrKey" : "LeafRef" + }, + + "QUEUE_WRED_NOT_EXIST": { + "desc": "Referring non-existing WRED table.", + "eStrKey" : "LeafRef" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/qos.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/qos.json new file mode 100644 index 0000000000..481990b4d6 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/qos.json @@ -0,0 +1,477 @@ +{ + "SCHEDULER_VALID": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cbs": 256, + "cir": 1250000, + "meter_type": "bytes", + "pbs": 1024, + "pir": 25000000, + "type": "DWRR", + "weight": 10 + }, + { + "name":"Test@1", + "cbs": 1024, + "cir": 1280000, + "meter_type": "bytes", + "pbs": 2048, + "pir": 2560000, + "type": "STRICT", + "priority": 0 + }, + { + "name":"Test@2", + "cbs": 256, + "cir": 1250000, + "meter_type": "bytes", + "pbs": 1024, + "pir": 25000000, + "type": "WRR", + "weight": 20 + } + ] + } + } + }, + + "SCHEDULER_UNDEFINED_TYPE": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "type": "invalid" + } + ] + } + } + }, + + "SCHEDULER_INVALID_WEIGHT": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "weight": 120 + } + ] + } + } + }, + + "SCHEDULER_INVALID_METER_TYPE": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "meter_type": "invalid" + } + ] + } + } + }, + + "SCHEDULER_CBS_NO_CIR": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cbs": 1024 + } + ] + } + } + }, + + "SCHEDULER_PIR_NO_CIR": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "pir": 1024 + } + ] + } + } + }, + + "SCHEDULER_PIR_VS_CIR": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cir": 2048, + "pir": 1024 + } + ] + } + } + }, + + + "WRED_PROFILE_EMPTY": { + "sonic-wred-profile:sonic-wred-profile":{ + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred1" + } + ] + } + } + }, + + "WRED_PROFILE_VALID": { + "sonic-wred-profile:sonic-wred-profile":{ + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred2", + "yellow_min_threshold": 2048, + "green_min_threshold": 4096, + "red_min_threshold": 1024, + "yellow_max_threshold": 4096, + "green_max_threshold": 8192, + "red_max_threshold": 2048, + "ecn": "ecn_none", + "wred_green_enable": true, + "wred_yellow_enable": true, + "wred_red_enable": true, + "yellow_drop_probability": 50, + "green_drop_probability": 25, + "red_drop_probability": 100 + }, + { + "name":"Wred3", + "yellow_min_threshold": 2048, + "green_min_threshold": 4096, + "red_min_threshold": 1024, + "yellow_max_threshold": 4096, + "green_max_threshold": 8192, + "red_max_threshold": 2048, + "ecn": "ecn_all", + "wred_green_enable": true, + "wred_yellow_enable": true, + "wred_red_enable": true, + "yellow_drop_probability": 50, + "green_drop_probability": 25, + "red_drop_probability": 100 + }, + { + "name":"Wred4", + "green_min_threshold": 4096, + "green_max_threshold": 8192, + "ecn": "ecn_all", + "wred_green_enable": true + } + ] + } + } + }, + + "WRED_PROFILE_INVALID_DROP_PROBABILITY": { + "sonic-wred-profile:sonic-wred-profile": { + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred4", + "red_min_threshold": 1024, + "red_max_threshold": 2048, + "wred_red_enable": true, + "red_drop_probability": 125, + "green_drop_probability": 25, + "yellow_drop_probability": 25, + "ecn": "ecn_all" + } + ] + } + } + }, + + "WRED_PROFILE_INVALID_GREEN_THRESHOLD": { + "sonic-wred-profile:sonic-wred-profile": { + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred4", + "green_min_threshold": 4096, + "green_max_threshold": 2048, + "wred_green_enable": true, + "green_drop_probability": 25, + "ecn": "ecn_all" + } + ] + } + } + }, + + "WRED_PROFILE_INVALID_YELLOW_THRESHOLD": { + "sonic-wred-profile:sonic-wred-profile": { + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred4", + "yellow_min_threshold": 4096, + "yellow_max_threshold": 2048, + "wred_yellow_enable": true, + "yellow_drop_probability": 25, + "ecn": "ecn_all" + } + ] + } + } + }, + + "WRED_PROFILE_INVALID_RED_THRESHOLD": { + "sonic-wred-profile:sonic-wred-profile": { + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred4", + "red_min_threshold": 4096, + "red_max_threshold": 2048, + "wred_red_enable": true, + "red_drop_probability": 25, + "ecn": "ecn_all" + } + ] + } + } + }, + + + "QUEUE_VALID": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cbs": 256, + "cir": 1250000, + "meter_type": "bytes", + "pbs": 1024, + "pir": 25000000, + "type": "DWRR", + "weight": 10 + } + ] + } + }, + "sonic-wred-profile:sonic-wred-profile":{ + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred1", + "yellow_min_threshold": 2048, + "green_min_threshold": 4096, + "red_min_threshold": 1024, + "yellow_max_threshold": 4096, + "green_max_threshold": 8192, + "red_max_threshold": 2048, + "ecn": "ecn_none", + "wred_green_enable": true, + "wred_yellow_enable": true, + "wred_red_enable": true, + "yellow_drop_probability": 50, + "green_drop_probability": 25, + "red_drop_probability": 100 + } + ] + } + }, + + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + + "sonic-queue:sonic-queue": { + "sonic-queue:QUEUE": { + "QUEUE_LIST": [ + { + "ifname": "Ethernet0", + "qindex": "0", + "scheduler": "Test@0", + "wred_profile": "Wred1" + } + ] + } + } + }, + + "QUEUE_PORT_NOT_EXIST": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cbs": 256, + "cir": 1250000, + "meter_type": "bytes", + "pbs": 1024, + "pir": 25000000, + "type": "DWRR", + "weight": 10 + } + ] + } + }, + "sonic-wred-profile:sonic-wred-profile":{ + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred1", + "yellow_min_threshold": 2048, + "green_min_threshold": 4096, + "red_min_threshold": 1024, + "yellow_max_threshold": 4096, + "green_max_threshold": 8192, + "red_max_threshold": 2048, + "ecn": "ecn_none", + "wred_green_enable": true, + "wred_yellow_enable": true, + "wred_red_enable": true, + "yellow_drop_probability": 50, + "green_drop_probability": 25, + "red_drop_probability": 100 + } + ] + } + }, + + "sonic-queue:sonic-queue": { + "sonic-queue:QUEUE": { + "QUEUE_LIST": [ + { + "ifname": "Ethernet0", + "qindex": "0", + "scheduler": "Test@0", + "wred_profile": "Wred1" + } + ] + } + } + }, + + "QUEUE_SCHEDULER_NOT_EXIST": { + "sonic-wred-profile:sonic-wred-profile":{ + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred1", + "yellow_min_threshold": 2048, + "green_min_threshold": 4096, + "red_min_threshold": 1024, + "yellow_max_threshold": 4096, + "green_max_threshold": 8192, + "red_max_threshold": 2048, + "ecn": "ecn_none", + "wred_green_enable": true, + "wred_yellow_enable": true, + "wred_red_enable": true, + "yellow_drop_probability": 50, + "green_drop_probability": 25, + "red_drop_probability": 100 + } + ] + } + }, + + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet4", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet4", + "speed": 25000 + } + ] + } + }, + + "sonic-queue:sonic-queue": { + "sonic-queue:QUEUE": { + "QUEUE_LIST": [ + { + "ifname": "Ethernet4", + "qindex": "0", + "scheduler": "Test@0", + "wred_profile": "Wred1" + } + ] + } + } + }, + + "QUEUE_WRED_NOT_EXIST": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cbs": 256, + "cir": 1250000, + "meter_type": "bytes", + "pbs": 1024, + "pir": 25000000, + "type": "DWRR", + "weight": 10 + } + ] + } + }, + + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + + "sonic-queue:sonic-queue": { + "sonic-queue:QUEUE": { + "QUEUE_LIST": [ + { + "ifname": "Ethernet8", + "qindex": "0", + "scheduler": "Test@0", + "wred_profile": "Wred1" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-queue.yang b/src/sonic-yang-models/yang-models/sonic-queue.yang new file mode 100644 index 0000000000..8e24faa72c --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-queue.yang @@ -0,0 +1,88 @@ +module sonic-queue { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-queue"; + + prefix squeue; + + import sonic-extension { + prefix sonic-ext; + } + + import sonic-port { + prefix port; + } + + import sonic-scheduler { + prefix sch; + } + + import sonic-wred-profile { + prefix wrd; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "QUEUE yang Module for SONiC OS"; + + revision 2021-04-01 { + description + "Initial revision"; + } + + container sonic-queue { + + container QUEUE { + + description "QUEUE part of config_db.json"; + + list QUEUE_LIST { + + key "ifname qindex"; + + // sonic-ext:key-pattern "QUEUE|{ifname}|{qindex}"; //special pattern used for extracting keys from redis-key and populate the yang instance + // Total list instances = number(key1) * number(key2) * number(key3) + + leaf ifname { + type union { + type leafref { + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; + } + type string { + pattern "CPU"; + } + } + description "Interface name."; + } + // qindex format is (X) | (X-Y). X is start and Y is end index. + // X and Y value depends on platform, example for physical ports 0-7 and + // for CPU port 0-48. Example qindex is 3-4 + leaf qindex { + // sonic-ext:custom-validation ValidateQindexPattern; + type string; + description "Queue index on the interface."; + } + + leaf scheduler { + type leafref { + path "/sch:sonic-scheduler/sch:SCHEDULER/sch:SCHEDULER_LIST/sch:name"; //Reference to SCHEDULER table + } + description "Scheduler for queue."; + } + + leaf wred_profile { + type leafref { + path "/wrd:sonic-wred-profile/wrd:WRED_PROFILE/wrd:WRED_PROFILE_LIST/wrd:name"; // Reference to WRED_PROFILE table + } + description "Wred profile for queue."; + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-scheduler.yang b/src/sonic-yang-models/yang-models/sonic-scheduler.yang new file mode 100644 index 0000000000..e6d1b7468f --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-scheduler.yang @@ -0,0 +1,148 @@ +module sonic-scheduler { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-scheduler"; + + prefix sch; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SCHEDULER yang Module for SONiC OS"; + + revision 2021-04-01 { + description + "Initial revision"; + } + + container sonic-scheduler { + + container SCHEDULER { + + description "SCHEDULER part of config_db.json"; + + list SCHEDULER_LIST { + + key "name"; + + leaf name { + + type string { + pattern "[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})|[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})([@]{1})([0-9]{1,3})"; + length 1..36 { + error-message "Invalid length for scheduler name."; + error-app-tag scheduler-name-invalid-length; + } + } + description "Scheduler name"; + } + + leaf type { + type enumeration { + enum DWRR { + description "Deficit Weighted Round-Robin Scheduling"; + } + enum WRR { + description "Weighted Round-Robin Scheduling"; + } + enum STRICT { + description "Strict Scheduling"; + } + } + default WRR; + description "Scheduling algorithm type"; + } + + leaf weight { + type uint8 { + range "1..100"; + } + default 1; + description "Scheduling algorithm weight"; + } + + leaf priority { + type uint8 { + range "0..9"; + } + description "Scheduler priority"; + } + + leaf meter_type { + type enumeration { + enum packets { + description "Metering is based on packets"; + } + enum bytes { + description "Metering is based on bytes"; + } + } + default bytes; + description "meter type"; + } + + leaf cir { + type uint64; + description + "Committed information rate for the dual-rate token + bucket policer.This value represents the rate at which + tokens are added to the primary bucket.nt Units is + Bps(Bytes per second) for meter type is bytes else + Pps(packets per second) for meter type is packets"; + } + + leaf pir { + must "((current()/../cir) and (current()/../cir > 0))" { + error-message "pir can't be configured without cir."; + } + must "(current() >= current()/../cir)" { + error-message "pir must be greater than or equal to cir"; + } + type uint64; + description + "Peak information rate for the dual-rate token bucket + policer.This value represents the rate at which tokens + are added to the secondary bucket.Unit is Bps(Bytes + per second) for meter type bytes else Pps(packets per + second) for meter type is packets"; + } + + leaf cbs { + + must "((current()/../cir) and (current()/../cir > 0))" { + error-message "cbs can't be configured without cir."; + } + + type uint32; + description + "Committed burst size for the dual-rate token bucket + policer.This value represents the depth of the token + bucket.Unit is bytes for meter type bytes else packets + for meter type is packets"; + } + + leaf pbs { + must "((current()/../pir) and (current()/../pir > 0))" { + error-message "pbs can't be configured without pir."; + } + + must "((not(current()/../cbs)) or (current() >= current()/../cbs))" { + error-message "pbs must be greater than or equal to cbs"; + } + + type uint32; + description + "Excess burst size for the dual-rate token bucket policer. + This value represents the depth of the secondary bucket. + Unit is bytes for meter type bytes else packets for meter type + is packets"; + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-wred-profile.yang b/src/sonic-yang-models/yang-models/sonic-wred-profile.yang new file mode 100644 index 0000000000..2ca7be26ca --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-wred-profile.yang @@ -0,0 +1,177 @@ +module sonic-wred-profile { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-wred-profile"; + + prefix wrd; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "WRED_PROFILE yang Module for SONiC OS"; + + revision 2021-04-01 { + description + "Initial revision."; + } + + container sonic-wred-profile { + + container WRED_PROFILE { + + description "WRED_PROFILE part of config_db.json"; + + list WRED_PROFILE_LIST { + + key "name"; + + leaf name { + type string { + pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})'; + length 1..32 { + error-message "Invalid length for wred profile name."; + error-app-tag wred-profile-name-invalid-length; + } + } + description "WRED profile name"; + } + + leaf yellow_min_threshold { + type uint64; + units bytes; + description "Yellow minimum threshold bytes"; + } + + leaf green_min_threshold { + type uint64; + units bytes; + description "Green minimum threshold bytes"; + } + + leaf red_min_threshold { + type uint64; + units bytes; + description "Red minimum threshold bytes"; + } + + leaf yellow_max_threshold { + type uint64; + units bytes; + must "(current() >= current()/../yellow_min_threshold)" { + error-message "Yellow max threshold must be greater than or equal to min threshold"; + } + description "Yellow maximum threshold bytes"; + } + + leaf green_max_threshold { + type uint64; + units bytes; + must "(current() >= current()/../green_min_threshold)" { + error-message "Green max threshold must be greater than or equal to min threshold"; + } + description "Green maximum threshold bytes"; + } + + leaf red_max_threshold { + type uint64; + units bytes; + must "(current() >= current()/../red_min_threshold)" { + error-message "Red max threshold must be greater than or equal to min threshold"; + } + description "Red maximum threshold bytes"; + } + + leaf ecn { + + type enumeration { + + enum ecn_none { + description "Disable ECN marking for all colors."; + } + + enum ecn_green { + description "Enable ECN marking for green color. Yellow and red are disabled."; + } + + enum ecn_yellow { + description "Enable ECN marking for yellow color. Green and red are disabled."; + } + + enum ecn_red { + description "Enable ECN marking for red color. Green and red are disabled."; + } + + enum ecn_green_yellow { + description "Enable ECN marking for green and yellow colors. Red is disabled."; + } + + enum ecn_green_red { + description "Enable ECN marking for green and red colors. Yellow is disabled."; + } + + enum ecn_yellow_red { + description "Enable ECN marking for yellow and red colors. Green is disabled."; + } + + enum ecn_all { + description "Enable ECN marking for all colors."; + + } + } + default ecn_none; + description "ECN mode"; + } + + leaf wred_green_enable { + type boolean; + default false; + description "Green enable"; + } + + leaf wred_yellow_enable { + type boolean; + default false; + description "Yellow enable"; + } + + leaf wred_red_enable { + type boolean; + default false; + description "Red enable"; + } + + leaf yellow_drop_probability { + type uint64 { + range "0..100"; + } + units percent; + default 100; + description "Yellow drop probability"; + } + + leaf green_drop_probability { + type uint64 { + range "0..100"; + } + units percent; + default 100; + description "Green drop probability"; + } + + leaf red_drop_probability { + type uint64 { + range "0..100"; + } + units percent; + default 100; + description "Red drop probability"; + } + } + } + } +}