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