#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;
}
- mlx5_free(action);
+ free(action);
return res;
#endif
#else
static void *
mlx5_glue_dr_create_flow_action_dest_port(void *domain, uint32_t port)
{
-#ifdef HAVE_MLX5DV_DR_DEVX_PORT
+#ifdef HAVE_MLX5DV_DR_CREATE_DEST_IB_PORT
return mlx5dv_dr_action_create_dest_ib_port(domain, port);
#else
#ifdef HAVE_MLX5DV_DR_ESWITCH
struct mlx5dv_flow_action_attr *action;
(void)offset;
- action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
+ action = malloc(sizeof(*action));
if (!action)
return NULL;
action->type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
#else
struct mlx5dv_flow_action_attr *action;
- action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
+ action = malloc(sizeof(*action));
if (!action)
return NULL;
action->type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
(void)domain;
(void)flags;
- action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
+ action = malloc(sizeof(*action));
if (!action)
return NULL;
action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
(void)flags;
struct mlx5dv_flow_action_attr *action;
- action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
+ action = malloc(sizeof(*action));
if (!action)
return NULL;
action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
#else /* HAVE_MLX5DV_DR */
struct mlx5dv_flow_action_attr *action;
- action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
+ action = malloc(sizeof(*action));
if (!action)
return NULL;
action->type = MLX5DV_FLOW_ACTION_TAG;
#endif
}
+static void *
+mlx5_glue_dv_create_flow_action_aso(struct mlx5dv_dr_domain *domain,
+ void *aso_obj,
+ uint32_t offset,
+ uint32_t flags,
+ uint8_t return_reg_c)
+{
+#if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_ASO)
+ return mlx5dv_dr_action_create_aso(domain, aso_obj, offset,
+ flags, return_reg_c);
+#else
+ (void)domain;
+ (void)aso_obj;
+ (void)offset;
+ (void)flags;
+ (void)return_reg_c;
+ errno = ENOTSUP;
+ return NULL;
+#endif
+}
+
static void *
mlx5_glue_dr_create_flow_action_default_miss(void)
{
}
static int
-mlx5_glue_devx_port_query(struct ibv_context *ctx,
- uint32_t port_num,
- struct mlx5dv_devx_port *mlx5_devx_port)
+mlx5_glue_devx_wq_query(struct ibv_wq *wq, const void *in, size_t inlen,
+ void *out, size_t outlen)
{
-#ifdef HAVE_MLX5DV_DR_DEVX_PORT
- return mlx5dv_query_devx_port(ctx, port_num, mlx5_devx_port);
+#ifdef HAVE_IBV_DEVX_QP
+ return mlx5dv_devx_wq_query(wq, in, inlen, out, outlen);
#else
- (void)ctx;
- (void)port_num;
- (void)mlx5_devx_port;
+ (void)wq;
+ (void)in;
+ (void)inlen;
+ (void)out;
+ (void)outlen;
errno = ENOTSUP;
return errno;
#endif
}
+static int
+mlx5_glue_devx_port_query(struct ibv_context *ctx,
+ uint32_t port_num,
+ struct mlx5_port_info *info)
+{
+ int err = 0;
+
+ info->query_flags = 0;
+#ifdef HAVE_MLX5DV_DR_DEVX_PORT_V35
+ /* The DevX port query API is implemented (rdma-core v35 and above). */
+ struct mlx5_ib_uapi_query_port devx_port;
+
+ memset(&devx_port, 0, sizeof(devx_port));
+ err = mlx5dv_query_port(ctx, port_num, &devx_port);
+ if (err)
+ return err;
+ if (devx_port.flags & MLX5DV_QUERY_PORT_VPORT_REG_C0) {
+ info->vport_meta_tag = devx_port.reg_c0.value;
+ info->vport_meta_mask = devx_port.reg_c0.mask;
+ info->query_flags |= MLX5_PORT_QUERY_REG_C0;
+ }
+ if (devx_port.flags & MLX5DV_QUERY_PORT_VPORT) {
+ info->vport_id = devx_port.vport;
+ info->query_flags |= MLX5_PORT_QUERY_VPORT;
+ }
+#else
+#ifdef HAVE_MLX5DV_DR_DEVX_PORT
+ /* The legacy DevX port query API is implemented (prior v35). */
+ struct mlx5dv_devx_port devx_port = {
+ .comp_mask = MLX5DV_DEVX_PORT_VPORT |
+ MLX5DV_DEVX_PORT_MATCH_REG_C_0
+ };
+
+ err = mlx5dv_query_devx_port(ctx, port_num, &devx_port);
+ if (err)
+ return err;
+ if (devx_port.comp_mask & MLX5DV_DEVX_PORT_MATCH_REG_C_0) {
+ info->vport_meta_tag = devx_port.reg_c_0.value;
+ info->vport_meta_mask = devx_port.reg_c_0.mask;
+ info->query_flags |= MLX5_PORT_QUERY_REG_C0;
+ }
+ if (devx_port.comp_mask & MLX5DV_DEVX_PORT_VPORT) {
+ info->vport_id = devx_port.vport_num;
+ info->query_flags |= MLX5_PORT_QUERY_VPORT;
+ }
+#else
+ RTE_SET_USED(ctx);
+ RTE_SET_USED(port_num);
+#endif /* HAVE_MLX5DV_DR_DEVX_PORT */
+#endif /* HAVE_MLX5DV_DR_DEVX_PORT_V35 */
+ return err;
+}
+
+static int
+mlx5_glue_dr_dump_single_rule(FILE *file, void *rule)
+{
+#ifdef HAVE_MLX5_DR_FLOW_DUMP_RULE
+ return mlx5dv_dump_dr_rule(file, rule);
+#else
+ RTE_SET_USED(file);
+ RTE_SET_USED(rule);
+ return -ENOTSUP;
+#endif
+}
+
static int
mlx5_glue_dr_dump_domain(FILE *file, void *domain)
{
#endif
}
+static void
+mlx5_glue_dr_allow_duplicate_rules(void *domain, uint32_t allow)
+{
+#ifdef HAVE_MLX5_DR_ALLOW_DUPLICATE
+ mlx5dv_dr_domain_allow_duplicate_rules(domain, allow);
+#else
+ (void)(allow);
+ (void)(domain);
+#endif
+}
+
static void
mlx5_glue_dv_free_pp(struct mlx5dv_pp *pp)
{
.dv_create_flow_action_tag = mlx5_glue_dv_create_flow_action_tag,
.dv_create_flow_action_meter = mlx5_glue_dv_create_flow_action_meter,
.dv_modify_flow_action_meter = mlx5_glue_dv_modify_flow_action_meter,
+ .dv_create_flow_action_aso = mlx5_glue_dv_create_flow_action_aso,
.dr_create_flow_action_default_miss =
mlx5_glue_dr_create_flow_action_default_miss,
.dv_destroy_flow = mlx5_glue_dv_destroy_flow,
.devx_umem_reg = mlx5_glue_devx_umem_reg,
.devx_umem_dereg = mlx5_glue_devx_umem_dereg,
.devx_qp_query = mlx5_glue_devx_qp_query,
+ .devx_wq_query = mlx5_glue_devx_wq_query,
.devx_port_query = mlx5_glue_devx_port_query,
.dr_dump_domain = mlx5_glue_dr_dump_domain,
+ .dr_dump_rule = mlx5_glue_dr_dump_single_rule,
.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,
+ .dr_allow_duplicate_rules = mlx5_glue_dr_allow_duplicate_rules,
.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,