Skip to content

Commit

Permalink
[yang]: Adding yang model for PFC watch dog parameters (#7839)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AmitKaushik7 authored Sep 20, 2021
1 parent d588b3b commit 4049067
Show file tree
Hide file tree
Showing 5 changed files with 333 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
'./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',
Expand Down
15 changes: 12 additions & 3 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -908,7 +919,6 @@
"agent_id": "Ethernet0"
}
},

"AAA": {
"authentication": {
"login": "local"
Expand All @@ -925,7 +935,6 @@
"timeout": "10"
}
},

"NAT_BINDINGS": {
"bind1": {
"nat_pool": "pool1",
Expand Down
42 changes: 42 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/pfc.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
199 changes: 199 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/pfc.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
}
}
}
79 changes: 79 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-pfcwd.yang
Original file line number Diff line number Diff line change
@@ -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.";
}
}
}
}
}

0 comments on commit 4049067

Please sign in to comment.