blob: e0753c0d576c6b85edd6fa7a32669ea6a7e19adc [file] [log] [blame]
Rich Lane1ac43002013-12-03 12:56:35 -08001// Copyright 2013, Big Switch Networks, Inc.
2//
3// LoxiGen is licensed under the Eclipse Public License,
4// version 1.0 (EPL), with the following special exception:
5//
6// LOXI Exception
7//
8// As a special exception to the terms of the EPL, you may
9// distribute libraries generated by LoxiGen (LoxiGen Libraries)
10// under the terms of your choice, provided that copyright and
11// licensing notices generated by LoxiGen are not altered or removed
12// from the LoxiGen Libraries and the notice provided below is (i)
13// included in the LoxiGen Libraries, if distributed in source code
14// form and (ii) included in any documentation for the LoxiGen
15// Libraries, if distributed in binary form.
16//
17// Notice: "Copyright 2013, Big Switch Networks, Inc.
18// This library was generated by the LoxiGen Compiler."
19//
20// You may not use this file except in compliance with the EPL or
21// LOXI Exception. You may obtain a copy of the EPL at:
22//
23// http://www.eclipse.org/legal/epl-v10.html
24//
25// Unless required by applicable law or agreed to in writing,
26// software distributed under the License is distributed on an "AS
27// IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
28// express or implied. See the EPL for the specific language
29// governing permissions and limitations under the EPL.
30
31#version 4
Rich Lane4b1d8f42014-10-31 15:25:14 -070032#version 5
Murat Parlakisikf95672c2016-12-05 00:53:17 -080033#version 6
Rich Lane1ac43002013-12-03 12:56:35 -080034
35// We have a number of switch agents that need to be configured by the
36// controller and report stats. Some of them will have large tables (1000+
37// entries) and so need an efficient synchronization mechanism (as can be
38// accomplished using the cookie field in flowtable entries). It's a
39// significant amount of work to do this from scratch for each new table.
40// This extension (and the corresponding Indigo code) provides a framework
41// to ease implementing new tables.
42
43// We don't plan on replacing our use of the OpenFlow flow table and group
44// table with this scheme. This is intended for controlling switch
45// functionality like the ARP and LACP agents which don't map at all to
46// flow-mods.
47
48// Each switch will have a number of tables indexed by a 16-bit table ID. Each
49// table has a name, id, a set of entries, and an array of checksum buckets.
50// There is no order to the entries; stats requests will return them in an
51// arbitrary order. The controller is expected to use the table name to
52// determine the semantics of a table.
53
54// Each entry has a key, value, stats, and checksum. The key and value are TLV
55// lists given by the controller in a gentable_entry_add message. The switch must
56// return these lists in stats replies exactly as it received them. The stats
57// are a list of TLVs controlled by the switch. The stats are expected to
58// include more than simple counters (for example, last hit time or seen TCP
59// flags). The checksum is an opaque value used for table synchronization.
60
61// LOXI includes a built-in type of_checksum_128_t, which is 128 bits but
62// only requires 32-bit alignment.
63
64
65// These TLV classes are used for keys, values, and stats. Like OXM, lists of
66// TLVs are tightly packed without padding. TLV lists may include duplicates
67// and the semantics of this is left to the particular table.
68//
69// If this is eventually standardized it would be good to add a "class" type
70// member as in OXM.
71struct of_bsn_tlv {
72 uint16_t type == ?;
73 uint16_t length;
74};
75
76
77// This message sets key=value in the given table. If key already exists in the
78// table then it modifies the value, preserving stats.
79//
80// If the switch cannot process the message then it should reply with an error
81// message. The contents of the table must not be changed in case of an error.
82struct of_bsn_gentable_entry_add : of_bsn_header {
83 uint8_t version;
84 uint8_t type == 4;
85 uint16_t length;
86 uint32_t xid;
87 uint32_t experimenter == 0x5c16c7;
88 uint32_t subtype == 46;
89 uint16_t table_id;
Murat Parlakisikf95672c2016-12-05 00:53:17 -080090 uint16_t key_length == length(key);
Rich Lane1ac43002013-12-03 12:56:35 -080091 of_checksum_128_t checksum;
92 list(of_bsn_tlv_t) key;
93 list(of_bsn_tlv_t) value;
94};
95
96
97// This message deletes the entry with the given key in the given table.
98//
99// If the switch cannot process the message then it should reply with an error
100// message. The contents of the table must not be changed in case of an error.
Rich Lane45e341f2014-02-05 13:28:58 -0800101// If the key does not exist in the table no error will be generated.
Rich Lane1ac43002013-12-03 12:56:35 -0800102struct of_bsn_gentable_entry_delete : of_bsn_header {
103 uint8_t version;
104 uint8_t type == 4;
105 uint16_t length;
106 uint32_t xid;
107 uint32_t experimenter == 0x5c16c7;
108 uint32_t subtype == 47;
109 uint16_t table_id;
110 list(of_bsn_tlv_t) key;
111};
112
113
114// This message deletes a range of table entries. The checksum_mask must be a
115// prefix mask. The checksum must be zero in the bits where the checksum_mask
116// is zero.
117//
118// The switch may fail to delete some table entries. No error messages will be
119// sent, but the error_count in the reply message will be incremented.
120struct of_bsn_gentable_clear_request : of_bsn_header {
121 uint8_t version;
122 uint8_t type == 4;
123 uint16_t length;
124 uint32_t xid;
125 uint32_t experimenter == 0x5c16c7;
126 uint32_t subtype == 48;
127 uint16_t table_id;
128 pad(2);
129 of_checksum_128_t checksum;
130 of_checksum_128_t checksum_mask;
131};
132
133struct of_bsn_gentable_clear_reply : of_bsn_header {
134 uint8_t version;
135 uint8_t type == 4;
136 uint16_t length;
137 uint32_t xid;
138 uint32_t experimenter == 0x5c16c7;
139 uint32_t subtype == 49;
140 uint16_t table_id;
141 pad(2);
142 uint32_t deleted_count;
143 uint32_t error_count;
144};
145
146
147// This message sets the size of the buckets array. The switch may reject this
Rich Lanef511bf02014-01-06 11:56:30 -0800148// message if the table has entries. buckets_size must be a power of 2.
Rich Lane1ac43002013-12-03 12:56:35 -0800149struct of_bsn_gentable_set_buckets_size : of_bsn_header {
150 uint8_t version;
151 uint8_t type == 4;
152 uint16_t length;
153 uint32_t xid;
154 uint32_t experimenter == 0x5c16c7;
155 uint32_t subtype == 50;
156 uint16_t table_id;
157 pad(2);
158 uint32_t buckets_size;
159};
160
161
162// Retrieve the configuration state (key, value, and checksum) for each table
163// entry in a range of buckets.
164//
165// The checksum_mask must be a prefix mask. The checksum must be zero in the
166// bits where the checksum_mask is zero.
167struct of_bsn_gentable_entry_desc_stats_request : of_bsn_stats_request {
168 uint8_t version;
169 uint8_t type == 18;
170 uint16_t length;
171 uint32_t xid;
172 uint16_t stats_type == 0xffff;
173 enum ofp_stats_request_flags flags;
174 pad(4);
175 uint32_t experimenter == 0x5c16c7;
176 uint32_t subtype == 2;
177 uint16_t table_id;
178 pad(2);
179 of_checksum_128_t checksum;
180 of_checksum_128_t checksum_mask;
181};
182
183struct of_bsn_gentable_entry_desc_stats_entry {
184 uint16_t length;
Murat Parlakisikf95672c2016-12-05 00:53:17 -0800185 uint16_t key_length == length(key);
Rich Lane1ac43002013-12-03 12:56:35 -0800186 of_checksum_128_t checksum;
187 list(of_bsn_tlv_t) key;
188 list(of_bsn_tlv_t) value;
189};
190
191struct of_bsn_gentable_entry_desc_stats_reply : of_bsn_stats_reply {
192 uint8_t version;
193 uint8_t type == 19;
194 uint16_t length;
195 uint32_t xid;
196 uint16_t stats_type == 0xffff;
197 enum ofp_stats_reply_flags flags;
198 pad(4);
199 uint32_t experimenter == 0x5c16c7;
200 uint32_t subtype == 2;
201 list(of_bsn_gentable_entry_desc_stats_entry_t) entries;
202};
203
204
205// Retrieve the runtime state (key and stats) for each table entry in a range
206// of buckets.
207//
208// The checksum_mask must be a prefix mask. The checksum must be zero in the
209// bits where the checksum_mask is zero.
210struct of_bsn_gentable_entry_stats_request : of_bsn_stats_request {
211 uint8_t version;
212 uint8_t type == 18;
213 uint16_t length;
214 uint32_t xid;
215 uint16_t stats_type == 0xffff;
216 enum ofp_stats_request_flags flags;
217 pad(4);
218 uint32_t experimenter == 0x5c16c7;
219 uint32_t subtype == 3;
220 uint16_t table_id;
221 pad(2);
222 of_checksum_128_t checksum;
223 of_checksum_128_t checksum_mask;
224};
225
226struct of_bsn_gentable_entry_stats_entry {
227 uint16_t length;
Murat Parlakisikf95672c2016-12-05 00:53:17 -0800228 uint16_t key_length == length(key);
Rich Lane1ac43002013-12-03 12:56:35 -0800229 list(of_bsn_tlv_t) key;
230 list(of_bsn_tlv_t) stats;
231};
232
233struct of_bsn_gentable_entry_stats_reply : of_bsn_stats_reply {
234 uint8_t version;
235 uint8_t type == 19;
236 uint16_t length;
237 uint32_t xid;
238 uint16_t stats_type == 0xffff;
239 enum ofp_stats_reply_flags flags;
240 pad(4);
241 uint32_t experimenter == 0x5c16c7;
242 uint32_t subtype == 3;
243 list(of_bsn_gentable_entry_stats_entry_t) entries;
244};
245
246
247// Retrieve the description for all tables.
248struct of_bsn_gentable_desc_stats_request : of_bsn_stats_request {
249 uint8_t version;
250 uint8_t type == 18;
251 uint16_t length;
252 uint32_t xid;
253 uint16_t stats_type == 0xffff;
254 enum ofp_stats_request_flags flags;
255 pad(4);
256 uint32_t experimenter == 0x5c16c7;
257 uint32_t subtype == 4;
258};
259
260struct of_bsn_gentable_desc_stats_entry {
261 uint16_t length;
262 uint16_t table_id;
263 of_table_name_t name;
264 uint32_t buckets_size;
Rich Lane7b2a8b62014-01-02 14:00:49 -0800265 uint32_t max_entries;
266 pad(4);
Rich Lane1ac43002013-12-03 12:56:35 -0800267 /* TODO properties */
268};
269
270struct of_bsn_gentable_desc_stats_reply : of_bsn_stats_reply {
271 uint8_t version;
272 uint8_t type == 19;
273 uint16_t length;
274 uint32_t xid;
275 uint16_t stats_type == 0xffff;
276 enum ofp_stats_reply_flags flags;
277 pad(4);
278 uint32_t experimenter == 0x5c16c7;
279 uint32_t subtype == 4;
280 list(of_bsn_gentable_desc_stats_entry_t) entries;
281};
282
283
284// Retrieves stats for every table. This includes the total checksum, so the
285// controller can quickly check whether the whole table is in sync.
286//
Rich Lane7f6288b2014-06-30 17:23:59 -0700287// The checksum of a table is the sum of the checksums of all entries in the
Rich Lane1ac43002013-12-03 12:56:35 -0800288// table.
289struct of_bsn_gentable_stats_request : of_bsn_stats_request {
290 uint8_t version;
291 uint8_t type == 18;
292 uint16_t length;
293 uint32_t xid;
294 uint16_t stats_type == 0xffff;
295 enum ofp_stats_request_flags flags;
296 pad(4);
297 uint32_t experimenter == 0x5c16c7;
298 uint32_t subtype == 7;
299};
300
301struct of_bsn_gentable_stats_entry {
302 uint16_t table_id;
303 pad(2);
304 uint32_t entry_count;
305 of_checksum_128_t checksum;
306};
307
308struct of_bsn_gentable_stats_reply : of_bsn_stats_reply {
309 uint8_t version;
310 uint8_t type == 19;
311 uint16_t length;
312 uint32_t xid;
313 uint16_t stats_type == 0xffff;
314 enum ofp_stats_reply_flags flags;
315 pad(4);
316 uint32_t experimenter == 0x5c16c7;
317 uint32_t subtype == 7;
318 list(of_bsn_gentable_stats_entry_t) entries;
319};
320
321
322// Retrieves the checksum for every bucket in a table. The entries are ordered
323// by bucket index.
324//
Rich Lane7f6288b2014-06-30 17:23:59 -0700325// The checksum of a bucket is the sum of the checksums of all entries in the
Rich Lane1ac43002013-12-03 12:56:35 -0800326// bucket.
327struct of_bsn_gentable_bucket_stats_request : of_bsn_stats_request {
328 uint8_t version;
329 uint8_t type == 18;
330 uint16_t length;
331 uint32_t xid;
332 uint16_t stats_type == 0xffff;
333 enum ofp_stats_request_flags flags;
334 pad(4);
335 uint32_t experimenter == 0x5c16c7;
336 uint32_t subtype == 5;
337 uint16_t table_id;
338};
339
340struct of_bsn_gentable_bucket_stats_entry {
341 of_checksum_128_t checksum;
342};
343
344struct of_bsn_gentable_bucket_stats_reply : of_bsn_stats_reply {
345 uint8_t version;
346 uint8_t type == 19;
347 uint16_t length;
348 uint32_t xid;
349 uint16_t stats_type == 0xffff;
350 enum ofp_stats_reply_flags flags;
351 pad(4);
352 uint32_t experimenter == 0x5c16c7;
353 uint32_t subtype == 5;
354 list(of_bsn_gentable_bucket_stats_entry_t) entries;
355};
Rich Lanefc9bbff2014-10-23 09:35:20 -0700356
357// Reference a gentable entry from an action list
358struct of_action_bsn_gentable : of_action_bsn {
359 uint16_t type == 65535;
360 uint16_t len;
361 uint32_t experimenter == 0x5c16c7;
362 uint32_t subtype == 5;
363 uint32_t table_id;
364 list(of_bsn_tlv_t) key;
365};
Murat Parlakisikf95672c2016-12-05 00:53:17 -0800366
367enum of_bsn_gentable_error_code(wire_type=uint16_t) {
368 OF_BSN_GENTABLE_ERROR_UNKNOWN = 0,
369 OF_BSN_GENTABLE_ERROR_PARAM = 1, // invalid parameter
370 OF_BSN_GENTABLE_ERROR_TABLE_FULL = 2,
371};
372
373// BSN gentable error message
374struct of_bsn_gentable_error : of_bsn_base_error {
375 uint8_t version;
376 uint8_t type == 1;
377 uint16_t length;
378 uint32_t xid;
379 uint16_t err_type == 0xffff;
380 uint16_t subtype == 2;
381 uint32_t experimenter == 0x5c16c7;
382 enum of_bsn_gentable_error_code error_code;
383 uint16_t table_id;
384 of_desc_str_t err_msg;
385 of_octets_t data;
386};