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