HONEYCOMB-83: Add Gre Feature within HC
[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
159   // TODO express constraints for L2 FIB entries in YANG if possible
160   grouping l2-fib-attributes {
161     container l2-fib-table {
162       list l2-fib-entry {
163         key "phys-address";
164
165         leaf phys-address {
166           type yang:phys-address;
167         }
168
169         leaf outgoing-interface {
170           type string;
171           // mandatory true;
172           // mandatory for forward action
173           // FIXME VPP's CLI does not require to set iface id for filter action
174           // VPP's binary api in constrast to CLI does some checks on the iface id value,
175           // so currently it has to be set for all actions
176           description
177             "One of interfaces assigned to the FIB table's bridge-domain.";
178         }
179         leaf static-config {
180           type boolean;
181           default false;
182           description
183             "Static entries cannot be overridden by mac learning.";
184         }
185         leaf action {
186           type l2-fib-action;
187           mandatory true;
188           description
189             "L2 FIB action. For filter action, entry must be configured as static.";
190         }
191         leaf bridged-virtual-interface {
192           when "../v3po:action = 'forward'";
193           type boolean;
194           config false; // FIXME setting bvi is currently not supported by VPP's binary api
195         }
196       }
197     }
198   }
199
200   grouping tap-interface-base-attributes {
201     leaf tap-name {
202       type string;
203     }
204   }
205
206   grouping tap-interface-config-attributes {
207     leaf mac {
208       type yang:phys-address;
209       mandatory false;
210       description "Mac address to be set for the tap interface. Random will be used if not configured";
211     }
212
213     leaf device-instance {
214       type uint32;
215       mandatory false;
216       description "Custom device instance. Autogenerated will be used if not configured";
217     }
218   }
219
220   grouping ethernet-base-attributes {
221     leaf mtu {
222       type uint16 {
223         range "64..9216";
224       }
225       units "octets";
226       default 9216;
227       description
228       "The size, in octets, of the largest packet that the
229        hardware interface will send and receive.";
230     }
231   }
232
233   grouping ethernet-state-attributes {
234     leaf manufacturer-description {
235       type string;
236       config false;
237     }
238     leaf duplex {
239       type enumeration {
240         enum "half";
241         enum "full";
242       }
243       config false;
244     }
245   }
246
247   grouping vhost-user-interface-base-attributes {
248     leaf socket {
249       type string {
250         length 1..255;
251       }
252     }
253     leaf role {
254       type vhost-user-role;
255       default "server";
256     }
257     description "vhost-user settings";
258   }
259
260   grouping vhost-user-interface-state-attributes {
261     leaf features {
262       type uint64;
263       config false;
264     }
265     leaf virtio-net-hdr-size {
266       type uint32;
267       config false;
268     }
269     leaf num-memory-regions {
270       type uint32;
271       config false;
272     }
273     leaf connect-error {
274       type string;
275       config false;
276     }
277   }
278
279   grouping vxlan-base-attributes {
280     // FIXME: this should be in an vxlan-specific extension
281     leaf src {
282       /*mandatory true;*/
283       type inet:ip-address;
284     }
285     leaf dst {
286       /*mandatory true;*/
287       type inet:ip-address;
288     }
289     leaf vni {
290       /*mandatory true;*/
291       type vxlan-vni;
292     }
293     leaf encap-vrf-id {
294       type uint32;
295     }
296   }
297
298   grouping gre-base-attributes {
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 outer-fib-id {
308       type uint32;
309     }
310   }
311
312   grouping vxlan-gpe-base-attributes {
313     leaf local {
314       /*mandatory true;*/
315       type inet:ip-address;
316     }
317     leaf remote {
318       /*mandatory true;*/
319       type inet:ip-address;
320     }
321     leaf vni {
322       /*mandatory true;*/
323       type vxlan-gpe-vni;
324     }
325     leaf next-protocol {
326       type vxlan-gpe-next-protocol;
327     }
328     leaf encap-vrf-id {
329       type uint32;
330     }
331     leaf decap-vrf-id {
332       type uint32;
333     }
334   }
335
336   grouping l2-base-attributes {
337       description
338       "Parameters for configuring Layer2 features on interfaces.";
339
340       choice interconnection {
341         case xconnect-based {
342           leaf xconnect-outgoing-interface {
343             /* Don't allow selection of this interface */
344             must "../../if:name != current()";
345             type if:interface-ref; // todo use interface-state-ref for operational data?
346             description
347               "L2 xconnect mode";
348           }
349         }
350         case bridge-based {
351           leaf bridge-domain {
352             type bridge-domain-ref;
353             mandatory true;
354             description
355               "Interfaces in a bridge-domain forward packets to other
356                interfaces in the same bridge-domain based on
357                destination mac address.";
358           }
359           leaf split-horizon-group {
360             when "../bridge-domain";
361             type uint8 {
362               range "1..255";
363             }
364             description
365               "Interface's split-horizon group. Interfaces in the same
366                bridge-domain and split-horizon group can not forward
367                packets between each other. ";
368           }
369           leaf bridged-virtual-interface {
370             when "../bridge-domain";
371             type boolean;
372             default false;
373             description
374               "Interface forward packets in the bridge-domain
375                associated with the BVI.";
376           }
377         }
378       }
379   }
380
381   grouping acl-base-attributes {
382     description
383       "Defines references to classify tables.
384        At least one table reference should be specified.";
385     container l2-acl {
386       leaf classify-table {
387         type vpp-classifier:classify-table-ref;
388         description
389           "An L2 ACL table";
390       }
391     }
392     container ip4-acl {
393       leaf classify-table {
394         type vpp-classifier:classify-table-ref;
395         description
396           "An IPv4 ACL table";
397       }
398     }
399     container ip6-acl {
400       leaf classify-table {
401         type vpp-classifier:classify-table-ref;
402         description
403           "An IPv6 ACL table";
404       }
405     }
406   }
407
408   augment /if:interfaces/if:interface {
409     ext:augment-identifier "vpp-interface-augmentation";
410
411     // FIXME using ietf-interfaces model for vpp interfaces makes it hard to implement because:
412     // 1. The link between interface type and this augmentation is unclear
413     // 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
414     // 3. The ietf-interfaces model does not define groupings which makes types reuse difficult
415
416     container tap {
417       when "../if:type = 'v3po:tap'";
418       uses tap-interface-base-attributes;
419       uses tap-interface-config-attributes;
420     }
421
422     container ethernet {
423       when "../if:type = 'ianaift:ethernetCsmacd'";
424       uses ethernet-base-attributes;
425     }
426
427     container routing {
428       leaf vrf-id { // todo no routing info for oper, is it possible to get it from the vpp?
429         type uint32;
430         default 0;
431       }
432     }
433
434     container vhost-user {
435       when "../if:type = 'v3po:vhost-user'";
436       uses vhost-user-interface-base-attributes;
437     }
438
439     container vxlan {
440       when "../if:type = 'v3po:vxlan-tunnel'";
441       uses vxlan-base-attributes;
442     }
443
444     container gre {
445       when "../if:type = 'v3po:gre-tunnel'";
446       uses gre-base-attributes;
447     }
448
449     container l2 {
450       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
451       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
452
453       uses l2-base-attributes;
454     }
455
456     container vxlan-gpe {
457       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
458
459       uses vxlan-gpe-base-attributes;
460     }
461
462     container acl {
463       uses acl-base-attributes;
464     }
465   }
466
467   container vpp {
468     description
469     "VPP config data";
470
471     container bridge-domains {
472       list bridge-domain {
473         key "name";
474
475         leaf name {
476           type string;
477         }
478
479         uses bridge-domain-attributes;
480         uses l2-fib-attributes;
481
482         description
483           "bridge-domain configuration";
484       }
485     }
486   }
487
488   augment /if:interfaces-state/if:interface {
489     ext:augment-identifier "vpp-interface-state-augmentation";
490
491     leaf description {
492       type string;
493     }
494
495     container tap {
496       when "../if:type = 'v3po:tap'";
497       uses tap-interface-base-attributes;
498     }
499
500     container ethernet {
501       when "../if:type = 'ianaift:ethernetCsmacd'";
502       uses ethernet-base-attributes;
503       uses ethernet-state-attributes;
504     }
505
506     container vhost-user {
507       when "../if:type = 'v3po:vhost-user'";
508       uses vhost-user-interface-base-attributes;
509       uses vhost-user-interface-state-attributes;
510     }
511
512     container vxlan {
513       when "../if:type = 'v3po:vxlan-tunnel'";
514       uses vxlan-base-attributes;
515     }
516     container vxlan-gpe {
517       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
518
519       uses vxlan-gpe-base-attributes;
520     }
521
522     container gre {
523       when "../if:type = 'gre-tunnel'";
524       uses gre-base-attributes;
525     }
526
527     container l2 {
528       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
529       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
530
531       uses l2-base-attributes;
532     }
533
534     container acl {
535       uses acl-base-attributes;
536     }
537   }
538
539   augment /if:interfaces-state/if:interface/if:statistics {
540     ext:augment-identifier "vpp-interface-statistics-augmentation";
541     leaf in-errors-no-buf {
542       type yang:counter64;
543     }
544     leaf in-errors-miss {
545       type yang:counter64;
546     }
547     leaf out-discards-fifo-full {
548       type yang:counter64;
549     }
550   }
551
552   container vpp-state {
553     config false;
554
555     description
556       "VPP operational data";
557
558     container bridge-domains {
559       // FIXME: Should this live in bridge-domain.yang in a modular fashion ?
560       list bridge-domain {
561
562         key "name";
563         leaf name {
564           type string;
565         }
566
567         uses bridge-domain-attributes;
568         uses l2-fib-attributes;
569
570         description
571           "bridge-domain operational data";
572       }
573     }
574
575     container version {
576       leaf name {
577         type string;
578       }
579       leaf build-directory {
580         type string;
581       }
582       leaf build-date {
583         type string;
584       }
585       leaf branch {
586         type string;
587       }
588       description
589       "vlib version info";
590     }
591   }
592
593   // VPP Notifications
594
595   typedef interface-status {
596     type enumeration {
597       enum up {
598         value 1;
599       }
600       enum down {
601         value 0;
602       }
603     }
604   }
605
606   typedef interface-name-or-index {
607     type union {
608       type string;
609       type uint32;
610     }
611   }
612
613   notification interface-state-change {
614     leaf name {
615         type interface-name-or-index;
616     }
617
618     leaf admin-status {
619         type interface-status;
620     }
621
622     leaf oper-status {
623         type interface-status;
624     }
625   }
626
627   notification interface-deleted {
628     leaf name {
629         type interface-name-or-index;
630     }
631   }
632 }