From 40490675341ce4dd5bdb916ef34cb1c6fd6e5685 Mon Sep 17 00:00:00 2001 From: AmitKaushik7 <52193450+AmitKaushik7@users.noreply.github.com> Date: Tue, 21 Sep 2021 03:28:30 +0530 Subject: [PATCH] [yang]: Adding yang model for PFC watch dog parameters (#7839) Added sonic-pfcwd.yang file that defines the yang model for PFC watch dog parameters sonic-pfcwd.yang is required for configuring action, detection_time, restoration time of PFC watchdog on the interface port. --- src/sonic-yang-models/setup.py | 1 + .../tests/files/sample_config_db.json | 15 +- .../tests/yang_model_tests/tests/pfc.json | 42 ++++ .../yang_model_tests/tests_config/pfc.json | 199 ++++++++++++++++++ .../yang-models/sonic-pfcwd.yang | 79 +++++++ 5 files changed, 333 insertions(+), 3 deletions(-) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/pfc.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/pfc.json create mode 100644 src/sonic-yang-models/yang-models/sonic-pfcwd.yang diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 13ce554d02..8c19b719e3 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -62,6 +62,7 @@ setup( './yang-models/sonic-nat.yang', './yang-models/sonic-port.yang', './yang-models/sonic-portchannel.yang', + './yang-models/sonic-pfcwd.yang', './yang-models/sonic-route-common.yang', './yang-models/sonic-route-map.yang', './yang-models/sonic-routing-policy-sets.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 5d8009afbc..0778a7a87a 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -879,7 +879,18 @@ "polling_interval": "0" } }, - + "PFC_WD": { + "Ethernet9": { + "action": "drop", + "detection_time": "100", + "restoration_time": "400" + } + }, + "PFC_WD": { + "GLOBAL": { + "POLL_INTERVAL": "100" + } + }, "SFLOW_COLLECTOR": { "collector1": { "collector_ip": "10.100.12.13", @@ -908,7 +919,6 @@ "agent_id": "Ethernet0" } }, - "AAA": { "authentication": { "login": "local" @@ -925,7 +935,6 @@ "timeout": "10" } }, - "NAT_BINDINGS": { "bind1": { "nat_pool": "pool1", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/pfc.json b/src/sonic-yang-models/tests/yang_model_tests/tests/pfc.json new file mode 100644 index 0000000000..4405075aee --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/pfc.json @@ -0,0 +1,42 @@ +{ + "PFC_WDOG_WITH_CORRECT_ACTION_DROP_VALUE": { + "desc": "PFC_WDOG_WITH_CORRECT_ACTION_DROP_VALUE no failure." + }, + "PFC_WDOG_WITH_CORRECT_ACTION_FORWARD_VALUE": { + "desc": "PFC_WDOG_WITH_CORRECT_ACTION_FORWARD_VALUE no failure." + }, + "PFC_WDOG_WITH_CORRECT_ACTION_ALERT_VALUE": { + "desc": "PFC_WDOG_WITH_CORRECT_ACTION_ALERT_VALUE no failure." + }, + "PFC_WDOG_WITH_WRONG_ACTION_VALUE": { + "desc": "PFC_WDOG_WITH_WRONG_ACTION_VALUE must contain a valid action", + "eStr": [ "wrong" ] + }, + "PFC_WDOG_WITH_CORRECT_POLL_INTERVAL_VALUE": { + "desc": "PFC_WDOG_WITH_CORRECT_POLL_INTERVAL_VALUE no failure" + }, + "PFC_WDOG_WITH_WRONG_POLL_INTERVAL_LOW_VALUE": { + "desc": "PFC_WDOG_WITH_WRONG_POLL_INTERVAL_LOW_VALUE", + "eStr": "range" + }, + "PFC_WDOG_WITH_WRONG_POLL_INTERVAL_HIGH_VALUE": { + "desc": "PFC_WDOG_WITH_WRONG_POLL_INTERVAL_HIGH_VALUE", + "eStr": "range" + }, + "PFC_WDOG_WITH_WRONG_DETECTION_TIME_LOW_VALUE": { + "desc": "PFC_WDOG_WITH_WRONG_DETECTION_TIME_LOW_VALUE", + "eStr": "range" + }, + "PFC_WDOG_WITH_WRONG_DETECTION_TIME_HIGH_VALUE": { + "desc": "PFC_WDOG_WITH_WRONG_DETECTION_TIME_HIGH_VALUE", + "eStr": "range" + }, + "PFC_WDOG_WITH_WRONG_RESTORATION_TIME_LOW_VALUE": { + "desc": "PFC_WDOG_WITH_WRONG_RESTORATION_TIME_LOW_VALUE", + "eStr": "range" + }, + "PFC_WDOG_WITH_WRONG_RESTORATION_TIME_HIGH_VALUE": { + "desc": "PFC_WDOG_WITH_WRONG_RESTORATION_TIME_HIGH_VALUE", + "eStr": "range" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/pfc.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pfc.json new file mode 100644 index 0000000000..8c31d6dd98 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pfc.json @@ -0,0 +1,199 @@ +{ + "PFC_WDOG_WITH_CORRECT_ACTION_DROP_VALUE": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet4", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet4", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "Ethernet4", + "action": "drop", + "detection_time": 300, + "restoration_time": 3000 + } + ] + } + } + }, + "PFC_WDOG_WITH_CORRECT_ACTION_FORWARD_VALUE": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet4", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet4", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "Ethernet4", + "action": "forward", + "detection_time": 300, + "restoration_time": 3000 + } + ] + } + } + }, + "PFC_WDOG_WITH_CORRECT_ACTION_ALERT_VALUE": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet4", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet4", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "Ethernet4", + "action": "alert", + "detection_time": 300, + "restoration_time": 3000 + } + ] + } + } + }, + "PFC_WDOG_WITH_WRONG_ACTION_VALUE": { + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "Ethernet4", + "action": "wrong", + "detection_time": 300, + "restoration_time": 3000 + } + ] + } + } + }, + "PFC_WDOG_WITH_CORRECT_POLL_INTERVAL_VALUE": { + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "GLOBAL", + "POLL_INTERVAL": 101 + } + ] + } + } + }, + "PFC_WDOG_WITH_WRONG_POLL_INTERVAL_LOW_VALUE": { + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "GLOBAL", + "POLL_INTERVAL":99 + } + ] + } + } + }, + "PFC_WDOG_WITH_WRONG_POLL_INTERVAL_HIGH_VALUE": { + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "GLOBAL", + "POLL_INTERVAL": 3001 + } + ] + } + } + }, + "PFC_WDOG_WITH_WRONG_DETECTION_TIME_LOW_VALUE": { + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "Ethernet4", + "action": "drop", + "detection_time": 99, + "restoration_time": 3000 + } + ] + } + } + }, + "PFC_WDOG_WITH_WRONG_DETECTION_TIME_HIGH_VALUE": { + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "Ethernet4", + "action": "wrong", + "detection_time": 5001, + "restoration_time": 3000 + } + ] + } + } + }, + "PFC_WDOG_WITH_WRONG_RESTORATION_TIME_LOW_VALUE": { + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "Ethernet4", + "action": "drop", + "detection_time": 99, + "restoration_time": 3000 + } + ] + } + } + }, + "PFC_WDOG_WITH_WRONG_RESTORATION_TIME_HIGH_VALUE": { + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "Ethernet4", + "action": "wrong", + "detection_time": 60001, + "restoration_time": 3000 + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-pfcwd.yang b/src/sonic-yang-models/yang-models/sonic-pfcwd.yang new file mode 100644 index 0000000000..beebf51965 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-pfcwd.yang @@ -0,0 +1,79 @@ +module sonic-pfcwd { + namespace "http://github.com/Azure/sonic-pfcwd"; + prefix sonic-pfcwd; + + yang-version 1.1; + + import sonic-port { + prefix port; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC PFC Watchdog parameters"; + + revision 2021-07-01 { + description + "Initial revision."; + } + + container sonic-pfcwd { + container PFC_WD { + list PFC_WD_LIST { + key "ifname"; + leaf ifname { + type union { + type leafref { + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; + } + type string { + pattern "GLOBAL" { + error-message "Invalid interface name"; + error-app-tag interface-name-invalid; + } + } + } + } + leaf action { + must "../ifname != 'GLOBAL'"; + type enumeration { + enum drop; + enum forward; + enum alert; + } + description + "PFC watchdog action when entering storm state."; + } + leaf detection_time { + must "../ifname != 'GLOBAL'"; + type uint32 { + range 100..5000; + } + description + "Detection interval for pause storm in msec."; + } + leaf restoration_time { + must "../ifname != 'GLOBAL'"; + type uint32 { + range 100..60000; + } + description + "Time delay before resuming normal PFC operation in msec."; + } + leaf POLL_INTERVAL { + must "../ifname = 'GLOBAL'"; + type uint32 { + range 100..3000; + } + description + "PFC watchdog global polling interval in msec."; + } + } + } + } +}