]> git.proxmox.com Git - ovs.git/blob - include/openflow/openflow-1.3.h
ofp-flow: Reduce memory consumption for ofputil_flow_mod, using minimatch.
[ovs.git] / include / openflow / openflow-1.3.h
1 /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
2 * Junior University
3 * Copyright (c) 2011, 2012 Open Networking Foundation
4 *
5 * We are making the OpenFlow specification and associated documentation
6 * (Software) available for public use and benefit with the expectation
7 * that others will use, modify and enhance the Software and contribute
8 * those enhancements back to the community. However, since we would
9 * like to make the Software available for broadest use, with as few
10 * restrictions as possible permission is hereby granted, free of
11 * charge, to any person obtaining a copy of this Software to deal in
12 * the Software under the copyrights without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sublicense, and/or sell copies of the Software, and to
15 * permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 * SOFTWARE.
29 *
30 * The name and trademarks of copyright holder(s) may NOT be used in
31 * advertising or publicity pertaining to the Software or any
32 * derivatives without specific, written prior permission.
33 */
34
35 /* OpenFlow: protocol between controller and datapath. */
36
37 #ifndef OPENFLOW_13_H
38 #define OPENFLOW_13_H 1
39
40 #include <openflow/openflow-1.2.h>
41
42 /*
43 * OpenFlow 1.3 modifies the syntax of the following message types:
44 *
45 * OFPT_FEATURES_REPLY = 6 (opf13_switch_features)
46 * - new field: auxiliary_id
47 * - removed: ofp_ports at the end
48 *
49 * OFPT_PACKET_IN = 10 (appends an ovs_be64 to ofp12_packet_in)
50 *
51 * OpenFlow 1.3 adds following new message types:
52 *
53 * * Asynchronous message configuration. *
54 * OFPT13_GET_ASYNC_REQUEST = 26 (void)
55 * OFPT13_GET_ASYNC_REPLY = 27 (ofp13_async_config)
56 * OFPT13_SET_ASYNC = 28 (ofp13_async_config)
57 *
58 * * Meters and rate limiters configuration messages. *
59 * OFPT13_METER_MOD = 29 (ofp13_meter_mod)
60 *
61 * OpenFlow 1.3 modifies the syntax of the following statistics message types
62 * (now called multipart message types):
63 *
64 * OFPMP13_FLOW_REPLY = 1 (struct ofp13_flow_stats[])
65 * OFPMP13_TABLE_REPLY = 3 (struct ofp13_table_stats[])
66 * OFPMP13_PORT_REPLY = 4 (struct ofp13_port_stats[])
67 * OFPMP13_QUEUE_REPLY = 5, (struct ofp13_queue_stats[])
68 * OFPMP13_GROUP_REPLY = 6, (struct ofp13_group_stats[])
69 *
70 * OpenFlow 1.3 adds the following multipart message types
71 *
72 * Meter statistics:
73 * OFPMP13_METER_REQUEST = 9, (struct ofp13_meter_multipart_request)
74 * OFPMP13_METER_REPLY = 9, (struct ofp13_meter_stats[])
75 *
76 * Meter configuration:
77 * OFPMP13_METER_CONFIG_REQUEST = 10, (struct ofp13_meter_multipart_request)
78 * OFPMP13_METER_CONFIG_REPLY = 10, (struct ofp13_meter_config[])
79 *
80 * Meter features:
81 * OFPMP13_METER_FEATURES_REQUEST = 11 (void)
82 * OFPMP13_METER_FEATURES_REPLY = 11 (struct ofp13_meter_features)
83 *
84 * Table features:
85 * OFPMP13_TABLE_FEATURES_REQUEST = 12, (struct ofp13_table_features[])
86 * OFPMP13_TABLE_FEATURES_REPLY = 12, (struct ofp13_table_features[])
87 *
88 */
89
90 enum ofp13_instruction_type {
91 OFPIT13_METER = 6 /* Apply meter (rate limiter) */
92 };
93
94 /* Instruction structure for OFPIT_METER */
95 struct ofp13_instruction_meter {
96 ovs_be16 type; /* OFPIT13_METER */
97 ovs_be16 len; /* Length is 8. */
98 ovs_be32 meter_id; /* Meter instance. */
99 };
100 OFP_ASSERT(sizeof(struct ofp13_instruction_meter) == 8);
101
102 /* enum ofp_config_flags value OFPC_INVALID_TTL_TO_CONTROLLER
103 * is deprecated in OpenFlow 1.3 */
104
105 /* Flags to configure the table. Reserved for future use. */
106 enum ofp13_table_config {
107 OFPTC13_DEPRECATED_MASK = 3 /* Deprecated bits */
108 };
109
110 /* OpenFlow 1.3 specific flags for flow_mod messages. */
111 enum ofp13_flow_mod_flags {
112 OFPFF13_NO_PKT_COUNTS = 1 << 3, /* Don't keep track of packet count. */
113 OFPFF13_NO_BYT_COUNTS = 1 << 4 /* Don't keep track of byte count. */
114 };
115
116 /* Common header for all meter bands */
117 struct ofp13_meter_band_header {
118 ovs_be16 type; /* One of OFPMBT_*. */
119 ovs_be16 len; /* Length in bytes of this band. */
120 ovs_be32 rate; /* Rate for this band. */
121 ovs_be32 burst_size; /* Size of bursts. */
122 };
123 OFP_ASSERT(sizeof(struct ofp13_meter_band_header) == 12);
124
125 /* Meter configuration. OFPT_METER_MOD. */
126 struct ofp13_meter_mod {
127 ovs_be16 command; /* One of OFPMC_*. */
128 ovs_be16 flags; /* Set of OFPMF_*. */
129 ovs_be32 meter_id; /* Meter instance. */
130 /* struct ofp13_meter_band_header bands[0]; The bands length is inferred
131 from the length field in the
132 header. */
133 };
134 OFP_ASSERT(sizeof(struct ofp13_meter_mod) == 8);
135
136 /* Meter numbering. Flow meters can use any number up to OFPM_MAX. */
137 enum ofp13_meter {
138 /* Last usable meter. */
139 OFPM13_MAX = 0xffff0000,
140 /* Virtual meters. */
141 OFPM13_SLOWPATH = 0xfffffffd, /* Meter for slow datapath. */
142 OFPM13_CONTROLLER = 0xfffffffe, /* Meter for controller connection. */
143 OFPM13_ALL = 0xffffffff, /* Represents all meters for stat requests
144 commands. */
145 };
146
147 /* Meter commands */
148 enum ofp13_meter_mod_command {
149 OFPMC13_ADD, /* New meter. */
150 OFPMC13_MODIFY, /* Modify specified meter. */
151 OFPMC13_DELETE /* Delete specified meter. */
152 };
153
154 /* Meter configuration flags */
155 enum ofp13_meter_flags {
156 OFPMF13_KBPS = 1 << 0, /* Rate value in kb/s (kilo-bit per second). */
157 OFPMF13_PKTPS = 1 << 1, /* Rate value in packet/sec. */
158 OFPMF13_BURST = 1 << 2, /* Do burst size. */
159 OFPMF13_STATS = 1 << 3 /* Collect statistics. */
160 };
161
162 /* Meter band types */
163 enum ofp13_meter_band_type {
164 OFPMBT13_DROP = 1, /* Drop packet. */
165 OFPMBT13_DSCP_REMARK = 2, /* Remark DSCP in the IP header. */
166 OFPMBT13_EXPERIMENTER = 0xFFFF /* Experimenter meter band. */
167 };
168
169 /* OFPMBT_DROP band - drop packets */
170 struct ofp13_meter_band_drop {
171 ovs_be16 type; /* OFPMBT_DROP. */
172 ovs_be16 len; /* Length in bytes of this band. */
173 ovs_be32 rate; /* Rate for dropping packets. */
174 ovs_be32 burst_size; /* Size of bursts. */
175 uint8_t pad[4];
176 };
177 OFP_ASSERT(sizeof(struct ofp13_meter_band_drop) == 16);
178
179 /* OFPMBT_DSCP_REMARK band - Remark DSCP in the IP header */
180 struct ofp13_meter_band_dscp_remark {
181 ovs_be16 type; /* OFPMBT_DSCP_REMARK. */
182 ovs_be16 len; /* Length in bytes of this band. */
183 ovs_be32 rate; /* Rate for remarking packets. */
184 ovs_be32 burst_size; /* Size of bursts. */
185 uint8_t prec_level; /* Number of drop precedence level to add. */
186 uint8_t pad[3];
187 };
188 OFP_ASSERT(sizeof(struct ofp13_meter_band_dscp_remark) == 16);
189
190 /* OFPMBT_EXPERIMENTER band - Write actions in action set */
191 struct ofp13_meter_band_experimenter {
192 ovs_be16 type; /* OFPMBT_EXPERIMENTER. */
193 ovs_be16 len; /* Length in bytes of this band. */
194 ovs_be32 rate; /* Rate for dropping packets. */
195 ovs_be32 burst_size; /* Size of bursts. */
196 ovs_be32 experimenter; /* Experimenter ID which takes the same form as
197 in struct ofp_experimenter_header. */
198 };
199 OFP_ASSERT(sizeof(struct ofp13_meter_band_experimenter) == 16);
200
201 /* OF 1.3 adds MORE flag also for requests */
202 enum ofp13_multipart_request_flags {
203 OFPMPF13_REQ_MORE = 1 << 0 /* More requests to follow. */
204 };
205
206 /* OF 1.3 splits table features off the ofp_table_stats */
207 /* Body of reply to OFPMP13_TABLE request. */
208 struct ofp13_table_stats {
209 uint8_t table_id; /* Identifier of table. Lower numbered tables are
210 consulted first. */
211 uint8_t pad[3]; /* Align to 32-bits. */
212 ovs_be32 active_count; /* Number of active entries. */
213 ovs_be64 lookup_count; /* Number of packets looked up in table. */
214 ovs_be64 matched_count; /* Number of packets that hit table. */
215 };
216 OFP_ASSERT(sizeof(struct ofp13_table_stats) == 24);
217
218 /* Body for ofp_multipart_request of type OFPMP_TABLE_FEATURES./
219 * Body of reply to OFPMP_TABLE_FEATURES request. */
220 struct ofp13_table_features {
221 ovs_be16 length; /* Length is padded to 64 bits. */
222 uint8_t table_id; /* Identifier of table. Lower numbered tables
223 are consulted first. */
224 uint8_t pad[5]; /* Align to 64-bits. */
225 char name[OFP_MAX_TABLE_NAME_LEN];
226 ovs_be64 metadata_match; /* Bits of metadata table can match. */
227 ovs_be64 metadata_write; /* Bits of metadata table can write. */
228
229 /* In OF1.3 this field was named 'config' and it was useless because OF1.3
230 * did not define any OFPTC_* bits.
231 *
232 * OF1.4 renamed this field to 'capabilities' and added OFPTC14_EVICTION
233 * and OFPTC14_VACANCY_EVENTS. */
234 ovs_be32 capabilities; /* Bitmap of OFPTC_* values */
235
236 ovs_be32 max_entries; /* Max number of entries supported. */
237
238 /* Table Feature Property list */
239 /* struct ofp13_table_feature_prop_header properties[0]; */
240 };
241 OFP_ASSERT(sizeof(struct ofp13_table_features) == 64);
242
243 /* Table Feature property types.
244 * Low order bit cleared indicates a property for a regular Flow Entry.
245 * Low order bit set indicates a property for the Table-Miss Flow Entry. */
246 enum ofp13_table_feature_prop_type {
247 OFPTFPT13_INSTRUCTIONS = 0, /* Instructions property. */
248 OFPTFPT13_INSTRUCTIONS_MISS = 1, /* Instructions for table-miss. */
249 OFPTFPT13_NEXT_TABLES = 2, /* Next Table property. */
250 OFPTFPT13_NEXT_TABLES_MISS = 3, /* Next Table for table-miss. */
251 OFPTFPT13_WRITE_ACTIONS = 4, /* Write Actions property. */
252 OFPTFPT13_WRITE_ACTIONS_MISS = 5, /* Write Actions for table-miss. */
253 OFPTFPT13_APPLY_ACTIONS = 6, /* Apply Actions property. */
254 OFPTFPT13_APPLY_ACTIONS_MISS = 7, /* Apply Actions for table-miss. */
255 OFPTFPT13_MATCH = 8, /* Match property. */
256 OFPTFPT13_WILDCARDS = 10, /* Wildcards property. */
257 OFPTFPT13_WRITE_SETFIELD = 12, /* Write Set-Field property. */
258 OFPTFPT13_WRITE_SETFIELD_MISS = 13, /* Write Set-Field for table-miss. */
259 OFPTFPT13_APPLY_SETFIELD = 14, /* Apply Set-Field property. */
260 OFPTFPT13_APPLY_SETFIELD_MISS = 15, /* Apply Set-Field for table-miss. */
261 OFPTFPT13_EXPERIMENTER = 0xFFFE, /* Experimenter property. */
262 OFPTFPT13_EXPERIMENTER_MISS = 0xFFFF, /* Experimenter for table-miss. */
263 };
264
265 /* Body of reply to OFPMP13_PORT request. If a counter is unsupported, set
266 * the field to all ones. */
267 struct ofp13_port_stats {
268 struct ofp11_port_stats ps;
269 ovs_be32 duration_sec; /* Time port has been alive in seconds. */
270 ovs_be32 duration_nsec; /* Time port has been alive in nanoseconds
271 beyond duration_sec. */
272 };
273 OFP_ASSERT(sizeof(struct ofp13_port_stats) == 112);
274
275 /* Body of reply to OFPMP13_QUEUE request */
276 struct ofp13_queue_stats {
277 struct ofp11_queue_stats qs;
278 ovs_be32 duration_sec; /* Time queue has been alive in seconds. */
279 ovs_be32 duration_nsec; /* Time queue has been alive in nanoseconds
280 beyond duration_sec. */
281 };
282 OFP_ASSERT(sizeof(struct ofp13_queue_stats) == 40);
283
284 /* Body of reply to OFPMP13_GROUP request */
285 struct ofp13_group_stats {
286 struct ofp11_group_stats gs;
287 ovs_be32 duration_sec; /* Time group has been alive in seconds. */
288 ovs_be32 duration_nsec; /* Time group has been alive in nanoseconds
289 beyond duration_sec. */
290 /* struct ofp11_bucket_counter bucket_stats[]; */
291 };
292 OFP_ASSERT(sizeof(struct ofp13_group_stats) == 40);
293
294 /* Body of OFPMP13_METER and OFPMP13_METER_CONFIG requests. */
295 struct ofp13_meter_multipart_request {
296 ovs_be32 meter_id; /* Meter instance, or OFPM_ALL. */
297 uint8_t pad[4]; /* Align to 64 bits. */
298 };
299 OFP_ASSERT(sizeof(struct ofp13_meter_multipart_request) == 8);
300
301 /* Statistics for each meter band */
302 struct ofp13_meter_band_stats {
303 ovs_be64 packet_band_count; /* Number of packets in band. */
304 ovs_be64 byte_band_count; /* Number of bytes in band. */
305 };
306 OFP_ASSERT(sizeof(struct ofp13_meter_band_stats) == 16);
307
308 /* Body of reply to OFPMP13_METER request. Meter statistics. */
309 struct ofp13_meter_stats {
310 ovs_be32 meter_id; /* Meter instance. */
311 ovs_be16 len; /* Length in bytes of this stats. */
312 uint8_t pad[6];
313 ovs_be32 flow_count; /* Number of flows bound to meter. */
314 ovs_be64 packet_in_count; /* Number of packets in input. */
315 ovs_be64 byte_in_count; /* Number of bytes in input. */
316 ovs_be32 duration_sec; /* Time meter has been alive in seconds. */
317 ovs_be32 duration_nsec; /* Time meter has been alive in nanoseconds
318 beyond duration_sec. */
319 struct ofp13_meter_band_stats band_stats[0]; /* The band_stats length is
320 inferred from the length field. */
321 };
322 OFP_ASSERT(sizeof(struct ofp13_meter_stats) == 40);
323
324 /* Body of reply to OFPMP13_METER_CONFIG request. Meter configuration. */
325 struct ofp13_meter_config {
326 ovs_be16 length; /* Length of this entry. */
327 ovs_be16 flags; /* Set of OFPMC_* that apply. */
328 ovs_be32 meter_id; /* Meter instance. */
329 /* struct ofp13_meter_band_header bands[0]; The bands length is inferred
330 from the length field. */
331 };
332 OFP_ASSERT(sizeof(struct ofp13_meter_config) == 8);
333
334 /* Body of reply to OFPMP13_METER_FEATURES request. Meter features. */
335 struct ofp13_meter_features {
336 ovs_be32 max_meter; /* Maximum number of meters. */
337 ovs_be32 band_types; /* Bitmaps of OFPMBT13_* values supported. */
338 ovs_be32 capabilities; /* Bitmaps of "ofp13_meter_flags". */
339 uint8_t max_bands; /* Maximum bands per meters */
340 uint8_t max_color; /* Maximum color value */
341 uint8_t pad[2];
342 };
343 OFP_ASSERT(sizeof(struct ofp13_meter_features) == 16);
344
345 /* Asynchronous message configuration. */
346 /* The body of this is the same as nx_async_config */
347 /* OFPT_GET_ASYNC_REPLY or OFPT_SET_ASYNC. */
348 struct ofp13_async_config {
349 ovs_be32 packet_in_mask[2]; /* Bitmasks of OFPR_* values. */
350 ovs_be32 port_status_mask[2]; /* Bitmasks of OFPPR_* values. */
351 ovs_be32 flow_removed_mask[2];/* Bitmasks of OFPRR_* values. */
352 };
353 OFP_ASSERT(sizeof(struct ofp13_async_config) == 24);
354
355 #endif /* openflow/openflow-1.3.h */