5b4ba2b9153966a2d6e269eed2647ef835a5fbcf
[cascardo/ovs.git] / include / openflow / openflow-1.1.h
1 /* Copyright (c) 2008, 2011, 2012, 2013, 2014 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    OFP11_PORT_C(0xffffff00)
71 #define OFPP11_OFFSET 0xffff0000    /* OFPP11_MAX - OFPP_MAX */
72
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
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  */
88 enum 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. */
95 enum 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 */
110 struct ofp11_port {
111     ovs_be32 port_no;
112     uint8_t pad[4];
113     struct eth_addr hw_addr;
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 };
130 OFP_ASSERT(sizeof(struct ofp11_port) == 64);
131
132 /* Modify behavior of the physical port */
133 struct ofp11_port_mod {
134     ovs_be32 port_no;
135     uint8_t pad[4];
136     struct eth_addr hw_addr; /* The hardware address is not configurable.  This
137                                 is used to sanity-check the request, so it must
138                                 be the same as returned in an ofp11_port
139                                 struct. */
140     uint8_t pad2[2];        /* Pad to 64 bits. */
141     ovs_be32 config;        /* Bitmap of OFPPC_* flags. */
142     ovs_be32 mask;          /* Bitmap of OFPPC_* flags to be changed. */
143
144     ovs_be32 advertise;     /* Bitmap of OFPPF_* and OFPPF11_*.  Zero all bits
145                                to prevent any action taking place. */
146     uint8_t pad3[4];        /* Pad to 64 bits. */
147 };
148 OFP_ASSERT(sizeof(struct ofp11_port_mod) == 32);
149
150 /* Group setup and teardown (controller -> datapath). */
151 struct ofp11_group_mod {
152     ovs_be16 command;             /* One of OFPGC11_*. */
153     uint8_t type;                 /* One of OFPGT11_*. */
154     uint8_t pad;                  /* Pad to 64 bits. */
155     ovs_be32 group_id;            /* Group identifier. */
156     /* struct ofp11_bucket buckets[0]; The bucket length is inferred from the
157                                        length field in the header. */
158 };
159 OFP_ASSERT(sizeof(struct ofp11_group_mod) == 8);
160
161 /* Query for port queue configuration. */
162 struct ofp11_queue_get_config_request {
163     ovs_be32 port;
164     /* Port to be queried. Should refer
165        to a valid physical port (i.e. < OFPP_MAX) */
166     uint8_t pad[4];
167 };
168 OFP_ASSERT(sizeof(struct ofp11_queue_get_config_request) == 8);
169
170 /* Group commands */
171 enum ofp11_group_mod_command {
172     OFPGC11_ADD,          /* New group. */
173     OFPGC11_MODIFY,       /* Modify all matching groups. */
174     OFPGC11_DELETE,       /* Delete all matching groups. */
175 };
176
177 /* OpenFlow 1.1 specific capabilities supported by the datapath (struct
178  * ofp_switch_features, member capabilities). */
179 enum ofp11_capabilities {
180     OFPC11_GROUP_STATS    = 1 << 3,  /* Group statistics. */
181 };
182
183 #define OFPMT11_STANDARD_LENGTH 88
184
185 struct ofp11_match_header {
186     ovs_be16 type;             /* One of OFPMT_* */
187     ovs_be16 length;           /* Length of match */
188 };
189 OFP_ASSERT(sizeof(struct ofp11_match_header) == 4);
190
191 /* Fields to match against flows */
192 struct ofp11_match {
193     struct ofp11_match_header omh;
194     ovs_be32 in_port;          /* Input switch port. */
195     ovs_be32 wildcards;        /* Wildcard fields. */
196     struct eth_addr dl_src;    /* Ethernet source address. */
197     struct eth_addr dl_src_mask; /* Ethernet source address mask.  */
198     struct eth_addr dl_dst;    /* Ethernet destination address. */
199     struct eth_addr dl_dst_mask; /* Ethernet destination address mask. */
200     ovs_be16 dl_vlan;          /* Input VLAN id. */
201     uint8_t dl_vlan_pcp;       /* Input VLAN priority. */
202     uint8_t pad1[1];           /* Align to 32-bits */
203     ovs_be16 dl_type;          /* Ethernet frame type. */
204     uint8_t nw_tos;            /* IP ToS (actually DSCP field, 6 bits). */
205     uint8_t nw_proto;          /* IP protocol or lower 8 bits of ARP opcode. */
206     ovs_be32 nw_src;           /* IP source address. */
207     ovs_be32 nw_src_mask;      /* IP source address mask. */
208     ovs_be32 nw_dst;           /* IP destination address. */
209     ovs_be32 nw_dst_mask;      /* IP destination address mask. */
210     ovs_be16 tp_src;           /* TCP/UDP/SCTP source port. */
211     ovs_be16 tp_dst;           /* TCP/UDP/SCTP destination port. */
212     ovs_be32 mpls_label;       /* MPLS label. */
213     uint8_t mpls_tc;           /* MPLS TC. */
214     uint8_t pad2[3];           /* Align to 64-bits */
215     ovs_be64 metadata;         /* Metadata passed between tables. */
216     ovs_be64 metadata_mask;    /* Mask for metadata. */
217 };
218 OFP_ASSERT(sizeof(struct ofp11_match) == OFPMT11_STANDARD_LENGTH);
219
220 /* Flow wildcards. */
221 enum ofp11_flow_wildcards {
222     OFPFW11_IN_PORT     = 1 << 0,  /* Switch input port. */
223     OFPFW11_DL_VLAN     = 1 << 1,  /* VLAN id. */
224     OFPFW11_DL_VLAN_PCP = 1 << 2,  /* VLAN priority. */
225     OFPFW11_DL_TYPE     = 1 << 3,  /* Ethernet frame type. */
226     OFPFW11_NW_TOS      = 1 << 4,  /* IP ToS (DSCP field, 6 bits). */
227     OFPFW11_NW_PROTO    = 1 << 5,  /* IP protocol. */
228     OFPFW11_TP_SRC      = 1 << 6,  /* TCP/UDP/SCTP source port. */
229     OFPFW11_TP_DST      = 1 << 7,  /* TCP/UDP/SCTP destination port. */
230     OFPFW11_MPLS_LABEL  = 1 << 8,  /* MPLS label. */
231     OFPFW11_MPLS_TC     = 1 << 9,  /* MPLS TC. */
232
233     /* Wildcard all fields. */
234     OFPFW11_ALL           = ((1 << 10) - 1)
235 };
236
237 /* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
238  * special conditions.
239  */
240 enum ofp11_vlan_id {
241     OFPVID11_ANY = 0xfffe,  /* Indicate that a VLAN id is set but don't care
242                                about it's value. Note: only valid when
243                                specifying the VLAN id in a match */
244     OFPVID11_NONE = 0xffff, /* No VLAN id was set. */
245 };
246
247 enum ofp11_instruction_type {
248     OFPIT11_GOTO_TABLE = 1,        /* Setup the next table in the lookup
249                                       pipeline */
250     OFPIT11_WRITE_METADATA = 2,    /* Setup the metadata field for use later
251                                       in pipeline */
252     OFPIT11_WRITE_ACTIONS = 3,     /* Write the action(s) onto the datapath
253                                       action set */
254     OFPIT11_APPLY_ACTIONS = 4,     /* Applies the action(s) immediately */
255     OFPIT11_CLEAR_ACTIONS = 5,     /* Clears all actions from the datapath
256                                       action set */
257     OFPIT11_EXPERIMENTER = 0xFFFF  /* Experimenter instruction */
258 };
259
260 #define OFP11_INSTRUCTION_ALIGN 8
261
262 /* Generic ofp_instruction structure. */
263 struct ofp11_instruction {
264     ovs_be16 type;              /* Instruction type */
265     ovs_be16 len;               /* Length of this struct in bytes. */
266     uint8_t pad[4];             /* Align to 64-bits */
267 };
268 OFP_ASSERT(sizeof(struct ofp11_instruction) == 8);
269
270 /* Instruction structure for OFPIT_GOTO_TABLE */
271 struct ofp11_instruction_goto_table {
272     ovs_be16 type;                 /* OFPIT_GOTO_TABLE */
273     ovs_be16 len;                  /* Length of this struct in bytes. */
274     uint8_t table_id;              /* Set next table in the lookup pipeline */
275     uint8_t pad[3];                /* Pad to 64 bits. */
276 };
277 OFP_ASSERT(sizeof(struct ofp11_instruction_goto_table) == 8);
278
279 /* Instruction structure for OFPIT_WRITE_METADATA */
280 struct ofp11_instruction_write_metadata {
281     ovs_be16 type;              /* OFPIT_WRITE_METADATA */
282     ovs_be16 len;               /* Length of this struct in bytes. */
283     uint8_t pad[4];             /* Align to 64-bits */
284     ovs_be64 metadata;          /* Metadata value to write */
285     ovs_be64 metadata_mask;     /* Metadata write bitmask */
286 };
287 OFP_ASSERT(sizeof(struct ofp11_instruction_write_metadata) == 24);
288
289 /* Instruction structure for OFPIT_WRITE/APPLY/CLEAR_ACTIONS */
290 struct ofp11_instruction_actions {
291     ovs_be16 type;              /* One of OFPIT_*_ACTIONS */
292     ovs_be16 len;               /* Length of this struct in bytes. */
293     uint8_t pad[4];             /* Align to 64-bits */
294     /* struct ofp_action_header actions[0];  Actions associated with
295                                              OFPIT_WRITE_ACTIONS and
296                                              OFPIT_APPLY_ACTIONS */
297 };
298 OFP_ASSERT(sizeof(struct ofp11_instruction_actions) == 8);
299
300 /* Instruction structure for experimental instructions */
301 struct ofp11_instruction_experimenter {
302     ovs_be16 type;              /* OFPIT11_EXPERIMENTER */
303     ovs_be16 len;               /* Length of this struct in bytes */
304     ovs_be32 experimenter;      /* Experimenter ID which takes the same form
305                                    as in struct ofp_vendor_header. */
306     /* Experimenter-defined arbitrary additional data. */
307 };
308 OFP_ASSERT(sizeof(struct ofp11_instruction_experimenter) == 8);
309
310 /* Configure/Modify behavior of a flow table */
311 struct ofp11_table_mod {
312     uint8_t table_id;       /* ID of the table, 0xFF indicates all tables */
313     uint8_t pad[3];         /* Pad to 32 bits */
314     ovs_be32 config;        /* Bitmap of OFPTC_* flags */
315 };
316 OFP_ASSERT(sizeof(struct ofp11_table_mod) == 8);
317
318 /* Flow setup and teardown (controller -> datapath). */
319 struct ofp11_flow_mod {
320     ovs_be64 cookie;             /* Opaque controller-issued identifier. */
321     ovs_be64 cookie_mask;        /* Mask used to restrict the cookie bits
322                                     that must match when the command is
323                                     OFPFC_MODIFY* or OFPFC_DELETE*. A value
324                                     of 0 indicates no restriction. */
325     /* Flow actions. */
326     uint8_t table_id;            /* ID of the table to put the flow in */
327     uint8_t command;             /* One of OFPFC_*. */
328     ovs_be16 idle_timeout;       /* Idle time before discarding (seconds). */
329     ovs_be16 hard_timeout;       /* Max time before discarding (seconds). */
330     ovs_be16 priority;           /* Priority level of flow entry. */
331     ovs_be32 buffer_id;          /* Buffered packet to apply to (or -1).
332                                     Not meaningful for OFPFC_DELETE*. */
333     ovs_be32 out_port;           /* For OFPFC_DELETE* commands, require
334                                     matching entries to include this as an
335                                     output port. A value of OFPP_ANY
336                                     indicates no restriction. */
337     ovs_be32 out_group;          /* For OFPFC_DELETE* commands, require
338                                     matching entries to include this as an
339                                     output group. A value of OFPG11_ANY
340                                     indicates no restriction. */
341     ovs_be16 flags;              /* One of OFPFF_*. */
342     ovs_be16 importance;         /* Eviction precedence (OF1.4+). */
343     /* Followed by an ofp11_match structure. */
344     /* Followed by an instruction set. */
345 };
346 OFP_ASSERT(sizeof(struct ofp11_flow_mod) == 40);
347
348 /* Group types. Values in the range [128, 255] are reserved for experimental
349  * use. */
350 enum ofp11_group_type {
351     OFPGT11_ALL,      /* All (multicast/broadcast) group. */
352     OFPGT11_SELECT,   /* Select group. */
353     OFPGT11_INDIRECT, /* Indirect group. */
354     OFPGT11_FF        /* Fast failover group. */
355 };
356
357 /* Group numbering. Groups can use any number up to OFPG_MAX. */
358 enum ofp11_group {
359     /* Last usable group number. */
360     OFPG11_MAX        = 0xffffff00,
361
362     /* Fake groups. */
363     OFPG11_ALL        = 0xfffffffc,  /* Represents all groups for group delete
364                                         commands. */
365     OFPG11_ANY        = 0xffffffff   /* Wildcard group used only for flow stats
366                                         requests. Selects all flows regardless
367                                         of group (including flows with no
368                                         group). */
369 };
370
371 /* Bucket for use in groups. */
372 struct ofp11_bucket {
373     ovs_be16 len;                    /* Length the bucket in bytes, including
374                                         this header and any padding to make it
375                                         64-bit aligned. */
376     ovs_be16 weight;                 /* Relative weight of bucket. Only
377                                         defined for select groups. */
378     ovs_be32 watch_port;             /* Port whose state affects whether this
379                                         bucket is live. Only required for fast
380                                         failover groups. */
381     ovs_be32 watch_group;            /* Group whose state affects whether this
382                                         bucket is live. Only required for fast
383                                         failover groups. */
384     uint8_t pad[4];
385     /* struct ofp_action_header actions[0]; The action length is inferred
386                                             from the length field in the
387                                             header. */
388 };
389 OFP_ASSERT(sizeof(struct ofp11_bucket) == 16);
390
391 /* Queue configuration for a given port. */
392 struct ofp11_queue_get_config_reply {
393     ovs_be32 port;
394     uint8_t pad[4];
395     /* struct ofp_packet_queue queues[0];  List of configured queues. */
396 };
397 OFP_ASSERT(sizeof(struct ofp11_queue_get_config_reply) == 8);
398
399 struct ofp11_stats_msg {
400     struct ofp_header header;
401     ovs_be16 type;              /* One of the OFPST_* constants. */
402     ovs_be16 flags;             /* OFPSF_REQ_* flags (none yet defined). */
403     uint8_t pad[4];
404     /* Followed by the body of the request. */
405 };
406 OFP_ASSERT(sizeof(struct ofp11_stats_msg) == 16);
407
408 /* Vendor extension stats message. */
409 struct ofp11_vendor_stats_msg {
410     struct ofp11_stats_msg osm; /* Type OFPST_VENDOR. */
411     ovs_be32 vendor;            /* Vendor ID:
412                                  * - MSB 0: low-order bytes are IEEE OUI.
413                                  * - MSB != 0: defined by OpenFlow
414                                  *   consortium. */
415     /* Followed by vendor-defined arbitrary additional data. */
416 };
417 OFP_ASSERT(sizeof(struct ofp11_vendor_stats_msg) == 20);
418
419 /* Stats request of type OFPST_FLOW. */
420 struct ofp11_flow_stats_request {
421     uint8_t table_id;         /* ID of table to read (from ofp_table_stats),
422                                  0xff for all tables. */
423     uint8_t pad[3];           /* Align to 64 bits. */
424     ovs_be32 out_port;        /* Require matching entries to include this
425                                  as an output port. A value of OFPP_ANY
426                                  indicates no restriction. */
427     ovs_be32 out_group;       /* Require matching entries to include this
428                                  as an output group. A value of OFPG11_ANY
429                                  indicates no restriction. */
430     uint8_t pad2[4];          /* Align to 64 bits. */
431     ovs_be64 cookie;          /* Require matching entries to contain this
432                                  cookie value */
433     ovs_be64 cookie_mask;     /* Mask used to restrict the cookie bits that
434                                  must match. A value of 0 indicates
435                                  no restriction. */
436     /* Followed by an ofp11_match structure. */
437 };
438 OFP_ASSERT(sizeof(struct ofp11_flow_stats_request) == 32);
439
440 /* Body of reply to OFPST_FLOW request. */
441 struct ofp11_flow_stats {
442     ovs_be16 length;           /* Length of this entry. */
443     uint8_t table_id;          /* ID of table flow came from. */
444     uint8_t pad;
445     ovs_be32 duration_sec;     /* Time flow has been alive in seconds. */
446     ovs_be32 duration_nsec;    /* Time flow has been alive in nanoseconds beyond
447                                   duration_sec. */
448     ovs_be16 priority;         /* Priority of the entry. Only meaningful
449                                   when this is not an exact-match entry. */
450     ovs_be16 idle_timeout;     /* Number of seconds idle before expiration. */
451     ovs_be16 hard_timeout;     /* Number of seconds before expiration. */
452     ovs_be16 flags;            /* OF 1.3: Set of OFPFF*. */
453     ovs_be16 importance;       /* Eviction precedence (OF1.4+). */
454     uint8_t  pad2[2];          /* Align to 64-bits. */
455     ovs_be64 cookie;           /* Opaque controller-issued identifier. */
456     ovs_be64 packet_count;     /* Number of packets in flow. */
457     ovs_be64 byte_count;       /* Number of bytes in flow. */
458     /* OpenFlow version specific match */
459     /* struct ofp11_instruction instructions[0];  Instruction set. */
460 };
461 OFP_ASSERT(sizeof(struct ofp11_flow_stats) == 48);
462
463 /* Body for ofp_stats_request of type OFPST_AGGREGATE. */
464 /* Identical to ofp11_flow_stats_request */
465
466 /* Flow match fields. */
467 enum ofp11_flow_match_fields {
468     OFPFMF11_IN_PORT     = 1 << 0,  /* Switch input port. */
469     OFPFMF11_DL_VLAN     = 1 << 1,  /* VLAN id. */
470     OFPFMF11_DL_VLAN_PCP = 1 << 2,  /* VLAN priority. */
471     OFPFMF11_DL_TYPE     = 1 << 3,  /* Ethernet frame type. */
472     OFPFMF11_NW_TOS      = 1 << 4,  /* IP ToS (DSCP field, 6 bits). */
473     OFPFMF11_NW_PROTO    = 1 << 5,  /* IP protocol. */
474     OFPFMF11_TP_SRC      = 1 << 6,  /* TCP/UDP/SCTP source port. */
475     OFPFMF11_TP_DST      = 1 << 7,  /* TCP/UDP/SCTP destination port. */
476     OFPFMF11_MPLS_LABEL  = 1 << 8,  /* MPLS label. */
477     OFPFMF11_MPLS_TC     = 1 << 9,  /* MPLS TC. */
478     OFPFMF11_TYPE        = 1 << 10, /* Match type. */
479     OFPFMF11_DL_SRC      = 1 << 11, /* Ethernet source address. */
480     OFPFMF11_DL_DST      = 1 << 12, /* Ethernet destination address. */
481     OFPFMF11_NW_SRC      = 1 << 13, /* IP source address. */
482     OFPFMF11_NW_DST      = 1 << 14, /* IP destination address. */
483     OFPFMF11_METADATA    = 1 << 15, /* Metadata passed between tables. */
484 };
485
486 /* Body of reply to OFPST_TABLE request. */
487 struct ofp11_table_stats {
488     uint8_t table_id;        /* Identifier of table. Lower numbered tables
489                                 are consulted first. */
490     uint8_t pad[7];          /* Align to 64-bits. */
491     char name[OFP_MAX_TABLE_NAME_LEN];
492     ovs_be32 wildcards;      /* Bitmap of OFPFMF_* wildcards that are
493                                 supported by the table. */
494     ovs_be32 match;          /* Bitmap of OFPFMF_* that indicate the fields
495                                 the table can match on. */
496     ovs_be32 instructions;   /* Bitmap of OFPIT_* values supported. */
497     ovs_be32 write_actions;  /* Bitmap of OFPAT_* that are supported
498                                 by the table with OFPIT_WRITE_ACTIONS.  */
499     ovs_be32 apply_actions;  /* Bitmap of OFPAT_* that are supported
500                                 by the table with OFPIT_APPLY_ACTIONS. */
501     ovs_be32 config;         /* Bitmap of OFPTC_* values */
502     ovs_be32 max_entries;    /* Max number of entries supported. */
503     ovs_be32 active_count;   /* Number of active entries. */
504     ovs_be64 lookup_count;   /* Number of packets looked up in table. */
505     ovs_be64 matched_count;  /* Number of packets that hit table. */
506 };
507 OFP_ASSERT(sizeof(struct ofp11_table_stats) == 88);
508
509 /* Body for ofp_stats_request of type OFPST_PORT. */
510 struct ofp11_port_stats_request {
511     ovs_be32 port_no;        /* OFPST_PORT message must request statistics
512                               * either for a single port (specified in
513                               * port_no) or for all ports (if port_no ==
514                               * OFPP_ANY). */
515     uint8_t pad[4];
516 };
517 OFP_ASSERT(sizeof(struct ofp11_port_stats_request) == 8);
518
519 /* Body of reply to OFPST_PORT request. If a counter is unsupported, set
520  * the field to all ones. */
521 struct ofp11_port_stats {
522     ovs_be32 port_no;
523     uint8_t pad[4];           /* Align to 64-bits. */
524     ovs_be64 rx_packets;      /* Number of received packets. */
525     ovs_be64 tx_packets;      /* Number of transmitted packets. */
526     ovs_be64 rx_bytes;        /* Number of received bytes. */
527     ovs_be64 tx_bytes;        /* Number of transmitted bytes. */
528     ovs_be64 rx_dropped;      /* Number of packets dropped by RX. */
529     ovs_be64 tx_dropped;      /* Number of packets dropped by TX. */
530     ovs_be64 rx_errors;       /* Number of receive errors.  This is a
531                                  super-set of receive errors and should be
532                                  great than or equal to the sum of all
533                                  rx_*_err values. */
534     ovs_be64 tx_errors;       /* Number of transmit errors.  This is a
535                                  super-set of transmit errors. */
536     ovs_be64 rx_frame_err;    /* Number of frame alignment errors. */
537     ovs_be64 rx_over_err;     /* Number of packets with RX overrun. */
538     ovs_be64 rx_crc_err;      /* Number of CRC errors. */
539     ovs_be64 collisions;      /* Number of collisions. */
540 };
541 OFP_ASSERT(sizeof(struct ofp11_port_stats) == 104);
542
543 struct ofp11_queue_stats_request {
544     ovs_be32 port_no;         /* All ports if OFPP_ANY. */
545     ovs_be32 queue_id;        /* All queues if OFPQ_ALL. */
546 };
547 OFP_ASSERT(sizeof(struct ofp11_queue_stats_request) == 8);
548
549 struct ofp11_queue_stats {
550     ovs_be32 port_no;
551     ovs_be32 queue_id;         /* Queue id. */
552     ovs_be64 tx_bytes;         /* Number of transmitted bytes. */
553     ovs_be64 tx_packets;       /* Number of transmitted packets. */
554     ovs_be64 tx_errors;        /* # of packets dropped due to overrun. */
555 };
556 OFP_ASSERT(sizeof(struct ofp11_queue_stats) == 32);
557
558 struct ofp11_group_stats_request {
559     ovs_be32 group_id;         /* All groups if OFPG_ALL. */
560     uint8_t pad[4];            /* Align to 64 bits. */
561 };
562 OFP_ASSERT(sizeof(struct ofp11_group_stats_request) == 8);
563
564 /* Used in group stats replies. */
565 struct ofp11_bucket_counter {
566     ovs_be64 packet_count;   /* Number of packets processed by bucket. */
567     ovs_be64 byte_count;     /* Number of bytes processed by bucket. */
568 };
569 OFP_ASSERT(sizeof(struct ofp11_bucket_counter) == 16);
570
571 /* Body of reply to OFPST11_GROUP request */
572 struct ofp11_group_stats {
573     ovs_be16 length;           /* Length of this entry. */
574     uint8_t pad[2];            /* Align to 64 bits. */
575     ovs_be32 group_id;         /* Group identifier. */
576     ovs_be32 ref_count;        /* Number of flows or groups that
577                                   directly forward to this group. */
578     uint8_t pad2[4];           /* Align to 64 bits. */
579     ovs_be64 packet_count;     /* Number of packets processed by group. */
580     ovs_be64 byte_count;       /* Number of bytes processed by group. */
581     /* struct ofp11_bucket_counter bucket_stats[]; */
582 };
583 OFP_ASSERT(sizeof(struct ofp11_group_stats) == 32);
584
585 /* Body of reply to OFPST11_GROUP_DESC request. */
586 struct ofp11_group_desc_stats {
587     ovs_be16 length;            /* Length of this entry. */
588     uint8_t type;               /* One of OFPGT11_*. */
589     uint8_t pad;                /* Pad to 64 bits. */
590     ovs_be32 group_id;          /* Group identifier. */
591     /* struct ofp11_bucket buckets[0]; */
592 };
593 OFP_ASSERT(sizeof(struct ofp11_group_desc_stats) == 8);
594
595 /* Send packet (controller -> datapath). */
596 struct ofp11_packet_out {
597     ovs_be32 buffer_id;       /* ID assigned by datapath (-1 if none). */
598     ovs_be32 in_port;         /* Packet's input port or OFPP_CONTROLLER. */
599     ovs_be16 actions_len;     /* Size of action array in bytes. */
600     uint8_t pad[6];
601     /* struct ofp_action_header actions[0];  Action list. */
602     /* uint8_t data[0]; */    /* Packet data. The length is inferred
603                                  from the length field in the header.
604                                  (Only meaningful if buffer_id == -1.) */
605 };
606 OFP_ASSERT(sizeof(struct ofp11_packet_out) == 16);
607
608 /* Packet received on port (datapath -> controller). */
609 struct ofp11_packet_in {
610     ovs_be32 buffer_id;     /* ID assigned by datapath. */
611     ovs_be32 in_port;       /* Port on which frame was received. */
612     ovs_be32 in_phy_port;   /* Physical Port on which frame was received. */
613     ovs_be16 total_len;     /* Full length of frame. */
614     uint8_t reason;         /* Reason packet is being sent (one of OFPR_*) */
615     uint8_t table_id;       /* ID of the table that was looked up */
616     /* Followed by Ethernet frame. */
617 };
618 OFP_ASSERT(sizeof(struct ofp11_packet_in) == 16);
619
620 /* Flow removed (datapath -> controller). */
621 struct ofp11_flow_removed {
622     ovs_be64 cookie;          /* Opaque controller-issued identifier. */
623
624     ovs_be16 priority;        /* Priority level of flow entry. */
625     uint8_t reason;           /* One of OFPRR_*. */
626     uint8_t table_id;         /* ID of the table */
627
628     ovs_be32 duration_sec;    /* Time flow was alive in seconds. */
629     ovs_be32 duration_nsec;   /* Time flow was alive in nanoseconds beyond
630                                  duration_sec. */
631     ovs_be16 idle_timeout;    /* Idle timeout from original flow mod. */
632     uint8_t pad2[2];          /* Align to 64-bits. */
633     ovs_be64 packet_count;
634     ovs_be64 byte_count;
635     /* Followed by an ofp11_match structure. */
636 };
637 OFP_ASSERT(sizeof(struct ofp11_flow_removed) == 40);
638
639 #endif /* openflow/openflow-1.1.h */