net/mlx5: add default flows for hairpin
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.h
index a79b48b..f81e1b1 100644 (file)
@@ -44,6 +44,7 @@ enum modify_reg {
 enum mlx5_rte_flow_item_type {
        MLX5_RTE_FLOW_ITEM_TYPE_END = INT_MIN,
        MLX5_RTE_FLOW_ITEM_TYPE_TAG,
+       MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE,
 };
 
 /* Private rte flow actions. */
@@ -64,6 +65,11 @@ struct mlx5_rte_flow_action_set_tag {
        rte_be32_t data;
 };
 
+/* Matches on source queue. */
+struct mlx5_rte_flow_item_tx_queue {
+       uint32_t queue;
+};
+
 /* Pattern outer Layer bits. */
 #define MLX5_FLOW_LAYER_OUTER_L2 (1u << 0)
 #define MLX5_FLOW_LAYER_OUTER_L3_IPV4 (1u << 1)
@@ -103,6 +109,9 @@ struct mlx5_rte_flow_action_set_tag {
 #define MLX5_FLOW_LAYER_NVGRE (1u << 23)
 #define MLX5_FLOW_LAYER_GENEVE (1u << 24)
 
+/* Queue items. */
+#define MLX5_FLOW_ITEM_TX_QUEUE (1u << 25)
+
 /* Outer Masks. */
 #define MLX5_FLOW_LAYER_OUTER_L3 \
        (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
@@ -527,8 +536,22 @@ struct mlx5_flow_driver_ops {
 #define MLX5_CNT_CONTAINER_UNUSED(sh, batch, thread) (&(sh)->cmng.ccont \
        [(~((sh)->cmng.mhi[batch] >> (thread)) & 0x1) * 2 + (batch)])
 
+/* ID generation structure. */
+struct mlx5_flow_id_pool {
+       uint32_t *free_arr; /**< Pointer to the a array of free values. */
+       uint32_t base_index;
+       /**< The next index that can be used without any free elements. */
+       uint32_t *curr; /**< Pointer to the index to pop. */
+       uint32_t *last; /**< Pointer to the last element in the empty arrray. */
+};
+
 /* mlx5_flow.c */
 
+struct mlx5_flow_id_pool *mlx5_flow_id_pool_alloc(void);
+void mlx5_flow_id_pool_release(struct mlx5_flow_id_pool *pool);
+uint32_t mlx5_flow_id_get(struct mlx5_flow_id_pool *pool, uint32_t *id);
+uint32_t mlx5_flow_id_release(struct mlx5_flow_id_pool *pool,
+                             uint32_t id);
 int mlx5_flow_group_to_table(const struct rte_flow_attr *attributes,
                             bool external, uint32_t group, uint32_t *table,
                             struct rte_flow_error *error);