1 /* SPDX-License-Identifier: GPL-2.0
2 * Marvell OcteonTX CPT driver
4 * Copyright (C) 2019 Marvell International Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #ifndef __OTX_CPT_ALGS_H
12 #define __OTX_CPT_ALGS_H
14 #include <crypto/hash.h>
15 #include "otx_cpt_common.h"
17 #define OTX_CPT_MAX_ENC_KEY_SIZE 32
18 #define OTX_CPT_MAX_HASH_KEY_SIZE 64
19 #define OTX_CPT_MAX_KEY_SIZE (OTX_CPT_MAX_ENC_KEY_SIZE + \
20 OTX_CPT_MAX_HASH_KEY_SIZE)
21 enum otx_cpt_request_type {
22 OTX_CPT_ENC_DEC_REQ = 0x1,
23 OTX_CPT_AEAD_ENC_DEC_REQ = 0x2,
24 OTX_CPT_AEAD_ENC_DEC_NULL_REQ = 0x3,
25 OTX_CPT_PASSTHROUGH_REQ = 0x4
28 enum otx_cpt_major_opcodes {
29 OTX_CPT_MAJOR_OP_MISC = 0x01,
30 OTX_CPT_MAJOR_OP_FC = 0x33,
31 OTX_CPT_MAJOR_OP_HMAC = 0x35,
34 enum otx_cpt_req_type {
39 enum otx_cpt_cipher_type {
40 OTX_CPT_CIPHER_NULL = 0x0,
41 OTX_CPT_DES3_CBC = 0x1,
42 OTX_CPT_DES3_ECB = 0x2,
43 OTX_CPT_AES_CBC = 0x3,
44 OTX_CPT_AES_ECB = 0x4,
45 OTX_CPT_AES_CFB = 0x5,
46 OTX_CPT_AES_CTR = 0x6,
47 OTX_CPT_AES_GCM = 0x7,
51 enum otx_cpt_mac_type {
52 OTX_CPT_MAC_NULL = 0x0,
62 enum otx_cpt_aes_key_len {
63 OTX_CPT_AES_128_BIT = 0x1,
64 OTX_CPT_AES_192_BIT = 0x2,
65 OTX_CPT_AES_256_BIT = 0x3
68 union otx_cpt_encr_ctrl {
72 #if defined(__BIG_ENDIAN_BITFIELD)
79 u64 auth_input_type:1;
91 u64 auth_input_type:1;
102 struct otx_cpt_cipher {
107 struct otx_cpt_enc_context {
108 union otx_cpt_encr_ctrl enc_ctrl;
113 union otx_cpt_fchmac_ctx {
119 u8 hmac_calc[64]; /* HMAC calculated */
120 u8 hmac_recv[64]; /* HMAC received */
124 struct otx_cpt_fc_ctx {
125 struct otx_cpt_enc_context enc;
126 union otx_cpt_fchmac_ctx hmac;
129 struct otx_cpt_enc_ctx {
131 u8 enc_key[OTX_CPT_MAX_KEY_SIZE];
136 struct otx_cpt_des3_ctx {
138 u8 des3_key[OTX_CPT_MAX_KEY_SIZE];
141 union otx_cpt_offset_ctrl_word {
145 #if defined(__BIG_ENDIAN_BITFIELD)
147 u64 enc_data_offset:16;
153 u64 enc_data_offset:16;
159 struct otx_cpt_req_ctx {
160 struct otx_cpt_req_info cpt_req;
161 union otx_cpt_offset_ctrl_word ctrl_word;
162 struct otx_cpt_fc_ctx fctx;
165 struct otx_cpt_sdesc {
166 struct shash_desc shash;
169 struct otx_cpt_aead_ctx {
170 u8 key[OTX_CPT_MAX_KEY_SIZE];
171 struct crypto_shash *hashalg;
172 struct otx_cpt_sdesc *sdesc;
182 int otx_cpt_crypto_init(struct pci_dev *pdev, struct module *mod,
183 enum otx_cptpf_type pf_type,
184 enum otx_cptvf_type engine_type,
185 int num_queues, int num_devices);
186 void otx_cpt_crypto_exit(struct pci_dev *pdev, struct module *mod,
187 enum otx_cptvf_type engine_type);
188 void otx_cpt_callback(int status, void *arg, void *req);
190 #endif /* __OTX_CPT_ALGS_H */