]> git.proxmox.com Git - mirror_ovs.git/blame - include/openvswitch/ofp-util.h
meta-flow: Remove cmap dependency.
[mirror_ovs.git] / include / openvswitch / ofp-util.h
CommitLineData
fa37b408 1/*
04f48a68 2 * Copyright (c) 2008-2017 Nicira, Inc.
fa37b408
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
f4248336
BW
17#ifndef OPENVSWITCH_OFP_UTIL_H
18#define OPENVSWITCH_OFP_UTIL_H 1
fa37b408 19
c1c9c9c4 20#include <stdbool.h>
fa37b408
BP
21#include <stddef.h>
22#include <stdint.h>
064d7f84 23#include "openvswitch/flow.h"
b19bab5b 24#include "openvswitch/list.h"
e29747e4 25#include "openvswitch/match.h"
064d7f84 26#include "openvswitch/meta-flow.h"
f4248336 27#include "openvswitch/netdev.h"
bc65c25a 28#include "openflow/netronome-ext.h"
492f7572 29#include "openflow/nicira-ext.h"
25070e04 30#include "openvswitch/ofp-msgs.h"
f4248336 31#include "openvswitch/ofpbuf.h"
44381c1b 32#include "openvswitch/types.h"
ae06a561 33#include "openvswitch/type-props.h"
f4248336 34#include "openvswitch/uuid.h"
fa37b408
BP
35
36struct ofpbuf;
e45e72f1 37union ofp_action;
b2dd70be 38struct ofpact_set_field;
aafee638 39struct vl_mff_map;
fa37b408 40
39dc9082 41/* Port numbers. */
4e022ec0
AW
42enum ofperr ofputil_port_from_ofp11(ovs_be32 ofp11_port,
43 ofp_port_t *ofp10_port);
44ovs_be32 ofputil_port_to_ofp11(ofp_port_t ofp10_port);
7b7503ea 45
4e022ec0
AW
46bool ofputil_port_from_string(const char *, ofp_port_t *portp);
47void ofputil_format_port(ofp_port_t port, struct ds *);
28b11432
BP
48void ofputil_port_to_string(ofp_port_t, char namebuf[OFP_MAX_PORT_NAME_LEN],
49 size_t bufsize);
d1e2cf21 50
7395c052
NZ
51/* Group numbers. */
52enum { MAX_GROUP_NAME_LEN = INT_STRLEN(uint32_t) };
53bool ofputil_group_from_string(const char *, uint32_t *group_id);
54void ofputil_format_group(uint32_t group_id, struct ds *);
55void ofputil_group_to_string(uint32_t group_id,
56 char namebuf[MAX_GROUP_NAME_LEN + 1],
57 size_t bufsize);
58
eec25dc1
BP
59/* Converting OFPFW10_NW_SRC_MASK and OFPFW10_NW_DST_MASK wildcard bit counts
60 * to and from IP bitmasks. */
0596e897
BP
61ovs_be32 ofputil_wcbits_to_netmask(int wcbits);
62int ofputil_netmask_to_wcbits(ovs_be32 netmask);
63
27527aa0 64/* Protocols.
85813857
BP
65 *
66 * A "protocol" is an OpenFlow version plus, for some OpenFlow versions,
67 * a bit extra about the flow match format in use.
27527aa0
BP
68 *
69 * These are arranged from most portable to least portable, or alternatively
85813857
BP
70 * from least powerful to most powerful. Protocols earlier on the list are
71 * more likely to be understood for the purpose of making requests, but
72 * protocol later on the list are more likely to accurately describe a flow
73 * within a switch.
27527aa0
BP
74 *
75 * On any given OpenFlow connection, a single protocol is in effect at any
76 * given time. These values use separate bits only because that makes it easy
77 * to test whether a particular protocol is within a given set of protocols and
78 * to implement set union and intersection.
79 */
80enum ofputil_protocol {
85813857
BP
81 /* OpenFlow 1.0 protocols.
82 *
83 * The "STD" protocols use the standard OpenFlow 1.0 flow format.
84 * The "NXM" protocols use the Nicira Extensible Match (NXM) flow format.
85 *
86 * The protocols with "TID" mean that the nx_flow_mod_table_id Nicira
87 * extension has been enabled. The other protocols have it disabled.
88 */
eb12aa89 89#define OFPUTIL_P_NONE 0
85813857
BP
90 OFPUTIL_P_OF10_STD = 1 << 0,
91 OFPUTIL_P_OF10_STD_TID = 1 << 1,
92 OFPUTIL_P_OF10_NXM = 1 << 2,
93 OFPUTIL_P_OF10_NXM_TID = 1 << 3,
94#define OFPUTIL_P_OF10_STD_ANY (OFPUTIL_P_OF10_STD | OFPUTIL_P_OF10_STD_TID)
95#define OFPUTIL_P_OF10_NXM_ANY (OFPUTIL_P_OF10_NXM | OFPUTIL_P_OF10_NXM_TID)
8621547c 96#define OFPUTIL_P_OF10_ANY (OFPUTIL_P_OF10_STD_ANY | OFPUTIL_P_OF10_NXM_ANY)
27527aa0 97
75fa58f8
BP
98 /* OpenFlow 1.1 protocol.
99 *
100 * We only support the standard OpenFlow 1.1 flow format.
101 *
102 * OpenFlow 1.1 always operates with an equivalent of the
103 * nx_flow_mod_table_id Nicira extension enabled, so there is no "TID"
104 * variant. */
105 OFPUTIL_P_OF11_STD = 1 << 4,
106
2e1ae200 107 /* OpenFlow 1.2+ protocols (only one variant each).
85813857 108 *
2e1ae200 109 * These use the standard OpenFlow Extensible Match (OXM) flow format.
85813857 110 *
2e1ae200 111 * OpenFlow 1.2+ always operates with an equivalent of the
85813857
BP
112 * nx_flow_mod_table_id Nicira extension enabled, so there is no "TID"
113 * variant. */
75fa58f8
BP
114 OFPUTIL_P_OF12_OXM = 1 << 5,
115 OFPUTIL_P_OF13_OXM = 1 << 6,
c37c0382 116 OFPUTIL_P_OF14_OXM = 1 << 7,
42dccab5 117 OFPUTIL_P_OF15_OXM = 1 << 8,
b79d45a1 118 OFPUTIL_P_OF16_OXM = 1 << 9,
42dccab5
BP
119#define OFPUTIL_P_ANY_OXM (OFPUTIL_P_OF12_OXM | \
120 OFPUTIL_P_OF13_OXM | \
121 OFPUTIL_P_OF14_OXM | \
b79d45a1
BP
122 OFPUTIL_P_OF15_OXM | \
123 OFPUTIL_P_OF16_OXM)
44d3732d 124
db0b6c29
JR
125#define OFPUTIL_P_NXM_OF11_UP (OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF11_STD | \
126 OFPUTIL_P_ANY_OXM)
127
128#define OFPUTIL_P_NXM_OXM_ANY (OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_ANY_OXM)
129
130#define OFPUTIL_P_OF11_UP (OFPUTIL_P_OF11_STD | OFPUTIL_P_ANY_OXM)
131
ab12d917
BP
132#define OFPUTIL_P_OF12_UP (OFPUTIL_P_OF12_OXM | OFPUTIL_P_OF13_UP)
133#define OFPUTIL_P_OF13_UP (OFPUTIL_P_OF13_OXM | OFPUTIL_P_OF14_UP)
42dccab5 134#define OFPUTIL_P_OF14_UP (OFPUTIL_P_OF14_OXM | OFPUTIL_P_OF15_UP)
b79d45a1
BP
135#define OFPUTIL_P_OF15_UP (OFPUTIL_P_OF15_OXM | OFPUTIL_P_OF16_UP)
136#define OFPUTIL_P_OF16_UP OFPUTIL_P_OF16_OXM
c37c0382 137
27527aa0 138 /* All protocols. */
b79d45a1 139#define OFPUTIL_P_ANY ((1 << 10) - 1)
27527aa0
BP
140
141 /* Protocols in which a specific table may be specified in flow_mods. */
7cd90356
BP
142#define OFPUTIL_P_TID (OFPUTIL_P_OF10_STD_TID | \
143 OFPUTIL_P_OF10_NXM_TID | \
75fa58f8 144 OFPUTIL_P_OF11_STD | \
4f13da56 145 OFPUTIL_P_ANY_OXM)
27527aa0
BP
146};
147
148/* Protocols to use for flow dumps, from most to least preferred. */
149extern enum ofputil_protocol ofputil_flow_dump_protocols[];
150extern size_t ofputil_n_flow_dump_protocols;
151
6d2c051a 152enum ofputil_protocol ofputil_protocol_from_ofp_version(enum ofp_version);
4f13da56
BP
153enum ofputil_protocol ofputil_protocols_from_ofp_version(enum ofp_version);
154enum ofp_version ofputil_protocol_to_ofp_version(enum ofputil_protocol);
9e1fd49b 155
27527aa0
BP
156bool ofputil_protocol_is_valid(enum ofputil_protocol);
157enum ofputil_protocol ofputil_protocol_set_tid(enum ofputil_protocol,
158 bool enable);
159enum ofputil_protocol ofputil_protocol_to_base(enum ofputil_protocol);
160enum ofputil_protocol ofputil_protocol_set_base(
161 enum ofputil_protocol cur, enum ofputil_protocol new_base);
162
163const char *ofputil_protocol_to_string(enum ofputil_protocol);
164char *ofputil_protocols_to_string(enum ofputil_protocol);
165enum ofputil_protocol ofputil_protocols_from_string(const char *);
27527aa0 166
03e1125c
SH
167void ofputil_format_version(struct ds *, enum ofp_version);
168void ofputil_format_version_name(struct ds *, enum ofp_version);
169
170/* A bitmap of version numbers
171 *
172 * Bit offsets correspond to ofp_version numbers which in turn correspond to
0746a84f
BP
173 * wire-protocol numbers for OpenFlow versions, e.g. (1u << OFP11_VERSION)
174 * is the mask for OpenFlow 1.1. If the bit for a version is set then it is
03e1125c
SH
175 * allowed, otherwise it is disallowed. */
176
177void ofputil_format_version_bitmap(struct ds *msg, uint32_t bitmap);
178void ofputil_format_version_bitmap_names(struct ds *msg, uint32_t bitmap);
179
9d84066c
BP
180enum ofp_version ofputil_version_from_string(const char *s);
181
4f13da56
BP
182uint32_t ofputil_protocols_to_version_bitmap(enum ofputil_protocol);
183enum ofputil_protocol ofputil_protocols_from_version_bitmap(uint32_t bitmap);
184
6dc53744
BP
185/* Bitmaps of OpenFlow versions that Open vSwitch supports, and that it enables
186 * by default. When Open vSwitch has experimental or incomplete support for
187 * newer versions of OpenFlow, those versions should not be supported by
188 * default and thus should be omitted from the latter bitmap. */
189#define OFPUTIL_SUPPORTED_VERSIONS ((1u << OFP10_VERSION) | \
190 (1u << OFP11_VERSION) | \
191 (1u << OFP12_VERSION) | \
192 (1u << OFP13_VERSION))
193#define OFPUTIL_DEFAULT_VERSIONS OFPUTIL_SUPPORTED_VERSIONS
03e1125c
SH
194
195enum ofputil_protocol ofputil_protocols_from_string(const char *s);
196
197const char *ofputil_version_to_string(enum ofp_version ofp_version);
198uint32_t ofputil_versions_from_string(const char *s);
7beaa082 199uint32_t ofputil_versions_from_strings(char ** const s, size_t count);
03e1125c 200
de6c85b0
SH
201bool ofputil_decode_hello(const struct ofp_header *,
202 uint32_t *allowed_versions);
203struct ofpbuf *ofputil_encode_hello(uint32_t version_bitmap);
204
27527aa0
BP
205struct ofpbuf *ofputil_encode_set_protocol(enum ofputil_protocol current,
206 enum ofputil_protocol want,
207 enum ofputil_protocol *next);
208
209/* nx_flow_format */
210struct ofpbuf *ofputil_encode_nx_set_flow_format(enum nx_flow_format);
211enum ofputil_protocol ofputil_nx_flow_format_to_protocol(enum nx_flow_format);
212bool ofputil_nx_flow_format_is_valid(enum nx_flow_format);
213const char *ofputil_nx_flow_format_to_string(enum nx_flow_format);
214
eec25dc1
BP
215/* Work with ofp10_match. */
216void ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *);
81a76618
BP
217void ofputil_match_from_ofp10_match(const struct ofp10_match *,
218 struct match *);
219void ofputil_normalize_match(struct match *);
220void ofputil_normalize_match_quiet(struct match *);
221void ofputil_match_to_ofp10_match(const struct match *, struct ofp10_match *);
d8ae4d67 222
410698cf 223/* Work with ofp11_match. */
8d8ab6c2
JG
224enum ofperr ofputil_pull_ofp11_match(struct ofpbuf *, const struct tun_table *,
225 struct match *,
36a16881 226 uint16_t *padded_match_len);
bc65c25a
SH
227enum ofperr ofputil_pull_ofp11_mask(struct ofpbuf *, struct match *,
228 struct mf_bitmap *bm);
81a76618
BP
229enum ofperr ofputil_match_from_ofp11_match(const struct ofp11_match *,
230 struct match *);
75fa58f8
BP
231int ofputil_put_ofp11_match(struct ofpbuf *, const struct match *,
232 enum ofputil_protocol);
81a76618 233void ofputil_match_to_ofp11_match(const struct match *, struct ofp11_match *);
75fa58f8 234int ofputil_match_typical_len(enum ofputil_protocol);
410698cf 235
36956a7d
BP
236/* dl_type translation between OpenFlow and 'struct flow' format. */
237ovs_be16 ofputil_dl_type_to_openflow(ovs_be16 flow_dl_type);
238ovs_be16 ofputil_dl_type_from_openflow(ovs_be16 ofp_dl_type);
239
54834960
EJ
240/* PACKET_IN. */
241bool ofputil_packet_in_format_is_valid(enum nx_packet_in_format);
242int ofputil_packet_in_format_from_string(const char *);
243const char *ofputil_packet_in_format_to_string(enum nx_packet_in_format);
3f4a1939
SH
244struct ofpbuf *ofputil_make_set_packet_in_format(enum ofp_version,
245 enum nx_packet_in_format);
54834960 246
6c1491fb
BP
247/* NXT_FLOW_MOD_TABLE_ID extension. */
248struct ofpbuf *ofputil_make_flow_mod_table_id(bool flow_mod_table_id);
249
0fb88c18
BP
250/* Protocol-independent flow_mod flags. */
251enum ofputil_flow_mod_flags {
3f517bcd
DB
252 /* Flags that are maintained with a flow as part of its state.
253 *
254 * (OFPUTIL_FF_EMERG would be here too, if OVS supported it.) */
0fb88c18 255 OFPUTIL_FF_SEND_FLOW_REM = 1 << 0, /* All versions. */
3f517bcd
DB
256 OFPUTIL_FF_NO_PKT_COUNTS = 1 << 1, /* OpenFlow 1.3+. */
257 OFPUTIL_FF_NO_BYT_COUNTS = 1 << 2, /* OpenFlow 1.3+. */
3f517bcd 258
13327b8e
BP
259 /* These flags primarily affects flow_mod behavior. They are not
260 * particularly useful as part of flow state. We include them in flow
261 * state only because OpenFlow implies that they should be. */
3f517bcd 262 OFPUTIL_FF_CHECK_OVERLAP = 1 << 3, /* All versions. */
13327b8e
BP
263 OFPUTIL_FF_RESET_COUNTS = 1 << 4, /* OpenFlow 1.2+. */
264
265 /* Not supported by OVS. */
266 OFPUTIL_FF_EMERG = 1 << 5, /* OpenFlow 1.0 only. */
267
268 /* The set of flags maintained as part of a flow table entry. */
269#define OFPUTIL_FF_STATE (OFPUTIL_FF_SEND_FLOW_REM \
270 | OFPUTIL_FF_NO_PKT_COUNTS \
271 | OFPUTIL_FF_NO_BYT_COUNTS \
272 | OFPUTIL_FF_CHECK_OVERLAP \
273 | OFPUTIL_FF_RESET_COUNTS)
adcf00ba
AZ
274
275 /* Flags that are only set by OVS for its internal use. Cannot be set via
276 * OpenFlow. */
277 OFPUTIL_FF_HIDDEN_FIELDS = 1 << 6, /* Allow hidden match fields to be
278 set or modified. */
279 OFPUTIL_FF_NO_READONLY = 1 << 7, /* Allow rules within read only tables
280 to be modified */
0fb88c18
BP
281};
282
623e1caf
JP
283/* Protocol-independent flow_mod.
284 *
285 * The handling of cookies across multiple versions of OpenFlow is a bit
7c9afefd 286 * confusing. See the topics/design doc for the details. */
a9a2da38 287struct ofputil_flow_mod {
ca6ba700 288 struct ovs_list list_node; /* For queuing flow_mods. */
3d9c5e58 289
81a76618 290 struct match match;
eb391b76 291 int priority;
23342857
BP
292
293 /* Cookie matching. The flow_mod affects only flows that have cookies that
294 * bitwise match 'cookie' bits in positions where 'cookie_mask has 1-bits.
295 *
296 * 'cookie_mask' should be zero for OFPFC_ADD flow_mods. */
623e1caf
JP
297 ovs_be64 cookie; /* Cookie bits to match. */
298 ovs_be64 cookie_mask; /* 1-bit in each 'cookie' bit to match. */
23342857
BP
299
300 /* Cookie changes.
301 *
302 * OFPFC_ADD uses 'new_cookie' as the new flow's cookie. 'new_cookie'
303 * should not be UINT64_MAX.
304 *
305 * OFPFC_MODIFY and OFPFC_MODIFY_STRICT have two cases:
306 *
307 * - If one or more matching flows exist and 'modify_cookie' is true,
308 * then the flow_mod changes the existing flows' cookies to
309 * 'new_cookie'. 'new_cookie' should not be UINT64_MAX.
310 *
311 * - If no matching flow exists, 'new_cookie' is not UINT64_MAX, and
312 * 'cookie_mask' is 0, then the flow_mod adds a new flow with
313 * 'new_cookie' as its cookie.
314 */
315 ovs_be64 new_cookie; /* New cookie to install or UINT64_MAX. */
316 bool modify_cookie; /* Set cookie of existing flow to 'new_cookie'? */
317
6c1491fb 318 uint8_t table_id;
2e4f5fcf
BP
319 uint16_t command;
320 uint16_t idle_timeout;
321 uint16_t hard_timeout;
322 uint32_t buffer_id;
4e022ec0 323 ofp_port_t out_port;
7395c052 324 uint32_t out_group;
0fb88c18 325 enum ofputil_flow_mod_flags flags;
ca26eb44 326 uint16_t importance; /* Eviction precedence. */
dc723c44
JR
327 struct ofpact *ofpacts; /* Series of "struct ofpact"s. */
328 size_t ofpacts_len; /* Length of ofpacts, in bytes. */
2e4f5fcf
BP
329};
330
90bf1e07
BP
331enum ofperr ofputil_decode_flow_mod(struct ofputil_flow_mod *,
332 const struct ofp_header *,
f25d0cf3 333 enum ofputil_protocol,
8d8ab6c2 334 const struct tun_table *,
04f48a68 335 const struct vl_mff_map *,
7e9f8266
BP
336 struct ofpbuf *ofpacts,
337 ofp_port_t max_port,
338 uint8_t max_table);
a9a2da38 339struct ofpbuf *ofputil_encode_flow_mod(const struct ofputil_flow_mod *,
27527aa0
BP
340 enum ofputil_protocol);
341
27527aa0 342/* Flow stats or aggregate stats request, independent of protocol. */
81d1ea94 343struct ofputil_flow_stats_request {
2e4f5fcf 344 bool aggregate; /* Aggregate results? */
81a76618 345 struct match match;
e729e793
JP
346 ovs_be64 cookie;
347 ovs_be64 cookie_mask;
4e022ec0 348 ofp_port_t out_port;
7395c052 349 uint32_t out_group;
2e4f5fcf
BP
350 uint8_t table_id;
351};
352
90bf1e07 353enum ofperr ofputil_decode_flow_stats_request(
8d8ab6c2
JG
354 struct ofputil_flow_stats_request *, const struct ofp_header *,
355 const struct tun_table *);
2e4f5fcf 356struct ofpbuf *ofputil_encode_flow_stats_request(
27527aa0 357 const struct ofputil_flow_stats_request *, enum ofputil_protocol);
2e4f5fcf 358
27527aa0 359/* Flow stats reply, independent of protocol. */
4ffd1b43 360struct ofputil_flow_stats {
81a76618 361 struct match match;
4ffd1b43
BP
362 ovs_be64 cookie;
363 uint8_t table_id;
81a76618 364 uint16_t priority;
4ffd1b43
BP
365 uint16_t idle_timeout;
366 uint16_t hard_timeout;
e0822031
HS
367 uint32_t duration_sec;
368 uint32_t duration_nsec;
f27f2134
BP
369 int idle_age; /* Seconds since last packet, -1 if unknown. */
370 int hard_age; /* Seconds since last change, -1 if unknown. */
5e9d0469
BP
371 uint64_t packet_count; /* Packet count, UINT64_MAX if unknown. */
372 uint64_t byte_count; /* Byte count, UINT64_MAX if unknown. */
dc723c44 373 const struct ofpact *ofpacts;
f25d0cf3 374 size_t ofpacts_len;
0fb88c18 375 enum ofputil_flow_mod_flags flags;
ca26eb44 376 uint16_t importance; /* Eviction precedence. */
4ffd1b43
BP
377};
378
379int ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *,
f27f2134 380 struct ofpbuf *msg,
f25d0cf3
BP
381 bool flow_age_extension,
382 struct ofpbuf *ofpacts);
349adfb2 383void ofputil_append_flow_stats_reply(const struct ofputil_flow_stats *,
8d8ab6c2
JG
384 struct ovs_list *replies,
385 const struct tun_table *);
4ffd1b43 386
27527aa0 387/* Aggregate stats reply, independent of protocol. */
76c93b22 388struct ofputil_aggregate_stats {
5e9d0469
BP
389 uint64_t packet_count; /* Packet count, UINT64_MAX if unknown. */
390 uint64_t byte_count; /* Byte count, UINT64_MAX if unknown. */
76c93b22
BP
391 uint32_t flow_count;
392};
393
394struct ofpbuf *ofputil_encode_aggregate_stats_reply(
395 const struct ofputil_aggregate_stats *stats,
982697a4
BP
396 const struct ofp_header *request);
397enum ofperr ofputil_decode_aggregate_stats_reply(
398 struct ofputil_aggregate_stats *,
399 const struct ofp_header *reply);
76c93b22 400
27527aa0 401/* Flow removed message, independent of protocol. */
9b045a0c 402struct ofputil_flow_removed {
81a76618 403 struct match match;
9b045a0c 404 ovs_be64 cookie;
e0822031 405 uint16_t priority;
9b045a0c 406 uint8_t reason; /* One of OFPRR_*. */
95216219 407 uint8_t table_id; /* 255 if message didn't include table ID. */
9b045a0c
BP
408 uint32_t duration_sec;
409 uint32_t duration_nsec;
410 uint16_t idle_timeout;
fa2bad0f 411 uint16_t hard_timeout;
5e9d0469
BP
412 uint64_t packet_count; /* Packet count, UINT64_MAX if unknown. */
413 uint64_t byte_count; /* Byte count, UINT64_MAX if unknown. */
9b045a0c
BP
414};
415
90bf1e07
BP
416enum ofperr ofputil_decode_flow_removed(struct ofputil_flow_removed *,
417 const struct ofp_header *);
588cd7b5 418struct ofpbuf *ofputil_encode_flow_removed(const struct ofputil_flow_removed *,
27527aa0 419 enum ofputil_protocol);
9b045a0c 420
9bfe9334
BP
421/* Abstract packet-in message.
422 *
423 * This omits the 'total_len' and 'buffer_id' fields, which we handle
424 * differently for encoding and decoding.*/
ebb57021 425struct ofputil_packet_in {
22ee3544
BP
426 /* Packet data and metadata.
427 *
9bfe9334
BP
428 * On encoding, the full packet should be supplied, but depending on its
429 * other parameters ofputil_encode_packet_in() might send only the first
430 * part of the packet.
22ee3544 431 *
9bfe9334
BP
432 * On decoding, the 'len' bytes in 'packet' might only be the first part of
433 * the original packet. ofputil_decode_packet_in() reports the full
434 * original length of the packet using its 'total_len' output parameter. */
95022b47 435 void *packet; /* The packet. */
4adaf182 436 size_t packet_len; /* Length of 'packet' in bytes. */
9bfe9334
BP
437
438 /* Input port and other metadata for packet. */
439 struct match flow_metadata;
5d6c3af0 440
22ee3544
BP
441 /* Reason that the packet-in is being sent. */
442 enum ofp_packet_in_reason reason; /* One of OFPR_*. */
443
444 /* Information about the OpenFlow flow that triggered the packet-in.
445 *
446 * A packet-in triggered by a flow table miss has no associated flow. In
d4fa4e79 447 * that case, 'cookie' is UINT64_MAX. */
22ee3544
BP
448 uint8_t table_id; /* OpenFlow table ID. */
449 ovs_be64 cookie; /* Flow's cookie. */
bdcad671
BP
450
451 /* Arbitrary user-provided data. */
452 uint8_t *userdata;
453 size_t userdata_len;
ebb57021
BP
454};
455
77ab5fd2 456void ofputil_packet_in_destroy(struct ofputil_packet_in *);
9bfe9334 457
77ab5fd2 458enum ofperr ofputil_decode_packet_in(const struct ofp_header *, bool loose,
8d8ab6c2 459 const struct tun_table *,
9bfe9334 460 struct ofputil_packet_in *,
77ab5fd2
BP
461 size_t *total_len, uint32_t *buffer_id,
462 struct ofpbuf *continuation);
463
464struct ofpbuf *ofputil_encode_resume(const struct ofputil_packet_in *pin,
465 const struct ofpbuf *continuation,
466 enum ofputil_protocol);
ebb57021 467
5014a89d
BP
468enum { OFPUTIL_PACKET_IN_REASON_BUFSIZE = INT_STRLEN(int) + 1 };
469const char *ofputil_packet_in_reason_to_string(enum ofp_packet_in_reason,
470 char *reasonbuf,
471 size_t bufsize);
7c1a76a4
BP
472bool ofputil_packet_in_reason_from_string(const char *,
473 enum ofp_packet_in_reason *);
474
77ab5fd2
BP
475/* A packet-in message, including continuation data. The format of
476 * continuation data is subject to change and thus it is supposed to be opaque
477 * to any process other than ovs-vswitchd. Therefore, only ovs-vswitchd should
478 * use ofputil_packet_in_private and the functions that operate on it. */
479struct ofputil_packet_in_private {
480 struct ofputil_packet_in public;
481
482 /* NXCPT_BRIDGE. */
483 struct uuid bridge;
484
485 /* NXCPT_STACK. */
84cf3c1f
JR
486 uint8_t *stack;
487 size_t stack_size;
77ab5fd2
BP
488
489 /* NXCPT_MIRRORS. */
490 uint32_t mirrors;
491
492 /* NXCPT_CONNTRACKED. */
493 bool conntracked;
494
495 /* NXCPT_ACTIONS. */
496 struct ofpact *actions;
497 size_t actions_len;
498
499 /* NXCPT_ACTION_SET. */
500 struct ofpact *action_set;
501 size_t action_set_len;
502};
503
504struct ofpbuf *ofputil_encode_packet_in_private(
505 const struct ofputil_packet_in_private *,
506 enum ofputil_protocol protocol,
c184807c 507 enum nx_packet_in_format);
77ab5fd2
BP
508
509enum ofperr ofputil_decode_packet_in_private(
510 const struct ofp_header *, bool loose,
8d8ab6c2 511 const struct tun_table *,
77ab5fd2
BP
512 struct ofputil_packet_in_private *,
513 size_t *total_len, uint32_t *buffer_id);
514
515void ofputil_packet_in_private_destroy(struct ofputil_packet_in_private *);
516
751c7785
BP
517/* Abstract packet-out message.
518 *
519 * ofputil_decode_packet_out() will ensure that 'in_port' is a physical port
520 * (OFPP_MAX or less) or one of OFPP_LOCAL, OFPP_NONE, or OFPP_CONTROLLER. */
c6a93eb7
BP
521struct ofputil_packet_out {
522 const void *packet; /* Packet data, if buffer_id == UINT32_MAX. */
523 size_t packet_len; /* Length of packet data in bytes. */
524 uint32_t buffer_id; /* Buffer id or UINT32_MAX if no buffer. */
4e022ec0 525 ofp_port_t in_port; /* Packet's input port. */
f25d0cf3
BP
526 struct ofpact *ofpacts; /* Actions. */
527 size_t ofpacts_len; /* Size of ofpacts in bytes. */
c6a93eb7
BP
528};
529
530enum ofperr ofputil_decode_packet_out(struct ofputil_packet_out *,
982697a4 531 const struct ofp_header *,
f25d0cf3 532 struct ofpbuf *ofpacts);
de0f3156
SH
533struct ofpbuf *ofputil_encode_packet_out(const struct ofputil_packet_out *,
534 enum ofputil_protocol protocol);
c6a93eb7 535
ad99e2ed
BP
536enum ofputil_frag_handling {
537 OFPUTIL_FRAG_NORMAL = OFPC_FRAG_NORMAL, /* No special handling. */
538 OFPUTIL_FRAG_DROP = OFPC_FRAG_DROP, /* Drop fragments. */
539 OFPUTIL_FRAG_REASM = OFPC_FRAG_REASM, /* Reassemble (if supported). */
540 OFPUTIL_FRAG_NX_MATCH = OFPC_FRAG_NX_MATCH /* Match on frag bits. */
541};
542
543const char *ofputil_frag_handling_to_string(enum ofputil_frag_handling);
544bool ofputil_frag_handling_from_string(const char *,
545 enum ofputil_frag_handling *);
546
547/* Abstract struct ofp_switch_config. */
548struct ofputil_switch_config {
549 /* Fragment handling. */
550 enum ofputil_frag_handling frag;
551
552 /* 0: Do not send packet to controller when decrementing invalid IP TTL.
553 * 1: Do send packet to controller when decrementing invalid IP TTL.
554 * -1: Unspecified (only OpenFlow 1.1 and 1.2 support this setting. */
555 int invalid_ttl_to_controller;
556
557 /* Maximum bytes of packet to send to controller on miss. */
558 uint16_t miss_send_len;
559};
560
561void ofputil_decode_get_config_reply(const struct ofp_header *,
562 struct ofputil_switch_config *);
563struct ofpbuf *ofputil_encode_get_config_reply(
564 const struct ofp_header *request, const struct ofputil_switch_config *);
565
566enum ofperr ofputil_decode_set_config(const struct ofp_header *,
567 struct ofputil_switch_config *);
568struct ofpbuf *ofputil_encode_set_config(
569 const struct ofputil_switch_config *, enum ofp_version);
570
9e1fd49b
BP
571enum ofputil_port_config {
572 /* OpenFlow 1.0 and 1.1 share these values for these port config bits. */
573 OFPUTIL_PC_PORT_DOWN = 1 << 0, /* Port is administratively down. */
574 OFPUTIL_PC_NO_RECV = 1 << 2, /* Drop all packets received by port. */
575 OFPUTIL_PC_NO_FWD = 1 << 5, /* Drop packets forwarded to port. */
576 OFPUTIL_PC_NO_PACKET_IN = 1 << 6, /* No send packet-in msgs for port. */
577 /* OpenFlow 1.0 only. */
578 OFPUTIL_PC_NO_STP = 1 << 1, /* No 802.1D spanning tree for port. */
579 OFPUTIL_PC_NO_RECV_STP = 1 << 3, /* Drop received 802.1D STP packets. */
580 OFPUTIL_PC_NO_FLOOD = 1 << 4, /* Do not include port when flooding. */
581 /* There are no OpenFlow 1.1-only bits. */
582};
583
584enum ofputil_port_state {
585 /* OpenFlow 1.0 and 1.1 share this values for these port state bits. */
586 OFPUTIL_PS_LINK_DOWN = 1 << 0, /* No physical link present. */
587 /* OpenFlow 1.1 only. */
588 OFPUTIL_PS_BLOCKED = 1 << 1, /* Port is blocked */
589 OFPUTIL_PS_LIVE = 1 << 2, /* Live for Fast Failover Group. */
590 /* OpenFlow 1.0 only. */
591 OFPUTIL_PS_STP_LISTEN = 0 << 8, /* Not learning or relaying frames. */
592 OFPUTIL_PS_STP_LEARN = 1 << 8, /* Learning but not relaying frames. */
593 OFPUTIL_PS_STP_FORWARD = 2 << 8, /* Learning and relaying frames. */
594 OFPUTIL_PS_STP_BLOCK = 3 << 8, /* Not part of spanning tree. */
595 OFPUTIL_PS_STP_MASK = 3 << 8 /* Bit mask for OFPPS10_STP_* values. */
596};
597
598/* Abstract ofp10_phy_port or ofp11_port. */
599struct ofputil_phy_port {
4e022ec0 600 ofp_port_t port_no;
74ff3298 601 struct eth_addr hw_addr;
9e1fd49b
BP
602 char name[OFP_MAX_PORT_NAME_LEN];
603 enum ofputil_port_config config;
604 enum ofputil_port_state state;
605
606 /* NETDEV_F_* feature bitmasks. */
607 enum netdev_features curr; /* Current features. */
608 enum netdev_features advertised; /* Features advertised by the port. */
609 enum netdev_features supported; /* Features supported by the port. */
610 enum netdev_features peer; /* Features advertised by peer. */
611
612 /* Speed. */
613 uint32_t curr_speed; /* Current speed, in kbps. */
614 uint32_t max_speed; /* Maximum supported speed, in kbps. */
615};
616
617enum ofputil_capabilities {
50b73fe1 618 /* All OpenFlow versions share these capability values. */
9e1fd49b
BP
619 OFPUTIL_C_FLOW_STATS = 1 << 0, /* Flow statistics. */
620 OFPUTIL_C_TABLE_STATS = 1 << 1, /* Table statistics. */
621 OFPUTIL_C_PORT_STATS = 1 << 2, /* Port statistics. */
622 OFPUTIL_C_IP_REASM = 1 << 5, /* Can reassemble IP fragments. */
623 OFPUTIL_C_QUEUE_STATS = 1 << 6, /* Queue statistics. */
60202987
SH
624
625 /* OpenFlow 1.0 and 1.1 share this capability. */
9e1fd49b
BP
626 OFPUTIL_C_ARP_MATCH_IP = 1 << 7, /* Match IP addresses in ARP pkts. */
627
628 /* OpenFlow 1.0 only. */
629 OFPUTIL_C_STP = 1 << 3, /* 802.1d spanning tree. */
630
50b73fe1
JR
631 /* OpenFlow 1.1+ only. Note that this bit value does not match the one
632 * in the OpenFlow message. */
9e1fd49b 633 OFPUTIL_C_GROUP_STATS = 1 << 4, /* Group statistics. */
60202987 634
50b73fe1 635 /* OpenFlow 1.2+ only. */
60202987 636 OFPUTIL_C_PORT_BLOCKED = 1 << 8, /* Switch will block looping ports */
50b73fe1
JR
637
638 /* OpenFlow 1.4+ only. */
639 OFPUTIL_C_BUNDLES = 1 << 9, /* Switch supports bundles. */
640 OFPUTIL_C_FLOW_MONITORING = 1 << 10, /* Switch supports flow monitoring. */
9e1fd49b
BP
641};
642
9e1fd49b
BP
643/* Abstract ofp_switch_features. */
644struct ofputil_switch_features {
645 uint64_t datapath_id; /* Datapath unique ID. */
646 uint32_t n_buffers; /* Max packets buffered at once. */
647 uint8_t n_tables; /* Number of tables supported by datapath. */
2e1ae200 648 uint8_t auxiliary_id; /* Identify auxiliary connections */
9e1fd49b 649 enum ofputil_capabilities capabilities;
08d1e234 650 uint64_t ofpacts; /* Bitmap of OFPACT_* bits. */
9e1fd49b
BP
651};
652
667bb1fb
BP
653enum ofperr ofputil_pull_switch_features(struct ofpbuf *,
654 struct ofputil_switch_features *);
9e1fd49b
BP
655
656struct ofpbuf *ofputil_encode_switch_features(
657 const struct ofputil_switch_features *, enum ofputil_protocol,
658 ovs_be32 xid);
659void ofputil_put_switch_features_port(const struct ofputil_phy_port *,
660 struct ofpbuf *);
fca6d553 661bool ofputil_switch_features_has_ports(struct ofpbuf *b);
9e1fd49b 662
2be393ed 663/* phy_port helper functions. */
2e3fa633 664int ofputil_pull_phy_port(enum ofp_version ofp_version, struct ofpbuf *,
2be393ed 665 struct ofputil_phy_port *);
2be393ed 666
9e1fd49b
BP
667/* Abstract ofp_port_status. */
668struct ofputil_port_status {
669 enum ofp_port_reason reason;
670 struct ofputil_phy_port desc;
671};
672
982697a4 673enum ofperr ofputil_decode_port_status(const struct ofp_header *,
9e1fd49b
BP
674 struct ofputil_port_status *);
675struct ofpbuf *ofputil_encode_port_status(const struct ofputil_port_status *,
676 enum ofputil_protocol);
677
678/* Abstract ofp_port_mod. */
679struct ofputil_port_mod {
4e022ec0 680 ofp_port_t port_no;
74ff3298 681 struct eth_addr hw_addr;
9e1fd49b
BP
682 enum ofputil_port_config config;
683 enum ofputil_port_config mask;
684 enum netdev_features advertise;
685};
686
687enum ofperr ofputil_decode_port_mod(const struct ofp_header *,
18cc69d9 688 struct ofputil_port_mod *, bool loose);
9e1fd49b
BP
689struct ofpbuf *ofputil_encode_port_mod(const struct ofputil_port_mod *,
690 enum ofputil_protocol);
6c038611 691
3c1bb396
BP
692/* Abstract version of OFPTC11_TABLE_MISS_*.
693 *
694 * OpenFlow 1.0 always sends packets that miss to the next flow table, or to
695 * the controller if they miss in the last flow table.
696 *
697 * OpenFlow 1.1 and 1.2 can configure table miss behavior via a "table-mod"
698 * that specifies "send to controller", "miss", or "drop".
699 *
700 * OpenFlow 1.3 and later never sends packets that miss to the controller.
701 */
702enum ofputil_table_miss {
703 /* Protocol-specific default behavior. On OpenFlow 1.0 through 1.2
704 * connections, the packet is sent to the controller, and on OpenFlow 1.3
705 * and later connections, the packet is dropped.
706 *
707 * This is also used as a result of decoding OpenFlow 1.3+ "config" values
708 * in table-mods, to indicate that no table-miss was specified. */
709 OFPUTIL_TABLE_MISS_DEFAULT, /* Protocol default behavior. */
710
711 /* These constants have the same meanings as those in OpenFlow with the
712 * same names. */
713 OFPUTIL_TABLE_MISS_CONTROLLER, /* Send to controller. */
714 OFPUTIL_TABLE_MISS_CONTINUE, /* Go to next table. */
715 OFPUTIL_TABLE_MISS_DROP, /* Drop the packet. */
716};
717
82c22d34
BP
718/* Abstract version of OFPTC14_EVICTION.
719 *
720 * OpenFlow 1.0 through 1.3 don't know anything about eviction, so decoding a
721 * message for one of these protocols always yields
722 * OFPUTIL_TABLE_EVICTION_DEFAULT. */
723enum ofputil_table_eviction {
724 OFPUTIL_TABLE_EVICTION_DEFAULT, /* No value. */
725 OFPUTIL_TABLE_EVICTION_ON, /* Enable eviction. */
726 OFPUTIL_TABLE_EVICTION_OFF /* Disable eviction. */
727};
3c1bb396 728
de7d3c07
SJ
729/* Abstract version of OFPTC14_VACANCY_EVENTS.
730 *
731 * OpenFlow 1.0 through 1.3 don't know anything about vacancy events, so
732 * decoding a message for one of these protocols always yields
733 * OFPUTIL_TABLE_VACANCY_DEFAULT. */
734enum ofputil_table_vacancy {
735 OFPUTIL_TABLE_VACANCY_DEFAULT, /* No value. */
736 OFPUTIL_TABLE_VACANCY_ON, /* Enable vacancy events. */
737 OFPUTIL_TABLE_VACANCY_OFF /* Disable vacancy events. */
738};
739
740/* Abstract version of OFPTMPT_VACANCY.
741 *
742 * Openflow 1.4+ defines vacancy events.
743 * The fields vacancy_down and vacancy_up are the threshold for generating
744 * vacancy events that should be configured on the flow table, expressed as
745 * a percent.
746 * The vacancy field is only used when this property in included in a
747 * OFPMP_TABLE_DESC multipart reply or a OFPT_TABLE_STATUS message and
748 * represent the current vacancy of the table, expressed as a percent. In
749 * OFP_TABLE_MOD requests, this field must be set to 0 */
750struct ofputil_table_mod_prop_vacancy {
751 uint8_t vacancy_down; /* Vacancy threshold when space decreases (%). */
752 uint8_t vacancy_up; /* Vacancy threshold when space increases (%). */
753 uint8_t vacancy; /* Current vacancy (%). */
754};
755
918f2b82
AZ
756/* Abstract ofp_table_mod. */
757struct ofputil_table_mod {
758 uint8_t table_id; /* ID of the table, 0xff indicates all tables. */
82c22d34
BP
759
760 /* OpenFlow 1.1 and 1.2 only. For other versions, ignored on encoding,
761 * decoded to OFPUTIL_TABLE_MISS_DEFAULT. */
762 enum ofputil_table_miss miss;
763
764 /* OpenFlow 1.4+ only. For other versions, ignored on encoding, decoded to
765 * OFPUTIL_TABLE_EVICTION_DEFAULT. */
766 enum ofputil_table_eviction eviction;
767
768 /* OpenFlow 1.4+ only and optional even there; UINT32_MAX indicates
769 * absence. For other versions, ignored on encoding, decoded to
770 * UINT32_MAX.*/
771 uint32_t eviction_flags; /* OFPTMPEF14_*. */
de7d3c07
SJ
772
773 /* OpenFlow 1.4+ only. For other versions, ignored on encoding, decoded to
774 * OFPUTIL_TABLE_VACANCY_DEFAULT. */
775 enum ofputil_table_vacancy vacancy;
776
777 /* Openflow 1.4+ only. Defines threshold values of vacancy expressed as
778 * percent, value of current vacancy is set to zero for table-mod.
779 * For other versions, ignored on encoding, all values decoded to
780 * zero. */
781 struct ofputil_table_mod_prop_vacancy table_vacancy;
918f2b82
AZ
782};
783
03c72922
BP
784/* Abstract ofp14_table_desc. */
785struct ofputil_table_desc {
786 uint8_t table_id; /* ID of the table. */
787 enum ofputil_table_eviction eviction;
788 uint32_t eviction_flags; /* UINT32_MAX if not present. */
de7d3c07
SJ
789 enum ofputil_table_vacancy vacancy;
790 struct ofputil_table_mod_prop_vacancy table_vacancy;
03c72922
BP
791};
792
918f2b82
AZ
793enum ofperr ofputil_decode_table_mod(const struct ofp_header *,
794 struct ofputil_table_mod *);
795struct ofpbuf *ofputil_encode_table_mod(const struct ofputil_table_mod *,
796 enum ofputil_protocol);
797
82c22d34
BP
798/* Abstract ofp_table_features.
799 *
800 * This is used for all versions of OpenFlow, even though ofp_table_features
801 * was only introduced in OpenFlow 1.3, because earlier versions of OpenFlow
802 * include support for a subset of ofp_table_features through OFPST_TABLE (aka
803 * OFPMP_TABLE). */
5deff5aa
AW
804struct ofputil_table_features {
805 uint8_t table_id; /* Identifier of table. Lower numbered tables
806 are consulted first. */
807 char name[OFP_MAX_TABLE_NAME_LEN];
808 ovs_be64 metadata_match; /* Bits of metadata table can match. */
809 ovs_be64 metadata_write; /* Bits of metadata table can write. */
5deff5aa
AW
810 uint32_t max_entries; /* Max number of entries supported. */
811
82c22d34
BP
812 /* Flags.
813 *
814 * 'miss_config' is relevant for OpenFlow 1.1 and 1.2 only, because those
815 * versions include OFPTC_MISS_* flags in OFPST_TABLE. For other versions,
816 * it is decoded to OFPUTIL_TABLE_MISS_DEFAULT and ignored for encoding.
817 *
818 * 'supports_eviction' and 'supports_vacancy_events' are relevant only for
819 * OpenFlow 1.4 and later only. For OF1.4, they are boolean: 1 if
820 * supported, otherwise 0. For other versions, they are decoded as -1 and
821 * ignored for encoding.
822 *
7c9afefd 823 * Search for "OFPTC_* Table Configuration" in the documentation for more
82c22d34
BP
824 * details of how OpenFlow has changed in this area.
825 */
826 enum ofputil_table_miss miss_config; /* OF1.1 and 1.2 only. */
827 int supports_eviction; /* OF1.4+ only. */
828 int supports_vacancy_events; /* OF1.4+ only. */
829
5deff5aa
AW
830 /* Table features related to instructions. There are two instances:
831 *
832 * - 'miss' reports features available in the table miss flow.
833 *
834 * - 'nonmiss' reports features available in other flows. */
835 struct ofputil_table_instruction_features {
836 /* Tables that "goto-table" may jump to. */
837 unsigned long int next[BITMAP_N_LONGS(255)];
838
839 /* Bitmap of OVSINST_* for supported instructions. */
840 uint32_t instructions;
841
842 /* Table features related to actions. There are two instances:
843 *
844 * - 'write' reports features available in a "write_actions"
845 * instruction.
846 *
847 * - 'apply' reports features available in an "apply_actions"
848 * instruction. */
849 struct ofputil_table_action_features {
08d1e234 850 uint64_t ofpacts; /* Bitmap of supported OFPACT_*. */
abadfcb0 851 struct mf_bitmap set_fields; /* Fields for "set-field". */
5deff5aa
AW
852 } write, apply;
853 } nonmiss, miss;
854
855 /* MFF_* bitmaps.
856 *
857 * For any given field the following combinations are valid:
858 *
859 * - match=0, wildcard=0, mask=0: Flows in this table cannot match on
860 * this field.
861 *
862 * - match=1, wildcard=0, mask=0: Flows in this table must match on all
863 * the bits in this field.
864 *
865 * - match=1, wildcard=1, mask=0: Flows in this table must either match
866 * on all the bits in the field or wildcard the field entirely.
867 *
868 * - match=1, wildcard=1, mask=1: Flows in this table may arbitrarily
869 * mask this field (as special cases, they may match on all the bits
870 * or wildcard it entirely).
871 *
872 * Other combinations do not make sense.
873 */
abadfcb0
BP
874 struct mf_bitmap match; /* Fields that may be matched. */
875 struct mf_bitmap mask; /* Subset of 'match' that may have masks. */
876 struct mf_bitmap wildcard; /* Subset of 'match' that may be wildcarded. */
5deff5aa
AW
877};
878
879int ofputil_decode_table_features(struct ofpbuf *,
880 struct ofputil_table_features *, bool loose);
03c72922
BP
881
882int ofputil_decode_table_desc(struct ofpbuf *,
883 struct ofputil_table_desc *,
884 enum ofp_version);
885
3c4e10fb
BP
886struct ofpbuf *ofputil_encode_table_features_request(enum ofp_version);
887
03c72922
BP
888struct ofpbuf *ofputil_encode_table_desc_request(enum ofp_version);
889
5deff5aa 890void ofputil_append_table_features_reply(
ca6ba700 891 const struct ofputil_table_features *tf, struct ovs_list *replies);
5deff5aa 892
03c72922
BP
893void ofputil_append_table_desc_reply(const struct ofputil_table_desc *td,
894 struct ovs_list *replies,
895 enum ofp_version);
896
0445637d 897/* Meter band configuration for all supported band types. */
638a19b0
JR
898struct ofputil_meter_band {
899 uint16_t type;
0445637d 900 uint8_t prec_level; /* Non-zero if type == OFPMBT_DSCP_REMARK. */
638a19b0
JR
901 uint32_t rate;
902 uint32_t burst_size;
903};
904
905struct ofputil_meter_band_stats {
906 uint64_t packet_count;
907 uint64_t byte_count;
908};
909
910struct ofputil_meter_config {
911 uint32_t meter_id;
912 uint16_t flags;
913 uint16_t n_bands;
914 struct ofputil_meter_band *bands;
915};
916
917/* Abstract ofp_meter_mod. */
918struct ofputil_meter_mod {
919 uint16_t command;
920 struct ofputil_meter_config meter;
921};
922
923struct ofputil_meter_stats {
924 uint32_t meter_id;
925 uint32_t flow_count;
926 uint64_t packet_in_count;
927 uint64_t byte_in_count;
928 uint32_t duration_sec;
929 uint32_t duration_nsec;
930 uint16_t n_bands;
0445637d 931 struct ofputil_meter_band_stats *bands;
638a19b0
JR
932};
933
934struct ofputil_meter_features {
0445637d
JR
935 uint32_t max_meters; /* Maximum number of meters. */
936 uint32_t band_types; /* Can support max 32 band types. */
937 uint32_t capabilities; /* Supported flags. */
638a19b0
JR
938 uint8_t max_bands;
939 uint8_t max_color;
940};
941
942enum ofperr ofputil_decode_meter_mod(const struct ofp_header *,
943 struct ofputil_meter_mod *,
0445637d
JR
944 struct ofpbuf *bands);
945struct ofpbuf *ofputil_encode_meter_mod(enum ofp_version,
638a19b0
JR
946 const struct ofputil_meter_mod *);
947
948void ofputil_decode_meter_features(const struct ofp_header *,
949 struct ofputil_meter_features *);
950struct ofpbuf *ofputil_encode_meter_features_reply(const struct
951 ofputil_meter_features *,
952 const struct ofp_header *
953 request);
954void ofputil_decode_meter_request(const struct ofp_header *,
955 uint32_t *meter_id);
956
ca6ba700 957void ofputil_append_meter_config(struct ovs_list *replies,
0445637d 958 const struct ofputil_meter_config *);
638a19b0 959
ca6ba700 960void ofputil_append_meter_stats(struct ovs_list *replies,
0445637d 961 const struct ofputil_meter_stats *);
638a19b0
JR
962
963enum ofputil_meter_request_type {
964 OFPUTIL_METER_FEATURES,
965 OFPUTIL_METER_CONFIG,
966 OFPUTIL_METER_STATS
967};
968
969struct ofpbuf *ofputil_encode_meter_request(enum ofp_version,
970 enum ofputil_meter_request_type,
971 uint32_t meter_id);
972
0445637d
JR
973int ofputil_decode_meter_stats(struct ofpbuf *,
974 struct ofputil_meter_stats *,
638a19b0
JR
975 struct ofpbuf *bands);
976
0445637d
JR
977int ofputil_decode_meter_config(struct ofpbuf *,
978 struct ofputil_meter_config *,
638a19b0
JR
979 struct ofpbuf *bands);
980
0445637d 981/* Type for meter_id in ofproto provider interface, UINT32_MAX if invalid. */
638a19b0
JR
982typedef struct { uint32_t uint32; } ofproto_meter_id;
983
6ea4776b
JR
984/* Abstract ofp_role_request and reply. */
985struct ofputil_role_request {
f4f1ea7e 986 enum ofp12_controller_role role;
6ea4776b 987 bool have_generation_id;
6ea4776b
JR
988 uint64_t generation_id;
989};
990
00467f73
AC
991struct ofputil_role_status {
992 enum ofp12_controller_role role;
993 enum ofp14_controller_role_reason reason;
994 uint64_t generation_id;
995};
996
6ea4776b
JR
997enum ofperr ofputil_decode_role_message(const struct ofp_header *,
998 struct ofputil_role_request *);
999struct ofpbuf *ofputil_encode_role_reply(const struct ofp_header *,
f4f1ea7e 1000 const struct ofputil_role_request *);
6ea4776b 1001
00467f73
AC
1002struct ofpbuf *ofputil_encode_role_status(
1003 const struct ofputil_role_status *status,
1004 enum ofputil_protocol protocol);
1005
1006enum ofperr ofputil_decode_role_status(const struct ofp_header *oh,
1007 struct ofputil_role_status *rs);
08d1e234 1008
3c1bb396
BP
1009/* Abstract table stats.
1010 *
1011 * This corresponds to the OpenFlow 1.3 table statistics structure, which only
1012 * includes actual statistics. In earlier versions of OpenFlow, several
1013 * members describe table features, so this structure has to be paired with
1014 * struct ofputil_table_features to get all information. */
1015struct ofputil_table_stats {
1016 uint8_t table_id; /* Identifier of table. */
08d1e234
BP
1017 uint32_t active_count; /* Number of active entries. */
1018 uint64_t lookup_count; /* Number of packets looked up in table. */
1019 uint64_t matched_count; /* Number of packets that hit table. */
1020};
307975da 1021
3c1bb396 1022struct ofpbuf *ofputil_encode_table_stats_reply(const struct ofp_header *rq);
03c72922
BP
1023
1024struct ofpbuf *ofputil_encode_table_desc_reply(const struct ofp_header *rq);
1025
3c1bb396
BP
1026void ofputil_append_table_stats_reply(struct ofpbuf *reply,
1027 const struct ofputil_table_stats *,
1028 const struct ofputil_table_features *);
1029
1030int ofputil_decode_table_stats_reply(struct ofpbuf *reply,
1031 struct ofputil_table_stats *,
1032 struct ofputil_table_features *);
307975da 1033
e8f9a7bb
VG
1034/* Queue configuration request. */
1035struct ofpbuf *ofputil_encode_queue_get_config_request(enum ofp_version,
e016fb63
BP
1036 ofp_port_t port,
1037 uint32_t queue);
e8f9a7bb 1038enum ofperr ofputil_decode_queue_get_config_request(const struct ofp_header *,
e016fb63
BP
1039 ofp_port_t *port,
1040 uint32_t *queue);
e8f9a7bb
VG
1041
1042/* Queue configuration reply. */
1043struct ofputil_queue_config {
56085be5 1044 ofp_port_t port;
e016fb63 1045 uint32_t queue;
e8f9a7bb
VG
1046
1047 /* Each of these optional values is expressed in tenths of a percent.
1048 * Values greater than 1000 indicate that the feature is disabled.
1049 * UINT16_MAX indicates that the value is omitted. */
1050 uint16_t min_rate;
1051 uint16_t max_rate;
1052};
1053
e016fb63
BP
1054void ofputil_start_queue_get_config_reply(const struct ofp_header *request,
1055 struct ovs_list *replies);
e8f9a7bb 1056void ofputil_append_queue_get_config_reply(
e016fb63 1057 const struct ofputil_queue_config *, struct ovs_list *replies);
e8f9a7bb 1058
e8f9a7bb
VG
1059int ofputil_pull_queue_get_config_reply(struct ofpbuf *reply,
1060 struct ofputil_queue_config *);
1061
1062
2b07c8b1
BP
1063/* Abstract nx_flow_monitor_request. */
1064struct ofputil_flow_monitor_request {
1065 uint32_t id;
1066 enum nx_flow_monitor_flags flags;
4e022ec0 1067 ofp_port_t out_port;
2b07c8b1 1068 uint8_t table_id;
81a76618 1069 struct match match;
2b07c8b1
BP
1070};
1071
1072int ofputil_decode_flow_monitor_request(struct ofputil_flow_monitor_request *,
1073 struct ofpbuf *msg);
1074void ofputil_append_flow_monitor_request(
1075 const struct ofputil_flow_monitor_request *, struct ofpbuf *msg);
1076
1077/* Abstract nx_flow_update. */
1078struct ofputil_flow_update {
1079 enum nx_flow_update_event event;
1080
1081 /* Used only for NXFME_ADDED, NXFME_DELETED, NXFME_MODIFIED. */
1082 enum ofp_flow_removed_reason reason;
1083 uint16_t idle_timeout;
1084 uint16_t hard_timeout;
1085 uint8_t table_id;
e0822031 1086 uint16_t priority;
2b07c8b1 1087 ovs_be64 cookie;
140f36ba 1088 struct match match;
dc723c44 1089 const struct ofpact *ofpacts;
2b07c8b1
BP
1090 size_t ofpacts_len;
1091
1092 /* Used only for NXFME_ABBREV. */
1093 ovs_be32 xid;
1094};
1095
1096int ofputil_decode_flow_update(struct ofputil_flow_update *,
1097 struct ofpbuf *msg, struct ofpbuf *ofpacts);
ca6ba700 1098void ofputil_start_flow_update(struct ovs_list *replies);
2b07c8b1 1099void ofputil_append_flow_update(const struct ofputil_flow_update *,
140f36ba
DDP
1100 struct ovs_list *replies,
1101 const struct tun_table *);
2b07c8b1
BP
1102
1103/* Abstract nx_flow_monitor_cancel. */
1104uint32_t ofputil_decode_flow_monitor_cancel(const struct ofp_header *);
1105struct ofpbuf *ofputil_encode_flow_monitor_cancel(uint32_t id);
1106
70ae4f93
BP
1107/* Port desc stats requests and replies. */
1108enum ofperr ofputil_decode_port_desc_stats_request(const struct ofp_header *,
1109 ofp_port_t *portp);
1110struct ofpbuf *ofputil_encode_port_desc_stats_request(
1111 enum ofp_version ofp_version, ofp_port_t);
1112
e28ac5cf 1113void ofputil_append_port_desc_stats_reply(const struct ofputil_phy_port *pp,
ca6ba700 1114 struct ovs_list *replies);
2be393ed 1115
982697a4 1116/* Encoding simple OpenFlow messages. */
1a126c0c 1117struct ofpbuf *make_echo_request(enum ofp_version);
fa37b408 1118struct ofpbuf *make_echo_reply(const struct ofp_header *rq);
7257b535 1119
a0ae0b6e 1120struct ofpbuf *ofputil_encode_barrier_request(enum ofp_version);
9aee0764
BP
1121\f
1122/* Actions. */
1123
dbba996b 1124bool action_outputs_to_port(const union ofp_action *, ovs_be16 port);
3052b0c5 1125
90bf1e07
BP
1126enum ofperr ofputil_pull_actions(struct ofpbuf *, unsigned int actions_len,
1127 union ofp_action **, size_t *);
18ddadc2
BP
1128
1129bool ofputil_actions_equal(const union ofp_action *a, size_t n_a,
1130 const union ofp_action *b, size_t n_b);
1131union ofp_action *ofputil_actions_clone(const union ofp_action *, size_t n);
26c112c2 1132
0ff22822
BP
1133/* Handy utility for parsing flows and actions. */
1134bool ofputil_parse_key_value(char **stringp, char **keyp, char **valuep);
1135
f8e4867e 1136struct ofputil_port_stats {
4e022ec0 1137 ofp_port_t port_no;
f8e4867e 1138 struct netdev_stats stats;
65e0be10
BP
1139 uint32_t duration_sec; /* UINT32_MAX if unknown. */
1140 uint32_t duration_nsec;
f8e4867e
SH
1141};
1142
1143struct ofpbuf *ofputil_encode_dump_ports_request(enum ofp_version ofp_version,
4e022ec0 1144 ofp_port_t port);
ca6ba700 1145void ofputil_append_port_stat(struct ovs_list *replies,
f8e4867e
SH
1146 const struct ofputil_port_stats *ops);
1147size_t ofputil_count_port_stats(const struct ofp_header *);
1148int ofputil_decode_port_stats(struct ofputil_port_stats *, struct ofpbuf *msg);
1149enum ofperr ofputil_decode_port_stats_request(const struct ofp_header *request,
4e022ec0 1150 ofp_port_t *ofp10_port);
64626975 1151
fb8f22c1
BY
1152struct ofputil_ipfix_stats {
1153 uint32_t collector_set_id; /* Used only for flow-based IPFIX statistics. */
1154 uint64_t total_flows; /* Totabl flows of this IPFIX exporter. */
1155 uint64_t current_flows; /* Current flows of this IPFIX exporter. */
1156 uint64_t pkts; /* Successfully sampled packets. */
1157 uint64_t ipv4_pkts; /* Successfully sampled IPV4 packets. */
1158 uint64_t ipv6_pkts; /* Successfully sampled IPV6 packets. */
1159 uint64_t error_pkts; /* Error packets when sampling. */
1160 uint64_t ipv4_error_pkts; /* Error IPV4 packets when sampling. */
1161 uint64_t ipv6_error_pkts; /* Error IPV6 packets when sampling. */
1162 uint64_t tx_pkts; /* TX IPFIX packets. */
1163 uint64_t tx_errors; /* IPFIX packets TX errors. */
1164};
1165
1166void ofputil_append_ipfix_stat(struct ovs_list *replies,
1167 const struct ofputil_ipfix_stats *ois);
1168size_t ofputil_count_ipfix_stats(const struct ofp_header *);
1169int ofputil_pull_ipfix_stats(struct ofputil_ipfix_stats *, struct ofpbuf *msg);
1170
64626975 1171struct ofputil_queue_stats_request {
4e022ec0 1172 ofp_port_t port_no; /* OFPP_ANY means "all ports". */
64626975
SH
1173 uint32_t queue_id;
1174};
1175
1176enum ofperr
1177ofputil_decode_queue_stats_request(const struct ofp_header *request,
1178 struct ofputil_queue_stats_request *oqsr);
1179struct ofpbuf *
1180ofputil_encode_queue_stats_request(enum ofp_version ofp_version,
1181 const struct ofputil_queue_stats_request *oqsr);
1182
1183struct ofputil_queue_stats {
4e022ec0 1184 ofp_port_t port_no;
64626975 1185 uint32_t queue_id;
6dc34a0d
BP
1186
1187 /* Values of unsupported statistics are set to all-1-bits (UINT64_MAX). */
1188 uint64_t tx_bytes;
1189 uint64_t tx_packets;
1190 uint64_t tx_errors;
1191
1192 /* UINT32_MAX if unknown. */
1193 uint32_t duration_sec;
1194 uint32_t duration_nsec;
64626975
SH
1195};
1196
1197size_t ofputil_count_queue_stats(const struct ofp_header *);
1198int ofputil_decode_queue_stats(struct ofputil_queue_stats *qs, struct ofpbuf *msg);
ca6ba700 1199void ofputil_append_queue_stat(struct ovs_list *replies,
64626975
SH
1200 const struct ofputil_queue_stats *oqs);
1201
1e684d7d
RW
1202struct bucket_counter {
1203 uint64_t packet_count; /* Number of packets processed by bucket. */
1204 uint64_t byte_count; /* Number of bytes processed by bucket. */
1205};
1206
7395c052
NZ
1207/* Bucket for use in groups. */
1208struct ofputil_bucket {
ca6ba700 1209 struct ovs_list list_node;
7395c052
NZ
1210 uint16_t weight; /* Relative weight, for "select" groups. */
1211 ofp_port_t watch_port; /* Port whose state affects whether this bucket
1212 * is live. Only required for fast failover
1213 * groups. */
1214 uint32_t watch_group; /* Group whose state affects whether this
1215 * bucket is live. Only required for fast
1216 * failover groups. */
18ac06d3 1217 uint32_t bucket_id; /* Bucket Id used to identify bucket*/
7395c052
NZ
1218 struct ofpact *ofpacts; /* Series of "struct ofpact"s. */
1219 size_t ofpacts_len; /* Length of ofpacts, in bytes. */
1e684d7d
RW
1220
1221 struct bucket_counter stats;
7395c052
NZ
1222};
1223
bc65c25a
SH
1224/* Protocol-independent group_mod. */
1225struct ofputil_group_props {
1226 /* NTR selection method */
1227 char selection_method[NTR_MAX_SELECTION_METHOD_LEN];
1228 uint64_t selection_method_param;
1229 struct field_array fields;
1230};
1231
7395c052
NZ
1232/* Protocol-independent group_mod. */
1233struct ofputil_group_mod {
18ac06d3 1234 uint16_t command; /* One of OFPGC15_*. */
7395c052
NZ
1235 uint8_t type; /* One of OFPGT11_*. */
1236 uint32_t group_id; /* Group identifier. */
18ac06d3
SH
1237 uint32_t command_bucket_id; /* Bucket Id used as part of
1238 * OFPGC15_INSERT_BUCKET and
1239 * OFPGC15_REMOVE_BUCKET commands
1240 * execution.*/
ca6ba700 1241 struct ovs_list buckets; /* Contains "struct ofputil_bucket"s. */
bc65c25a 1242 struct ofputil_group_props props; /* Group properties. */
7395c052
NZ
1243};
1244
7395c052
NZ
1245/* Group stats reply, independent of protocol. */
1246struct ofputil_group_stats {
1247 uint32_t group_id; /* Group identifier. */
1248 uint32_t ref_count;
1249 uint64_t packet_count; /* Packet count, UINT64_MAX if unknown. */
1250 uint64_t byte_count; /* Byte count, UINT64_MAX if unknown. */
1251 uint32_t duration_sec; /* UINT32_MAX if unknown. */
1252 uint32_t duration_nsec;
1253 uint32_t n_buckets;
646b2a9c 1254 struct bucket_counter *bucket_stats;
7395c052
NZ
1255};
1256
f0e7025f
BP
1257/* Group features reply, independent of protocol.
1258 *
1259 * Only OF1.2 and later support group features replies. */
7395c052
NZ
1260struct ofputil_group_features {
1261 uint32_t types; /* Bitmap of OFPGT_* values supported. */
1262 uint32_t capabilities; /* Bitmap of OFPGFC12_* capability supported. */
1263 uint32_t max_groups[4]; /* Maximum number of groups for each type. */
08d1e234 1264 uint64_t ofpacts[4]; /* Bitmaps of supported OFPACT_* */
7395c052
NZ
1265};
1266
1267/* Group desc reply, independent of protocol. */
1268struct ofputil_group_desc {
1269 uint8_t type; /* One of OFPGT_*. */
1270 uint32_t group_id; /* Group identifier. */
ca6ba700 1271 struct ovs_list buckets; /* Contains "struct ofputil_bucket"s. */
bc65c25a 1272 struct ofputil_group_props props; /* Group properties. */
7395c052
NZ
1273};
1274
e8dba719
JR
1275void ofputil_group_properties_destroy(struct ofputil_group_props *);
1276void ofputil_group_properties_copy(struct ofputil_group_props *to,
1277 const struct ofputil_group_props *from);
ca6ba700
TG
1278void ofputil_bucket_list_destroy(struct ovs_list *buckets);
1279void ofputil_bucket_clone_list(struct ovs_list *dest,
1280 const struct ovs_list *src,
103b4866 1281 const struct ofputil_bucket *);
ca6ba700 1282struct ofputil_bucket *ofputil_bucket_find(const struct ovs_list *,
103b4866 1283 uint32_t bucket_id);
ca6ba700
TG
1284bool ofputil_bucket_check_duplicate_id(const struct ovs_list *);
1285struct ofputil_bucket *ofputil_bucket_list_front(const struct ovs_list *);
1286struct ofputil_bucket *ofputil_bucket_list_back(const struct ovs_list *);
7395c052 1287
e57681e5
SH
1288static inline bool
1289ofputil_bucket_has_liveness(const struct ofputil_bucket *bucket)
1290{
1291 return (bucket->watch_port != OFPP_ANY ||
1292 bucket->watch_group != OFPG_ANY);
1293}
1294
7395c052
NZ
1295struct ofpbuf *ofputil_encode_group_stats_request(enum ofp_version,
1296 uint32_t group_id);
1297enum ofperr ofputil_decode_group_stats_request(
1298 const struct ofp_header *request, uint32_t *group_id);
ca6ba700 1299void ofputil_append_group_stats(struct ovs_list *replies,
7395c052
NZ
1300 const struct ofputil_group_stats *);
1301struct ofpbuf *ofputil_encode_group_features_request(enum ofp_version);
1302struct ofpbuf *ofputil_encode_group_features_reply(
1303 const struct ofputil_group_features *, const struct ofp_header *request);
1304void ofputil_decode_group_features_reply(const struct ofp_header *,
1305 struct ofputil_group_features *);
bc65c25a 1306void ofputil_uninit_group_mod(struct ofputil_group_mod *gm);
7395c052
NZ
1307struct ofpbuf *ofputil_encode_group_mod(enum ofp_version ofp_version,
1308 const struct ofputil_group_mod *gm);
1309
1310enum ofperr ofputil_decode_group_mod(const struct ofp_header *,
1311 struct ofputil_group_mod *);
1312
1313int ofputil_decode_group_stats_reply(struct ofpbuf *,
1314 struct ofputil_group_stats *);
1315
bc65c25a 1316void ofputil_uninit_group_desc(struct ofputil_group_desc *gd);
19187a71
BP
1317uint32_t ofputil_decode_group_desc_request(const struct ofp_header *);
1318struct ofpbuf *ofputil_encode_group_desc_request(enum ofp_version,
1319 uint32_t group_id);
1320
7395c052 1321int ofputil_decode_group_desc_reply(struct ofputil_group_desc *,
a7a2d006 1322 struct ofpbuf *, enum ofp_version);
7395c052
NZ
1323
1324void ofputil_append_group_desc_reply(const struct ofputil_group_desc *,
1667bb34 1325 const struct ovs_list *buckets,
ca6ba700 1326 struct ovs_list *replies);
7395c052 1327
777af88d
AC
1328struct ofputil_bundle_ctrl_msg {
1329 uint32_t bundle_id;
1330 uint16_t type;
1331 uint16_t flags;
1332};
1333
1334struct ofputil_bundle_add_msg {
1335 uint32_t bundle_id;
1336 uint16_t flags;
1337 const struct ofp_header *msg;
1338};
1339
1340enum ofperr ofputil_decode_bundle_ctrl(const struct ofp_header *,
1341 struct ofputil_bundle_ctrl_msg *);
1342
db5076ee
JR
1343struct ofpbuf *ofputil_encode_bundle_ctrl_request(enum ofp_version,
1344 struct ofputil_bundle_ctrl_msg *);
777af88d
AC
1345struct ofpbuf *ofputil_encode_bundle_ctrl_reply(const struct ofp_header *,
1346 struct ofputil_bundle_ctrl_msg *);
1347
1348struct ofpbuf *ofputil_encode_bundle_add(enum ofp_version ofp_version,
1349 struct ofputil_bundle_add_msg *msg);
1350
1351enum ofperr ofputil_decode_bundle_add(const struct ofp_header *,
7ac27a04
JR
1352 struct ofputil_bundle_add_msg *,
1353 enum ofptype *type);
6159c531 1354
6dd3c787 1355/* Bundle message as produced by ofp-parse. */
25070e04
JR
1356struct ofputil_bundle_msg {
1357 enum ofptype type;
1358 union {
1359 struct ofputil_flow_mod fm;
1360 struct ofputil_group_mod gm;
6dd3c787 1361 struct ofputil_packet_out po;
25070e04
JR
1362 };
1363};
1364
6dd3c787
JR
1365void ofputil_encode_bundle_msgs(const struct ofputil_bundle_msg *bms,
1366 size_t n_bms, struct ovs_list *requests,
25070e04 1367 enum ofputil_protocol);
6dd3c787 1368void ofputil_free_bundle_msgs(struct ofputil_bundle_msg *bms, size_t n_bms);
25070e04 1369
4e548ad9 1370struct ofputil_tlv_map {
6159c531
JG
1371 struct ovs_list list_node;
1372
1373 uint16_t option_class;
1374 uint8_t option_type;
1375 uint8_t option_len;
1376 uint16_t index;
1377};
1378
4e548ad9 1379struct ofputil_tlv_table_mod {
6159c531 1380 uint16_t command;
4e548ad9 1381 struct ovs_list mappings; /* Contains "struct ofputil_tlv_map"s. */
6159c531
JG
1382};
1383
4e548ad9 1384struct ofputil_tlv_table_reply {
6159c531
JG
1385 uint32_t max_option_space;
1386 uint16_t max_fields;
4e548ad9 1387 struct ovs_list mappings; /* Contains "struct ofputil_tlv_map"s. */
6159c531
JG
1388};
1389
4e548ad9
ML
1390struct ofpbuf *ofputil_encode_tlv_table_mod(enum ofp_version ofp_version,
1391 struct ofputil_tlv_table_mod *);
1392enum ofperr ofputil_decode_tlv_table_mod(const struct ofp_header *,
1393 struct ofputil_tlv_table_mod *);
1394struct ofpbuf *ofputil_encode_tlv_table_reply(const struct ofp_header *,
1395 struct ofputil_tlv_table_reply *);
1396enum ofperr ofputil_decode_tlv_table_reply(const struct ofp_header *,
1397 struct ofputil_tlv_table_reply *);
1398void ofputil_uninit_tlv_table(struct ovs_list *mappings);
6159c531 1399
98090482 1400enum ofputil_async_msg_type {
af7bc161 1401 /* Standard asynchronous messages. */
98090482
NR
1402 OAM_PACKET_IN, /* OFPT_PACKET_IN or NXT_PACKET_IN. */
1403 OAM_PORT_STATUS, /* OFPT_PORT_STATUS. */
0b9af7cb 1404 OAM_FLOW_REMOVED, /* OFPT_FLOW_REMOVED or NXT_FLOW_REMOVED. */
98090482
NR
1405 OAM_ROLE_STATUS, /* OFPT_ROLE_STATUS. */
1406 OAM_TABLE_STATUS, /* OFPT_TABLE_STATUS. */
1407 OAM_REQUESTFORWARD, /* OFPT_REQUESTFORWARD. */
af7bc161
BP
1408
1409 /* Extension asynchronous messages (none yet--coming soon!). */
1410#define OAM_EXTENSIONS 0 /* Bitmap of all extensions. */
1411
98090482
NR
1412 OAM_N_TYPES
1413};
2da7974c 1414const char *ofputil_async_msg_type_to_string(enum ofputil_async_msg_type);
98090482 1415
a930d4c5
BP
1416struct ofputil_async_cfg {
1417 uint32_t master[OAM_N_TYPES];
1418 uint32_t slave[OAM_N_TYPES];
1419};
1420#define OFPUTIL_ASYNC_CFG_INIT (struct ofputil_async_cfg) { .master[0] = 0 }
1421
98090482 1422enum ofperr ofputil_decode_set_async_config(const struct ofp_header *,
a930d4c5 1423 bool loose,
5876b4db 1424 const struct ofputil_async_cfg *,
a930d4c5
BP
1425 struct ofputil_async_cfg *);
1426
af7bc161 1427struct ofpbuf *ofputil_encode_get_async_reply(
a930d4c5 1428 const struct ofp_header *, const struct ofputil_async_cfg *);
af7bc161
BP
1429struct ofpbuf *ofputil_encode_set_async_config(
1430 const struct ofputil_async_cfg *, uint32_t oams, enum ofp_version);
98090482 1431
a930d4c5 1432struct ofputil_async_cfg ofputil_async_cfg_default(enum ofp_version);
98090482 1433
3c35db62
NR
1434struct ofputil_requestforward {
1435 ovs_be32 xid;
1436 enum ofp14_requestforward_reason reason;
1437 union {
1438 /* reason == OFPRFR_METER_MOD. */
3c35db62 1439 struct {
eaa0e88b 1440 struct ofputil_meter_mod *meter_mod;
3c35db62
NR
1441 struct ofpbuf bands;
1442 };
eaa0e88b
BP
1443
1444 /* reason == OFPRFR_GROUP_MOD. */
1445 struct ofputil_group_mod *group_mod;
3c35db62
NR
1446 };
1447};
1448
1449struct ofpbuf *ofputil_encode_requestforward(
1450 const struct ofputil_requestforward *, enum ofputil_protocol);
1451enum ofperr ofputil_decode_requestforward(const struct ofp_header *,
1452 struct ofputil_requestforward *);
1453void ofputil_destroy_requestforward(struct ofputil_requestforward *);
1454
6c6eedc5
SJ
1455/* Abstract ofp14_table_status. */
1456struct ofputil_table_status {
1457 enum ofp14_table_reason reason; /* One of OFPTR_*. */
1458 struct ofputil_table_desc desc; /* New table config. */
1459};
1460
1461enum ofperr ofputil_decode_table_status(const struct ofp_header *oh,
1462 struct ofputil_table_status *ts);
1463
1464struct ofpbuf *
1465ofputil_encode_table_status(const struct ofputil_table_status *ts,
1466 enum ofputil_protocol protocol);
fa37b408 1467#endif /* ofp-util.h */