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