diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 8c651a7a590c..1cf2e990ef7b 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -131,6 +131,7 @@ def run(self): './yang-models/sonic-exp-fc-map.yang', './yang-models/sonic-dscp-tc-map.yang', './yang-models/sonic-dot1p-tc-map.yang', + './yang-models/sonic-storm-control.yang', './yang-models/sonic-tc-priority-group-map.yang', './yang-models/sonic-tc-queue-map.yang', './yang-models/sonic-pfc-priority-queue-map.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 541cdb0f3ce3..0e4e07519bcb 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -973,13 +973,22 @@ "polling_interval": "0" } }, - "WARM_RESTART": { "bgp": { "bgp_timer": "500" } }, - + "PORT_STORM_CONTROL": { + "Ethernet0|broadcast": { + "kbps": "10000" + }, + "Ethernet0|unknown-multicast": { + "kbps": "30000" + }, + "Ethernet0|unknown-unicast": { + "kbps": "20000" + } + }, "PFC_WD": { "Ethernet9": { "action": "drop", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/storm_control.json b/src/sonic-yang-models/tests/yang_model_tests/tests/storm_control.json new file mode 100644 index 000000000000..16542eb1183b --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/storm_control.json @@ -0,0 +1,26 @@ +{ + "STORM_BROADCAST_TEST": { + "desc": "Broadcast storm-control" + }, + "STORM_UUCAST_TEST": { + "desc": "unknown-unicast storm-control" + }, + "STORM_UMCAST_TEST": { + "desc": "unknown-multicast storm-control" + }, + "STORM_INVALID_STORM_TYPE_TEST": { + "desc": "storm-control invalid storm-type", + "eStrKey" : "InvalidValue", + "eStr": ["storm_type"] + }, + "STORM_BROADCAST_INVALID_KBPS": { + "desc": "Broadcast storm-control invalid kbps", + "eStrKey" : "InvalidValue", + "eStr": ["kbps"] + }, + "STORM_BROADCAST_INVALID_INTERFACE": { + "desc": "Broadcast storm-control invalid interface", + "eStrKey" : "LeafRef", + "eStr": ["Eth"] + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/storm_control.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/storm_control.json new file mode 100644 index 000000000000..d5c56249e484 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/storm_control.json @@ -0,0 +1,170 @@ +{ + "STORM_BROADCAST_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Ethernet0", + "storm_type": "broadcast", + "kbps": "100000" + } + ] + } + } + }, + "STORM_UUCAST_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Ethernet0", + "storm_type": "unknown-unicast", + "kbps": "200000" + } + ] + } + } + }, + "STORM_UMCAST_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Ethernet0", + "storm_type": "unknown-multicast", + "kbps": "300000" + } + ] + } + } + }, + "STORM_INVALID_STORM_TYPE_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Ethernet0", + "storm_type": "xyz", + "kbps": "400000" + } + ] + } + } + }, + "STORM_BROADCAST_INVALID_KBPS": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Ethernet0", + "storm_type": "broadcast", + "kbps": "xyz-kbps-value" + } + ] + } + } + }, + "STORM_BROADCAST_INVALID_INTERFACE": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Eth", + "storm_type": "broadcast", + "kbps": "500000" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-storm-control.yang b/src/sonic-yang-models/yang-models/sonic-storm-control.yang new file mode 100644 index 000000000000..6d4e2b66a0f5 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-storm-control.yang @@ -0,0 +1,56 @@ +module sonic-storm-control { + namespace "http://github.com/Azure/sonic-storm-control"; + yang-version "1"; + + prefix ssc; + + import sonic-port { + prefix prt; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "This module defines configuration and operational state + data for broadcast, unknown-unicast and unknown-multicast (BUM) storm-control. + storm-control can be enabled on ethernet interfaces. + Rate is defined in bits-per-second. All three types of storm-control can be + enabled on an interface."; + + revision 2021-12-13 { + description + "Initial revision"; + } + + container sonic-storm-control { + container PORT_STORM_CONTROL { + list PORT_STORM_CONTROL_LIST { + key "ifname storm_type"; + /*scommon:key-pattern "PORT_STORM_CONTROL|{ifname}|{storm_type}";*/ + leaf ifname { + type leafref { + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + } + } + leaf storm_type { + type enumeration{ + enum broadcast; + enum unknown-unicast; + enum unknown-multicast; + } + } + leaf kbps { + type uint64 { + range "0..100000000" { + error-message "kbps value out of range"; + } + } + } + } + } + } +}