Skip to contentSkip to conversation

crypto: Add Keem Bay OCS AES/SM4 driver

PATCH In review Daniele Alessandrelli 3 participants 5 messages Nov 26, 2020 – Dec 11, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover crypto: Add Keem Bay OCS AES/SM4 driver

The Intel Keem Bay SoC has an Offload Crypto Subsystem (OCS) featuring a crypto engine for accelerating AES/SM4 operations.

This driver adds support for such hardware thus enabling hardware acceleration for the following transformations on the Intel Keem Bay SoC:

- ecb(aes), cbc(aes), ctr(aes), cts(cbc(aes)), gcm(aes) and cbc(aes); supported for 128-bit and 256-bit keys.

- ecb(sm4), cbc(sm4), ctr(sm4), cts(cbc(sm4)), gcm(sm4) and cbc(sm4); supported for 128-bit keys.

The driver passes crypto manager self-tests, including the extra tests (CRYPTO_MANAGER_EXTRA_TESTS=y).

Note: this driver is different from the Keem Bay OCS HCU driver previously submitted. Keem Bay OCS HCU provides hardware-accelerated ahash, while Keem Bay AES/SM4 (i.e., this driver) provides hardware-accelerated skcipher and aead.

Daniele Alessandrelli (1):
dt-bindings: Add Keem Bay OCS AES bindings

Mike Healy (1):
crypto: keembay-ocs-aes: Add support for Keem Bay OCS AES/SM4

 .../crypto/intel,keembay-ocs-aes.yaml         |   45 +
 MAINTAINERS                                   |   10 +
 drivers/crypto/Kconfig                        |    2 +
 drivers/crypto/Makefile                       |    1 +
 drivers/crypto/keembay/Kconfig                |   39 +
 drivers/crypto/keembay/Makefile               |    5 +
 drivers/crypto/keembay/keembay-ocs-aes-core.c | 1713 +++++++++++++++++
 drivers/crypto/keembay/ocs-aes.c              | 1489 ++++++++++++++
 drivers/crypto/keembay/ocs-aes.h              |  129 ++
 9 files changed, 3433 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/intel,keembay-ocs-aes.yaml
 create mode 100644 drivers/crypto/keembay/Kconfig
 create mode 100644 drivers/crypto/keembay/Makefile
 create mode 100644 drivers/crypto/keembay/keembay-ocs-aes-core.c
 create mode 100644 drivers/crypto/keembay/ocs-aes.c
 create mode 100644 drivers/crypto/keembay/ocs-aes.h

base-commit: c3a98c3ad5c0dc60a1ac66bf91147a3f39cac96b

Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/2 dt-bindings: Add Keem Bay OCS AES bindings

From: Daniele Alessandrelli <[email protected]>

Add device-tree bindings for Intel Keem Bay Offload and Crypto Subsystem (OCS) AES crypto driver.

---
 .../crypto/intel,keembay-ocs-aes.yaml         | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/intel,keembay-ocs-aes.yaml
Documentation/devicetree/bindings/crypto/intel,keembay-ocs-aes.yaml new file +45 -0
new file mode 100644
index 000000000000..ee2c099981b2
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/crypto/intel,keembay-ocs-aes.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Intel Keem Bay OCS AES Device Tree Bindings
+
+maintainers:
+  - Daniele Alessandrelli <[email protected]>
+
+description:
+  The Intel Keem Bay Offload and Crypto Subsystem (OCS) AES engine provides
+  hardware-accelerated AES/SM4 encryption/decryption.
+
+properties:
+  compatible:
+    const: intel,keembay-ocs-aes
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    crypto@30008000 {
+      compatible = "intel,keembay-ocs-aes";
+      reg = <0x30008000 0x1000>;
+      interrupts = <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>;
+      clocks = <&scmi_clk 95>;
+    };
Signature · 1 line
2.26.2
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] dt-bindings: Add Keem Bay OCS AES bindings

Quoted 5 lines · Daniele Alessandrelli

From: Daniele Alessandrelli <[email protected]>

Add device-tree bindings for Intel Keem Bay Offload and Crypto Subsystem (OCS) AES crypto driver.

Quoted 7 lines
---
 .../crypto/intel,keembay-ocs-aes.yaml         | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/intel,keembay-ocs-aes.yaml
#3 lore raw

PATCH 2/2 crypto: keembay-ocs-aes: Add support for Keem Bay OCS AES/SM4

In reply to Daniele Alessandrelli

From: Mike Healy <[email protected]>

Add support for the AES/SM4 crypto engine included in the Offload and Crypto Subsystem (OCS) of the Intel Keem Bay SoC, thus enabling hardware-acceleration for the following transformations:

- ecb(aes), cbc(aes), ctr(aes), cts(cbc(aes)), gcm(aes) and cbc(aes); supported for 128-bit and 256-bit keys.

- ecb(sm4), cbc(sm4), ctr(sm4), cts(cbc(sm4)), gcm(sm4) and cbc(sm4); supported for 128-bit keys.

The driver passes crypto manager self-tests, including the extra tests (CRYPTO_MANAGER_EXTRA_TESTS=y).

---
 MAINTAINERS                                   |   10 +
 drivers/crypto/Kconfig                        |    2 +
 drivers/crypto/Makefile                       |    1 +
 drivers/crypto/keembay/Kconfig                |   39 +
 drivers/crypto/keembay/Makefile               |    5 +
 drivers/crypto/keembay/keembay-ocs-aes-core.c | 1713 +++++++++++++++++
 drivers/crypto/keembay/ocs-aes.c              | 1489 ++++++++++++++
 drivers/crypto/keembay/ocs-aes.h              |  129 ++
 8 files changed, 3388 insertions(+)
 create mode 100644 drivers/crypto/keembay/Kconfig
 create mode 100644 drivers/crypto/keembay/Makefile
 create mode 100644 drivers/crypto/keembay/keembay-ocs-aes-core.c
 create mode 100644 drivers/crypto/keembay/ocs-aes.c
 create mode 100644 drivers/crypto/keembay/ocs-aes.h
MAINTAINERS +10 -0
index 606f9d7ef19a..f5f6539ae3eb 100644
@@ -8863,6 +8863,16 @@ M:	Deepak Saxena <[email protected]>
 S:	Maintained
 F:	drivers/char/hw_random/ixp4xx-rng.c
 
+INTEL KEEM BAY OCS AES/SM4 CRYPTO DRIVER
+M:	Daniele Alessandrelli <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/crypto/intel,keembay-ocs-aes.yaml
+F:	drivers/crypto/keembay/Kconfig
+F:	drivers/crypto/keembay/Makefile
+F:	drivers/crypto/keembay/keembay-ocs-aes-core.c
+F:	drivers/crypto/keembay/ocs-aes.c
+F:	drivers/crypto/keembay/ocs-aes.h
+
 INTEL MANAGEMENT ENGINE (mei)
 M:	Tomas Winkler <[email protected]>
 L:	[email protected]
drivers/crypto/Kconfig +2 -0
index c2950127def6..e636be70b18d 100644
@@ -881,4 +881,6 @@ config CRYPTO_DEV_SA2UL
 	  used for crypto offload.  Select this if you want to use hardware
 	  acceleration for cryptographic algorithms on these devices.
 
+source "drivers/crypto/keembay/Kconfig"
+
 endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
index 53fc115cf459..fff9a70348e1 100644
@@ -51,3 +51,4 @@ obj-$(CONFIG_CRYPTO_DEV_ARTPEC6) += axis/
 obj-$(CONFIG_CRYPTO_DEV_ZYNQMP_AES) += xilinx/
 obj-y += hisilicon/
 obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic/
+obj-y += keembay/
drivers/crypto/keembay/Kconfig new file +39 -0
new file mode 100644
index 000000000000..3c16797b25b9
@@ -0,0 +1,39 @@
+config CRYPTO_DEV_KEEMBAY_OCS_AES_SM4
+	tristate "Support for Intel Keem Bay OCS AES/SM4 HW acceleration"
+	depends on OF || COMPILE_TEST
+	select CRYPTO_SKCIPHER
+	select CRYPTO_AEAD
+	select CRYPTO_ENGINE
+	help
+	  Support for Intel Keem Bay Offload and Crypto Subsystem (OCS) AES and
+	  SM4 cihper hardware acceleration for use with Crypto API.
+
+	  Provides HW acceleration for the following transformations:
+	  cbc(aes), ctr(aes), ccm(aes), gcm(aes), cbc(sm4), ctr(sm4), ccm(sm4)
+	  and gcm(sm4).
+
+	  Optionally, support for the following transformations can also be
+	  enabled: ecb(aes), cts(cbc(aes)), ecb(sm4) and cts(cbc(sm4)).
+
+config CRYPTO_DEV_KEEMBAY_OCS_AES_SM4_ECB
+	bool "Support for Intel Keem Bay OCS AES/SM4 ECB HW acceleration"
+	depends on CRYPTO_DEV_KEEMBAY_OCS_AES_SM4
+	help
+	  Support for Intel Keem Bay Offload and Crypto Subsystem (OCS)
+	  AES/SM4 ECB mode hardware acceleration for use with Crypto API.
+
+	  Provides OCS version of ecb(aes) and ecb(sm4)
+
+	  Intel does not recommend use of ECB mode with AES/SM4.
+
+config CRYPTO_DEV_KEEMBAY_OCS_AES_SM4_CTS
+	bool "Support for Intel Keem Bay OCS AES/SM4 CTS HW acceleration"
+	depends on CRYPTO_DEV_KEEMBAY_OCS_AES_SM4
+	help
+	  Support for Intel Keem Bay Offload and Crypto Subsystem (OCS)
+	  AES/SM4 CBC with CTS mode hardware acceleration for use with
+	  Crypto API.
+
+	  Provides OCS version of cts(cbc(aes)) and cts(cbc(sm4)).
+
+	  Intel does not recommend use of CTS mode with AES/SM4.
drivers/crypto/keembay/Makefile new file +5 -0
new file mode 100644
index 000000000000..f21e2c4ab3b3
@@ -0,0 +1,5 @@
+#
+# Makefile for Intel Keem Bay OCS Crypto API Linux drivers
+#
+obj-$(CONFIG_CRYPTO_DEV_KEEMBAY_OCS_AES_SM4) += keembay-ocs-aes.o
+keembay-ocs-aes-objs := keembay-ocs-aes-core.o ocs-aes.o
drivers/crypto/keembay/keembay-ocs-aes-core.c new file +1713 -0

1,713 lines not on this page · raw message

drivers/crypto/keembay/ocs-aes.c new file +1489 -0

1,217 lines not on this page · raw message

drivers/crypto/keembay/ocs-aes.h new file +129 -0

129 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.26.2

Part of the diff is not shown here. View the raw message.

maintainer
#4 lore raw
In reply to Daniele Alessandrelli
Quoted 27 lines · Daniele Alessandrelli

The Intel Keem Bay SoC has an Offload Crypto Subsystem (OCS) featuring a crypto engine for accelerating AES/SM4 operations.

This driver adds support for such hardware thus enabling hardware acceleration for the following transformations on the Intel Keem Bay SoC:

- ecb(aes), cbc(aes), ctr(aes), cts(cbc(aes)), gcm(aes) and cbc(aes); supported for 128-bit and 256-bit keys.

- ecb(sm4), cbc(sm4), ctr(sm4), cts(cbc(sm4)), gcm(sm4) and cbc(sm4); supported for 128-bit keys.

The driver passes crypto manager self-tests, including the extra tests (CRYPTO_MANAGER_EXTRA_TESTS=y).

Note: this driver is different from the Keem Bay OCS HCU driver previously submitted. Keem Bay OCS HCU provides hardware-accelerated ahash, while Keem Bay AES/SM4 (i.e., this driver) provides hardware-accelerated skcipher and aead.

Daniele Alessandrelli (1):
dt-bindings: Add Keem Bay OCS AES bindings

Mike Healy (1):
crypto: keembay-ocs-aes: Add support for Keem Bay OCS AES/SM4

Quoted 16 lines
 .../crypto/intel,keembay-ocs-aes.yaml         |   45 +
 MAINTAINERS                                   |   10 +
 drivers/crypto/Kconfig                        |    2 +
 drivers/crypto/Makefile                       |    1 +
 drivers/crypto/keembay/Kconfig                |   39 +
 drivers/crypto/keembay/Makefile               |    5 +
 drivers/crypto/keembay/keembay-ocs-aes-core.c | 1713 +++++++++++++++++
 drivers/crypto/keembay/ocs-aes.c              | 1489 ++++++++++++++
 drivers/crypto/keembay/ocs-aes.h              |  129 ++
 9 files changed, 3433 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/intel,keembay-ocs-aes.yaml
 create mode 100644 drivers/crypto/keembay/Kconfig
 create mode 100644 drivers/crypto/keembay/Makefile
 create mode 100644 drivers/crypto/keembay/keembay-ocs-aes-core.c
 create mode 100644 drivers/crypto/keembay/ocs-aes.c
 create mode 100644 drivers/crypto/keembay/ocs-aes.h

All 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