xref: /dpdk/drivers/crypto/uadk/uadk_crypto_pmd_private.h (revision 2b843cac232eb3f2fa79e4254e21766817e2019f)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2022-2023 Huawei Technologies Co.,Ltd. All rights reserved.
3  * Copyright 2022-2023 Linaro ltd.
4  */
5 
6 #ifndef _UADK_CRYPTO_PMD_PRIVATE_H_
7 #define _UADK_CRYPTO_PMD_PRIVATE_H_
8 
9 /* Maximum length for digest (SHA-512 needs 64 bytes) */
10 #define DIGEST_LENGTH_MAX 64
11 
12 struct __rte_cache_aligned uadk_qp {
13 	/* Ring for placing process packets */
14 	struct rte_ring *processed_pkts;
15 	/* Queue pair statistics */
16 	struct rte_cryptodev_stats qp_stats;
17 	/* Queue Pair Identifier */
18 	uint16_t id;
19 	/* Unique Queue Pair Name */
20 	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
21 	/* Buffer used to store the digest generated
22 	 * by the driver when verifying a digest provided
23 	 * by the user (using authentication verify operation)
24 	 */
25 	uint8_t temp_digest[DIGEST_LENGTH_MAX];
26 };
27 
28 enum uadk_chain_order {
29 	UADK_CHAIN_ONLY_CIPHER,
30 	UADK_CHAIN_ONLY_AUTH,
31 	UADK_CHAIN_CIPHER_AUTH,
32 	UADK_CHAIN_AUTH_CIPHER,
33 	UADK_CHAIN_NOT_SUPPORTED
34 };
35 
36 struct __rte_cache_aligned uadk_crypto_session {
37 	handle_t handle_cipher;
38 	handle_t handle_digest;
39 	enum uadk_chain_order chain_order;
40 
41 	/* IV parameters */
42 	struct {
43 		uint16_t length;
44 		uint16_t offset;
45 	} iv;
46 
47 	/* Cipher Parameters */
48 	struct {
49 		enum rte_crypto_cipher_operation direction;
50 		struct wd_cipher_req req;
51 	} cipher;
52 
53 	/* Authentication Parameters */
54 	struct {
55 		struct wd_digest_req req;
56 		enum rte_crypto_auth_operation operation;
57 		uint16_t digest_length;
58 	} auth;
59 };
60 
61 enum uadk_crypto_version {
62 	UADK_CRYPTO_V2,
63 	UADK_CRYPTO_V3,
64 };
65 
66 struct __rte_cache_aligned uadk_crypto_priv {
67 	bool env_cipher_init;
68 	bool env_auth_init;
69 	enum uadk_crypto_version version;
70 	unsigned int max_nb_qpairs;
71 };
72 
73 extern int uadk_crypto_logtype;
74 #define RTE_LOGTYPE_UADK_CRYPTO uadk_crypto_logtype
75 
76 #define UADK_LOG(level, ...)  \
77 	RTE_LOG_LINE_PREFIX(level, UADK_CRYPTO, "%s() line %u: ", \
78 		__func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)
79 
80 #endif /* _UADK_CRYPTO_PMD_PRIVATE_H_ */
81