]> git.proxmox.com Git - mirror_ovs.git/blob - include/openvswitch/meta-flow.h
userspace: Add support for NSH MD1 match fields
[mirror_ovs.git] / include / openvswitch / meta-flow.h
1 /*
2 * Copyright (c) 2011-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_META_FLOW_H
18 #define OPENVSWITCH_META_FLOW_H 1
19
20 #include <limits.h>
21 #include <stdarg.h>
22 #include <string.h>
23 #include <sys/types.h>
24 #include <netinet/in.h>
25 #include <netinet/ip6.h>
26 #include "openvswitch/flow.h"
27 #include "openvswitch/ofp-errors.h"
28 #include "openvswitch/packets.h"
29 #include "openvswitch/util.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 struct ds;
36 struct match;
37 struct ofputil_port_map;
38 struct ofputil_tlv_table_mod;
39
40 /* Open vSwitch fields
41 * ===================
42 *
43 * Refer to ovs-fields(7) for a detailed introduction to Open vSwitch fields.
44 *
45 *
46 * Field specifications
47 * ====================
48 *
49 * Each of the enumeration values below represents a field. The comments
50 * preceding each enum must be in a stylized form that is parsed at compile
51 * time by the extract-ofp-fields program. The comment itself consists of a
52 * series of paragraphs separate by blank lines. The paragraphs consist of:
53 *
54 * - The first paragraph gives the user-visible name of the field as a
55 * quoted string. This is the name used for parsing and formatting the
56 * field.
57 *
58 * For historical reasons, some fields have an additional name that is
59 * accepted as an alternative in parsing. This name, when there is one,
60 * is given as a quoted string in parentheses along with "aka". For
61 * example:
62 *
63 * "tun_id" (aka "tunnel_id").
64 *
65 * New fields should have only one name.
66 *
67 * - Any number of paragraphs of free text that describe the field. These
68 * are kept brief because the main description is in meta-flow.xml.
69 *
70 * - A final paragraph that consists of a series of key-value pairs, one
71 * per line, in the form "key: value." where the period at the end of the
72 * line is a mandatory part of the syntax.
73 *
74 * Every field must specify the following key-value pairs:
75 *
76 * Type:
77 *
78 * The format and size of the field's value. Some possible values are
79 * generic:
80 *
81 * u8: A one-byte field.
82 * be16: A two-byte field.
83 * be32: A four-byte field.
84 * be64: An eight-byte field.
85 *
86 * The remaining values imply more about the value's semantics, though OVS
87 * does not currently take advantage of this additional information:
88 *
89 * MAC: A six-byte field whose value is an Ethernet address.
90 * IPv6: A 16-byte field whose value is an IPv6 address.
91 * tunnelMD: A variable length field, up to 124 bytes, that carries
92 * tunnel metadata.
93 *
94 * Maskable:
95 *
96 * Either "bitwise", if OVS supports matching any subset of bits in the
97 * field, or "no", if OVS only supports matching or wildcarding the entire
98 * field.
99 *
100 * Formatting:
101 *
102 * Explains how a field's value is formatted and parsed for human
103 * consumption. Some of the options are fairly generally useful:
104 *
105 * decimal: Formats the value as a decimal number. On parsing, accepts
106 * decimal (with no prefix), hexadecimal with 0x prefix, or octal
107 * with 0 prefix.
108 *
109 * hexadecimal: Same as decimal except nonzero values are formatted in
110 * hex with 0x prefix. The default for parsing is *not* hexadecimal:
111 * only with a 0x prefix is the input in hexadecimal.
112 *
113 * Ethernet: Formats and accepts the common format xx:xx:xx:xx:xx:xx.
114 * 6-byte fields only.
115 *
116 * IPv4: Formats and accepts the common format w.x.y.z. 4-byte fields
117 * only.
118 *
119 * IPv6: Formats and accepts the common IPv6 formats. 16-byte fields
120 * only.
121 *
122 * OpenFlow 1.0 port: Accepts an OpenFlow well-known port name
123 * (e.g. "IN_PORT") in uppercase or lowercase, or a 16-bit port
124 * number in decimal. Formats ports using their well-known names in
125 * uppercase, or in decimal otherwise. 2-byte fields only.
126 *
127 * OpenFlow 1.1+ port: Same syntax as for OpenFlow 1.0 ports but for
128 * 4-byte OpenFlow 1.1+ port number fields.
129 *
130 * Others are very specific to particular fields:
131 *
132 * frag: One of the strings "no", "first", "later", "yes", "not_later"
133 * describing which IPv4/v6 fragments are matched.
134 *
135 * tunnel flags: Any number of the strings "df", "csum", "key", or
136 * "oam" separated by "|".
137 *
138 * TCP flags: See the description of tcp_flags in ovs-ofctl(8).
139 *
140 * packet type: A pair of packet type namespace NS and NS_TYPE within
141 * that namespace "(NS,NS_TYPE)". NS and NS_TYPE are formatted in
142 * decimal or hexadecimal as and accept decimal and hexadecimal (with
143 * 0x prefix) at parsing.
144 *
145 * Prerequisites:
146 *
147 * The field's prerequisites. The values should be straightfoward.
148 *
149 * Access:
150 *
151 * Either "read-only", for a field that cannot be changed via OpenFlow, or
152 * "read/write" for a modifiable field.
153 *
154 * NXM:
155 *
156 * If the field has an NXM field assignment, then this specifies the NXM
157 * name of the field (e.g. "NXM_OF_ETH_SRC"), followed by its nxm_type in
158 * parentheses, followed by "since v<x>.<y>" specifying the version of Open
159 * vSwitch that first supported this field in NXM (e.g. "since v1.1" if it
160 * was introduced in Open vSwitch 1.1).
161 *
162 * The NXM name must begin with NXM_OF_ or NXM_NX_. This allows OVS to
163 * determine the correct NXM class.
164 *
165 * If the field does not have an NXM field assignment, specify "none".
166 *
167 * OXM:
168 *
169 * If the field has an OXM field assignment, then this specifies the OXM
170 * name of the field (e.g. "OXM_OF_ETH_SRC"), followed by its nxm_type in
171 * parentheses, followed by "since OF<a>.<b> v<x>.<y>" specifying the
172 * versions of OpenFlow and Open vSwitch that first supported this field in
173 * OXM (e.g. "since OF1.3 and v1.10" if it was introduced in OpenFlow 1.3
174 * and first supported by Open vSwitch in version 1.10).
175 *
176 * Some fields have more than one OXM field assignment. For example,
177 * actset_output has an experimenter OXM assignment in OpenFlow 1.3 and a
178 * standard OXM assignment in OpenFlow 1.5. In such a case, specify both,
179 * separated by commas.
180 *
181 * OVS uses the start of the OXM field name to determine the correct OXM
182 * class. To support a new OXM class, edit the mapping table in
183 * build-aux/extract-ofp-fields.
184 *
185 * If the field does not have an OXM field assignment, specify "none".
186 *
187 * The following key-value pairs are optional. Open vSwitch already supports
188 * all the fields to which they apply, so new fields should probably not
189 * include these pairs:
190 *
191 * OF1.0:
192 *
193 * Specify this as "exact match" if OpenFlow 1.0 can match or wildcard the
194 * entire field, or as "CIDR mask" if OpenFlow 1.0 can match any CIDR
195 * prefix of the field. (OpenFlow 1.0 did not support bitwise matching.)
196 * Omit, if OpenFlow 1.0 did not support this field.
197 *
198 * OF1.1:
199 *
200 * Specify this as "exact match" if OpenFlow 1.1 can match or wildcard the
201 * entire field, or as "bitwise" if OpenFlow 1.1 can match any subset of
202 * bits in the field. Omit, if OpenFlow 1.1 did not support this field.
203 *
204 * The following key-value pair is optional:
205 *
206 * Prefix lookup member:
207 *
208 * If this field makes sense for use with classifier_set_prefix_fields(),
209 * specify the name of the "struct flow" member that corresponds to the
210 * field.
211 *
212 * Finally, a few "register" fields have very similar names and purposes,
213 * e.g. MFF_REG0 through MFF_REG15. For these, the comments may be merged
214 * together using <N> as a metasyntactic variable for the numeric suffix.
215 * Lines in the comment that are specific to one of the particular fields by
216 * writing, e.g. <1>, to consider that line only for e.g. MFF_REG1.
217 */
218
219 enum OVS_PACKED_ENUM mf_field_id {
220 /* ## -------- ## */
221 /* ## Metadata ## */
222 /* ## -------- ## */
223
224 /* "dp_hash".
225 *
226 * Flow hash computed in the datapath. Internal use only, not programmable
227 * from controller.
228 *
229 * The OXM code point for this is an attempt to test OXM experimenter
230 * support, which is otherwise difficult to test due to the dearth of use
231 * out in the wild. Because controllers can't add flows that match on
232 * dp_hash, this doesn't commit OVS to supporting this OXM experimenter
233 * code point in the future.
234 *
235 * Type: be32.
236 * Maskable: bitwise.
237 * Formatting: hexadecimal.
238 * Prerequisites: none.
239 * Access: read-only.
240 * NXM: NXM_NX_DP_HASH(35) since v2.2.
241 * OXM: NXOXM_ET_DP_HASH(0) since OF1.5 and v2.4.
242 */
243 MFF_DP_HASH,
244
245 /* "recirc_id".
246 *
247 * ID for recirculation. The value 0 is reserved for initially received
248 * packets. Internal use only, not programmable from controller.
249 *
250 * Type: be32.
251 * Maskable: no.
252 * Formatting: decimal.
253 * Prerequisites: none.
254 * Access: read-only.
255 * NXM: NXM_NX_RECIRC_ID(36) since v2.2.
256 * OXM: none.
257 */
258 MFF_RECIRC_ID,
259
260 /* "packet_type".
261 *
262 * Define the packet type in OpenFlow 1.5+.
263 *
264 * Type: be32.
265 * Maskable: no.
266 * Formatting: packet type.
267 * Prerequisites: none.
268 * Access: read-only.
269 * NXM: none.
270 * OXM: OXM_OF_PACKET_TYPE(44) since OF1.5 and v2.8.
271 */
272 MFF_PACKET_TYPE,
273
274 /* "conj_id".
275 *
276 * ID for "conjunction" actions. Please refer to ovs-ofctl(8)
277 * documentation of "conjunction" for details.
278 *
279 * Type: be32.
280 * Maskable: no.
281 * Formatting: decimal.
282 * Prerequisites: none.
283 * Access: read-only.
284 * NXM: NXM_NX_CONJ_ID(37) since v2.4.
285 * OXM: none. */
286 MFF_CONJ_ID,
287
288 /* "tun_id" (aka "tunnel_id").
289 *
290 * The "key" or "tunnel ID" or "VNI" in a packet received via a keyed
291 * tunnel. For protocols in which the key is shorter than 64 bits, the key
292 * is stored in the low bits and the high bits are zeroed. For non-keyed
293 * tunnels and packets not received via a tunnel, the value is 0.
294 *
295 * Type: be64.
296 * Maskable: bitwise.
297 * Formatting: hexadecimal.
298 * Prerequisites: none.
299 * Access: read/write.
300 * NXM: NXM_NX_TUN_ID(16) since v1.1.
301 * OXM: OXM_OF_TUNNEL_ID(38) since OF1.3 and v1.10.
302 * Prefix lookup member: tunnel.tun_id.
303 */
304 MFF_TUN_ID,
305
306 /* "tun_src".
307 *
308 * The IPv4 source address in the outer IP header of a tunneled packet.
309 *
310 * For non-tunneled packets, the value is 0.
311 *
312 * Type: be32.
313 * Maskable: bitwise.
314 * Formatting: IPv4.
315 * Prerequisites: none.
316 * Access: read/write.
317 * NXM: NXM_NX_TUN_IPV4_SRC(31) since v2.0.
318 * OXM: none.
319 * Prefix lookup member: tunnel.ip_src.
320 */
321 MFF_TUN_SRC,
322
323 /* "tun_dst".
324 *
325 * The IPv4 destination address in the outer IP header of a tunneled
326 * packet.
327 *
328 * For non-tunneled packets, the value is 0.
329 *
330 * Type: be32.
331 * Maskable: bitwise.
332 * Formatting: IPv4.
333 * Prerequisites: none.
334 * Access: read/write.
335 * NXM: NXM_NX_TUN_IPV4_DST(32) since v2.0.
336 * OXM: none.
337 * Prefix lookup member: tunnel.ip_dst.
338 */
339 MFF_TUN_DST,
340
341 /* "tun_ipv6_src".
342 *
343 * The IPv6 source address in the outer IP header of a tunneled packet.
344 *
345 * For non-tunneled packets, the value is 0.
346 *
347 * Type: be128.
348 * Maskable: bitwise.
349 * Formatting: IPv6.
350 * Prerequisites: none.
351 * Access: read/write.
352 * NXM: NXM_NX_TUN_IPV6_SRC(109) since v2.5.
353 * OXM: none.
354 * Prefix lookup member: tunnel.ipv6_src.
355 */
356 MFF_TUN_IPV6_SRC,
357
358 /* "tun_ipv6_dst".
359 *
360 * The IPv6 destination address in the outer IP header of a tunneled
361 * packet.
362 *
363 * For non-tunneled packets, the value is 0.
364 *
365 * Type: be128.
366 * Maskable: bitwise.
367 * Formatting: IPv6.
368 * Prerequisites: none.
369 * Access: read/write.
370 * NXM: NXM_NX_TUN_IPV6_DST(110) since v2.5.
371 * OXM: none.
372 * Prefix lookup member: tunnel.ipv6_dst.
373 */
374 MFF_TUN_IPV6_DST,
375
376 /* "tun_flags".
377 *
378 * Flags representing aspects of tunnel behavior.
379 *
380 * For non-tunneled packets, the value is 0.
381 *
382 * Type: be16 (low 1 bits).
383 * Maskable: bitwise.
384 * Formatting: tunnel flags.
385 * Prerequisites: none.
386 * Access: read/write.
387 * NXM: NXM_NX_TUN_FLAGS(104) since v2.5.
388 * OXM: none.
389 */
390 MFF_TUN_FLAGS,
391
392 /* "tun_ttl".
393 *
394 * The TTL in the outer IP header of a tunneled packet. Internal use only,
395 * not programmable from controller.
396 *
397 * For non-tunneled packets, the value is 0.
398 *
399 * Type: u8.
400 * Maskable: no.
401 * Formatting: decimal.
402 * Prerequisites: none.
403 * Access: read-only.
404 * NXM: none.
405 * OXM: none.
406 */
407 MFF_TUN_TTL,
408
409 /* "tun_tos".
410 *
411 * The ToS value in the outer IP header of a tunneled packet. Internal use
412 * only, not programmable from controller.
413 *
414 * Type: u8.
415 * Maskable: no.
416 * Formatting: decimal.
417 * Prerequisites: none.
418 * Access: read-only.
419 * NXM: none.
420 * OXM: none.
421 */
422 MFF_TUN_TOS,
423
424 /* "tun_gbp_id".
425 *
426 * VXLAN Group Policy ID
427 *
428 * Type: be16.
429 * Maskable: bitwise.
430 * Formatting: decimal.
431 * Prerequisites: none.
432 * Access: read/write.
433 * NXM: NXM_NX_TUN_GBP_ID(38) since v2.4.
434 * OXM: none.
435 */
436 MFF_TUN_GBP_ID,
437
438 /* "tun_gbp_flags".
439 *
440 * VXLAN Group Policy flags
441 *
442 * Type: u8.
443 * Maskable: bitwise.
444 * Formatting: hexadecimal.
445 * Prerequisites: none.
446 * Access: read/write.
447 * NXM: NXM_NX_TUN_GBP_FLAGS(39) since v2.4.
448 * OXM: none.
449 */
450 MFF_TUN_GBP_FLAGS,
451
452 #if TUN_METADATA_NUM_OPTS == 64
453 /* "tun_metadata<N>".
454 *
455 * Encapsulation metadata for tunnels.
456 *
457 * Each NXM can be dynamically mapped onto a particular tunnel field using
458 * OpenFlow commands. The individual NXMs can each carry up to 124 bytes
459 * of data and a combined total of 256 across all allocated fields.
460 *
461 * Type: tunnelMD.
462 * Maskable: bitwise.
463 * Formatting: hexadecimal.
464 * Prerequisites: none.
465 * Access: read/write.
466 * NXM: NXM_NX_TUN_METADATA0(40) since v2.5. <0>
467 * NXM: NXM_NX_TUN_METADATA1(41) since v2.5. <1>
468 * NXM: NXM_NX_TUN_METADATA2(42) since v2.5. <2>
469 * NXM: NXM_NX_TUN_METADATA3(43) since v2.5. <3>
470 * NXM: NXM_NX_TUN_METADATA4(44) since v2.5. <4>
471 * NXM: NXM_NX_TUN_METADATA5(45) since v2.5. <5>
472 * NXM: NXM_NX_TUN_METADATA6(46) since v2.5. <6>
473 * NXM: NXM_NX_TUN_METADATA7(47) since v2.5. <7>
474 * NXM: NXM_NX_TUN_METADATA8(48) since v2.5. <8>
475 * NXM: NXM_NX_TUN_METADATA9(49) since v2.5. <9>
476 * NXM: NXM_NX_TUN_METADATA10(50) since v2.5. <10>
477 * NXM: NXM_NX_TUN_METADATA11(51) since v2.5. <11>
478 * NXM: NXM_NX_TUN_METADATA12(52) since v2.5. <12>
479 * NXM: NXM_NX_TUN_METADATA13(53) since v2.5. <13>
480 * NXM: NXM_NX_TUN_METADATA14(54) since v2.5. <14>
481 * NXM: NXM_NX_TUN_METADATA15(55) since v2.5. <15>
482 * NXM: NXM_NX_TUN_METADATA16(56) since v2.5. <16>
483 * NXM: NXM_NX_TUN_METADATA17(57) since v2.5. <17>
484 * NXM: NXM_NX_TUN_METADATA18(58) since v2.5. <18>
485 * NXM: NXM_NX_TUN_METADATA19(59) since v2.5. <19>
486 * NXM: NXM_NX_TUN_METADATA20(60) since v2.5. <20>
487 * NXM: NXM_NX_TUN_METADATA21(61) since v2.5. <21>
488 * NXM: NXM_NX_TUN_METADATA22(62) since v2.5. <22>
489 * NXM: NXM_NX_TUN_METADATA23(63) since v2.5. <23>
490 * NXM: NXM_NX_TUN_METADATA24(64) since v2.5. <24>
491 * NXM: NXM_NX_TUN_METADATA25(65) since v2.5. <25>
492 * NXM: NXM_NX_TUN_METADATA26(66) since v2.5. <26>
493 * NXM: NXM_NX_TUN_METADATA27(67) since v2.5. <27>
494 * NXM: NXM_NX_TUN_METADATA28(68) since v2.5. <28>
495 * NXM: NXM_NX_TUN_METADATA29(69) since v2.5. <29>
496 * NXM: NXM_NX_TUN_METADATA30(70) since v2.5. <30>
497 * NXM: NXM_NX_TUN_METADATA31(71) since v2.5. <31>
498 * NXM: NXM_NX_TUN_METADATA32(72) since v2.5. <32>
499 * NXM: NXM_NX_TUN_METADATA33(73) since v2.5. <33>
500 * NXM: NXM_NX_TUN_METADATA34(74) since v2.5. <34>
501 * NXM: NXM_NX_TUN_METADATA35(75) since v2.5. <35>
502 * NXM: NXM_NX_TUN_METADATA36(76) since v2.5. <36>
503 * NXM: NXM_NX_TUN_METADATA37(77) since v2.5. <37>
504 * NXM: NXM_NX_TUN_METADATA38(78) since v2.5. <38>
505 * NXM: NXM_NX_TUN_METADATA39(79) since v2.5. <39>
506 * NXM: NXM_NX_TUN_METADATA40(80) since v2.5. <40>
507 * NXM: NXM_NX_TUN_METADATA41(81) since v2.5. <41>
508 * NXM: NXM_NX_TUN_METADATA42(82) since v2.5. <42>
509 * NXM: NXM_NX_TUN_METADATA43(83) since v2.5. <43>
510 * NXM: NXM_NX_TUN_METADATA44(84) since v2.5. <44>
511 * NXM: NXM_NX_TUN_METADATA45(85) since v2.5. <45>
512 * NXM: NXM_NX_TUN_METADATA46(86) since v2.5. <46>
513 * NXM: NXM_NX_TUN_METADATA47(87) since v2.5. <47>
514 * NXM: NXM_NX_TUN_METADATA48(88) since v2.5. <48>
515 * NXM: NXM_NX_TUN_METADATA49(89) since v2.5. <49>
516 * NXM: NXM_NX_TUN_METADATA50(90) since v2.5. <50>
517 * NXM: NXM_NX_TUN_METADATA51(91) since v2.5. <51>
518 * NXM: NXM_NX_TUN_METADATA52(92) since v2.5. <52>
519 * NXM: NXM_NX_TUN_METADATA53(93) since v2.5. <53>
520 * NXM: NXM_NX_TUN_METADATA54(94) since v2.5. <54>
521 * NXM: NXM_NX_TUN_METADATA55(95) since v2.5. <55>
522 * NXM: NXM_NX_TUN_METADATA56(96) since v2.5. <56>
523 * NXM: NXM_NX_TUN_METADATA57(97) since v2.5. <57>
524 * NXM: NXM_NX_TUN_METADATA58(98) since v2.5. <58>
525 * NXM: NXM_NX_TUN_METADATA59(99) since v2.5. <59>
526 * NXM: NXM_NX_TUN_METADATA60(100) since v2.5. <60>
527 * NXM: NXM_NX_TUN_METADATA61(101) since v2.5. <61>
528 * NXM: NXM_NX_TUN_METADATA62(102) since v2.5. <62>
529 * NXM: NXM_NX_TUN_METADATA63(103) since v2.5. <63>
530 * OXM: none.
531 */
532 MFF_TUN_METADATA0,
533 MFF_TUN_METADATA1,
534 MFF_TUN_METADATA2,
535 MFF_TUN_METADATA3,
536 MFF_TUN_METADATA4,
537 MFF_TUN_METADATA5,
538 MFF_TUN_METADATA6,
539 MFF_TUN_METADATA7,
540 MFF_TUN_METADATA8,
541 MFF_TUN_METADATA9,
542 MFF_TUN_METADATA10,
543 MFF_TUN_METADATA11,
544 MFF_TUN_METADATA12,
545 MFF_TUN_METADATA13,
546 MFF_TUN_METADATA14,
547 MFF_TUN_METADATA15,
548 MFF_TUN_METADATA16,
549 MFF_TUN_METADATA17,
550 MFF_TUN_METADATA18,
551 MFF_TUN_METADATA19,
552 MFF_TUN_METADATA20,
553 MFF_TUN_METADATA21,
554 MFF_TUN_METADATA22,
555 MFF_TUN_METADATA23,
556 MFF_TUN_METADATA24,
557 MFF_TUN_METADATA25,
558 MFF_TUN_METADATA26,
559 MFF_TUN_METADATA27,
560 MFF_TUN_METADATA28,
561 MFF_TUN_METADATA29,
562 MFF_TUN_METADATA30,
563 MFF_TUN_METADATA31,
564 MFF_TUN_METADATA32,
565 MFF_TUN_METADATA33,
566 MFF_TUN_METADATA34,
567 MFF_TUN_METADATA35,
568 MFF_TUN_METADATA36,
569 MFF_TUN_METADATA37,
570 MFF_TUN_METADATA38,
571 MFF_TUN_METADATA39,
572 MFF_TUN_METADATA40,
573 MFF_TUN_METADATA41,
574 MFF_TUN_METADATA42,
575 MFF_TUN_METADATA43,
576 MFF_TUN_METADATA44,
577 MFF_TUN_METADATA45,
578 MFF_TUN_METADATA46,
579 MFF_TUN_METADATA47,
580 MFF_TUN_METADATA48,
581 MFF_TUN_METADATA49,
582 MFF_TUN_METADATA50,
583 MFF_TUN_METADATA51,
584 MFF_TUN_METADATA52,
585 MFF_TUN_METADATA53,
586 MFF_TUN_METADATA54,
587 MFF_TUN_METADATA55,
588 MFF_TUN_METADATA56,
589 MFF_TUN_METADATA57,
590 MFF_TUN_METADATA58,
591 MFF_TUN_METADATA59,
592 MFF_TUN_METADATA60,
593 MFF_TUN_METADATA61,
594 MFF_TUN_METADATA62,
595 MFF_TUN_METADATA63,
596 #else
597 #error "Need to update MFF_TUN_METADATA* to match TUN_METADATA_NUM_OPTS"
598 #endif
599
600 /* "metadata".
601 *
602 * A scratch pad value standardized in OpenFlow 1.1+. Initially zero, at
603 * the beginning of the pipeline.
604 *
605 * Type: be64.
606 * Maskable: bitwise.
607 * Formatting: hexadecimal.
608 * Prerequisites: none.
609 * Access: read/write.
610 * NXM: none.
611 * OXM: OXM_OF_METADATA(2) since OF1.2 and v1.8.
612 * OF1.1: bitwise mask.
613 */
614 MFF_METADATA,
615
616 /* "in_port".
617 *
618 * 16-bit (OpenFlow 1.0) view of the physical or virtual port on which the
619 * packet was received.
620 *
621 * Type: be16.
622 * Maskable: no.
623 * Formatting: OpenFlow 1.0 port.
624 * Prerequisites: none.
625 * Access: read/write.
626 * NXM: NXM_OF_IN_PORT(0) since v1.1.
627 * OXM: none.
628 * OF1.0: exact match.
629 * OF1.1: exact match.
630 */
631 MFF_IN_PORT,
632
633 /* "in_port_oxm".
634 *
635 * 32-bit (OpenFlow 1.1+) view of the physical or virtual port on which the
636 * packet was received.
637 *
638 * Type: be32.
639 * Maskable: no.
640 * Formatting: OpenFlow 1.1+ port.
641 * Prerequisites: none.
642 * Access: read/write.
643 * NXM: none.
644 * OXM: OXM_OF_IN_PORT(0) since OF1.2 and v1.7.
645 * OF1.1: exact match.
646 */
647 MFF_IN_PORT_OXM,
648
649 /* "actset_output".
650 *
651 * Type: be32.
652 * Maskable: no.
653 * Formatting: OpenFlow 1.1+ port.
654 * Prerequisites: none.
655 * Access: read-only.
656 * NXM: none.
657 * OXM: ONFOXM_ET_ACTSET_OUTPUT(43) since OF1.3 and v2.4,
658 * OXM_OF_ACTSET_OUTPUT(43) since OF1.5 and v2.4.
659 */
660 MFF_ACTSET_OUTPUT,
661
662 /* "skb_priority".
663 *
664 * Designates the queue to which output will be directed. The value in
665 * this field is not necessarily the OpenFlow queue number; with the Linux
666 * kernel switch, it instead has a pair of subfields designating the
667 * "major" and "minor" numbers of a Linux kernel qdisc handle.
668 *
669 * This field is "semi-internal" in that it can be set with the "set_queue"
670 * action but not matched or read or written other ways.
671 *
672 * Type: be32.
673 * Maskable: no.
674 * Formatting: hexadecimal.
675 * Prerequisites: none.
676 * Access: read-only.
677 * NXM: none.
678 * OXM: none.
679 */
680 MFF_SKB_PRIORITY,
681
682 /* "pkt_mark".
683 *
684 * Packet metadata mark. The mark may be passed into other system
685 * components in order to facilitate interaction between subsystems. On
686 * Linux this corresponds to struct sk_buff's "skb_mark" member but the
687 * exact implementation is platform-dependent.
688 *
689 * Type: be32.
690 * Maskable: bitwise.
691 * Formatting: hexadecimal.
692 * Prerequisites: none.
693 * Access: read/write.
694 * NXM: NXM_NX_PKT_MARK(33) since v2.0.
695 * OXM: none.
696 */
697 MFF_PKT_MARK,
698
699 /* "ct_state".
700 *
701 * Connection tracking state. The field is populated by the NXAST_CT
702 * action.
703 *
704 * Type: be32.
705 * Maskable: bitwise.
706 * Formatting: ct state.
707 * Prerequisites: none.
708 * Access: read-only.
709 * NXM: NXM_NX_CT_STATE(105) since v2.5.
710 * OXM: none.
711 */
712 MFF_CT_STATE,
713
714 /* "ct_zone".
715 *
716 * Connection tracking zone. The field is populated by the
717 * NXAST_CT action.
718 *
719 * Type: be16.
720 * Maskable: no.
721 * Formatting: hexadecimal.
722 * Prerequisites: none.
723 * Access: read-only.
724 * NXM: NXM_NX_CT_ZONE(106) since v2.5.
725 * OXM: none.
726 */
727 MFF_CT_ZONE,
728
729 /* "ct_mark".
730 *
731 * Connection tracking mark. The mark is carried with the
732 * connection tracking state. On Linux this corresponds to the
733 * nf_conn's "mark" member but the exact implementation is
734 * platform-dependent.
735 *
736 * Writable only from nested actions within the NXAST_CT action.
737 *
738 * Type: be32.
739 * Maskable: bitwise.
740 * Formatting: hexadecimal.
741 * Prerequisites: none.
742 * Access: read/write.
743 * NXM: NXM_NX_CT_MARK(107) since v2.5.
744 * OXM: none.
745 */
746 MFF_CT_MARK,
747
748 /* "ct_label".
749 *
750 * Connection tracking label. The label is carried with the
751 * connection tracking state. On Linux this is held in the
752 * conntrack label extension but the exact implementation is
753 * platform-dependent.
754 *
755 * Writable only from nested actions within the NXAST_CT action.
756 *
757 * Type: be128.
758 * Maskable: bitwise.
759 * Formatting: hexadecimal.
760 * Prerequisites: none.
761 * Access: read/write.
762 * NXM: NXM_NX_CT_LABEL(108) since v2.5.
763 * OXM: none.
764 */
765 MFF_CT_LABEL,
766
767 /* "ct_nw_proto".
768 *
769 * The "protocol" byte in the IPv4 or IPv6 header for the original
770 * direction conntrack tuple, or of the master conntrack entry, if the
771 * current connection is a related connection.
772 *
773 * The value is initially zero and populated by the CT action. The value
774 * remains zero after the CT action only if the packet can not be
775 * associated with a valid connection, in which case the prerequisites
776 * for matching this field ("CT") are not met.
777 *
778 * Type: u8.
779 * Maskable: no.
780 * Formatting: decimal.
781 * Prerequisites: CT.
782 * Access: read-only.
783 * NXM: NXM_NX_CT_NW_PROTO(119) since v2.8.
784 * OXM: none.
785 */
786 MFF_CT_NW_PROTO,
787
788 /* "ct_nw_src".
789 *
790 * IPv4 source address of the original direction tuple of the conntrack
791 * entry, or of the master conntrack entry, if the current connection is a
792 * related connection.
793 *
794 * The value is populated by the CT action.
795 *
796 * Type: be32.
797 * Maskable: bitwise.
798 * Formatting: IPv4.
799 * Prerequisites: CT.
800 * Access: read-only.
801 * NXM: NXM_NX_CT_NW_SRC(120) since v2.8.
802 * OXM: none.
803 * Prefix lookup member: ct_nw_src.
804 */
805 MFF_CT_NW_SRC,
806
807 /* "ct_nw_dst".
808 *
809 * IPv4 destination address of the original direction tuple of the
810 * conntrack entry, or of the master conntrack entry, if the current
811 * connection is a related connection.
812 *
813 * The value is populated by the CT action.
814 *
815 * Type: be32.
816 * Maskable: bitwise.
817 * Formatting: IPv4.
818 * Prerequisites: CT.
819 * Access: read-only.
820 * NXM: NXM_NX_CT_NW_DST(121) since v2.8.
821 * OXM: none.
822 * Prefix lookup member: ct_nw_dst.
823 */
824 MFF_CT_NW_DST,
825
826 /* "ct_ipv6_src".
827 *
828 * IPv6 source address of the original direction tuple of the conntrack
829 * entry, or of the master conntrack entry, if the current connection is a
830 * related connection.
831 *
832 * The value is populated by the CT action.
833 *
834 * Type: be128.
835 * Maskable: bitwise.
836 * Formatting: IPv6.
837 * Prerequisites: CT.
838 * Access: read-only.
839 * NXM: NXM_NX_CT_IPV6_SRC(122) since v2.8.
840 * OXM: none.
841 * Prefix lookup member: ct_ipv6_src.
842 */
843 MFF_CT_IPV6_SRC,
844
845 /* "ct_ipv6_dst".
846 *
847 * IPv6 destination address of the original direction tuple of the
848 * conntrack entry, or of the master conntrack entry, if the current
849 * connection is a related connection.
850 *
851 * The value is populated by the CT action.
852 *
853 * Type: be128.
854 * Maskable: bitwise.
855 * Formatting: IPv6.
856 * Prerequisites: CT.
857 * Access: read-only.
858 * NXM: NXM_NX_CT_IPV6_DST(123) since v2.8.
859 * OXM: none.
860 * Prefix lookup member: ct_ipv6_dst.
861 */
862 MFF_CT_IPV6_DST,
863
864 /* "ct_tp_src".
865 *
866 * Transport layer source port of the original direction tuple of the
867 * conntrack entry, or of the master conntrack entry, if the current
868 * connection is a related connection.
869 *
870 * The value is populated by the CT action.
871 *
872 * Type: be16.
873 * Maskable: bitwise.
874 * Formatting: decimal.
875 * Prerequisites: CT.
876 * Access: read-only.
877 * NXM: NXM_NX_CT_TP_SRC(124) since v2.8.
878 * OXM: none.
879 */
880 MFF_CT_TP_SRC,
881
882 /* "ct_tp_dst".
883 *
884 * Transport layer destination port of the original direction tuple of the
885 * conntrack entry, or of the master conntrack entry, if the current
886 * connection is a related connection.
887 *
888 * The value is populated by the CT action.
889 *
890 * Type: be16.
891 * Maskable: bitwise.
892 * Formatting: decimal.
893 * Prerequisites: CT.
894 * Access: read-only.
895 * NXM: NXM_NX_CT_TP_DST(125) since v2.8.
896 * OXM: none.
897 */
898 MFF_CT_TP_DST,
899
900 #if FLOW_N_REGS == 16
901 /* "reg<N>".
902 *
903 * Nicira extension scratch pad register with initial value 0.
904 *
905 * Type: be32.
906 * Maskable: bitwise.
907 * Formatting: hexadecimal.
908 * Prerequisites: none.
909 * Access: read/write.
910 * NXM: NXM_NX_REG0(0) since v1.1. <0>
911 * NXM: NXM_NX_REG1(1) since v1.1. <1>
912 * NXM: NXM_NX_REG2(2) since v1.1. <2>
913 * NXM: NXM_NX_REG3(3) since v1.1. <3>
914 * NXM: NXM_NX_REG4(4) since v1.3. <4>
915 * NXM: NXM_NX_REG5(5) since v1.7. <5>
916 * NXM: NXM_NX_REG6(6) since v1.7. <6>
917 * NXM: NXM_NX_REG7(7) since v1.7. <7>
918 * NXM: NXM_NX_REG8(8) since v2.6. <8>
919 * NXM: NXM_NX_REG9(9) since v2.6. <9>
920 * NXM: NXM_NX_REG10(10) since v2.6. <10>
921 * NXM: NXM_NX_REG11(11) since v2.6. <11>
922 * NXM: NXM_NX_REG12(12) since v2.6. <12>
923 * NXM: NXM_NX_REG13(13) since v2.6. <13>
924 * NXM: NXM_NX_REG14(14) since v2.6. <14>
925 * NXM: NXM_NX_REG15(15) since v2.6. <15>
926 * OXM: none.
927 */
928 MFF_REG0,
929 MFF_REG1,
930 MFF_REG2,
931 MFF_REG3,
932 MFF_REG4,
933 MFF_REG5,
934 MFF_REG6,
935 MFF_REG7,
936 MFF_REG8,
937 MFF_REG9,
938 MFF_REG10,
939 MFF_REG11,
940 MFF_REG12,
941 MFF_REG13,
942 MFF_REG14,
943 MFF_REG15,
944 #else
945 #error "Need to update MFF_REG* to match FLOW_N_REGS"
946 #endif
947
948 #if FLOW_N_XREGS == 8
949 /* "xreg<N>".
950 *
951 * OpenFlow 1.5 ``extended register".
952 *
953 * Type: be64.
954 * Maskable: bitwise.
955 * Formatting: hexadecimal.
956 * Prerequisites: none.
957 * Access: read/write.
958 * NXM: none.
959 * OXM: OXM_OF_PKT_REG<N>(<N>) since OF1.3 and v2.4.
960 */
961 MFF_XREG0,
962 MFF_XREG1,
963 MFF_XREG2,
964 MFF_XREG3,
965 MFF_XREG4,
966 MFF_XREG5,
967 MFF_XREG6,
968 MFF_XREG7,
969 #else
970 #error "Need to update MFF_REG* to match FLOW_N_XREGS"
971 #endif
972
973 #if FLOW_N_XXREGS == 4
974 /* "xxreg<N>".
975 *
976 * ``extended-extended register".
977 *
978 * Type: be128.
979 * Maskable: bitwise.
980 * Formatting: hexadecimal.
981 * Prerequisites: none.
982 * Access: read/write.
983 * NXM: NXM_NX_XXREG0(111) since v2.6. <0>
984 * NXM: NXM_NX_XXREG1(112) since v2.6. <1>
985 * NXM: NXM_NX_XXREG2(113) since v2.6. <2>
986 * NXM: NXM_NX_XXREG3(114) since v2.6. <3>
987 * NXM: NXM_NX_XXREG4(115) since vX.Y. <4>
988 * NXM: NXM_NX_XXREG5(116) since vX.Y. <5>
989 * NXM: NXM_NX_XXREG6(117) since vX.Y. <6>
990 * NXM: NXM_NX_XXREG7(118) since vX.Y. <7>
991 * OXM: none.
992 */
993 MFF_XXREG0,
994 MFF_XXREG1,
995 MFF_XXREG2,
996 MFF_XXREG3,
997 #else
998 #error "Need to update MFF_REG* to match FLOW_N_XXREGS"
999 #endif
1000
1001 /* ## -------- ## */
1002 /* ## Ethernet ## */
1003 /* ## -------- ## */
1004
1005 /* "eth_src" (aka "dl_src").
1006 *
1007 * Source address in Ethernet header.
1008 *
1009 * Type: MAC.
1010 * Maskable: bitwise.
1011 * Formatting: Ethernet.
1012 * Prerequisites: Ethernet.
1013 * Access: read/write.
1014 * NXM: NXM_OF_ETH_SRC(2) since v1.1.
1015 * OXM: OXM_OF_ETH_SRC(4) since OF1.2 and v1.7.
1016 * OF1.0: exact match.
1017 * OF1.1: bitwise mask.
1018 */
1019 MFF_ETH_SRC,
1020
1021 /* "eth_dst" (aka "dl_dst").
1022 *
1023 * Destination address in Ethernet header.
1024 *
1025 * Type: MAC.
1026 * Maskable: bitwise.
1027 * Formatting: Ethernet.
1028 * Prerequisites: Ethernet.
1029 * Access: read/write.
1030 * NXM: NXM_OF_ETH_DST(1) since v1.1.
1031 * OXM: OXM_OF_ETH_DST(3) since OF1.2 and v1.7.
1032 * OF1.0: exact match.
1033 * OF1.1: bitwise mask.
1034 */
1035 MFF_ETH_DST,
1036
1037 /* "eth_type" (aka "dl_type").
1038 *
1039 * Packet's Ethernet type.
1040 *
1041 * For a packet with an 802.1Q header, this is the type of the encapsulated
1042 * frame.
1043 *
1044 * Type: be16.
1045 * Maskable: no.
1046 * Formatting: hexadecimal.
1047 * Prerequisites: Ethernet.
1048 * Access: read-only.
1049 * NXM: NXM_OF_ETH_TYPE(3) since v1.1.
1050 * OXM: OXM_OF_ETH_TYPE(5) since OF1.2 and v1.7.
1051 * OF1.0: exact match.
1052 * OF1.1: exact match.
1053 */
1054 MFF_ETH_TYPE,
1055
1056 /* ## ---- ## */
1057 /* ## VLAN ## */
1058 /* ## ---- ## */
1059
1060 /* It looks odd for vlan_tci, vlan_vid, and vlan_pcp to say that they are
1061 * supported in OF1.0 and OF1.1, since the detailed semantics of these fields
1062 * only apply to NXM or OXM. They are marked as supported for exact matches in
1063 * OF1.0 and OF1.1 because exact matches on those fields can be successfully
1064 * translated into the OF1.0 and OF1.1 flow formats. */
1065
1066 /* "vlan_tci".
1067 *
1068 * 802.1Q TCI.
1069 *
1070 * For a packet with an 802.1Q header, this is the Tag Control Information
1071 * (TCI) field, with the CFI bit forced to 1. For a packet with no 802.1Q
1072 * header, this has value 0.
1073 *
1074 * Type: be16.
1075 * Maskable: bitwise.
1076 * Formatting: hexadecimal.
1077 * Prerequisites: Ethernet.
1078 * Access: read/write.
1079 * NXM: NXM_OF_VLAN_TCI(4) since v1.1.
1080 * OXM: none.
1081 * OF1.0: exact match.
1082 * OF1.1: exact match.
1083 */
1084 MFF_VLAN_TCI,
1085
1086 /* "dl_vlan" (OpenFlow 1.0).
1087 *
1088 * VLAN ID field. Zero if no 802.1Q header is present.
1089 *
1090 * Type: be16 (low 12 bits).
1091 * Maskable: no.
1092 * Formatting: decimal.
1093 * Prerequisites: Ethernet.
1094 * Access: read/write.
1095 * NXM: none.
1096 * OXM: none.
1097 * OF1.0: exact match.
1098 * OF1.1: exact match.
1099 */
1100 MFF_DL_VLAN,
1101
1102 /* "vlan_vid" (OpenFlow 1.2+).
1103 *
1104 * If an 802.1Q header is present, this field's value is 0x1000
1105 * bitwise-or'd with the VLAN ID. If no 802.1Q is present, this field's
1106 * value is 0.
1107 *
1108 * Type: be16 (low 12 bits).
1109 * Maskable: bitwise.
1110 * Formatting: decimal.
1111 * Prerequisites: Ethernet.
1112 * Access: read/write.
1113 * NXM: none.
1114 * OXM: OXM_OF_VLAN_VID(6) since OF1.2 and v1.7.
1115 * OF1.0: exact match.
1116 * OF1.1: exact match.
1117 */
1118 MFF_VLAN_VID,
1119
1120 /* "dl_vlan_pcp" (OpenFlow 1.0).
1121 *
1122 * VLAN priority (PCP) field. Zero if no 802.1Q header is present.
1123 *
1124 * Type: u8 (low 3 bits).
1125 * Maskable: no.
1126 * Formatting: decimal.
1127 * Prerequisites: Ethernet.
1128 * Access: read/write.
1129 * NXM: none.
1130 * OXM: none.
1131 * OF1.0: exact match.
1132 * OF1.1: exact match.
1133 */
1134 MFF_DL_VLAN_PCP,
1135
1136 /* "vlan_pcp" (OpenFlow 1.2+).
1137 *
1138 * VLAN priority (PCP) field. Zero if no 802.1Q header is present.
1139 *
1140 * Type: u8 (low 3 bits).
1141 * Maskable: no.
1142 * Formatting: decimal.
1143 * Prerequisites: VLAN VID.
1144 * Access: read/write.
1145 * NXM: none.
1146 * OXM: OXM_OF_VLAN_PCP(7) since OF1.2 and v1.7.
1147 * OF1.0: exact match.
1148 * OF1.1: exact match.
1149 */
1150 MFF_VLAN_PCP,
1151
1152 /* ## ---- ## */
1153 /* ## MPLS ## */
1154 /* ## ---- ## */
1155
1156 /* "mpls_label".
1157 *
1158 * The outermost MPLS label, or 0 if no MPLS labels are present.
1159 *
1160 * Type: be32 (low 20 bits).
1161 * Maskable: no.
1162 * Formatting: decimal.
1163 * Prerequisites: MPLS.
1164 * Access: read/write.
1165 * NXM: none.
1166 * OXM: OXM_OF_MPLS_LABEL(34) since OF1.2 and v1.11.
1167 * OF1.1: exact match.
1168 */
1169 MFF_MPLS_LABEL,
1170
1171 /* "mpls_tc".
1172 *
1173 * The outermost MPLS label's traffic control (TC) field, or 0 if no MPLS
1174 * labels are present.
1175 *
1176 * Type: u8 (low 3 bits).
1177 * Maskable: no.
1178 * Formatting: decimal.
1179 * Prerequisites: MPLS.
1180 * Access: read/write.
1181 * NXM: none.
1182 * OXM: OXM_OF_MPLS_TC(35) since OF1.2 and v1.11.
1183 * OF1.1: exact match.
1184 */
1185 MFF_MPLS_TC,
1186
1187 /* "mpls_bos".
1188 *
1189 * The outermost MPLS label's bottom of stack (BoS) field, or 0 if no MPLS
1190 * labels are present.
1191 *
1192 * Type: u8 (low 1 bits).
1193 * Maskable: no.
1194 * Formatting: decimal.
1195 * Prerequisites: MPLS.
1196 * Access: read-only.
1197 * NXM: none.
1198 * OXM: OXM_OF_MPLS_BOS(36) since OF1.3 and v1.11.
1199 */
1200 MFF_MPLS_BOS,
1201
1202 /* "mpls_ttl".
1203 *
1204 * The outermost MPLS label's time-to-live (TTL) field, or 0 if no MPLS
1205 * labels are present.
1206 *
1207 * Type: u8.
1208 * Maskable: no.
1209 * Formatting: decimal.
1210 * Prerequisites: MPLS.
1211 * Access: read/write.
1212 * NXM: NXM_NX_MPLS_TTL(30) since v2.6.
1213 * OXM: none.
1214 */
1215 MFF_MPLS_TTL,
1216
1217 /* ## ---- ## */
1218 /* ## IPv4 ## */
1219 /* ## ---- ## */
1220
1221 /* Update mf_is_l3_or_higher() if MFF_IPV4_SRC is no longer the first element
1222 * for a field of layer 3 or higher */
1223
1224 /* "ip_src" (aka "nw_src").
1225 *
1226 * The source address in the IPv4 header.
1227 *
1228 * Before Open vSwitch 1.8, only CIDR masks were supported.
1229 *
1230 * Type: be32.
1231 * Maskable: bitwise.
1232 * Formatting: IPv4.
1233 * Prerequisites: IPv4.
1234 * Access: read/write.
1235 * NXM: NXM_OF_IP_SRC(7) since v1.1.
1236 * OXM: OXM_OF_IPV4_SRC(11) since OF1.2 and v1.7.
1237 * OF1.0: CIDR mask.
1238 * OF1.1: bitwise mask.
1239 * Prefix lookup member: nw_src.
1240 */
1241 MFF_IPV4_SRC,
1242
1243 /* "ip_dst" (aka "nw_dst").
1244 *
1245 * The destination address in the IPv4 header.
1246 *
1247 * Before Open vSwitch 1.8, only CIDR masks were supported.
1248 *
1249 * Type: be32.
1250 * Maskable: bitwise.
1251 * Formatting: IPv4.
1252 * Prerequisites: IPv4.
1253 * Access: read/write.
1254 * NXM: NXM_OF_IP_DST(8) since v1.1.
1255 * OXM: OXM_OF_IPV4_DST(12) since OF1.2 and v1.7.
1256 * OF1.0: CIDR mask.
1257 * OF1.1: bitwise mask.
1258 * Prefix lookup member: nw_dst.
1259 */
1260 MFF_IPV4_DST,
1261
1262 /* ## ---- ## */
1263 /* ## IPv6 ## */
1264 /* ## ---- ## */
1265
1266 /* "ipv6_src".
1267 *
1268 * The source address in the IPv6 header.
1269 *
1270 * Type: be128.
1271 * Maskable: bitwise.
1272 * Formatting: IPv6.
1273 * Prerequisites: IPv6.
1274 * Access: read/write.
1275 * NXM: NXM_NX_IPV6_SRC(19) since v1.1.
1276 * OXM: OXM_OF_IPV6_SRC(26) since OF1.2 and v1.1.
1277 * Prefix lookup member: ipv6_src.
1278 */
1279 MFF_IPV6_SRC,
1280
1281 /* "ipv6_dst".
1282 *
1283 * The destination address in the IPv6 header.
1284 *
1285 * Type: be128.
1286 * Maskable: bitwise.
1287 * Formatting: IPv6.
1288 * Prerequisites: IPv6.
1289 * Access: read/write.
1290 * NXM: NXM_NX_IPV6_DST(20) since v1.1.
1291 * OXM: OXM_OF_IPV6_DST(27) since OF1.2 and v1.1.
1292 * Prefix lookup member: ipv6_dst.
1293 */
1294 MFF_IPV6_DST,
1295
1296 /* "ipv6_label".
1297 *
1298 * The flow label in the IPv6 header.
1299 *
1300 * Type: be32 (low 20 bits).
1301 * Maskable: bitwise.
1302 * Formatting: hexadecimal.
1303 * Prerequisites: IPv6.
1304 * Access: read/write.
1305 * NXM: NXM_NX_IPV6_LABEL(27) since v1.4.
1306 * OXM: OXM_OF_IPV6_FLABEL(28) since OF1.2 and v1.7.
1307 */
1308 MFF_IPV6_LABEL,
1309
1310 /* ## ----------------------- ## */
1311 /* ## IPv4/IPv6 common fields ## */
1312 /* ## ----------------------- ## */
1313
1314 /* "nw_proto" (aka "ip_proto").
1315 *
1316 * The "protocol" byte in the IPv4 or IPv6 header.
1317 *
1318 * Type: u8.
1319 * Maskable: no.
1320 * Formatting: decimal.
1321 * Prerequisites: IPv4/IPv6.
1322 * Access: read-only.
1323 * NXM: NXM_OF_IP_PROTO(6) since v1.1.
1324 * OXM: OXM_OF_IP_PROTO(10) since OF1.2 and v1.7.
1325 * OF1.0: exact match.
1326 * OF1.1: exact match.
1327 */
1328 MFF_IP_PROTO,
1329
1330 /* Both views of the DSCP below are marked as supported in all of the versions
1331 * of OpenFlow because a match on either view can be successfully translated
1332 * into every OpenFlow flow format. */
1333
1334 /* "nw_tos" (OpenFlow 1.0/1.1).
1335 *
1336 * The DSCP byte in the IPv4 header or the traffic class byte from the IPv6
1337 * header, with the ECN bits forced to 0. (That is, bits 2-7 contain the
1338 * type of service and bits 0-1 are zero.)
1339 *
1340 * Type: u8.
1341 * Maskable: no.
1342 * Formatting: decimal.
1343 * Prerequisites: IPv4/IPv6.
1344 * Access: read/write.
1345 * NXM: NXM_OF_IP_TOS(5) since v1.1.
1346 * OXM: none.
1347 * OF1.0: exact match.
1348 * OF1.1: exact match.
1349 */
1350 MFF_IP_DSCP,
1351
1352 /* "ip_dscp" (OpenFlow 1.2+).
1353 *
1354 * The DSCP byte in the IPv4 header or the traffic class byte from the IPv6
1355 * header, shifted right 2 bits. (That is, bits 0-5 contain the type of
1356 * service and bits 6-7 are zero.)
1357 *
1358 * Type: u8 (low 6 bits).
1359 * Maskable: no.
1360 * Formatting: decimal.
1361 * Prerequisites: IPv4/IPv6.
1362 * Access: read/write.
1363 * NXM: none.
1364 * OXM: OXM_OF_IP_DSCP(8) since OF1.2 and v1.7.
1365 * OF1.0: exact match.
1366 * OF1.1: exact match.
1367 */
1368 MFF_IP_DSCP_SHIFTED,
1369
1370 /* "nw_ecn" (aka "ip_ecn").
1371 *
1372 * The ECN bits in the IPv4 or IPv6 header.
1373 *
1374 * Type: u8 (low 2 bits).
1375 * Maskable: no.
1376 * Formatting: decimal.
1377 * Prerequisites: IPv4/IPv6.
1378 * Access: read/write.
1379 * NXM: NXM_NX_IP_ECN(28) since v1.4.
1380 * OXM: OXM_OF_IP_ECN(9) since OF1.2 and v1.7.
1381 * OF1.1: exact match.
1382 */
1383 MFF_IP_ECN,
1384
1385 /* "nw_ttl".
1386 *
1387 * The time-to-live (TTL) in the IPv4 header or hop limit in the IPv6
1388 * header.
1389 *
1390 * Type: u8.
1391 * Maskable: no.
1392 * Formatting: decimal.
1393 * Prerequisites: IPv4/IPv6.
1394 * Access: read/write.
1395 * NXM: NXM_NX_IP_TTL(29) since v1.4.
1396 * OXM: none.
1397 */
1398 MFF_IP_TTL,
1399
1400 /* "ip_frag".
1401 *
1402 * IP fragment information.
1403 *
1404 * Type: u8 (low 2 bits).
1405 * Maskable: bitwise.
1406 * Formatting: frag.
1407 * Prerequisites: IPv4/IPv6.
1408 * Access: read-only.
1409 * NXM: NXM_NX_IP_FRAG(26) since v1.3.
1410 * OXM: none.
1411 */
1412 MFF_IP_FRAG,
1413
1414 /* ## --- ## */
1415 /* ## ARP ## */
1416 /* ## --- ## */
1417
1418 /* "arp_op".
1419 *
1420 * ARP opcode.
1421 *
1422 * For an Ethernet+IP ARP packet, the opcode in the ARP header. Always 0
1423 * otherwise. Only ARP opcodes between 1 and 255 should be specified for
1424 * matching.
1425 *
1426 * Type: be16.
1427 * Maskable: no.
1428 * Formatting: decimal.
1429 * Prerequisites: ARP.
1430 * Access: read/write.
1431 * NXM: NXM_OF_ARP_OP(15) since v1.1.
1432 * OXM: OXM_OF_ARP_OP(21) since OF1.2 and v1.7.
1433 * OF1.0: exact match.
1434 * OF1.1: exact match.
1435 */
1436 MFF_ARP_OP,
1437
1438 /* "arp_spa".
1439 *
1440 * For an Ethernet+IP ARP packet, the source protocol (IPv4) address in the
1441 * ARP header. Always 0 otherwise.
1442 *
1443 * Before Open vSwitch 1.8, only CIDR masks were supported.
1444 *
1445 * Type: be32.
1446 * Maskable: bitwise.
1447 * Formatting: IPv4.
1448 * Prerequisites: ARP.
1449 * Access: read/write.
1450 * NXM: NXM_OF_ARP_SPA(16) since v1.1.
1451 * OXM: OXM_OF_ARP_SPA(22) since OF1.2 and v1.7.
1452 * OF1.0: CIDR mask.
1453 * OF1.1: bitwise mask.
1454 */
1455 MFF_ARP_SPA,
1456
1457 /* "arp_tpa".
1458 *
1459 * For an Ethernet+IP ARP packet, the target protocol (IPv4) address in the
1460 * ARP header. Always 0 otherwise.
1461 *
1462 * Before Open vSwitch 1.8, only CIDR masks were supported.
1463 *
1464 * Type: be32.
1465 * Maskable: bitwise.
1466 * Formatting: IPv4.
1467 * Prerequisites: ARP.
1468 * Access: read/write.
1469 * NXM: NXM_OF_ARP_TPA(17) since v1.1.
1470 * OXM: OXM_OF_ARP_TPA(23) since OF1.2 and v1.7.
1471 * OF1.0: CIDR mask.
1472 * OF1.1: bitwise mask.
1473 */
1474 MFF_ARP_TPA,
1475
1476 /* "arp_sha".
1477 *
1478 * For an Ethernet+IP ARP packet, the source hardware (Ethernet) address in
1479 * the ARP header. Always 0 otherwise.
1480 *
1481 * Type: MAC.
1482 * Maskable: bitwise.
1483 * Formatting: Ethernet.
1484 * Prerequisites: ARP.
1485 * Access: read/write.
1486 * NXM: NXM_NX_ARP_SHA(17) since v1.1.
1487 * OXM: OXM_OF_ARP_SHA(24) since OF1.2 and v1.7.
1488 */
1489 MFF_ARP_SHA,
1490
1491 /* "arp_tha".
1492 *
1493 * For an Ethernet+IP ARP packet, the target hardware (Ethernet) address in
1494 * the ARP header. Always 0 otherwise.
1495 *
1496 * Type: MAC.
1497 * Maskable: bitwise.
1498 * Formatting: Ethernet.
1499 * Prerequisites: ARP.
1500 * Access: read/write.
1501 * NXM: NXM_NX_ARP_THA(18) since v1.1.
1502 * OXM: OXM_OF_ARP_THA(25) since OF1.2 and v1.7.
1503 */
1504 MFF_ARP_THA,
1505
1506 /* ## --- ## */
1507 /* ## TCP ## */
1508 /* ## --- ## */
1509
1510 /* "tcp_src" (aka "tp_src").
1511 *
1512 * TCP source port.
1513 *
1514 * Type: be16.
1515 * Maskable: bitwise.
1516 * Formatting: decimal.
1517 * Prerequisites: TCP.
1518 * Access: read/write.
1519 * NXM: NXM_OF_TCP_SRC(9) since v1.1.
1520 * OXM: OXM_OF_TCP_SRC(13) since OF1.2 and v1.7.
1521 * OF1.0: exact match.
1522 * OF1.1: exact match.
1523 */
1524 MFF_TCP_SRC,
1525
1526 /* "tcp_dst" (aka "tp_dst").
1527 *
1528 * TCP destination port.
1529 *
1530 * Type: be16.
1531 * Maskable: bitwise.
1532 * Formatting: decimal.
1533 * Prerequisites: TCP.
1534 * Access: read/write.
1535 * NXM: NXM_OF_TCP_DST(10) since v1.1.
1536 * OXM: OXM_OF_TCP_DST(14) since OF1.2 and v1.7.
1537 * OF1.0: exact match.
1538 * OF1.1: exact match.
1539 */
1540 MFF_TCP_DST,
1541
1542 /* "tcp_flags".
1543 *
1544 * Flags in the TCP header.
1545 *
1546 * TCP currently defines 9 flag bits, and additional 3 bits are reserved
1547 * (must be transmitted as zero). See RFCs 793, 3168, and 3540.
1548 *
1549 * Type: be16 (low 12 bits).
1550 * Maskable: bitwise.
1551 * Formatting: TCP flags.
1552 * Prerequisites: TCP.
1553 * Access: read-only.
1554 * NXM: NXM_NX_TCP_FLAGS(34) since v2.1.
1555 * OXM: ONFOXM_ET_TCP_FLAGS(42) since OF1.3 and v2.4,
1556 * OXM_OF_TCP_FLAGS(42) since OF1.5 and v2.3.
1557 */
1558 MFF_TCP_FLAGS,
1559
1560 /* ## --- ## */
1561 /* ## UDP ## */
1562 /* ## --- ## */
1563
1564 /* "udp_src".
1565 *
1566 * UDP source port.
1567 *
1568 * Type: be16.
1569 * Maskable: bitwise.
1570 * Formatting: decimal.
1571 * Prerequisites: UDP.
1572 * Access: read/write.
1573 * NXM: NXM_OF_UDP_SRC(11) since v1.1.
1574 * OXM: OXM_OF_UDP_SRC(15) since OF1.2 and v1.7.
1575 * OF1.0: exact match.
1576 * OF1.1: exact match.
1577 */
1578 MFF_UDP_SRC,
1579
1580 /* "udp_dst".
1581 *
1582 * UDP destination port
1583 *
1584 * Type: be16.
1585 * Maskable: bitwise.
1586 * Formatting: decimal.
1587 * Prerequisites: UDP.
1588 * Access: read/write.
1589 * NXM: NXM_OF_UDP_DST(12) since v1.1.
1590 * OXM: OXM_OF_UDP_DST(16) since OF1.2 and v1.7.
1591 * OF1.0: exact match.
1592 * OF1.1: exact match.
1593 */
1594 MFF_UDP_DST,
1595
1596 /* ## ---- ## */
1597 /* ## SCTP ## */
1598 /* ## ---- ## */
1599
1600 /* "sctp_src".
1601 *
1602 * SCTP source port.
1603 *
1604 * Type: be16.
1605 * Maskable: bitwise.
1606 * Formatting: decimal.
1607 * Prerequisites: SCTP.
1608 * Access: read/write.
1609 * NXM: none.
1610 * OXM: OXM_OF_SCTP_SRC(17) since OF1.2 and v2.0.
1611 * OF1.1: exact match.
1612 */
1613 MFF_SCTP_SRC,
1614
1615 /* "sctp_dst".
1616 *
1617 * SCTP destination port.
1618 *
1619 * Type: be16.
1620 * Maskable: bitwise.
1621 * Formatting: decimal.
1622 * Prerequisites: SCTP.
1623 * Access: read/write.
1624 * NXM: none.
1625 * OXM: OXM_OF_SCTP_DST(18) since OF1.2 and v2.0.
1626 * OF1.1: exact match.
1627 */
1628 MFF_SCTP_DST,
1629
1630 /* ## ---- ## */
1631 /* ## ICMP ## */
1632 /* ## ---- ## */
1633
1634 /* "icmp_type".
1635 *
1636 * ICMPv4 type.
1637 *
1638 * Type: u8.
1639 * Maskable: no.
1640 * Formatting: decimal.
1641 * Prerequisites: ICMPv4.
1642 * Access: read/write.
1643 * NXM: NXM_OF_ICMP_TYPE(13) since v1.1.
1644 * OXM: OXM_OF_ICMPV4_TYPE(19) since OF1.2 and v1.7.
1645 * OF1.0: exact match.
1646 * OF1.1: exact match.
1647 */
1648 MFF_ICMPV4_TYPE,
1649
1650 /* "icmp_code".
1651 *
1652 * ICMPv4 code.
1653 *
1654 * Type: u8.
1655 * Maskable: no.
1656 * Formatting: decimal.
1657 * Prerequisites: ICMPv4.
1658 * Access: read/write.
1659 * NXM: NXM_OF_ICMP_CODE(14) since v1.1.
1660 * OXM: OXM_OF_ICMPV4_CODE(20) since OF1.2 and v1.7.
1661 * OF1.0: exact match.
1662 * OF1.1: exact match.
1663 */
1664 MFF_ICMPV4_CODE,
1665
1666 /* "icmpv6_type".
1667 *
1668 * ICMPv6 type.
1669 *
1670 * Type: u8.
1671 * Maskable: no.
1672 * Formatting: decimal.
1673 * Prerequisites: ICMPv6.
1674 * Access: read/write.
1675 * NXM: NXM_NX_ICMPV6_TYPE(21) since v1.1.
1676 * OXM: OXM_OF_ICMPV6_TYPE(29) since OF1.2 and v1.7.
1677 */
1678 MFF_ICMPV6_TYPE,
1679
1680 /* "icmpv6_code".
1681 *
1682 * ICMPv6 code.
1683 *
1684 * Type: u8.
1685 * Maskable: no.
1686 * Formatting: decimal.
1687 * Prerequisites: ICMPv6.
1688 * Access: read/write.
1689 * NXM: NXM_NX_ICMPV6_CODE(22) since v1.1.
1690 * OXM: OXM_OF_ICMPV6_CODE(30) since OF1.2 and v1.7.
1691 */
1692 MFF_ICMPV6_CODE,
1693
1694 /* ## ------------------------- ## */
1695 /* ## ICMPv6 Neighbor Discovery ## */
1696 /* ## ------------------------- ## */
1697
1698 /* "nd_target".
1699 *
1700 * The target address in an IPv6 Neighbor Discovery message.
1701 *
1702 * Before Open vSwitch 1.8, only CIDR masks were supported.
1703 *
1704 * Type: be128.
1705 * Maskable: bitwise.
1706 * Formatting: IPv6.
1707 * Prerequisites: ND.
1708 * Access: read/write.
1709 * NXM: NXM_NX_ND_TARGET(23) since v1.1.
1710 * OXM: OXM_OF_IPV6_ND_TARGET(31) since OF1.2 and v1.7.
1711 */
1712 MFF_ND_TARGET,
1713
1714 /* "nd_sll".
1715 *
1716 * The source link layer address in an IPv6 Neighbor Discovery message.
1717 *
1718 * Type: MAC.
1719 * Maskable: bitwise.
1720 * Formatting: Ethernet.
1721 * Prerequisites: ND solicit.
1722 * Access: read/write.
1723 * NXM: NXM_NX_ND_SLL(24) since v1.1.
1724 * OXM: OXM_OF_IPV6_ND_SLL(32) since OF1.2 and v1.7.
1725 */
1726 MFF_ND_SLL,
1727
1728 /* "nd_tll".
1729 *
1730 * The target link layer address in an IPv6 Neighbor Discovery message.
1731 *
1732 * Type: MAC.
1733 * Maskable: bitwise.
1734 * Formatting: Ethernet.
1735 * Prerequisites: ND advert.
1736 * Access: read/write.
1737 * NXM: NXM_NX_ND_TLL(25) since v1.1.
1738 * OXM: OXM_OF_IPV6_ND_TLL(33) since OF1.2 and v1.7.
1739 */
1740 MFF_ND_TLL,
1741
1742 /* ## ---- ## */
1743 /* ## NSH ## */
1744 /* ## ---- ## */
1745
1746 /* "nsh_flags".
1747 *
1748 * flags field in NSH base header.
1749 *
1750 * Type: u8.
1751 * Maskable: bitwise.
1752 * Formatting: decimal.
1753 * Prerequisites: NSH.
1754 * Access: read/write.
1755 * NXM: none.
1756 * OXM: NXOXM_NSH_FLAGS(1) since OF1.3 and v2.8.
1757 */
1758 MFF_NSH_FLAGS,
1759
1760 /* "nsh_mdtype".
1761 *
1762 * mdtype field in NSH base header.
1763 *
1764 * Type: u8.
1765 * Maskable: no.
1766 * Formatting: decimal.
1767 * Prerequisites: NSH.
1768 * Access: read-only.
1769 * NXM: none.
1770 * OXM: NXOXM_NSH_MDTYPE(2) since OF1.3 and v2.8.
1771 */
1772 MFF_NSH_MDTYPE,
1773
1774 /* "nsh_np".
1775 *
1776 * np (next protocol) field in NSH base header.
1777 *
1778 * Type: u8.
1779 * Maskable: no.
1780 * Formatting: decimal.
1781 * Prerequisites: NSH.
1782 * Access: read-only.
1783 * NXM: none.
1784 * OXM: NXOXM_NSH_NP(3) since OF1.3 and v2.8.
1785 */
1786 MFF_NSH_NP,
1787
1788 /* "nsh_spi" (aka "nsp").
1789 *
1790 * spi (service path identifier) field in NSH base header.
1791 *
1792 * Type: be32 (low 24 bits).
1793 * Maskable: no.
1794 * Formatting: hexadecimal.
1795 * Prerequisites: NSH.
1796 * Access: read/write.
1797 * NXM: none.
1798 * OXM: NXOXM_NSH_SPI(4) since OF1.3 and v2.8.
1799 */
1800 MFF_NSH_SPI,
1801
1802 /* "nsh_si" (aka "nsi").
1803 *
1804 * si (service index) field in NSH base header.
1805 *
1806 * Type: u8.
1807 * Maskable: no.
1808 * Formatting: decimal.
1809 * Prerequisites: NSH.
1810 * Access: read/write.
1811 * NXM: none.
1812 * OXM: NXOXM_NSH_SI(5) since OF1.3 and v2.8.
1813 */
1814 MFF_NSH_SI,
1815
1816 /* "nsh_c<N>" (aka "nshc<N>").
1817 *
1818 * context fields in NSH context header.
1819 *
1820 * Type: be32.
1821 * Maskable: bitwise.
1822 * Formatting: hexadecimal.
1823 * Prerequisites: NSH.
1824 * Access: read/write.
1825 * NXM: none.
1826 * OXM: NXOXM_NSH_C1(6) since OF1.3 and v2.8. <1>
1827 * OXM: NXOXM_NSH_C2(7) since OF1.3 and v2.8. <2>
1828 * OXM: NXOXM_NSH_C3(8) since OF1.3 and v2.8. <3>
1829 * OXM: NXOXM_NSH_C4(9) since OF1.3 and v2.8. <4>
1830 */
1831 MFF_NSH_C1,
1832 MFF_NSH_C2,
1833 MFF_NSH_C3,
1834 MFF_NSH_C4,
1835
1836 MFF_N_IDS
1837 };
1838
1839 /* A set of mf_field_ids. */
1840 struct mf_bitmap {
1841 unsigned long bm[BITMAP_N_LONGS(MFF_N_IDS)];
1842 };
1843 #define MF_BITMAP_INITIALIZER { { [0] = 0 } }
1844
1845 /* Use this macro as CASE_MFF_REGS: in a switch statement to choose all of the
1846 * MFF_REGn cases. */
1847 #if FLOW_N_REGS ==16
1848 #define CASE_MFF_REGS \
1849 case MFF_REG0: case MFF_REG1: case MFF_REG2: case MFF_REG3: \
1850 case MFF_REG4: case MFF_REG5: case MFF_REG6: case MFF_REG7: \
1851 case MFF_REG8: case MFF_REG9: case MFF_REG10: case MFF_REG11: \
1852 case MFF_REG12: case MFF_REG13: case MFF_REG14: case MFF_REG15
1853 #else
1854 #error "Need to update CASE_MFF_REGS to match FLOW_N_REGS"
1855 #endif
1856
1857 /* Use this macro as CASE_MFF_XREGS: in a switch statement to choose all of the
1858 * MFF_REGn cases. */
1859 #if FLOW_N_XREGS == 8
1860 #define CASE_MFF_XREGS \
1861 case MFF_XREG0: case MFF_XREG1: case MFF_XREG2: case MFF_XREG3: \
1862 case MFF_XREG4: case MFF_XREG5: case MFF_XREG6: case MFF_XREG7
1863 #else
1864 #error "Need to update CASE_MFF_XREGS to match FLOW_N_XREGS"
1865 #endif
1866
1867 /* Use this macro as CASE_MFF_XXREGS: in a switch statement to choose
1868 * all of the MFF_REGn cases. */
1869 #if FLOW_N_XXREGS == 4
1870 #define CASE_MFF_XXREGS \
1871 case MFF_XXREG0: case MFF_XXREG1: case MFF_XXREG2: case MFF_XXREG3
1872 #else
1873 #error "Need to update CASE_MFF_XXREGS to match FLOW_N_XXREGS"
1874 #endif
1875
1876 static inline bool
1877 mf_is_register(enum mf_field_id id)
1878 {
1879 return ((id >= MFF_REG0 && id < MFF_REG0 + FLOW_N_REGS) ||
1880 (id >= MFF_XREG0 && id < MFF_XREG0 + FLOW_N_XREGS) ||
1881 (id >= MFF_XXREG0 && id < MFF_XXREG0 + FLOW_N_XXREGS));
1882 }
1883
1884 /* Use this macro as CASE_MFF_TUN_METADATA: in a switch statement to choose
1885 * all of the MFF_TUN_METADATAn cases. */
1886 #define CASE_MFF_TUN_METADATA \
1887 case MFF_TUN_METADATA0: case MFF_TUN_METADATA1: \
1888 case MFF_TUN_METADATA2: case MFF_TUN_METADATA3: \
1889 case MFF_TUN_METADATA4: case MFF_TUN_METADATA5: \
1890 case MFF_TUN_METADATA6: case MFF_TUN_METADATA7: \
1891 case MFF_TUN_METADATA8: case MFF_TUN_METADATA9: \
1892 case MFF_TUN_METADATA10: case MFF_TUN_METADATA11: \
1893 case MFF_TUN_METADATA12: case MFF_TUN_METADATA13: \
1894 case MFF_TUN_METADATA14: case MFF_TUN_METADATA15: \
1895 case MFF_TUN_METADATA16: case MFF_TUN_METADATA17: \
1896 case MFF_TUN_METADATA18: case MFF_TUN_METADATA19: \
1897 case MFF_TUN_METADATA20: case MFF_TUN_METADATA21: \
1898 case MFF_TUN_METADATA22: case MFF_TUN_METADATA23: \
1899 case MFF_TUN_METADATA24: case MFF_TUN_METADATA25: \
1900 case MFF_TUN_METADATA26: case MFF_TUN_METADATA27: \
1901 case MFF_TUN_METADATA28: case MFF_TUN_METADATA29: \
1902 case MFF_TUN_METADATA30: case MFF_TUN_METADATA31: \
1903 case MFF_TUN_METADATA32: case MFF_TUN_METADATA33: \
1904 case MFF_TUN_METADATA34: case MFF_TUN_METADATA35: \
1905 case MFF_TUN_METADATA36: case MFF_TUN_METADATA37: \
1906 case MFF_TUN_METADATA38: case MFF_TUN_METADATA39: \
1907 case MFF_TUN_METADATA40: case MFF_TUN_METADATA41: \
1908 case MFF_TUN_METADATA42: case MFF_TUN_METADATA43: \
1909 case MFF_TUN_METADATA44: case MFF_TUN_METADATA45: \
1910 case MFF_TUN_METADATA46: case MFF_TUN_METADATA47: \
1911 case MFF_TUN_METADATA48: case MFF_TUN_METADATA49: \
1912 case MFF_TUN_METADATA50: case MFF_TUN_METADATA51: \
1913 case MFF_TUN_METADATA52: case MFF_TUN_METADATA53: \
1914 case MFF_TUN_METADATA54: case MFF_TUN_METADATA55: \
1915 case MFF_TUN_METADATA56: case MFF_TUN_METADATA57: \
1916 case MFF_TUN_METADATA58: case MFF_TUN_METADATA59: \
1917 case MFF_TUN_METADATA60: case MFF_TUN_METADATA61: \
1918 case MFF_TUN_METADATA62: case MFF_TUN_METADATA63
1919
1920 /* Prerequisites for matching a field.
1921 *
1922 * A field may only be matched if the correct lower-level protocols are also
1923 * matched. For example, the TCP port may be matched only if the Ethernet type
1924 * matches ETH_TYPE_IP and the IP protocol matches IPPROTO_TCP. */
1925 enum OVS_PACKED_ENUM mf_prereqs {
1926 MFP_NONE,
1927
1928 /* L2 requirements. */
1929 MFP_ETHERNET,
1930 MFP_ARP,
1931 MFP_VLAN_VID,
1932 MFP_IPV4,
1933 MFP_IPV6,
1934 MFP_IP_ANY,
1935 MFP_NSH,
1936
1937 /* L2.5 requirements. */
1938 MFP_MPLS,
1939
1940 /* L2+L3 requirements. */
1941 MFP_TCP, /* On IPv4 or IPv6. */
1942 MFP_UDP, /* On IPv4 or IPv6. */
1943 MFP_SCTP, /* On IPv4 or IPv6. */
1944 MFP_ICMPV4,
1945 MFP_ICMPV6,
1946 MFP_CT_VALID, /* Implies IPv4 or IPv6. */
1947
1948 /* L2+L3+L4 requirements. */
1949 MFP_ND,
1950 MFP_ND_SOLICIT,
1951 MFP_ND_ADVERT
1952 };
1953
1954 /* Forms of partial-field masking allowed for a field.
1955 *
1956 * Every field may be masked as a whole. */
1957 enum OVS_PACKED_ENUM mf_maskable {
1958 MFM_NONE, /* No sub-field masking. */
1959 MFM_FULLY, /* Every bit is individually maskable. */
1960 };
1961
1962 /* How to format or parse a field's value. */
1963 enum OVS_PACKED_ENUM mf_string {
1964 /* Integer formats.
1965 *
1966 * The particular MFS_* constant sets the output format. On input, either
1967 * decimal or hexadecimal (prefixed with 0x) is accepted. */
1968 MFS_DECIMAL,
1969 MFS_HEXADECIMAL,
1970
1971 /* Other formats. */
1972 MFS_CT_STATE, /* Connection tracking state */
1973 MFS_ETHERNET,
1974 MFS_IPV4,
1975 MFS_IPV6,
1976 MFS_OFP_PORT, /* 16-bit OpenFlow 1.0 port number or name. */
1977 MFS_OFP_PORT_OXM, /* 32-bit OpenFlow 1.1+ port number or name. */
1978 MFS_FRAG, /* no, yes, first, later, not_later */
1979 MFS_TNL_FLAGS, /* FLOW_TNL_F_* flags */
1980 MFS_TCP_FLAGS, /* TCP_* flags */
1981 MFS_PACKET_TYPE, /* "(NS,NS_TYPE)" */
1982 };
1983
1984 struct mf_field {
1985 /* Identification. */
1986 enum mf_field_id id; /* MFF_*. */
1987 const char *name; /* Name of this field, e.g. "eth_type". */
1988 const char *extra_name; /* Alternate name, e.g. "dl_type", or NULL. */
1989
1990 /* Size.
1991 *
1992 * Most fields have n_bytes * 8 == n_bits. There are a few exceptions:
1993 *
1994 * - "dl_vlan" is 2 bytes but only 12 bits.
1995 * - "dl_vlan_pcp" is 1 byte but only 3 bits.
1996 * - "is_frag" is 1 byte but only 2 bits.
1997 * - "ipv6_label" is 4 bytes but only 20 bits.
1998 * - "mpls_label" is 4 bytes but only 20 bits.
1999 * - "mpls_tc" is 1 byte but only 3 bits.
2000 * - "mpls_bos" is 1 byte but only 1 bit.
2001 */
2002 unsigned int n_bytes; /* Width of the field in bytes. */
2003 unsigned int n_bits; /* Number of significant bits in field. */
2004 bool variable_len; /* Length is variable, if so width is max. */
2005
2006 /* Properties. */
2007 enum mf_maskable maskable;
2008 enum mf_string string;
2009 enum mf_prereqs prereqs;
2010 bool writable; /* May be written by actions? */
2011 bool mapped; /* Variable length mf_field is mapped. */
2012
2013 /* Usable protocols.
2014 *
2015 * NXM and OXM are extensible, allowing later extensions to be sent in
2016 * earlier protocol versions, so this does not necessarily correspond to
2017 * the OpenFlow protocol version the field was introduced in.
2018 * Also, some field types are tranparently mapped to each other via the
2019 * struct flow (like vlan and dscp/tos fields), so each variant supports
2020 * all protocols.
2021 *
2022 * These are combinations of OFPUTIL_P_*. (They are not declared as type
2023 * enum ofputil_protocol because that would give meta-flow.h and ofp-util.h
2024 * a circular dependency.) */
2025 uint32_t usable_protocols_exact; /* Matching or setting whole field. */
2026 uint32_t usable_protocols_cidr; /* Matching a CIDR mask in field. */
2027 uint32_t usable_protocols_bitwise; /* Matching arbitrary bits in field. */
2028
2029 int flow_be32ofs; /* Field's be32 offset in "struct flow", if prefix tree
2030 * lookup is supported for the field, or -1. */
2031 };
2032
2033 /* The representation of a field's value. */
2034 union mf_value {
2035 uint8_t b[128];
2036 uint8_t tun_metadata[128];
2037 struct in6_addr ipv6;
2038 struct eth_addr mac;
2039 ovs_be128 be128;
2040 ovs_be64 be64;
2041 ovs_be32 be32;
2042 ovs_be16 be16;
2043 uint8_t u8;
2044 };
2045 BUILD_ASSERT_DECL(sizeof(union mf_value) == 128);
2046 BUILD_ASSERT_DECL(sizeof(union mf_value) >= TLV_MAX_OPT_SIZE);
2047
2048 /* A const mf_value with all bits initialized to ones. */
2049 extern const union mf_value exact_match_mask;
2050
2051 /* Part of a field. */
2052 struct mf_subfield {
2053 const struct mf_field *field;
2054 unsigned int ofs; /* Bit offset. */
2055 unsigned int n_bits; /* Number of bits. */
2056 };
2057
2058 /* Data for some part of an mf_field.
2059 *
2060 * The data is stored "right-justified". For example, if "union mf_subvalue
2061 * value" contains NXM_OF_VLAN_TCI[0..11], then one could access the
2062 * corresponding data in value.be16[7] as the bits in the mask htons(0xfff). */
2063 union mf_subvalue {
2064 /* Access to full data. */
2065 uint8_t u8[128];
2066 ovs_be16 be16[64];
2067 ovs_be32 be32[32];
2068 ovs_be64 be64[16];
2069 ovs_be128 be128[8];
2070
2071 /* Convenient access to just least-significant bits in various forms. */
2072 struct {
2073 uint8_t dummy_u8[127];
2074 uint8_t u8_val;
2075 };
2076 struct {
2077 ovs_be16 dummy_be16[63];
2078 ovs_be16 be16_int;
2079 };
2080 struct {
2081 ovs_be32 dummy_be32[31];
2082 ovs_be32 be32_int;
2083 };
2084 struct {
2085 ovs_be64 dummy_integer[15];
2086 ovs_be64 integer;
2087 };
2088 struct {
2089 ovs_be128 dummy_be128[7];
2090 ovs_be128 be128_int;
2091 };
2092 struct {
2093 uint8_t dummy_mac[122];
2094 struct eth_addr mac;
2095 };
2096 struct {
2097 ovs_be32 dummy_ipv4[31];
2098 ovs_be32 ipv4;
2099 };
2100 struct {
2101 struct in6_addr dummy_ipv6[7];
2102 struct in6_addr ipv6;
2103 };
2104 };
2105 BUILD_ASSERT_DECL(sizeof(union mf_value) == sizeof (union mf_subvalue));
2106
2107 bool mf_subvalue_intersect(const union mf_subvalue *a_value,
2108 const union mf_subvalue *a_mask,
2109 const union mf_subvalue *b_value,
2110 const union mf_subvalue *b_mask,
2111 union mf_subvalue *dst_value,
2112 union mf_subvalue *dst_mask);
2113 int mf_subvalue_width(const union mf_subvalue *);
2114 void mf_subvalue_shift(union mf_subvalue *, int n);
2115 void mf_subvalue_format(const union mf_subvalue *, struct ds *);
2116
2117 static inline void mf_subvalue_from_value(const struct mf_subfield *sf,
2118 union mf_subvalue *sv,
2119 const void *value)
2120 {
2121 unsigned int n_bytes = DIV_ROUND_UP(sf->n_bits, 8);
2122 memset(sv, 0, sizeof *sv - n_bytes);
2123 memcpy(&sv->u8[sizeof sv->u8 - n_bytes], value, n_bytes);
2124 }
2125
2126
2127 /* Set of field values. 'values' only includes the actual data bytes for each
2128 * field for which is used, as marked by 1-bits in 'used'. */
2129 struct field_array {
2130 struct mf_bitmap used;
2131 size_t values_size; /* Number of bytes currently in 'values'. */
2132 uint8_t *values; /* Dynamically allocated to the correct size. */
2133 };
2134
2135 /* Finding mf_fields. */
2136 const struct mf_field *mf_from_name(const char *name);
2137 const struct mf_field *mf_from_name_len(const char *name, size_t len);
2138
2139 static inline const struct mf_field *
2140 mf_from_id(enum mf_field_id id)
2141 {
2142 extern const struct mf_field mf_fields[MFF_N_IDS];
2143 ovs_assert((unsigned int) id < MFF_N_IDS);
2144 return &mf_fields[id];
2145 }
2146
2147 /* Inspecting wildcarded bits. */
2148 bool mf_is_all_wild(const struct mf_field *, const struct flow_wildcards *);
2149
2150 bool mf_is_mask_valid(const struct mf_field *, const union mf_value *mask);
2151 void mf_get_mask(const struct mf_field *, const struct flow_wildcards *,
2152 union mf_value *mask);
2153
2154 /* Prerequisites. */
2155 bool mf_are_prereqs_ok(const struct mf_field *mf, const struct flow *flow,
2156 struct flow_wildcards *wc);
2157 bool mf_are_match_prereqs_ok(const struct mf_field *, const struct match *);
2158
2159 static inline bool
2160 mf_is_l3_or_higher(const struct mf_field *mf)
2161 {
2162 return mf->id >= MFF_IPV4_SRC;
2163 }
2164
2165 /* Field values. */
2166 bool mf_is_value_valid(const struct mf_field *, const union mf_value *value);
2167
2168 void mf_get_value(const struct mf_field *, const struct flow *,
2169 union mf_value *value);
2170 void mf_set_value(const struct mf_field *, const union mf_value *value,
2171 struct match *, char **err_str);
2172 void mf_set_flow_value(const struct mf_field *, const union mf_value *value,
2173 struct flow *);
2174 void mf_set_flow_value_masked(const struct mf_field *,
2175 const union mf_value *value,
2176 const union mf_value *mask,
2177 struct flow *);
2178 bool mf_is_tun_metadata(const struct mf_field *);
2179 bool mf_is_pipeline_field(const struct mf_field *);
2180 bool mf_is_set(const struct mf_field *, const struct flow *);
2181 void mf_mask_field(const struct mf_field *, struct flow_wildcards *);
2182 void mf_mask_field_masked(const struct mf_field *, const union mf_value *mask,
2183 struct flow_wildcards *);
2184 int mf_field_len(const struct mf_field *, const union mf_value *value,
2185 const union mf_value *mask, bool *is_masked);
2186
2187 void mf_get(const struct mf_field *, const struct match *,
2188 union mf_value *value, union mf_value *mask);
2189
2190 /* Returns the set of usable protocols. */
2191 uint32_t mf_set(const struct mf_field *, const union mf_value *value,
2192 const union mf_value *mask, struct match *, char **err_str);
2193
2194 void mf_set_wild(const struct mf_field *, struct match *, char **err_str);
2195
2196 /* Subfields. */
2197 void mf_write_subfield_flow(const struct mf_subfield *,
2198 const union mf_subvalue *, struct flow *);
2199 void mf_write_subfield(const struct mf_subfield *, const union mf_subvalue *,
2200 struct match *);
2201 void mf_write_subfield_value(const struct mf_subfield *, const void *src,
2202 struct match *);
2203
2204 void mf_mask_subfield(const struct mf_field *,
2205 const union mf_subvalue *value,
2206 const union mf_subvalue *mask,
2207 struct match *);
2208
2209 void mf_read_subfield(const struct mf_subfield *, const struct flow *,
2210 union mf_subvalue *);
2211 uint64_t mf_get_subfield(const struct mf_subfield *, const struct flow *);
2212
2213 void mf_subfield_copy(const struct mf_subfield *src,
2214 const struct mf_subfield *dst,
2215 struct flow *, struct flow_wildcards *);
2216 void mf_subfield_swap(const struct mf_subfield *,
2217 const struct mf_subfield *,
2218 struct flow *flow, struct flow_wildcards *);
2219
2220 enum ofperr mf_check_src(const struct mf_subfield *, const struct match *);
2221 enum ofperr mf_check_dst(const struct mf_subfield *, const struct match *);
2222
2223 /* Parsing and formatting. */
2224 char *mf_parse(const struct mf_field *, const char *,
2225 const struct ofputil_port_map *,
2226 union mf_value *value, union mf_value *mask);
2227 char *mf_parse_value(const struct mf_field *, const char *,
2228 const struct ofputil_port_map *, union mf_value *);
2229 void mf_format(const struct mf_field *,
2230 const union mf_value *value, const union mf_value *mask,
2231 const struct ofputil_port_map *,
2232 struct ds *);
2233 void mf_format_subvalue(const union mf_subvalue *subvalue, struct ds *s);
2234
2235 /* Field Arrays. */
2236 void field_array_set(enum mf_field_id id, const union mf_value *,
2237 struct field_array *);
2238
2239 #ifdef __cplusplus
2240 }
2241 #endif
2242
2243 #endif /* meta-flow.h */