]> git.proxmox.com Git - mirror_ovs.git/blob - include/openvswitch/ofp-actions.h
meta-flow: Remove cmap dependency.
[mirror_ovs.git] / include / openvswitch / ofp-actions.h
1 /*
2 * Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017 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 OPENVSWITCH_OFP_ACTIONS_H
18 #define OPENVSWITCH_OFP_ACTIONS_H 1
19
20 #include <stddef.h>
21 #include <stdint.h>
22 #include "openflow/openflow.h"
23 #include "openflow/nicira-ext.h"
24 #include "openvswitch/meta-flow.h"
25 #include "openvswitch/ofp-util.h"
26 #include "openvswitch/ofp-errors.h"
27 #include "openvswitch/types.h"
28
29 struct vl_mff_map;
30
31 /* List of OVS abstracted actions.
32 *
33 * This macro is used directly only internally by this header, but the list is
34 * still of interest to developers.
35 *
36 * Each OFPACT invocation has the following parameters:
37 *
38 * 1. <ENUM>, used below in the enum definition of OFPACT_<ENUM>, and
39 * elsewhere.
40 *
41 * 2. <STRUCT> corresponding to a structure "struct <STRUCT>", that must be
42 * defined below. This structure must be an abstract definition of the
43 * action. Its first member must have type "struct ofpact" and name
44 * "ofpact". It may be fixed length or end with a flexible array member
45 * (e.g. "int member[];").
46 *
47 * 3. <MEMBER>, which has one of two possible values:
48 *
49 * - If "struct <STRUCT>" is fixed-length, it must be "ofpact".
50 *
51 * - If "struct <STRUCT>" is variable-length, it must be the name of the
52 * flexible array member.
53 *
54 * 4. <NAME>, a quoted string that gives the name of the action, for use in
55 * parsing actions from text.
56 */
57 #define OFPACTS \
58 /* Output. */ \
59 OFPACT(OUTPUT, ofpact_output, ofpact, "output") \
60 OFPACT(GROUP, ofpact_group, ofpact, "group") \
61 OFPACT(CONTROLLER, ofpact_controller, userdata, "controller") \
62 OFPACT(ENQUEUE, ofpact_enqueue, ofpact, "enqueue") \
63 OFPACT(OUTPUT_REG, ofpact_output_reg, ofpact, "output_reg") \
64 OFPACT(BUNDLE, ofpact_bundle, slaves, "bundle") \
65 \
66 /* Header changes. */ \
67 OFPACT(SET_FIELD, ofpact_set_field, ofpact, "set_field") \
68 OFPACT(SET_VLAN_VID, ofpact_vlan_vid, ofpact, "set_vlan_vid") \
69 OFPACT(SET_VLAN_PCP, ofpact_vlan_pcp, ofpact, "set_vlan_pcp") \
70 OFPACT(STRIP_VLAN, ofpact_null, ofpact, "strip_vlan") \
71 OFPACT(PUSH_VLAN, ofpact_null, ofpact, "push_vlan") \
72 OFPACT(SET_ETH_SRC, ofpact_mac, ofpact, "mod_dl_src") \
73 OFPACT(SET_ETH_DST, ofpact_mac, ofpact, "mod_dl_dst") \
74 OFPACT(SET_IPV4_SRC, ofpact_ipv4, ofpact, "mod_nw_src") \
75 OFPACT(SET_IPV4_DST, ofpact_ipv4, ofpact, "mod_nw_dst") \
76 OFPACT(SET_IP_DSCP, ofpact_dscp, ofpact, "mod_nw_tos") \
77 OFPACT(SET_IP_ECN, ofpact_ecn, ofpact, "mod_nw_ecn") \
78 OFPACT(SET_IP_TTL, ofpact_ip_ttl, ofpact, "mod_nw_ttl") \
79 OFPACT(SET_L4_SRC_PORT, ofpact_l4_port, ofpact, "mod_tp_src") \
80 OFPACT(SET_L4_DST_PORT, ofpact_l4_port, ofpact, "mod_tp_dst") \
81 OFPACT(REG_MOVE, ofpact_reg_move, ofpact, "move") \
82 OFPACT(STACK_PUSH, ofpact_stack, ofpact, "push") \
83 OFPACT(STACK_POP, ofpact_stack, ofpact, "pop") \
84 OFPACT(DEC_TTL, ofpact_cnt_ids, cnt_ids, "dec_ttl") \
85 OFPACT(SET_MPLS_LABEL, ofpact_mpls_label, ofpact, "set_mpls_label") \
86 OFPACT(SET_MPLS_TC, ofpact_mpls_tc, ofpact, "set_mpls_tc") \
87 OFPACT(SET_MPLS_TTL, ofpact_mpls_ttl, ofpact, "set_mpls_ttl") \
88 OFPACT(DEC_MPLS_TTL, ofpact_null, ofpact, "dec_mpls_ttl") \
89 OFPACT(PUSH_MPLS, ofpact_push_mpls, ofpact, "push_mpls") \
90 OFPACT(POP_MPLS, ofpact_pop_mpls, ofpact, "pop_mpls") \
91 \
92 /* Metadata. */ \
93 OFPACT(SET_TUNNEL, ofpact_tunnel, ofpact, "set_tunnel") \
94 OFPACT(SET_QUEUE, ofpact_queue, ofpact, "set_queue") \
95 OFPACT(POP_QUEUE, ofpact_null, ofpact, "pop_queue") \
96 OFPACT(FIN_TIMEOUT, ofpact_fin_timeout, ofpact, "fin_timeout") \
97 \
98 /* Flow table interaction. */ \
99 OFPACT(RESUBMIT, ofpact_resubmit, ofpact, "resubmit") \
100 OFPACT(LEARN, ofpact_learn, specs, "learn") \
101 OFPACT(CONJUNCTION, ofpact_conjunction, ofpact, "conjunction") \
102 \
103 /* Arithmetic. */ \
104 OFPACT(MULTIPATH, ofpact_multipath, ofpact, "multipath") \
105 \
106 /* Other. */ \
107 OFPACT(NOTE, ofpact_note, data, "note") \
108 OFPACT(EXIT, ofpact_null, ofpact, "exit") \
109 OFPACT(SAMPLE, ofpact_sample, ofpact, "sample") \
110 OFPACT(UNROLL_XLATE, ofpact_unroll_xlate, ofpact, "unroll_xlate") \
111 OFPACT(CT, ofpact_conntrack, ofpact, "ct") \
112 OFPACT(CT_CLEAR, ofpact_null, ofpact, "ct_clear") \
113 OFPACT(NAT, ofpact_nat, ofpact, "nat") \
114 OFPACT(OUTPUT_TRUNC, ofpact_output_trunc,ofpact, "output_trunc") \
115 OFPACT(CLONE, ofpact_nest, actions, "clone") \
116 \
117 /* Debugging actions. \
118 * \
119 * These are intentionally undocumented, subject to change, and \
120 * only accepted if ovs-vswitchd is started with --enable-dummy. */ \
121 OFPACT(DEBUG_RECIRC, ofpact_null, ofpact, "debug_recirc") \
122 \
123 /* Instructions. */ \
124 OFPACT(METER, ofpact_meter, ofpact, "meter") \
125 OFPACT(CLEAR_ACTIONS, ofpact_null, ofpact, "clear_actions") \
126 OFPACT(WRITE_ACTIONS, ofpact_nest, actions, "write_actions") \
127 OFPACT(WRITE_METADATA, ofpact_metadata, ofpact, "write_metadata") \
128 OFPACT(GOTO_TABLE, ofpact_goto_table, ofpact, "goto_table")
129
130 /* enum ofpact_type, with a member OFPACT_<ENUM> for each action. */
131 enum OVS_PACKED_ENUM ofpact_type {
132 #define OFPACT(ENUM, STRUCT, MEMBER, NAME) OFPACT_##ENUM,
133 OFPACTS
134 #undef OFPACT
135 };
136
137 /* Define N_OFPACTS to the number of types of ofpacts. */
138 enum {
139 #define OFPACT(ENUM, STRUCT, MEMBER, NAME) + 1
140 N_OFPACTS = OFPACTS
141 #undef OFPACT
142 };
143
144 /* Header for an action.
145 *
146 * Each action is a structure "struct ofpact_*" that begins with "struct
147 * ofpact", usually followed by other data that describes the action. Actions
148 * are padded out to a multiple of OFPACT_ALIGNTO bytes in length.
149 *
150 * The 'raw' member is special:
151 *
152 * - Most "struct ofpact"s correspond to one particular kind of OpenFlow
153 * action, at least in a given OpenFlow version. For example,
154 * OFPACT_SET_VLAN_VID corresponds to OFPAT10_SET_VLAN_VID in OpenFlow
155 * 1.0.
156 *
157 * For such actions, the 'raw' member is not meaningful and generally
158 * should be zero.
159 *
160 * - A few "struct ofpact"s correspond to multiple OpenFlow actions. For
161 * example, OFPACT_SET_TUNNEL can be NXAST_SET_TUNNEL or
162 * NXAST_SET_TUNNEL64. In these cases, if the "struct ofpact" originated
163 * from OpenFlow, then we want to make sure that, if it gets translated
164 * back to OpenFlow later, it is translated back to the same action type.
165 * (Otherwise, we'd violate the promise made in the topics/design doc, in
166 * the "Action Reproduction" section.)
167 *
168 * For such actions, the 'raw' member should be the "enum ofp_raw_action"
169 * originally extracted from the OpenFlow action. (If the action didn't
170 * originate from OpenFlow, then setting 'raw' to zero should be fine:
171 * code to translate the ofpact to OpenFlow must tolerate this case.)
172 */
173 struct ofpact {
174 /* We want the space advantage of an 8-bit type here on every
175 * implementation, without giving up the advantage of having a useful type
176 * on implementations that support packed enums. */
177 #ifdef HAVE_PACKED_ENUM
178 enum ofpact_type type; /* OFPACT_*. */
179 #else
180 uint8_t type; /* OFPACT_* */
181 #endif
182
183 uint8_t raw; /* Original type when added, if any. */
184 uint16_t len; /* Length of the action, in bytes, including
185 * struct ofpact, excluding padding. */
186 };
187 BUILD_ASSERT_DECL(sizeof(struct ofpact) == 4);
188
189 /* Alignment. */
190 #define OFPACT_ALIGNTO 8
191 #define OFPACT_ALIGN(SIZE) ROUND_UP(SIZE, OFPACT_ALIGNTO)
192 #define OFPACT_PADDED_MEMBERS(MEMBERS) PADDED_MEMBERS(OFPACT_ALIGNTO, MEMBERS)
193
194 /* Returns the ofpact following 'ofpact'. */
195 static inline struct ofpact *
196 ofpact_next(const struct ofpact *ofpact)
197 {
198 return (void *) ((uint8_t *) ofpact + OFPACT_ALIGN(ofpact->len));
199 }
200
201 struct ofpact *ofpact_next_flattened(const struct ofpact *);
202
203 static inline struct ofpact *
204 ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len)
205 {
206 return (void *) ((uint8_t *) ofpacts + ofpacts_len);
207 }
208
209 static inline const struct ofpact *
210 ofpact_find_type_flattened(const struct ofpact *a, enum ofpact_type type,
211 const struct ofpact * const end)
212 {
213 while (a < end) {
214 if (a->type == type) {
215 return a;
216 }
217 a = ofpact_next_flattened(a);
218 }
219 return NULL;
220 }
221
222 #define OFPACT_FIND_TYPE_FLATTENED(A, TYPE, END) \
223 ofpact_get_##TYPE##_nullable( \
224 ofpact_find_type_flattened(A, OFPACT_##TYPE, END))
225
226 /* Assigns POS to each ofpact, in turn, in the OFPACTS_LEN bytes of ofpacts
227 * starting at OFPACTS. */
228 #define OFPACT_FOR_EACH(POS, OFPACTS, OFPACTS_LEN) \
229 for ((POS) = (OFPACTS); (POS) < ofpact_end(OFPACTS, OFPACTS_LEN); \
230 (POS) = ofpact_next(POS))
231
232 /* Assigns POS to each ofpact, in turn, in the OFPACTS_LEN bytes of ofpacts
233 * starting at OFPACTS.
234 *
235 * For ofpacts that contain nested ofpacts, this visits each of the inner
236 * ofpacts as well. */
237 #define OFPACT_FOR_EACH_FLATTENED(POS, OFPACTS, OFPACTS_LEN) \
238 for ((POS) = (OFPACTS); (POS) < ofpact_end(OFPACTS, OFPACTS_LEN); \
239 (POS) = ofpact_next_flattened(POS))
240
241 #define OFPACT_FOR_EACH_TYPE_FLATTENED(POS, TYPE, OFPACTS, OFPACTS_LEN) \
242 for ((POS) = OFPACT_FIND_TYPE_FLATTENED(OFPACTS, TYPE, \
243 ofpact_end(OFPACTS, OFPACTS_LEN)); \
244 (POS); \
245 (POS) = OFPACT_FIND_TYPE_FLATTENED( \
246 ofpact_next_flattened(&(POS)->ofpact), TYPE, \
247 ofpact_end(OFPACTS, OFPACTS_LEN)))
248 \f
249 /* Action structure for each OFPACT_*. */
250
251 /* OFPACT_STRIP_VLAN, OFPACT_POP_QUEUE, OFPACT_EXIT, OFPACT_CLEAR_ACTIONS.
252 *
253 * Used for OFPAT10_STRIP_VLAN, NXAST_POP_QUEUE, NXAST_EXIT,
254 * OFPAT11_POP_VLAN, OFPIT11_CLEAR_ACTIONS.
255 *
256 * Action structure for actions that do not have any extra data beyond the
257 * action type. */
258 struct ofpact_null {
259 struct ofpact ofpact;
260 };
261
262 /* OFPACT_OUTPUT.
263 *
264 * Used for OFPAT10_OUTPUT. */
265 struct ofpact_output {
266 struct ofpact ofpact;
267 ofp_port_t port; /* Output port. */
268 uint16_t max_len; /* Max send len, for port OFPP_CONTROLLER. */
269 };
270
271 /* OFPACT_CONTROLLER.
272 *
273 * Used for NXAST_CONTROLLER. */
274 struct ofpact_controller {
275 OFPACT_PADDED_MEMBERS(
276 struct ofpact ofpact;
277 uint16_t max_len; /* Max length to send to controller. */
278 uint16_t controller_id; /* Controller ID to send packet-in. */
279 enum ofp_packet_in_reason reason; /* Reason to put in packet-in. */
280
281 /* If true, this action freezes packet traversal of the OpenFlow
282 * tables and adds a continuation to the packet-in message, that
283 * a controller can use to resume that traversal. */
284 bool pause;
285
286 /* Arbitrary data to include in the packet-in message (currently,
287 * only in NXT_PACKET_IN2). */
288 uint16_t userdata_len;
289 );
290 uint8_t userdata[0];
291 };
292
293 /* OFPACT_ENQUEUE.
294 *
295 * Used for OFPAT10_ENQUEUE. */
296 struct ofpact_enqueue {
297 struct ofpact ofpact;
298 ofp_port_t port;
299 uint32_t queue;
300 };
301
302 /* OFPACT_OUTPUT_REG.
303 *
304 * Used for NXAST_OUTPUT_REG. */
305 struct ofpact_output_reg {
306 struct ofpact ofpact;
307 uint16_t max_len;
308 struct mf_subfield src;
309 };
310
311 /* OFPACT_OUTPUT_TRUNC.
312 *
313 * Used for NXAST_OUTPUT_TRUNC. */
314 struct ofpact_output_trunc {
315 struct ofpact ofpact;
316 ofp_port_t port; /* Output port. */
317 uint32_t max_len; /* Max send len. */
318 };
319
320 /* Bundle slave choice algorithm to apply.
321 *
322 * In the descriptions below, 'slaves' is the list of possible slaves in the
323 * order they appear in the OpenFlow action. */
324 enum nx_bd_algorithm {
325 /* Chooses the first live slave listed in the bundle.
326 *
327 * O(n_slaves) performance. */
328 NX_BD_ALG_ACTIVE_BACKUP = 0,
329
330 /* Highest Random Weight.
331 *
332 * for i in [0,n_slaves):
333 * weights[i] = hash(flow, i)
334 * slave = { slaves[i] such that weights[i] >= weights[j] for all j != i }
335 *
336 * Redistributes 1/n_slaves of traffic when a slave's liveness changes.
337 * O(n_slaves) performance.
338 *
339 * Uses the 'fields' and 'basis' parameters. */
340 NX_BD_ALG_HRW = 1
341 };
342
343 /* OFPACT_BUNDLE.
344 *
345 * Used for NXAST_BUNDLE. */
346 struct ofpact_bundle {
347 struct ofpact ofpact;
348
349 /* Slave choice algorithm to apply to hash value. */
350 enum nx_bd_algorithm algorithm;
351
352 /* What fields to hash and how. */
353 enum nx_hash_fields fields;
354 uint16_t basis; /* Universal hash parameter. */
355
356 struct mf_subfield dst;
357
358 /* Slaves for output. */
359 unsigned int n_slaves;
360 ofp_port_t slaves[];
361 };
362
363 /* OFPACT_SET_VLAN_VID.
364 *
365 * We keep track if vlan was present at action validation time to avoid a
366 * PUSH_VLAN when translating to OpenFlow 1.1+.
367 *
368 * We also keep the originating OFPUTIL action code in ofpact.compat.
369 *
370 * Used for OFPAT10_SET_VLAN_VID and OFPAT11_SET_VLAN_VID. */
371 struct ofpact_vlan_vid {
372 struct ofpact ofpact;
373 uint16_t vlan_vid; /* VLAN VID in low 12 bits, 0 in other bits. */
374 bool push_vlan_if_needed; /* OF 1.0 semantics if true. */
375 bool flow_has_vlan; /* VLAN present at action validation time? */
376 };
377
378 /* OFPACT_SET_VLAN_PCP.
379 *
380 * We keep track if vlan was present at action validation time to avoid a
381 * PUSH_VLAN when translating to OpenFlow 1.1+.
382 *
383 * We also keep the originating OFPUTIL action code in ofpact.compat.
384 *
385 * Used for OFPAT10_SET_VLAN_PCP and OFPAT11_SET_VLAN_PCP. */
386 struct ofpact_vlan_pcp {
387 struct ofpact ofpact;
388 uint8_t vlan_pcp; /* VLAN PCP in low 3 bits, 0 in other bits. */
389 bool push_vlan_if_needed; /* OF 1.0 semantics if true. */
390 bool flow_has_vlan; /* VLAN present at action validation time? */
391 };
392
393 /* OFPACT_SET_ETH_SRC, OFPACT_SET_ETH_DST.
394 *
395 * Used for OFPAT10_SET_DL_SRC, OFPAT10_SET_DL_DST. */
396 struct ofpact_mac {
397 struct ofpact ofpact;
398 struct eth_addr mac;
399 };
400
401 /* OFPACT_SET_IPV4_SRC, OFPACT_SET_IPV4_DST.
402 *
403 * Used for OFPAT10_SET_NW_SRC, OFPAT10_SET_NW_DST. */
404 struct ofpact_ipv4 {
405 struct ofpact ofpact;
406 ovs_be32 ipv4;
407 };
408
409 /* OFPACT_SET_IP_DSCP.
410 *
411 * Used for OFPAT10_SET_NW_TOS. */
412 struct ofpact_dscp {
413 struct ofpact ofpact;
414 uint8_t dscp; /* DSCP in high 6 bits, rest ignored. */
415 };
416
417 /* OFPACT_SET_IP_ECN.
418 *
419 * Used for OFPAT11_SET_NW_ECN. */
420 struct ofpact_ecn {
421 struct ofpact ofpact;
422 uint8_t ecn; /* ECN in low 2 bits, rest ignored. */
423 };
424
425 /* OFPACT_SET_IP_TTL.
426 *
427 * Used for OFPAT11_SET_NW_TTL. */
428 struct ofpact_ip_ttl {
429 struct ofpact ofpact;
430 uint8_t ttl;
431 };
432
433 /* OFPACT_SET_L4_SRC_PORT, OFPACT_SET_L4_DST_PORT.
434 *
435 * Used for OFPAT10_SET_TP_SRC, OFPAT10_SET_TP_DST. */
436 struct ofpact_l4_port {
437 struct ofpact ofpact;
438 uint16_t port; /* TCP, UDP or SCTP port number. */
439 uint8_t flow_ip_proto; /* IP proto from corresponding match, or 0 */
440 };
441
442 /* OFPACT_REG_MOVE.
443 *
444 * Used for NXAST_REG_MOVE. */
445 struct ofpact_reg_move {
446 struct ofpact ofpact;
447 struct mf_subfield src;
448 struct mf_subfield dst;
449 };
450
451 /* OFPACT_STACK_PUSH.
452 *
453 * Used for NXAST_STACK_PUSH and NXAST_STACK_POP. */
454 struct ofpact_stack {
455 struct ofpact ofpact;
456 struct mf_subfield subfield;
457 };
458
459 /* OFPACT_SET_FIELD.
460 *
461 * Used for NXAST_REG_LOAD and OFPAT12_SET_FIELD. */
462 struct ofpact_set_field {
463 OFPACT_PADDED_MEMBERS(
464 struct ofpact ofpact;
465 bool flow_has_vlan; /* VLAN present at action validation time. */
466 const struct mf_field *field;
467 );
468 union mf_value value[]; /* Significant value bytes followed by
469 * significant mask bytes. */
470 };
471 BUILD_ASSERT_DECL(offsetof(struct ofpact_set_field, value)
472 % OFPACT_ALIGNTO == 0);
473 BUILD_ASSERT_DECL(offsetof(struct ofpact_set_field, value)
474 == sizeof(struct ofpact_set_field));
475
476 /* Use macro to not have to deal with constness. */
477 #define ofpact_set_field_mask(SF) \
478 ALIGNED_CAST(union mf_value *, \
479 (uint8_t *)(SF)->value + (SF)->field->n_bytes)
480
481 /* OFPACT_PUSH_VLAN/MPLS/PBB
482 *
483 * Used for NXAST_PUSH_MPLS, OFPAT11_PUSH_MPLS. */
484 struct ofpact_push_mpls {
485 struct ofpact ofpact;
486 ovs_be16 ethertype;
487 };
488
489 /* OFPACT_POP_MPLS
490 *
491 * Used for NXAST_POP_MPLS, OFPAT11_POP_MPLS.. */
492 struct ofpact_pop_mpls {
493 struct ofpact ofpact;
494 ovs_be16 ethertype;
495 };
496
497 /* OFPACT_SET_TUNNEL.
498 *
499 * Used for NXAST_SET_TUNNEL, NXAST_SET_TUNNEL64. */
500 struct ofpact_tunnel {
501 struct ofpact ofpact;
502 uint64_t tun_id;
503 };
504
505 /* OFPACT_SET_QUEUE.
506 *
507 * Used for NXAST_SET_QUEUE. */
508 struct ofpact_queue {
509 struct ofpact ofpact;
510 uint32_t queue_id;
511 };
512
513 /* OFPACT_FIN_TIMEOUT.
514 *
515 * Used for NXAST_FIN_TIMEOUT. */
516 struct ofpact_fin_timeout {
517 struct ofpact ofpact;
518 uint16_t fin_idle_timeout;
519 uint16_t fin_hard_timeout;
520 };
521
522 /* OFPACT_WRITE_METADATA.
523 *
524 * Used for NXAST_WRITE_METADATA. */
525 struct ofpact_metadata {
526 struct ofpact ofpact;
527 ovs_be64 metadata;
528 ovs_be64 mask;
529 };
530
531 /* OFPACT_METER.
532 *
533 * Used for OFPIT13_METER. */
534 struct ofpact_meter {
535 struct ofpact ofpact;
536 uint32_t meter_id;
537 };
538
539 /* OFPACT_WRITE_ACTIONS, OFPACT_CLONE.
540 *
541 * Used for OFPIT11_WRITE_ACTIONS, NXAST_CLONE. */
542 struct ofpact_nest {
543 OFPACT_PADDED_MEMBERS(struct ofpact ofpact;);
544 struct ofpact actions[];
545 };
546 BUILD_ASSERT_DECL(offsetof(struct ofpact_nest, actions) % OFPACT_ALIGNTO == 0);
547 BUILD_ASSERT_DECL(offsetof(struct ofpact_nest, actions)
548 == sizeof(struct ofpact_nest));
549
550 static inline size_t
551 ofpact_nest_get_action_len(const struct ofpact_nest *on)
552 {
553 return on->ofpact.len - offsetof(struct ofpact_nest, actions);
554 }
555
556 /* Bits for 'flags' in struct nx_action_conntrack.
557 *
558 * If NX_CT_F_COMMIT is set, then the connection entry is moved from the
559 * unconfirmed to confirmed list in the tracker. */
560 enum nx_conntrack_flags {
561 NX_CT_F_COMMIT = 1 << 0,
562 };
563
564 /* Magic value for struct nx_action_conntrack 'recirc_table' field, to specify
565 * that the packet should not be recirculated. */
566 #define NX_CT_RECIRC_NONE OFPTT_ALL
567
568 #if !defined(IPPORT_FTP)
569 #define IPPORT_FTP 21
570 #endif
571
572 #if !defined(IPPORT_TFTP)
573 #define IPPORT_TFTP 69
574 #endif
575
576 /* OFPACT_CT.
577 *
578 * Used for NXAST_CT. */
579 struct ofpact_conntrack {
580 OFPACT_PADDED_MEMBERS(
581 struct ofpact ofpact;
582 uint16_t flags;
583 uint16_t zone_imm;
584 struct mf_subfield zone_src;
585 uint16_t alg;
586 uint8_t recirc_table;
587 );
588 struct ofpact actions[0];
589 };
590 BUILD_ASSERT_DECL(offsetof(struct ofpact_conntrack, actions)
591 % OFPACT_ALIGNTO == 0);
592 BUILD_ASSERT_DECL(offsetof(struct ofpact_conntrack, actions)
593 == sizeof(struct ofpact_conntrack));
594
595 static inline size_t
596 ofpact_ct_get_action_len(const struct ofpact_conntrack *oc)
597 {
598 return oc->ofpact.len - offsetof(struct ofpact_conntrack, actions);
599 }
600
601 void ofpacts_execute_action_set(struct ofpbuf *action_list,
602 const struct ofpbuf *action_set);
603
604 /* Bits for 'flags' in struct nx_action_nat.
605 */
606 enum nx_nat_flags {
607 NX_NAT_F_SRC = 1 << 0, /* Mutually exclusive with NX_NAT_F_DST. */
608 NX_NAT_F_DST = 1 << 1,
609 NX_NAT_F_PERSISTENT = 1 << 2,
610 NX_NAT_F_PROTO_HASH = 1 << 3, /* Mutually exclusive with PROTO_RANDOM. */
611 NX_NAT_F_PROTO_RANDOM = 1 << 4,
612 NX_NAT_F_MASK = (NX_NAT_F_SRC | NX_NAT_F_DST | NX_NAT_F_PERSISTENT | NX_NAT_F_PROTO_HASH | NX_NAT_F_PROTO_RANDOM)
613 };
614
615 /* OFPACT_NAT.
616 *
617 * Used for NXAST_NAT. */
618 struct ofpact_nat {
619 struct ofpact ofpact;
620 uint8_t range_af; /* AF_UNSPEC, AF_INET, or AF_INET6 */
621 uint16_t flags; /* NX_NAT_F_* */
622 struct {
623 struct {
624 uint16_t min;
625 uint16_t max;
626 } proto;
627 union {
628 struct {
629 ovs_be32 min;
630 ovs_be32 max;
631 } ipv4;
632 struct {
633 struct in6_addr min;
634 struct in6_addr max;
635 } ipv6;
636 } addr;
637 } range;
638 };
639
640
641 /* OFPACT_RESUBMIT.
642 *
643 * Used for NXAST_RESUBMIT, NXAST_RESUBMIT_TABLE. */
644 struct ofpact_resubmit {
645 struct ofpact ofpact;
646 ofp_port_t in_port;
647 uint8_t table_id;
648 };
649
650 /* Bits for 'flags' in struct nx_action_learn.
651 *
652 * If NX_LEARN_F_SEND_FLOW_REM is set, then the learned flows will have their
653 * OFPFF_SEND_FLOW_REM flag set.
654 *
655 * If NX_LEARN_F_DELETE_LEARNED is set, then removing this action will delete
656 * all the flows from the learn action's 'table_id' that have the learn
657 * action's 'cookie'. Important points:
658 *
659 * - The deleted flows include those created by this action, those created
660 * by other learn actions with the same 'table_id' and 'cookie', those
661 * created by flow_mod requests by a controller in the specified table
662 * with the specified cookie, and those created through any other
663 * means.
664 *
665 * - If multiple flows specify "learn" actions with
666 * NX_LEARN_F_DELETE_LEARNED with the same 'table_id' and 'cookie', then
667 * no deletion occurs until all of those "learn" actions are deleted.
668 *
669 * - Deleting a flow that contains a learn action is the most obvious way
670 * to delete a learn action. Modifying a flow's actions, or replacing it
671 * by a new flow, can also delete a learn action. Finally, replacing a
672 * learn action with NX_LEARN_F_DELETE_LEARNED with a learn action
673 * without that flag also effectively deletes the learn action and can
674 * trigger flow deletion.
675 *
676 * NX_LEARN_F_DELETE_LEARNED was added in Open vSwitch 2.4. */
677 enum nx_learn_flags {
678 NX_LEARN_F_SEND_FLOW_REM = 1 << 0,
679 NX_LEARN_F_DELETE_LEARNED = 1 << 1,
680 };
681
682 #define NX_LEARN_N_BITS_MASK 0x3ff
683
684 #define NX_LEARN_SRC_FIELD (0 << 13) /* Copy from field. */
685 #define NX_LEARN_SRC_IMMEDIATE (1 << 13) /* Copy from immediate value. */
686 #define NX_LEARN_SRC_MASK (1 << 13)
687
688 #define NX_LEARN_DST_MATCH (0 << 11) /* Add match criterion. */
689 #define NX_LEARN_DST_LOAD (1 << 11) /* Add NXAST_REG_LOAD action. */
690 #define NX_LEARN_DST_OUTPUT (2 << 11) /* Add OFPAT_OUTPUT action. */
691 #define NX_LEARN_DST_RESERVED (3 << 11) /* Not yet defined. */
692 #define NX_LEARN_DST_MASK (3 << 11)
693
694 /* Part of struct ofpact_learn, below. */
695 struct ofpact_learn_spec {
696 OFPACT_PADDED_MEMBERS(
697 struct mf_subfield src; /* NX_LEARN_SRC_FIELD only. */
698 struct mf_subfield dst; /* NX_LEARN_DST_MATCH,
699 * NX_LEARN_DST_LOAD only. */
700 uint16_t src_type; /* One of NX_LEARN_SRC_*. */
701 uint16_t dst_type; /* One of NX_LEARN_DST_*. */
702 uint8_t n_bits; /* Number of bits in source and dest. */
703 );
704 /* Followed by 'DIV_ROUND_UP(n_bits, 8)' bytes of immediate data for
705 * match 'dst_type's NX_LEARN_DST_MATCH and NX_LEARN_DST_LOAD when
706 * NX_LEARN_SRC_IMMEDIATE is set in 'src_type', followed by zeroes to align
707 * to OFPACT_ALIGNTO. */
708 };
709 BUILD_ASSERT_DECL(sizeof(struct ofpact_learn_spec) % OFPACT_ALIGNTO == 0);
710
711 static inline const void *
712 ofpact_learn_spec_imm(const struct ofpact_learn_spec *spec)
713 {
714 return spec + 1;
715 }
716
717 static inline const struct ofpact_learn_spec *
718 ofpact_learn_spec_next(const struct ofpact_learn_spec *spec)
719 {
720 if (spec->src_type == NX_LEARN_SRC_IMMEDIATE) {
721 unsigned int n_bytes = OFPACT_ALIGN(DIV_ROUND_UP(spec->n_bits, 8));
722 return ALIGNED_CAST(const struct ofpact_learn_spec *,
723 (const uint8_t *)(spec + 1) + n_bytes);
724 }
725 return spec + 1;
726 }
727
728 /* OFPACT_LEARN.
729 *
730 * Used for NXAST_LEARN. */
731 struct ofpact_learn {
732 OFPACT_PADDED_MEMBERS(
733 struct ofpact ofpact;
734
735 uint16_t idle_timeout; /* Idle time before discarding (seconds). */
736 uint16_t hard_timeout; /* Max time before discarding (seconds). */
737 uint16_t priority; /* Priority level of flow entry. */
738 uint8_t table_id; /* Table to insert flow entry. */
739 enum nx_learn_flags flags; /* NX_LEARN_F_*. */
740 ovs_be64 cookie; /* Cookie for new flow. */
741 uint16_t fin_idle_timeout; /* Idle timeout after FIN, if nonzero. */
742 uint16_t fin_hard_timeout; /* Hard timeout after FIN, if nonzero. */
743 );
744
745 struct ofpact_learn_spec specs[];
746 };
747
748 static inline const struct ofpact_learn_spec *
749 ofpact_learn_spec_end(const struct ofpact_learn *learn)
750 {
751 return ALIGNED_CAST(const struct ofpact_learn_spec *,
752 ofpact_next(&learn->ofpact));
753 }
754
755 #define OFPACT_LEARN_SPEC_FOR_EACH(SPEC, LEARN) \
756 for ((SPEC) = (LEARN)->specs; \
757 (SPEC) < ofpact_learn_spec_end(LEARN); \
758 (SPEC) = ofpact_learn_spec_next(SPEC))
759
760 /* Multipath link choice algorithm to apply.
761 *
762 * In the descriptions below, 'n_links' is max_link + 1. */
763 enum nx_mp_algorithm {
764 /* link = hash(flow) % n_links.
765 *
766 * Redistributes all traffic when n_links changes. O(1) performance. See
767 * RFC 2992.
768 *
769 * Use UINT16_MAX for max_link to get a raw hash value. */
770 NX_MP_ALG_MODULO_N = 0,
771
772 /* link = hash(flow) / (MAX_HASH / n_links).
773 *
774 * Redistributes between one-quarter and one-half of traffic when n_links
775 * changes. O(1) performance. See RFC 2992.
776 */
777 NX_MP_ALG_HASH_THRESHOLD = 1,
778
779 /* Highest Random Weight.
780 *
781 * for i in [0,n_links):
782 * weights[i] = hash(flow, i)
783 * link = { i such that weights[i] >= weights[j] for all j != i }
784 *
785 * Redistributes 1/n_links of traffic when n_links changes. O(n_links)
786 * performance. If n_links is greater than a threshold (currently 64, but
787 * subject to change), Open vSwitch will substitute another algorithm
788 * automatically. See RFC 2992. */
789 NX_MP_ALG_HRW = 2,
790
791 /* Iterative Hash.
792 *
793 * i = 0
794 * repeat:
795 * i = i + 1
796 * link = hash(flow, i) % arg
797 * while link > max_link
798 *
799 * Redistributes 1/n_links of traffic when n_links changes. O(1)
800 * performance when arg/max_link is bounded by a constant.
801 *
802 * Redistributes all traffic when arg changes.
803 *
804 * arg must be greater than max_link and for best performance should be no
805 * more than approximately max_link * 2. If arg is outside the acceptable
806 * range, Open vSwitch will automatically substitute the least power of 2
807 * greater than max_link.
808 *
809 * This algorithm is specific to Open vSwitch.
810 */
811 NX_MP_ALG_ITER_HASH = 3,
812 };
813
814 /* OFPACT_CONJUNCTION.
815 *
816 * Used for NXAST_CONJUNCTION. */
817 struct ofpact_conjunction {
818 struct ofpact ofpact;
819 uint8_t clause;
820 uint8_t n_clauses;
821 uint32_t id;
822 };
823
824 /* OFPACT_MULTIPATH.
825 *
826 * Used for NXAST_MULTIPATH. */
827 struct ofpact_multipath {
828 struct ofpact ofpact;
829
830 /* What fields to hash and how. */
831 enum nx_hash_fields fields;
832 uint16_t basis; /* Universal hash parameter. */
833
834 /* Multipath link choice algorithm to apply to hash value. */
835 enum nx_mp_algorithm algorithm;
836 uint16_t max_link; /* Number of output links, minus 1. */
837 uint32_t arg; /* Algorithm-specific argument. */
838
839 /* Where to store the result. */
840 struct mf_subfield dst;
841 };
842
843 /* OFPACT_NOTE.
844 *
845 * Used for NXAST_NOTE. */
846 struct ofpact_note {
847 struct ofpact ofpact;
848 size_t length;
849 uint8_t data[];
850 };
851
852 /* Direction of sampled packets. */
853 enum nx_action_sample_direction {
854 /* OVS will attempt to infer the sample's direction based on whether
855 * 'sampling_port' is the packet's output port. This is generally
856 * effective except when sampling happens as part of an output to a patch
857 * port, which doesn't involve a datapath output action. */
858 NX_ACTION_SAMPLE_DEFAULT,
859
860 /* Explicit direction. This is useful for sampling packets coming in from
861 * or going out of a patch port, where the direction cannot be inferred. */
862 NX_ACTION_SAMPLE_INGRESS,
863 NX_ACTION_SAMPLE_EGRESS
864 };
865
866 /* OFPACT_SAMPLE.
867 *
868 * Used for NXAST_SAMPLE, NXAST_SAMPLE2, and NXAST_SAMPLE3. */
869 struct ofpact_sample {
870 struct ofpact ofpact;
871 uint16_t probability; /* Always positive. */
872 uint32_t collector_set_id;
873 uint32_t obs_domain_id;
874 uint32_t obs_point_id;
875 ofp_port_t sampling_port;
876 enum nx_action_sample_direction direction;
877 };
878
879 /* OFPACT_DEC_TTL.
880 *
881 * Used for OFPAT11_DEC_NW_TTL, NXAST_DEC_TTL and NXAST_DEC_TTL_CNT_IDS. */
882 struct ofpact_cnt_ids {
883 struct ofpact ofpact;
884
885 /* Controller ids. */
886 unsigned int n_controllers;
887 uint16_t cnt_ids[];
888 };
889
890 /* OFPACT_SET_MPLS_LABEL.
891 *
892 * Used for OFPAT11_SET_MPLS_LABEL and NXAST_SET_MPLS_LABEL */
893 struct ofpact_mpls_label {
894 struct ofpact ofpact;
895
896 ovs_be32 label;
897 };
898
899 /* OFPACT_SET_MPLS_TC.
900 *
901 * Used for OFPAT11_SET_MPLS_TC and NXAST_SET_MPLS_TC */
902 struct ofpact_mpls_tc {
903 struct ofpact ofpact;
904
905 uint8_t tc;
906 };
907
908 /* OFPACT_SET_MPLS_TTL.
909 *
910 * Used for OFPAT11_SET_MPLS_TTL and NXAST_SET_MPLS_TTL */
911 struct ofpact_mpls_ttl {
912 struct ofpact ofpact;
913
914 uint8_t ttl;
915 };
916
917 /* OFPACT_GOTO_TABLE
918 *
919 * Used for OFPIT11_GOTO_TABLE */
920 struct ofpact_goto_table {
921 struct ofpact ofpact;
922 uint8_t table_id;
923 };
924
925 /* OFPACT_GROUP.
926 *
927 * Used for OFPAT11_GROUP. */
928 struct ofpact_group {
929 struct ofpact ofpact;
930 uint32_t group_id;
931 };
932
933 /* OFPACT_UNROLL_XLATE.
934 *
935 * Used only internally. */
936 struct ofpact_unroll_xlate {
937 struct ofpact ofpact;
938
939 /* Metadata in xlate context, visible to controller via PACKET_INs. */
940 uint8_t rule_table_id; /* 0xFF if none. */
941 ovs_be64 rule_cookie; /* OVS_BE64_MAX if none. */
942 };
943
944 /* Converting OpenFlow to ofpacts. */
945 enum ofperr ofpacts_pull_openflow_actions(struct ofpbuf *openflow,
946 unsigned int actions_len,
947 enum ofp_version version,
948 const struct vl_mff_map *,
949 struct ofpbuf *ofpacts);
950 enum ofperr
951 ofpacts_pull_openflow_instructions(struct ofpbuf *openflow,
952 unsigned int instructions_len,
953 enum ofp_version version,
954 const struct vl_mff_map *vl_mff_map,
955 struct ofpbuf *ofpacts);
956 enum ofperr ofpacts_check(struct ofpact[], size_t ofpacts_len,
957 struct flow *, ofp_port_t max_ports,
958 uint8_t table_id, uint8_t n_tables,
959 enum ofputil_protocol *usable_protocols);
960 enum ofperr ofpacts_check_consistency(struct ofpact[], size_t ofpacts_len,
961 struct flow *, ofp_port_t max_ports,
962 uint8_t table_id, uint8_t n_tables,
963 enum ofputil_protocol usable_protocols);
964 enum ofperr ofpact_check_output_port(ofp_port_t port, ofp_port_t max_ports);
965
966 /* Converting ofpacts to OpenFlow. */
967 size_t ofpacts_put_openflow_actions(const struct ofpact[], size_t ofpacts_len,
968 struct ofpbuf *openflow, enum ofp_version);
969 void ofpacts_put_openflow_instructions(const struct ofpact[],
970 size_t ofpacts_len,
971 struct ofpbuf *openflow,
972 enum ofp_version ofp_version);
973
974 /* Sets of supported actions. */
975 ovs_be32 ofpact_bitmap_to_openflow(uint64_t ofpacts_bitmap, enum ofp_version);
976 uint64_t ofpact_bitmap_from_openflow(ovs_be32 ofpat_bitmap, enum ofp_version);
977 void ofpact_bitmap_format(uint64_t ofpacts_bitmap, struct ds *);
978
979 /* Working with ofpacts. */
980 bool ofpacts_output_to_port(const struct ofpact[], size_t ofpacts_len,
981 ofp_port_t port);
982 bool ofpacts_output_to_group(const struct ofpact[], size_t ofpacts_len,
983 uint32_t group_id);
984 bool ofpacts_equal(const struct ofpact a[], size_t a_len,
985 const struct ofpact b[], size_t b_len);
986 const struct mf_field *ofpact_get_mf_dst(const struct ofpact *ofpact);
987 uint32_t ofpacts_get_meter(const struct ofpact[], size_t ofpacts_len);
988
989 /* Formatting and parsing ofpacts. */
990 void ofpacts_format(const struct ofpact[], size_t ofpacts_len, struct ds *);
991 char *ofpacts_parse_actions(const char *, struct ofpbuf *ofpacts,
992 enum ofputil_protocol *usable_protocols)
993 OVS_WARN_UNUSED_RESULT;
994 char *ofpacts_parse_instructions(const char *, struct ofpbuf *ofpacts,
995 enum ofputil_protocol *usable_protocols)
996 OVS_WARN_UNUSED_RESULT;
997 const char *ofpact_name(enum ofpact_type);
998
999 /* Internal use by the helpers below. */
1000 void ofpact_init(struct ofpact *, enum ofpact_type, size_t len);
1001 void *ofpact_put(struct ofpbuf *, enum ofpact_type, size_t len);
1002 void *ofpact_finish(struct ofpbuf *, struct ofpact *);
1003
1004 /* For each OFPACT_<ENUM> with a corresponding struct <STRUCT>, this defines
1005 * the following commonly useful functions:
1006 *
1007 * struct <STRUCT> *ofpact_put_<ENUM>(struct ofpbuf *ofpacts);
1008 *
1009 * Appends a new 'ofpact', of length OFPACT_<ENUM>_SIZE, to 'ofpacts',
1010 * initializes it with ofpact_init_<ENUM>(), and returns it. Also sets
1011 * 'ofpacts->header' to the returned action.
1012 *
1013 * After using this function to add a variable-length action, add the
1014 * elements of the flexible array (e.g. with ofpbuf_put()), then use
1015 * ofpact_finish() to pad the action to a multiple of OFPACT_ALIGNTO bytes
1016 * and update its embedded length field. (Keep in mind the need to refresh
1017 * the structure from 'ofpacts->header' after adding data to 'ofpacts'.)
1018 *
1019 * struct <STRUCT> *ofpact_get_<ENUM>(const struct ofpact *ofpact);
1020 *
1021 * Returns 'ofpact' cast to "struct <STRUCT> *". 'ofpact->type' must be
1022 * OFPACT_<ENUM>.
1023 *
1024 * void ofpact_finish_<ENUM>(struct ofpbuf *ofpacts, struct <STRUCT> **ap);
1025 *
1026 * Finishes composing variable-length action '*ap' (begun using
1027 * ofpact_put_<NAME>() on 'ofpacts'), by padding the action to a multiple
1028 * of OFPACT_ALIGNTO bytes and updating its embedded length field.
1029 *
1030 * May reallocate 'ofpacts', and so as a convenience automatically updates
1031 * '*ap' to point to the new location. If the caller has other pointers
1032 * within 'ap' or 'ofpacts', it needs to update them manually.
1033 *
1034 * as well as the following more rarely useful definitions:
1035 *
1036 * void ofpact_init_<ENUM>(struct <STRUCT> *ofpact);
1037 *
1038 * Initializes the parts of 'ofpact' that identify it as having type
1039 * OFPACT_<ENUM> and length OFPACT_<ENUM>_SIZE and zeros the rest.
1040 *
1041 * <ENUM>_SIZE
1042 *
1043 * The size of the action structure. For a fixed-length action, this is
1044 * sizeof(struct <STRUCT>) rounded up to a multiple of OFPACT_ALIGNTO. For
1045 * a variable-length action, this is the offset to the variable-length
1046 * part.
1047 */
1048 #define OFPACT(ENUM, STRUCT, MEMBER, NAME) \
1049 BUILD_ASSERT_DECL(offsetof(struct STRUCT, ofpact) == 0); \
1050 \
1051 enum { OFPACT_##ENUM##_SIZE \
1052 = (offsetof(struct STRUCT, MEMBER) \
1053 ? offsetof(struct STRUCT, MEMBER) \
1054 : OFPACT_ALIGN(sizeof(struct STRUCT))) }; \
1055 \
1056 static inline struct STRUCT * \
1057 ofpact_get_##ENUM(const struct ofpact *ofpact) \
1058 { \
1059 ovs_assert(ofpact->type == OFPACT_##ENUM); \
1060 return ALIGNED_CAST(struct STRUCT *, ofpact); \
1061 } \
1062 \
1063 static inline struct STRUCT * \
1064 ofpact_get_##ENUM##_nullable(const struct ofpact *ofpact) \
1065 { \
1066 ovs_assert(!ofpact || ofpact->type == OFPACT_##ENUM); \
1067 return ALIGNED_CAST(struct STRUCT *, ofpact); \
1068 } \
1069 \
1070 static inline struct STRUCT * \
1071 ofpact_put_##ENUM(struct ofpbuf *ofpacts) \
1072 { \
1073 return ofpact_put(ofpacts, OFPACT_##ENUM, \
1074 OFPACT_##ENUM##_SIZE); \
1075 } \
1076 \
1077 static inline void \
1078 ofpact_init_##ENUM(struct STRUCT *ofpact) \
1079 { \
1080 ofpact_init(&ofpact->ofpact, OFPACT_##ENUM, \
1081 OFPACT_##ENUM##_SIZE); \
1082 } \
1083 \
1084 static inline void \
1085 ofpact_finish_##ENUM(struct ofpbuf *ofpbuf, struct STRUCT **ofpactp) \
1086 { \
1087 struct ofpact *ofpact = &(*ofpactp)->ofpact; \
1088 ovs_assert(ofpact->type == OFPACT_##ENUM); \
1089 *ofpactp = ofpact_finish(ofpbuf, ofpact); \
1090 }
1091 OFPACTS
1092 #undef OFPACT
1093
1094 /* Additional functions for composing ofpacts. */
1095 struct ofpact_set_field *ofpact_put_set_field(struct ofpbuf *ofpacts,
1096 const struct mf_field *,
1097 const void *value,
1098 const void *mask);
1099 struct ofpact_set_field *ofpact_put_reg_load(struct ofpbuf *ofpacts,
1100 const struct mf_field *,
1101 const void *value,
1102 const void *mask);
1103 struct ofpact_set_field *ofpact_put_reg_load2(struct ofpbuf *ofpacts,
1104 const struct mf_field *,
1105 const void *value,
1106 const void *mask);
1107
1108 /* OpenFlow 1.1 instructions.
1109 * The order is sorted in execution order. Not in the value of OFPIT11_xxx.
1110 * It is enforced on parser from text string.
1111 */
1112 #define OVS_INSTRUCTIONS \
1113 DEFINE_INST(OFPIT13_METER, \
1114 ofp13_instruction_meter, false, \
1115 "meter") \
1116 \
1117 DEFINE_INST(OFPIT11_APPLY_ACTIONS, \
1118 ofp11_instruction_actions, true, \
1119 "apply_actions") \
1120 \
1121 DEFINE_INST(OFPIT11_CLEAR_ACTIONS, \
1122 ofp11_instruction, false, \
1123 "clear_actions") \
1124 \
1125 DEFINE_INST(OFPIT11_WRITE_ACTIONS, \
1126 ofp11_instruction_actions, true, \
1127 "write_actions") \
1128 \
1129 DEFINE_INST(OFPIT11_WRITE_METADATA, \
1130 ofp11_instruction_write_metadata, false, \
1131 "write_metadata") \
1132 \
1133 DEFINE_INST(OFPIT11_GOTO_TABLE, \
1134 ofp11_instruction_goto_table, false, \
1135 "goto_table")
1136
1137 enum ovs_instruction_type {
1138 #define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) OVSINST_##ENUM,
1139 OVS_INSTRUCTIONS
1140 #undef DEFINE_INST
1141 };
1142
1143 enum {
1144 #define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
1145 N_OVS_INSTRUCTIONS = OVS_INSTRUCTIONS
1146 #undef DEFINE_INST
1147 };
1148
1149 const char *ovs_instruction_name_from_type(enum ovs_instruction_type type);
1150 int ovs_instruction_type_from_name(const char *name);
1151 enum ovs_instruction_type ovs_instruction_type_from_ofpact_type(
1152 enum ofpact_type);
1153 enum ofperr ovs_instruction_type_from_inst_type(
1154 enum ovs_instruction_type *instruction_type, const uint16_t inst_type);
1155
1156 ovs_be32 ovsinst_bitmap_to_openflow(uint32_t ovsinst_bitmap, enum ofp_version);
1157 uint32_t ovsinst_bitmap_from_openflow(ovs_be32 ofpit_bitmap,
1158 enum ofp_version);
1159
1160 #endif /* ofp-actions.h */