net/mlx5: add abstraction for multiple flow drivers
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.h
index e5c6bf3..d2ec6d3 100644 (file)
        (MLX5_FLOW_LAYER_INNER_L2 | MLX5_FLOW_LAYER_INNER_L3 | \
         MLX5_FLOW_LAYER_INNER_L4)
 
-/* Actions that modify the fate of matching traffic. */
-#define MLX5_FLOW_FATE_DROP (1u << 0)
-#define MLX5_FLOW_FATE_QUEUE (1u << 1)
-#define MLX5_FLOW_FATE_RSS (1u << 2)
-
-/* Modify a packet. */
-#define MLX5_FLOW_MOD_FLAG (1u << 0)
-#define MLX5_FLOW_MOD_MARK (1u << 1)
-#define MLX5_FLOW_MOD_COUNT (1u << 2)
-
 /* Actions */
 #define MLX5_FLOW_ACTION_DROP (1u << 0)
 #define MLX5_FLOW_ACTION_QUEUE (1u << 1)
 #define IPPROTO_MPLS 137
 #endif
 
+/* UDP port numbers for VxLAN. */
+#define MLX5_UDP_PORT_VXLAN 4789
+#define MLX5_UDP_PORT_VXLAN_GPE 4790
+
 /* Priority reserved for default flows. */
 #define MLX5_FLOW_PRIO_RSVD ((uint32_t)-1)
 
 #define MLX5_PRIORITY_MAP_L4 0
 #define MLX5_PRIORITY_MAP_MAX 3
 
+/* Valid layer type for IPV4 RSS. */
+#define MLX5_IPV4_LAYER_TYPES \
+       (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
+        ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV4_UDP | \
+        ETH_RSS_NONFRAG_IPV4_OTHER)
+
+/* IBV hash source bits  for IPV4. */
+#define MLX5_IPV4_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4)
+
+/* Valid layer type for IPV6 RSS. */
+#define MLX5_IPV6_LAYER_TYPES \
+       (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_TCP | \
+        ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_IPV6_EX  | ETH_RSS_IPV6_TCP_EX | \
+        ETH_RSS_IPV6_UDP_EX | ETH_RSS_NONFRAG_IPV6_OTHER)
+
+/* IBV hash source bits  for IPV6. */
+#define MLX5_IPV6_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6)
+
 /* Max number of actions per DV flow. */
 #define MLX5_DV_MAX_NUMBER_OF_ACTIONS 8
 
+enum mlx5_flow_drv_type {
+       MLX5_FLOW_TYPE_MIN,
+       MLX5_FLOW_TYPE_DV,
+       MLX5_FLOW_TYPE_VERBS,
+       MLX5_FLOW_TYPE_MAX,
+};
+
 /* Matcher PRM representation */
 struct mlx5_flow_dv_match_params {
        size_t size;
@@ -116,6 +135,8 @@ struct mlx5_flow_dv_match_params {
        /**< Matcher value. This value is used as the mask or as a key. */
 };
 
+#define MLX5_DV_MAX_NUMBER_OF_ACTIONS 8
+
 /* Matcher structure. */
 struct mlx5_flow_dv_matcher {
        LIST_ENTRY(mlx5_flow_dv_matcher) next;
@@ -137,6 +158,11 @@ struct mlx5_flow_dv {
        struct mlx5_flow_dv_match_params value;
        /**< Holds the value that the packet is compared to. */
        struct ibv_flow *flow; /**< Installed flow. */
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
+       struct mlx5dv_flow_action_attr actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS];
+       /**< Action list. */
+#endif
+       int actions_n; /**< number of actions. */
 };
 
 /* Verbs specification header. */
@@ -165,7 +191,9 @@ struct mlx5_flow {
        struct rte_flow *flow; /**< Pointer to the main flow. */
        uint32_t layers; /**< Bit-fields that holds the detected layers. */
        union {
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
                struct mlx5_flow_dv dv;
+#endif
                struct mlx5_flow_verbs verbs;
        };
 };
@@ -184,7 +212,7 @@ struct mlx5_flow_counter {
 /* Flow structure. */
 struct rte_flow {
        TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */
-       struct rte_flow_attr attributes; /**< User flow attribute. */
+       enum mlx5_flow_drv_type drv_type; /**< Drvier type. */
        uint32_t layers;
        /**< Bit-fields of present layers see MLX5_FLOW_LAYER_*. */
        struct mlx5_flow_counter *counter; /**< Holds flow counter. */
@@ -228,6 +256,9 @@ struct mlx5_flow_driver_ops {
 
 /* mlx5_flow.c */
 
+uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow *dev_flow, int tunnel,
+                                    uint32_t layer_types,
+                                    uint64_t hash_fields);
 uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
                                   uint32_t subpriority);
 int mlx5_flow_validate_action_count(struct rte_eth_dev *dev,
@@ -285,13 +316,5 @@ int mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
                                      uint64_t item_flags,
                                      struct rte_eth_dev *dev,
                                      struct rte_flow_error *error);
-void mlx5_flow_init_driver_ops(struct rte_eth_dev *dev);
-
-/* mlx5_flow_dv.c */
-void mlx5_flow_dv_get_driver_ops(struct mlx5_flow_driver_ops *flow_ops);
-
-/* mlx5_flow_verbs.c */
-
-void mlx5_flow_verbs_get_driver_ops(struct mlx5_flow_driver_ops *flow_ops);
 
 #endif /* RTE_PMD_MLX5_FLOW_H_ */