18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This file is part of the Chelsio T6 Crypto driver for Linux.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (c) 2003-2016 Chelsio Communications, Inc. All rights reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
78c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
88c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
98c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the
108c2ecf20Sopenharmony_ci * OpenIB.org BSD license below:
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
138c2ecf20Sopenharmony_ci *     without modification, are permitted provided that the following
148c2ecf20Sopenharmony_ci *     conditions are met:
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci *      - Redistributions of source code must retain the above
178c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
188c2ecf20Sopenharmony_ci *        disclaimer.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
218c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
228c2ecf20Sopenharmony_ci *        disclaimer in the documentation and/or other materials
238c2ecf20Sopenharmony_ci *        provided with the distribution.
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
268c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
278c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
288c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
298c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
308c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
318c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
328c2ecf20Sopenharmony_ci * SOFTWARE.
338c2ecf20Sopenharmony_ci *
348c2ecf20Sopenharmony_ci */
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#ifndef __CHCR_CRYPTO_H__
378c2ecf20Sopenharmony_ci#define __CHCR_CRYPTO_H__
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define GHASH_BLOCK_SIZE    16
408c2ecf20Sopenharmony_ci#define GHASH_DIGEST_SIZE   16
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define CCM_B0_SIZE             16
438c2ecf20Sopenharmony_ci#define CCM_AAD_FIELD_SIZE      2
448c2ecf20Sopenharmony_ci// 511 - 16(For IV)
458c2ecf20Sopenharmony_ci#define T6_MAX_AAD_SIZE 495
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/* Define following if h/w is not dropping the AAD and IV data before
498c2ecf20Sopenharmony_ci * giving the processed data
508c2ecf20Sopenharmony_ci */
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define CHCR_CRA_PRIORITY 500
538c2ecf20Sopenharmony_ci#define CHCR_AEAD_PRIORITY 6000
548c2ecf20Sopenharmony_ci#define CHCR_AES_MAX_KEY_LEN  (2 * (AES_MAX_KEY_SIZE)) /* consider xts */
558c2ecf20Sopenharmony_ci#define CHCR_MAX_CRYPTO_IV_LEN 16 /* AES IV len */
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define CHCR_MAX_AUTHENC_AES_KEY_LEN 32 /* max aes key length*/
588c2ecf20Sopenharmony_ci#define CHCR_MAX_AUTHENC_SHA_KEY_LEN 128 /* max sha key length*/
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci#define CHCR_GIVENCRYPT_OP 2
618c2ecf20Sopenharmony_ci/* CPL/SCMD parameters */
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#define CHCR_ENCRYPT_OP 0
648c2ecf20Sopenharmony_ci#define CHCR_DECRYPT_OP 1
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define CHCR_SCMD_SEQ_NO_CTRL_32BIT     1
678c2ecf20Sopenharmony_ci#define CHCR_SCMD_SEQ_NO_CTRL_48BIT     2
688c2ecf20Sopenharmony_ci#define CHCR_SCMD_SEQ_NO_CTRL_64BIT     3
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci#define CHCR_SCMD_PROTO_VERSION_GENERIC 4
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_CTRL_AUTH_CIPHER 0
738c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_CTRL_CIPHER_AUTH 1
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_NOP               0
768c2ecf20Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_AES_CBC           1
778c2ecf20Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_AES_GCM           2
788c2ecf20Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_AES_CTR           3
798c2ecf20Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_GENERIC_AES       4
808c2ecf20Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_AES_XTS           6
818c2ecf20Sopenharmony_ci#define CHCR_SCMD_CIPHER_MODE_AES_CCM           7
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_NOP             0
848c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA1            1
858c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA224          2
868c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA256          3
878c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_GHASH           4
888c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA512_224      5
898c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA512_256      6
908c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA512_384      7
918c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_SHA512_512      8
928c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_CBCMAC          9
938c2ecf20Sopenharmony_ci#define CHCR_SCMD_AUTH_MODE_CMAC            10
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_NOP             0
968c2ecf20Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_NO_TRUNC        1
978c2ecf20Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_TRUNC_RFC4366   2
988c2ecf20Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_IPSEC_96BIT     3
998c2ecf20Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_PL1		    4
1008c2ecf20Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_PL2		    5
1018c2ecf20Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_PL3		    6
1028c2ecf20Sopenharmony_ci#define CHCR_SCMD_HMAC_CTRL_DIV2	    7
1038c2ecf20Sopenharmony_ci#define VERIFY_HW 0
1048c2ecf20Sopenharmony_ci#define VERIFY_SW 1
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci#define CHCR_SCMD_IVGEN_CTRL_HW             0
1078c2ecf20Sopenharmony_ci#define CHCR_SCMD_IVGEN_CTRL_SW             1
1088c2ecf20Sopenharmony_ci/* This are not really mac key size. They are intermediate values
1098c2ecf20Sopenharmony_ci * of sha engine and its size
1108c2ecf20Sopenharmony_ci */
1118c2ecf20Sopenharmony_ci#define CHCR_KEYCTX_MAC_KEY_SIZE_128        0
1128c2ecf20Sopenharmony_ci#define CHCR_KEYCTX_MAC_KEY_SIZE_160        1
1138c2ecf20Sopenharmony_ci#define CHCR_KEYCTX_MAC_KEY_SIZE_192        2
1148c2ecf20Sopenharmony_ci#define CHCR_KEYCTX_MAC_KEY_SIZE_256        3
1158c2ecf20Sopenharmony_ci#define CHCR_KEYCTX_MAC_KEY_SIZE_512        4
1168c2ecf20Sopenharmony_ci#define CHCR_KEYCTX_CIPHER_KEY_SIZE_128     0
1178c2ecf20Sopenharmony_ci#define CHCR_KEYCTX_CIPHER_KEY_SIZE_192     1
1188c2ecf20Sopenharmony_ci#define CHCR_KEYCTX_CIPHER_KEY_SIZE_256     2
1198c2ecf20Sopenharmony_ci#define CHCR_KEYCTX_NO_KEY                  15
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#define CHCR_CPL_FW4_PLD_IV_OFFSET          (5 * 64) /* bytes. flt #5 and #6 */
1228c2ecf20Sopenharmony_ci#define CHCR_CPL_FW4_PLD_HASH_RESULT_OFFSET (7 * 64) /* bytes. flt #7 */
1238c2ecf20Sopenharmony_ci#define CHCR_CPL_FW4_PLD_DATA_SIZE          (4 * 64) /* bytes. flt #4 to #7 */
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci#define KEY_CONTEXT_HDR_SALT_AND_PAD	    16
1268c2ecf20Sopenharmony_ci#define flits_to_bytes(x)  (x * 8)
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci#define IV_NOP                  0
1298c2ecf20Sopenharmony_ci#define IV_IMMEDIATE            1
1308c2ecf20Sopenharmony_ci#define IV_DSGL			2
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#define AEAD_H_SIZE             16
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_MASK            0x0f000000
1358c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_HASH_HMAC       0x01000000
1368c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106    0x02000000
1378c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_AEAD_GCM	    0x03000000
1388c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CBC_SHA	    0x04000000
1398c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_AEAD_CCM        0x05000000
1408c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_AEAD_RFC4309    0x06000000
1418c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CBC_NULL	    0x07000000
1428c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CTR             0x08000000
1438c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CTR_RFC3686     0x09000000
1448c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_XTS		    0x0a000000
1458c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CBC		    0x0b000000
1468c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CTR_SHA	    0x0c000000
1478c2ecf20Sopenharmony_ci#define CRYPTO_ALG_SUB_TYPE_CTR_NULL   0x0d000000
1488c2ecf20Sopenharmony_ci#define CRYPTO_ALG_TYPE_HMAC (CRYPTO_ALG_TYPE_AHASH |\
1498c2ecf20Sopenharmony_ci			      CRYPTO_ALG_SUB_TYPE_HASH_HMAC)
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci#define MAX_SCRATCH_PAD_SIZE    32
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci#define CHCR_HASH_MAX_BLOCK_SIZE_64  64
1548c2ecf20Sopenharmony_ci#define CHCR_HASH_MAX_BLOCK_SIZE_128 128
1558c2ecf20Sopenharmony_ci#define CHCR_SRC_SG_SIZE (0x10000 - sizeof(int))
1568c2ecf20Sopenharmony_ci#define CHCR_DST_SG_SIZE 2048
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_cistatic inline struct chcr_context *a_ctx(struct crypto_aead *tfm)
1598c2ecf20Sopenharmony_ci{
1608c2ecf20Sopenharmony_ci	return crypto_aead_ctx(tfm);
1618c2ecf20Sopenharmony_ci}
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_cistatic inline struct chcr_context *c_ctx(struct crypto_skcipher *tfm)
1648c2ecf20Sopenharmony_ci{
1658c2ecf20Sopenharmony_ci	return crypto_skcipher_ctx(tfm);
1668c2ecf20Sopenharmony_ci}
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_cistatic inline struct chcr_context *h_ctx(struct crypto_ahash *tfm)
1698c2ecf20Sopenharmony_ci{
1708c2ecf20Sopenharmony_ci	return crypto_tfm_ctx(crypto_ahash_tfm(tfm));
1718c2ecf20Sopenharmony_ci}
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_cistruct ablk_ctx {
1748c2ecf20Sopenharmony_ci	struct crypto_skcipher *sw_cipher;
1758c2ecf20Sopenharmony_ci	__be32 key_ctx_hdr;
1768c2ecf20Sopenharmony_ci	unsigned int enckey_len;
1778c2ecf20Sopenharmony_ci	unsigned char ciph_mode;
1788c2ecf20Sopenharmony_ci	u8 key[CHCR_AES_MAX_KEY_LEN];
1798c2ecf20Sopenharmony_ci	u8 nonce[4];
1808c2ecf20Sopenharmony_ci	u8 rrkey[AES_MAX_KEY_SIZE];
1818c2ecf20Sopenharmony_ci};
1828c2ecf20Sopenharmony_cistruct chcr_aead_reqctx {
1838c2ecf20Sopenharmony_ci	struct	sk_buff	*skb;
1848c2ecf20Sopenharmony_ci	dma_addr_t iv_dma;
1858c2ecf20Sopenharmony_ci	dma_addr_t b0_dma;
1868c2ecf20Sopenharmony_ci	unsigned int b0_len;
1878c2ecf20Sopenharmony_ci	unsigned int op;
1888c2ecf20Sopenharmony_ci	u16 imm;
1898c2ecf20Sopenharmony_ci	u16 verify;
1908c2ecf20Sopenharmony_ci	u16 txqidx;
1918c2ecf20Sopenharmony_ci	u16 rxqidx;
1928c2ecf20Sopenharmony_ci	u8 iv[CHCR_MAX_CRYPTO_IV_LEN + MAX_SCRATCH_PAD_SIZE];
1938c2ecf20Sopenharmony_ci	u8 *scratch_pad;
1948c2ecf20Sopenharmony_ci};
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_cistruct ulptx_walk {
1978c2ecf20Sopenharmony_ci	struct ulptx_sgl *sgl;
1988c2ecf20Sopenharmony_ci	unsigned int nents;
1998c2ecf20Sopenharmony_ci	unsigned int pair_idx;
2008c2ecf20Sopenharmony_ci	unsigned int last_sg_len;
2018c2ecf20Sopenharmony_ci	struct scatterlist *last_sg;
2028c2ecf20Sopenharmony_ci	struct ulptx_sge_pair *pair;
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci};
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_cistruct dsgl_walk {
2078c2ecf20Sopenharmony_ci	unsigned int nents;
2088c2ecf20Sopenharmony_ci	unsigned int last_sg_len;
2098c2ecf20Sopenharmony_ci	struct scatterlist *last_sg;
2108c2ecf20Sopenharmony_ci	struct cpl_rx_phys_dsgl *dsgl;
2118c2ecf20Sopenharmony_ci	struct phys_sge_pairs *to;
2128c2ecf20Sopenharmony_ci};
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_cistruct chcr_gcm_ctx {
2158c2ecf20Sopenharmony_ci	u8 ghash_h[AEAD_H_SIZE];
2168c2ecf20Sopenharmony_ci};
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cistruct chcr_authenc_ctx {
2198c2ecf20Sopenharmony_ci	u8 dec_rrkey[AES_MAX_KEY_SIZE];
2208c2ecf20Sopenharmony_ci	u8 h_iopad[2 * CHCR_HASH_MAX_DIGEST_SIZE];
2218c2ecf20Sopenharmony_ci	unsigned char auth_mode;
2228c2ecf20Sopenharmony_ci};
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_cistruct __aead_ctx {
2258c2ecf20Sopenharmony_ci	struct chcr_gcm_ctx gcm[0];
2268c2ecf20Sopenharmony_ci	struct chcr_authenc_ctx authenc[];
2278c2ecf20Sopenharmony_ci};
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_cistruct chcr_aead_ctx {
2308c2ecf20Sopenharmony_ci	__be32 key_ctx_hdr;
2318c2ecf20Sopenharmony_ci	unsigned int enckey_len;
2328c2ecf20Sopenharmony_ci	struct crypto_aead *sw_cipher;
2338c2ecf20Sopenharmony_ci	u8 salt[MAX_SALT];
2348c2ecf20Sopenharmony_ci	u8 key[CHCR_AES_MAX_KEY_LEN];
2358c2ecf20Sopenharmony_ci	u8 nonce[4];
2368c2ecf20Sopenharmony_ci	u16 hmac_ctrl;
2378c2ecf20Sopenharmony_ci	u16 mayverify;
2388c2ecf20Sopenharmony_ci	struct	__aead_ctx ctx[];
2398c2ecf20Sopenharmony_ci};
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_cistruct hmac_ctx {
2428c2ecf20Sopenharmony_ci	struct crypto_shash *base_hash;
2438c2ecf20Sopenharmony_ci	u8 ipad[CHCR_HASH_MAX_BLOCK_SIZE_128];
2448c2ecf20Sopenharmony_ci	u8 opad[CHCR_HASH_MAX_BLOCK_SIZE_128];
2458c2ecf20Sopenharmony_ci};
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_cistruct __crypto_ctx {
2488c2ecf20Sopenharmony_ci	struct hmac_ctx hmacctx[0];
2498c2ecf20Sopenharmony_ci	struct ablk_ctx ablkctx[0];
2508c2ecf20Sopenharmony_ci	struct chcr_aead_ctx aeadctx[];
2518c2ecf20Sopenharmony_ci};
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_cistruct chcr_context {
2548c2ecf20Sopenharmony_ci	struct chcr_dev *dev;
2558c2ecf20Sopenharmony_ci	unsigned char rxq_perchan;
2568c2ecf20Sopenharmony_ci	unsigned char txq_perchan;
2578c2ecf20Sopenharmony_ci	unsigned int  ntxq;
2588c2ecf20Sopenharmony_ci	unsigned int  nrxq;
2598c2ecf20Sopenharmony_ci	struct completion cbc_aes_aio_done;
2608c2ecf20Sopenharmony_ci	struct __crypto_ctx crypto_ctx[];
2618c2ecf20Sopenharmony_ci};
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_cistruct chcr_hctx_per_wr {
2648c2ecf20Sopenharmony_ci	struct scatterlist *srcsg;
2658c2ecf20Sopenharmony_ci	struct sk_buff *skb;
2668c2ecf20Sopenharmony_ci	dma_addr_t dma_addr;
2678c2ecf20Sopenharmony_ci	u32 dma_len;
2688c2ecf20Sopenharmony_ci	unsigned int src_ofst;
2698c2ecf20Sopenharmony_ci	unsigned int processed;
2708c2ecf20Sopenharmony_ci	u32 result;
2718c2ecf20Sopenharmony_ci	u8 is_sg_map;
2728c2ecf20Sopenharmony_ci	u8 imm;
2738c2ecf20Sopenharmony_ci	/*Final callback called. Driver cannot rely on nbytes to decide
2748c2ecf20Sopenharmony_ci	 * final call
2758c2ecf20Sopenharmony_ci	 */
2768c2ecf20Sopenharmony_ci	u8 isfinal;
2778c2ecf20Sopenharmony_ci};
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_cistruct chcr_ahash_req_ctx {
2808c2ecf20Sopenharmony_ci	struct chcr_hctx_per_wr hctx_wr;
2818c2ecf20Sopenharmony_ci	u8 *reqbfr;
2828c2ecf20Sopenharmony_ci	u8 *skbfr;
2838c2ecf20Sopenharmony_ci	/* SKB which is being sent to the hardware for processing */
2848c2ecf20Sopenharmony_ci	u64 data_len;  /* Data len till time */
2858c2ecf20Sopenharmony_ci	u16 txqidx;
2868c2ecf20Sopenharmony_ci	u16 rxqidx;
2878c2ecf20Sopenharmony_ci	u8 reqlen;
2888c2ecf20Sopenharmony_ci	u8 partial_hash[CHCR_HASH_MAX_DIGEST_SIZE];
2898c2ecf20Sopenharmony_ci	u8 bfr1[CHCR_HASH_MAX_BLOCK_SIZE_128];
2908c2ecf20Sopenharmony_ci	u8 bfr2[CHCR_HASH_MAX_BLOCK_SIZE_128];
2918c2ecf20Sopenharmony_ci};
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_cistruct chcr_skcipher_req_ctx {
2948c2ecf20Sopenharmony_ci	struct sk_buff *skb;
2958c2ecf20Sopenharmony_ci	struct scatterlist *dstsg;
2968c2ecf20Sopenharmony_ci	unsigned int processed;
2978c2ecf20Sopenharmony_ci	unsigned int last_req_len;
2988c2ecf20Sopenharmony_ci	unsigned int partial_req;
2998c2ecf20Sopenharmony_ci	struct scatterlist *srcsg;
3008c2ecf20Sopenharmony_ci	unsigned int src_ofst;
3018c2ecf20Sopenharmony_ci	unsigned int dst_ofst;
3028c2ecf20Sopenharmony_ci	unsigned int op;
3038c2ecf20Sopenharmony_ci	u16 imm;
3048c2ecf20Sopenharmony_ci	u8 iv[CHCR_MAX_CRYPTO_IV_LEN];
3058c2ecf20Sopenharmony_ci	u8 init_iv[CHCR_MAX_CRYPTO_IV_LEN];
3068c2ecf20Sopenharmony_ci	u16 txqidx;
3078c2ecf20Sopenharmony_ci	u16 rxqidx;
3088c2ecf20Sopenharmony_ci	struct skcipher_request fallback_req;	// keep at the end
3098c2ecf20Sopenharmony_ci};
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_cistruct chcr_alg_template {
3128c2ecf20Sopenharmony_ci	u32 type;
3138c2ecf20Sopenharmony_ci	u32 is_registered;
3148c2ecf20Sopenharmony_ci	union {
3158c2ecf20Sopenharmony_ci		struct skcipher_alg skcipher;
3168c2ecf20Sopenharmony_ci		struct ahash_alg hash;
3178c2ecf20Sopenharmony_ci		struct aead_alg aead;
3188c2ecf20Sopenharmony_ci	} alg;
3198c2ecf20Sopenharmony_ci};
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_citypedef struct sk_buff *(*create_wr_t)(struct aead_request *req,
3228c2ecf20Sopenharmony_ci				       unsigned short qid,
3238c2ecf20Sopenharmony_ci				       int size);
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_civoid chcr_verify_tag(struct aead_request *req, u8 *input, int *err);
3268c2ecf20Sopenharmony_ciint chcr_aead_dma_map(struct device *dev, struct aead_request *req,
3278c2ecf20Sopenharmony_ci		      unsigned short op_type);
3288c2ecf20Sopenharmony_civoid chcr_aead_dma_unmap(struct device *dev, struct aead_request *req,
3298c2ecf20Sopenharmony_ci			 unsigned short op_type);
3308c2ecf20Sopenharmony_civoid chcr_add_aead_dst_ent(struct aead_request *req,
3318c2ecf20Sopenharmony_ci			   struct cpl_rx_phys_dsgl *phys_cpl,
3328c2ecf20Sopenharmony_ci			   unsigned short qid);
3338c2ecf20Sopenharmony_civoid chcr_add_aead_src_ent(struct aead_request *req, struct ulptx_sgl *ulptx);
3348c2ecf20Sopenharmony_civoid chcr_add_cipher_src_ent(struct skcipher_request *req,
3358c2ecf20Sopenharmony_ci			     void *ulptx,
3368c2ecf20Sopenharmony_ci			     struct  cipher_wr_param *wrparam);
3378c2ecf20Sopenharmony_ciint chcr_cipher_dma_map(struct device *dev, struct skcipher_request *req);
3388c2ecf20Sopenharmony_civoid chcr_cipher_dma_unmap(struct device *dev, struct skcipher_request *req);
3398c2ecf20Sopenharmony_civoid chcr_add_cipher_dst_ent(struct skcipher_request *req,
3408c2ecf20Sopenharmony_ci			     struct cpl_rx_phys_dsgl *phys_cpl,
3418c2ecf20Sopenharmony_ci			     struct  cipher_wr_param *wrparam,
3428c2ecf20Sopenharmony_ci			     unsigned short qid);
3438c2ecf20Sopenharmony_ciint sg_nents_len_skip(struct scatterlist *sg, u64 len, u64 skip);
3448c2ecf20Sopenharmony_civoid chcr_add_hash_src_ent(struct ahash_request *req, struct ulptx_sgl *ulptx,
3458c2ecf20Sopenharmony_ci			   struct hash_wr_param *param);
3468c2ecf20Sopenharmony_ciint chcr_hash_dma_map(struct device *dev, struct ahash_request *req);
3478c2ecf20Sopenharmony_civoid chcr_hash_dma_unmap(struct device *dev, struct ahash_request *req);
3488c2ecf20Sopenharmony_civoid chcr_aead_common_exit(struct aead_request *req);
3498c2ecf20Sopenharmony_ci#endif /* __CHCR_CRYPTO_H__ */
350