diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2016-07-13 08:46:56 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-07-14 10:53:40 +0200 |
commit | 5fc7ae574e71ac326521d3fe8860f38604bedf53 (patch) | |
tree | 8ffcd6c90b0359112e3b75adf9b34e6f4fa6f8b3 | |
parent | 632055ae0e29d16b831519b095b5c34dd430e19c (diff) |
HONEYCOMB-49: VPP classifier model. Initial version
Change-Id: I8dbd22657c1cd1c9dfc45ca130015b5b3dbffee1
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
4 files changed, 255 insertions, 0 deletions
diff --git a/v3po/api/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpp/classifier/rev150603/OpaqueIndexBuilder.java b/v3po/api/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpp/classifier/rev150603/OpaqueIndexBuilder.java new file mode 100644 index 000000000..01f088469 --- /dev/null +++ b/v3po/api/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpp/classifier/rev150603/OpaqueIndexBuilder.java @@ -0,0 +1,24 @@ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603; + + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +public class OpaqueIndexBuilder { + + public static OpaqueIndex getDefaultInstance(java.lang.String defaultValue) { + try { + final long value = Long.parseLong(defaultValue); // u32 value + return new OpaqueIndex(value); + } catch (NumberFormatException e) { + return new OpaqueIndex(VppNodeBuilder.getDefaultInstance(defaultValue)); + } + } + +} diff --git a/v3po/api/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpp/classifier/rev150603/VppNodeBuilder.java b/v3po/api/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpp/classifier/rev150603/VppNodeBuilder.java new file mode 100644 index 000000000..dd37bbe84 --- /dev/null +++ b/v3po/api/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpp/classifier/rev150603/VppNodeBuilder.java @@ -0,0 +1,25 @@ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603; + + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +public class VppNodeBuilder { + + public static VppNode getDefaultInstance(java.lang.String defaultValue) { + if (PacketHandlingAction.Deny.toString().equalsIgnoreCase(defaultValue)) { + return new VppNode(PacketHandlingAction.Deny); + } else if (PacketHandlingAction.Permit.toString().equalsIgnoreCase(defaultValue)) { + return new VppNode(PacketHandlingAction.Permit); + } else { + throw new IllegalArgumentException(String.format("Could not parse VppNode: %s", defaultValue)); + } + } + +} diff --git a/v3po/api/src/main/yang/v3po.yang b/v3po/api/src/main/yang/v3po.yang index ce2999364..5d582181f 100644 --- a/v3po/api/src/main/yang/v3po.yang +++ b/v3po/api/src/main/yang/v3po.yang @@ -25,6 +25,9 @@ module v3po { import yang-ext { prefix "ext"; } + import vpp-classifier { + prefix "vpp-classifier"; + } typedef bridge-domain-ref { type leafref { @@ -357,6 +360,33 @@ module v3po { } } + grouping acl-base-attributes { + description + "Defines references to classify tables. + At least one table reference should be specified."; + container l2-acl { + leaf classify-table { + type vpp-classifier:classify-table-ref; + description + "An L2 ACL table"; + } + } + container ip4-acl { + leaf classify-table { + type vpp-classifier:classify-table-ref; + description + "An IPv4 ACL table"; + } + } + container ip6-acl { + leaf classify-table { + type vpp-classifier:classify-table-ref; + description + "An IPv6 ACL table"; + } + } + } + augment /if:interfaces/if:interface { ext:augment-identifier "vpp-interface-augmentation"; @@ -405,6 +435,10 @@ module v3po { uses vxlan-gpe-base-attributes; } + + container acl { + uses acl-base-attributes; + } } container vpp { @@ -468,6 +502,10 @@ module v3po { uses l2-base-attributes; } + + container acl { + uses acl-base-attributes; + } } augment /if:interfaces-state/if:interface/if:statistics { diff --git a/v3po/api/src/main/yang/vpp-classifier.yang b/v3po/api/src/main/yang/vpp-classifier.yang new file mode 100644 index 000000000..0ba94f1cb --- /dev/null +++ b/v3po/api/src/main/yang/vpp-classifier.yang @@ -0,0 +1,168 @@ +module vpp-classifier { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:vpp:classifier"; + prefix "vpp-classifier"; + + revision "2015-06-03" { + description + "Initial revision of model for VPP packet classifier. + The model can be used ony to implement ACLs. + Other classify table usages are not supported yet, + see https://jira.fd.io/browse/VPP-203 for details."; + reference + "https://wiki.fd.io/view/VPP/Introduction_To_N-tuple_Classifiers"; + } + + import ietf-yang-types { + prefix "yang"; + } + + typedef classify-table-ref { + type leafref { + path "/vpp-classifier:vpp-classifier/classify-table/name"; + } + description + "This type is used by data models that need to reference + configured classify tables."; + } + + typedef packet-handling-action { + type enumeration { + enum "deny" { + // by VPP convention, first neighbour node (at index 0) is a drop node + value 0; + } + enum "permit" { + value -1; // indicates that the next node not set + } + } + } + + typedef vpp-node { + type union { + // FIXME: enable after VPP-203 is fixed + // type string; // name of vpp-node neighbour, TODO: base node also needs to be defined + type packet-handling-action; + } + description + "Defines VPP node reference using relative node name or packet handling action."; + } + + typedef opaque-index { + type union { + type vpp-node; + type uint32; + } + description + "Defines opaque-index type - metadata that can be attached to session-hit packets. + Vpp nodes can't be referenced by index, because node indexes might change after vpp restart."; + } + + grouping classify-session-attributes { + description + "Defines classify session attributes that are mapped to classify_add_del_session + and classify_session_details messages parameters."; + + leaf hit_next_index { + type vpp-node; + mandatory true; + description + "Vpp node to which packet will be send when it produces a match."; + } + leaf opaque_index { + type opaque-index; + } + leaf advance { + type int32; + default 0; + description + "Nodes like ip4/6-classify use the parameter to \"consume\" networking layer. + Example: tunnel decapsulation."; + } + } + + grouping classify-table-attributes { + description + "Defines classify table attributes that are mapped to classify_add_del_table + and classify_table_info_reply messages parameters."; + + leaf nbuckets { + mandatory true; + type uint32; + description + "Used by classifier hashing algorithm. It is not possible to resize the bucket array, + therefore suggested value is approximate number of expected entries."; + } + leaf memory_size { + mandatory true; + type uint32; + description + "Memory size for classify table and its entries."; + } + leaf skip_n_vectors { + type uint32; + default 0; + description + "Number of 16 byte vectors to be skipped before applying mask."; + } + leaf next_table { + type classify-table-ref; + description + "Reference to the next classify table. Required when multiple table chaining is used."; + } + leaf miss_next_index { + mandatory true; + type vpp-node; + description + "Vpp node to which packet will be send when it falis to produce a match"; + } + leaf mask { + type yang:hex-string; + mandatory true; + description + "Defines match mask (multiple of 16 bytes)"; + } + leaf active_sessions { + type uint32; + mandatory true; + config false; + description + "Number of sessions defined for the classify table."; + } + + list classify-session { + key "match"; + + leaf match { + type yang:hex-string; + description + "Defines actual value to be matched that is + a byte vector, which length is multiple of 16 bytes"; + + must "string-length(match) = string-length(../../mask)" { + error-message + "Match length is not equal to classify table mask length."; + description + "Match length must be equal to classify table mask length."; + } + } + + uses classify-session-attributes; + } + } + + container vpp-classifier { + list classify-table { + key "name"; + + leaf name { + type string; + description + "Hides classify table identifier managed by vpp."; + } + + uses classify-table-attributes; + } + } + +} |