diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-23 09:54:19 -0800 | 
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-23 09:54:19 -0800 | 
| commit | 5bcbe22ca47da04cda3a858cef67f55b550c1d13 (patch) | |
| tree | 49bd61e32eb2d652085a49182436322a3e0e9840 /drivers/crypto/bcm/spum.h | |
| parent | 1db934a5b77a9e37c4742c704fde6af233187a98 (diff) | |
| parent | 12cb3a1c4184f891d965d1f39f8cfcc9ef617647 (diff) | |
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu:
 "API:
   - Try to catch hash output overrun in testmgr
   - Introduce walksize attribute for batched walking
   - Make crypto_xor() and crypto_inc() alignment agnostic
  Algorithms:
   - Add time-invariant AES algorithm
   - Add standalone CBCMAC algorithm
  Drivers:
   - Add NEON acclerated chacha20 on ARM/ARM64
   - Expose AES-CTR as synchronous skcipher on ARM64
   - Add scalar AES implementation on ARM64
   - Improve scalar AES implementation on ARM
   - Improve NEON AES implementation on ARM/ARM64
   - Merge CRC32 and PMULL instruction based drivers on ARM64
   - Add NEON acclerated CBCMAC/CMAC/XCBC AES on ARM64
   - Add IPsec AUTHENC implementation in atmel
   - Add Support for Octeon-tx CPT Engine
   - Add Broadcom SPU driver
   - Add MediaTek driver"
* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (142 commits)
  crypto: xts - Add ECB dependency
  crypto: cavium - switch to pci_alloc_irq_vectors
  crypto: cavium - switch to pci_alloc_irq_vectors
  crypto: cavium - remove dead MSI-X related define
  crypto: brcm - Avoid double free in ahash_finup()
  crypto: cavium - fix Kconfig dependencies
  crypto: cavium - cpt_bind_vq_to_grp could return an error code
  crypto: doc - fix typo
  hwrng: omap - update Kconfig help description
  crypto: ccm - drop unnecessary minimum 32-bit alignment
  crypto: ccm - honour alignmask of subordinate MAC cipher
  crypto: caam - fix state buffer DMA (un)mapping
  crypto: caam - abstract ahash request double buffering
  crypto: caam - fix error path for ctx_dma mapping failure
  crypto: caam - fix DMA API leaks for multiple setkey() calls
  crypto: caam - don't dma_map key for hash algorithms
  crypto: caam - use dma_map_sg() return code
  crypto: caam - replace sg_count() with sg_nents_for_len()
  crypto: caam - check sg_count() return value
  crypto: caam - fix HW S/G in ablkcipher_giv_edesc_alloc()
  ..
Diffstat (limited to 'drivers/crypto/bcm/spum.h')
| -rw-r--r-- | drivers/crypto/bcm/spum.h | 174 | 
1 files changed, 174 insertions, 0 deletions
| diff --git a/drivers/crypto/bcm/spum.h b/drivers/crypto/bcm/spum.h new file mode 100644 index 000000000000..d0a5b5828638 --- /dev/null +++ b/drivers/crypto/bcm/spum.h @@ -0,0 +1,174 @@ +/* + * Copyright 2016 Broadcom + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation (the "GPL"). + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. + */ + +/* + * This file contains SPU message definitions specific to SPU-M. + */ + +#ifndef _SPUM_H_ +#define _SPUM_H_ + +#define SPU_CRYPTO_OPERATION_GENERIC	0x1 + +/* Length of STATUS field in tx and rx packets */ +#define SPU_TX_STATUS_LEN  4 + +/* SPU-M error codes */ +#define SPU_STATUS_MASK                 0x0000FF00 +#define SPU_STATUS_SUCCESS              0x00000000 +#define SPU_STATUS_INVALID_ICV          0x00000100 + +#define SPU_STATUS_ERROR_FLAG           0x00020000 + +/* Request message. MH + EMH + BDESC + BD header */ +#define SPU_REQ_FIXED_LEN 24 + +/* + * Max length of a SPU message header. Used to allocate a buffer where + * the SPU message header is constructed. Can be used for either a SPU-M + * header or a SPU2 header. + * For SPU-M, sum of the following: + *    MH - 4 bytes + *    EMH - 4 + *    SCTX - 3 + + *      max auth key len - 64 + *      max cipher key len - 264 (RC4) + *      max IV len - 16 + *    BDESC - 12 + *    BD header - 4 + * Total:  371 + * + * For SPU2, FMD_SIZE (32) plus lengths of hash and cipher keys, + * hash and cipher IVs. If SPU2 does not support RC4, then + */ +#define SPU_HEADER_ALLOC_LEN  (SPU_REQ_FIXED_LEN + MAX_KEY_SIZE + \ +				MAX_KEY_SIZE + MAX_IV_SIZE) + +/* + * Response message header length. Normally MH, EMH, BD header, but when + * BD_SUPPRESS is used for hash requests, there is no BD header. + */ +#define SPU_RESP_HDR_LEN 12 +#define SPU_HASH_RESP_HDR_LEN 8 + +/* + * Max value that can be represented in the Payload Length field of the BD + * header. This is a 16-bit field. + */ +#define SPUM_NS2_MAX_PAYLOAD  (BIT(16) - 1) + +/* + * NSP SPU is limited to ~9KB because of FA2 FIFO size limitations; + * Set MAX_PAYLOAD to 8k to allow for addition of header, digest, etc. + * and stay within limitation. + */ + +#define SPUM_NSP_MAX_PAYLOAD	8192 + +/* Buffer Descriptor Header [BDESC]. SPU in big-endian mode. */ +struct BDESC_HEADER { +	u16 offset_mac;		/* word 0 [31-16] */ +	u16 length_mac;		/* word 0 [15-0]  */ +	u16 offset_crypto;	/* word 1 [31-16] */ +	u16 length_crypto;	/* word 1 [15-0]  */ +	u16 offset_icv;		/* word 2 [31-16] */ +	u16 offset_iv;		/* word 2 [15-0]  */ +}; + +/* Buffer Data Header [BD]. SPU in big-endian mode. */ +struct BD_HEADER { +	u16 size; +	u16 prev_length; +}; + +/* Command Context Header. SPU-M in big endian mode. */ +struct MHEADER { +	u8 flags;	/* [31:24] */ +	u8 op_code;	/* [23:16] */ +	u16 reserved;	/* [15:0] */ +}; + +/* MH header flags bits */ +#define MH_SUPDT_PRES   BIT(0) +#define MH_HASH_PRES    BIT(2) +#define MH_BD_PRES      BIT(3) +#define MH_MFM_PRES     BIT(4) +#define MH_BDESC_PRES   BIT(5) +#define MH_SCTX_PRES	BIT(7) + +/* SCTX word 0 bit offsets and fields masks */ +#define SCTX_SIZE               0x000000FF + +/* SCTX word 1 bit shifts and field masks */ +#define  UPDT_OFST              0x000000FF   /* offset of SCTX updateable fld */ +#define  HASH_TYPE              0x00000300   /* hash alg operation type */ +#define  HASH_TYPE_SHIFT                 8 +#define  HASH_MODE              0x00001C00   /* one of spu2_hash_mode */ +#define  HASH_MODE_SHIFT                10 +#define  HASH_ALG               0x0000E000   /* hash algorithm */ +#define  HASH_ALG_SHIFT                 13 +#define  CIPHER_TYPE            0x00030000   /* encryption operation type */ +#define  CIPHER_TYPE_SHIFT              16 +#define  CIPHER_MODE            0x001C0000   /* encryption mode */ +#define  CIPHER_MODE_SHIFT              18 +#define  CIPHER_ALG             0x00E00000   /* encryption algo */ +#define  CIPHER_ALG_SHIFT               21 +#define  ICV_IS_512                BIT(27) +#define  ICV_IS_512_SHIFT		27 +#define  CIPHER_ORDER               BIT(30) +#define  CIPHER_ORDER_SHIFT             30 +#define  CIPHER_INBOUND             BIT(31) +#define  CIPHER_INBOUND_SHIFT           31 + +/* SCTX word 2 bit shifts and field masks */ +#define  EXP_IV_SIZE                   0x7 +#define  IV_OFFSET                   BIT(3) +#define  IV_OFFSET_SHIFT                 3 +#define  GEN_IV                      BIT(5) +#define  GEN_IV_SHIFT                    5 +#define  EXPLICIT_IV                 BIT(6) +#define  EXPLICIT_IV_SHIFT               6 +#define  SCTX_IV                     BIT(7) +#define  SCTX_IV_SHIFT                   7 +#define  ICV_SIZE                   0x0F00 +#define  ICV_SIZE_SHIFT                  8 +#define  CHECK_ICV                  BIT(12) +#define  CHECK_ICV_SHIFT                12 +#define  INSERT_ICV                 BIT(13) +#define  INSERT_ICV_SHIFT               13 +#define  BD_SUPPRESS                BIT(19) +#define  BD_SUPPRESS_SHIFT              19 + +/* Generic Mode Security Context Structure [SCTX] */ +struct SCTX { +/* word 0: protocol flags */ +	u32 proto_flags; + +/* word 1: cipher flags */ +	u32 cipher_flags; + +/* word 2: Extended cipher flags */ +	u32 ecf; + +}; + +struct SPUHEADER { +	struct MHEADER mh; +	u32 emh; +	struct SCTX sa; +}; + +#endif /* _SPUM_H_ */ | 
