common/mlx5: wrap event channel functions per OS
authorTal Shnaiderman <talshn@nvidia.com>
Mon, 28 Dec 2020 09:54:19 +0000 (11:54 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Jan 2021 15:03:07 +0000 (16:03 +0100)
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 <talshn@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/common/mlx5/linux/mlx5_common_os.h
drivers/net/mlx5/mlx5_devx.c
drivers/net/mlx5/mlx5_txpp.c
drivers/vdpa/mlx5/mlx5_vdpa_event.c

index bd44ecb..63f070d 100644 (file)
@@ -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.
  *
index 235fd57..84a5c55 100644 (file)
@@ -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. */
index 749529c..726bdc6 100644 (file)
@@ -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);
index 3aeaeb8..fd61509 100644 (file)
@@ -15,6 +15,7 @@
 #include <rte_alarm.h>
 
 #include <mlx5_common.h>
+#include <mlx5_common_os.h>
 #include <mlx5_glue.h>
 
 #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);