ethdev: add hash function to RSS flow API action
[dpdk.git] / lib / librte_ether / rte_flow.h
index 44ae19d..97d7d35 100644 (file)
  * associated actions in hardware through flow rules.
  */
 
+#include <stddef.h>
 #include <stdint.h>
 
 #include <rte_arp.h>
 #include <rte_ether.h>
+#include <rte_eth_ctrl.h>
 #include <rte_icmp.h>
 #include <rte_ip.h>
 #include <rte_sctp.h>
@@ -78,15 +80,13 @@ struct rte_flow_attr {
  *
  * Pattern items fall in two categories:
  *
- * - Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4,
- *   IPV6, ICMP, UDP, TCP, SCTP, VXLAN and so on), usually associated with a
+ * - Matching protocol headers and packet data, usually associated with a
  *   specification structure. These must be stacked in the same order as the
- *   protocol layers to match, starting from the lowest.
+ *   protocol layers to match inside packets, starting from the lowest.
  *
- * - Matching meta-data or affecting pattern processing (END, VOID, INVERT,
- *   PF, VF, PORT and so on), often without a specification structure. Since
- *   they do not match packet contents, these can be specified anywhere
- *   within item lists without affecting others.
+ * - Matching meta-data or affecting pattern processing, often without a
+ *   specification structure. Since they do not match packet contents, their
+ *   position in the list is usually not relevant.
  *
  * See the description of individual types for more information. Those
  * marked with [META] fall into the second category.
@@ -434,7 +434,7 @@ struct rte_flow_item_raw {
        int32_t offset; /**< Absolute or relative offset for pattern. */
        uint16_t limit; /**< Search area limit for start of pattern. */
        uint16_t length; /**< Pattern length. */
-       uint8_t pattern[]; /**< Byte string to look for. */
+       const uint8_t *pattern; /**< Byte string to look for. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
@@ -446,6 +446,7 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
        .offset = 0xffffffff,
        .limit = 0xffff,
        .length = 0xffff,
+       .pattern = NULL,
 };
 #endif
 
@@ -861,33 +862,28 @@ struct rte_flow_item {
  *
  * Each possible action is represented by a type. Some have associated
  * configuration structures. Several actions combined in a list can be
- * affected to a flow rule. That list is not ordered.
+ * assigned to a flow rule and are performed in order.
  *
  * They fall in three categories:
  *
- * - Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent
- *   processing matched packets by subsequent flow rules, unless overridden
- *   with PASSTHRU.
+ * - Actions that modify the fate of matching traffic, for instance by
+ *   dropping or assigning it a specific destination.
  *
- * - Non terminating actions (PASSTHRU, DUP) that leave matched packets up
- *   for additional processing by subsequent flow rules.
+ * - Actions that modify matching traffic contents or its properties. This
+ *   includes adding/removing encapsulation, encryption, compression and
+ *   marks.
  *
- * - Other non terminating meta actions that do not affect the fate of
- *   packets (END, VOID, MARK, FLAG, COUNT).
+ * - Actions related to the flow rule itself, such as updating counters or
+ *   making it non-terminating.
  *
- * When several actions are combined in a flow rule, they should all have
- * different types (e.g. dropping a packet twice is not possible).
+ * Flow rules being terminating by default, not specifying any action of the
+ * fate kind results in undefined behavior. This applies to both ingress and
+ * egress.
  *
- * Only the last action of a given type is taken into account. PMDs still
- * perform error checking on the entire list.
- *
- * Note that PASSTHRU is the only action able to override a terminating
- * rule.
+ * PASSTHRU, when supported, makes a flow rule non-terminating.
  */
 enum rte_flow_action_type {
        /**
-        * [META]
-        *
         * End marker for action lists. Prevents further processing of
         * actions, thereby ending the list.
         *
@@ -896,8 +892,6 @@ enum rte_flow_action_type {
        RTE_FLOW_ACTION_TYPE_END,
 
        /**
-        * [META]
-        *
         * Used as a placeholder for convenience. It is ignored and simply
         * discarded by PMDs.
         *
@@ -906,18 +900,14 @@ enum rte_flow_action_type {
        RTE_FLOW_ACTION_TYPE_VOID,
 
        /**
-        * Leaves packets up for additional processing by subsequent flow
-        * rules. This is the default when a rule does not contain a
-        * terminating action, but can be specified to force a rule to
-        * become non-terminating.
+        * Leaves traffic up for additional processing by subsequent flow
+        * rules; makes a flow rule non-terminating.
         *
         * No associated configuration structure.
         */
        RTE_FLOW_ACTION_TYPE_PASSTHRU,
 
        /**
-        * [META]
-        *
         * Attaches an integer value to packets and sets PKT_RX_FDIR and
         * PKT_RX_FDIR_ID mbuf flags.
         *
@@ -926,8 +916,6 @@ enum rte_flow_action_type {
        RTE_FLOW_ACTION_TYPE_MARK,
 
        /**
-        * [META]
-        *
         * Flags packets. Similar to MARK without a specific value; only
         * sets the PKT_RX_FDIR mbuf flag.
         *
@@ -952,9 +940,7 @@ enum rte_flow_action_type {
        RTE_FLOW_ACTION_TYPE_DROP,
 
        /**
-        * [META]
-        *
-        * Enables counters for this rule.
+        * Enables counters for this flow rule.
         *
         * These counters can be retrieved and reset through rte_flow_query(),
         * see struct rte_flow_query_count.
@@ -963,16 +949,6 @@ enum rte_flow_action_type {
         */
        RTE_FLOW_ACTION_TYPE_COUNT,
 
-       /**
-        * Duplicates packets to a given queue index.
-        *
-        * This is normally combined with QUEUE, however when used alone, it
-        * is actually similar to QUEUE + PASSTHRU.
-        *
-        * See struct rte_flow_action_dup.
-        */
-       RTE_FLOW_ACTION_TYPE_DUP,
-
        /**
         * Similar to QUEUE, except RSS is additionally performed on packets
         * to spread them among several queues according to the provided
@@ -1033,8 +1009,6 @@ struct rte_flow_action_mark {
  * RTE_FLOW_ACTION_TYPE_QUEUE
  *
  * Assign packets to a given queue index.
- *
- * Terminating by default.
  */
 struct rte_flow_action_queue {
        uint16_t index; /**< Queue index to use. */
@@ -1054,36 +1028,29 @@ struct rte_flow_query_count {
        uint64_t bytes; /**< Number of bytes through this rule [out]. */
 };
 
-/**
- * RTE_FLOW_ACTION_TYPE_DUP
- *
- * Duplicates packets to a given queue index.
- *
- * This is normally combined with QUEUE, however when used alone, it is
- * actually similar to QUEUE + PASSTHRU.
- *
- * Non-terminating by default.
- */
-struct rte_flow_action_dup {
-       uint16_t index; /**< Queue index to duplicate packets to. */
-};
-
 /**
  * RTE_FLOW_ACTION_TYPE_RSS
  *
  * Similar to QUEUE, except RSS is additionally performed on packets to
  * spread them among several queues according to the provided parameters.
  *
+ * Unlike global RSS settings used by other DPDK APIs, unsetting the
+ * @p types field does not disable RSS in a flow rule. Doing so instead
+ * requests safe unspecified "best-effort" settings from the underlying PMD,
+ * which depending on the flow rule, may result in anything ranging from
+ * empty (single queue) to all-inclusive RSS.
+ *
  * 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.
  */
 struct rte_flow_action_rss {
-       const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */
-       uint16_t num; /**< Number of entries in queue[]. */
-       uint16_t queue[]; /**< Queues indices to use. */
+       enum rte_eth_hash_function func; /**< RSS hash function to apply. */
+       uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
+       uint32_t key_len; /**< Hash key length in bytes. */
+       uint32_t queue_num; /**< Number of entries in @p queue. */
+       const uint8_t *key; /**< Hash key. */
+       const uint16_t *queue; /**< Queue indices to use. */
 };
 
 /**
@@ -1096,8 +1063,6 @@ struct rte_flow_action_rss {
  * and is not guaranteed to work properly if the VF part is matched by a
  * prior flow rule or if packets are not addressed to a VF in the first
  * place.
- *
- * Terminating by default.
  */
 struct rte_flow_action_vf {
        uint32_t original:1; /**< Use original VF ID if possible. */
@@ -1112,8 +1077,6 @@ struct rte_flow_action_vf {
  *
  * Packets matched by items of this type can be either dropped or passed to the
  * next item with their color set by the MTR object.
- *
- * Non-terminating by default.
  */
 struct rte_flow_action_meter {
        uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
@@ -1143,8 +1106,6 @@ struct rte_flow_action_meter {
  * direction.
  *
  * Multiple flows can be configured to use the same security session.
- *
- * Non-terminating by default.
  */
 struct rte_flow_action_security {
        void *security_session; /**< Pointer to security session structure. */
@@ -1186,8 +1147,12 @@ enum rte_flow_error_type {
        RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
        RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
        RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
+       RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
+       RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
+       RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
        RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
        RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
+       RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
        RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
 };