Skip to contentSkip to conversation

crypto: add gemini/sl3516 crypto driver

PATCH In review Corentin Labbe 2 participants 7 messages Jun 1, 2021 – Jun 11, 2021

Subsystems (5)
lore
Share & tools
lore

Corentin Labbe

author maintainer
#0 lore raw

v2 cover crypto: add gemini/sl3516 crypto driver

The gemini SL3516 SoC has a crypto IP.
This serie had support for 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).

Performance 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.

Changes since v1:
- reworded dt-binding subject patch
- fixed build with CRYPTO_DEV_SL3516_DEBUG

Corentin Labbe (5):
dt-bindings: crypto: Add 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             | 347 ++++++++++++
 11 files changed, 1419 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.31.1
author maintainer
#1 lore raw

PATCH v2 1/5 dt-bindings: crypto: Add 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.31.1
author maintainer
#2 lore raw

PATCH v2 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        | 347 +++++++++++++++
 7 files changed, 1353 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 +347 -0

347 lines not on this page · raw message

Signature · 1 line
2.31.1
author maintainer
#3 lore raw

PATCH v2 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.31.1
author maintainer
#4 lore raw

PATCH v2 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.31.1
author maintainer
#5 lore raw

PATCH v2 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 d8648ee43199..439e353539de 100644
@@ -1812,6 +1812,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
@@ -7589,6 +7590,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.31.1
maintainer
#6 lore raw
In reply to Corentin Labbe
Quoted 33 lines · Corentin Labbe

The gemini SL3516 SoC has a crypto IP.
This serie had support for 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).

Performance 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.

Changes since v1:
- reworded dt-binding subject patch
- fixed build with CRYPTO_DEV_SL3516_DEBUG

Corentin Labbe (5):
dt-bindings: crypto: Add 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 ++
Quoted 8 lines
 drivers/crypto/gemini/sl3516-ce.h             | 347 ++++++++++++
 11 files changed, 1419 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

Patches 1,2,5 applied. Thanks.

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