net/mlx5: add Direct Rules API
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.h
index cb1e6fd..8ba37a0 100644 (file)
@@ -21,6 +21,9 @@
 #pragma GCC diagnostic error "-Wpedantic"
 #endif
 
+#include "mlx5.h"
+#include "mlx5_prm.h"
+
 /* Pattern outer Layer bits. */
 #define MLX5_FLOW_LAYER_OUTER_L2 (1u << 0)
 #define MLX5_FLOW_LAYER_OUTER_L3_IPV4 (1u << 1)
@@ -201,6 +204,7 @@ struct mlx5_flow_dv_matcher {
        uint16_t crc; /**< CRC of key. */
        uint16_t priority; /**< Priority of matcher. */
        uint8_t egress; /**< Egress matcher. */
+       uint32_t group; /**< The matcher group. */
        struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
 };
 
@@ -211,12 +215,23 @@ struct mlx5_flow_dv_encap_decap_resource {
        LIST_ENTRY(mlx5_flow_dv_encap_decap_resource) next;
        /* Pointer to next element. */
        rte_atomic32_t refcnt; /**< Reference counter. */
-       struct ibv_flow_action *verbs_action;
+       void *verbs_action;
        /**< Verbs encap/decap action object. */
        uint8_t buf[MLX5_ENCAP_MAX_LEN];
        size_t size;
        uint8_t reformat_type;
        uint8_t ft_type;
+       uint64_t flags; /**< Flags for RDMA API. */
+};
+
+/* Tag resource structure. */
+struct mlx5_flow_dv_tag_resource {
+       LIST_ENTRY(mlx5_flow_dv_tag_resource) next;
+       /* Pointer to next element. */
+       rte_atomic32_t refcnt; /**< Reference counter. */
+       void *action;
+       /**< Verbs tag action object. */
+       uint32_t tag; /**< the tag value. */
 };
 
 /* Number of modification commands. */
@@ -256,7 +271,7 @@ struct mlx5_flow_dv {
        /**< Pointer to modify header resource in cache. */
        struct ibv_flow *flow; /**< Installed flow. */
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
-       struct mlx5dv_flow_action_attr actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS];
+       void *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS];
        /**< Action list. */
 #endif
        int actions_n; /**< number of actions. */
@@ -319,20 +334,26 @@ struct mlx5_flow_counter {
        uint32_t shared:1; /**< Share counter ID with other flow rules. */
        uint32_t ref_cnt:31; /**< Reference counter. */
        uint32_t id; /**< Counter ID. */
+       union {  /**< Holds the counters for the rule. */
 #if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42)
-       struct ibv_counter_set *cs; /**< Holds the counters for the rule. */
+               struct ibv_counter_set *cs;
 #elif defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45)
-       struct ibv_counters *cs; /**< Holds the counters for the rule. */
+               struct ibv_counters *cs;
 #endif
+               struct mlx5_devx_counter_set *dcs;
+       };
        uint64_t hits; /**< Number of packets matched by the rule. */
        uint64_t bytes; /**< Number of bytes matched by the rule. */
+       void *action; /**< Pointer to the dv action. */
 };
 
 /* Flow structure. */
 struct rte_flow {
        TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */
-       enum mlx5_flow_drv_type drv_type; /**< Drvier type. */
+       enum mlx5_flow_drv_type drv_type; /**< Driver type. */
        struct mlx5_flow_counter *counter; /**< Holds flow counter. */
+       struct mlx5_flow_dv_tag_resource *tag_resource;
+       /**< pointer to the tag action. */
        struct rte_flow_action_rss rss;/**< RSS context. */
        uint8_t key[MLX5_RSS_HASH_KEY_LEN]; /**< RSS hash key. */
        uint16_t (*queue)[]; /**< Destination queues to redirect traffic to. */
@@ -341,6 +362,8 @@ struct rte_flow {
        uint64_t actions;
        /**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */
        struct mlx5_fdir *fdir; /**< Pointer to associated FDIR if any. */
+       uint8_t ingress; /**< 1 if the flow is ingress. */
+       uint32_t group; /**< The group index. */
 };
 
 typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
@@ -425,9 +448,11 @@ int mlx5_flow_validate_item_gre(const struct rte_flow_item *item,
                                struct rte_flow_error *error);
 int mlx5_flow_validate_item_ipv4(const struct rte_flow_item *item,
                                 uint64_t item_flags,
+                                const struct rte_flow_item_ipv4 *acc_mask,
                                 struct rte_flow_error *error);
 int mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,
                                 uint64_t item_flags,
+                                const struct rte_flow_item_ipv6 *acc_mask,
                                 struct rte_flow_error *error);
 int mlx5_flow_validate_item_mpls(struct rte_eth_dev *dev,
                                 const struct rte_flow_item *item,