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