SONiC Yang model support for COPP (#7199)

* SONiC Yang model support for COPP
* Tables: COPP_GROUP, COPP_TRAP.
This commit is contained in:
Aravindu Maneti 2021-06-29 22:09:08 +05:30 committed by GitHub
parent 9de7e6860b
commit 5acf2348ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 406 additions and 1 deletions

View File

@ -47,6 +47,7 @@ setup(
'./yang-models/sonic-bgp-neighbor.yang',
'./yang-models/sonic-bgp-peergroup.yang',
'./yang-models/sonic-breakout_cfg.yang',
'./yang-models/sonic-copp.yang',
'./yang-models/sonic-crm.yang',
'./yang-models/sonic-device_metadata.yang',
'./yang-models/sonic-device_neighbor.yang',

View File

@ -841,7 +841,6 @@
"local_ip": "12.12.0.2"
}
},
"BGP_GLOBALS": {
"default": {
"router_id": "5.5.5.5",
@ -907,6 +906,24 @@
"PREFIX": {
"prefix1|1|10.0.0.0/8|8..16": {
}
},
"COPP_GROUP": {
"queue1_group1": {
"queue": "1",
"trap_priority":"1",
"trap_action":"trap",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"6000",
"cbs":"6000",
"red_action":"drop"
}
},
"COPP_TRAP": {
"ip2me": {
"trap_ids": "ip2me",
"trap_group": "queue1_group1"
}
}
},

View File

@ -0,0 +1,29 @@
{
"COPP_TRAP_WITH_EXIST_GROUP": {
"desc": "Configure COPP_TRAP with group in COPP_GROUP table."
},
"COPP_TRAP_WITH_NON_EXIST_GROUP": {
"desc": "Configure COPP_TRAP with group which does not exist in COPP_GROUP table.",
"eStrKey" : "LeafRef"
},
"COPP_GROUP_MANDATORY_TRAP_ACTION": {
"desc": "Configure COPP_GROUP with no trap_action.",
"eStrKey" : "Mandatory"
},
"COPP_GROUP_MANDATORY_METER_TYPE": {
"desc": "Configure COPP_GROUP with no meter_type.",
"eStrKey" : "Mandatory"
},
"COPP_GROUP_PIR_LESS_THAN_CIR": {
"desc": "Configure COPP_GROUP with PIR less than CIR.",
"eStr": ["pir must be greater than or equal to cir"]
},
"COPP_TRAP_MANDATORY_TRAP_IDS": {
"desc": "Configure COPP_TRAP with no trap_ids.",
"eStrKey" : "Mandatory"
},
"COPP_GROUP_WHEN_SRTCM_WITH_PIR": {
"desc": "Configure COPP_GROUP with srtcm and pir.",
"eStrKey" : "When"
}
}

View File

@ -0,0 +1,147 @@
{
"COPP_TRAP_WITH_EXIST_GROUP": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue1_group1",
"trap_action":"trap",
"trap_priority":"1",
"queue": "1",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"6000",
"cbs":"6000",
"red_action":"drop"
}]
},
"sonic-copp:COPP_TRAP": {
"COPP_TRAP_LIST": [{
"name": "ip2me",
"trap_ids": "ip2me",
"trap_group": "queue1_group1"
}]
}
}
},
"COPP_TRAP_WITH_NON_EXIST_GROUP": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue2_group2",
"trap_action":"trap",
"trap_priority":"2",
"queue": "2",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"5000",
"cbs":"5000",
"red_action":"drop"
}]
},
"sonic-copp:COPP_TRAP": {
"COPP_TRAP_LIST": [{
"name": "udld",
"trap_ids": "udld",
"trap_group": "queue3_group3"
}]
}
}
},
"COPP_GROUP_MANDATORY_TRAP_ACTION": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue3_group4",
"trap_priority":"3",
"queue": "3",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"5000",
"cbs":"5000",
"red_action":"drop"
}]
}
}
},
"COPP_GROUP_MANDATORY_METER_TYPE": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue4_group5",
"trap_action":"trap",
"trap_priority":"4",
"queue": "4",
"mode":"sr_tcm",
"cir":"5000",
"cbs":"5000",
"red_action":"drop"
}]
}
}
},
"COPP_GROUP_PIR_LESS_THAN_CIR": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue5_group6",
"trap_action":"trap",
"trap_priority":"5",
"queue": "5",
"mode":"tr_tcm",
"cir":"5000",
"cbs":"5000",
"pir":"4000",
"pbs":"4000",
"red_action":"drop"
}]
}
}
},
"COPP_TRAP_MANDATORY_TRAP_IDS": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue6_group7",
"trap_action":"trap",
"trap_priority":"6",
"queue": "6",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"6000",
"cbs":"6000",
"red_action":"drop"
}]
},
"sonic-copp:COPP_TRAP": {
"COPP_TRAP_LIST": [{
"name": "bgp",
"trap_group": "queue6_group7"
}]
}
}
},
"COPP_GROUP_WHEN_SRTCM_WITH_PIR": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue6_group7",
"trap_action":"trap",
"trap_priority":"6",
"queue": "6",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"6000",
"cbs":"6000",
"pir":"6000",
"red_action":"drop"
}]
}
}
}
}

View File

@ -0,0 +1,191 @@
module sonic-copp {
yang-version 1.1;
namespace "http://github.com/Azure/sonic-copp";
prefix copp;
import sonic-types {
prefix stypes;
}
description "CoPP YANG Module for SONiC OS";
revision 2021-03-31 {
description
"First Revision";
}
container sonic-copp {
container COPP_GROUP {
list COPP_GROUP_LIST {
key name;
leaf name {
type string;
description "Control plane policing group name";
}
leaf queue {
type uint32;
default 0;
description "CPU Rx queue id";
}
leaf trap_priority {
type uint32;
default 0;
description "Trap priority";
}
leaf trap_action {
mandatory true;
type stypes:copp_packet_action;
description "Trap action";
}
leaf meter_type {
mandatory true;
type stypes:meter_type;
description "Policer meter type";
}
leaf mode {
mandatory true;
type enumeration {
enum sr_tcm;
enum tr_tcm;
enum storm;
}
description "Policer mode";
}
leaf color {
type enumeration {
enum blind;
enum color;
}
default "color";
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.";
}
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.";
}
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.";
}
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.";
}
leaf green_action {
type stypes:copp_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;
default "forward";
description "Yellow action";
}
leaf red_action {
type stypes:copp_packet_action;
default "forward";
description "Red action";
}
}
/* end of list COPP_GROUP_LIST */
}
/* end of container COPP_GROUP */
container COPP_TRAP {
list COPP_TRAP_LIST {
key name;
leaf name {
type string;
description "Control plane policing trap name";
}
leaf trap_ids {
mandatory true;
type string;
description "list of trap_ids";
}
leaf trap_group {
type leafref {
path "/sonic-copp/COPP_GROUP/COPP_GROUP_LIST/name";
}
description "reference to CoPP group";
}
}
/* end of list COPP_TRAP_LIST */
}
/* end of container COPP_TRAP */
}
/* end of top level container */
rpc get-match-protocols {
description
"RPC to get allowed match protocols";
output {
list Match_protocols {
key "Protocol";
leaf Protocol {
type string;
description
"Protocol name";
}
}
}
}
/* end of rpc get-match-protocols */
}
/* end of module sonic-copp */

View File

@ -159,4 +159,24 @@ module sonic-types {
pattern "0x8100|0x9100|0x9200|0x88a8|0x88A8";
}
}
typedef meter_type {
type enumeration {
enum packets;
enum bytes;
}
}
typedef copp_packet_action {
type enumeration {
enum drop;
enum forward;
enum copy;
enum copy_cancel;
enum trap;
enum log;
enum deny;
enum transit;
}
}
}