summaryrefslogtreecommitdiffstats
path: root/vpp-classifier/api/src/main/yang/vpp-classifier@2017-03-27.yang
blob: f761fea5bf7452bbaf10a0c31e44ec0198f82b28 (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
module vpp-classifier {
  yang-version 1;
  namespace "urn:opendaylight:params:xml:ns:yang:vpp:classifier";
  prefix "vpp-classifier";

  import ietf-yang-types {
    prefix "yang";
  }

  import policer {
    prefix "policer";
  }

  organization
    "FD.io - The Fast Data Project";

  contact
    "Hc2vpp Wiki <https://wiki.fd.io/view/Hc2vpp>
     Mailing List <hc2vpp@lists.fd.io>";

  description
    "This module contains a collection of YANG definitions for
     managing VPP packet classifier.

     Copyright (c) 2016-2017 Cisco and/or its affiliates.

     Licensed under the Apache License, Version 2.0 (the 'License');
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at:

     http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an 'AS IS' BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.";

  revision "2017-03-27" {
    description
      "This revision updates classify table ref to be compatible with LeafRefContext
        (ODL tool for checking leafrefs in runtime)";
  }

  revision "2017-03-15" {
    description
      "This revision adds policer support";
  }

  revision "2016-12-14" {
    description
      "This revision adds the following new features:
        - updates order of union types for opaque-index";
  }

  revision "2016-06-03" {
    description
      "Initial revision of model for VPP packet classifier.
      The model can be used ony to implement ACLs.
      Other classify table usages are not supported yet,
      see https://jira.fd.io/browse/VPP-203 for details.";
    reference
      "https://wiki.fd.io/view/VPP/Introduction_To_N-tuple_Classifiers";
  }

  typedef classify-table-ref {
    type leafref {
      path "/vpp-classifier/classify-table/name";
    }
    description
      "This type is used by data models that need to reference
       configured classify tables.";
  }

  typedef packet-handling-action {
    type enumeration {
      enum "deny" {
        // by VPP convention, first neighbour node (at index 0) is a drop node
        value 0;
      }
      enum "permit" {
        value -1; // indicates that the next node not set
      }
    }
  }

  typedef vpp-node-name {
    type string;
  }

  typedef vpp-node {
    type union {
      type packet-handling-action;
      type vpp-node-name;
    }
    description
      "Defines VPP node reference using packet handling action or relative node name
       (if definition in terms of packet handling action is not possible).";
  }

  typedef opaque-index {
    type union {
      type uint32;
      type vpp-node;
    }
    description
      "Defines opaque-index type - metadata that can be attached to session-hit packets.
       Vpp nodes can't be referenced by index, because node indexes might change after vpp restart.";
  }

  grouping classify-session-attributes {
    description
      "Defines classify session attributes that are mapped to classify_add_del_session
       and classify_session_details messages parameters.
       Either hit_next or policer_hit_next should be defined.";

    choice next_node {
      mandatory true;
      description
        "Options for expressing the next node on classify hit and associated metadata to be passed";
      case standard {
        leaf hit_next {
          mandatory true;
          type vpp-node;
          description
            "Vpp node to which packet will be send when it produces a match.";
        }
        leaf opaque_index {
          type opaque-index;
        }
      }
      case policer {
        leaf policer_hit_next {
          mandatory true;
          type policer:policer-ref;
        }
        leaf color_classfier {
          type policer:color-classfier;
        }
      }
    }

    leaf advance {
      type int32;
      default 0;
      description
        "Nodes like ip4/6-classify use the parameter to \"consume\" networking layer.
        Example: tunnel decapsulation.";
    }
  }

  grouping classify-table-base-attributes {
    description
      "Defines classify table attributes that are mapped to classify_add_del_table message parameters.";

    leaf classifier-node {
      type vpp-node-name;
      description
        "Name of VPP node the table is defined for.";
    }
    leaf nbuckets {
      mandatory true;
      type uint32;
      description
        "Used by classifier hashing algorithm. It is not possible to resize the bucket array,
        therefore suggested value is approximate number of expected entries.";
    }
    leaf skip_n_vectors {
      type uint32;
      default 0;
      description
        "Number of 16 byte vectors to be skipped before applying mask.";
    }
    leaf next_table {
      type classify-table-ref;
      description
        "Reference to the next classify table. Required when multiple table chaining is used.";
    }
    leaf miss_next {
      mandatory true;
      type vpp-node;
      description
        "Vpp node to which packet will be send when it falis to produce a match";
    }
    leaf mask {
      type yang:hex-string;
      mandatory true;
      description
        "Defines match mask (multiple of 16 bytes)";
    }

    list classify-session {
      key "match";

      leaf match {
        type yang:hex-string;
        description
          "Defines actual value to be matched that is
           a byte vector, which length is multiple of 16 bytes";

        must "string-length(match) = string-length(../../mask)" {
          error-message
            "Match length is not equal to classify table mask length.";
          description
            "Match length must be equal to classify table mask length.";
        }
      }

      uses classify-session-attributes;
    }
  }

  grouping classify-table-config-attributes {
    description
      "Defines classify table config only attributes (present in classify_add_del_table message
       but not in classify_table_info_reply).";

    // TODO(HC2VPP-10): move to classify-table-base-attributes
    // after https://jira.fd.io/browse/VPP-208 is fixed
    leaf memory_size {
      type uint32;
      // mandatory true; // TODO(HC2VPP-10): uncomment
      description
        "Memory size for classify table and its entries.";
    }
  }

  grouping classify-table-operational-attributes {
    description
      "Defines classify table operational attributes (present in classify_table_info_reply message
       but not in classify_add_del_table).";

    leaf active_sessions {
      type uint32;
      config false;
      description
        "Number of sessions defined for the classify table.";
    }
  }

  container vpp-classifier {
    list classify-table {
      key "name";

      leaf name {
        type string;
        description
          "Hides classify table identifier managed by vpp.";
      }

      uses classify-table-base-attributes;
      uses classify-table-config-attributes;
    }
  }

  container vpp-classifier-state {
    config false;

    list classify-table {
      key "name";

      leaf name {
        type string;
        description
          "Hides classify table identifier managed by vpp.";
      }

      uses classify-table-base-attributes;
      uses classify-table-operational-attributes;
    }
  }
}