From patchwork Thu Oct 7 18:43:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 100771 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F0FB3A034F; Fri, 8 Oct 2021 12:56:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5764741137; Fri, 8 Oct 2021 12:56:00 +0200 (CEST) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by mails.dpdk.org (Postfix) with ESMTP id 17F9A411E0 for ; Thu, 7 Oct 2021 20:44:22 +0200 (CEST) Received: by mail-pg1-f171.google.com with SMTP id 66so640277pgc.9 for ; Thu, 07 Oct 2021 11:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SCiDwcmZ9wju0qauoRPefGhGDoF4vNLEO/QWe5/PrBE=; b=EZGKaxh5/acPqjcUeZeCNNfsHQCyHuXLN8w0j4wQXNdqGUnHJ68oe6rzg8HPhiok/0 yJFdmO6aFQ20tEOdmE4lgmRVlqJiaqtkSxyN3ggza8s35q3MUuOZhrJIESP7ewQ7VFo2 HUGUVtsTFMhrDgSDb9HeBko66iHNsSVXkSa/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SCiDwcmZ9wju0qauoRPefGhGDoF4vNLEO/QWe5/PrBE=; b=6d5Y155Ssc6wDGEVLl6tVVwZ4MFWEVVGFofrR8RXKrcVKDb11gLdCGfhwPJizR3b6b +B2voj8frwetFQaVkUU1PfNdgvajxgoupTKMb04CvalVDA72JTERnprBwPU64XNGua7m ilXaUNWrja+D91qKg09pqHSwAP/vSioOP+P9OMLQVVr/kRZxFeqcT1/Y/d+0zVbt5zLr G0huZ1ImylPJJadrDC/qQVUVhhvdgkHMPghejyAizRtV/pr61X33vKNNpUiV9KaVQ5m3 pYgRLniz//Dvf3w2W2/KiIxsqNnof6UtL02QoBC634+z4x9uvDow5EEA6xQsqWb7/wXR 2GQg== X-Gm-Message-State: AOAM532lnDwFg9Y/2jGCRCKbxirSDhQFApNaSniax+uqgTj945iUagiF z070E95r+17eXJGzJdl9yzz2GA== X-Google-Smtp-Source: ABdhPJy218NYzYe29wvVMXPEs3V2Eco9gI9TYSFfr+5sGnJ+8ZNCyZnLUf90tkYt2/gvhppV3ig9xQ== X-Received: by 2002:a05:6a00:14c2:b0:44c:d483:4df3 with SMTP id w2-20020a056a0014c200b0044cd4834df3mr843260pfu.52.1633632261274; Thu, 07 Oct 2021 11:44:21 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([136.185.113.102]) by smtp.gmail.com with ESMTPSA id c11sm3311586pji.38.2021.10.07.11.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 11:44:20 -0700 (PDT) From: Srikanth Kaka To: Matan Azrad , Viacheslav Ovsiienko Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Fri, 8 Oct 2021 00:13:12 +0530 Message-Id: <20211007184350.73858-4-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211007184350.73858-1-srikanth.k@oneconvergence.com> References: <20211007184350.73858-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 08 Oct 2021 12:55:54 +0200 Subject: [dpdk-dev] [PATCH v2 03/41] common/mlx5: add FreeBSD getter functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add helper functions in mlx5_common_os.h from its Linux counterpart Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/common/mlx5/freebsd/mlx5_common_os.h | 244 +++++++++++++++++++ 1 file changed, 244 insertions(+) diff --git a/drivers/common/mlx5/freebsd/mlx5_common_os.h b/drivers/common/mlx5/freebsd/mlx5_common_os.h index 0bf22e016a..dab67ecbf0 100644 --- a/drivers/common/mlx5/freebsd/mlx5_common_os.h +++ b/drivers/common/mlx5/freebsd/mlx5_common_os.h @@ -8,6 +8,250 @@ #include +#include +#include +#include +#include +#include +#include + +#include "mlx5_autoconf.h" +#include "mlx5_glue.h" + +/** + * Get device name. Given an ibv_device pointer - return a + * pointer to the corresponding device name. + * + * @param[in] dev + * Pointer to ibv device. + * + * @return + * Pointer to device name if dev is valid, NULL otherwise. + */ +static inline const char * +mlx5_os_get_dev_device_name(void *dev) +{ + if (!dev) + return NULL; + return ((struct ibv_device *)dev)->name; +} + +/** + * Get ibv device name. Given an ibv_context pointer - return a + * pointer to the corresponding device name. + * + * @param[in] ctx + * Pointer to ibv context. + * + * @return + * Pointer to device name if ctx is valid, NULL otherwise. + */ +static inline const char * +mlx5_os_get_ctx_device_name(void *ctx) +{ + if (!ctx) + return NULL; + return ((struct ibv_context *)ctx)->device->name; +} + +/** + * Get ibv device path name. Given an ibv_context pointer - return a + * pointer to the corresponding device path name. + * + * @param[in] ctx + * Pointer to ibv context. + * + * @return + * Pointer to device path name if ctx is valid, NULL otherwise. + */ + +static inline const char * +mlx5_os_get_ctx_device_path(void *ctx) +{ + if (!ctx) + return NULL; + + return ((struct ibv_context *)ctx)->device->ibdev_path; +} + +/** + * Get umem id. Given a pointer to umem object of type + * 'struct mlx5dv_devx_umem *' - return its id. + * + * @param[in] umem + * Pointer to umem object. + * + * @return + * The umem id if umem is valid, 0 otherwise. + */ +static inline uint32_t +mlx5_os_get_umem_id(void *umem) +{ + if (!umem) + return 0; + return ((struct mlx5dv_devx_umem *)umem)->umem_id; +} + +/** + * Get fd. Given a pointer to DevX channel object of type + * 'struct mlx5dv_devx_event_channel*' - return its fd. + * + * @param[in] channel + * Pointer to channel object. + * + * @return + * The fd if channel is valid, 0 otherwise. + */ +static inline int +mlx5_os_get_devx_channel_fd(void *channel) +{ + if (!channel) + return 0; + return ((struct mlx5dv_devx_event_channel *)channel)->fd; +} + +/** + * Get mmap offset. Given a pointer to an DevX UAR object of type + * 'struct mlx5dv_devx_uar *' - return its mmap offset. + * + * @param[in] uar + * Pointer to UAR object. + * + * @return + * The mmap offset if uar is valid, 0 otherwise. + */ +static inline off_t +mlx5_os_get_devx_uar_mmap_offset(void *uar) +{ +#ifdef HAVE_MLX5DV_DEVX_UAR_OFFSET + if (!uar) + return 0; + return ((struct mlx5dv_devx_uar *)uar)->mmap_off; +#else + RTE_SET_USED(uar); + return 0; +#endif +} + +/** + * Get base addr pointer. Given a pointer to an UAR object of type + * 'struct mlx5dv_devx_uar *' - return its base address. + * + * @param[in] uar + * Pointer to an UAR object. + * + * @return + * The base address if UAR is valid, 0 otherwise. + */ +static inline void * +mlx5_os_get_devx_uar_base_addr(void *uar) +{ +#ifdef HAVE_MLX5DV_DEVX_UAR_OFFSET + if (!uar) + return NULL; + return ((struct mlx5dv_devx_uar *)uar)->base_addr; +#else + RTE_SET_USED(uar); + return NULL; +#endif +} + +/** + * Get reg addr pointer. Given a pointer to an UAR object of type + * 'struct mlx5dv_devx_uar *' - return its reg address. + * + * @param[in] uar + * Pointer to an UAR object. + * + * @return + * The reg address if UAR is valid, 0 otherwise. + */ +static inline void * +mlx5_os_get_devx_uar_reg_addr(void *uar) +{ +#ifdef HAVE_MLX5DV_DEVX_UAR_OFFSET + if (!uar) + return NULL; + return ((struct mlx5dv_devx_uar *)uar)->reg_addr; +#else + RTE_SET_USED(uar); + return NULL; +#endif +} + +/** + * Get page id. Given a pointer to an UAR object of type + * 'struct mlx5dv_devx_uar *' - return its page id. + * + * @param[in] uar + * Pointer to an UAR object. + * + * @return + * The page id if UAR is valid, 0 otherwise. + */ +static inline uint32_t +mlx5_os_get_devx_uar_page_id(void *uar) +{ +#ifdef HAVE_MLX5DV_DEVX_UAR_OFFSET + if (!uar) + return 0; + return ((struct mlx5dv_devx_uar *)uar)->page_id; +#else + RTE_SET_USED(uar); + return 0; +#endif +} + +__rte_internal +static inline void * +mlx5_os_alloc_pd(void *ctx) +{ + return mlx5_glue->alloc_pd(ctx); +} + +__rte_internal +static inline int +mlx5_os_dealloc_pd(void *pd) +{ + return mlx5_glue->dealloc_pd(pd); +} + +__rte_internal +static inline void * +mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access) +{ + return mlx5_glue->devx_umem_reg(ctx, addr, size, access); +} + +__rte_internal +static inline int +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. *