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