net/dpaa2: support basic stats
[dpdk.git] / lib / librte_ether / rte_flow.h
index 98084ac..8013eca 100644 (file)
@@ -268,6 +268,34 @@ enum rte_flow_item_type {
         * See struct rte_flow_item_vxlan.
         */
        RTE_FLOW_ITEM_TYPE_VXLAN,
+
+       /**
+        * Matches a E_TAG header.
+        *
+        * See struct rte_flow_item_e_tag.
+        */
+       RTE_FLOW_ITEM_TYPE_E_TAG,
+
+       /**
+        * Matches a NVGRE header.
+        *
+        * See struct rte_flow_item_nvgre.
+        */
+       RTE_FLOW_ITEM_TYPE_NVGRE,
+
+       /**
+        * Matches a MPLS header.
+        *
+        * See struct rte_flow_item_mpls.
+        */
+       RTE_FLOW_ITEM_TYPE_MPLS,
+
+       /**
+        * Matches a GRE header.
+        *
+        * See struct rte_flow_item_gre.
+        */
+       RTE_FLOW_ITEM_TYPE_GRE,
 };
 
 /**
@@ -282,7 +310,12 @@ enum rte_flow_item_type {
  * A zeroed mask stands for any number of layers.
  */
 struct rte_flow_item_any {
-       uint32_t num; /* Number of layers covered. */
+       uint32_t num; /**< Number of layers covered. */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
+static const struct rte_flow_item_any rte_flow_item_any_mask = {
+       .num = 0x00000000,
 };
 
 /**
@@ -307,6 +340,11 @@ struct rte_flow_item_vf {
        uint32_t id; /**< Destination VF ID. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
+static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
+       .id = 0x00000000,
+};
+
 /**
  * RTE_FLOW_ITEM_TYPE_PORT
  *
@@ -331,6 +369,11 @@ struct rte_flow_item_port {
        uint32_t index; /**< Physical port index. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_PORT. */
+static const struct rte_flow_item_port rte_flow_item_port_mask = {
+       .index = 0x00000000,
+};
+
 /**
  * RTE_FLOW_ITEM_TYPE_RAW
  *
@@ -359,6 +402,16 @@ struct rte_flow_item_raw {
        uint8_t pattern[]; /**< Byte string to look for. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
+static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
+       .relative = 1,
+       .search = 1,
+       .reserved = 0x3fffffff,
+       .offset = 0xffffffff,
+       .limit = 0xffff,
+       .length = 0xffff,
+};
+
 /**
  * RTE_FLOW_ITEM_TYPE_ETH
  *
@@ -370,6 +423,13 @@ struct rte_flow_item_eth {
        uint16_t type; /**< EtherType. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
+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 = 0x0000,
+};
+
 /**
  * RTE_FLOW_ITEM_TYPE_VLAN
  *
@@ -383,6 +443,12 @@ struct rte_flow_item_vlan {
        uint16_t tci; /**< Tag control information. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
+static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
+       .tpid = 0x0000,
+       .tci = 0xffff,
+};
+
 /**
  * RTE_FLOW_ITEM_TYPE_IPV4
  *
@@ -394,6 +460,14 @@ struct rte_flow_item_ipv4 {
        struct ipv4_hdr hdr; /**< IPv4 header definition. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
+static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
+       .hdr = {
+               .src_addr = 0xffffffff,
+               .dst_addr = 0xffffffff,
+       },
+};
+
 /**
  * RTE_FLOW_ITEM_TYPE_IPV6.
  *
@@ -405,6 +479,18 @@ struct rte_flow_item_ipv6 {
        struct ipv6_hdr hdr; /**< IPv6 header definition. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
+static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
+       .hdr = {
+               .src_addr =
+                       "\xff\xff\xff\xff\xff\xff\xff\xff"
+                       "\xff\xff\xff\xff\xff\xff\xff\xff",
+               .dst_addr =
+                       "\xff\xff\xff\xff\xff\xff\xff\xff"
+                       "\xff\xff\xff\xff\xff\xff\xff\xff",
+       },
+};
+
 /**
  * RTE_FLOW_ITEM_TYPE_ICMP.
  *
@@ -414,6 +500,14 @@ struct rte_flow_item_icmp {
        struct icmp_hdr hdr; /**< ICMP header definition. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
+static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
+       .hdr = {
+               .icmp_type = 0xff,
+               .icmp_code = 0xff,
+       },
+};
+
 /**
  * RTE_FLOW_ITEM_TYPE_UDP.
  *
@@ -423,6 +517,14 @@ struct rte_flow_item_udp {
        struct udp_hdr hdr; /**< UDP header definition. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
+static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
+       .hdr = {
+               .src_port = 0xffff,
+               .dst_port = 0xffff,
+       },
+};
+
 /**
  * RTE_FLOW_ITEM_TYPE_TCP.
  *
@@ -432,6 +534,14 @@ struct rte_flow_item_tcp {
        struct tcp_hdr hdr; /**< TCP header definition. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
+static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
+       .hdr = {
+               .src_port = 0xffff,
+               .dst_port = 0xffff,
+       },
+};
+
 /**
  * RTE_FLOW_ITEM_TYPE_SCTP.
  *
@@ -441,6 +551,14 @@ struct rte_flow_item_sctp {
        struct sctp_hdr hdr; /**< SCTP header definition. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
+static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
+       .hdr = {
+               .src_port = 0xffff,
+               .dst_port = 0xffff,
+       },
+};
+
 /**
  * RTE_FLOW_ITEM_TYPE_VXLAN.
  *
@@ -453,6 +571,84 @@ struct rte_flow_item_vxlan {
        uint8_t rsvd1; /**< Reserved, normally 0x00. */
 };
 
+/** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
+static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
+       .vni = "\xff\xff\xff",
+};
+
+/**
+ * RTE_FLOW_ITEM_TYPE_E_TAG.
+ *
+ * Matches a E-tag header.
+ */
+struct rte_flow_item_e_tag {
+       uint16_t tpid; /**< Tag protocol identifier (0x893F). */
+       /**
+        * E-Tag control information (E-TCI).
+        * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
+        */
+       uint16_t epcp_edei_in_ecid_b;
+       /** Reserved (2b), GRP (2b), E-CID base (12b). */
+       uint16_t rsvd_grp_ecid_b;
+       uint8_t in_ecid_e; /**< Ingress E-CID ext. */
+       uint8_t ecid_e; /**< E-CID ext. */
+};
+
+/**
+ * RTE_FLOW_ITEM_TYPE_NVGRE.
+ *
+ * Matches a NVGRE header.
+ */
+struct rte_flow_item_nvgre {
+       /**
+        * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
+        * reserved 0 (9b), version (3b).
+        *
+        * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
+        */
+       uint16_t c_k_s_rsvd0_ver;
+       uint16_t protocol; /**< Protocol type (0x6558). */
+       uint8_t tni[3]; /**< Virtual subnet ID. */
+       uint8_t flow_id; /**< Flow ID. */
+};
+
+/**
+ * RTE_FLOW_ITEM_TYPE_MPLS.
+ *
+ * Matches a MPLS header.
+ */
+struct rte_flow_item_mpls {
+       /**
+        * Label (20b), TC (3b), Bottom of Stack (1b).
+        */
+       uint8_t label_tc_s[3];
+       uint8_t ttl; /** Time-to-Live. */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
+static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
+       .label_tc_s = "\xff\xff\xf0",
+};
+
+/**
+ * RTE_FLOW_ITEM_TYPE_GRE.
+ *
+ * Matches a GRE header.
+ */
+struct rte_flow_item_gre {
+       /**
+        * Checksum (1b), reserved 0 (12b), version (3b).
+        * Refer to RFC 2784.
+        */
+       uint16_t c_rsvd0_ver;
+       uint16_t protocol; /**< Protocol type. */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
+static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
+       .protocol = 0xffff,
+};
+
 /**
  * Matching pattern item definition.
  *
@@ -464,15 +660,18 @@ struct rte_flow_item_vxlan {
  * Patterns are terminated by END items.
  *
  * The spec field should be a valid pointer to a structure of the related
- * item type. It may be set to NULL in many cases to use default values.
+ * item type. It may remain unspecified (NULL) in many cases to request
+ * broad (nonspecific) matching. In such cases, last and mask must also be
+ * set to NULL.
  *
  * Optionally, last can point to a structure of the same type to define an
  * inclusive range. This is mostly supported by integer and address fields,
  * may cause errors otherwise. Fields that do not support ranges must be set
  * to 0 or to the same value as the corresponding fields in spec.
  *
- * By default all fields present in spec are considered relevant (see note
- * below). This behavior can be altered by providing a mask structure of the
+ * Only the fields defined to nonzero values in the default masks (see
+ * rte_flow_item_{name}_mask constants) are considered relevant by
+ * default. This can be overridden by providing a mask structure of the
  * same type with applicable bits set to one. It can also be used to
  * partially filter out specific fields (e.g. as an alternate mean to match
  * ranges of IP addresses).
@@ -482,10 +681,6 @@ struct rte_flow_item_vxlan {
  * carefully. For example, if for an IPv4 address field, spec provides
  * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
  * effective range becomes 10.1.0.0 to 10.3.255.255.
- *
- * Note: the defaults for data-matching items such as IPv4 when mask is not
- * specified actually depend on the underlying implementation since only
- * recognized fields can be taken into account.
  */
 struct rte_flow_item {
        enum rte_flow_item_type type; /**< Item type. */
@@ -556,7 +751,8 @@ enum rte_flow_action_type {
        /**
         * [META]
         *
-        * Attaches a 32 bit value to packets.
+        * Attaches an integer value to packets and sets PKT_RX_FDIR and
+        * PKT_RX_FDIR_ID mbuf flags.
         *
         * See struct rte_flow_action_mark.
         */
@@ -565,9 +761,8 @@ enum rte_flow_action_type {
        /**
         * [META]
         *
-        * Flag packets. Similar to MARK but only affects ol_flags.
-        *
-        * Note: a distinctive flag must be defined for it.
+        * Flags packets. Similar to MARK without a specific value; only
+        * sets the PKT_RX_FDIR mbuf flag.
         *
         * No associated configuration structure.
         */
@@ -640,14 +835,15 @@ enum rte_flow_action_type {
 /**
  * RTE_FLOW_ACTION_TYPE_MARK
  *
- * Attaches a 32 bit value to packets.
+ * Attaches an integer value to packets and sets PKT_RX_FDIR and
+ * PKT_RX_FDIR_ID mbuf flags.
  *
- * This value is arbitrary and application-defined. For compatibility with
- * FDIR it is returned in the hash.fdir.hi mbuf field. PKT_RX_FDIR_ID is
- * also set in ol_flags.
+ * This value is arbitrary and application-defined. Maximum allowed value
+ * depends on the underlying implementation. It is returned in the
+ * hash.fdir.hi mbuf field.
  */
 struct rte_flow_action_mark {
-       uint32_t id; /**< 32 bit value to return with packets. */
+       uint32_t id; /**< Integer value to return with packets. */
 };
 
 /**
@@ -695,11 +891,9 @@ struct rte_flow_action_dup {
  * Similar to QUEUE, except RSS is additionally performed on packets to
  * spread them among several queues according to the provided parameters.
  *
- * Note: RSS hash result is normally stored in the hash.rss mbuf field,
- * however it conflicts with the MARK action as they share the same
- * space. When both actions are specified, the RSS hash is discarded and
- * PKT_RX_RSS_HASH is not set in ol_flags. MARK has priority. The mbuf
- * structure should eventually evolve to store both.
+ * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
+ * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
+ * both can be requested simultaneously.
  *
  * Terminating by default.
  */