1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2021 NVIDIA Corporation & Affiliates
10 #include <rte_cryptodev.h>
11 #include <cryptodev_pmd.h>
13 #include <mlx5_common_utils.h>
14 #include <mlx5_common_devx.h>
15 #include <mlx5_common_mr.h>
17 #define MLX5_CRYPTO_DEK_HTABLE_SZ (1 << 11)
18 #define MLX5_CRYPTO_KEY_LENGTH 80
20 struct mlx5_crypto_priv {
21 TAILQ_ENTRY(mlx5_crypto_priv) next;
22 struct mlx5_common_device *cdev; /* Backend mlx5 device. */
23 struct rte_cryptodev *crypto_dev;
24 void *uar; /* User Access Region. */
25 volatile uint64_t *uar_addr;
26 uint32_t max_segs_num; /* Maximum supported data segs. */
27 struct mlx5_hlist *dek_hlist; /* Dek hash list. */
28 struct rte_cryptodev_config dev_config;
29 struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
30 struct mlx5_devx_obj *login_obj;
32 uint16_t wqe_set_size;
33 uint16_t umr_wqe_size;
34 uint16_t umr_wqe_stride;
35 uint16_t max_rdmar_ds;
37 rte_spinlock_t uar32_sl;
38 #endif /* RTE_ARCH_64 */
41 struct mlx5_crypto_qp {
42 struct mlx5_crypto_priv *priv;
43 struct mlx5_devx_cq cq_obj;
44 struct mlx5_devx_qp qp_obj;
45 struct rte_cryptodev_stats stats;
46 struct rte_crypto_op **ops;
47 struct mlx5_devx_obj **mkey; /* WQE's indirect mekys. */
48 struct mlx5_mr_ctrl mr_ctrl;
56 struct mlx5_crypto_dek {
57 struct mlx5_list_entry entry; /* Pointer to DEK hash list entry. */
58 struct mlx5_devx_obj *obj; /* Pointer to DEK DevX object. */
59 uint8_t data[MLX5_CRYPTO_KEY_LENGTH]; /* DEK key data. */
60 bool size_is_48; /* Whether the key\data size is 48 bytes or not. */
61 } __rte_cache_aligned;
63 struct mlx5_crypto_devarg_params {
65 struct mlx5_devx_crypto_login_attr login_attr;
67 uint32_t max_segs_num;
71 mlx5_crypto_dek_destroy(struct mlx5_crypto_priv *priv,
72 struct mlx5_crypto_dek *dek);
74 struct mlx5_crypto_dek *
75 mlx5_crypto_dek_prepare(struct mlx5_crypto_priv *priv,
76 struct rte_crypto_cipher_xform *cipher);
79 mlx5_crypto_dek_setup(struct mlx5_crypto_priv *priv);
82 mlx5_crypto_dek_unset(struct mlx5_crypto_priv *priv);
84 #endif /* MLX5_CRYPTO_H_ */