Path: blob/master/drivers/crypto/marvell/octeontx/otx_cptvf_algs.h
26285 views
/* SPDX-License-Identifier: GPL-2.01* Marvell OcteonTX CPT driver2*3* Copyright (C) 2019 Marvell International Ltd.4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License version 2 as7* published by the Free Software Foundation.8*/910#ifndef __OTX_CPT_ALGS_H11#define __OTX_CPT_ALGS_H1213#include <crypto/hash.h>14#include "otx_cpt_common.h"1516#define OTX_CPT_MAX_ENC_KEY_SIZE 3217#define OTX_CPT_MAX_HASH_KEY_SIZE 6418#define OTX_CPT_MAX_KEY_SIZE (OTX_CPT_MAX_ENC_KEY_SIZE + \19OTX_CPT_MAX_HASH_KEY_SIZE)20enum otx_cpt_request_type {21OTX_CPT_ENC_DEC_REQ = 0x1,22OTX_CPT_AEAD_ENC_DEC_REQ = 0x2,23OTX_CPT_AEAD_ENC_DEC_NULL_REQ = 0x3,24OTX_CPT_PASSTHROUGH_REQ = 0x425};2627enum otx_cpt_major_opcodes {28OTX_CPT_MAJOR_OP_MISC = 0x01,29OTX_CPT_MAJOR_OP_FC = 0x33,30OTX_CPT_MAJOR_OP_HMAC = 0x35,31};3233enum otx_cpt_req_type {34OTX_CPT_AE_CORE_REQ,35OTX_CPT_SE_CORE_REQ36};3738enum otx_cpt_cipher_type {39OTX_CPT_CIPHER_NULL = 0x0,40OTX_CPT_DES3_CBC = 0x1,41OTX_CPT_DES3_ECB = 0x2,42OTX_CPT_AES_CBC = 0x3,43OTX_CPT_AES_ECB = 0x4,44OTX_CPT_AES_CFB = 0x5,45OTX_CPT_AES_CTR = 0x6,46OTX_CPT_AES_GCM = 0x7,47OTX_CPT_AES_XTS = 0x848};4950enum otx_cpt_mac_type {51OTX_CPT_MAC_NULL = 0x0,52OTX_CPT_MD5 = 0x1,53OTX_CPT_SHA1 = 0x2,54OTX_CPT_SHA224 = 0x3,55OTX_CPT_SHA256 = 0x4,56OTX_CPT_SHA384 = 0x5,57OTX_CPT_SHA512 = 0x6,58OTX_CPT_GMAC = 0x759};6061enum otx_cpt_aes_key_len {62OTX_CPT_AES_128_BIT = 0x1,63OTX_CPT_AES_192_BIT = 0x2,64OTX_CPT_AES_256_BIT = 0x365};6667union otx_cpt_encr_ctrl {68__be64 flags;69u64 cflags;70struct {71#if defined(__BIG_ENDIAN_BITFIELD)72u64 enc_cipher:4;73u64 reserved1:1;74u64 aes_key:2;75u64 iv_source:1;76u64 mac_type:4;77u64 reserved2:3;78u64 auth_input_type:1;79u64 mac_len:8;80u64 reserved3:8;81u64 encr_offset:16;82u64 iv_offset:8;83u64 auth_offset:8;84#else85u64 auth_offset:8;86u64 iv_offset:8;87u64 encr_offset:16;88u64 reserved3:8;89u64 mac_len:8;90u64 auth_input_type:1;91u64 reserved2:3;92u64 mac_type:4;93u64 iv_source:1;94u64 aes_key:2;95u64 reserved1:1;96u64 enc_cipher:4;97#endif98} e;99};100101struct otx_cpt_cipher {102const char *name;103u8 value;104};105106struct otx_cpt_enc_context {107union otx_cpt_encr_ctrl enc_ctrl;108u8 encr_key[32];109u8 encr_iv[16];110};111112union otx_cpt_fchmac_ctx {113struct {114u8 ipad[64];115u8 opad[64];116} e;117struct {118u8 hmac_calc[64]; /* HMAC calculated */119u8 hmac_recv[64]; /* HMAC received */120} s;121};122123struct otx_cpt_fc_ctx {124struct otx_cpt_enc_context enc;125union otx_cpt_fchmac_ctx hmac;126};127128struct otx_cpt_enc_ctx {129u32 key_len;130u8 enc_key[OTX_CPT_MAX_KEY_SIZE];131u8 cipher_type;132u8 key_type;133};134135struct otx_cpt_des3_ctx {136u32 key_len;137u8 des3_key[OTX_CPT_MAX_KEY_SIZE];138};139140union otx_cpt_offset_ctrl_word {141__be64 flags;142u64 cflags;143struct {144#if defined(__BIG_ENDIAN_BITFIELD)145u64 reserved:32;146u64 enc_data_offset:16;147u64 iv_offset:8;148u64 auth_offset:8;149#else150u64 auth_offset:8;151u64 iv_offset:8;152u64 enc_data_offset:16;153u64 reserved:32;154#endif155} e;156};157158struct otx_cpt_req_ctx {159struct otx_cpt_req_info cpt_req;160union otx_cpt_offset_ctrl_word ctrl_word;161struct otx_cpt_fc_ctx fctx;162};163164struct otx_cpt_sdesc {165struct shash_desc shash;166};167168struct otx_cpt_aead_ctx {169u8 key[OTX_CPT_MAX_KEY_SIZE];170struct crypto_shash *hashalg;171struct otx_cpt_sdesc *sdesc;172u8 *ipad;173u8 *opad;174u32 enc_key_len;175u32 auth_key_len;176u8 cipher_type;177u8 mac_type;178u8 key_type;179u8 is_trunc_hmac;180};181int otx_cpt_crypto_init(struct pci_dev *pdev, struct module *mod,182enum otx_cptpf_type pf_type,183enum otx_cptvf_type engine_type,184int num_queues, int num_devices);185void otx_cpt_crypto_exit(struct pci_dev *pdev, struct module *mod,186enum otx_cptvf_type engine_type);187188#endif /* __OTX_CPT_ALGS_H */189190191