#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.
#include <sys/types.h>
#include "mlx5_glue.h"
+#include "../mlx5_malloc.h"
static int
mlx5_glue_fork_init(void)
res = ibv_destroy_flow_action(attr->action);
break;
}
- free(action);
+ mlx5_free(action);
return res;
#endif
#else
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,
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;
#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;
(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;
(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;
#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 *
#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)
#endif
}
-
static void
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,
.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,
.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,
};