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