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