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