Skip to contentSkip to conversation

Support MLX5 crypto driver on Windows

RFC PATCH New Tal Shnaiderman 1 participant 11 messages Sep 14, 2021

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover Support MLX5 crypto driver on Windows

Support the MLX5 crypto driver on Windows OS by moving the driver's control path communication with the Kernel to be OS agnostic.
---
Depends-on: patch 98796 ("cryptodev: build on Windows")
---
Tal Shnaiderman (10):
common/mlx5: add DV enums to Windows defs file common/mlx5: add an agnostic OS function to open device context common/mlx5: move pdn getter to common driver common/mlx5: add memory region OS agnostic functions for Linux crypto/mlx5: replace UNIX functions with EAL functions crypto/mlx5: use OS agnostic functions for UMEM operations crypto/mlx5: use OS agnostic functions for PD operations crypto/mlx5: use OS agnostic functions for Verbs operations crypto/mlx5: fix size of UMR WQE
crypto/mlx5: support on Windows

 drivers/common/mlx5/linux/mlx5_common_os.c   |  98 +++++++++++++++++++
 drivers/common/mlx5/mlx5_common.h            |  17 ++++
 drivers/common/mlx5/version.map              |   5 +-
 drivers/common/mlx5/windows/mlx5_common_os.c | 141 ++++++++++++++++++++++++++-
 drivers/common/mlx5/windows/mlx5_common_os.h |   8 +-
 drivers/common/mlx5/windows/mlx5_win_defs.h  |  12 +++
 drivers/crypto/aesni_gcm/meson.build         |   6 ++
 drivers/crypto/aesni_mb/meson.build          |   6 ++
 drivers/crypto/armv8/meson.build             |   6 ++
 drivers/crypto/bcmfs/meson.build             |   6 ++
 drivers/crypto/ccp/meson.build               |   1 +
 drivers/crypto/kasumi/meson.build            |   6 ++
 drivers/crypto/meson.build                   |   3 -
 drivers/crypto/mlx5/meson.build              |   4 +-
 drivers/crypto/mlx5/mlx5_crypto.c            |  80 ++++++++-------
 drivers/crypto/mlx5/mlx5_crypto.h            |   6 +-
 drivers/crypto/mvsam/meson.build             |   6 ++
 drivers/crypto/null/meson.build              |   6 ++
 drivers/crypto/octeontx/meson.build          |   6 ++
 drivers/crypto/openssl/meson.build           |   6 ++
 drivers/crypto/qat/meson.build               |   6 ++
 drivers/crypto/scheduler/meson.build         |   6 ++
 drivers/crypto/snow3g/meson.build            |   6 ++
 drivers/crypto/virtio/meson.build            |   6 ++
 drivers/crypto/zuc/meson.build               |   6 ++
 drivers/net/mlx5/linux/mlx5_os.c             |  35 -------
 drivers/net/mlx5/mlx5.h                      |   1 -
 drivers/net/mlx5/windows/mlx5_os.c           |  85 +---------------
 28 files changed, 402 insertions(+), 178 deletions(-)
Signature · 1 line
2.16.1.windows.4
#1 lore raw

RFC PATCH 1/10 common/mlx5: add DV enums to Windows defs file

Add needed DV enums used by the crypto PMD and missing for Windows OS.

---
 drivers/common/mlx5/windows/mlx5_win_defs.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/common/mlx5/windows/mlx5_win_defs.h +12 -0
index 47bfc907e7..9f709ff30d 100644
@@ -93,6 +93,18 @@ enum {
 	MLX5_ETH_WQE_L4_CSUM = (1 << 7),
 };
 
+enum {
+	MLX5_WQE_CTRL_CQ_UPDATE	= 2 << 2,
+	MLX5_WQE_CTRL_SOLICITED	= 1 << 1,
+	MLX5_WQE_CTRL_FENCE	= 4 << 5,
+	MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE = 1 << 5,
+};
+
+enum {
+	MLX5_SEND_WQE_BB	= 64,
+	MLX5_SEND_WQE_SHIFT	= 6,
+};
+
 /*
  * RX Hash fields enable to set which incoming packet's field should
  * participates in RX Hash. Each flag represent certain packet's field,
Signature · 1 line
2.16.1.windows.4
#2 lore raw

RFC PATCH 2/10 common/mlx5: add an agnostic OS function to open device context

In reply to Tal Shnaiderman

Add a function to open device context from a rte_device.

Function mlx5_os_open_device_context can be used both on Windows and Linux OS.

---
 drivers/common/mlx5/linux/mlx5_common_os.c   |  28 +++++++
 drivers/common/mlx5/mlx5_common.h            |   4 +
 drivers/common/mlx5/version.map              |   2 +
 drivers/common/mlx5/windows/mlx5_common_os.c | 118 +++++++++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_common_os.h |   2 +
 drivers/net/mlx5/windows/mlx5_os.c           |  64 +--------------
 6 files changed, 155 insertions(+), 63 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.c +28 -0
index 9e0c823c97..3ef507944f 100644
@@ -428,3 +428,31 @@ mlx5_os_get_ibv_device(const struct rte_pci_addr *addr)
 	mlx5_glue->free_device_list(ibv_list);
 	return ibv_match;
 }
+
+/**
+ * Open device context from a rte_device.
+ *
+ * @param[in] dev
+ *  Pointer to an rte_device struct.
+ * @return
+ *   Pointer to device context or NULL in case context cannot be found.
+ */
+void *
+mlx5_os_open_device_context(struct rte_device *dev)
+{
+	struct ibv_device *ibv;
+	void *ctx;
+
+	ibv = mlx5_os_get_ibv_dev(dev);
+	if (ibv == NULL) {
+		DRV_LOG(ERR, "Failed getting ibv_dev");
+		return NULL;
+	}
+	ctx = mlx5_glue->dv_open_device(ibv);
+	if (ctx == NULL) {
+		DRV_LOG(ERR, "Failed to open IB device \"%s\".", ibv->name);
+		rte_errno = ENODEV;
+		return NULL;
+	}
+	return ctx;
+}
drivers/common/mlx5/mlx5_common.h +4 -0
index a772371200..249804b00c 100644
@@ -419,4 +419,8 @@ __rte_internal
 bool
 mlx5_dev_is_pci(const struct rte_device *dev);
 
+__rte_internal
+void *
+mlx5_os_open_device_context(struct rte_device *dev);
+
 #endif /* RTE_PMD_MLX5_COMMON_H_ */
drivers/common/mlx5/version.map +2 -0
index e5cb6b7060..6d4258dd25 100644
@@ -141,6 +141,8 @@ INTERNAL {
 	mlx5_os_alloc_pd;
 	mlx5_os_dealloc_pd;
 	mlx5_os_dereg_mr;
+	mlx5_os_match_devx_devices_to_addr;
+	mlx5_os_open_device_context;
 	mlx5_os_get_ibv_dev; # WINDOWS_NO_EXPORT
 	mlx5_os_reg_mr;
 	mlx5_os_umem_dereg;
drivers/common/mlx5/windows/mlx5_common_os.c +118 -0

127 lines not on this page · raw message

drivers/common/mlx5/windows/mlx5_common_os.h +2 -0
index 3756e1959b..c3d74d3b67 100644
@@ -261,4 +261,6 @@ int mlx5_os_reg_mr(void *pd,
 		   void *addr, size_t length, struct mlx5_pmd_mr *pmd_mr);
 __rte_internal
 void mlx5_os_dereg_mr(struct mlx5_pmd_mr *pmd_mr);
+int mlx5_os_match_devx_devices_to_addr(struct devx_device_bdf *devx_bdf,
+				struct rte_pci_addr *addr);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/net/mlx5/windows/mlx5_os.c +1 -63

76 lines not on this page · raw message

Signature · 1 line
2.16.1.windows.4
#3 lore raw

RFC PATCH 3/10 common/mlx5: move pdn getter to common driver

In reply to Tal Shnaiderman

Move to common and export the function mlx5_os_get_pdn.

---
 drivers/common/mlx5/linux/mlx5_common_os.c   | 35 ++++++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_common.h            |  4 ++++
 drivers/common/mlx5/version.map              |  1 +
 drivers/common/mlx5/windows/mlx5_common_os.c | 21 +++++++++++++++++
 drivers/net/mlx5/linux/mlx5_os.c             | 35 ----------------------------
 drivers/net/mlx5/mlx5.h                      |  1 -
 drivers/net/mlx5/windows/mlx5_os.c           | 21 -----------------
 7 files changed, 61 insertions(+), 57 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.c +35 -0
index 3ef507944f..4aada82669 100644
@@ -456,3 +456,38 @@ mlx5_os_open_device_context(struct rte_device *dev)
 	}
 	return ctx;
 }
+
+/**
+ * Extract pdn of PD object using DV API.
+ *
+ * @param[in] pd
+ *   Pointer to the verbs PD object.
+ * @param[out] pdn
+ *   Pointer to the PD object number variable.
+ *
+ * @return
+ *   0 on success, error value otherwise.
+ */
+int
+mlx5_os_get_pdn(void *pd, uint32_t *pdn)
+{
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
+	struct mlx5dv_obj obj;
+	struct mlx5dv_pd pd_info;
+	int ret = 0;
+
+	obj.pd.in = pd;
+	obj.pd.out = &pd_info;
+	ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD);
+	if (ret) {
+		DRV_LOG(DEBUG, "Fail to get PD object info");
+		return ret;
+	}
+	*pdn = pd_info.pdn;
+	return 0;
+#else
+	(void)pd;
+	(void)pdn;
+	return -ENOTSUP;
+#endif /* HAVE_IBV_FLOW_DV_SUPPORT */
+}
drivers/common/mlx5/mlx5_common.h +4 -0
index 249804b00c..fcdf376193 100644
@@ -423,4 +423,8 @@ __rte_internal
 void *
 mlx5_os_open_device_context(struct rte_device *dev);
 
+__rte_internal
+int
+mlx5_os_get_pdn(void *pd, uint32_t *pdn);
+
 #endif /* RTE_PMD_MLX5_COMMON_H_ */
drivers/common/mlx5/version.map +1 -0
index 6d4258dd25..c6de706fdb 100644
@@ -144,6 +144,7 @@ INTERNAL {
 	mlx5_os_match_devx_devices_to_addr;
 	mlx5_os_open_device_context;
 	mlx5_os_get_ibv_dev; # WINDOWS_NO_EXPORT
+	mlx5_os_get_pdn;
 	mlx5_os_reg_mr;
 	mlx5_os_umem_dereg;
 	mlx5_os_umem_reg;
drivers/common/mlx5/windows/mlx5_common_os.c +21 -0
index 3b59e57e57..5c9cccd3e9 100644
@@ -323,3 +323,24 @@ mlx5_os_open_device_context(struct rte_device *dev)
 	mlx5_glue->free_device_list(orig_devx_bdf_devs);
 	return devx_ctx_match;
 }
+
+/**
+ * Extract pdn of PD object using DevX
+ *
+ * @param[in] pd
+ *   Pointer to the DevX PD object.
+ * @param[out] pdn
+ *   Pointer to the PD object number variable.
+ *
+ * @return
+ *   0 on success, error value otherwise.
+ */
+int
+mlx5_os_get_pdn(void *pd, uint32_t *pdn)
+{
+	if (!pd)
+		return -EINVAL;
+
+	*pdn = ((struct mlx5_pd *)pd)->pdn;
+	return 0;
+}
drivers/net/mlx5/linux/mlx5_os.c +0 -35
index 470b16cb9a..a7df1ddb2e 100644
@@ -2811,41 +2811,6 @@ mlx5_restore_doorbell_mapping_env(int value)
 		setenv(MLX5_SHUT_UP_BF, value ? "1" : "0", 1);
 }
 
-/**
- * Extract pdn of PD object using DV API.
- *
- * @param[in] pd
- *   Pointer to the verbs PD object.
- * @param[out] pdn
- *   Pointer to the PD object number variable.
- *
- * @return
- *   0 on success, error value otherwise.
- */
-int
-mlx5_os_get_pdn(void *pd, uint32_t *pdn)
-{
-#ifdef HAVE_IBV_FLOW_DV_SUPPORT
-	struct mlx5dv_obj obj;
-	struct mlx5dv_pd pd_info;
-	int ret = 0;
-
-	obj.pd.in = pd;
-	obj.pd.out = &pd_info;
-	ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD);
-	if (ret) {
-		DRV_LOG(DEBUG, "Fail to get PD object info");
-		return ret;
-	}
-	*pdn = pd_info.pdn;
-	return 0;
-#else
-	(void)pd;
-	(void)pdn;
-	return -ENOTSUP;
-#endif /* HAVE_IBV_FLOW_DV_SUPPORT */
-}
-
 /**
  * Function API to open IB device.
  *
drivers/net/mlx5/mlx5.h +0 -1
index e02714e231..cb05929efe 100644
@@ -1770,7 +1770,6 @@ void mlx5_os_free_shared_dr(struct mlx5_priv *priv);
 int mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
 			 const struct mlx5_dev_config *config,
 			 struct mlx5_dev_ctx_shared *sh);
-int mlx5_os_get_pdn(void *pd, uint32_t *pdn);
 int mlx5_os_net_probe(struct rte_device *dev);
 void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh);
 void mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh);
drivers/net/mlx5/windows/mlx5_os.c +0 -21
index 9dea6d639e..336b41d33b 100644
@@ -1102,25 +1102,4 @@ mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 	*dereg_mr_cb = mlx5_os_dereg_mr;
 }
 
-/**
- * Extract pdn of PD object using DevX
- *
- * @param[in] pd
- *   Pointer to the DevX PD object.
- * @param[out] pdn
- *   Pointer to the PD object number variable.
- *
- * @return
- *   0 on success, error value otherwise.
- */
-int
-mlx5_os_get_pdn(void *pd, uint32_t *pdn)
-{
-	if (!pd)
-		return -EINVAL;
-
-	*pdn = ((struct mlx5_pd *)pd)->pdn;
-	return 0;
-}
-
 const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};
Signature · 1 line
2.16.1.windows.4
#4 lore raw

RFC PATCH 4/10 common/mlx5: add memory region OS agnostic functions for Linux

In reply to Tal Shnaiderman

The OS agnostic functions for memory region registration/deregistration (mlx5_os_reg_mr mlx5_os_dereg_mr) exist only for Windows OS.

Adding them for Linux as well as they are needed for memory region activities in shared code.

---
 drivers/common/mlx5/linux/mlx5_common_os.c   | 35 ++++++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_common.h            |  9 +++++++
 drivers/common/mlx5/windows/mlx5_common_os.c |  2 +-
 drivers/common/mlx5/windows/mlx5_common_os.h |  6 -----
 4 files changed, 45 insertions(+), 7 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.c +35 -0
index 4aada82669..fd0ec6b748 100644
@@ -491,3 +491,38 @@ mlx5_os_get_pdn(void *pd, uint32_t *pdn)
 	return -ENOTSUP;
 #endif /* HAVE_IBV_FLOW_DV_SUPPORT */
 }
+
+/**
+ * Register mr. Given protection domain pointer, pointer to addr and length
+ * register the memory region.
+ *
+ * @param[in] pd
+ *   Pointer to protection domain context (type mlx5_pd).
+ * @param[in] addr
+ *   Pointer to memory start address (type devx_device_ctx).
+ * @param[in] length
+ *   Lengtoh of the memory to register.
+ * @param[out] pmd_mr
+ *   pmd_mr struct set with lkey, address, length, pointer to mr object, mkey
+ *
+ * @return
+ *   0 on successful registration, -1 otherwise
+ */
+int
+mlx5_os_reg_mr(void *pd,
+	       void *addr, size_t length, struct mlx5_pmd_mr *pmd_mr)
+{
+	return mlx5_common_verbs_reg_mr(pd, addr, length, pmd_mr);
+}
+
+/**
+ * De-register mr.
+ *
+ * @param[in] pmd_mr
+ *  Pointer to PMD mr object
+ */
+void
+mlx5_os_dereg_mr(struct mlx5_pmd_mr *pmd_mr)
+{
+	mlx5_common_verbs_dereg_mr(pmd_mr);
+}
drivers/common/mlx5/mlx5_common.h +9 -0
index fcdf376193..a87318db91 100644
@@ -21,6 +21,7 @@
 
 #include "mlx5_prm.h"
 #include "mlx5_devx_cmds.h"
+#include "mlx5_common_mr.h"
 #include "mlx5_common_os.h"
 
 /* Reported driver name. */
@@ -427,4 +428,12 @@ __rte_internal
 int
 mlx5_os_get_pdn(void *pd, uint32_t *pdn);
 
+__rte_internal
+int
+mlx5_os_reg_mr(void *pd,
+		   void *addr, size_t length, struct mlx5_pmd_mr *pmd_mr);
+__rte_internal
+void
+mlx5_os_dereg_mr(struct mlx5_pmd_mr *pmd_mr);
+
 #endif /* RTE_PMD_MLX5_COMMON_H_ */
drivers/common/mlx5/windows/mlx5_common_os.c +1 -1
index 5c9cccd3e9..2ecdf78310 100644
@@ -134,7 +134,7 @@ mlx5_os_umem_dereg(void *pumem)
 }
 
 /**
- * Register mr. Given protection doamin pointer, pointer to addr and length
+ * Register mr. Given protection domain pointer, pointer to addr and length
  * register the memory region.
  *
  * @param[in] pd
drivers/common/mlx5/windows/mlx5_common_os.h +0 -6
index c3d74d3b67..62bdcb40cd 100644
@@ -13,7 +13,6 @@
 #include "mlx5_autoconf.h"
 #include "mlx5_glue.h"
 #include "mlx5_malloc.h"
-#include "mlx5_common_mr.h"
 #include "mlx5_win_ext.h"
 
 #define MLX5_BF_OFFSET 0x800
@@ -256,11 +255,6 @@ __rte_internal
 void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access);
 __rte_internal
 int mlx5_os_umem_dereg(void *pumem);
-__rte_internal
-int mlx5_os_reg_mr(void *pd,
-		   void *addr, size_t length, struct mlx5_pmd_mr *pmd_mr);
-__rte_internal
-void mlx5_os_dereg_mr(struct mlx5_pmd_mr *pmd_mr);
 int mlx5_os_match_devx_devices_to_addr(struct devx_device_bdf *devx_bdf,
 				struct rte_pci_addr *addr);
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
Signature · 1 line
2.16.1.windows.4
#5 lore raw

RFC PATCH 5/10 crypto/mlx5: replace UNIX functions with EAL functions

In reply to Tal Shnaiderman

Use the OS agnostic EAL function rte_mem_page_size to get page size value instead of the Linux specific implementation.

Also remove the usage of PTHREAD_MUTEX_INITIALIZER which is not support in Windows and initialize priv_list_lock in RTE_INIT.

---
 drivers/crypto/mlx5/mlx5_crypto.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/crypto/mlx5/mlx5_crypto.c +4 -2
index b3d5200ca3..3dac69f860 100644
@@ -4,6 +4,7 @@
 
 #include <rte_malloc.h>
 #include <rte_mempool.h>
+#include <rte_eal_paging.h>
 #include <rte_errno.h>
 #include <rte_log.h>
 #include <rte_bus_pci.h>
@@ -33,7 +34,7 @@
 
 TAILQ_HEAD(mlx5_crypto_privs, mlx5_crypto_priv) mlx5_crypto_priv_list =
 				TAILQ_HEAD_INITIALIZER(mlx5_crypto_priv_list);
-static pthread_mutex_t priv_list_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t priv_list_lock;
 
 int mlx5_crypto_logtype;
 
@@ -700,7 +701,7 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	attr.pd = priv->pdn;
 	attr.uar_index = mlx5_os_get_devx_uar_page_id(priv->uar);
 	attr.cqn = qp->cq_obj.cq->id;
-	attr.log_page_size = rte_log2_u32(sysconf(_SC_PAGESIZE));
+	attr.log_page_size = rte_log2_u32(rte_mem_page_size());
 	attr.rq_size =  0;
 	attr.sq_size = RTE_BIT32(log_nb_desc);
 	attr.dbr_umem_valid = 1;
@@ -1134,6 +1135,7 @@ static struct mlx5_class_driver mlx5_crypto_driver = {
 
 RTE_INIT(rte_mlx5_crypto_init)
 {
+	pthread_mutex_init(&priv_list_lock, NULL);
 	mlx5_common_init();
 	if (mlx5_glue != NULL)
 		mlx5_class_driver_register(&mlx5_crypto_driver);
Signature · 1 line
2.16.1.windows.4
#6 lore raw

RFC PATCH 6/10 crypto/mlx5: use OS agnostic functions for UMEM operations

In reply to Tal Shnaiderman

use the functions mlx5_os_umem_reg, mlx5_os_umem_dereg mlx5_os_get_umem_id instead of the glue functions to support UMEM operations on all OSs.

---
 drivers/crypto/mlx5/mlx5_crypto.c | 14 +++++++-------
 drivers/crypto/mlx5/mlx5_crypto.h |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/crypto/mlx5/mlx5_crypto.c +7 -7
index 3dac69f860..ccae113770 100644
@@ -261,7 +261,7 @@ mlx5_crypto_queue_pair_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	if (qp->qp_obj != NULL)
 		claim_zero(mlx5_devx_cmd_destroy(qp->qp_obj));
 	if (qp->umem_obj != NULL)
-		claim_zero(mlx5_glue->devx_umem_dereg(qp->umem_obj));
+		claim_zero(mlx5_os_umem_dereg(qp->umem_obj));
 	if (qp->umem_buf != NULL)
 		rte_free(qp->umem_buf);
 	mlx5_mr_btree_free(&qp->mr_ctrl.cache_bh);
@@ -682,10 +682,10 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		rte_errno = ENOMEM;
 		goto error;
 	}
-	qp->umem_obj = mlx5_glue->devx_umem_reg(priv->ctx,
-					       (void *)(uintptr_t)qp->umem_buf,
-					       umem_size,
-					       IBV_ACCESS_LOCAL_WRITE);
+	qp->umem_obj = mlx5_os_umem_reg(priv->ctx,
+					(void *)(uintptr_t)qp->umem_buf,
+					umem_size,
+					IBV_ACCESS_LOCAL_WRITE);
 	if (qp->umem_obj == NULL) {
 		DRV_LOG(ERR, "Failed to register QP umem.");
 		goto error;
@@ -705,9 +705,9 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	attr.rq_size =  0;
 	attr.sq_size = RTE_BIT32(log_nb_desc);
 	attr.dbr_umem_valid = 1;
-	attr.wq_umem_id = qp->umem_obj->umem_id;
+	attr.wq_umem_id = mlx5_os_get_umem_id(qp->umem_obj);
 	attr.wq_umem_offset = 0;
-	attr.dbr_umem_id = qp->umem_obj->umem_id;
+	attr.dbr_umem_id = mlx5_os_get_umem_id(qp->umem_obj);
 	attr.dbr_address = RTE_BIT64(log_nb_desc) * priv->wqe_set_size;
 	qp->qp_obj = mlx5_devx_cmd_create_qp(priv->ctx, &attr);
 	if (qp->qp_obj == NULL) {
drivers/crypto/mlx5/mlx5_crypto.h +1 -1
index d49b0001f0..d5cc509e42 100644
@@ -45,7 +45,7 @@ struct mlx5_crypto_qp {
 	struct mlx5_devx_cq cq_obj;
 	struct mlx5_devx_obj *qp_obj;
 	struct rte_cryptodev_stats stats;
-	struct mlx5dv_devx_umem *umem_obj;
+	void *umem_obj;
 	void *umem_buf;
 	volatile uint32_t *db_rec;
 	struct rte_crypto_op **ops;
Signature · 1 line
2.16.1.windows.4
#7 lore raw

RFC PATCH 7/10 crypto/mlx5: use OS agnostic functions for PD operations

In reply to Tal Shnaiderman

use the functions mlx5_os_alloc_pd, mlx5_os_dealloc_pd mlx5_os_get_pdn instead of the glue functions to support PD operations on all OSs.

---
 drivers/crypto/mlx5/mlx5_crypto.c | 15 ++++++---------
 drivers/crypto/mlx5/mlx5_crypto.h |  2 +-
 2 files changed, 7 insertions(+), 10 deletions(-)
drivers/crypto/mlx5/mlx5_crypto.c +6 -9
index ccae113770..35319d0115 100644
@@ -784,7 +784,7 @@ static void
 mlx5_crypto_hw_global_release(struct mlx5_crypto_priv *priv)
 {
 	if (priv->pd != NULL) {
-		claim_zero(mlx5_glue->dealloc_pd(priv->pd));
+		claim_zero(mlx5_os_dealloc_pd(priv->pd));
 		priv->pd = NULL;
 	}
 	if (priv->uar != NULL) {
@@ -801,21 +801,18 @@ mlx5_crypto_pd_create(struct mlx5_crypto_priv *priv)
 	struct mlx5dv_pd pd_info;
 	int ret;
 
-	priv->pd = mlx5_glue->alloc_pd(priv->ctx);
+	priv->pd = mlx5_os_alloc_pd(priv->ctx);
 	if (priv->pd == NULL) {
 		DRV_LOG(ERR, "Failed to allocate PD.");
 		return errno ? -errno : -ENOMEM;
 	}
-	obj.pd.in = priv->pd;
-	obj.pd.out = &pd_info;
-	ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD);
+	ret = mlx5_os_get_pdn(priv->pd, &priv->pdn);
 	if (ret != 0) {
-		DRV_LOG(ERR, "Fail to get PD object info.");
-		mlx5_glue->dealloc_pd(priv->pd);
+		DRV_LOG(ERR, "Fail to get PDN.");
+		mlx5_os_dealloc_pd(priv->pd);
 		priv->pd = NULL;
 		return -errno;
 	}
-	priv->pdn = pd_info.pdn;
 	return 0;
 #else
 	(void)priv;
@@ -834,7 +831,7 @@ mlx5_crypto_hw_global_prepare(struct mlx5_crypto_priv *priv)
 		priv->uar_addr = mlx5_os_get_devx_uar_reg_addr(priv->uar);
 	if (priv->uar == NULL || priv->uar_addr == NULL) {
 		rte_errno = errno;
-		claim_zero(mlx5_glue->dealloc_pd(priv->pd));
+		claim_zero(mlx5_os_dealloc_pd(priv->pd));
 		DRV_LOG(ERR, "Failed to allocate UAR.");
 		return -1;
 	}
drivers/crypto/mlx5/mlx5_crypto.h +1 -1
index d5cc509e42..91e3f438b8 100644
@@ -25,7 +25,7 @@ struct mlx5_crypto_priv {
 	volatile uint64_t *uar_addr;
 	uint32_t pdn; /* Protection Domain number. */
 	uint32_t max_segs_num; /* Maximum supported data segs. */
-	struct ibv_pd *pd;
+	void *pd;
 	struct mlx5_hlist *dek_hlist; /* Dek hash list. */
 	struct rte_cryptodev_config dev_config;
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
Signature · 1 line
2.16.1.windows.4
#8 lore raw

RFC PATCH 8/10 crypto/mlx5: use OS agnostic functions for Verbs operations

In reply to Tal Shnaiderman

use the functions mlx5_os_open_device_context, mlx5_os_get_ctx_device_name mlx5_os_reg_mr mlx5_os_dereg_mr instead of the ib verbs functions and variables to support device operations on all OSs.

---
 drivers/crypto/mlx5/mlx5_crypto.c | 41 +++++++++++++++++----------------------
 drivers/crypto/mlx5/mlx5_crypto.h |  2 +-
 2 files changed, 19 insertions(+), 24 deletions(-)
drivers/crypto/mlx5/mlx5_crypto.c +18 -23
index 35319d0115..3f5a6745dc 100644
@@ -796,9 +796,6 @@ mlx5_crypto_hw_global_release(struct mlx5_crypto_priv *priv)
 static int
 mlx5_crypto_pd_create(struct mlx5_crypto_priv *priv)
 {
-#ifdef HAVE_IBV_FLOW_DV_SUPPORT
-	struct mlx5dv_obj obj;
-	struct mlx5dv_pd pd_info;
 	int ret;
 
 	priv->pd = mlx5_os_alloc_pd(priv->ctx);
@@ -814,11 +811,6 @@ mlx5_crypto_pd_create(struct mlx5_crypto_priv *priv)
 		return -errno;
 	}
 	return 0;
-#else
-	(void)priv;
-	DRV_LOG(ERR, "Cannot get pdn - no DV support.");
-	return -ENOTSUP;
-#endif /* HAVE_IBV_FLOW_DV_SUPPORT */
 }
 
 static int
@@ -964,8 +956,8 @@ mlx5_crypto_mr_mem_event_cb(enum rte_mem_event event_type, const void *addr,
 		/* Iterate all the existing mlx5 devices. */
 		TAILQ_FOREACH(priv, &mlx5_crypto_priv_list, next)
 			mlx5_free_mr_by_addr(&priv->mr_scache,
-					     priv->ctx->device->name,
-					     addr, len);
+					     mlx5_os_get_ctx_device_name(
+					     priv->ctx), addr, len);
 		pthread_mutex_unlock(&priv_list_lock);
 		break;
 	case RTE_MEM_EVENT_ALLOC:
@@ -977,9 +969,9 @@ mlx5_crypto_mr_mem_event_cb(enum rte_mem_event event_type, const void *addr,
 static int
 mlx5_crypto_dev_probe(struct rte_device *dev)
 {
-	struct ibv_device *ibv;
 	struct rte_cryptodev *crypto_dev;
-	struct ibv_context *ctx;
+	void *ctx;
+	const char *device_name;
 	struct mlx5_devx_obj *login;
 	struct mlx5_crypto_priv *priv;
 	struct mlx5_crypto_devarg_params devarg_prms = { 0 };
@@ -999,15 +991,19 @@ mlx5_crypto_dev_probe(struct rte_device *dev)
 		rte_errno = ENOTSUP;
 		return -rte_errno;
 	}
-	ibv = mlx5_os_get_ibv_dev(dev);
-	if (ibv == NULL)
-		return -rte_errno;
-	ctx = mlx5_glue->dv_open_device(ibv);
+	ctx = mlx5_os_open_device_context(dev);
 	if (ctx == NULL) {
-		DRV_LOG(ERR, "Failed to open IB device \"%s\".", ibv->name);
+		DRV_LOG(ERR, "Failed to open IB device.");
 		rte_errno = ENODEV;
 		return -rte_errno;
 	}
+	device_name = mlx5_os_get_ctx_device_name(ctx);
+	if (!device_name) {
+		DRV_LOG(ERR, "Failed getting device name");
+		claim_zero(mlx5_glue->close_device(ctx));
+		rte_errno = ENODEV;
+		return -ENODEV;
+	}
 	if (mlx5_devx_cmd_query_hca_attr(ctx, &attr) != 0 ||
 	    attr.crypto == 0 || attr.aes_xts == 0) {
 		DRV_LOG(ERR, "Not enough capabilities to support crypto "
@@ -1029,15 +1025,14 @@ mlx5_crypto_dev_probe(struct rte_device *dev)
 		claim_zero(mlx5_glue->close_device(ctx));
 		return -rte_errno;
 	}
-	crypto_dev = rte_cryptodev_pmd_create(ibv->name, dev,
-					&init_params);
+	crypto_dev = rte_cryptodev_pmd_create(device_name, dev, &init_params);
 	if (crypto_dev == NULL) {
-		DRV_LOG(ERR, "Failed to create device \"%s\".", ibv->name);
+		DRV_LOG(ERR, "Failed to create device \"%s\".", device_name);
 		claim_zero(mlx5_glue->close_device(ctx));
 		return -ENODEV;
 	}
 	DRV_LOG(INFO,
-		"Crypto device %s was created successfully.", ibv->name);
+		"Crypto device %s was created successfully.", device_name);
 	crypto_dev->dev_ops = &mlx5_crypto_ops;
 	crypto_dev->dequeue_burst = mlx5_crypto_dequeue_burst;
 	crypto_dev->enqueue_burst = mlx5_crypto_enqueue_burst;
@@ -1061,8 +1056,8 @@ mlx5_crypto_dev_probe(struct rte_device *dev)
 		rte_errno = ENOMEM;
 		return -rte_errno;
 	}
-	priv->mr_scache.reg_mr_cb = mlx5_common_verbs_reg_mr;
-	priv->mr_scache.dereg_mr_cb = mlx5_common_verbs_dereg_mr;
+	priv->mr_scache.reg_mr_cb = mlx5_os_reg_mr;
+	priv->mr_scache.dereg_mr_cb = mlx5_os_dereg_mr;
 	priv->keytag = rte_cpu_to_be_64(devarg_prms.keytag);
 	priv->max_segs_num = devarg_prms.max_segs_num;
 	priv->umr_wqe_size = sizeof(struct mlx5_wqe_umr_bsf_seg) +
drivers/crypto/mlx5/mlx5_crypto.h +1 -1
index 91e3f438b8..57461a8a33 100644
@@ -19,7 +19,7 @@
 
 struct mlx5_crypto_priv {
 	TAILQ_ENTRY(mlx5_crypto_priv) next;
-	struct ibv_context *ctx; /* Device context. */
+	void *ctx; /* Device context. */
 	struct rte_cryptodev *crypto_dev;
 	void *uar; /* User Access Region. */
 	volatile uint64_t *uar_addr;
Signature · 1 line
2.16.1.windows.4
#9 lore raw

RFC PATCH 9/10 crypto/mlx5: fix size of UMR WQE

In reply to Tal Shnaiderman

The size of the UMR WQE allocated object is decided by a sizof operation on the struct, however since the struct contains a union of flexible array members this sizeof results can differ between compilers.

GCC for example treats the union as 0 sized, MSVC adds a padding of 16Bits.

To resolve the ambiguity the allocation size will be calculated by the sizes of the members excluding the flexible union.

Fixes a1978aa23bf4 ("crypto/mlx5: add maximum segments configuration")
---
 drivers/crypto/mlx5/mlx5_crypto.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/mlx5/mlx5_crypto.c +3 -1
index 3f5a6745dc..4b8d561e33 100644
@@ -1061,7 +1061,9 @@ mlx5_crypto_dev_probe(struct rte_device *dev)
 	priv->keytag = rte_cpu_to_be_64(devarg_prms.keytag);
 	priv->max_segs_num = devarg_prms.max_segs_num;
 	priv->umr_wqe_size = sizeof(struct mlx5_wqe_umr_bsf_seg) +
-			     sizeof(struct mlx5_umr_wqe) +
+			     sizeof(struct mlx5_wqe_cseg) +
+			     sizeof(struct mlx5_wqe_umr_cseg) +
+			     sizeof(struct mlx5_wqe_mkey_cseg) +
 			     RTE_ALIGN(priv->max_segs_num, 4) *
 			     sizeof(struct mlx5_wqe_dseg);
 	rdmw_wqe_size = sizeof(struct mlx5_rdma_write_wqe) +
Signature · 1 line
2.16.1.windows.4
#10 lore raw

RFC PATCH 10/10 crypto/mlx5: support on Windows

In reply to Tal Shnaiderman

Add support for mlx5 crypto pmd on Windows OS.

---
 drivers/common/mlx5/version.map      | 2 +-
 drivers/crypto/aesni_gcm/meson.build | 6 ++++++
 drivers/crypto/aesni_mb/meson.build  | 6 ++++++
 drivers/crypto/armv8/meson.build     | 6 ++++++
 drivers/crypto/bcmfs/meson.build     | 6 ++++++
 drivers/crypto/ccp/meson.build       | 1 +
 drivers/crypto/kasumi/meson.build    | 6 ++++++
 drivers/crypto/meson.build           | 3 ---
 drivers/crypto/mlx5/meson.build      | 4 ++--
 drivers/crypto/mvsam/meson.build     | 6 ++++++
 drivers/crypto/null/meson.build      | 6 ++++++
 drivers/crypto/octeontx/meson.build  | 6 ++++++
 drivers/crypto/openssl/meson.build   | 6 ++++++
 drivers/crypto/qat/meson.build       | 6 ++++++
 drivers/crypto/scheduler/meson.build | 6 ++++++
 drivers/crypto/snow3g/meson.build    | 6 ++++++
 drivers/crypto/virtio/meson.build    | 6 ++++++
 drivers/crypto/zuc/meson.build       | 6 ++++++
 18 files changed, 88 insertions(+), 6 deletions(-)
drivers/common/mlx5/version.map +1 -1
index c6de706fdb..f595ef30fb 100644
@@ -17,7 +17,7 @@ INTERNAL {
 	mlx5_dev_is_pci;
 	mlx5_dev_to_pci_str;
 
-	mlx5_devx_alloc_uar; # WINDOWS_NO_EXPORT
+	mlx5_devx_alloc_uar;
 
 	mlx5_devx_cmd_alloc_pd;
 	mlx5_devx_cmd_create_conn_track_offload_obj;
drivers/crypto/aesni_gcm/meson.build +6 -0
index 0fcac2a8eb..7d0140ff22 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Intel Corporation
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 IMB_required_ver = '0.52.0'
 lib = cc.find_library('IPSec_MB', required: false)
 if not lib.found()
drivers/crypto/aesni_mb/meson.build +6 -0
index ed6b9f53e4..b7512383c3 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Intel Corporation
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 IMB_required_ver = '0.52.0'
 lib = cc.find_library('IPSec_MB', required: false)
 if not lib.found()
drivers/crypto/armv8/meson.build +6 -0
index 40a4dbb7bb..5effba8bbc 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019 Arm Limited
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 dep = dependency('libAArch64crypto', required: false, method: 'pkg-config')
 if not dep.found()
     build = false
drivers/crypto/bcmfs/meson.build +6 -0
index d67e78d51b..5842f83a3b 100644
@@ -3,6 +3,12 @@
 # All rights reserved.
 #
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 deps += ['eal', 'bus_vdev']
 sources = files(
         'bcmfs_logs.c',
drivers/crypto/ccp/meson.build +1 -0
index 0f82b9b90b..a4f3406009 100644
@@ -4,6 +4,7 @@
 if not is_linux
     build = false
     reason = 'only supported on Linux'
+    subdir_done()
 endif
 dep = dependency('libcrypto', required: false, method: 'pkg-config')
 if not dep.found()
drivers/crypto/kasumi/meson.build +6 -0
index e6e0f08c3d..966b8a5214 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018-2020 Intel Corporation
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 IMB_required_ver = '0.53.0'
 lib = cc.find_library('IPSec_MB', required: false)
 if not lib.found()
drivers/crypto/meson.build +0 -3
index ea239f4c56..c49ec501d4 100644
@@ -1,9 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    subdir_done()
-endif
 
 drivers = [
         'aesni_gcm',
drivers/crypto/mlx5/meson.build +2 -2
index 1d6e413dd5..9d9c9c00bc 100644
@@ -1,9 +1,9 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright (c) 2021 NVIDIA Corporation & Affiliates
 
-if not is_linux
+if not (is_linux or is_windows)
     build = false
-    reason = 'only supported on Linux'
+    reason = 'only supported on Linux and Windows'
     subdir_done()
 endif
 
drivers/crypto/mvsam/meson.build +6 -0
index fec167bf29..bf3c4323de 100644
@@ -3,6 +3,12 @@
 # Copyright(c) 2018 Semihalf.
 # All rights reserved.
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 dep = dependency('libmusdk', required: false, method: 'pkg-config')
 if not dep.found()
     build = false
drivers/crypto/null/meson.build +6 -0
index 1f7d644de1..acc16e7d81 100644
@@ -1,5 +1,11 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 deps += 'bus_vdev'
 sources = files('null_crypto_pmd.c', 'null_crypto_pmd_ops.c')
drivers/crypto/octeontx/meson.build +6 -0
index 244b16230e..48e8e263c1 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Cavium, Inc
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 deps += ['bus_pci']
 deps += ['bus_vdev']
 deps += ['common_cpt']
drivers/crypto/openssl/meson.build +6 -0
index b21fca0be3..cd962da1d6 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 dep = dependency('libcrypto', required: false, method: 'pkg-config')
 if not dep.found()
     build = false
drivers/crypto/qat/meson.build +6 -0
index b3b2d17258..d08a24c7b3 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2018 Intel Corporation
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 # this does not build the QAT driver, instead that is done in the compression
 # driver which comes later. Here we just add our sources files to the list
 build = false
drivers/crypto/scheduler/meson.build +6 -0
index d510f49970..cd18efc791 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Luca Boccassi <[email protected]>
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 deps += ['bus_vdev', 'reorder']
 sources = files(
         'rte_cryptodev_scheduler.c',
drivers/crypto/snow3g/meson.build +6 -0
index 0c087baa2a..ac4d0354ea 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019-2020 Intel Corporation
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 IMB_required_ver = '0.53.0'
 lib = cc.find_library('IPSec_MB', required: false)
 if not lib.found()
drivers/crypto/virtio/meson.build +6 -0
index 1b6d77f66f..45533c9b89 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD.
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 includes += include_directories('../../../lib/vhost')
 deps += 'bus_pci'
 sources = files(
drivers/crypto/zuc/meson.build +6 -0
index a5f77a22d8..0a29885610 100644
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018-2020 Intel Corporation
 
+if is_windows
+    build = false
+    reason = 'not supported on Windows'
+    subdir_done()
+endif
+
 IMB_required_ver = '0.53.0'
 lib = cc.find_library('IPSec_MB', required: false)
 if not lib.found()
Signature · 1 line
2.16.1.windows.4