xref: /openbmc/linux/drivers/crypto/sa2ul.h (revision 2612e3bbc0386368a850140a6c9b990cd496a5ec)
17694b6caSKeerthy /* SPDX-License-Identifier: GPL-2.0 */
27694b6caSKeerthy /*
37694b6caSKeerthy  * K3 SA2UL crypto accelerator driver
47694b6caSKeerthy  *
57694b6caSKeerthy  * Copyright (C) 2018-2020 Texas Instruments Incorporated - http://www.ti.com
67694b6caSKeerthy  *
77694b6caSKeerthy  * Authors:	Keerthy
87694b6caSKeerthy  *		Vitaly Andrianov
97694b6caSKeerthy  *		Tero Kristo
107694b6caSKeerthy  */
117694b6caSKeerthy 
127694b6caSKeerthy #ifndef _K3_SA2UL_
137694b6caSKeerthy #define _K3_SA2UL_
147694b6caSKeerthy 
157694b6caSKeerthy #include <crypto/aes.h>
16a24d22b2SEric Biggers #include <crypto/sha1.h>
17a24d22b2SEric Biggers #include <crypto/sha2.h>
187694b6caSKeerthy 
19b77e34f5SAndrew Davis #define SA_ENGINE_STATUS		0x0008
207694b6caSKeerthy #define SA_ENGINE_ENABLE_CONTROL	0x1000
217694b6caSKeerthy 
227694b6caSKeerthy struct sa_tfm_ctx;
237694b6caSKeerthy /*
247694b6caSKeerthy  * SA_ENGINE_ENABLE_CONTROL register bits
257694b6caSKeerthy  */
267694b6caSKeerthy #define SA_EEC_ENCSS_EN			0x00000001
277694b6caSKeerthy #define SA_EEC_AUTHSS_EN		0x00000002
287694b6caSKeerthy #define SA_EEC_TRNG_EN			0x00000008
297694b6caSKeerthy #define SA_EEC_PKA_EN			0x00000010
307694b6caSKeerthy #define SA_EEC_CTXCACH_EN		0x00000080
317694b6caSKeerthy #define SA_EEC_CPPI_PORT_IN_EN		0x00000200
327694b6caSKeerthy #define SA_EEC_CPPI_PORT_OUT_EN		0x00000800
337694b6caSKeerthy 
347694b6caSKeerthy /*
357694b6caSKeerthy  * Encoding used to identify the typo of crypto operation
367694b6caSKeerthy  * performed on the packet when the packet is returned
377694b6caSKeerthy  * by SA
387694b6caSKeerthy  */
397694b6caSKeerthy #define SA_REQ_SUBTYPE_ENC	0x0001
407694b6caSKeerthy #define SA_REQ_SUBTYPE_DEC	0x0002
417694b6caSKeerthy #define SA_REQ_SUBTYPE_SHIFT	16
427694b6caSKeerthy #define SA_REQ_SUBTYPE_MASK	0xffff
437694b6caSKeerthy 
447694b6caSKeerthy /* Number of 32 bit words in EPIB  */
457694b6caSKeerthy #define SA_DMA_NUM_EPIB_WORDS   4
467694b6caSKeerthy 
477694b6caSKeerthy /* Number of 32 bit words in PS data  */
487694b6caSKeerthy #define SA_DMA_NUM_PS_WORDS     16
497694b6caSKeerthy #define NKEY_SZ			3
507694b6caSKeerthy #define MCI_SZ			27
517694b6caSKeerthy 
527694b6caSKeerthy /*
537694b6caSKeerthy  * Maximum number of simultaeneous security contexts
547694b6caSKeerthy  * supported by the driver
557694b6caSKeerthy  */
567694b6caSKeerthy #define SA_MAX_NUM_CTX	512
577694b6caSKeerthy 
587694b6caSKeerthy /*
597694b6caSKeerthy  * Assumption: CTX size is multiple of 32
607694b6caSKeerthy  */
617694b6caSKeerthy #define SA_CTX_SIZE_TO_DMA_SIZE(ctx_sz) \
627694b6caSKeerthy 		((ctx_sz) ? ((ctx_sz) / 32 - 1) : 0)
637694b6caSKeerthy 
647694b6caSKeerthy #define SA_CTX_ENC_KEY_OFFSET   32
657694b6caSKeerthy #define SA_CTX_ENC_AUX1_OFFSET  64
667694b6caSKeerthy #define SA_CTX_ENC_AUX2_OFFSET  96
677694b6caSKeerthy #define SA_CTX_ENC_AUX3_OFFSET  112
687694b6caSKeerthy #define SA_CTX_ENC_AUX4_OFFSET  128
697694b6caSKeerthy 
707694b6caSKeerthy /* Next Engine Select code in CP_ACE */
717694b6caSKeerthy #define SA_ENG_ID_EM1   2       /* Enc/Dec engine with AES/DEC core */
727694b6caSKeerthy #define SA_ENG_ID_EM2   3       /* Encryption/Decryption enginefor pass 2 */
737694b6caSKeerthy #define SA_ENG_ID_AM1   4       /* Auth. engine with SHA1/MD5/SHA2 core */
747694b6caSKeerthy #define SA_ENG_ID_AM2   5       /*  Authentication engine for pass 2 */
757694b6caSKeerthy #define SA_ENG_ID_OUTPORT2 20   /*  Egress module 2  */
767694b6caSKeerthy 
777694b6caSKeerthy /*
787694b6caSKeerthy  * Command Label Definitions
797694b6caSKeerthy  */
807694b6caSKeerthy #define SA_CMDL_OFFSET_NESC           0      /* Next Engine Select Code */
817694b6caSKeerthy #define SA_CMDL_OFFSET_LABEL_LEN      1      /* Engine Command Label Length */
827694b6caSKeerthy /* 16-bit Length of Data to be processed */
837694b6caSKeerthy #define SA_CMDL_OFFSET_DATA_LEN       2
847694b6caSKeerthy #define SA_CMDL_OFFSET_DATA_OFFSET    4      /* Stat Data Offset */
857694b6caSKeerthy #define SA_CMDL_OFFSET_OPTION_CTRL1   5      /* Option Control Byte 1 */
867694b6caSKeerthy #define SA_CMDL_OFFSET_OPTION_CTRL2   6      /* Option Control Byte 2 */
877694b6caSKeerthy #define SA_CMDL_OFFSET_OPTION_CTRL3   7      /* Option Control Byte 3 */
887694b6caSKeerthy #define SA_CMDL_OFFSET_OPTION_BYTE    8
897694b6caSKeerthy 
907694b6caSKeerthy #define SA_CMDL_HEADER_SIZE_BYTES	8
917694b6caSKeerthy 
927694b6caSKeerthy #define SA_CMDL_OPTION_BYTES_MAX_SIZE     72
937694b6caSKeerthy #define SA_CMDL_MAX_SIZE_BYTES (SA_CMDL_HEADER_SIZE_BYTES + \
947694b6caSKeerthy 				SA_CMDL_OPTION_BYTES_MAX_SIZE)
957694b6caSKeerthy 
967694b6caSKeerthy /* SWINFO word-0 flags */
977694b6caSKeerthy #define SA_SW_INFO_FLAG_EVICT   0x0001
987694b6caSKeerthy #define SA_SW_INFO_FLAG_TEAR    0x0002
997694b6caSKeerthy #define SA_SW_INFO_FLAG_NOPD    0x0004
1007694b6caSKeerthy 
1017694b6caSKeerthy /*
1027694b6caSKeerthy  * This type represents the various packet types to be processed
1037694b6caSKeerthy  * by the PHP engine in SA.
1047694b6caSKeerthy  * It is used to identify the corresponding PHP processing function.
1057694b6caSKeerthy  */
1067694b6caSKeerthy #define SA_CTX_PE_PKT_TYPE_3GPP_AIR    0    /* 3GPP Air Cipher */
1077694b6caSKeerthy #define SA_CTX_PE_PKT_TYPE_SRTP        1    /* SRTP */
1087694b6caSKeerthy #define SA_CTX_PE_PKT_TYPE_IPSEC_AH    2    /* IPSec Authentication Header */
1097694b6caSKeerthy /* IPSec Encapsulating Security Payload */
1107694b6caSKeerthy #define SA_CTX_PE_PKT_TYPE_IPSEC_ESP   3
1117694b6caSKeerthy /* Indicates that it is in data mode, It may not be used by PHP */
1127694b6caSKeerthy #define SA_CTX_PE_PKT_TYPE_NONE        4
1137694b6caSKeerthy #define SA_CTX_ENC_TYPE1_SZ     64      /* Encryption SC with Key only */
1147694b6caSKeerthy #define SA_CTX_ENC_TYPE2_SZ     96      /* Encryption SC with Key and Aux1 */
1157694b6caSKeerthy 
1167694b6caSKeerthy #define SA_CTX_AUTH_TYPE1_SZ    64      /* Auth SC with Key only */
1177694b6caSKeerthy #define SA_CTX_AUTH_TYPE2_SZ    96      /* Auth SC with Key and Aux1 */
1187694b6caSKeerthy /* Size of security context for PHP engine */
1197694b6caSKeerthy #define SA_CTX_PHP_PE_CTX_SZ    64
1207694b6caSKeerthy 
1217694b6caSKeerthy #define SA_CTX_MAX_SZ (64 + SA_CTX_ENC_TYPE2_SZ + SA_CTX_AUTH_TYPE2_SZ)
1227694b6caSKeerthy 
1237694b6caSKeerthy /*
1247694b6caSKeerthy  * Encoding of F/E control in SCCTL
1257694b6caSKeerthy  *  Bit 0-1: Fetch PHP Bytes
1267694b6caSKeerthy  *  Bit 2-3: Fetch Encryption/Air Ciphering Bytes
1277694b6caSKeerthy  *  Bit 4-5: Fetch Authentication Bytes or Encr pass 2
1287694b6caSKeerthy  *  Bit 6-7: Evict PHP Bytes
1297694b6caSKeerthy  *
1307694b6caSKeerthy  *  where   00 = 0 bytes
1317694b6caSKeerthy  *          01 = 64 bytes
1327694b6caSKeerthy  *          10 = 96 bytes
1337694b6caSKeerthy  *          11 = 128 bytes
1347694b6caSKeerthy  */
1357694b6caSKeerthy #define SA_CTX_DMA_SIZE_0       0
1367694b6caSKeerthy #define SA_CTX_DMA_SIZE_64      1
1377694b6caSKeerthy #define SA_CTX_DMA_SIZE_96      2
1387694b6caSKeerthy #define SA_CTX_DMA_SIZE_128     3
1397694b6caSKeerthy 
1407694b6caSKeerthy /*
1417694b6caSKeerthy  * Byte offset of the owner word in SCCTL
1427694b6caSKeerthy  * in the security context
1437694b6caSKeerthy  */
1447694b6caSKeerthy #define SA_CTX_SCCTL_OWNER_OFFSET 0
1457694b6caSKeerthy 
1467694b6caSKeerthy #define SA_CTX_ENC_KEY_OFFSET   32
1477694b6caSKeerthy #define SA_CTX_ENC_AUX1_OFFSET  64
1487694b6caSKeerthy #define SA_CTX_ENC_AUX2_OFFSET  96
1497694b6caSKeerthy #define SA_CTX_ENC_AUX3_OFFSET  112
1507694b6caSKeerthy #define SA_CTX_ENC_AUX4_OFFSET  128
1517694b6caSKeerthy 
1527694b6caSKeerthy #define SA_SCCTL_FE_AUTH_ENC	0x65
1537694b6caSKeerthy #define SA_SCCTL_FE_ENC		0x8D
1547694b6caSKeerthy 
1557694b6caSKeerthy #define SA_ALIGN_MASK		(sizeof(u32) - 1)
1567694b6caSKeerthy #define SA_ALIGNED		__aligned(32)
1577694b6caSKeerthy 
1582dc53d00SKeerthy #define SA_AUTH_SW_CTRL_MD5	1
1592dc53d00SKeerthy #define SA_AUTH_SW_CTRL_SHA1	2
1602dc53d00SKeerthy #define SA_AUTH_SW_CTRL_SHA224	3
1612dc53d00SKeerthy #define SA_AUTH_SW_CTRL_SHA256	4
1622dc53d00SKeerthy #define SA_AUTH_SW_CTRL_SHA384	5
1632dc53d00SKeerthy #define SA_AUTH_SW_CTRL_SHA512	6
1642dc53d00SKeerthy 
1657694b6caSKeerthy /* SA2UL can only handle maximum data size of 64KB */
1667694b6caSKeerthy #define SA_MAX_DATA_SZ		U16_MAX
1677694b6caSKeerthy 
1687694b6caSKeerthy /*
1697694b6caSKeerthy  * SA2UL can provide unpredictable results with packet sizes that fall
1707694b6caSKeerthy  * the following range, so avoid using it.
1717694b6caSKeerthy  */
1727694b6caSKeerthy #define SA_UNSAFE_DATA_SZ_MIN	240
173*a69c5000STero Kristo #define SA_UNSAFE_DATA_SZ_MAX	255
1747694b6caSKeerthy 
1750bc42311SPeter Ujfalusi struct sa_match_data;
1760bc42311SPeter Ujfalusi 
1777694b6caSKeerthy /**
1787694b6caSKeerthy  * struct sa_crypto_data - Crypto driver instance data
1797694b6caSKeerthy  * @base: Base address of the register space
1800bc42311SPeter Ujfalusi  * @soc_data: Pointer to SoC specific data
1817694b6caSKeerthy  * @pdev: Platform device pointer
1827694b6caSKeerthy  * @sc_pool: security context pool
1837694b6caSKeerthy  * @dev: Device pointer
1847694b6caSKeerthy  * @scid_lock: secure context ID lock
1857694b6caSKeerthy  * @sc_id_start: starting index for SC ID
1867694b6caSKeerthy  * @sc_id_end: Ending index for SC ID
1877694b6caSKeerthy  * @sc_id: Security Context ID
1887694b6caSKeerthy  * @ctx_bm: Bitmap to keep track of Security context ID's
1897694b6caSKeerthy  * @ctx: SA tfm context pointer
1907694b6caSKeerthy  * @dma_rx1: Pointer to DMA rx channel for sizes < 256 Bytes
1917694b6caSKeerthy  * @dma_rx2: Pointer to DMA rx channel for sizes > 256 Bytes
1927694b6caSKeerthy  * @dma_tx: Pointer to DMA TX channel
1937694b6caSKeerthy  */
1947694b6caSKeerthy struct sa_crypto_data {
1957694b6caSKeerthy 	void __iomem *base;
1960bc42311SPeter Ujfalusi 	const struct sa_match_data *match_data;
1977694b6caSKeerthy 	struct platform_device	*pdev;
1987694b6caSKeerthy 	struct dma_pool		*sc_pool;
1997694b6caSKeerthy 	struct device *dev;
2007694b6caSKeerthy 	spinlock_t	scid_lock; /* lock for SC-ID allocation */
2017694b6caSKeerthy 	/* Security context data */
2027694b6caSKeerthy 	u16		sc_id_start;
2037694b6caSKeerthy 	u16		sc_id_end;
2047694b6caSKeerthy 	u16		sc_id;
2057694b6caSKeerthy 	unsigned long	ctx_bm[DIV_ROUND_UP(SA_MAX_NUM_CTX,
2067694b6caSKeerthy 				BITS_PER_LONG)];
2077694b6caSKeerthy 	struct sa_tfm_ctx	*ctx;
2087694b6caSKeerthy 	struct dma_chan		*dma_rx1;
2097694b6caSKeerthy 	struct dma_chan		*dma_rx2;
2107694b6caSKeerthy 	struct dma_chan		*dma_tx;
2117694b6caSKeerthy };
2127694b6caSKeerthy 
2137694b6caSKeerthy /**
2147694b6caSKeerthy  * struct sa_cmdl_param_info: Command label parameters info
2157694b6caSKeerthy  * @index: Index of the parameter in the command label format
2167694b6caSKeerthy  * @offset: the offset of the parameter
2177694b6caSKeerthy  * @size: Size of the parameter
2187694b6caSKeerthy  */
2197694b6caSKeerthy struct sa_cmdl_param_info {
2207694b6caSKeerthy 	u16	index;
2217694b6caSKeerthy 	u16	offset;
2227694b6caSKeerthy 	u16	size;
2237694b6caSKeerthy };
2247694b6caSKeerthy 
2257694b6caSKeerthy /* Maximum length of Auxiliary data in 32bit words */
2267694b6caSKeerthy #define SA_MAX_AUX_DATA_WORDS	8
2277694b6caSKeerthy 
2287694b6caSKeerthy /**
2297694b6caSKeerthy  * struct sa_cmdl_upd_info: Command label updation info
2307694b6caSKeerthy  * @flags: flags in command label
2317694b6caSKeerthy  * @submode: Encryption submodes
2327694b6caSKeerthy  * @enc_size: Size of first pass encryption size
2337694b6caSKeerthy  * @enc_size2: Size of second pass encryption size
2347694b6caSKeerthy  * @enc_offset: Encryption payload offset in the packet
2357694b6caSKeerthy  * @enc_iv: Encryption initialization vector for pass2
2367694b6caSKeerthy  * @enc_iv2: Encryption initialization vector for pass2
2377694b6caSKeerthy  * @aad: Associated data
2387694b6caSKeerthy  * @payload: Payload info
2397694b6caSKeerthy  * @auth_size: Authentication size for pass 1
2407694b6caSKeerthy  * @auth_size2: Authentication size for pass 2
2417694b6caSKeerthy  * @auth_offset: Authentication payload offset
2427694b6caSKeerthy  * @auth_iv: Authentication initialization vector
2437694b6caSKeerthy  * @aux_key_info: Authentication aux key information
2447694b6caSKeerthy  * @aux_key: Aux key for authentication
2457694b6caSKeerthy  */
2467694b6caSKeerthy struct sa_cmdl_upd_info {
2477694b6caSKeerthy 	u16	flags;
2487694b6caSKeerthy 	u16	submode;
2497694b6caSKeerthy 	struct sa_cmdl_param_info	enc_size;
2507694b6caSKeerthy 	struct sa_cmdl_param_info	enc_size2;
2517694b6caSKeerthy 	struct sa_cmdl_param_info	enc_offset;
2527694b6caSKeerthy 	struct sa_cmdl_param_info	enc_iv;
2537694b6caSKeerthy 	struct sa_cmdl_param_info	enc_iv2;
2547694b6caSKeerthy 	struct sa_cmdl_param_info	aad;
2557694b6caSKeerthy 	struct sa_cmdl_param_info	payload;
2567694b6caSKeerthy 	struct sa_cmdl_param_info	auth_size;
2577694b6caSKeerthy 	struct sa_cmdl_param_info	auth_size2;
2587694b6caSKeerthy 	struct sa_cmdl_param_info	auth_offset;
2597694b6caSKeerthy 	struct sa_cmdl_param_info	auth_iv;
2607694b6caSKeerthy 	struct sa_cmdl_param_info	aux_key_info;
2617694b6caSKeerthy 	u32				aux_key[SA_MAX_AUX_DATA_WORDS];
2627694b6caSKeerthy };
2637694b6caSKeerthy 
2647694b6caSKeerthy /*
2657694b6caSKeerthy  * Number of 32bit words appended after the command label
2667694b6caSKeerthy  * in PSDATA to identify the crypto request context.
2677694b6caSKeerthy  * word-0: Request type
2687694b6caSKeerthy  * word-1: pointer to request
2697694b6caSKeerthy  */
2707694b6caSKeerthy #define SA_PSDATA_CTX_WORDS 4
2717694b6caSKeerthy 
2727694b6caSKeerthy /* Maximum size of Command label in 32 words */
2737694b6caSKeerthy #define SA_MAX_CMDL_WORDS (SA_DMA_NUM_PS_WORDS - SA_PSDATA_CTX_WORDS)
2747694b6caSKeerthy 
2757694b6caSKeerthy /**
2767694b6caSKeerthy  * struct sa_ctx_info: SA context information
2777694b6caSKeerthy  * @sc: Pointer to security context
2787694b6caSKeerthy  * @sc_phys: Security context physical address that is passed on to SA2UL
2797694b6caSKeerthy  * @sc_id: Security context ID
2807694b6caSKeerthy  * @cmdl_size: Command label size
2817694b6caSKeerthy  * @cmdl: Command label for a particular iteration
2827694b6caSKeerthy  * @cmdl_upd_info: structure holding command label updation info
2837694b6caSKeerthy  * @epib: Extended protocol information block words
2847694b6caSKeerthy  */
2857694b6caSKeerthy struct sa_ctx_info {
2867694b6caSKeerthy 	u8		*sc;
2877694b6caSKeerthy 	dma_addr_t	sc_phys;
2887694b6caSKeerthy 	u16		sc_id;
2897694b6caSKeerthy 	u16		cmdl_size;
2907694b6caSKeerthy 	u32		cmdl[SA_MAX_CMDL_WORDS];
2917694b6caSKeerthy 	struct sa_cmdl_upd_info cmdl_upd_info;
2927694b6caSKeerthy 	/* Store Auxiliary data such as K2/K3 subkeys in AES-XCBC */
2937694b6caSKeerthy 	u32		epib[SA_DMA_NUM_EPIB_WORDS];
2947694b6caSKeerthy };
2957694b6caSKeerthy 
2967694b6caSKeerthy /**
2977694b6caSKeerthy  * struct sa_tfm_ctx: TFM context structure
2987694b6caSKeerthy  * @dev_data: struct sa_crypto_data pointer
2997694b6caSKeerthy  * @enc: struct sa_ctx_info for encryption
3007694b6caSKeerthy  * @dec: struct sa_ctx_info for decryption
3017694b6caSKeerthy  * @keylen: encrption/decryption keylength
3027694b6caSKeerthy  * @iv_idx: Initialization vector index
3037694b6caSKeerthy  * @key: encryption key
3047694b6caSKeerthy  * @fallback: SW fallback algorithm
3057694b6caSKeerthy  */
3067694b6caSKeerthy struct sa_tfm_ctx {
3077694b6caSKeerthy 	struct sa_crypto_data *dev_data;
3087694b6caSKeerthy 	struct sa_ctx_info enc;
3097694b6caSKeerthy 	struct sa_ctx_info dec;
3102dc53d00SKeerthy 	struct sa_ctx_info auth;
3117694b6caSKeerthy 	int keylen;
3127694b6caSKeerthy 	int iv_idx;
3137694b6caSKeerthy 	u32 key[AES_KEYSIZE_256 / sizeof(u32)];
3142dc53d00SKeerthy 	u8 authkey[SHA512_BLOCK_SIZE];
3152dc53d00SKeerthy 	struct crypto_shash	*shash;
3167694b6caSKeerthy 	/* for fallback */
3177694b6caSKeerthy 	union {
318ad0bb4e4SHerbert Xu 		struct crypto_skcipher		*skcipher;
3192dc53d00SKeerthy 		struct crypto_ahash		*ahash;
320d2c8ac18SKeerthy 		struct crypto_aead		*aead;
3217694b6caSKeerthy 	} fallback;
3227694b6caSKeerthy };
3237694b6caSKeerthy 
3242dc53d00SKeerthy /**
3252dc53d00SKeerthy  * struct sa_sha_req_ctx: Structure used for sha request
3262dc53d00SKeerthy  * @dev_data: struct sa_crypto_data pointer
3272dc53d00SKeerthy  * @cmdl: Complete command label with psdata and epib included
3282dc53d00SKeerthy  * @fallback_req: SW fallback request container
3292dc53d00SKeerthy  */
3302dc53d00SKeerthy struct sa_sha_req_ctx {
3312dc53d00SKeerthy 	struct sa_crypto_data	*dev_data;
3322dc53d00SKeerthy 	u32			cmdl[SA_MAX_CMDL_WORDS + SA_PSDATA_CTX_WORDS];
3332dc53d00SKeerthy 	struct ahash_request	fallback_req;
3342dc53d00SKeerthy };
3352dc53d00SKeerthy 
3367694b6caSKeerthy enum sa_submode {
3377694b6caSKeerthy 	SA_MODE_GEN = 0,
3387694b6caSKeerthy 	SA_MODE_CCM,
3397694b6caSKeerthy 	SA_MODE_GCM,
3407694b6caSKeerthy 	SA_MODE_GMAC
3417694b6caSKeerthy };
3427694b6caSKeerthy 
3437694b6caSKeerthy /* Encryption algorithms */
3447694b6caSKeerthy enum sa_ealg_id {
3457694b6caSKeerthy 	SA_EALG_ID_NONE = 0,        /* No encryption */
3467694b6caSKeerthy 	SA_EALG_ID_NULL,            /* NULL encryption */
3477694b6caSKeerthy 	SA_EALG_ID_AES_CTR,         /* AES Counter mode */
3487694b6caSKeerthy 	SA_EALG_ID_AES_F8,          /* AES F8 mode */
3497694b6caSKeerthy 	SA_EALG_ID_AES_CBC,         /* AES CBC mode */
3507694b6caSKeerthy 	SA_EALG_ID_DES_CBC,         /* DES CBC mode */
3517694b6caSKeerthy 	SA_EALG_ID_3DES_CBC,        /* 3DES CBC mode */
3527694b6caSKeerthy 	SA_EALG_ID_CCM,             /* Counter with CBC-MAC mode */
3537694b6caSKeerthy 	SA_EALG_ID_GCM,             /* Galois Counter mode */
3547694b6caSKeerthy 	SA_EALG_ID_AES_ECB,
3557694b6caSKeerthy 	SA_EALG_ID_LAST
3567694b6caSKeerthy };
3577694b6caSKeerthy 
3587694b6caSKeerthy /* Authentication algorithms */
3597694b6caSKeerthy enum sa_aalg_id {
3607694b6caSKeerthy 	SA_AALG_ID_NONE = 0,      /* No Authentication  */
3617694b6caSKeerthy 	SA_AALG_ID_NULL = SA_EALG_ID_LAST, /* NULL Authentication  */
3627694b6caSKeerthy 	SA_AALG_ID_MD5,           /* MD5 mode */
3637694b6caSKeerthy 	SA_AALG_ID_SHA1,          /* SHA1 mode */
3647694b6caSKeerthy 	SA_AALG_ID_SHA2_224,      /* 224-bit SHA2 mode */
3657694b6caSKeerthy 	SA_AALG_ID_SHA2_256,      /* 256-bit SHA2 mode */
3667694b6caSKeerthy 	SA_AALG_ID_SHA2_512,      /* 512-bit SHA2 mode */
3677694b6caSKeerthy 	SA_AALG_ID_HMAC_MD5,      /* HMAC with MD5 mode */
3687694b6caSKeerthy 	SA_AALG_ID_HMAC_SHA1,     /* HMAC with SHA1 mode */
3697694b6caSKeerthy 	SA_AALG_ID_HMAC_SHA2_224, /* HMAC with 224-bit SHA2 mode */
3707694b6caSKeerthy 	SA_AALG_ID_HMAC_SHA2_256, /* HMAC with 256-bit SHA2 mode */
3717694b6caSKeerthy 	SA_AALG_ID_GMAC,          /* Galois Message Auth. Code mode */
3727694b6caSKeerthy 	SA_AALG_ID_CMAC,          /* Cipher-based Mes. Auth. Code mode */
3737694b6caSKeerthy 	SA_AALG_ID_CBC_MAC,       /* Cipher Block Chaining */
3747694b6caSKeerthy 	SA_AALG_ID_AES_XCBC       /* AES Extended Cipher Block Chaining */
3757694b6caSKeerthy };
3767694b6caSKeerthy 
3777694b6caSKeerthy /*
3787694b6caSKeerthy  * Mode control engine algorithms used to index the
3797694b6caSKeerthy  * mode control instruction tables
3807694b6caSKeerthy  */
3817694b6caSKeerthy enum sa_eng_algo_id {
3827694b6caSKeerthy 	SA_ENG_ALGO_ECB = 0,
3837694b6caSKeerthy 	SA_ENG_ALGO_CBC,
3847694b6caSKeerthy 	SA_ENG_ALGO_CFB,
3857694b6caSKeerthy 	SA_ENG_ALGO_OFB,
3867694b6caSKeerthy 	SA_ENG_ALGO_CTR,
3877694b6caSKeerthy 	SA_ENG_ALGO_F8,
3887694b6caSKeerthy 	SA_ENG_ALGO_F8F9,
3897694b6caSKeerthy 	SA_ENG_ALGO_GCM,
3907694b6caSKeerthy 	SA_ENG_ALGO_GMAC,
3917694b6caSKeerthy 	SA_ENG_ALGO_CCM,
3927694b6caSKeerthy 	SA_ENG_ALGO_CMAC,
3937694b6caSKeerthy 	SA_ENG_ALGO_CBCMAC,
3947694b6caSKeerthy 	SA_NUM_ENG_ALGOS
3957694b6caSKeerthy };
3967694b6caSKeerthy 
3977694b6caSKeerthy /**
3987694b6caSKeerthy  * struct sa_eng_info: Security accelerator engine info
3997694b6caSKeerthy  * @eng_id: Engine ID
4007694b6caSKeerthy  * @sc_size: security context size
4017694b6caSKeerthy  */
4027694b6caSKeerthy struct sa_eng_info {
4037694b6caSKeerthy 	u8	eng_id;
4047694b6caSKeerthy 	u16	sc_size;
4057694b6caSKeerthy };
4067694b6caSKeerthy 
4077694b6caSKeerthy #endif /* _K3_SA2UL_ */
408