1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2021 NVIDIA Corporation & Affiliates
10 #include <rte_cryptodev.h>
11 #include <rte_cryptodev_pmd.h>
13 #include <mlx5_common_utils.h>
14 #include <mlx5_common_devx.h>
16 #define MLX5_CRYPTO_DEK_HTABLE_SZ (1 << 11)
17 #define MLX5_CRYPTO_KEY_LENGTH 80
18 #define MLX5_CRYPTO_WQE_SET_SIZE 1024
20 struct mlx5_crypto_priv {
21 TAILQ_ENTRY(mlx5_crypto_priv) next;
22 struct ibv_context *ctx; /* Device context. */
23 struct rte_pci_device *pci_dev;
24 struct rte_cryptodev *crypto_dev;
25 void *uar; /* User Access Region. */
26 uint32_t pdn; /* Protection Domain number. */
28 struct mlx5_hlist *dek_hlist; /* Dek hash list. */
29 struct rte_cryptodev_config dev_config;
32 struct mlx5_crypto_qp {
33 struct mlx5_devx_cq cq_obj;
34 struct mlx5_devx_obj *qp_obj;
35 struct mlx5dv_devx_umem *umem_obj;
37 volatile uint32_t *db_rec;
38 struct rte_crypto_op **ops;
41 struct mlx5_crypto_dek {
42 struct mlx5_list_entry entry; /* Pointer to DEK hash list entry. */
43 struct mlx5_devx_obj *obj; /* Pointer to DEK DevX object. */
44 uint8_t data[MLX5_CRYPTO_KEY_LENGTH]; /* DEK key data. */
45 bool size_is_48; /* Whether the key\data size is 48 bytes or not. */
46 } __rte_cache_aligned;
49 mlx5_crypto_dek_destroy(struct mlx5_crypto_priv *priv,
50 struct mlx5_crypto_dek *dek);
52 struct mlx5_crypto_dek *
53 mlx5_crypto_dek_prepare(struct mlx5_crypto_priv *priv,
54 struct rte_crypto_cipher_xform *cipher);
57 mlx5_crypto_dek_setup(struct mlx5_crypto_priv *priv);
60 mlx5_crypto_dek_unset(struct mlx5_crypto_priv *priv);
62 #endif /* MLX5_CRYPTO_H_ */