net/txgbe: add queue stats mapping
[dpdk.git] / drivers / common / mlx5 / linux / mlx5_glue.c
index 62c4cc7..47b7e98 100644 (file)
@@ -8,6 +8,7 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <rte_memory.h>
 /*
  * Not needed by this file; included to work around the lack of off_t
  * definition for mlx5dv.h with unpatched rdma-core versions.
@@ -15,6 +16,7 @@
 #include <sys/types.h>
 
 #include "mlx5_glue.h"
+#include "../mlx5_malloc.h"
 
 static int
 mlx5_glue_fork_init(void)
@@ -184,7 +186,7 @@ mlx5_glue_destroy_flow_action(void *action)
                res = ibv_destroy_flow_action(attr->action);
                break;
        }
-       free(action);
+       mlx5_free(action);
        return res;
 #endif
 #else
@@ -587,11 +589,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,
@@ -616,7 +619,7 @@ mlx5_glue_dv_create_flow_action_counter(void *counter_obj, uint32_t offset)
        struct mlx5dv_flow_action_attr *action;
 
        (void)offset;
-       action = malloc(sizeof(*action));
+       action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
        if (!action)
                return NULL;
        action->type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
@@ -640,7 +643,7 @@ mlx5_glue_dv_create_flow_action_dest_ibv_qp(void *qp)
 #else
        struct mlx5dv_flow_action_attr *action;
 
-       action = malloc(sizeof(*action));
+       action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
        if (!action)
                return NULL;
        action->type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
@@ -685,7 +688,7 @@ mlx5_glue_dv_create_flow_action_modify_header
 
        (void)domain;
        (void)flags;
-       action = malloc(sizeof(*action));
+       action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
        if (!action)
                return NULL;
        action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
@@ -725,7 +728,7 @@ mlx5_glue_dv_create_flow_action_packet_reformat
        (void)flags;
        struct mlx5dv_flow_action_attr *action;
 
-       action = malloc(sizeof(*action));
+       action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
        if (!action)
                return NULL;
        action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
@@ -752,19 +755,21 @@ 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));
+
+       action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
        if (!action)
                return NULL;
        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 *
@@ -1058,6 +1063,39 @@ mlx5_glue_dr_dump_domain(FILE *file, void *domain)
 #endif
 }
 
+static void *
+mlx5_glue_dr_create_flow_action_sampler
+                       (struct mlx5dv_dr_flow_sampler_attr *attr)
+{
+#ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE
+       return mlx5dv_dr_action_create_flow_sampler(attr);
+#else
+       (void)attr;
+       errno = ENOTSUP;
+       return NULL;
+#endif
+}
+
+static void *
+mlx5_glue_dr_action_create_dest_array
+                       (void *domain,
+                        size_t num_dest,
+                        struct mlx5dv_dr_action_dest_attr *dests[])
+{
+#ifdef HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY
+       return mlx5dv_dr_action_create_dest_array
+                               (domain,
+                               num_dest,
+                               dests);
+#else
+       (void)domain;
+       (void)num_dest;
+       (void)dests;
+       errno = ENOTSUP;
+       return NULL;
+#endif
+}
+
 static int
 mlx5_glue_devx_query_eqn(struct ibv_context *ctx, uint32_t cpus,
                         uint32_t *eqn)
@@ -1193,7 +1231,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 +1242,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,
@@ -1307,6 +1372,10 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
        .devx_port_query = mlx5_glue_devx_port_query,
        .dr_dump_domain = mlx5_glue_dr_dump_domain,
        .dr_reclaim_domain_memory = mlx5_glue_dr_reclaim_domain_memory,
+       .dr_create_flow_action_sampler =
+               mlx5_glue_dr_create_flow_action_sampler,
+       .dr_create_flow_action_dest_array =
+               mlx5_glue_dr_action_create_dest_array,
        .devx_query_eqn = mlx5_glue_devx_query_eqn,
        .devx_create_event_channel = mlx5_glue_devx_create_event_channel,
        .devx_destroy_event_channel = mlx5_glue_devx_destroy_event_channel,
@@ -1317,4 +1386,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,
 };