ovs-ofctl: Accept port keywords, OF1.1 port numbers, reject port number 0.
[sliver-openvswitch.git] / include / openflow / openflow-1.0.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /* OpenFlow: protocol between controller and datapath. */
18
19 #ifndef OPENFLOW_OPENFLOW10_H
20 #define OPENFLOW_OPENFLOW10_H 1
21
22 #include "openflow/openflow-common.h"
23
24 /* Port number(s)   meaning
25  * ---------------  --------------------------------------
26  * 0x0000           not assigned a meaning by OpenFlow 1.0
27  * 0x0001...0xfeff  "physical" ports
28  * 0xff00...0xfff7  "reserved" but not assigned a meaning by OpenFlow 1.0
29  * 0xfff8...0xffff  "reserved" OFPP_* ports with assigned meanings
30  */
31 enum ofp_port {
32     /* Ranges. */
33     OFPP_MAX        = 0xff00,   /* Maximum number of physical switch ports. */
34     OFPP_FIRST_RESV = 0xfff8,   /* First assigned reserved port number. */
35     OFPP_LAST_RESV  = 0xffff,   /* Last assigned reserved port number. */
36
37     /* Reserved output "ports". */
38     OFPP_IN_PORT    = 0xfff8,  /* Send the packet out the input port.  This
39                                   virtual port must be explicitly used
40                                   in order to send back out of the input
41                                   port. */
42     OFPP_TABLE      = 0xfff9,  /* Perform actions in flow table.
43                                   NB: This can only be the destination
44                                   port for packet-out messages. */
45     OFPP_NORMAL     = 0xfffa,  /* Process with normal L2/L3 switching. */
46     OFPP_FLOOD      = 0xfffb,  /* All physical ports except input port and
47                                   those disabled by STP. */
48     OFPP_ALL        = 0xfffc,  /* All physical ports except input port. */
49     OFPP_CONTROLLER = 0xfffd,  /* Send to controller. */
50     OFPP_LOCAL      = 0xfffe,  /* Local openflow "port". */
51     OFPP_NONE       = 0xffff   /* Not associated with a physical port. */
52 };
53
54 #define OFP_DEFAULT_MISS_SEND_LEN   128
55
56 enum ofp_config_flags {
57     /* Handling of IP fragments. */
58     OFPC_FRAG_NORMAL   = 0,  /* No special handling for fragments. */
59     OFPC_FRAG_DROP     = 1,  /* Drop fragments. */
60     OFPC_FRAG_REASM    = 2,  /* Reassemble (only if OFPC_IP_REASM set). */
61     OFPC_FRAG_NX_MATCH = 3,  /* Make first fragments available for matching. */
62     OFPC_FRAG_MASK     = 3,
63
64     /* TTL processing - applicable for IP and MPLS packets. */
65     OFPC_INVALID_TTL_TO_CONTROLLER = 1 << 2, /* Send packets with invalid TTL
66                                                 to the controller. */
67 };
68
69 /* Switch configuration. */
70 struct ofp_switch_config {
71     ovs_be16 flags;             /* OFPC_* flags. */
72     ovs_be16 miss_send_len;     /* Max bytes of new flow that datapath should
73                                    send to the controller. */
74 };
75 OFP_ASSERT(sizeof(struct ofp_switch_config) == 4);
76
77 /* OpenFlow 1.0 specific capabilities supported by the datapath (struct
78  * ofp_switch_features, member capabilities). */
79 enum ofp10_capabilities {
80     OFPC10_STP            = 1 << 3,  /* 802.1d spanning tree. */
81     OFPC10_RESERVED       = 1 << 4,  /* Reserved, must not be set. */
82 };
83
84 /* OpenFlow 1.0 specific flags to indicate behavior of the physical port.
85  * These flags are used in ofp10_phy_port to describe the current
86  * configuration.  They are used in the ofp10_port_mod message to configure the
87  * port's behavior.
88  */
89 enum ofp10_port_config {
90     OFPPC10_NO_STP       = 1 << 1, /* Disable 802.1D spanning tree on port. */
91     OFPPC10_NO_RECV_STP  = 1 << 3, /* Drop received 802.1D STP packets. */
92     OFPPC10_NO_FLOOD     = 1 << 4, /* Do not include port when flooding. */
93 #define OFPPC10_ALL (OFPPC_PORT_DOWN | OFPPC10_NO_STP | OFPPC_NO_RECV | \
94                      OFPPC10_NO_RECV_STP | OFPPC10_NO_FLOOD | OFPPC_NO_FWD | \
95                      OFPPC_NO_PACKET_IN)
96 };
97
98 /* OpenFlow 1.0 specific current state of the physical port.  These are not
99  * configurable from the controller.
100  */
101 enum ofp10_port_state {
102     /* The OFPPS10_STP_* bits have no effect on switch operation.  The
103      * controller must adjust OFPPC_NO_RECV, OFPPC_NO_FWD, and
104      * OFPPC_NO_PACKET_IN appropriately to fully implement an 802.1D spanning
105      * tree. */
106     OFPPS10_STP_LISTEN  = 0 << 8, /* Not learning or relaying frames. */
107     OFPPS10_STP_LEARN   = 1 << 8, /* Learning but not relaying frames. */
108     OFPPS10_STP_FORWARD = 2 << 8, /* Learning and relaying frames. */
109     OFPPS10_STP_BLOCK   = 3 << 8, /* Not part of spanning tree. */
110     OFPPS10_STP_MASK    = 3 << 8  /* Bit mask for OFPPS10_STP_* values. */
111
112 #define OFPPS10_ALL (OFPPS_LINK_DOWN | OFPPS10_STP_MASK)
113 };
114
115 /* OpenFlow 1.0 specific features of physical ports available in a datapath. */
116 enum ofp10_port_features {
117     OFPPF10_COPPER     = 1 << 7,  /* Copper medium. */
118     OFPPF10_FIBER      = 1 << 8,  /* Fiber medium. */
119     OFPPF10_AUTONEG    = 1 << 9,  /* Auto-negotiation. */
120     OFPPF10_PAUSE      = 1 << 10, /* Pause. */
121     OFPPF10_PAUSE_ASYM = 1 << 11  /* Asymmetric pause. */
122 };
123
124 /* Description of a physical port */
125 struct ofp10_phy_port {
126     ovs_be16 port_no;
127     uint8_t hw_addr[OFP_ETH_ALEN];
128     char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
129
130     ovs_be32 config;        /* Bitmap of OFPPC_* and OFPPC10_* flags. */
131     ovs_be32 state;         /* Bitmap of OFPPS_* and OFPPS10_* flags. */
132
133     /* Bitmaps of OFPPF_* and OFPPF10_* that describe features.  All bits
134      * zeroed if unsupported or unavailable. */
135     ovs_be32 curr;          /* Current features. */
136     ovs_be32 advertised;    /* Features being advertised by the port. */
137     ovs_be32 supported;     /* Features supported by the port. */
138     ovs_be32 peer;          /* Features advertised by peer. */
139 };
140 OFP_ASSERT(sizeof(struct ofp10_phy_port) == 48);
141
142 /* Modify behavior of the physical port */
143 struct ofp10_port_mod {
144     ovs_be16 port_no;
145     uint8_t hw_addr[OFP_ETH_ALEN]; /* The hardware address is not
146                                       configurable.  This is used to
147                                       sanity-check the request, so it must
148                                       be the same as returned in an
149                                       ofp10_phy_port struct. */
150
151     ovs_be32 config;        /* Bitmap of OFPPC_* flags. */
152     ovs_be32 mask;          /* Bitmap of OFPPC_* flags to be changed. */
153
154     ovs_be32 advertise;     /* Bitmap of "ofp_port_features"s.  Zero all
155                                bits to prevent any action taking place. */
156     uint8_t pad[4];         /* Pad to 64-bits. */
157 };
158 OFP_ASSERT(sizeof(struct ofp10_port_mod) == 24);
159
160 /* Query for port queue configuration. */
161 struct ofp10_queue_get_config_request {
162     ovs_be16 port;          /* Port to be queried. Should refer
163                                to a valid physical port (i.e. < OFPP_MAX) */
164     uint8_t pad[2];
165     /* 32-bit alignment. */
166 };
167 OFP_ASSERT(sizeof(struct ofp10_queue_get_config_request) == 4);
168
169 /* Queue configuration for a given port. */
170 struct ofp10_queue_get_config_reply {
171     ovs_be16 port;
172     uint8_t pad[6];
173     /* struct ofp10_packet_queue queues[0]; List of configured queues. */
174 };
175 OFP_ASSERT(sizeof(struct ofp10_queue_get_config_reply) == 8);
176
177 /* Packet received on port (datapath -> controller). */
178 struct ofp_packet_in {
179     ovs_be32 buffer_id;     /* ID assigned by datapath. */
180     ovs_be16 total_len;     /* Full length of frame. */
181     ovs_be16 in_port;       /* Port on which frame was received. */
182     uint8_t reason;         /* Reason packet is being sent (one of OFPR_*) */
183     uint8_t pad;
184     uint8_t data[0];        /* Ethernet frame, halfway through 32-bit word,
185                                so the IP header is 32-bit aligned.  The
186                                amount of data is inferred from the length
187                                field in the header.  Because of padding,
188                                offsetof(struct ofp_packet_in, data) ==
189                                sizeof(struct ofp_packet_in) - 2. */
190 };
191 OFP_ASSERT(sizeof(struct ofp_packet_in) == 12);
192
193 enum ofp10_action_type {
194     OFPAT10_OUTPUT,             /* Output to switch port. */
195     OFPAT10_SET_VLAN_VID,       /* Set the 802.1q VLAN id. */
196     OFPAT10_SET_VLAN_PCP,       /* Set the 802.1q priority. */
197     OFPAT10_STRIP_VLAN,         /* Strip the 802.1q header. */
198     OFPAT10_SET_DL_SRC,         /* Ethernet source address. */
199     OFPAT10_SET_DL_DST,         /* Ethernet destination address. */
200     OFPAT10_SET_NW_SRC,         /* IP source address. */
201     OFPAT10_SET_NW_DST,         /* IP destination address. */
202     OFPAT10_SET_NW_TOS,         /* IP ToS (DSCP field, 6 bits). */
203     OFPAT10_SET_TP_SRC,         /* TCP/UDP source port. */
204     OFPAT10_SET_TP_DST,         /* TCP/UDP destination port. */
205     OFPAT10_ENQUEUE,            /* Output to queue. */
206     OFPAT10_VENDOR = 0xffff
207 };
208
209 /* Action structure for OFPAT10_OUTPUT, which sends packets out 'port'.
210  * When the 'port' is the OFPP_CONTROLLER, 'max_len' indicates the max
211  * number of bytes to send.  A 'max_len' of zero means no bytes of the
212  * packet should be sent. */
213 struct ofp10_action_output {
214     ovs_be16 type;                  /* OFPAT10_OUTPUT. */
215     ovs_be16 len;                   /* Length is 8. */
216     ovs_be16 port;                  /* Output port. */
217     ovs_be16 max_len;               /* Max length to send to controller. */
218 };
219 OFP_ASSERT(sizeof(struct ofp10_action_output) == 8);
220
221 /* Action header for OFPAT10_VENDOR. The rest of the body is vendor-defined. */
222 struct ofp_action_vendor_header {
223     ovs_be16 type;                  /* OFPAT10_VENDOR. */
224     ovs_be16 len;                   /* Length is a multiple of 8. */
225     ovs_be32 vendor;                /* Vendor ID, which takes the same form
226                                        as in "struct ofp_vendor_header". */
227 };
228 OFP_ASSERT(sizeof(struct ofp_action_vendor_header) == 8);
229
230 /* Action header that is common to all actions.  The length includes the
231  * header and any padding used to make the action 64-bit aligned.
232  * NB: The length of an action *must* always be a multiple of eight. */
233 struct ofp_action_header {
234     ovs_be16 type;                  /* One of OFPAT10_*. */
235     ovs_be16 len;                   /* Length of action, including this
236                                        header.  This is the length of action,
237                                        including any padding to make it
238                                        64-bit aligned. */
239     uint8_t pad[4];
240 };
241 OFP_ASSERT(sizeof(struct ofp_action_header) == 8);
242
243 /* OFPAT10_ENQUEUE action struct: send packets to given queue on port. */
244 struct ofp_action_enqueue {
245     ovs_be16 type;            /* OFPAT10_ENQUEUE. */
246     ovs_be16 len;             /* Len is 16. */
247     ovs_be16 port;            /* Port that queue belongs. Should
248                                  refer to a valid physical port
249                                  (i.e. < OFPP_MAX) or OFPP_IN_PORT. */
250     uint8_t pad[6];           /* Pad for 64-bit alignment. */
251     ovs_be32 queue_id;        /* Where to enqueue the packets. */
252 };
253 OFP_ASSERT(sizeof(struct ofp_action_enqueue) == 16);
254
255 union ofp_action {
256     ovs_be16 type;
257     struct ofp_action_header header;
258     struct ofp_action_vendor_header vendor;
259     struct ofp10_action_output output10;
260     struct ofp_action_vlan_vid vlan_vid;
261     struct ofp_action_vlan_pcp vlan_pcp;
262     struct ofp_action_nw_addr nw_addr;
263     struct ofp_action_nw_tos nw_tos;
264     struct ofp_action_tp_port tp_port;
265 };
266 OFP_ASSERT(sizeof(union ofp_action) == 8);
267
268 /* Send packet (controller -> datapath). */
269 struct ofp_packet_out {
270     ovs_be32 buffer_id;           /* ID assigned by datapath or UINT32_MAX. */
271     ovs_be16 in_port;             /* Packet's input port (OFPP_NONE if none). */
272     ovs_be16 actions_len;         /* Size of action array in bytes. */
273     /* Followed by:
274      *   - Exactly 'actions_len' bytes (possibly 0 bytes, and always a multiple
275      *     of 8) containing actions.
276      *   - If 'buffer_id' == UINT32_MAX, packet data to fill out the remainder
277      *     of the message length.
278      */
279 };
280 OFP_ASSERT(sizeof(struct ofp_packet_out) == 8);
281
282 /* Flow wildcards. */
283 enum ofp_flow_wildcards {
284     OFPFW10_IN_PORT    = 1 << 0,  /* Switch input port. */
285     OFPFW10_DL_VLAN    = 1 << 1,  /* VLAN vid. */
286     OFPFW10_DL_SRC     = 1 << 2,  /* Ethernet source address. */
287     OFPFW10_DL_DST     = 1 << 3,  /* Ethernet destination address. */
288     OFPFW10_DL_TYPE    = 1 << 4,  /* Ethernet frame type. */
289     OFPFW10_NW_PROTO   = 1 << 5,  /* IP protocol. */
290     OFPFW10_TP_SRC     = 1 << 6,  /* TCP/UDP source port. */
291     OFPFW10_TP_DST     = 1 << 7,  /* TCP/UDP destination port. */
292
293     /* IP source address wildcard bit count.  0 is exact match, 1 ignores the
294      * LSB, 2 ignores the 2 least-significant bits, ..., 32 and higher wildcard
295      * the entire field.  This is the *opposite* of the usual convention where
296      * e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded. */
297     OFPFW10_NW_SRC_SHIFT = 8,
298     OFPFW10_NW_SRC_BITS = 6,
299     OFPFW10_NW_SRC_MASK = (((1 << OFPFW10_NW_SRC_BITS) - 1)
300                            << OFPFW10_NW_SRC_SHIFT),
301     OFPFW10_NW_SRC_ALL = 32 << OFPFW10_NW_SRC_SHIFT,
302
303     /* IP destination address wildcard bit count.  Same format as source. */
304     OFPFW10_NW_DST_SHIFT = 14,
305     OFPFW10_NW_DST_BITS = 6,
306     OFPFW10_NW_DST_MASK = (((1 << OFPFW10_NW_DST_BITS) - 1)
307                            << OFPFW10_NW_DST_SHIFT),
308     OFPFW10_NW_DST_ALL = 32 << OFPFW10_NW_DST_SHIFT,
309
310     OFPFW10_DL_VLAN_PCP = 1 << 20, /* VLAN priority. */
311     OFPFW10_NW_TOS = 1 << 21, /* IP ToS (DSCP field, 6 bits). */
312
313     /* Wildcard all fields. */
314     OFPFW10_ALL = ((1 << 22) - 1)
315 };
316
317 /* The wildcards for ICMP type and code fields use the transport source
318  * and destination port fields, respectively. */
319 #define OFPFW10_ICMP_TYPE OFPFW10_TP_SRC
320 #define OFPFW10_ICMP_CODE OFPFW10_TP_DST
321
322 /* Values below this cutoff are 802.3 packets and the two bytes
323  * following MAC addresses are used as a frame length.  Otherwise, the
324  * two bytes are used as the Ethernet type.
325  */
326 #define OFP_DL_TYPE_ETH2_CUTOFF   0x0600
327
328 /* Value of dl_type to indicate that the frame does not include an
329  * Ethernet type.
330  */
331 #define OFP_DL_TYPE_NOT_ETH_TYPE  0x05ff
332
333 /* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
334  * special conditions.  All ones indicates that 802.1Q header is not present.
335  */
336 #define OFP10_VLAN_NONE      0xffff
337
338 /* Fields to match against flows */
339 struct ofp10_match {
340     ovs_be32 wildcards;        /* Wildcard fields. */
341     ovs_be16 in_port;          /* Input switch port. */
342     uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */
343     uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */
344     ovs_be16 dl_vlan;          /* Input VLAN. */
345     uint8_t dl_vlan_pcp;       /* Input VLAN priority. */
346     uint8_t pad1[1];           /* Align to 64-bits. */
347     ovs_be16 dl_type;          /* Ethernet frame type. */
348     uint8_t nw_tos;            /* IP ToS (DSCP field, 6 bits). */
349     uint8_t nw_proto;          /* IP protocol or lower 8 bits of
350                                   ARP opcode. */
351     uint8_t pad2[2];           /* Align to 64-bits. */
352     ovs_be32 nw_src;           /* IP source address. */
353     ovs_be32 nw_dst;           /* IP destination address. */
354     ovs_be16 tp_src;           /* TCP/UDP source port. */
355     ovs_be16 tp_dst;           /* TCP/UDP destination port. */
356 };
357 OFP_ASSERT(sizeof(struct ofp10_match) == 40);
358
359 /* Value used in "idle_timeout" and "hard_timeout" to indicate that the entry
360  * is permanent. */
361 #define OFP_FLOW_PERMANENT 0
362
363 /* By default, choose a priority in the middle. */
364 #define OFP_DEFAULT_PRIORITY 0x8000
365
366 enum ofp10_flow_mod_flags {
367     OFPFF10_EMERG       = 1 << 2   /* Ramark this is for emergency. */
368 };
369
370 /* Flow setup and teardown (controller -> datapath). */
371 struct ofp10_flow_mod {
372     struct ofp10_match match;    /* Fields to match */
373     ovs_be64 cookie;             /* Opaque controller-issued identifier. */
374
375     /* Flow actions. */
376     ovs_be16 command;             /* One of OFPFC_*. */
377     ovs_be16 idle_timeout;        /* Idle time before discarding (seconds). */
378     ovs_be16 hard_timeout;        /* Max time before discarding (seconds). */
379     ovs_be16 priority;            /* Priority level of flow entry. */
380     ovs_be32 buffer_id;           /* Buffered packet to apply to (or -1).
381                                      Not meaningful for OFPFC_DELETE*. */
382     ovs_be16 out_port;            /* For OFPFC_DELETE* commands, require
383                                      matching entries to include this as an
384                                      output port.  A value of OFPP_NONE
385                                      indicates no restriction. */
386     ovs_be16 flags;               /* One of OFPFF_*. */
387     struct ofp_action_header actions[0]; /* The action length is inferred
388                                             from the length field in the
389                                             header. */
390 };
391 OFP_ASSERT(sizeof(struct ofp10_flow_mod) == 64);
392
393 /* Flow removed (datapath -> controller). */
394 struct ofp_flow_removed {
395     struct ofp10_match match; /* Description of fields. */
396     ovs_be64 cookie;          /* Opaque controller-issued identifier. */
397
398     ovs_be16 priority;        /* Priority level of flow entry. */
399     uint8_t reason;           /* One of OFPRR_*. */
400     uint8_t pad[1];           /* Align to 32-bits. */
401
402     ovs_be32 duration_sec;    /* Time flow was alive in seconds. */
403     ovs_be32 duration_nsec;   /* Time flow was alive in nanoseconds beyond
404                                  duration_sec. */
405     ovs_be16 idle_timeout;    /* Idle timeout from original flow mod. */
406     uint8_t pad2[2];          /* Align to 64-bits. */
407     ovs_be64 packet_count;
408     ovs_be64 byte_count;
409 };
410 OFP_ASSERT(sizeof(struct ofp_flow_removed) == 80);
411
412 /* OFPT_ERROR: Error message (datapath -> controller). */
413 struct ofp_error_msg {
414     ovs_be16 type;
415     ovs_be16 code;
416     uint8_t data[0];          /* Variable-length data.  Interpreted based
417                                  on the type and code. */
418 };
419 OFP_ASSERT(sizeof(struct ofp_error_msg) == 4);
420
421 /* Statistics request or reply message. */
422 struct ofp10_stats_msg {
423     struct ofp_header header;
424     ovs_be16 type;              /* One of the OFPST_* constants. */
425     ovs_be16 flags;             /* Requests: always 0.
426                                  * Replies: 0 or OFPSF_REPLY_MORE. */
427 };
428 OFP_ASSERT(sizeof(struct ofp10_stats_msg) == 12);
429
430 enum ofp_stats_reply_flags {
431     OFPSF_REPLY_MORE  = 1 << 0  /* More replies to follow. */
432 };
433
434 /* Stats request of type OFPST_AGGREGATE or OFPST_FLOW. */
435 struct ofp10_flow_stats_request {
436     struct ofp10_match match; /* Fields to match. */
437     uint8_t table_id;         /* ID of table to read (from ofp_table_stats)
438                                  or 0xff for all tables. */
439     uint8_t pad;              /* Align to 32 bits. */
440     ovs_be16 out_port;        /* Require matching entries to include this
441                                  as an output port.  A value of OFPP_NONE
442                                  indicates no restriction. */
443 };
444 OFP_ASSERT(sizeof(struct ofp10_flow_stats_request) == 44);
445
446 /* Body of reply to OFPST_FLOW request. */
447 struct ofp10_flow_stats {
448     ovs_be16 length;          /* Length of this entry. */
449     uint8_t table_id;         /* ID of table flow came from. */
450     uint8_t pad;
451     struct ofp10_match match; /* Description of fields. */
452     ovs_be32 duration_sec;    /* Time flow has been alive in seconds. */
453     ovs_be32 duration_nsec;   /* Time flow has been alive in nanoseconds
454                                  beyond duration_sec. */
455     ovs_be16 priority;        /* Priority of the entry. Only meaningful
456                                  when this is not an exact-match entry. */
457     ovs_be16 idle_timeout;    /* Number of seconds idle before expiration. */
458     ovs_be16 hard_timeout;    /* Number of seconds before expiration. */
459     uint8_t pad2[6];          /* Align to 64 bits. */
460     ovs_32aligned_be64 cookie;       /* Opaque controller-issued identifier. */
461     ovs_32aligned_be64 packet_count; /* Number of packets in flow. */
462     ovs_32aligned_be64 byte_count;   /* Number of bytes in flow. */
463     struct ofp_action_header actions[0]; /* Actions. */
464 };
465 OFP_ASSERT(sizeof(struct ofp10_flow_stats) == 88);
466
467 /* Body of reply to OFPST_TABLE request. */
468 struct ofp10_table_stats {
469     uint8_t table_id;        /* Identifier of table.  Lower numbered tables
470                                 are consulted first. */
471     uint8_t pad[3];          /* Align to 32-bits. */
472     char name[OFP_MAX_TABLE_NAME_LEN];
473     ovs_be32 wildcards;      /* Bitmap of OFPFW10_* wildcards that are
474                                 supported by the table. */
475     ovs_be32 max_entries;    /* Max number of entries supported. */
476     ovs_be32 active_count;   /* Number of active entries. */
477     ovs_32aligned_be64 lookup_count;  /* # of packets looked up in table. */
478     ovs_32aligned_be64 matched_count; /* Number of packets that hit table. */
479 };
480 OFP_ASSERT(sizeof(struct ofp10_table_stats) == 64);
481
482 /* Stats request of type OFPST_PORT. */
483 struct ofp10_port_stats_request {
484     ovs_be16 port_no;        /* OFPST_PORT message may request statistics
485                                 for a single port (specified with port_no)
486                                 or for all ports (port_no == OFPP_NONE). */
487     uint8_t pad[6];
488 };
489 OFP_ASSERT(sizeof(struct ofp10_port_stats_request) == 8);
490
491 /* Body of reply to OFPST_PORT request. If a counter is unsupported, set
492  * the field to all ones. */
493 struct ofp10_port_stats {
494     ovs_be16 port_no;
495     uint8_t pad[6];          /* Align to 64-bits. */
496     ovs_32aligned_be64 rx_packets;     /* Number of received packets. */
497     ovs_32aligned_be64 tx_packets;     /* Number of transmitted packets. */
498     ovs_32aligned_be64 rx_bytes;       /* Number of received bytes. */
499     ovs_32aligned_be64 tx_bytes;       /* Number of transmitted bytes. */
500     ovs_32aligned_be64 rx_dropped;     /* Number of packets dropped by RX. */
501     ovs_32aligned_be64 tx_dropped;     /* Number of packets dropped by TX. */
502     ovs_32aligned_be64 rx_errors; /* Number of receive errors.  This is a
503                                      super-set of receive errors and should be
504                                      great than or equal to the sum of all
505                                      rx_*_err values. */
506     ovs_32aligned_be64 tx_errors; /* Number of transmit errors.  This is a
507                                      super-set of transmit errors. */
508     ovs_32aligned_be64 rx_frame_err; /* Number of frame alignment errors. */
509     ovs_32aligned_be64 rx_over_err;  /* Number of packets with RX overrun. */
510     ovs_32aligned_be64 rx_crc_err;   /* Number of CRC errors. */
511     ovs_32aligned_be64 collisions;   /* Number of collisions. */
512 };
513 OFP_ASSERT(sizeof(struct ofp10_port_stats) == 104);
514
515 /* All ones is used to indicate all queues in a port (for stats retrieval). */
516 #define OFPQ_ALL      0xffffffff
517
518 /* Body for stats request of type OFPST_QUEUE. */
519 struct ofp10_queue_stats_request {
520     ovs_be16 port_no;        /* All ports if OFPP_ALL. */
521     uint8_t pad[2];          /* Align to 32-bits. */
522     ovs_be32 queue_id;       /* All queues if OFPQ_ALL. */
523 };
524 OFP_ASSERT(sizeof(struct ofp10_queue_stats_request) == 8);
525
526 /* Body for stats reply of type OFPST_QUEUE consists of an array of this
527  * structure type. */
528 struct ofp10_queue_stats {
529     ovs_be16 port_no;
530     uint8_t pad[2];          /* Align to 32-bits. */
531     ovs_be32 queue_id;       /* Queue id. */
532     ovs_32aligned_be64 tx_bytes;   /* Number of transmitted bytes. */
533     ovs_32aligned_be64 tx_packets; /* Number of transmitted packets. */
534     ovs_32aligned_be64 tx_errors;  /* # of packets dropped due to overrun. */
535 };
536 OFP_ASSERT(sizeof(struct ofp10_queue_stats) == 32);
537
538 /* Vendor extension stats message. */
539 struct ofp10_vendor_stats_msg {
540     struct ofp10_stats_msg osm; /* Type OFPST_VENDOR. */
541     ovs_be32 vendor;            /* Vendor ID:
542                                  * - MSB 0: low-order bytes are IEEE OUI.
543                                  * - MSB != 0: defined by OpenFlow
544                                  *   consortium. */
545     /* Followed by vendor-defined arbitrary additional data. */
546 };
547 OFP_ASSERT(sizeof(struct ofp10_vendor_stats_msg) == 16);
548
549 /* Vendor extension. */
550 struct ofp_vendor_header {
551     struct ofp_header header;   /* Type OFPT_VENDOR. */
552     ovs_be32 vendor;            /* Vendor ID:
553                                  * - MSB 0: low-order bytes are IEEE OUI.
554                                  * - MSB != 0: defined by OpenFlow
555                                  *   consortium. */
556     /* Vendor-defined arbitrary additional data. */
557 };
558 OFP_ASSERT(sizeof(struct ofp_vendor_header) == 12);
559
560 #endif /* openflow/openflow-1.0.h */