]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/drivers/crypto/qat/qat_sym_session.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / dpdk / drivers / crypto / qat / qat_sym_session.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2018 Intel Corporation
3 */
4 #ifndef _QAT_SYM_SESSION_H_
5 #define _QAT_SYM_SESSION_H_
6
7 #include <rte_crypto.h>
8 #include <rte_cryptodev_pmd.h>
9
10 #include "qat_common.h"
11 #include "icp_qat_hw.h"
12 #include "icp_qat_fw.h"
13 #include "icp_qat_fw_la.h"
14
15 /*
16 * Key Modifier (KM) value used in KASUMI algorithm in F9 mode to XOR
17 * Integrity Key (IK)
18 */
19 #define KASUMI_F9_KEY_MODIFIER_4_BYTES 0xAAAAAAAA
20
21 #define KASUMI_F8_KEY_MODIFIER_4_BYTES 0x55555555
22
23 /* 3DES key sizes */
24 #define QAT_3DES_KEY_SZ_OPT1 24 /* Keys are independent */
25 #define QAT_3DES_KEY_SZ_OPT2 16 /* K3=K1 */
26 #define QAT_3DES_KEY_SZ_OPT3 8 /* K1=K2=K3 */
27
28
29 #define QAT_AES_HW_CONFIG_CBC_ENC(alg) \
30 ICP_QAT_HW_CIPHER_CONFIG_BUILD(ICP_QAT_HW_CIPHER_CBC_MODE, alg, \
31 ICP_QAT_HW_CIPHER_NO_CONVERT, \
32 ICP_QAT_HW_CIPHER_ENCRYPT)
33
34 #define QAT_AES_HW_CONFIG_CBC_DEC(alg) \
35 ICP_QAT_HW_CIPHER_CONFIG_BUILD(ICP_QAT_HW_CIPHER_CBC_MODE, alg, \
36 ICP_QAT_HW_CIPHER_KEY_CONVERT, \
37 ICP_QAT_HW_CIPHER_DECRYPT)
38
39 enum qat_sym_proto_flag {
40 QAT_CRYPTO_PROTO_FLAG_NONE = 0,
41 QAT_CRYPTO_PROTO_FLAG_CCM = 1,
42 QAT_CRYPTO_PROTO_FLAG_GCM = 2,
43 QAT_CRYPTO_PROTO_FLAG_SNOW3G = 3,
44 QAT_CRYPTO_PROTO_FLAG_ZUC = 4
45 };
46
47 /* Common content descriptor */
48 struct qat_sym_cd {
49 struct icp_qat_hw_cipher_algo_blk cipher;
50 struct icp_qat_hw_auth_algo_blk hash;
51 } __rte_packed __rte_cache_aligned;
52
53 struct qat_sym_session {
54 enum icp_qat_fw_la_cmd_id qat_cmd;
55 enum icp_qat_hw_cipher_algo qat_cipher_alg;
56 enum icp_qat_hw_cipher_dir qat_dir;
57 enum icp_qat_hw_cipher_mode qat_mode;
58 enum icp_qat_hw_auth_algo qat_hash_alg;
59 enum icp_qat_hw_auth_op auth_op;
60 void *bpi_ctx;
61 struct qat_sym_cd cd;
62 uint8_t *cd_cur_ptr;
63 phys_addr_t cd_paddr;
64 struct icp_qat_fw_la_bulk_req fw_req;
65 uint8_t aad_len;
66 struct qat_crypto_instance *inst;
67 struct {
68 uint16_t offset;
69 uint16_t length;
70 } cipher_iv;
71 struct {
72 uint16_t offset;
73 uint16_t length;
74 } auth_iv;
75 uint16_t digest_length;
76 rte_spinlock_t lock; /* protects this struct */
77 enum qat_device_gen min_qat_dev_gen;
78 };
79
80 int
81 qat_sym_session_configure(struct rte_cryptodev *dev,
82 struct rte_crypto_sym_xform *xform,
83 struct rte_cryptodev_sym_session *sess,
84 struct rte_mempool *mempool);
85
86 int
87 qat_sym_session_set_parameters(struct rte_cryptodev *dev,
88 struct rte_crypto_sym_xform *xform, void *session_private);
89
90 int
91 qat_sym_session_configure_aead(struct rte_crypto_sym_xform *xform,
92 struct qat_sym_session *session);
93
94 int
95 qat_sym_session_configure_cipher(struct rte_cryptodev *dev,
96 struct rte_crypto_sym_xform *xform,
97 struct qat_sym_session *session);
98
99 int
100 qat_sym_session_configure_auth(struct rte_cryptodev *dev,
101 struct rte_crypto_sym_xform *xform,
102 struct qat_sym_session *session);
103
104 int
105 qat_sym_session_aead_create_cd_cipher(struct qat_sym_session *cd,
106 uint8_t *enckey,
107 uint32_t enckeylen);
108
109 int
110 qat_sym_session_aead_create_cd_auth(struct qat_sym_session *cdesc,
111 uint8_t *authkey,
112 uint32_t authkeylen,
113 uint32_t aad_length,
114 uint32_t digestsize,
115 unsigned int operation);
116
117 void
118 qat_sym_session_clear(struct rte_cryptodev *dev,
119 struct rte_cryptodev_sym_session *session);
120
121 unsigned int
122 qat_sym_session_get_private_size(struct rte_cryptodev *dev);
123
124 void
125 qat_sym_sesssion_init_common_hdr(struct icp_qat_fw_comn_req_hdr *header,
126 enum qat_sym_proto_flag proto_flags);
127 int
128 qat_sym_validate_aes_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
129 int
130 qat_sym_validate_aes_docsisbpi_key(int key_len,
131 enum icp_qat_hw_cipher_algo *alg);
132 int
133 qat_sym_validate_snow3g_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
134 int
135 qat_sym_validate_kasumi_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
136 int
137 qat_sym_validate_3des_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
138 int
139 qat_sym_validate_des_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
140 int
141 qat_cipher_get_block_size(enum icp_qat_hw_cipher_algo qat_cipher_alg);
142 int
143 qat_sym_validate_zuc_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
144
145 #endif /* _QAT_SYM_SESSION_H_ */