aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/inside-secure/safexcel.h
diff options
context:
space:
mode:
authorPascal van Leeuwen <pascalvanl@gmail.com>2019-08-30 03:40:54 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2019-09-05 00:37:01 -0400
commit062b64ca6db409fd6e102aed0fa59716b5cdfd78 (patch)
tree0de1abd004dae25cdab4444ca9557b0b392784f8 /drivers/crypto/inside-secure/safexcel.h
parentc7da38a71cfbb5c0f20f84864a290b9450ad78e9 (diff)
crypto: inside-secure - Only enable algorithms advertised by the hardware
This patch probes the supported algorithms from the hardware and only registers the ones that the hardware actually supports. This is necessary because this is a generic driver supposed to run on a wide variety of engines, which may or may not implement certain algorithms. Signed-off-by: Pascal van Leeuwen <pvanleeuwen@verimatrix.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/inside-secure/safexcel.h')
-rw-r--r--drivers/crypto/inside-secure/safexcel.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/crypto/inside-secure/safexcel.h b/drivers/crypto/inside-secure/safexcel.h
index 0a30a7bf4fe0..b5ff62fa3044 100644
--- a/drivers/crypto/inside-secure/safexcel.h
+++ b/drivers/crypto/inside-secure/safexcel.h
@@ -145,6 +145,7 @@
145#define EIP197_PE_EIP96_FUNCTION_EN(n) (0x1004 + (0x2000 * (n))) 145#define EIP197_PE_EIP96_FUNCTION_EN(n) (0x1004 + (0x2000 * (n)))
146#define EIP197_PE_EIP96_CONTEXT_CTRL(n) (0x1008 + (0x2000 * (n))) 146#define EIP197_PE_EIP96_CONTEXT_CTRL(n) (0x1008 + (0x2000 * (n)))
147#define EIP197_PE_EIP96_CONTEXT_STAT(n) (0x100c + (0x2000 * (n))) 147#define EIP197_PE_EIP96_CONTEXT_STAT(n) (0x100c + (0x2000 * (n)))
148#define EIP197_PE_EIP96_OPTIONS(n) (0x13f8 + (0x2000 * (n)))
148#define EIP197_PE_OUT_DBUF_THRES(n) (0x1c00 + (0x2000 * (n))) 149#define EIP197_PE_OUT_DBUF_THRES(n) (0x1c00 + (0x2000 * (n)))
149#define EIP197_PE_OUT_TBUF_THRES(n) (0x1d00 + (0x2000 * (n))) 150#define EIP197_PE_OUT_TBUF_THRES(n) (0x1d00 + (0x2000 * (n)))
150#define EIP197_MST_CTRL 0xfff4 151#define EIP197_MST_CTRL 0xfff4
@@ -597,6 +598,32 @@ enum safexcel_eip_version {
597 EIP197_DEVBRD 598 EIP197_DEVBRD
598}; 599};
599 600
601/* EIP algorithm presence flags */
602enum safexcel_eip_algorithms {
603 SAFEXCEL_ALG_BC0 = BIT(5),
604 SAFEXCEL_ALG_SM4 = BIT(6),
605 SAFEXCEL_ALG_SM3 = BIT(7),
606 SAFEXCEL_ALG_CHACHA20 = BIT(8),
607 SAFEXCEL_ALG_POLY1305 = BIT(9),
608 SAFEXCEL_SEQMASK_256 = BIT(10),
609 SAFEXCEL_SEQMASK_384 = BIT(11),
610 SAFEXCEL_ALG_AES = BIT(12),
611 SAFEXCEL_ALG_AES_XFB = BIT(13),
612 SAFEXCEL_ALG_DES = BIT(15),
613 SAFEXCEL_ALG_DES_XFB = BIT(16),
614 SAFEXCEL_ALG_ARC4 = BIT(18),
615 SAFEXCEL_ALG_AES_XTS = BIT(20),
616 SAFEXCEL_ALG_WIRELESS = BIT(21),
617 SAFEXCEL_ALG_MD5 = BIT(22),
618 SAFEXCEL_ALG_SHA1 = BIT(23),
619 SAFEXCEL_ALG_SHA2_256 = BIT(25),
620 SAFEXCEL_ALG_SHA2_512 = BIT(26),
621 SAFEXCEL_ALG_XCBC_MAC = BIT(27),
622 SAFEXCEL_ALG_CBC_MAC_ALL = BIT(29),
623 SAFEXCEL_ALG_GHASH = BIT(30),
624 SAFEXCEL_ALG_SHA3 = BIT(31),
625};
626
600struct safexcel_register_offsets { 627struct safexcel_register_offsets {
601 u32 hia_aic; 628 u32 hia_aic;
602 u32 hia_aic_g; 629 u32 hia_aic_g;
@@ -614,6 +641,10 @@ enum safexcel_flags {
614 EIP197_TRC_CACHE = BIT(0), 641 EIP197_TRC_CACHE = BIT(0),
615}; 642};
616 643
644struct safexcel_hwconfig {
645 enum safexcel_eip_algorithms algo_flags;
646};
647
617struct safexcel_crypto_priv { 648struct safexcel_crypto_priv {
618 void __iomem *base; 649 void __iomem *base;
619 struct device *dev; 650 struct device *dev;
@@ -623,6 +654,7 @@ struct safexcel_crypto_priv {
623 654
624 enum safexcel_eip_version version; 655 enum safexcel_eip_version version;
625 struct safexcel_register_offsets offsets; 656 struct safexcel_register_offsets offsets;
657 struct safexcel_hwconfig hwconfig;
626 u32 flags; 658 u32 flags;
627 659
628 /* context DMA pool */ 660 /* context DMA pool */
@@ -667,6 +699,7 @@ struct safexcel_ahash_export_state {
667struct safexcel_alg_template { 699struct safexcel_alg_template {
668 struct safexcel_crypto_priv *priv; 700 struct safexcel_crypto_priv *priv;
669 enum safexcel_alg_type type; 701 enum safexcel_alg_type type;
702 enum safexcel_eip_algorithms algo_mask;
670 union { 703 union {
671 struct skcipher_alg skcipher; 704 struct skcipher_alg skcipher;
672 struct aead_alg aead; 705 struct aead_alg aead;