]> git.proxmox.com Git - ovs.git/blame - lib/ofp-actions.h
User-Space MPLS actions and matches
[ovs.git] / lib / ofp-actions.h
CommitLineData
f25d0cf3 1/*
b02475c5 2 * Copyright (c) 2012, 2013 Nicira, Inc.
f25d0cf3
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#ifndef OFP_ACTIONS_H
18#define OFP_ACTIONS_H 1
19
20#include <stdint.h>
21#include "meta-flow.h"
22#include "ofp-errors.h"
23#include "ofp-util.h"
24#include "openflow/openflow.h"
25#include "openflow/nicira-ext.h"
26#include "openvswitch/types.h"
27
28/* List of OVS abstracted actions.
29 *
30 * This macro is used directly only internally by this header, but the list is
31 * still of interest to developers.
32 *
33 * Each DEFINE_OFPACT invocation has the following parameters:
34 *
35 * 1. <ENUM>, used below in the enum definition of OFPACT_<ENUM>, and
36 * elsewhere.
37 *
38 * 2. <STRUCT> corresponding to a structure "struct <STRUCT>", that must be
39 * defined below. This structure must be an abstract definition of the
40 * action. Its first member must have type "struct ofpact" and name
41 * "ofpact". It may be fixed length or end with a flexible array member
42 * (e.g. "int member[];").
43 *
44 * 3. <MEMBER>, which has one of two possible values:
45 *
46 * - If "struct <STRUCT>" is fixed-length, it must be "ofpact".
47 *
48 * - If "struct <STRUCT>" is variable-length, it must be the name of the
49 * flexible array member.
50 */
51#define OFPACTS \
52 /* Output. */ \
53 DEFINE_OFPACT(OUTPUT, ofpact_output, ofpact) \
54 DEFINE_OFPACT(CONTROLLER, ofpact_controller, ofpact) \
55 DEFINE_OFPACT(ENQUEUE, ofpact_enqueue, ofpact) \
56 DEFINE_OFPACT(OUTPUT_REG, ofpact_output_reg, ofpact) \
57 DEFINE_OFPACT(BUNDLE, ofpact_bundle, slaves) \
58 \
59 /* Header changes. */ \
60 DEFINE_OFPACT(SET_VLAN_VID, ofpact_vlan_vid, ofpact) \
61 DEFINE_OFPACT(SET_VLAN_PCP, ofpact_vlan_pcp, ofpact) \
62 DEFINE_OFPACT(STRIP_VLAN, ofpact_null, ofpact) \
3e34fbdd 63 DEFINE_OFPACT(PUSH_VLAN, ofpact_null, ofpact) \
f25d0cf3
BP
64 DEFINE_OFPACT(SET_ETH_SRC, ofpact_mac, ofpact) \
65 DEFINE_OFPACT(SET_ETH_DST, ofpact_mac, ofpact) \
66 DEFINE_OFPACT(SET_IPV4_SRC, ofpact_ipv4, ofpact) \
67 DEFINE_OFPACT(SET_IPV4_DST, ofpact_ipv4, ofpact) \
68 DEFINE_OFPACT(SET_IPV4_DSCP, ofpact_dscp, ofpact) \
69 DEFINE_OFPACT(SET_L4_SRC_PORT, ofpact_l4_port, ofpact) \
70 DEFINE_OFPACT(SET_L4_DST_PORT, ofpact_l4_port, ofpact) \
71 DEFINE_OFPACT(REG_MOVE, ofpact_reg_move, ofpact) \
72 DEFINE_OFPACT(REG_LOAD, ofpact_reg_load, ofpact) \
c2d967a5 73 DEFINE_OFPACT(DEC_TTL, ofpact_cnt_ids, cnt_ids) \
b02475c5
SH
74 DEFINE_OFPACT(PUSH_MPLS, ofpact_push_mpls, ofpact) \
75 DEFINE_OFPACT(POP_MPLS, ofpact_pop_mpls, ofpact) \
f25d0cf3
BP
76 \
77 /* Metadata. */ \
78 DEFINE_OFPACT(SET_TUNNEL, ofpact_tunnel, ofpact) \
79 DEFINE_OFPACT(SET_QUEUE, ofpact_queue, ofpact) \
80 DEFINE_OFPACT(POP_QUEUE, ofpact_null, ofpact) \
81 DEFINE_OFPACT(FIN_TIMEOUT, ofpact_fin_timeout, ofpact) \
82 \
83 /* Flow table interaction. */ \
84 DEFINE_OFPACT(RESUBMIT, ofpact_resubmit, ofpact) \
85 DEFINE_OFPACT(LEARN, ofpact_learn, specs) \
86 \
87 /* Arithmetic. */ \
88 DEFINE_OFPACT(MULTIPATH, ofpact_multipath, ofpact) \
89 DEFINE_OFPACT(AUTOPATH, ofpact_autopath, ofpact) \
90 \
91 /* Other. */ \
92 DEFINE_OFPACT(NOTE, ofpact_note, data) \
8dd54666
IY
93 DEFINE_OFPACT(EXIT, ofpact_null, ofpact) \
94 \
95 /* Instructions */ \
5dca28b5 96 /* XXX Write-Actions */ \
4cceacb9 97 DEFINE_OFPACT(WRITE_METADATA, ofpact_metadata, ofpact) \
b19e8793 98 DEFINE_OFPACT(CLEAR_ACTIONS, ofpact_null, ofpact) \
8dd54666 99 DEFINE_OFPACT(GOTO_TABLE, ofpact_goto_table, ofpact)
f25d0cf3
BP
100
101/* enum ofpact_type, with a member OFPACT_<ENUM> for each action. */
102enum OVS_PACKED_ENUM ofpact_type {
103#define DEFINE_OFPACT(ENUM, STRUCT, MEMBER) OFPACT_##ENUM,
104 OFPACTS
105#undef DEFINE_OFPACT
106};
107
108/* N_OFPACTS, the number of values of "enum ofpact_type". */
109enum {
110 N_OFPACTS =
111#define DEFINE_OFPACT(ENUM, STRUCT, MEMBER) + 1
112 OFPACTS
113#undef DEFINE_OFPACT
114};
115
116/* Header for an action.
117 *
118 * Each action is a structure "struct ofpact_*" that begins with "struct
119 * ofpact", usually followed by other data that describes the action. Actions
2ac3c572
BP
120 * are padded out to a multiple of OFPACT_ALIGNTO bytes in length.
121 *
122 * The 'compat' member is special:
123 *
124 * - Most "struct ofpact"s correspond to one particular kind of OpenFlow
125 * action, at least in a given OpenFlow version. For example,
126 * OFPACT_SET_VLAN_VID corresponds to OFPAT10_SET_VLAN_VID in OpenFlow
127 * 1.0.
128 *
129 * For such actions, the 'compat' member is not meaningful and generally
130 * should be zero.
131 *
132 * - A few "struct ofpact"s correspond to multiple OpenFlow actions. For
133 * example, OFPACT_SET_TUNNEL can be NXAST_SET_TUNNEL or
134 * NXAST_SET_TUNNEL64. In these cases, if the "struct ofpact" originated
135 * from OpenFlow, then we want to make sure that, if it gets translated
136 * back to OpenFlow later, it is translated back to the same action type.
137 * (Otherwise, we'd violate the promise made in DESIGN, in the "Action
138 * Reproduction" section.)
139 *
140 * For such actions, the 'compat' member should be the original action
141 * type. (If the action didn't originate from OpenFlow, then setting
142 * 'compat' to zero should be fine: code to translate the ofpact to
143 * OpenFlow must tolerate this case.)
144 */
f25d0cf3
BP
145struct ofpact {
146 enum ofpact_type type; /* OFPACT_*. */
147 enum ofputil_action_code compat; /* Original type when added, if any. */
148 uint16_t len; /* Length of the action, in bytes, including
149 * struct ofpact, excluding padding. */
150};
151
152#ifdef __GNUC__
153/* Make sure that OVS_PACKED_ENUM really worked. */
154BUILD_ASSERT_DECL(sizeof(struct ofpact) == 4);
155#endif
156
157/* Alignment. */
158#define OFPACT_ALIGNTO 8
159#define OFPACT_ALIGN(SIZE) ROUND_UP(SIZE, OFPACT_ALIGNTO)
160
161static inline struct ofpact *
162ofpact_next(const struct ofpact *ofpact)
163{
164 return (void *) ((uint8_t *) ofpact + OFPACT_ALIGN(ofpact->len));
165}
166
167static inline struct ofpact *
168ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len)
169{
170 return (void *) ((uint8_t *) ofpacts + ofpacts_len);
171}
172
173/* Assigns POS to each ofpact, in turn, in the OFPACTS_LEN bytes of ofpacts
174 * starting at OFPACTS. */
175#define OFPACT_FOR_EACH(POS, OFPACTS, OFPACTS_LEN) \
176 for ((POS) = (OFPACTS); (POS) < ofpact_end(OFPACTS, OFPACTS_LEN); \
177 (POS) = ofpact_next(POS))
178\f
179/* Action structure for each OFPACT_*. */
180
b19e8793 181/* OFPACT_STRIP_VLAN, OFPACT_POP_QUEUE, OFPACT_EXIT, OFPACT_CLEAR_ACTIONS.
f25d0cf3 182 *
7bcb1506 183 * Used for OFPAT10_STRIP_VLAN, NXAST_POP_QUEUE, NXAST_EXIT,
8e61c110 184 * OFPAT11_POP_VLAN, OFPIT11_CLEAR_ACTIONS.
f25d0cf3
BP
185 *
186 * Action structure for actions that do not have any extra data beyond the
187 * action type. */
188struct ofpact_null {
189 struct ofpact ofpact;
190};
191
192/* OFPACT_OUTPUT.
193 *
194 * Used for OFPAT10_OUTPUT. */
195struct ofpact_output {
196 struct ofpact ofpact;
197 uint16_t port; /* Output port. */
198 uint16_t max_len; /* Max send len, for port OFPP_CONTROLLER. */
199};
200
201/* OFPACT_CONTROLLER.
202 *
203 * Used for NXAST_CONTROLLER. */
204struct ofpact_controller {
205 struct ofpact ofpact;
206 uint16_t max_len; /* Maximum length to send to controller. */
207 uint16_t controller_id; /* Controller ID to send packet-in. */
208 enum ofp_packet_in_reason reason; /* Reason to put in packet-in. */
209};
210
211/* OFPACT_ENQUEUE.
212 *
213 * Used for OFPAT10_ENQUEUE. */
214struct ofpact_enqueue {
215 struct ofpact ofpact;
216 uint16_t port;
217 uint32_t queue;
218};
219
220/* OFPACT_OUTPUT_REG.
221 *
222 * Used for NXAST_OUTPUT_REG. */
223struct ofpact_output_reg {
224 struct ofpact ofpact;
225 struct mf_subfield src;
226 uint16_t max_len;
227};
228
229/* OFPACT_BUNDLE.
230 *
231 * Used for NXAST_BUNDLE. */
232struct ofpact_bundle {
233 struct ofpact ofpact;
234
235 /* Slave choice algorithm to apply to hash value. */
236 enum nx_bd_algorithm algorithm;
237
238 /* What fields to hash and how. */
239 enum nx_hash_fields fields;
240 uint16_t basis; /* Universal hash parameter. */
241
242 struct mf_subfield dst;
243
244 /* Slaves for output. */
245 unsigned int n_slaves;
246 uint16_t slaves[];
247};
248
249/* OFPACT_SET_VLAN_VID.
250 *
251 * Used for OFPAT10_SET_VLAN_VID. */
252struct ofpact_vlan_vid {
253 struct ofpact ofpact;
254 uint16_t vlan_vid; /* VLAN VID in low 12 bits, 0 in other bits. */
255};
256
257/* OFPACT_SET_VLAN_PCP.
258 *
259 * Used for OFPAT10_SET_VLAN_PCP. */
260struct ofpact_vlan_pcp {
261 struct ofpact ofpact;
262 uint8_t vlan_pcp; /* VLAN PCP in low 3 bits, 0 in other bits. */
263};
264
265/* OFPACT_SET_ETH_SRC, OFPACT_SET_ETH_DST.
266 *
267 * Used for OFPAT10_SET_DL_SRC, OFPAT10_SET_DL_DST. */
268struct ofpact_mac {
269 struct ofpact ofpact;
270 uint8_t mac[ETH_ADDR_LEN];
271};
272
273/* OFPACT_SET_IPV4_SRC, OFPACT_SET_IPV4_DST.
274 *
275 * Used for OFPAT10_SET_NW_SRC, OFPAT10_SET_NW_DST. */
276struct ofpact_ipv4 {
277 struct ofpact ofpact;
278 ovs_be32 ipv4;
279};
280
281/* OFPACT_SET_IPV4_DSCP.
282 *
283 * Used for OFPAT10_SET_NW_TOS. */
284struct ofpact_dscp {
285 struct ofpact ofpact;
286 uint8_t dscp; /* DSCP in high 6 bits, rest ignored. */
287};
288
289/* OFPACT_SET_L4_SRC_PORT, OFPACT_SET_L4_DST_PORT.
290 *
291 * Used for OFPAT10_SET_TP_SRC, OFPAT10_SET_TP_DST. */
292struct ofpact_l4_port {
293 struct ofpact ofpact;
294 uint16_t port; /* TCP or UDP port number. */
295};
296
297/* OFPACT_REG_MOVE.
298 *
299 * Used for NXAST_REG_MOVE. */
300struct ofpact_reg_move {
301 struct ofpact ofpact;
302 struct mf_subfield src;
303 struct mf_subfield dst;
304};
305
306/* OFPACT_REG_LOAD.
307 *
9bab681f 308 * Used for NXAST_REG_LOAD, OFPAT12_SET_FIELD. */
f25d0cf3
BP
309struct ofpact_reg_load {
310 struct ofpact ofpact;
311 struct mf_subfield dst;
158edc8d 312 union mf_subvalue subvalue; /* Least-significant bits are used. */
f25d0cf3
BP
313};
314
b02475c5
SH
315/* OFPACT_PUSH_VLAN/MPLS/PBB
316 *
317 * Used for NXAST_PUSH_MPLS, OFPAT11_PUSH_MPLS. */
318struct ofpact_push_mpls {
319 struct ofpact ofpact;
320 ovs_be16 ethertype;
321};
322
323/* OFPACT_POP_MPLS
324 *
325 * Used for NXAST_POP_MPLS, OFPAT11_POP_MPLS.. */
326struct ofpact_pop_mpls {
327 struct ofpact ofpact;
328 ovs_be16 ethertype;
329};
330
f25d0cf3
BP
331/* OFPACT_SET_TUNNEL.
332 *
333 * Used for NXAST_SET_TUNNEL, NXAST_SET_TUNNEL64. */
334struct ofpact_tunnel {
335 struct ofpact ofpact;
336 uint64_t tun_id;
337};
338
339/* OFPACT_SET_QUEUE.
340 *
341 * Used for NXAST_SET_QUEUE. */
342struct ofpact_queue {
343 struct ofpact ofpact;
344 uint32_t queue_id;
345};
346
347/* OFPACT_FIN_TIMEOUT.
348 *
349 * Used for NXAST_FIN_TIMEOUT. */
350struct ofpact_fin_timeout {
351 struct ofpact ofpact;
352 uint16_t fin_idle_timeout;
353 uint16_t fin_hard_timeout;
354};
355
4cceacb9
JS
356/* OFPACT_WRITE_METADATA.
357 *
358 * Used for NXAST_WRITE_METADATA. */
359struct ofpact_metadata {
360 struct ofpact ofpact;
361 ovs_be64 metadata;
362 ovs_be64 mask;
363};
364
f25d0cf3
BP
365/* OFPACT_RESUBMIT.
366 *
367 * Used for NXAST_RESUBMIT, NXAST_RESUBMIT_TABLE. */
368struct ofpact_resubmit {
369 struct ofpact ofpact;
370 uint16_t in_port;
371 uint8_t table_id;
372};
373
374/* Part of struct ofpact_learn, below. */
375struct ofpact_learn_spec {
376 int n_bits;
377
378 int src_type;
379 struct mf_subfield src;
380 union mf_subvalue src_imm;
381
382 int dst_type;
383 struct mf_subfield dst;
384};
385
386/* OFPACT_LEARN.
387 *
388 * Used for NXAST_LEARN. */
389struct ofpact_learn {
390 struct ofpact ofpact;
391
392 uint16_t idle_timeout; /* Idle time before discarding (seconds). */
393 uint16_t hard_timeout; /* Max time before discarding (seconds). */
394 uint16_t priority; /* Priority level of flow entry. */
395 uint64_t cookie; /* Cookie for new flow. */
396 uint16_t flags; /* Either 0 or OFPFF_SEND_FLOW_REM. */
397 uint8_t table_id; /* Table to insert flow entry. */
398 uint16_t fin_idle_timeout; /* Idle timeout after FIN, if nonzero. */
399 uint16_t fin_hard_timeout; /* Hard timeout after FIN, if nonzero. */
400
401 unsigned int n_specs;
402 struct ofpact_learn_spec specs[];
403};
404
405/* OFPACT_MULTIPATH.
406 *
407 * Used for NXAST_MULTIPATH. */
408struct ofpact_multipath {
409 struct ofpact ofpact;
410
411 /* What fields to hash and how. */
412 enum nx_hash_fields fields;
413 uint16_t basis; /* Universal hash parameter. */
414
415 /* Multipath link choice algorithm to apply to hash value. */
416 enum nx_mp_algorithm algorithm;
417 uint16_t max_link; /* Number of output links, minus 1. */
418 uint32_t arg; /* Algorithm-specific argument. */
419
420 /* Where to store the result. */
421 struct mf_subfield dst;
422};
423
424/* OFPACT_AUTOPATH.
425 *
426 * Used for NXAST_AUTOPATH. */
427struct ofpact_autopath {
428 struct ofpact ofpact;
429 struct mf_subfield dst;
430 uint32_t port;
431};
432
433/* OFPACT_NOTE.
434 *
435 * Used for NXAST_NOTE. */
436struct ofpact_note {
437 struct ofpact ofpact;
438 size_t length;
439 uint8_t data[];
440};
441
c2d967a5
MM
442/* OFPACT_DEC_TTL.
443 *
7bcb1506 444 * Used for OFPAT11_DEC_NW_TTL, NXAST_DEC_TTL and NXAST_DEC_TTL_CNT_IDS. */
c2d967a5
MM
445struct ofpact_cnt_ids {
446 struct ofpact ofpact;
447
448 /* Controller ids. */
449 unsigned int n_controllers;
450 uint16_t cnt_ids[];
8dd54666 451};
c2d967a5 452
8dd54666
IY
453/* OFPACT_GOTO_TABLE
454 *
455 * Used for OFPIT11_GOTO_TABLE */
456struct ofpact_goto_table {
457 struct ofpact ofpact;
458 uint8_t table_id;
c2d967a5
MM
459};
460
f25d0cf3 461/* Converting OpenFlow to ofpacts. */
d01c980f
BP
462enum ofperr ofpacts_pull_openflow10(struct ofpbuf *openflow,
463 unsigned int actions_len,
464 struct ofpbuf *ofpacts);
465enum ofperr ofpacts_pull_openflow11_actions(struct ofpbuf *openflow,
466 unsigned int actions_len,
467 struct ofpbuf *ofpacts);
468enum ofperr ofpacts_pull_openflow11_instructions(struct ofpbuf *openflow,
469 unsigned int instructions_len,
470 struct ofpbuf *ofpacts);
f25d0cf3
BP
471enum ofperr ofpacts_check(const struct ofpact[], size_t ofpacts_len,
472 const struct flow *, int max_ports);
4cceacb9 473enum ofperr ofpacts_verify(const struct ofpact ofpacts[], size_t ofpacts_len);
f25d0cf3
BP
474
475/* Converting ofpacts to OpenFlow. */
d01c980f
BP
476void ofpacts_put_openflow10(const struct ofpact[], size_t ofpacts_len,
477 struct ofpbuf *openflow);
a07c15bc
SH
478size_t ofpacts_put_openflow11_actions(const struct ofpact[], size_t ofpacts_len,
479 struct ofpbuf *openflow);
d01c980f
BP
480void ofpacts_put_openflow11_instructions(const struct ofpact[],
481 size_t ofpacts_len,
482 struct ofpbuf *openflow);
f25d0cf3
BP
483
484/* Working with ofpacts. */
485bool ofpacts_output_to_port(const struct ofpact[], size_t ofpacts_len,
486 uint16_t port);
487bool ofpacts_equal(const struct ofpact a[], size_t a_len,
488 const struct ofpact b[], size_t b_len);
489
490/* Formatting ofpacts.
491 *
492 * (For parsing ofpacts, see ofp-parse.h.) */
493void ofpacts_format(const struct ofpact[], size_t ofpacts_len, struct ds *);
494
495/* Internal use by the helpers below. */
496void ofpact_init(struct ofpact *, enum ofpact_type, size_t len);
497void *ofpact_put(struct ofpbuf *, enum ofpact_type, size_t len);
498
499/* For each OFPACT_<ENUM> with a corresponding struct <STRUCT>, this defines
500 * the following commonly useful functions:
501 *
502 * struct <STRUCT> *ofpact_put_<ENUM>(struct ofpbuf *ofpacts);
503 *
504 * Appends a new 'ofpact', of length OFPACT_<ENUM>_RAW_SIZE, to 'ofpacts',
505 * initializes it with ofpact_init_<ENUM>(), and returns it. Also sets
506 * 'ofpacts->l2' to the returned action.
507 *
508 * After using this function to add a variable-length action, add the
509 * elements of the flexible array (e.g. with ofpbuf_put()), then use
510 * ofpact_update_len() to update the length embedded into the action.
511 * (Keep in mind the need to refresh the structure from 'ofpacts->l2' after
512 * adding data to 'ofpacts'.)
513 *
514 * struct <STRUCT> *ofpact_get_<ENUM>(const struct ofpact *ofpact);
515 *
516 * Returns 'ofpact' cast to "struct <STRUCT> *". 'ofpact->type' must be
517 * OFPACT_<ENUM>.
518 *
519 * as well as the following more rarely useful definitions:
520 *
521 * void ofpact_init_<ENUM>(struct <STRUCT> *ofpact);
522 *
523 * Initializes the parts of 'ofpact' that identify it as having type
524 * OFPACT_<ENUM> and length OFPACT_<ENUM>_RAW_SIZE and zeros the rest.
525 *
526 * <ENUM>_RAW_SIZE
527 *
528 * The size of the action structure. For a fixed-length action, this is
529 * sizeof(struct <STRUCT>). For a variable-length action, this is the
530 * offset to the variable-length part.
531 *
532 * <ENUM>_SIZE
533 *
534 * An integer constant, the value of OFPACT_<ENUM>_RAW_SIZE rounded up to a
535 * multiple of OFPACT_ALIGNTO.
536 */
537#define DEFINE_OFPACT(ENUM, STRUCT, MEMBER) \
538 BUILD_ASSERT_DECL(offsetof(struct STRUCT, ofpact) == 0); \
539 \
540 enum { OFPACT_##ENUM##_RAW_SIZE \
541 = (offsetof(struct STRUCT, MEMBER) \
542 ? offsetof(struct STRUCT, MEMBER) \
543 : sizeof(struct STRUCT)) }; \
544 \
545 enum { OFPACT_##ENUM##_SIZE \
546 = ROUND_UP(OFPACT_##ENUM##_RAW_SIZE, OFPACT_ALIGNTO) }; \
547 \
548 static inline struct STRUCT * \
549 ofpact_get_##ENUM(const struct ofpact *ofpact) \
550 { \
cb22974d 551 ovs_assert(ofpact->type == OFPACT_##ENUM); \
f25d0cf3
BP
552 return (struct STRUCT *) ofpact; \
553 } \
554 \
555 static inline struct STRUCT * \
556 ofpact_put_##ENUM(struct ofpbuf *ofpacts) \
557 { \
558 return ofpact_put(ofpacts, OFPACT_##ENUM, \
559 OFPACT_##ENUM##_RAW_SIZE); \
560 } \
561 \
562 static inline void \
563 ofpact_init_##ENUM(struct STRUCT *ofpact) \
564 { \
565 ofpact_init(&ofpact->ofpact, OFPACT_##ENUM, \
566 OFPACT_##ENUM##_RAW_SIZE); \
567 }
568OFPACTS
569#undef DEFINE_OFPACT
570
571/* Functions to use after adding ofpacts to a buffer. */
572void ofpact_update_len(struct ofpbuf *, struct ofpact *);
573void ofpact_pad(struct ofpbuf *);
574
99c476dc
IY
575/* OpenFlow 1.1 instructions.
576 * The order is sorted in execution order. Not in the value of OFPIT11_xxx.
577 * It is enforced on parser from text string.
578 */
a64f0b0f 579#define OVS_INSTRUCTIONS \
99c476dc
IY
580 DEFINE_INST(OFPIT11_APPLY_ACTIONS, \
581 ofp11_instruction_actions, true, \
582 "apply_actions") \
a64f0b0f 583 \
99c476dc
IY
584 DEFINE_INST(OFPIT11_CLEAR_ACTIONS, \
585 ofp11_instruction, false, \
586 "clear_actions") \
a64f0b0f
IY
587 \
588 DEFINE_INST(OFPIT11_WRITE_ACTIONS, \
589 ofp11_instruction_actions, true, \
590 "write_actions") \
591 \
99c476dc
IY
592 DEFINE_INST(OFPIT11_WRITE_METADATA, \
593 ofp11_instruction_write_metadata, false, \
594 "write_metadata") \
a64f0b0f 595 \
99c476dc
IY
596 DEFINE_INST(OFPIT11_GOTO_TABLE, \
597 ofp11_instruction_goto_table, false, \
598 "goto_table")
a64f0b0f
IY
599
600enum ovs_instruction_type {
601#define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) OVSINST_##ENUM,
602 OVS_INSTRUCTIONS
603#undef DEFINE_INST
604};
605
606enum {
607#define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
608 N_OVS_INSTRUCTIONS = OVS_INSTRUCTIONS
609#undef DEFINE_INST
610};
611
8dd54666
IY
612
613static inline bool
614ofpact_is_instruction(const struct ofpact *a)
615{
5dca28b5 616 /* XXX Write-Actions */
b19e8793 617 return a->type == OFPACT_CLEAR_ACTIONS
4cceacb9 618 || a->type == OFPACT_WRITE_METADATA
b19e8793 619 || a->type == OFPACT_GOTO_TABLE;
8dd54666
IY
620}
621
a359d5ad
IY
622const char *ofpact_instruction_name_from_type(enum ovs_instruction_type type);
623int ofpact_instruction_type_from_name(const char *name);
624
f5c45121
SH
625void ofpact_set_field_init(struct ofpact_reg_load *load,
626 const struct mf_field *mf, const void *src);
627
f25d0cf3 628#endif /* ofp-actions.h */