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