[v1,42/72] common/mlx5/windows: add DevX UAR getters

Message ID 20201027232335.31427-43-ophirmu@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series mlx5 Windows support - part #5 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ophir Munk Oct. 27, 2020, 11:23 p.m. UTC
  The following getters are added: mlx5_os_get_devx_uar_mmap_offset,
mlx5_os_get_devx_uar_base_addr, mlx5_os_get_devx_uar_reg_addr,
mlx5_os_get_devx_uar_page_id.  This commit is the Windows equivalent of
the Linux implementation in (1).

(1)
commit 8638e19a10aa ("net/mlx5: remove more DV dependencies")

Signed-off-by: Ophir Munk <ophirmu@nvidia.com>
---
 drivers/common/mlx5/windows/mlx5_common_os.h | 74 ++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
  

Comments

Narcisa Ana Maria Vasile Nov. 11, 2020, 12:07 a.m. UTC | #1
On Tue, Oct 27, 2020 at 11:23:05PM +0000, Ophir Munk wrote:
> The following getters are added: mlx5_os_get_devx_uar_mmap_offset,
> mlx5_os_get_devx_uar_base_addr, mlx5_os_get_devx_uar_reg_addr,
> mlx5_os_get_devx_uar_page_id.  This commit is the Windows equivalent of
> the Linux implementation in (1).
> 
> (1)
> commit 8638e19a10aa ("net/mlx5: remove more DV dependencies")
> 
> Signed-off-by: Ophir Munk <ophirmu@nvidia.com>
> ---
>  drivers/common/mlx5/windows/mlx5_common_os.h | 74 ++++++++++++++++++++++++++++
>  1 file changed, 74 insertions(+)
> 
> diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h
> + * 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)
> +{
> +	if (!uar)
> +		return 0;
> +	return 0;

Should we return uar->mmap_off here?

> +}
> +
> +/**
> + * Get base addr pointer. Given a pointer to an UAR object of type
> + * 'struct mlx5dv_devx_uar *' - return its base address.
> + *
  
Tal Shnaiderman Nov. 14, 2020, 9:41 p.m. UTC | #2
> Subject: Re: [dpdk-dev] [PATCH v1 42/72] common/mlx5/windows: add
> DevX UAR getters
> 
> On Tue, Oct 27, 2020 at 11:23:05PM +0000, Ophir Munk wrote:
> > The following getters are added: mlx5_os_get_devx_uar_mmap_offset,
> > mlx5_os_get_devx_uar_base_addr, mlx5_os_get_devx_uar_reg_addr,
> > mlx5_os_get_devx_uar_page_id.  This commit is the Windows equivalent
> > of the Linux implementation in (1).
> >
> > (1)
> > commit 8638e19a10aa ("net/mlx5: remove more DV dependencies")
> >
> > Signed-off-by: Ophir Munk <ophirmu@nvidia.com>
> > ---
> >  drivers/common/mlx5/windows/mlx5_common_os.h | 74
> > ++++++++++++++++++++++++++++
> >  1 file changed, 74 insertions(+)
> >
> > diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h
> > b/drivers/common/mlx5/windows/mlx5_common_os.h
> > + * 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) {
> > +	if (!uar)
> > +		return 0;
> > +	return 0;
> 
> Should we return uar->mmap_off here?

In Windows, this function will always return 0 as mmap offset is unneeded, I'll update the function docu and change it to reflect it, thanks.

> 
> > +}
> > +
> > +/**
> > + * Get base addr pointer. Given a pointer to an UAR object of type
> > + * 'struct mlx5dv_devx_uar *' - return its base address.
> > + *
  

Patch

diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h
index ba16641..9ff6bef 100644
--- a/drivers/common/mlx5/windows/mlx5_common_os.h
+++ b/drivers/common/mlx5/windows/mlx5_common_os.h
@@ -15,6 +15,8 @@ 
 #include "mlx5_common_mr.h"
 #include "mlx5_win_ext.h"
 
+#define MLX5_BF_OFFSET 0x800
+
 /**
  * This API allocates aligned or non-aligned memory.  The free can be on either
  * aligned or nonaligned memory.  To be protected - even though there may be no
@@ -144,6 +146,78 @@  mlx5_os_get_umem_id(void *umem)
 	return ((struct mlx5_devx_umem *)umem)->umem_id;
 }
 
+/**
+ * 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)
+{
+	if (!uar)
+		return 0;
+	return 0;
+}
+
+/**
+ * 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, NULL otherwise.
+ */
+static inline void *
+mlx5_os_get_devx_uar_base_addr(void *uar)
+{
+	if (!uar)
+		return NULL;
+	return ((devx_uar_handle *)uar)->uar_page;
+}
+
+/**
+ * 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, NULL otherwise.
+ */
+static inline void *
+mlx5_os_get_devx_uar_reg_addr(void *uar)
+{
+	if (!uar)
+		return NULL;
+	return ((char *)((devx_uar_handle *)uar)->uar_page) + MLX5_BF_OFFSET;
+}
+
+/**
+ * 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)
+{
+	if (!uar)
+		return 0;
+	return ((devx_uar_handle *)uar)->uar_index;
+}
+
 void *mlx5_os_alloc_pd(void *ctx);
 int mlx5_os_dealloc_pd(void *pd);
 void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access);