Remove reduntant list of interfaces for BD
[honeycomb.git] / v3po / api / src / main / yang / vpp-vlan.yang
1 module vpp-vlan {
2   yang-version 1;
3   namespace "urn:opendaylight:params:xml:ns:yang:vpp:vlan";
4   prefix "vpp-vlan";
5
6   revision "2015-05-27" {
7     description
8     "Initial revision of vlan model for VPP.
9      Reuses some concepts from draft-wilton-netmod-intf-vlan-yang-02 model.";
10   }
11
12   import ietf-interfaces {
13     prefix "if";
14   }
15   import ietf-yang-types {
16     prefix "yang";
17   }
18   import yang-ext {
19     prefix "ext";
20   }
21   import dot1q-types {
22     prefix dot1q;
23   }
24   import v3po {
25     prefix v3po;
26   }
27
28   typedef sub-interface-status {
29     type enumeration {
30       enum "up";
31       enum "down";
32     }
33   }
34
35   // todo add 802dot1ad support to dot1q-types.yang
36   /*
37    * Defines the supported IEEE 802.1Q types that can be used for
38    * VLAN tag matching.
39    */
40   identity vlan-type {
41     description "Base identity from which all VLAN types
42                  are derived from";
43   }
44
45   identity 802dot1q {
46     base vlan-type;
47     description
48       "An 802.1Q VLAN type";
49   }
50
51   identity 802dot1ad {
52     base vlan-type;
53     description
54       "An 802.1ad VLAN type";
55   }
56
57   typedef vlan-type {
58     type identityref {
59       base "vlan-type";
60     }
61     description "Identifies a specific VLAN type";
62   }
63
64   grouping match-attributes {
65     choice match-type {
66       mandatory true;
67       description "Provides a choice of how the frames may be matched";
68
69       case default {
70         description "Default match";
71         leaf default {
72           type empty;
73           description
74             "Default match.  Matches all traffic not matched to any
75              other peer sub-interface by a more specific
76              encapsulation.";
77         } // leaf default
78       } // case default
79
80       case untagged {
81         description "Match untagged Ethernet frames only";
82         leaf untagged {
83           type empty;
84             description
85               "Untagged match.  Matches all untagged traffic.";
86         } // leaf untagged
87       } // case untagged
88
89       case vlan-tagged {
90         container vlan-tagged {
91           description "Matches VLAN tagged frames. Vlan tags need to be specified to use this match type";
92
93           leaf match-exact-tags {
94             type boolean;
95             default true;
96             description
97               "If set, indicates that all 802.1Q VLAN tags in the
98                Ethernet frame header must be explicitly matched, i.e.
99                the EtherType following the matched tags must not be a
100                802.1Q tag EtherType.  If unset then extra 802.1Q VLAN
101                tags are allowed.";
102           }
103         } // container vlan-tagged
104       } // case vlan-tagged
105     }
106   }
107
108   // TODO VPP does not allow to change subinterface nor delete it (except for tag-rewrite operation)
109   grouping sub-interface-base-attributes {
110     leaf vlan-type {
111       type vlan-type;
112       default 802dot1q;
113     }
114
115     container tags {
116       list tag {
117         key "index";
118         max-elements 2;
119
120         description "The VLAN tags to use by locally sourced traffic";
121
122         leaf index {
123           type uint8 {
124             range "0..1";
125           }
126
127           /*
128            * Only allow a push of an inner tag if an outer tag is also
129            * being pushed.
130            */
131           must "index != 0 or
132                 count(../../push-tags[index = 0]/index) > 0" {
133             error-message "An inner tag can only be pushed if an outer
134                            tag is also specified";
135             description "Only allow a push of an inner tag if an outer
136                          tag is also being pushed";
137           }
138           description "The index into the tag stack";
139         }
140
141         uses dot1q:dot1q-tag-or-any;
142
143       }
144     }
145
146     container match {
147       description
148        "The match used to classify frames to this interface";
149       uses match-attributes;
150     }
151
152     container l2 {
153       uses v3po:l2-base-attributes;
154       container rewrite {
155         uses tag-rewrite;
156       }
157     }
158   }
159
160   grouping sub-interface-config-attributes {
161     leaf enabled {
162       type boolean;
163       default "false";
164       description
165         "Contains the configured, desired state of the sub-interface.
166         To enable sub-interface, the super inerface needs to be enabled";
167     }
168   }
169
170   grouping sub-interface-operational-attributes {
171     leaf admin-status {
172       type sub-interface-status;
173       mandatory true;
174     }
175     leaf oper-status {
176       type sub-interface-status;
177       mandatory true;
178     }
179     leaf if-index {
180       type int32 {
181         range "1..2147483647";
182       }
183       mandatory true;
184     }
185     leaf phys-address {
186       type yang:phys-address;
187       description
188         "The sub-interface's Media Access Control (MAC) address.";
189     }
190     leaf speed {
191       type yang:gauge64;
192       units "bits/second";
193     }
194   }
195
196   /*
197    * Only symetrical rewrite is supported
198    */
199   grouping tag-rewrite {
200     description "Flexible rewrite";
201
202     leaf vlan-type { // todo rename to push_dot1q, mandatory(?) with default true
203       type vlan-type;
204       default 802dot1q;
205     }
206
207     leaf pop-tags {
208       type uint8 {
209         range 1..2;
210       }
211       description "The number of tags to pop (or translate if used in
212                    conjunction with push-tags)";
213     }
214
215     list push-tags {
216       key "index";
217       max-elements 2;
218       description "The number of tags to push (or translate if used
219                    in conjunction with pop-tags)";
220       /*
221        * Server should order by increasing index.
222        */
223       leaf index {
224         type uint8 {
225           range 0..1;
226         }
227
228         /*
229          * Only allow a push of an inner tag if an outer tag is also
230          * being pushed.
231          */
232         must "index != 0 or
233               count(../../push-tags[index = 0]/index) > 0" {
234           error-message "An inner tag can only be pushed if an outer
235                          tag is also specified";
236           description "Only allow a push of an inner tag if an outer
237                        tag is also being pushed";
238         }
239       }
240
241       uses dot1q:dot1q-tag;
242     }
243   }
244
245   augment /if:interfaces/if:interface {
246     ext:augment-identifier "subinterface-augmentation";
247
248     container sub-interfaces {
249       description "L2 vlan subinterfaces";
250
251
252       list sub-interface {
253         key "identifier";
254         leaf identifier {
255           type uint32;
256         }
257
258         uses sub-interface-base-attributes;
259         uses sub-interface-config-attributes;
260       }
261     }
262   }
263
264   augment /if:interfaces-state/if:interface {
265     ext:augment-identifier "subinterface-state-augmentation";
266
267     container sub-interfaces {
268       description "L2 vlan subinterfaces";
269
270       list sub-interface {
271         key "identifier";
272         leaf identifier {
273           type uint32;
274         }
275
276         uses sub-interface-base-attributes;
277         uses sub-interface-operational-attributes;
278       }
279     }
280   }
281
282 }