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