162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * This file is part of the Chelsio T6 Crypto driver for Linux.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright (c) 2003-2016 Chelsio Communications, Inc. All rights reserved.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * This software is available to you under a choice of one of two
762306a36Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
862306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
962306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the
1062306a36Sopenharmony_ci * OpenIB.org BSD license below:
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
1362306a36Sopenharmony_ci *     without modification, are permitted provided that the following
1462306a36Sopenharmony_ci *     conditions are met:
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci *      - Redistributions of source code must retain the above
1762306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
1862306a36Sopenharmony_ci *        disclaimer.
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
2162306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
2262306a36Sopenharmony_ci *        disclaimer in the documentation and/or other materials
2362306a36Sopenharmony_ci *        provided with the distribution.
2462306a36Sopenharmony_ci *
2562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2662306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2762306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2862306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2962306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3062306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3162306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3262306a36Sopenharmony_ci * SOFTWARE.
3362306a36Sopenharmony_ci *
3462306a36Sopenharmony_ci */
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#ifndef __CHCR_CRYPTO_H__
3762306a36Sopenharmony_ci#define __CHCR_CRYPTO_H__
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#define GHASH_BLOCK_SIZE    16
4062306a36Sopenharmony_ci#define GHASH_DIGEST_SIZE   16
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define CCM_B0_SIZE             16
4362306a36Sopenharmony_ci#define CCM_AAD_FIELD_SIZE      2
4462306a36Sopenharmony_ci// 511 - 16(For IV)
4562306a36Sopenharmony_ci#define T6_MAX_AAD_SIZE 495
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci/* Define following if h/w is not dropping the AAD and IV data before
4962306a36Sopenharmony_ci * giving the processed data
5062306a36Sopenharmony_ci */
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#define CHCR_CRA_PRIORITY 500
5362306a36Sopenharmony_ci#define CHCR_AEAD_PRIORITY 6000
5462306a36Sopenharmony_ci#define CHCR_AES_MAX_KEY_LEN  (2 * (AES_MAX_KEY_SIZE)) /* consider xts */
5562306a36Sopenharmony_ci#define CHCR_MAX_CRYPTO_IV_LEN 16 /* AES IV len */
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#define CHCR_MAX_AUTHENC_AES_KEY_LEN 32 /* max aes key length*/
5862306a36Sopenharmony_ci#define CHCR_MAX_AUTHENC_SHA_KEY_LEN 128 /* max sha key length*/
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#define CHCR_GIVENCRYPT_OP 2
6162306a36Sopenharmony_ci/* CPL/SCMD parameters */
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define CHCR_ENCRYPT_OP 0
6462306a36Sopenharmony_ci#define CHCR_DECRYPT_OP 1
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci#define CHCR_SCMD_SEQ_NO_CTRL_32BIT     1
6762306a36Sopenharmony_ci#define CHCR_SCMD_SEQ_NO_CTRL_48BIT     2
6862306a36Sopenharmony_ci#define CHCR_SCMD_SEQ_NO_CTRL_64BIT     3
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci#define CHCR_SCMD_PROTO_VERSION_GENERIC 4
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_CTRL_AUTH_CIPHER 0
7362306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_CTRL_CIPHER_AUTH 1
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_NOP               0
7662306a36Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_AES_CBC           1
7762306a36Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_AES_GCM           2
7862306a36Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_AES_CTR           3
7962306a36Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_GENERIC_AES       4
8062306a36Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_AES_XTS           6
8162306a36Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_AES_CCM           7
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_NOP             0
8462306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA1            1
8562306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA224          2
8662306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA256          3
8762306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_GHASH           4
8862306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA512_224      5
8962306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA512_256      6
9062306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA512_384      7
9162306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA512_512      8
9262306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_CBCMAC          9
9362306a36Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_CMAC            10
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_NOP             0
9662306a36Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_NO_TRUNC        1
9762306a36Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_TRUNC_RFC4366   2
9862306a36Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_IPSEC_96BIT     3
9962306a36Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_PL1		    4
10062306a36Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_PL2		    5
10162306a36Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_PL3		    6
10262306a36Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_DIV2	    7
10362306a36Sopenharmony_ci#define VERIFY_HW 0
10462306a36Sopenharmony_ci#define VERIFY_SW 1
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci#define CHCR_SCMD_IVGEN_CTRL_HW             0
10762306a36Sopenharmony_ci#define CHCR_SCMD_IVGEN_CTRL_SW             1
10862306a36Sopenharmony_ci/* This are not really mac key size. They are intermediate values
10962306a36Sopenharmony_ci * of sha engine and its size
11062306a36Sopenharmony_ci */
11162306a36Sopenharmony_ci#define CHCR_KEYCTX_MAC_KEY_SIZE_128        0
11262306a36Sopenharmony_ci#define CHCR_KEYCTX_MAC_KEY_SIZE_160        1
11362306a36Sopenharmony_ci#define CHCR_KEYCTX_MAC_KEY_SIZE_192        2
11462306a36Sopenharmony_ci#define CHCR_KEYCTX_MAC_KEY_SIZE_256        3
11562306a36Sopenharmony_ci#define CHCR_KEYCTX_MAC_KEY_SIZE_512        4
11662306a36Sopenharmony_ci#define CHCR_KEYCTX_CIPHER_KEY_SIZE_128     0
11762306a36Sopenharmony_ci#define CHCR_KEYCTX_CIPHER_KEY_SIZE_192     1
11862306a36Sopenharmony_ci#define CHCR_KEYCTX_CIPHER_KEY_SIZE_256     2
11962306a36Sopenharmony_ci#define CHCR_KEYCTX_NO_KEY                  15
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci#define CHCR_CPL_FW4_PLD_IV_OFFSET          (5 * 64) /* bytes. flt #5 and #6 */
12262306a36Sopenharmony_ci#define CHCR_CPL_FW4_PLD_HASH_RESULT_OFFSET (7 * 64) /* bytes. flt #7 */
12362306a36Sopenharmony_ci#define CHCR_CPL_FW4_PLD_DATA_SIZE          (4 * 64) /* bytes. flt #4 to #7 */
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci#define KEY_CONTEXT_HDR_SALT_AND_PAD	    16
12662306a36Sopenharmony_ci#define flits_to_bytes(x)  (x * 8)
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci#define IV_NOP                  0
12962306a36Sopenharmony_ci#define IV_IMMEDIATE            1
13062306a36Sopenharmony_ci#define IV_DSGL			2
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci#define AEAD_H_SIZE             16
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_MASK            0x0f000000
13562306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_HASH_HMAC       0x01000000
13662306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106    0x02000000
13762306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_AEAD_GCM	    0x03000000
13862306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CBC_SHA	    0x04000000
13962306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_AEAD_CCM        0x05000000
14062306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_AEAD_RFC4309    0x06000000
14162306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CBC_NULL	    0x07000000
14262306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CTR             0x08000000
14362306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CTR_RFC3686     0x09000000
14462306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_XTS		    0x0a000000
14562306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CBC		    0x0b000000
14662306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CTR_SHA	    0x0c000000
14762306a36Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CTR_NULL   0x0d000000
14862306a36Sopenharmony_ci#define CRYPTO_ALG_TYPE_HMAC (CRYPTO_ALG_TYPE_AHASH |\
14962306a36Sopenharmony_ci			      CRYPTO_ALG_SUB_TYPE_HASH_HMAC)
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci#define MAX_SCRATCH_PAD_SIZE    32
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci#define CHCR_HASH_MAX_BLOCK_SIZE_64  64
15462306a36Sopenharmony_ci#define CHCR_HASH_MAX_BLOCK_SIZE_128 128
15562306a36Sopenharmony_ci#define CHCR_SRC_SG_SIZE (0x10000 - sizeof(int))
15662306a36Sopenharmony_ci#define CHCR_DST_SG_SIZE 2048
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_cistatic inline struct chcr_context *a_ctx(struct crypto_aead *tfm)
15962306a36Sopenharmony_ci{
16062306a36Sopenharmony_ci	return crypto_aead_ctx(tfm);
16162306a36Sopenharmony_ci}
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_cistatic inline struct chcr_context *c_ctx(struct crypto_skcipher *tfm)
16462306a36Sopenharmony_ci{
16562306a36Sopenharmony_ci	return crypto_skcipher_ctx(tfm);
16662306a36Sopenharmony_ci}
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_cistatic inline struct chcr_context *h_ctx(struct crypto_ahash *tfm)
16962306a36Sopenharmony_ci{
17062306a36Sopenharmony_ci	return crypto_tfm_ctx(crypto_ahash_tfm(tfm));
17162306a36Sopenharmony_ci}
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_cistruct ablk_ctx {
17462306a36Sopenharmony_ci	struct crypto_skcipher *sw_cipher;
17562306a36Sopenharmony_ci	__be32 key_ctx_hdr;
17662306a36Sopenharmony_ci	unsigned int enckey_len;
17762306a36Sopenharmony_ci	unsigned char ciph_mode;
17862306a36Sopenharmony_ci	u8 key[CHCR_AES_MAX_KEY_LEN];
17962306a36Sopenharmony_ci	u8 nonce[4];
18062306a36Sopenharmony_ci	u8 rrkey[AES_MAX_KEY_SIZE];
18162306a36Sopenharmony_ci};
18262306a36Sopenharmony_cistruct chcr_aead_reqctx {
18362306a36Sopenharmony_ci	struct	sk_buff	*skb;
18462306a36Sopenharmony_ci	dma_addr_t iv_dma;
18562306a36Sopenharmony_ci	dma_addr_t b0_dma;
18662306a36Sopenharmony_ci	unsigned int b0_len;
18762306a36Sopenharmony_ci	unsigned int op;
18862306a36Sopenharmony_ci	u16 imm;
18962306a36Sopenharmony_ci	u16 verify;
19062306a36Sopenharmony_ci	u16 txqidx;
19162306a36Sopenharmony_ci	u16 rxqidx;
19262306a36Sopenharmony_ci	u8 iv[CHCR_MAX_CRYPTO_IV_LEN + MAX_SCRATCH_PAD_SIZE];
19362306a36Sopenharmony_ci	u8 *scratch_pad;
19462306a36Sopenharmony_ci};
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_cistruct ulptx_walk {
19762306a36Sopenharmony_ci	struct ulptx_sgl *sgl;
19862306a36Sopenharmony_ci	unsigned int nents;
19962306a36Sopenharmony_ci	unsigned int pair_idx;
20062306a36Sopenharmony_ci	unsigned int last_sg_len;
20162306a36Sopenharmony_ci	struct scatterlist *last_sg;
20262306a36Sopenharmony_ci	struct ulptx_sge_pair *pair;
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci};
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_cistruct dsgl_walk {
20762306a36Sopenharmony_ci	unsigned int nents;
20862306a36Sopenharmony_ci	unsigned int last_sg_len;
20962306a36Sopenharmony_ci	struct scatterlist *last_sg;
21062306a36Sopenharmony_ci	struct cpl_rx_phys_dsgl *dsgl;
21162306a36Sopenharmony_ci	struct phys_sge_pairs *to;
21262306a36Sopenharmony_ci};
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_cistruct chcr_gcm_ctx {
21562306a36Sopenharmony_ci	u8 ghash_h[AEAD_H_SIZE];
21662306a36Sopenharmony_ci};
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_cistruct chcr_authenc_ctx {
21962306a36Sopenharmony_ci	u8 dec_rrkey[AES_MAX_KEY_SIZE];
22062306a36Sopenharmony_ci	u8 h_iopad[2 * CHCR_HASH_MAX_DIGEST_SIZE];
22162306a36Sopenharmony_ci	unsigned char auth_mode;
22262306a36Sopenharmony_ci};
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_cistruct __aead_ctx {
22562306a36Sopenharmony_ci	union {
22662306a36Sopenharmony_ci		DECLARE_FLEX_ARRAY(struct chcr_gcm_ctx, gcm);
22762306a36Sopenharmony_ci		DECLARE_FLEX_ARRAY(struct chcr_authenc_ctx, authenc);
22862306a36Sopenharmony_ci	};
22962306a36Sopenharmony_ci};
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_cistruct chcr_aead_ctx {
23262306a36Sopenharmony_ci	__be32 key_ctx_hdr;
23362306a36Sopenharmony_ci	unsigned int enckey_len;
23462306a36Sopenharmony_ci	struct crypto_aead *sw_cipher;
23562306a36Sopenharmony_ci	u8 salt[MAX_SALT];
23662306a36Sopenharmony_ci	u8 key[CHCR_AES_MAX_KEY_LEN];
23762306a36Sopenharmony_ci	u8 nonce[4];
23862306a36Sopenharmony_ci	u16 hmac_ctrl;
23962306a36Sopenharmony_ci	u16 mayverify;
24062306a36Sopenharmony_ci	struct	__aead_ctx ctx[];
24162306a36Sopenharmony_ci};
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_cistruct hmac_ctx {
24462306a36Sopenharmony_ci	struct crypto_shash *base_hash;
24562306a36Sopenharmony_ci	u8 ipad[CHCR_HASH_MAX_BLOCK_SIZE_128];
24662306a36Sopenharmony_ci	u8 opad[CHCR_HASH_MAX_BLOCK_SIZE_128];
24762306a36Sopenharmony_ci};
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_cistruct __crypto_ctx {
25062306a36Sopenharmony_ci	union {
25162306a36Sopenharmony_ci		struct hmac_ctx hmacctx;
25262306a36Sopenharmony_ci		struct ablk_ctx ablkctx;
25362306a36Sopenharmony_ci		struct chcr_aead_ctx aeadctx;
25462306a36Sopenharmony_ci	};
25562306a36Sopenharmony_ci};
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_cistruct chcr_context {
25862306a36Sopenharmony_ci	struct chcr_dev *dev;
25962306a36Sopenharmony_ci	unsigned char rxq_perchan;
26062306a36Sopenharmony_ci	unsigned char txq_perchan;
26162306a36Sopenharmony_ci	unsigned int  ntxq;
26262306a36Sopenharmony_ci	unsigned int  nrxq;
26362306a36Sopenharmony_ci	struct completion cbc_aes_aio_done;
26462306a36Sopenharmony_ci	struct __crypto_ctx crypto_ctx[];
26562306a36Sopenharmony_ci};
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_cistruct chcr_hctx_per_wr {
26862306a36Sopenharmony_ci	struct scatterlist *srcsg;
26962306a36Sopenharmony_ci	struct sk_buff *skb;
27062306a36Sopenharmony_ci	dma_addr_t dma_addr;
27162306a36Sopenharmony_ci	u32 dma_len;
27262306a36Sopenharmony_ci	unsigned int src_ofst;
27362306a36Sopenharmony_ci	unsigned int processed;
27462306a36Sopenharmony_ci	u32 result;
27562306a36Sopenharmony_ci	u8 is_sg_map;
27662306a36Sopenharmony_ci	u8 imm;
27762306a36Sopenharmony_ci	/*Final callback called. Driver cannot rely on nbytes to decide
27862306a36Sopenharmony_ci	 * final call
27962306a36Sopenharmony_ci	 */
28062306a36Sopenharmony_ci	u8 isfinal;
28162306a36Sopenharmony_ci};
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_cistruct chcr_ahash_req_ctx {
28462306a36Sopenharmony_ci	struct chcr_hctx_per_wr hctx_wr;
28562306a36Sopenharmony_ci	u8 *reqbfr;
28662306a36Sopenharmony_ci	u8 *skbfr;
28762306a36Sopenharmony_ci	/* SKB which is being sent to the hardware for processing */
28862306a36Sopenharmony_ci	u64 data_len;  /* Data len till time */
28962306a36Sopenharmony_ci	u16 txqidx;
29062306a36Sopenharmony_ci	u16 rxqidx;
29162306a36Sopenharmony_ci	u8 reqlen;
29262306a36Sopenharmony_ci	u8 partial_hash[CHCR_HASH_MAX_DIGEST_SIZE];
29362306a36Sopenharmony_ci	u8 bfr1[CHCR_HASH_MAX_BLOCK_SIZE_128];
29462306a36Sopenharmony_ci	u8 bfr2[CHCR_HASH_MAX_BLOCK_SIZE_128];
29562306a36Sopenharmony_ci};
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_cistruct chcr_skcipher_req_ctx {
29862306a36Sopenharmony_ci	struct sk_buff *skb;
29962306a36Sopenharmony_ci	struct scatterlist *dstsg;
30062306a36Sopenharmony_ci	unsigned int processed;
30162306a36Sopenharmony_ci	unsigned int last_req_len;
30262306a36Sopenharmony_ci	unsigned int partial_req;
30362306a36Sopenharmony_ci	struct scatterlist *srcsg;
30462306a36Sopenharmony_ci	unsigned int src_ofst;
30562306a36Sopenharmony_ci	unsigned int dst_ofst;
30662306a36Sopenharmony_ci	unsigned int op;
30762306a36Sopenharmony_ci	u16 imm;
30862306a36Sopenharmony_ci	u8 iv[CHCR_MAX_CRYPTO_IV_LEN];
30962306a36Sopenharmony_ci	u8 init_iv[CHCR_MAX_CRYPTO_IV_LEN];
31062306a36Sopenharmony_ci	u16 txqidx;
31162306a36Sopenharmony_ci	u16 rxqidx;
31262306a36Sopenharmony_ci	struct skcipher_request fallback_req;	// keep at the end
31362306a36Sopenharmony_ci};
31462306a36Sopenharmony_ci
31562306a36Sopenharmony_cistruct chcr_alg_template {
31662306a36Sopenharmony_ci	u32 type;
31762306a36Sopenharmony_ci	u32 is_registered;
31862306a36Sopenharmony_ci	union {
31962306a36Sopenharmony_ci		struct skcipher_alg skcipher;
32062306a36Sopenharmony_ci		struct ahash_alg hash;
32162306a36Sopenharmony_ci		struct aead_alg aead;
32262306a36Sopenharmony_ci	} alg;
32362306a36Sopenharmony_ci};
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_citypedef struct sk_buff *(*create_wr_t)(struct aead_request *req,
32662306a36Sopenharmony_ci				       unsigned short qid,
32762306a36Sopenharmony_ci				       int size);
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_civoid chcr_verify_tag(struct aead_request *req, u8 *input, int *err);
33062306a36Sopenharmony_ciint chcr_aead_dma_map(struct device *dev, struct aead_request *req,
33162306a36Sopenharmony_ci		      unsigned short op_type);
33262306a36Sopenharmony_civoid chcr_aead_dma_unmap(struct device *dev, struct aead_request *req,
33362306a36Sopenharmony_ci			 unsigned short op_type);
33462306a36Sopenharmony_civoid chcr_add_aead_dst_ent(struct aead_request *req,
33562306a36Sopenharmony_ci			   struct cpl_rx_phys_dsgl *phys_cpl,
33662306a36Sopenharmony_ci			   unsigned short qid);
33762306a36Sopenharmony_civoid chcr_add_aead_src_ent(struct aead_request *req, struct ulptx_sgl *ulptx);
33862306a36Sopenharmony_civoid chcr_add_cipher_src_ent(struct skcipher_request *req,
33962306a36Sopenharmony_ci			     void *ulptx,
34062306a36Sopenharmony_ci			     struct  cipher_wr_param *wrparam);
34162306a36Sopenharmony_ciint chcr_cipher_dma_map(struct device *dev, struct skcipher_request *req);
34262306a36Sopenharmony_civoid chcr_cipher_dma_unmap(struct device *dev, struct skcipher_request *req);
34362306a36Sopenharmony_civoid chcr_add_cipher_dst_ent(struct skcipher_request *req,
34462306a36Sopenharmony_ci			     struct cpl_rx_phys_dsgl *phys_cpl,
34562306a36Sopenharmony_ci			     struct  cipher_wr_param *wrparam,
34662306a36Sopenharmony_ci			     unsigned short qid);
34762306a36Sopenharmony_civoid chcr_add_hash_src_ent(struct ahash_request *req, struct ulptx_sgl *ulptx,
34862306a36Sopenharmony_ci			   struct hash_wr_param *param);
34962306a36Sopenharmony_ciint chcr_hash_dma_map(struct device *dev, struct ahash_request *req);
35062306a36Sopenharmony_civoid chcr_hash_dma_unmap(struct device *dev, struct ahash_request *req);
35162306a36Sopenharmony_civoid chcr_aead_common_exit(struct aead_request *req);
35262306a36Sopenharmony_ci#endif /* __CHCR_CRYPTO_H__ */
353