[yang]YANG model for policer table (#9948)
#### Why I did it Added yang model for policer table Fixes https://github.com/Azure/sonic-buildimage/issues/9742 and https://github.com/Azure/sonic-buildimage/issues/9743 #### How I did it Creating yang model for policer #### How to verify it Added UT to verify the yang model The configuration schema for policer is added in the pull request https://github.com/Azure/sonic-swss/pull/2144
This commit is contained in:
parent
cf1bc8dc65
commit
0b59f0b641
@ -110,6 +110,7 @@ setup(
|
||||
'./yang-models/sonic-nat.yang',
|
||||
'./yang-models/sonic-pbh.yang',
|
||||
'./yang-models/sonic-port.yang',
|
||||
'./yang-models/sonic-policer.yang',
|
||||
'./yang-models/sonic-portchannel.yang',
|
||||
'./yang-models/sonic-pfcwd.yang',
|
||||
'./yang-models/sonic-route-common.yang',
|
||||
@ -165,6 +166,7 @@ setup(
|
||||
'./cvlyang-models/sonic-ntp.yang',
|
||||
'./cvlyang-models/sonic-nat.yang',
|
||||
'./cvlyang-models/sonic-pbh.yang',
|
||||
'./cvlyang-models/sonic-policer.yang',
|
||||
'./cvlyang-models/sonic-port.yang',
|
||||
'./cvlyang-models/sonic-portchannel.yang',
|
||||
'./cvlyang-models/sonic-pfcwd.yang',
|
||||
|
@ -1570,6 +1570,7 @@
|
||||
"queue": "0",
|
||||
"src_ip": "10.1.1.1",
|
||||
"ttl": "10",
|
||||
"policer": "everflow_static_policer",
|
||||
"type": "ERSPAN"
|
||||
},
|
||||
"span": {
|
||||
@ -1582,6 +1583,16 @@
|
||||
]
|
||||
|
||||
}
|
||||
},
|
||||
"POLICER": {
|
||||
"everflow_static_policer": {
|
||||
"meter_type": "bytes",
|
||||
"mode": "sr_tcm",
|
||||
"cir": "12500000",
|
||||
"cbs": "12500000",
|
||||
"color": "aware",
|
||||
"red_packet_action": "drop"
|
||||
}
|
||||
}
|
||||
},
|
||||
"SAMPLE_CONFIG_DB_UNKNOWN": {
|
||||
|
@ -3,79 +3,86 @@
|
||||
"desc": "Configuring ERSPAN entry with valid values."
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_TYPE": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid type",
|
||||
"desc": "Configuring ERSPAN entry with invalid type",
|
||||
"eStrKey": "InvalidValue"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_DST_IP": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid dst_ip",
|
||||
"desc": "Configuring ERSPAN entry with invalid dst_ip",
|
||||
"eStrKey" : "Pattern"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_DST_IP_TYPE": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid dst_ip",
|
||||
"desc": "Configuring ERSPAN entry with invalid dst_ip",
|
||||
"eStrKey" : "When"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_SRC_IP": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid src_ip",
|
||||
"desc": "Configuring ERSPAN entry with invalid src_ip",
|
||||
"eStrKey" : "Pattern"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_SRC_IP_TYPE": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid src_ip",
|
||||
"desc": "Configuring ERSPAN entry with invalid src_ip",
|
||||
"eStrKey" : "When"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid GRE type",
|
||||
"desc": "Configuring ERSPAN entry with invalid GRE type",
|
||||
"eStrKey" : "Pattern"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_GRE_WRONG_TYPE": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid GRE type",
|
||||
"desc": "Configuring ERSPAN entry with invalid GRE type",
|
||||
"eStrKey" : "When"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_DSCP": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid dscp",
|
||||
"desc": "Configuring ERSPAN entry with invalid dscp",
|
||||
"eStr" : "Invalid dscp value"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_DSCP_TYPE": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid dscp",
|
||||
"desc": "Configuring ERSPAN entry with invalid dscp",
|
||||
"eStrKey" : "When"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_TTL": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid ttl",
|
||||
"desc": "Configuring ERSPAN entry with invalid ttl",
|
||||
"eStr": "Invalid TTL value"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_TTL_TYPE": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid ttl",
|
||||
"desc": "Configuring ERSPAN entry with invalid ttl",
|
||||
"eStrKey" : "When"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_VALID_SRC_PORT": {
|
||||
"desc": "Configurinng ERSPAN entry with valid source port"
|
||||
"desc": "Configuring ERSPAN entry with valid source port"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_VALID_SRC_PORTCHANNEL": {
|
||||
"desc": "Configurinng ERSPAN entry with valid source portchannel"
|
||||
"desc": "Configuring ERSPAN entry with valid source portchannel"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_INVALID_SRC_PORT": {
|
||||
"desc": "Configurinng ERSPAN entry with invalid source port",
|
||||
"desc": "Configuring ERSPAN entry with invalid source port",
|
||||
"eStrKey" : "InvalidValue"
|
||||
},
|
||||
"MIRROR_SPAN_ENTRY_WITH_VALID_VALUES": {
|
||||
"desc": "Configurinng SPAN entry with valid source and destination ports"
|
||||
"desc": "Configuring SPAN entry with valid source and destination ports"
|
||||
},
|
||||
"MIRROR_SPAN_ENTRY_INVALID_DST_PORT": {
|
||||
"desc": "Configurinng SPAN entry with invalid destination ports",
|
||||
"desc": "Configuring SPAN entry with invalid destination ports",
|
||||
"eStrKey" : "InvalidValue"
|
||||
},
|
||||
"MIRROR_SPAN_ENTRY_INVALID_DST_PORT_TYPE": {
|
||||
"desc": "Configurinng SPAN entry with invalid destination ports",
|
||||
"desc": "Configuring SPAN entry with invalid destination ports",
|
||||
"eStrKey" : "When"
|
||||
},
|
||||
"MIRROR_SPAN_ENTRY_VALID_DST_PORT_CPU": {
|
||||
"desc": "Configurinng SPAN entry with valid destination port CPU"
|
||||
"desc": "Configuring SPAN entry with valid destination port CPU"
|
||||
},
|
||||
"MIRROR_SPAN_ENTRY_INVALID_SRC_PORT": {
|
||||
"desc": "Configurinng SPAN entry with invalid destination ports",
|
||||
"desc": "Configuring SPAN entry with invalid destination ports",
|
||||
"eStrKey" : "InvalidValue"
|
||||
},
|
||||
"MIRROR_SPAN_ENTRY_INVALID_DIRECTION": {
|
||||
"desc": "Configurinng SPAN entry with invalid direction",
|
||||
"desc": "Configuring SPAN entry with invalid direction",
|
||||
"eStrKey": "InvalidValue"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_POLICER": {
|
||||
"desc": "Configuring SPAN entry with valid policer"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_INVALID_POLICER": {
|
||||
"desc": "Configuring SPAN entry with invalid policer",
|
||||
"eStrKey": "LeafRef"
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
{
|
||||
"POLICER_TABLE": {
|
||||
"desc": "Configure policer with all fields."
|
||||
},
|
||||
"POLICER_MANDATORY_MODE": {
|
||||
"desc": "Configure policer with no mode.",
|
||||
"eStrKey" : "Mandatory"
|
||||
},
|
||||
"POLICER_MANDATORY_METER_TYPE": {
|
||||
"desc": "Configure policer with no meter type.",
|
||||
"eStrKey" : "Mandatory"
|
||||
},
|
||||
"POLICER_UNKNOWN_METER_TYPE": {
|
||||
"desc": "Configure policer with unknown meter type.",
|
||||
"eStrKey" : "InvalidValue",
|
||||
"eStr" : ["meter_type"]
|
||||
},
|
||||
"POLICER_UNKNOWN_MODE": {
|
||||
"desc": "Configure policer with unknown mode.",
|
||||
"eStrKey" : "InvalidValue",
|
||||
"eStr" : ["mode"]
|
||||
},
|
||||
"POLICER_UNKNOWN_ACTION": {
|
||||
"desc": "Configure policer with unknown action.",
|
||||
"eStrKey" : "InvalidValue",
|
||||
"eStr" : ["red_packet_action"]
|
||||
},
|
||||
"POLICER_UNKNOWN_COLOR": {
|
||||
"desc": "Configure policer with unknown color awareness.",
|
||||
"eStrKey" : "InvalidValue",
|
||||
"eStr" : ["color"]
|
||||
},
|
||||
"POLICER_CBS_WITHOUT_CIR": {
|
||||
"desc": "Configure policer with cbs but without cir.",
|
||||
"eStr": ["cbs can't be configured without cir."]
|
||||
},
|
||||
"POLICER_CBS_LESS_THAN_CIR": {
|
||||
"desc": "Configure policer with cbs less than cir.",
|
||||
"eStr": ["cbs must be greater than or equal to cir"]
|
||||
},
|
||||
"POLICER_PIR_LESS_THAN_CIR": {
|
||||
"desc": "Configure policer with pir less than cir.",
|
||||
"eStr": ["pir must be greater than or equal to cir"]
|
||||
},
|
||||
"POLICER_PBS_WITH_STORM": {
|
||||
"desc": "Configure policer with pbs configured in storm mode.",
|
||||
"eStrKey" : "When"
|
||||
},
|
||||
"POLICER_PBS_LESS_THAN_CBS": {
|
||||
"desc": "Configure policer with pbs less than cbs.",
|
||||
"eStr": ["pbs must be greater than or equal to cbs"]
|
||||
},
|
||||
"POLICER_PIR_WITHOUT_CIR": {
|
||||
"desc": "Configure policer with pir but without cir.",
|
||||
"eStr": ["pir can't be configured without cir."]
|
||||
},
|
||||
"POLICER_WHEN_SRTCM_WITH_PIR": {
|
||||
"desc": "Configure policer with pir configured in sr_tcm mode.",
|
||||
"eStrKey" : "When"
|
||||
}
|
||||
}
|
@ -442,5 +442,56 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_POLICER": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [
|
||||
{
|
||||
"name": "erspan_policer",
|
||||
"meter_type":"packets",
|
||||
"mode":"tr_tcm",
|
||||
"color": "aware",
|
||||
"cir":"5000",
|
||||
"cbs":"5000",
|
||||
"pir":"15000",
|
||||
"pbs":"15000",
|
||||
"red_packet_action":"drop"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"sonic-mirror-session:sonic-mirror-session": {
|
||||
"MIRROR_SESSION": {
|
||||
"MIRROR_SESSION_LIST": [
|
||||
{
|
||||
"name": "erspan",
|
||||
"type": "ERSPAN",
|
||||
"dst_ip": "11.1.1.1",
|
||||
"src_ip": "10.1.1.1",
|
||||
"gre_type": "0x1234",
|
||||
"dscp": "10",
|
||||
"policer": "erspan_policer"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_INVALID_POLICER": {
|
||||
"sonic-mirror-session:sonic-mirror-session": {
|
||||
"MIRROR_SESSION": {
|
||||
"MIRROR_SESSION_LIST": [
|
||||
{
|
||||
"name": "erspan",
|
||||
"type": "ERSPAN",
|
||||
"dst_ip": "11.1.1.1",
|
||||
"src_ip": "10.1.1.1",
|
||||
"gre_type": "0x1234",
|
||||
"dscp": "10",
|
||||
"policer": "erspan_policer2"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,220 @@
|
||||
{
|
||||
"POLICER_TABLE": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "everflow_session1_policer",
|
||||
"meter_type":"packets",
|
||||
"mode":"tr_tcm",
|
||||
"color": "aware",
|
||||
"cir":"5000",
|
||||
"cbs":"5000",
|
||||
"pir":"15000",
|
||||
"pbs":"15000",
|
||||
"yellow_packet_action":"forward",
|
||||
"green_packet_action":"forward"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_MANDATORY_MODE": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "everflow_session1_policer",
|
||||
"meter_type":"packets",
|
||||
"cir":"5000",
|
||||
"cbs":"5000",
|
||||
"red_packet_action":"drop"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_MANDATORY_METER_TYPE": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "everflow_session2_policer",
|
||||
"mode":"sr_tcm",
|
||||
"cir":"5000",
|
||||
"cbs":"5000",
|
||||
"red_packet_action":"drop"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_UNKNOWN_METER_TYPE": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "everflow_session4_policer",
|
||||
"mode":"sr_tcm",
|
||||
"meter_type":"bits",
|
||||
"cir":"5000",
|
||||
"cbs":"5000",
|
||||
"red_packet_action":"drop"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_UNKNOWN_MODE": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "everflow_session5_policer",
|
||||
"mode":"srtcm",
|
||||
"meter_type":"bytes",
|
||||
"cir":"5000",
|
||||
"cbs":"5000",
|
||||
"red_packet_action":"drop"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_UNKNOWN_ACTION": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "everflow_session6_policer",
|
||||
"mode":"storm",
|
||||
"meter_type":"bytes",
|
||||
"cir":"5000",
|
||||
"cbs":"5000",
|
||||
"color":"aware",
|
||||
"red_packet_action":"act"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_UNKNOWN_COLOR": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "everflow_session7_policer",
|
||||
"mode":"sr_tcm",
|
||||
"meter_type":"bytes",
|
||||
"cir":"5000",
|
||||
"cbs":"5000",
|
||||
"red_packet_action":"drop",
|
||||
"color":"yes"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_CBS_WITHOUT_CIR": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "p5",
|
||||
"meter_type":"bytes",
|
||||
"mode":"tr_tcm",
|
||||
"cbs":"5000",
|
||||
"pir":"4000",
|
||||
"pbs":"4000",
|
||||
"red_packet_action":"drop"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_CBS_LESS_THAN_CIR": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "policer5",
|
||||
"meter_type":"bytes",
|
||||
"mode":"sr_tcm",
|
||||
"cbs":"5000",
|
||||
"cir":"6000",
|
||||
"red_packet_action":"drop"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_PIR_LESS_THAN_CIR": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "e3_policer",
|
||||
"meter_type":"bytes",
|
||||
"mode":"tr_tcm",
|
||||
"cir":"5000",
|
||||
"cbs":"5000",
|
||||
"pir":"4000",
|
||||
"pbs":"4000",
|
||||
"red_packet_action":"drop"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_PBS_WITH_STORM": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "e1policer",
|
||||
"meter_type":"bytes",
|
||||
"mode":"storm",
|
||||
"cir":"5000",
|
||||
"cbs":"5000",
|
||||
"pbs":"6000",
|
||||
"red_packet_action":"drop"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_PBS_LESS_THAN_CBS": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "e2policer",
|
||||
"meter_type":"bytes",
|
||||
"mode":"tr_tcm",
|
||||
"cir":"5000",
|
||||
"cbs":"5000",
|
||||
"pbs":"2000",
|
||||
"red_packet_action":"drop"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_PIR_WITHOUT_CIR": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "e3policer",
|
||||
"meter_type":"bytes",
|
||||
"mode":"tr_tcm",
|
||||
"pir":"2000",
|
||||
"red_packet_action":"drop"
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"POLICER_WHEN_SRTCM_WITH_PIR": {
|
||||
"sonic-policer:sonic-policer": {
|
||||
"sonic-policer:POLICER": {
|
||||
"POLICER_LIST": [{
|
||||
"name": "policer1",
|
||||
"meter_type":"packets",
|
||||
"mode":"sr_tcm",
|
||||
"cir":"6000",
|
||||
"cbs":"6000",
|
||||
"pir":"6000",
|
||||
"red_packet_action":"drop"
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -40,7 +40,7 @@ module sonic-copp {
|
||||
|
||||
leaf trap_action {
|
||||
mandatory true;
|
||||
type stypes:copp_packet_action;
|
||||
type stypes:policer_packet_action;
|
||||
description "Trap action";
|
||||
}
|
||||
|
||||
@ -61,12 +61,8 @@ module sonic-copp {
|
||||
}
|
||||
|
||||
leaf color {
|
||||
type enumeration {
|
||||
enum blind;
|
||||
enum color;
|
||||
}
|
||||
default "color";
|
||||
description "Policer color source";
|
||||
type stypes:policer_color_source;
|
||||
description "Policer color Source";
|
||||
}
|
||||
|
||||
leaf cir {
|
||||
@ -120,20 +116,20 @@ module sonic-copp {
|
||||
}
|
||||
|
||||
leaf green_action {
|
||||
type stypes:copp_packet_action;
|
||||
type stypes:policer_packet_action;
|
||||
default "forward";
|
||||
description "Green action";
|
||||
}
|
||||
|
||||
leaf yellow_action {
|
||||
when "((current()/../mode = 'sr_tcm') or (current()/../mode = 'tr_tcm'))";
|
||||
type stypes:copp_packet_action;
|
||||
type stypes:policer_packet_action;
|
||||
default "forward";
|
||||
description "Yellow action";
|
||||
}
|
||||
|
||||
leaf red_action {
|
||||
type stypes:copp_packet_action;
|
||||
type stypes:policer_packet_action;
|
||||
default "forward";
|
||||
description "Red action";
|
||||
}
|
||||
|
@ -17,6 +17,10 @@ module sonic-mirror-session {
|
||||
prefix lag;
|
||||
}
|
||||
|
||||
import sonic-policer {
|
||||
prefix policer;
|
||||
}
|
||||
|
||||
description
|
||||
"SONiC Mirror session yang model";
|
||||
|
||||
@ -174,6 +178,14 @@ module sonic-mirror-session {
|
||||
TX: Captures frames egressing on source port.
|
||||
BOTH: Captures frames ingressing or egressing on source port.";
|
||||
}
|
||||
|
||||
leaf policer {
|
||||
type leafref {
|
||||
path "/policer:sonic-policer/policer:POLICER/policer:POLICER_LIST/policer:name";
|
||||
}
|
||||
description
|
||||
"Policer to be applied for the mirrored traffic.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
129
src/sonic-yang-models/yang-templates/sonic-policer.yang.j2
Normal file
129
src/sonic-yang-models/yang-templates/sonic-policer.yang.j2
Normal file
@ -0,0 +1,129 @@
|
||||
{% if yang_model_type == "cvl" %}
|
||||
/* this is sonic cvl yang model */
|
||||
{% else %}
|
||||
/* this is sonic py yang model */
|
||||
{% endif %}
|
||||
module sonic-policer {
|
||||
|
||||
yang-version 1.1;
|
||||
|
||||
namespace "http://github.com/Azure/sonic-policer";
|
||||
prefix policer;
|
||||
|
||||
import sonic-types {
|
||||
prefix stypes;
|
||||
}
|
||||
|
||||
description "Policer YANG Module for SONiC OS";
|
||||
|
||||
revision 2022-02-03 {
|
||||
description
|
||||
"First Revision";
|
||||
}
|
||||
|
||||
container sonic-policer {
|
||||
container POLICER {
|
||||
list POLICER_LIST {
|
||||
key name;
|
||||
|
||||
leaf name {
|
||||
type string;
|
||||
description "Policer name";
|
||||
}
|
||||
|
||||
leaf meter_type {
|
||||
mandatory true;
|
||||
type stypes:meter_type;
|
||||
description "Policer meter type";
|
||||
}
|
||||
|
||||
leaf mode {
|
||||
mandatory true;
|
||||
type stypes:policer_mode;
|
||||
description "Policer mode";
|
||||
}
|
||||
|
||||
leaf color {
|
||||
type stypes:policer_color_source;
|
||||
description "Policer color Source";
|
||||
}
|
||||
|
||||
leaf cir {
|
||||
type uint64;
|
||||
default 0;
|
||||
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. Unit is bytes/sec
|
||||
or packets/sec based on meter_type";
|
||||
}
|
||||
|
||||
leaf cbs {
|
||||
must "((current()/../cir) and (current()/../cir > 0))" {
|
||||
error-message "cbs can't be configured without cir.";
|
||||
}
|
||||
must "(current() >= current()/../cir)" {
|
||||
error-message "cbs must be greater than or equal to cir";
|
||||
}
|
||||
type uint64;
|
||||
default 0;
|
||||
description
|
||||
"Committed burst size for the dual-rate token bucket
|
||||
policer. This value represents the depth of the token
|
||||
bucket. Unit is bytes or packets based on meter_type";
|
||||
}
|
||||
|
||||
leaf pir {
|
||||
when "current()/../mode = 'tr_tcm'";
|
||||
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 bytes/sec or
|
||||
packets/sec based on meter_type";
|
||||
}
|
||||
|
||||
leaf pbs {
|
||||
when "((current()/../mode = 'sr_tcm') or (current()/../mode = 'tr_tcm'))";
|
||||
must "((not(current()/../cbs)) or (current() >= current()/../cbs))" {
|
||||
error-message "pbs must be greater than or equal to cbs";
|
||||
}
|
||||
type uint64;
|
||||
description
|
||||
"Excess burst size for the dual-rate token bucket policer.
|
||||
This value represents the depth of the secondary bucket. Unit
|
||||
is bytes or packets based on meter_type";
|
||||
}
|
||||
|
||||
leaf green_packet_action {
|
||||
type stypes:policer_packet_action;
|
||||
default "forward";
|
||||
description "Green action";
|
||||
}
|
||||
|
||||
leaf yellow_packet_action {
|
||||
when "((current()/../mode = 'sr_tcm') or (current()/../mode = 'tr_tcm'))";
|
||||
type stypes:policer_packet_action;
|
||||
default "forward";
|
||||
description "Yellow action";
|
||||
}
|
||||
|
||||
leaf red_packet_action {
|
||||
type stypes:policer_packet_action;
|
||||
default "forward";
|
||||
description "Red action";
|
||||
}
|
||||
}
|
||||
/* end of list POLICER_LIST */
|
||||
}
|
||||
/* end of container POLICER */
|
||||
}
|
||||
/* end of top level container */
|
||||
}
|
||||
/* end of module sonic-policer */
|
@ -205,7 +205,23 @@ module sonic-types {
|
||||
}
|
||||
}
|
||||
|
||||
typedef copp_packet_action {
|
||||
typedef policer_mode {
|
||||
type enumeration {
|
||||
enum sr_tcm;
|
||||
enum tr_tcm;
|
||||
enum storm;
|
||||
}
|
||||
}
|
||||
|
||||
typedef policer_color_source {
|
||||
type enumeration {
|
||||
enum aware;
|
||||
enum blind;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef policer_packet_action {
|
||||
type enumeration {
|
||||
enum drop;
|
||||
enum forward;
|
||||
|
Loading…
Reference in New Issue
Block a user