2 * Copyright (c) 2011-2017 Nicira, Inc.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef OPENVSWITCH_META_FLOW_H
18 #define OPENVSWITCH_META_FLOW_H 1
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"
37 struct ofputil_port_map
;
38 struct ofputil_tlv_table_mod
;
40 /* Open vSwitch fields
43 * Refer to ovs-fields(7) for a detailed introduction to Open vSwitch fields.
46 * Field specifications
47 * ====================
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:
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
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
63 * "tun_id" (aka "tunnel_id").
65 * New fields should have only one name.
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.
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.
74 * Every field must specify the following key-value pairs:
78 * The format and size of the field's value. Some possible values are
81 * u8: A one-byte field.
82 * be16: A two-byte field.
83 * be32: A four-byte field.
84 * be64: An eight-byte field.
86 * The remaining values imply more about the value's semantics, though OVS
87 * does not currently take advantage of this additional information:
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
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
102 * Explains how a field's value is formatted and parsed for human
103 * consumption. Some of the options are fairly generally useful:
105 * decimal: Formats the value as a decimal number. On parsing, accepts
106 * decimal (with no prefix), hexadecimal with 0x prefix, or octal
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.
113 * Ethernet: Formats and accepts the common format xx:xx:xx:xx:xx:xx.
114 * 6-byte fields only.
116 * IPv4: Formats and accepts the common format w.x.y.z. 4-byte fields
119 * IPv6: Formats and accepts the common IPv6 formats. 16-byte fields
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.
127 * OpenFlow 1.1+ port: Same syntax as for OpenFlow 1.0 ports but for
128 * 4-byte OpenFlow 1.1+ port number fields.
130 * Others are very specific to particular fields:
132 * frag: One of the strings "no", "first", "later", "yes", "not_later"
133 * describing which IPv4/v6 fragments are matched.
135 * tunnel flags: Any number of the strings "df", "csum", "key", or
136 * "oam" separated by "|".
138 * TCP flags: See the description of tcp_flags in ovs-ofctl(8).
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.
147 * The field's prerequisites. The values should be straightfoward.
151 * Either "read-only", for a field that cannot be changed via OpenFlow, or
152 * "read/write" for a modifiable field.
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).
162 * The NXM name must begin with NXM_OF_ or NXM_NX_. This allows OVS to
163 * determine the correct NXM class.
165 * If the field does not have an NXM field assignment, specify "none".
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).
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.
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.
185 * If the field does not have an OXM field assignment, specify "none".
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:
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.
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.
204 * The following key-value pair is optional:
206 * Prefix lookup member:
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
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.
219 enum OVS_PACKED_ENUM mf_field_id
{
226 * Flow hash computed in the datapath. Internal use only, not programmable
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.
237 * Formatting: hexadecimal.
238 * Prerequisites: none.
240 * NXM: NXM_NX_DP_HASH(35) since v2.2.
241 * OXM: NXOXM_ET_DP_HASH(0) since OF1.5 and v2.4.
247 * ID for recirculation. The value 0 is reserved for initially received
248 * packets. Internal use only, not programmable from controller.
252 * Formatting: decimal.
253 * Prerequisites: none.
255 * NXM: NXM_NX_RECIRC_ID(36) since v2.2.
262 * Define the packet type in OpenFlow 1.5+.
266 * Formatting: packet type.
267 * Prerequisites: none.
270 * OXM: OXM_OF_PACKET_TYPE(44) since OF1.5 and v2.8.
276 * ID for "conjunction" actions. Please refer to ovs-ofctl(8)
277 * documentation of "conjunction" for details.
281 * Formatting: decimal.
282 * Prerequisites: none.
284 * NXM: NXM_NX_CONJ_ID(37) since v2.4.
288 /* "tun_id" (aka "tunnel_id").
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.
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.
308 * The IPv4 source address in the outer IP header of a tunneled packet.
310 * For non-tunneled packets, the value is 0.
315 * Prerequisites: none.
316 * Access: read/write.
317 * NXM: NXM_NX_TUN_IPV4_SRC(31) since v2.0.
319 * Prefix lookup member: tunnel.ip_src.
325 * The IPv4 destination address in the outer IP header of a tunneled
328 * For non-tunneled packets, the value is 0.
333 * Prerequisites: none.
334 * Access: read/write.
335 * NXM: NXM_NX_TUN_IPV4_DST(32) since v2.0.
337 * Prefix lookup member: tunnel.ip_dst.
343 * The IPv6 source address in the outer IP header of a tunneled packet.
345 * For non-tunneled packets, the value is 0.
350 * Prerequisites: none.
351 * Access: read/write.
352 * NXM: NXM_NX_TUN_IPV6_SRC(109) since v2.5.
354 * Prefix lookup member: tunnel.ipv6_src.
360 * The IPv6 destination address in the outer IP header of a tunneled
363 * For non-tunneled packets, the value is 0.
368 * Prerequisites: none.
369 * Access: read/write.
370 * NXM: NXM_NX_TUN_IPV6_DST(110) since v2.5.
372 * Prefix lookup member: tunnel.ipv6_dst.
378 * Flags representing aspects of tunnel behavior.
380 * For non-tunneled packets, the value is 0.
382 * Type: be16 (low 1 bits).
384 * Formatting: tunnel flags.
385 * Prerequisites: none.
386 * Access: read/write.
387 * NXM: NXM_NX_TUN_FLAGS(104) since v2.5.
394 * The TTL in the outer IP header of a tunneled packet. Internal use only,
395 * not programmable from controller.
397 * For non-tunneled packets, the value is 0.
401 * Formatting: decimal.
402 * Prerequisites: none.
411 * The ToS value in the outer IP header of a tunneled packet. Internal use
412 * only, not programmable from controller.
416 * Formatting: decimal.
417 * Prerequisites: none.
426 * VXLAN Group Policy ID
430 * Formatting: decimal.
431 * Prerequisites: none.
432 * Access: read/write.
433 * NXM: NXM_NX_TUN_GBP_ID(38) since v2.4.
440 * VXLAN Group Policy flags
444 * Formatting: hexadecimal.
445 * Prerequisites: none.
446 * Access: read/write.
447 * NXM: NXM_NX_TUN_GBP_FLAGS(39) since v2.4.
452 #if TUN_METADATA_NUM_OPTS == 64
453 /* "tun_metadata<N>".
455 * Encapsulation metadata for tunnels.
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.
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>
597 #error "Need to update MFF_TUN_METADATA* to match TUN_METADATA_NUM_OPTS"
602 * A scratch pad value standardized in OpenFlow 1.1+. Initially zero, at
603 * the beginning of the pipeline.
607 * Formatting: hexadecimal.
608 * Prerequisites: none.
609 * Access: read/write.
611 * OXM: OXM_OF_METADATA(2) since OF1.2 and v1.8.
612 * OF1.1: bitwise mask.
618 * 16-bit (OpenFlow 1.0) view of the physical or virtual port on which the
619 * packet was received.
623 * Formatting: OpenFlow 1.0 port.
624 * Prerequisites: none.
625 * Access: read/write.
626 * NXM: NXM_OF_IN_PORT(0) since v1.1.
628 * OF1.0: exact match.
629 * OF1.1: exact match.
635 * 32-bit (OpenFlow 1.1+) view of the physical or virtual port on which the
636 * packet was received.
640 * Formatting: OpenFlow 1.1+ port.
641 * Prerequisites: none.
642 * Access: read/write.
644 * OXM: OXM_OF_IN_PORT(0) since OF1.2 and v1.7.
645 * OF1.1: exact match.
653 * Formatting: OpenFlow 1.1+ port.
654 * Prerequisites: 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.
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.
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.
674 * Formatting: hexadecimal.
675 * Prerequisites: none.
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.
691 * Formatting: hexadecimal.
692 * Prerequisites: none.
693 * Access: read/write.
694 * NXM: NXM_NX_PKT_MARK(33) since v2.0.
701 * Connection tracking state. The field is populated by the NXAST_CT
706 * Formatting: ct state.
707 * Prerequisites: none.
709 * NXM: NXM_NX_CT_STATE(105) since v2.5.
716 * Connection tracking zone. The field is populated by the
721 * Formatting: hexadecimal.
722 * Prerequisites: none.
724 * NXM: NXM_NX_CT_ZONE(106) since v2.5.
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.
736 * Writable only from nested actions within the NXAST_CT action.
740 * Formatting: hexadecimal.
741 * Prerequisites: none.
742 * Access: read/write.
743 * NXM: NXM_NX_CT_MARK(107) since v2.5.
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.
755 * Writable only from nested actions within the NXAST_CT action.
759 * Formatting: hexadecimal.
760 * Prerequisites: none.
761 * Access: read/write.
762 * NXM: NXM_NX_CT_LABEL(108) since v2.5.
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.
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.
780 * Formatting: decimal.
783 * NXM: NXM_NX_CT_NW_PROTO(119) since v2.8.
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.
794 * The value is populated by the CT action.
801 * NXM: NXM_NX_CT_NW_SRC(120) since v2.8.
803 * Prefix lookup member: ct_nw_src.
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.
813 * The value is populated by the CT action.
820 * NXM: NXM_NX_CT_NW_DST(121) since v2.8.
822 * Prefix lookup member: ct_nw_dst.
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.
832 * The value is populated by the CT action.
839 * NXM: NXM_NX_CT_IPV6_SRC(122) since v2.8.
841 * Prefix lookup member: ct_ipv6_src.
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.
851 * The value is populated by the CT action.
858 * NXM: NXM_NX_CT_IPV6_DST(123) since v2.8.
860 * Prefix lookup member: ct_ipv6_dst.
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.
870 * The value is populated by the CT action.
874 * Formatting: decimal.
877 * NXM: NXM_NX_CT_TP_SRC(124) since v2.8.
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.
888 * The value is populated by the CT action.
892 * Formatting: decimal.
895 * NXM: NXM_NX_CT_TP_DST(125) since v2.8.
900 #if FLOW_N_REGS == 16
903 * Nicira extension scratch pad register with initial value 0.
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>
945 #error "Need to update MFF_REG* to match FLOW_N_REGS"
948 #if FLOW_N_XREGS == 8
951 * OpenFlow 1.5 ``extended register".
955 * Formatting: hexadecimal.
956 * Prerequisites: none.
957 * Access: read/write.
959 * OXM: OXM_OF_PKT_REG<N>(<N>) since OF1.3 and v2.4.
970 #error "Need to update MFF_REG* to match FLOW_N_XREGS"
973 #if FLOW_N_XXREGS == 4
976 * ``extended-extended register".
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>
998 #error "Need to update MFF_REG* to match FLOW_N_XXREGS"
1001 /* ## -------- ## */
1002 /* ## Ethernet ## */
1003 /* ## -------- ## */
1005 /* "eth_src" (aka "dl_src").
1007 * Source address in Ethernet header.
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.
1021 /* "eth_dst" (aka "dl_dst").
1023 * Destination address in Ethernet header.
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.
1037 /* "eth_type" (aka "dl_type").
1039 * Packet's Ethernet type.
1041 * For a packet with an 802.1Q header, this is the type of the encapsulated
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.
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. */
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.
1075 * Maskable: bitwise.
1076 * Formatting: hexadecimal.
1077 * Prerequisites: Ethernet.
1078 * Access: read/write.
1079 * NXM: NXM_OF_VLAN_TCI(4) since v1.1.
1081 * OF1.0: exact match.
1082 * OF1.1: exact match.
1086 /* "dl_vlan" (OpenFlow 1.0).
1088 * VLAN ID field. Zero if no 802.1Q header is present.
1090 * Type: be16 (low 12 bits).
1092 * Formatting: decimal.
1093 * Prerequisites: Ethernet.
1094 * Access: read/write.
1097 * OF1.0: exact match.
1098 * OF1.1: exact match.
1102 /* "vlan_vid" (OpenFlow 1.2+).
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
1108 * Type: be16 (low 12 bits).
1109 * Maskable: bitwise.
1110 * Formatting: decimal.
1111 * Prerequisites: Ethernet.
1112 * Access: read/write.
1114 * OXM: OXM_OF_VLAN_VID(6) since OF1.2 and v1.7.
1115 * OF1.0: exact match.
1116 * OF1.1: exact match.
1120 /* "dl_vlan_pcp" (OpenFlow 1.0).
1122 * VLAN priority (PCP) field. Zero if no 802.1Q header is present.
1124 * Type: u8 (low 3 bits).
1126 * Formatting: decimal.
1127 * Prerequisites: Ethernet.
1128 * Access: read/write.
1131 * OF1.0: exact match.
1132 * OF1.1: exact match.
1136 /* "vlan_pcp" (OpenFlow 1.2+).
1138 * VLAN priority (PCP) field. Zero if no 802.1Q header is present.
1140 * Type: u8 (low 3 bits).
1142 * Formatting: decimal.
1143 * Prerequisites: VLAN VID.
1144 * Access: read/write.
1146 * OXM: OXM_OF_VLAN_PCP(7) since OF1.2 and v1.7.
1147 * OF1.0: exact match.
1148 * OF1.1: exact match.
1158 * The outermost MPLS label, or 0 if no MPLS labels are present.
1160 * Type: be32 (low 20 bits).
1162 * Formatting: decimal.
1163 * Prerequisites: MPLS.
1164 * Access: read/write.
1166 * OXM: OXM_OF_MPLS_LABEL(34) since OF1.2 and v1.11.
1167 * OF1.1: exact match.
1173 * The outermost MPLS label's traffic control (TC) field, or 0 if no MPLS
1174 * labels are present.
1176 * Type: u8 (low 3 bits).
1178 * Formatting: decimal.
1179 * Prerequisites: MPLS.
1180 * Access: read/write.
1182 * OXM: OXM_OF_MPLS_TC(35) since OF1.2 and v1.11.
1183 * OF1.1: exact match.
1189 * The outermost MPLS label's bottom of stack (BoS) field, or 0 if no MPLS
1190 * labels are present.
1192 * Type: u8 (low 1 bits).
1194 * Formatting: decimal.
1195 * Prerequisites: MPLS.
1196 * Access: read-only.
1198 * OXM: OXM_OF_MPLS_BOS(36) since OF1.3 and v1.11.
1204 * The outermost MPLS label's time-to-live (TTL) field, or 0 if no MPLS
1205 * labels are present.
1209 * Formatting: decimal.
1210 * Prerequisites: MPLS.
1211 * Access: read/write.
1212 * NXM: NXM_NX_MPLS_TTL(30) since v2.6.
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 */
1224 /* "ip_src" (aka "nw_src").
1226 * The source address in the IPv4 header.
1228 * Before Open vSwitch 1.8, only CIDR masks were supported.
1231 * Maskable: bitwise.
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.
1238 * OF1.1: bitwise mask.
1239 * Prefix lookup member: nw_src.
1243 /* "ip_dst" (aka "nw_dst").
1245 * The destination address in the IPv4 header.
1247 * Before Open vSwitch 1.8, only CIDR masks were supported.
1250 * Maskable: bitwise.
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.
1257 * OF1.1: bitwise mask.
1258 * Prefix lookup member: nw_dst.
1268 * The source address in the IPv6 header.
1271 * Maskable: bitwise.
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.
1283 * The destination address in the IPv6 header.
1286 * Maskable: bitwise.
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.
1298 * The flow label in the IPv6 header.
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.
1310 /* ## ----------------------- ## */
1311 /* ## IPv4/IPv6 common fields ## */
1312 /* ## ----------------------- ## */
1314 /* "nw_proto" (aka "ip_proto").
1316 * The "protocol" byte in the IPv4 or IPv6 header.
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.
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. */
1334 /* "nw_tos" (OpenFlow 1.0/1.1).
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.)
1342 * Formatting: decimal.
1343 * Prerequisites: IPv4/IPv6.
1344 * Access: read/write.
1345 * NXM: NXM_OF_IP_TOS(5) since v1.1.
1347 * OF1.0: exact match.
1348 * OF1.1: exact match.
1352 /* "ip_dscp" (OpenFlow 1.2+).
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.)
1358 * Type: u8 (low 6 bits).
1360 * Formatting: decimal.
1361 * Prerequisites: IPv4/IPv6.
1362 * Access: read/write.
1364 * OXM: OXM_OF_IP_DSCP(8) since OF1.2 and v1.7.
1365 * OF1.0: exact match.
1366 * OF1.1: exact match.
1368 MFF_IP_DSCP_SHIFTED
,
1370 /* "nw_ecn" (aka "ip_ecn").
1372 * The ECN bits in the IPv4 or IPv6 header.
1374 * Type: u8 (low 2 bits).
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.
1387 * The time-to-live (TTL) in the IPv4 header or hop limit in the IPv6
1392 * Formatting: decimal.
1393 * Prerequisites: IPv4/IPv6.
1394 * Access: read/write.
1395 * NXM: NXM_NX_IP_TTL(29) since v1.4.
1402 * IP fragment information.
1404 * Type: u8 (low 2 bits).
1405 * Maskable: bitwise.
1407 * Prerequisites: IPv4/IPv6.
1408 * Access: read-only.
1409 * NXM: NXM_NX_IP_FRAG(26) since v1.3.
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
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.
1440 * For an Ethernet+IP ARP packet, the source protocol (IPv4) address in the
1441 * ARP header. Always 0 otherwise.
1443 * Before Open vSwitch 1.8, only CIDR masks were supported.
1446 * Maskable: bitwise.
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.
1453 * OF1.1: bitwise mask.
1459 * For an Ethernet+IP ARP packet, the target protocol (IPv4) address in the
1460 * ARP header. Always 0 otherwise.
1462 * Before Open vSwitch 1.8, only CIDR masks were supported.
1465 * Maskable: bitwise.
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.
1472 * OF1.1: bitwise mask.
1478 * For an Ethernet+IP ARP packet, the source hardware (Ethernet) address in
1479 * the ARP header. Always 0 otherwise.
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.
1493 * For an Ethernet+IP ARP packet, the target hardware (Ethernet) address in
1494 * the ARP header. Always 0 otherwise.
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.
1510 /* "tcp_src" (aka "tp_src").
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.
1526 /* "tcp_dst" (aka "tp_dst").
1528 * TCP destination port.
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.
1544 * Flags in the TCP header.
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.
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.
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.
1582 * UDP destination port
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.
1605 * Maskable: bitwise.
1606 * Formatting: decimal.
1607 * Prerequisites: SCTP.
1608 * Access: read/write.
1610 * OXM: OXM_OF_SCTP_SRC(17) since OF1.2 and v2.0.
1611 * OF1.1: exact match.
1617 * SCTP destination port.
1620 * Maskable: bitwise.
1621 * Formatting: decimal.
1622 * Prerequisites: SCTP.
1623 * Access: read/write.
1625 * OXM: OXM_OF_SCTP_DST(18) since OF1.2 and v2.0.
1626 * OF1.1: exact match.
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.
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.
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.
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.
1694 /* ## ------------------------- ## */
1695 /* ## ICMPv6 Neighbor Discovery ## */
1696 /* ## ------------------------- ## */
1700 * The target address in an IPv6 Neighbor Discovery message.
1702 * Before Open vSwitch 1.8, only CIDR masks were supported.
1705 * Maskable: bitwise.
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.
1716 * The source link layer address in an IPv6 Neighbor Discovery message.
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.
1730 * The target link layer address in an IPv6 Neighbor Discovery message.
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.
1748 * flags field in NSH base header.
1751 * Maskable: bitwise.
1752 * Formatting: decimal.
1753 * Prerequisites: NSH.
1754 * Access: read/write.
1756 * OXM: NXOXM_NSH_FLAGS(1) since OF1.3 and v2.8.
1762 * mdtype field in NSH base header.
1766 * Formatting: decimal.
1767 * Prerequisites: NSH.
1768 * Access: read-only.
1770 * OXM: NXOXM_NSH_MDTYPE(2) since OF1.3 and v2.8.
1776 * np (next protocol) field in NSH base header.
1780 * Formatting: decimal.
1781 * Prerequisites: NSH.
1782 * Access: read-only.
1784 * OXM: NXOXM_NSH_NP(3) since OF1.3 and v2.8.
1788 /* "nsh_spi" (aka "nsp").
1790 * spi (service path identifier) field in NSH base header.
1792 * Type: be32 (low 24 bits).
1794 * Formatting: hexadecimal.
1795 * Prerequisites: NSH.
1796 * Access: read/write.
1798 * OXM: NXOXM_NSH_SPI(4) since OF1.3 and v2.8.
1802 /* "nsh_si" (aka "nsi").
1804 * si (service index) field in NSH base header.
1808 * Formatting: decimal.
1809 * Prerequisites: NSH.
1810 * Access: read/write.
1812 * OXM: NXOXM_NSH_SI(5) since OF1.3 and v2.8.
1816 /* "nsh_c<N>" (aka "nshc<N>").
1818 * context fields in NSH context header.
1821 * Maskable: bitwise.
1822 * Formatting: hexadecimal.
1823 * Prerequisites: NSH.
1824 * Access: read/write.
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>
1839 /* A set of mf_field_ids. */
1841 unsigned long bm
[BITMAP_N_LONGS(MFF_N_IDS
)];
1843 #define MF_BITMAP_INITIALIZER { { [0] = 0 } }
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
1854 #error "Need to update CASE_MFF_REGS to match FLOW_N_REGS"
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
1864 #error "Need to update CASE_MFF_XREGS to match FLOW_N_XREGS"
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
1873 #error "Need to update CASE_MFF_XXREGS to match FLOW_N_XXREGS"
1877 mf_is_register(enum mf_field_id id
)
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
));
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
1920 /* Prerequisites for matching a field.
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
{
1928 /* L2 requirements. */
1937 /* L2.5 requirements. */
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. */
1946 MFP_CT_VALID
, /* Implies IPv4 or IPv6. */
1948 /* L2+L3+L4 requirements. */
1954 /* Forms of partial-field masking allowed for a field.
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. */
1962 /* How to format or parse a field's value. */
1963 enum OVS_PACKED_ENUM mf_string
{
1966 * The particular MFS_* constant sets the output format. On input, either
1967 * decimal or hexadecimal (prefixed with 0x) is accepted. */
1971 /* Other formats. */
1972 MFS_CT_STATE
, /* Connection tracking state */
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)" */
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. */
1992 * Most fields have n_bytes * 8 == n_bits. There are a few exceptions:
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.
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. */
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. */
2013 /* Usable protocols.
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
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. */
2029 int flow_be32ofs
; /* Field's be32 offset in "struct flow", if prefix tree
2030 * lookup is supported for the field, or -1. */
2033 /* The representation of a field's value. */
2036 uint8_t tun_metadata
[128];
2037 struct in6_addr ipv6
;
2038 struct eth_addr mac
;
2045 BUILD_ASSERT_DECL(sizeof(union mf_value
) == 128);
2046 BUILD_ASSERT_DECL(sizeof(union mf_value
) >= TLV_MAX_OPT_SIZE
);
2048 /* A const mf_value with all bits initialized to ones. */
2049 extern const union mf_value exact_match_mask
;
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. */
2058 /* Data for some part of an mf_field.
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). */
2064 /* Access to full data. */
2071 /* Convenient access to just least-significant bits in various forms. */
2073 uint8_t dummy_u8
[127];
2077 ovs_be16 dummy_be16
[63];
2081 ovs_be32 dummy_be32
[31];
2085 ovs_be64 dummy_integer
[15];
2089 ovs_be128 dummy_be128
[7];
2090 ovs_be128 be128_int
;
2093 uint8_t dummy_mac
[122];
2094 struct eth_addr mac
;
2097 ovs_be32 dummy_ipv4
[31];
2101 struct in6_addr dummy_ipv6
[7];
2102 struct in6_addr ipv6
;
2105 BUILD_ASSERT_DECL(sizeof(union mf_value
) == sizeof (union mf_subvalue
));
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
*);
2117 static inline void mf_subvalue_from_value(const struct mf_subfield
*sf
,
2118 union mf_subvalue
*sv
,
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
);
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. */
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
);
2139 static inline const struct mf_field
*
2140 mf_from_id(enum mf_field_id id
)
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
];
2147 /* Inspecting wildcarded bits. */
2148 bool mf_is_all_wild(const struct mf_field
*, const struct flow_wildcards
*);
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
);
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
*);
2160 mf_is_l3_or_higher(const struct mf_field
*mf
)
2162 return mf
->id
>= MFF_IPV4_SRC
;
2166 bool mf_is_value_valid(const struct mf_field
*, const union mf_value
*value
);
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
,
2174 void mf_set_flow_value_masked(const struct mf_field
*,
2175 const union mf_value
*value
,
2176 const union mf_value
*mask
,
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
);
2187 void mf_get(const struct mf_field
*, const struct match
*,
2188 union mf_value
*value
, union mf_value
*mask
);
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
);
2194 void mf_set_wild(const struct mf_field
*, struct match
*, char **err_str
);
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
*,
2201 void mf_write_subfield_value(const struct mf_subfield
*, const void *src
,
2204 void mf_mask_subfield(const struct mf_field
*,
2205 const union mf_subvalue
*value
,
2206 const union mf_subvalue
*mask
,
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
*);
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
*);
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
*);
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
*,
2233 void mf_format_subvalue(const union mf_subvalue
*subvalue
, struct ds
*s
);
2236 void field_array_set(enum mf_field_id id
, const union mf_value
*,
2237 struct field_array
*);
2243 #endif /* meta-flow.h */