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