#include <rte_sctp.h>
#include <rte_tcp.h>
#include <rte_udp.h>
+#include <rte_vxlan.h>
#include <rte_byteorder.h>
#include <rte_esp.h>
#include <rte_higig.h>
* See struct rte_flow_item_ipv6_frag_ext.
*/
RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+
+ /**
+ * Matches Geneve Variable Length Option
+ *
+ * See struct rte_flow_item_geneve_opt
+ */
+ RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
};
/**
*
* Matches an Ethernet header.
*
- * The @p type field either stands for "EtherType" or "TPID" when followed
- * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
- * the latter case, @p type refers to that of the outer header, with the
- * inner EtherType/TPID provided by the subsequent pattern item. This is the
- * same order as on the wire.
- * If the @p type field contains a TPID value, then only tagged packets with the
- * specified TPID will match the pattern.
- * The field @p has_vlan can be used to match any type of tagged packets,
- * instead of using the @p type field.
- * If the @p type and @p has_vlan fields are not specified, then both tagged
- * and untagged packets will match the pattern.
+ * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
+ * or TPID, depending on whether the item is followed by a VLAN item or not. If
+ * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
+ * contains the inner TPID in the similar header field. The innermost VLAN item
+ * contains a layer-3 EtherType. All of that follows the order seen on the wire.
+ *
+ * If the field in question contains a TPID value, only tagged packets with the
+ * specified TPID will match the pattern. Alternatively, it's possible to match
+ * any type of tagged packets by means of the field @p has_vlan rather than use
+ * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
+ * If this is the case, both tagged and untagged packets will match the pattern.
*/
+RTE_STD_C11
struct rte_flow_item_eth {
- struct rte_ether_addr dst; /**< Destination MAC. */
- struct rte_ether_addr src; /**< Source MAC. */
- rte_be16_t type; /**< EtherType or TPID. */
+ union {
+ struct {
+ /*
+ * These fields are retained for compatibility.
+ * Please switch to the new header field below.
+ */
+ struct rte_ether_addr dst; /**< Destination MAC. */
+ struct rte_ether_addr src; /**< Source MAC. */
+ rte_be16_t type; /**< EtherType or TPID. */
+ };
+ struct rte_ether_hdr hdr;
+ };
uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
uint32_t reserved:31; /**< Reserved, must be zero. */
};
/** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
#ifndef __cplusplus
static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
- .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
- .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
- .type = RTE_BE16(0x0000),
+ .hdr.d_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
+ .hdr.s_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
+ .hdr.ether_type = RTE_BE16(0x0000),
};
#endif
* If a @p VLAN item is present in the pattern, then only tagged packets will
* match the pattern.
* The field @p has_more_vlan can be used to match any type of tagged packets,
- * instead of using the @p inner_type field.
- * If the @p inner_type and @p has_more_vlan fields are not specified,
+ * instead of using the @p eth_proto field of @p hdr.
+ * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
* then any tagged packets will match the pattern.
*/
+RTE_STD_C11
struct rte_flow_item_vlan {
- rte_be16_t tci; /**< Tag control information. */
- rte_be16_t inner_type; /**< Inner EtherType or TPID. */
+ union {
+ struct {
+ /*
+ * These fields are retained for compatibility.
+ * Please switch to the new header field below.
+ */
+ rte_be16_t tci; /**< Tag control information. */
+ rte_be16_t inner_type; /**< Inner EtherType or TPID. */
+ };
+ struct rte_vlan_hdr hdr;
+ };
uint32_t has_more_vlan:1;
/**< Packet header contains at least one more VLAN, after this VLAN. */
uint32_t reserved:31; /**< Reserved, must be zero. */
/** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
#ifndef __cplusplus
static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
- .tci = RTE_BE16(0x0fff),
- .inner_type = RTE_BE16(0x0000),
+ .hdr.vlan_tci = RTE_BE16(0x0fff),
+ .hdr.eth_proto = RTE_BE16(0x0000),
};
#endif
*
* Matches a VXLAN header (RFC 7348).
*/
+RTE_STD_C11
struct rte_flow_item_vxlan {
- uint8_t flags; /**< Normally 0x08 (I flag). */
- uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
- uint8_t vni[3]; /**< VXLAN identifier. */
- uint8_t rsvd1; /**< Reserved, normally 0x00. */
+ union {
+ struct {
+ /*
+ * These fields are retained for compatibility.
+ * Please switch to the new header field below.
+ */
+ uint8_t flags; /**< Normally 0x08 (I flag). */
+ uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
+ uint8_t vni[3]; /**< VXLAN identifier. */
+ uint8_t rsvd1; /**< Reserved, normally 0x00. */
+ };
+ struct rte_vxlan_hdr hdr;
+ };
};
/** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
#ifndef __cplusplus
static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
- .vni = "\xff\xff\xff",
+ .hdr.vx_vni = RTE_BE32(__builtin_constant_p(0xffffff << 8)),
};
#endif
};
#endif
+/**
+ * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
+ *
+ * Matches a GENEVE Variable Length Option
+ */
+struct rte_flow_item_geneve_opt {
+ rte_be16_t option_class;
+ uint8_t option_type;
+ uint8_t option_len;
+ uint32_t *data;
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
+#ifndef __cplusplus
+static const struct rte_flow_item_geneve_opt
+rte_flow_item_geneve_opt_mask = {
+ .option_type = 0xff,
+};
+#endif
+
/**
* Matching pattern item definition.
*
* struct rte_flow_shared_action).
*/
RTE_FLOW_ACTION_TYPE_SHARED,
+
+ /**
+ * Modify a packet header field, tag, mark or metadata.
+ *
+ * Allow the modification of an arbitrary header field via
+ * set, add and sub operations or copying its content into
+ * tag, meta or mark for future processing.
+ *
+ * See struct rte_flow_action_modify_field.
+ */
+ RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
};
/**
uint8_t dscp;
};
-
/**
* RTE_FLOW_ACTION_TYPE_SHARED
*
*/
struct rte_flow_shared_action;
+/**
+ * Field IDs for MODIFY_FIELD action.
+ */
+enum rte_flow_field_id {
+ RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
+ RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
+ RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
+ RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */
+ RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */
+ RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
+ RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
+ RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
+ RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
+ RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
+ RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
+ RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
+ RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
+ RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
+ RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
+ RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
+ RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
+ RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
+ RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
+ RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
+ RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
+ RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
+ RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
+ RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
+ RTE_FLOW_FIELD_TAG, /**< Tag value. */
+ RTE_FLOW_FIELD_MARK, /**< Mark value. */
+ RTE_FLOW_FIELD_META, /**< Metadata value. */
+ RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
+ RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
+};
+
+/**
+ * Field description for MODIFY_FIELD action.
+ */
+struct rte_flow_action_modify_data {
+ enum rte_flow_field_id field; /**< Field or memory type ID. */
+ RTE_STD_C11
+ union {
+ struct {
+ /**< Encapsulation level or tag index. */
+ uint32_t level;
+ /**< Number of bits to skip from a field. */
+ uint32_t offset;
+ };
+ /**
+ * Immediate value for RTE_FLOW_FIELD_VALUE or
+ * memory address for RTE_FLOW_FIELD_POINTER.
+ */
+ uint64_t value;
+ };
+};
+
+/**
+ * Operation types for MODIFY_FIELD action.
+ */
+enum rte_flow_modify_op {
+ RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
+ RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
+ RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
+ *
+ * Modify a destination header field according to the specified
+ * operation. Another packet field can be used as a source as well
+ * as tag, mark, metadata, immediate value or a pointer to it.
+ */
+struct rte_flow_action_modify_field {
+ enum rte_flow_modify_op operation; /**< Operation to perform. */
+ struct rte_flow_action_modify_data dst; /**< Destination field. */
+ struct rte_flow_action_modify_data src; /**< Source field. */
+ uint32_t width; /**< Number of bits to use from a source field. */
+};
+
/* Mbuf dynamic field offset for metadata. */
extern int32_t rte_flow_dynf_metadata_offs;