summaryrefslogtreecommitdiffstats
path: root/v3po/api/src/main/yang/vpp-vlan.yang
blob: fdf878b754ab4aba4848f0f6f312873aa90a55e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
module vpp-vlan {
  yang-version 1;
  namespace "urn:opendaylight:params:xml:ns:yang:vpp:vlan";
  prefix "vpp-vlan";

  revision "2015-05-27" {
    description
    "Initial revision of vlan model for VPP.
     Reuses some concepts from draft-wilton-netmod-intf-vlan-yang-02 model.";
  }

  import ietf-interfaces {
    prefix "if";
  }
  import ietf-yang-types {
    prefix "yang";
  }
  import yang-ext {
    prefix "ext";
  }
  import dot1q-types {
    prefix dot1q;
  }
  import v3po {
    prefix v3po;
  }

  typedef sub-interface-status {
    type enumeration {
      enum "up";
      enum "down";
    }
  }

  // todo add 802dot1ad support to dot1q-types.yang
  /*
   * Defines the supported IEEE 802.1Q types that can be used for
   * VLAN tag matching.
   */
  identity vlan-type {
    description "Base identity from which all VLAN types
                 are derived from";
  }

  identity 802dot1q {
    base vlan-type;
    description
      "An 802.1Q VLAN type";
  }

  identity 802dot1ad {
    base vlan-type;
    description
      "An 802.1ad VLAN type";
  }

  typedef vlan-type {
    type identityref {
      base "vlan-type";
    }
    description "Identifies a specific VLAN type";
  }

  grouping match-attributes {
    choice match-type {
      mandatory true;
      description "Provides a choice of how the frames may be matched";

      case default {
        description "Default match";
        leaf default {
          type empty;
          description
            "Default match.  Matches all traffic not matched to any
             other peer sub-interface by a more specific
             encapsulation.";
        } // leaf default
      } // case default

      case untagged {
        description "Match untagged Ethernet frames only";
        leaf untagged {
          type empty;
            description
              "Untagged match.  Matches all untagged traffic.";
        } // leaf untagged
      } // case untagged

      case vlan-tagged {
        container vlan-tagged {
          description "Matches VLAN tagged frames. Vlan tags need to be specified to use this match type";

          leaf match-exact-tags {
            type boolean;
            default true;
            description
              "If set, indicates that all 802.1Q VLAN tags in the
               Ethernet frame header must be explicitly matched, i.e.
               the EtherType following the matched tags must not be a
               802.1Q tag EtherType.  If unset then extra 802.1Q VLAN
               tags are allowed.";
          }
        } // container vlan-tagged
      } // case vlan-tagged
    }
  }

  // TODO VPP does not allow to change subinterface nor delete it (except for tag-rewrite operation)
  grouping sub-interface-base-attributes {
    leaf vlan-type {
      type vlan-type;
      default 802dot1q;
    }

    container tags {
      list tag {
        key "index";
        max-elements 2;

        description "The VLAN tags to use by locally sourced traffic";

        leaf index {
          type uint8 {
            range "0..1";
          }

          /*
           * Only allow a push of an inner tag if an outer tag is also
           * being pushed.
           */
          must "index != 0 or
                count(../../push-tags[index = 0]/index) > 0" {
            error-message "An inner tag can only be pushed if an outer
                           tag is also specified";
            description "Only allow a push of an inner tag if an outer
                         tag is also being pushed";
          }
          description "The index into the tag stack";
        }

        uses dot1q:dot1q-tag-or-any;

      }
    }

    container match {
      description
       "The match used to classify frames to this interface";
      uses match-attributes;
    }

    container l2 {
      uses v3po:l2-base-attributes;
      container rewrite {
        uses tag-rewrite;
      }
    }
  }

  grouping sub-interface-config-attributes {
    leaf enabled {
      type boolean;
      default "false";
      description
        "Contains the configured, desired state of the sub-interface.
        To enable sub-interface, the super inerface needs to be enabled";
    }
  }

  grouping sub-interface-operational-attributes {
    leaf admin-status {
      type sub-interface-status;
      mandatory true;
    }
    leaf oper-status {
      type sub-interface-status;
      mandatory true;
    }
    leaf if-index {
      type int32 {
        range "1..2147483647";
      }
      mandatory true;
    }
    leaf phys-address {
      type yang:phys-address;
      description
        "The sub-interface's Media Access Control (MAC) address.";
    }
    leaf speed {
      type yang:gauge64;
      units "bits/second";
    }
  }

  /*
   * Only symetrical rewrite is supported
   */
  grouping tag-rewrite {
    description "Flexible rewrite";

    leaf vlan-type { // todo rename to push_dot1q, mandatory(?) with default true
      type vlan-type;
      default 802dot1q;
    }

    leaf pop-tags {
      type uint8 {
        range 1..2;
      }
      description "The number of tags to pop (or translate if used in
                   conjunction with push-tags)";
    }

    list push-tags {
      key "index";
      max-elements 2;
      description "The number of tags to push (or translate if used
                   in conjunction with pop-tags)";
      /*
       * Server should order by increasing index.
       */
      leaf index {
        type uint8 {
          range 0..1;
        }

        /*
         * Only allow a push of an inner tag if an outer tag is also
         * being pushed.
         */
        must "index != 0 or
              count(../../push-tags[index = 0]/index) > 0" {
          error-message "An inner tag can only be pushed if an outer
                         tag is also specified";
          description "Only allow a push of an inner tag if an outer
                       tag is also being pushed";
        }
      }

      uses dot1q:dot1q-tag;
    }
  }

  augment /if:interfaces/if:interface {
    ext:augment-identifier "subinterface-augmentation";

    container sub-interfaces {
      description "L2 vlan subinterfaces";


      list sub-interface {
        key "identifier";
        leaf identifier {
          type uint32;
        }

        uses sub-interface-base-attributes;
        uses sub-interface-config-attributes;
      }
    }
  }

  augment /if:interfaces-state/if:interface {
    ext:augment-identifier "subinterface-state-augmentation";

    container sub-interfaces {
      description "L2 vlan subinterfaces";

      list sub-interface {
        key "identifier";
        leaf identifier {
          type uint32;
        }

        uses sub-interface-base-attributes;
        uses sub-interface-operational-attributes;
      }
    }
  }

}