1 /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
3 * Copyright (c) 2011, 2012 Open Networking Foundation
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:
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
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
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.
35 /* OpenFlow: protocol between controller and datapath. */
38 #define OPENFLOW_13_H 1
40 #include "openflow/openflow-1.2.h"
43 * OpenFlow 1.3 modifies the syntax of the following message types:
45 * OFPT_FEATURES_REPLY = 6 (opf13_switch_features)
46 * - new field: auxiliary_id
47 * - removed: ofp_ports at the end
49 * OFPT_PACKET_IN = 10 (ofp13_packet_in) new field: cookie
51 * OpenFlow 1.3 adds following new message types:
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)
58 * * Meters and rate limiters configuration messages. *
59 * OFPT13_METER_MOD = 29 (ofp13_meter_mod)
61 * OpenFlow 1.3 modifies the syntax of the following statistics message types
62 * (now called multipart message types):
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[])
70 * OpenFlow 1.3 adds the following multipart message types
73 * OFPMP13_METER_REQUEST = 9, (struct ofp13_meter_multipart_request)
74 * OFPMP13_METER_REPLY = 9, (struct ofp13_meter_stats[])
76 * Meter configuration:
77 * OFPMP13_METER_CONFIG_REQUEST = 10, (struct ofp13_meter_multipart_request)
78 * OFPMP13_METER_CONFIG_REPLY = 10, (struct ofp13_meter_config[])
81 * OFPMP13_METER_FEATURES_REQUEST = 11 (void)
82 * OFPMP13_METER_FEATURES_REPLY = 11 (struct ofp13_meter_features)
85 * OFPMP13_TABLE_FEATURES_REQUEST = 12, (struct ofp13_table_features[])
86 * OFPMP13_TABLE_FEATURES_REPLY = 12, (struct ofp13_table_features[])
90 enum ofp13_instruction_type {
91 OFPIT13_METER = 6 /* Apply meter (rate limiter) */
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. */
100 OFP_ASSERT(sizeof(struct ofp13_instruction_meter) == 8);
102 enum ofp13_action_type {
103 OFPAT13_OUTPUT = 0, /* Output to switch port. */
104 OFPAT13_COPY_TTL_OUT = 11, /* Copy TTL "outwards" -- from next-to-outermost
106 OFPAT13_COPY_TTL_IN = 12, /* Copy TTL "inwards" -- from outermost to
108 OFPAT13_SET_MPLS_TTL = 15, /* MPLS TTL */
109 OFPAT13_DEC_MPLS_TTL = 16, /* Decrement MPLS TTL */
110 OFPAT13_PUSH_VLAN = 17, /* Push a new VLAN tag */
111 OFPAT13_POP_VLAN = 18, /* Pop the outer VLAN tag */
112 OFPAT13_PUSH_MPLS = 19, /* Push a new MPLS Label Stack Entry */
113 OFPAT13_POP_MPLS = 20, /* Pop the outer MPLS Label Stack Entry */
114 OFPAT13_SET_QUEUE = 21, /* Set queue id when outputting to a port */
115 OFPAT13_GROUP = 22, /* Apply group. */
116 OFPAT13_SET_NW_TTL = 23, /* IP TTL. */
117 OFPAT13_DEC_NW_TTL = 24, /* Decrement IP TTL. */
118 OFPAT13_SET_FIELD = 25, /* Set a header field using OXM TLV format. */
119 OFPAT13_PUSH_PBB = 26, /* Push a new PBB service tag (I-TAG) */
120 OFPAT13_POP_PBB = 27 /* Pop the outer PBB service tag (I-TAG) */
123 /* enum ofp_config_flags value OFPC_INVALID_TTL_TO_CONTROLLER
124 * is deprecated in OpenFlow 1.3 */
126 /* Flags to configure the table. Reserved for future use. */
127 enum ofp13_table_config {
128 OFPTC13_DEPRECATED_MASK = 3 /* Deprecated bits */
131 /* OpenFlow 1.3 specific flags for flow_mod messages. */
132 enum ofp13_flow_mod_flags {
133 OFPFF13_NO_PKT_COUNTS = 1 << 3, /* Don't keep track of packet count. */
134 OFPFF13_NO_BYT_COUNTS = 1 << 4 /* Don't keep track of byte count. */
137 /* Common header for all meter bands */
138 struct ofp13_meter_band_header {
139 ovs_be16 type; /* One of OFPMBT_*. */
140 ovs_be16 len; /* Length in bytes of this band. */
141 ovs_be32 rate; /* Rate for this band. */
142 ovs_be32 burst_size; /* Size of bursts. */
144 OFP_ASSERT(sizeof(struct ofp13_meter_band_header) == 12);
146 /* Meter configuration. OFPT_METER_MOD. */
147 struct ofp13_meter_mod {
148 ovs_be16 command; /* One of OFPMC_*. */
149 ovs_be16 flags; /* Set of OFPMF_*. */
150 ovs_be32 meter_id; /* Meter instance. */
151 /* struct ofp13_meter_band_header bands[0]; The bands length is inferred
152 from the length field in the
155 OFP_ASSERT(sizeof(struct ofp13_meter_mod) == 8);
157 /* Meter numbering. Flow meters can use any number up to OFPM_MAX. */
159 /* Last usable meter. */
160 OFPM13_MAX = 0xffff0000,
161 /* Virtual meters. */
162 OFPM13_SLOWPATH = 0xfffffffd, /* Meter for slow datapath. */
163 OFPM13_CONTROLLER = 0xfffffffe, /* Meter for controller connection. */
164 OFPM13_ALL = 0xffffffff, /* Represents all meters for stat requests
169 enum ofp13_meter_mod_command {
170 OFPMC13_ADD, /* New meter. */
171 OFPMC13_MODIFY, /* Modify specified meter. */
172 OFPMC13_DELETE /* Delete specified meter. */
175 /* Meter configuration flags */
176 enum ofp13_meter_flags {
177 OFPMF13_KBPS = 1 << 0, /* Rate value in kb/s (kilo-bit per second). */
178 OFPMF13_PKTPS = 1 << 1, /* Rate value in packet/sec. */
179 OFPMF13_BURST = 1 << 2, /* Do burst size. */
180 OFPMF13_STATS = 1 << 3 /* Collect statistics. */
183 /* Meter band types */
184 enum ofp13_meter_band_type {
185 OFPMBT13_DROP = 1, /* Drop packet. */
186 OFPMBT13_DSCP_REMARK = 2, /* Remark DSCP in the IP header. */
187 OFPMBT13_EXPERIMENTER = 0xFFFF /* Experimenter meter band. */
190 /* OFPMBT_DROP band - drop packets */
191 struct ofp13_meter_band_drop {
192 ovs_be16 type; /* OFPMBT_DROP. */
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. */
198 OFP_ASSERT(sizeof(struct ofp13_meter_band_drop) == 16);
200 /* OFPMBT_DSCP_REMARK band - Remark DSCP in the IP header */
201 struct ofp13_meter_band_dscp_remark {
202 ovs_be16 type; /* OFPMBT_DSCP_REMARK. */
203 ovs_be16 len; /* Length in bytes of this band. */
204 ovs_be32 rate; /* Rate for remarking packets. */
205 ovs_be32 burst_size; /* Size of bursts. */
206 uint8_t prec_level; /* Number of drop precedence level to add. */
209 OFP_ASSERT(sizeof(struct ofp13_meter_band_dscp_remark) == 16);
211 /* OFPMBT_EXPERIMENTER band - Write actions in action set */
212 struct ofp13_meter_band_experimenter {
213 ovs_be16 type; /* OFPMBT_EXPERIMENTER. */
214 ovs_be16 len; /* Length in bytes of this band. */
215 ovs_be32 rate; /* Rate for dropping packets. */
216 ovs_be32 burst_size; /* Size of bursts. */
217 ovs_be32 experimenter; /* Experimenter ID which takes the same form as
218 in struct ofp_experimenter_header. */
220 OFP_ASSERT(sizeof(struct ofp13_meter_band_experimenter) == 16);
222 /* OF 1.3 adds MORE flag also for requests */
223 enum ofp13_multipart_request_flags {
224 OFPMPF13_REQ_MORE = 1 << 0 /* More requests to follow. */
227 /* OF 1.3 splits table features off the ofp_table_stats */
228 /* Body of reply to OFPMP13_TABLE request. */
229 struct ofp13_table_stats {
230 uint8_t table_id; /* Identifier of table. Lower numbered tables are
232 uint8_t pad[3]; /* Align to 32-bits. */
233 ovs_be32 active_count; /* Number of active entries. */
234 ovs_be64 lookup_count; /* Number of packets looked up in table. */
235 ovs_be64 matched_count; /* Number of packets that hit table. */
237 OFP_ASSERT(sizeof(struct ofp13_table_stats) == 24);
239 /* Common header for all Table Feature Properties */
240 struct ofp13_table_feature_prop_header {
241 ovs_be16 type; /* One of OFPTFPT_*. */
242 ovs_be16 length; /* Length in bytes of this property. */
244 OFP_ASSERT(sizeof(struct ofp13_table_feature_prop_header) == 4);
246 /* Body for ofp_multipart_request of type OFPMP_TABLE_FEATURES./
247 * Body of reply to OFPMP_TABLE_FEATURES request. */
248 struct ofp13_table_features {
249 ovs_be16 length; /* Length is padded to 64 bits. */
250 uint8_t table_id; /* Identifier of table. Lower numbered tables
251 are consulted first. */
252 uint8_t pad[5]; /* Align to 64-bits. */
253 char name[OFP_MAX_TABLE_NAME_LEN];
254 ovs_be64 metadata_match; /* Bits of metadata table can match. */
255 ovs_be64 metadata_write; /* Bits of metadata table can write. */
256 ovs_be32 config; /* Bitmap of OFPTC_* values */
257 ovs_be32 max_entries; /* Max number of entries supported. */
259 /* Table Feature Property list */
260 /* struct ofp13_table_feature_prop_header properties[0]; */
262 OFP_ASSERT(sizeof(struct ofp13_table_features) == 64);
264 /* Table Feature property types.
265 * Low order bit cleared indicates a property for a regular Flow Entry.
266 * Low order bit set indicates a property for the Table-Miss Flow Entry. */
267 enum ofp13_table_feature_prop_type {
268 OFPTFPT13_INSTRUCTIONS = 0, /* Instructions property. */
269 OFPTFPT13_INSTRUCTIONS_MISS = 1, /* Instructions for table-miss. */
270 OFPTFPT13_NEXT_TABLES = 2, /* Next Table property. */
271 OFPTFPT13_NEXT_TABLES_MISS = 3, /* Next Table for table-miss. */
272 OFPTFPT13_WRITE_ACTIONS = 4, /* Write Actions property. */
273 OFPTFPT13_WRITE_ACTIONS_MISS = 5, /* Write Actions for table-miss. */
274 OFPTFPT13_APPLY_ACTIONS = 6, /* Apply Actions property. */
275 OFPTFPT13_APPLY_ACTIONS_MISS = 7, /* Apply Actions for table-miss. */
276 OFPTFPT13_MATCH = 8, /* Match property. */
277 OFPTFPT13_WILDCARDS = 10, /* Wildcards property. */
278 OFPTFPT13_WRITE_SETFIELD = 12, /* Write Set-Field property. */
279 OFPTFPT13_WRITE_SETFIELD_MISS = 13, /* Write Set-Field for table-miss. */
280 OFPTFPT13_APPLY_SETFIELD = 14, /* Apply Set-Field property. */
281 OFPTFPT13_APPLY_SETFIELD_MISS = 15, /* Apply Set-Field for table-miss. */
282 OFPTFPT13_EXPERIMENTER = 0xFFFE, /* Experimenter property. */
283 OFPTFPT13_EXPERIMENTER_MISS = 0xFFFF, /* Experimenter for table-miss. */
286 /* Instructions property */
287 struct ofp13_table_feature_prop_instructions {
288 ovs_be16 type; /* One of OFPTFPT13_INSTRUCTIONS,
289 OFPTFPT13_INSTRUCTIONS_MISS. */
290 ovs_be16 length; /* Length in bytes of this property. */
292 * - Exactly (length - 4) bytes containing the instruction ids, then
293 * - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
294 * bytes of all-zero bytes */
295 /* struct ofp11_instruction instruction_ids[0]; List of instructions
298 OFP_ASSERT(sizeof(struct ofp13_table_feature_prop_instructions) == 4);
300 /* Next Tables property */
301 struct ofp13_table_feature_prop_next_tables {
302 ovs_be16 type; /* One of OFPTFPT13_NEXT_TABLES,
303 OFPTFPT13_NEXT_TABLES_MISS. */
304 ovs_be16 length; /* Length in bytes of this property. */
306 * - Exactly (length - 4) bytes containing the table_ids, then
307 * - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
308 * bytes of all-zero bytes */
309 /* uint8_t next_table_ids[0]; */
311 OFP_ASSERT(sizeof(struct ofp13_table_feature_prop_next_tables) == 4);
313 /* Actions property */
314 struct ofp13_table_feature_prop_actions {
315 ovs_be16 type; /* One of OFPTFPT13_WRITE_ACTIONS,
316 OFPTFPT13_WRITE_ACTIONS_MISS,
317 OFPTFPT13_APPLY_ACTIONS,
318 OFPTFPT13_APPLY_ACTIONS_MISS. */
319 ovs_be16 length; /* Length in bytes of this property. */
321 * - Exactly (length - 4) bytes containing the action_ids, then
322 * - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
323 * bytes of all-zero bytes */
324 /* struct ofp_action_header action_ids[0]; List of actions
327 OFP_ASSERT(sizeof(struct ofp13_table_feature_prop_actions) == 4);
330 /* Match, Wildcard or Set-Field property */
331 struct ofp13_table_feature_prop_oxm {
332 ovs_be16 type; /* One of OFPTFPT13_MATCH, OFPTFPT13_WILDCARDS,
333 OFPTFPT13_WRITE_SETFIELD,
334 OFPTFPT13_WRITE_SETFIELD_MISS,
335 OFPTFPT13_APPLY_SETFIELD,
336 OFPTFPT13_APPLY_SETFIELD_MISS. */
337 ovs_be16 length; /* Length in bytes of this property. */
339 * - Exactly (length - 4) bytes containing the oxm_ids, then
340 * - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
341 * bytes of all-zero bytes */
342 /* ovs_be32 oxm_ids[0]; Array of OXM headers */
344 OFP_ASSERT(sizeof(struct ofp13_table_feature_prop_oxm) == 4);
346 /* Experimenter table feature property */
347 struct ofp13_table_feature_prop_experimenter {
348 ovs_be16 type; /* One of OFPTFPT13_EXPERIMENTER,
349 OFPTFPT13_EXPERIMENTER_MISS. */
350 ovs_be16 length; /* Length in bytes of this property. */
351 ovs_be32 experimenter; /* Experimenter ID which takes the same form
352 as in struct ofp_experimenter_header. */
353 ovs_be32 exp_type; /* Experimenter defined. */
355 * - Exactly (length - 12) bytes containing the experimenter data, then
356 * - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
357 * bytes of all-zero bytes */
358 /* ovs_be32 experimenter_data[0]; */
360 OFP_ASSERT(sizeof(struct ofp13_table_feature_prop_experimenter) == 12);
362 /* Body of reply to OFPMP13_PORT request. If a counter is unsupported, set
363 * the field to all ones. */
364 struct ofp13_port_stats {
365 struct ofp11_port_stats ps;
366 ovs_be32 duration_sec; /* Time port has been alive in seconds. */
367 ovs_be32 duration_nsec; /* Time port has been alive in nanoseconds
368 beyond duration_sec. */
370 OFP_ASSERT(sizeof(struct ofp13_port_stats) == 112);
372 /* Body of reply to OFPMP13_QUEUE request */
373 struct ofp13_queue_stats {
374 struct ofp11_queue_stats qs;
375 ovs_be32 duration_sec; /* Time queue has been alive in seconds. */
376 ovs_be32 duration_nsec; /* Time queue has been alive in nanoseconds
377 beyond duration_sec. */
379 OFP_ASSERT(sizeof(struct ofp13_queue_stats) == 40);
381 /* Body of reply to OFPMP13_GROUP request */
382 struct ofp13_group_stats {
383 struct ofp11_group_stats gs;
384 ovs_be32 duration_sec; /* Time group has been alive in seconds. */
385 ovs_be32 duration_nsec; /* Time group has been alive in nanoseconds
386 beyond duration_sec. */
387 /* struct ofp11_bucket_counter bucket_stats[]; */
389 OFP_ASSERT(sizeof(struct ofp13_group_stats) == 40);
391 /* Body of OFPMP13_METER and OFPMP13_METER_CONFIG requests. */
392 struct ofp13_meter_multipart_request {
393 ovs_be32 meter_id; /* Meter instance, or OFPM_ALL. */
394 uint8_t pad[4]; /* Align to 64 bits. */
396 OFP_ASSERT(sizeof(struct ofp13_meter_multipart_request) == 8);
398 /* Statistics for each meter band */
399 struct ofp13_meter_band_stats {
400 ovs_be64 packet_band_count; /* Number of packets in band. */
401 ovs_be64 byte_band_count; /* Number of bytes in band. */
403 OFP_ASSERT(sizeof(struct ofp13_meter_band_stats) == 16);
405 /* Body of reply to OFPMP13_METER request. Meter statistics. */
406 struct ofp13_meter_stats {
407 ovs_be32 meter_id; /* Meter instance. */
408 ovs_be16 len; /* Length in bytes of this stats. */
410 ovs_be32 flow_count; /* Number of flows bound to meter. */
411 ovs_be64 packet_in_count; /* Number of packets in input. */
412 ovs_be64 byte_in_count; /* Number of bytes in input. */
413 ovs_be32 duration_sec; /* Time meter has been alive in seconds. */
414 ovs_be32 duration_nsec; /* Time meter has been alive in nanoseconds
415 beyond duration_sec. */
416 struct ofp13_meter_band_stats band_stats[0]; /* The band_stats length is
417 inferred from the length field. */
419 OFP_ASSERT(sizeof(struct ofp13_meter_stats) == 40);
421 /* Body of reply to OFPMP13_METER_CONFIG request. Meter configuration. */
422 struct ofp13_meter_config {
423 ovs_be16 length; /* Length of this entry. */
424 ovs_be16 flags; /* Set of OFPMC_* that apply. */
425 ovs_be32 meter_id; /* Meter instance. */
426 /* struct ofp13_meter_band_header bands[0]; The bands length is inferred
427 from the length field. */
429 OFP_ASSERT(sizeof(struct ofp13_meter_config) == 8);
431 /* Body of reply to OFPMP13_METER_FEATURES request. Meter features. */
432 struct ofp13_meter_features {
433 ovs_be32 max_meter; /* Maximum number of meters. */
434 ovs_be32 band_types; /* Bitmaps of OFPMBT13_* values supported. */
435 ovs_be32 capabilities; /* Bitmaps of "ofp13_meter_flags". */
436 uint8_t max_bands; /* Maximum bands per meters */
437 uint8_t max_color; /* Maximum color value */
440 OFP_ASSERT(sizeof(struct ofp13_meter_features) == 16);
442 /* Asynchronous message configuration. */
443 /* The body of this is the same as nx_async_config */
444 /* OFPT_GET_ASYNC_REPLY or OFPT_SET_ASYNC. */
445 struct ofp13_async_config {
446 ovs_be32 packet_in_mask[2]; /* Bitmasks of OFPR_* values. */
447 ovs_be32 port_status_mask[2]; /* Bitmasks of OFPPR_* values. */
448 ovs_be32 flow_removed_mask[2];/* Bitmasks of OFPRR_* values. */
450 OFP_ASSERT(sizeof(struct ofp13_async_config) == 24);
453 /* Packet received on port (datapath -> controller). */
454 struct ofp13_packet_in {
455 struct ofp12_packet_in pi;
456 ovs_be64 cookie; /* Cookie of the flow entry that was looked up */
459 * - Exactly 2 all-zero padding bytes, then
460 * - An Ethernet frame whose length is inferred from header.length.
461 * The padding bytes preceding the Ethernet frame ensure that the IP
462 * header (if any) following the Ethernet header is 32-bit aligned.
464 /* struct ofp12_match match; */
465 /* uint8_t pad[2]; Align to 64 bit + 16 bit */
466 /* uint8_t data[0]; Ethernet frame */
468 OFP_ASSERT(sizeof(struct ofp13_packet_in) == 16);
471 #endif /* openflow/openflow-1.3.h */