3f783fc956aa8229487dd6e99edd80f3e9a1abae
[dpdk.git] / drivers / crypto / mlx5 / mlx5_crypto.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2021 NVIDIA Corporation & Affiliates
3  */
4
5 #ifndef MLX5_CRYPTO_H_
6 #define MLX5_CRYPTO_H_
7
8 #include <stdbool.h>
9
10 #include <rte_cryptodev.h>
11 #include <rte_cryptodev_pmd.h>
12
13 #include <mlx5_common_utils.h>
14
15 #define MLX5_CRYPTO_DEK_HTABLE_SZ (1 << 11)
16 #define MLX5_CRYPTO_KEY_LENGTH 80
17
18 struct mlx5_crypto_priv {
19         TAILQ_ENTRY(mlx5_crypto_priv) next;
20         struct ibv_context *ctx; /* Device context. */
21         struct rte_pci_device *pci_dev;
22         struct rte_cryptodev *crypto_dev;
23         void *uar; /* User Access Region. */
24         uint32_t pdn; /* Protection Domain number. */
25         struct ibv_pd *pd;
26         struct mlx5_hlist *dek_hlist; /* Dek hash list. */
27 };
28
29 struct mlx5_crypto_dek {
30         struct mlx5_list_entry entry; /* Pointer to DEK hash list entry. */
31         struct mlx5_devx_obj *obj; /* Pointer to DEK DevX object. */
32         uint8_t data[MLX5_CRYPTO_KEY_LENGTH]; /* DEK key data. */
33         bool size_is_48; /* Whether the key\data size is 48 bytes or not. */
34 } __rte_cache_aligned;
35
36 int
37 mlx5_crypto_dek_destroy(struct mlx5_crypto_priv *priv,
38                         struct mlx5_crypto_dek *dek);
39
40 struct mlx5_crypto_dek *
41 mlx5_crypto_dek_prepare(struct mlx5_crypto_priv *priv,
42                         struct rte_crypto_cipher_xform *cipher);
43
44 int
45 mlx5_crypto_dek_setup(struct mlx5_crypto_priv *priv);
46
47 void
48 mlx5_crypto_dek_unset(struct mlx5_crypto_priv *priv);
49
50 #endif /* MLX5_CRYPTO_H_ */