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