+/* Source or destination address in Ethernet header.
+ *
+ * Prereqs: None.
+ *
+ * Format: 48-bit Ethernet MAC address.
+ *
+ * Masking: The nxm_mask patterns 01:00:00:00:00:00 and FE:FF:FF:FF:FF:FF must
+ * be supported for NXM_OF_ETH_DST_W (as well as the trivial patterns that
+ * are all-0-bits or all-1-bits). Support for other patterns and for masking
+ * of NXM_OF_ETH_SRC is optional. */
+#define NXM_OF_ETH_DST NXM_HEADER (0x0000, 1, 6)
+#define NXM_OF_ETH_DST_W NXM_HEADER_W(0x0000, 1, 6)
+#define NXM_OF_ETH_SRC NXM_HEADER (0x0000, 2, 6)
+
+/* Packet's Ethernet type.
+ *
+ * For an Ethernet II packet this is taken from the Ethernet header. For an
+ * 802.2 LLC+SNAP header with OUI 00-00-00 this is taken from the SNAP header.
+ * A packet that has neither format has value 0x05ff
+ * (OFP_DL_TYPE_NOT_ETH_TYPE).
+ *
+ * For a packet with an 802.1Q header, this is the type of the encapsulated
+ * frame.
+ *
+ * Prereqs: None.
+ *
+ * Format: 16-bit integer in network byte order.
+ *
+ * Masking: Not maskable. */
+#define NXM_OF_ETH_TYPE NXM_HEADER (0x0000, 3, 2)
+
+/* 802.1Q TCI.
+ *
+ * For a packet with an 802.1Q header, this is the Tag Control Information
+ * (TCI) field, with the CFI bit forced to 1. For a packet with no 802.1Q
+ * header, this has value 0.
+ *
+ * Prereqs: None.
+ *
+ * Format: 16-bit integer in network byte order.
+ *
+ * Masking: Arbitrary masks.
+ *
+ * This field can be used in various ways:
+ *
+ * - If it is not constrained at all, the nx_match matches packets without
+ * an 802.1Q header or with an 802.1Q header that has any TCI value.
+ *
+ * - Testing for an exact match with 0 matches only packets without an
+ * 802.1Q header.
+ *
+ * - Testing for an exact match with a TCI value with CFI=1 matches packets
+ * that have an 802.1Q header with a specified VID and PCP.
+ *
+ * - Testing for an exact match with a nonzero TCI value with CFI=0 does
+ * not make sense. The switch may reject this combination.
+ *
+ * - Testing with a specific VID and CFI=1, with nxm_mask=0x1fff, matches
+ * packets that have an 802.1Q header with that VID (and any PCP).
+ *
+ * - Testing with a specific PCP and CFI=1, with nxm_mask=0xf000, matches
+ * packets that have an 802.1Q header with that PCP (and any VID).
+ *
+ * - Testing with nxm_value=0, nxm_mask=0x0fff matches packets with no 802.1Q
+ * header or with an 802.1Q header with a VID of 0.
+ *
+ * - Testing with nxm_value=0, nxm_mask=0xe000 matches packets with no 802.1Q
+ * header or with an 802.1Q header with a PCP of 0.
+ *
+ * - Testing with nxm_value=0, nxm_mask=0xefff matches packets with no 802.1Q
+ * header or with an 802.1Q header with both VID and PCP of 0.
+ */
+#define NXM_OF_VLAN_TCI NXM_HEADER (0x0000, 4, 2)
+#define NXM_OF_VLAN_TCI_W NXM_HEADER_W(0x0000, 4, 2)
+
+/* The "type of service" byte of the IP header, with the ECN bits forced to 0.
+ *
+ * Prereqs: NXM_OF_ETH_TYPE must be either 0x0800 or 0x86dd.
+ *
+ * Format: 8-bit integer with 2 least-significant bits forced to 0.
+ *
+ * Masking: Not maskable. */
+#define NXM_OF_IP_TOS NXM_HEADER (0x0000, 5, 1)
+
+/* The "protocol" byte in the IP header.
+ *
+ * Prereqs: NXM_OF_ETH_TYPE must be either 0x0800 or 0x86dd.
+ *
+ * Format: 8-bit integer.
+ *
+ * Masking: Not maskable. */
+#define NXM_OF_IP_PROTO NXM_HEADER (0x0000, 6, 1)
+
+/* The source or destination address in the IP header.
+ *
+ * Prereqs: NXM_OF_ETH_TYPE must match 0x0800 exactly.
+ *
+ * Format: 32-bit integer in network byte order.
+ *
+ * Masking: Only CIDR masks are allowed, that is, masks that consist of N
+ * high-order bits set to 1 and the other 32-N bits set to 0. */
+#define NXM_OF_IP_SRC NXM_HEADER (0x0000, 7, 4)
+#define NXM_OF_IP_SRC_W NXM_HEADER_W(0x0000, 7, 4)
+#define NXM_OF_IP_DST NXM_HEADER (0x0000, 8, 4)
+#define NXM_OF_IP_DST_W NXM_HEADER_W(0x0000, 8, 4)
+
+/* The source or destination port in the TCP header.
+ *
+ * Prereqs:
+ * NXM_OF_ETH_TYPE must be either 0x0800 or 0x86dd.
+ * NXM_OF_IP_PROTO must match 6 exactly.
+ *
+ * Format: 16-bit integer in network byte order.
+ *
+ * Masking: Not maskable. */
+#define NXM_OF_TCP_SRC NXM_HEADER (0x0000, 9, 2)
+#define NXM_OF_TCP_DST NXM_HEADER (0x0000, 10, 2)
+
+/* The source or destination port in the UDP header.
+ *
+ * Prereqs:
+ * NXM_OF_ETH_TYPE must match either 0x0800 or 0x86dd.
+ * NXM_OF_IP_PROTO must match 17 exactly.
+ *
+ * Format: 16-bit integer in network byte order.
+ *
+ * Masking: Not maskable. */
+#define NXM_OF_UDP_SRC NXM_HEADER (0x0000, 11, 2)
+#define NXM_OF_UDP_DST NXM_HEADER (0x0000, 12, 2)
+
+/* The type or code in the ICMP header.
+ *
+ * Prereqs:
+ * NXM_OF_ETH_TYPE must match 0x0800 exactly.
+ * NXM_OF_IP_PROTO must match 1 exactly.
+ *
+ * Format: 8-bit integer.
+ *
+ * Masking: Not maskable. */
+#define NXM_OF_ICMP_TYPE NXM_HEADER (0x0000, 13, 1)
+#define NXM_OF_ICMP_CODE NXM_HEADER (0x0000, 14, 1)
+
+/* ARP opcode.
+ *
+ * For an Ethernet+IP ARP packet, the opcode in the ARP header. Always 0
+ * otherwise. Only ARP opcodes between 1 and 255 should be specified for
+ * matching.
+ *
+ * Prereqs: NXM_OF_ETH_TYPE must match 0x0806 exactly.
+ *
+ * Format: 16-bit integer in network byte order.
+ *
+ * Masking: Not maskable. */
+#define NXM_OF_ARP_OP NXM_HEADER (0x0000, 15, 2)
+
+/* For an Ethernet+IP ARP packet, the source or target protocol address
+ * in the ARP header. Always 0 otherwise.
+ *
+ * Prereqs: NXM_OF_ETH_TYPE must match 0x0806 exactly.
+ *
+ * Format: 32-bit integer in network byte order.
+ *
+ * Masking: Only CIDR masks are allowed, that is, masks that consist of N
+ * high-order bits set to 1 and the other 32-N bits set to 0. */
+#define NXM_OF_ARP_SPA NXM_HEADER (0x0000, 16, 4)
+#define NXM_OF_ARP_SPA_W NXM_HEADER_W(0x0000, 16, 4)
+#define NXM_OF_ARP_TPA NXM_HEADER (0x0000, 17, 4)
+#define NXM_OF_ARP_TPA_W NXM_HEADER_W(0x0000, 17, 4)
+
+/* ## ------------------------ ## */
+/* ## Nicira match extensions. ## */
+/* ## ------------------------ ## */
+
+/* Metadata registers.
+ *
+ * Registers initially have value 0. Actions allow register values to be
+ * manipulated.
+ *
+ * Prereqs: None.
+ *
+ * Format: Array of 32-bit integer registers. Space is reserved for up to
+ * NXM_NX_MAX_REGS registers, but switches may implement fewer.
+ *
+ * Masking: Arbitrary masks. */
+#define NXM_NX_MAX_REGS 16
+#define NXM_NX_REG(IDX) NXM_HEADER (0x0001, IDX, 4)
+#define NXM_NX_REG_W(IDX) NXM_HEADER_W(0x0001, IDX, 4)
+#define NXM_NX_REG_IDX(HEADER) NXM_FIELD(HEADER)
+#define NXM_IS_NX_REG(HEADER) (!((((HEADER) ^ NXM_NX_REG0)) & 0xffffe1ff))
+#define NXM_IS_NX_REG_W(HEADER) (!((((HEADER) ^ NXM_NX_REG0_W)) & 0xffffe1ff))
+#define NXM_NX_REG0 NXM_HEADER (0x0001, 0, 4)
+#define NXM_NX_REG0_W NXM_HEADER_W(0x0001, 0, 4)
+#define NXM_NX_REG1 NXM_HEADER (0x0001, 1, 4)
+#define NXM_NX_REG1_W NXM_HEADER_W(0x0001, 1, 4)
+#define NXM_NX_REG2 NXM_HEADER (0x0001, 2, 4)
+#define NXM_NX_REG2_W NXM_HEADER_W(0x0001, 2, 4)
+#define NXM_NX_REG3 NXM_HEADER (0x0001, 3, 4)
+#define NXM_NX_REG3_W NXM_HEADER_W(0x0001, 3, 4)
+
+/* Tunnel ID.
+ *
+ * For a packet received via GRE tunnel including a (32-bit) key, the key is
+ * stored in the low 32-bits and the high bits are zeroed. For other packets,
+ * the value is 0.
+ *
+ * Prereqs: None.
+ *
+ * Format: 64-bit integer in network byte order.
+ *
+ * Masking: Arbitrary masks. */
+#define NXM_NX_TUN_ID NXM_HEADER (0x0001, 16, 8)
+#define NXM_NX_TUN_ID_W NXM_HEADER_W(0x0001, 16, 8)
+
+/* For an Ethernet+IP ARP packet, the source or target hardware address
+ * in the ARP header. Always 0 otherwise.
+ *
+ * Prereqs: NXM_OF_ETH_TYPE must match 0x0806 exactly.
+ *
+ * Format: 48-bit Ethernet MAC address.
+ *
+ * Masking: Not maskable. */
+#define NXM_NX_ARP_SHA NXM_HEADER (0x0001, 17, 6)
+#define NXM_NX_ARP_THA NXM_HEADER (0x0001, 18, 6)
+
+/* The source or destination address in the IPv6 header.
+ *
+ * Prereqs: NXM_OF_ETH_TYPE must match 0x86dd exactly.
+ *
+ * Format: 128-bit IPv6 address.
+ *
+ * Masking: Only CIDR masks are allowed, that is, masks that consist of N
+ * high-order bits set to 1 and the other 128-N bits set to 0. */
+#define NXM_NX_IPV6_SRC NXM_HEADER (0x0001, 19, 16)
+#define NXM_NX_IPV6_SRC_W NXM_HEADER_W(0x0001, 19, 16)
+#define NXM_NX_IPV6_DST NXM_HEADER (0x0001, 20, 16)
+#define NXM_NX_IPV6_DST_W NXM_HEADER_W(0x0001, 20, 16)
+
+/* The type or code in the ICMPv6 header.
+ *
+ * Prereqs:
+ * NXM_OF_ETH_TYPE must match 0x86dd exactly.
+ * NXM_OF_IP_PROTO must match 58 exactly.
+ *
+ * Format: 8-bit integer.
+ *
+ * Masking: Not maskable. */
+#define NXM_NX_ICMPV6_TYPE NXM_HEADER (0x0001, 21, 1)
+#define NXM_NX_ICMPV6_CODE NXM_HEADER (0x0001, 22, 1)
+
+/* The target address in an IPv6 Neighbor Discovery message.
+ *
+ * Prereqs:
+ * NXM_OF_ETH_TYPE must match 0x86dd exactly.
+ * NXM_OF_IP_PROTO must match 58 exactly.
+ * NXM_OF_ICMPV6_TYPE must be either 135 or 136.
+ *
+ * Format: 128-bit IPv6 address.
+ *
+ * Masking: Not maskable. */
+#define NXM_NX_ND_TARGET NXM_HEADER (0x0001, 23, 16)
+
+/* The source link-layer address option in an IPv6 Neighbor Discovery
+ * message.
+ *
+ * Prereqs:
+ * NXM_OF_ETH_TYPE must match 0x86dd exactly.
+ * NXM_OF_IP_PROTO must match 58 exactly.
+ * NXM_OF_ICMPV6_TYPE must be exactly 135.
+ *
+ * Format: 48-bit Ethernet MAC address.
+ *
+ * Masking: Not maskable. */
+#define NXM_NX_ND_SLL NXM_HEADER (0x0001, 24, 6)
+
+/* The target link-layer address option in an IPv6 Neighbor Discovery
+ * message.
+ *
+ * Prereqs:
+ * NXM_OF_ETH_TYPE must match 0x86dd exactly.
+ * NXM_OF_IP_PROTO must match 58 exactly.
+ * NXM_OF_ICMPV6_TYPE must be exactly 136.
+ *
+ * Format: 48-bit Ethernet MAC address.
+ *
+ * Masking: Not maskable. */
+#define NXM_NX_ND_TLL NXM_HEADER (0x0001, 25, 6)
+
+
+/* ## --------------------- ## */
+/* ## Requests and replies. ## */
+/* ## --------------------- ## */
+
+enum nx_flow_format {
+ NXFF_OPENFLOW10 = 0, /* Standard OpenFlow 1.0 compatible. */
+ NXFF_NXM = 2 /* Nicira extended match. */