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