]> git.proxmox.com Git - mirror_ovs.git/blame - include/openflow/openflow-1.1.h
include/openflow: Moved remaining common definitions from openflow-1.0.h
[mirror_ovs.git] / include / openflow / openflow-1.1.h
CommitLineData
5293a2e1 1/* Copyright (c) 2008, 2011, 2012 The Board of Trustees of The Leland Stanford
87ea5e5e
BP
2 * Junior University
3 *
4 * We are making the OpenFlow specification and associated documentation
5 * (Software) available for public use and benefit with the expectation
6 * that others will use, modify and enhance the Software and contribute
7 * those enhancements back to the community. However, since we would
8 * like to make the Software available for broadest use, with as few
9 * restrictions as possible permission is hereby granted, free of
10 * charge, to any person obtaining a copy of this Software to deal in
11 * the Software under the copyrights without restriction, including
12 * without limitation the rights to use, copy, modify, merge, publish,
13 * distribute, sublicense, and/or sell copies of the Software, and to
14 * permit persons to whom the Software is furnished to do so, subject to
15 * the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be
18 * included in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
28 *
29 * The name and trademarks of copyright holder(s) may NOT be used in
30 * advertising or publicity pertaining to the Software or any
31 * derivatives without specific, written prior permission.
32 */
33
34/*
e0edde6f 35 * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
87ea5e5e
BP
36 *
37 * Licensed under the Apache License, Version 2.0 (the "License");
38 * you may not use this file except in compliance with the License.
39 * You may obtain a copy of the License at:
40 *
41 * http://www.apache.org/licenses/LICENSE-2.0
42 *
43 * Unless required by applicable law or agreed to in writing, software
44 * distributed under the License is distributed on an "AS IS" BASIS,
45 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 * See the License for the specific language governing permissions and
47 * limitations under the License.
48 */
49
50/* OpenFlow: protocol between controller and datapath. */
51
52#ifndef OPENFLOW_11_H
53#define OPENFLOW_11_H 1
54
55#include "openflow/openflow-common.h"
56
7b7503ea
BP
57/* OpenFlow 1.1 uses 32-bit port numbers. Open vSwitch, for now, uses OpenFlow
58 * 1.0 port numbers internally. We map them to OpenFlow 1.0 as follows:
59 *
60 * OF1.1 <=> OF1.0
61 * ----------------------- ---------------
62 * 0x00000000...0x0000feff <=> 0x0000...0xfeff "physical" ports
63 * 0x0000ff00...0xfffffeff <=> not supported
64 * 0xffffff00...0xffffffff <=> 0xff00...0xffff "reserved" OFPP_* ports
65 *
66 * OFPP11_OFFSET is the value that must be added or subtracted to convert
67 * an OpenFlow 1.0 reserved port number to or from, respectively, the
68 * corresponding OpenFlow 1.1 reserved port number.
69 */
70#define OFPP11_MAX 0xffffff00
71#define OFPP11_OFFSET (OFPP11_MAX - OFPP_MAX)
87ea5e5e 72
7f05e7ab
JR
73/* Reserved wildcard port used only for flow mod (delete) and flow stats
74 * requests. Selects all flows regardless of output port
75 * (including flows with no output port)
76 *
77 * Define it via OFPP_NONE (0xFFFF) so that OFPP_ANY is still an enum ofp_port
78 */
79#define OFPP_ANY OFPP_NONE
80
9e1fd49b
BP
81/* OpenFlow 1.1 port config flags are just the common flags. */
82#define OFPPC11_ALL \
83 (OFPPC_PORT_DOWN | OFPPC_NO_RECV | OFPPC_NO_FWD | OFPPC_NO_PACKET_IN)
84
85/* OpenFlow 1.1 specific current state of the physical port. These are not
86 * configurable from the controller.
87 */
88enum ofp11_port_state {
89 OFPPS11_BLOCKED = 1 << 1, /* Port is blocked */
90 OFPPS11_LIVE = 1 << 2, /* Live for Fast Failover Group. */
91#define OFPPS11_ALL (OFPPS_LINK_DOWN | OFPPS11_BLOCKED | OFPPS11_LIVE)
92};
93
94/* OpenFlow 1.1 specific features of ports available in a datapath. */
95enum ofp11_port_features {
96 OFPPF11_40GB_FD = 1 << 7, /* 40 Gb full-duplex rate support. */
97 OFPPF11_100GB_FD = 1 << 8, /* 100 Gb full-duplex rate support. */
98 OFPPF11_1TB_FD = 1 << 9, /* 1 Tb full-duplex rate support. */
99 OFPPF11_OTHER = 1 << 10, /* Other rate, not in the list. */
100
101 OFPPF11_COPPER = 1 << 11, /* Copper medium. */
102 OFPPF11_FIBER = 1 << 12, /* Fiber medium. */
103 OFPPF11_AUTONEG = 1 << 13, /* Auto-negotiation. */
104 OFPPF11_PAUSE = 1 << 14, /* Pause. */
105 OFPPF11_PAUSE_ASYM = 1 << 15 /* Asymmetric pause. */
106#define OFPPF11_ALL ((1 << 16) - 1)
107};
108
109/* Description of a port */
110struct ofp11_port {
111 ovs_be32 port_no;
112 uint8_t pad[4];
113 uint8_t hw_addr[OFP_ETH_ALEN];
114 uint8_t pad2[2]; /* Align to 64 bits. */
115 char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
116
117 ovs_be32 config; /* Bitmap of OFPPC_* flags. */
118 ovs_be32 state; /* Bitmap of OFPPS_* and OFPPS11_* flags. */
119
120 /* Bitmaps of OFPPF_* and OFPPF11_* that describe features. All bits
121 * zeroed if unsupported or unavailable. */
122 ovs_be32 curr; /* Current features. */
123 ovs_be32 advertised; /* Features being advertised by the port. */
124 ovs_be32 supported; /* Features supported by the port. */
125 ovs_be32 peer; /* Features advertised by peer. */
126
127 ovs_be32 curr_speed; /* Current port bitrate in kbps. */
128 ovs_be32 max_speed; /* Max port bitrate in kbps */
129};
2e1ae200 130OFP_ASSERT(sizeof(struct ofp11_port) == 64);
9e1fd49b
BP
131
132/* Modify behavior of the physical port */
133struct ofp11_port_mod {
9e1fd49b
BP
134 ovs_be32 port_no;
135 uint8_t pad[4];
136 uint8_t hw_addr[OFP_ETH_ALEN]; /* The hardware address is not
137 configurable. This is used to
138 sanity-check the request, so it must
139 be the same as returned in an
140 ofp11_port struct. */
141 uint8_t pad2[2]; /* Pad to 64 bits. */
142 ovs_be32 config; /* Bitmap of OFPPC_* flags. */
143 ovs_be32 mask; /* Bitmap of OFPPC_* flags to be changed. */
144
145 ovs_be32 advertise; /* Bitmap of OFPPF_* and OFPPF11_*. Zero all bits
146 to prevent any action taking place. */
147 uint8_t pad3[4]; /* Pad to 64 bits. */
148};
982697a4 149OFP_ASSERT(sizeof(struct ofp11_port_mod) == 32);
9e1fd49b 150
04f68eb2
SH
151/* Group setup and teardown (controller -> datapath). */
152struct ofp11_group_mod {
04f68eb2
SH
153 ovs_be16 command; /* One of OFPGC_*. */
154 uint8_t type; /* One of OFPGT_*. */
155 uint8_t pad; /* Pad to 64 bits. */
156 ovs_be32 group_id; /* Group identifier. */
157 /* struct ofp11_bucket buckets[0]; The bucket length is inferred from the
158 length field in the header. */
159};
982697a4 160OFP_ASSERT(sizeof(struct ofp11_group_mod) == 8);
04f68eb2
SH
161
162/* Query for port queue configuration. */
163struct ofp11_queue_get_config_request {
04f68eb2
SH
164 ovs_be32 port;
165 /* Port to be queried. Should refer
166 to a valid physical port (i.e. < OFPP_MAX) */
167 uint8_t pad[4];
168};
982697a4 169OFP_ASSERT(sizeof(struct ofp11_queue_get_config_request) == 8);
04f68eb2
SH
170
171/* Group commands */
172enum ofp11_group_mod_command {
173 OFPGC11_ADD, /* New group. */
174 OFPGC11_MODIFY, /* Modify all matching groups. */
175 OFPGC11_DELETE, /* Delete all matching groups. */
176};
177
9e1fd49b
BP
178/* OpenFlow 1.1 specific capabilities supported by the datapath (struct
179 * ofp_switch_features, member capabilities). */
180enum ofp11_capabilities {
181 OFPC11_GROUP_STATS = 1 << 3, /* Group statistics. */
182};
183
08f94c0e
BP
184enum ofp11_action_type {
185 OFPAT11_OUTPUT, /* Output to switch port. */
186 OFPAT11_SET_VLAN_VID, /* Set the 802.1q VLAN id. */
187 OFPAT11_SET_VLAN_PCP, /* Set the 802.1q priority. */
188 OFPAT11_SET_DL_SRC, /* Ethernet source address. */
189 OFPAT11_SET_DL_DST, /* Ethernet destination address. */
190 OFPAT11_SET_NW_SRC, /* IP source address. */
191 OFPAT11_SET_NW_DST, /* IP destination address. */
192 OFPAT11_SET_NW_TOS, /* IP ToS (DSCP field, 6 bits). */
193 OFPAT11_SET_NW_ECN, /* IP ECN (2 bits). */
194 OFPAT11_SET_TP_SRC, /* TCP/UDP/SCTP source port. */
195 OFPAT11_SET_TP_DST, /* TCP/UDP/SCTP destination port. */
196 OFPAT11_COPY_TTL_OUT, /* Copy TTL "outwards" -- from next-to-outermost
197 to outermost */
198 OFPAT11_COPY_TTL_IN, /* Copy TTL "inwards" -- from outermost to
199 next-to-outermost */
200 OFPAT11_SET_MPLS_LABEL, /* MPLS label */
201 OFPAT11_SET_MPLS_TC, /* MPLS TC */
202 OFPAT11_SET_MPLS_TTL, /* MPLS TTL */
203 OFPAT11_DEC_MPLS_TTL, /* Decrement MPLS TTL */
204
205 OFPAT11_PUSH_VLAN, /* Push a new VLAN tag */
206 OFPAT11_POP_VLAN, /* Pop the outer VLAN tag */
207 OFPAT11_PUSH_MPLS, /* Push a new MPLS tag */
208 OFPAT11_POP_MPLS, /* Pop the outer MPLS tag */
209 OFPAT11_SET_QUEUE, /* Set queue id when outputting to a port */
210 OFPAT11_GROUP, /* Apply group. */
211 OFPAT11_SET_NW_TTL, /* IP TTL. */
212 OFPAT11_DEC_NW_TTL, /* Decrement IP TTL. */
213 OFPAT11_EXPERIMENTER = 0xffff
214};
215
04f68eb2
SH
216#define OFPMT11_STANDARD_LENGTH 88
217
218struct ofp11_match_header {
219 ovs_be16 type; /* One of OFPMT_* */
220 ovs_be16 length; /* Length of match */
221};
222OFP_ASSERT(sizeof(struct ofp11_match_header) == 4);
223
224/* Fields to match against flows */
225struct ofp11_match {
226 struct ofp11_match_header omh;
227 ovs_be32 in_port; /* Input switch port. */
228 ovs_be32 wildcards; /* Wildcard fields. */
229 uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */
230 uint8_t dl_src_mask[OFP_ETH_ALEN]; /* Ethernet source address mask. */
231 uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */
232 uint8_t dl_dst_mask[OFP_ETH_ALEN]; /* Ethernet destination address mask. */
233 ovs_be16 dl_vlan; /* Input VLAN id. */
234 uint8_t dl_vlan_pcp; /* Input VLAN priority. */
235 uint8_t pad1[1]; /* Align to 32-bits */
236 ovs_be16 dl_type; /* Ethernet frame type. */
237 uint8_t nw_tos; /* IP ToS (actually DSCP field, 6 bits). */
238 uint8_t nw_proto; /* IP protocol or lower 8 bits of ARP opcode. */
239 ovs_be32 nw_src; /* IP source address. */
240 ovs_be32 nw_src_mask; /* IP source address mask. */
241 ovs_be32 nw_dst; /* IP destination address. */
242 ovs_be32 nw_dst_mask; /* IP destination address mask. */
243 ovs_be16 tp_src; /* TCP/UDP/SCTP source port. */
244 ovs_be16 tp_dst; /* TCP/UDP/SCTP destination port. */
245 ovs_be32 mpls_label; /* MPLS label. */
246 uint8_t mpls_tc; /* MPLS TC. */
247 uint8_t pad2[3]; /* Align to 64-bits */
248 ovs_be64 metadata; /* Metadata passed between tables. */
249 ovs_be64 metadata_mask; /* Mask for metadata. */
250};
251OFP_ASSERT(sizeof(struct ofp11_match) == OFPMT11_STANDARD_LENGTH);
252
253/* Flow wildcards. */
254enum ofp11_flow_wildcards {
7c00ccb6
BP
255 OFPFW11_IN_PORT = 1 << 0, /* Switch input port. */
256 OFPFW11_DL_VLAN = 1 << 1, /* VLAN id. */
257 OFPFW11_DL_VLAN_PCP = 1 << 2, /* VLAN priority. */
258 OFPFW11_DL_TYPE = 1 << 3, /* Ethernet frame type. */
259 OFPFW11_NW_TOS = 1 << 4, /* IP ToS (DSCP field, 6 bits). */
260 OFPFW11_NW_PROTO = 1 << 5, /* IP protocol. */
261 OFPFW11_TP_SRC = 1 << 6, /* TCP/UDP/SCTP source port. */
262 OFPFW11_TP_DST = 1 << 7, /* TCP/UDP/SCTP destination port. */
263 OFPFW11_MPLS_LABEL = 1 << 8, /* MPLS label. */
264 OFPFW11_MPLS_TC = 1 << 9, /* MPLS TC. */
04f68eb2
SH
265
266 /* Wildcard all fields. */
7c00ccb6 267 OFPFW11_ALL = ((1 << 10) - 1)
04f68eb2
SH
268};
269
270/* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
271 * special conditions.
272 */
273enum ofp11_vlan_id {
274 OFPVID11_ANY = 0xfffe, /* Indicate that a VLAN id is set but don't care
275 about it's value. Note: only valid when
276 specifying the VLAN id in a match */
277 OFPVID11_NONE = 0xffff, /* No VLAN id was set. */
278};
279
280enum ofp11_instruction_type {
281 OFPIT11_GOTO_TABLE = 1, /* Setup the next table in the lookup
282 pipeline */
283 OFPIT11_WRITE_METADATA = 2, /* Setup the metadata field for use later
284 in pipeline */
285 OFPIT11_WRITE_ACTIONS = 3, /* Write the action(s) onto the datapath
286 action set */
287 OFPIT11_APPLY_ACTIONS = 4, /* Applies the action(s) immediately */
288 OFPIT11_CLEAR_ACTIONS = 5, /* Clears all actions from the datapath
289 action set */
290 OFPIT11_EXPERIMENTER = 0xFFFF /* Experimenter instruction */
291};
292
307975da
SH
293#define OFPIT11_ALL (OFPIT11_GOTO_TABLE | OFPIT11_WRITE_METADATA | \
294 OFPIT11_WRITE_ACTIONS | OFPIT11_APPLY_ACTIONS | \
295 OFPIT11_CLEAR_ACTIONS)
296
d01c980f
BP
297#define OFP11_INSTRUCTION_ALIGN 8
298
299/* Generic ofp_instruction structure. */
300struct ofp11_instruction {
301 ovs_be16 type; /* Instruction type */
302 ovs_be16 len; /* Length of this struct in bytes. */
303 uint8_t pad[4]; /* Align to 64-bits */
304};
305OFP_ASSERT(sizeof(struct ofp11_instruction) == 8);
306
04f68eb2
SH
307/* Instruction structure for OFPIT_GOTO_TABLE */
308struct ofp11_instruction_goto_table {
309 ovs_be16 type; /* OFPIT_GOTO_TABLE */
310 ovs_be16 len; /* Length of this struct in bytes. */
311 uint8_t table_id; /* Set next table in the lookup pipeline */
312 uint8_t pad[3]; /* Pad to 64 bits. */
313};
314OFP_ASSERT(sizeof(struct ofp11_instruction_goto_table) == 8);
315
316/* Instruction structure for OFPIT_WRITE_METADATA */
317struct ofp11_instruction_write_metadata {
318 ovs_be16 type; /* OFPIT_WRITE_METADATA */
319 ovs_be16 len; /* Length of this struct in bytes. */
320 uint8_t pad[4]; /* Align to 64-bits */
321 ovs_be64 metadata; /* Metadata value to write */
322 ovs_be64 metadata_mask; /* Metadata write bitmask */
323};
324OFP_ASSERT(sizeof(struct ofp11_instruction_write_metadata) == 24);
325
326/* Instruction structure for OFPIT_WRITE/APPLY/CLEAR_ACTIONS */
327struct ofp11_instruction_actions {
328 ovs_be16 type; /* One of OFPIT_*_ACTIONS */
329 ovs_be16 len; /* Length of this struct in bytes. */
330 uint8_t pad[4]; /* Align to 64-bits */
331 /* struct ofp_action_header actions[0]; Actions associated with
332 OFPIT_WRITE_ACTIONS and
333 OFPIT_APPLY_ACTIONS */
334};
335OFP_ASSERT(sizeof(struct ofp11_instruction_actions) == 8);
336
d01c980f
BP
337/* Instruction structure for experimental instructions */
338struct ofp11_instruction_experimenter {
339 ovs_be16 type; /* OFPIT11_EXPERIMENTER */
340 ovs_be16 len; /* Length of this struct in bytes */
341 ovs_be32 experimenter; /* Experimenter ID which takes the same form
342 as in struct ofp_vendor_header. */
343 /* Experimenter-defined arbitrary additional data. */
344};
345OFP_ASSERT(sizeof(struct ofp11_instruction_experimenter) == 8);
346
04f68eb2
SH
347/* Action structure for OFPAT_OUTPUT, which sends packets out 'port'.
348 * When the 'port' is the OFPP_CONTROLLER, 'max_len' indicates the max
349 * number of bytes to send. A 'max_len' of zero means no bytes of the
350 * packet should be sent.*/
351struct ofp11_action_output {
352 ovs_be16 type; /* OFPAT11_OUTPUT. */
353 ovs_be16 len; /* Length is 16. */
354 ovs_be32 port; /* Output port. */
355 ovs_be16 max_len; /* Max length to send to controller. */
356 uint8_t pad[6]; /* Pad to 64 bits. */
357};
358OFP_ASSERT(sizeof(struct ofp11_action_output) == 16);
359
360/* Action structure for OFPAT_GROUP. */
361struct ofp11_action_group {
362 ovs_be16 type; /* OFPAT11_GROUP. */
363 ovs_be16 len; /* Length is 8. */
364 ovs_be32 group_id; /* Group identifier. */
365};
366OFP_ASSERT(sizeof(struct ofp11_action_group) == 8);
367
368/* OFPAT_SET_QUEUE action struct: send packets to given queue on port. */
369struct ofp11_action_set_queue {
370 ovs_be16 type; /* OFPAT11_SET_QUEUE. */
371 ovs_be16 len; /* Len is 8. */
372 ovs_be32 queue_id; /* Queue id for the packets. */
373};
374OFP_ASSERT(sizeof(struct ofp11_action_set_queue) == 8);
375
376/* Action structure for OFPAT11_SET_MPLS_LABEL. */
377struct ofp11_action_mpls_label {
378 ovs_be16 type; /* OFPAT11_SET_MPLS_LABEL. */
379 ovs_be16 len; /* Length is 8. */
380 ovs_be32 mpls_label; /* MPLS label */
381};
382OFP_ASSERT(sizeof(struct ofp11_action_mpls_label) == 8);
383
384/* Action structure for OFPAT11_SET_MPLS_TC. */
385struct ofp11_action_mpls_tc {
386 ovs_be16 type; /* OFPAT11_SET_MPLS_TC. */
387 ovs_be16 len; /* Length is 8. */
388 uint8_t mpls_tc; /* MPLS TC */
389 uint8_t pad[3];
390};
391OFP_ASSERT(sizeof(struct ofp11_action_mpls_tc) == 8);
392
393/* Action structure for OFPAT11_SET_MPLS_TTL. */
394struct ofp11_action_mpls_ttl {
395 ovs_be16 type; /* OFPAT11_SET_MPLS_TTL. */
396 ovs_be16 len; /* Length is 8. */
397 uint8_t mpls_ttl; /* MPLS TTL */
398 uint8_t pad[3];
399};
400OFP_ASSERT(sizeof(struct ofp11_action_mpls_ttl) == 8);
401
402/* Action structure for OFPAT11_SET_NW_ECN. */
403struct ofp11_action_nw_ecn {
404 ovs_be16 type; /* OFPAT11_SET_TW_SRC/DST. */
405 ovs_be16 len; /* Length is 8. */
406 uint8_t nw_ecn; /* IP ECN (2 bits). */
407 uint8_t pad[3];
408};
409OFP_ASSERT(sizeof(struct ofp11_action_nw_ecn) == 8);
410
411/* Action structure for OFPAT11_SET_NW_TTL. */
412struct ofp11_action_nw_ttl {
413 ovs_be16 type; /* OFPAT11_SET_NW_TTL. */
414 ovs_be16 len; /* Length is 8. */
415 uint8_t nw_ttl; /* IP TTL */
416 uint8_t pad[3];
417};
418OFP_ASSERT(sizeof(struct ofp11_action_nw_ttl) == 8);
419
420/* Action structure for OFPAT11_PUSH_VLAN/MPLS. */
421struct ofp11_action_push {
422 ovs_be16 type; /* OFPAT11_PUSH_VLAN/MPLS. */
423 ovs_be16 len; /* Length is 8. */
424 ovs_be16 ethertype; /* Ethertype */
425 uint8_t pad[2];
426};
427OFP_ASSERT(sizeof(struct ofp11_action_push) == 8);
428
429/* Action structure for OFPAT11_POP_MPLS. */
430struct ofp11_action_pop_mpls {
431 ovs_be16 type; /* OFPAT11_POP_MPLS. */
432 ovs_be16 len; /* Length is 8. */
433 ovs_be16 ethertype; /* Ethertype */
434 uint8_t pad[2];
435};
436OFP_ASSERT(sizeof(struct ofp11_action_pop_mpls) == 8);
437
438/* Configure/Modify behavior of a flow table */
439struct ofp11_table_mod {
04f68eb2
SH
440 uint8_t table_id; /* ID of the table, 0xFF indicates all tables */
441 uint8_t pad[3]; /* Pad to 32 bits */
442 ovs_be32 config; /* Bitmap of OFPTC_* flags */
443};
982697a4 444OFP_ASSERT(sizeof(struct ofp11_table_mod) == 8);
04f68eb2
SH
445
446/* Flags to indicate behavior of the flow table for unmatched packets.
447 These flags are used in ofp_table_stats messages to describe the current
448 configuration and in ofp_table_mod messages to configure table behavior. */
449enum ofp11_table_config {
450 OFPTC11_TABLE_MISS_CONTROLLER = 0, /* Send to controller. */
451 OFPTC11_TABLE_MISS_CONTINUE = 1 << 0, /* Continue to the next table in the
452 pipeline (OpenFlow 1.0
453 behavior). */
454 OFPTC11_TABLE_MISS_DROP = 1 << 1, /* Drop the packet. */
455 OFPTC11_TABLE_MISS_MASK = 3
456};
457
458/* Flow setup and teardown (controller -> datapath). */
459struct ofp11_flow_mod {
04f68eb2
SH
460 ovs_be64 cookie; /* Opaque controller-issued identifier. */
461 ovs_be64 cookie_mask; /* Mask used to restrict the cookie bits
462 that must match when the command is
463 OFPFC_MODIFY* or OFPFC_DELETE*. A value
464 of 0 indicates no restriction. */
465 /* Flow actions. */
466 uint8_t table_id; /* ID of the table to put the flow in */
467 uint8_t command; /* One of OFPFC_*. */
468 ovs_be16 idle_timeout; /* Idle time before discarding (seconds). */
469 ovs_be16 hard_timeout; /* Max time before discarding (seconds). */
470 ovs_be16 priority; /* Priority level of flow entry. */
471 ovs_be32 buffer_id; /* Buffered packet to apply to (or -1).
472 Not meaningful for OFPFC_DELETE*. */
473 ovs_be32 out_port; /* For OFPFC_DELETE* commands, require
474 matching entries to include this as an
475 output port. A value of OFPP_ANY
476 indicates no restriction. */
477 ovs_be32 out_group; /* For OFPFC_DELETE* commands, require
478 matching entries to include this as an
539d1fa7 479 output group. A value of OFPG11_ANY
04f68eb2
SH
480 indicates no restriction. */
481 ovs_be16 flags; /* One of OFPFF_*. */
482 uint8_t pad[2];
aa319503
BP
483 /* Followed by an ofp11_match structure. */
484 /* Followed by an instruction set. */
04f68eb2 485};
982697a4 486OFP_ASSERT(sizeof(struct ofp11_flow_mod) == 40);
04f68eb2
SH
487
488/* Group types. Values in the range [128, 255] are reserved for experimental
489 * use. */
490enum ofp11_group_type {
491 OFPGT11_ALL, /* All (multicast/broadcast) group. */
492 OFPGT11_SELECT, /* Select group. */
493 OFPGT11_INDIRECT, /* Indirect group. */
494 OFPGT11_FF /* Fast failover group. */
495};
496
539d1fa7
SH
497/* Group numbering. Groups can use any number up to OFPG_MAX. */
498enum ofp11_group {
499 /* Last usable group number. */
500 OFPG11_MAX = 0xffffff00,
501
502 /* Fake groups. */
503 OFPG11_ALL = 0xfffffffc, /* Represents all groups for group delete
504 commands. */
505 OFPG11_ANY = 0xffffffff /* Wildcard group used only for flow stats
506 requests. Selects all flows regardless
507 of group (including flows with no
508 group). */
509};
510
04f68eb2
SH
511/* Bucket for use in groups. */
512struct ofp11_bucket {
513 ovs_be16 len; /* Length the bucket in bytes, including
514 this header and any padding to make it
515 64-bit aligned. */
516 ovs_be16 weight; /* Relative weight of bucket. Only
517 defined for select groups. */
518 ovs_be32 watch_port; /* Port whose state affects whether this
519 bucket is live. Only required for fast
520 failover groups. */
521 ovs_be32 watch_group; /* Group whose state affects whether this
522 bucket is live. Only required for fast
523 failover groups. */
524 uint8_t pad[4];
525 /* struct ofp_action_header actions[0]; The action length is inferred
526 from the length field in the
527 header. */
528};
529OFP_ASSERT(sizeof(struct ofp11_bucket) == 16);
530
531/* Queue configuration for a given port. */
532struct ofp11_queue_get_config_reply {
04f68eb2
SH
533 ovs_be32 port;
534 uint8_t pad[4];
535 /* struct ofp_packet_queue queues[0]; List of configured queues. */
536};
982697a4 537OFP_ASSERT(sizeof(struct ofp11_queue_get_config_reply) == 8);
04f68eb2
SH
538
539struct ofp11_stats_msg {
540 struct ofp_header header;
541 ovs_be16 type; /* One of the OFPST_* constants. */
542 ovs_be16 flags; /* OFPSF_REQ_* flags (none yet defined). */
543 uint8_t pad[4];
aa319503 544 /* Followed by the body of the request. */
04f68eb2
SH
545};
546OFP_ASSERT(sizeof(struct ofp11_stats_msg) == 16);
547
982697a4
BP
548/* Vendor extension stats message. */
549struct ofp11_vendor_stats_msg {
550 struct ofp11_stats_msg osm; /* Type OFPST_VENDOR. */
551 ovs_be32 vendor; /* Vendor ID:
552 * - MSB 0: low-order bytes are IEEE OUI.
553 * - MSB != 0: defined by OpenFlow
554 * consortium. */
555 /* Followed by vendor-defined arbitrary additional data. */
556};
557OFP_ASSERT(sizeof(struct ofp11_vendor_stats_msg) == 20);
558
04f68eb2
SH
559/* Stats request of type OFPST_FLOW. */
560struct ofp11_flow_stats_request {
04f68eb2
SH
561 uint8_t table_id; /* ID of table to read (from ofp_table_stats),
562 0xff for all tables. */
563 uint8_t pad[3]; /* Align to 64 bits. */
564 ovs_be32 out_port; /* Require matching entries to include this
565 as an output port. A value of OFPP_ANY
566 indicates no restriction. */
567 ovs_be32 out_group; /* Require matching entries to include this
539d1fa7 568 as an output group. A value of OFPG11_ANY
04f68eb2
SH
569 indicates no restriction. */
570 uint8_t pad2[4]; /* Align to 64 bits. */
571 ovs_be64 cookie; /* Require matching entries to contain this
572 cookie value */
573 ovs_be64 cookie_mask; /* Mask used to restrict the cookie bits that
574 must match. A value of 0 indicates
575 no restriction. */
aa319503 576 /* Followed by an ofp11_match structure. */
04f68eb2 577};
aa319503 578OFP_ASSERT(sizeof(struct ofp11_flow_stats_request) == 32);
04f68eb2
SH
579
580/* Body of reply to OFPST_FLOW request. */
581struct ofp11_flow_stats {
582 ovs_be16 length; /* Length of this entry. */
583 uint8_t table_id; /* ID of table flow came from. */
584 uint8_t pad;
585 ovs_be32 duration_sec; /* Time flow has been alive in seconds. */
586 ovs_be32 duration_nsec; /* Time flow has been alive in nanoseconds beyond
587 duration_sec. */
588 ovs_be16 priority; /* Priority of the entry. Only meaningful
589 when this is not an exact-match entry. */
590 ovs_be16 idle_timeout; /* Number of seconds idle before expiration. */
591 ovs_be16 hard_timeout; /* Number of seconds before expiration. */
2e1ae200
JR
592 ovs_be16 flags; /* OF 1.3: Set of OFPFF*. */
593 uint8_t pad2[4]; /* Align to 64-bits. */
04f68eb2
SH
594 ovs_be64 cookie; /* Opaque controller-issued identifier. */
595 ovs_be64 packet_count; /* Number of packets in flow. */
596 ovs_be64 byte_count; /* Number of bytes in flow. */
597 /* Open Flow version specific match */
598 /* struct ofp11_instruction instructions[0]; Instruction set. */
599};
600OFP_ASSERT(sizeof(struct ofp11_flow_stats) == 48);
601
602/* Body for ofp_stats_request of type OFPST_AGGREGATE. */
603/* Identical to ofp11_flow_stats_request */
604
307975da
SH
605/* Flow match fields. */
606enum ofp11_flow_match_fields {
607 OFPFMF11_IN_PORT = 1 << 0, /* Switch input port. */
608 OFPFMF11_DL_VLAN = 1 << 1, /* VLAN id. */
609 OFPFMF11_DL_VLAN_PCP = 1 << 2, /* VLAN priority. */
610 OFPFMF11_DL_TYPE = 1 << 3, /* Ethernet frame type. */
611 OFPFMF11_NW_TOS = 1 << 4, /* IP ToS (DSCP field, 6 bits). */
612 OFPFMF11_NW_PROTO = 1 << 5, /* IP protocol. */
613 OFPFMF11_TP_SRC = 1 << 6, /* TCP/UDP/SCTP source port. */
614 OFPFMF11_TP_DST = 1 << 7, /* TCP/UDP/SCTP destination port. */
615 OFPFMF11_MPLS_LABEL = 1 << 8, /* MPLS label. */
616 OFPFMF11_MPLS_TC = 1 << 9, /* MPLS TC. */
617 OFPFMF11_TYPE = 1 << 10, /* Match type. */
618 OFPFMF11_DL_SRC = 1 << 11, /* Ethernet source address. */
619 OFPFMF11_DL_DST = 1 << 12, /* Ethernet destination address. */
620 OFPFMF11_NW_SRC = 1 << 13, /* IP source address. */
621 OFPFMF11_NW_DST = 1 << 14, /* IP destination address. */
622 OFPFMF11_METADATA = 1 << 15, /* Metadata passed between tables. */
623};
624
04f68eb2
SH
625/* Body of reply to OFPST_TABLE request. */
626struct ofp11_table_stats {
04f68eb2
SH
627 uint8_t table_id; /* Identifier of table. Lower numbered tables
628 are consulted first. */
629 uint8_t pad[7]; /* Align to 64-bits. */
630 char name[OFP_MAX_TABLE_NAME_LEN];
631 ovs_be32 wildcards; /* Bitmap of OFPFMF_* wildcards that are
632 supported by the table. */
633 ovs_be32 match; /* Bitmap of OFPFMF_* that indicate the fields
634 the table can match on. */
635 ovs_be32 instructions; /* Bitmap of OFPIT_* values supported. */
636 ovs_be32 write_actions; /* Bitmap of OFPAT_* that are supported
637 by the table with OFPIT_WRITE_ACTIONS. */
638 ovs_be32 apply_actions; /* Bitmap of OFPAT_* that are supported
639 by the table with OFPIT_APPLY_ACTIONS. */
640 ovs_be32 config; /* Bitmap of OFPTC_* values */
641 ovs_be32 max_entries; /* Max number of entries supported. */
642 ovs_be32 active_count; /* Number of active entries. */
643 ovs_be64 lookup_count; /* Number of packets looked up in table. */
644 ovs_be64 matched_count; /* Number of packets that hit table. */
645};
982697a4 646OFP_ASSERT(sizeof(struct ofp11_table_stats) == 88);
04f68eb2
SH
647
648/* Body for ofp_stats_request of type OFPST_PORT. */
649struct ofp11_port_stats_request {
04f68eb2
SH
650 ovs_be32 port_no; /* OFPST_PORT message must request statistics
651 * either for a single port (specified in
652 * port_no) or for all ports (if port_no ==
653 * OFPP_ANY). */
654 uint8_t pad[4];
655};
982697a4 656OFP_ASSERT(sizeof(struct ofp11_port_stats_request) == 8);
04f68eb2
SH
657
658/* Body of reply to OFPST_PORT request. If a counter is unsupported, set
659 * the field to all ones. */
660struct ofp11_port_stats {
04f68eb2
SH
661 ovs_be32 port_no;
662 uint8_t pad[4]; /* Align to 64-bits. */
663 ovs_be64 rx_packets; /* Number of received packets. */
664 ovs_be64 tx_packets; /* Number of transmitted packets. */
665 ovs_be64 rx_bytes; /* Number of received bytes. */
666 ovs_be64 tx_bytes; /* Number of transmitted bytes. */
667 ovs_be64 rx_dropped; /* Number of packets dropped by RX. */
668 ovs_be64 tx_dropped; /* Number of packets dropped by TX. */
669 ovs_be64 rx_errors; /* Number of receive errors. This is a
670 super-set of receive errors and should be
671 great than or equal to the sum of all
672 rx_*_err values. */
673 ovs_be64 tx_errors; /* Number of transmit errors. This is a
674 super-set of transmit errors. */
675 ovs_be64 rx_frame_err; /* Number of frame alignment errors. */
676 ovs_be64 rx_over_err; /* Number of packets with RX overrun. */
677 ovs_be64 rx_crc_err; /* Number of CRC errors. */
678 ovs_be64 collisions; /* Number of collisions. */
679};
982697a4 680OFP_ASSERT(sizeof(struct ofp11_port_stats) == 104);
04f68eb2
SH
681
682struct ofp11_queue_stats_request {
04f68eb2
SH
683 ovs_be32 port_no; /* All ports if OFPP_ANY. */
684 ovs_be32 queue_id; /* All queues if OFPQ_ALL. */
685};
982697a4 686OFP_ASSERT(sizeof(struct ofp11_queue_stats_request) == 8);
04f68eb2
SH
687
688struct ofp11_queue_stats {
04f68eb2
SH
689 ovs_be32 port_no;
690 ovs_be32 queue_id; /* Queue id. */
691 ovs_be64 tx_bytes; /* Number of transmitted bytes. */
692 ovs_be64 tx_packets; /* Number of transmitted packets. */
693 ovs_be64 tx_errors; /* # of packets dropped due to overrun. */
694};
982697a4 695OFP_ASSERT(sizeof(struct ofp11_queue_stats) == 32);
04f68eb2
SH
696
697struct ofp11_group_stats_request {
04f68eb2
SH
698 ovs_be32 group_id; /* All groups if OFPG_ALL. */
699 uint8_t pad[4]; /* Align to 64 bits. */
700};
982697a4 701OFP_ASSERT(sizeof(struct ofp11_group_stats_request) == 8);
04f68eb2
SH
702
703/* Body of reply to OFPST11_GROUP request */
704struct ofp11_group_stats {
705 ovs_be16 length; /* Length of this entry. */
706 uint8_t pad[2]; /* Align to 64 bits. */
707 ovs_be32 group_id; /* Group identifier. */
708 ovs_be32 ref_count; /* Number of flows or groups that
709 directly forward to this group. */
710 uint8_t pad2[4]; /* Align to 64 bits. */
711 ovs_be64 packet_count; /* Number of packets processed by group. */
712 ovs_be64 byte_count; /* Number of bytes processed by group. */
713 /* struct ofp11_bucket_counter bucket_stats[0]; */
714
715};
716OFP_ASSERT(sizeof(struct ofp11_group_stats) == 32);
717
718/* Used in group stats replies. */
719struct ofp11_bucket_counter {
04f68eb2
SH
720 ovs_be64 packet_count; /* Number of packets processed by bucket. */
721 ovs_be64 byte_count; /* Number of bytes processed by bucket. */
722};
982697a4 723OFP_ASSERT(sizeof(struct ofp11_bucket_counter) == 16);
04f68eb2
SH
724
725/* Body of reply to OFPST11_GROUP_DESC request. */
726struct ofp11_group_desc_stats {
727 ovs_be16 length; /* Length of this entry. */
728 uint8_t type; /* One of OFPGT_*. */
729 uint8_t pad; /* Pad to 64 bits. */
730 ovs_be32 group_id; /* Group identifier. */
731 /* struct ofp11_bucket buckets[0]; */
732};
733OFP_ASSERT(sizeof(struct ofp11_group_desc_stats) == 8);
734
735/* Send packet (controller -> datapath). */
736struct ofp11_packet_out {
04f68eb2
SH
737 ovs_be32 buffer_id; /* ID assigned by datapath (-1 if none). */
738 ovs_be32 in_port; /* Packet's input port or OFPP_CONTROLLER. */
739 ovs_be16 actions_len; /* Size of action array in bytes. */
740 uint8_t pad[6];
741 /* struct ofp_action_header actions[0]; Action list. */
742 /* uint8_t data[0]; */ /* Packet data. The length is inferred
743 from the length field in the header.
744 (Only meaningful if buffer_id == -1.) */
745};
982697a4 746OFP_ASSERT(sizeof(struct ofp11_packet_out) == 16);
04f68eb2
SH
747
748/* Packet received on port (datapath -> controller). */
749struct ofp11_packet_in {
04f68eb2
SH
750 ovs_be32 buffer_id; /* ID assigned by datapath. */
751 ovs_be32 in_port; /* Port on which frame was received. */
752 ovs_be32 in_phy_port; /* Physical Port on which frame was received. */
753 ovs_be16 total_len; /* Full length of frame. */
754 uint8_t reason; /* Reason packet is being sent (one of OFPR_*) */
755 uint8_t table_id; /* ID of the table that was looked up */
31a9e63f 756 /* uint8_t data[0]; Ethernet frame, halfway through 32-bit word,
04f68eb2
SH
757 so the IP header is 32-bit aligned. The
758 amount of data is inferred from the length
759 field in the header. Because of padding,
760 offsetof(struct ofp_packet_in, data) ==
761 sizeof(struct ofp_packet_in) - 2. */
762};
982697a4 763OFP_ASSERT(sizeof(struct ofp11_packet_in) == 16);
04f68eb2
SH
764
765/* Flow removed (datapath -> controller). */
766struct ofp11_flow_removed {
04f68eb2
SH
767 ovs_be64 cookie; /* Opaque controller-issued identifier. */
768
769 ovs_be16 priority; /* Priority level of flow entry. */
770 uint8_t reason; /* One of OFPRR_*. */
771 uint8_t table_id; /* ID of the table */
772
773 ovs_be32 duration_sec; /* Time flow was alive in seconds. */
774 ovs_be32 duration_nsec; /* Time flow was alive in nanoseconds beyond
775 duration_sec. */
776 ovs_be16 idle_timeout; /* Idle timeout from original flow mod. */
777 uint8_t pad2[2]; /* Align to 64-bits. */
778 ovs_be64 packet_count;
779 ovs_be64 byte_count;
aa319503 780 /* Followed by an ofp11_match structure. */
04f68eb2 781};
aa319503 782OFP_ASSERT(sizeof(struct ofp11_flow_removed) == 40);
04f68eb2 783
87ea5e5e 784#endif /* openflow/openflow-1.1.h */