Global replace of Nicira Networks.
[sliver-openvswitch.git] / include / openflow / openflow-1.1.h
1 /* Copyright (c) 2008, 2011, 2012 The Board of Trustees of The Leland Stanford
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 /*
35  * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
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
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)
72
73 /* OpenFlow 1.1 specific message types, in addition to the common message
74  * types. */
75 enum ofp11_type {
76     /* Controller command messages. */
77     OFPT11_PACKET_OUT = 13,     /* Controller/switch message */
78     OFPT11_FLOW_MOD,            /* Controller/switch message */
79     OFPT11_GROUP_MOD,           /* Controller/switch message */
80     OFPT11_PORT_MOD,            /* Controller/switch message */
81     OFPT11_TABLE_MOD,           /* Controller/switch message */
82
83     /* Statistics messages. */
84     OFPT11_STATS_REQUEST,       /* Controller/switch message */
85     OFPT11_STATS_REPLY,         /* Controller/switch message */
86
87     /* Barrier messages. */
88     OFPT11_BARRIER_REQUEST,     /* Controller/switch message */
89     OFPT11_BARRIER_REPLY,       /* Controller/switch message */
90
91     /* Queue Configuration messages. */
92     OFPT11_QUEUE_GET_CONFIG_REQUEST,  /* Controller/switch message */
93     OFPT11_QUEUE_GET_CONFIG_REPLY,    /* Controller/switch message */
94 };
95
96 /* OpenFlow 1.1 port config flags are just the common flags. */
97 #define OFPPC11_ALL \
98     (OFPPC_PORT_DOWN | OFPPC_NO_RECV | OFPPC_NO_FWD | OFPPC_NO_PACKET_IN)
99
100 /* OpenFlow 1.1 specific current state of the physical port.  These are not
101  * configurable from the controller.
102  */
103 enum ofp11_port_state {
104     OFPPS11_BLOCKED      = 1 << 1,  /* Port is blocked */
105     OFPPS11_LIVE         = 1 << 2,  /* Live for Fast Failover Group. */
106 #define OFPPS11_ALL (OFPPS_LINK_DOWN | OFPPS11_BLOCKED | OFPPS11_LIVE)
107 };
108
109 /* OpenFlow 1.1 specific features of ports available in a datapath. */
110 enum ofp11_port_features {
111     OFPPF11_40GB_FD    = 1 << 7,  /* 40 Gb full-duplex rate support. */
112     OFPPF11_100GB_FD   = 1 << 8,  /* 100 Gb full-duplex rate support. */
113     OFPPF11_1TB_FD     = 1 << 9,  /* 1 Tb full-duplex rate support. */
114     OFPPF11_OTHER      = 1 << 10, /* Other rate, not in the list. */
115
116     OFPPF11_COPPER     = 1 << 11, /* Copper medium. */
117     OFPPF11_FIBER      = 1 << 12, /* Fiber medium. */
118     OFPPF11_AUTONEG    = 1 << 13, /* Auto-negotiation. */
119     OFPPF11_PAUSE      = 1 << 14, /* Pause. */
120     OFPPF11_PAUSE_ASYM = 1 << 15  /* Asymmetric pause. */
121 #define OFPPF11_ALL ((1 << 16) - 1)
122 };
123
124 /* Description of a port */
125 struct ofp11_port {
126     ovs_be32 port_no;
127     uint8_t pad[4];
128     uint8_t hw_addr[OFP_ETH_ALEN];
129     uint8_t pad2[2];                  /* Align to 64 bits. */
130     char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
131
132     ovs_be32 config;        /* Bitmap of OFPPC_* flags. */
133     ovs_be32 state;         /* Bitmap of OFPPS_* and OFPPS11_* flags. */
134
135     /* Bitmaps of OFPPF_* and OFPPF11_* that describe features.  All bits
136      * zeroed if unsupported or unavailable. */
137     ovs_be32 curr;          /* Current features. */
138     ovs_be32 advertised;    /* Features being advertised by the port. */
139     ovs_be32 supported;     /* Features supported by the port. */
140     ovs_be32 peer;          /* Features advertised by peer. */
141
142     ovs_be32 curr_speed;    /* Current port bitrate in kbps. */
143     ovs_be32 max_speed;     /* Max port bitrate in kbps */
144 };
145
146 /* Modify behavior of the physical port */
147 struct ofp11_port_mod {
148     struct ofp_header header;
149     ovs_be32 port_no;
150     uint8_t pad[4];
151     uint8_t hw_addr[OFP_ETH_ALEN]; /* The hardware address is not
152                                       configurable.  This is used to
153                                       sanity-check the request, so it must
154                                       be the same as returned in an
155                                       ofp11_port struct. */
156     uint8_t pad2[2];        /* Pad to 64 bits. */
157     ovs_be32 config;        /* Bitmap of OFPPC_* flags. */
158     ovs_be32 mask;          /* Bitmap of OFPPC_* flags to be changed. */
159
160     ovs_be32 advertise;     /* Bitmap of OFPPF_* and OFPPF11_*.  Zero all bits
161                                to prevent any action taking place. */
162     uint8_t pad3[4];        /* Pad to 64 bits. */
163 };
164 OFP_ASSERT(sizeof(struct ofp11_port_mod) == 40);
165
166 /* Group setup and teardown (controller -> datapath). */
167 struct ofp11_group_mod {
168     struct ofp_header header;
169     ovs_be16 command;             /* One of OFPGC_*. */
170     uint8_t type;                 /* One of OFPGT_*. */
171     uint8_t pad;                  /* Pad to 64 bits. */
172     ovs_be32 group_id;            /* Group identifier. */
173     /* struct ofp11_bucket buckets[0]; The bucket length is inferred from the
174                                        length field in the header. */
175 };
176 OFP_ASSERT(sizeof(struct ofp11_group_mod) == 16);
177
178 /* Query for port queue configuration. */
179 struct ofp11_queue_get_config_request {
180     struct ofp_header header;
181     ovs_be32 port;
182     /* Port to be queried. Should refer
183        to a valid physical port (i.e. < OFPP_MAX) */
184     uint8_t pad[4];
185 };
186 OFP_ASSERT(sizeof(struct ofp11_queue_get_config_request) == 16);
187
188 /* Group commands */
189 enum ofp11_group_mod_command {
190     OFPGC11_ADD,          /* New group. */
191     OFPGC11_MODIFY,       /* Modify all matching groups. */
192     OFPGC11_DELETE,       /* Delete all matching groups. */
193 };
194
195 /* OpenFlow 1.1 specific capabilities supported by the datapath (struct
196  * ofp_switch_features, member capabilities). */
197 enum ofp11_capabilities {
198     OFPC11_GROUP_STATS    = 1 << 3,  /* Group statistics. */
199 };
200
201 enum ofp11_action_type {
202     OFPAT11_OUTPUT,           /* Output to switch port. */
203     OFPAT11_SET_VLAN_VID,     /* Set the 802.1q VLAN id. */
204     OFPAT11_SET_VLAN_PCP,     /* Set the 802.1q priority. */
205     OFPAT11_SET_DL_SRC,       /* Ethernet source address. */
206     OFPAT11_SET_DL_DST,       /* Ethernet destination address. */
207     OFPAT11_SET_NW_SRC,       /* IP source address. */
208     OFPAT11_SET_NW_DST,       /* IP destination address. */
209     OFPAT11_SET_NW_TOS,       /* IP ToS (DSCP field, 6 bits). */
210     OFPAT11_SET_NW_ECN,       /* IP ECN (2 bits). */
211     OFPAT11_SET_TP_SRC,       /* TCP/UDP/SCTP source port. */
212     OFPAT11_SET_TP_DST,       /* TCP/UDP/SCTP destination port. */
213     OFPAT11_COPY_TTL_OUT,     /* Copy TTL "outwards" -- from next-to-outermost
214                                  to outermost */
215     OFPAT11_COPY_TTL_IN,      /* Copy TTL "inwards" -- from outermost to
216                                next-to-outermost */
217     OFPAT11_SET_MPLS_LABEL,   /* MPLS label */
218     OFPAT11_SET_MPLS_TC,      /* MPLS TC */
219     OFPAT11_SET_MPLS_TTL,     /* MPLS TTL */
220     OFPAT11_DEC_MPLS_TTL,     /* Decrement MPLS TTL */
221
222     OFPAT11_PUSH_VLAN,        /* Push a new VLAN tag */
223     OFPAT11_POP_VLAN,         /* Pop the outer VLAN tag */
224     OFPAT11_PUSH_MPLS,        /* Push a new MPLS tag */
225     OFPAT11_POP_MPLS,         /* Pop the outer MPLS tag */
226     OFPAT11_SET_QUEUE,        /* Set queue id when outputting to a port */
227     OFPAT11_GROUP,            /* Apply group. */
228     OFPAT11_SET_NW_TTL,       /* IP TTL. */
229     OFPAT11_DEC_NW_TTL,       /* Decrement IP TTL. */
230     OFPAT11_EXPERIMENTER = 0xffff
231 };
232
233 #define OFPMT11_STANDARD_LENGTH 88
234
235 struct ofp11_match_header {
236     ovs_be16 type;             /* One of OFPMT_* */
237     ovs_be16 length;           /* Length of match */
238 };
239 OFP_ASSERT(sizeof(struct ofp11_match_header) == 4);
240
241 /* Fields to match against flows */
242 struct ofp11_match {
243     struct ofp11_match_header omh;
244     ovs_be32 in_port;          /* Input switch port. */
245     ovs_be32 wildcards;        /* Wildcard fields. */
246     uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */
247     uint8_t dl_src_mask[OFP_ETH_ALEN]; /* Ethernet source address mask.  */
248     uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */
249     uint8_t dl_dst_mask[OFP_ETH_ALEN]; /* Ethernet destination address mask. */
250     ovs_be16 dl_vlan;          /* Input VLAN id. */
251     uint8_t dl_vlan_pcp;       /* Input VLAN priority. */
252     uint8_t pad1[1];           /* Align to 32-bits */
253     ovs_be16 dl_type;          /* Ethernet frame type. */
254     uint8_t nw_tos;            /* IP ToS (actually DSCP field, 6 bits). */
255     uint8_t nw_proto;          /* IP protocol or lower 8 bits of ARP opcode. */
256     ovs_be32 nw_src;           /* IP source address. */
257     ovs_be32 nw_src_mask;      /* IP source address mask. */
258     ovs_be32 nw_dst;           /* IP destination address. */
259     ovs_be32 nw_dst_mask;      /* IP destination address mask. */
260     ovs_be16 tp_src;           /* TCP/UDP/SCTP source port. */
261     ovs_be16 tp_dst;           /* TCP/UDP/SCTP destination port. */
262     ovs_be32 mpls_label;       /* MPLS label. */
263     uint8_t mpls_tc;           /* MPLS TC. */
264     uint8_t pad2[3];           /* Align to 64-bits */
265     ovs_be64 metadata;         /* Metadata passed between tables. */
266     ovs_be64 metadata_mask;    /* Mask for metadata. */
267 };
268 OFP_ASSERT(sizeof(struct ofp11_match) == OFPMT11_STANDARD_LENGTH);
269
270 /* Flow wildcards. */
271 enum ofp11_flow_wildcards {
272     OFPFW11_IN_PORT    = 1 << 0,  /* Switch input port. */
273     OFPFW11_DL_VLAN    = 1 << 1,  /* VLAN vid. */
274     OFPFW11_DL_SRC     = 1 << 2,  /* Ethernet source address. */
275     OFPFW11_DL_DST     = 1 << 3,  /* Ethernet destination address. */
276     OFPFW11_DL_TYPE    = 1 << 4,  /* Ethernet frame type. */
277     OFPFW11_NW_PROTO   = 1 << 5,  /* IP protocol. */
278     OFPFW11_TP_SRC     = 1 << 6,  /* TCP/UDP source port. */
279     OFPFW11_TP_DST     = 1 << 7,  /* TCP/UDP destination port. */
280     OFPFW11_MPLS_LABEL = 1 << 8,  /* MPLS label. */
281     OFPFW11_MPLS_TC    = 1 << 9,  /* MPLS TC. */
282
283     /* Wildcard all fields. */
284     OFPFW11_ALL = ((1 << 10) - 1)
285 };
286
287 /* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
288  * special conditions.
289  */
290 enum ofp11_vlan_id {
291     OFPVID11_ANY = 0xfffe,  /* Indicate that a VLAN id is set but don't care
292                                about it's value. Note: only valid when
293                                specifying the VLAN id in a match */
294     OFPVID11_NONE = 0xffff, /* No VLAN id was set. */
295 };
296
297 enum ofp11_instruction_type {
298     OFPIT11_GOTO_TABLE = 1,        /* Setup the next table in the lookup
299                                       pipeline */
300     OFPIT11_WRITE_METADATA = 2,    /* Setup the metadata field for use later
301                                       in pipeline */
302     OFPIT11_WRITE_ACTIONS = 3,     /* Write the action(s) onto the datapath
303                                       action set */
304     OFPIT11_APPLY_ACTIONS = 4,     /* Applies the action(s) immediately */
305     OFPIT11_CLEAR_ACTIONS = 5,     /* Clears all actions from the datapath
306                                       action set */
307     OFPIT11_EXPERIMENTER = 0xFFFF  /* Experimenter instruction */
308 };
309
310 /* Instruction structure for OFPIT_GOTO_TABLE */
311 struct ofp11_instruction_goto_table {
312     ovs_be16 type;                 /* OFPIT_GOTO_TABLE */
313     ovs_be16 len;                  /* Length of this struct in bytes. */
314     uint8_t table_id;              /* Set next table in the lookup pipeline */
315     uint8_t pad[3];                /* Pad to 64 bits. */
316 };
317 OFP_ASSERT(sizeof(struct ofp11_instruction_goto_table) == 8);
318
319 /* Instruction structure for OFPIT_WRITE_METADATA */
320 struct ofp11_instruction_write_metadata {
321     ovs_be16 type;              /* OFPIT_WRITE_METADATA */
322     ovs_be16 len;               /* Length of this struct in bytes. */
323     uint8_t pad[4];             /* Align to 64-bits */
324     ovs_be64 metadata;          /* Metadata value to write */
325     ovs_be64 metadata_mask;     /* Metadata write bitmask */
326 };
327 OFP_ASSERT(sizeof(struct ofp11_instruction_write_metadata) == 24);
328
329 /* Instruction structure for OFPIT_WRITE/APPLY/CLEAR_ACTIONS */
330 struct ofp11_instruction_actions {
331     ovs_be16 type;              /* One of OFPIT_*_ACTIONS */
332     ovs_be16 len;               /* Length of this struct in bytes. */
333     uint8_t pad[4];             /* Align to 64-bits */
334     /* struct ofp_action_header actions[0];  Actions associated with
335                                              OFPIT_WRITE_ACTIONS and
336                                              OFPIT_APPLY_ACTIONS */
337 };
338 OFP_ASSERT(sizeof(struct ofp11_instruction_actions) == 8);
339
340 /* Action structure for OFPAT_OUTPUT, which sends packets out 'port'.
341    * When the 'port' is the OFPP_CONTROLLER, 'max_len' indicates the max
342    * number of bytes to send. A 'max_len' of zero means no bytes of the
343    * packet should be sent.*/
344 struct ofp11_action_output {
345     ovs_be16 type;                    /* OFPAT11_OUTPUT. */
346     ovs_be16 len;                     /* Length is 16. */
347     ovs_be32 port;                    /* Output port. */
348     ovs_be16 max_len;                 /* Max length to send to controller. */
349     uint8_t pad[6];                   /* Pad to 64 bits. */
350 };
351 OFP_ASSERT(sizeof(struct ofp11_action_output) == 16);
352
353 /* Action structure for OFPAT_GROUP. */
354 struct ofp11_action_group {
355     ovs_be16 type;                    /* OFPAT11_GROUP. */
356     ovs_be16 len;                     /* Length is 8. */
357     ovs_be32 group_id;                /* Group identifier. */
358 };
359 OFP_ASSERT(sizeof(struct ofp11_action_group) == 8);
360
361 /* OFPAT_SET_QUEUE action struct: send packets to given queue on port. */
362 struct ofp11_action_set_queue {
363     ovs_be16 type;                    /* OFPAT11_SET_QUEUE. */
364     ovs_be16 len;                     /* Len is 8. */
365     ovs_be32 queue_id;                /* Queue id for the packets. */
366 };
367 OFP_ASSERT(sizeof(struct ofp11_action_set_queue) == 8);
368
369 /* Action structure for OFPAT11_SET_MPLS_LABEL. */
370 struct ofp11_action_mpls_label {
371     ovs_be16 type;                    /* OFPAT11_SET_MPLS_LABEL. */
372     ovs_be16 len;                     /* Length is 8. */
373     ovs_be32 mpls_label;              /* MPLS label */
374 };
375 OFP_ASSERT(sizeof(struct ofp11_action_mpls_label) == 8);
376
377 /* Action structure for OFPAT11_SET_MPLS_TC. */
378 struct ofp11_action_mpls_tc {
379     ovs_be16 type;                    /* OFPAT11_SET_MPLS_TC. */
380     ovs_be16 len;                     /* Length is 8. */
381     uint8_t mpls_tc;                  /* MPLS TC */
382     uint8_t pad[3];
383 };
384 OFP_ASSERT(sizeof(struct ofp11_action_mpls_tc) == 8);
385
386 /* Action structure for OFPAT11_SET_MPLS_TTL. */
387 struct ofp11_action_mpls_ttl {
388     ovs_be16 type;                    /* OFPAT11_SET_MPLS_TTL. */
389     ovs_be16 len;                     /* Length is 8. */
390     uint8_t mpls_ttl;                 /* MPLS TTL */
391     uint8_t pad[3];
392 };
393 OFP_ASSERT(sizeof(struct ofp11_action_mpls_ttl) == 8);
394
395 /* Action structure for OFPAT11_SET_NW_ECN. */
396 struct ofp11_action_nw_ecn {
397     ovs_be16 type;                    /* OFPAT11_SET_TW_SRC/DST. */
398     ovs_be16 len;                     /* Length is 8. */
399     uint8_t nw_ecn;                   /* IP ECN (2 bits). */
400     uint8_t pad[3];
401 };
402 OFP_ASSERT(sizeof(struct ofp11_action_nw_ecn) == 8);
403
404 /* Action structure for OFPAT11_SET_NW_TTL. */
405 struct ofp11_action_nw_ttl {
406     ovs_be16 type;                    /* OFPAT11_SET_NW_TTL. */
407     ovs_be16 len;                     /* Length is 8. */
408     uint8_t nw_ttl;                   /* IP TTL */
409     uint8_t pad[3];
410 };
411 OFP_ASSERT(sizeof(struct ofp11_action_nw_ttl) == 8);
412
413 /* Action structure for OFPAT11_PUSH_VLAN/MPLS. */
414 struct ofp11_action_push {
415     ovs_be16 type;                    /* OFPAT11_PUSH_VLAN/MPLS. */
416     ovs_be16 len;                     /* Length is 8. */
417     ovs_be16 ethertype;               /* Ethertype */
418     uint8_t pad[2];
419 };
420 OFP_ASSERT(sizeof(struct ofp11_action_push) == 8);
421
422 /* Action structure for OFPAT11_POP_MPLS. */
423 struct ofp11_action_pop_mpls {
424     ovs_be16 type;                    /* OFPAT11_POP_MPLS. */
425     ovs_be16 len;                     /* Length is 8. */
426     ovs_be16 ethertype;               /* Ethertype */
427     uint8_t pad[2];
428 };
429 OFP_ASSERT(sizeof(struct ofp11_action_pop_mpls) == 8);
430
431 /* Configure/Modify behavior of a flow table */
432 struct ofp11_table_mod {
433     struct ofp_header header;
434     uint8_t table_id;       /* ID of the table, 0xFF indicates all tables */
435     uint8_t pad[3];         /* Pad to 32 bits */
436     ovs_be32 config;        /* Bitmap of OFPTC_* flags */
437 };
438 OFP_ASSERT(sizeof(struct ofp11_table_mod) == 16);
439
440 /* Flags to indicate behavior of the flow table for unmatched packets.
441    These flags are used in ofp_table_stats messages to describe the current
442    configuration and in ofp_table_mod messages to configure table behavior.  */
443 enum ofp11_table_config {
444     OFPTC11_TABLE_MISS_CONTROLLER = 0,    /* Send to controller. */
445     OFPTC11_TABLE_MISS_CONTINUE = 1 << 0, /* Continue to the next table in the
446                                              pipeline (OpenFlow 1.0
447                                              behavior). */
448     OFPTC11_TABLE_MISS_DROP = 1 << 1,     /* Drop the packet. */
449     OFPTC11_TABLE_MISS_MASK = 3
450 };
451
452 /* Flow setup and teardown (controller -> datapath). */
453 struct ofp11_flow_mod {
454     struct ofp_header header;
455     ovs_be64 cookie;             /* Opaque controller-issued identifier. */
456     ovs_be64 cookie_mask;        /* Mask used to restrict the cookie bits
457                                     that must match when the command is
458                                     OFPFC_MODIFY* or OFPFC_DELETE*. A value
459                                     of 0 indicates no restriction. */
460     /* Flow actions. */
461     uint8_t table_id;            /* ID of the table to put the flow in */
462     uint8_t command;             /* One of OFPFC_*. */
463     ovs_be16 idle_timeout;       /* Idle time before discarding (seconds). */
464     ovs_be16 hard_timeout;       /* Max time before discarding (seconds). */
465     ovs_be16 priority;           /* Priority level of flow entry. */
466     ovs_be32 buffer_id;          /* Buffered packet to apply to (or -1).
467                                     Not meaningful for OFPFC_DELETE*. */
468     ovs_be32 out_port;           /* For OFPFC_DELETE* commands, require
469                                     matching entries to include this as an
470                                     output port. A value of OFPP_ANY
471                                     indicates no restriction. */
472     ovs_be32 out_group;          /* For OFPFC_DELETE* commands, require
473                                     matching entries to include this as an
474                                     output group. A value of OFPG_ANY
475                                     indicates no restriction. */
476     ovs_be16 flags;              /* One of OFPFF_*. */
477     uint8_t pad[2];
478     /* Open Flow version specific match */
479     /* struct ofp_instruction instructions[0];  Instruction set */
480 };
481 OFP_ASSERT(sizeof(struct ofp11_flow_mod) == 48);
482
483 /* Group types. Values in the range [128, 255] are reserved for experimental
484  * use. */
485 enum ofp11_group_type {
486     OFPGT11_ALL,      /* All (multicast/broadcast) group. */
487     OFPGT11_SELECT,   /* Select group. */
488     OFPGT11_INDIRECT, /* Indirect group. */
489     OFPGT11_FF        /* Fast failover group. */
490 };
491
492 /* Bucket for use in groups. */
493 struct ofp11_bucket {
494     ovs_be16 len;                    /* Length the bucket in bytes, including
495                                         this header and any padding to make it
496                                         64-bit aligned. */
497     ovs_be16 weight;                 /* Relative weight of bucket. Only
498                                         defined for select groups. */
499     ovs_be32 watch_port;             /* Port whose state affects whether this
500                                         bucket is live. Only required for fast
501                                         failover groups. */
502     ovs_be32 watch_group;            /* Group whose state affects whether this
503                                         bucket is live. Only required for fast
504                                         failover groups. */
505     uint8_t pad[4];
506     /* struct ofp_action_header actions[0]; The action length is inferred
507                                             from the length field in the
508                                             header. */
509 };
510 OFP_ASSERT(sizeof(struct ofp11_bucket) == 16);
511
512 /* Queue configuration for a given port. */
513 struct ofp11_queue_get_config_reply {
514     struct ofp_header header;
515     ovs_be32 port;
516     uint8_t pad[4];
517     /* struct ofp_packet_queue queues[0];  List of configured queues. */
518 };
519 OFP_ASSERT(sizeof(struct ofp11_queue_get_config_reply) == 16);
520
521 struct ofp11_stats_msg {
522     struct ofp_header header;
523     ovs_be16 type;              /* One of the OFPST_* constants. */
524     ovs_be16 flags;             /* OFPSF_REQ_* flags (none yet defined). */
525     uint8_t pad[4];
526     /* uint8_t body[0];             Body of the request. */
527 };
528 OFP_ASSERT(sizeof(struct ofp11_stats_msg) == 16);
529
530 /* Stats request of type OFPST_FLOW. */
531 struct ofp11_flow_stats_request {
532     struct ofp11_stats_msg osm;
533     uint8_t table_id;         /* ID of table to read (from ofp_table_stats),
534                                  0xff for all tables. */
535     uint8_t pad[3];           /* Align to 64 bits. */
536     ovs_be32 out_port;        /* Require matching entries to include this
537                                  as an output port. A value of OFPP_ANY
538                                  indicates no restriction. */
539     ovs_be32 out_group;       /* Require matching entries to include this
540                                  as an output group. A value of OFPG_ANY
541                                  indicates no restriction. */
542     uint8_t pad2[4];          /* Align to 64 bits. */
543     ovs_be64 cookie;          /* Require matching entries to contain this
544                                  cookie value */
545     ovs_be64 cookie_mask;     /* Mask used to restrict the cookie bits that
546                                  must match. A value of 0 indicates
547                                  no restriction. */
548     struct ofp11_match match; /* Fields to match. */
549 };
550 OFP_ASSERT(sizeof(struct ofp11_flow_stats_request) == 136);
551
552 /* Body of reply to OFPST_FLOW request. */
553 struct ofp11_flow_stats {
554     ovs_be16 length;           /* Length of this entry. */
555     uint8_t table_id;          /* ID of table flow came from. */
556     uint8_t pad;
557     ovs_be32 duration_sec;     /* Time flow has been alive in seconds. */
558     ovs_be32 duration_nsec;    /* Time flow has been alive in nanoseconds beyond
559                                   duration_sec. */
560     ovs_be16 priority;         /* Priority of the entry. Only meaningful
561                                   when this is not an exact-match entry. */
562     ovs_be16 idle_timeout;     /* Number of seconds idle before expiration. */
563     ovs_be16 hard_timeout;     /* Number of seconds before expiration. */
564     uint8_t pad2[6];           /* Align to 64-bits. */
565     ovs_be64 cookie;           /* Opaque controller-issued identifier. */
566     ovs_be64 packet_count;     /* Number of packets in flow. */
567     ovs_be64 byte_count;       /* Number of bytes in flow. */
568     /* Open Flow version specific match */
569     /* struct ofp11_instruction instructions[0];  Instruction set. */
570 };
571 OFP_ASSERT(sizeof(struct ofp11_flow_stats) == 48);
572
573 /* Body for ofp_stats_request of type OFPST_AGGREGATE. */
574 /* Identical to ofp11_flow_stats_request */
575
576 /* Body of reply to OFPST_TABLE request. */
577 struct ofp11_table_stats {
578     struct ofp11_stats_msg osm;
579     uint8_t table_id;        /* Identifier of table. Lower numbered tables
580                                 are consulted first. */
581     uint8_t pad[7];          /* Align to 64-bits. */
582     char name[OFP_MAX_TABLE_NAME_LEN];
583     ovs_be32 wildcards;      /* Bitmap of OFPFMF_* wildcards that are
584                                 supported by the table. */
585     ovs_be32 match;          /* Bitmap of OFPFMF_* that indicate the fields
586                                 the table can match on. */
587     ovs_be32 instructions;   /* Bitmap of OFPIT_* values supported. */
588     ovs_be32 write_actions;  /* Bitmap of OFPAT_* that are supported
589                                 by the table with OFPIT_WRITE_ACTIONS.  */
590     ovs_be32 apply_actions;  /* Bitmap of OFPAT_* that are supported
591                                 by the table with OFPIT_APPLY_ACTIONS. */
592     ovs_be32 config;         /* Bitmap of OFPTC_* values */
593     ovs_be32 max_entries;    /* Max number of entries supported. */
594     ovs_be32 active_count;   /* Number of active entries. */
595     ovs_be64 lookup_count;   /* Number of packets looked up in table. */
596     ovs_be64 matched_count;  /* Number of packets that hit table. */
597 };
598 OFP_ASSERT(sizeof(struct ofp11_table_stats) == 104);
599
600 /* Body for ofp_stats_request of type OFPST_PORT. */
601 struct ofp11_port_stats_request {
602     struct ofp11_stats_msg osm;
603     ovs_be32 port_no;        /* OFPST_PORT message must request statistics
604                               * either for a single port (specified in
605                               * port_no) or for all ports (if port_no ==
606                               * OFPP_ANY). */
607     uint8_t pad[4];
608 };
609 OFP_ASSERT(sizeof(struct ofp11_port_stats_request) == 24);
610
611 /* Body of reply to OFPST_PORT request. If a counter is unsupported, set
612  * the field to all ones. */
613 struct ofp11_port_stats {
614     struct ofp11_stats_msg osm;
615     ovs_be32 port_no;
616     uint8_t pad[4];           /* Align to 64-bits. */
617     ovs_be64 rx_packets;      /* Number of received packets. */
618     ovs_be64 tx_packets;      /* Number of transmitted packets. */
619     ovs_be64 rx_bytes;        /* Number of received bytes. */
620     ovs_be64 tx_bytes;        /* Number of transmitted bytes. */
621     ovs_be64 rx_dropped;      /* Number of packets dropped by RX. */
622     ovs_be64 tx_dropped;      /* Number of packets dropped by TX. */
623     ovs_be64 rx_errors;       /* Number of receive errors.  This is a
624                                  super-set of receive errors and should be
625                                  great than or equal to the sum of all
626                                  rx_*_err values. */
627     ovs_be64 tx_errors;       /* Number of transmit errors.  This is a
628                                  super-set of transmit errors. */
629     ovs_be64 rx_frame_err;    /* Number of frame alignment errors. */
630     ovs_be64 rx_over_err;     /* Number of packets with RX overrun. */
631     ovs_be64 rx_crc_err;      /* Number of CRC errors. */
632     ovs_be64 collisions;      /* Number of collisions. */
633 };
634 OFP_ASSERT(sizeof(struct ofp11_port_stats) == 120);
635
636 struct ofp11_queue_stats_request {
637     struct ofp11_stats_msg osm;
638     ovs_be32 port_no;         /* All ports if OFPP_ANY. */
639     ovs_be32 queue_id;        /* All queues if OFPQ_ALL. */
640 };
641 OFP_ASSERT(sizeof(struct ofp11_queue_stats_request) == 24);
642
643 struct ofp11_queue_stats {
644     struct ofp11_stats_msg osm;
645     ovs_be32 port_no;
646     ovs_be32 queue_id;         /* Queue id. */
647     ovs_be64 tx_bytes;         /* Number of transmitted bytes. */
648     ovs_be64 tx_packets;       /* Number of transmitted packets. */
649     ovs_be64 tx_errors;        /* # of packets dropped due to overrun. */
650 };
651 OFP_ASSERT(sizeof(struct ofp11_queue_stats) == 48);
652
653 struct ofp11_group_stats_request {
654     struct ofp11_stats_msg osm;
655     ovs_be32 group_id;         /* All groups if OFPG_ALL. */
656     uint8_t pad[4];            /* Align to 64 bits. */
657 };
658 OFP_ASSERT(sizeof(struct ofp11_group_stats_request) == 24);
659
660 /* Body of reply to OFPST11_GROUP request */
661 struct ofp11_group_stats {
662     ovs_be16 length;           /* Length of this entry. */
663     uint8_t pad[2];            /* Align to 64 bits. */
664     ovs_be32 group_id;         /* Group identifier. */
665     ovs_be32 ref_count;        /* Number of flows or groups that
666                                   directly forward to this group. */
667     uint8_t pad2[4];           /* Align to 64 bits. */
668     ovs_be64 packet_count;     /* Number of packets processed by group. */
669     ovs_be64 byte_count;       /* Number of bytes processed by group. */
670     /* struct ofp11_bucket_counter bucket_stats[0]; */
671
672 };
673 OFP_ASSERT(sizeof(struct ofp11_group_stats) == 32);
674
675 /* Used in group stats replies. */
676 struct ofp11_bucket_counter {
677     struct ofp11_stats_msg osm;
678     ovs_be64 packet_count;   /* Number of packets processed by bucket. */
679     ovs_be64 byte_count;     /* Number of bytes processed by bucket. */
680 };
681 OFP_ASSERT(sizeof(struct ofp11_bucket_counter) == 32);
682
683 /* Body of reply to OFPST11_GROUP_DESC request. */
684 struct ofp11_group_desc_stats {
685     ovs_be16 length;            /* Length of this entry. */
686     uint8_t type;               /* One of OFPGT_*. */
687     uint8_t pad;                /* Pad to 64 bits. */
688     ovs_be32 group_id;          /* Group identifier. */
689     /* struct ofp11_bucket buckets[0]; */
690 };
691 OFP_ASSERT(sizeof(struct ofp11_group_desc_stats) == 8);
692
693 /* Send packet (controller -> datapath). */
694 struct ofp11_packet_out {
695     struct ofp_header header;
696     ovs_be32 buffer_id;       /* ID assigned by datapath (-1 if none). */
697     ovs_be32 in_port;         /* Packet's input port or OFPP_CONTROLLER. */
698     ovs_be16 actions_len;     /* Size of action array in bytes. */
699     uint8_t pad[6];
700     /* struct ofp_action_header actions[0];  Action list. */
701     /* uint8_t data[0]; */    /* Packet data. The length is inferred
702                                  from the length field in the header.
703                                  (Only meaningful if buffer_id == -1.) */
704 };
705 OFP_ASSERT(sizeof(struct ofp11_packet_out) == 24);
706
707 /* Packet received on port (datapath -> controller). */
708 struct ofp11_packet_in {
709     struct ofp_header header;
710     ovs_be32 buffer_id;     /* ID assigned by datapath. */
711     ovs_be32 in_port;       /* Port on which frame was received. */
712     ovs_be32 in_phy_port;   /* Physical Port on which frame was received. */
713     ovs_be16 total_len;     /* Full length of frame. */
714     uint8_t reason;         /* Reason packet is being sent (one of OFPR_*) */
715     uint8_t table_id;       /* ID of the table that was looked up */
716     uint8_t data[0];        /* Ethernet frame, halfway through 32-bit word,
717                                so the IP header is 32-bit aligned. The
718                                amount of data is inferred from the length
719                                field in the header. Because of padding,
720                                offsetof(struct ofp_packet_in, data) ==
721                                sizeof(struct ofp_packet_in) - 2. */
722 };
723 OFP_ASSERT(sizeof(struct ofp11_packet_in) == 24);
724
725 /* Flow removed (datapath -> controller). */
726 struct ofp11_flow_removed {
727     struct ofp_header header;
728     ovs_be64 cookie;          /* Opaque controller-issued identifier. */
729
730     ovs_be16 priority;        /* Priority level of flow entry. */
731     uint8_t reason;           /* One of OFPRR_*. */
732     uint8_t table_id;         /* ID of the table */
733
734     ovs_be32 duration_sec;    /* Time flow was alive in seconds. */
735     ovs_be32 duration_nsec;   /* Time flow was alive in nanoseconds beyond
736                                  duration_sec. */
737     ovs_be16 idle_timeout;    /* Idle timeout from original flow mod. */
738     uint8_t pad2[2];          /* Align to 64-bits. */
739     ovs_be64 packet_count;
740     ovs_be64 byte_count;
741     struct ofp11_match match; /* Description of fields. */
742 };
743 OFP_ASSERT(sizeof(struct ofp11_flow_removed) == 136);
744
745 #endif /* openflow/openflow-1.1.h */