f17ee9ae1018fd2e666e18c680186f3e6eb227fe
[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   import ietf-access-control-list {
32     prefix "acl";
33   }
34
35   typedef bridge-domain-ref {
36     type leafref {
37       path "/vpp/bridge-domains/bridge-domain/name";
38     }
39     description
40       "This type is used by to reference a bridge domain table";
41   }
42
43   typedef bridged-virtual-interface-ref {
44     type leafref {
45       path "/if:interfaces/if:interface/l2/bridged-virtual-interface";
46     }
47     description
48       "This type is used by to reference a bridged virtual interface";
49   }
50
51   identity vxlan-tunnel {
52     base if:interface-type;
53   }
54
55   identity gre-tunnel {
56     base if:interface-type;
57   }
58
59   identity vhost-user {
60     base if:interface-type;
61   }
62
63   identity tap {
64     base if:interface-type;
65   }
66
67   identity l2-fib-action {
68     description "Base identity for l2-fib actions";
69   }
70
71   identity l2-fib-forward {
72     base l2-fib-action;
73     description
74       "Forwards packet with configured mac address";
75   }
76
77   identity l2-fib-filter {
78     base l2-fib-action;
79     description
80       "Drops packet with configured mac address";
81   }
82
83   typedef l2-fib-action {
84     type identityref {
85       base "l2-fib-action";
86     }
87     description "Identifies a specific L2 FIB action";
88   }
89
90   typedef vxlan-vni {
91     // FIXME: should be in a vxlan-specific model
92     description "VNI used in a VXLAN tunnel";
93     type uint32 {
94       range "0..16777215";
95     }
96   }
97
98   typedef vhost-user-role {
99     type enumeration {
100       enum "server";
101       enum "client";
102     }
103   }
104
105   identity vxlan-gpe-tunnel {
106     base if:interface-type;
107   }
108
109   typedef vxlan-gpe-vni {
110     description "VNI used in a VXLAN-GPE tunnel";
111     type uint32 {
112       range "0..16777215";
113     }
114   }
115
116   typedef vxlan-gpe-next-protocol {
117     type enumeration {
118       enum "ipv4" {
119         value 1;
120       }
121       enum "ipv6" {
122         value 2;
123       }
124       enum "ethernet" {
125         value 3;
126       }
127       enum "nsh" {
128         value 4;
129       }
130     }
131   }
132
133   typedef interface-mode {
134     type enumeration {
135       enum "l2";
136       enum "l3";
137     }
138   }
139
140   grouping bridge-domain-attributes {
141     leaf flood {
142       type boolean;
143       default true;
144       description
145       "Enable/disable L2 flooding.";
146     }
147     leaf forward {
148       type boolean;
149       default true;
150       description
151       "Enable/disable L2 forwarding.";
152     }
153     leaf learn {
154       type boolean;
155       default true;
156       description
157       "Enable/disable L2 learning.";
158     }
159     leaf unknown-unicast-flood {
160       type boolean;
161       default true;
162     }
163     leaf arp-termination {
164       type boolean;
165       default false;
166     }
167
168     container arp-termination-table {
169       when "../v3po:arp-termination = 'true'";
170
171       // TODO(HONEYCOMB-133): add support for read (after VPP-230 is done)
172       list arp-termination-table-entry {
173         key "ip-address phys-address";
174         leaf ip-address {
175           // FIXME: change to ip-address-no-zone after https://bugs.opendaylight.org/show_bug.cgi?id=6413 is resolved
176           type inet:ip-address;
177         }
178         leaf phys-address {
179           type yang:phys-address;
180         }
181       }
182     }
183   }
184
185   // TODO express constraints for L2 FIB entries in YANG if possible
186   grouping l2-fib-attributes {
187     container l2-fib-table {
188       list l2-fib-entry {
189         key "phys-address";
190
191         leaf phys-address {
192           type yang:phys-address;
193         }
194
195         leaf outgoing-interface {
196           type string;
197           // mandatory true;
198           // mandatory for forward action
199           // FIXME VPP's CLI does not require to set iface id for filter action
200           // VPP's binary api in constrast to CLI does some checks on the iface id value,
201           // so currently it has to be set for all actions
202           description
203             "One of interfaces assigned to the FIB table's bridge-domain.";
204         }
205         leaf static-config {
206           type boolean;
207           default false;
208           description
209             "Static entries cannot be overridden by mac learning.";
210         }
211         leaf action {
212           type l2-fib-action;
213           mandatory true;
214           description
215             "L2 FIB action. For filter action, entry must be configured as static.";
216         }
217         leaf bridged-virtual-interface {
218           when "../action = 'forward'";
219           type boolean;
220           config false; // FIXME setting bvi is currently not supported by VPP's binary api
221         }
222       }
223     }
224   }
225
226   grouping tap-interface-base-attributes {
227     leaf tap-name {
228       type string{
229         pattern "[a-zA-Z0-9\-;.+@$#^&*!_()=\[\]]*";
230       }
231     }
232   }
233
234   grouping tap-interface-config-attributes {
235     leaf mac {
236       type yang:phys-address;
237       mandatory false;
238       description "Mac address to be set for the tap interface. Random will be used if not configured";
239     }
240
241     leaf device-instance {
242       type uint32;
243       mandatory false;
244       description "Custom device instance. Autogenerated will be used if not configured";
245     }
246   }
247
248   grouping ethernet-base-attributes {
249     leaf mtu {
250       type uint16 {
251         range "64..9216";
252       }
253       units "octets";
254       default 9216;
255       description
256       "The size, in octets, of the largest packet that the
257        hardware interface will send and receive.";
258     }
259   }
260
261   grouping ethernet-state-attributes {
262     leaf manufacturer-description {
263       type string;
264       config false;
265     }
266     leaf duplex {
267       type enumeration {
268         enum "half";
269         enum "full";
270       }
271       config false;
272     }
273   }
274
275   grouping vhost-user-interface-base-attributes {
276     leaf socket {
277       type string {
278         length 1..255;
279       }
280     }
281     leaf role {
282       type vhost-user-role;
283       default "server";
284     }
285     description "vhost-user settings";
286   }
287
288   grouping vhost-user-interface-state-attributes {
289     leaf features {
290       type uint64;
291       config false;
292     }
293     leaf virtio-net-hdr-size {
294       type uint32;
295       config false;
296     }
297     leaf num-memory-regions {
298       type uint32;
299       config false;
300     }
301     leaf connect-error {
302       type string;
303       config false;
304     }
305   }
306
307   grouping vxlan-base-attributes {
308     // FIXME: this should be in an vxlan-specific extension
309     leaf src {
310       /*mandatory true;*/
311       type inet:ip-address;
312     }
313     leaf dst {
314       /*mandatory true;*/
315       type inet:ip-address;
316     }
317     leaf vni {
318       /*mandatory true;*/
319       type vxlan-vni;
320     }
321     leaf encap-vrf-id {
322       type uint32;
323     }
324   }
325
326   grouping gre-base-attributes {
327     leaf src {
328       /*mandatory true;*/
329       type inet:ip-address;
330     }
331     leaf dst {
332       /*mandatory true;*/
333       type inet:ip-address;
334     }
335     leaf outer-fib-id {
336       type uint32;
337     }
338   }
339
340   grouping vxlan-gpe-base-attributes {
341     leaf local {
342       /*mandatory true;*/
343       type inet:ip-address;
344     }
345     leaf remote {
346       /*mandatory true;*/
347       type inet:ip-address;
348     }
349     leaf vni {
350       /*mandatory true;*/
351       type vxlan-gpe-vni;
352     }
353     leaf next-protocol {
354       type vxlan-gpe-next-protocol;
355     }
356     leaf encap-vrf-id {
357       type uint32;
358     }
359     leaf decap-vrf-id {
360       type uint32;
361     }
362   }
363
364   grouping l2-base-attributes {
365       description
366       "Parameters for configuring Layer2 features on interfaces.";
367
368       choice interconnection {
369         case xconnect-based {
370           leaf xconnect-outgoing-interface {
371             /* Don't allow selection of this interface */
372             must "../../if:name != current()";
373             type if:interface-ref; // todo use interface-state-ref for operational data?
374             description
375               "L2 xconnect mode";
376           }
377         }
378         case bridge-based {
379           leaf bridge-domain {
380             type bridge-domain-ref;
381             mandatory true;
382             description
383               "Interfaces in a bridge-domain forward packets to other
384                interfaces in the same bridge-domain based on
385                destination mac address.";
386           }
387           leaf split-horizon-group {
388             when "../bridge-domain";
389             type uint8 {
390               range "0..255";
391             }
392             default 0; //no split horizon group
393             description
394               "Interface's split-horizon group. Interfaces in the same
395                bridge-domain and split-horizon group can not forward
396                packets between each other. ";
397           }
398           leaf bridged-virtual-interface {
399             when "../bridge-domain";
400             type boolean;
401             default false;
402             description
403               "Interface forward packets in the bridge-domain
404                associated with the BVI.";
405           }
406         }
407       }
408   }
409
410   grouping proxy-arp-attributes {
411         description
412         "Parameters for configuring Proxy ARP on interfaces.";
413
414       leaf vrf-id {
415         type uint32;
416         default 0;
417       }
418       leaf low-addr {
419           type inet:ipv4-address;
420       }
421       leaf high-addr {
422           type inet:ipv4-address;
423       }
424   }
425
426   grouping acl-base-attributes {
427     description
428       "Defines references to classify tables.
429        At least one table reference should be specified.";
430     container l2-acl {
431       leaf classify-table {
432         type vpp-classifier:classify-table-ref;
433         description
434           "An L2 ACL table";
435       }
436     }
437     container ip4-acl {
438       leaf classify-table {
439         type vpp-classifier:classify-table-ref;
440         description
441           "An IPv4 ACL table";
442       }
443     }
444     container ip6-acl {
445       leaf classify-table {
446         type vpp-classifier:classify-table-ref;
447         description
448           "An IPv6 ACL table";
449       }
450     }
451   }
452
453   grouping ietf-acl-base-attributes {
454     description
455       "Provides limited support for ietf-acl model.";
456
457     container access-lists {
458       description
459         "Defines references to ietf-acl lists. Before assignment to interface,
460         ACL lists are merged into 3 type of acls (eth0, ip4 and ip6) that are supported by vpp.
461         Then corresponding tables and sessions are created and assigned to the interface.
462
463         All ACEs for all assigned ACLs have to use the same packet-handling action (either deny or parmit).
464
465         Assignment update/delete removes all created tables and sessions and repeats process described above.
466         Update/delete of ACL lists referenced here is not permitted (assignment needs to be removed first).
467
468         Read is supported only for acls that were created and assigned by Honeycomb agent
469         (corresponding metadata are present).
470
471         Limitations (due to vpp limitations):
472         - egress rules are currently ignored (HONEYCOMB-234)
473         - L4 rules are currently not supported (limited support will by provided by HONEYCOMB-218)
474         - mixing L2/L3/L4 rules is currently not supported (limited support will by provided by HONEYCOMB-233)
475         - L2 only rules on L3 interfaces are not supported (not allowed by vpp,
476           in the future defining L2/L3 pairs should be partially supported)
477         - vlan tags are supported only for sub-interfaces defined as exact-match";
478       list acl {
479         key "type name";
480
481         leaf type {
482           type acl:acl-type;
483         }
484
485         leaf name {
486           type acl:access-control-list-ref;
487         }
488       }
489
490       leaf mode {
491         type interface-mode;
492         default l3;
493         description
494           "The way ACLs are translated depends on the interface mode.
495            In case of L2 interfaces (bridge/interconnection)
496            classify tables are assigned as l2_table using input_acl_set_interface (ether type matching is automatically
497            added in case of L3 rules).
498            In case of L3 interfaces, classify tables are assigned as ip4/ip6 tables.
499
500            It is the user responsibility to choose mode that matches target interface.
501            ";
502       }
503     }
504   }
505
506   augment /if:interfaces/if:interface {
507     ext:augment-identifier "vpp-interface-augmentation";
508
509     // FIXME using ietf-interfaces model for vpp interfaces makes it hard to implement because:
510     // 1. The link between interface type and this augmentation is unclear
511     // 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
512     // 3. The ietf-interfaces model does not define groupings which makes types reuse difficult
513
514     container tap {
515       when "../if:type = 'v3po:tap'";
516       uses tap-interface-base-attributes;
517       uses tap-interface-config-attributes;
518     }
519
520     container ethernet {
521       when "../if:type = 'ianaift:ethernetCsmacd'";
522       uses ethernet-base-attributes;
523     }
524
525     container routing {
526       leaf vrf-id { // todo no routing info for oper, is it possible to get it from the vpp?
527         type uint32;
528         default 0;
529       }
530     }
531
532     container vhost-user {
533       when "../if:type = 'v3po:vhost-user'";
534       uses vhost-user-interface-base-attributes;
535     }
536
537     container vxlan {
538       when "../if:type = 'v3po:vxlan-tunnel'";
539       uses vxlan-base-attributes;
540     }
541
542     container gre {
543       when "../if:type = 'v3po:gre-tunnel'";
544       uses gre-base-attributes;
545     }
546
547     container l2 {
548       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
549       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
550
551       uses l2-base-attributes;
552     }
553
554     container vxlan-gpe {
555       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
556
557       uses vxlan-gpe-base-attributes;
558     }
559
560     container proxy-arp {
561       uses proxy-arp-attributes;
562     }
563
564     container acl {
565       container ingress {
566         uses acl-base-attributes;
567       }
568       container egress {
569         uses acl-base-attributes;
570       }
571     }
572
573     container ietf-acl {
574       container ingress {
575         uses ietf-acl-base-attributes;
576       }
577       container egress {
578         uses ietf-acl-base-attributes;
579       }
580     }
581   }
582
583   container vpp {
584     description
585     "VPP config data";
586
587     container bridge-domains {
588       list bridge-domain {
589         key "name";
590
591         leaf name {
592           type string;
593         }
594
595         uses bridge-domain-attributes;
596         uses l2-fib-attributes;
597
598         description
599           "bridge-domain configuration";
600       }
601     }
602   }
603
604   augment /if:interfaces-state/if:interface {
605     ext:augment-identifier "vpp-interface-state-augmentation";
606
607     leaf description {
608       type string;
609     }
610
611     container tap {
612       when "../if:type = 'v3po:tap'";
613       uses tap-interface-base-attributes;
614     }
615
616     container ethernet {
617       when "../if:type = 'ianaift:ethernetCsmacd'";
618       uses ethernet-base-attributes;
619       uses ethernet-state-attributes;
620     }
621
622     container vhost-user {
623       when "../if:type = 'v3po:vhost-user'";
624       uses vhost-user-interface-base-attributes;
625       uses vhost-user-interface-state-attributes;
626     }
627
628     container vxlan {
629       when "../if:type = 'v3po:vxlan-tunnel'";
630       uses vxlan-base-attributes;
631     }
632     container vxlan-gpe {
633       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
634
635       uses vxlan-gpe-base-attributes;
636     }
637
638     container gre {
639       when "../if:type = 'gre-tunnel'";
640       uses gre-base-attributes;
641     }
642
643     container l2 {
644       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
645       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
646
647       uses l2-base-attributes;
648     }
649
650     container proxy-arp {
651       uses proxy-arp-attributes;
652     }
653
654     container acl {
655       container ingress {
656         uses acl-base-attributes;
657       }
658       container egress {
659         uses acl-base-attributes;
660       }
661     }
662
663     container ietf-acl {
664       container ingress {
665         uses ietf-acl-base-attributes;
666       }
667       container egress {
668         uses ietf-acl-base-attributes;
669       }
670     }
671   }
672
673   augment /if:interfaces-state/if:interface/if:statistics {
674     ext:augment-identifier "vpp-interface-statistics-augmentation";
675     leaf in-errors-no-buf {
676       type yang:counter64;
677     }
678     leaf in-errors-miss {
679       type yang:counter64;
680     }
681     leaf out-discards-fifo-full {
682       type yang:counter64;
683     }
684   }
685
686   container vpp-state {
687     config false;
688
689     description
690       "VPP operational data";
691
692     container bridge-domains {
693       // FIXME: Should this live in bridge-domain.yang in a modular fashion ?
694       list bridge-domain {
695
696         key "name";
697         leaf name {
698           type string;
699         }
700
701         uses bridge-domain-attributes;
702         uses l2-fib-attributes;
703
704         description
705           "bridge-domain operational data";
706       }
707     }
708
709     container version {
710       leaf name {
711         type string;
712       }
713       leaf build-directory {
714         type string;
715       }
716       leaf build-date {
717         type string;
718       }
719       leaf branch {
720         type string;
721       }
722       description
723       "vlib version info";
724     }
725   }
726
727   // VPP Notifications
728
729   typedef interface-status {
730     type enumeration {
731       enum up {
732         value 1;
733       }
734       enum down {
735         value 0;
736       }
737     }
738   }
739
740   typedef interface-name-or-index {
741     type union {
742       type string;
743       type uint32;
744     }
745   }
746
747   notification interface-state-change {
748     leaf name {
749         type interface-name-or-index;
750     }
751
752     leaf admin-status {
753         type interface-status;
754     }
755
756     leaf oper-status {
757         type interface-status;
758     }
759   }
760
761   notification interface-deleted {
762     leaf name {
763         type interface-name-or-index;
764     }
765   }
766 }