summaryrefslogtreecommitdiffstats
path: root/vpp-classifier
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-02-27 07:39:22 +0100
committerMarek Gradzki <mgradzki@cisco.com>2017-03-14 14:31:10 +0100
commite7903be79d4451f5b6e6f633b7ea20f8330ac0c1 (patch)
tree3a6c129ba19b30fc0ef21deebc2bc225b8992095 /vpp-classifier
parentb54f6dc31761d4a2f9d951fc551b11d9047eac56 (diff)
HC2VPP-39: yang model for policer configuration in VPP
Change-Id: I6c84c5fb85e2a4073a7a885db390b08a6582639d Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-classifier')
-rw-r--r--vpp-classifier/api/src/main/yang/interface-policer.yang61
-rw-r--r--vpp-classifier/api/src/main/yang/policer.yang284
-rw-r--r--vpp-classifier/api/src/main/yang/vpp-classifier.yang38
-rw-r--r--vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/read/ClassifySessionReader.java9
-rw-r--r--vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriter.java6
-rw-r--r--vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java8
6 files changed, 392 insertions, 14 deletions
diff --git a/vpp-classifier/api/src/main/yang/interface-policer.yang b/vpp-classifier/api/src/main/yang/interface-policer.yang
new file mode 100644
index 000000000..d92faa9bf
--- /dev/null
+++ b/vpp-classifier/api/src/main/yang/interface-policer.yang
@@ -0,0 +1,61 @@
+module interface-policer {
+
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:interface:policer";
+ prefix "ifc-policer";
+
+ description
+ "This YANG module defines policer configuration and
+ operational data for interfaces in VPP.
+ Mapped to policer_classify_set_interface:
+ https://git.fd.io/vpp/tree/src/vnet/classify/classify.api#n119";
+
+ revision "2017-03-15" {
+ description "Initial revision of policer model";
+ }
+
+ import vpp-classifier {
+ prefix "vpp-classifier";
+ }
+
+ import ietf-interfaces {
+ prefix "if";
+ }
+
+ import yang-ext {
+ prefix "ext";
+ }
+
+ grouping interface-policer-attributes {
+ description
+ "Defines references to policer classify tables.
+ At least one table reference should be specified.";
+ leaf l2-table {
+ type vpp-classifier:classify-table-ref;
+ description
+ "An L2 policer table";
+ }
+ leaf ip4-table {
+ type vpp-classifier:classify-table-ref;
+ description
+ "An IPv4 policer table";
+ }
+ leaf ip6-table {
+ type vpp-classifier:classify-table-ref;
+ description
+ "An IPv6 policer table";
+ }
+ }
+
+ augment /if:interfaces/if:interface {
+ ext:augment-identifier "policer-interface-augmentation";
+
+ uses interface-policer-attributes;
+ }
+
+ augment /if:interfaces-state/if:interface {
+ ext:augment-identifier "policer-interface-state-augmentation";
+
+ uses interface-policer-attributes;
+ }
+} \ No newline at end of file
diff --git a/vpp-classifier/api/src/main/yang/policer.yang b/vpp-classifier/api/src/main/yang/policer.yang
new file mode 100644
index 000000000..1f730b6a5
--- /dev/null
+++ b/vpp-classifier/api/src/main/yang/policer.yang
@@ -0,0 +1,284 @@
+module policer {
+
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:policer";
+ prefix "policer";
+
+ description
+ "VPP specific configuration of policer messages. Mapped to policer API:
+ https://git.fd.io/vpp/tree/src/vnet/policer/policer.api
+
+ Partially based on
+ https://tools.ietf.org/html/draft-asechoud-netmod-qos-model-02";
+
+ reference
+ "https://docs.fd.io/vpp/17.04/clicmd_src_vnet_policer.html";
+
+ revision "2017-03-15" {
+ description "Initial revision of policer model";
+ }
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ typedef policer-ref {
+ type leafref {
+ path "/policers/policer/name";
+ }
+ description
+ "This type is used by data models that need to reference
+ configured policer.";
+ }
+
+ typedef color-classfier {
+ type enumeration {
+ enum conform-color;
+ enum exceed-color;
+ }
+ default conform-color;
+ }
+
+ typedef meter-type {
+ type enumeration {
+ enum 1r2c;
+ enum 1r3c;
+ enum 2r3c-2698;
+ enum 2r3c-4115;
+ enum 2r3c-mef5cf1;
+ }
+ default 1r2c;
+ }
+
+ typedef policer-round-type {
+ type enumeration {
+ enum closest;
+ enum up;
+ enum down;
+ }
+ default closest;
+ }
+
+ typedef policer-rate-type {
+ type enumeration {
+ enum kbps;
+ enum pps;
+ }
+ default kbps;
+ }
+
+ // adapted from draft-asechoud-netmod-qos-model-02
+ identity meter-action-type {
+ description
+ "action type in a meter";
+ }
+
+ identity meter-action-drop {
+ base meter-action-type;
+ description
+ "drop action type in a meter";
+ }
+
+ identity meter-action-mark-dscp {
+ base meter-action-type;
+ description
+ "dscp mark and transmit action type in a meter";
+ }
+
+ identity meter-action-transmit {
+ base meter-action-type;
+ description
+ "transmit action type in a meter";
+ }
+
+ typedef vpp-dcsp-type {
+ description
+ "DSCP field values supported by VPP";
+ type enumeration {
+ enum CS0 {
+ value 0;
+ }
+ enum CS1 {
+ value 8;
+ }
+ enum AF11 {
+ value 10;
+ }
+ enum AF12 {
+ value 12;
+ }
+ enum AF13 {
+ value 14;
+ }
+ enum CS2 {
+ value 16;
+ }
+ enum AF21 {
+ value 18;
+ }
+ enum AF22 {
+ value 20;
+ }
+ enum AF23 {
+ value 22;
+ }
+ enum CS3 {
+ value 24;
+ }
+ enum AF31 {
+ value 26;
+ }
+ enum AF32 {
+ value 28;
+ }
+ enum AF33 {
+ value 30;
+ }
+ enum CS4 {
+ value 32;
+ }
+ enum AF41 {
+ value 34;
+ }
+ enum AF42 {
+ value 36;
+ }
+ enum AF43 {
+ value 38;
+ }
+ enum CS5 {
+ value 40;
+ }
+ enum EF {
+ value 46;
+ }
+ enum CS6 {
+ value 48;
+ }
+ enum CS7 {
+ value 50;
+ }
+ }
+ default CS0;
+ }
+
+ typedef dcsp-type {
+ type union {
+ type vpp-dcsp-type;
+ type inet:dscp;
+ }
+ }
+
+ grouping meter-action-params {
+ description
+ "meter action parameters";
+ leaf meter-action-type {
+ mandatory true;
+ type identityref {
+ base meter-action-type;
+ }
+ description
+ "meter action type";
+ }
+ leaf dscp {
+ when "../meter-action-type = meter-action-mark-dscp";
+ type dcsp-type;
+ description
+ "dscp marking";
+ }
+ }
+
+ grouping policer-base-attributes {
+ leaf cir {
+ type uint32;
+ }
+ leaf eir {
+ type uint32;
+ }
+ leaf cb {
+ type uint64;
+ description "Committed Burst";
+ }
+ leaf eb {
+ type uint64;
+ description "Excess or Peak Bursnatt";
+ }
+ leaf rate-type {
+ type policer-rate-type;
+ }
+ leaf round-type {
+ type policer-round-type;
+ }
+ leaf type {
+ type meter-type;
+ description "policer algorithm";
+ }
+ leaf color-aware {
+ type boolean;
+ }
+ container conform-action {
+ uses meter-action-params;
+ }
+ container exceed-action {
+ uses meter-action-params;
+ }
+ container violate-action {
+ uses meter-action-params;
+ }
+ }
+
+ grouping policer-operational-attributes {
+ leaf single-rate {
+ type boolean;
+ }
+ leaf scale {
+ type uint32;
+ }
+ leaf cir-tokens-per-period {
+ type uint32;
+ }
+ leaf pir_tokens-per-period {
+ type uint32;
+ }
+ leaf current-limit {
+ type uint32;
+ }
+ leaf current-bucket {
+ type uint32;
+ }
+ leaf extended-limit {
+ type uint32;
+ }
+ leaf extended-bucket {
+ type uint32;
+ }
+ leaf last-update-time {
+ type uint64;
+ }
+ }
+
+ container policers {
+ list policer {
+ key name;
+ leaf name {
+ type string {
+ length 1..63;
+ }
+ }
+ uses policer-base-attributes;
+ }
+ }
+
+ container policers-state {
+ list policer {
+ key name;
+ leaf name {
+ type string {
+ length 1..63;
+ }
+ }
+ uses policer-base-attributes;
+ uses policer-operational-attributes;
+ }
+ }
+}
diff --git a/vpp-classifier/api/src/main/yang/vpp-classifier.yang b/vpp-classifier/api/src/main/yang/vpp-classifier.yang
index beb4def85..c1aa1794c 100644
--- a/vpp-classifier/api/src/main/yang/vpp-classifier.yang
+++ b/vpp-classifier/api/src/main/yang/vpp-classifier.yang
@@ -19,10 +19,16 @@ module vpp-classifier {
"https://wiki.fd.io/view/VPP/Introduction_To_N-tuple_Classifiers";
}
+ // TODO add revision (policer inclusion)
+
import ietf-yang-types {
prefix "yang";
}
+ import policer {
+ prefix "policer";
+ }
+
typedef classify-table-ref {
type leafref {
path "/vpp-classifier:vpp-classifier/classify-table/name";
@@ -71,17 +77,35 @@ module vpp-classifier {
grouping classify-session-attributes {
description
"Defines classify session attributes that are mapped to classify_add_del_session
- and classify_session_details messages parameters.";
+ and classify_session_details messages parameters.
+ Either hit_next or policer_hit_next should be defined.";
- leaf hit_next {
- type vpp-node;
+ choice next_node {
mandatory true;
description
- "Vpp node to which packet will be send when it produces a match.";
- }
- leaf opaque_index {
- type opaque-index;
+ "Options for expressing the next node on classify hit and associated metadata to be passed";
+ case standard {
+ leaf hit_next {
+ mandatory true;
+ type vpp-node;
+ description
+ "Vpp node to which packet will be send when it produces a match.";
+ }
+ leaf opaque_index {
+ type opaque-index;
+ }
+ }
+ case policer {
+ leaf policer_hit_next {
+ mandatory true;
+ type policer:policer-ref;
+ }
+ leaf color_classfier {
+ type policer:color-classfier;
+ }
+ }
}
+
leaf advance {
type int32;
default 0;
diff --git a/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/read/ClassifySessionReader.java b/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/read/ClassifySessionReader.java
index 4b985538e..e30a56615 100644
--- a/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/read/ClassifySessionReader.java
+++ b/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/read/ClassifySessionReader.java
@@ -44,6 +44,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.OpaqueIndex;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppNodeName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.session.attributes.next_node.StandardBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySession;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySessionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySessionKey;
@@ -105,15 +106,17 @@ public class ClassifySessionReader extends FutureJVppCustomizer
final ClassifySessionDetails detail = classifySession.get();
final Optional<VppNode> node =
readVppNode(detail.tableId, detail.hitNextIndex, classifyTableContext, ctx.getMappingContext(), LOG);
+ final StandardBuilder nextNode = new StandardBuilder();
if (node.isPresent()) {
- builder.setHitNext(node.get());
+ nextNode.setHitNext(node.get());
} else {
- builder.setHitNext(new VppNode(new VppNodeName("unknown"))); // TODO(HC2VPP-9): remove this workaround
+ nextNode.setHitNext(new VppNode(new VppNodeName("unknown")));
}
if (detail.opaqueIndex != ~0) {
// value is specified:
- builder.setOpaqueIndex(readOpaqueIndex(detail.tableId, detail.opaqueIndex, ctx.getMappingContext()));
+ nextNode.setOpaqueIndex(readOpaqueIndex(detail.tableId, detail.opaqueIndex, ctx.getMappingContext()));
}
+ builder.setNextNode(nextNode.build());
builder.setAdvance(detail.advance);
builder.setMatch(key.getMatch());
diff --git a/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriter.java b/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriter.java
index 00e858955..8b1db57b7 100644
--- a/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriter.java
+++ b/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriter.java
@@ -36,6 +36,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.DatatypeConverter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.OpaqueIndex;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.session.attributes.next_node.Standard;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySession;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySessionKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.vpp.classifier.ClassifyTable;
@@ -108,10 +109,11 @@ public class ClassifySessionWriter extends VppNodeWriter
final ClassifyTable classifyTable =
getClassifyTable(writeContext, id.firstIdentifierOf(ClassifyTable.class), isAdd);
- final int hitNextIndex = getNodeIndex(classifySession.getHitNext(), classifyTable, classifyTableContext,
+ final int hitNextIndex = getNodeIndex(((Standard)classifySession.getNextNode()).getHitNext(),
+ classifyTable, classifyTableContext,
writeContext.getMappingContext(), id);
final int opaqueIndex =
- getOpaqueIndex(classifySession.getOpaqueIndex(), classifyTable, writeContext.getMappingContext(), id);
+ getOpaqueIndex(((Standard)classifySession.getNextNode()).getOpaqueIndex(), classifyTable, writeContext.getMappingContext(), id);
final CompletionStage<ClassifyAddDelSessionReply> createClassifyTableReplyCompletionStage = getFutureJVpp()
.classifyAddDelSession(
diff --git a/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java b/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java
index 49e172fac..abc3901b6 100644
--- a/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java
+++ b/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java
@@ -39,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.clas
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppClassifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppNodeName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.session.attributes.next_node.StandardBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySession;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySessionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySessionKey;
@@ -57,8 +58,11 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest {
private static ClassifySession generateClassifySession(final long opaqueIndex, final String match) {
final ClassifySessionBuilder builder = new ClassifySessionBuilder();
- builder.setOpaqueIndex(new OpaqueIndex(opaqueIndex));
- builder.setHitNext(new VppNode(PacketHandlingAction.Deny));
+ builder.setNextNode(
+ new StandardBuilder()
+ .setOpaqueIndex(new OpaqueIndex(opaqueIndex))
+ .setHitNext(new VppNode(PacketHandlingAction.Deny))
+ .build());
builder.setAdvance(123);
builder.setMatch(new HexString(match));
return builder.build();