86a2764b82747687bf02c92119498eb0ec4eb8d1
[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   typedef vlan-type {
46     type enumeration {
47       enum 802dot1q;
48       enum 802dot1ad;
49     }
50   }
51
52   // todo remove from v3po
53   typedef tag-rewrite-operation {
54     type enumeration {
55       enum disabled;
56       enum push-1;
57       enum push-2;
58       enum pop-1;
59       enum pop-2;
60       enum translate-1-to-1;
61       enum translate-1-to-2;
62       enum translate-2-to-1;
63       enum translate-2-to-2;
64     }
65   }
66
67   typedef vlan-tag {
68     type uint16 {
69       range "1..4094";
70     }
71   }
72
73   identity vxlan-tunnel {
74     base if:interface-type;
75   }
76
77   identity vhost-user {
78     base if:interface-type;
79   }
80
81   identity tap {
82     base if:interface-type;
83   }
84
85   identity sub-interface {
86     base if:interface-type;
87   }
88
89   typedef vxlan-vni {
90     // FIXME: should be in a vxlan-specific model
91     description "VNI used in a VXLAN tunnel";
92     type uint32 {
93       range "0..16777215";
94     }
95   }
96
97   typedef vhost-user-role {
98     type enumeration {
99       enum "server";
100       enum "client";
101     }
102   }
103
104   identity vxlan-gpe-tunnel {
105     base if:interface-type;
106   }
107
108   typedef vxlan-gpe-vni {
109     description "VNI used in a VXLAN-GPE tunnel";
110     type uint32 {
111       range "0..16777215";
112     }
113   }
114
115   typedef vxlan-gpe-next-protocol {
116     type enumeration {
117       enum ipv4;
118       enum ipv6;
119       enum ethernet;
120       enum nsh;
121     }
122   }
123
124   grouping bridge-domain-attributes {
125     leaf flood {
126       type boolean;
127       default true;
128       description
129       "Enable/disable L2 flooding.";
130     }
131     leaf forward {
132       type boolean;
133       default true;
134       description
135       "Enable/disable L2 forwarding.";
136     }
137     leaf learn {
138       type boolean;
139       default true;
140       description
141       "Enable/disable L2 learning.";
142     }
143     leaf unknown-unicast-flood {
144       type boolean;
145       default true;
146     }
147     leaf arp-termination {
148       type boolean;
149       default false;
150     }
151   }
152
153   // todo remove from v3po
154   grouping sub-interface-base-attributes {
155     leaf identifier {
156       type uint32;
157     }
158     leaf vlan-type {
159       type vlan-type;
160       default '802dot1q';
161     }
162     leaf number-of-tags {
163       type uint8 {
164         range "0..2";
165       }
166       default 1;
167     }
168     leaf outer-id {
169       type vlan-tag;
170     }
171     leaf inner-id {
172       type vlan-tag;
173     }
174     leaf match-any-outer-id {
175       type empty;
176     }
177     leaf match-any-inner-id {
178       type empty;
179     }
180     leaf exact-match {
181       type empty;
182     }
183     leaf default-subif {
184       type empty;
185     }
186   }
187
188   grouping tap-interface-base-attributes {
189     leaf tap-name {
190       type string;
191     }
192   }
193
194   grouping tap-interface-config-attributes {
195     leaf mac {
196       type yang:phys-address;
197       mandatory false;
198       description "Mac address to be set for the tap interface. Random will be used if not configured";
199     }
200
201     leaf device-instance {
202       type uint32;
203       mandatory false;
204       description "Custom device instance. Autogenerated will be used if not configured";
205     }
206   }
207
208   grouping ethernet-base-attributes {
209     leaf mtu {
210       type uint16 {
211         range "64..9216";
212       }
213       units "octets";
214       default 9216;
215       description
216       "The size, in octets, of the largest packet that the
217        hardware interface will send and receive.";
218     }
219   }
220
221   grouping ethernet-state-attributes {
222     leaf manufacturer-description {
223       type string;
224       config false;
225     }
226     leaf duplex {
227       type enumeration {
228         enum "half";
229         enum "full";
230       }
231       config false;
232     }
233   }
234
235   grouping vhost-user-interface-base-attributes {
236     leaf socket {
237       type string {
238         length 1..255;
239       }
240     }
241     leaf role {
242       type vhost-user-role;
243       default "server";
244     }
245     description "vhost-user settings";
246   }
247
248   grouping vhost-user-interface-state-attributes {
249     leaf features {
250       type uint64;
251       config false;
252     }
253     leaf virtio-net-hdr-size {
254       type uint32;
255       config false;
256     }
257     leaf num-memory-regions {
258       type uint32;
259       config false;
260     }
261     leaf connect-error {
262       type string;
263       config false;
264     }
265   }
266
267   grouping vxlan-base-attributes {
268     // FIXME: this should be in an vxlan-specific extension
269     leaf src {
270       /*mandatory true;*/
271       type inet:ip-address;
272     }
273     leaf dst {
274       /*mandatory true;*/
275       type inet:ip-address;
276     }
277     leaf vni {
278       /*mandatory true;*/
279       type vxlan-vni;
280     }
281     leaf encap-vrf-id {
282       type uint32;
283     }
284   }
285
286   grouping vxlan-gpe-base-attributes {
287     leaf local {
288       /*mandatory true;*/
289       type inet:ip-address;
290     }
291     leaf remote {
292       /*mandatory true;*/
293       type inet:ip-address;
294     }
295     leaf vni {
296       /*mandatory true;*/
297       type vxlan-gpe-vni;
298     }
299     leaf next-protocol {
300       type vxlan-gpe-next-protocol;
301     }
302     leaf encap-vrf-id {
303       type uint32;
304     }
305     leaf decap-vrf-id {
306       type uint32;
307     }
308   }
309
310   grouping vlan-tag-rewrite-attributes {
311     leaf rewrite-operation {
312       type tag-rewrite-operation;
313       default 'disabled';
314     }
315     leaf first-pushed {
316       type vlan-type;
317       default '802dot1q';
318     }
319     leaf tag1 {
320       type vlan-tag;
321     }
322     leaf tag2 {
323       type vlan-tag;
324     }
325   }
326
327   grouping l2-base-attributes {
328       description
329       "Parameters for configuring Layer2 features on interfaces.";
330
331       choice interconnection {
332         case xconnect-based {
333           leaf xconnect-outgoing-interface {
334             /* Don't allow selection of this interface */
335             must "../../if:name != current()";
336             type if:interface-ref; // todo use interface-state-ref for operational data?
337             description
338               "L2 xconnect mode";
339           }
340         }
341         case bridge-based {
342           leaf bridge-domain {
343             type bridge-domain-ref;
344             description
345               "Interfaces in a bridge-domain forward packets to other
346                interfaces in the same bridge-domain based on
347                destination mac address.";
348           }
349           leaf split-horizon-group {
350             when "../bridge-domain";
351             type uint8 {
352               range "0..255";
353             }
354             default 0;
355             description
356               "Interface's split-horizon group. Interfaces in the same
357                bridge-domain and split-horizon group can not forward
358                packets between each other. ";
359           }
360           leaf bridged-virtual-interface {
361             when "../bridge-domain";
362             type boolean;
363             default false;
364             description
365               "Interface forward packets in the bridge-domain
366                associated with the BVI.";
367           }
368         }
369       }
370   }
371
372   augment /if:interfaces/if:interface {
373     ext:augment-identifier "vpp-interface-augmentation";
374
375     // FIXME using ietf-interfaces model for vpp interfaces makes it hard to implement because:
376     // 1. The link between interface type and this augmentation is unclear
377     // 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
378     // 3. The ietf-interfaces model does not define groupings which makes types reuse difficult
379
380     container sub-interface {
381       when "../if:type = 'v3po:sub-interface'";
382       leaf super-interface {
383         type if:interface-ref;
384       }
385       uses sub-interface-base-attributes;
386     }
387
388     container tap {
389       when "../if:type = 'v3po:tap'";
390       uses tap-interface-base-attributes;
391       uses tap-interface-config-attributes;
392     }
393
394     container ethernet {
395       when "../if:type = 'ianaift:ethernetCsmacd'";
396       uses ethernet-base-attributes;
397     }
398
399     container routing {
400       leaf vrf-id { // todo no routing info for oper, is it possible to get it from the vpp?
401         type uint32;
402         default 0;
403       }
404     }
405
406     container vhost-user {
407       when "../if:type = 'v3po:vhost-user'";
408       uses vhost-user-interface-base-attributes;
409     }
410
411     container vxlan {
412       when "../if:type = 'v3po:vxlan-tunnel'";
413       uses vxlan-base-attributes;
414     }
415
416     container l2 {
417       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
418       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
419
420       uses l2-base-attributes;
421
422       container vlan-tag-rewrite {
423         uses vlan-tag-rewrite-attributes;
424       }
425     }
426
427     container vxlan-gpe {
428       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
429
430       uses vxlan-gpe-base-attributes;
431     }
432   }
433
434   container vpp {
435     description
436     "VPP config data";
437
438     container bridge-domains {
439       list bridge-domain {
440         key "name";
441         // TODO: where does this come from?
442         max-elements 1024;
443
444         leaf name {
445           type string;
446         }
447
448         uses bridge-domain-attributes;
449
450         list l2-fib {
451           key "phys-address";
452
453           leaf phys-address {
454             type yang:phys-address;
455           }
456           leaf action {
457             type enumeration {
458               enum "forward";
459               enum "filter";
460             }
461             mandatory true;
462           }
463           leaf outgoing-interface {
464             type if:interface-ref;
465           }
466         }
467       }
468     }
469   }
470
471   augment /if:interfaces-state/if:interface {
472     ext:augment-identifier "vpp-interface-state-augmentation";
473
474     leaf description {
475       type string;
476     }
477
478     container sub-interface {
479       when "../if:type = 'v3po:sub-interface'";
480       leaf super-interface {
481         type if:interface-state-ref;
482       }
483       uses sub-interface-base-attributes;
484     }
485
486     container tap {
487       when "../if:type = 'v3po:tap'";
488       uses tap-interface-base-attributes;
489     }
490
491     container ethernet {
492       when "../if:type = 'ianaift:ethernetCsmacd'";
493       uses ethernet-base-attributes;
494       uses ethernet-state-attributes;
495     }
496
497     container vhost-user {
498       when "../if:type = 'v3po:vhost-user'";
499       uses vhost-user-interface-base-attributes;
500       uses vhost-user-interface-state-attributes;
501     }
502
503     container vxlan {
504       when "../if:type = 'v3po:vxlan-tunnel'";
505       uses vxlan-base-attributes;
506     }
507     container vxlan-gpe {
508       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
509
510       uses vxlan-gpe-base-attributes;
511     }
512
513     container l2 {
514       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
515       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
516
517       uses l2-base-attributes;
518
519       container vlan-tag-rewrite {
520         uses vlan-tag-rewrite-attributes;
521       }
522     }
523   }
524
525   augment /if:interfaces-state/if:interface/if:statistics {
526     ext:augment-identifier "vpp-interface-statistics-augmentation";
527     leaf in-errors-no-buf {
528       type yang:counter64;
529     }
530     leaf in-errors-miss {
531       type yang:counter64;
532     }
533     leaf out-discards-fifo-full {
534       type yang:counter64;
535     }
536   }
537
538   container vpp-state {
539     config false;
540
541     description
542       "VPP operational data";
543
544     container bridge-domains {
545       // FIXME: Should this live in bridge-domain.yang in a modular fashion ?
546       list bridge-domain {
547
548         key "name";
549         leaf name {
550           type string;
551         }
552
553         uses bridge-domain-attributes;
554
555         list interface {
556           key "name";
557
558           leaf name {
559             type if:interface-state-ref;
560           }
561
562           leaf split-horizon-group {
563             type uint8;
564           }
565
566           leaf bridged-virtual-interface {
567             type boolean;
568           }
569         }
570
571         list l2-fib {
572           key "phys-address";
573
574           leaf phys-address {
575             type yang:phys-address;
576           }
577           leaf static-config {
578             type boolean;
579           }
580           leaf outgoing-interface {
581             when "../v3po:action = 'forward'";
582             type if:interface-state-ref;
583           }
584           leaf action {
585             type enumeration {
586               enum "forward";
587               enum "filter";
588             }
589             mandatory true;
590           }
591           leaf bridged-virtual-interface {
592             when "../v3po:action = 'forward'";
593             type boolean;
594           }
595         }
596         description
597           "bridge-domain operational data";
598       }
599     }
600
601     container version {
602       leaf name {
603         type string;
604       }
605       leaf build-directory {
606         type string;
607       }
608       leaf build-date {
609         type string;
610       }
611       leaf branch {
612         type string;
613       }
614       description
615       "vlib version info";
616     }
617   }
618 }