2 * Copyright (c) 2012, 2013 Nicira, Inc.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #define OFP_ACTIONS_H 1
22 #include "meta-flow.h"
23 #include "ofp-errors.h"
25 #include "openflow/openflow.h"
26 #include "openflow/nicira-ext.h"
27 #include "openvswitch/types.h"
29 /* List of OVS abstracted actions.
31 * This macro is used directly only internally by this header, but the list is
32 * still of interest to developers.
34 * Each DEFINE_OFPACT invocation has the following parameters:
36 * 1. <ENUM>, used below in the enum definition of OFPACT_<ENUM>, and
39 * 2. <STRUCT> corresponding to a structure "struct <STRUCT>", that must be
40 * defined below. This structure must be an abstract definition of the
41 * action. Its first member must have type "struct ofpact" and name
42 * "ofpact". It may be fixed length or end with a flexible array member
43 * (e.g. "int member[];").
45 * 3. <MEMBER>, which has one of two possible values:
47 * - If "struct <STRUCT>" is fixed-length, it must be "ofpact".
49 * - If "struct <STRUCT>" is variable-length, it must be the name of the
50 * flexible array member.
54 DEFINE_OFPACT(OUTPUT, ofpact_output, ofpact) \
55 DEFINE_OFPACT(GROUP, ofpact_group, ofpact) \
56 DEFINE_OFPACT(CONTROLLER, ofpact_controller, ofpact) \
57 DEFINE_OFPACT(ENQUEUE, ofpact_enqueue, ofpact) \
58 DEFINE_OFPACT(OUTPUT_REG, ofpact_output_reg, ofpact) \
59 DEFINE_OFPACT(BUNDLE, ofpact_bundle, slaves) \
61 /* Header changes. */ \
62 DEFINE_OFPACT(SET_VLAN_VID, ofpact_vlan_vid, ofpact) \
63 DEFINE_OFPACT(SET_VLAN_PCP, ofpact_vlan_pcp, ofpact) \
64 DEFINE_OFPACT(STRIP_VLAN, ofpact_null, ofpact) \
65 DEFINE_OFPACT(PUSH_VLAN, ofpact_null, ofpact) \
66 DEFINE_OFPACT(SET_ETH_SRC, ofpact_mac, ofpact) \
67 DEFINE_OFPACT(SET_ETH_DST, ofpact_mac, ofpact) \
68 DEFINE_OFPACT(SET_IPV4_SRC, ofpact_ipv4, ofpact) \
69 DEFINE_OFPACT(SET_IPV4_DST, ofpact_ipv4, ofpact) \
70 DEFINE_OFPACT(SET_IP_DSCP, ofpact_dscp, ofpact) \
71 DEFINE_OFPACT(SET_IP_ECN, ofpact_ecn, ofpact) \
72 DEFINE_OFPACT(SET_IP_TTL, ofpact_ip_ttl, ofpact) \
73 DEFINE_OFPACT(SET_L4_SRC_PORT, ofpact_l4_port, ofpact) \
74 DEFINE_OFPACT(SET_L4_DST_PORT, ofpact_l4_port, ofpact) \
75 DEFINE_OFPACT(REG_MOVE, ofpact_reg_move, ofpact) \
76 DEFINE_OFPACT(REG_LOAD, ofpact_reg_load, ofpact) \
77 DEFINE_OFPACT(STACK_PUSH, ofpact_stack, ofpact) \
78 DEFINE_OFPACT(STACK_POP, ofpact_stack, ofpact) \
79 DEFINE_OFPACT(DEC_TTL, ofpact_cnt_ids, cnt_ids) \
80 DEFINE_OFPACT(SET_MPLS_TTL, ofpact_mpls_ttl, ofpact) \
81 DEFINE_OFPACT(DEC_MPLS_TTL, ofpact_null, ofpact) \
82 DEFINE_OFPACT(PUSH_MPLS, ofpact_push_mpls, ofpact) \
83 DEFINE_OFPACT(POP_MPLS, ofpact_pop_mpls, ofpact) \
86 DEFINE_OFPACT(SET_TUNNEL, ofpact_tunnel, ofpact) \
87 DEFINE_OFPACT(SET_QUEUE, ofpact_queue, ofpact) \
88 DEFINE_OFPACT(POP_QUEUE, ofpact_null, ofpact) \
89 DEFINE_OFPACT(FIN_TIMEOUT, ofpact_fin_timeout, ofpact) \
91 /* Flow table interaction. */ \
92 DEFINE_OFPACT(RESUBMIT, ofpact_resubmit, ofpact) \
93 DEFINE_OFPACT(LEARN, ofpact_learn, specs) \
96 DEFINE_OFPACT(MULTIPATH, ofpact_multipath, ofpact) \
99 DEFINE_OFPACT(NOTE, ofpact_note, data) \
100 DEFINE_OFPACT(EXIT, ofpact_null, ofpact) \
101 DEFINE_OFPACT(SAMPLE, ofpact_sample, ofpact) \
104 DEFINE_OFPACT(METER, ofpact_meter, ofpact) \
105 DEFINE_OFPACT(CLEAR_ACTIONS, ofpact_null, ofpact) \
106 DEFINE_OFPACT(WRITE_ACTIONS, ofpact_nest, ofpact) \
107 DEFINE_OFPACT(WRITE_METADATA, ofpact_metadata, ofpact) \
108 DEFINE_OFPACT(GOTO_TABLE, ofpact_goto_table, ofpact)
110 /* enum ofpact_type, with a member OFPACT_<ENUM> for each action. */
111 enum OVS_PACKED_ENUM ofpact_type {
112 #define DEFINE_OFPACT(ENUM, STRUCT, MEMBER) OFPACT_##ENUM,
117 /* N_OFPACTS, the number of values of "enum ofpact_type". */
120 #define DEFINE_OFPACT(ENUM, STRUCT, MEMBER) + 1
125 /* Header for an action.
127 * Each action is a structure "struct ofpact_*" that begins with "struct
128 * ofpact", usually followed by other data that describes the action. Actions
129 * are padded out to a multiple of OFPACT_ALIGNTO bytes in length.
131 * The 'compat' member is special:
133 * - Most "struct ofpact"s correspond to one particular kind of OpenFlow
134 * action, at least in a given OpenFlow version. For example,
135 * OFPACT_SET_VLAN_VID corresponds to OFPAT10_SET_VLAN_VID in OpenFlow
138 * For such actions, the 'compat' member is not meaningful and generally
141 * - A few "struct ofpact"s correspond to multiple OpenFlow actions. For
142 * example, OFPACT_SET_TUNNEL can be NXAST_SET_TUNNEL or
143 * NXAST_SET_TUNNEL64. In these cases, if the "struct ofpact" originated
144 * from OpenFlow, then we want to make sure that, if it gets translated
145 * back to OpenFlow later, it is translated back to the same action type.
146 * (Otherwise, we'd violate the promise made in DESIGN, in the "Action
147 * Reproduction" section.)
149 * For such actions, the 'compat' member should be the original action
150 * type. (If the action didn't originate from OpenFlow, then setting
151 * 'compat' to zero should be fine: code to translate the ofpact to
152 * OpenFlow must tolerate this case.)
155 enum ofpact_type type; /* OFPACT_*. */
156 enum ofputil_action_code compat; /* Original type when added, if any. */
157 uint16_t len; /* Length of the action, in bytes, including
158 * struct ofpact, excluding padding. */
162 /* Make sure that OVS_PACKED_ENUM really worked. */
163 BUILD_ASSERT_DECL(sizeof(struct ofpact) == 4);
167 #define OFPACT_ALIGNTO 8
168 #define OFPACT_ALIGN(SIZE) ROUND_UP(SIZE, OFPACT_ALIGNTO)
170 static inline struct ofpact *
171 ofpact_next(const struct ofpact *ofpact)
173 return (void *) ((uint8_t *) ofpact + OFPACT_ALIGN(ofpact->len));
176 static inline struct ofpact *
177 ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len)
179 return (void *) ((uint8_t *) ofpacts + ofpacts_len);
182 /* Assigns POS to each ofpact, in turn, in the OFPACTS_LEN bytes of ofpacts
183 * starting at OFPACTS. */
184 #define OFPACT_FOR_EACH(POS, OFPACTS, OFPACTS_LEN) \
185 for ((POS) = (OFPACTS); (POS) < ofpact_end(OFPACTS, OFPACTS_LEN); \
186 (POS) = ofpact_next(POS))
188 /* Action structure for each OFPACT_*. */
190 /* OFPACT_STRIP_VLAN, OFPACT_POP_QUEUE, OFPACT_EXIT, OFPACT_CLEAR_ACTIONS.
192 * Used for OFPAT10_STRIP_VLAN, NXAST_POP_QUEUE, NXAST_EXIT,
193 * OFPAT11_POP_VLAN, OFPIT11_CLEAR_ACTIONS.
195 * Action structure for actions that do not have any extra data beyond the
198 struct ofpact ofpact;
203 * Used for OFPAT10_OUTPUT. */
204 struct ofpact_output {
205 struct ofpact ofpact;
206 ofp_port_t port; /* Output port. */
207 uint16_t max_len; /* Max send len, for port OFPP_CONTROLLER. */
210 /* OFPACT_CONTROLLER.
212 * Used for NXAST_CONTROLLER. */
213 struct ofpact_controller {
214 struct ofpact ofpact;
215 uint16_t max_len; /* Maximum length to send to controller. */
216 uint16_t controller_id; /* Controller ID to send packet-in. */
217 enum ofp_packet_in_reason reason; /* Reason to put in packet-in. */
222 * Used for OFPAT10_ENQUEUE. */
223 struct ofpact_enqueue {
224 struct ofpact ofpact;
229 /* OFPACT_OUTPUT_REG.
231 * Used for NXAST_OUTPUT_REG. */
232 struct ofpact_output_reg {
233 struct ofpact ofpact;
234 struct mf_subfield src;
240 * Used for NXAST_BUNDLE. */
241 struct ofpact_bundle {
242 struct ofpact ofpact;
244 /* Slave choice algorithm to apply to hash value. */
245 enum nx_bd_algorithm algorithm;
247 /* What fields to hash and how. */
248 enum nx_hash_fields fields;
249 uint16_t basis; /* Universal hash parameter. */
251 struct mf_subfield dst;
253 /* Slaves for output. */
254 unsigned int n_slaves;
258 /* OFPACT_SET_VLAN_VID.
260 * We keep track if vlan was present at action validation time to avoid a
261 * PUSH_VLAN when translating to OpenFlow 1.1+.
263 * We also keep the originating OFPUTIL action code in ofpact.compat.
265 * Used for OFPAT10_SET_VLAN_VID and OFPAT11_SET_VLAN_VID. */
266 struct ofpact_vlan_vid {
267 struct ofpact ofpact;
268 uint16_t vlan_vid; /* VLAN VID in low 12 bits, 0 in other bits. */
269 bool push_vlan_if_needed; /* OF 1.0 semantics if true. */
270 bool flow_has_vlan; /* VLAN present at action validation time? */
273 /* OFPACT_SET_VLAN_PCP.
275 * We keep track if vlan was present at action validation time to avoid a
276 * PUSH_VLAN when translating to OpenFlow 1.1+.
278 * We also keep the originating OFPUTIL action code in ofpact.compat.
280 * Used for OFPAT10_SET_VLAN_PCP and OFPAT11_SET_VLAN_PCP. */
281 struct ofpact_vlan_pcp {
282 struct ofpact ofpact;
283 uint8_t vlan_pcp; /* VLAN PCP in low 3 bits, 0 in other bits. */
284 bool push_vlan_if_needed; /* OF 1.0 semantics if true. */
285 bool flow_has_vlan; /* VLAN present at action validation time? */
288 /* OFPACT_SET_ETH_SRC, OFPACT_SET_ETH_DST.
290 * Used for OFPAT10_SET_DL_SRC, OFPAT10_SET_DL_DST. */
292 struct ofpact ofpact;
293 uint8_t mac[ETH_ADDR_LEN];
296 /* OFPACT_SET_IPV4_SRC, OFPACT_SET_IPV4_DST.
298 * Used for OFPAT10_SET_NW_SRC, OFPAT10_SET_NW_DST. */
300 struct ofpact ofpact;
304 /* OFPACT_SET_IP_DSCP.
306 * Used for OFPAT10_SET_NW_TOS. */
308 struct ofpact ofpact;
309 uint8_t dscp; /* DSCP in high 6 bits, rest ignored. */
312 /* OFPACT_SET_IP_ECN.
314 * Used for OFPAT11_SET_NW_ECN. */
316 struct ofpact ofpact;
317 uint8_t ecn; /* ECN in low 2 bits, rest ignored. */
320 /* OFPACT_SET_IP_TTL.
322 * Used for OFPAT11_SET_NW_TTL. */
323 struct ofpact_ip_ttl {
324 struct ofpact ofpact;
328 /* OFPACT_SET_L4_SRC_PORT, OFPACT_SET_L4_DST_PORT.
330 * Used for OFPAT10_SET_TP_SRC, OFPAT10_SET_TP_DST. */
331 struct ofpact_l4_port {
332 struct ofpact ofpact;
333 uint16_t port; /* TCP or UDP port number. */
338 * Used for NXAST_REG_MOVE. */
339 struct ofpact_reg_move {
340 struct ofpact ofpact;
341 struct mf_subfield src;
342 struct mf_subfield dst;
345 /* OFPACT_STACK_PUSH.
347 * Used for NXAST_STACK_PUSH and NXAST_STACK_POP. */
348 struct ofpact_stack {
349 struct ofpact ofpact;
350 struct mf_subfield subfield;
355 * Used for NXAST_REG_LOAD, OFPAT12_SET_FIELD. */
356 struct ofpact_reg_load {
357 struct ofpact ofpact;
358 struct mf_subfield dst;
359 union mf_subvalue subvalue; /* Least-significant bits are used. */
362 /* The position in the packet at which to insert an MPLS header.
364 * Used NXAST_PUSH_MPLS, OFPAT11_PUSH_MPLS. */
365 enum ofpact_mpls_position {
366 /* Add the MPLS LSE after the Ethernet header but before any VLAN tags.
367 * OpenFlow 1.3+ requires this behavior. */
368 OFPACT_MPLS_BEFORE_VLAN,
370 /* Add the MPLS LSE after the Ethernet header and any VLAN tags.
371 * OpenFlow 1.1 and 1.2 require this behavior. */
372 OFPACT_MPLS_AFTER_VLAN
375 /* OFPACT_PUSH_VLAN/MPLS/PBB
377 * Used for NXAST_PUSH_MPLS, OFPAT11_PUSH_MPLS. */
378 struct ofpact_push_mpls {
379 struct ofpact ofpact;
381 enum ofpact_mpls_position position;
386 * Used for NXAST_POP_MPLS, OFPAT11_POP_MPLS.. */
387 struct ofpact_pop_mpls {
388 struct ofpact ofpact;
392 /* OFPACT_SET_TUNNEL.
394 * Used for NXAST_SET_TUNNEL, NXAST_SET_TUNNEL64. */
395 struct ofpact_tunnel {
396 struct ofpact ofpact;
402 * Used for NXAST_SET_QUEUE. */
403 struct ofpact_queue {
404 struct ofpact ofpact;
408 /* OFPACT_FIN_TIMEOUT.
410 * Used for NXAST_FIN_TIMEOUT. */
411 struct ofpact_fin_timeout {
412 struct ofpact ofpact;
413 uint16_t fin_idle_timeout;
414 uint16_t fin_hard_timeout;
417 /* OFPACT_WRITE_METADATA.
419 * Used for NXAST_WRITE_METADATA. */
420 struct ofpact_metadata {
421 struct ofpact ofpact;
428 * Used for OFPIT13_METER. */
429 struct ofpact_meter {
430 struct ofpact ofpact;
434 /* OFPACT_WRITE_ACTIONS.
436 * Used for OFPIT11_WRITE_ACTIONS. */
438 struct ofpact ofpact;
439 uint8_t pad[OFPACT_ALIGN(sizeof(struct ofpact)) - sizeof(struct ofpact)];
440 struct ofpact actions[];
442 BUILD_ASSERT_DECL(offsetof(struct ofpact_nest, actions) == OFPACT_ALIGNTO);
445 ofpact_nest_get_action_len(const struct ofpact_nest *on)
447 return on->ofpact.len - offsetof(struct ofpact_nest, actions);
450 void ofpacts_execute_action_set(struct ofpbuf *action_list,
451 const struct ofpbuf *action_set);
455 * Used for NXAST_RESUBMIT, NXAST_RESUBMIT_TABLE. */
456 struct ofpact_resubmit {
457 struct ofpact ofpact;
462 /* Part of struct ofpact_learn, below. */
463 struct ofpact_learn_spec {
464 int n_bits; /* Number of bits in source and dest. */
466 int src_type; /* One of NX_LEARN_SRC_*. */
467 struct mf_subfield src; /* NX_LEARN_SRC_FIELD only. */
468 union mf_subvalue src_imm; /* NX_LEARN_SRC_IMMEDIATE only. */
470 int dst_type; /* One of NX_LEARN_DST_*. */
471 struct mf_subfield dst; /* NX_LEARN_DST_MATCH, NX_LEARN_DST_LOAD only. */
476 * Used for NXAST_LEARN. */
477 struct ofpact_learn {
478 struct ofpact ofpact;
480 uint16_t idle_timeout; /* Idle time before discarding (seconds). */
481 uint16_t hard_timeout; /* Max time before discarding (seconds). */
482 uint16_t priority; /* Priority level of flow entry. */
483 uint64_t cookie; /* Cookie for new flow. */
484 enum ofputil_flow_mod_flags flags;
485 uint8_t table_id; /* Table to insert flow entry. */
486 uint16_t fin_idle_timeout; /* Idle timeout after FIN, if nonzero. */
487 uint16_t fin_hard_timeout; /* Hard timeout after FIN, if nonzero. */
489 unsigned int n_specs;
490 struct ofpact_learn_spec specs[];
495 * Used for NXAST_MULTIPATH. */
496 struct ofpact_multipath {
497 struct ofpact ofpact;
499 /* What fields to hash and how. */
500 enum nx_hash_fields fields;
501 uint16_t basis; /* Universal hash parameter. */
503 /* Multipath link choice algorithm to apply to hash value. */
504 enum nx_mp_algorithm algorithm;
505 uint16_t max_link; /* Number of output links, minus 1. */
506 uint32_t arg; /* Algorithm-specific argument. */
508 /* Where to store the result. */
509 struct mf_subfield dst;
514 * Used for NXAST_NOTE. */
516 struct ofpact ofpact;
523 * Used for NXAST_SAMPLE. */
524 struct ofpact_sample {
525 struct ofpact ofpact;
526 uint16_t probability; // Always >0.
527 uint32_t collector_set_id;
528 uint32_t obs_domain_id;
529 uint32_t obs_point_id;
534 * Used for OFPAT11_DEC_NW_TTL, NXAST_DEC_TTL and NXAST_DEC_TTL_CNT_IDS. */
535 struct ofpact_cnt_ids {
536 struct ofpact ofpact;
538 /* Controller ids. */
539 unsigned int n_controllers;
543 /* OFPACT_SET_MPLS_TTL.
545 * Used for NXAST_SET_MPLS_TTL */
546 struct ofpact_mpls_ttl {
547 struct ofpact ofpact;
554 * Used for OFPIT11_GOTO_TABLE */
555 struct ofpact_goto_table {
556 struct ofpact ofpact;
562 * Used for OFPAT11_GROUP. */
563 struct ofpact_group {
564 struct ofpact ofpact;
568 /* Converting OpenFlow to ofpacts. */
569 enum ofperr ofpacts_pull_openflow10(struct ofpbuf *openflow,
570 unsigned int actions_len,
571 struct ofpbuf *ofpacts);
572 enum ofperr ofpacts_pull_openflow11_actions(struct ofpbuf *openflow,
573 enum ofp_version version,
574 unsigned int actions_len,
575 struct ofpbuf *ofpacts);
576 enum ofperr ofpacts_pull_openflow11_instructions(struct ofpbuf *openflow,
577 enum ofp_version version,
578 unsigned int instructions_len,
579 struct ofpbuf *ofpacts);
580 enum ofperr ofpacts_check(struct ofpact[], size_t ofpacts_len,
581 struct flow *, ofp_port_t max_ports,
582 uint8_t table_id, bool enforce_consistency);
583 enum ofperr ofpacts_verify(const struct ofpact ofpacts[], size_t ofpacts_len);
585 /* Converting ofpacts to OpenFlow. */
586 void ofpacts_put_openflow10(const struct ofpact[], size_t ofpacts_len,
587 struct ofpbuf *openflow);
588 size_t ofpacts_put_openflow11_actions(const struct ofpact[], size_t ofpacts_len,
589 struct ofpbuf *openflow);
590 void ofpacts_put_openflow11_instructions(const struct ofpact[],
592 struct ofpbuf *openflow);
594 /* Working with ofpacts. */
595 bool ofpacts_output_to_port(const struct ofpact[], size_t ofpacts_len,
597 bool ofpacts_output_to_group(const struct ofpact[], size_t ofpacts_len,
599 bool ofpacts_equal(const struct ofpact a[], size_t a_len,
600 const struct ofpact b[], size_t b_len);
601 uint32_t ofpacts_get_meter(const struct ofpact[], size_t ofpacts_len);
603 /* Formatting ofpacts.
605 * (For parsing ofpacts, see ofp-parse.h.) */
606 void ofpacts_format(const struct ofpact[], size_t ofpacts_len, struct ds *);
608 /* Internal use by the helpers below. */
609 void ofpact_init(struct ofpact *, enum ofpact_type, size_t len);
610 void *ofpact_put(struct ofpbuf *, enum ofpact_type, size_t len);
612 /* For each OFPACT_<ENUM> with a corresponding struct <STRUCT>, this defines
613 * the following commonly useful functions:
615 * struct <STRUCT> *ofpact_put_<ENUM>(struct ofpbuf *ofpacts);
617 * Appends a new 'ofpact', of length OFPACT_<ENUM>_RAW_SIZE, to 'ofpacts',
618 * initializes it with ofpact_init_<ENUM>(), and returns it. Also sets
619 * 'ofpacts->l2' to the returned action.
621 * After using this function to add a variable-length action, add the
622 * elements of the flexible array (e.g. with ofpbuf_put()), then use
623 * ofpact_update_len() to update the length embedded into the action.
624 * (Keep in mind the need to refresh the structure from 'ofpacts->l2' after
625 * adding data to 'ofpacts'.)
627 * struct <STRUCT> *ofpact_get_<ENUM>(const struct ofpact *ofpact);
629 * Returns 'ofpact' cast to "struct <STRUCT> *". 'ofpact->type' must be
632 * as well as the following more rarely useful definitions:
634 * void ofpact_init_<ENUM>(struct <STRUCT> *ofpact);
636 * Initializes the parts of 'ofpact' that identify it as having type
637 * OFPACT_<ENUM> and length OFPACT_<ENUM>_RAW_SIZE and zeros the rest.
641 * The size of the action structure. For a fixed-length action, this is
642 * sizeof(struct <STRUCT>). For a variable-length action, this is the
643 * offset to the variable-length part.
647 * An integer constant, the value of OFPACT_<ENUM>_RAW_SIZE rounded up to a
648 * multiple of OFPACT_ALIGNTO.
650 #define DEFINE_OFPACT(ENUM, STRUCT, MEMBER) \
651 BUILD_ASSERT_DECL(offsetof(struct STRUCT, ofpact) == 0); \
653 enum { OFPACT_##ENUM##_RAW_SIZE \
654 = (offsetof(struct STRUCT, MEMBER) \
655 ? offsetof(struct STRUCT, MEMBER) \
656 : sizeof(struct STRUCT)) }; \
658 enum { OFPACT_##ENUM##_SIZE \
659 = ROUND_UP(OFPACT_##ENUM##_RAW_SIZE, OFPACT_ALIGNTO) }; \
661 static inline struct STRUCT * \
662 ofpact_get_##ENUM(const struct ofpact *ofpact) \
664 ovs_assert(ofpact->type == OFPACT_##ENUM); \
665 return ALIGNED_CAST(struct STRUCT *, ofpact); \
668 static inline struct STRUCT * \
669 ofpact_put_##ENUM(struct ofpbuf *ofpacts) \
671 return ofpact_put(ofpacts, OFPACT_##ENUM, \
672 OFPACT_##ENUM##_RAW_SIZE); \
676 ofpact_init_##ENUM(struct STRUCT *ofpact) \
678 ofpact_init(&ofpact->ofpact, OFPACT_##ENUM, \
679 OFPACT_##ENUM##_RAW_SIZE); \
684 /* Functions to use after adding ofpacts to a buffer. */
685 void ofpact_update_len(struct ofpbuf *, struct ofpact *);
686 void ofpact_pad(struct ofpbuf *);
688 /* OpenFlow 1.1 instructions.
689 * The order is sorted in execution order. Not in the value of OFPIT11_xxx.
690 * It is enforced on parser from text string.
692 #define OVS_INSTRUCTIONS \
693 DEFINE_INST(OFPIT13_METER, \
694 ofp13_instruction_meter, false, \
697 DEFINE_INST(OFPIT11_APPLY_ACTIONS, \
698 ofp11_instruction_actions, true, \
701 DEFINE_INST(OFPIT11_CLEAR_ACTIONS, \
702 ofp11_instruction, false, \
705 DEFINE_INST(OFPIT11_WRITE_ACTIONS, \
706 ofp11_instruction_actions, true, \
709 DEFINE_INST(OFPIT11_WRITE_METADATA, \
710 ofp11_instruction_write_metadata, false, \
713 DEFINE_INST(OFPIT11_GOTO_TABLE, \
714 ofp11_instruction_goto_table, false, \
717 enum ovs_instruction_type {
718 #define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) OVSINST_##ENUM,
724 #define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
725 N_OVS_INSTRUCTIONS = OVS_INSTRUCTIONS
729 const char *ovs_instruction_name_from_type(enum ovs_instruction_type type);
730 int ovs_instruction_type_from_name(const char *name);
731 enum ovs_instruction_type ovs_instruction_type_from_ofpact_type(
734 void ofpact_set_field_init(struct ofpact_reg_load *load,
735 const struct mf_field *mf, const void *src);
736 #endif /* ofp-actions.h */