common/mlx5: prepare support of packet pacing
[dpdk.git] / drivers / common / mlx5 / linux / mlx5_glue.c
index 62c4cc7..4d3875f 100644 (file)
@@ -587,11 +587,12 @@ mlx5_glue_dv_create_flow(void *matcher,
        return mlx5dv_dr_rule_create(matcher, match_value, num_actions,
                                     (struct mlx5dv_dr_action **)actions);
 #else
+       size_t i;
        struct mlx5dv_flow_action_attr actions_attr[8];
 
        if (num_actions > 8)
                return NULL;
-       for (size_t i = 0; i < num_actions; i++)
+       for (i = 0; i < num_actions; i++)
                actions_attr[i] =
                        *((struct mlx5dv_flow_action_attr *)(actions[i]));
        return mlx5dv_create_flow(matcher, match_value,
@@ -752,7 +753,7 @@ mlx5_glue_dv_create_flow_action_tag(uint32_t tag)
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
 #ifdef HAVE_MLX5DV_DR
        return mlx5dv_dr_action_create_tag(tag);
-#else
+#else /* HAVE_MLX5DV_DR */
        struct mlx5dv_flow_action_attr *action;
        action = malloc(sizeof(*action));
        if (!action)
@@ -760,11 +761,12 @@ mlx5_glue_dv_create_flow_action_tag(uint32_t tag)
        action->type = MLX5DV_FLOW_ACTION_TAG;
        action->tag_value = tag;
        return action;
-#endif
-#endif
+#endif /* HAVE_MLX5DV_DR */
+#else /* HAVE_IBV_FLOW_DV_SUPPORT */
        (void)tag;
        errno = ENOTSUP;
        return NULL;
+#endif /* HAVE_IBV_FLOW_DV_SUPPORT */
 }
 
 static void *
@@ -1193,7 +1195,6 @@ mlx5_glue_dv_free_var(struct mlx5dv_var *var)
 #endif
 }
 
-
 static void
 mlx5_glue_dr_reclaim_domain_memory(void *domain, uint32_t enable)
 {
@@ -1205,6 +1206,34 @@ mlx5_glue_dr_reclaim_domain_memory(void *domain, uint32_t enable)
 #endif
 }
 
+static struct mlx5dv_pp *
+mlx5_glue_dv_alloc_pp(struct ibv_context *context,
+                     size_t pp_context_sz,
+                     const void *pp_context,
+                     uint32_t flags)
+{
+#ifdef HAVE_MLX5DV_PP_ALLOC
+       return mlx5dv_pp_alloc(context, pp_context_sz, pp_context, flags);
+#else
+       RTE_SET_USED(context);
+       RTE_SET_USED(pp_context_sz);
+       RTE_SET_USED(pp_context);
+       RTE_SET_USED(flags);
+       errno = ENOTSUP;
+       return NULL;
+#endif
+}
+
+static void
+mlx5_glue_dv_free_pp(struct mlx5dv_pp *pp)
+{
+#ifdef HAVE_MLX5DV_PP_ALLOC
+       mlx5dv_pp_free(pp);
+#else
+       RTE_SET_USED(pp);
+#endif
+}
+
 __rte_cache_aligned
 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
        .version = MLX5_GLUE_VERSION,
@@ -1317,4 +1346,6 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
        .devx_free_uar = mlx5_glue_devx_free_uar,
        .dv_alloc_var = mlx5_glue_dv_alloc_var,
        .dv_free_var = mlx5_glue_dv_free_var,
+       .dv_alloc_pp = mlx5_glue_dv_alloc_pp,
+       .dv_free_pp = mlx5_glue_dv_free_pp,
 };