Skip to contentSkip to conversation

crypto: add gemini/sl3516 crypto driver

PATCH Superseded Corentin Labbe 5 participants 15 messages May 18, 2021 – May 28, 2021

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Corentin Labbe

author maintainer
#0 lore raw

cover crypto: add gemini/sl3516 crypto driver

The gemini SL3516 SoC has a crypto IP.
This serie had support for it.

Corentin Labbe (5):
db-dinding: crypto: Add DT bindings documentation for sl3516-ce
crypto: Add sl3516 crypto engine
ARM: dts: gemini: add crypto node
ARM: gemini_config: enable sl3516-ce crypto
MAINTAINERS: add gemini crypto sl3516-ce

 .../crypto/cortina,sl3516-crypto.yaml         |  50 ++
 MAINTAINERS                                   |   7 +
 arch/arm/boot/dts/gemini.dtsi                 |   8 +
 arch/arm/configs/gemini_defconfig             |   1 +
 drivers/crypto/Kconfig                        |  19 +
 drivers/crypto/Makefile                       |   1 +
 drivers/crypto/gemini/Makefile                |   2 +
 drivers/crypto/gemini/sl3516-ce-cipher.c      | 388 +++++++++++++
 drivers/crypto/gemini/sl3516-ce-core.c        | 535 ++++++++++++++++++
 drivers/crypto/gemini/sl3516-ce-rng.c         |  61 ++
 drivers/crypto/gemini/sl3516-ce.h             | 349 ++++++++++++
 11 files changed, 1421 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/cortina,sl3516-crypto.yaml
 create mode 100644 drivers/crypto/gemini/Makefile
 create mode 100644 drivers/crypto/gemini/sl3516-ce-cipher.c
 create mode 100644 drivers/crypto/gemini/sl3516-ce-core.c
 create mode 100644 drivers/crypto/gemini/sl3516-ce-rng.c
 create mode 100644 drivers/crypto/gemini/sl3516-ce.h
Signature · 1 line
2.26.3
author maintainer
#1 lore raw

PATCH 1/5 db-dinding: crypto: Add DT bindings documentation for sl3516-ce

This patch adds documentation for Device-Tree bindings for the SL3516-ce cryptographic offloader driver.

---
 .../crypto/cortina,sl3516-crypto.yaml         | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/cortina,sl3516-crypto.yaml
Documentation/devicetree/bindings/crypto/cortina,sl3516-crypto.yaml new file +50 -0
new file mode 100644
index 000000000000..8330b16a07e8
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/crypto/cortina,sl3516-crypto.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SL3516 cryptographic offloader driver
+
+maintainers:
+  - Corentin Labbe <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - cortina,sl3516-crypto
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - resets
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/cortina,gemini-clock.h>
+    #include <dt-bindings/reset/cortina,gemini-reset.h>
+
+    crypto@62000000 {
+        compatible = "cortina,sl3516-crypto";
+        reg = <0x62000000 0x10000>;
+        interrupts = <7 IRQ_TYPE_EDGE_RISING>;
+        resets = <&syscon GEMINI_RESET_SECURITY>;
+        clocks = <&syscon GEMINI_CLK_GATE_SECURITY>;
+    };
Signature · 1 line
2.26.3
author maintainer
#4 lore raw

PATCH 2/5 crypto: Add sl3516 crypto engine

In reply to Corentin Labbe

The cortina/gemini SL3516 SoC has a crypto IP name either (crypto engine/crypto acceleration engine in the datasheet).
It support many algorithms like [AES|DES|3DES][ECB|CBC], SHA1, MD5 and some HMAC.

This patch adds the core files and support for ecb(aes) and the RNG.

---
 drivers/crypto/Kconfig                   |  19 +
 drivers/crypto/Makefile                  |   1 +
 drivers/crypto/gemini/Makefile           |   2 +
 drivers/crypto/gemini/sl3516-ce-cipher.c | 388 ++++++++++++++++
 drivers/crypto/gemini/sl3516-ce-core.c   | 535 +++++++++++++++++++++++
 drivers/crypto/gemini/sl3516-ce-rng.c    |  61 +++
 drivers/crypto/gemini/sl3516-ce.h        | 349 +++++++++++++++
 7 files changed, 1355 insertions(+)
 create mode 100644 drivers/crypto/gemini/Makefile
 create mode 100644 drivers/crypto/gemini/sl3516-ce-cipher.c
 create mode 100644 drivers/crypto/gemini/sl3516-ce-core.c
 create mode 100644 drivers/crypto/gemini/sl3516-ce-rng.c
 create mode 100644 drivers/crypto/gemini/sl3516-ce.h
drivers/crypto/Kconfig +19 -0
index 1d5b342e6b42..99b090790178 100644
@@ -266,6 +266,25 @@ config CRYPTO_DEV_NIAGARA2
 	  Group, which can perform encryption, decryption, hashing,
 	  checksumming, and raw copies.
 
+config CRYPTO_DEV_SL3516
+	tristate "Stormlink SL3516 crypto offloader"
+	select CRYPTO_SKCIPHER
+	select CRYPTO_ENGINE
+	select CRYPTO_ECB
+	select CRYPTO_AES
+	select HW_RANDOM
+	help
+	  This option allows you to have support for SL3516 crypto offloader.
+
+config CRYPTO_DEV_SL3516_DEBUG
+	bool "Enable SL3516 stats"
+	depends on CRYPTO_DEV_SL3516
+	depends on DEBUG_FS
+	help
+	  Say y to enable SL3516 debug stats.
+	  This will create /sys/kernel/debug/sl3516/stats for displaying
+	  the number of requests per algorithm and other internal stats.
+
 config CRYPTO_DEV_HIFN_795X
 	tristate "Driver HIFN 795x crypto accelerator chips"
 	select CRYPTO_LIB_DES
drivers/crypto/Makefile +1 -0
index fa22cb19e242..1fe5120eb966 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_CRYPTO_DEV_ROCKCHIP) += rockchip/
 obj-$(CONFIG_CRYPTO_DEV_S5P) += s5p-sss.o
 obj-$(CONFIG_CRYPTO_DEV_SA2UL) += sa2ul.o
 obj-$(CONFIG_CRYPTO_DEV_SAHARA) += sahara.o
+obj-$(CONFIG_CRYPTO_DEV_SL3516) += gemini/
 obj-$(CONFIG_ARCH_STM32) += stm32/
 obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o
 obj-$(CONFIG_CRYPTO_DEV_UX500) += ux500/
drivers/crypto/gemini/Makefile new file +2 -0
new file mode 100644
index 000000000000..c73c8b69260d
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CRYPTO_DEV_SL3516) += sl3516-ce.o
+sl3516-ce-y += sl3516-ce-core.o sl3516-ce-cipher.o sl3516-ce-rng.o
drivers/crypto/gemini/sl3516-ce-cipher.c new file +388 -0

388 lines not on this page · raw message

drivers/crypto/gemini/sl3516-ce-core.c new file +535 -0

535 lines not on this page · raw message

drivers/crypto/gemini/sl3516-ce-rng.c new file +61 -0

61 lines not on this page · raw message

drivers/crypto/gemini/sl3516-ce.h new file +349 -0

349 lines not on this page · raw message

Signature · 1 line
2.26.3
author maintainer
#7 lore raw

PATCH 3/5 ARM: dts: gemini: add crypto node

In reply to Corentin Labbe

The SL3516 SoC has a crypto offloader IP.
This patch adds it on the gemini SoC Device-tree.

---
 arch/arm/boot/dts/gemini.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/gemini.dtsi +8 -0
index 6e043869d495..cf4b081c13d9 100644
@@ -356,6 +356,14 @@ gmac1: ethernet-port@1 {
 			};
 		};
 
+		crypto: crypto@62000000 {
+			compatible = "cortina,sl3516-crypto";
+			reg = <0x62000000 0x10000>;
+			interrupts = <7 IRQ_TYPE_EDGE_RISING>;
+			resets = <&syscon GEMINI_RESET_SECURITY>;
+			clocks = <&syscon GEMINI_CLK_GATE_SECURITY>;
+		};
+
 		ide0: ide@63000000 {
 			compatible = "cortina,gemini-pata", "faraday,ftide010";
 			reg = <0x63000000 0x1000>;
Signature · 1 line
2.26.3
author maintainer
#9 lore raw

PATCH 4/5 ARM: gemini_config: enable sl3516-ce crypto

In reply to Corentin Labbe

Enable the crypto offloader by default.

---
 arch/arm/configs/gemini_defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/configs/gemini_defconfig +1 -0
index d2d5f1cf815f..3ae4b8f62b82 100644
@@ -100,3 +100,4 @@ CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ISO8859_1=y
 # CONFIG_ENABLE_MUST_CHECK is not set
 CONFIG_DEBUG_FS=y
+CONFIG_CRYPTO_DEV_SL3516=y
Signature · 1 line
2.26.3
author maintainer
#11 lore raw

PATCH 5/5 MAINTAINERS: add gemini crypto sl3516-ce

In reply to Corentin Labbe

Add myself as maintainer of gemini sl3516-ce crypto driver. Add also the driver to the list of files for gemini SoC.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index c59e8d6a3862..2d5495e21d0a 100644
@@ -1811,6 +1811,7 @@ F:	Documentation/devicetree/bindings/net/cortina,gemini-ethernet.txt
 F:	Documentation/devicetree/bindings/pinctrl/cortina,gemini-pinctrl.txt
 F:	Documentation/devicetree/bindings/rtc/faraday,ftrtc010.txt
 F:	arch/arm/mach-gemini/
+F:	drivers/crypto/gemini/
 F:	drivers/net/ethernet/cortina/
 F:	drivers/pinctrl/pinctrl-gemini.c
 F:	drivers/rtc/rtc-ftrtc010.c
@@ -7567,6 +7568,12 @@ M:	Kieran Bingham <[email protected]>
 S:	Supported
 F:	scripts/gdb/
 
+GEMINI CRYPTO DRIVER
+M:	Corentin Labbe <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/crypto/gemini/
+
 GEMTEK FM RADIO RECEIVER DRIVER
 M:	Hans Verkuil <[email protected]>
 L:	[email protected]
Signature · 1 line
2.26.3
Acked-by on v1 2/5
#5 lore raw

Re: [PATCH 2/5] crypto: Add sl3516 crypto engine

In reply to Corentin Labbe
Quoted 8 lines · Corentin Labbe

The cortina/gemini SL3516 SoC has a crypto IP name either (crypto engine/crypto acceleration engine in the datasheet).
It support many algorithms like [AES|DES|3DES][ECB|CBC], SHA1, MD5 and some HMAC.

This patch adds the core files and support for ecb(aes) and the RNG.

I'm not a crypto guy and definitely trust you and the crypto folks with this, but FWIW I am obviously happy about this so:

Yours,
Linus Walleij

#8 lore raw

Re: [PATCH 3/5] ARM: dts: gemini: add crypto node

In reply to Corentin Labbe
Quoted 4 lines · Corentin Labbe

The SL3516 SoC has a crypto offloader IP.
This patch adds it on the gemini SoC Device-tree.

Looks good to me, as soon as the bindings are accepted I will apply this patch to my gemini DTS branch.

Yours,
Linus Walleij

maintainer Reviewed-by
#3 lore raw

Re: [PATCH 1/5] db-dinding: crypto: Add DT bindings documentation for sl3516-ce

In reply to Linus Walleij
Quoted 8 lines · Linus Walleij
Quoted 3 lines · Corentin Labbe

This patch adds documentation for Device-Tree bindings for the SL3516-ce cryptographic offloader driver.

Apart from misspelled subject "db-binding" I don't see any problems so

And try not to say 'dt binding' twice in the subject and 'documentation' is redundant as that's all bindings.

Quoted 1 line
Quoted 3 lines

Yours,
Linus Walleij

author maintainer
#14 lore raw
In reply to Eric Biggers
Quoted 6 lines · Eric Biggers
Quoted 3 lines · Corentin Labbe

The gemini SL3516 SoC has a crypto IP.
This serie had support for it.

Please describe how this was tested.

Sorry I forgot to write it.
It was tested with CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y.
Furthermore, it survives hours and gigs of write/read to a luks2 using xts(ecb-aes-sl3516).

I forgot also to write on performance, which is quite good.
On a luks2 partition (2To with bs=4096), a fsck comes from 14m26(without CE) to 8m48(with CE). So it is really usefull.

With bs=512, the performance is similar with software.

Regards

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#6 lore raw

Re: [PATCH 2/5] crypto: Add sl3516 crypto engine

In reply to Corentin Labbe

drivers/crypto/gemini/sl3516-ce-cipher.c line 110

Quoted 12 lines · Corentin Labbe
drivers/crypto/gemini/sl3516-ce-cipher.c new file +11 -0
+static int sl3516_ce_cipher_fallback(struct skcipher_request *areq)
+{
+	struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
+	struct sl3516_ce_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);
+	struct sl3516_ce_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
+	struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
+	struct sl3516_ce_alg_template *algt;
+	int err;
+
+	algt = container_of(alg, struct sl3516_ce_alg_template, alg.skcipher);
+	algt->stat_fb++;

This fails to build if CRYPTO_DEV_SL3516_DEBUG is off.

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