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