ea2788289f0c6e5cc695ac5e415101ba7ac991da
[honeycomb.git] / v3po / api / src / main / yang / vpp-classifier.yang
1 module vpp-classifier {
2   yang-version 1;
3   namespace "urn:opendaylight:params:xml:ns:yang:vpp:classifier";
4   prefix "vpp-classifier";
5
6   revision "2016-12-14" {
7     description
8       "This revision adds the following new features:
9         - updates order of union types for opaque-index";
10   }
11
12   revision "2015-06-03" {
13     description
14       "Initial revision of model for VPP packet classifier.
15       The model can be used ony to implement ACLs.
16       Other classify table usages are not supported yet,
17       see https://jira.fd.io/browse/VPP-203 for details.";
18     reference
19       "https://wiki.fd.io/view/VPP/Introduction_To_N-tuple_Classifiers";
20   }
21
22   import ietf-yang-types {
23     prefix "yang";
24   }
25
26   typedef classify-table-ref {
27     type leafref {
28       path "/vpp-classifier:vpp-classifier/classify-table/name";
29     }
30     description
31       "This type is used by data models that need to reference
32        configured classify tables.";
33   }
34
35   typedef packet-handling-action {
36     type enumeration {
37       enum "deny" {
38         // by VPP convention, first neighbour node (at index 0) is a drop node
39         value 0;
40       }
41       enum "permit" {
42         value -1; // indicates that the next node not set
43       }
44     }
45   }
46
47   typedef vpp-node-name {
48     type string;
49   }
50
51   typedef vpp-node {
52     type union {
53       type packet-handling-action;
54       type vpp-node-name;
55     }
56     description
57       "Defines VPP node reference using packet handling action or relative node name
58        (if definition in terms of packet handling action is not possible).";
59   }
60
61   typedef opaque-index {
62     type union {
63       type uint32;
64       type vpp-node;
65     }
66     description
67       "Defines opaque-index type - metadata that can be attached to session-hit packets.
68        Vpp nodes can't be referenced by index, because node indexes might change after vpp restart.";
69   }
70
71   grouping classify-session-attributes {
72     description
73       "Defines classify session attributes that are mapped to classify_add_del_session
74        and classify_session_details messages parameters.";
75
76     leaf hit_next {
77       type vpp-node;
78       mandatory true;
79       description
80         "Vpp node to which packet will be send when it produces a match.";
81     }
82     leaf opaque_index {
83       type opaque-index;
84     }
85     leaf advance {
86       type int32;
87       default 0;
88       description
89         "Nodes like ip4/6-classify use the parameter to \"consume\" networking layer.
90         Example: tunnel decapsulation.";
91     }
92   }
93
94   grouping classify-table-base-attributes {
95     description
96       "Defines classify table attributes that are mapped to classify_add_del_table message parameters.";
97
98     leaf classifier-node {
99       type vpp-node-name;
100       description
101         "Name of VPP node the table is defined for.";
102     }
103     leaf nbuckets {
104       mandatory true;
105       type uint32;
106       description
107         "Used by classifier hashing algorithm. It is not possible to resize the bucket array,
108         therefore suggested value is approximate number of expected entries.";
109     }
110     leaf skip_n_vectors {
111       type uint32;
112       default 0;
113       description
114         "Number of 16 byte vectors to be skipped before applying mask.";
115     }
116     leaf next_table {
117       type classify-table-ref;
118       description
119         "Reference to the next classify table. Required when multiple table chaining is used.";
120     }
121     leaf miss_next {
122       mandatory true;
123       type vpp-node;
124       description
125         "Vpp node to which packet will be send when it falis to produce a match";
126     }
127     leaf mask {
128       type yang:hex-string;
129       mandatory true;
130       description
131         "Defines match mask (multiple of 16 bytes)";
132     }
133
134     list classify-session {
135       key "match";
136
137       leaf match {
138         type yang:hex-string;
139         description
140           "Defines actual value to be matched that is
141            a byte vector, which length is multiple of 16 bytes";
142
143         must "string-length(match) = string-length(../../mask)" {
144           error-message
145             "Match length is not equal to classify table mask length.";
146           description
147             "Match length must be equal to classify table mask length.";
148         }
149       }
150
151       uses classify-session-attributes;
152     }
153   }
154
155   grouping classify-table-config-attributes {
156     description
157       "Defines classify table config only attributes (present in classify_add_del_table message
158        but not in classify_table_info_reply).";
159
160     // FIXME move to classify-table-base-attributes
161     // after https://jira.fd.io/browse/VPP-208 is fixed
162     leaf memory_size {
163       type uint32;
164       mandatory true;
165       description
166         "Memory size for classify table and its entries.";
167     }
168   }
169
170   grouping classify-table-operational-attributes {
171     description
172       "Defines classify table operational attributes (present in classify_table_info_reply message
173        but not in classify_add_del_table).";
174
175     leaf active_sessions {
176       type uint32;
177       config false;
178       description
179         "Number of sessions defined for the classify table.";
180     }
181   }
182
183   container vpp-classifier {
184     list classify-table {
185       key "name";
186
187       leaf name {
188         type string;
189         description
190           "Hides classify table identifier managed by vpp.";
191       }
192
193       uses classify-table-base-attributes;
194       uses classify-table-config-attributes;
195     }
196   }
197
198   container vpp-classifier-state {
199     config false;
200
201     list classify-table {
202       key "name";
203
204       leaf name {
205         type string;
206         description
207           "Hides classify table identifier managed by vpp.";
208       }
209
210       uses classify-table-base-attributes;
211       uses classify-table-operational-attributes;
212     }
213   }
214
215 }