Skip to content

Commit

Permalink
[yang]: Add constraint for pfcwd (#9513)
Browse files Browse the repository at this point in the history
#### Why I did it
POLL_INTERVAL cannot be set if any of the detection/restoration times in this table is less than the POLL_INTERVAL.

#### How I did it
Add "must" constraint to make sure detection/restoration times are greater than POLL_INTERVAL.

#### How to verify it
Use apply-patch command to update POLL_INTERVAL.
Build sonic-yang-model.
  • Loading branch information
ganglyu authored Dec 20, 2021
1 parent 3af4a96 commit dfddd55
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/pfc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@
"desc": "PFC_WDOG_WITH_WRONG_DETECTION_TIME_HIGH_VALUE",
"eStr": "range"
},
"PFC_WDOG_WITH_INVALID_DETECTION_TIME": {
"desc": "PFC_WDOG_WITH_INVALID_DETECTION_TIME",
"eStr": ["detection_time must be greater than or equal to POLL_INTERVAL"]
},
"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"
},
"PFC_WDOG_WITH_INVALID_RESTORATION_TIME": {
"desc": "PFC_WDOG_WITH_INVALID_RESTORATION_TIME",
"eStr": ["restoration_time must be greater than or equal to POLL_INTERVAL"]
}
}
138 changes: 136 additions & 2 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/pfc.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,36 +105,102 @@
}
},
"PFC_WDOG_WITH_CORRECT_POLL_INTERVAL_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": "GLOBAL",
"POLL_INTERVAL": 101
},
{
"ifname": "Ethernet4",
"action": "drop",
"detection_time": 101,
"restoration_time": 3000
}
]
}
}
},
"PFC_WDOG_WITH_WRONG_POLL_INTERVAL_LOW_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": "GLOBAL",
"POLL_INTERVAL":99
},
{
"ifname": "Ethernet4",
"action": "drop",
"detection_time": 100,
"restoration_time": 3000
}
]
}
}
},
"PFC_WDOG_WITH_WRONG_POLL_INTERVAL_HIGH_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": "GLOBAL",
"POLL_INTERVAL": 3001
},
{
"ifname": "Ethernet4",
"action": "drop",
"detection_time": 3001,
"restoration_time": 3001
}
]
}
Expand All @@ -160,14 +226,48 @@
"PFC_WD_LIST": [
{
"ifname": "Ethernet4",
"action": "wrong",
"action": "drop",
"detection_time": 5001,
"restoration_time": 3000
}
]
}
}
},
"PFC_WDOG_WITH_INVALID_DETECTION_TIME": {
"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": "GLOBAL",
"POLL_INTERVAL": 1000
},
{
"ifname": "Ethernet4",
"action": "drop",
"detection_time": 999,
"restoration_time": 1000
}
]
}
}
},
"PFC_WDOG_WITH_WRONG_RESTORATION_TIME_LOW_VALUE": {
"sonic-pfcwd:sonic-pfcwd": {
"sonic-pfcwd:PFC_WD": {
Expand All @@ -188,12 +288,46 @@
"PFC_WD_LIST": [
{
"ifname": "Ethernet4",
"action": "wrong",
"action": "drop",
"detection_time": 60001,
"restoration_time": 3000
}
]
}
}
},
"PFC_WDOG_WITH_INVALID_RESTORATION_TIME": {
"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": "GLOBAL",
"POLL_INTERVAL": 1000
},
{
"ifname": "Ethernet4",
"action": "drop",
"detection_time": 1000,
"restoration_time": 999
}
]
}
}
}
}
6 changes: 6 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-pfcwd.yang
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ module sonic-pfcwd {
}
leaf detection_time {
must "../ifname != 'GLOBAL'";
must "(not(boolean(current()/../../PFC_WD_LIST[ifname='GLOBAL'])) or (current() >= current()/../../PFC_WD_LIST[ifname='GLOBAL']/POLL_INTERVAL))" {
error-message "detection_time must be greater than or equal to POLL_INTERVAL";
}
type uint32 {
range 100..5000;
}
Expand All @@ -59,6 +62,9 @@ module sonic-pfcwd {
}
leaf restoration_time {
must "../ifname != 'GLOBAL'";
must "(not(boolean(current()/../../PFC_WD_LIST[ifname='GLOBAL'])) or (current() >= current()/../../PFC_WD_LIST[ifname='GLOBAL']/POLL_INTERVAL))" {
error-message "restoration_time must be greater than or equal to POLL_INTERVAL";
}
type uint32 {
range 100..60000;
}
Expand Down

0 comments on commit dfddd55

Please sign in to comment.