crypto/qat: remove unused includes
[dpdk.git] / drivers / crypto / qat / qat_adf / qat_algs.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  * Copyright(c) 2015-2018 Intel Corporation
3  */
4 #ifndef _ICP_QAT_ALGS_H_
5 #define _ICP_QAT_ALGS_H_
6 #include <rte_memory.h>
7 #include <rte_crypto.h>
8 #include "icp_qat_hw.h"
9 #include "icp_qat_fw.h"
10 #include "icp_qat_fw_la.h"
11 #include "../qat_crypto.h"
12
13 /*
14  * Key Modifier (KM) value used in KASUMI algorithm in F9 mode to XOR
15  * Integrity Key (IK)
16  */
17 #define KASUMI_F9_KEY_MODIFIER_4_BYTES   0xAAAAAAAA
18
19 #define KASUMI_F8_KEY_MODIFIER_4_BYTES   0x55555555
20
21 /* 3DES key sizes */
22 #define QAT_3DES_KEY_SZ_OPT1 24 /* Keys are independent */
23 #define QAT_3DES_KEY_SZ_OPT2 16 /* K3=K1 */
24
25 #define QAT_AES_HW_CONFIG_CBC_ENC(alg) \
26         ICP_QAT_HW_CIPHER_CONFIG_BUILD(ICP_QAT_HW_CIPHER_CBC_MODE, alg, \
27                                         ICP_QAT_HW_CIPHER_NO_CONVERT, \
28                                         ICP_QAT_HW_CIPHER_ENCRYPT)
29
30 #define QAT_AES_HW_CONFIG_CBC_DEC(alg) \
31         ICP_QAT_HW_CIPHER_CONFIG_BUILD(ICP_QAT_HW_CIPHER_CBC_MODE, alg, \
32                                         ICP_QAT_HW_CIPHER_KEY_CONVERT, \
33                                         ICP_QAT_HW_CIPHER_DECRYPT)
34
35 enum qat_crypto_proto_flag {
36         QAT_CRYPTO_PROTO_FLAG_NONE = 0,
37         QAT_CRYPTO_PROTO_FLAG_CCM = 1,
38         QAT_CRYPTO_PROTO_FLAG_GCM = 2,
39         QAT_CRYPTO_PROTO_FLAG_SNOW3G = 3,
40         QAT_CRYPTO_PROTO_FLAG_ZUC = 4
41 };
42
43 /* Common content descriptor */
44 struct qat_alg_cd {
45         struct icp_qat_hw_cipher_algo_blk cipher;
46         struct icp_qat_hw_auth_algo_blk hash;
47 } __rte_packed __rte_cache_aligned;
48
49 struct qat_session {
50         enum icp_qat_fw_la_cmd_id qat_cmd;
51         enum icp_qat_hw_cipher_algo qat_cipher_alg;
52         enum icp_qat_hw_cipher_dir qat_dir;
53         enum icp_qat_hw_cipher_mode qat_mode;
54         enum icp_qat_hw_auth_algo qat_hash_alg;
55         enum icp_qat_hw_auth_op auth_op;
56         void *bpi_ctx;
57         struct qat_alg_cd cd;
58         uint8_t *cd_cur_ptr;
59         rte_iova_t cd_paddr;
60         struct icp_qat_fw_la_bulk_req fw_req;
61         uint8_t aad_len;
62         struct qat_crypto_instance *inst;
63         struct {
64                 uint16_t offset;
65                 uint16_t length;
66         } cipher_iv;
67         struct {
68                 uint16_t offset;
69                 uint16_t length;
70         } auth_iv;
71         uint16_t digest_length;
72         rte_spinlock_t lock;    /* protects this struct */
73         enum qat_device_gen min_qat_dev_gen;
74 };
75
76 int qat_get_inter_state_size(enum icp_qat_hw_auth_algo qat_hash_alg);
77
78 int qat_alg_aead_session_create_content_desc_cipher(struct qat_session *cd,
79                                                 uint8_t *enckey,
80                                                 uint32_t enckeylen);
81
82 int qat_alg_aead_session_create_content_desc_auth(struct qat_session *cdesc,
83                                                 uint8_t *authkey,
84                                                 uint32_t authkeylen,
85                                                 uint32_t aad_length,
86                                                 uint32_t digestsize,
87                                                 unsigned int operation);
88
89 void qat_alg_init_common_hdr(struct icp_qat_fw_comn_req_hdr *header,
90                                         enum qat_crypto_proto_flag proto_flags);
91
92 int qat_alg_validate_aes_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
93 int qat_alg_validate_aes_docsisbpi_key(int key_len,
94                                         enum icp_qat_hw_cipher_algo *alg);
95 int qat_alg_validate_snow3g_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
96 int qat_alg_validate_kasumi_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
97 int qat_alg_validate_3des_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
98 int qat_alg_validate_des_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
99 int qat_cipher_get_block_size(enum icp_qat_hw_cipher_algo qat_cipher_alg);
100 int qat_alg_validate_zuc_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
101 #endif