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