9ef133979069d295114233b7f57f971b8f69fb2b
[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   import vpp-classifier {
29     prefix "vpp-classifier";
30   }
31
32   typedef bridge-domain-ref {
33     type leafref {
34       path "/vpp/bridge-domains/bridge-domain/name";
35     }
36     description
37       "This type is used by to reference a bridge domain table";
38   }
39
40   typedef bridged-virtual-interface-ref {
41     type leafref {
42       path "/if:interfaces/if:interface/l2/bridged-virtual-interface";
43     }
44     description
45       "This type is used by to reference a bridged virtual interface";
46   }
47
48   identity vxlan-tunnel {
49     base if:interface-type;
50   }
51
52   identity gre-tunnel {
53     base if:interface-type;
54   }
55
56   identity vhost-user {
57     base if:interface-type;
58   }
59
60   identity tap {
61     base if:interface-type;
62   }
63
64   identity l2-fib-action {
65     description "Base identity for l2-fib actions";
66   }
67
68   identity l2-fib-forward {
69     base l2-fib-action;
70     description
71       "Forwards packet with configured mac address";
72   }
73
74   identity l2-fib-filter {
75     base l2-fib-action;
76     description
77       "Drops packet with configured mac address";
78   }
79
80   typedef l2-fib-action {
81     type identityref {
82       base "l2-fib-action";
83     }
84     description "Identifies a specific L2 FIB action";
85   }
86
87   typedef vxlan-vni {
88     // FIXME: should be in a vxlan-specific model
89     description "VNI used in a VXLAN tunnel";
90     type uint32 {
91       range "0..16777215";
92     }
93   }
94
95   typedef vhost-user-role {
96     type enumeration {
97       enum "server";
98       enum "client";
99     }
100   }
101
102   identity vxlan-gpe-tunnel {
103     base if:interface-type;
104   }
105
106   typedef vxlan-gpe-vni {
107     description "VNI used in a VXLAN-GPE tunnel";
108     type uint32 {
109       range "0..16777215";
110     }
111   }
112
113   typedef vxlan-gpe-next-protocol {
114     type enumeration {
115       enum "ipv4" {
116         value 1;
117       }
118       enum "ipv6" {
119         value 2;
120       }
121       enum "ethernet" {
122         value 3;
123       }
124       enum "nsh" {
125         value 4;
126       }
127     }
128   }
129
130   grouping bridge-domain-attributes {
131     leaf flood {
132       type boolean;
133       default true;
134       description
135       "Enable/disable L2 flooding.";
136     }
137     leaf forward {
138       type boolean;
139       default true;
140       description
141       "Enable/disable L2 forwarding.";
142     }
143     leaf learn {
144       type boolean;
145       default true;
146       description
147       "Enable/disable L2 learning.";
148     }
149     leaf unknown-unicast-flood {
150       type boolean;
151       default true;
152     }
153     leaf arp-termination {
154       type boolean;
155       default false;
156     }
157
158     container arp-termination-table {
159       when "../v3po:arp-termination = 'true'";
160
161       // TODO(HONEYCOMB-133): add support for read (after VPP-230 is done)
162       list arp-termination-table-entry {
163         key "ip-address phys-address";
164         leaf ip-address {
165           // FIXME: change to ip-address-no-zone after https://bugs.opendaylight.org/show_bug.cgi?id=6413 is resolved
166           type inet:ip-address;
167         }
168         leaf phys-address {
169           type yang:phys-address;
170         }
171       }
172     }
173   }
174
175   // TODO express constraints for L2 FIB entries in YANG if possible
176   grouping l2-fib-attributes {
177     container l2-fib-table {
178       list l2-fib-entry {
179         key "phys-address";
180
181         leaf phys-address {
182           type yang:phys-address;
183         }
184
185         leaf outgoing-interface {
186           type string;
187           // mandatory true;
188           // mandatory for forward action
189           // FIXME VPP's CLI does not require to set iface id for filter action
190           // VPP's binary api in constrast to CLI does some checks on the iface id value,
191           // so currently it has to be set for all actions
192           description
193             "One of interfaces assigned to the FIB table's bridge-domain.";
194         }
195         leaf static-config {
196           type boolean;
197           default false;
198           description
199             "Static entries cannot be overridden by mac learning.";
200         }
201         leaf action {
202           type l2-fib-action;
203           mandatory true;
204           description
205             "L2 FIB action. For filter action, entry must be configured as static.";
206         }
207         leaf bridged-virtual-interface {
208           when "../action = 'forward'";
209           type boolean;
210           config false; // FIXME setting bvi is currently not supported by VPP's binary api
211         }
212       }
213     }
214   }
215
216   grouping tap-interface-base-attributes {
217     leaf tap-name {
218       type string{
219         pattern "[a-zA-Z0-9\-;.+@$#^&*!_()=\[\]]*";
220       }
221     }
222   }
223
224   grouping tap-interface-config-attributes {
225     leaf mac {
226       type yang:phys-address;
227       mandatory false;
228       description "Mac address to be set for the tap interface. Random will be used if not configured";
229     }
230
231     leaf device-instance {
232       type uint32;
233       mandatory false;
234       description "Custom device instance. Autogenerated will be used if not configured";
235     }
236   }
237
238   grouping ethernet-base-attributes {
239     leaf mtu {
240       type uint16 {
241         range "64..9216";
242       }
243       units "octets";
244       default 9216;
245       description
246       "The size, in octets, of the largest packet that the
247        hardware interface will send and receive.";
248     }
249   }
250
251   grouping ethernet-state-attributes {
252     leaf manufacturer-description {
253       type string;
254       config false;
255     }
256     leaf duplex {
257       type enumeration {
258         enum "half";
259         enum "full";
260       }
261       config false;
262     }
263   }
264
265   grouping vhost-user-interface-base-attributes {
266     leaf socket {
267       type string {
268         length 1..255;
269       }
270     }
271     leaf role {
272       type vhost-user-role;
273       default "server";
274     }
275     description "vhost-user settings";
276   }
277
278   grouping vhost-user-interface-state-attributes {
279     leaf features {
280       type uint64;
281       config false;
282     }
283     leaf virtio-net-hdr-size {
284       type uint32;
285       config false;
286     }
287     leaf num-memory-regions {
288       type uint32;
289       config false;
290     }
291     leaf connect-error {
292       type string;
293       config false;
294     }
295   }
296
297   grouping vxlan-base-attributes {
298     // FIXME: this should be in an vxlan-specific extension
299     leaf src {
300       /*mandatory true;*/
301       type inet:ip-address;
302     }
303     leaf dst {
304       /*mandatory true;*/
305       type inet:ip-address;
306     }
307     leaf vni {
308       /*mandatory true;*/
309       type vxlan-vni;
310     }
311     leaf encap-vrf-id {
312       type uint32;
313     }
314   }
315
316   grouping gre-base-attributes {
317     leaf src {
318       /*mandatory true;*/
319       type inet:ip-address;
320     }
321     leaf dst {
322       /*mandatory true;*/
323       type inet:ip-address;
324     }
325     leaf outer-fib-id {
326       type uint32;
327     }
328   }
329
330   grouping vxlan-gpe-base-attributes {
331     leaf local {
332       /*mandatory true;*/
333       type inet:ip-address;
334     }
335     leaf remote {
336       /*mandatory true;*/
337       type inet:ip-address;
338     }
339     leaf vni {
340       /*mandatory true;*/
341       type vxlan-gpe-vni;
342     }
343     leaf next-protocol {
344       type vxlan-gpe-next-protocol;
345     }
346     leaf encap-vrf-id {
347       type uint32;
348     }
349     leaf decap-vrf-id {
350       type uint32;
351     }
352   }
353
354   grouping l2-base-attributes {
355       description
356       "Parameters for configuring Layer2 features on interfaces.";
357
358       choice interconnection {
359         case xconnect-based {
360           leaf xconnect-outgoing-interface {
361             /* Don't allow selection of this interface */
362             must "../../if:name != current()";
363             type if:interface-ref; // todo use interface-state-ref for operational data?
364             description
365               "L2 xconnect mode";
366           }
367         }
368         case bridge-based {
369           leaf bridge-domain {
370             type bridge-domain-ref;
371             mandatory true;
372             description
373               "Interfaces in a bridge-domain forward packets to other
374                interfaces in the same bridge-domain based on
375                destination mac address.";
376           }
377           leaf split-horizon-group {
378             when "../bridge-domain";
379             type uint8 {
380               range "0..255";
381             }
382             default 0; //no split horizon group
383             description
384               "Interface's split-horizon group. Interfaces in the same
385                bridge-domain and split-horizon group can not forward
386                packets between each other. ";
387           }
388           leaf bridged-virtual-interface {
389             when "../bridge-domain";
390             type boolean;
391             default false;
392             description
393               "Interface forward packets in the bridge-domain
394                associated with the BVI.";
395           }
396         }
397       }
398   }
399
400   grouping acl-base-attributes {
401     description
402       "Defines references to classify tables.
403        At least one table reference should be specified.";
404     container l2-acl {
405       leaf classify-table {
406         type vpp-classifier:classify-table-ref;
407         description
408           "An L2 ACL table";
409       }
410     }
411     container ip4-acl {
412       leaf classify-table {
413         type vpp-classifier:classify-table-ref;
414         description
415           "An IPv4 ACL table";
416       }
417     }
418     container ip6-acl {
419       leaf classify-table {
420         type vpp-classifier:classify-table-ref;
421         description
422           "An IPv6 ACL table";
423       }
424     }
425   }
426
427   augment /if:interfaces/if:interface {
428     ext:augment-identifier "vpp-interface-augmentation";
429
430     // FIXME using ietf-interfaces model for vpp interfaces makes it hard to implement because:
431     // 1. The link between interface type and this augmentation is unclear
432     // 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
433     // 3. The ietf-interfaces model does not define groupings which makes types reuse difficult
434
435     container tap {
436       when "../if:type = 'v3po:tap'";
437       uses tap-interface-base-attributes;
438       uses tap-interface-config-attributes;
439     }
440
441     container ethernet {
442       when "../if:type = 'ianaift:ethernetCsmacd'";
443       uses ethernet-base-attributes;
444     }
445
446     container routing {
447       leaf vrf-id { // todo no routing info for oper, is it possible to get it from the vpp?
448         type uint32;
449         default 0;
450       }
451     }
452
453     container vhost-user {
454       when "../if:type = 'v3po:vhost-user'";
455       uses vhost-user-interface-base-attributes;
456     }
457
458     container vxlan {
459       when "../if:type = 'v3po:vxlan-tunnel'";
460       uses vxlan-base-attributes;
461     }
462
463     container gre {
464       when "../if:type = 'v3po:gre-tunnel'";
465       uses gre-base-attributes;
466     }
467
468     container l2 {
469       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
470       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
471
472       uses l2-base-attributes;
473     }
474
475     container vxlan-gpe {
476       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
477
478       uses vxlan-gpe-base-attributes;
479     }
480
481     container acl {
482       uses acl-base-attributes;
483     }
484   }
485
486   container vpp {
487     description
488     "VPP config data";
489
490     container bridge-domains {
491       list bridge-domain {
492         key "name";
493
494         leaf name {
495           type string;
496         }
497
498         uses bridge-domain-attributes;
499         uses l2-fib-attributes;
500
501         description
502           "bridge-domain configuration";
503       }
504     }
505   }
506
507   augment /if:interfaces-state/if:interface {
508     ext:augment-identifier "vpp-interface-state-augmentation";
509
510     leaf description {
511       type string;
512     }
513
514     container tap {
515       when "../if:type = 'v3po:tap'";
516       uses tap-interface-base-attributes;
517     }
518
519     container ethernet {
520       when "../if:type = 'ianaift:ethernetCsmacd'";
521       uses ethernet-base-attributes;
522       uses ethernet-state-attributes;
523     }
524
525     container vhost-user {
526       when "../if:type = 'v3po:vhost-user'";
527       uses vhost-user-interface-base-attributes;
528       uses vhost-user-interface-state-attributes;
529     }
530
531     container vxlan {
532       when "../if:type = 'v3po:vxlan-tunnel'";
533       uses vxlan-base-attributes;
534     }
535     container vxlan-gpe {
536       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
537
538       uses vxlan-gpe-base-attributes;
539     }
540
541     container gre {
542       when "../if:type = 'gre-tunnel'";
543       uses gre-base-attributes;
544     }
545
546     container l2 {
547       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
548       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
549
550       uses l2-base-attributes;
551     }
552
553     container acl {
554       uses acl-base-attributes;
555     }
556   }
557
558   augment /if:interfaces-state/if:interface/if:statistics {
559     ext:augment-identifier "vpp-interface-statistics-augmentation";
560     leaf in-errors-no-buf {
561       type yang:counter64;
562     }
563     leaf in-errors-miss {
564       type yang:counter64;
565     }
566     leaf out-discards-fifo-full {
567       type yang:counter64;
568     }
569   }
570
571   container vpp-state {
572     config false;
573
574     description
575       "VPP operational data";
576
577     container bridge-domains {
578       // FIXME: Should this live in bridge-domain.yang in a modular fashion ?
579       list bridge-domain {
580
581         key "name";
582         leaf name {
583           type string;
584         }
585
586         uses bridge-domain-attributes;
587         uses l2-fib-attributes;
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
612   // VPP Notifications
613
614   typedef interface-status {
615     type enumeration {
616       enum up {
617         value 1;
618       }
619       enum down {
620         value 0;
621       }
622     }
623   }
624
625   typedef interface-name-or-index {
626     type union {
627       type string;
628       type uint32;
629     }
630   }
631
632   notification interface-state-change {
633     leaf name {
634         type interface-name-or-index;
635     }
636
637     leaf admin-status {
638         type interface-status;
639     }
640
641     leaf oper-status {
642         type interface-status;
643     }
644   }
645
646   notification interface-deleted {
647     leaf name {
648         type interface-name-or-index;
649     }
650   }
651 }