Skip to contentSkip to conversation

Add Support for Marvell OcteonTX2 Cryptographic

PATCH Superseded Srujana Challa 6 participants 16 messages Aug 7, 2020 – Sep 8, 2020

Subsystems (5)

v2 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Srujana Challa

author maintainer
#0 lore raw

v2 cover Add Support for Marvell OcteonTX2 Cryptographic

The following series adds support for Marvell Cryptographic Acceleration Unit(CPT) on OcteonTX2 CN96XX SoC.
This series is tested with CRYPTO_EXTRA_TESTS enabled and CRYPTO_DISABLE_TESTS disabled.

Changes since v1:
* Moved Makefile changes from patch4 to patch2 and patch3.

Srujana Challa (3):
octeontx2-af: add support to manage the CPT unit
drivers: crypto: add support for OCTEONTX2 CPT engine
drivers: crypto: add the Virtual Function driver for OcteonTX2 CPT

 drivers/crypto/marvell/Kconfig                     |   17 +
 drivers/crypto/marvell/Makefile                    |    1 +
 drivers/crypto/marvell/octeontx2/Makefile          |   10 +
 drivers/crypto/marvell/octeontx2/otx2_cpt_common.h |   53 +
 .../crypto/marvell/octeontx2/otx2_cpt_hw_types.h   |  572 ++++++
 .../marvell/octeontx2/otx2_cpt_mbox_common.c       |  286 +++
 .../marvell/octeontx2/otx2_cpt_mbox_common.h       |  100 +
 drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h |  202 ++
 drivers/crypto/marvell/octeontx2/otx2_cptlf.h      |  370 ++++
 drivers/crypto/marvell/octeontx2/otx2_cptlf_main.c |  964 +++++++++
 drivers/crypto/marvell/octeontx2/otx2_cptpf.h      |   79 +
 drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c |  599 ++++++
 drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c |  694 +++++++
 .../crypto/marvell/octeontx2/otx2_cptpf_ucode.c    | 2173 ++++++++++++++++++++
 .../crypto/marvell/octeontx2/otx2_cptpf_ucode.h    |  180 ++
 drivers/crypto/marvell/octeontx2/otx2_cptvf.h      |   29 +
 drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c | 1708 +++++++++++++++
 drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h |  172 ++
 drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c |  229 +++
 drivers/crypto/marvell/octeontx2/otx2_cptvf_mbox.c |  189 ++
 .../crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c   |  536 +++++
 drivers/net/ethernet/marvell/octeontx2/af/Makefile |    2 +-
 drivers/net/ethernet/marvell/octeontx2/af/mbox.h   |   85 +
 drivers/net/ethernet/marvell/octeontx2/af/rvu.c    |    2 +-
 drivers/net/ethernet/marvell/octeontx2/af/rvu.h    |    7 +
 .../net/ethernet/marvell/octeontx2/af/rvu_cpt.c    |  343 +++
 .../ethernet/marvell/octeontx2/af/rvu_debugfs.c    |  342 +++
 .../net/ethernet/marvell/octeontx2/af/rvu_nix.c    |   76 +
 .../net/ethernet/marvell/octeontx2/af/rvu_reg.h    |   65 +-
 29 files changed, 10077 insertions(+), 8 deletions(-)
 create mode 100644 drivers/crypto/marvell/octeontx2/Makefile
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cpt_common.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cpt_mbox_common.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cpt_mbox_common.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptlf.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptlf_main.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptpf.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf_mbox.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c
Signature · 1 line
1.9.1
author maintainer
#1 lore raw

PATCH v2 1/3 octeontx2-af: add support to manage the CPT unit

The Admin function (AF) manages hardware resources on the cryptographic acceleration unit(CPT). This patch adds a mailbox interface for PFs and VFs to configure hardware resources for cryptography and inline-ipsec.

---
 drivers/net/ethernet/marvell/octeontx2/af/Makefile |   2 +-
 drivers/net/ethernet/marvell/octeontx2/af/mbox.h   |  85 +++++
 drivers/net/ethernet/marvell/octeontx2/af/rvu.c    |   2 +-
 drivers/net/ethernet/marvell/octeontx2/af/rvu.h    |   7 +
 .../net/ethernet/marvell/octeontx2/af/rvu_cpt.c    | 343 +++++++++++++++++++++
 .../ethernet/marvell/octeontx2/af/rvu_debugfs.c    | 342 ++++++++++++++++++++
 .../net/ethernet/marvell/octeontx2/af/rvu_nix.c    |  76 +++++
 .../net/ethernet/marvell/octeontx2/af/rvu_reg.h    |  65 +++-
 8 files changed, 914 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c
drivers/net/ethernet/marvell/octeontx2/af/Makefile +1 -1
index 1b25948..2f2efef 100644
@@ -8,4 +8,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
 
 octeontx2_mbox-y := mbox.o
 octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \
-		  rvu_reg.o rvu_npc.o rvu_debugfs.o
+		  rvu_reg.o rvu_npc.o rvu_debugfs.o rvu_cpt.o
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +85 -0

107 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu.c +1 -1
index 557e429..b3111c0 100644
@@ -1022,7 +1022,7 @@ int rvu_mbox_handler_ready(struct rvu *rvu, struct msg_req *req,
 /* Get current count of a RVU block's LF/slots
  * provisioned to a given RVU func.
  */
-static u16 rvu_get_rsrc_mapcount(struct rvu_pfvf *pfvf, int blktype)
+u16 rvu_get_rsrc_mapcount(struct rvu_pfvf *pfvf, int blktype)
 {
 	switch (blktype) {
 	case BLKTYPE_NPA:
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +7 -0
index dcf25a0..f057825 100644
@@ -42,6 +42,10 @@ struct dump_ctx {
 	bool	all;
 };
 
+struct cpt_dump_ctx {
+	char    e_type[NAME_SIZE];
+};
+
 struct rvu_debugfs {
 	struct dentry *root;
 	struct dentry *cgx_root;
@@ -50,11 +54,13 @@ struct rvu_debugfs {
 	struct dentry *npa;
 	struct dentry *nix;
 	struct dentry *npc;
+	struct dentry *cpt;
 	struct dump_ctx npa_aura_ctx;
 	struct dump_ctx npa_pool_ctx;
 	struct dump_ctx nix_cq_ctx;
 	struct dump_ctx nix_rq_ctx;
 	struct dump_ctx nix_sq_ctx;
+	struct cpt_dump_ctx cpt_ctx;
 	int npa_qsize_id;
 	int nix_qsize_id;
 };
@@ -408,6 +414,7 @@ static inline bool is_rvu_fwdata_valid(struct rvu *rvu)
 int rvu_lf_reset(struct rvu *rvu, struct rvu_block *block, int lf);
 int rvu_get_blkaddr(struct rvu *rvu, int blktype, u16 pcifunc);
 int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero);
+u16 rvu_get_rsrc_mapcount(struct rvu_pfvf *pfvf, int blktype);
 
 /* RVU HW reg validation */
 enum regmap_block {
drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c new file +343 -0

343 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +342 -0

354 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +76 -0

79 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +59 -6

77 lines not on this page · raw message

Signature · 1 line
1.9.1
author maintainer
#2 lore raw

PATCH v2 2/3 drivers: crypto: add support for OCTEONTX2 CPT engine

In reply to Srujana Challa

Add support for the cryptographic acceleration unit (CPT) on OcteonTX2 CN96XX SoC.

---
 drivers/crypto/marvell/Kconfig                     |   13 +
 drivers/crypto/marvell/Makefile                    |    1 +
 drivers/crypto/marvell/octeontx2/Makefile          |    7 +
 drivers/crypto/marvell/octeontx2/otx2_cpt_common.h |   53 +
 .../crypto/marvell/octeontx2/otx2_cpt_hw_types.h   |  567 +++++
 .../marvell/octeontx2/otx2_cpt_mbox_common.c       |  286 +++
 .../marvell/octeontx2/otx2_cpt_mbox_common.h       |  100 +
 drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h |   81 +
 drivers/crypto/marvell/octeontx2/otx2_cptlf.h      |  365 ++++
 drivers/crypto/marvell/octeontx2/otx2_cptpf.h      |   79 +
 drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c |  599 ++++++
 drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c |  694 +++++++
 .../crypto/marvell/octeontx2/otx2_cptpf_ucode.c    | 2173 ++++++++++++++++++++
 .../crypto/marvell/octeontx2/otx2_cptpf_ucode.h    |  180 ++
 drivers/crypto/marvell/octeontx2/otx2_cptvf.h      |   24 +
 15 files changed, 5222 insertions(+)
 create mode 100644 drivers/crypto/marvell/octeontx2/Makefile
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cpt_common.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cpt_mbox_common.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cpt_mbox_common.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptlf.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptpf.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf.h
drivers/crypto/marvell/Kconfig +13 -0
index 1306338..aaf55f1 100644
@@ -35,3 +35,16 @@ config CRYPTO_DEV_OCTEONTX_CPT
 
 		To compile this driver as module, choose M here:
 		the modules will be called octeontx-cpt and octeontx-cptvf
+
+config CRYPTO_DEV_OCTEONTX2_CPT
+	tristate "Support for Marvell OcteonTX2 CPT driver"
+	depends on ARCH_THUNDER || COMPILE_TEST
+	depends on PCI_MSI && 64BIT
+	select OCTEONTX2_MBOX
+	select CRYPTO_DEV_MARVELL
+	help
+		This driver allows you to utilize the Marvell Cryptographic
+		Accelerator Unit(CPT) found in OcteonTX2 series of processors.
+
+		To compile this driver as module, choose M here:
+		the modules will be called octeontx2-cpt and octeontx2-cptvf
drivers/crypto/marvell/Makefile +1 -0
index 6c6a151..39db6d9 100644
@@ -2,3 +2,4 @@
 
 obj-$(CONFIG_CRYPTO_DEV_MARVELL_CESA) += cesa/
 obj-$(CONFIG_CRYPTO_DEV_OCTEONTX_CPT) += octeontx/
+obj-$(CONFIG_CRYPTO_DEV_OCTEONTX2_CPT) += octeontx2/
drivers/crypto/marvell/octeontx2/Makefile new file +7 -0
new file mode 100644
index 0000000..d5d8f96
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_CRYPTO_DEV_OCTEONTX2_CPT) += octeontx2-cpt.o
+
+octeontx2-cpt-objs := otx2_cptpf_main.o otx2_cptpf_mbox.o otx2_cptpf_ucode.o \
+		      otx2_cpt_mbox_common.o
+
+ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af
drivers/crypto/marvell/octeontx2/otx2_cpt_common.h new file +53 -0

53 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h new file +567 -0

567 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cpt_mbox_common.c new file +286 -0

286 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cpt_mbox_common.h new file +100 -0

100 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h new file +81 -0

81 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptlf.h new file +365 -0

365 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptpf.h new file +79 -0

79 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c new file +599 -0

599 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c new file +694 -0

694 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c new file +2173 -0

149 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.h new file +180 -0

180 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptvf.h new file +24 -0
new file mode 100644
index 0000000..51039c7

Lines of this file are not shown. View the raw message.

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

Signature · 1 line
1.9.1

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

maintainer
#3 lore raw

Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 2 lines · On Fri, 7 Aug 2020 19:39:19 +0530 Srujana Challa wrote:

Add support for the cryptographic acceleration unit (CPT) on OcteonTX2 CN96XX SoC.

Please address the W=1 C=1 build warnings

../drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c:475:51: warning: cast removes address space '__iomem' of expression ../drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c:158:39: warning: incorrect type in assignment (different address spaces)
../drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c:158:39: expected void *lmtline
../drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c:158:39: got void [noderef] __iomem *
../drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c:161:37: warning: incorrect type in assignment (different address spaces)
../drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c:161:37: expected void *ioreg
../drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c:161:37: got void [noderef] __iomem *
../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:394:22: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:394:22: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:394:22: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:394:22: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:394:22: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:394:22: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:1025:23: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:1025:23: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:1025:23: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:1025:23: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:1025:23: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:1025:23: warning: cast to restricted __be32 ../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:1887:29: warning: incorrect type in assignment (different base types)
../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:1887:29: expected unsigned short [assigned] [usertype] opcode
../drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:1887:29: got restricted __be16 [usertype]

maintainer
#4 lore raw

Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

In reply to Srujana Challa
Quoted 9 lines · Srujana Challa
drivers/crypto/marvell/octeontx2/otx2_cptlf.h new file +8 -0
+/*
+ * On OcteonTX2 platform the parameter insts_num is used as a count of
+ * instructions to be enqueued. The valid values for insts_num are:
+ * 1 - 1 CPT instruction will be enqueued during LMTST operation
+ * 2 - 2 CPT instructions will be enqueued during LMTST operation
+ */
+static inline void otx2_cpt_send_cmd(union otx2_cpt_inst_s *cptinst,
+				     u32 insts_num, void *obj)

drivers/crypto/marvell/octeontx2/otx2_cptlf.h line 330

Quoted 10 lines
drivers/crypto/marvell/octeontx2/otx2_cptlf.h new file +10 -0
+{
+	struct otx2_cptlf_info *lf = obj;
+	void *lmtline = lf->lmtline;
+	long ret;
+
+	/*
+	 * Make sure memory areas pointed in CPT_INST_S
+	 * are flushed before the instruction is sent to CPT
+	 */
+	smp_wmb();

Why should this be a NOOP on UP?

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
maintainer
#5 lore raw

Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

In reply to Srujana Challa
Quoted 7 lines · Srujana Challa
drivers/crypto/marvell/octeontx2/otx2_cptlf.h new file +6 -0
+#if defined(CONFIG_ARM64)
+static inline long otx2_lmt_flush(void *ioreg)
+{
+	long result = 0;
+
+	__asm__ volatile(".cpu  generic+lse\n"

drivers/crypto/marvell/octeontx2/otx2_cptlf.h line 311

Quoted 10 lines
drivers/crypto/marvell/octeontx2/otx2_cptlf.h new file +10 -0
+			 "ldeor xzr, %0, [%1]\n"
+			 : "=r" (result)
+			 : "r" (ioreg) : "memory");
+
+	return result;
+}
+
+#else
+#define otx2_lmt_flush(addr)     ({ 0; })
+#endif

This is not acceptable. Please work out a way with the ARM folks to fix this without adding assembly code in a driver.

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
author maintainer
#6 lore raw

RE: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 17 lines

Subject: Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 12 lines · Srujana Challa
drivers/crypto/marvell/octeontx2/otx2_cptlf.h new file +11 -0
+#if defined(CONFIG_ARM64)
+static inline long otx2_lmt_flush(void *ioreg)
+{
+	long result = 0;
+
+	__asm__ volatile(".cpu  generic+lse\n"
+			 "ldeor xzr, %0, [%1]\n"
+			 : "=r" (result)
+			 : "r" (ioreg) : "memory");
+
+	return result;
Quoted 9 lines

drivers/crypto/marvell/octeontx2/otx2_cptlf.h line 311

Quoted 5 lines
drivers/crypto/marvell/octeontx2/otx2_cptlf.h new file +5 -0
+}
+
+#else
+#define otx2_lmt_flush(addr)     ({ 0; })
+#endif

This is not acceptable. Please work out a way with the ARM folks to fix this without adding assembly code in a driver.

This block of code is used for LMT store operations. The LMT store operation is specific to our platform, and this uses the "ldeor" instruction(which is actually an LSE atomic instruction available on v8.1 CPUs) targeting the IO address.
We add it in the driver since we want LMT store to work even if LSE_ATOMICS is disabled.

Thanks,
Srujana

Quoted 15 lines

Thanks,
--
Email: Herbert Xu <[email protected]>
Home Page: https://urldefense.proofpoint.com/v2/url?u=http-
3A__gondor.apana.org.au_- 7Eherbert_&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=Fj4OoD5hcKFpANhTW dwQzjT1Jpf7veC5263T47JVpnc&m=Xm4oQ3dI4peur80298SnMa5gz- 1rdAxVE1rwHkmHvc0&s=7S5Z2Mpq- th_W_KeJSQIOSo274CMg5UI0Tc9mkUkypg&e=
PGP Key: https://urldefense.proofpoint.com/v2/url?u=http-
3A__gondor.apana.org.au_- 7Eherbert_pubkey.txt&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=Fj4OoD5hcK FpANhTWdwQzjT1Jpf7veC5263T47JVpnc&m=Xm4oQ3dI4peur80298SnMa5gz- 1rdAxVE1rwHkmHvc0&s=yf6R1d7GDuz4Wmq_7Z7GoPuIkewZfs0x8h6xXvf3b2o&e =

maintainer
#7 lore raw

Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 7 lines · Srujana Challa

This block of code is used for LMT store operations. The LMT store operation is specific to our platform, and this uses the "ldeor" instruction(which is actually an LSE atomic instruction available on v8.1 CPUs) targeting the IO address.
We add it in the driver since we want LMT store to work even if LSE_ATOMICS is disabled.

You have exactly the same macro in your net driver. Move it into a header file in arch/arm64/include/asm and also add one under include/asm-generic so we can compile-test.

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
author maintainer
#8 lore raw

RE: [EXT] Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 15 lines

Subject: [EXT] Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

External Email

----------------------------------------------------------------------

Quoted 7 lines · Srujana Challa

This block of code is used for LMT store operations. The LMT store operation is specific to our platform, and this uses the "ldeor" instruction(which is actually an LSE atomic instruction available on v8.1 CPUs) targeting the IO address.
We add it in the driver since we want LMT store to work even if LSE_ATOMICS is disabled.

Quoted 4 lines

You have exactly the same macro in your net driver. Move it into a header file in arch/arm64/include/asm and also add one under include/asm-generic so we can compile-test.

Since LMT store is our platform specific, it cannot be generalized to all ARM64.

Quoted 14 lines

Thanks,
--
Email: Herbert Xu <[email protected]>
Home Page: https://urldefense.proofpoint.com/v2/url?u=http-
3A__gondor.apana.org.au_- 7Eherbert_&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=Fj4OoD5hcKFpANhTW dwQzjT1Jpf7veC5263T47JVpnc&m=awJiW_TrzVYeiwrZnqhly73OXSVuKm8XrM7oN Nd7Iiw&s=XZLFIH9uZTPOhsn-5jAzt7GXzT0iLbCYru55UjgkbqA&e= PGP Key: https://urldefense.proofpoint.com/v2/url?u=http-
3A__gondor.apana.org.au_- 7Eherbert_pubkey.txt&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=Fj4OoD5hcK FpANhTWdwQzjT1Jpf7veC5263T47JVpnc&m=awJiW_TrzVYeiwrZnqhly73OXSVuK m8XrM7oNNd7Iiw&s=pBxsW4mXz4mOiEMFDfIJfgC1Ngfvm2egNK0ak5oX7ms&e =

maintainer
#9 lore raw

Re: [EXT] Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 2 lines · Srujana Challa

Since LMT store is our platform specific, it cannot be generalized to all ARM64.

I'm not asking you to generalise it to all of ARM64. I'm asking you to move this into a header file under arch/arm64 that can then be shared by both your crypto driver and your network driver so you don't duplicate this everywhere.

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
#10 lore raw

RE: [EXT] Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 17 lines

-----Original Message-----
From: Herbert Xu <[email protected]>
Sent: Friday, September 4, 2020 7:48 PM
To: Srujana Challa <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; Suheil Chandran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Sunil Kovvuri Goutham <[email protected]>; Linu Cherian <[email protected]>; Geethasowjanya Akula <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Ard Biesheuvel <[email protected]>
Subject: Re: [EXT] Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 1 line · Srujana Challa
Quoted 8 lines
Quoted 1 line

Since LMT store is our platform specific, it cannot be generalized to all

ARM64.

I'm not asking you to generalise it to all of ARM64. I'm asking you to move this into a header file under arch/arm64 that can then be shared by both your crypto driver and your network driver so you don't duplicate this everywhere.

For ARM64 , except erratas other platform or machine dependent stuff are not allowed inside arch/arm64. Also an earlier attempt by us to add few APIs addressing 128bit operations were not allowed by ARM folks as they don't work in a generic way and are SOC specific.
http://lkml.iu.edu/hypermail/linux/kernel/1801.3/02211.html

Thanks,
Sunil.

#11 lore raw

Re: [EXT] Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 26 lines · Sunil Kovvuri Goutham
Quoted 17 lines

-----Original Message-----
From: Herbert Xu <[email protected]>
Sent: Friday, September 4, 2020 7:48 PM
To: Srujana Challa <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; Suheil Chandran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Sunil Kovvuri Goutham <[email protected]>; Linu Cherian <[email protected]>; Geethasowjanya Akula <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Ard Biesheuvel <[email protected]>
Subject: Re: [EXT] Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 1 line · Srujana Challa
Quoted 8 lines
Quoted 1 line

Since LMT store is our platform specific, it cannot be generalized to all

ARM64.

I'm not asking you to generalise it to all of ARM64. I'm asking you to move this into a header file under arch/arm64 that can then be shared by both your crypto driver and your network driver so you don't duplicate this everywhere.

Quoted 4 lines

For ARM64 , except erratas other platform or machine dependent stuff are not allowed inside arch/arm64. Also an earlier attempt by us to add few APIs addressing 128bit operations were not allowed by ARM folks as they don't work in a generic way and are SOC specific.
http://lkml.iu.edu/hypermail/linux/kernel/1801.3/02211.html

Maybe put it in include/linux/soc/ ?

Andrew

author maintainer
#12 lore raw

RE: [EXT] Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 34 lines

Subject: Re: [EXT] Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 20 lines · Sunil Kovvuri Goutham
Quoted 20 lines

-----Original Message-----
From: Herbert Xu <[email protected]>
Sent: Friday, September 4, 2020 7:48 PM
To: Srujana Challa <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; Suheil Chandran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Sunil Kovvuri Goutham <[email protected]>; Linu Cherian <[email protected]>; Geethasowjanya Akula <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Ard Biesheuvel <[email protected]>
Subject: Re: [EXT] Re: [PATCH v2 2/3] drivers: crypto: add support for OCTEONTX2 CPT engine

Quoted 2 lines · Srujana Challa

Since LMT store is our platform specific, it cannot be generalized to all

ARM64.

Quoted 7 lines
Quoted 5 lines

I'm not asking you to generalise it to all of ARM64. I'm asking you to move this into a header file under arch/arm64 that can then be shared by both your crypto driver and your network driver so you don't duplicate this everywhere.

For ARM64 , except erratas other platform or machine dependent stuff are not

allowed inside arch/arm64.

Quoted 1 line

Also an earlier attempt by us to add few APIs addressing 128bit operations were

not allowed by ARM folks

Quoted 9 lines
Quoted 2 lines

as they don't work in a generic way and are SOC specific.
https://urldefense.proofpoint.com/v2/url?u=http-

3A__lkml.iu.edu_hypermail_linux_kernel_1801.3_02211.html&d=DwIBAg&c=nKj Wec2b6R0mOyPaz7xtfQ&r=Fj4OoD5hcKFpANhTWdwQzjT1Jpf7veC5263T47JVpnc &m=_Crtymahn2yLpOWm4M2GAuzClE9EQVX2165DSnCx79E&s=FfyU3YaCxgJRXa 2EzyZrTvnWFYh8K2KmifpZAQN0gJk&e=

Maybe put it in include/linux/soc/ ?

Okay, I will move this block of code into a header file under include/linux/soc.
Thanks.

Quoted 1 line

Andrew

author maintainer
#13 lore raw

PATCH v2 3/3 drivers: crypto: add the Virtual Function driver for OcteonTX2 CPT

In reply to Srujana Challa

Add support for the cryptographic accelerator unit virtual functions on OcteonTX2 96XX SoC.

---
 drivers/crypto/marvell/Kconfig                     |    4 +
 drivers/crypto/marvell/octeontx2/Makefile          |    5 +-
 .../crypto/marvell/octeontx2/otx2_cpt_hw_types.h   |    5 +
 drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h |  121 ++
 drivers/crypto/marvell/octeontx2/otx2_cptlf.h      |    5 +
 drivers/crypto/marvell/octeontx2/otx2_cptlf_main.c |  964 +++++++++++
 drivers/crypto/marvell/octeontx2/otx2_cptvf.h      |    5 +
 drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c | 1708 ++++++++++++++++++++
 drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h |  172 ++
 drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c |  229 +++
 drivers/crypto/marvell/octeontx2/otx2_cptvf_mbox.c |  189 +++
 .../crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c   |  536 ++++++
 12 files changed, 3942 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptlf_main.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf_mbox.c
 create mode 100644 drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c
drivers/crypto/marvell/Kconfig +4 -0
index aaf55f1..1e2e85a 100644
@@ -40,8 +40,12 @@ config CRYPTO_DEV_OCTEONTX2_CPT
 	tristate "Support for Marvell OcteonTX2 CPT driver"
 	depends on ARCH_THUNDER || COMPILE_TEST
 	depends on PCI_MSI && 64BIT
+	depends on CRYPTO_LIB_AES
 	select OCTEONTX2_MBOX
 	select CRYPTO_DEV_MARVELL
+	select CRYPTO_SKCIPHER
+	select CRYPTO_HASH
+	select CRYPTO_AEAD
 	help
 		This driver allows you to utilize the Marvell Cryptographic
 		Accelerator Unit(CPT) found in OcteonTX2 series of processors.
drivers/crypto/marvell/octeontx2/Makefile +4 -1
index d5d8f96..e08df48 100644
@@ -1,7 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_CRYPTO_DEV_OCTEONTX2_CPT) += octeontx2-cpt.o
+obj-$(CONFIG_CRYPTO_DEV_OCTEONTX2_CPT) += octeontx2-cpt.o octeontx2-cptvf.o
 
 octeontx2-cpt-objs := otx2_cptpf_main.o otx2_cptpf_mbox.o otx2_cptpf_ucode.o \
 		      otx2_cpt_mbox_common.o
+octeontx2-cptvf-objs := otx2_cptvf_main.o otx2_cptvf_mbox.o otx2_cptlf_main.o \
+			otx2_cptvf_reqmgr.o otx2_cptvf_algs.o \
+			otx2_cpt_mbox_common.o
 
 ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af
drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h +5 -0
index 8063259..c403e24 100644
@@ -104,6 +104,11 @@
 #define OTX2_CPT_LMT_LFBASE             BIT_ULL(OTX2_CPT_RVU_FUNC_BLKADDR_SHIFT)
 #define OTX2_CPT_LMT_LF_LMTLINEX(a)     (OTX2_CPT_LMT_LFBASE | 0x000 | \
 					 (a) << 12)
+/* RVU VF registers */
+#define OTX2_RVU_VF_INT                 (0x20)
+#define OTX2_RVU_VF_INT_W1S             (0x28)
+#define OTX2_RVU_VF_INT_ENA_W1S         (0x30)
+#define OTX2_RVU_VF_INT_ENA_W1C         (0x38)
 
 /*
  * Enumeration otx2_cpt_ucode_error_code_e
drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h +121 -0

131 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptlf.h +5 -0
index 528f16f..1842aa9 100644
@@ -362,4 +362,9 @@ static inline void otx2_cpt_send_cmd(union otx2_cpt_inst_s *cptinst,
 
 	} while (!ret);
 }
+
+int otx2_cptvf_lf_init(struct pci_dev *pdev, void *reg_base,
+		       struct otx2_cptlfs_info *lfs, int lfs_num);
+int otx2_cptvf_lf_shutdown(struct pci_dev *pdev, struct otx2_cptlfs_info *lfs);
+
 #endif /* __OTX2_CPTLF_H */
drivers/crypto/marvell/octeontx2/otx2_cptlf_main.c new file +964 -0

964 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptvf.h +5 -0
index 51039c7..6a4d8b5 100644
@@ -21,4 +21,9 @@ struct otx2_cptvf_dev {
 	struct workqueue_struct *pfvf_mbox_wq;
 };
 
+irqreturn_t otx2_cptvf_pfvf_mbox_intr(int irq, void *arg);
+void otx2_cptvf_pfvf_mbox_handler(struct work_struct *work);
+int otx2_cptvf_send_eng_grp_num_msg(struct otx2_cptvf_dev *cptvf, int eng_type);
+int otx2_cptvf_send_kcrypto_limits_msg(struct otx2_cptvf_dev *cptvf);
+
 #endif /* __OTX2_CPTVF_H */
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c new file +1708 -0

1,708 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h new file +172 -0

145 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c new file +229 -0

229 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptvf_mbox.c new file +189 -0

189 lines not on this page · raw message

drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c new file +536 -0

536 lines not on this page · raw message

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

Signature · 1 line
1.9.1

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

maintainer
#14 lore raw

Re: [PATCH v2 3/3] drivers: crypto: add the Virtual Function driver for OcteonTX2 CPT

drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c line 1553

Quoted 13 lines · Srujana Challa
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c new file +12 -0
+static inline int is_any_alg_used(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(otx2_cpt_skciphers); i++)
+		if (refcount_read(&otx2_cpt_skciphers[i].base.cra_refcnt) != 1)
+			return true;
+	for (i = 0; i < ARRAY_SIZE(otx2_cpt_aeads); i++)
+		if (refcount_read(&otx2_cpt_aeads[i].base.cra_refcnt) != 1)
+			return true;
+	return false;
+}

This is racy as there is nothing stopping new users from coming in after you've finished the test.

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
maintainer
#15 lore raw
In reply to Srujana Challa

From: Srujana Challa <[email protected]>
Date: Fri, 7 Aug 2020 19:39:17 +0530

Quoted 4 lines

The following series adds support for Marvell Cryptographic Acceleration Unit(CPT) on OcteonTX2 CN96XX SoC.
This series is tested with CRYPTO_EXTRA_TESTS enabled and CRYPTO_DISABLE_TESTS disabled.

net-next is closed, please do not submit these feature addition changes until the net-next tree is open again.

Thank you.