Skip to contentSkip to conversation

crypto: talitos - Implementation of SEC1

PATCH Superseded Christophe Leroy 1 participant 1 message Mar 5, 2015 Crypto API

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 15/17 crypto: talitos - Implementation of SEC1

This patch adds talitos1.c and talitos1.h with all specificities needed to handle the SEC1 security engine found in MPC885 and MPC8272.

The SEC1 has several differences with its younger brother SEC2:
* Several bits in registers have different locations
* Many bits are missing
* Some bits are in addition
* SEC1 doesn't support scatter/gather
* SEC1 has a different descriptor structure

We add a helper function for clearing the desc field in the descriptor as that field needs to be cleared on SEC1 and doesn't exist on SEC2.

---
 drivers/crypto/Kconfig    |   6 +-
 drivers/crypto/Makefile   |   1 +
 drivers/crypto/talitos.c  |   4 +
 drivers/crypto/talitos.h  |   5 +
 drivers/crypto/talitos1.c | 176 ++++++++++++++++++++++++
 drivers/crypto/talitos1.h | 339 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/crypto/talitos2.h |   4 +
 7 files changed, 534 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/talitos1.c
 create mode 100644 drivers/crypto/talitos1.h
drivers/crypto/Kconfig +5 -1
index 4fd6d7e..f863cac 100644
@@ -211,7 +211,8 @@ config CRYPTO_DEV_TALITOS
 	select CRYPTO_ALGAPI
 	select CRYPTO_AUTHENC
 	select HW_RANDOM
-	select CRYPTO_DEV_TALITOS2
+	select CRYPTO_DEV_TALITOS1 if PPC_8xx || PPC_82xx
+	select CRYPTO_DEV_TALITOS2 if !CRYPTO_DEV_TALITOS1
 	depends on FSL_SOC
 	help
 	  Say 'Y' here to use the Freescale Security Engine (SEC)
@@ -223,6 +224,9 @@ config CRYPTO_DEV_TALITOS
 	  To compile this driver as a module, choose M here: the module
 	  will be called talitos.
 
+config CRYPTO_DEV_TALITOS1
+	bool
+
 config CRYPTO_DEV_TALITOS2
 	bool
 
drivers/crypto/Makefile +1 -0
index f26159f..ef16f7b 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/
 obj-$(CONFIG_CRYPTO_DEV_S5P) += s5p-sss.o
 obj-$(CONFIG_CRYPTO_DEV_SAHARA) += sahara.o
 obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o
+obj-$(CONFIG_CRYPTO_DEV_TALITOS1) += talitos1.o
 obj-$(CONFIG_CRYPTO_DEV_TALITOS2) += talitos2.o
 obj-$(CONFIG_CRYPTO_DEV_UX500) += ux500/
 obj-$(CONFIG_CRYPTO_DEV_QAT) += qat/
drivers/crypto/talitos.c +4 -0
index 37d7746..112a25a 100644
@@ -655,6 +655,8 @@ static int common_nonsnoop(struct talitos_edesc *edesc,
 	/* last DWORD empty */
 	desc->ptr[6] = zero_entry;
 
+	to_talitos_next_desc_clear(desc);
+
 	ret = talitos_submit(dev, ctx->ch, desc, callback, areq);
 	if (ret != -EINPROGRESS) {
 		common_nonsnoop_unmap(dev, edesc, areq);
@@ -813,6 +815,8 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc,
 	/* last DWORD empty */
 	desc->ptr[6] = zero_entry;
 
+	to_talitos_next_desc_clear(desc);
+
 	ret = talitos_submit(dev, ctx->ch, desc, callback, areq);
 	if (ret != -EINPROGRESS) {
 		common_nonsnoop_hash_unmap(dev, edesc, areq);
drivers/crypto/talitos.h +5 -0
index a11ad53..68191cf 100644
@@ -372,4 +372,9 @@ static inline int sg_count(struct scatterlist *sg_list, int nbytes,
 #define DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU	cpu_to_be32(2 << 3)
 #define DESC_HDR_TYPE_HMAC_SNOOP_NO_AFEU	cpu_to_be32(4 << 3)
 
+#ifdef CONFIG_CRYPTO_DEV_TALITOS1
+#include "talitos1.h"
+#endif
+#ifdef CONFIG_CRYPTO_DEV_TALITOS2
 #include "talitos2.h"
+#endif
drivers/crypto/talitos1.c new file +176 -0

176 lines not on this page · raw message

drivers/crypto/talitos1.h new file +339 -0

339 lines not on this page · raw message

drivers/crypto/talitos2.h +4 -0
index 6f98b12..2715c72 100644
@@ -95,6 +95,10 @@ static inline void to_talitos_ptr_extent_clear(struct talitos_ptr *ptr)
 	ptr->j_extent = 0;
 }
 
+static inline void to_talitos_next_desc_clear(struct talitos_desc *desc)
+{
+}
+
 /*
  * map virtual single (contiguous) pointer to h/w descriptor pointer
  */
Signature · 1 line
2.1.0