Skip to contentSkip to conversation

Add Support for Marvell OcteonTX2 Cryptographic

PATCH Applied Srujana Challa 2 participants 5 messages Nov 18, 2020 – Nov 20, 2020

Subsystems (5)
lore
Share & tools
lore

Srujana Challa

author maintainer
#0 lore raw

v10 cover Add Support for Marvell OcteonTX2 Cryptographic

This patchset adds support for CPT in OcteonTX2 admin function(AF). CPT is a cryptographic accelerator unit and it includes microcoded Giga Cipher engines.

OcteonTX2 SOC's resource virtualization unit (RVU) supports multiple physical and virtual functions. Each of the PF/VF's functionality is determined by what kind of resources are attached to it. When the CPT block is attached to a VF, it can function as a security device. The following document provides an overview of the hardware and different drivers for the OcteonTX2 SOC:
https://www.kernel.org/doc/Documentation/networking/device_drivers/marvell/octeontx2.rst

This patch series includes:
- Patch to update existing Marvell sources to support CPT.
- Patch that adds mailbox messages to the admin function (AF) driver, to configure CPT HW registers.
- Patch to provide debug information about CPT.

Changes since v9:
* Dropped CPT PF & VF driver patches to submit to cryptodev-2.6 in next release cycle.
Changes since v8:
* Load firmware files individually instead of tar.
Changes since v7:
* Removed writable entries in debugfs.
* Dropped IPsec support.
Changes since v6:
* Removed driver version.
Changes since v4:
* Rebased the patches onto net-next tree with base
'commit bc081a693a56 ("Merge branch 'Offload-tc-vlan-mangle-to-mscc_ocelot-switch'")'
Changes since v3:
* Splitup the patches into smaller patches with more informartion.
Changes since v2:
* Fixed C=1 warnings.
* Added code to exit CPT VF driver gracefully.
* Moved OcteonTx2 asm code to a header file under include/linux/soc/
Changes since v1:
* Moved Makefile changes from patch4 to patch2 and patch3.

Srujana Challa (3):
octeontx2-pf: move lmt flush to include/linux/soc
octeontx2-af: add mailbox interface for CPT
octeontx2-af: add debugfs entries for CPT block

 MAINTAINERS                                   |   2 +
 .../ethernet/marvell/octeontx2/af/Makefile    |   3 +-
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  33 +++
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   1 +
 .../ethernet/marvell/octeontx2/af/rvu_cpt.c   | 233 +++++++++++++++
 .../marvell/octeontx2/af/rvu_debugfs.c        | 272 ++++++++++++++++++
 .../ethernet/marvell/octeontx2/af/rvu_reg.h   |  63 +++-
 .../marvell/octeontx2/nic/otx2_common.h       |  13 +-
 include/linux/soc/marvell/octeontx2/asm.h     |  29 ++
 9 files changed, 630 insertions(+), 19 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c
 create mode 100644 include/linux/soc/marvell/octeontx2/asm.h
Signature · 1 line
2.29.0
author maintainer
#1 lore raw

PATCH v10 1/3 octeontx2-pf: move lmt flush to include/linux/soc

On OcteonTX2 platform CPT instruction enqueue and NIX packet send are only possible via LMTST operations which uses LDEOR instruction. This patch moves lmt flush function from OcteonTX2 nic driver to include/linux/soc since it will be used by OcteonTX2 CPT and NIC driver for LMTST.

---
 MAINTAINERS                                   |  2 ++
 .../marvell/octeontx2/nic/otx2_common.h       | 13 +--------
 include/linux/soc/marvell/octeontx2/asm.h     | 29 +++++++++++++++++++
 3 files changed, 32 insertions(+), 12 deletions(-)
 create mode 100644 include/linux/soc/marvell/octeontx2/asm.h
MAINTAINERS +2 -0
index 3341959af0c7..0169168dcd59 100644
@@ -10470,6 +10470,7 @@ M:	Srujana Challa <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	drivers/crypto/marvell/
+F:	include/linux/soc/marvell/octeontx2/
 
 MARVELL GIGABIT ETHERNET DRIVERS (skge/sky2)
 M:	Mirko Lindner <[email protected]>
@@ -10542,6 +10543,7 @@ M:	hariprasad <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	drivers/net/ethernet/marvell/octeontx2/nic/
+F:	include/linux/soc/marvell/octeontx2/
 
 MARVELL OCTEONTX2 RVU ADMIN FUNCTION DRIVER
 M:	Sunil Goutham <[email protected]>
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +1 -12
index b18b45d02165..ceec649bdd13 100644
@@ -16,6 +16,7 @@
 #include <linux/net_tstamp.h>
 #include <linux/ptp_clock_kernel.h>
 #include <linux/timecounter.h>
+#include <linux/soc/marvell/octeontx2/asm.h>
 
 #include <mbox.h>
 #include <npc.h>
@@ -462,21 +463,9 @@ static inline u64 otx2_atomic64_add(u64 incr, u64 *ptr)
 	return result;
 }
 
-static inline u64 otx2_lmt_flush(uint64_t addr)
-{
-	u64 result = 0;
-
-	__asm__ volatile(".cpu  generic+lse\n"
-			 "ldeor xzr,%x[rf],[%[rs]]"
-			 : [rf]"=r"(result)
-			 : [rs]"r"(addr));
-	return result;
-}
-
 #else
 #define otx2_write128(lo, hi, addr)
 #define otx2_atomic64_add(incr, ptr)		({ *ptr += incr; })
-#define otx2_lmt_flush(addr)			({ 0; })
 #endif
 
 /* Alloc pointer from pool/aura */
include/linux/soc/marvell/octeontx2/asm.h new file +29 -0
new file mode 100644
index 000000000000..ae2279fe830a
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * Copyright (C) 2020 Marvell.
+ */
+
+#ifndef __SOC_OTX2_ASM_H
+#define __SOC_OTX2_ASM_H
+
+#if defined(CONFIG_ARM64)
+/*
+ * otx2_lmt_flush is used for LMT store operation.
+ * On octeontx2 platform CPT instruction enqueue and
+ * NIX packet send are only possible via LMTST
+ * operations and it uses LDEOR instruction targeting
+ * the coprocessor address.
+ */
+#define otx2_lmt_flush(ioaddr)                          \
+({                                                      \
+	u64 result = 0;                                 \
+	__asm__ volatile(".cpu  generic+lse\n"          \
+			 "ldeor xzr, %x[rf], [%[rs]]"   \
+			 : [rf]"=r" (result)            \
+			 : [rs]"r" (ioaddr));           \
+	(result);                                       \
+})
+#else
+#define otx2_lmt_flush(ioaddr)          ({ 0; })
+#endif
+
+#endif /* __SOC_OTX2_ASM_H */
Signature · 1 line
2.29.0
author maintainer
#2 lore raw

PATCH v10 2/3 octeontx2-af: add mailbox interface for CPT

In reply to Srujana Challa

On OcteonTX2 SoC, the admin function (AF) is the only one with all priviliges to configure HW and alloc resources, PFs and it's VFs have to request AF via mailbox for all their needs. This patch adds a mailbox interface for CPT PFs and VFs to allocate resources for cryptography. It also adds hardware CPT AF register defines.

---
 .../ethernet/marvell/octeontx2/af/Makefile    |   3 +-
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  33 +++
 .../ethernet/marvell/octeontx2/af/rvu_cpt.c   | 233 ++++++++++++++++++
 .../ethernet/marvell/octeontx2/af/rvu_reg.h   |  63 ++++-
 4 files changed, 325 insertions(+), 7 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c
drivers/net/ethernet/marvell/octeontx2/af/Makefile +2 -1
index ffc681b67f1c..7100d1dd856e 100644
@@ -9,4 +9,5 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
 
 octeontx2_mbox-y := mbox.o rvu_trace.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 ptp.o rvu_npc_fs.o
+		  rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \
+		  rvu_cpt.o
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +33 -0
index cb4e3d86b58b..221fe5b7c093 100644
@@ -158,6 +158,11 @@ M(NPA_HWCTX_DISABLE,	0x403, npa_hwctx_disable, hwctx_disable_req, msg_rsp)\
 /* SSO/SSOW mbox IDs (range 0x600 - 0x7FF) */				\
 /* TIM mbox IDs (range 0x800 - 0x9FF) */				\
 /* CPT mbox IDs (range 0xA00 - 0xBFF) */				\
+M(CPT_LF_ALLOC,		0xA00, cpt_lf_alloc, cpt_lf_alloc_req_msg,	\
+			       msg_rsp)					\
+M(CPT_LF_FREE,		0xA01, cpt_lf_free, msg_req, msg_rsp)		\
+M(CPT_RD_WR_REGISTER,	0xA02, cpt_rd_wr_register,  cpt_rd_wr_reg_msg,	\
+			       cpt_rd_wr_reg_msg)			\
 /* NPC mbox IDs (range 0x6000 - 0x7FFF) */				\
 M(NPC_MCAM_ALLOC_ENTRY,	0x6000, npc_mcam_alloc_entry, npc_mcam_alloc_entry_req,\
 				npc_mcam_alloc_entry_rsp)		\
@@ -1046,4 +1051,32 @@ struct ptp_rsp {
 	u64 clk;
 };
 
+/* CPT mailbox error codes
+ * Range 901 - 1000.
+ */
+enum cpt_af_status {
+	CPT_AF_ERR_PARAM		= -901,
+	CPT_AF_ERR_GRP_INVALID		= -902,
+	CPT_AF_ERR_LF_INVALID		= -903,
+	CPT_AF_ERR_ACCESS_DENIED	= -904,
+	CPT_AF_ERR_SSO_PF_FUNC_INVALID	= -905,
+	CPT_AF_ERR_NIX_PF_FUNC_INVALID	= -906
+};
+
+/* CPT mbox message formats */
+struct cpt_rd_wr_reg_msg {
+	struct mbox_msghdr hdr;
+	u64 reg_offset;
+	u64 *ret_val;
+	u64 val;
+	u8 is_write;
+};
+
+struct cpt_lf_alloc_req_msg {
+	struct mbox_msghdr hdr;
+	u16 nix_pf_func;
+	u16 sso_pf_func;
+	u16 eng_grpmsk;
+};
+
 #endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c new file +233 -0

233 lines not on this page · raw message

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

69 lines not on this page · raw message

Signature · 1 line
2.29.0
author maintainer
#3 lore raw

PATCH v10 3/3 octeontx2-af: add debugfs entries for CPT block

In reply to Srujana Challa

Add entries to debugfs at /sys/kernel/debug/octeontx2/cpt.

cpt_pc: dump cpt performance HW registers.
Usage:
cat /sys/kernel/debug/octeontx2/cpt/cpt_pc

cpt_ae_sts: show cpt asymmetric engines current state Usage:
cat /sys/kernel/debug/octeontx2/cpt/cpt_ae_sts

cpt_se_sts: show cpt symmetric engines current state Usage:
cat /sys/kernel/debug/octeontx2/cpt/cpt_se_sts

cpt_engines_info: dump cpt engine control registers. Usage:
cat /sys/kernel/debug/octeontx2/cpt/cpt_engines_info

cpt_lfs_info: dump cpt lfs control registers.
Usage:
cat /sys/kernel/debug/octeontx2/cpt/cpt_lfs_info

cpt_err_info: dump cpt error registers.
Usage:
cat /sys/kernel/debug/octeontx2/cpt/cpt_err_info

---
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   1 +
 .../marvell/octeontx2/af/rvu_debugfs.c        | 272 ++++++++++++++++++
 2 files changed, 273 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1 -0
index 37774bac32b0..b6c0977499ab 100644
@@ -52,6 +52,7 @@ 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;
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +272 -0

290 lines not on this page · raw message

Signature · 1 line
2.29.0
#4 lore raw
In reply to Srujana Challa
This series was applied to netdev/net-next.git (refs/heads/master):

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

Quoted 12 lines · On Wed, 18 Nov 2020 17:14:13 +0530 you wrote:

This patchset adds support for CPT in OcteonTX2 admin function(AF). CPT is a cryptographic accelerator unit and it includes microcoded Giga Cipher engines.

OcteonTX2 SOC's resource virtualization unit (RVU) supports multiple physical and virtual functions. Each of the PF/VF's functionality is determined by what kind of resources are attached to it. When the CPT block is attached to a VF, it can function as a security device. The following document provides an overview of the hardware and different drivers for the OcteonTX2 SOC:
https://www.kernel.org/doc/Documentation/networking/device_drivers/marvell/octeontx2.rst

Quoted 1 line

[...]

Here is the summary with links:
- [v10,net-next,1/3] octeontx2-pf: move lmt flush to include/linux/soc

    https://git.kernel.org/netdev/net-next/c/956fb852181e
  - [v10,net-next,2/3] octeontx2-af: add mailbox interface for CPT
    https://git.kernel.org/netdev/net-next/c/ae454086e3c2
  - [v10,net-next,3/3] octeontx2-af: add debugfs entries for CPT block
    https://git.kernel.org/netdev/net-next/c/76638a2e5850

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html