net/mlx5: add Direct Verbs translate actions
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.h
index 467b5a8..9870805 100644 (file)
 #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
+
+/* Matcher PRM representation */
+struct mlx5_flow_dv_match_params {
+       size_t size;
+       /**< Size of match value. Do NOT split size and key! */
+       uint32_t buf[MLX5_ST_SZ_DW(fte_match_param)];
+       /**< 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;
+       /* Pointer to the next element. */
+       rte_atomic32_t refcnt; /**< Reference counter. */
+       void *matcher_object; /**< Pointer to DV matcher */
+       uint16_t crc; /**< CRC of key. */
+       uint16_t priority; /**< Priority of matcher. */
+       uint8_t egress; /**< Egress matcher. */
+       struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
+};
+
+/* DV flows structure. */
+struct mlx5_flow_dv {
+       uint64_t hash_fields; /**< Fields that participate in the hash. */
+       struct mlx5_hrxq *hrxq; /**< Hash Rx queues. */
+       /* Flow DV api: */
+       struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */
+       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. */
 struct ibv_spec_header {
        enum ibv_flow_spec_type type;
@@ -131,7 +194,8 @@ struct mlx5_flow {
        struct rte_flow *flow; /**< Pointer to the main flow. */
        uint32_t layers; /**< Bit-fields that holds the detected layers. */
        union {
-               struct mlx5_flow_verbs verbs; /**< Holds the verbs dev-flow. */
+               struct mlx5_flow_dv dv;
+               struct mlx5_flow_verbs verbs;
        };
 };
 
@@ -193,6 +257,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,
@@ -252,6 +319,9 @@ int mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
                                      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);