Remove artificial limit on the maximum number of bridge-domains
[honeycomb.git] / v3po / api / src / main / yang / v3po.yang
1 module v3po {
2   yang-version 1;
3   namespace "urn:opendaylight:params:xml:ns:yang:v3po";
4   prefix "v3po";
5
6   revision "2015-01-05" {
7     description "Initial revision of v3po model";
8   }
9
10   import iana-if-type {
11     prefix "ianaift";
12   }
13   import ietf-interfaces {
14     prefix "if";
15   }
16   import ietf-yang-types {
17     prefix "yang";
18   }
19   import ietf-inet-types {
20     prefix "inet";
21   }
22   import ietf-ip {
23     prefix "ip";
24   }
25   import yang-ext {
26     prefix "ext";
27   }
28
29   typedef bridge-domain-ref {
30     type leafref {
31       path "/vpp/bridge-domains/bridge-domain/name";
32     }
33     description
34       "This type is used by to reference a bridge domain table";
35   }
36
37   typedef bridged-virtual-interface-ref {
38     type leafref {
39       path "/if:interfaces/if:interface/l2/bridged-virtual-interface";
40     }
41     description
42       "This type is used by to reference a bridged virtual interface";
43   }
44
45   identity vxlan-tunnel {
46     base if:interface-type;
47   }
48
49   identity vhost-user {
50     base if:interface-type;
51   }
52
53   identity tap {
54     base if:interface-type;
55   }
56
57   typedef vxlan-vni {
58     // FIXME: should be in a vxlan-specific model
59     description "VNI used in a VXLAN tunnel";
60     type uint32 {
61       range "0..16777215";
62     }
63   }
64
65   typedef vhost-user-role {
66     type enumeration {
67       enum "server";
68       enum "client";
69     }
70   }
71
72   identity vxlan-gpe-tunnel {
73     base if:interface-type;
74   }
75
76   typedef vxlan-gpe-vni {
77     description "VNI used in a VXLAN-GPE tunnel";
78     type uint32 {
79       range "0..16777215";
80     }
81   }
82
83   typedef vxlan-gpe-next-protocol {
84     type enumeration {
85       enum ipv4;
86       enum ipv6;
87       enum ethernet;
88       enum nsh;
89     }
90   }
91
92   grouping bridge-domain-attributes {
93     leaf flood {
94       type boolean;
95       default true;
96       description
97       "Enable/disable L2 flooding.";
98     }
99     leaf forward {
100       type boolean;
101       default true;
102       description
103       "Enable/disable L2 forwarding.";
104     }
105     leaf learn {
106       type boolean;
107       default true;
108       description
109       "Enable/disable L2 learning.";
110     }
111     leaf unknown-unicast-flood {
112       type boolean;
113       default true;
114     }
115     leaf arp-termination {
116       type boolean;
117       default false;
118     }
119   }
120
121   grouping tap-interface-base-attributes {
122     leaf tap-name {
123       type string;
124     }
125   }
126
127   grouping tap-interface-config-attributes {
128     leaf mac {
129       type yang:phys-address;
130       mandatory false;
131       description "Mac address to be set for the tap interface. Random will be used if not configured";
132     }
133
134     leaf device-instance {
135       type uint32;
136       mandatory false;
137       description "Custom device instance. Autogenerated will be used if not configured";
138     }
139   }
140
141   grouping ethernet-base-attributes {
142     leaf mtu {
143       type uint16 {
144         range "64..9216";
145       }
146       units "octets";
147       default 9216;
148       description
149       "The size, in octets, of the largest packet that the
150        hardware interface will send and receive.";
151     }
152   }
153
154   grouping ethernet-state-attributes {
155     leaf manufacturer-description {
156       type string;
157       config false;
158     }
159     leaf duplex {
160       type enumeration {
161         enum "half";
162         enum "full";
163       }
164       config false;
165     }
166   }
167
168   grouping vhost-user-interface-base-attributes {
169     leaf socket {
170       type string {
171         length 1..255;
172       }
173     }
174     leaf role {
175       type vhost-user-role;
176       default "server";
177     }
178     description "vhost-user settings";
179   }
180
181   grouping vhost-user-interface-state-attributes {
182     leaf features {
183       type uint64;
184       config false;
185     }
186     leaf virtio-net-hdr-size {
187       type uint32;
188       config false;
189     }
190     leaf num-memory-regions {
191       type uint32;
192       config false;
193     }
194     leaf connect-error {
195       type string;
196       config false;
197     }
198   }
199
200   grouping vxlan-base-attributes {
201     // FIXME: this should be in an vxlan-specific extension
202     leaf src {
203       /*mandatory true;*/
204       type inet:ip-address;
205     }
206     leaf dst {
207       /*mandatory true;*/
208       type inet:ip-address;
209     }
210     leaf vni {
211       /*mandatory true;*/
212       type vxlan-vni;
213     }
214     leaf encap-vrf-id {
215       type uint32;
216     }
217   }
218
219   grouping vxlan-gpe-base-attributes {
220     leaf local {
221       /*mandatory true;*/
222       type inet:ip-address;
223     }
224     leaf remote {
225       /*mandatory true;*/
226       type inet:ip-address;
227     }
228     leaf vni {
229       /*mandatory true;*/
230       type vxlan-gpe-vni;
231     }
232     leaf next-protocol {
233       type vxlan-gpe-next-protocol;
234     }
235     leaf encap-vrf-id {
236       type uint32;
237     }
238     leaf decap-vrf-id {
239       type uint32;
240     }
241   }
242
243   grouping l2-base-attributes {
244       description
245       "Parameters for configuring Layer2 features on interfaces.";
246
247       choice interconnection {
248         case xconnect-based {
249           leaf xconnect-outgoing-interface {
250             /* Don't allow selection of this interface */
251             must "../../if:name != current()";
252             type if:interface-ref; // todo use interface-state-ref for operational data?
253             description
254               "L2 xconnect mode";
255           }
256         }
257         case bridge-based {
258           leaf bridge-domain {
259             type bridge-domain-ref;
260             description
261               "Interfaces in a bridge-domain forward packets to other
262                interfaces in the same bridge-domain based on
263                destination mac address.";
264           }
265           leaf split-horizon-group {
266             when "../bridge-domain";
267             type uint8 {
268               range "0..255";
269             }
270             default 0;
271             description
272               "Interface's split-horizon group. Interfaces in the same
273                bridge-domain and split-horizon group can not forward
274                packets between each other. ";
275           }
276           leaf bridged-virtual-interface {
277             when "../bridge-domain";
278             type boolean;
279             default false;
280             description
281               "Interface forward packets in the bridge-domain
282                associated with the BVI.";
283           }
284         }
285       }
286   }
287
288   augment /if:interfaces/if:interface {
289     ext:augment-identifier "vpp-interface-augmentation";
290
291     // FIXME using ietf-interfaces model for vpp interfaces makes it hard to implement because:
292     // 1. The link between interface type and this augmentation is unclear
293     // 2. Only this augmentation with combination of ifc type is trigger to do something for vpp, what if user only configures base interface stuff ? + We need to get leaves defined by ietf-interfaces when we are processing this augment
294     // 3. The ietf-interfaces model does not define groupings which makes types reuse difficult
295
296     container tap {
297       when "../if:type = 'v3po:tap'";
298       uses tap-interface-base-attributes;
299       uses tap-interface-config-attributes;
300     }
301
302     container ethernet {
303       when "../if:type = 'ianaift:ethernetCsmacd'";
304       uses ethernet-base-attributes;
305     }
306
307     container routing {
308       leaf vrf-id { // todo no routing info for oper, is it possible to get it from the vpp?
309         type uint32;
310         default 0;
311       }
312     }
313
314     container vhost-user {
315       when "../if:type = 'v3po:vhost-user'";
316       uses vhost-user-interface-base-attributes;
317     }
318
319     container vxlan {
320       when "../if:type = 'v3po:vxlan-tunnel'";
321       uses vxlan-base-attributes;
322     }
323
324     container l2 {
325       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
326       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
327
328       uses l2-base-attributes;
329     }
330
331     container vxlan-gpe {
332       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
333
334       uses vxlan-gpe-base-attributes;
335     }
336   }
337
338   container vpp {
339     description
340     "VPP config data";
341
342     container bridge-domains {
343       list bridge-domain {
344         key "name";
345
346         leaf name {
347           type string;
348         }
349
350         uses bridge-domain-attributes;
351
352         list l2-fib {
353           key "phys-address";
354
355           leaf phys-address {
356             type yang:phys-address;
357           }
358           leaf action {
359             type enumeration {
360               enum "forward";
361               enum "filter";
362             }
363             mandatory true;
364           }
365           leaf outgoing-interface {
366             type if:interface-ref;
367           }
368         }
369       }
370     }
371   }
372
373   augment /if:interfaces-state/if:interface {
374     ext:augment-identifier "vpp-interface-state-augmentation";
375
376     leaf description {
377       type string;
378     }
379
380     container tap {
381       when "../if:type = 'v3po:tap'";
382       uses tap-interface-base-attributes;
383     }
384
385     container ethernet {
386       when "../if:type = 'ianaift:ethernetCsmacd'";
387       uses ethernet-base-attributes;
388       uses ethernet-state-attributes;
389     }
390
391     container vhost-user {
392       when "../if:type = 'v3po:vhost-user'";
393       uses vhost-user-interface-base-attributes;
394       uses vhost-user-interface-state-attributes;
395     }
396
397     container vxlan {
398       when "../if:type = 'v3po:vxlan-tunnel'";
399       uses vxlan-base-attributes;
400     }
401     container vxlan-gpe {
402       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
403
404       uses vxlan-gpe-base-attributes;
405     }
406
407     container l2 {
408       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
409       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
410
411       uses l2-base-attributes;
412     }
413   }
414
415   augment /if:interfaces-state/if:interface/if:statistics {
416     ext:augment-identifier "vpp-interface-statistics-augmentation";
417     leaf in-errors-no-buf {
418       type yang:counter64;
419     }
420     leaf in-errors-miss {
421       type yang:counter64;
422     }
423     leaf out-discards-fifo-full {
424       type yang:counter64;
425     }
426   }
427
428   container vpp-state {
429     config false;
430
431     description
432       "VPP operational data";
433
434     container bridge-domains {
435       // FIXME: Should this live in bridge-domain.yang in a modular fashion ?
436       list bridge-domain {
437
438         key "name";
439         leaf name {
440           type string;
441         }
442
443         uses bridge-domain-attributes;
444
445         list interface {
446           key "name";
447
448           leaf name {
449             type if:interface-state-ref;
450           }
451
452           leaf split-horizon-group {
453             type uint8;
454           }
455
456           leaf bridged-virtual-interface {
457             type boolean;
458           }
459         }
460
461         list l2-fib {
462           key "phys-address";
463
464           leaf phys-address {
465             type yang:phys-address;
466           }
467           leaf static-config {
468             type boolean;
469           }
470           leaf outgoing-interface {
471             when "../v3po:action = 'forward'";
472             type if:interface-state-ref;
473           }
474           leaf action {
475             type enumeration {
476               enum "forward";
477               enum "filter";
478             }
479             mandatory true;
480           }
481           leaf bridged-virtual-interface {
482             when "../v3po:action = 'forward'";
483             type boolean;
484           }
485         }
486         description
487           "bridge-domain operational data";
488       }
489     }
490
491     container version {
492       leaf name {
493         type string;
494       }
495       leaf build-directory {
496         type string;
497       }
498       leaf build-date {
499         type string;
500       }
501       leaf branch {
502         type string;
503       }
504       description
505       "vlib version info";
506     }
507   }
508 }