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