From 981746264ebc4e5b5e26f5859d809c19a4a217d5 Mon Sep 17 00:00:00 2001 From: Tal Shnaiderman Date: Mon, 28 Dec 2020 11:54:19 +0200 Subject: [PATCH] common/mlx5: wrap event channel functions per OS Wrap the API to create/destroy event channel and to subscribe an event with OS calls. In Linux those calls are implemented by glue functions while in Windows they are not supported. Signed-off-by: Tal Shnaiderman Acked-by: Matan Azrad --- drivers/common/mlx5/linux/mlx5_common_os.h | 22 ++++++++++++++++++++++ drivers/net/mlx5/mlx5_devx.c | 8 ++++---- drivers/net/mlx5/mlx5_txpp.c | 6 +++--- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 7 ++++--- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h index bd44ecb7d6..63f070d9c4 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.h +++ b/drivers/common/mlx5/linux/mlx5_common_os.h @@ -227,6 +227,28 @@ mlx5_os_umem_dereg(void *pumem) return mlx5_glue->devx_umem_dereg(pumem); } +static inline void * +mlx5_os_devx_create_event_channel(void *ctx, int flags) +{ + return mlx5_glue->devx_create_event_channel(ctx, flags); +} + +static inline void +mlx5_os_devx_destroy_event_channel(void *eventc) +{ + mlx5_glue->devx_destroy_event_channel(eventc); +} + +static inline int +mlx5_os_devx_subscribe_devx_event(void *eventc, + void *obj, + uint16_t events_sz, uint16_t events_num[], + uint64_t cookie) +{ + return mlx5_glue->devx_subscribe_devx_event(eventc, obj, events_sz, + events_num, cookie); +} + /** * Memory allocation optionally with alignment. * diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index 235fd5798d..84a5c55ee0 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -216,7 +216,7 @@ mlx5_rxq_devx_obj_release(struct mlx5_rxq_obj *rxq_obj) claim_zero(mlx5_devx_cmd_destroy(rxq_obj->rq)); claim_zero(mlx5_devx_cmd_destroy(rxq_obj->devx_cq)); if (rxq_obj->devx_channel) - mlx5_glue->devx_destroy_event_channel + mlx5_os_devx_destroy_event_channel (rxq_obj->devx_channel); mlx5_rxq_release_devx_rq_resources(rxq_obj->rxq_ctrl); mlx5_rxq_release_devx_cq_resources(rxq_obj->rxq_ctrl); @@ -533,7 +533,7 @@ mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx) rxq_data->cqe_n = log_cqe_n; rxq_data->cqn = cq_obj->id; if (rxq_ctrl->obj->devx_channel) { - ret = mlx5_glue->devx_subscribe_devx_event + ret = mlx5_os_devx_subscribe_devx_event (rxq_ctrl->obj->devx_channel, cq_obj->obj, sizeof(event_nums), @@ -644,7 +644,7 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx) int devx_ev_flag = MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA; - tmpl->devx_channel = mlx5_glue->devx_create_event_channel + tmpl->devx_channel = mlx5_os_devx_create_event_channel (priv->sh->ctx, devx_ev_flag); if (!tmpl->devx_channel) { @@ -686,7 +686,7 @@ error: if (tmpl->devx_cq) claim_zero(mlx5_devx_cmd_destroy(tmpl->devx_cq)); if (tmpl->devx_channel) - mlx5_glue->devx_destroy_event_channel(tmpl->devx_channel); + mlx5_os_devx_destroy_event_channel(tmpl->devx_channel); mlx5_rxq_release_devx_rq_resources(rxq_ctrl); mlx5_rxq_release_devx_cq_resources(rxq_ctrl); rte_errno = ret; /* Restore rte_errno. */ diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c index 749529c410..726bdc6ae1 100644 --- a/drivers/net/mlx5/mlx5_txpp.c +++ b/drivers/net/mlx5/mlx5_txpp.c @@ -37,7 +37,7 @@ static void mlx5_txpp_destroy_event_channel(struct mlx5_dev_ctx_shared *sh) { if (sh->txpp.echan) { - mlx5_glue->devx_destroy_event_channel(sh->txpp.echan); + mlx5_os_devx_destroy_event_channel(sh->txpp.echan); sh->txpp.echan = NULL; } } @@ -47,7 +47,7 @@ static int mlx5_txpp_create_event_channel(struct mlx5_dev_ctx_shared *sh) { MLX5_ASSERT(!sh->txpp.echan); - sh->txpp.echan = mlx5_glue->devx_create_event_channel(sh->ctx, + sh->txpp.echan = mlx5_os_devx_create_event_channel(sh->ctx, MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA); if (!sh->txpp.echan) { rte_errno = errno; @@ -937,7 +937,7 @@ mlx5_txpp_start_service(struct mlx5_dev_ctx_shared *sh) return -rte_errno; } /* Subscribe CQ event to the event channel controlled by the driver. */ - ret = mlx5_glue->devx_subscribe_devx_event(sh->txpp.echan, + ret = mlx5_os_devx_subscribe_devx_event(sh->txpp.echan, sh->txpp.rearm_queue.cq->obj, sizeof(event_nums), event_nums, 0); diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c index 3aeaeb893f..fd6150928b 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c @@ -15,6 +15,7 @@ #include #include +#include #include #include "mlx5_vdpa_utils.h" @@ -43,7 +44,7 @@ mlx5_vdpa_event_qp_global_release(struct mlx5_vdpa_priv *priv) sizeof(out.buf)) >= (ssize_t)sizeof(out.event_resp.cookie)) ; - mlx5_glue->devx_destroy_event_channel(priv->eventc); + mlx5_os_devx_destroy_event_channel(priv->eventc); priv->eventc = NULL; } #endif @@ -63,7 +64,7 @@ mlx5_vdpa_event_qp_global_prepare(struct mlx5_vdpa_priv *priv) DRV_LOG(ERR, "Failed to query EQ number %d.", rte_errno); return -1; } - priv->eventc = mlx5_glue->devx_create_event_channel(priv->ctx, + priv->eventc = mlx5_os_devx_create_event_channel(priv->ctx, MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA); if (!priv->eventc) { rte_errno = errno; @@ -176,7 +177,7 @@ mlx5_vdpa_cq_create(struct mlx5_vdpa_priv *priv, uint16_t log_desc_n, cq->cq_ci = 0; rte_spinlock_init(&cq->sl); /* Subscribe CQ event to the event channel controlled by the driver. */ - ret = mlx5_glue->devx_subscribe_devx_event(priv->eventc, cq->cq->obj, + ret = mlx5_os_devx_subscribe_devx_event(priv->eventc, cq->cq->obj, sizeof(event_nums), event_nums, (uint64_t)(uintptr_t)cq); -- 2.20.1