1 /* SPDX-License-Identifier: GPL-2.0-only
2 * Copyright (C) 2020 Marvell.
5 #ifndef __OTX2_CPT_ALGS_H
6 #define __OTX2_CPT_ALGS_H
8 #include <crypto/hash.h>
9 #include <crypto/skcipher.h>
10 #include <crypto/aead.h>
11 #include "otx2_cpt_common.h"
13 #define OTX2_CPT_MAX_ENC_KEY_SIZE 32
14 #define OTX2_CPT_MAX_HASH_KEY_SIZE 64
15 #define OTX2_CPT_MAX_KEY_SIZE (OTX2_CPT_MAX_ENC_KEY_SIZE + \
16 OTX2_CPT_MAX_HASH_KEY_SIZE)
17 enum otx2_cpt_request_type {
18 OTX2_CPT_ENC_DEC_REQ = 0x1,
19 OTX2_CPT_AEAD_ENC_DEC_REQ = 0x2,
20 OTX2_CPT_AEAD_ENC_DEC_NULL_REQ = 0x3,
21 OTX2_CPT_PASSTHROUGH_REQ = 0x4
24 enum otx2_cpt_major_opcodes {
25 OTX2_CPT_MAJOR_OP_MISC = 0x01,
26 OTX2_CPT_MAJOR_OP_FC = 0x33,
27 OTX2_CPT_MAJOR_OP_HMAC = 0x35,
30 enum otx2_cpt_cipher_type {
31 OTX2_CPT_CIPHER_NULL = 0x0,
32 OTX2_CPT_DES3_CBC = 0x1,
33 OTX2_CPT_DES3_ECB = 0x2,
34 OTX2_CPT_AES_CBC = 0x3,
35 OTX2_CPT_AES_ECB = 0x4,
36 OTX2_CPT_AES_CFB = 0x5,
37 OTX2_CPT_AES_CTR = 0x6,
38 OTX2_CPT_AES_GCM = 0x7,
39 OTX2_CPT_AES_XTS = 0x8
42 enum otx2_cpt_mac_type {
43 OTX2_CPT_MAC_NULL = 0x0,
46 OTX2_CPT_SHA224 = 0x3,
47 OTX2_CPT_SHA256 = 0x4,
48 OTX2_CPT_SHA384 = 0x5,
49 OTX2_CPT_SHA512 = 0x6,
53 enum otx2_cpt_aes_key_len {
54 OTX2_CPT_AES_128_BIT = 0x1,
55 OTX2_CPT_AES_192_BIT = 0x2,
56 OTX2_CPT_AES_256_BIT = 0x3
59 union otx2_cpt_encr_ctrl {
62 #if defined(__BIG_ENDIAN_BITFIELD)
69 u64 auth_input_type:1;
81 u64 auth_input_type:1;
92 struct otx2_cpt_cipher {
97 struct otx2_cpt_fc_enc_ctx {
98 union otx2_cpt_encr_ctrl enc_ctrl;
103 union otx2_cpt_fc_hmac_ctx {
109 u8 hmac_calc[64]; /* HMAC calculated */
110 u8 hmac_recv[64]; /* HMAC received */
114 struct otx2_cpt_fc_ctx {
115 struct otx2_cpt_fc_enc_ctx enc;
116 union otx2_cpt_fc_hmac_ctx hmac;
119 struct otx2_cpt_enc_ctx {
121 u8 enc_key[OTX2_CPT_MAX_KEY_SIZE];
125 struct crypto_skcipher *fbk_cipher;
128 union otx2_cpt_offset_ctrl {
131 #if defined(__BIG_ENDIAN_BITFIELD)
133 u64 enc_data_offset:16;
139 u64 enc_data_offset:16;
145 struct otx2_cpt_req_ctx {
146 struct otx2_cpt_req_info cpt_req;
147 union otx2_cpt_offset_ctrl ctrl_word;
148 struct otx2_cpt_fc_ctx fctx;
150 struct skcipher_request sk_fbk_req;
151 struct aead_request fbk_req;
155 struct otx2_cpt_sdesc {
156 struct shash_desc shash;
159 struct otx2_cpt_aead_ctx {
160 u8 key[OTX2_CPT_MAX_KEY_SIZE];
161 struct crypto_shash *hashalg;
162 struct otx2_cpt_sdesc *sdesc;
163 struct crypto_aead *fbk_cipher;
174 int otx2_cpt_crypto_init(struct pci_dev *pdev, struct module *mod,
175 int num_queues, int num_devices);
176 void otx2_cpt_crypto_exit(struct pci_dev *pdev, struct module *mod);
178 #endif /* __OTX2_CPT_ALGS_H */