HONEYCOMB-58 - Routing Api
[honeycomb.git] / v3po / api / src / main / yang / vpp-vlan.yang
1 module vpp-vlan {
2   yang-version 1;
3   namespace "urn:opendaylight:params:xml:ns:yang:vpp:vlan";
4   prefix "vpp-vlan";
5
6   revision "2016-12-14" {
7     description
8       "This revision adds the following new features:
9        - ingress/egress ACLs support";
10   }
11
12   revision "2015-05-27" {
13     description
14     "Initial revision of vlan model for VPP.
15      Reuses some concepts from draft-wilton-netmod-intf-vlan-yang-02 model.";
16   }
17
18   import ietf-interfaces {
19     prefix "if";
20   }
21   import ietf-inet-types {
22     prefix inet;
23   }
24   import ietf-yang-types {
25     prefix "yang";
26   }
27   import yang-ext {
28     prefix "ext";
29   }
30   import dot1q-types {
31     prefix dot1q;
32   }
33   import v3po {
34     prefix v3po;
35   }
36   import vpp-acl {
37     prefix vpp-acl;
38   }
39
40   typedef sub-interface-status {
41     type enumeration {
42       enum "up";
43       enum "down";
44     }
45   }
46
47   // todo add 802dot1ad support to dot1q-types.yang
48   /*
49    * Defines the supported IEEE 802.1Q types that can be used for
50    * VLAN tag matching.
51    */
52   identity vlan-type {
53     description "Base identity from which all VLAN types
54                  are derived from";
55   }
56
57   identity 802dot1q {
58     base vlan-type;
59     description
60       "An 802.1Q VLAN type";
61   }
62
63   identity 802dot1ad {
64     base vlan-type;
65     description
66       "An 802.1ad VLAN type";
67   }
68
69   typedef vlan-type {
70     type identityref {
71       base "vlan-type";
72     }
73     description "Identifies a specific VLAN type";
74   }
75
76   grouping match-attributes {
77     choice match-type {
78       mandatory true;
79       description "Provides a choice of how the frames may be matched";
80
81       case default {
82         description "Default match";
83         leaf default {
84           type empty;
85           description
86             "Default match.  Matches all traffic not matched to any
87              other peer sub-interface by a more specific
88              encapsulation.";
89         } // leaf default
90       } // case default
91
92       case untagged {
93         description "Match untagged Ethernet frames only";
94         leaf untagged {
95           type empty;
96             description
97               "Untagged match.  Matches all untagged traffic.";
98         } // leaf untagged
99       } // case untagged
100
101       case vlan-tagged {
102         container vlan-tagged {
103           description "Matches VLAN tagged frames. Vlan tags need to be specified to use this match type";
104
105           leaf match-exact-tags {
106             type boolean;
107             default true;
108             description
109               "If set, indicates that all 802.1Q VLAN tags in the
110                Ethernet frame header must be explicitly matched, i.e.
111                the EtherType following the matched tags must not be a
112                802.1Q tag EtherType.  If unset then extra 802.1Q VLAN
113                tags are allowed.";
114           }
115         } // container vlan-tagged
116       } // case vlan-tagged
117     }
118   }
119
120   // TODO VPP does not allow to change subinterface nor delete it (except for tag-rewrite operation)
121   grouping sub-interface-base-attributes {
122     leaf vlan-type {
123       type vlan-type;
124       default 802dot1q;
125     }
126
127     container tags {
128       list tag {
129         key "index";
130         max-elements 2;
131
132         description "The VLAN tags to use by locally sourced traffic";
133
134         leaf index {
135           type uint8 {
136             range "0..1";
137           }
138
139           /*
140            * Only allow a push of an inner tag if an outer tag is also
141            * being pushed.
142            */
143           must "index != 0 or
144                 count(../../push-tags[index = 0]/index) > 0" {
145             error-message "An inner tag can only be pushed if an outer
146                            tag is also specified";
147             description "Only allow a push of an inner tag if an outer
148                          tag is also being pushed";
149           }
150           description "The index into the tag stack";
151         }
152
153         uses dot1q:dot1q-tag-or-any;
154
155       }
156     }
157
158     container match {
159       description
160        "The match used to classify frames to this interface";
161       uses match-attributes;
162     }
163
164     container l2 {
165       uses v3po:l2-base-attributes;
166       container rewrite {
167         uses tag-rewrite;
168       }
169     }
170
171     container acl {
172       container ingress {
173         uses vpp-acl:acl-base-attributes;
174       }
175       container egress {
176         uses vpp-acl:acl-base-attributes;
177       }
178     }
179
180     container ietf-acl {
181       container ingress {
182         uses vpp-acl:ietf-acl-base-attributes;
183       }
184       container egress {
185         uses vpp-acl:ietf-acl-base-attributes;
186       }
187     }
188   }
189
190   grouping sub-interface-config-attributes {
191     leaf enabled {
192       type boolean;
193       default "false";
194       description
195         "Contains the configured, desired state of the sub-interface.
196         To enable sub-interface, the super inerface needs to be enabled";
197     }
198   }
199
200   grouping sub-interface-operational-attributes {
201     leaf admin-status {
202       type sub-interface-status;
203       mandatory true;
204     }
205     leaf oper-status {
206       type sub-interface-status;
207       mandatory true;
208     }
209     leaf if-index {
210       type int32 {
211         range "1..2147483647";
212       }
213       mandatory true;
214     }
215     leaf phys-address {
216       type yang:phys-address;
217       description
218         "The sub-interface's Media Access Control (MAC) address.";
219     }
220     leaf speed {
221       type yang:gauge64;
222       units "bits/second";
223     }
224   }
225
226   /*
227    * Only symetrical rewrite is supported
228    */
229   grouping tag-rewrite {
230     description "Flexible rewrite";
231
232     leaf vlan-type { // todo rename to push_dot1q, mandatory(?) with default true
233       type vlan-type;
234       default 802dot1q;
235     }
236
237     leaf pop-tags {
238       type uint8 {
239         range 1..2;
240       }
241       description "The number of tags to pop (or translate if used in
242                    conjunction with push-tags)";
243     }
244
245     list push-tags {
246       key "index";
247       max-elements 2;
248       description "The number of tags to push (or translate if used
249                    in conjunction with pop-tags)";
250       /*
251        * Server should order by increasing index.
252        */
253       leaf index {
254         type uint8 {
255           range 0..1;
256         }
257
258         /*
259          * Only allow a push of an inner tag if an outer tag is also
260          * being pushed.
261          */
262         must "index != 0 or
263               count(../../push-tags[index = 0]/index) > 0" {
264           error-message "An inner tag can only be pushed if an outer
265                          tag is also specified";
266           description "Only allow a push of an inner tag if an outer
267                        tag is also being pushed";
268         }
269       }
270
271       uses dot1q:dot1q-tag;
272     }
273   }
274
275   grouping sub-interface-ip4-attributes {
276     container ipv4 {
277       // TODO: add currently unsupported:
278       // enabled, forwarding, mtu, address/origin(config false), neighbor/origin(config false)
279
280       // TODO: reuse groupings once ietf-ip provides them
281
282       description
283         "Parameters for the IPv4 address family (based on ietf-ip rev. 2014-06-16)";
284
285       list address {
286         key "ip";
287         description
288           "The list of configured IPv4 addresses on the interface.";
289         leaf ip {
290           type inet:ipv4-address-no-zone;
291           description
292             "The IPv4 address on the interface.";
293         }
294
295         choice subnet {
296           mandatory true;
297           description
298             "The subnet can be specified as a prefix-length, or,
299              if the server supports non-contiguous netmasks, as
300              a netmask.";
301           leaf prefix-length {
302             type uint8 {
303               range "0..32";
304             }
305             description
306               "The length of the subnet prefix.";
307           }
308           leaf netmask {
309             type yang:dotted-quad;
310             description
311               "The subnet specified as a netmask (contiguous)";
312           }
313         }  // choice subnet
314       }  // list address
315
316       list neighbor {
317         key "ip";
318         description
319           "A list of mappings from IPv4 addresses to
320           link-layer addresses.
321
322           Entries in this list are used as static entries in the
323           ARP Cache.";
324         reference
325           "RFC 826: An Ethernet Address Resolution Protocol";
326
327         leaf ip {
328           type inet:ipv4-address-no-zone;
329           description
330             "The IPv4 address of the neighbor node.";
331         }
332
333         leaf link-layer-address {
334           type yang:phys-address;
335           mandatory true;
336           description
337             "The link-layer address of the neighbor node.";
338         }
339       }  // list neighbor
340     }
341   }
342
343   grouping sub-interface-ip6-attributes {
344     container ipv6 {
345       // TODO: add currently unsupported:
346       // enabled, forwarding, mtu, neighbor, dup-addr-detect-transmits, autoconf,
347       // address(config false): origin, status
348       // neighbor(config false): origin, is-router, state
349
350       // TODO: reuse groupings once ietf-ip provides them
351
352       description
353         "Parameters for the IPv6 address family (based on ietf-ip rev. 2014-06-16)";
354
355       list address {
356         key "ip";
357         description
358           "The list of configured IPv6 addresses on the interface.";
359         leaf ip {
360           type inet:ipv6-address-no-zone;
361           description
362             "The IPv6 address on the interface.";
363         }
364
365         leaf prefix-length {
366           type uint8 {
367             range "0..128";
368           }
369           mandatory true;
370           description
371             "The length of the subnet prefix.";
372         }
373       }  // list address
374
375       list neighbor {
376         key "ip";
377         description
378           "A list of mappings from IPv6 addresses to
379         link-layer addresses.
380
381         Entries in this list are used as static entries in the
382         Neighbor Cache.";
383         reference
384           "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)";
385
386         leaf ip {
387           type inet:ipv6-address-no-zone;
388           description
389             "The IPv6 address of the neighbor node.";
390         }
391
392         leaf link-layer-address {
393           type yang:phys-address;
394           mandatory true;
395           description
396             "The link-layer address of the neighbor node.";
397         }
398       }  // list neighbor
399     }
400   }
401
402   augment /if:interfaces/if:interface {
403     ext:augment-identifier "subinterface-augmentation";
404
405     container sub-interfaces {
406       description "L2 vlan subinterfaces";
407
408
409       list sub-interface {
410         key "identifier";
411         leaf identifier {
412           type uint32;
413         }
414
415         uses sub-interface-base-attributes;
416         uses sub-interface-config-attributes;
417         uses sub-interface-ip4-attributes;
418         uses sub-interface-ip6-attributes;
419       }
420     }
421   }
422
423   augment /if:interfaces-state/if:interface {
424     ext:augment-identifier "subinterface-state-augmentation";
425
426     container sub-interfaces {
427       description "L2 vlan subinterfaces";
428
429       list sub-interface {
430         key "identifier";
431         leaf identifier {
432           type uint32;
433         }
434
435         uses sub-interface-base-attributes;
436         uses sub-interface-operational-attributes;
437         uses sub-interface-ip4-attributes;
438         uses sub-interface-ip6-attributes;
439       }
440     }
441   }
442
443 }