Add Broadcom SPU Crypto Driver
Subsystems (2)
v3 cover Add Broadcom SPU Crypto Driver
Changes in v3:
- rebase to 4.10-rc3 in cryptodev-2.6 tree
- in bindings doc, list all valid compatibility strings
- rename DT nodes "crypto" rather than "spu-crypto"
- include a separate DT node for each SPU hardware block. Previously, there was a single SPU node listing a register range for each hw block.
- select hash algos in Kconfig. Driver HMAC implementation uses hash sw algos for inner and outer hashes.
- Fix crash for AES CCM decrypt when AAD and data are both empty
Change in v2:
- select CRYPTO_DES in Kconfig
The Broadcom SPU crypto driver provides access to SPU hardware for symmetric crypto offload. The driver supports ablkcipher, ahash, and aead operations. The driver supports several Broadcom SoCs with different revisions of the SPU hardware. The driver supports SPU-M and SPU2 hardware revisions, and a couple versions of each hw revision, each version with minor differences.
Rob Rice (3):
crypto: brcm: DT documentation for Broadcom SPU hardware
crypto: brcm: Add Broadcom SPU driver
arm64: dts: ns2: Add Broadcom SPU driver DT entry.
.../devicetree/bindings/crypto/brcm,spu-crypto.txt | 22 + arch/arm64/boot/dts/broadcom/ns2.dtsi | 24 + drivers/crypto/Kconfig | 15 + drivers/crypto/Makefile | 2 + drivers/crypto/bcm/Makefile | 15 + drivers/crypto/bcm/cipher.c | 4955 ++++++++++++++++++++ drivers/crypto/bcm/cipher.h | 475 ++ drivers/crypto/bcm/spu.c | 1252 +++++ drivers/crypto/bcm/spu.h | 288 ++ drivers/crypto/bcm/spu2.c | 1402 ++++++ drivers/crypto/bcm/spu2.h | 228 + drivers/crypto/bcm/spum.h | 174 + drivers/crypto/bcm/util.c | 581 +++ drivers/crypto/bcm/util.h | 116 + 14 files changed, 9549 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/brcm,spu-crypto.txt create mode 100644 drivers/crypto/bcm/Makefile create mode 100644 drivers/crypto/bcm/cipher.c create mode 100644 drivers/crypto/bcm/cipher.h create mode 100644 drivers/crypto/bcm/spu.c create mode 100644 drivers/crypto/bcm/spu.h create mode 100644 drivers/crypto/bcm/spu2.c create mode 100644 drivers/crypto/bcm/spu2.h create mode 100644 drivers/crypto/bcm/spum.h create mode 100644 drivers/crypto/bcm/util.c create mode 100644 drivers/crypto/bcm/util.h
Signature · 1 line
2.1.0
PATCH v3 1/3 crypto: brcm: DT documentation for Broadcom SPU hardware
Device tree documentation for Broadcom Secure Processing Unit (SPU) crypto hardware.
--- .../devicetree/bindings/crypto/brcm,spu-crypto.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/brcm,spu-crypto.txt
Documentation/devicetree/bindings/crypto/brcm,spu-crypto.txt new file +22 -0
@@ -0,0 +1,22 @@ +The Broadcom Secure Processing Unit (SPU) hardware supports symmetric +cryptographic offload for Broadcom SoCs. A SoC may have multiple SPU hardware +blocks. + +Required properties: +- compatible: Should be one of the following: + brcm,spum-crypto - for devices with SPU-M hardware + brcm,spu2-crypto - for devices with SPU2 hardware + brcm,spu2-v2-crypto - for devices with enhanced SPU2 hardware features like SHA3 + and Rabin Fingerprint support + brcm,spum-nsp-crypto - for the Northstar Plus variant of the SPU-M hardware + +- reg: Should contain SPU registers location and length. +- mboxes: The mailbox channel to be used to communicate with the SPU. + Mailbox channels correspond to DMA rings on the device. + +Example: + crypto at 612d0000 { + compatible = "brcm,spum-crypto"; + reg = <0 0x612d0000 0 0x900>; + mboxes = <&pdc0 0>; + };
Signature · 1 line
2.1.0
Re: [PATCH v3 1/3] crypto: brcm: DT documentation for Broadcom SPU hardware
Quoted 9 lines · Rob Rice
Device tree documentation for Broadcom Secure Processing Unit (SPU) crypto hardware.
Signed-off-by Steve Lin <[email protected]>Signed-off-by Rob Rice <[email protected]>--- .../devicetree/bindings/crypto/brcm,spu-crypto.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/brcm,spu-crypto.txt
PATCH v3 2/3 crypto: brcm: Add Broadcom SPU driver
In reply to Rob RiceAdd Broadcom Secure Processing Unit (SPU) crypto driver for SPU hardware crypto offload. The driver supports ablkcipher, ahash, and aead symmetric crypto operations.
--- drivers/crypto/Kconfig | 15 + drivers/crypto/Makefile | 2 + drivers/crypto/bcm/Makefile | 15 + drivers/crypto/bcm/cipher.c | 4955 +++++++++++++++++++++++++++++++++++++++++++ drivers/crypto/bcm/cipher.h | 475 +++++ drivers/crypto/bcm/spu.c | 1252 +++++++++++ drivers/crypto/bcm/spu.h | 288 +++ drivers/crypto/bcm/spu2.c | 1402 ++++++++++++ drivers/crypto/bcm/spu2.h | 228 ++ drivers/crypto/bcm/spum.h | 174 ++ drivers/crypto/bcm/util.c | 581 +++++ drivers/crypto/bcm/util.h | 116 + 12 files changed, 9503 insertions(+) create mode 100644 drivers/crypto/bcm/Makefile create mode 100644 drivers/crypto/bcm/cipher.c create mode 100644 drivers/crypto/bcm/cipher.h create mode 100644 drivers/crypto/bcm/spu.c create mode 100644 drivers/crypto/bcm/spu.h create mode 100644 drivers/crypto/bcm/spu2.c create mode 100644 drivers/crypto/bcm/spu2.h create mode 100644 drivers/crypto/bcm/spum.h create mode 100644 drivers/crypto/bcm/util.c create mode 100644 drivers/crypto/bcm/util.h
drivers/crypto/Kconfig +15 -0
@@ -571,4 +571,19 @@ source "drivers/crypto/chelsio/Kconfig" source "drivers/crypto/virtio/Kconfig" +config CRYPTO_DEV_BCM_SPU + tristate "Broadcom symmetric crypto/hash acceleration support" + depends on ARCH_BCM_IPROC + depends on BCM_PDC_MBOX + default m + select CRYPTO_DES + select CRYPTO_MD5 + select CRYPTO_SHA1 + select CRYPTO_SHA256 + select CRYPTO_SHA512 + help + This driver provides support for Broadcom crypto acceleration using the + Secure Processing Unit (SPU). The SPU driver registers ablkcipher, + ahash, and aead algorithms with the kernel cryptographic API. + endif # CRYPTO_HW
drivers/crypto/Makefile +2 -0
@@ -34,3 +34,5 @@ obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o obj-$(CONFIG_CRYPTO_DEV_UX500) += ux500/ obj-$(CONFIG_CRYPTO_DEV_VIRTIO) += virtio/ obj-$(CONFIG_CRYPTO_DEV_VMX) += vmx/ +obj-$(CONFIG_CRYPTO_DEV_BCM_SPU) += bcm/ +
drivers/crypto/bcm/Makefile new file +15 -0
@@ -0,0 +1,15 @@ +# File: drivers/crypto/bcm/Makefile +# +# Makefile for crypto acceleration files for Broadcom SPU driver +# +# Uncomment to enable debug tracing in the SPU driver. +# CFLAGS_util.o := -DDEBUG +# CFLAGS_cipher.o := -DDEBUG +# CFLAGS_spu.o := -DDEBUG +# CFLAGS_spu2.o := -DDEBUG + +obj-$(CONFIG_CRYPTO_DEV_BCM_SPU) := bcm_crypto_spu.o + +bcm_crypto_spu-objs := util.o spu.o spu2.o cipher.o + +ccflags-y += -I. -DBCMDRIVER
drivers/crypto/bcm/cipher.c new file +4955 -0
2,961 lines not on this page · raw message
drivers/crypto/bcm/cipher.h new file +475 -0
475 lines not on this page · raw message
drivers/crypto/bcm/spu.c new file +1252 -0
1,252 lines not on this page · raw message
drivers/crypto/bcm/spu.h new file +288 -0
288 lines not on this page · raw message
drivers/crypto/bcm/spu2.c new file +1402 -0
1,402 lines not on this page · raw message
drivers/crypto/bcm/spu2.h new file +228 -0
228 lines not on this page · raw message
drivers/crypto/bcm/spum.h new file +174 -0
174 lines not on this page · raw message
drivers/crypto/bcm/util.c new file +581 -0
581 lines not on this page · raw message
drivers/crypto/bcm/util.h new file +116 -0
116 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Part of the diff is not shown here. View the raw message.
Herbert Xu
maintainerRe: [PATCH v3 2/3] crypto: brcm: Add Broadcom SPU driver
drivers/crypto/bcm/cipher.c line 2404
Quoted 8 lines · Rob Rice
drivers/crypto/bcm/cipher.c new file +7
-0+static int ahash_export (struct ahash_request *req,void *out) +{ +const struct iproc_reqctx_s *rctx =ahash_request_ctx (req); + +memcpy (out, rctx, offsetof(struct iproc_reqctx_s , msg_buf)); +return 0 ; +}
The reqctx data structure seems to contain a lot of info unrelated to the hash state. Can't we get away with just copying the hash state (incr_hash) itself?
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH v3 2/3] crypto: brcm: Add Broadcom SPU driver
Herbert,
Quoted 15 lines · Herbert Xu
drivers/crypto/bcm/cipher.c line 2404
Quoted 8 lines · Rob Rice
drivers/crypto/bcm/cipher.c new file +7
-0+static int ahash_export (struct ahash_request *req,void *out) +{ +const struct iproc_reqctx_s *rctx =ahash_request_ctx (req); + +memcpy (out, rctx, offsetof(struct iproc_reqctx_s , msg_buf)); +return 0 ; +}The reqctx data structure seems to contain a lot of info unrelated to the hash state. Can't we get away with just copying the hash state (
incr_hash) itself?
Yes, I see your point. I?ll whittle the export state down to just what?s needed for the hash.
Quoted 6 lines
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
PATCH v3 3/3 arm64: dts: ns2: Add Broadcom SPU driver DT entry.
In reply to Rob RiceAdd Northstar2 device tree entry for Broadcom Secure Processing Unit (SPU) crypto hardware.
--- arch/arm64/boot/dts/broadcom/ns2.dtsi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/arm64/boot/dts/broadcom/ns2.dtsi +24 -0
@@ -218,6 +218,12 @@ brcm,use-bcm-hdr; }; + crypto0: crypto at 612d0000 { + compatible = "brcm,spum-crypto"; + reg = <0x612d0000 0x900>; + mboxes = <&pdc0 0>; + }; + pdc1: iproc-pdc1 at 612e0000 { compatible = "brcm,iproc-pdc-mbox"; reg = <0x612e0000 0x445>; /* PDC FS1 regs */
@@ -227,6 +233,12 @@ brcm,use-bcm-hdr; }; + crypto1: crypto at 612f0000 { + compatible = "brcm,spum-crypto"; + reg = <0x612f0000 0x900>; + mboxes = <&pdc1 0>; + }; + pdc2: iproc-pdc2 at 61300000 { compatible = "brcm,iproc-pdc-mbox"; reg = <0x61300000 0x445>; /* PDC FS2 regs */
@@ -236,6 +248,12 @@ brcm,use-bcm-hdr; }; + crypto2: crypto at 61310000 { + compatible = "brcm,spum-crypto"; + reg = <0x61310000 0x900>; + mboxes = <&pdc2 0>; + }; + pdc3: iproc-pdc3 at 61320000 { compatible = "brcm,iproc-pdc-mbox"; reg = <0x61320000 0x445>; /* PDC FS3 regs */
@@ -245,6 +263,12 @@ brcm,use-bcm-hdr; }; + crypto3: crypto at 61330000 { + compatible = "brcm,spum-crypto"; + reg = <0x61330000 0x900>; + mboxes = <&pdc3 0>; + }; + dma0: dma at 61360000 { compatible = "arm,pl330", "arm,primecell"; reg = <0x61360000 0x1000>;
Signature · 1 line
2.1.0
Quoted 14 lines · Rob Rice
Changes in v3:
- rebase to 4.10-rc3 in cryptodev-2.6 tree
- in bindings doc, list all valid compatibility strings
- rename DT nodes "crypto" rather than "spu-crypto"
- include a separate DT node for each SPU hardware block. Previously, there was a single SPU node listing a register range for each hw block.
- select hash algos inKconfig. Driver HMAC implementation uses hash sw algos for inner and outer hashes.
- Fix crash for AES CCM decrypt when AAD and data are both emptyChange in v2:
- selectCRYPTO_DESinKconfig
Quoted 7 lines
The Broadcom SPU crypto driver provides access to SPU hardware for symmetric crypto offload. The driver supports ablkcipher, ahash, and aead operations. The driver supports several Broadcom SoCs with different revisions of the SPU hardware. The driver supports SPU-M and SPU2 hardware revisions, and a couple versions of each hw revision, each version with minor differences.
Herbert, can you take patches 1-2, and I will take patch 3 through my arm64-soc git pull requests? Thanks!!
Quoted 33 lines
Rob Rice (3):
crypto: brcm: DT documentation for Broadcom SPU hardware
crypto: brcm: Add Broadcom SPU driver
arm64: dts: ns2: Add Broadcom SPU driver DT entry..../devicetree/bindings/crypto/brcm,spu-crypto.txt | 22 + arch/arm64/boot/dts/broadcom/ns2.dtsi | 24 + drivers/crypto/Kconfig | 15 + drivers/crypto/Makefile | 2 + drivers/crypto/bcm/Makefile | 15 + drivers/crypto/bcm/cipher.c | 4955 ++++++++++++++++++++ drivers/crypto/bcm/cipher.h | 475 ++ drivers/crypto/bcm/spu.c | 1252 +++++ drivers/crypto/bcm/spu.h | 288 ++ drivers/crypto/bcm/spu2.c | 1402 ++++++ drivers/crypto/bcm/spu2.h | 228 + drivers/crypto/bcm/spum.h | 174 + drivers/crypto/bcm/util.c | 581 +++ drivers/crypto/bcm/util.h | 116 + 14 files changed, 9549 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/brcm,spu-crypto.txt create mode 100644 drivers/crypto/bcm/Makefile create mode 100644 drivers/crypto/bcm/cipher.c create mode 100644 drivers/crypto/bcm/cipher.h create mode 100644 drivers/crypto/bcm/spu.c create mode 100644 drivers/crypto/bcm/spu.h create mode 100644 drivers/crypto/bcm/spu2.c create mode 100644 drivers/crypto/bcm/spu2.h create mode 100644 drivers/crypto/bcm/spum.h create mode 100644 drivers/crypto/bcm/util.c create mode 100644 drivers/crypto/bcm/util.h
Signature · 1 line
Florian