Skip to contentSkip to conversation

Add Crypto PMD for Broadcom`s FlexSparc devices

PATCH New Vikas Gupta 5 participants 75 messages Aug 12, 2020 – Oct 16, 2020

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

cover Add Crypto PMD for Broadcom`s FlexSparc devices

Hi,
This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.
BCMFS is an acronym for Broadcom FlexSparc device used in the patchest.

The patchset progressively adds major modules as below.
a) Detection of platform-device based on the known registered platforms and attaching with VFIO.
b) Creation of Cryptodevice.
c) Addition of session handling.
d) Add Cryptodevice into test Cryptodev framework.

The patchset has been tested on the above mentioned SoCs.

Regards,
Vikas

Vikas Gupta (8):
crypto/bcmfs: add BCMFS driver crypto/bcmfs: add vfio support crypto/bcmfs: add apis for queue pair management crypto/bcmfs: add hw queue pair operations crypto/bcmfs: create a symmetric cryptodev crypto/bcmfs: add session handling and capabilities crypto/bcmfs: add crypto h/w module crypto/bcmfs: add crypto pmd into cryptodev test

 MAINTAINERS                                   |   7 +
 app/test/test_cryptodev.c                     | 261 +++++
 app/test/test_cryptodev.h                     |   1 +
 config/common_base                            |   5 +
 doc/guides/cryptodevs/bcmfs.rst               |  72 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |  56 +
 doc/guides/cryptodevs/index.rst               |   1 +
 drivers/crypto/bcmfs/bcmfs_dev_msg.h          |  29 +
 drivers/crypto/bcmfs/bcmfs_device.c           | 331 ++++++
 drivers/crypto/bcmfs/bcmfs_device.h           |  76 ++
 drivers/crypto/bcmfs/bcmfs_hw_defs.h          |  38 +
 drivers/crypto/bcmfs/bcmfs_logs.c             |  38 +
 drivers/crypto/bcmfs/bcmfs_logs.h             |  34 +
 drivers/crypto/bcmfs/bcmfs_qp.c               | 383 +++++++
 drivers/crypto/bcmfs/bcmfs_qp.h               | 142 +++
 drivers/crypto/bcmfs/bcmfs_sym.c              | 316 ++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c | 764 ++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         | 186 ++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.c       | 994 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h       | 103 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          | 426 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h          |  38 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h          |  62 ++
 drivers/crypto/bcmfs/bcmfs_sym_session.c      | 426 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      |  99 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c             |  94 ++
 drivers/crypto/bcmfs/bcmfs_vfio.h             |  17 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c           | 742 +++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c           | 677 ++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c     |  82 ++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h     |  46 +
 drivers/crypto/bcmfs/meson.build              |  20 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |   3 +
 drivers/crypto/meson.build                    |   3 +-
 mk/rte.app.mk                                 |   1 +
 36 files changed, 6588 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
Signature · 1 line
2.17.1
#1 lore raw

cover Add Crypto PMD for Broadcom`s FlexSparc devices

Hi,
This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.
BCMFS is an acronym for Broadcom FlexSparc device used in the patchest.

The patchset progressively adds major modules as below.
a) Detection of platform-device based on the known registered platforms and attaching with VFIO.
b) Creation of Cryptodevice.
c) Addition of session handling.
d) Add Cryptodevice into test Cryptodev framework.

The patchset has been tested on the above mentioned SoCs.

Regards,
Vikas

Changes from v0->v1:
Updated the ABI version in map file 'rte_pmd_bcmfs_version.map'

Vikas Gupta (8):
crypto/bcmfs: add BCMFS driver crypto/bcmfs: add vfio support crypto/bcmfs: add apis for queue pair management crypto/bcmfs: add hw queue pair operations crypto/bcmfs: create a symmetric cryptodev crypto/bcmfs: add session handling and capabilities crypto/bcmfs: add crypto h/w module crypto/bcmfs: add crypto pmd into cryptodev test

 MAINTAINERS                                   |   7 +
 app/test/test_cryptodev.c                     | 261 +++++
 app/test/test_cryptodev.h                     |   1 +
 config/common_base                            |   5 +
 doc/guides/cryptodevs/bcmfs.rst               |  72 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |  56 +
 doc/guides/cryptodevs/index.rst               |   1 +
 drivers/crypto/bcmfs/bcmfs_dev_msg.h          |  29 +
 drivers/crypto/bcmfs/bcmfs_device.c           | 331 ++++++
 drivers/crypto/bcmfs/bcmfs_device.h           |  76 ++
 drivers/crypto/bcmfs/bcmfs_hw_defs.h          |  38 +
 drivers/crypto/bcmfs/bcmfs_logs.c             |  38 +
 drivers/crypto/bcmfs/bcmfs_logs.h             |  34 +
 drivers/crypto/bcmfs/bcmfs_qp.c               | 383 +++++++
 drivers/crypto/bcmfs/bcmfs_qp.h               | 142 +++
 drivers/crypto/bcmfs/bcmfs_sym.c              | 316 ++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c | 764 ++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         | 186 ++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.c       | 994 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h       | 103 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          | 426 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h          |  38 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h          |  62 ++
 drivers/crypto/bcmfs/bcmfs_sym_session.c      | 426 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      |  99 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c             |  94 ++
 drivers/crypto/bcmfs/bcmfs_vfio.h             |  17 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c           | 742 +++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c           | 677 ++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c     |  82 ++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h     |  46 +
 drivers/crypto/bcmfs/meson.build              |  20 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |   3 +
 drivers/crypto/meson.build                    |   3 +-
 mk/rte.app.mk                                 |   1 +
 36 files changed, 6588 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/8 crypto/bcmfs: add BCMFS driver

Add Broadcom FlexSparc(FS) device creation driver which registers to a vdev and create a device. Add APIs for logs, supportive documention and maintainers file.

---
 MAINTAINERS                                   |   7 +
 config/common_base                            |   5 +
 doc/guides/cryptodevs/bcmfs.rst               |  26 ++
 doc/guides/cryptodevs/index.rst               |   1 +
 drivers/crypto/bcmfs/Makefile                 |  27 ++
 drivers/crypto/bcmfs/bcmfs_device.c           | 256 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_device.h           |  40 +++
 drivers/crypto/bcmfs/bcmfs_logs.c             |  38 +++
 drivers/crypto/bcmfs/bcmfs_logs.h             |  34 +++
 drivers/crypto/bcmfs/meson.build              |  10 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |   3 +
 drivers/crypto/meson.build                    |   3 +-
 mk/rte.app.mk                                 |   1 +
 13 files changed, 450 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 drivers/crypto/bcmfs/Makefile
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
MAINTAINERS +7 -0
index 3cd402b34..7c2d7ff1b 100644
@@ -1099,6 +1099,13 @@ F: drivers/crypto/zuc/
 F: doc/guides/cryptodevs/zuc.rst
 F: doc/guides/cryptodevs/features/zuc.ini
 
+Broadcom FlexSparc
+M: Vikas Gupta  <vikas.gupta@@broadcom.com>
+M: Raveendra Padasalagi <[email protected]>
+M: Ajit Khaparde <[email protected]>
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 -------------------
config/common_base +5 -0
index f7a8824f5..21daadcdd 100644
@@ -705,6 +705,11 @@ CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO=n
 #
 CONFIG_RTE_LIBRTE_PMD_NITROX=y
 
+#
+# Compile PMD for Broadcom crypto device
+#
+CONFIG_RTE_LIBRTE_PMD_BCMFS=y
+
 #
 # Compile generic security library
 #
doc/guides/cryptodevs/bcmfs.rst new file +26 -0
new file mode 100644
index 000000000..752ce028a
@@ -0,0 +1,26 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(C) 2020 Broadcom
+
+Broadcom FlexSparc Crypto Poll Mode Driver
+==========================================
+
+The FlexSparc crypto poll mode driver provides support for offloading
+cryptographic operations to the Broadcom SoCs having FlexSparc4/FlexSparc5 unit.
+Detailed information about SoCs can be found in
+
+* https://www.broadcom.com/
+
+Installation
+------------
+
+For compiling the Broadcom FlexSparc crypto PMD, please check if the
+CONFIG_RTE_LIBRTE_PMD_BCMFS setting is set to `y` in config/common_base file.
+
+* ``CONFIG_RTE_LIBRTE_PMD_BCMFS=y``
+
+Initialization
+--------------
+BCMFS crypto PMD depend upon the devices present in the path
+/sys/bus/platform/devices/fs<version>/<dev_name> on the platform.
+Each cryptodev PMD instance can be attached to the nodes present
+in the mentioned path.
doc/guides/cryptodevs/index.rst +1 -0
index a67ed5a28..5d7e028bd 100644
@@ -29,3 +29,4 @@ Crypto Device Drivers
     qat
     virtio
     zuc
+    bcmfs
drivers/crypto/bcmfs/Makefile new file +27 -0
new file mode 100644
index 000000000..781ee6efa
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2020 Broadcom
+# All rights reserved.
+#
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_bcmfs.a
+
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/crypto/bcmfs
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-y += bcmfs_logs.c
+SRCS-y += bcmfs_device.c
+
+LDLIBS += -lrte_eal -lrte_bus_vdev
+
+EXPORT_MAP := rte_pmd_bcmfs_version.map
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/crypto/bcmfs/bcmfs_device.c new file +256 -0

256 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h new file +40 -0
new file mode 100644
index 000000000..4b0c6d3ca
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_DEV_H_
+#define _BCMFS_DEV_H_
+
+#include <sys/queue.h>
+
+#include <rte_bus_vdev.h>
+
+#include "bcmfs_logs.h"
+
+/* max number of dev nodes */
+#define BCMFS_MAX_NODES		4
+#define BCMFS_MAX_PATH_LEN	512
+#define BCMFS_DEV_NAME_LEN	64
+
+/* Path for BCM-Platform device directory */
+#define SYSFS_BCM_PLTFORM_DEVICES    "/sys/bus/platform/devices"
+
+/* Supported devices */
+enum bcmfs_device_type {
+	BCMFS_SYM_FS4,
+	BCMFS_SYM_FS5,
+	BCMFS_UNKNOWN
+};
+
+struct bcmfs_device {
+	TAILQ_ENTRY(bcmfs_device) next;
+	/* Directoy path for vfio */
+	char dirname[BCMFS_MAX_PATH_LEN];
+	/* BCMFS device name */
+	char name[BCMFS_DEV_NAME_LEN];
+	/* Parent vdev */
+	struct rte_vdev_device *vdev;
+};
+
+#endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_logs.c new file +38 -0
new file mode 100644
index 000000000..86f4ff3b5
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <rte_log.h>
+#include <rte_hexdump.h>
+
+#include "bcmfs_logs.h"
+
+int bcmfs_conf_logtype;
+int bcmfs_dp_logtype;
+
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
+		const void *buf, unsigned int len)
+{
+	if (level > rte_log_get_global_level())
+		return 0;
+	if (level > (uint32_t)(rte_log_get_level(logtype)))
+		return 0;
+
+	rte_hexdump(rte_log_get_stream(), title, buf, len);
+	return 0;
+}
+
+RTE_INIT(bcmfs_device_init_log)
+{
+	/* Configuration and general logs */
+	bcmfs_conf_logtype = rte_log_register("pmd.bcmfs_config");
+	if (bcmfs_conf_logtype >= 0)
+		rte_log_set_level(bcmfs_conf_logtype, RTE_LOG_NOTICE);
+
+	/* data-path logs */
+	bcmfs_dp_logtype = rte_log_register("pmd.bcmfs_fp");
+	if (bcmfs_dp_logtype >= 0)
+		rte_log_set_level(bcmfs_dp_logtype, RTE_LOG_NOTICE);
+}
drivers/crypto/bcmfs/bcmfs_logs.h new file +34 -0
new file mode 100644
index 000000000..c03a49b75
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_LOGS_H_
+#define _BCMFS_LOGS_H_
+
+#include <rte_log.h>
+
+extern int bcmfs_conf_logtype;
+extern int bcmfs_dp_logtype;
+
+#define BCMFS_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_conf_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_dp_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_HEXDUMP_LOG(level, title, buf, len)	\
+	bcmfs_hexdump_log(RTE_LOG_ ## level, bcmfs_dp_logtype, title, buf, len)
+
+/**
+ * bcmfs_hexdump_log Dump out memory in a special hex dump format.
+ *
+ * The message will be sent to the stream used by the rte_log infrastructure.
+ */
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *heading,
+		  const void *buf, unsigned int len);
+
+#endif /* _BCMFS_LOGS_H_ */
drivers/crypto/bcmfs/meson.build new file +10 -0
new file mode 100644
index 000000000..a4bdd8ee5
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2020 Broadcom
+# All rights reserved.
+#
+
+deps += ['eal', 'bus_vdev']
+sources = files(
+		'bcmfs_logs.c',
+		'bcmfs_device.c'
+		)
drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map new file +3 -0
new file mode 100644
index 000000000..299ae632d
@@ -0,0 +1,3 @@
+DPDK_21.0 {
+	local: *;
+};
drivers/crypto/meson.build +2 -1
index a2423507a..8e06d0533 100644
@@ -23,7 +23,8 @@ drivers = ['aesni_gcm',
 	   'scheduler',
 	   'snow3g',
 	   'virtio',
-	   'zuc']
+	   'zuc',
+	   'bcmfs']
 
 std_deps = ['cryptodev'] # cryptodev pulls in all other needed deps
 config_flag_fmt = 'RTE_LIBRTE_@0@_PMD'
mk/rte.app.mk +1 -0
index 0ce8cf541..5e268f8c0 100644
@@ -308,6 +308,7 @@ ifeq ($(CONFIG_RTE_LIBRTE_SECURITY),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_CAAM_JR)   += -lrte_pmd_caam_jr
 endif # CONFIG_RTE_LIBRTE_SECURITY
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += -lrte_pmd_virtio_crypto
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BCMFS)      += -lrte_pmd_bcmfs
 endif # CONFIG_RTE_LIBRTE_CRYPTODEV
 
 ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y)
Signature · 1 line
2.17.1
#3 lore raw

PATCH 2/8 crypto/bcmfs: add vfio support

In reply to Vikas Gupta

Add vfio support for device.

---
 drivers/crypto/bcmfs/Makefile       |  1 +
 drivers/crypto/bcmfs/bcmfs_device.c |  5 ++
 drivers/crypto/bcmfs/bcmfs_device.h |  6 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c   | 94 +++++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_vfio.h   | 17 ++++++
 drivers/crypto/bcmfs/meson.build    |  3 +-
 6 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
drivers/crypto/bcmfs/Makefile +1 -0
index 781ee6efa..5f691f7ba 100644
@@ -19,6 +19,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API
 #
 SRCS-y += bcmfs_logs.c
 SRCS-y += bcmfs_device.c
+SRCS-y += bcmfs_vfio.c
 
 LDLIBS += -lrte_eal -lrte_bus_vdev
 
drivers/crypto/bcmfs/bcmfs_device.c +5 -0
index 47c776de6..3b5cc9e98 100644
@@ -11,6 +11,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -71,6 +72,10 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 
 	fsdev->vdev = vdev;
 
+	/* attach to VFIO */
+	if (bcmfs_attach_vfio(fsdev))
+		goto cleanup;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +6 -0
index 4b0c6d3ca..5232bdea5 100644
@@ -35,6 +35,12 @@ struct bcmfs_device {
 	char name[BCMFS_DEV_NAME_LEN];
 	/* Parent vdev */
 	struct rte_vdev_device *vdev;
+	/* vfio handle */
+	int vfio_dev_fd;
+	/* mapped address */
+	uint8_t *mmap_addr;
+	/* mapped size */
+	uint32_t mmap_size;
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_vfio.c new file +94 -0

94 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_vfio.h new file +17 -0
new file mode 100644
index 000000000..d0fdf6483
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_VFIO_H_
+#define _BCMFS_VFIO_H_
+
+/* Attach the bcmfs device to vfio */
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev);
+
+/* Release the bcmfs device from vfio */
+void
+bcmfs_release_vfio(struct bcmfs_device *dev);
+
+#endif /* _BCMFS_VFIO_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index a4bdd8ee5..fd39eba20 100644
@@ -6,5 +6,6 @@
 deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
-		'bcmfs_device.c'
+		'bcmfs_device.c',
+		'bcmfs_vfio.c'
 		)
Signature · 1 line
2.17.1
#4 lore raw

PATCH 3/8 crypto/bcmfs: add apis for queue pair management

In reply to Vikas Gupta

Add queue pair management APIs which will be used by Crypto device to manage h/w queues. A bcmfs device structure owns multiple queue-pairs based on the mapped address allocated to it.

---
 drivers/crypto/bcmfs/Makefile        |  28 ---
 drivers/crypto/bcmfs/bcmfs_device.c  |   4 +
 drivers/crypto/bcmfs/bcmfs_device.h  |   5 +
 drivers/crypto/bcmfs/bcmfs_hw_defs.h |  38 +++
 drivers/crypto/bcmfs/bcmfs_qp.c      | 345 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_qp.h      | 122 ++++++++++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 7 files changed, 516 insertions(+), 29 deletions(-)
 delete mode 100644 drivers/crypto/bcmfs/Makefile
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
drivers/crypto/bcmfs/Makefile deleted +0 -28
deleted file mode 100644
index 5f691f7ba..000000000
@@ -1,28 +0,0 @@
-# SPDX-License-Identifier: BSD-3-Clause
-# Copyright(C) 2020 Broadcom
-# All rights reserved.
-#
-
-include $(RTE_SDK)/mk/rte.vars.mk
-
-#
-# library name
-#
-LIB = librte_pmd_bcmfs.a
-
-CFLAGS += $(WERROR_FLAGS)
-CFLAGS += -I$(RTE_SDK)/drivers/crypto/bcmfs
-CFLAGS += -DALLOW_EXPERIMENTAL_API
-
-#
-# all source are stored in SRCS-y
-#
-SRCS-y += bcmfs_logs.c
-SRCS-y += bcmfs_device.c
-SRCS-y += bcmfs_vfio.c
-
-LDLIBS += -lrte_eal -lrte_bus_vdev
-
-EXPORT_MAP := rte_pmd_bcmfs_version.map
-
-include $(RTE_SDK)/mk/rte.lib.mk
drivers/crypto/bcmfs/bcmfs_device.c +4 -0
index 3b5cc9e98..b475c2933 100644
@@ -11,6 +11,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
@@ -76,6 +77,9 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 	if (bcmfs_attach_vfio(fsdev))
 		goto cleanup;
 
+	/* Maximum number of QPs supported */
+	fsdev->max_hw_qps = fsdev->mmap_size / BCMFS_HW_QUEUE_IO_ADDR_LEN;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +5 -0
index 5232bdea5..e03ce5b5b 100644
@@ -11,6 +11,7 @@
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES		4
@@ -41,6 +42,10 @@ struct bcmfs_device {
 	uint8_t *mmap_addr;
 	/* mapped size */
 	uint32_t mmap_size;
+	/* max number of h/w queue pairs detected */
+	uint16_t max_hw_qps;
+	/* current qpairs in use */
+	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_hw_defs.h new file +38 -0
new file mode 100644
index 000000000..ecb0c09ba
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_RM_DEFS_H_
+#define _BCMFS_RM_DEFS_H_
+
+#include <rte_atomic.h>
+#include <rte_byteorder.h>
+#include <rte_common.h>
+#include <rte_io.h>
+
+/* 32-bit MMIO register write */
+#define FS_MMIO_WRITE32(value, addr) rte_write32_relaxed((value), (addr))
+
+/* 32-bit MMIO register read */
+#define FS_MMIO_READ32(addr) rte_read32_relaxed((addr))
+
+#ifndef BIT
+#define BIT(nr)         (1UL << (nr))
+#endif
+
+#define FS_RING_REGS_SIZE		0x10000
+#define FS_RING_DESC_SIZE		8
+#define FS_RING_BD_ALIGN_ORDER		12
+#define FS_RING_BD_DESC_PER_REQ		32
+#define FS_RING_CMPL_ALIGN_ORDER	13
+#define FS_RING_CMPL_SIZE		(1024 * FS_RING_DESC_SIZE)
+#define FS_RING_MAX_REQ_COUNT		1024
+#define FS_RING_PAGE_SHFT		12
+#define FS_RING_PAGE_SIZE		BIT(FS_RING_PAGE_SHFT)
+
+/* Minimum and maximum number of requests supported */
+#define FS_RM_MAX_REQS			1024
+#define FS_RM_MIN_REQS			32
+
+#endif /* BCMFS_RM_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c new file +345 -0

345 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_qp.h new file +122 -0

122 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +2 -1
index fd39eba20..7e2bcbf14 100644
@@ -7,5 +7,6 @@ deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
-		'bcmfs_vfio.c'
+		'bcmfs_vfio.c',
+		'bcmfs_qp.c'
 		)
Signature · 1 line
2.17.1
#5 lore raw

PATCH 4/8 crypto/bcmfs: add hw queue pair operations

In reply to Vikas Gupta

Add queue pair operations exported by supported devices.

---
 drivers/crypto/bcmfs/bcmfs_dev_msg.h      |  29 +
 drivers/crypto/bcmfs/bcmfs_device.c       |  51 ++
 drivers/crypto/bcmfs/bcmfs_device.h       |  16 +
 drivers/crypto/bcmfs/bcmfs_qp.c           |   1 +
 drivers/crypto/bcmfs/bcmfs_qp.h           |   4 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c       | 742 ++++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c       | 677 ++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c |  82 +++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h |  46 ++
 drivers/crypto/bcmfs/meson.build          |   5 +-
 10 files changed, 1652 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
drivers/crypto/bcmfs/bcmfs_dev_msg.h new file +29 -0
new file mode 100644
index 000000000..5b50bde35
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_DEV_MSG_H_
+#define _BCMFS_DEV_MSG_H_
+
+#define MAX_SRC_ADDR_BUFFERS    8
+#define MAX_DST_ADDR_BUFFERS    3
+
+struct bcmfs_qp_message {
+	/** Physical address of each source */
+	uint64_t srcs_addr[MAX_SRC_ADDR_BUFFERS];
+	/** Length of each sources */
+	uint32_t srcs_len[MAX_SRC_ADDR_BUFFERS];
+	/** Total number of sources */
+	unsigned int srcs_count;
+	/** Physical address of each destination */
+	uint64_t dsts_addr[MAX_DST_ADDR_BUFFERS];
+	/** Length of each destination */
+	uint32_t dsts_len[MAX_DST_ADDR_BUFFERS];
+	/** Total number of destinations */
+	unsigned int dsts_count;
+
+	void *ctx;
+};
+
+#endif /* _BCMFS_DEV_MSG_H_ */
drivers/crypto/bcmfs/bcmfs_device.c +51 -0

69 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h +16 -0
index e03ce5b5b..96beb10fa 100644
@@ -8,6 +8,7 @@
 
 #include <sys/queue.h>
 
+#include <rte_spinlock.h>
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
@@ -28,6 +29,19 @@ enum bcmfs_device_type {
 	BCMFS_UNKNOWN
 };
 
+/* A table to store registered queue pair opertations */
+struct bcmfs_hw_queue_pair_ops_table {
+	rte_spinlock_t tl;
+	/* Number of used ops structs in the table. */
+	uint32_t num_ops;
+	 /*  Storage for all possible ops structs. */
+	struct bcmfs_hw_queue_pair_ops qp_ops[BCMFS_MAX_NODES];
+};
+
+/* HW queue pair ops register function */
+int bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops
+				     *qp_ops);
+
 struct bcmfs_device {
 	TAILQ_ENTRY(bcmfs_device) next;
 	/* Directoy path for vfio */
@@ -46,6 +60,8 @@ struct bcmfs_device {
 	uint16_t max_hw_qps;
 	/* current qpairs in use */
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
+	/* queue pair ops exported by symmetric crypto hw */
+	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +1 -0
index 864e7bb74..ec1327b78 100644
@@ -227,6 +227,7 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	qp->qpair_id = queue_pair_id;
 	qp->ioreg = qp_conf->iobase;
 	qp->nb_descriptors = nb_descriptors;
+	qp->ops = qp_conf->ops;
 
 	qp->stats.enqueued_count = 0;
 	qp->stats.dequeued_count = 0;
drivers/crypto/bcmfs/bcmfs_qp.h +4 -0
index 027d7a50c..e4b0c3f2f 100644
@@ -44,6 +44,8 @@ struct bcmfs_qp_config {
 	uint16_t nb_descriptors;
 	/* Maximum number of h/w descriptors needed by a request */
 	uint16_t max_descs_req;
+	/* h/w ops associated with qp */
+	struct bcmfs_hw_queue_pair_ops *ops;
 };
 
 struct bcmfs_queue {
@@ -61,6 +63,8 @@ struct bcmfs_queue {
 		/* s/w pointer for completion h/w queue*/
 		uint32_t cmpl_read_ptr;
 	};
+	/* number of inflight descriptor accumulated  before next db ring */
+	uint16_t descs_inflight;
 	/* Memzone name */
 	char memz_name[RTE_MEMZONE_NAMESIZE];
 };
drivers/crypto/bcmfs/hw/bcmfs4_rm.c new file +742 -0

742 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs5_rm.c new file +677 -0

677 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.c new file +82 -0

82 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.h new file +46 -0

46 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +4 -1
index 7e2bcbf14..cd58bd5e2 100644
@@ -8,5 +8,8 @@ sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
 		'bcmfs_vfio.c',
-		'bcmfs_qp.c'
+		'bcmfs_qp.c',
+		'hw/bcmfs4_rm.c',
+		'hw/bcmfs5_rm.c',
+		'hw/bcmfs_rm_common.c'
 		)
Signature · 1 line
2.17.1
#6 lore raw

PATCH 5/8 crypto/bcmfs: create a symmetric cryptodev

In reply to Vikas Gupta

Create a symmetric crypto device and supported cryptodev ops.

---
 drivers/crypto/bcmfs/bcmfs_device.c  |  15 ++
 drivers/crypto/bcmfs/bcmfs_device.h  |   9 +
 drivers/crypto/bcmfs/bcmfs_qp.c      |  37 +++
 drivers/crypto/bcmfs/bcmfs_qp.h      |  16 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c | 387 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h |  38 +++
 drivers/crypto/bcmfs/bcmfs_sym_req.h |  22 ++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 8 files changed, 526 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
drivers/crypto/bcmfs/bcmfs_device.c +15 -0
index bd2d64acf..c9263ec28 100644
@@ -13,6 +13,7 @@
 #include "bcmfs_logs.h"
 #include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
+#include "bcmfs_sym_pmd.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -239,6 +240,7 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 	char out_dirname[BCMFS_MAX_PATH_LEN];
 	uint32_t fsdev_dev[BCMFS_MAX_NODES];
 	enum bcmfs_device_type dtype;
+	int err;
 	int i = 0;
 	int dev_idx;
 	int count = 0;
@@ -290,7 +292,20 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 		return -ENODEV;
 	}
 
+	err = bcmfs_sym_dev_create(fsdev);
+	if (err) {
+		BCMFS_LOG(WARNING,
+			  "Failed to create BCMFS SYM PMD for device %s",
+			  fsdev->name);
+		goto pmd_create_fail;
+	}
+
 	return 0;
+
+pmd_create_fail:
+	fsdev_release(fsdev);
+
+	return err;
 }
 
 static int
drivers/crypto/bcmfs/bcmfs_device.h +9 -0
index 96beb10fa..37907b91f 100644
@@ -62,6 +62,15 @@ struct bcmfs_device {
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 	/* queue pair ops exported by symmetric crypto hw */
 	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
+	/* a cryptodevice attached to bcmfs device */
+	struct rte_cryptodev *cdev;
+	/* a rte_device to register with cryptodev */
+	struct rte_device sym_rte_dev;
+	/* private info to keep with cryptodev */
+	struct bcmfs_sym_dev_private *sym_dev;
 };
 
+/* stats exported by device */
+
+
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +37 -0
index ec1327b78..cb5ff6c61 100644
@@ -344,3 +344,40 @@ bcmfs_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops)
 
 	return deq;
 }
+
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats)
+{
+	int i;
+
+	if (stats == NULL) {
+		BCMFS_LOG(ERR, "invalid param: stats %p",
+			  stats);
+		return;
+	}
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+
+		stats->enqueued_count += qp[i]->stats.enqueued_count;
+		stats->dequeued_count += qp[i]->stats.dequeued_count;
+		stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
+		stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
+	}
+}
+
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp)
+{
+	int i;
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+		memset(&qp[i]->stats, 0, sizeof(qp[i]->stats));
+	}
+}
drivers/crypto/bcmfs/bcmfs_qp.h +16 -0
index e4b0c3f2f..fec58ca71 100644
@@ -24,6 +24,13 @@ enum bcmfs_queue_type {
 	BCMFS_RM_CPLQ
 };
 
+#define BCMFS_QP_IOBASE_XLATE(base, idx)	\
+		((base) + ((idx) * BCMFS_HW_QUEUE_IO_ADDR_LEN))
+
+/* Max pkts for preprocessing before submitting to h/w qp */
+#define BCMFS_MAX_REQS_BUFF	64
+
+/* qp stats */
 struct bcmfs_qp_stats {
 	/* Count of all operations enqueued */
 	uint64_t enqueued_count;
@@ -92,6 +99,10 @@ struct bcmfs_qp {
 	struct bcmfs_qp_stats stats;
 	/* h/w ops associated with qp */
 	struct bcmfs_hw_queue_pair_ops *ops;
+	/* bcmfs requests pool*/
+	struct rte_mempool *sr_mp;
+	/* a temporary buffer to keep message pointers */
+	struct bcmfs_qp_message *infl_msgs[BCMFS_MAX_REQS_BUFF];
 
 } __rte_cache_aligned;
 
@@ -123,4 +134,9 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	       uint16_t queue_pair_id,
 	       struct bcmfs_qp_config *bcmfs_conf);
 
+/* stats functions*/
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats);
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp);
+
 #endif /* _BCMFS_QP_H_ */
drivers/crypto/bcmfs/bcmfs_sym_pmd.c new file +387 -0

387 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.h new file +38 -0
new file mode 100644
index 000000000..65d704609
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_PMD_H_
+#define _BCMFS_SYM_PMD_H_
+
+#include <rte_cryptodev.h>
+
+#include "bcmfs_device.h"
+
+#define CRYPTODEV_NAME_BCMFS_SYM_PMD	crypto_bcmfs
+
+#define BCMFS_CRYPTO_MAX_HW_DESCS_PER_REQ	16
+
+extern uint8_t cryptodev_bcmfs_driver_id;
+
+/** private data structure for a BCMFS device.
+ *  This BCMFS device is a device offering only symmetric crypto service,
+ *  there can be one of these on each bcmfs_pci_device (VF).
+ */
+struct bcmfs_sym_dev_private {
+	/* The bcmfs device hosting the service */
+	struct bcmfs_device *fsdev;
+	/* Device instance for this rte_cryptodev */
+	uint8_t sym_dev_id;
+	/* BCMFS device symmetric crypto capabilities */
+	const struct rte_cryptodev_capabilities *fsdev_capabilities;
+};
+
+int
+bcmfs_sym_dev_create(struct bcmfs_device *fdev);
+
+int
+bcmfs_sym_dev_destroy(struct bcmfs_device *fdev);
+
+#endif /* _BCMFS_SYM_PMD_H_ */
drivers/crypto/bcmfs/bcmfs_sym_req.h new file +22 -0
new file mode 100644
index 000000000..0f0b051f1
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_REQ_H_
+#define _BCMFS_SYM_REQ_H_
+
+#include "bcmfs_dev_msg.h"
+
+/*
+ * This structure hold the supportive data required to process a
+ * rte_crypto_op
+ */
+struct bcmfs_sym_request {
+	/* bcmfs qp message for h/w queues to process */
+	struct bcmfs_qp_message msgs;
+	/* crypto op */
+	struct rte_crypto_op *op;
+};
+
+#endif /* _BCMFS_SYM_REQ_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index cd58bd5e2..d9a3d73e9 100644
@@ -11,5 +11,6 @@ sources = files(
 		'bcmfs_qp.c',
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
-		'hw/bcmfs_rm_common.c'
+		'hw/bcmfs_rm_common.c',
+		'bcmfs_sym_pmd.c'
 		)
Signature · 1 line
2.17.1
#7 lore raw

PATCH 6/8 crypto/bcmfs: add session handling and capabilities

In reply to Vikas Gupta

Add session handling and capabilities supported by crypto h/w accelerator.

---
 doc/guides/cryptodevs/bcmfs.rst               |  46 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |  56 ++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c | 764 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         | 170 ++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          |  13 +
 drivers/crypto/bcmfs/bcmfs_sym_session.c      | 426 ++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      |  99 +++
 drivers/crypto/bcmfs/meson.build              |   4 +-
 9 files changed, 1593 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
doc/guides/cryptodevs/bcmfs.rst +46 -0
index 752ce028a..2488b19f7 100644
@@ -18,9 +18,55 @@ CONFIG_RTE_LIBRTE_PMD_BCMFS setting is set to `y` in config/common_base file.
 
 * ``CONFIG_RTE_LIBRTE_PMD_BCMFS=y``
 
+Features
+~~~~~~~~
+
+The BCMFS SYM PMD has support for:
+
+Cipher algorithms:
+
+* ``RTE_CRYPTO_CIPHER_3DES_CBC``
+* ``RTE_CRYPTO_CIPHER_3DES_CTR``
+* ``RTE_CRYPTO_CIPHER_AES128_CBC``
+* ``RTE_CRYPTO_CIPHER_AES192_CBC``
+* ``RTE_CRYPTO_CIPHER_AES256_CBC``
+* ``RTE_CRYPTO_CIPHER_AES128_CTR``
+* ``RTE_CRYPTO_CIPHER_AES192_CTR``
+* ``RTE_CRYPTO_CIPHER_AES256_CTR``
+* ``RTE_CRYPTO_CIPHER_AES_XTS``
+* ``RTE_CRYPTO_CIPHER_DES_CBC``
+
+Hash algorithms:
+
+* ``RTE_CRYPTO_AUTH_SHA1``
+* ``RTE_CRYPTO_AUTH_SHA1_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA224``
+* ``RTE_CRYPTO_AUTH_SHA224_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA256``
+* ``RTE_CRYPTO_AUTH_SHA256_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA384``
+* ``RTE_CRYPTO_AUTH_SHA384_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA512``
+* ``RTE_CRYPTO_AUTH_SHA512_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_XCBC_MAC``
+* ``RTE_CRYPTO_AUTH_MD5_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_GMAC``
+* ``RTE_CRYPTO_AUTH_AES_CMAC``
+
+Supported AEAD algorithms:
+
+* ``RTE_CRYPTO_AEAD_AES_GCM``
+* ``RTE_CRYPTO_AEAD_AES_CCM``
+
 Initialization
 --------------
 BCMFS crypto PMD depend upon the devices present in the path
 /sys/bus/platform/devices/fs<version>/<dev_name> on the platform.
 Each cryptodev PMD instance can be attached to the nodes present
 in the mentioned path.
+
+Limitations
+~~~~~~~~~~~
+
+* Only supports the session-oriented API implementation (session-less APIs are not supported).
+* CCM is not supported on Broadcom`s SoCs having FlexSparc4 unit.
doc/guides/cryptodevs/features/bcmfs.ini new file +56 -0

56 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.c new file +764 -0

764 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.h new file +16 -0
new file mode 100644
index 000000000..3ff61b7d2
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_CAPABILITIES_H_
+#define _BCMFS_SYM_CAPABILITIES_H_
+
+/*
+ * Get capabilities list for the device
+ *
+ */
+const struct rte_cryptodev_capabilities *bcmfs_sym_get_capabilities(void);
+
+#endif /* _BCMFS_SYM_CAPABILITIES_H__ */
+
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +170 -0

170 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.c +13 -0
index 0f96915f7..381ca8ea4 100644
@@ -14,6 +14,8 @@
 #include "bcmfs_qp.h"
 #include "bcmfs_sym_pmd.h"
 #include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+#include "bcmfs_sym_capabilities.h"
 
 uint8_t cryptodev_bcmfs_driver_id;
 
@@ -65,6 +67,7 @@ bcmfs_sym_dev_info_get(struct rte_cryptodev *dev,
 		dev_info->max_nb_queue_pairs = fsdev->max_hw_qps;
 		/* No limit of number of sessions */
 		dev_info->sym.max_nb_sessions = 0;
+		dev_info->capabilities = bcmfs_sym_get_capabilities();
 	}
 }
 
@@ -228,6 +231,10 @@ static struct rte_cryptodev_ops crypto_bcmfs_ops = {
 	/* Queue-Pair management */
 	.queue_pair_setup       = bcmfs_sym_qp_setup,
 	.queue_pair_release     = bcmfs_sym_qp_release,
+	/* Crypto session related operations */
+	.sym_session_get_size   = bcmfs_sym_session_get_private_size,
+	.sym_session_configure  = bcmfs_sym_session_configure,
+	.sym_session_clear      = bcmfs_sym_session_clear
 };
 
 /** Enqueue burst */
@@ -239,6 +246,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	int i, j;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
+	struct bcmfs_sym_session *sess;
 	struct bcmfs_qp *qp = (struct bcmfs_qp *)queue_pair;
 
 	if (nb_ops == 0)
@@ -252,6 +260,10 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		nb_ops = qp->nb_descriptors - qp->nb_pending_requests;
 
 	for (i = 0; i < nb_ops; i++) {
+		sess = bcmfs_sym_get_session(ops[i]);
+		if (unlikely(sess == NULL))
+			goto enqueue_err;
+
 		if (rte_mempool_get(qp->sr_mp, (void **)&sreq))
 			goto enqueue_err;
 
@@ -356,6 +368,7 @@ bcmfs_sym_dev_create(struct bcmfs_device *fsdev)
 	fsdev->sym_dev = internals;
 
 	internals->sym_dev_id = cryptodev->data->dev_id;
+	internals->fsdev_capabilities = bcmfs_sym_get_capabilities();
 
 	BCMFS_LOG(DEBUG, "Created bcmfs-sym device %s as cryptodev instance %d",
 		  cryptodev->data->name, internals->sym_dev_id);
drivers/crypto/bcmfs/bcmfs_sym_session.c new file +426 -0

426 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_session.h new file +99 -0

99 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +3 -1
index d9a3d73e9..2e86c733e 100644
@@ -12,5 +12,7 @@ sources = files(
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
 		'hw/bcmfs_rm_common.c',
-		'bcmfs_sym_pmd.c'
+		'bcmfs_sym_pmd.c',
+		'bcmfs_sym_capabilities.c',
+		'bcmfs_sym_session.c'
 		)
Signature · 1 line
2.17.1
#8 lore raw

PATCH 7/8 crypto/bcmfs: add crypto h/w module

In reply to Vikas Gupta

Add crypto h/w module to process crypto op. Crypto op is processed via sym_engine module before submitting the crypto request to h/w queues.

---
 drivers/crypto/bcmfs/bcmfs_sym.c        | 316 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_defs.h   |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_engine.c | 994 ++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h | 103 +++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c    |  26 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h    |  40 +
 drivers/crypto/bcmfs/meson.build        |   4 +-
 7 files changed, 1498 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
drivers/crypto/bcmfs/bcmfs_sym.c new file +316 -0
new file mode 100644
index 000000000..8f9415b5e
@@ -0,0 +1,316 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <stdbool.h>
+
+#include <rte_byteorder.h>
+#include <rte_crypto_sym.h>
+#include <rte_cryptodev.h>
+#include <rte_mbuf.h>
+#include <rte_mempool.h>
+
+#include "bcmfs_sym_defs.h"
+#include "bcmfs_sym_engine.h"
+#include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+
+/** Process cipher operation */
+static int
+process_crypto_cipher_op(struct rte_crypto_op *op,
+			 struct rte_mbuf *mbuf_src,
+			 struct rte_mbuf *mbuf_dst,
+			 struct bcmfs_sym_session *sess,
+			 struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv, key;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+	fsattr_pa(&dst) = rte_pktmbuf_iova(mbuf_dst);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						     uint8_t *,
+						     sess->cipher.iv.offset);
+
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&key) = sess->cipher.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->cipher.key.length;
+
+	rc = bcmfs_crypto_build_cipher_req(req, sess->cipher.algo,
+					   sess->cipher.direction, &src,
+					   &dst, &key, &iv);
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process auth operation */
+static int
+process_crypto_auth_op(struct rte_crypto_op *op,
+			   struct rte_mbuf *mbuf_src,
+			   struct bcmfs_sym_session *sess,
+			   struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, mac, key;
+
+	fsattr_sz(&src) = op->sym->auth.data.length;
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset(mbuf_src,
+						   uint8_t *,
+						   op->sym->auth.data.offset);
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+
+	if (!sess->auth.operation) {
+		fsattr_va(&mac) = op->sym->auth.digest.data;
+		fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&mac) = sess->auth.digest_length;
+	} else {
+		fsattr_va(&dst) = op->sym->auth.digest.data;
+		fsattr_pa(&dst) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&dst) = sess->auth.digest_length;
+	}
+
+	fsattr_va(&key) = sess->auth.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->auth.key.length;
+
+	/* AES-GMAC uses AES-GCM-128 authenticator */
+	if (sess->auth.algo == BCMFS_CRYPTO_AUTH_AES_GMAC) {
+		struct fsattr  iv;
+		fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+							    uint8_t *,
+							    sess->auth.iv.offset);
+		fsattr_pa(&iv) = 0;
+		fsattr_sz(&iv) = sess->auth.iv.length;
+
+		rc = bcmfs_crypto_build_aead_request(req,
+						     BCMFS_CRYPTO_CIPHER_NONE,
+						     0,
+						     BCMFS_CRYPTO_AUTH_AES_GMAC,
+						     sess->auth.operation,
+						     &src, NULL, NULL, &key,
+						     &iv, NULL,
+						     sess->auth.operation ?
+							(&dst) : &(mac),
+						     0);
+	} else {
+		rc = bcmfs_crypto_build_auth_req(req, sess->auth.algo,
+						 sess->auth.operation,
+						 &src,
+						 (sess->auth.operation) ? (&dst) : NULL,
+						 (sess->auth.operation) ? NULL  : (&mac),
+						 &key);
+	}
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process combined/chained mode operation */
+static int
+process_crypto_combined_op(struct rte_crypto_op *op,
+			   struct rte_mbuf *mbuf_src,
+			   struct rte_mbuf *mbuf_dst,
+			   struct bcmfs_sym_session *sess,
+			   struct bcmfs_sym_request *req)
+{
+	int rc = 0, aad_size = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr cipher_key, aad, mac, auth_key;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->cipher.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						sym_op->cipher.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						     uint8_t *,
+						     sess->cipher.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&cipher_key) = sess->cipher.key.data;
+	fsattr_pa(&cipher_key) = 0;
+	fsattr_sz(&cipher_key) = sess->cipher.key.length;
+
+	fsattr_va(&auth_key) = sess->auth.key.data;
+	fsattr_pa(&auth_key) = 0;
+	fsattr_sz(&auth_key) = sess->auth.key.length;
+
+	fsattr_va(&mac) = op->sym->auth.digest.data;
+	fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+	fsattr_sz(&mac) = sess->auth.digest_length;
+
+	aad_size = sym_op->auth.data.length - sym_op->cipher.data.length;
+
+	if (aad_size > 0) {
+		fsattr_sz(&aad) =  aad_size;
+		fsattr_va(&aad) = rte_pktmbuf_mtod_offset
+						(mbuf_src,
+						 uint8_t *,
+						sym_op->auth.data.offset);
+		fsattr_pa(&aad) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->auth.data.offset);
+	}
+
+	rc = bcmfs_crypto_build_aead_request(req, sess->cipher.algo,
+					     sess->cipher.direction,
+					     sess->auth.algo,
+					     sess->auth.operation,
+					     &src, &dst, &cipher_key,
+					     &auth_key, &iv,
+					     (aad_size > 0) ? (&aad) : NULL,
+					     &mac, sess->cipher_first);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process AEAD operation */
+static int
+process_crypto_aead_op(struct rte_crypto_op *op,
+		       struct rte_mbuf *mbuf_src,
+		       struct rte_mbuf *mbuf_dst,
+		       struct bcmfs_sym_session *sess,
+		       struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr cipher_key, aad, mac, auth_key;
+	enum bcmfs_crypto_cipher_op cipher_op;
+	enum bcmfs_crypto_auth_op auth_op;
+
+	if (sess->cipher.direction) {
+		auth_op = BCMFS_CRYPTO_AUTH_OP_VERIFY;
+		cipher_op = BCMFS_CRYPTO_CIPHER_OP_DECRYPT;
+	} else {
+		auth_op = BCMFS_CRYPTO_AUTH_OP_GENERATE;
+		cipher_op = BCMFS_CRYPTO_CIPHER_OP_ENCRYPT;
+	}
+
+	fsattr_sz(&src) = sym_op->aead.data.length;
+	fsattr_sz(&dst) = sym_op->aead.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 sym_op->aead.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 sym_op->aead.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->aead.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						sym_op->aead.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						    uint8_t *,
+						    sess->cipher.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&cipher_key) = sess->cipher.key.data;
+	fsattr_pa(&cipher_key) = 0;
+	fsattr_sz(&cipher_key) = sess->cipher.key.length;
+
+	fsattr_va(&auth_key) = sess->auth.key.data;
+	fsattr_pa(&auth_key) = 0;
+	fsattr_sz(&auth_key) = sess->auth.key.length;
+
+	fsattr_va(&mac) = op->sym->aead.digest.data;
+	fsattr_pa(&mac) = op->sym->aead.digest.phys_addr;
+	fsattr_sz(&mac) = sess->auth.digest_length;
+
+	fsattr_va(&aad) = op->sym->aead.aad.data;
+	fsattr_pa(&aad) = op->sym->aead.aad.phys_addr;
+	fsattr_sz(&aad) = sess->aead.aad_length;
+
+	rc = bcmfs_crypto_build_aead_request(req, sess->cipher.algo,
+					     cipher_op, sess->auth.algo,
+					     auth_op, &src, &dst, &cipher_key,
+					     &auth_key, &iv, &aad, &mac,
+					     sess->cipher.direction ? 0 : 1);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process crypto operation for mbuf */
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req)
+{
+	struct rte_mbuf *msrc, *mdst;
+	int rc = 0;
+
+	msrc = op->sym->m_src;
+	mdst = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src;
+	op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+
+	switch (sess->chain_order) {
+	case BCMFS_SYM_CHAIN_ONLY_CIPHER:
+		rc = process_crypto_cipher_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_ONLY_AUTH:
+		rc = process_crypto_auth_op(op, msrc, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_CIPHER_AUTH:
+	case BCMFS_SYM_CHAIN_AUTH_CIPHER:
+		rc = process_crypto_combined_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_AEAD:
+		rc = process_crypto_aead_op(op, msrc, mdst, sess, req);
+		break;
+	default:
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+		break;
+	}
+
+	return rc;
+}
drivers/crypto/bcmfs/bcmfs_sym_defs.h +16 -0
index b5657a9bc..8824521dd 100644
@@ -15,6 +15,18 @@
 #define BCMFS_MAX_IV_SIZE	16
 #define BCMFS_MAX_DIGEST_SIZE	64
 
+struct bcmfs_sym_session;
+struct bcmfs_sym_request;
+
+/** Crypto Request processing successful. */
+#define BCMFS_SYM_RESPONSE_SUCCESS               (0)
+/** Crypot Request processing protocol failure. */
+#define BCMFS_SYM_RESPONSE_PROTO_FAILURE         (1)
+/** Crypot Request processing completion failure. */
+#define BCMFS_SYM_RESPONSE_COMPL_ERROR           (2)
+/** Crypot Request processing hash tag check error. */
+#define BCMFS_SYM_RESPONSE_HASH_TAG_ERROR        (3)
+
 /** Symmetric Cipher Direction */
 enum bcmfs_crypto_cipher_op {
 	/** Encrypt cipher operation */
@@ -167,4 +179,8 @@ enum bcmfs_sym_crypto_class {
 	BCMFS_CRYPTO_AEAD,
 };
 
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req);
 #endif /* _BCMFS_SYM_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_sym_engine.c new file +994 -0

994 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_engine.h new file +103 -0

103 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.c +26 -0
index 381ca8ea4..568797b4f 100644
@@ -132,6 +132,12 @@ static void
 spu_req_init(struct bcmfs_sym_request *sr, rte_iova_t iova __rte_unused)
 {
 	memset(sr, 0, sizeof(*sr));
+	sr->fptr = iova;
+	sr->cptr = iova + offsetof(struct bcmfs_sym_request, cipher_key);
+	sr->aptr = iova + offsetof(struct bcmfs_sym_request, auth_key);
+	sr->iptr = iova + offsetof(struct bcmfs_sym_request, iv);
+	sr->dptr = iova + offsetof(struct bcmfs_sym_request, digest);
+	sr->rptr = iova + offsetof(struct bcmfs_sym_request, resp);
 }
 
 static void
@@ -244,6 +250,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 			       uint16_t nb_ops)
 {
 	int i, j;
+	int retval;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
 	struct bcmfs_sym_session *sess;
@@ -273,6 +280,11 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		/* save context */
 		qp->infl_msgs[i] = &sreq->msgs;
 		qp->infl_msgs[i]->ctx = (void *)sreq;
+
+		/* pre process the request crypto h/w acceleration */
+		retval = bcmfs_process_sym_crypto_op(ops[i], sess, sreq);
+		if (unlikely(retval < 0))
+			goto enqueue_err;
 	}
 	/* Send burst request to hw QP */
 	enq = bcmfs_enqueue_op_burst(qp, (void **)qp->infl_msgs, i);
@@ -289,6 +301,17 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	return enq;
 }
 
+static void bcmfs_sym_set_request_status(struct rte_crypto_op *op,
+					 struct bcmfs_sym_request *out)
+{
+	if (*out->resp == BCMFS_SYM_RESPONSE_SUCCESS)
+		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+	else if (*out->resp == BCMFS_SYM_RESPONSE_HASH_TAG_ERROR)
+		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+	else
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+}
+
 static uint16_t
 bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 			       struct rte_crypto_op **ops,
@@ -308,6 +331,9 @@ bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 	for (i = 0; i < deq; i++) {
 		sreq = (struct bcmfs_sym_request *)qp->infl_msgs[i]->ctx;
 
+		/* set the status based on the response from the crypto h/w */
+		bcmfs_sym_set_request_status(sreq->op, sreq);
+
 		ops[pkts++] = sreq->op;
 
 		rte_mempool_put(qp->sr_mp, sreq);
drivers/crypto/bcmfs/bcmfs_sym_req.h +40 -0
index 0f0b051f1..e53c50adc 100644
@@ -6,13 +6,53 @@
 #ifndef _BCMFS_SYM_REQ_H_
 #define _BCMFS_SYM_REQ_H_
 
+#include <rte_cryptodev.h>
+
 #include "bcmfs_dev_msg.h"
+#include "bcmfs_sym_defs.h"
+
+/* Fixed SPU2 Metadata */
+struct spu2_fmd {
+	uint64_t ctrl0;
+	uint64_t ctrl1;
+	uint64_t ctrl2;
+	uint64_t ctrl3;
+};
 
 /*
  * This structure hold the supportive data required to process a
  * rte_crypto_op
  */
 struct bcmfs_sym_request {
+	/* spu2 engine related data */
+	struct spu2_fmd fmd;
+	/* cipher key */
+	uint8_t cipher_key[BCMFS_MAX_KEY_SIZE];
+	/* auth key */
+	uint8_t auth_key[BCMFS_MAX_KEY_SIZE];
+	/* iv key */
+	uint8_t iv[BCMFS_MAX_IV_SIZE];
+	/* digest data output from crypto h/w */
+	uint8_t digest[BCMFS_MAX_DIGEST_SIZE];
+	/* 2-Bytes response from crypto h/w */
+	uint8_t resp[2];
+	/*
+	 * Below are all iovas for above members
+	 * from top
+	 */
+	/* iova for fmd */
+	rte_iova_t fptr;
+	/* iova for cipher key */
+	rte_iova_t cptr;
+	/* iova for auth key */
+	rte_iova_t aptr;
+	/* iova for iv key */
+	rte_iova_t iptr;
+	/* iova for digest */
+	rte_iova_t dptr;
+	/* iova for response */
+	rte_iova_t rptr;
+
 	/* bcmfs qp message for h/w queues to process */
 	struct bcmfs_qp_message msgs;
 	/* crypto op */
drivers/crypto/bcmfs/meson.build +3 -1
index 2e86c733e..7aa0f05db 100644
@@ -14,5 +14,7 @@ sources = files(
 		'hw/bcmfs_rm_common.c',
 		'bcmfs_sym_pmd.c',
 		'bcmfs_sym_capabilities.c',
-		'bcmfs_sym_session.c'
+		'bcmfs_sym_session.c',
+		'bcmfs_sym.c',
+		'bcmfs_sym_engine.c'
 		)
Signature · 1 line
2.17.1
#9 lore raw

PATCH 8/8 crypto/bcmfs: add crypto pmd into cryptodev test

In reply to Vikas Gupta

Add test suites for supported algorithms by bcmfs crypto pmd

---
 app/test/test_cryptodev.c | 261 ++++++++++++++++++++++++++++++++++++++
 app/test/test_cryptodev.h |   1 +
 2 files changed, 262 insertions(+)
app/test/test_cryptodev.c +261 -0
index 70bf6fe2c..6e7d8471c 100644
@@ -12681,6 +12681,250 @@ static struct unit_test_suite cryptodev_nitrox_testsuite  = {
 	}
 };
 
+static struct unit_test_suite cryptodev_bcmfs_testsuite  = {
+	.suite_name = "Crypto BCMFS Unit Test Suite",
+	.setup = testsuite_setup,
+	.teardown = testsuite_teardown,
+	.unit_test_cases = {
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			     test_device_configure_invalid_dev_id),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+				test_device_configure_invalid_queue_pair_ids),
+
+		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
+
+		/** AES GCM Authenticated Encryption */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_7),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_8),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_J0_authenticated_encryption_test_case_1),
+
+		/** AES GCM Authenticated Decryption */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_7),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_8),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_J0_authenticated_decryption_test_case_1),
+
+		/** AES GCM Authenticated Encryption 192 bits key */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_7),
+
+		/** AES GCM Authenticated Decryption 192 bits key */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_7),
+
+		/** AES GCM Authenticated Encryption 256 bits key */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_7),
+
+		/** AES GCM Authenticated Decryption 256 bits key */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_7),
+
+		/** AES GCM Authenticated Encryption big aad size */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_aad_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_aad_2),
+
+		/** AES GCM Authenticated Decryption big aad size */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_aad_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_aad_2),
+
+		/** Out of place tests */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_oop_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_oop_test_case_1),
+
+		/** AES GMAC Authentication */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_4),
+
+		/** Negative tests */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			authentication_verify_HMAC_SHA1_fail_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_iv_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_aad_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_tag_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_iv_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_aad_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_tag_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			authentication_verify_AES128_GMAC_fail_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			authentication_verify_AES128_GMAC_fail_tag_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
+
+		/** AES GMAC Authentication */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_4),
+
+		/** HMAC_MD5 Authentication */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_MD5_HMAC_generate_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_MD5_HMAC_verify_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_MD5_HMAC_generate_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_MD5_HMAC_verify_case_2),
+
+		/** Mixed CIPHER + HASH algorithms */
+		/** AUTH AES CMAC + CIPHER AES CTR */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
+
+		/** AUTH NULL + CIPHER AES CTR */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_auth_null_cipher_aes_ctr_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_verify_auth_null_cipher_aes_ctr_test_case_1),
+
+		/** AUTH AES CMAC + CIPHER NULL */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_auth_aes_cmac_cipher_null_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_verify_auth_aes_cmac_cipher_null_test_case_1),
+
+		TEST_CASES_END() /**< NULL terminate unit test array */
+	}
+};
+
 static int
 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
 {
@@ -13041,6 +13285,22 @@ test_cryptodev_nitrox(void)
 	return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
 }
 
+static int
+test_cryptodev_bcmfs(void)
+{
+	gbl_driver_id =	rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
+
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded. Check if "
+				"CONFIG_RTE_LIBRTE_PMD_BCMFS is enabled "
+				"in config file to run this testsuite.\n");
+		return TEST_FAILED;
+	}
+
+	return unit_test_suite_runner(&cryptodev_bcmfs_testsuite);
+}
+
 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
@@ -13063,3 +13323,4 @@ REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
+REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
app/test/test_cryptodev.h +1 -0
index 41542e055..c58126368 100644
@@ -70,6 +70,7 @@
 #define CRYPTODEV_NAME_OCTEONTX2_PMD	crypto_octeontx2
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 #define CRYPTODEV_NAME_NITROX_PMD	crypto_nitrox_sym
+#define CRYPTODEV_NAME_BCMFS_PMD	crypto_bcmfs
 
 /**
  * Write (spread) data from buffer to mbuf data
Signature · 1 line
2.17.1
#10 lore raw

Re: [dpdk-dev] [PATCH v1 8/8] crypto/bcmfs: add crypto pmd into cryptodev test

Quoted 10 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Vikas Gupta
Sent: Wednesday, 12 August, 2020 08:31
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; Vikas Gupta <[email protected]>; Raveendra Padasalagi <[email protected]>
Subject: [dpdk-dev] [PATCH v1 8/8] crypto/bcmfs: add crypto pmd into cryptodev test

Quoted 8 lines

Add test suites for supported algorithms by bcmfs crypto pmd

Signed-off-by Raveendra Padasalagi

<[email protected]>

---
 app/test/test_cryptodev.c | 261

[Adam] The test suites set was refactored in recent months to use one big list of tests and run/skip them depending on the capability checks. I strongly propose to do this also for your new BCMFS PMD. Have a look at e.g. QAT PMD test suite in the same file. It has one function to properly initialize the run (check the device id) and then it uses big common area of individual tests (some of them are skipped because of requiring specific capabilities).

Adam Dybkowski

#11 lore raw

v2 cover Add Crypto PMD for Broadcom`s FlexSparc devices

In reply to Vikas Gupta

Hi,
This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.
BCMFS is an acronym for Broadcom FlexSparc device used in the patchest.

The patchset progressively adds major modules as below.
a) Detection of platform-device based on the known registered platforms and attaching with VFIO.
b) Creation of Cryptodevice.
c) Addition of session handling.
d) Add Cryptodevice into test Cryptodev framework.

The patchset has been tested on the above mentioned SoCs.

Regards,
Vikas

Changes from v0->v1:
Updated the ABI version in file .../crypto/bcmfs/rte_pmd_bcmfs_version.map

Changes from v1->v2:
- Fix compilation errors and coding style warnings.
- Use global test crypto suite suggested by Adam Dybkowski

Vikas Gupta (8):
crypto/bcmfs: add BCMFS driver crypto/bcmfs: add vfio support crypto/bcmfs: add apis for queue pair management crypto/bcmfs: add hw queue pair operations crypto/bcmfs: create a symmetric cryptodev crypto/bcmfs: add session handling and capabilities crypto/bcmfs: add crypto h/w module crypto/bcmfs: add crypto pmd into cryptodev test

 MAINTAINERS                                   |   7 +
 app/test/test_cryptodev.c                     |  17 +
 app/test/test_cryptodev.h                     |   1 +
 config/common_base                            |   5 +
 doc/guides/cryptodevs/bcmfs.rst               |  72 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |  56 +
 doc/guides/cryptodevs/index.rst               |   1 +
 drivers/crypto/bcmfs/bcmfs_dev_msg.h          |  29 +
 drivers/crypto/bcmfs/bcmfs_device.c           | 331 ++++++
 drivers/crypto/bcmfs/bcmfs_device.h           |  76 ++
 drivers/crypto/bcmfs/bcmfs_hw_defs.h          |  38 +
 drivers/crypto/bcmfs/bcmfs_logs.c             |  38 +
 drivers/crypto/bcmfs/bcmfs_logs.h             |  34 +
 drivers/crypto/bcmfs/bcmfs_qp.c               | 383 +++++++
 drivers/crypto/bcmfs/bcmfs_qp.h               | 142 +++
 drivers/crypto/bcmfs/bcmfs_sym.c              | 316 ++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c | 764 ++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         | 186 ++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.c       | 994 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h       | 103 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          | 426 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h          |  38 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h          |  62 ++
 drivers/crypto/bcmfs/bcmfs_sym_session.c      | 424 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      |  99 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c             | 107 ++
 drivers/crypto/bcmfs/bcmfs_vfio.h             |  17 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c           | 742 +++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c           | 677 ++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c     |  82 ++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h     |  46 +
 drivers/crypto/bcmfs/meson.build              |  20 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |   3 +
 drivers/crypto/meson.build                    |   3 +-
 mk/rte.app.mk                                 |   1 +
 36 files changed, 6355 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
Signature · 1 line
2.17.1
#12 lore raw

PATCH v2 1/8 crypto/bcmfs: add BCMFS driver

Add Broadcom FlexSparc(FS) device creation driver which registers to a vdev and create a device. Add APIs for logs, supportive documention and maintainers file.

---
 MAINTAINERS                                   |   7 +
 config/common_base                            |   5 +
 doc/guides/cryptodevs/bcmfs.rst               |  26 ++
 doc/guides/cryptodevs/index.rst               |   1 +
 drivers/crypto/bcmfs/bcmfs_device.c           | 256 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_device.h           |  40 +++
 drivers/crypto/bcmfs/bcmfs_logs.c             |  38 +++
 drivers/crypto/bcmfs/bcmfs_logs.h             |  34 +++
 drivers/crypto/bcmfs/meson.build              |  10 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |   3 +
 drivers/crypto/meson.build                    |   3 +-
 mk/rte.app.mk                                 |   1 +
 12 files changed, 423 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
MAINTAINERS +7 -0
index 3cd402b34..7c2d7ff1b 100644
@@ -1099,6 +1099,13 @@ F: drivers/crypto/zuc/
 F: doc/guides/cryptodevs/zuc.rst
 F: doc/guides/cryptodevs/features/zuc.ini
 
+Broadcom FlexSparc
+M: Vikas Gupta  <vikas.gupta@@broadcom.com>
+M: Raveendra Padasalagi <[email protected]>
+M: Ajit Khaparde <[email protected]>
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 -------------------
config/common_base +5 -0
index f7a8824f5..21daadcdd 100644
@@ -705,6 +705,11 @@ CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO=n
 #
 CONFIG_RTE_LIBRTE_PMD_NITROX=y
 
+#
+# Compile PMD for Broadcom crypto device
+#
+CONFIG_RTE_LIBRTE_PMD_BCMFS=y
+
 #
 # Compile generic security library
 #
doc/guides/cryptodevs/bcmfs.rst new file +26 -0
new file mode 100644
index 000000000..752ce028a
@@ -0,0 +1,26 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(C) 2020 Broadcom
+
+Broadcom FlexSparc Crypto Poll Mode Driver
+==========================================
+
+The FlexSparc crypto poll mode driver provides support for offloading
+cryptographic operations to the Broadcom SoCs having FlexSparc4/FlexSparc5 unit.
+Detailed information about SoCs can be found in
+
+* https://www.broadcom.com/
+
+Installation
+------------
+
+For compiling the Broadcom FlexSparc crypto PMD, please check if the
+CONFIG_RTE_LIBRTE_PMD_BCMFS setting is set to `y` in config/common_base file.
+
+* ``CONFIG_RTE_LIBRTE_PMD_BCMFS=y``
+
+Initialization
+--------------
+BCMFS crypto PMD depend upon the devices present in the path
+/sys/bus/platform/devices/fs<version>/<dev_name> on the platform.
+Each cryptodev PMD instance can be attached to the nodes present
+in the mentioned path.
doc/guides/cryptodevs/index.rst +1 -0
index a67ed5a28..5d7e028bd 100644
@@ -29,3 +29,4 @@ Crypto Device Drivers
     qat
     virtio
     zuc
+    bcmfs
drivers/crypto/bcmfs/bcmfs_device.c new file +256 -0

256 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h new file +40 -0
new file mode 100644
index 000000000..cc64a8df2
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_DEV_H_
+#define _BCMFS_DEV_H_
+
+#include <sys/queue.h>
+
+#include <rte_bus_vdev.h>
+
+#include "bcmfs_logs.h"
+
+/* max number of dev nodes */
+#define BCMFS_MAX_NODES		4
+#define BCMFS_MAX_PATH_LEN	512
+#define BCMFS_DEV_NAME_LEN	64
+
+/* Path for BCM-Platform device directory */
+#define SYSFS_BCM_PLTFORM_DEVICES    "/sys/bus/platform/devices"
+
+/* Supported devices */
+enum bcmfs_device_type {
+	BCMFS_SYM_FS4,
+	BCMFS_SYM_FS5,
+	BCMFS_UNKNOWN
+};
+
+struct bcmfs_device {
+	TAILQ_ENTRY(bcmfs_device) next;
+	/* Directory path for vfio */
+	char dirname[BCMFS_MAX_PATH_LEN];
+	/* BCMFS device name */
+	char name[BCMFS_DEV_NAME_LEN];
+	/* Parent vdev */
+	struct rte_vdev_device *vdev;
+};
+
+#endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_logs.c new file +38 -0
new file mode 100644
index 000000000..86f4ff3b5
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <rte_log.h>
+#include <rte_hexdump.h>
+
+#include "bcmfs_logs.h"
+
+int bcmfs_conf_logtype;
+int bcmfs_dp_logtype;
+
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
+		const void *buf, unsigned int len)
+{
+	if (level > rte_log_get_global_level())
+		return 0;
+	if (level > (uint32_t)(rte_log_get_level(logtype)))
+		return 0;
+
+	rte_hexdump(rte_log_get_stream(), title, buf, len);
+	return 0;
+}
+
+RTE_INIT(bcmfs_device_init_log)
+{
+	/* Configuration and general logs */
+	bcmfs_conf_logtype = rte_log_register("pmd.bcmfs_config");
+	if (bcmfs_conf_logtype >= 0)
+		rte_log_set_level(bcmfs_conf_logtype, RTE_LOG_NOTICE);
+
+	/* data-path logs */
+	bcmfs_dp_logtype = rte_log_register("pmd.bcmfs_fp");
+	if (bcmfs_dp_logtype >= 0)
+		rte_log_set_level(bcmfs_dp_logtype, RTE_LOG_NOTICE);
+}
drivers/crypto/bcmfs/bcmfs_logs.h new file +34 -0
new file mode 100644
index 000000000..c03a49b75
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_LOGS_H_
+#define _BCMFS_LOGS_H_
+
+#include <rte_log.h>
+
+extern int bcmfs_conf_logtype;
+extern int bcmfs_dp_logtype;
+
+#define BCMFS_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_conf_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_dp_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_HEXDUMP_LOG(level, title, buf, len)	\
+	bcmfs_hexdump_log(RTE_LOG_ ## level, bcmfs_dp_logtype, title, buf, len)
+
+/**
+ * bcmfs_hexdump_log Dump out memory in a special hex dump format.
+ *
+ * The message will be sent to the stream used by the rte_log infrastructure.
+ */
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *heading,
+		  const void *buf, unsigned int len);
+
+#endif /* _BCMFS_LOGS_H_ */
drivers/crypto/bcmfs/meson.build new file +10 -0
new file mode 100644
index 000000000..a4bdd8ee5
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2020 Broadcom
+# All rights reserved.
+#
+
+deps += ['eal', 'bus_vdev']
+sources = files(
+		'bcmfs_logs.c',
+		'bcmfs_device.c'
+		)
drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map new file +3 -0
new file mode 100644
index 000000000..299ae632d
@@ -0,0 +1,3 @@
+DPDK_21.0 {
+	local: *;
+};
drivers/crypto/meson.build +2 -1
index a2423507a..8e06d0533 100644
@@ -23,7 +23,8 @@ drivers = ['aesni_gcm',
 	   'scheduler',
 	   'snow3g',
 	   'virtio',
-	   'zuc']
+	   'zuc',
+	   'bcmfs']
 
 std_deps = ['cryptodev'] # cryptodev pulls in all other needed deps
 config_flag_fmt = 'RTE_LIBRTE_@0@_PMD'
mk/rte.app.mk +1 -0
index 0ce8cf541..5e268f8c0 100644
@@ -308,6 +308,7 @@ ifeq ($(CONFIG_RTE_LIBRTE_SECURITY),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_CAAM_JR)   += -lrte_pmd_caam_jr
 endif # CONFIG_RTE_LIBRTE_SECURITY
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += -lrte_pmd_virtio_crypto
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BCMFS)      += -lrte_pmd_bcmfs
 endif # CONFIG_RTE_LIBRTE_CRYPTODEV
 
 ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y)
Signature · 1 line
2.17.1
#13 lore raw

Re: [dpdk-dev] [PATCH v2 1/8] crypto/bcmfs: add BCMFS driver

Hi Vikas,

doc/guides/cryptodevs/bcmfs.rst line 26

Quoted 4 lines
doc/guides/cryptodevs/bcmfs.rst new file +4 -0
+BCMFS crypto PMD depend upon the devices present in the path
+/sys/bus/platform/devices/fs<version>/<dev_name> on the platform.
+Each cryptodev PMD instance can be attached to the nodes present
+in the mentioned path.

It would be good, if you can mention the details about the SDKs which need To be installed, any kernel dependencies if any.
The device path mentioned is from which rootfs? This looks incomplete documentation.

doc/guides/cryptodevs/index.rst Crypto Device Drivers · line 32

Quoted 9 lines
doc/guides/cryptodevs/index.rst +1 -0
index a67ed5a28..5d7e028bd 100644
@@ -29,3 +29,4 @@ Crypto Device Drivers
     qat
     virtio
     zuc
+    bcmfs

It is better to maintain an alphabetical order.

Quoted 52 lines
drivers/crypto/bcmfs/bcmfs_device.c new file +45 -0
new file mode 100644
index 000000000..47c776de6
@@ -0,0 +1,256 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include <dirent.h>
+#include <stdbool.h>
+#include <sys/queue.h>
+
+#include <rte_string_fns.h>
+
+#include "bcmfs_device.h"
+#include "bcmfs_logs.h"
+
+struct bcmfs_device_attr {
+	const char name[BCMFS_MAX_PATH_LEN];
+	const char suffix[BCMFS_DEV_NAME_LEN];
+	const enum bcmfs_device_type type;
+	const uint32_t offset;
+	const uint32_t version;
+};
+
+/* BCMFS supported devices */
+static struct bcmfs_device_attr dev_table[] = {
+	{
+		.name = "fs4",
+		.suffix = "crypto_mbox",
+		.type = BCMFS_SYM_FS4,
+		.offset = 0,
+		.version = 0x76303031
+	},
+	{
+		.name = "fs5",
+		.suffix = "mbox",
+		.type = BCMFS_SYM_FS5,
+		.offset = 0,
+		.version = 0x76303032
+	},
+	{
+		/* sentinel */
+	}
+};
+
+TAILQ_HEAD(fsdev_list, bcmfs_device);
+static struct fsdev_list fsdev_list = TAILQ_HEAD_INITIALIZER(fsdev_list);

drivers/crypto/bcmfs/bcmfs_device.c line 55

Quoted 10 lines
drivers/crypto/bcmfs/bcmfs_device.c new file +10 -0
+
+static struct bcmfs_device *
+fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
+		       char *dirpath,
+		       char *devname,
+		       enum bcmfs_device_type dev_type __rte_unused)
+{
+	struct bcmfs_device *fsdev;
+
+	fsdev = calloc(1, sizeof(*fsdev));

Can we use rte_calloc

Quoted 28 lines
drivers/crypto/bcmfs/bcmfs_device.c new file +28 -0
+	if (!fsdev)
+		return NULL;
+
+	if (strlen(dirpath) > sizeof(fsdev->dirname)) {
+		BCMFS_LOG(ERR, "dir path name is too long");
+		goto cleanup;
+	}
+
+	if (strlen(devname) > sizeof(fsdev->name)) {
+		BCMFS_LOG(ERR, "devname is too long");
+		goto cleanup;
+	}
+
+	strcpy(fsdev->dirname, dirpath);
+	strcpy(fsdev->name, devname);
+
+	fsdev->vdev = vdev;
+
+	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
+
+	return fsdev;
+
+cleanup:
+	free(fsdev);
+
+	return NULL;
+}
+

<snip>

drivers/crypto/meson.build drivers = ['aesni_gcm', · line 27

Quoted 11 lines
drivers/crypto/meson.build +2 -1
index a2423507a..8e06d0533 100644
@@ -23,7 +23,8 @@ drivers = ['aesni_gcm',
 	   'scheduler',
 	   'snow3g',
 	   'virtio',
-	   'zuc']
+	   'zuc',
+	   'bcmfs']

Please maintain an alphabetical order.

#14 lore raw

Re: [dpdk-dev] [PATCH v2 1/8] crypto/bcmfs: add BCMFS driver

Hi Akhil,

Quoted 11 lines · Akhil Goyal

Hi Vikas,

doc/guides/cryptodevs/bcmfs.rst line 26

Quoted 4 lines
doc/guides/cryptodevs/bcmfs.rst new file +4 -0
+BCMFS crypto PMD depend upon the devices present in the path
+/sys/bus/platform/devices/fs<version>/<dev_name> on the platform.
+Each cryptodev PMD instance can be attached to the nodes present
+in the mentioned path.

It would be good, if you can mention the details about the SDKs which need To be installed, any kernel dependencies if any.
The device path mentioned is from which rootfs? This looks incomplete documentation.

Ok sure I`ll add missing items in next patch set.

Quoted 12 lines

doc/guides/cryptodevs/index.rst Crypto Device Drivers · line 32

Quoted 10 lines
doc/guides/cryptodevs/index.rst +1 -0
index a67ed5a28..5d7e028bd 100644
@@ -29,3 +29,4 @@ Crypto Device Drivers
     qat
     virtio
     zuc
+    bcmfs

It is better to maintain an alphabetical order.

Sure.

Quoted 57 lines
Quoted 57 lines
drivers/crypto/bcmfs/bcmfs_device.c new file +49 -0
new file mode 100644
index 000000000..47c776de6
@@ -0,0 +1,256 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include <dirent.h>
+#include <stdbool.h>
+#include <sys/queue.h>
+
+#include <rte_string_fns.h>
+
+#include "bcmfs_device.h"
+#include "bcmfs_logs.h"
+
+struct bcmfs_device_attr {
+     const char name[BCMFS_MAX_PATH_LEN];
+     const char suffix[BCMFS_DEV_NAME_LEN];
+     const enum bcmfs_device_type type;
+     const uint32_t offset;
+     const uint32_t version;
+};
+
+/* BCMFS supported devices */
+static struct bcmfs_device_attr dev_table[] = {
+     {
+             .name = "fs4",
+             .suffix = "crypto_mbox",
+             .type = BCMFS_SYM_FS4,
+             .offset = 0,
+             .version = 0x76303031
+     },
+     {
+             .name = "fs5",
+             .suffix = "mbox",
+             .type = BCMFS_SYM_FS5,
+             .offset = 0,
+             .version = 0x76303032
+     },
+     {
+             /* sentinel */
+     }
+};
+
+TAILQ_HEAD(fsdev_list, bcmfs_device);
+static struct fsdev_list fsdev_list = TAILQ_HEAD_INITIALIZER(fsdev_list);
+
+static struct bcmfs_device *
+fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
+                    char *dirpath,
Quoted 8 lines

drivers/crypto/bcmfs/bcmfs_device.c line 55

Quoted 6 lines
drivers/crypto/bcmfs/bcmfs_device.c new file +6 -0
+                    char *devname,
+                    enum bcmfs_device_type dev_type __rte_unused)
+{
+     struct bcmfs_device *fsdev;
+
+     fsdev = calloc(1, sizeof(*fsdev));

Can we use rte_calloc

will fix it in next patch set.

Quoted 32 lines
Quoted 29 lines
drivers/crypto/bcmfs/bcmfs_device.c new file +28 -0
+     if (!fsdev)
+             return NULL;
+
+     if (strlen(dirpath) > sizeof(fsdev->dirname)) {
+             BCMFS_LOG(ERR, "dir path name is too long");
+             goto cleanup;
+     }
+
+     if (strlen(devname) > sizeof(fsdev->name)) {
+             BCMFS_LOG(ERR, "devname is too long");
+             goto cleanup;
+     }
+
+     strcpy(fsdev->dirname, dirpath);
+     strcpy(fsdev->name, devname);
+
+     fsdev->vdev = vdev;
+
+     TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
+
+     return fsdev;
+
+cleanup:
+     free(fsdev);
+
+     return NULL;
+}
+

<snip>

Quoted 13 lines

drivers/crypto/meson.build drivers = ['aesni_gcm', · line 27

Quoted 11 lines
drivers/crypto/meson.build +2 -1
index a2423507a..8e06d0533 100644
@@ -23,7 +23,8 @@ drivers = ['aesni_gcm',
         'scheduler',
         'snow3g',
         'virtio',
-        'zuc']
+        'zuc',
+        'bcmfs']

Please maintain an alphabetical order.

Sure.

#15 lore raw

PATCH v2 2/8 crypto/bcmfs: add vfio support

In reply to Vikas Gupta

Add vfio support for device.

---
 drivers/crypto/bcmfs/bcmfs_device.c |   5 ++
 drivers/crypto/bcmfs/bcmfs_device.h |   6 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c   | 107 ++++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_vfio.h   |  17 +++++
 drivers/crypto/bcmfs/meson.build    |   3 +-
 5 files changed, 137 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
drivers/crypto/bcmfs/bcmfs_device.c +5 -0
index 47c776de6..3b5cc9e98 100644
@@ -11,6 +11,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -71,6 +72,10 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 
 	fsdev->vdev = vdev;
 
+	/* attach to VFIO */
+	if (bcmfs_attach_vfio(fsdev))
+		goto cleanup;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +6 -0
index cc64a8df2..c41cc0031 100644
@@ -35,6 +35,12 @@ struct bcmfs_device {
 	char name[BCMFS_DEV_NAME_LEN];
 	/* Parent vdev */
 	struct rte_vdev_device *vdev;
+	/* vfio handle */
+	int vfio_dev_fd;
+	/* mapped address */
+	uint8_t *mmap_addr;
+	/* mapped size */
+	uint32_t mmap_size;
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_vfio.c new file +107 -0

107 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_vfio.h new file +17 -0
new file mode 100644
index 000000000..d0fdf6483
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_VFIO_H_
+#define _BCMFS_VFIO_H_
+
+/* Attach the bcmfs device to vfio */
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev);
+
+/* Release the bcmfs device from vfio */
+void
+bcmfs_release_vfio(struct bcmfs_device *dev);
+
+#endif /* _BCMFS_VFIO_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index a4bdd8ee5..fd39eba20 100644
@@ -6,5 +6,6 @@
 deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
-		'bcmfs_device.c'
+		'bcmfs_device.c',
+		'bcmfs_vfio.c'
 		)
Signature · 1 line
2.17.1
#16 lore raw

Re: [dpdk-dev] [PATCH v2 2/8] crypto/bcmfs: add vfio support

Hi Vikas,

Quoted 72 lines

Subject: [PATCH v2 2/8] crypto/bcmfs: add vfio support

Add vfio support for device.

---
 drivers/crypto/bcmfs/bcmfs_device.c |   5 ++
 drivers/crypto/bcmfs/bcmfs_device.h |   6 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c   | 107 ++++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_vfio.h   |  17 +++++
 drivers/crypto/bcmfs/meson.build    |   3 +-
 5 files changed, 137 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
drivers/crypto/bcmfs/bcmfs_device.c +5 -0
index 47c776de6..3b5cc9e98 100644
@@ -11,6 +11,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -71,6 +72,10 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 
 	fsdev->vdev = vdev;
 
+	/* attach to VFIO */
+	if (bcmfs_attach_vfio(fsdev))
+		goto cleanup;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +6 -0
index cc64a8df2..c41cc0031 100644
@@ -35,6 +35,12 @@ struct bcmfs_device {
 	char name[BCMFS_DEV_NAME_LEN];
 	/* Parent vdev */
 	struct rte_vdev_device *vdev;
+	/* vfio handle */
+	int vfio_dev_fd;
+	/* mapped address */
+	uint8_t *mmap_addr;
+	/* mapped size */
+	uint32_t mmap_size;
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_vfio.c new file +6 -0
new file mode 100644
index 000000000..dc2def580
@@ -0,0 +1,107 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include <errno.h>

drivers/crypto/bcmfs/bcmfs_vfio.c line 16

Quoted 10 lines
drivers/crypto/bcmfs/bcmfs_vfio.c new file +10 -0
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+
+#include <rte_vfio.h>
+
+#include "bcmfs_device.h"
+#include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
+
+#ifdef VFIO_PRESENT

I cannot see VFIO_PRESENT flag defined in this patch. Hence the below code is a dead code and the patch Title is not justified as it says adding support for VFIO.

drivers/crypto/bcmfs/bcmfs_vfio.c line 19

Quoted 3 lines
drivers/crypto/bcmfs/bcmfs_vfio.c new file +3 -0
+static int
+vfio_map_dev_obj(const char *path, const char *dev_obj,
+		 uint32_t *size, void **addr, int *dev_fd)

Regards,
Akhil

#17 lore raw

Re: [dpdk-dev] [PATCH v2 2/8] crypto/bcmfs: add vfio support

Hi Akhil,

Quoted 81 lines · Akhil Goyal

Hi Vikas,

Quoted 78 lines

Subject: [PATCH v2 2/8] crypto/bcmfs: add vfio support

Add vfio support for device.

---
 drivers/crypto/bcmfs/bcmfs_device.c |   5 ++
 drivers/crypto/bcmfs/bcmfs_device.h |   6 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c   | 107 ++++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_vfio.h   |  17 +++++
 drivers/crypto/bcmfs/meson.build    |   3 +-
 5 files changed, 137 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
drivers/crypto/bcmfs/bcmfs_device.c +5 -0
index 47c776de6..3b5cc9e98 100644
@@ -11,6 +11,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
      const char name[BCMFS_MAX_PATH_LEN];
@@ -71,6 +72,10 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 
      fsdev->vdev = vdev;
 
+     /* attach to VFIO */
+     if (bcmfs_attach_vfio(fsdev))
+             goto cleanup;
+
      TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
      return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +6 -0
index cc64a8df2..c41cc0031 100644
@@ -35,6 +35,12 @@ struct bcmfs_device {
      char name[BCMFS_DEV_NAME_LEN];
      /* Parent vdev */
      struct rte_vdev_device *vdev;
+     /* vfio handle */
+     int vfio_dev_fd;
+     /* mapped address */
+     uint8_t *mmap_addr;
+     /* mapped size */
+     uint32_t mmap_size;
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_vfio.c new file +12 -0
new file mode 100644
index 000000000..dc2def580
@@ -0,0 +1,107 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+
+#include <rte_vfio.h>
+
+#include "bcmfs_device.h"
Quoted 8 lines

drivers/crypto/bcmfs/bcmfs_vfio.c line 16

Quoted 4 lines
drivers/crypto/bcmfs/bcmfs_vfio.c new file +4 -0
+#include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
+
+#ifdef VFIO_PRESENT

I cannot see VFIO_PRESENT flag defined in this patch. Hence the below code is a dead code and the patch Title is not justified as it says adding support for VFIO.

I believe VFIO_PRESENT flag is dependent on the platform who supports VFIO and determined in rte_vfio.h.
The driver will not work without VFIO support and returns silently (functions in #else part).
Do you mean I need to change the title?

Quoted 7 lines

drivers/crypto/bcmfs/bcmfs_vfio.c line 19

Quoted 4 lines
drivers/crypto/bcmfs/bcmfs_vfio.c new file +3 -0
+static int
+vfio_map_dev_obj(const char *path, const char *dev_obj,
+              uint32_t *size, void **addr, int *dev_fd)

Regards,
Akhil

Thanks,
Vikas

#18 lore raw

Re: [dpdk-dev] [PATCH v2 2/8] crypto/bcmfs: add vfio support

Hi Vikas,

Quoted 9 lines

Hi Akhil,

Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+#ifdef VFIO_PRESENT

I cannot see VFIO_PRESENT flag defined in this patch. Hence the below code is a dead code and the patch Title is not justified as it says adding support for VFIO.

Quoted 5 lines

I believe VFIO_PRESENT flag is dependent on the platform who supports VFIO and determined in rte_vfio.h.
The driver will not work without VFIO support and returns silently (functions in #else part).
Do you mean I need to change the title?

Title is OK. You can explain in the patch description and bcmfs.rst about how it is getting enabled, which config flags need to be enabled and probably in the bcmfs.rst as well.

Regards,
Akhil

#19 lore raw

PATCH v2 3/8 crypto/bcmfs: add apis for queue pair management

In reply to Vikas Gupta

Add queue pair management APIs which will be used by Crypto device to manage h/w queues. A bcmfs device structure owns multiple queue-pairs based on the mapped address allocated to it.

---
 drivers/crypto/bcmfs/bcmfs_device.c  |   4 +
 drivers/crypto/bcmfs/bcmfs_device.h  |   5 +
 drivers/crypto/bcmfs/bcmfs_hw_defs.h |  38 +++
 drivers/crypto/bcmfs/bcmfs_qp.c      | 345 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_qp.h      | 122 ++++++++++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 6 files changed, 516 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
drivers/crypto/bcmfs/bcmfs_device.c +4 -0
index 3b5cc9e98..b475c2933 100644
@@ -11,6 +11,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
@@ -76,6 +77,9 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 	if (bcmfs_attach_vfio(fsdev))
 		goto cleanup;
 
+	/* Maximum number of QPs supported */
+	fsdev->max_hw_qps = fsdev->mmap_size / BCMFS_HW_QUEUE_IO_ADDR_LEN;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +5 -0
index c41cc0031..a47537332 100644
@@ -11,6 +11,7 @@
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES		4
@@ -41,6 +42,10 @@ struct bcmfs_device {
 	uint8_t *mmap_addr;
 	/* mapped size */
 	uint32_t mmap_size;
+	/* max number of h/w queue pairs detected */
+	uint16_t max_hw_qps;
+	/* current qpairs in use */
+	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_hw_defs.h new file +38 -0
new file mode 100644
index 000000000..ecb0c09ba
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_RM_DEFS_H_
+#define _BCMFS_RM_DEFS_H_
+
+#include <rte_atomic.h>
+#include <rte_byteorder.h>
+#include <rte_common.h>
+#include <rte_io.h>
+
+/* 32-bit MMIO register write */
+#define FS_MMIO_WRITE32(value, addr) rte_write32_relaxed((value), (addr))
+
+/* 32-bit MMIO register read */
+#define FS_MMIO_READ32(addr) rte_read32_relaxed((addr))
+
+#ifndef BIT
+#define BIT(nr)         (1UL << (nr))
+#endif
+
+#define FS_RING_REGS_SIZE		0x10000
+#define FS_RING_DESC_SIZE		8
+#define FS_RING_BD_ALIGN_ORDER		12
+#define FS_RING_BD_DESC_PER_REQ		32
+#define FS_RING_CMPL_ALIGN_ORDER	13
+#define FS_RING_CMPL_SIZE		(1024 * FS_RING_DESC_SIZE)
+#define FS_RING_MAX_REQ_COUNT		1024
+#define FS_RING_PAGE_SHFT		12
+#define FS_RING_PAGE_SIZE		BIT(FS_RING_PAGE_SHFT)
+
+/* Minimum and maximum number of requests supported */
+#define FS_RM_MAX_REQS			1024
+#define FS_RM_MIN_REQS			32
+
+#endif /* BCMFS_RM_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c new file +345 -0

345 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_qp.h new file +122 -0

122 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +2 -1
index fd39eba20..7e2bcbf14 100644
@@ -7,5 +7,6 @@ deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
-		'bcmfs_vfio.c'
+		'bcmfs_vfio.c',
+		'bcmfs_qp.c'
 		)
Signature · 1 line
2.17.1
#20 lore raw

Re: [dpdk-dev] [PATCH v2 3/8] crypto/bcmfs: add apis for queue pair management

Quoted 9 lines

Subject: [PATCH v2 3/8] crypto/bcmfs: add apis for queue pair management

drivers/crypto/bcmfs/bcmfs_hw_defs.h new file +0 -0
new file mode 100644
index 000000000..ecb0c09ba

drivers/crypto/bcmfs/bcmfs_hw_defs.h line 7

Quoted 7 lines
drivers/crypto/bcmfs/bcmfs_hw_defs.h new file +7 -0
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_RM_DEFS_H_
+#define _BCMFS_RM_DEFS_H_

The file name is bcmfs_hw_defs.h
Check for other headers also.

#21 lore raw

Re: [dpdk-dev] [PATCH v2 3/8] crypto/bcmfs: add apis for queue pair management

Hi Akhil,

Quoted 12 lines · Akhil Goyal
Quoted 12 lines

Subject: [PATCH v2 3/8] crypto/bcmfs: add apis for queue pair management

drivers/crypto/bcmfs/bcmfs_hw_defs.h new file +2 -0
new file mode 100644
index 000000000..ecb0c09ba
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
Quoted 9 lines

drivers/crypto/bcmfs/bcmfs_hw_defs.h line 7

Quoted 5 lines
drivers/crypto/bcmfs/bcmfs_hw_defs.h new file +5 -0
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_RM_DEFS_H_
+#define _BCMFS_RM_DEFS_H_

The file name is bcmfs_hw_defs.h
Check for other headers also.

Will fix it next patch set. Thank you for catching this.

Thanks,
Vikas

#22 lore raw

PATCH v2 4/8 crypto/bcmfs: add hw queue pair operations

In reply to Vikas Gupta

Add queue pair operations exported by supported devices.

---
 drivers/crypto/bcmfs/bcmfs_dev_msg.h      |  29 +
 drivers/crypto/bcmfs/bcmfs_device.c       |  51 ++
 drivers/crypto/bcmfs/bcmfs_device.h       |  16 +
 drivers/crypto/bcmfs/bcmfs_qp.c           |   1 +
 drivers/crypto/bcmfs/bcmfs_qp.h           |   4 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c       | 742 ++++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c       | 677 ++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c |  82 +++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h |  46 ++
 drivers/crypto/bcmfs/meson.build          |   5 +-
 10 files changed, 1652 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
drivers/crypto/bcmfs/bcmfs_dev_msg.h new file +29 -0
new file mode 100644
index 000000000..5b50bde35
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_DEV_MSG_H_
+#define _BCMFS_DEV_MSG_H_
+
+#define MAX_SRC_ADDR_BUFFERS    8
+#define MAX_DST_ADDR_BUFFERS    3
+
+struct bcmfs_qp_message {
+	/** Physical address of each source */
+	uint64_t srcs_addr[MAX_SRC_ADDR_BUFFERS];
+	/** Length of each sources */
+	uint32_t srcs_len[MAX_SRC_ADDR_BUFFERS];
+	/** Total number of sources */
+	unsigned int srcs_count;
+	/** Physical address of each destination */
+	uint64_t dsts_addr[MAX_DST_ADDR_BUFFERS];
+	/** Length of each destination */
+	uint32_t dsts_len[MAX_DST_ADDR_BUFFERS];
+	/** Total number of destinations */
+	unsigned int dsts_count;
+
+	void *ctx;
+};
+
+#endif /* _BCMFS_DEV_MSG_H_ */
drivers/crypto/bcmfs/bcmfs_device.c +51 -0

69 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h +16 -0
index a47537332..9e40c5d74 100644
@@ -8,6 +8,7 @@
 
 #include <sys/queue.h>
 
+#include <rte_spinlock.h>
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
@@ -28,6 +29,19 @@ enum bcmfs_device_type {
 	BCMFS_UNKNOWN
 };
 
+/* A table to store registered queue pair opertations */
+struct bcmfs_hw_queue_pair_ops_table {
+	rte_spinlock_t tl;
+	/* Number of used ops structs in the table. */
+	uint32_t num_ops;
+	 /*  Storage for all possible ops structs. */
+	struct bcmfs_hw_queue_pair_ops qp_ops[BCMFS_MAX_NODES];
+};
+
+/* HW queue pair ops register function */
+int bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops
+				     *qp_ops);
+
 struct bcmfs_device {
 	TAILQ_ENTRY(bcmfs_device) next;
 	/* Directory path for vfio */
@@ -46,6 +60,8 @@ struct bcmfs_device {
 	uint16_t max_hw_qps;
 	/* current qpairs in use */
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
+	/* queue pair ops exported by symmetric crypto hw */
+	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +1 -0
index 864e7bb74..ec1327b78 100644
@@ -227,6 +227,7 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	qp->qpair_id = queue_pair_id;
 	qp->ioreg = qp_conf->iobase;
 	qp->nb_descriptors = nb_descriptors;
+	qp->ops = qp_conf->ops;
 
 	qp->stats.enqueued_count = 0;
 	qp->stats.dequeued_count = 0;
drivers/crypto/bcmfs/bcmfs_qp.h +4 -0
index 027d7a50c..e4b0c3f2f 100644
@@ -44,6 +44,8 @@ struct bcmfs_qp_config {
 	uint16_t nb_descriptors;
 	/* Maximum number of h/w descriptors needed by a request */
 	uint16_t max_descs_req;
+	/* h/w ops associated with qp */
+	struct bcmfs_hw_queue_pair_ops *ops;
 };
 
 struct bcmfs_queue {
@@ -61,6 +63,8 @@ struct bcmfs_queue {
 		/* s/w pointer for completion h/w queue*/
 		uint32_t cmpl_read_ptr;
 	};
+	/* number of inflight descriptor accumulated  before next db ring */
+	uint16_t descs_inflight;
 	/* Memzone name */
 	char memz_name[RTE_MEMZONE_NAMESIZE];
 };
drivers/crypto/bcmfs/hw/bcmfs4_rm.c new file +742 -0

742 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs5_rm.c new file +677 -0

677 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.c new file +82 -0

82 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.h new file +46 -0

46 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +4 -1
index 7e2bcbf14..cd58bd5e2 100644
@@ -8,5 +8,8 @@ sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
 		'bcmfs_vfio.c',
-		'bcmfs_qp.c'
+		'bcmfs_qp.c',
+		'hw/bcmfs4_rm.c',
+		'hw/bcmfs5_rm.c',
+		'hw/bcmfs_rm_common.c'
 		)
Signature · 1 line
2.17.1
#23 lore raw

PATCH v2 5/8 crypto/bcmfs: create a symmetric cryptodev

In reply to Vikas Gupta

Create a symmetric crypto device and supported cryptodev ops.

---
 drivers/crypto/bcmfs/bcmfs_device.c  |  15 ++
 drivers/crypto/bcmfs/bcmfs_device.h  |   9 +
 drivers/crypto/bcmfs/bcmfs_qp.c      |  37 +++
 drivers/crypto/bcmfs/bcmfs_qp.h      |  16 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c | 387 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h |  38 +++
 drivers/crypto/bcmfs/bcmfs_sym_req.h |  22 ++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 8 files changed, 526 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
drivers/crypto/bcmfs/bcmfs_device.c +15 -0
index bd2d64acf..c9263ec28 100644
@@ -13,6 +13,7 @@
 #include "bcmfs_logs.h"
 #include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
+#include "bcmfs_sym_pmd.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -239,6 +240,7 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 	char out_dirname[BCMFS_MAX_PATH_LEN];
 	uint32_t fsdev_dev[BCMFS_MAX_NODES];
 	enum bcmfs_device_type dtype;
+	int err;
 	int i = 0;
 	int dev_idx;
 	int count = 0;
@@ -290,7 +292,20 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 		return -ENODEV;
 	}
 
+	err = bcmfs_sym_dev_create(fsdev);
+	if (err) {
+		BCMFS_LOG(WARNING,
+			  "Failed to create BCMFS SYM PMD for device %s",
+			  fsdev->name);
+		goto pmd_create_fail;
+	}
+
 	return 0;
+
+pmd_create_fail:
+	fsdev_release(fsdev);
+
+	return err;
 }
 
 static int
drivers/crypto/bcmfs/bcmfs_device.h +9 -0
index 9e40c5d74..e8a9c4091 100644
@@ -62,6 +62,15 @@ struct bcmfs_device {
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 	/* queue pair ops exported by symmetric crypto hw */
 	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
+	/* a cryptodevice attached to bcmfs device */
+	struct rte_cryptodev *cdev;
+	/* a rte_device to register with cryptodev */
+	struct rte_device sym_rte_dev;
+	/* private info to keep with cryptodev */
+	struct bcmfs_sym_dev_private *sym_dev;
 };
 
+/* stats exported by device */
+
+
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +37 -0
index ec1327b78..cb5ff6c61 100644
@@ -344,3 +344,40 @@ bcmfs_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops)
 
 	return deq;
 }
+
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats)
+{
+	int i;
+
+	if (stats == NULL) {
+		BCMFS_LOG(ERR, "invalid param: stats %p",
+			  stats);
+		return;
+	}
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+
+		stats->enqueued_count += qp[i]->stats.enqueued_count;
+		stats->dequeued_count += qp[i]->stats.dequeued_count;
+		stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
+		stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
+	}
+}
+
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp)
+{
+	int i;
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+		memset(&qp[i]->stats, 0, sizeof(qp[i]->stats));
+	}
+}
drivers/crypto/bcmfs/bcmfs_qp.h +16 -0
index e4b0c3f2f..fec58ca71 100644
@@ -24,6 +24,13 @@ enum bcmfs_queue_type {
 	BCMFS_RM_CPLQ
 };
 
+#define BCMFS_QP_IOBASE_XLATE(base, idx)	\
+		((base) + ((idx) * BCMFS_HW_QUEUE_IO_ADDR_LEN))
+
+/* Max pkts for preprocessing before submitting to h/w qp */
+#define BCMFS_MAX_REQS_BUFF	64
+
+/* qp stats */
 struct bcmfs_qp_stats {
 	/* Count of all operations enqueued */
 	uint64_t enqueued_count;
@@ -92,6 +99,10 @@ struct bcmfs_qp {
 	struct bcmfs_qp_stats stats;
 	/* h/w ops associated with qp */
 	struct bcmfs_hw_queue_pair_ops *ops;
+	/* bcmfs requests pool*/
+	struct rte_mempool *sr_mp;
+	/* a temporary buffer to keep message pointers */
+	struct bcmfs_qp_message *infl_msgs[BCMFS_MAX_REQS_BUFF];
 
 } __rte_cache_aligned;
 
@@ -123,4 +134,9 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	       uint16_t queue_pair_id,
 	       struct bcmfs_qp_config *bcmfs_conf);
 
+/* stats functions*/
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats);
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp);
+
 #endif /* _BCMFS_QP_H_ */
drivers/crypto/bcmfs/bcmfs_sym_pmd.c new file +387 -0

387 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.h new file +38 -0
new file mode 100644
index 000000000..65d704609
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_PMD_H_
+#define _BCMFS_SYM_PMD_H_
+
+#include <rte_cryptodev.h>
+
+#include "bcmfs_device.h"
+
+#define CRYPTODEV_NAME_BCMFS_SYM_PMD	crypto_bcmfs
+
+#define BCMFS_CRYPTO_MAX_HW_DESCS_PER_REQ	16
+
+extern uint8_t cryptodev_bcmfs_driver_id;
+
+/** private data structure for a BCMFS device.
+ *  This BCMFS device is a device offering only symmetric crypto service,
+ *  there can be one of these on each bcmfs_pci_device (VF).
+ */
+struct bcmfs_sym_dev_private {
+	/* The bcmfs device hosting the service */
+	struct bcmfs_device *fsdev;
+	/* Device instance for this rte_cryptodev */
+	uint8_t sym_dev_id;
+	/* BCMFS device symmetric crypto capabilities */
+	const struct rte_cryptodev_capabilities *fsdev_capabilities;
+};
+
+int
+bcmfs_sym_dev_create(struct bcmfs_device *fdev);
+
+int
+bcmfs_sym_dev_destroy(struct bcmfs_device *fdev);
+
+#endif /* _BCMFS_SYM_PMD_H_ */
drivers/crypto/bcmfs/bcmfs_sym_req.h new file +22 -0
new file mode 100644
index 000000000..0f0b051f1
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_REQ_H_
+#define _BCMFS_SYM_REQ_H_
+
+#include "bcmfs_dev_msg.h"
+
+/*
+ * This structure hold the supportive data required to process a
+ * rte_crypto_op
+ */
+struct bcmfs_sym_request {
+	/* bcmfs qp message for h/w queues to process */
+	struct bcmfs_qp_message msgs;
+	/* crypto op */
+	struct rte_crypto_op *op;
+};
+
+#endif /* _BCMFS_SYM_REQ_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index cd58bd5e2..d9a3d73e9 100644
@@ -11,5 +11,6 @@ sources = files(
 		'bcmfs_qp.c',
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
-		'hw/bcmfs_rm_common.c'
+		'hw/bcmfs_rm_common.c',
+		'bcmfs_sym_pmd.c'
 		)
Signature · 1 line
2.17.1
#24 lore raw

PATCH v2 6/8 crypto/bcmfs: add session handling and capabilities

In reply to Vikas Gupta

Add session handling and capabilities supported by crypto h/w accelerator.

---
 doc/guides/cryptodevs/bcmfs.rst               |  46 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |  56 ++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c | 764 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         | 170 ++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          |  13 +
 drivers/crypto/bcmfs/bcmfs_sym_session.c      | 424 ++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      |  99 +++
 drivers/crypto/bcmfs/meson.build              |   4 +-
 9 files changed, 1591 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
doc/guides/cryptodevs/bcmfs.rst +46 -0
index 752ce028a..2488b19f7 100644
@@ -18,9 +18,55 @@ CONFIG_RTE_LIBRTE_PMD_BCMFS setting is set to `y` in config/common_base file.
 
 * ``CONFIG_RTE_LIBRTE_PMD_BCMFS=y``
 
+Features
+~~~~~~~~
+
+The BCMFS SYM PMD has support for:
+
+Cipher algorithms:
+
+* ``RTE_CRYPTO_CIPHER_3DES_CBC``
+* ``RTE_CRYPTO_CIPHER_3DES_CTR``
+* ``RTE_CRYPTO_CIPHER_AES128_CBC``
+* ``RTE_CRYPTO_CIPHER_AES192_CBC``
+* ``RTE_CRYPTO_CIPHER_AES256_CBC``
+* ``RTE_CRYPTO_CIPHER_AES128_CTR``
+* ``RTE_CRYPTO_CIPHER_AES192_CTR``
+* ``RTE_CRYPTO_CIPHER_AES256_CTR``
+* ``RTE_CRYPTO_CIPHER_AES_XTS``
+* ``RTE_CRYPTO_CIPHER_DES_CBC``
+
+Hash algorithms:
+
+* ``RTE_CRYPTO_AUTH_SHA1``
+* ``RTE_CRYPTO_AUTH_SHA1_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA224``
+* ``RTE_CRYPTO_AUTH_SHA224_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA256``
+* ``RTE_CRYPTO_AUTH_SHA256_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA384``
+* ``RTE_CRYPTO_AUTH_SHA384_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA512``
+* ``RTE_CRYPTO_AUTH_SHA512_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_XCBC_MAC``
+* ``RTE_CRYPTO_AUTH_MD5_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_GMAC``
+* ``RTE_CRYPTO_AUTH_AES_CMAC``
+
+Supported AEAD algorithms:
+
+* ``RTE_CRYPTO_AEAD_AES_GCM``
+* ``RTE_CRYPTO_AEAD_AES_CCM``
+
 Initialization
 --------------
 BCMFS crypto PMD depend upon the devices present in the path
 /sys/bus/platform/devices/fs<version>/<dev_name> on the platform.
 Each cryptodev PMD instance can be attached to the nodes present
 in the mentioned path.
+
+Limitations
+~~~~~~~~~~~
+
+* Only supports the session-oriented API implementation (session-less APIs are not supported).
+* CCM is not supported on Broadcom`s SoCs having FlexSparc4 unit.
doc/guides/cryptodevs/features/bcmfs.ini new file +56 -0

56 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.c new file +764 -0

764 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.h new file +16 -0
new file mode 100644
index 000000000..3ff61b7d2
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_CAPABILITIES_H_
+#define _BCMFS_SYM_CAPABILITIES_H_
+
+/*
+ * Get capabilities list for the device
+ *
+ */
+const struct rte_cryptodev_capabilities *bcmfs_sym_get_capabilities(void);
+
+#endif /* _BCMFS_SYM_CAPABILITIES_H__ */
+
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +170 -0

170 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.c +13 -0
index 0f96915f7..381ca8ea4 100644
@@ -14,6 +14,8 @@
 #include "bcmfs_qp.h"
 #include "bcmfs_sym_pmd.h"
 #include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+#include "bcmfs_sym_capabilities.h"
 
 uint8_t cryptodev_bcmfs_driver_id;
 
@@ -65,6 +67,7 @@ bcmfs_sym_dev_info_get(struct rte_cryptodev *dev,
 		dev_info->max_nb_queue_pairs = fsdev->max_hw_qps;
 		/* No limit of number of sessions */
 		dev_info->sym.max_nb_sessions = 0;
+		dev_info->capabilities = bcmfs_sym_get_capabilities();
 	}
 }
 
@@ -228,6 +231,10 @@ static struct rte_cryptodev_ops crypto_bcmfs_ops = {
 	/* Queue-Pair management */
 	.queue_pair_setup       = bcmfs_sym_qp_setup,
 	.queue_pair_release     = bcmfs_sym_qp_release,
+	/* Crypto session related operations */
+	.sym_session_get_size   = bcmfs_sym_session_get_private_size,
+	.sym_session_configure  = bcmfs_sym_session_configure,
+	.sym_session_clear      = bcmfs_sym_session_clear
 };
 
 /** Enqueue burst */
@@ -239,6 +246,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	int i, j;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
+	struct bcmfs_sym_session *sess;
 	struct bcmfs_qp *qp = (struct bcmfs_qp *)queue_pair;
 
 	if (nb_ops == 0)
@@ -252,6 +260,10 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		nb_ops = qp->nb_descriptors - qp->nb_pending_requests;
 
 	for (i = 0; i < nb_ops; i++) {
+		sess = bcmfs_sym_get_session(ops[i]);
+		if (unlikely(sess == NULL))
+			goto enqueue_err;
+
 		if (rte_mempool_get(qp->sr_mp, (void **)&sreq))
 			goto enqueue_err;
 
@@ -356,6 +368,7 @@ bcmfs_sym_dev_create(struct bcmfs_device *fsdev)
 	fsdev->sym_dev = internals;
 
 	internals->sym_dev_id = cryptodev->data->dev_id;
+	internals->fsdev_capabilities = bcmfs_sym_get_capabilities();
 
 	BCMFS_LOG(DEBUG, "Created bcmfs-sym device %s as cryptodev instance %d",
 		  cryptodev->data->name, internals->sym_dev_id);
drivers/crypto/bcmfs/bcmfs_sym_session.c new file +424 -0

424 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_session.h new file +99 -0

99 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +3 -1
index d9a3d73e9..2e86c733e 100644
@@ -12,5 +12,7 @@ sources = files(
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
 		'hw/bcmfs_rm_common.c',
-		'bcmfs_sym_pmd.c'
+		'bcmfs_sym_pmd.c',
+		'bcmfs_sym_capabilities.c',
+		'bcmfs_sym_session.c'
 		)
Signature · 1 line
2.17.1
#25 lore raw

Re: [dpdk-dev] [PATCH v2 6/8] crypto/bcmfs: add session handling and capabilities

Hi Vikas,

Quoted 41 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +34 -0
new file mode 100644
index 000000000..82d2c639d
@@ -0,0 +1,56 @@
+;
+; Supported features of the 'bcmfs' crypto driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Symmetric crypto       = Y
+Sym operation chaining = Y
+HW Accelerated         = Y
+Protocol offload       = Y
+In Place SGL           = Y
+
+;
+; Supported crypto algorithms of the 'bcmfs' crypto driver.
+;
+[Cipher]
+AES CBC (128)  = Y
+AES CBC (192)  = Y
+AES CBC (256)  = Y
+AES CTR (128)  = Y
+AES CTR (192)  = Y
+AES CTR (256)  = Y
+AES XTS (128)  = Y
+AES XTS (256)  = Y
+3DES CBC       = Y
+DES CBC        = Y
+;
+; Supported authentication algorithms of the 'bcmfs' crypto driver.
+;
+[Auth]
+MD5 HMAC     = Y
+SHA1         = Y
+SHA1 HMAC    = Y
+SHA224       = Y

doc/guides/cryptodevs/features/bcmfs.ini line 44

Quoted 10 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +10 -0
+SHA224 HMAC  = Y
+SHA256       = Y
+SHA256 HMAC  = Y
+SHA384       = Y
+SHA384 HMAC  = Y
+SHA512       = Y
+SHA512 HMAC  = Y
+AES GMAC     = Y
+AES CMAC (128) = Y
+AES CBC = Y

AES CBC is not an auth algo
You should use AES CBC MAC
Please use the same notation as there in default.ini Check for all the names.

doc/guides/cryptodevs/features/bcmfs.ini line 56

Quoted 12 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +12 -0
+AES XCBC = Y
+
+;
+; Supported AEAD algorithms of the 'bcmfs' crypto driver.
+;
+[AEAD]
+AES GCM (128)     = Y
+AES GCM (192)     = Y
+AES GCM (256)     = Y
+AES CCM (128)     = Y
+AES CCM (192)     = Y
+AES CCM (256)     = Y

// snip//

doc/guides/cryptodevs/features/bcmfs.ini

Quoted 12 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +12 -0
+	{
+		/* SHA1 HMAC */
+		.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+		{.sym = {
+			.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+			{.auth = {
+				.algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
+				.block_size = 64,
+				.key_size = {
+					.min = 1,
+					.max = 64,
+					.increment = 0

Increment should be 1 for all HMAC cases.

doc/guides/cryptodevs/features/bcmfs.ini

Quoted 10 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +10 -0
+				},
+				.digest_size = {
+					.min = 20,
+					.max = 20,
+					.increment = 0
+				},
+				.aad_size = { 0 }
+			}, }
+		}, }
+	},

//snipp//

doc/guides/cryptodevs/features/bcmfs.ini

Quoted 12 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +12 -0
+	{
+		/* AES CMAC */
+		.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+		{.sym = {
+			.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+			{.auth = {
+				.algo = RTE_CRYPTO_AUTH_AES_CMAC,
+				.block_size = 16,
+				.key_size = {
+					.min = 1,
+					.max = 16,
+					.increment = 0

Do you only support key sizes of 1 and 16? I see increment =0 in many cases.

doc/guides/cryptodevs/features/bcmfs.ini

Quoted 11 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +11 -0
+				},
+				.digest_size = {
+					.min = 16,
+					.max = 16,
+					.increment = 0
+				},
+				.aad_size = { 0 }
+			}, }
+		}, }
+	},
+	{

//snip//

Quoted 52 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +6 -0
+
+const struct rte_cryptodev_capabilities *
+bcmfs_sym_get_capabilities(void)
+{
+	return bcmfs_sym_capabilities;
+}
drivers/crypto/bcmfs/bcmfs_sym_capabilities.h new file +16 -0
new file mode 100644
index 000000000..3ff61b7d2
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_CAPABILITIES_H_
+#define _BCMFS_SYM_CAPABILITIES_H_
+
+/*
+ * Get capabilities list for the device
+ *
+ */
+const struct rte_cryptodev_capabilities *bcmfs_sym_get_capabilities(void);
+
+#endif /* _BCMFS_SYM_CAPABILITIES_H__ */
+
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +16 -0
new file mode 100644
index 000000000..d94446d35
@@ -0,0 +1,170 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_DEFS_H_
+#define _BCMFS_SYM_DEFS_H_
+
+/*
+ * Max block size of hash algorithm
+ * currently SHA3 supports max block size
+ * of 144 bytes
+ */
+#define BCMFS_MAX_KEY_SIZE	144
+#define BCMFS_MAX_IV_SIZE	16
+#define BCMFS_MAX_DIGEST_SIZE	64

drivers/crypto/bcmfs/bcmfs_sym_defs.h line 26

Quoted 10 lines
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +10 -0
+
+/** Symmetric Cipher Direction */
+enum bcmfs_crypto_cipher_op {
+	/** Encrypt cipher operation */
+	BCMFS_CRYPTO_CIPHER_OP_ENCRYPT,
+
+	/** Decrypt cipher operation */
+	BCMFS_CRYPTO_CIPHER_OP_DECRYPT,
+};
+

Why are these enums needed, Aren't these replica of rte_sym_crypto.h

Are these enum values getting filled in some HW desc/registers. If so, then Probably move it to the hw folder.

Quoted 39 lines
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +39 -0
+/** Symmetric Cipher Algorithms */
+enum bcmfs_crypto_cipher_algorithm {
+	/** NULL cipher algorithm. No mode applies to the NULL algorithm. */
+	BCMFS_CRYPTO_CIPHER_NONE = 0,
+
+	/** Triple DES algorithm in CBC mode */
+	BCMFS_CRYPTO_CIPHER_DES_CBC,
+
+	/** Triple DES algorithm in ECB mode */
+	BCMFS_CRYPTO_CIPHER_DES_ECB,
+
+	/** Triple DES algorithm in CBC mode */
+	BCMFS_CRYPTO_CIPHER_3DES_CBC,
+
+	/** Triple DES algorithm in ECB mode */
+	BCMFS_CRYPTO_CIPHER_3DES_ECB,
+
+	/** AES algorithm in CBC mode */
+	BCMFS_CRYPTO_CIPHER_AES_CBC,
+
+	/** AES algorithm in CCM mode. */
+	BCMFS_CRYPTO_CIPHER_AES_CCM,
+
+	/** AES algorithm in Counter mode */
+	BCMFS_CRYPTO_CIPHER_AES_CTR,
+
+	/** AES algorithm in ECB mode */
+	BCMFS_CRYPTO_CIPHER_AES_ECB,
+
+	/** AES algorithm in GCM mode. */
+	BCMFS_CRYPTO_CIPHER_AES_GCM,
+
+	/** AES algorithm in XTS mode */
+	BCMFS_CRYPTO_CIPHER_AES_XTS,
+
+	/** AES algorithm in OFB mode */
+	BCMFS_CRYPTO_CIPHER_AES_OFB,
+};
+
#26 lore raw

Re: [dpdk-dev] [PATCH v2 6/8] crypto/bcmfs: add session handling and capabilities

Hi Akhil,

Quoted 51 lines · Akhil Goyal

Hi Vikas,

Quoted 48 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +41 -0
new file mode 100644
index 000000000..82d2c639d
@@ -0,0 +1,56 @@
+;
+; Supported features of the 'bcmfs' crypto driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Symmetric crypto       = Y
+Sym operation chaining = Y
+HW Accelerated         = Y
+Protocol offload       = Y
+In Place SGL           = Y
+
+;
+; Supported crypto algorithms of the 'bcmfs' crypto driver.
+;
+[Cipher]
+AES CBC (128)  = Y
+AES CBC (192)  = Y
+AES CBC (256)  = Y
+AES CTR (128)  = Y
+AES CTR (192)  = Y
+AES CTR (256)  = Y
+AES XTS (128)  = Y
+AES XTS (256)  = Y
+3DES CBC       = Y
+DES CBC        = Y
+;
+; Supported authentication algorithms of the 'bcmfs' crypto driver.
+;
+[Auth]
+MD5 HMAC     = Y
+SHA1         = Y
+SHA1 HMAC    = Y
+SHA224       = Y
+SHA224 HMAC  = Y
+SHA256       = Y
+SHA256 HMAC  = Y
+SHA384       = Y
+SHA384 HMAC  = Y
+SHA512       = Y
+SHA512 HMAC  = Y
Quoted 8 lines

doc/guides/cryptodevs/features/bcmfs.ini line 44

Quoted 3 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +3 -0
+AES GMAC     = Y
+AES CMAC (128) = Y
+AES CBC = Y

AES CBC is not an auth algo
You should use AES CBC MAC
Please use the same notation as there in default.ini Check for all the names.

Will fix it.

Quoted 29 lines

doc/guides/cryptodevs/features/bcmfs.ini line 56

Quoted 13 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +12 -0
+AES XCBC = Y
+
+;
+; Supported AEAD algorithms of the 'bcmfs' crypto driver.
+;
+[AEAD]
+AES GCM (128)     = Y
+AES GCM (192)     = Y
+AES GCM (256)     = Y
+AES CCM (128)     = Y
+AES CCM (192)     = Y
+AES CCM (256)     = Y

// snip//

doc/guides/cryptodevs/features/bcmfs.ini

Quoted 12 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +12 -0
+     {
+             /* SHA1 HMAC */
+             .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+             {.sym = {
+                     .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+                     {.auth = {
+                             .algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
+                             .block_size = 64,
+                             .key_size = {
+                                     .min = 1,
+                                     .max = 64,
+                                     .increment = 0
Quoted 1 line

Increment should be 1 for all HMAC cases.

I`ll go through all the list again. Thanks for catching.

Quoted 27 lines

doc/guides/cryptodevs/features/bcmfs.ini

Quoted 11 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +10 -0
+                             },
+                             .digest_size = {
+                                     .min = 20,
+                                     .max = 20,
+                                     .increment = 0
+                             },
+                             .aad_size = { 0 }
+                     }, }
+             }, }
+     },

//snipp//

doc/guides/cryptodevs/features/bcmfs.ini

Quoted 12 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +12 -0
+     {
+             /* AES CMAC */
+             .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+             {.sym = {
+                     .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+                     {.auth = {
+                             .algo = RTE_CRYPTO_AUTH_AES_CMAC,
+                             .block_size = 16,
+                             .key_size = {
+                                     .min = 1,
+                                     .max = 16,
+                                     .increment = 0
Quoted 1 line

Do you only support key sizes of 1 and 16? I see increment =0 in many cases.

Will review the list and fix it accordingly.

Quoted 81 lines

doc/guides/cryptodevs/features/bcmfs.ini

Quoted 12 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +11 -0
+                             },
+                             .digest_size = {
+                                     .min = 16,
+                                     .max = 16,
+                                     .increment = 0
+                             },
+                             .aad_size = { 0 }
+                     }, }
+             }, }
+     },
+     {

//snip//

Quoted 52 lines
doc/guides/cryptodevs/features/bcmfs.ini new file +6 -0
+
+const struct rte_cryptodev_capabilities *
+bcmfs_sym_get_capabilities(void)
+{
+     return bcmfs_sym_capabilities;
+}
drivers/crypto/bcmfs/bcmfs_sym_capabilities.h new file +16 -0
new file mode 100644
index 000000000..3ff61b7d2
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_CAPABILITIES_H_
+#define _BCMFS_SYM_CAPABILITIES_H_
+
+/*
+ * Get capabilities list for the device
+ *
+ */
+const struct rte_cryptodev_capabilities *bcmfs_sym_get_capabilities(void);
+
+#endif /* _BCMFS_SYM_CAPABILITIES_H__ */
+
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +16 -0
new file mode 100644
index 000000000..d94446d35
@@ -0,0 +1,170 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_DEFS_H_
+#define _BCMFS_SYM_DEFS_H_
+
+/*
+ * Max block size of hash algorithm
+ * currently SHA3 supports max block size
+ * of 144 bytes
+ */
+#define BCMFS_MAX_KEY_SIZE   144
+#define BCMFS_MAX_IV_SIZE    16
+#define BCMFS_MAX_DIGEST_SIZE        64

drivers/crypto/bcmfs/bcmfs_sym_defs.h line 26

Quoted 10 lines
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +10 -0
+
+/** Symmetric Cipher Direction */
+enum bcmfs_crypto_cipher_op {
+     /** Encrypt cipher operation */
+     BCMFS_CRYPTO_CIPHER_OP_ENCRYPT,
+
+     /** Decrypt cipher operation */
+     BCMFS_CRYPTO_CIPHER_OP_DECRYPT,
+};
+

Why are these enums needed, Aren't these replica of rte_sym_crypto.h

Quoted 2 lines

Are these enum values getting filled in some HW desc/registers. If so, then Probably move it to the hw folder.

We`ll review this and place/modify macros accordingly.

Quoted 32 lines
Quoted 32 lines
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +31 -0
+/** Symmetric Cipher Algorithms */
+enum bcmfs_crypto_cipher_algorithm {
+     /** NULL cipher algorithm. No mode applies to the NULL algorithm. */
+     BCMFS_CRYPTO_CIPHER_NONE = 0,
+
+     /** Triple DES algorithm in CBC mode */
+     BCMFS_CRYPTO_CIPHER_DES_CBC,
+
+     /** Triple DES algorithm in ECB mode */
+     BCMFS_CRYPTO_CIPHER_DES_ECB,
+
+     /** Triple DES algorithm in CBC mode */
+     BCMFS_CRYPTO_CIPHER_3DES_CBC,
+
+     /** Triple DES algorithm in ECB mode */
+     BCMFS_CRYPTO_CIPHER_3DES_ECB,
+
+     /** AES algorithm in CBC mode */
+     BCMFS_CRYPTO_CIPHER_AES_CBC,
+
+     /** AES algorithm in CCM mode. */
+     BCMFS_CRYPTO_CIPHER_AES_CCM,
+
+     /** AES algorithm in Counter mode */
+     BCMFS_CRYPTO_CIPHER_AES_CTR,
+
+     /** AES algorithm in ECB mode */
+     BCMFS_CRYPTO_CIPHER_AES_ECB,
+
+     /** AES algorithm in GCM mode. */
+     BCMFS_CRYPTO_CIPHER_AES_GCM,
Quoted 8 lines

drivers/crypto/bcmfs/bcmfs_sym_defs.h line 65

Quoted 8 lines
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +8 -0
+
+     /** AES algorithm in XTS mode */
+     BCMFS_CRYPTO_CIPHER_AES_XTS,
+
+     /** AES algorithm in OFB mode */
+     BCMFS_CRYPTO_CIPHER_AES_OFB,
+};
+

Thanks,
Vikas

#27 lore raw

PATCH v2 7/8 crypto/bcmfs: add crypto h/w module

In reply to Vikas Gupta

Add crypto h/w module to process crypto op. Crypto op is processed via sym_engine module before submitting the crypto request to h/w queues.

---
 drivers/crypto/bcmfs/bcmfs_sym.c        | 316 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_defs.h   |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_engine.c | 994 ++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h | 103 +++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c    |  26 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h    |  40 +
 drivers/crypto/bcmfs/meson.build        |   4 +-
 7 files changed, 1498 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
drivers/crypto/bcmfs/bcmfs_sym.c new file +316 -0
new file mode 100644
index 000000000..8f9415b5e
@@ -0,0 +1,316 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <stdbool.h>
+
+#include <rte_byteorder.h>
+#include <rte_crypto_sym.h>
+#include <rte_cryptodev.h>
+#include <rte_mbuf.h>
+#include <rte_mempool.h>
+
+#include "bcmfs_sym_defs.h"
+#include "bcmfs_sym_engine.h"
+#include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+
+/** Process cipher operation */
+static int
+process_crypto_cipher_op(struct rte_crypto_op *op,
+			 struct rte_mbuf *mbuf_src,
+			 struct rte_mbuf *mbuf_dst,
+			 struct bcmfs_sym_session *sess,
+			 struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv, key;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+	fsattr_pa(&dst) = rte_pktmbuf_iova(mbuf_dst);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						     uint8_t *,
+						     sess->cipher.iv.offset);
+
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&key) = sess->cipher.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->cipher.key.length;
+
+	rc = bcmfs_crypto_build_cipher_req(req, sess->cipher.algo,
+					   sess->cipher.direction, &src,
+					   &dst, &key, &iv);
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process auth operation */
+static int
+process_crypto_auth_op(struct rte_crypto_op *op,
+			   struct rte_mbuf *mbuf_src,
+			   struct bcmfs_sym_session *sess,
+			   struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, mac, key;
+
+	fsattr_sz(&src) = op->sym->auth.data.length;
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset(mbuf_src,
+						   uint8_t *,
+						   op->sym->auth.data.offset);
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+
+	if (!sess->auth.operation) {
+		fsattr_va(&mac) = op->sym->auth.digest.data;
+		fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&mac) = sess->auth.digest_length;
+	} else {
+		fsattr_va(&dst) = op->sym->auth.digest.data;
+		fsattr_pa(&dst) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&dst) = sess->auth.digest_length;
+	}
+
+	fsattr_va(&key) = sess->auth.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->auth.key.length;
+
+	/* AES-GMAC uses AES-GCM-128 authenticator */
+	if (sess->auth.algo == BCMFS_CRYPTO_AUTH_AES_GMAC) {
+		struct fsattr  iv;
+		fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+							    uint8_t *,
+							    sess->auth.iv.offset);
+		fsattr_pa(&iv) = 0;
+		fsattr_sz(&iv) = sess->auth.iv.length;
+
+		rc = bcmfs_crypto_build_aead_request(req,
+						     BCMFS_CRYPTO_CIPHER_NONE,
+						     0,
+						     BCMFS_CRYPTO_AUTH_AES_GMAC,
+						     sess->auth.operation,
+						     &src, NULL, NULL, &key,
+						     &iv, NULL,
+						     sess->auth.operation ?
+							(&dst) : &(mac),
+						     0);
+	} else {
+		rc = bcmfs_crypto_build_auth_req(req, sess->auth.algo,
+						 sess->auth.operation,
+						 &src,
+						 (sess->auth.operation) ? (&dst) : NULL,
+						 (sess->auth.operation) ? NULL  : (&mac),
+						 &key);
+	}
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process combined/chained mode operation */
+static int
+process_crypto_combined_op(struct rte_crypto_op *op,
+			   struct rte_mbuf *mbuf_src,
+			   struct rte_mbuf *mbuf_dst,
+			   struct bcmfs_sym_session *sess,
+			   struct bcmfs_sym_request *req)
+{
+	int rc = 0, aad_size = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr cipher_key, aad, mac, auth_key;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->cipher.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						sym_op->cipher.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						     uint8_t *,
+						     sess->cipher.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&cipher_key) = sess->cipher.key.data;
+	fsattr_pa(&cipher_key) = 0;
+	fsattr_sz(&cipher_key) = sess->cipher.key.length;
+
+	fsattr_va(&auth_key) = sess->auth.key.data;
+	fsattr_pa(&auth_key) = 0;
+	fsattr_sz(&auth_key) = sess->auth.key.length;
+
+	fsattr_va(&mac) = op->sym->auth.digest.data;
+	fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+	fsattr_sz(&mac) = sess->auth.digest_length;
+
+	aad_size = sym_op->auth.data.length - sym_op->cipher.data.length;
+
+	if (aad_size > 0) {
+		fsattr_sz(&aad) =  aad_size;
+		fsattr_va(&aad) = rte_pktmbuf_mtod_offset
+						(mbuf_src,
+						 uint8_t *,
+						sym_op->auth.data.offset);
+		fsattr_pa(&aad) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->auth.data.offset);
+	}
+
+	rc = bcmfs_crypto_build_aead_request(req, sess->cipher.algo,
+					     sess->cipher.direction,
+					     sess->auth.algo,
+					     sess->auth.operation,
+					     &src, &dst, &cipher_key,
+					     &auth_key, &iv,
+					     (aad_size > 0) ? (&aad) : NULL,
+					     &mac, sess->cipher_first);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process AEAD operation */
+static int
+process_crypto_aead_op(struct rte_crypto_op *op,
+		       struct rte_mbuf *mbuf_src,
+		       struct rte_mbuf *mbuf_dst,
+		       struct bcmfs_sym_session *sess,
+		       struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr cipher_key, aad, mac, auth_key;
+	enum bcmfs_crypto_cipher_op cipher_op;
+	enum bcmfs_crypto_auth_op auth_op;
+
+	if (sess->cipher.direction) {
+		auth_op = BCMFS_CRYPTO_AUTH_OP_VERIFY;
+		cipher_op = BCMFS_CRYPTO_CIPHER_OP_DECRYPT;
+	} else {
+		auth_op = BCMFS_CRYPTO_AUTH_OP_GENERATE;
+		cipher_op = BCMFS_CRYPTO_CIPHER_OP_ENCRYPT;
+	}
+
+	fsattr_sz(&src) = sym_op->aead.data.length;
+	fsattr_sz(&dst) = sym_op->aead.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 sym_op->aead.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 sym_op->aead.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->aead.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						sym_op->aead.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						    uint8_t *,
+						    sess->cipher.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&cipher_key) = sess->cipher.key.data;
+	fsattr_pa(&cipher_key) = 0;
+	fsattr_sz(&cipher_key) = sess->cipher.key.length;
+
+	fsattr_va(&auth_key) = sess->auth.key.data;
+	fsattr_pa(&auth_key) = 0;
+	fsattr_sz(&auth_key) = sess->auth.key.length;
+
+	fsattr_va(&mac) = op->sym->aead.digest.data;
+	fsattr_pa(&mac) = op->sym->aead.digest.phys_addr;
+	fsattr_sz(&mac) = sess->auth.digest_length;
+
+	fsattr_va(&aad) = op->sym->aead.aad.data;
+	fsattr_pa(&aad) = op->sym->aead.aad.phys_addr;
+	fsattr_sz(&aad) = sess->aead.aad_length;
+
+	rc = bcmfs_crypto_build_aead_request(req, sess->cipher.algo,
+					     cipher_op, sess->auth.algo,
+					     auth_op, &src, &dst, &cipher_key,
+					     &auth_key, &iv, &aad, &mac,
+					     sess->cipher.direction ? 0 : 1);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process crypto operation for mbuf */
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req)
+{
+	struct rte_mbuf *msrc, *mdst;
+	int rc = 0;
+
+	msrc = op->sym->m_src;
+	mdst = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src;
+	op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+
+	switch (sess->chain_order) {
+	case BCMFS_SYM_CHAIN_ONLY_CIPHER:
+		rc = process_crypto_cipher_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_ONLY_AUTH:
+		rc = process_crypto_auth_op(op, msrc, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_CIPHER_AUTH:
+	case BCMFS_SYM_CHAIN_AUTH_CIPHER:
+		rc = process_crypto_combined_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_AEAD:
+		rc = process_crypto_aead_op(op, msrc, mdst, sess, req);
+		break;
+	default:
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+		break;
+	}
+
+	return rc;
+}
drivers/crypto/bcmfs/bcmfs_sym_defs.h +16 -0
index d94446d35..90280dba5 100644
@@ -15,6 +15,18 @@
 #define BCMFS_MAX_IV_SIZE	16
 #define BCMFS_MAX_DIGEST_SIZE	64
 
+struct bcmfs_sym_session;
+struct bcmfs_sym_request;
+
+/** Crypto Request processing successful. */
+#define BCMFS_SYM_RESPONSE_SUCCESS               (0)
+/** Crypot Request processing protocol failure. */
+#define BCMFS_SYM_RESPONSE_PROTO_FAILURE         (1)
+/** Crypot Request processing completion failure. */
+#define BCMFS_SYM_RESPONSE_COMPL_ERROR           (2)
+/** Crypot Request processing hash tag check error. */
+#define BCMFS_SYM_RESPONSE_HASH_TAG_ERROR        (3)
+
 /** Symmetric Cipher Direction */
 enum bcmfs_crypto_cipher_op {
 	/** Encrypt cipher operation */
@@ -167,4 +179,8 @@ enum bcmfs_sym_crypto_class {
 	BCMFS_CRYPTO_AEAD,
 };
 
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req);
 #endif /* _BCMFS_SYM_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_sym_engine.c new file +994 -0

994 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_engine.h new file +103 -0

103 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.c +26 -0
index 381ca8ea4..568797b4f 100644
@@ -132,6 +132,12 @@ static void
 spu_req_init(struct bcmfs_sym_request *sr, rte_iova_t iova __rte_unused)
 {
 	memset(sr, 0, sizeof(*sr));
+	sr->fptr = iova;
+	sr->cptr = iova + offsetof(struct bcmfs_sym_request, cipher_key);
+	sr->aptr = iova + offsetof(struct bcmfs_sym_request, auth_key);
+	sr->iptr = iova + offsetof(struct bcmfs_sym_request, iv);
+	sr->dptr = iova + offsetof(struct bcmfs_sym_request, digest);
+	sr->rptr = iova + offsetof(struct bcmfs_sym_request, resp);
 }
 
 static void
@@ -244,6 +250,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 			       uint16_t nb_ops)
 {
 	int i, j;
+	int retval;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
 	struct bcmfs_sym_session *sess;
@@ -273,6 +280,11 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		/* save context */
 		qp->infl_msgs[i] = &sreq->msgs;
 		qp->infl_msgs[i]->ctx = (void *)sreq;
+
+		/* pre process the request crypto h/w acceleration */
+		retval = bcmfs_process_sym_crypto_op(ops[i], sess, sreq);
+		if (unlikely(retval < 0))
+			goto enqueue_err;
 	}
 	/* Send burst request to hw QP */
 	enq = bcmfs_enqueue_op_burst(qp, (void **)qp->infl_msgs, i);
@@ -289,6 +301,17 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	return enq;
 }
 
+static void bcmfs_sym_set_request_status(struct rte_crypto_op *op,
+					 struct bcmfs_sym_request *out)
+{
+	if (*out->resp == BCMFS_SYM_RESPONSE_SUCCESS)
+		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+	else if (*out->resp == BCMFS_SYM_RESPONSE_HASH_TAG_ERROR)
+		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+	else
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+}
+
 static uint16_t
 bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 			       struct rte_crypto_op **ops,
@@ -308,6 +331,9 @@ bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 	for (i = 0; i < deq; i++) {
 		sreq = (struct bcmfs_sym_request *)qp->infl_msgs[i]->ctx;
 
+		/* set the status based on the response from the crypto h/w */
+		bcmfs_sym_set_request_status(sreq->op, sreq);
+
 		ops[pkts++] = sreq->op;
 
 		rte_mempool_put(qp->sr_mp, sreq);
drivers/crypto/bcmfs/bcmfs_sym_req.h +40 -0
index 0f0b051f1..e53c50adc 100644
@@ -6,13 +6,53 @@
 #ifndef _BCMFS_SYM_REQ_H_
 #define _BCMFS_SYM_REQ_H_
 
+#include <rte_cryptodev.h>
+
 #include "bcmfs_dev_msg.h"
+#include "bcmfs_sym_defs.h"
+
+/* Fixed SPU2 Metadata */
+struct spu2_fmd {
+	uint64_t ctrl0;
+	uint64_t ctrl1;
+	uint64_t ctrl2;
+	uint64_t ctrl3;
+};
 
 /*
  * This structure hold the supportive data required to process a
  * rte_crypto_op
  */
 struct bcmfs_sym_request {
+	/* spu2 engine related data */
+	struct spu2_fmd fmd;
+	/* cipher key */
+	uint8_t cipher_key[BCMFS_MAX_KEY_SIZE];
+	/* auth key */
+	uint8_t auth_key[BCMFS_MAX_KEY_SIZE];
+	/* iv key */
+	uint8_t iv[BCMFS_MAX_IV_SIZE];
+	/* digest data output from crypto h/w */
+	uint8_t digest[BCMFS_MAX_DIGEST_SIZE];
+	/* 2-Bytes response from crypto h/w */
+	uint8_t resp[2];
+	/*
+	 * Below are all iovas for above members
+	 * from top
+	 */
+	/* iova for fmd */
+	rte_iova_t fptr;
+	/* iova for cipher key */
+	rte_iova_t cptr;
+	/* iova for auth key */
+	rte_iova_t aptr;
+	/* iova for iv key */
+	rte_iova_t iptr;
+	/* iova for digest */
+	rte_iova_t dptr;
+	/* iova for response */
+	rte_iova_t rptr;
+
 	/* bcmfs qp message for h/w queues to process */
 	struct bcmfs_qp_message msgs;
 	/* crypto op */
drivers/crypto/bcmfs/meson.build +3 -1
index 2e86c733e..7aa0f05db 100644
@@ -14,5 +14,7 @@ sources = files(
 		'hw/bcmfs_rm_common.c',
 		'bcmfs_sym_pmd.c',
 		'bcmfs_sym_capabilities.c',
-		'bcmfs_sym_session.c'
+		'bcmfs_sym_session.c',
+		'bcmfs_sym.c',
+		'bcmfs_sym_engine.c'
 		)
Signature · 1 line
2.17.1
#28 lore raw

Re: [dpdk-dev] [PATCH v2 7/8] crypto/bcmfs: add crypto h/w module

Hi Vikas,

Quoted 11 lines

Subject: [PATCH v2 7/8] crypto/bcmfs: add crypto h/w module

Add crypto h/w module to process crypto op. Crypto op is processed via sym_engine module before submitting the crypto request to h/w queues.

---
 drivers/crypto/bcmfs/bcmfs_sym.c        | 316 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_defs.h   |  16 +

You can probably move the hardware specific defines and enums into hw Directory of your driver.

Quoted 10 lines
 drivers/crypto/bcmfs/bcmfs_sym_engine.c | 994 ++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h | 103 +++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c    |  26 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h    |  40 +
 drivers/crypto/bcmfs/meson.build        |   4 +-
 7 files changed, 1498 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
#29 lore raw

PATCH v2 8/8 crypto/bcmfs: add crypto pmd into cryptodev test

In reply to Vikas Gupta

Add global test suite for bcmfs crypto pmd

---
 app/test/test_cryptodev.c | 17 +++++++++++++++++
 app/test/test_cryptodev.h |  1 +
 2 files changed, 18 insertions(+)
app/test/test_cryptodev.c +17 -0
index 70bf6fe2c..9157115ab 100644
@@ -13041,6 +13041,22 @@ test_cryptodev_nitrox(void)
 	return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
 }
 
+static int
+test_cryptodev_bcmfs(void)
+{
+	gbl_driver_id =	rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
+
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded. Check if "
+				"CONFIG_RTE_LIBRTE_PMD_BCMFS is enabled "
+				"in config file to run this testsuite.\n");
+		return TEST_FAILED;
+	}
+
+	return unit_test_suite_runner(&cryptodev_testsuite);
+}
+
 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
@@ -13063,3 +13079,4 @@ REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
+REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
app/test/test_cryptodev.h +1 -0
index 41542e055..c58126368 100644
@@ -70,6 +70,7 @@
 #define CRYPTODEV_NAME_OCTEONTX2_PMD	crypto_octeontx2
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 #define CRYPTODEV_NAME_NITROX_PMD	crypto_nitrox_sym
+#define CRYPTODEV_NAME_BCMFS_PMD	crypto_bcmfs
 
 /**
  * Write (spread) data from buffer to mbuf data
Signature · 1 line
2.17.1
#31 lore raw
In reply to Vikas Gupta
Quoted 65 lines

Hi,
This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.
BCMFS is an acronym for Broadcom FlexSparc device used in the patchest.

The patchset progressively adds major modules as below.
a) Detection of platform-device based on the known registered platforms and attaching with VFIO.
b) Creation of Cryptodevice.
c) Addition of session handling.
d) Add Cryptodevice into test Cryptodev framework.

The patchset has been tested on the above mentioned SoCs.

Regards,
Vikas

Changes from v0->v1:
Updated the ABI version in
file .../crypto/bcmfs/rte_pmd_bcmfs_version.map

Changes from v1->v2:
- Fix compilation errors and coding style warnings.
- Use global test crypto suite suggested by Adam Dybkowski

Vikas Gupta (8):
crypto/bcmfs: add BCMFS driver crypto/bcmfs: add vfio support crypto/bcmfs: add apis for queue pair management crypto/bcmfs: add hw queue pair operations crypto/bcmfs: create a symmetric cryptodev crypto/bcmfs: add session handling and capabilities crypto/bcmfs: add crypto h/w module crypto/bcmfs: add crypto pmd into cryptodev test

 MAINTAINERS                                   |   7 +
 app/test/test_cryptodev.c                     |  17 +
 app/test/test_cryptodev.h                     |   1 +
 config/common_base                            |   5 +
 doc/guides/cryptodevs/bcmfs.rst               |  72 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |  56 +
 doc/guides/cryptodevs/index.rst               |   1 +
 drivers/crypto/bcmfs/bcmfs_dev_msg.h          |  29 +
 drivers/crypto/bcmfs/bcmfs_device.c           | 331 ++++++
 drivers/crypto/bcmfs/bcmfs_device.h           |  76 ++
 drivers/crypto/bcmfs/bcmfs_hw_defs.h          |  38 +
 drivers/crypto/bcmfs/bcmfs_logs.c             |  38 +
 drivers/crypto/bcmfs/bcmfs_logs.h             |  34 +
 drivers/crypto/bcmfs/bcmfs_qp.c               | 383 +++++++
 drivers/crypto/bcmfs/bcmfs_qp.h               | 142 +++
 drivers/crypto/bcmfs/bcmfs_sym.c              | 316 ++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c | 764 ++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         | 186 ++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.c       | 994 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h       | 103 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          | 426 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h          |  38 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h          |  62 ++
 drivers/crypto/bcmfs/bcmfs_sym_session.c      | 424 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      |  99 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c             | 107 ++
 drivers/crypto/bcmfs/bcmfs_vfio.h             |  17 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c           | 742 +++++++++++++
Quoted 8 lines
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c           | 677 ++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c     |  82 ++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h     |  46 +
 drivers/crypto/bcmfs/meson.build              |  20 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |   3 +
 drivers/crypto/meson.build                    |   3 +-
 mk/rte.app.mk                                 |   1 +
 36 files changed, 6355 insertions(+), 1 deletion(-)

Release notes missing.

#32 lore raw

Hi Vikas

Quoted 14 lines
Quoted 14 lines

Hi,
This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.
BCMFS is an acronym for Broadcom FlexSparc device used in the patchest.

The patchset progressively adds major modules as below.
a) Detection of platform-device based on the known registered platforms and attaching with VFIO.
b) Creation of Cryptodevice.
c) Addition of session handling.
d) Add Cryptodevice into test Cryptodev framework.

Quoted 5 lines
Quoted 2 lines

The patchset has been tested on the above mentioned SoCs.

Release notes missing.

When do you plan to submit the next version. I plan to merge it in RC1 timeline.

#33 lore raw
Quoted 17 lines · Akhil Goyal

Hi Vikas

Quoted 14 lines
Quoted 14 lines

Hi,
This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.
BCMFS is an acronym for Broadcom FlexSparc device used in the patchest.

The patchset progressively adds major modules as below.
a) Detection of platform-device based on the known registered platforms and attaching with VFIO.
b) Creation of Cryptodevice.
c) Addition of session handling.
d) Add Cryptodevice into test Cryptodev framework.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

The patchset has been tested on the above mentioned SoCs.

Release notes missing.

When do you plan to submit the next version. I plan to merge it in RC1 timeline.

Akhil, You can expect a new version in a day - worst case two.

#34 lore raw

Hi Akhil,

Quoted 19 lines · Ajit Khaparde
Quoted 17 lines · Akhil Goyal

Hi Vikas

Quoted 14 lines
Quoted 14 lines

Hi,
This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.
BCMFS is an acronym for Broadcom FlexSparc device used in the patchest.

The patchset progressively adds major modules as below.
a) Detection of platform-device based on the known registered platforms and attaching with VFIO.
b) Creation of Cryptodevice.
c) Addition of session handling.
d) Add Cryptodevice into test Cryptodev framework.

Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

The patchset has been tested on the above mentioned SoCs.

Release notes missing.

When do you plan to submit the next version. I plan to merge it in RC1 timeline.

Akhil, You can expect a new version in a day - worst case two.

I have pushed the v3 patchset.

Thanks,
Vikas

#35 lore raw

v3 cover Add Crypto PMD for Broadcom`s FlexSparc devices

In reply to Vikas Gupta

Hi,
This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.
BCMFS is an acronym for Broadcom FlexSparc device used in the patchest.

The patchset progressively adds major modules as below.
a) Detection of platform-device based on the known registered platforms and attaching with VFIO.
b) Creation of Cryptodevice.
c) Addition of session handling.
d) Add Cryptodevice into test Cryptodev framework.

The patchset has been tested on the above mentioned SoCs.

Regards,
Vikas

Changes from v0->v1:
Updated the ABI version in file .../crypto/bcmfs/rte_pmd_bcmfs_version.map

Changes from v1->v2:
- Fix compilation errors and coding style warnings.
- Use global test crypto suite suggested by Adam Dybkowski

Changes from v2->v3:
- Release notes updated.
- bcmfs.rst updated with missing information about installation.
- Review comments from patch1 from v2 addressed.
- Updated description about dependency of PMD driver on VFIO_PRESENT.
- Fixed typo in bcmfs_hw_defs.h (comments on patch3 from v2 addressed)
- Comments on patch6 from v2 addressed and capability list is fixed. Removed redundant enums and macros from the file bcmfs_sym_defs.h and updated other impacted APIs accordingly. patch7 too is updated due to removal of redundancy. Thanks! to Akhil for pointing out the redundancy.
- Fix minor code style issues in few files as part of review.

Vikas Gupta (8):
crypto/bcmfs: add BCMFS driver crypto/bcmfs: add vfio support crypto/bcmfs: add apis for queue pair management crypto/bcmfs: add hw queue pair operations crypto/bcmfs: create a symmetric cryptodev crypto/bcmfs: add session handling and capabilities crypto/bcmfs: add crypto h/w module crypto/bcmfs: add crypto pmd into cryptodev test

 MAINTAINERS                                   |    7 +
 app/test/test_cryptodev.c                     |   17 +
 app/test/test_cryptodev.h                     |    1 +
 doc/guides/cryptodevs/bcmfs.rst               |  109 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |   56 +
 doc/guides/cryptodevs/index.rst               |    1 +
 doc/guides/rel_notes/release_20_11.rst        |    5 +
 drivers/crypto/bcmfs/bcmfs_dev_msg.h          |   29 +
 drivers/crypto/bcmfs/bcmfs_device.c           |  332 +++++
 drivers/crypto/bcmfs/bcmfs_device.h           |   76 ++
 drivers/crypto/bcmfs/bcmfs_hw_defs.h          |   32 +
 drivers/crypto/bcmfs/bcmfs_logs.c             |   38 +
 drivers/crypto/bcmfs/bcmfs_logs.h             |   34 +
 drivers/crypto/bcmfs/bcmfs_qp.c               |  383 ++++++
 drivers/crypto/bcmfs/bcmfs_qp.h               |  142 ++
 drivers/crypto/bcmfs/bcmfs_sym.c              |  289 +++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c |  764 +++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |   16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         |   34 +
 drivers/crypto/bcmfs/bcmfs_sym_engine.c       | 1155 +++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h       |  115 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          |  426 ++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h          |   38 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h          |   62 +
 drivers/crypto/bcmfs/bcmfs_sym_session.c      |  282 ++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      |  109 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c             |  107 ++
 drivers/crypto/bcmfs/bcmfs_vfio.h             |   17 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c           |  743 +++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c           |  677 ++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c     |   82 ++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h     |   51 +
 drivers/crypto/bcmfs/meson.build              |   20 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |    3 +
 drivers/crypto/meson.build                    |    1 +
 35 files changed, 6253 insertions(+)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
Signature · 1 line
2.17.1
#36 lore raw

PATCH v3 1/8 crypto/bcmfs: add BCMFS driver

Add Broadcom FlexSparc(FS) device creation driver which registers to a vdev and create a device. Add APIs for logs, supportive documention and maintainers file.

---
 MAINTAINERS                                   |   7 +
 doc/guides/cryptodevs/bcmfs.rst               |  51 ++++
 doc/guides/cryptodevs/index.rst               |   1 +
 doc/guides/rel_notes/release_20_11.rst        |   5 +
 drivers/crypto/bcmfs/bcmfs_device.c           | 257 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_device.h           |  40 +++
 drivers/crypto/bcmfs/bcmfs_logs.c             |  38 +++
 drivers/crypto/bcmfs/bcmfs_logs.h             |  34 +++
 drivers/crypto/bcmfs/meson.build              |  10 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |   3 +
 drivers/crypto/meson.build                    |   1 +
 11 files changed, 447 insertions(+)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
MAINTAINERS +7 -0
index c0abbe0fc8..ab849ac1d1 100644
@@ -1081,6 +1081,13 @@ F: drivers/crypto/zuc/
 F: doc/guides/cryptodevs/zuc.rst
 F: doc/guides/cryptodevs/features/zuc.ini
 
+Broadcom FlexSparc
+M: Vikas Gupta  <vikas.gupta@@broadcom.com>
+M: Raveendra Padasalagi <[email protected]>
+M: Ajit Khaparde <[email protected]>
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 -------------------
doc/guides/cryptodevs/bcmfs.rst new file +51 -0

51 lines not on this page · raw message

doc/guides/cryptodevs/index.rst +1 -0
index a67ed5a282..279f56a002 100644
@@ -13,6 +13,7 @@ Crypto Device Drivers
     aesni_mb
     aesni_gcm
     armv8
+    bcmfs
     caam_jr
     ccp
     dpaa2_sec
doc/guides/rel_notes/release_20_11.rst +5 -0
index 73ac08fb0e..8643330321 100644
@@ -185,3 +185,8 @@ Tested Platforms
    This section is a comment. Do not overwrite or remove it.
    Also, make sure to start the actual text at the margin.
    =======================================================
+
+* **Added Broadcom BCMFS symmetric crypto PMD.**
+
+  Added a symmetric crypto PMD for Broadcom FlexSparc crypto units.
+  See :doc:`../cryptodevs/bcmfs` guide for more details on this new PMD.
drivers/crypto/bcmfs/bcmfs_device.c new file +257 -0

257 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h new file +40 -0
new file mode 100644
index 0000000000..cc64a8df2c
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_DEV_H_
+#define _BCMFS_DEV_H_
+
+#include <sys/queue.h>
+
+#include <rte_bus_vdev.h>
+
+#include "bcmfs_logs.h"
+
+/* max number of dev nodes */
+#define BCMFS_MAX_NODES		4
+#define BCMFS_MAX_PATH_LEN	512
+#define BCMFS_DEV_NAME_LEN	64
+
+/* Path for BCM-Platform device directory */
+#define SYSFS_BCM_PLTFORM_DEVICES    "/sys/bus/platform/devices"
+
+/* Supported devices */
+enum bcmfs_device_type {
+	BCMFS_SYM_FS4,
+	BCMFS_SYM_FS5,
+	BCMFS_UNKNOWN
+};
+
+struct bcmfs_device {
+	TAILQ_ENTRY(bcmfs_device) next;
+	/* Directory path for vfio */
+	char dirname[BCMFS_MAX_PATH_LEN];
+	/* BCMFS device name */
+	char name[BCMFS_DEV_NAME_LEN];
+	/* Parent vdev */
+	struct rte_vdev_device *vdev;
+};
+
+#endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_logs.c new file +38 -0
new file mode 100644
index 0000000000..86f4ff3b53
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <rte_log.h>
+#include <rte_hexdump.h>
+
+#include "bcmfs_logs.h"
+
+int bcmfs_conf_logtype;
+int bcmfs_dp_logtype;
+
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
+		const void *buf, unsigned int len)
+{
+	if (level > rte_log_get_global_level())
+		return 0;
+	if (level > (uint32_t)(rte_log_get_level(logtype)))
+		return 0;
+
+	rte_hexdump(rte_log_get_stream(), title, buf, len);
+	return 0;
+}
+
+RTE_INIT(bcmfs_device_init_log)
+{
+	/* Configuration and general logs */
+	bcmfs_conf_logtype = rte_log_register("pmd.bcmfs_config");
+	if (bcmfs_conf_logtype >= 0)
+		rte_log_set_level(bcmfs_conf_logtype, RTE_LOG_NOTICE);
+
+	/* data-path logs */
+	bcmfs_dp_logtype = rte_log_register("pmd.bcmfs_fp");
+	if (bcmfs_dp_logtype >= 0)
+		rte_log_set_level(bcmfs_dp_logtype, RTE_LOG_NOTICE);
+}
drivers/crypto/bcmfs/bcmfs_logs.h new file +34 -0
new file mode 100644
index 0000000000..c03a49b75c
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_LOGS_H_
+#define _BCMFS_LOGS_H_
+
+#include <rte_log.h>
+
+extern int bcmfs_conf_logtype;
+extern int bcmfs_dp_logtype;
+
+#define BCMFS_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_conf_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_dp_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_HEXDUMP_LOG(level, title, buf, len)	\
+	bcmfs_hexdump_log(RTE_LOG_ ## level, bcmfs_dp_logtype, title, buf, len)
+
+/**
+ * bcmfs_hexdump_log Dump out memory in a special hex dump format.
+ *
+ * The message will be sent to the stream used by the rte_log infrastructure.
+ */
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *heading,
+		  const void *buf, unsigned int len);
+
+#endif /* _BCMFS_LOGS_H_ */
drivers/crypto/bcmfs/meson.build new file +10 -0
new file mode 100644
index 0000000000..a4bdd8ee5d
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2020 Broadcom
+# All rights reserved.
+#
+
+deps += ['eal', 'bus_vdev']
+sources = files(
+		'bcmfs_logs.c',
+		'bcmfs_device.c'
+		)
drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map new file +3 -0
new file mode 100644
index 0000000000..299ae632da
@@ -0,0 +1,3 @@
+DPDK_21.0 {
+	local: *;
+};
drivers/crypto/meson.build +1 -0
index a2423507ad..93c2968acb 100644
@@ -8,6 +8,7 @@ endif
 drivers = ['aesni_gcm',
 	   'aesni_mb',
 	   'armv8',
+	   'bcmfs',
 	   'caam_jr',
 	   'ccp',
 	   'dpaa_sec',
Signature · 1 line
2.17.1
#37 lore raw

PATCH v3 2/8 crypto/bcmfs: add vfio support

In reply to Vikas Gupta

Add VFIO support for BCMFS PMD.
The BCMFS PMD functionality is dependent on the VFIO_PRESENT flag, which gets enabled in the rte_vfio.h.
If this flag is not enabled in the compiling platform driver will silently return with error, when executed.

---
 drivers/crypto/bcmfs/bcmfs_device.c |   5 ++
 drivers/crypto/bcmfs/bcmfs_device.h |   6 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c   | 107 ++++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_vfio.h   |  17 +++++
 drivers/crypto/bcmfs/meson.build    |   3 +-
 5 files changed, 137 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
drivers/crypto/bcmfs/bcmfs_device.c +5 -0
index c9865ee6a5..1ea6c3b13e 100644
@@ -12,6 +12,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -72,6 +73,10 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 
 	fsdev->vdev = vdev;
 
+	/* attach to VFIO */
+	if (bcmfs_attach_vfio(fsdev))
+		goto cleanup;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +6 -0
index cc64a8df2c..c41cc00318 100644
@@ -35,6 +35,12 @@ struct bcmfs_device {
 	char name[BCMFS_DEV_NAME_LEN];
 	/* Parent vdev */
 	struct rte_vdev_device *vdev;
+	/* vfio handle */
+	int vfio_dev_fd;
+	/* mapped address */
+	uint8_t *mmap_addr;
+	/* mapped size */
+	uint32_t mmap_size;
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_vfio.c new file +107 -0

107 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_vfio.h new file +17 -0
new file mode 100644
index 0000000000..d0fdf6483f
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_VFIO_H_
+#define _BCMFS_VFIO_H_
+
+/* Attach the bcmfs device to vfio */
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev);
+
+/* Release the bcmfs device from vfio */
+void
+bcmfs_release_vfio(struct bcmfs_device *dev);
+
+#endif /* _BCMFS_VFIO_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index a4bdd8ee5d..fd39eba20e 100644
@@ -6,5 +6,6 @@
 deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
-		'bcmfs_device.c'
+		'bcmfs_device.c',
+		'bcmfs_vfio.c'
 		)
Signature · 1 line
2.17.1
#38 lore raw

PATCH v3 3/8 crypto/bcmfs: add apis for queue pair management

In reply to Vikas Gupta

Add queue pair management APIs which will be used by Crypto device to manage h/w queues. A bcmfs device structure owns multiple queue-pairs based on the mapped address allocated to it.

---
 drivers/crypto/bcmfs/bcmfs_device.c  |   4 +
 drivers/crypto/bcmfs/bcmfs_device.h  |   5 +
 drivers/crypto/bcmfs/bcmfs_hw_defs.h |  32 +++
 drivers/crypto/bcmfs/bcmfs_qp.c      | 345 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_qp.h      | 122 ++++++++++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 6 files changed, 510 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
drivers/crypto/bcmfs/bcmfs_device.c +4 -0
index 1ea6c3b13e..7622720a40 100644
@@ -12,6 +12,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
@@ -77,6 +78,9 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 	if (bcmfs_attach_vfio(fsdev))
 		goto cleanup;
 
+	/* Maximum number of QPs supported */
+	fsdev->max_hw_qps = fsdev->mmap_size / BCMFS_HW_QUEUE_IO_ADDR_LEN;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +5 -0
index c41cc00318..a475373324 100644
@@ -11,6 +11,7 @@
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES		4
@@ -41,6 +42,10 @@ struct bcmfs_device {
 	uint8_t *mmap_addr;
 	/* mapped size */
 	uint32_t mmap_size;
+	/* max number of h/w queue pairs detected */
+	uint16_t max_hw_qps;
+	/* current qpairs in use */
+	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_hw_defs.h new file +32 -0
new file mode 100644
index 0000000000..7d5bb5d8fe
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_HW_DEFS_H_
+#define _BCMFS_HW_DEFS_H_
+
+#include <rte_atomic.h>
+#include <rte_byteorder.h>
+#include <rte_common.h>
+#include <rte_io.h>
+
+#ifndef BIT
+#define BIT(nr)         (1UL << (nr))
+#endif
+
+#define FS_RING_REGS_SIZE		0x10000
+#define FS_RING_DESC_SIZE		8
+#define FS_RING_BD_ALIGN_ORDER		12
+#define FS_RING_BD_DESC_PER_REQ		32
+#define FS_RING_CMPL_ALIGN_ORDER	13
+#define FS_RING_CMPL_SIZE		(1024 * FS_RING_DESC_SIZE)
+#define FS_RING_MAX_REQ_COUNT		1024
+#define FS_RING_PAGE_SHFT		12
+#define FS_RING_PAGE_SIZE		BIT(FS_RING_PAGE_SHFT)
+
+/* Minimum and maximum number of requests supported */
+#define FS_RM_MAX_REQS			4096
+#define FS_RM_MIN_REQS			32
+
+#endif /* BCMFS_HW_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c new file +345 -0

345 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_qp.h new file +122 -0

122 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +2 -1
index fd39eba20e..7e2bcbf14b 100644
@@ -7,5 +7,6 @@ deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
-		'bcmfs_vfio.c'
+		'bcmfs_vfio.c',
+		'bcmfs_qp.c'
 		)
Signature · 1 line
2.17.1
#39 lore raw

PATCH v3 4/8 crypto/bcmfs: add hw queue pair operations

In reply to Vikas Gupta

Add queue pair operations exported by supported devices.

---
 drivers/crypto/bcmfs/bcmfs_dev_msg.h      |  29 +
 drivers/crypto/bcmfs/bcmfs_device.c       |  51 ++
 drivers/crypto/bcmfs/bcmfs_device.h       |  16 +
 drivers/crypto/bcmfs/bcmfs_qp.c           |   1 +
 drivers/crypto/bcmfs/bcmfs_qp.h           |   4 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c       | 743 ++++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c       | 677 ++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c |  82 +++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h |  51 ++
 drivers/crypto/bcmfs/meson.build          |   5 +-
 10 files changed, 1658 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
drivers/crypto/bcmfs/bcmfs_dev_msg.h new file +29 -0
new file mode 100644
index 0000000000..5b50bde35a
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_DEV_MSG_H_
+#define _BCMFS_DEV_MSG_H_
+
+#define MAX_SRC_ADDR_BUFFERS    8
+#define MAX_DST_ADDR_BUFFERS    3
+
+struct bcmfs_qp_message {
+	/** Physical address of each source */
+	uint64_t srcs_addr[MAX_SRC_ADDR_BUFFERS];
+	/** Length of each sources */
+	uint32_t srcs_len[MAX_SRC_ADDR_BUFFERS];
+	/** Total number of sources */
+	unsigned int srcs_count;
+	/** Physical address of each destination */
+	uint64_t dsts_addr[MAX_DST_ADDR_BUFFERS];
+	/** Length of each destination */
+	uint32_t dsts_len[MAX_DST_ADDR_BUFFERS];
+	/** Total number of destinations */
+	unsigned int dsts_count;
+
+	void *ctx;
+};
+
+#endif /* _BCMFS_DEV_MSG_H_ */
drivers/crypto/bcmfs/bcmfs_device.c +51 -0

69 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h +16 -0
index a475373324..9e40c5d747 100644
@@ -8,6 +8,7 @@
 
 #include <sys/queue.h>
 
+#include <rte_spinlock.h>
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
@@ -28,6 +29,19 @@ enum bcmfs_device_type {
 	BCMFS_UNKNOWN
 };
 
+/* A table to store registered queue pair opertations */
+struct bcmfs_hw_queue_pair_ops_table {
+	rte_spinlock_t tl;
+	/* Number of used ops structs in the table. */
+	uint32_t num_ops;
+	 /*  Storage for all possible ops structs. */
+	struct bcmfs_hw_queue_pair_ops qp_ops[BCMFS_MAX_NODES];
+};
+
+/* HW queue pair ops register function */
+int bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops
+				     *qp_ops);
+
 struct bcmfs_device {
 	TAILQ_ENTRY(bcmfs_device) next;
 	/* Directory path for vfio */
@@ -46,6 +60,8 @@ struct bcmfs_device {
 	uint16_t max_hw_qps;
 	/* current qpairs in use */
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
+	/* queue pair ops exported by symmetric crypto hw */
+	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +1 -0
index 864e7bb746..ec1327b780 100644
@@ -227,6 +227,7 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	qp->qpair_id = queue_pair_id;
 	qp->ioreg = qp_conf->iobase;
 	qp->nb_descriptors = nb_descriptors;
+	qp->ops = qp_conf->ops;
 
 	qp->stats.enqueued_count = 0;
 	qp->stats.dequeued_count = 0;
drivers/crypto/bcmfs/bcmfs_qp.h +4 -0
index 52c487956e..59785865b0 100644
@@ -44,6 +44,8 @@ struct bcmfs_qp_config {
 	uint16_t nb_descriptors;
 	/* Maximum number of h/w descriptors needed by a request */
 	uint16_t max_descs_req;
+	/* h/w ops associated with qp */
+	struct bcmfs_hw_queue_pair_ops *ops;
 };
 
 struct bcmfs_queue {
@@ -61,6 +63,8 @@ struct bcmfs_queue {
 		/* s/w pointer for completion h/w queue*/
 		uint32_t cmpl_read_ptr;
 	};
+	/* number of inflight descriptor accumulated  before next db ring */
+	uint16_t descs_inflight;
 	/* Memzone name */
 	char memz_name[RTE_MEMZONE_NAMESIZE];
 };
drivers/crypto/bcmfs/hw/bcmfs4_rm.c new file +743 -0

743 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs5_rm.c new file +677 -0

677 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.c new file +82 -0

82 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.h new file +51 -0

51 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +4 -1
index 7e2bcbf14b..cd58bd5e25 100644
@@ -8,5 +8,8 @@ sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
 		'bcmfs_vfio.c',
-		'bcmfs_qp.c'
+		'bcmfs_qp.c',
+		'hw/bcmfs4_rm.c',
+		'hw/bcmfs5_rm.c',
+		'hw/bcmfs_rm_common.c'
 		)
Signature · 1 line
2.17.1
#40 lore raw

PATCH v3 5/8 crypto/bcmfs: create a symmetric cryptodev

In reply to Vikas Gupta

Create a symmetric crypto device and add supported cryptodev ops.

---
 drivers/crypto/bcmfs/bcmfs_device.c  |  15 ++
 drivers/crypto/bcmfs/bcmfs_device.h  |   9 +
 drivers/crypto/bcmfs/bcmfs_qp.c      |  37 +++
 drivers/crypto/bcmfs/bcmfs_qp.h      |  16 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c | 387 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h |  38 +++
 drivers/crypto/bcmfs/bcmfs_sym_req.h |  22 ++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 8 files changed, 526 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
drivers/crypto/bcmfs/bcmfs_device.c +15 -0
index 6ff65adfc7..0c99cc7adf 100644
@@ -14,6 +14,7 @@
 #include "bcmfs_logs.h"
 #include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
+#include "bcmfs_sym_pmd.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -240,6 +241,7 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 	char out_dirname[BCMFS_MAX_PATH_LEN];
 	uint32_t fsdev_dev[BCMFS_MAX_NODES];
 	enum bcmfs_device_type dtype;
+	int err;
 	int i = 0;
 	int dev_idx;
 	int count = 0;
@@ -291,7 +293,20 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 		return -ENODEV;
 	}
 
+	err = bcmfs_sym_dev_create(fsdev);
+	if (err) {
+		BCMFS_LOG(WARNING,
+			  "Failed to create BCMFS SYM PMD for device %s",
+			  fsdev->name);
+		goto pmd_create_fail;
+	}
+
 	return 0;
+
+pmd_create_fail:
+	fsdev_release(fsdev);
+
+	return err;
 }
 
 static int
drivers/crypto/bcmfs/bcmfs_device.h +9 -0
index 9e40c5d747..e8a9c40910 100644
@@ -62,6 +62,15 @@ struct bcmfs_device {
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 	/* queue pair ops exported by symmetric crypto hw */
 	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
+	/* a cryptodevice attached to bcmfs device */
+	struct rte_cryptodev *cdev;
+	/* a rte_device to register with cryptodev */
+	struct rte_device sym_rte_dev;
+	/* private info to keep with cryptodev */
+	struct bcmfs_sym_dev_private *sym_dev;
 };
 
+/* stats exported by device */
+
+
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +37 -0
index ec1327b780..cb5ff6c61b 100644
@@ -344,3 +344,40 @@ bcmfs_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops)
 
 	return deq;
 }
+
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats)
+{
+	int i;
+
+	if (stats == NULL) {
+		BCMFS_LOG(ERR, "invalid param: stats %p",
+			  stats);
+		return;
+	}
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+
+		stats->enqueued_count += qp[i]->stats.enqueued_count;
+		stats->dequeued_count += qp[i]->stats.dequeued_count;
+		stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
+		stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
+	}
+}
+
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp)
+{
+	int i;
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+		memset(&qp[i]->stats, 0, sizeof(qp[i]->stats));
+	}
+}
drivers/crypto/bcmfs/bcmfs_qp.h +16 -0
index 59785865b0..57fe0a93a3 100644
@@ -24,6 +24,13 @@ enum bcmfs_queue_type {
 	BCMFS_RM_CPLQ
 };
 
+#define BCMFS_QP_IOBASE_XLATE(base, idx)	\
+		((base) + ((idx) * BCMFS_HW_QUEUE_IO_ADDR_LEN))
+
+/* Max pkts for preprocessing before submitting to h/w qp */
+#define BCMFS_MAX_REQS_BUFF	64
+
+/* qp stats */
 struct bcmfs_qp_stats {
 	/* Count of all operations enqueued */
 	uint64_t enqueued_count;
@@ -92,6 +99,10 @@ struct bcmfs_qp {
 	struct bcmfs_qp_stats stats;
 	/* h/w ops associated with qp */
 	struct bcmfs_hw_queue_pair_ops *ops;
+	/* bcmfs requests pool*/
+	struct rte_mempool *sr_mp;
+	/* a temporary buffer to keep message pointers */
+	struct bcmfs_qp_message *infl_msgs[BCMFS_MAX_REQS_BUFF];
 
 } __rte_cache_aligned;
 
@@ -123,4 +134,9 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	       uint16_t queue_pair_id,
 	       struct bcmfs_qp_config *bcmfs_conf);
 
+/* stats functions*/
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats);
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp);
+
 #endif /* _BCMFS_QP_H_ */
drivers/crypto/bcmfs/bcmfs_sym_pmd.c new file +387 -0

387 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.h new file +38 -0
new file mode 100644
index 0000000000..65d7046090
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_PMD_H_
+#define _BCMFS_SYM_PMD_H_
+
+#include <rte_cryptodev.h>
+
+#include "bcmfs_device.h"
+
+#define CRYPTODEV_NAME_BCMFS_SYM_PMD	crypto_bcmfs
+
+#define BCMFS_CRYPTO_MAX_HW_DESCS_PER_REQ	16
+
+extern uint8_t cryptodev_bcmfs_driver_id;
+
+/** private data structure for a BCMFS device.
+ *  This BCMFS device is a device offering only symmetric crypto service,
+ *  there can be one of these on each bcmfs_pci_device (VF).
+ */
+struct bcmfs_sym_dev_private {
+	/* The bcmfs device hosting the service */
+	struct bcmfs_device *fsdev;
+	/* Device instance for this rte_cryptodev */
+	uint8_t sym_dev_id;
+	/* BCMFS device symmetric crypto capabilities */
+	const struct rte_cryptodev_capabilities *fsdev_capabilities;
+};
+
+int
+bcmfs_sym_dev_create(struct bcmfs_device *fdev);
+
+int
+bcmfs_sym_dev_destroy(struct bcmfs_device *fdev);
+
+#endif /* _BCMFS_SYM_PMD_H_ */
drivers/crypto/bcmfs/bcmfs_sym_req.h new file +22 -0
new file mode 100644
index 0000000000..0f0b051f1e
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_REQ_H_
+#define _BCMFS_SYM_REQ_H_
+
+#include "bcmfs_dev_msg.h"
+
+/*
+ * This structure hold the supportive data required to process a
+ * rte_crypto_op
+ */
+struct bcmfs_sym_request {
+	/* bcmfs qp message for h/w queues to process */
+	struct bcmfs_qp_message msgs;
+	/* crypto op */
+	struct rte_crypto_op *op;
+};
+
+#endif /* _BCMFS_SYM_REQ_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index cd58bd5e25..d9a3d73e99 100644
@@ -11,5 +11,6 @@ sources = files(
 		'bcmfs_qp.c',
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
-		'hw/bcmfs_rm_common.c'
+		'hw/bcmfs_rm_common.c',
+		'bcmfs_sym_pmd.c'
 		)
Signature · 1 line
2.17.1
#41 lore raw

PATCH v3 6/8 crypto/bcmfs: add session handling and capabilities

In reply to Vikas Gupta

Add session handling and capabilities supported by crypto h/w accelerator

---
 doc/guides/cryptodevs/bcmfs.rst               |  47 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |  56 ++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c | 764 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         |  34 +
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          |  13 +
 drivers/crypto/bcmfs/bcmfs_sym_session.c      | 282 +++++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      | 109 +++
 drivers/crypto/bcmfs/meson.build              |   4 +-
 9 files changed, 1324 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
doc/guides/cryptodevs/bcmfs.rst +47 -0
index dc21bf60cc..aaa6e1af70 100644
@@ -15,6 +15,47 @@ Supported Broadcom SoCs
 * Stingray
 * Stingray2
 
+Features
+--------
+
+The BCMFS SYM PMD has support for:
+
+Cipher algorithms:
+
+* ``RTE_CRYPTO_CIPHER_3DES_CBC``
+* ``RTE_CRYPTO_CIPHER_3DES_CTR``
+* ``RTE_CRYPTO_CIPHER_AES128_CBC``
+* ``RTE_CRYPTO_CIPHER_AES192_CBC``
+* ``RTE_CRYPTO_CIPHER_AES256_CBC``
+* ``RTE_CRYPTO_CIPHER_AES128_CTR``
+* ``RTE_CRYPTO_CIPHER_AES192_CTR``
+* ``RTE_CRYPTO_CIPHER_AES256_CTR``
+* ``RTE_CRYPTO_CIPHER_AES_XTS``
+* ``RTE_CRYPTO_CIPHER_DES_CBC``
+
+Hash algorithms:
+
+* ``RTE_CRYPTO_AUTH_SHA1``
+* ``RTE_CRYPTO_AUTH_SHA1_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA224``
+* ``RTE_CRYPTO_AUTH_SHA224_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA256``
+* ``RTE_CRYPTO_AUTH_SHA256_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA384``
+* ``RTE_CRYPTO_AUTH_SHA384_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA512``
+* ``RTE_CRYPTO_AUTH_SHA512_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_XCBC_MAC``
+* ``RTE_CRYPTO_AUTH_AES_CBC_MAC``
+* ``RTE_CRYPTO_AUTH_MD5_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_GMAC``
+* ``RTE_CRYPTO_AUTH_AES_CMAC``
+
+Supported AEAD algorithms:
+
+* ``RTE_CRYPTO_AEAD_AES_GCM``
+* ``RTE_CRYPTO_AEAD_AES_CCM``
+
 Installation
 ------------
 Information about kernel, rootfs and toolchain can be found at
@@ -49,3 +90,9 @@ For example, below commands can be run to get hold of a device node by VFIO.
     io_device_name="vfio-platform"
     echo $io_device_name > /sys/bus/platform/devices/${SETUP_SYSFS_DEV_NAME}/driver_override
     echo ${SETUP_SYSFS_DEV_NAME} > /sys/bus/platform/drivers_probe
+
+Limitations
+-----------
+
+* Only supports the session-oriented API implementation (session-less APIs are not supported).
+* CCM is not supported on Broadcom`s SoCs having FlexSparc4 unit.
doc/guides/cryptodevs/features/bcmfs.ini new file +56 -0

56 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.c new file +764 -0

764 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.h new file +16 -0
new file mode 100644
index 0000000000..3ff61b7d29
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_CAPABILITIES_H_
+#define _BCMFS_SYM_CAPABILITIES_H_
+
+/*
+ * Get capabilities list for the device
+ *
+ */
+const struct rte_cryptodev_capabilities *bcmfs_sym_get_capabilities(void);
+
+#endif /* _BCMFS_SYM_CAPABILITIES_H__ */
+
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +34 -0
new file mode 100644
index 0000000000..aea1f281e4
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_DEFS_H_
+#define _BCMFS_SYM_DEFS_H_
+
+/*
+ * Max block size of hash algorithm
+ * currently SHA3 supports max block size
+ * of 144 bytes
+ */
+#define BCMFS_MAX_KEY_SIZE	144
+#define BCMFS_MAX_IV_SIZE	16
+#define BCMFS_MAX_DIGEST_SIZE	64
+
+struct bcmfs_sym_session;
+struct bcmfs_sym_request;
+
+/** Crypto Request processing successful. */
+#define BCMFS_SYM_RESPONSE_SUCCESS               (0)
+/** Crypot Request processing protocol failure. */
+#define BCMFS_SYM_RESPONSE_PROTO_FAILURE         (1)
+/** Crypot Request processing completion failure. */
+#define BCMFS_SYM_RESPONSE_COMPL_ERROR           (2)
+/** Crypot Request processing hash tag check error. */
+#define BCMFS_SYM_RESPONSE_HASH_TAG_ERROR        (3)
+
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req);
+#endif /* _BCMFS_SYM_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_sym_pmd.c +13 -0
index 0f96915f70..381ca8ea48 100644
@@ -14,6 +14,8 @@
 #include "bcmfs_qp.h"
 #include "bcmfs_sym_pmd.h"
 #include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+#include "bcmfs_sym_capabilities.h"
 
 uint8_t cryptodev_bcmfs_driver_id;
 
@@ -65,6 +67,7 @@ bcmfs_sym_dev_info_get(struct rte_cryptodev *dev,
 		dev_info->max_nb_queue_pairs = fsdev->max_hw_qps;
 		/* No limit of number of sessions */
 		dev_info->sym.max_nb_sessions = 0;
+		dev_info->capabilities = bcmfs_sym_get_capabilities();
 	}
 }
 
@@ -228,6 +231,10 @@ static struct rte_cryptodev_ops crypto_bcmfs_ops = {
 	/* Queue-Pair management */
 	.queue_pair_setup       = bcmfs_sym_qp_setup,
 	.queue_pair_release     = bcmfs_sym_qp_release,
+	/* Crypto session related operations */
+	.sym_session_get_size   = bcmfs_sym_session_get_private_size,
+	.sym_session_configure  = bcmfs_sym_session_configure,
+	.sym_session_clear      = bcmfs_sym_session_clear
 };
 
 /** Enqueue burst */
@@ -239,6 +246,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	int i, j;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
+	struct bcmfs_sym_session *sess;
 	struct bcmfs_qp *qp = (struct bcmfs_qp *)queue_pair;
 
 	if (nb_ops == 0)
@@ -252,6 +260,10 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		nb_ops = qp->nb_descriptors - qp->nb_pending_requests;
 
 	for (i = 0; i < nb_ops; i++) {
+		sess = bcmfs_sym_get_session(ops[i]);
+		if (unlikely(sess == NULL))
+			goto enqueue_err;
+
 		if (rte_mempool_get(qp->sr_mp, (void **)&sreq))
 			goto enqueue_err;
 
@@ -356,6 +368,7 @@ bcmfs_sym_dev_create(struct bcmfs_device *fsdev)
 	fsdev->sym_dev = internals;
 
 	internals->sym_dev_id = cryptodev->data->dev_id;
+	internals->fsdev_capabilities = bcmfs_sym_get_capabilities();
 
 	BCMFS_LOG(DEBUG, "Created bcmfs-sym device %s as cryptodev instance %d",
 		  cryptodev->data->name, internals->sym_dev_id);
drivers/crypto/bcmfs/bcmfs_sym_session.c new file +282 -0

282 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_session.h new file +109 -0

109 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +3 -1
index d9a3d73e99..2e86c733e1 100644
@@ -12,5 +12,7 @@ sources = files(
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
 		'hw/bcmfs_rm_common.c',
-		'bcmfs_sym_pmd.c'
+		'bcmfs_sym_pmd.c',
+		'bcmfs_sym_capabilities.c',
+		'bcmfs_sym_session.c'
 		)
Signature · 1 line
2.17.1
#42 lore raw

PATCH v3 7/8 crypto/bcmfs: add crypto h/w module

In reply to Vikas Gupta

Add crypto h/w module to process crypto op. Crypto op is processed via sym_engine module before submitting the crypto request to h/w queues.

---
 drivers/crypto/bcmfs/bcmfs_sym.c        |  289 ++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.c | 1155 +++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h |  115 +++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c    |   26 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h    |   40 +
 drivers/crypto/bcmfs/meson.build        |    4 +-
 6 files changed, 1628 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
drivers/crypto/bcmfs/bcmfs_sym.c new file +289 -0
new file mode 100644
index 0000000000..2d164a1ec8
@@ -0,0 +1,289 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <stdbool.h>
+
+#include <rte_byteorder.h>
+#include <rte_crypto_sym.h>
+#include <rte_cryptodev.h>
+#include <rte_mbuf.h>
+#include <rte_mempool.h>
+
+#include "bcmfs_sym_defs.h"
+#include "bcmfs_sym_engine.h"
+#include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+
+/** Process cipher operation */
+static int
+process_crypto_cipher_op(struct rte_crypto_op *op,
+			 struct rte_mbuf *mbuf_src,
+			 struct rte_mbuf *mbuf_dst,
+			 struct bcmfs_sym_session *sess,
+			 struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv, key;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+	fsattr_pa(&dst) = rte_pktmbuf_iova(mbuf_dst);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						   uint8_t *,
+						   sess->cipher.iv.offset);
+
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&key) = sess->cipher.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->cipher.key.length;
+
+	rc = bcmfs_crypto_build_cipher_req(req, sess->cipher.algo,
+					   sess->cipher.op, &src,
+					   &dst, &key, &iv);
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process auth operation */
+static int
+process_crypto_auth_op(struct rte_crypto_op *op,
+		       struct rte_mbuf *mbuf_src,
+		       struct bcmfs_sym_session *sess,
+		       struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, mac, key, iv;
+
+	fsattr_sz(&src) = op->sym->auth.data.length;
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset(mbuf_src,
+						  uint8_t *,
+						  op->sym->auth.data.offset);
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+
+	if (!sess->auth.op) {
+		fsattr_va(&mac) = op->sym->auth.digest.data;
+		fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&mac) = sess->auth.digest_length;
+	} else {
+		fsattr_va(&dst) = op->sym->auth.digest.data;
+		fsattr_pa(&dst) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&dst) = sess->auth.digest_length;
+	}
+
+	fsattr_va(&key) = sess->auth.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->auth.key.length;
+
+	/* AES-GMAC uses AES-GCM-128 authenticator */
+	if (sess->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC) {
+		fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+							   uint8_t *,
+							   sess->auth.iv.offset);
+		fsattr_pa(&iv) = 0;
+		fsattr_sz(&iv) = sess->auth.iv.length;
+	} else {
+		fsattr_va(&iv) = NULL;
+		fsattr_sz(&iv) = 0;
+	}
+
+		rc = bcmfs_crypto_build_auth_req(req, sess->auth.algo,
+						 sess->auth.op,
+						 &src,
+						 (sess->auth.op) ? (&dst) : NULL,
+						 (sess->auth.op) ? NULL  : (&mac),
+						 &key, &iv);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process combined/chained mode operation */
+static int
+process_crypto_combined_op(struct rte_crypto_op *op,
+			   struct rte_mbuf *mbuf_src,
+			   struct rte_mbuf *mbuf_dst,
+			   struct bcmfs_sym_session *sess,
+			   struct bcmfs_sym_request *req)
+{
+	int rc = 0, aad_size = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr cipher_key, aad, mac, auth_key;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						  sym_op->cipher.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						  sym_op->cipher.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						   uint8_t *,
+						   sess->cipher.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&cipher_key) = sess->cipher.key.data;
+	fsattr_pa(&cipher_key) = 0;
+	fsattr_sz(&cipher_key) = sess->cipher.key.length;
+
+	fsattr_va(&auth_key) = sess->auth.key.data;
+	fsattr_pa(&auth_key) = 0;
+	fsattr_sz(&auth_key) = sess->auth.key.length;
+
+	fsattr_va(&mac) = op->sym->auth.digest.data;
+	fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+	fsattr_sz(&mac) = sess->auth.digest_length;
+
+	aad_size = sym_op->auth.data.length - sym_op->cipher.data.length;
+
+	if (aad_size > 0) {
+		fsattr_sz(&aad) =  aad_size;
+		fsattr_va(&aad) = rte_pktmbuf_mtod_offset
+						(mbuf_src,
+						 uint8_t *,
+						sym_op->auth.data.offset);
+		fsattr_pa(&aad) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->auth.data.offset);
+	}
+
+	rc = bcmfs_crypto_build_chain_request(req, sess->cipher.algo,
+					      sess->cipher.op,
+					      sess->auth.algo,
+					      sess->auth.op,
+					      &src, &dst, &cipher_key,
+					      &auth_key, &iv,
+					      (aad_size > 0) ? (&aad) : NULL,
+					      &mac, sess->cipher_first);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process AEAD operation */
+static int
+process_crypto_aead_op(struct rte_crypto_op *op,
+		       struct rte_mbuf *mbuf_src,
+		       struct rte_mbuf *mbuf_dst,
+		       struct bcmfs_sym_session *sess,
+		       struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr key, aad, mac;
+
+	fsattr_sz(&src) = sym_op->aead.data.length;
+	fsattr_sz(&dst) = sym_op->aead.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset(mbuf_src,
+						  uint8_t *,
+						  sym_op->aead.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset(mbuf_dst,
+						  uint8_t *,
+						  sym_op->aead.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						  sym_op->aead.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						  sym_op->aead.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						   uint8_t *,
+						   sess->aead.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->aead.iv.length;
+
+	fsattr_va(&key) = sess->aead.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->aead.key.length;
+
+	fsattr_va(&mac) = op->sym->aead.digest.data;
+	fsattr_pa(&mac) = op->sym->aead.digest.phys_addr;
+	fsattr_sz(&mac) = sess->aead.digest_length;
+
+	fsattr_va(&aad) = op->sym->aead.aad.data;
+	fsattr_pa(&aad) = op->sym->aead.aad.phys_addr;
+	fsattr_sz(&aad) = sess->aead.aad_length;
+
+	rc = bcmfs_crypto_build_aead_request(req, sess->aead.algo,
+					     sess->aead.op, &src, &dst,
+					     &key, &iv, &aad, &mac);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process crypto operation for mbuf */
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req)
+{
+	struct rte_mbuf *msrc, *mdst;
+	int rc = 0;
+
+	msrc = op->sym->m_src;
+	mdst = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src;
+	op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+
+	switch (sess->chain_order) {
+	case BCMFS_SYM_CHAIN_ONLY_CIPHER:
+		rc = process_crypto_cipher_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_ONLY_AUTH:
+		rc = process_crypto_auth_op(op, msrc, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_CIPHER_AUTH:
+	case BCMFS_SYM_CHAIN_AUTH_CIPHER:
+		rc = process_crypto_combined_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_AEAD:
+		rc = process_crypto_aead_op(op, msrc, mdst, sess, req);
+		break;
+	default:
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+		break;
+	}
+
+	return rc;
+}
drivers/crypto/bcmfs/bcmfs_sym_engine.c new file +1155 -0

1,155 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_engine.h new file +115 -0

115 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.c +26 -0
index 381ca8ea48..568797b4fd 100644
@@ -132,6 +132,12 @@ static void
 spu_req_init(struct bcmfs_sym_request *sr, rte_iova_t iova __rte_unused)
 {
 	memset(sr, 0, sizeof(*sr));
+	sr->fptr = iova;
+	sr->cptr = iova + offsetof(struct bcmfs_sym_request, cipher_key);
+	sr->aptr = iova + offsetof(struct bcmfs_sym_request, auth_key);
+	sr->iptr = iova + offsetof(struct bcmfs_sym_request, iv);
+	sr->dptr = iova + offsetof(struct bcmfs_sym_request, digest);
+	sr->rptr = iova + offsetof(struct bcmfs_sym_request, resp);
 }
 
 static void
@@ -244,6 +250,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 			       uint16_t nb_ops)
 {
 	int i, j;
+	int retval;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
 	struct bcmfs_sym_session *sess;
@@ -273,6 +280,11 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		/* save context */
 		qp->infl_msgs[i] = &sreq->msgs;
 		qp->infl_msgs[i]->ctx = (void *)sreq;
+
+		/* pre process the request crypto h/w acceleration */
+		retval = bcmfs_process_sym_crypto_op(ops[i], sess, sreq);
+		if (unlikely(retval < 0))
+			goto enqueue_err;
 	}
 	/* Send burst request to hw QP */
 	enq = bcmfs_enqueue_op_burst(qp, (void **)qp->infl_msgs, i);
@@ -289,6 +301,17 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	return enq;
 }
 
+static void bcmfs_sym_set_request_status(struct rte_crypto_op *op,
+					 struct bcmfs_sym_request *out)
+{
+	if (*out->resp == BCMFS_SYM_RESPONSE_SUCCESS)
+		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+	else if (*out->resp == BCMFS_SYM_RESPONSE_HASH_TAG_ERROR)
+		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+	else
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+}
+
 static uint16_t
 bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 			       struct rte_crypto_op **ops,
@@ -308,6 +331,9 @@ bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 	for (i = 0; i < deq; i++) {
 		sreq = (struct bcmfs_sym_request *)qp->infl_msgs[i]->ctx;
 
+		/* set the status based on the response from the crypto h/w */
+		bcmfs_sym_set_request_status(sreq->op, sreq);
+
 		ops[pkts++] = sreq->op;
 
 		rte_mempool_put(qp->sr_mp, sreq);
drivers/crypto/bcmfs/bcmfs_sym_req.h +40 -0
index 0f0b051f1e..e53c50adc1 100644
@@ -6,13 +6,53 @@
 #ifndef _BCMFS_SYM_REQ_H_
 #define _BCMFS_SYM_REQ_H_
 
+#include <rte_cryptodev.h>
+
 #include "bcmfs_dev_msg.h"
+#include "bcmfs_sym_defs.h"
+
+/* Fixed SPU2 Metadata */
+struct spu2_fmd {
+	uint64_t ctrl0;
+	uint64_t ctrl1;
+	uint64_t ctrl2;
+	uint64_t ctrl3;
+};
 
 /*
  * This structure hold the supportive data required to process a
  * rte_crypto_op
  */
 struct bcmfs_sym_request {
+	/* spu2 engine related data */
+	struct spu2_fmd fmd;
+	/* cipher key */
+	uint8_t cipher_key[BCMFS_MAX_KEY_SIZE];
+	/* auth key */
+	uint8_t auth_key[BCMFS_MAX_KEY_SIZE];
+	/* iv key */
+	uint8_t iv[BCMFS_MAX_IV_SIZE];
+	/* digest data output from crypto h/w */
+	uint8_t digest[BCMFS_MAX_DIGEST_SIZE];
+	/* 2-Bytes response from crypto h/w */
+	uint8_t resp[2];
+	/*
+	 * Below are all iovas for above members
+	 * from top
+	 */
+	/* iova for fmd */
+	rte_iova_t fptr;
+	/* iova for cipher key */
+	rte_iova_t cptr;
+	/* iova for auth key */
+	rte_iova_t aptr;
+	/* iova for iv key */
+	rte_iova_t iptr;
+	/* iova for digest */
+	rte_iova_t dptr;
+	/* iova for response */
+	rte_iova_t rptr;
+
 	/* bcmfs qp message for h/w queues to process */
 	struct bcmfs_qp_message msgs;
 	/* crypto op */
drivers/crypto/bcmfs/meson.build +3 -1
index 2e86c733e1..7aa0f05dbd 100644
@@ -14,5 +14,7 @@ sources = files(
 		'hw/bcmfs_rm_common.c',
 		'bcmfs_sym_pmd.c',
 		'bcmfs_sym_capabilities.c',
-		'bcmfs_sym_session.c'
+		'bcmfs_sym_session.c',
+		'bcmfs_sym.c',
+		'bcmfs_sym_engine.c'
 		)
Signature · 1 line
2.17.1
#43 lore raw

PATCH v3 8/8 crypto/bcmfs: add crypto pmd into cryptodev test

In reply to Vikas Gupta

Add global test suite for bcmfs crypto pmd

---
 app/test/test_cryptodev.c       | 17 +++++++++++++++++
 app/test/test_cryptodev.h       |  1 +
 doc/guides/cryptodevs/bcmfs.rst | 11 +++++++++++
 3 files changed, 29 insertions(+)
app/test/test_cryptodev.c +17 -0
index 70bf6fe2c1..9157115ab3 100644
@@ -13041,6 +13041,22 @@ test_cryptodev_nitrox(void)
 	return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
 }
 
+static int
+test_cryptodev_bcmfs(void)
+{
+	gbl_driver_id =	rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
+
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded. Check if "
+				"CONFIG_RTE_LIBRTE_PMD_BCMFS is enabled "
+				"in config file to run this testsuite.\n");
+		return TEST_FAILED;
+	}
+
+	return unit_test_suite_runner(&cryptodev_testsuite);
+}
+
 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
@@ -13063,3 +13079,4 @@ REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
+REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
app/test/test_cryptodev.h +1 -0
index 41542e0552..c58126368c 100644
@@ -70,6 +70,7 @@
 #define CRYPTODEV_NAME_OCTEONTX2_PMD	crypto_octeontx2
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 #define CRYPTODEV_NAME_NITROX_PMD	crypto_nitrox_sym
+#define CRYPTODEV_NAME_BCMFS_PMD	crypto_bcmfs
 
 /**
  * Write (spread) data from buffer to mbuf data
doc/guides/cryptodevs/bcmfs.rst +11 -0
index aaa6e1af70..f7b7cde6d7 100644
@@ -96,3 +96,14 @@ Limitations
 
 * Only supports the session-oriented API implementation (session-less APIs are not supported).
 * CCM is not supported on Broadcom`s SoCs having FlexSparc4 unit.
+
+Testing
+-------
+
+The symmetric crypto operations on BCMFS crypto PMD may be verified by running the test
+application:
+
+.. code-block:: console
+
+    ./test
+    RTE>>cryptodev_bcmfs_autotest
Signature · 1 line
2.17.1
#44 lore raw

v4 cover Add Crypto PMD for Broadcom`s FlexSparc devices

In reply to Vikas Gupta

Hi,
This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.
BCMFS is an acronym for Broadcom FlexSparc device used in the patchest.

The patchset progressively adds major modules as below.
a) Detection of platform-device based on the known registered platforms and attaching with VFIO.
b) Creation of Cryptodevice.
c) Addition of session handling.
d) Add Cryptodevice into test Cryptodev framework.

The patchset has been tested on the above mentioned SoCs.

Regards,
Vikas

Changes from v0->v1:
Updated the ABI version in file .../crypto/bcmfs/rte_pmd_bcmfs_version.map

Changes from v1->v2:
- Fix compilation errors and coding style warnings.
- Use global test crypto suite suggested by Adam Dybkowski

Changes from v2->v3:
- Release notes updated.
- bcmfs.rst updated with missing information about installation.
- Review comments from patch1 from v2 addressed.
- Updated description about dependency of PMD driver on VFIO_PRESENT.
- Fixed typo in bcmfs_hw_defs.h (comments on patch3 from v2 addressed)
- Comments on patch6 from v2 addressed and capability list is fixed. Removed redundant enums and macros from the file bcmfs_sym_defs.h and updated other impacted APIs accordingly. patch7 too is updated due to removal of redundancy. Thanks! to Akhil for pointing out the redundancy.
- Fix minor code style issues in few files as part of review.

Changes from v3->v4:
- Code style issues fixed.
- Change of barrier API in bcmfs4_rm.c and bcmfs5_rm.c

Vikas Gupta (8):
crypto/bcmfs: add BCMFS driver crypto/bcmfs: add vfio support crypto/bcmfs: add queue pair management API crypto/bcmfs: add HW queue pair operations crypto/bcmfs: create a symmetric cryptodev crypto/bcmfs: add session handling and capabilities crypto/bcmfs: add crypto HW module crypto/bcmfs: add crypto pmd into cryptodev test

 MAINTAINERS                                   |    7 +
 app/test/test_cryptodev.c                     |   17 +
 app/test/test_cryptodev.h                     |    1 +
 doc/guides/cryptodevs/bcmfs.rst               |  109 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |   56 +
 doc/guides/cryptodevs/index.rst               |    1 +
 doc/guides/rel_notes/release_20_11.rst        |    5 +
 drivers/crypto/bcmfs/bcmfs_dev_msg.h          |   29 +
 drivers/crypto/bcmfs/bcmfs_device.c           |  332 +++++
 drivers/crypto/bcmfs/bcmfs_device.h           |   76 ++
 drivers/crypto/bcmfs/bcmfs_hw_defs.h          |   32 +
 drivers/crypto/bcmfs/bcmfs_logs.c             |   38 +
 drivers/crypto/bcmfs/bcmfs_logs.h             |   34 +
 drivers/crypto/bcmfs/bcmfs_qp.c               |  383 ++++++
 drivers/crypto/bcmfs/bcmfs_qp.h               |  142 ++
 drivers/crypto/bcmfs/bcmfs_sym.c              |  289 +++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c |  764 +++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |   16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         |   34 +
 drivers/crypto/bcmfs/bcmfs_sym_engine.c       | 1155 +++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h       |  115 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          |  426 ++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h          |   38 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h          |   62 +
 drivers/crypto/bcmfs/bcmfs_sym_session.c      |  282 ++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      |  109 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c             |  107 ++
 drivers/crypto/bcmfs/bcmfs_vfio.h             |   17 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c           |  743 +++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c           |  677 ++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c     |   82 ++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h     |   51 +
 drivers/crypto/bcmfs/meson.build              |   20 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |    3 +
 drivers/crypto/meson.build                    |    1 +
 35 files changed, 6253 insertions(+)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
Signature · 1 line
2.17.1
#45 lore raw

PATCH v4 1/8 crypto/bcmfs: add BCMFS driver

Add Broadcom FlexSparc(FS) device creation driver which registers to a vdev and create a device. Add APIs for logs, supportive documentation and maintainers file.

---
 MAINTAINERS                                   |   7 +
 doc/guides/cryptodevs/bcmfs.rst               |  51 ++++
 doc/guides/cryptodevs/index.rst               |   1 +
 doc/guides/rel_notes/release_20_11.rst        |   5 +
 drivers/crypto/bcmfs/bcmfs_device.c           | 257 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_device.h           |  43 +++
 drivers/crypto/bcmfs/bcmfs_logs.c             |  38 +++
 drivers/crypto/bcmfs/bcmfs_logs.h             |  34 +++
 drivers/crypto/bcmfs/meson.build              |  10 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |   3 +
 drivers/crypto/meson.build                    |   1 +
 11 files changed, 450 insertions(+)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
MAINTAINERS +7 -0
index c0abbe0fc8..49c015ebbe 100644
@@ -1081,6 +1081,13 @@ F: drivers/crypto/zuc/
 F: doc/guides/cryptodevs/zuc.rst
 F: doc/guides/cryptodevs/features/zuc.ini
 
+Broadcom FlexSparc
+M: Ajit Khaparde <[email protected]>
+M: Raveendra Padasalagi <[email protected]>
+M: Vikas Gupta <vikas.gupta@@broadcom.com>
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 -------------------
doc/guides/cryptodevs/bcmfs.rst new file +51 -0

51 lines not on this page · raw message

doc/guides/cryptodevs/index.rst +1 -0
index a67ed5a282..279f56a002 100644
@@ -13,6 +13,7 @@ Crypto Device Drivers
     aesni_mb
     aesni_gcm
     armv8
+    bcmfs
     caam_jr
     ccp
     dpaa2_sec
doc/guides/rel_notes/release_20_11.rst +5 -0
index 73ac08fb0e..8643330321 100644
@@ -185,3 +185,8 @@ Tested Platforms
    This section is a comment. Do not overwrite or remove it.
    Also, make sure to start the actual text at the margin.
    =======================================================
+
+* **Added Broadcom BCMFS symmetric crypto PMD.**
+
+  Added a symmetric crypto PMD for Broadcom FlexSparc crypto units.
+  See :doc:`../cryptodevs/bcmfs` guide for more details on this new PMD.
drivers/crypto/bcmfs/bcmfs_device.c new file +257 -0

257 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h new file +43 -0

43 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_logs.c new file +38 -0
new file mode 100644
index 0000000000..86f4ff3b53
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <rte_log.h>
+#include <rte_hexdump.h>
+
+#include "bcmfs_logs.h"
+
+int bcmfs_conf_logtype;
+int bcmfs_dp_logtype;
+
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
+		const void *buf, unsigned int len)
+{
+	if (level > rte_log_get_global_level())
+		return 0;
+	if (level > (uint32_t)(rte_log_get_level(logtype)))
+		return 0;
+
+	rte_hexdump(rte_log_get_stream(), title, buf, len);
+	return 0;
+}
+
+RTE_INIT(bcmfs_device_init_log)
+{
+	/* Configuration and general logs */
+	bcmfs_conf_logtype = rte_log_register("pmd.bcmfs_config");
+	if (bcmfs_conf_logtype >= 0)
+		rte_log_set_level(bcmfs_conf_logtype, RTE_LOG_NOTICE);
+
+	/* data-path logs */
+	bcmfs_dp_logtype = rte_log_register("pmd.bcmfs_fp");
+	if (bcmfs_dp_logtype >= 0)
+		rte_log_set_level(bcmfs_dp_logtype, RTE_LOG_NOTICE);
+}
drivers/crypto/bcmfs/bcmfs_logs.h new file +34 -0
new file mode 100644
index 0000000000..c03a49b75c
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_LOGS_H_
+#define _BCMFS_LOGS_H_
+
+#include <rte_log.h>
+
+extern int bcmfs_conf_logtype;
+extern int bcmfs_dp_logtype;
+
+#define BCMFS_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_conf_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_dp_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_HEXDUMP_LOG(level, title, buf, len)	\
+	bcmfs_hexdump_log(RTE_LOG_ ## level, bcmfs_dp_logtype, title, buf, len)
+
+/**
+ * bcmfs_hexdump_log Dump out memory in a special hex dump format.
+ *
+ * The message will be sent to the stream used by the rte_log infrastructure.
+ */
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *heading,
+		  const void *buf, unsigned int len);
+
+#endif /* _BCMFS_LOGS_H_ */
drivers/crypto/bcmfs/meson.build new file +10 -0
new file mode 100644
index 0000000000..a4bdd8ee5d
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2020 Broadcom
+# All rights reserved.
+#
+
+deps += ['eal', 'bus_vdev']
+sources = files(
+		'bcmfs_logs.c',
+		'bcmfs_device.c'
+		)
drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map new file +3 -0
new file mode 100644
index 0000000000..299ae632da
@@ -0,0 +1,3 @@
+DPDK_21.0 {
+	local: *;
+};
drivers/crypto/meson.build +1 -0
index a2423507ad..93c2968acb 100644
@@ -8,6 +8,7 @@ endif
 drivers = ['aesni_gcm',
 	   'aesni_mb',
 	   'armv8',
+	   'bcmfs',
 	   'caam_jr',
 	   'ccp',
 	   'dpaa_sec',
Signature · 1 line
2.17.1
#46 lore raw

PATCH v4 2/8 crypto/bcmfs: add vfio support

In reply to Vikas Gupta

Add VFIO support for BCMFS PMD.
The BCMFS PMD functionality is dependent on the VFIO_PRESENT flag, which gets enabled in the rte_vfio.h.
If this flag is not enabled in the compiling platform driver will silently return with error, when executed.

---
 drivers/crypto/bcmfs/bcmfs_device.c |   5 ++
 drivers/crypto/bcmfs/bcmfs_device.h |   6 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c   | 107 ++++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_vfio.h   |  17 +++++
 drivers/crypto/bcmfs/meson.build    |   3 +-
 5 files changed, 137 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
drivers/crypto/bcmfs/bcmfs_device.c +5 -0
index f1050ff112..0ccddea202 100644
@@ -12,6 +12,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -72,6 +73,10 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 
 	fsdev->vdev = vdev;
 
+	/* attach to VFIO */
+	if (bcmfs_attach_vfio(fsdev))
+		goto cleanup;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +6 -0
index 1a4d0cf365..f99d57d4bd 100644
@@ -38,6 +38,12 @@ struct bcmfs_device {
 	char name[BCMFS_DEV_NAME_LEN];
 	/* Parent vdev */
 	struct rte_vdev_device *vdev;
+	/* vfio handle */
+	int vfio_dev_fd;
+	/* mapped address */
+	uint8_t *mmap_addr;
+	/* mapped size */
+	uint32_t mmap_size;
 };
 
 #endif /* _BCMFS_DEVICE_H_ */
drivers/crypto/bcmfs/bcmfs_vfio.c new file +107 -0

107 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_vfio.h new file +17 -0
new file mode 100644
index 0000000000..d0fdf6483f
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_VFIO_H_
+#define _BCMFS_VFIO_H_
+
+/* Attach the bcmfs device to vfio */
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev);
+
+/* Release the bcmfs device from vfio */
+void
+bcmfs_release_vfio(struct bcmfs_device *dev);
+
+#endif /* _BCMFS_VFIO_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index a4bdd8ee5d..fd39eba20e 100644
@@ -6,5 +6,6 @@
 deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
-		'bcmfs_device.c'
+		'bcmfs_device.c',
+		'bcmfs_vfio.c'
 		)
Signature · 1 line
2.17.1
#47 lore raw

PATCH v4 3/8 crypto/bcmfs: add queue pair management API

In reply to Vikas Gupta

Add queue pair management APIs which will be used by Crypto device to manage h/w queues. A bcmfs device structure owns multiple queue-pairs based on the mapped address allocated to it.

---
 drivers/crypto/bcmfs/bcmfs_device.c  |   4 +
 drivers/crypto/bcmfs/bcmfs_device.h  |   5 +
 drivers/crypto/bcmfs/bcmfs_hw_defs.h |  32 +++
 drivers/crypto/bcmfs/bcmfs_qp.c      | 345 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_qp.h      | 122 ++++++++++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 6 files changed, 510 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
drivers/crypto/bcmfs/bcmfs_device.c +4 -0
index 0ccddea202..a01a5c79d5 100644
@@ -12,6 +12,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
@@ -77,6 +78,9 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 	if (bcmfs_attach_vfio(fsdev))
 		goto cleanup;
 
+	/* Maximum number of QPs supported */
+	fsdev->max_hw_qps = fsdev->mmap_size / BCMFS_HW_QUEUE_IO_ADDR_LEN;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +5 -0
index f99d57d4bd..dede5b82dc 100644
@@ -11,6 +11,7 @@
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES		4
@@ -44,6 +45,10 @@ struct bcmfs_device {
 	uint8_t *mmap_addr;
 	/* mapped size */
 	uint32_t mmap_size;
+	/* max number of h/w queue pairs detected */
+	uint16_t max_hw_qps;
+	/* current qpairs in use */
+	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 };
 
 #endif /* _BCMFS_DEVICE_H_ */
drivers/crypto/bcmfs/bcmfs_hw_defs.h new file +32 -0
new file mode 100644
index 0000000000..7d5bb5d8fe
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_HW_DEFS_H_
+#define _BCMFS_HW_DEFS_H_
+
+#include <rte_atomic.h>
+#include <rte_byteorder.h>
+#include <rte_common.h>
+#include <rte_io.h>
+
+#ifndef BIT
+#define BIT(nr)         (1UL << (nr))
+#endif
+
+#define FS_RING_REGS_SIZE		0x10000
+#define FS_RING_DESC_SIZE		8
+#define FS_RING_BD_ALIGN_ORDER		12
+#define FS_RING_BD_DESC_PER_REQ		32
+#define FS_RING_CMPL_ALIGN_ORDER	13
+#define FS_RING_CMPL_SIZE		(1024 * FS_RING_DESC_SIZE)
+#define FS_RING_MAX_REQ_COUNT		1024
+#define FS_RING_PAGE_SHFT		12
+#define FS_RING_PAGE_SIZE		BIT(FS_RING_PAGE_SHFT)
+
+/* Minimum and maximum number of requests supported */
+#define FS_RM_MAX_REQS			4096
+#define FS_RM_MIN_REQS			32
+
+#endif /* BCMFS_HW_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c new file +345 -0

345 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_qp.h new file +122 -0

122 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +2 -1
index fd39eba20e..7e2bcbf14b 100644
@@ -7,5 +7,6 @@ deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
-		'bcmfs_vfio.c'
+		'bcmfs_vfio.c',
+		'bcmfs_qp.c'
 		)
Signature · 1 line
2.17.1
#48 lore raw

PATCH v4 4/8 crypto/bcmfs: add HW queue pair operations

In reply to Vikas Gupta

Add queue pair operations exported by supported devices.

---
 drivers/crypto/bcmfs/bcmfs_dev_msg.h      |  29 +
 drivers/crypto/bcmfs/bcmfs_device.c       |  51 ++
 drivers/crypto/bcmfs/bcmfs_device.h       |  16 +
 drivers/crypto/bcmfs/bcmfs_qp.c           |   1 +
 drivers/crypto/bcmfs/bcmfs_qp.h           |   4 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c       | 743 ++++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c       | 677 ++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c |  82 +++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h |  51 ++
 drivers/crypto/bcmfs/meson.build          |   5 +-
 10 files changed, 1658 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
drivers/crypto/bcmfs/bcmfs_dev_msg.h new file +29 -0
new file mode 100644
index 0000000000..5b50bde35a
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_DEV_MSG_H_
+#define _BCMFS_DEV_MSG_H_
+
+#define MAX_SRC_ADDR_BUFFERS    8
+#define MAX_DST_ADDR_BUFFERS    3
+
+struct bcmfs_qp_message {
+	/** Physical address of each source */
+	uint64_t srcs_addr[MAX_SRC_ADDR_BUFFERS];
+	/** Length of each sources */
+	uint32_t srcs_len[MAX_SRC_ADDR_BUFFERS];
+	/** Total number of sources */
+	unsigned int srcs_count;
+	/** Physical address of each destination */
+	uint64_t dsts_addr[MAX_DST_ADDR_BUFFERS];
+	/** Length of each destination */
+	uint32_t dsts_len[MAX_DST_ADDR_BUFFERS];
+	/** Total number of destinations */
+	unsigned int dsts_count;
+
+	void *ctx;
+};
+
+#endif /* _BCMFS_DEV_MSG_H_ */
drivers/crypto/bcmfs/bcmfs_device.c +51 -0

69 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h +16 -0
index dede5b82dc..2fb8eed143 100644
@@ -8,6 +8,7 @@
 
 #include <sys/queue.h>
 
+#include <rte_spinlock.h>
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
@@ -31,6 +32,19 @@ enum bcmfs_device_type {
 	BCMFS_UNKNOWN
 };
 
+/* A table to store registered queue pair opertations */
+struct bcmfs_hw_queue_pair_ops_table {
+	rte_spinlock_t tl;
+	/* Number of used ops structs in the table. */
+	uint32_t num_ops;
+	 /*  Storage for all possible ops structs. */
+	struct bcmfs_hw_queue_pair_ops qp_ops[BCMFS_MAX_NODES];
+};
+
+/* HW queue pair ops register function */
+int
+bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops *qp_ops);
+
 struct bcmfs_device {
 	TAILQ_ENTRY(bcmfs_device) next;
 	/* Directory path for vfio */
@@ -49,6 +63,8 @@ struct bcmfs_device {
 	uint16_t max_hw_qps;
 	/* current qpairs in use */
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
+	/* queue pair ops exported by symmetric crypto hw */
+	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
 };
 
 #endif /* _BCMFS_DEVICE_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +1 -0
index 864e7bb746..ec1327b780 100644
@@ -227,6 +227,7 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	qp->qpair_id = queue_pair_id;
 	qp->ioreg = qp_conf->iobase;
 	qp->nb_descriptors = nb_descriptors;
+	qp->ops = qp_conf->ops;
 
 	qp->stats.enqueued_count = 0;
 	qp->stats.dequeued_count = 0;
drivers/crypto/bcmfs/bcmfs_qp.h +4 -0
index 52c487956e..59785865b0 100644
@@ -44,6 +44,8 @@ struct bcmfs_qp_config {
 	uint16_t nb_descriptors;
 	/* Maximum number of h/w descriptors needed by a request */
 	uint16_t max_descs_req;
+	/* h/w ops associated with qp */
+	struct bcmfs_hw_queue_pair_ops *ops;
 };
 
 struct bcmfs_queue {
@@ -61,6 +63,8 @@ struct bcmfs_queue {
 		/* s/w pointer for completion h/w queue*/
 		uint32_t cmpl_read_ptr;
 	};
+	/* number of inflight descriptor accumulated  before next db ring */
+	uint16_t descs_inflight;
 	/* Memzone name */
 	char memz_name[RTE_MEMZONE_NAMESIZE];
 };
drivers/crypto/bcmfs/hw/bcmfs4_rm.c new file +743 -0

743 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs5_rm.c new file +677 -0

677 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.c new file +82 -0

82 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.h new file +51 -0

51 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +4 -1
index 7e2bcbf14b..cd58bd5e25 100644
@@ -8,5 +8,8 @@ sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
 		'bcmfs_vfio.c',
-		'bcmfs_qp.c'
+		'bcmfs_qp.c',
+		'hw/bcmfs4_rm.c',
+		'hw/bcmfs5_rm.c',
+		'hw/bcmfs_rm_common.c'
 		)
Signature · 1 line
2.17.1
#49 lore raw

PATCH v4 5/8 crypto/bcmfs: create a symmetric cryptodev

In reply to Vikas Gupta

Create a symmetric crypto device and add supported cryptodev ops.

---
 drivers/crypto/bcmfs/bcmfs_device.c  |  15 ++
 drivers/crypto/bcmfs/bcmfs_device.h  |   6 +
 drivers/crypto/bcmfs/bcmfs_qp.c      |  37 +++
 drivers/crypto/bcmfs/bcmfs_qp.h      |  16 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c | 387 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h |  38 +++
 drivers/crypto/bcmfs/bcmfs_sym_req.h |  22 ++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 8 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
drivers/crypto/bcmfs/bcmfs_device.c +15 -0
index 07423d3cc1..27720e4eb8 100644
@@ -14,6 +14,7 @@
 #include "bcmfs_logs.h"
 #include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
+#include "bcmfs_sym_pmd.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -240,6 +241,7 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 	char out_dirname[BCMFS_MAX_PATH_LEN];
 	uint32_t fsdev_dev[BCMFS_MAX_NODES];
 	enum bcmfs_device_type dtype;
+	int err;
 	int i = 0;
 	int dev_idx;
 	int count = 0;
@@ -291,7 +293,20 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 		return -ENODEV;
 	}
 
+	err = bcmfs_sym_dev_create(fsdev);
+	if (err) {
+		BCMFS_LOG(WARNING,
+			  "Failed to create BCMFS SYM PMD for device %s",
+			  fsdev->name);
+		goto pmd_create_fail;
+	}
+
 	return 0;
+
+pmd_create_fail:
+	fsdev_release(fsdev);
+
+	return err;
 }
 
 static int
drivers/crypto/bcmfs/bcmfs_device.h +6 -0
index 2fb8eed143..e5ca866977 100644
@@ -65,6 +65,12 @@ struct bcmfs_device {
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 	/* queue pair ops exported by symmetric crypto hw */
 	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
+	/* a cryptodevice attached to bcmfs device */
+	struct rte_cryptodev *cdev;
+	/* a rte_device to register with cryptodev */
+	struct rte_device sym_rte_dev;
+	/* private info to keep with cryptodev */
+	struct bcmfs_sym_dev_private *sym_dev;
 };
 
 #endif /* _BCMFS_DEVICE_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +37 -0
index ec1327b780..cb5ff6c61b 100644
@@ -344,3 +344,40 @@ bcmfs_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops)
 
 	return deq;
 }
+
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats)
+{
+	int i;
+
+	if (stats == NULL) {
+		BCMFS_LOG(ERR, "invalid param: stats %p",
+			  stats);
+		return;
+	}
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+
+		stats->enqueued_count += qp[i]->stats.enqueued_count;
+		stats->dequeued_count += qp[i]->stats.dequeued_count;
+		stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
+		stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
+	}
+}
+
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp)
+{
+	int i;
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+		memset(&qp[i]->stats, 0, sizeof(qp[i]->stats));
+	}
+}
drivers/crypto/bcmfs/bcmfs_qp.h +16 -0
index 59785865b0..57fe0a93a3 100644
@@ -24,6 +24,13 @@ enum bcmfs_queue_type {
 	BCMFS_RM_CPLQ
 };
 
+#define BCMFS_QP_IOBASE_XLATE(base, idx)	\
+		((base) + ((idx) * BCMFS_HW_QUEUE_IO_ADDR_LEN))
+
+/* Max pkts for preprocessing before submitting to h/w qp */
+#define BCMFS_MAX_REQS_BUFF	64
+
+/* qp stats */
 struct bcmfs_qp_stats {
 	/* Count of all operations enqueued */
 	uint64_t enqueued_count;
@@ -92,6 +99,10 @@ struct bcmfs_qp {
 	struct bcmfs_qp_stats stats;
 	/* h/w ops associated with qp */
 	struct bcmfs_hw_queue_pair_ops *ops;
+	/* bcmfs requests pool*/
+	struct rte_mempool *sr_mp;
+	/* a temporary buffer to keep message pointers */
+	struct bcmfs_qp_message *infl_msgs[BCMFS_MAX_REQS_BUFF];
 
 } __rte_cache_aligned;
 
@@ -123,4 +134,9 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	       uint16_t queue_pair_id,
 	       struct bcmfs_qp_config *bcmfs_conf);
 
+/* stats functions*/
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats);
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp);
+
 #endif /* _BCMFS_QP_H_ */
drivers/crypto/bcmfs/bcmfs_sym_pmd.c new file +387 -0

387 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.h new file +38 -0
new file mode 100644
index 0000000000..65d7046090
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_PMD_H_
+#define _BCMFS_SYM_PMD_H_
+
+#include <rte_cryptodev.h>
+
+#include "bcmfs_device.h"
+
+#define CRYPTODEV_NAME_BCMFS_SYM_PMD	crypto_bcmfs
+
+#define BCMFS_CRYPTO_MAX_HW_DESCS_PER_REQ	16
+
+extern uint8_t cryptodev_bcmfs_driver_id;
+
+/** private data structure for a BCMFS device.
+ *  This BCMFS device is a device offering only symmetric crypto service,
+ *  there can be one of these on each bcmfs_pci_device (VF).
+ */
+struct bcmfs_sym_dev_private {
+	/* The bcmfs device hosting the service */
+	struct bcmfs_device *fsdev;
+	/* Device instance for this rte_cryptodev */
+	uint8_t sym_dev_id;
+	/* BCMFS device symmetric crypto capabilities */
+	const struct rte_cryptodev_capabilities *fsdev_capabilities;
+};
+
+int
+bcmfs_sym_dev_create(struct bcmfs_device *fdev);
+
+int
+bcmfs_sym_dev_destroy(struct bcmfs_device *fdev);
+
+#endif /* _BCMFS_SYM_PMD_H_ */
drivers/crypto/bcmfs/bcmfs_sym_req.h new file +22 -0
new file mode 100644
index 0000000000..0f0b051f1e
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_REQ_H_
+#define _BCMFS_SYM_REQ_H_
+
+#include "bcmfs_dev_msg.h"
+
+/*
+ * This structure hold the supportive data required to process a
+ * rte_crypto_op
+ */
+struct bcmfs_sym_request {
+	/* bcmfs qp message for h/w queues to process */
+	struct bcmfs_qp_message msgs;
+	/* crypto op */
+	struct rte_crypto_op *op;
+};
+
+#endif /* _BCMFS_SYM_REQ_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index cd58bd5e25..d9a3d73e99 100644
@@ -11,5 +11,6 @@ sources = files(
 		'bcmfs_qp.c',
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
-		'hw/bcmfs_rm_common.c'
+		'hw/bcmfs_rm_common.c',
+		'bcmfs_sym_pmd.c'
 		)
Signature · 1 line
2.17.1
#50 lore raw

PATCH v4 6/8 crypto/bcmfs: add session handling and capabilities

In reply to Vikas Gupta

Add session handling and capabilities supported by crypto h/w accelerator

---
 doc/guides/cryptodevs/bcmfs.rst               |  47 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |  56 ++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c | 764 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         |  34 +
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          |  13 +
 drivers/crypto/bcmfs/bcmfs_sym_session.c      | 282 +++++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      | 109 +++
 drivers/crypto/bcmfs/meson.build              |   4 +-
 9 files changed, 1324 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
doc/guides/cryptodevs/bcmfs.rst +47 -0
index 6b68673df0..f7e15f4cfb 100644
@@ -15,6 +15,47 @@ Supported Broadcom SoCs
 * Stingray
 * Stingray2
 
+Features
+--------
+
+The BCMFS SYM PMD has support for:
+
+Cipher algorithms:
+
+* ``RTE_CRYPTO_CIPHER_3DES_CBC``
+* ``RTE_CRYPTO_CIPHER_3DES_CTR``
+* ``RTE_CRYPTO_CIPHER_AES128_CBC``
+* ``RTE_CRYPTO_CIPHER_AES192_CBC``
+* ``RTE_CRYPTO_CIPHER_AES256_CBC``
+* ``RTE_CRYPTO_CIPHER_AES128_CTR``
+* ``RTE_CRYPTO_CIPHER_AES192_CTR``
+* ``RTE_CRYPTO_CIPHER_AES256_CTR``
+* ``RTE_CRYPTO_CIPHER_AES_XTS``
+* ``RTE_CRYPTO_CIPHER_DES_CBC``
+
+Hash algorithms:
+
+* ``RTE_CRYPTO_AUTH_SHA1``
+* ``RTE_CRYPTO_AUTH_SHA1_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA224``
+* ``RTE_CRYPTO_AUTH_SHA224_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA256``
+* ``RTE_CRYPTO_AUTH_SHA256_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA384``
+* ``RTE_CRYPTO_AUTH_SHA384_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA512``
+* ``RTE_CRYPTO_AUTH_SHA512_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_XCBC_MAC``
+* ``RTE_CRYPTO_AUTH_AES_CBC_MAC``
+* ``RTE_CRYPTO_AUTH_MD5_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_GMAC``
+* ``RTE_CRYPTO_AUTH_AES_CMAC``
+
+Supported AEAD algorithms:
+
+* ``RTE_CRYPTO_AEAD_AES_GCM``
+* ``RTE_CRYPTO_AEAD_AES_CCM``
+
 Installation
 ------------
 Information about kernel, rootfs and toolchain can be found at
@@ -49,3 +90,9 @@ For example, below commands can be run to get hold of a device node by VFIO.
     io_device_name="vfio-platform"
     echo $io_device_name > /sys/bus/platform/devices/${SETUP_SYSFS_DEV_NAME}/driver_override
     echo ${SETUP_SYSFS_DEV_NAME} > /sys/bus/platform/drivers_probe
+
+Limitations
+-----------
+
+* Only supports the session-oriented API implementation (session-less APIs are not supported).
+* CCM is not supported on Broadcom`s SoCs having FlexSparc4 unit.
doc/guides/cryptodevs/features/bcmfs.ini new file +56 -0

56 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.c new file +764 -0

764 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.h new file +16 -0
new file mode 100644
index 0000000000..3ff61b7d29
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_CAPABILITIES_H_
+#define _BCMFS_SYM_CAPABILITIES_H_
+
+/*
+ * Get capabilities list for the device
+ *
+ */
+const struct rte_cryptodev_capabilities *bcmfs_sym_get_capabilities(void);
+
+#endif /* _BCMFS_SYM_CAPABILITIES_H__ */
+
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +34 -0
new file mode 100644
index 0000000000..aea1f281e4
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_DEFS_H_
+#define _BCMFS_SYM_DEFS_H_
+
+/*
+ * Max block size of hash algorithm
+ * currently SHA3 supports max block size
+ * of 144 bytes
+ */
+#define BCMFS_MAX_KEY_SIZE	144
+#define BCMFS_MAX_IV_SIZE	16
+#define BCMFS_MAX_DIGEST_SIZE	64
+
+struct bcmfs_sym_session;
+struct bcmfs_sym_request;
+
+/** Crypto Request processing successful. */
+#define BCMFS_SYM_RESPONSE_SUCCESS               (0)
+/** Crypot Request processing protocol failure. */
+#define BCMFS_SYM_RESPONSE_PROTO_FAILURE         (1)
+/** Crypot Request processing completion failure. */
+#define BCMFS_SYM_RESPONSE_COMPL_ERROR           (2)
+/** Crypot Request processing hash tag check error. */
+#define BCMFS_SYM_RESPONSE_HASH_TAG_ERROR        (3)
+
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req);
+#endif /* _BCMFS_SYM_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_sym_pmd.c +13 -0
index 0f96915f70..381ca8ea48 100644
@@ -14,6 +14,8 @@
 #include "bcmfs_qp.h"
 #include "bcmfs_sym_pmd.h"
 #include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+#include "bcmfs_sym_capabilities.h"
 
 uint8_t cryptodev_bcmfs_driver_id;
 
@@ -65,6 +67,7 @@ bcmfs_sym_dev_info_get(struct rte_cryptodev *dev,
 		dev_info->max_nb_queue_pairs = fsdev->max_hw_qps;
 		/* No limit of number of sessions */
 		dev_info->sym.max_nb_sessions = 0;
+		dev_info->capabilities = bcmfs_sym_get_capabilities();
 	}
 }
 
@@ -228,6 +231,10 @@ static struct rte_cryptodev_ops crypto_bcmfs_ops = {
 	/* Queue-Pair management */
 	.queue_pair_setup       = bcmfs_sym_qp_setup,
 	.queue_pair_release     = bcmfs_sym_qp_release,
+	/* Crypto session related operations */
+	.sym_session_get_size   = bcmfs_sym_session_get_private_size,
+	.sym_session_configure  = bcmfs_sym_session_configure,
+	.sym_session_clear      = bcmfs_sym_session_clear
 };
 
 /** Enqueue burst */
@@ -239,6 +246,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	int i, j;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
+	struct bcmfs_sym_session *sess;
 	struct bcmfs_qp *qp = (struct bcmfs_qp *)queue_pair;
 
 	if (nb_ops == 0)
@@ -252,6 +260,10 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		nb_ops = qp->nb_descriptors - qp->nb_pending_requests;
 
 	for (i = 0; i < nb_ops; i++) {
+		sess = bcmfs_sym_get_session(ops[i]);
+		if (unlikely(sess == NULL))
+			goto enqueue_err;
+
 		if (rte_mempool_get(qp->sr_mp, (void **)&sreq))
 			goto enqueue_err;
 
@@ -356,6 +368,7 @@ bcmfs_sym_dev_create(struct bcmfs_device *fsdev)
 	fsdev->sym_dev = internals;
 
 	internals->sym_dev_id = cryptodev->data->dev_id;
+	internals->fsdev_capabilities = bcmfs_sym_get_capabilities();
 
 	BCMFS_LOG(DEBUG, "Created bcmfs-sym device %s as cryptodev instance %d",
 		  cryptodev->data->name, internals->sym_dev_id);
drivers/crypto/bcmfs/bcmfs_sym_session.c new file +282 -0

282 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_session.h new file +109 -0

109 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +3 -1
index d9a3d73e99..2e86c733e1 100644
@@ -12,5 +12,7 @@ sources = files(
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
 		'hw/bcmfs_rm_common.c',
-		'bcmfs_sym_pmd.c'
+		'bcmfs_sym_pmd.c',
+		'bcmfs_sym_capabilities.c',
+		'bcmfs_sym_session.c'
 		)
Signature · 1 line
2.17.1
#51 lore raw

PATCH v4 7/8 crypto/bcmfs: add crypto HW module

In reply to Vikas Gupta

Add crypto h/w module to process crypto op. Crypto op is processed via sym_engine module before submitting the crypto request to h/w queues.

---
 drivers/crypto/bcmfs/bcmfs_sym.c        |  289 ++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.c | 1155 +++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h |  115 +++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c    |   26 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h    |   40 +
 drivers/crypto/bcmfs/meson.build        |    4 +-
 6 files changed, 1628 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
drivers/crypto/bcmfs/bcmfs_sym.c new file +289 -0
new file mode 100644
index 0000000000..2d164a1ec8
@@ -0,0 +1,289 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <stdbool.h>
+
+#include <rte_byteorder.h>
+#include <rte_crypto_sym.h>
+#include <rte_cryptodev.h>
+#include <rte_mbuf.h>
+#include <rte_mempool.h>
+
+#include "bcmfs_sym_defs.h"
+#include "bcmfs_sym_engine.h"
+#include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+
+/** Process cipher operation */
+static int
+process_crypto_cipher_op(struct rte_crypto_op *op,
+			 struct rte_mbuf *mbuf_src,
+			 struct rte_mbuf *mbuf_dst,
+			 struct bcmfs_sym_session *sess,
+			 struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv, key;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+	fsattr_pa(&dst) = rte_pktmbuf_iova(mbuf_dst);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						   uint8_t *,
+						   sess->cipher.iv.offset);
+
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&key) = sess->cipher.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->cipher.key.length;
+
+	rc = bcmfs_crypto_build_cipher_req(req, sess->cipher.algo,
+					   sess->cipher.op, &src,
+					   &dst, &key, &iv);
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process auth operation */
+static int
+process_crypto_auth_op(struct rte_crypto_op *op,
+		       struct rte_mbuf *mbuf_src,
+		       struct bcmfs_sym_session *sess,
+		       struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, mac, key, iv;
+
+	fsattr_sz(&src) = op->sym->auth.data.length;
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset(mbuf_src,
+						  uint8_t *,
+						  op->sym->auth.data.offset);
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+
+	if (!sess->auth.op) {
+		fsattr_va(&mac) = op->sym->auth.digest.data;
+		fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&mac) = sess->auth.digest_length;
+	} else {
+		fsattr_va(&dst) = op->sym->auth.digest.data;
+		fsattr_pa(&dst) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&dst) = sess->auth.digest_length;
+	}
+
+	fsattr_va(&key) = sess->auth.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->auth.key.length;
+
+	/* AES-GMAC uses AES-GCM-128 authenticator */
+	if (sess->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC) {
+		fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+							   uint8_t *,
+							   sess->auth.iv.offset);
+		fsattr_pa(&iv) = 0;
+		fsattr_sz(&iv) = sess->auth.iv.length;
+	} else {
+		fsattr_va(&iv) = NULL;
+		fsattr_sz(&iv) = 0;
+	}
+
+		rc = bcmfs_crypto_build_auth_req(req, sess->auth.algo,
+						 sess->auth.op,
+						 &src,
+						 (sess->auth.op) ? (&dst) : NULL,
+						 (sess->auth.op) ? NULL  : (&mac),
+						 &key, &iv);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process combined/chained mode operation */
+static int
+process_crypto_combined_op(struct rte_crypto_op *op,
+			   struct rte_mbuf *mbuf_src,
+			   struct rte_mbuf *mbuf_dst,
+			   struct bcmfs_sym_session *sess,
+			   struct bcmfs_sym_request *req)
+{
+	int rc = 0, aad_size = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr cipher_key, aad, mac, auth_key;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						  sym_op->cipher.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						  sym_op->cipher.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						   uint8_t *,
+						   sess->cipher.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&cipher_key) = sess->cipher.key.data;
+	fsattr_pa(&cipher_key) = 0;
+	fsattr_sz(&cipher_key) = sess->cipher.key.length;
+
+	fsattr_va(&auth_key) = sess->auth.key.data;
+	fsattr_pa(&auth_key) = 0;
+	fsattr_sz(&auth_key) = sess->auth.key.length;
+
+	fsattr_va(&mac) = op->sym->auth.digest.data;
+	fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+	fsattr_sz(&mac) = sess->auth.digest_length;
+
+	aad_size = sym_op->auth.data.length - sym_op->cipher.data.length;
+
+	if (aad_size > 0) {
+		fsattr_sz(&aad) =  aad_size;
+		fsattr_va(&aad) = rte_pktmbuf_mtod_offset
+						(mbuf_src,
+						 uint8_t *,
+						sym_op->auth.data.offset);
+		fsattr_pa(&aad) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->auth.data.offset);
+	}
+
+	rc = bcmfs_crypto_build_chain_request(req, sess->cipher.algo,
+					      sess->cipher.op,
+					      sess->auth.algo,
+					      sess->auth.op,
+					      &src, &dst, &cipher_key,
+					      &auth_key, &iv,
+					      (aad_size > 0) ? (&aad) : NULL,
+					      &mac, sess->cipher_first);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process AEAD operation */
+static int
+process_crypto_aead_op(struct rte_crypto_op *op,
+		       struct rte_mbuf *mbuf_src,
+		       struct rte_mbuf *mbuf_dst,
+		       struct bcmfs_sym_session *sess,
+		       struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr key, aad, mac;
+
+	fsattr_sz(&src) = sym_op->aead.data.length;
+	fsattr_sz(&dst) = sym_op->aead.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset(mbuf_src,
+						  uint8_t *,
+						  sym_op->aead.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset(mbuf_dst,
+						  uint8_t *,
+						  sym_op->aead.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						  sym_op->aead.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						  sym_op->aead.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						   uint8_t *,
+						   sess->aead.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->aead.iv.length;
+
+	fsattr_va(&key) = sess->aead.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->aead.key.length;
+
+	fsattr_va(&mac) = op->sym->aead.digest.data;
+	fsattr_pa(&mac) = op->sym->aead.digest.phys_addr;
+	fsattr_sz(&mac) = sess->aead.digest_length;
+
+	fsattr_va(&aad) = op->sym->aead.aad.data;
+	fsattr_pa(&aad) = op->sym->aead.aad.phys_addr;
+	fsattr_sz(&aad) = sess->aead.aad_length;
+
+	rc = bcmfs_crypto_build_aead_request(req, sess->aead.algo,
+					     sess->aead.op, &src, &dst,
+					     &key, &iv, &aad, &mac);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process crypto operation for mbuf */
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req)
+{
+	struct rte_mbuf *msrc, *mdst;
+	int rc = 0;
+
+	msrc = op->sym->m_src;
+	mdst = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src;
+	op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+
+	switch (sess->chain_order) {
+	case BCMFS_SYM_CHAIN_ONLY_CIPHER:
+		rc = process_crypto_cipher_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_ONLY_AUTH:
+		rc = process_crypto_auth_op(op, msrc, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_CIPHER_AUTH:
+	case BCMFS_SYM_CHAIN_AUTH_CIPHER:
+		rc = process_crypto_combined_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_AEAD:
+		rc = process_crypto_aead_op(op, msrc, mdst, sess, req);
+		break;
+	default:
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+		break;
+	}
+
+	return rc;
+}
drivers/crypto/bcmfs/bcmfs_sym_engine.c new file +1155 -0

1,155 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_engine.h new file +115 -0

115 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.c +26 -0
index 381ca8ea48..568797b4fd 100644
@@ -132,6 +132,12 @@ static void
 spu_req_init(struct bcmfs_sym_request *sr, rte_iova_t iova __rte_unused)
 {
 	memset(sr, 0, sizeof(*sr));
+	sr->fptr = iova;
+	sr->cptr = iova + offsetof(struct bcmfs_sym_request, cipher_key);
+	sr->aptr = iova + offsetof(struct bcmfs_sym_request, auth_key);
+	sr->iptr = iova + offsetof(struct bcmfs_sym_request, iv);
+	sr->dptr = iova + offsetof(struct bcmfs_sym_request, digest);
+	sr->rptr = iova + offsetof(struct bcmfs_sym_request, resp);
 }
 
 static void
@@ -244,6 +250,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 			       uint16_t nb_ops)
 {
 	int i, j;
+	int retval;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
 	struct bcmfs_sym_session *sess;
@@ -273,6 +280,11 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		/* save context */
 		qp->infl_msgs[i] = &sreq->msgs;
 		qp->infl_msgs[i]->ctx = (void *)sreq;
+
+		/* pre process the request crypto h/w acceleration */
+		retval = bcmfs_process_sym_crypto_op(ops[i], sess, sreq);
+		if (unlikely(retval < 0))
+			goto enqueue_err;
 	}
 	/* Send burst request to hw QP */
 	enq = bcmfs_enqueue_op_burst(qp, (void **)qp->infl_msgs, i);
@@ -289,6 +301,17 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	return enq;
 }
 
+static void bcmfs_sym_set_request_status(struct rte_crypto_op *op,
+					 struct bcmfs_sym_request *out)
+{
+	if (*out->resp == BCMFS_SYM_RESPONSE_SUCCESS)
+		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+	else if (*out->resp == BCMFS_SYM_RESPONSE_HASH_TAG_ERROR)
+		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+	else
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+}
+
 static uint16_t
 bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 			       struct rte_crypto_op **ops,
@@ -308,6 +331,9 @@ bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 	for (i = 0; i < deq; i++) {
 		sreq = (struct bcmfs_sym_request *)qp->infl_msgs[i]->ctx;
 
+		/* set the status based on the response from the crypto h/w */
+		bcmfs_sym_set_request_status(sreq->op, sreq);
+
 		ops[pkts++] = sreq->op;
 
 		rte_mempool_put(qp->sr_mp, sreq);
drivers/crypto/bcmfs/bcmfs_sym_req.h +40 -0
index 0f0b051f1e..e53c50adc1 100644
@@ -6,13 +6,53 @@
 #ifndef _BCMFS_SYM_REQ_H_
 #define _BCMFS_SYM_REQ_H_
 
+#include <rte_cryptodev.h>
+
 #include "bcmfs_dev_msg.h"
+#include "bcmfs_sym_defs.h"
+
+/* Fixed SPU2 Metadata */
+struct spu2_fmd {
+	uint64_t ctrl0;
+	uint64_t ctrl1;
+	uint64_t ctrl2;
+	uint64_t ctrl3;
+};
 
 /*
  * This structure hold the supportive data required to process a
  * rte_crypto_op
  */
 struct bcmfs_sym_request {
+	/* spu2 engine related data */
+	struct spu2_fmd fmd;
+	/* cipher key */
+	uint8_t cipher_key[BCMFS_MAX_KEY_SIZE];
+	/* auth key */
+	uint8_t auth_key[BCMFS_MAX_KEY_SIZE];
+	/* iv key */
+	uint8_t iv[BCMFS_MAX_IV_SIZE];
+	/* digest data output from crypto h/w */
+	uint8_t digest[BCMFS_MAX_DIGEST_SIZE];
+	/* 2-Bytes response from crypto h/w */
+	uint8_t resp[2];
+	/*
+	 * Below are all iovas for above members
+	 * from top
+	 */
+	/* iova for fmd */
+	rte_iova_t fptr;
+	/* iova for cipher key */
+	rte_iova_t cptr;
+	/* iova for auth key */
+	rte_iova_t aptr;
+	/* iova for iv key */
+	rte_iova_t iptr;
+	/* iova for digest */
+	rte_iova_t dptr;
+	/* iova for response */
+	rte_iova_t rptr;
+
 	/* bcmfs qp message for h/w queues to process */
 	struct bcmfs_qp_message msgs;
 	/* crypto op */
drivers/crypto/bcmfs/meson.build +3 -1
index 2e86c733e1..7aa0f05dbd 100644
@@ -14,5 +14,7 @@ sources = files(
 		'hw/bcmfs_rm_common.c',
 		'bcmfs_sym_pmd.c',
 		'bcmfs_sym_capabilities.c',
-		'bcmfs_sym_session.c'
+		'bcmfs_sym_session.c',
+		'bcmfs_sym.c',
+		'bcmfs_sym_engine.c'
 		)
Signature · 1 line
2.17.1
#52 lore raw

PATCH v4 8/8 crypto/bcmfs: add crypto pmd into cryptodev test

In reply to Vikas Gupta

Add global test suite for bcmfs crypto pmd

---
 app/test/test_cryptodev.c       | 17 +++++++++++++++++
 app/test/test_cryptodev.h       |  1 +
 doc/guides/cryptodevs/bcmfs.rst | 11 +++++++++++
 3 files changed, 29 insertions(+)
app/test/test_cryptodev.c +17 -0
index 70bf6fe2c1..9157115ab3 100644
@@ -13041,6 +13041,22 @@ test_cryptodev_nitrox(void)
 	return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
 }
 
+static int
+test_cryptodev_bcmfs(void)
+{
+	gbl_driver_id =	rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
+
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded. Check if "
+				"CONFIG_RTE_LIBRTE_PMD_BCMFS is enabled "
+				"in config file to run this testsuite.\n");
+		return TEST_FAILED;
+	}
+
+	return unit_test_suite_runner(&cryptodev_testsuite);
+}
+
 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
@@ -13063,3 +13079,4 @@ REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
+REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
app/test/test_cryptodev.h +1 -0
index 41542e0552..c58126368c 100644
@@ -70,6 +70,7 @@
 #define CRYPTODEV_NAME_OCTEONTX2_PMD	crypto_octeontx2
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 #define CRYPTODEV_NAME_NITROX_PMD	crypto_nitrox_sym
+#define CRYPTODEV_NAME_BCMFS_PMD	crypto_bcmfs
 
 /**
  * Write (spread) data from buffer to mbuf data
doc/guides/cryptodevs/bcmfs.rst +11 -0
index f7e15f4cfb..5a7eb23c0f 100644
@@ -96,3 +96,14 @@ Limitations
 
 * Only supports the session-oriented API implementation (session-less APIs are not supported).
 * CCM is not supported on Broadcom`s SoCs having FlexSparc4 unit.
+
+Testing
+-------
+
+The symmetric crypto operations on BCMFS crypto PMD may be verified by running the test
+application:
+
+.. code-block:: console
+
+    ./test
+    RTE>>cryptodev_bcmfs_autotest
Signature · 1 line
2.17.1
#53 lore raw

v5 cover Add Crypto PMD for Broadcom`s FlexSparc devices

In reply to Vikas Gupta

Hi,
This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.
BCMFS is an acronym for Broadcom FlexSparc device used in the patchest.

The patchset progressively adds major modules as below.
a) Detection of platform-device based on the known registered platforms and attaching with VFIO.
b) Creation of Cryptodevice.
c) Addition of session handling.
d) Add Cryptodevice into test Cryptodev framework.

The patchset has been tested on the above mentioned SoCs.

Regards,
Vikas

Changes from v0->v1:
Updated the ABI version in file .../crypto/bcmfs/rte_pmd_bcmfs_version.map

Changes from v1->v2:
- Fix compilation errors and coding style warnings.
- Use global test crypto suite suggested by Adam Dybkowski

Changes from v2->v3:
- Release notes updated.
- bcmfs.rst updated with missing information about installation.
- Review comments from patch1 from v2 addressed.
- Updated description about dependency of PMD driver on VFIO_PRESENT.
- Fixed typo in bcmfs_hw_defs.h (comments on patch3 from v2 addressed)
- Comments on patch6 from v2 addressed and capability list is fixed. Removed redundant enums and macros from the file bcmfs_sym_defs.h and updated other impacted APIs accordingly. patch7 too is updated due to removal of redundancy. Thanks! to Akhil for pointing out the redundancy.
- Fix minor code style issues in few files as part of review.

Changes from v3->v4:
- Code style issues fixed.
- Change of barrier API in bcmfs4_rm.c and bcmfs5_rm.c

Changes from v4->v5:
- Change of barrier API in bcmfs4_rm.c. Missed one in v4

Vikas Gupta (8):
crypto/bcmfs: add BCMFS driver crypto/bcmfs: add vfio support crypto/bcmfs: add queue pair management API crypto/bcmfs: add HW queue pair operations crypto/bcmfs: create a symmetric cryptodev crypto/bcmfs: add session handling and capabilities crypto/bcmfs: add crypto HW module crypto/bcmfs: add crypto pmd into cryptodev test

 MAINTAINERS                                   |    7 +
 app/test/test_cryptodev.c                     |   17 +
 app/test/test_cryptodev.h                     |    1 +
 doc/guides/cryptodevs/bcmfs.rst               |  109 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |   56 +
 doc/guides/cryptodevs/index.rst               |    1 +
 doc/guides/rel_notes/release_20_11.rst        |    5 +
 drivers/crypto/bcmfs/bcmfs_dev_msg.h          |   29 +
 drivers/crypto/bcmfs/bcmfs_device.c           |  332 +++++
 drivers/crypto/bcmfs/bcmfs_device.h           |   76 ++
 drivers/crypto/bcmfs/bcmfs_hw_defs.h          |   32 +
 drivers/crypto/bcmfs/bcmfs_logs.c             |   38 +
 drivers/crypto/bcmfs/bcmfs_logs.h             |   34 +
 drivers/crypto/bcmfs/bcmfs_qp.c               |  383 ++++++
 drivers/crypto/bcmfs/bcmfs_qp.h               |  142 ++
 drivers/crypto/bcmfs/bcmfs_sym.c              |  289 +++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c |  764 +++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |   16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         |   34 +
 drivers/crypto/bcmfs/bcmfs_sym_engine.c       | 1155 +++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h       |  115 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          |  426 ++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h          |   38 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h          |   62 +
 drivers/crypto/bcmfs/bcmfs_sym_session.c      |  282 ++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      |  109 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c             |  107 ++
 drivers/crypto/bcmfs/bcmfs_vfio.h             |   17 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c           |  743 +++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c           |  677 ++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c     |   82 ++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h     |   51 +
 drivers/crypto/bcmfs/meson.build              |   20 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |    3 +
 drivers/crypto/meson.build                    |    1 +
 35 files changed, 6253 insertions(+)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
Signature · 1 line
2.17.1
#54 lore raw

PATCH v5 1/8 crypto/bcmfs: add BCMFS driver

Add Broadcom FlexSparc(FS) device creation driver which registers to a vdev and create a device. Add APIs for logs, supportive documentation and maintainers file.

---
 MAINTAINERS                                   |   7 +
 doc/guides/cryptodevs/bcmfs.rst               |  51 ++++
 doc/guides/cryptodevs/index.rst               |   1 +
 doc/guides/rel_notes/release_20_11.rst        |   5 +
 drivers/crypto/bcmfs/bcmfs_device.c           | 257 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_device.h           |  43 +++
 drivers/crypto/bcmfs/bcmfs_logs.c             |  38 +++
 drivers/crypto/bcmfs/bcmfs_logs.h             |  34 +++
 drivers/crypto/bcmfs/meson.build              |  10 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |   3 +
 drivers/crypto/meson.build                    |   1 +
 11 files changed, 450 insertions(+)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
MAINTAINERS +7 -0
index c0abbe0fc8..49c015ebbe 100644
@@ -1081,6 +1081,13 @@ F: drivers/crypto/zuc/
 F: doc/guides/cryptodevs/zuc.rst
 F: doc/guides/cryptodevs/features/zuc.ini
 
+Broadcom FlexSparc
+M: Ajit Khaparde <[email protected]>
+M: Raveendra Padasalagi <[email protected]>
+M: Vikas Gupta <vikas.gupta@@broadcom.com>
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 -------------------
doc/guides/cryptodevs/bcmfs.rst new file +51 -0

51 lines not on this page · raw message

doc/guides/cryptodevs/index.rst +1 -0
index a67ed5a282..279f56a002 100644
@@ -13,6 +13,7 @@ Crypto Device Drivers
     aesni_mb
     aesni_gcm
     armv8
+    bcmfs
     caam_jr
     ccp
     dpaa2_sec
doc/guides/rel_notes/release_20_11.rst +5 -0
index 73ac08fb0e..8643330321 100644
@@ -185,3 +185,8 @@ Tested Platforms
    This section is a comment. Do not overwrite or remove it.
    Also, make sure to start the actual text at the margin.
    =======================================================
+
+* **Added Broadcom BCMFS symmetric crypto PMD.**
+
+  Added a symmetric crypto PMD for Broadcom FlexSparc crypto units.
+  See :doc:`../cryptodevs/bcmfs` guide for more details on this new PMD.
drivers/crypto/bcmfs/bcmfs_device.c new file +257 -0

257 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h new file +43 -0

43 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_logs.c new file +38 -0
new file mode 100644
index 0000000000..86f4ff3b53
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <rte_log.h>
+#include <rte_hexdump.h>
+
+#include "bcmfs_logs.h"
+
+int bcmfs_conf_logtype;
+int bcmfs_dp_logtype;
+
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
+		const void *buf, unsigned int len)
+{
+	if (level > rte_log_get_global_level())
+		return 0;
+	if (level > (uint32_t)(rte_log_get_level(logtype)))
+		return 0;
+
+	rte_hexdump(rte_log_get_stream(), title, buf, len);
+	return 0;
+}
+
+RTE_INIT(bcmfs_device_init_log)
+{
+	/* Configuration and general logs */
+	bcmfs_conf_logtype = rte_log_register("pmd.bcmfs_config");
+	if (bcmfs_conf_logtype >= 0)
+		rte_log_set_level(bcmfs_conf_logtype, RTE_LOG_NOTICE);
+
+	/* data-path logs */
+	bcmfs_dp_logtype = rte_log_register("pmd.bcmfs_fp");
+	if (bcmfs_dp_logtype >= 0)
+		rte_log_set_level(bcmfs_dp_logtype, RTE_LOG_NOTICE);
+}
drivers/crypto/bcmfs/bcmfs_logs.h new file +34 -0
new file mode 100644
index 0000000000..c03a49b75c
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_LOGS_H_
+#define _BCMFS_LOGS_H_
+
+#include <rte_log.h>
+
+extern int bcmfs_conf_logtype;
+extern int bcmfs_dp_logtype;
+
+#define BCMFS_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_conf_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_dp_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_HEXDUMP_LOG(level, title, buf, len)	\
+	bcmfs_hexdump_log(RTE_LOG_ ## level, bcmfs_dp_logtype, title, buf, len)
+
+/**
+ * bcmfs_hexdump_log Dump out memory in a special hex dump format.
+ *
+ * The message will be sent to the stream used by the rte_log infrastructure.
+ */
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *heading,
+		  const void *buf, unsigned int len);
+
+#endif /* _BCMFS_LOGS_H_ */
drivers/crypto/bcmfs/meson.build new file +10 -0
new file mode 100644
index 0000000000..a4bdd8ee5d
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2020 Broadcom
+# All rights reserved.
+#
+
+deps += ['eal', 'bus_vdev']
+sources = files(
+		'bcmfs_logs.c',
+		'bcmfs_device.c'
+		)
drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map new file +3 -0
new file mode 100644
index 0000000000..299ae632da
@@ -0,0 +1,3 @@
+DPDK_21.0 {
+	local: *;
+};
drivers/crypto/meson.build +1 -0
index a2423507ad..93c2968acb 100644
@@ -8,6 +8,7 @@ endif
 drivers = ['aesni_gcm',
 	   'aesni_mb',
 	   'armv8',
+	   'bcmfs',
 	   'caam_jr',
 	   'ccp',
 	   'dpaa_sec',
Signature · 1 line
2.17.1
#55 lore raw

Re: [dpdk-dev] [PATCH v5 1/8] crypto/bcmfs: add BCMFS driver

07/10/2020 19:18, Vikas Gupta:

MAINTAINERS F: drivers/crypto/zuc/ · line 1083

Quoted 6 lines
MAINTAINERS +0 -0
@@ -1081,6 +1081,13 @@ F: drivers/crypto/zuc/
 F: doc/guides/cryptodevs/zuc.rst
 F: doc/guides/cryptodevs/features/zuc.ini
 

Drivers are alphabetically sorted.

MAINTAINERS F: drivers/crypto/zuc/ · line 1087

Quoted 4 lines
MAINTAINERS +4 -0
+Broadcom FlexSparc
+M: Ajit Khaparde <[email protected]>
+M: Raveendra Padasalagi <[email protected]>
+M: Vikas Gupta <vikas.gupta@@broadcom.com>

Nice trick for not being disturbed with emails: @@

MAINTAINERS F: drivers/crypto/zuc/ · line 1090

Quoted 3 lines
MAINTAINERS +3 -0
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini

Will fix while pulling next-crypto.

#56 lore raw

Re: [dpdk-dev] [PATCH v5 1/8] crypto/bcmfs: add BCMFS driver

In reply to Vikas Gupta

07/10/2020 19:18, Vikas Gupta:

drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map line 3

Quoted 6 lines
drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map new file +3 -0
@@ -0,0 +1,3 @@
+DPDK_21.0 {
+	local: *;
+};

No!
Please be careful, all other libs use ABI DPDK_21.

Will fix

#57 lore raw

PATCH v5 2/8 crypto/bcmfs: add vfio support

In reply to Vikas Gupta

Add VFIO support for BCMFS PMD.
The BCMFS PMD functionality is dependent on the VFIO_PRESENT flag, which gets enabled in the rte_vfio.h.
If this flag is not enabled in the compiling platform driver will silently return with error, when executed.

---
 drivers/crypto/bcmfs/bcmfs_device.c |   5 ++
 drivers/crypto/bcmfs/bcmfs_device.h |   6 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c   | 107 ++++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_vfio.h   |  17 +++++
 drivers/crypto/bcmfs/meson.build    |   3 +-
 5 files changed, 137 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
drivers/crypto/bcmfs/bcmfs_device.c +5 -0
index f1050ff112..0ccddea202 100644
@@ -12,6 +12,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -72,6 +73,10 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 
 	fsdev->vdev = vdev;
 
+	/* attach to VFIO */
+	if (bcmfs_attach_vfio(fsdev))
+		goto cleanup;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +6 -0
index 1a4d0cf365..f99d57d4bd 100644
@@ -38,6 +38,12 @@ struct bcmfs_device {
 	char name[BCMFS_DEV_NAME_LEN];
 	/* Parent vdev */
 	struct rte_vdev_device *vdev;
+	/* vfio handle */
+	int vfio_dev_fd;
+	/* mapped address */
+	uint8_t *mmap_addr;
+	/* mapped size */
+	uint32_t mmap_size;
 };
 
 #endif /* _BCMFS_DEVICE_H_ */
drivers/crypto/bcmfs/bcmfs_vfio.c new file +107 -0

107 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_vfio.h new file +17 -0
new file mode 100644
index 0000000000..d0fdf6483f
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_VFIO_H_
+#define _BCMFS_VFIO_H_
+
+/* Attach the bcmfs device to vfio */
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev);
+
+/* Release the bcmfs device from vfio */
+void
+bcmfs_release_vfio(struct bcmfs_device *dev);
+
+#endif /* _BCMFS_VFIO_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index a4bdd8ee5d..fd39eba20e 100644
@@ -6,5 +6,6 @@
 deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
-		'bcmfs_device.c'
+		'bcmfs_device.c',
+		'bcmfs_vfio.c'
 		)
Signature · 1 line
2.17.1
#58 lore raw

PATCH v5 3/8 crypto/bcmfs: add queue pair management API

In reply to Vikas Gupta

Add queue pair management APIs which will be used by Crypto device to manage h/w queues. A bcmfs device structure owns multiple queue-pairs based on the mapped address allocated to it.

---
 drivers/crypto/bcmfs/bcmfs_device.c  |   4 +
 drivers/crypto/bcmfs/bcmfs_device.h  |   5 +
 drivers/crypto/bcmfs/bcmfs_hw_defs.h |  32 +++
 drivers/crypto/bcmfs/bcmfs_qp.c      | 345 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_qp.h      | 122 ++++++++++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 6 files changed, 510 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
drivers/crypto/bcmfs/bcmfs_device.c +4 -0
index 0ccddea202..a01a5c79d5 100644
@@ -12,6 +12,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
@@ -77,6 +78,9 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 	if (bcmfs_attach_vfio(fsdev))
 		goto cleanup;
 
+	/* Maximum number of QPs supported */
+	fsdev->max_hw_qps = fsdev->mmap_size / BCMFS_HW_QUEUE_IO_ADDR_LEN;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +5 -0
index f99d57d4bd..dede5b82dc 100644
@@ -11,6 +11,7 @@
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES		4
@@ -44,6 +45,10 @@ struct bcmfs_device {
 	uint8_t *mmap_addr;
 	/* mapped size */
 	uint32_t mmap_size;
+	/* max number of h/w queue pairs detected */
+	uint16_t max_hw_qps;
+	/* current qpairs in use */
+	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 };
 
 #endif /* _BCMFS_DEVICE_H_ */
drivers/crypto/bcmfs/bcmfs_hw_defs.h new file +32 -0
new file mode 100644
index 0000000000..7d5bb5d8fe
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_HW_DEFS_H_
+#define _BCMFS_HW_DEFS_H_
+
+#include <rte_atomic.h>
+#include <rte_byteorder.h>
+#include <rte_common.h>
+#include <rte_io.h>
+
+#ifndef BIT
+#define BIT(nr)         (1UL << (nr))
+#endif
+
+#define FS_RING_REGS_SIZE		0x10000
+#define FS_RING_DESC_SIZE		8
+#define FS_RING_BD_ALIGN_ORDER		12
+#define FS_RING_BD_DESC_PER_REQ		32
+#define FS_RING_CMPL_ALIGN_ORDER	13
+#define FS_RING_CMPL_SIZE		(1024 * FS_RING_DESC_SIZE)
+#define FS_RING_MAX_REQ_COUNT		1024
+#define FS_RING_PAGE_SHFT		12
+#define FS_RING_PAGE_SIZE		BIT(FS_RING_PAGE_SHFT)
+
+/* Minimum and maximum number of requests supported */
+#define FS_RM_MAX_REQS			4096
+#define FS_RM_MIN_REQS			32
+
+#endif /* BCMFS_HW_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c new file +345 -0

345 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_qp.h new file +122 -0

122 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +2 -1
index fd39eba20e..7e2bcbf14b 100644
@@ -7,5 +7,6 @@ deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
-		'bcmfs_vfio.c'
+		'bcmfs_vfio.c',
+		'bcmfs_qp.c'
 		)
Signature · 1 line
2.17.1
#59 lore raw

PATCH v5 4/8 crypto/bcmfs: add HW queue pair operations

In reply to Vikas Gupta

Add queue pair operations exported by supported devices.

---
 drivers/crypto/bcmfs/bcmfs_dev_msg.h      |  29 +
 drivers/crypto/bcmfs/bcmfs_device.c       |  51 ++
 drivers/crypto/bcmfs/bcmfs_device.h       |  16 +
 drivers/crypto/bcmfs/bcmfs_qp.c           |   1 +
 drivers/crypto/bcmfs/bcmfs_qp.h           |   4 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c       | 743 ++++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c       | 677 ++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c |  82 +++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h |  51 ++
 drivers/crypto/bcmfs/meson.build          |   5 +-
 10 files changed, 1658 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
drivers/crypto/bcmfs/bcmfs_dev_msg.h new file +29 -0
new file mode 100644
index 0000000000..5b50bde35a
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_DEV_MSG_H_
+#define _BCMFS_DEV_MSG_H_
+
+#define MAX_SRC_ADDR_BUFFERS    8
+#define MAX_DST_ADDR_BUFFERS    3
+
+struct bcmfs_qp_message {
+	/** Physical address of each source */
+	uint64_t srcs_addr[MAX_SRC_ADDR_BUFFERS];
+	/** Length of each sources */
+	uint32_t srcs_len[MAX_SRC_ADDR_BUFFERS];
+	/** Total number of sources */
+	unsigned int srcs_count;
+	/** Physical address of each destination */
+	uint64_t dsts_addr[MAX_DST_ADDR_BUFFERS];
+	/** Length of each destination */
+	uint32_t dsts_len[MAX_DST_ADDR_BUFFERS];
+	/** Total number of destinations */
+	unsigned int dsts_count;
+
+	void *ctx;
+};
+
+#endif /* _BCMFS_DEV_MSG_H_ */
drivers/crypto/bcmfs/bcmfs_device.c +51 -0

69 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h +16 -0
index dede5b82dc..2fb8eed143 100644
@@ -8,6 +8,7 @@
 
 #include <sys/queue.h>
 
+#include <rte_spinlock.h>
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
@@ -31,6 +32,19 @@ enum bcmfs_device_type {
 	BCMFS_UNKNOWN
 };
 
+/* A table to store registered queue pair opertations */
+struct bcmfs_hw_queue_pair_ops_table {
+	rte_spinlock_t tl;
+	/* Number of used ops structs in the table. */
+	uint32_t num_ops;
+	 /*  Storage for all possible ops structs. */
+	struct bcmfs_hw_queue_pair_ops qp_ops[BCMFS_MAX_NODES];
+};
+
+/* HW queue pair ops register function */
+int
+bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops *qp_ops);
+
 struct bcmfs_device {
 	TAILQ_ENTRY(bcmfs_device) next;
 	/* Directory path for vfio */
@@ -49,6 +63,8 @@ struct bcmfs_device {
 	uint16_t max_hw_qps;
 	/* current qpairs in use */
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
+	/* queue pair ops exported by symmetric crypto hw */
+	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
 };
 
 #endif /* _BCMFS_DEVICE_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +1 -0
index 864e7bb746..ec1327b780 100644
@@ -227,6 +227,7 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	qp->qpair_id = queue_pair_id;
 	qp->ioreg = qp_conf->iobase;
 	qp->nb_descriptors = nb_descriptors;
+	qp->ops = qp_conf->ops;
 
 	qp->stats.enqueued_count = 0;
 	qp->stats.dequeued_count = 0;
drivers/crypto/bcmfs/bcmfs_qp.h +4 -0
index 52c487956e..59785865b0 100644
@@ -44,6 +44,8 @@ struct bcmfs_qp_config {
 	uint16_t nb_descriptors;
 	/* Maximum number of h/w descriptors needed by a request */
 	uint16_t max_descs_req;
+	/* h/w ops associated with qp */
+	struct bcmfs_hw_queue_pair_ops *ops;
 };
 
 struct bcmfs_queue {
@@ -61,6 +63,8 @@ struct bcmfs_queue {
 		/* s/w pointer for completion h/w queue*/
 		uint32_t cmpl_read_ptr;
 	};
+	/* number of inflight descriptor accumulated  before next db ring */
+	uint16_t descs_inflight;
 	/* Memzone name */
 	char memz_name[RTE_MEMZONE_NAMESIZE];
 };
drivers/crypto/bcmfs/hw/bcmfs4_rm.c new file +743 -0

743 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs5_rm.c new file +677 -0

677 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.c new file +82 -0

82 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.h new file +51 -0

51 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +4 -1
index 7e2bcbf14b..cd58bd5e25 100644
@@ -8,5 +8,8 @@ sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
 		'bcmfs_vfio.c',
-		'bcmfs_qp.c'
+		'bcmfs_qp.c',
+		'hw/bcmfs4_rm.c',
+		'hw/bcmfs5_rm.c',
+		'hw/bcmfs_rm_common.c'
 		)
Signature · 1 line
2.17.1
#60 lore raw

PATCH v5 5/8 crypto/bcmfs: create a symmetric cryptodev

In reply to Vikas Gupta

Create a symmetric crypto device and add supported cryptodev ops.

---
 drivers/crypto/bcmfs/bcmfs_device.c  |  15 ++
 drivers/crypto/bcmfs/bcmfs_device.h  |   6 +
 drivers/crypto/bcmfs/bcmfs_qp.c      |  37 +++
 drivers/crypto/bcmfs/bcmfs_qp.h      |  16 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c | 387 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h |  38 +++
 drivers/crypto/bcmfs/bcmfs_sym_req.h |  22 ++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 8 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
drivers/crypto/bcmfs/bcmfs_device.c +15 -0
index 07423d3cc1..27720e4eb8 100644
@@ -14,6 +14,7 @@
 #include "bcmfs_logs.h"
 #include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
+#include "bcmfs_sym_pmd.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -240,6 +241,7 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 	char out_dirname[BCMFS_MAX_PATH_LEN];
 	uint32_t fsdev_dev[BCMFS_MAX_NODES];
 	enum bcmfs_device_type dtype;
+	int err;
 	int i = 0;
 	int dev_idx;
 	int count = 0;
@@ -291,7 +293,20 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 		return -ENODEV;
 	}
 
+	err = bcmfs_sym_dev_create(fsdev);
+	if (err) {
+		BCMFS_LOG(WARNING,
+			  "Failed to create BCMFS SYM PMD for device %s",
+			  fsdev->name);
+		goto pmd_create_fail;
+	}
+
 	return 0;
+
+pmd_create_fail:
+	fsdev_release(fsdev);
+
+	return err;
 }
 
 static int
drivers/crypto/bcmfs/bcmfs_device.h +6 -0
index 2fb8eed143..e5ca866977 100644
@@ -65,6 +65,12 @@ struct bcmfs_device {
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 	/* queue pair ops exported by symmetric crypto hw */
 	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
+	/* a cryptodevice attached to bcmfs device */
+	struct rte_cryptodev *cdev;
+	/* a rte_device to register with cryptodev */
+	struct rte_device sym_rte_dev;
+	/* private info to keep with cryptodev */
+	struct bcmfs_sym_dev_private *sym_dev;
 };
 
 #endif /* _BCMFS_DEVICE_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +37 -0
index ec1327b780..cb5ff6c61b 100644
@@ -344,3 +344,40 @@ bcmfs_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops)
 
 	return deq;
 }
+
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats)
+{
+	int i;
+
+	if (stats == NULL) {
+		BCMFS_LOG(ERR, "invalid param: stats %p",
+			  stats);
+		return;
+	}
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+
+		stats->enqueued_count += qp[i]->stats.enqueued_count;
+		stats->dequeued_count += qp[i]->stats.dequeued_count;
+		stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
+		stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
+	}
+}
+
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp)
+{
+	int i;
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+		memset(&qp[i]->stats, 0, sizeof(qp[i]->stats));
+	}
+}
drivers/crypto/bcmfs/bcmfs_qp.h +16 -0
index 59785865b0..57fe0a93a3 100644
@@ -24,6 +24,13 @@ enum bcmfs_queue_type {
 	BCMFS_RM_CPLQ
 };
 
+#define BCMFS_QP_IOBASE_XLATE(base, idx)	\
+		((base) + ((idx) * BCMFS_HW_QUEUE_IO_ADDR_LEN))
+
+/* Max pkts for preprocessing before submitting to h/w qp */
+#define BCMFS_MAX_REQS_BUFF	64
+
+/* qp stats */
 struct bcmfs_qp_stats {
 	/* Count of all operations enqueued */
 	uint64_t enqueued_count;
@@ -92,6 +99,10 @@ struct bcmfs_qp {
 	struct bcmfs_qp_stats stats;
 	/* h/w ops associated with qp */
 	struct bcmfs_hw_queue_pair_ops *ops;
+	/* bcmfs requests pool*/
+	struct rte_mempool *sr_mp;
+	/* a temporary buffer to keep message pointers */
+	struct bcmfs_qp_message *infl_msgs[BCMFS_MAX_REQS_BUFF];
 
 } __rte_cache_aligned;
 
@@ -123,4 +134,9 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	       uint16_t queue_pair_id,
 	       struct bcmfs_qp_config *bcmfs_conf);
 
+/* stats functions*/
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats);
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp);
+
 #endif /* _BCMFS_QP_H_ */
drivers/crypto/bcmfs/bcmfs_sym_pmd.c new file +387 -0

387 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.h new file +38 -0
new file mode 100644
index 0000000000..65d7046090
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_PMD_H_
+#define _BCMFS_SYM_PMD_H_
+
+#include <rte_cryptodev.h>
+
+#include "bcmfs_device.h"
+
+#define CRYPTODEV_NAME_BCMFS_SYM_PMD	crypto_bcmfs
+
+#define BCMFS_CRYPTO_MAX_HW_DESCS_PER_REQ	16
+
+extern uint8_t cryptodev_bcmfs_driver_id;
+
+/** private data structure for a BCMFS device.
+ *  This BCMFS device is a device offering only symmetric crypto service,
+ *  there can be one of these on each bcmfs_pci_device (VF).
+ */
+struct bcmfs_sym_dev_private {
+	/* The bcmfs device hosting the service */
+	struct bcmfs_device *fsdev;
+	/* Device instance for this rte_cryptodev */
+	uint8_t sym_dev_id;
+	/* BCMFS device symmetric crypto capabilities */
+	const struct rte_cryptodev_capabilities *fsdev_capabilities;
+};
+
+int
+bcmfs_sym_dev_create(struct bcmfs_device *fdev);
+
+int
+bcmfs_sym_dev_destroy(struct bcmfs_device *fdev);
+
+#endif /* _BCMFS_SYM_PMD_H_ */
drivers/crypto/bcmfs/bcmfs_sym_req.h new file +22 -0
new file mode 100644
index 0000000000..0f0b051f1e
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_REQ_H_
+#define _BCMFS_SYM_REQ_H_
+
+#include "bcmfs_dev_msg.h"
+
+/*
+ * This structure hold the supportive data required to process a
+ * rte_crypto_op
+ */
+struct bcmfs_sym_request {
+	/* bcmfs qp message for h/w queues to process */
+	struct bcmfs_qp_message msgs;
+	/* crypto op */
+	struct rte_crypto_op *op;
+};
+
+#endif /* _BCMFS_SYM_REQ_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index cd58bd5e25..d9a3d73e99 100644
@@ -11,5 +11,6 @@ sources = files(
 		'bcmfs_qp.c',
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
-		'hw/bcmfs_rm_common.c'
+		'hw/bcmfs_rm_common.c',
+		'bcmfs_sym_pmd.c'
 		)
Signature · 1 line
2.17.1
#61 lore raw

PATCH v5 6/8 crypto/bcmfs: add session handling and capabilities

In reply to Vikas Gupta

Add session handling and capabilities supported by crypto HW accelerator

---
 doc/guides/cryptodevs/bcmfs.rst               |  47 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |  56 ++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c | 764 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         |  34 +
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          |  13 +
 drivers/crypto/bcmfs/bcmfs_sym_session.c      | 282 +++++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      | 109 +++
 drivers/crypto/bcmfs/meson.build              |   4 +-
 9 files changed, 1324 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
doc/guides/cryptodevs/bcmfs.rst +47 -0
index 6b68673df0..f7e15f4cfb 100644
@@ -15,6 +15,47 @@ Supported Broadcom SoCs
 * Stingray
 * Stingray2
 
+Features
+--------
+
+The BCMFS SYM PMD has support for:
+
+Cipher algorithms:
+
+* ``RTE_CRYPTO_CIPHER_3DES_CBC``
+* ``RTE_CRYPTO_CIPHER_3DES_CTR``
+* ``RTE_CRYPTO_CIPHER_AES128_CBC``
+* ``RTE_CRYPTO_CIPHER_AES192_CBC``
+* ``RTE_CRYPTO_CIPHER_AES256_CBC``
+* ``RTE_CRYPTO_CIPHER_AES128_CTR``
+* ``RTE_CRYPTO_CIPHER_AES192_CTR``
+* ``RTE_CRYPTO_CIPHER_AES256_CTR``
+* ``RTE_CRYPTO_CIPHER_AES_XTS``
+* ``RTE_CRYPTO_CIPHER_DES_CBC``
+
+Hash algorithms:
+
+* ``RTE_CRYPTO_AUTH_SHA1``
+* ``RTE_CRYPTO_AUTH_SHA1_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA224``
+* ``RTE_CRYPTO_AUTH_SHA224_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA256``
+* ``RTE_CRYPTO_AUTH_SHA256_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA384``
+* ``RTE_CRYPTO_AUTH_SHA384_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA512``
+* ``RTE_CRYPTO_AUTH_SHA512_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_XCBC_MAC``
+* ``RTE_CRYPTO_AUTH_AES_CBC_MAC``
+* ``RTE_CRYPTO_AUTH_MD5_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_GMAC``
+* ``RTE_CRYPTO_AUTH_AES_CMAC``
+
+Supported AEAD algorithms:
+
+* ``RTE_CRYPTO_AEAD_AES_GCM``
+* ``RTE_CRYPTO_AEAD_AES_CCM``
+
 Installation
 ------------
 Information about kernel, rootfs and toolchain can be found at
@@ -49,3 +90,9 @@ For example, below commands can be run to get hold of a device node by VFIO.
     io_device_name="vfio-platform"
     echo $io_device_name > /sys/bus/platform/devices/${SETUP_SYSFS_DEV_NAME}/driver_override
     echo ${SETUP_SYSFS_DEV_NAME} > /sys/bus/platform/drivers_probe
+
+Limitations
+-----------
+
+* Only supports the session-oriented API implementation (session-less APIs are not supported).
+* CCM is not supported on Broadcom`s SoCs having FlexSparc4 unit.
doc/guides/cryptodevs/features/bcmfs.ini new file +56 -0

56 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.c new file +764 -0

764 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.h new file +16 -0
new file mode 100644
index 0000000000..3ff61b7d29
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_CAPABILITIES_H_
+#define _BCMFS_SYM_CAPABILITIES_H_
+
+/*
+ * Get capabilities list for the device
+ *
+ */
+const struct rte_cryptodev_capabilities *bcmfs_sym_get_capabilities(void);
+
+#endif /* _BCMFS_SYM_CAPABILITIES_H__ */
+
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +34 -0
new file mode 100644
index 0000000000..aea1f281e4
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_DEFS_H_
+#define _BCMFS_SYM_DEFS_H_
+
+/*
+ * Max block size of hash algorithm
+ * currently SHA3 supports max block size
+ * of 144 bytes
+ */
+#define BCMFS_MAX_KEY_SIZE	144
+#define BCMFS_MAX_IV_SIZE	16
+#define BCMFS_MAX_DIGEST_SIZE	64
+
+struct bcmfs_sym_session;
+struct bcmfs_sym_request;
+
+/** Crypto Request processing successful. */
+#define BCMFS_SYM_RESPONSE_SUCCESS               (0)
+/** Crypot Request processing protocol failure. */
+#define BCMFS_SYM_RESPONSE_PROTO_FAILURE         (1)
+/** Crypot Request processing completion failure. */
+#define BCMFS_SYM_RESPONSE_COMPL_ERROR           (2)
+/** Crypot Request processing hash tag check error. */
+#define BCMFS_SYM_RESPONSE_HASH_TAG_ERROR        (3)
+
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req);
+#endif /* _BCMFS_SYM_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_sym_pmd.c +13 -0
index 0f96915f70..381ca8ea48 100644
@@ -14,6 +14,8 @@
 #include "bcmfs_qp.h"
 #include "bcmfs_sym_pmd.h"
 #include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+#include "bcmfs_sym_capabilities.h"
 
 uint8_t cryptodev_bcmfs_driver_id;
 
@@ -65,6 +67,7 @@ bcmfs_sym_dev_info_get(struct rte_cryptodev *dev,
 		dev_info->max_nb_queue_pairs = fsdev->max_hw_qps;
 		/* No limit of number of sessions */
 		dev_info->sym.max_nb_sessions = 0;
+		dev_info->capabilities = bcmfs_sym_get_capabilities();
 	}
 }
 
@@ -228,6 +231,10 @@ static struct rte_cryptodev_ops crypto_bcmfs_ops = {
 	/* Queue-Pair management */
 	.queue_pair_setup       = bcmfs_sym_qp_setup,
 	.queue_pair_release     = bcmfs_sym_qp_release,
+	/* Crypto session related operations */
+	.sym_session_get_size   = bcmfs_sym_session_get_private_size,
+	.sym_session_configure  = bcmfs_sym_session_configure,
+	.sym_session_clear      = bcmfs_sym_session_clear
 };
 
 /** Enqueue burst */
@@ -239,6 +246,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	int i, j;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
+	struct bcmfs_sym_session *sess;
 	struct bcmfs_qp *qp = (struct bcmfs_qp *)queue_pair;
 
 	if (nb_ops == 0)
@@ -252,6 +260,10 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		nb_ops = qp->nb_descriptors - qp->nb_pending_requests;
 
 	for (i = 0; i < nb_ops; i++) {
+		sess = bcmfs_sym_get_session(ops[i]);
+		if (unlikely(sess == NULL))
+			goto enqueue_err;
+
 		if (rte_mempool_get(qp->sr_mp, (void **)&sreq))
 			goto enqueue_err;
 
@@ -356,6 +368,7 @@ bcmfs_sym_dev_create(struct bcmfs_device *fsdev)
 	fsdev->sym_dev = internals;
 
 	internals->sym_dev_id = cryptodev->data->dev_id;
+	internals->fsdev_capabilities = bcmfs_sym_get_capabilities();
 
 	BCMFS_LOG(DEBUG, "Created bcmfs-sym device %s as cryptodev instance %d",
 		  cryptodev->data->name, internals->sym_dev_id);
drivers/crypto/bcmfs/bcmfs_sym_session.c new file +282 -0

282 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_session.h new file +109 -0

109 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +3 -1
index d9a3d73e99..2e86c733e1 100644
@@ -12,5 +12,7 @@ sources = files(
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
 		'hw/bcmfs_rm_common.c',
-		'bcmfs_sym_pmd.c'
+		'bcmfs_sym_pmd.c',
+		'bcmfs_sym_capabilities.c',
+		'bcmfs_sym_session.c'
 		)
Signature · 1 line
2.17.1
#62 lore raw

PATCH v5 7/8 crypto/bcmfs: add crypto HW module

In reply to Vikas Gupta

Add crypto h/w module to process crypto op. Crypto op is processed via sym_engine module before submitting the crypto request to HW queues.

---
 drivers/crypto/bcmfs/bcmfs_sym.c        |  289 ++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.c | 1155 +++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h |  115 +++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c    |   26 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h    |   40 +
 drivers/crypto/bcmfs/meson.build        |    4 +-
 6 files changed, 1628 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
drivers/crypto/bcmfs/bcmfs_sym.c new file +289 -0
new file mode 100644
index 0000000000..2d164a1ec8
@@ -0,0 +1,289 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <stdbool.h>
+
+#include <rte_byteorder.h>
+#include <rte_crypto_sym.h>
+#include <rte_cryptodev.h>
+#include <rte_mbuf.h>
+#include <rte_mempool.h>
+
+#include "bcmfs_sym_defs.h"
+#include "bcmfs_sym_engine.h"
+#include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+
+/** Process cipher operation */
+static int
+process_crypto_cipher_op(struct rte_crypto_op *op,
+			 struct rte_mbuf *mbuf_src,
+			 struct rte_mbuf *mbuf_dst,
+			 struct bcmfs_sym_session *sess,
+			 struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv, key;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+	fsattr_pa(&dst) = rte_pktmbuf_iova(mbuf_dst);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						   uint8_t *,
+						   sess->cipher.iv.offset);
+
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&key) = sess->cipher.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->cipher.key.length;
+
+	rc = bcmfs_crypto_build_cipher_req(req, sess->cipher.algo,
+					   sess->cipher.op, &src,
+					   &dst, &key, &iv);
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process auth operation */
+static int
+process_crypto_auth_op(struct rte_crypto_op *op,
+		       struct rte_mbuf *mbuf_src,
+		       struct bcmfs_sym_session *sess,
+		       struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, mac, key, iv;
+
+	fsattr_sz(&src) = op->sym->auth.data.length;
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset(mbuf_src,
+						  uint8_t *,
+						  op->sym->auth.data.offset);
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+
+	if (!sess->auth.op) {
+		fsattr_va(&mac) = op->sym->auth.digest.data;
+		fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&mac) = sess->auth.digest_length;
+	} else {
+		fsattr_va(&dst) = op->sym->auth.digest.data;
+		fsattr_pa(&dst) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&dst) = sess->auth.digest_length;
+	}
+
+	fsattr_va(&key) = sess->auth.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->auth.key.length;
+
+	/* AES-GMAC uses AES-GCM-128 authenticator */
+	if (sess->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC) {
+		fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+							   uint8_t *,
+							   sess->auth.iv.offset);
+		fsattr_pa(&iv) = 0;
+		fsattr_sz(&iv) = sess->auth.iv.length;
+	} else {
+		fsattr_va(&iv) = NULL;
+		fsattr_sz(&iv) = 0;
+	}
+
+		rc = bcmfs_crypto_build_auth_req(req, sess->auth.algo,
+						 sess->auth.op,
+						 &src,
+						 (sess->auth.op) ? (&dst) : NULL,
+						 (sess->auth.op) ? NULL  : (&mac),
+						 &key, &iv);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process combined/chained mode operation */
+static int
+process_crypto_combined_op(struct rte_crypto_op *op,
+			   struct rte_mbuf *mbuf_src,
+			   struct rte_mbuf *mbuf_dst,
+			   struct bcmfs_sym_session *sess,
+			   struct bcmfs_sym_request *req)
+{
+	int rc = 0, aad_size = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr cipher_key, aad, mac, auth_key;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						  sym_op->cipher.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						  sym_op->cipher.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						   uint8_t *,
+						   sess->cipher.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&cipher_key) = sess->cipher.key.data;
+	fsattr_pa(&cipher_key) = 0;
+	fsattr_sz(&cipher_key) = sess->cipher.key.length;
+
+	fsattr_va(&auth_key) = sess->auth.key.data;
+	fsattr_pa(&auth_key) = 0;
+	fsattr_sz(&auth_key) = sess->auth.key.length;
+
+	fsattr_va(&mac) = op->sym->auth.digest.data;
+	fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+	fsattr_sz(&mac) = sess->auth.digest_length;
+
+	aad_size = sym_op->auth.data.length - sym_op->cipher.data.length;
+
+	if (aad_size > 0) {
+		fsattr_sz(&aad) =  aad_size;
+		fsattr_va(&aad) = rte_pktmbuf_mtod_offset
+						(mbuf_src,
+						 uint8_t *,
+						sym_op->auth.data.offset);
+		fsattr_pa(&aad) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->auth.data.offset);
+	}
+
+	rc = bcmfs_crypto_build_chain_request(req, sess->cipher.algo,
+					      sess->cipher.op,
+					      sess->auth.algo,
+					      sess->auth.op,
+					      &src, &dst, &cipher_key,
+					      &auth_key, &iv,
+					      (aad_size > 0) ? (&aad) : NULL,
+					      &mac, sess->cipher_first);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process AEAD operation */
+static int
+process_crypto_aead_op(struct rte_crypto_op *op,
+		       struct rte_mbuf *mbuf_src,
+		       struct rte_mbuf *mbuf_dst,
+		       struct bcmfs_sym_session *sess,
+		       struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr key, aad, mac;
+
+	fsattr_sz(&src) = sym_op->aead.data.length;
+	fsattr_sz(&dst) = sym_op->aead.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset(mbuf_src,
+						  uint8_t *,
+						  sym_op->aead.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset(mbuf_dst,
+						  uint8_t *,
+						  sym_op->aead.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						  sym_op->aead.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						  sym_op->aead.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						   uint8_t *,
+						   sess->aead.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->aead.iv.length;
+
+	fsattr_va(&key) = sess->aead.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->aead.key.length;
+
+	fsattr_va(&mac) = op->sym->aead.digest.data;
+	fsattr_pa(&mac) = op->sym->aead.digest.phys_addr;
+	fsattr_sz(&mac) = sess->aead.digest_length;
+
+	fsattr_va(&aad) = op->sym->aead.aad.data;
+	fsattr_pa(&aad) = op->sym->aead.aad.phys_addr;
+	fsattr_sz(&aad) = sess->aead.aad_length;
+
+	rc = bcmfs_crypto_build_aead_request(req, sess->aead.algo,
+					     sess->aead.op, &src, &dst,
+					     &key, &iv, &aad, &mac);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process crypto operation for mbuf */
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req)
+{
+	struct rte_mbuf *msrc, *mdst;
+	int rc = 0;
+
+	msrc = op->sym->m_src;
+	mdst = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src;
+	op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+
+	switch (sess->chain_order) {
+	case BCMFS_SYM_CHAIN_ONLY_CIPHER:
+		rc = process_crypto_cipher_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_ONLY_AUTH:
+		rc = process_crypto_auth_op(op, msrc, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_CIPHER_AUTH:
+	case BCMFS_SYM_CHAIN_AUTH_CIPHER:
+		rc = process_crypto_combined_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_AEAD:
+		rc = process_crypto_aead_op(op, msrc, mdst, sess, req);
+		break;
+	default:
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+		break;
+	}
+
+	return rc;
+}
drivers/crypto/bcmfs/bcmfs_sym_engine.c new file +1155 -0

1,155 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_engine.h new file +115 -0

115 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.c +26 -0
index 381ca8ea48..568797b4fd 100644
@@ -132,6 +132,12 @@ static void
 spu_req_init(struct bcmfs_sym_request *sr, rte_iova_t iova __rte_unused)
 {
 	memset(sr, 0, sizeof(*sr));
+	sr->fptr = iova;
+	sr->cptr = iova + offsetof(struct bcmfs_sym_request, cipher_key);
+	sr->aptr = iova + offsetof(struct bcmfs_sym_request, auth_key);
+	sr->iptr = iova + offsetof(struct bcmfs_sym_request, iv);
+	sr->dptr = iova + offsetof(struct bcmfs_sym_request, digest);
+	sr->rptr = iova + offsetof(struct bcmfs_sym_request, resp);
 }
 
 static void
@@ -244,6 +250,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 			       uint16_t nb_ops)
 {
 	int i, j;
+	int retval;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
 	struct bcmfs_sym_session *sess;
@@ -273,6 +280,11 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		/* save context */
 		qp->infl_msgs[i] = &sreq->msgs;
 		qp->infl_msgs[i]->ctx = (void *)sreq;
+
+		/* pre process the request crypto h/w acceleration */
+		retval = bcmfs_process_sym_crypto_op(ops[i], sess, sreq);
+		if (unlikely(retval < 0))
+			goto enqueue_err;
 	}
 	/* Send burst request to hw QP */
 	enq = bcmfs_enqueue_op_burst(qp, (void **)qp->infl_msgs, i);
@@ -289,6 +301,17 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	return enq;
 }
 
+static void bcmfs_sym_set_request_status(struct rte_crypto_op *op,
+					 struct bcmfs_sym_request *out)
+{
+	if (*out->resp == BCMFS_SYM_RESPONSE_SUCCESS)
+		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+	else if (*out->resp == BCMFS_SYM_RESPONSE_HASH_TAG_ERROR)
+		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+	else
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+}
+
 static uint16_t
 bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 			       struct rte_crypto_op **ops,
@@ -308,6 +331,9 @@ bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 	for (i = 0; i < deq; i++) {
 		sreq = (struct bcmfs_sym_request *)qp->infl_msgs[i]->ctx;
 
+		/* set the status based on the response from the crypto h/w */
+		bcmfs_sym_set_request_status(sreq->op, sreq);
+
 		ops[pkts++] = sreq->op;
 
 		rte_mempool_put(qp->sr_mp, sreq);
drivers/crypto/bcmfs/bcmfs_sym_req.h +40 -0
index 0f0b051f1e..e53c50adc1 100644
@@ -6,13 +6,53 @@
 #ifndef _BCMFS_SYM_REQ_H_
 #define _BCMFS_SYM_REQ_H_
 
+#include <rte_cryptodev.h>
+
 #include "bcmfs_dev_msg.h"
+#include "bcmfs_sym_defs.h"
+
+/* Fixed SPU2 Metadata */
+struct spu2_fmd {
+	uint64_t ctrl0;
+	uint64_t ctrl1;
+	uint64_t ctrl2;
+	uint64_t ctrl3;
+};
 
 /*
  * This structure hold the supportive data required to process a
  * rte_crypto_op
  */
 struct bcmfs_sym_request {
+	/* spu2 engine related data */
+	struct spu2_fmd fmd;
+	/* cipher key */
+	uint8_t cipher_key[BCMFS_MAX_KEY_SIZE];
+	/* auth key */
+	uint8_t auth_key[BCMFS_MAX_KEY_SIZE];
+	/* iv key */
+	uint8_t iv[BCMFS_MAX_IV_SIZE];
+	/* digest data output from crypto h/w */
+	uint8_t digest[BCMFS_MAX_DIGEST_SIZE];
+	/* 2-Bytes response from crypto h/w */
+	uint8_t resp[2];
+	/*
+	 * Below are all iovas for above members
+	 * from top
+	 */
+	/* iova for fmd */
+	rte_iova_t fptr;
+	/* iova for cipher key */
+	rte_iova_t cptr;
+	/* iova for auth key */
+	rte_iova_t aptr;
+	/* iova for iv key */
+	rte_iova_t iptr;
+	/* iova for digest */
+	rte_iova_t dptr;
+	/* iova for response */
+	rte_iova_t rptr;
+
 	/* bcmfs qp message for h/w queues to process */
 	struct bcmfs_qp_message msgs;
 	/* crypto op */
drivers/crypto/bcmfs/meson.build +3 -1
index 2e86c733e1..7aa0f05dbd 100644
@@ -14,5 +14,7 @@ sources = files(
 		'hw/bcmfs_rm_common.c',
 		'bcmfs_sym_pmd.c',
 		'bcmfs_sym_capabilities.c',
-		'bcmfs_sym_session.c'
+		'bcmfs_sym_session.c',
+		'bcmfs_sym.c',
+		'bcmfs_sym_engine.c'
 		)
Signature · 1 line
2.17.1
#63 lore raw

PATCH v5 8/8 crypto/bcmfs: add crypto pmd into cryptodev test

In reply to Vikas Gupta

Add global test suite for bcmfs crypto pmd

---
 app/test/test_cryptodev.c       | 17 +++++++++++++++++
 app/test/test_cryptodev.h       |  1 +
 doc/guides/cryptodevs/bcmfs.rst | 11 +++++++++++
 3 files changed, 29 insertions(+)
app/test/test_cryptodev.c +17 -0
index 70bf6fe2c1..9157115ab3 100644
@@ -13041,6 +13041,22 @@ test_cryptodev_nitrox(void)
 	return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
 }
 
+static int
+test_cryptodev_bcmfs(void)
+{
+	gbl_driver_id =	rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
+
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded. Check if "
+				"CONFIG_RTE_LIBRTE_PMD_BCMFS is enabled "
+				"in config file to run this testsuite.\n");
+		return TEST_FAILED;
+	}
+
+	return unit_test_suite_runner(&cryptodev_testsuite);
+}
+
 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
@@ -13063,3 +13079,4 @@ REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
+REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
app/test/test_cryptodev.h +1 -0
index 41542e0552..c58126368c 100644
@@ -70,6 +70,7 @@
 #define CRYPTODEV_NAME_OCTEONTX2_PMD	crypto_octeontx2
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 #define CRYPTODEV_NAME_NITROX_PMD	crypto_nitrox_sym
+#define CRYPTODEV_NAME_BCMFS_PMD	crypto_bcmfs
 
 /**
  * Write (spread) data from buffer to mbuf data
doc/guides/cryptodevs/bcmfs.rst +11 -0
index f7e15f4cfb..5a7eb23c0f 100644
@@ -96,3 +96,14 @@ Limitations
 
 * Only supports the session-oriented API implementation (session-less APIs are not supported).
 * CCM is not supported on Broadcom`s SoCs having FlexSparc4 unit.
+
+Testing
+-------
+
+The symmetric crypto operations on BCMFS crypto PMD may be verified by running the test
+application:
+
+.. code-block:: console
+
+    ./test
+    RTE>>cryptodev_bcmfs_autotest
Signature · 1 line
2.17.1
#64 lore raw

Re: [dpdk-dev] [PATCH v5 8/8] crypto/bcmfs: add crypto pmd into cryptodev test

Hi Vikas,

Quoted 30 lines

Add global test suite for bcmfs crypto pmd

---
 app/test/test_cryptodev.c       | 17 +++++++++++++++++
 app/test/test_cryptodev.h       |  1 +
 doc/guides/cryptodevs/bcmfs.rst | 11 +++++++++++
 3 files changed, 29 insertions(+)
app/test/test_cryptodev.c +9 -0
index 70bf6fe2c1..9157115ab3 100644
@@ -13041,6 +13041,22 @@ test_cryptodev_nitrox(void)
 	return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
 }
 
+static int
+test_cryptodev_bcmfs(void)
+{
+	gbl_driver_id =	rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
+
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded. Check if "
+				"CONFIG_RTE_LIBRTE_PMD_BCMFS is enabled

"

app/test/test_cryptodev.c test_cryptodev_nitrox(void) · line 13053

Quoted 1 line
app/test/test_cryptodev.c +1 -0
+				"in config file to run this testsuite.\n");

Modified this LOG print message to remove the config. Configs are no longer used.

Quoted 48 lines
app/test/test_cryptodev.c +6 -0
+		return TEST_FAILED;
+	}
+
+	return unit_test_suite_runner(&cryptodev_testsuite);
+}
+
 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest,

test_cryptodev_aesni_mb);
REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,

app/test/test_cryptodev.c +0 -0
@@ -13063,3 +13079,4 @@
 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest,
 test_cryptodev_octeontx);
 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest,

test_cryptodev_octeontx2);
REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest,
test_cryptodev_caam_jr);
REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest,
test_cryptodev_nitrox); +REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);

app/test/test_cryptodev.h +1 -0
index 41542e0552..c58126368c 100644
@@ -70,6 +70,7 @@
 #define CRYPTODEV_NAME_OCTEONTX2_PMD	crypto_octeontx2
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 #define CRYPTODEV_NAME_NITROX_PMD	crypto_nitrox_sym
+#define CRYPTODEV_NAME_BCMFS_PMD	crypto_bcmfs
 
 /**
  * Write (spread) data from buffer to mbuf data
doc/guides/cryptodevs/bcmfs.rst +0 -0
index f7e15f4cfb..5a7eb23c0f 100644
@@ -96,3 +96,14 @@ Limitations
 
 * Only supports the session-oriented API implementation (session-less APIs are

not supported).
* CCM is not supported on Broadcom`s SoCs having FlexSparc4 unit.

doc/guides/cryptodevs/bcmfs.rst +5 -0
+
+Testing
+-------
+
+The symmetric crypto operations on BCMFS crypto PMD may be verified by

running the test

doc/guides/cryptodevs/bcmfs.rst Limitations · line 108

Quoted 5 lines
doc/guides/cryptodevs/bcmfs.rst +5 -0
+application:
+
+.. code-block:: console
+
+    ./test

This has been changed to ./dpdk-test

Quoted 3 lines

+ RTE>>cryptodev_bcmfs_autotest
--
2.17.1

#65 lore raw
In reply to Vikas Gupta
Quoted 41 lines

Hi,
This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.
BCMFS is an acronym for Broadcom FlexSparc device used in the patchest.

The patchset progressively adds major modules as below.
a) Detection of platform-device based on the known registered platforms and attaching with VFIO.
b) Creation of Cryptodevice.
c) Addition of session handling.
d) Add Cryptodevice into test Cryptodev framework.

The patchset has been tested on the above mentioned SoCs.

Regards,
Vikas

Changes from v0->v1:
Updated the ABI version in
file .../crypto/bcmfs/rte_pmd_bcmfs_version.map

Changes from v1->v2:
- Fix compilation errors and coding style warnings.
- Use global test crypto suite suggested by Adam Dybkowski

Changes from v2->v3:
- Release notes updated.
- bcmfs.rst updated with missing information about installation.
- Review comments from patch1 from v2 addressed.
- Updated description about dependency of PMD driver on
VFIO_PRESENT.
- Fixed typo in bcmfs_hw_defs.h (comments on patch3 from v2
addressed)
- Comments on patch6 from v2 addressed and capability list is fixed. Removed redundant enums and macros from the file bcmfs_sym_defs.h and updated other impacted APIs
accordingly.
patch7 too is updated due to removal of redundancy.
Thanks! to Akhil for pointing out the redundancy.
- Fix minor code style issues in few files as part of review.

Quoted 7 lines

Changes from v3->v4:
- Code style issues fixed.
- Change of barrier API in bcmfs4_rm.c and bcmfs5_rm.c

Changes from v4->v5:
- Change of barrier API in bcmfs4_rm.c. Missed one in v4

Series applied to dpdk-next-crypto With 2 fixes as mentioned in the last patch.

Thanks.

#66 lore raw

09/10/2020 17:00, Akhil Goyal:

Quoted 2 lines
Quoted 2 lines

This patchset contains support for Crypto offload on Broadcom’s Stingray/Stingray2 SoCs having FlexSparc unit.

[...]

Quoted 1 line

Series applied to dpdk-next-crypto With 2 fixes as mentioned in the last patch.

There are 2 errors in the doc:

Warning generate_overview_table(): Unknown feature 'AES CBC MAC' in 'bcmfs.ini' Warning generate_overview_table(): File 'bcmfs.ini' has no [Asymmetric] secton

Please send a patch to fix.

#67 lore raw

PATCH 1/8 crypto/bcmfs: add BCMFS driver

In reply to Vikas Gupta

Add Broadcom FlexSparc(FS) device creation driver which registers to a vdev and create a device. Add APIs for logs, supportive documention and maintainers file.

---
 MAINTAINERS                                   |   7 +
 config/common_base                            |   5 +
 doc/guides/cryptodevs/bcmfs.rst               |  26 ++
 doc/guides/cryptodevs/index.rst               |   1 +
 drivers/crypto/bcmfs/Makefile                 |  27 ++
 drivers/crypto/bcmfs/bcmfs_device.c           | 256 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_device.h           |  40 +++
 drivers/crypto/bcmfs/bcmfs_logs.c             |  38 +++
 drivers/crypto/bcmfs/bcmfs_logs.h             |  34 +++
 drivers/crypto/bcmfs/meson.build              |  10 +
 .../crypto/bcmfs/rte_pmd_bcmfs_version.map    |   3 +
 drivers/crypto/meson.build                    |   3 +-
 mk/rte.app.mk                                 |   1 +
 13 files changed, 450 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/bcmfs.rst
 create mode 100644 drivers/crypto/bcmfs/Makefile
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_device.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_logs.h
 create mode 100644 drivers/crypto/bcmfs/meson.build
 create mode 100644 drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map
MAINTAINERS +7 -0
index 3cd402b34..7c2d7ff1b 100644
@@ -1099,6 +1099,13 @@ F: drivers/crypto/zuc/
 F: doc/guides/cryptodevs/zuc.rst
 F: doc/guides/cryptodevs/features/zuc.ini
 
+Broadcom FlexSparc
+M: Vikas Gupta  <vikas.gupta@@broadcom.com>
+M: Raveendra Padasalagi <[email protected]>
+M: Ajit Khaparde <[email protected]>
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 -------------------
config/common_base +5 -0
index f7a8824f5..21daadcdd 100644
@@ -705,6 +705,11 @@ CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO=n
 #
 CONFIG_RTE_LIBRTE_PMD_NITROX=y
 
+#
+# Compile PMD for Broadcom crypto device
+#
+CONFIG_RTE_LIBRTE_PMD_BCMFS=y
+
 #
 # Compile generic security library
 #
doc/guides/cryptodevs/bcmfs.rst new file +26 -0
new file mode 100644
index 000000000..752ce028a
@@ -0,0 +1,26 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(C) 2020 Broadcom
+
+Broadcom FlexSparc Crypto Poll Mode Driver
+==========================================
+
+The FlexSparc crypto poll mode driver provides support for offloading
+cryptographic operations to the Broadcom SoCs having FlexSparc4/FlexSparc5 unit.
+Detailed information about SoCs can be found in
+
+* https://www.broadcom.com/
+
+Installation
+------------
+
+For compiling the Broadcom FlexSparc crypto PMD, please check if the
+CONFIG_RTE_LIBRTE_PMD_BCMFS setting is set to `y` in config/common_base file.
+
+* ``CONFIG_RTE_LIBRTE_PMD_BCMFS=y``
+
+Initialization
+--------------
+BCMFS crypto PMD depend upon the devices present in the path
+/sys/bus/platform/devices/fs<version>/<dev_name> on the platform.
+Each cryptodev PMD instance can be attached to the nodes present
+in the mentioned path.
doc/guides/cryptodevs/index.rst +1 -0
index a67ed5a28..5d7e028bd 100644
@@ -29,3 +29,4 @@ Crypto Device Drivers
     qat
     virtio
     zuc
+    bcmfs
drivers/crypto/bcmfs/Makefile new file +27 -0
new file mode 100644
index 000000000..781ee6efa
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2020 Broadcom
+# All rights reserved.
+#
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_bcmfs.a
+
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/crypto/bcmfs
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-y += bcmfs_logs.c
+SRCS-y += bcmfs_device.c
+
+LDLIBS += -lrte_eal -lrte_bus_vdev
+
+EXPORT_MAP := rte_pmd_bcmfs_version.map
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/crypto/bcmfs/bcmfs_device.c new file +256 -0

256 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h new file +40 -0
new file mode 100644
index 000000000..4b0c6d3ca
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_DEV_H_
+#define _BCMFS_DEV_H_
+
+#include <sys/queue.h>
+
+#include <rte_bus_vdev.h>
+
+#include "bcmfs_logs.h"
+
+/* max number of dev nodes */
+#define BCMFS_MAX_NODES		4
+#define BCMFS_MAX_PATH_LEN	512
+#define BCMFS_DEV_NAME_LEN	64
+
+/* Path for BCM-Platform device directory */
+#define SYSFS_BCM_PLTFORM_DEVICES    "/sys/bus/platform/devices"
+
+/* Supported devices */
+enum bcmfs_device_type {
+	BCMFS_SYM_FS4,
+	BCMFS_SYM_FS5,
+	BCMFS_UNKNOWN
+};
+
+struct bcmfs_device {
+	TAILQ_ENTRY(bcmfs_device) next;
+	/* Directoy path for vfio */
+	char dirname[BCMFS_MAX_PATH_LEN];
+	/* BCMFS device name */
+	char name[BCMFS_DEV_NAME_LEN];
+	/* Parent vdev */
+	struct rte_vdev_device *vdev;
+};
+
+#endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_logs.c new file +38 -0
new file mode 100644
index 000000000..86f4ff3b5
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <rte_log.h>
+#include <rte_hexdump.h>
+
+#include "bcmfs_logs.h"
+
+int bcmfs_conf_logtype;
+int bcmfs_dp_logtype;
+
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
+		const void *buf, unsigned int len)
+{
+	if (level > rte_log_get_global_level())
+		return 0;
+	if (level > (uint32_t)(rte_log_get_level(logtype)))
+		return 0;
+
+	rte_hexdump(rte_log_get_stream(), title, buf, len);
+	return 0;
+}
+
+RTE_INIT(bcmfs_device_init_log)
+{
+	/* Configuration and general logs */
+	bcmfs_conf_logtype = rte_log_register("pmd.bcmfs_config");
+	if (bcmfs_conf_logtype >= 0)
+		rte_log_set_level(bcmfs_conf_logtype, RTE_LOG_NOTICE);
+
+	/* data-path logs */
+	bcmfs_dp_logtype = rte_log_register("pmd.bcmfs_fp");
+	if (bcmfs_dp_logtype >= 0)
+		rte_log_set_level(bcmfs_dp_logtype, RTE_LOG_NOTICE);
+}
drivers/crypto/bcmfs/bcmfs_logs.h new file +34 -0
new file mode 100644
index 000000000..c03a49b75
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_LOGS_H_
+#define _BCMFS_LOGS_H_
+
+#include <rte_log.h>
+
+extern int bcmfs_conf_logtype;
+extern int bcmfs_dp_logtype;
+
+#define BCMFS_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_conf_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, bcmfs_dp_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
+
+#define BCMFS_DP_HEXDUMP_LOG(level, title, buf, len)	\
+	bcmfs_hexdump_log(RTE_LOG_ ## level, bcmfs_dp_logtype, title, buf, len)
+
+/**
+ * bcmfs_hexdump_log Dump out memory in a special hex dump format.
+ *
+ * The message will be sent to the stream used by the rte_log infrastructure.
+ */
+int
+bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *heading,
+		  const void *buf, unsigned int len);
+
+#endif /* _BCMFS_LOGS_H_ */
drivers/crypto/bcmfs/meson.build new file +10 -0
new file mode 100644
index 000000000..a4bdd8ee5
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2020 Broadcom
+# All rights reserved.
+#
+
+deps += ['eal', 'bus_vdev']
+sources = files(
+		'bcmfs_logs.c',
+		'bcmfs_device.c'
+		)
drivers/crypto/bcmfs/rte_pmd_bcmfs_version.map new file +3 -0
new file mode 100644
index 000000000..f9f17e4f6
@@ -0,0 +1,3 @@
+DPDK_20.0 {
+	local: *;
+};
drivers/crypto/meson.build +2 -1
index a2423507a..8e06d0533 100644
@@ -23,7 +23,8 @@ drivers = ['aesni_gcm',
 	   'scheduler',
 	   'snow3g',
 	   'virtio',
-	   'zuc']
+	   'zuc',
+	   'bcmfs']
 
 std_deps = ['cryptodev'] # cryptodev pulls in all other needed deps
 config_flag_fmt = 'RTE_LIBRTE_@0@_PMD'
mk/rte.app.mk +1 -0
index 0ce8cf541..5e268f8c0 100644
@@ -308,6 +308,7 @@ ifeq ($(CONFIG_RTE_LIBRTE_SECURITY),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_CAAM_JR)   += -lrte_pmd_caam_jr
 endif # CONFIG_RTE_LIBRTE_SECURITY
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO) += -lrte_pmd_virtio_crypto
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BCMFS)      += -lrte_pmd_bcmfs
 endif # CONFIG_RTE_LIBRTE_CRYPTODEV
 
 ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y)
Signature · 1 line
2.17.1
#68 lore raw

PATCH 2/8 crypto/bcmfs: add vfio support

In reply to Vikas Gupta

Add vfio support for device.

---
 drivers/crypto/bcmfs/Makefile       |  1 +
 drivers/crypto/bcmfs/bcmfs_device.c |  5 ++
 drivers/crypto/bcmfs/bcmfs_device.h |  6 ++
 drivers/crypto/bcmfs/bcmfs_vfio.c   | 94 +++++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_vfio.h   | 17 ++++++
 drivers/crypto/bcmfs/meson.build    |  3 +-
 6 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_vfio.h
drivers/crypto/bcmfs/Makefile +1 -0
index 781ee6efa..5f691f7ba 100644
@@ -19,6 +19,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API
 #
 SRCS-y += bcmfs_logs.c
 SRCS-y += bcmfs_device.c
+SRCS-y += bcmfs_vfio.c
 
 LDLIBS += -lrte_eal -lrte_bus_vdev
 
drivers/crypto/bcmfs/bcmfs_device.c +5 -0
index 47c776de6..3b5cc9e98 100644
@@ -11,6 +11,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -71,6 +72,10 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 
 	fsdev->vdev = vdev;
 
+	/* attach to VFIO */
+	if (bcmfs_attach_vfio(fsdev))
+		goto cleanup;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +6 -0
index 4b0c6d3ca..5232bdea5 100644
@@ -35,6 +35,12 @@ struct bcmfs_device {
 	char name[BCMFS_DEV_NAME_LEN];
 	/* Parent vdev */
 	struct rte_vdev_device *vdev;
+	/* vfio handle */
+	int vfio_dev_fd;
+	/* mapped address */
+	uint8_t *mmap_addr;
+	/* mapped size */
+	uint32_t mmap_size;
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_vfio.c new file +94 -0

94 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_vfio.h new file +17 -0
new file mode 100644
index 000000000..d0fdf6483
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_VFIO_H_
+#define _BCMFS_VFIO_H_
+
+/* Attach the bcmfs device to vfio */
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev);
+
+/* Release the bcmfs device from vfio */
+void
+bcmfs_release_vfio(struct bcmfs_device *dev);
+
+#endif /* _BCMFS_VFIO_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index a4bdd8ee5..fd39eba20 100644
@@ -6,5 +6,6 @@
 deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
-		'bcmfs_device.c'
+		'bcmfs_device.c',
+		'bcmfs_vfio.c'
 		)
Signature · 1 line
2.17.1
#69 lore raw

PATCH 3/8 crypto/bcmfs: add apis for queue pair management

In reply to Vikas Gupta

Add queue pair management APIs which will be used by Crypto device to manage h/w queues. A bcmfs device structure owns multiple queue-pairs based on the mapped address allocated to it.

---
 drivers/crypto/bcmfs/Makefile        |  28 ---
 drivers/crypto/bcmfs/bcmfs_device.c  |   4 +
 drivers/crypto/bcmfs/bcmfs_device.h  |   5 +
 drivers/crypto/bcmfs/bcmfs_hw_defs.h |  38 +++
 drivers/crypto/bcmfs/bcmfs_qp.c      | 345 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_qp.h      | 122 ++++++++++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 7 files changed, 516 insertions(+), 29 deletions(-)
 delete mode 100644 drivers/crypto/bcmfs/Makefile
 create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h
drivers/crypto/bcmfs/Makefile deleted +0 -28
deleted file mode 100644
index 5f691f7ba..000000000
@@ -1,28 +0,0 @@
-# SPDX-License-Identifier: BSD-3-Clause
-# Copyright(C) 2020 Broadcom
-# All rights reserved.
-#
-
-include $(RTE_SDK)/mk/rte.vars.mk
-
-#
-# library name
-#
-LIB = librte_pmd_bcmfs.a
-
-CFLAGS += $(WERROR_FLAGS)
-CFLAGS += -I$(RTE_SDK)/drivers/crypto/bcmfs
-CFLAGS += -DALLOW_EXPERIMENTAL_API
-
-#
-# all source are stored in SRCS-y
-#
-SRCS-y += bcmfs_logs.c
-SRCS-y += bcmfs_device.c
-SRCS-y += bcmfs_vfio.c
-
-LDLIBS += -lrte_eal -lrte_bus_vdev
-
-EXPORT_MAP := rte_pmd_bcmfs_version.map
-
-include $(RTE_SDK)/mk/rte.lib.mk
drivers/crypto/bcmfs/bcmfs_device.c +4 -0
index 3b5cc9e98..b475c2933 100644
@@ -11,6 +11,7 @@
 
 #include "bcmfs_device.h"
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
 
 struct bcmfs_device_attr {
@@ -76,6 +77,9 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
 	if (bcmfs_attach_vfio(fsdev))
 		goto cleanup;
 
+	/* Maximum number of QPs supported */
+	fsdev->max_hw_qps = fsdev->mmap_size / BCMFS_HW_QUEUE_IO_ADDR_LEN;
+
 	TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);
 
 	return fsdev;
drivers/crypto/bcmfs/bcmfs_device.h +5 -0
index 5232bdea5..e03ce5b5b 100644
@@ -11,6 +11,7 @@
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES		4
@@ -41,6 +42,10 @@ struct bcmfs_device {
 	uint8_t *mmap_addr;
 	/* mapped size */
 	uint32_t mmap_size;
+	/* max number of h/w queue pairs detected */
+	uint16_t max_hw_qps;
+	/* current qpairs in use */
+	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_hw_defs.h new file +38 -0
new file mode 100644
index 000000000..ecb0c09ba
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_RM_DEFS_H_
+#define _BCMFS_RM_DEFS_H_
+
+#include <rte_atomic.h>
+#include <rte_byteorder.h>
+#include <rte_common.h>
+#include <rte_io.h>
+
+/* 32-bit MMIO register write */
+#define FS_MMIO_WRITE32(value, addr) rte_write32_relaxed((value), (addr))
+
+/* 32-bit MMIO register read */
+#define FS_MMIO_READ32(addr) rte_read32_relaxed((addr))
+
+#ifndef BIT
+#define BIT(nr)         (1UL << (nr))
+#endif
+
+#define FS_RING_REGS_SIZE		0x10000
+#define FS_RING_DESC_SIZE		8
+#define FS_RING_BD_ALIGN_ORDER		12
+#define FS_RING_BD_DESC_PER_REQ		32
+#define FS_RING_CMPL_ALIGN_ORDER	13
+#define FS_RING_CMPL_SIZE		(1024 * FS_RING_DESC_SIZE)
+#define FS_RING_MAX_REQ_COUNT		1024
+#define FS_RING_PAGE_SHFT		12
+#define FS_RING_PAGE_SIZE		BIT(FS_RING_PAGE_SHFT)
+
+/* Minimum and maximum number of requests supported */
+#define FS_RM_MAX_REQS			1024
+#define FS_RM_MIN_REQS			32
+
+#endif /* BCMFS_RM_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c new file +345 -0

345 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_qp.h new file +122 -0

122 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +2 -1
index fd39eba20..7e2bcbf14 100644
@@ -7,5 +7,6 @@ deps += ['eal', 'bus_vdev']
 sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
-		'bcmfs_vfio.c'
+		'bcmfs_vfio.c',
+		'bcmfs_qp.c'
 		)
Signature · 1 line
2.17.1
#70 lore raw

PATCH 4/8 crypto/bcmfs: add hw queue pair operations

In reply to Vikas Gupta

Add queue pair operations exported by supported devices.

---
 drivers/crypto/bcmfs/bcmfs_dev_msg.h      |  29 +
 drivers/crypto/bcmfs/bcmfs_device.c       |  51 ++
 drivers/crypto/bcmfs/bcmfs_device.h       |  16 +
 drivers/crypto/bcmfs/bcmfs_qp.c           |   1 +
 drivers/crypto/bcmfs/bcmfs_qp.h           |   4 +
 drivers/crypto/bcmfs/hw/bcmfs4_rm.c       | 742 ++++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs5_rm.c       | 677 ++++++++++++++++++++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c |  82 +++
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h |  46 ++
 drivers/crypto/bcmfs/meson.build          |   5 +-
 10 files changed, 1652 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_dev_msg.h
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs4_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs5_rm.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
 create mode 100644 drivers/crypto/bcmfs/hw/bcmfs_rm_common.h
drivers/crypto/bcmfs/bcmfs_dev_msg.h new file +29 -0
new file mode 100644
index 000000000..5b50bde35
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_DEV_MSG_H_
+#define _BCMFS_DEV_MSG_H_
+
+#define MAX_SRC_ADDR_BUFFERS    8
+#define MAX_DST_ADDR_BUFFERS    3
+
+struct bcmfs_qp_message {
+	/** Physical address of each source */
+	uint64_t srcs_addr[MAX_SRC_ADDR_BUFFERS];
+	/** Length of each sources */
+	uint32_t srcs_len[MAX_SRC_ADDR_BUFFERS];
+	/** Total number of sources */
+	unsigned int srcs_count;
+	/** Physical address of each destination */
+	uint64_t dsts_addr[MAX_DST_ADDR_BUFFERS];
+	/** Length of each destination */
+	uint32_t dsts_len[MAX_DST_ADDR_BUFFERS];
+	/** Total number of destinations */
+	unsigned int dsts_count;
+
+	void *ctx;
+};
+
+#endif /* _BCMFS_DEV_MSG_H_ */
drivers/crypto/bcmfs/bcmfs_device.c +51 -0

69 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_device.h +16 -0
index e03ce5b5b..96beb10fa 100644
@@ -8,6 +8,7 @@
 
 #include <sys/queue.h>
 
+#include <rte_spinlock.h>
 #include <rte_bus_vdev.h>
 
 #include "bcmfs_logs.h"
@@ -28,6 +29,19 @@ enum bcmfs_device_type {
 	BCMFS_UNKNOWN
 };
 
+/* A table to store registered queue pair opertations */
+struct bcmfs_hw_queue_pair_ops_table {
+	rte_spinlock_t tl;
+	/* Number of used ops structs in the table. */
+	uint32_t num_ops;
+	 /*  Storage for all possible ops structs. */
+	struct bcmfs_hw_queue_pair_ops qp_ops[BCMFS_MAX_NODES];
+};
+
+/* HW queue pair ops register function */
+int bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops
+				     *qp_ops);
+
 struct bcmfs_device {
 	TAILQ_ENTRY(bcmfs_device) next;
 	/* Directoy path for vfio */
@@ -46,6 +60,8 @@ struct bcmfs_device {
 	uint16_t max_hw_qps;
 	/* current qpairs in use */
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
+	/* queue pair ops exported by symmetric crypto hw */
+	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
 };
 
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +1 -0
index 864e7bb74..ec1327b78 100644
@@ -227,6 +227,7 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	qp->qpair_id = queue_pair_id;
 	qp->ioreg = qp_conf->iobase;
 	qp->nb_descriptors = nb_descriptors;
+	qp->ops = qp_conf->ops;
 
 	qp->stats.enqueued_count = 0;
 	qp->stats.dequeued_count = 0;
drivers/crypto/bcmfs/bcmfs_qp.h +4 -0
index 027d7a50c..e4b0c3f2f 100644
@@ -44,6 +44,8 @@ struct bcmfs_qp_config {
 	uint16_t nb_descriptors;
 	/* Maximum number of h/w descriptors needed by a request */
 	uint16_t max_descs_req;
+	/* h/w ops associated with qp */
+	struct bcmfs_hw_queue_pair_ops *ops;
 };
 
 struct bcmfs_queue {
@@ -61,6 +63,8 @@ struct bcmfs_queue {
 		/* s/w pointer for completion h/w queue*/
 		uint32_t cmpl_read_ptr;
 	};
+	/* number of inflight descriptor accumulated  before next db ring */
+	uint16_t descs_inflight;
 	/* Memzone name */
 	char memz_name[RTE_MEMZONE_NAMESIZE];
 };
drivers/crypto/bcmfs/hw/bcmfs4_rm.c new file +742 -0

742 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs5_rm.c new file +677 -0

677 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.c new file +82 -0

82 lines not on this page · raw message

drivers/crypto/bcmfs/hw/bcmfs_rm_common.h new file +46 -0

46 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +4 -1
index 7e2bcbf14..cd58bd5e2 100644
@@ -8,5 +8,8 @@ sources = files(
 		'bcmfs_logs.c',
 		'bcmfs_device.c',
 		'bcmfs_vfio.c',
-		'bcmfs_qp.c'
+		'bcmfs_qp.c',
+		'hw/bcmfs4_rm.c',
+		'hw/bcmfs5_rm.c',
+		'hw/bcmfs_rm_common.c'
 		)
Signature · 1 line
2.17.1
#71 lore raw

PATCH 5/8 crypto/bcmfs: create a symmetric cryptodev

In reply to Vikas Gupta

Create a symmetric crypto device and supported cryptodev ops.

---
 drivers/crypto/bcmfs/bcmfs_device.c  |  15 ++
 drivers/crypto/bcmfs/bcmfs_device.h  |   9 +
 drivers/crypto/bcmfs/bcmfs_qp.c      |  37 +++
 drivers/crypto/bcmfs/bcmfs_qp.h      |  16 ++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c | 387 +++++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.h |  38 +++
 drivers/crypto/bcmfs/bcmfs_sym_req.h |  22 ++
 drivers/crypto/bcmfs/meson.build     |   3 +-
 8 files changed, 526 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_pmd.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_req.h
drivers/crypto/bcmfs/bcmfs_device.c +15 -0
index bd2d64acf..c9263ec28 100644
@@ -13,6 +13,7 @@
 #include "bcmfs_logs.h"
 #include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
+#include "bcmfs_sym_pmd.h"
 
 struct bcmfs_device_attr {
 	const char name[BCMFS_MAX_PATH_LEN];
@@ -239,6 +240,7 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 	char out_dirname[BCMFS_MAX_PATH_LEN];
 	uint32_t fsdev_dev[BCMFS_MAX_NODES];
 	enum bcmfs_device_type dtype;
+	int err;
 	int i = 0;
 	int dev_idx;
 	int count = 0;
@@ -290,7 +292,20 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
 		return -ENODEV;
 	}
 
+	err = bcmfs_sym_dev_create(fsdev);
+	if (err) {
+		BCMFS_LOG(WARNING,
+			  "Failed to create BCMFS SYM PMD for device %s",
+			  fsdev->name);
+		goto pmd_create_fail;
+	}
+
 	return 0;
+
+pmd_create_fail:
+	fsdev_release(fsdev);
+
+	return err;
 }
 
 static int
drivers/crypto/bcmfs/bcmfs_device.h +9 -0
index 96beb10fa..37907b91f 100644
@@ -62,6 +62,15 @@ struct bcmfs_device {
 	struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];
 	/* queue pair ops exported by symmetric crypto hw */
 	struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops;
+	/* a cryptodevice attached to bcmfs device */
+	struct rte_cryptodev *cdev;
+	/* a rte_device to register with cryptodev */
+	struct rte_device sym_rte_dev;
+	/* private info to keep with cryptodev */
+	struct bcmfs_sym_dev_private *sym_dev;
 };
 
+/* stats exported by device */
+
+
 #endif /* _BCMFS_DEV_H_ */
drivers/crypto/bcmfs/bcmfs_qp.c +37 -0
index ec1327b78..cb5ff6c61 100644
@@ -344,3 +344,40 @@ bcmfs_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops)
 
 	return deq;
 }
+
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats)
+{
+	int i;
+
+	if (stats == NULL) {
+		BCMFS_LOG(ERR, "invalid param: stats %p",
+			  stats);
+		return;
+	}
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+
+		stats->enqueued_count += qp[i]->stats.enqueued_count;
+		stats->dequeued_count += qp[i]->stats.dequeued_count;
+		stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
+		stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
+	}
+}
+
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp)
+{
+	int i;
+
+	for (i = 0; i < num_qp; i++) {
+		if (qp[i] == NULL) {
+			BCMFS_LOG(DEBUG, "Uninitialised qp %d", i);
+			continue;
+		}
+		memset(&qp[i]->stats, 0, sizeof(qp[i]->stats));
+	}
+}
drivers/crypto/bcmfs/bcmfs_qp.h +16 -0
index e4b0c3f2f..fec58ca71 100644
@@ -24,6 +24,13 @@ enum bcmfs_queue_type {
 	BCMFS_RM_CPLQ
 };
 
+#define BCMFS_QP_IOBASE_XLATE(base, idx)	\
+		((base) + ((idx) * BCMFS_HW_QUEUE_IO_ADDR_LEN))
+
+/* Max pkts for preprocessing before submitting to h/w qp */
+#define BCMFS_MAX_REQS_BUFF	64
+
+/* qp stats */
 struct bcmfs_qp_stats {
 	/* Count of all operations enqueued */
 	uint64_t enqueued_count;
@@ -92,6 +99,10 @@ struct bcmfs_qp {
 	struct bcmfs_qp_stats stats;
 	/* h/w ops associated with qp */
 	struct bcmfs_hw_queue_pair_ops *ops;
+	/* bcmfs requests pool*/
+	struct rte_mempool *sr_mp;
+	/* a temporary buffer to keep message pointers */
+	struct bcmfs_qp_message *infl_msgs[BCMFS_MAX_REQS_BUFF];
 
 } __rte_cache_aligned;
 
@@ -123,4 +134,9 @@ bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 	       uint16_t queue_pair_id,
 	       struct bcmfs_qp_config *bcmfs_conf);
 
+/* stats functions*/
+void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
+			struct bcmfs_qp_stats *stats);
+void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp);
+
 #endif /* _BCMFS_QP_H_ */
drivers/crypto/bcmfs/bcmfs_sym_pmd.c new file +387 -0

387 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.h new file +38 -0
new file mode 100644
index 000000000..65d704609
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_PMD_H_
+#define _BCMFS_SYM_PMD_H_
+
+#include <rte_cryptodev.h>
+
+#include "bcmfs_device.h"
+
+#define CRYPTODEV_NAME_BCMFS_SYM_PMD	crypto_bcmfs
+
+#define BCMFS_CRYPTO_MAX_HW_DESCS_PER_REQ	16
+
+extern uint8_t cryptodev_bcmfs_driver_id;
+
+/** private data structure for a BCMFS device.
+ *  This BCMFS device is a device offering only symmetric crypto service,
+ *  there can be one of these on each bcmfs_pci_device (VF).
+ */
+struct bcmfs_sym_dev_private {
+	/* The bcmfs device hosting the service */
+	struct bcmfs_device *fsdev;
+	/* Device instance for this rte_cryptodev */
+	uint8_t sym_dev_id;
+	/* BCMFS device symmetric crypto capabilities */
+	const struct rte_cryptodev_capabilities *fsdev_capabilities;
+};
+
+int
+bcmfs_sym_dev_create(struct bcmfs_device *fdev);
+
+int
+bcmfs_sym_dev_destroy(struct bcmfs_device *fdev);
+
+#endif /* _BCMFS_SYM_PMD_H_ */
drivers/crypto/bcmfs/bcmfs_sym_req.h new file +22 -0
new file mode 100644
index 000000000..0f0b051f1
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_REQ_H_
+#define _BCMFS_SYM_REQ_H_
+
+#include "bcmfs_dev_msg.h"
+
+/*
+ * This structure hold the supportive data required to process a
+ * rte_crypto_op
+ */
+struct bcmfs_sym_request {
+	/* bcmfs qp message for h/w queues to process */
+	struct bcmfs_qp_message msgs;
+	/* crypto op */
+	struct rte_crypto_op *op;
+};
+
+#endif /* _BCMFS_SYM_REQ_H_ */
drivers/crypto/bcmfs/meson.build +2 -1
index cd58bd5e2..d9a3d73e9 100644
@@ -11,5 +11,6 @@ sources = files(
 		'bcmfs_qp.c',
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
-		'hw/bcmfs_rm_common.c'
+		'hw/bcmfs_rm_common.c',
+		'bcmfs_sym_pmd.c'
 		)
Signature · 1 line
2.17.1
#72 lore raw

PATCH 6/8 crypto/bcmfs: add session handling and capabilities

In reply to Vikas Gupta

Add session handling and capabilities supported by crypto h/w accelerator.

---
 doc/guides/cryptodevs/bcmfs.rst               |  46 ++
 doc/guides/cryptodevs/features/bcmfs.ini      |  56 ++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c | 764 ++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_defs.h         | 170 ++++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c          |  13 +
 drivers/crypto/bcmfs/bcmfs_sym_session.c      | 426 ++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_session.h      |  99 +++
 drivers/crypto/bcmfs/meson.build              |   4 +-
 9 files changed, 1593 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/cryptodevs/features/bcmfs.ini
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_defs.h
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_session.h
doc/guides/cryptodevs/bcmfs.rst +46 -0
index 752ce028a..2488b19f7 100644
@@ -18,9 +18,55 @@ CONFIG_RTE_LIBRTE_PMD_BCMFS setting is set to `y` in config/common_base file.
 
 * ``CONFIG_RTE_LIBRTE_PMD_BCMFS=y``
 
+Features
+~~~~~~~~
+
+The BCMFS SYM PMD has support for:
+
+Cipher algorithms:
+
+* ``RTE_CRYPTO_CIPHER_3DES_CBC``
+* ``RTE_CRYPTO_CIPHER_3DES_CTR``
+* ``RTE_CRYPTO_CIPHER_AES128_CBC``
+* ``RTE_CRYPTO_CIPHER_AES192_CBC``
+* ``RTE_CRYPTO_CIPHER_AES256_CBC``
+* ``RTE_CRYPTO_CIPHER_AES128_CTR``
+* ``RTE_CRYPTO_CIPHER_AES192_CTR``
+* ``RTE_CRYPTO_CIPHER_AES256_CTR``
+* ``RTE_CRYPTO_CIPHER_AES_XTS``
+* ``RTE_CRYPTO_CIPHER_DES_CBC``
+
+Hash algorithms:
+
+* ``RTE_CRYPTO_AUTH_SHA1``
+* ``RTE_CRYPTO_AUTH_SHA1_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA224``
+* ``RTE_CRYPTO_AUTH_SHA224_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA256``
+* ``RTE_CRYPTO_AUTH_SHA256_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA384``
+* ``RTE_CRYPTO_AUTH_SHA384_HMAC``
+* ``RTE_CRYPTO_AUTH_SHA512``
+* ``RTE_CRYPTO_AUTH_SHA512_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_XCBC_MAC``
+* ``RTE_CRYPTO_AUTH_MD5_HMAC``
+* ``RTE_CRYPTO_AUTH_AES_GMAC``
+* ``RTE_CRYPTO_AUTH_AES_CMAC``
+
+Supported AEAD algorithms:
+
+* ``RTE_CRYPTO_AEAD_AES_GCM``
+* ``RTE_CRYPTO_AEAD_AES_CCM``
+
 Initialization
 --------------
 BCMFS crypto PMD depend upon the devices present in the path
 /sys/bus/platform/devices/fs<version>/<dev_name> on the platform.
 Each cryptodev PMD instance can be attached to the nodes present
 in the mentioned path.
+
+Limitations
+~~~~~~~~~~~
+
+* Only supports the session-oriented API implementation (session-less APIs are not supported).
+* CCM is not supported on Broadcom`s SoCs having FlexSparc4 unit.
doc/guides/cryptodevs/features/bcmfs.ini new file +56 -0

56 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.c new file +764 -0

764 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_capabilities.h new file +16 -0
new file mode 100644
index 000000000..3ff61b7d2
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BCMFS_SYM_CAPABILITIES_H_
+#define _BCMFS_SYM_CAPABILITIES_H_
+
+/*
+ * Get capabilities list for the device
+ *
+ */
+const struct rte_cryptodev_capabilities *bcmfs_sym_get_capabilities(void);
+
+#endif /* _BCMFS_SYM_CAPABILITIES_H__ */
+
drivers/crypto/bcmfs/bcmfs_sym_defs.h new file +170 -0

170 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.c +13 -0
index 0f96915f7..381ca8ea4 100644
@@ -14,6 +14,8 @@
 #include "bcmfs_qp.h"
 #include "bcmfs_sym_pmd.h"
 #include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+#include "bcmfs_sym_capabilities.h"
 
 uint8_t cryptodev_bcmfs_driver_id;
 
@@ -65,6 +67,7 @@ bcmfs_sym_dev_info_get(struct rte_cryptodev *dev,
 		dev_info->max_nb_queue_pairs = fsdev->max_hw_qps;
 		/* No limit of number of sessions */
 		dev_info->sym.max_nb_sessions = 0;
+		dev_info->capabilities = bcmfs_sym_get_capabilities();
 	}
 }
 
@@ -228,6 +231,10 @@ static struct rte_cryptodev_ops crypto_bcmfs_ops = {
 	/* Queue-Pair management */
 	.queue_pair_setup       = bcmfs_sym_qp_setup,
 	.queue_pair_release     = bcmfs_sym_qp_release,
+	/* Crypto session related operations */
+	.sym_session_get_size   = bcmfs_sym_session_get_private_size,
+	.sym_session_configure  = bcmfs_sym_session_configure,
+	.sym_session_clear      = bcmfs_sym_session_clear
 };
 
 /** Enqueue burst */
@@ -239,6 +246,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	int i, j;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
+	struct bcmfs_sym_session *sess;
 	struct bcmfs_qp *qp = (struct bcmfs_qp *)queue_pair;
 
 	if (nb_ops == 0)
@@ -252,6 +260,10 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		nb_ops = qp->nb_descriptors - qp->nb_pending_requests;
 
 	for (i = 0; i < nb_ops; i++) {
+		sess = bcmfs_sym_get_session(ops[i]);
+		if (unlikely(sess == NULL))
+			goto enqueue_err;
+
 		if (rte_mempool_get(qp->sr_mp, (void **)&sreq))
 			goto enqueue_err;
 
@@ -356,6 +368,7 @@ bcmfs_sym_dev_create(struct bcmfs_device *fsdev)
 	fsdev->sym_dev = internals;
 
 	internals->sym_dev_id = cryptodev->data->dev_id;
+	internals->fsdev_capabilities = bcmfs_sym_get_capabilities();
 
 	BCMFS_LOG(DEBUG, "Created bcmfs-sym device %s as cryptodev instance %d",
 		  cryptodev->data->name, internals->sym_dev_id);
drivers/crypto/bcmfs/bcmfs_sym_session.c new file +426 -0

426 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_session.h new file +99 -0

99 lines not on this page · raw message

drivers/crypto/bcmfs/meson.build +3 -1
index d9a3d73e9..2e86c733e 100644
@@ -12,5 +12,7 @@ sources = files(
 		'hw/bcmfs4_rm.c',
 		'hw/bcmfs5_rm.c',
 		'hw/bcmfs_rm_common.c',
-		'bcmfs_sym_pmd.c'
+		'bcmfs_sym_pmd.c',
+		'bcmfs_sym_capabilities.c',
+		'bcmfs_sym_session.c'
 		)
Signature · 1 line
2.17.1
#73 lore raw

PATCH 7/8 crypto/bcmfs: add crypto h/w module

In reply to Vikas Gupta

Add crypto h/w module to process crypto op. Crypto op is processed via sym_engine module before submitting the crypto request to h/w queues.

---
 drivers/crypto/bcmfs/bcmfs_sym.c        | 316 ++++++++
 drivers/crypto/bcmfs/bcmfs_sym_defs.h   |  16 +
 drivers/crypto/bcmfs/bcmfs_sym_engine.c | 994 ++++++++++++++++++++++++
 drivers/crypto/bcmfs/bcmfs_sym_engine.h | 103 +++
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c    |  26 +
 drivers/crypto/bcmfs/bcmfs_sym_req.h    |  40 +
 drivers/crypto/bcmfs/meson.build        |   4 +-
 7 files changed, 1498 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.c
 create mode 100644 drivers/crypto/bcmfs/bcmfs_sym_engine.h
drivers/crypto/bcmfs/bcmfs_sym.c new file +316 -0
new file mode 100644
index 000000000..8f9415b5e
@@ -0,0 +1,316 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <stdbool.h>
+
+#include <rte_byteorder.h>
+#include <rte_crypto_sym.h>
+#include <rte_cryptodev.h>
+#include <rte_mbuf.h>
+#include <rte_mempool.h>
+
+#include "bcmfs_sym_defs.h"
+#include "bcmfs_sym_engine.h"
+#include "bcmfs_sym_req.h"
+#include "bcmfs_sym_session.h"
+
+/** Process cipher operation */
+static int
+process_crypto_cipher_op(struct rte_crypto_op *op,
+			 struct rte_mbuf *mbuf_src,
+			 struct rte_mbuf *mbuf_dst,
+			 struct bcmfs_sym_session *sess,
+			 struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv, key;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 op->sym->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+	fsattr_pa(&dst) = rte_pktmbuf_iova(mbuf_dst);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						     uint8_t *,
+						     sess->cipher.iv.offset);
+
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&key) = sess->cipher.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->cipher.key.length;
+
+	rc = bcmfs_crypto_build_cipher_req(req, sess->cipher.algo,
+					   sess->cipher.direction, &src,
+					   &dst, &key, &iv);
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process auth operation */
+static int
+process_crypto_auth_op(struct rte_crypto_op *op,
+			   struct rte_mbuf *mbuf_src,
+			   struct bcmfs_sym_session *sess,
+			   struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, mac, key;
+
+	fsattr_sz(&src) = op->sym->auth.data.length;
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset(mbuf_src,
+						   uint8_t *,
+						   op->sym->auth.data.offset);
+	fsattr_pa(&src) = rte_pktmbuf_iova(mbuf_src);
+
+	if (!sess->auth.operation) {
+		fsattr_va(&mac) = op->sym->auth.digest.data;
+		fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&mac) = sess->auth.digest_length;
+	} else {
+		fsattr_va(&dst) = op->sym->auth.digest.data;
+		fsattr_pa(&dst) = op->sym->auth.digest.phys_addr;
+		fsattr_sz(&dst) = sess->auth.digest_length;
+	}
+
+	fsattr_va(&key) = sess->auth.key.data;
+	fsattr_pa(&key) = 0;
+	fsattr_sz(&key) = sess->auth.key.length;
+
+	/* AES-GMAC uses AES-GCM-128 authenticator */
+	if (sess->auth.algo == BCMFS_CRYPTO_AUTH_AES_GMAC) {
+		struct fsattr  iv;
+		fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+							    uint8_t *,
+							    sess->auth.iv.offset);
+		fsattr_pa(&iv) = 0;
+		fsattr_sz(&iv) = sess->auth.iv.length;
+
+		rc = bcmfs_crypto_build_aead_request(req,
+						     BCMFS_CRYPTO_CIPHER_NONE,
+						     0,
+						     BCMFS_CRYPTO_AUTH_AES_GMAC,
+						     sess->auth.operation,
+						     &src, NULL, NULL, &key,
+						     &iv, NULL,
+						     sess->auth.operation ?
+							(&dst) : &(mac),
+						     0);
+	} else {
+		rc = bcmfs_crypto_build_auth_req(req, sess->auth.algo,
+						 sess->auth.operation,
+						 &src,
+						 (sess->auth.operation) ? (&dst) : NULL,
+						 (sess->auth.operation) ? NULL  : (&mac),
+						 &key);
+	}
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process combined/chained mode operation */
+static int
+process_crypto_combined_op(struct rte_crypto_op *op,
+			   struct rte_mbuf *mbuf_src,
+			   struct rte_mbuf *mbuf_dst,
+			   struct bcmfs_sym_session *sess,
+			   struct bcmfs_sym_request *req)
+{
+	int rc = 0, aad_size = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr cipher_key, aad, mac, auth_key;
+
+	fsattr_sz(&src) = sym_op->cipher.data.length;
+	fsattr_sz(&dst) = sym_op->cipher.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 sym_op->cipher.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->cipher.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						sym_op->cipher.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						     uint8_t *,
+						     sess->cipher.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&cipher_key) = sess->cipher.key.data;
+	fsattr_pa(&cipher_key) = 0;
+	fsattr_sz(&cipher_key) = sess->cipher.key.length;
+
+	fsattr_va(&auth_key) = sess->auth.key.data;
+	fsattr_pa(&auth_key) = 0;
+	fsattr_sz(&auth_key) = sess->auth.key.length;
+
+	fsattr_va(&mac) = op->sym->auth.digest.data;
+	fsattr_pa(&mac) = op->sym->auth.digest.phys_addr;
+	fsattr_sz(&mac) = sess->auth.digest_length;
+
+	aad_size = sym_op->auth.data.length - sym_op->cipher.data.length;
+
+	if (aad_size > 0) {
+		fsattr_sz(&aad) =  aad_size;
+		fsattr_va(&aad) = rte_pktmbuf_mtod_offset
+						(mbuf_src,
+						 uint8_t *,
+						sym_op->auth.data.offset);
+		fsattr_pa(&aad) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->auth.data.offset);
+	}
+
+	rc = bcmfs_crypto_build_aead_request(req, sess->cipher.algo,
+					     sess->cipher.direction,
+					     sess->auth.algo,
+					     sess->auth.operation,
+					     &src, &dst, &cipher_key,
+					     &auth_key, &iv,
+					     (aad_size > 0) ? (&aad) : NULL,
+					     &mac, sess->cipher_first);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process AEAD operation */
+static int
+process_crypto_aead_op(struct rte_crypto_op *op,
+		       struct rte_mbuf *mbuf_src,
+		       struct rte_mbuf *mbuf_dst,
+		       struct bcmfs_sym_session *sess,
+		       struct bcmfs_sym_request *req)
+{
+	int rc = 0;
+	struct fsattr src, dst, iv;
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct fsattr cipher_key, aad, mac, auth_key;
+	enum bcmfs_crypto_cipher_op cipher_op;
+	enum bcmfs_crypto_auth_op auth_op;
+
+	if (sess->cipher.direction) {
+		auth_op = BCMFS_CRYPTO_AUTH_OP_VERIFY;
+		cipher_op = BCMFS_CRYPTO_CIPHER_OP_DECRYPT;
+	} else {
+		auth_op = BCMFS_CRYPTO_AUTH_OP_GENERATE;
+		cipher_op = BCMFS_CRYPTO_CIPHER_OP_ENCRYPT;
+	}
+
+	fsattr_sz(&src) = sym_op->aead.data.length;
+	fsattr_sz(&dst) = sym_op->aead.data.length;
+
+	fsattr_va(&src) = rte_pktmbuf_mtod_offset
+					(mbuf_src,
+					 uint8_t *,
+					 sym_op->aead.data.offset);
+
+	fsattr_va(&dst) = rte_pktmbuf_mtod_offset
+					(mbuf_dst,
+					 uint8_t *,
+					 sym_op->aead.data.offset);
+
+	fsattr_pa(&src) = rte_pktmbuf_iova_offset(mbuf_src,
+						sym_op->aead.data.offset);
+	fsattr_pa(&dst) = rte_pktmbuf_iova_offset(mbuf_dst,
+						sym_op->aead.data.offset);
+
+	fsattr_va(&iv) = rte_crypto_op_ctod_offset(op,
+						    uint8_t *,
+						    sess->cipher.iv.offset);
+
+	fsattr_pa(&iv) = 0;
+	fsattr_sz(&iv) = sess->cipher.iv.length;
+
+	fsattr_va(&cipher_key) = sess->cipher.key.data;
+	fsattr_pa(&cipher_key) = 0;
+	fsattr_sz(&cipher_key) = sess->cipher.key.length;
+
+	fsattr_va(&auth_key) = sess->auth.key.data;
+	fsattr_pa(&auth_key) = 0;
+	fsattr_sz(&auth_key) = sess->auth.key.length;
+
+	fsattr_va(&mac) = op->sym->aead.digest.data;
+	fsattr_pa(&mac) = op->sym->aead.digest.phys_addr;
+	fsattr_sz(&mac) = sess->auth.digest_length;
+
+	fsattr_va(&aad) = op->sym->aead.aad.data;
+	fsattr_pa(&aad) = op->sym->aead.aad.phys_addr;
+	fsattr_sz(&aad) = sess->aead.aad_length;
+
+	rc = bcmfs_crypto_build_aead_request(req, sess->cipher.algo,
+					     cipher_op, sess->auth.algo,
+					     auth_op, &src, &dst, &cipher_key,
+					     &auth_key, &iv, &aad, &mac,
+					     sess->cipher.direction ? 0 : 1);
+
+	if (rc)
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+
+	return rc;
+}
+
+/** Process crypto operation for mbuf */
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req)
+{
+	struct rte_mbuf *msrc, *mdst;
+	int rc = 0;
+
+	msrc = op->sym->m_src;
+	mdst = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src;
+	op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+
+	switch (sess->chain_order) {
+	case BCMFS_SYM_CHAIN_ONLY_CIPHER:
+		rc = process_crypto_cipher_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_ONLY_AUTH:
+		rc = process_crypto_auth_op(op, msrc, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_CIPHER_AUTH:
+	case BCMFS_SYM_CHAIN_AUTH_CIPHER:
+		rc = process_crypto_combined_op(op, msrc, mdst, sess, req);
+		break;
+	case BCMFS_SYM_CHAIN_AEAD:
+		rc = process_crypto_aead_op(op, msrc, mdst, sess, req);
+		break;
+	default:
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+		break;
+	}
+
+	return rc;
+}
drivers/crypto/bcmfs/bcmfs_sym_defs.h +16 -0
index b5657a9bc..8824521dd 100644
@@ -15,6 +15,18 @@
 #define BCMFS_MAX_IV_SIZE	16
 #define BCMFS_MAX_DIGEST_SIZE	64
 
+struct bcmfs_sym_session;
+struct bcmfs_sym_request;
+
+/** Crypto Request processing successful. */
+#define BCMFS_SYM_RESPONSE_SUCCESS               (0)
+/** Crypot Request processing protocol failure. */
+#define BCMFS_SYM_RESPONSE_PROTO_FAILURE         (1)
+/** Crypot Request processing completion failure. */
+#define BCMFS_SYM_RESPONSE_COMPL_ERROR           (2)
+/** Crypot Request processing hash tag check error. */
+#define BCMFS_SYM_RESPONSE_HASH_TAG_ERROR        (3)
+
 /** Symmetric Cipher Direction */
 enum bcmfs_crypto_cipher_op {
 	/** Encrypt cipher operation */
@@ -167,4 +179,8 @@ enum bcmfs_sym_crypto_class {
 	BCMFS_CRYPTO_AEAD,
 };
 
+int
+bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
+			    struct bcmfs_sym_session *sess,
+			    struct bcmfs_sym_request *req);
 #endif /* _BCMFS_SYM_DEFS_H_ */
drivers/crypto/bcmfs/bcmfs_sym_engine.c new file +994 -0

994 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_engine.h new file +103 -0

103 lines not on this page · raw message

drivers/crypto/bcmfs/bcmfs_sym_pmd.c +26 -0
index 381ca8ea4..568797b4f 100644
@@ -132,6 +132,12 @@ static void
 spu_req_init(struct bcmfs_sym_request *sr, rte_iova_t iova __rte_unused)
 {
 	memset(sr, 0, sizeof(*sr));
+	sr->fptr = iova;
+	sr->cptr = iova + offsetof(struct bcmfs_sym_request, cipher_key);
+	sr->aptr = iova + offsetof(struct bcmfs_sym_request, auth_key);
+	sr->iptr = iova + offsetof(struct bcmfs_sym_request, iv);
+	sr->dptr = iova + offsetof(struct bcmfs_sym_request, digest);
+	sr->rptr = iova + offsetof(struct bcmfs_sym_request, resp);
 }
 
 static void
@@ -244,6 +250,7 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 			       uint16_t nb_ops)
 {
 	int i, j;
+	int retval;
 	uint16_t enq = 0;
 	struct bcmfs_sym_request *sreq;
 	struct bcmfs_sym_session *sess;
@@ -273,6 +280,11 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 		/* save context */
 		qp->infl_msgs[i] = &sreq->msgs;
 		qp->infl_msgs[i]->ctx = (void *)sreq;
+
+		/* pre process the request crypto h/w acceleration */
+		retval = bcmfs_process_sym_crypto_op(ops[i], sess, sreq);
+		if (unlikely(retval < 0))
+			goto enqueue_err;
 	}
 	/* Send burst request to hw QP */
 	enq = bcmfs_enqueue_op_burst(qp, (void **)qp->infl_msgs, i);
@@ -289,6 +301,17 @@ bcmfs_sym_pmd_enqueue_op_burst(void *queue_pair,
 	return enq;
 }
 
+static void bcmfs_sym_set_request_status(struct rte_crypto_op *op,
+					 struct bcmfs_sym_request *out)
+{
+	if (*out->resp == BCMFS_SYM_RESPONSE_SUCCESS)
+		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+	else if (*out->resp == BCMFS_SYM_RESPONSE_HASH_TAG_ERROR)
+		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+	else
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+}
+
 static uint16_t
 bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 			       struct rte_crypto_op **ops,
@@ -308,6 +331,9 @@ bcmfs_sym_pmd_dequeue_op_burst(void *queue_pair,
 	for (i = 0; i < deq; i++) {
 		sreq = (struct bcmfs_sym_request *)qp->infl_msgs[i]->ctx;
 
+		/* set the status based on the response from the crypto h/w */
+		bcmfs_sym_set_request_status(sreq->op, sreq);
+
 		ops[pkts++] = sreq->op;
 
 		rte_mempool_put(qp->sr_mp, sreq);
drivers/crypto/bcmfs/bcmfs_sym_req.h +40 -0
index 0f0b051f1..e53c50adc 100644
@@ -6,13 +6,53 @@
 #ifndef _BCMFS_SYM_REQ_H_
 #define _BCMFS_SYM_REQ_H_
 
+#include <rte_cryptodev.h>
+
 #include "bcmfs_dev_msg.h"
+#include "bcmfs_sym_defs.h"
+
+/* Fixed SPU2 Metadata */
+struct spu2_fmd {
+	uint64_t ctrl0;
+	uint64_t ctrl1;
+	uint64_t ctrl2;
+	uint64_t ctrl3;
+};
 
 /*
  * This structure hold the supportive data required to process a
  * rte_crypto_op
  */
 struct bcmfs_sym_request {
+	/* spu2 engine related data */
+	struct spu2_fmd fmd;
+	/* cipher key */
+	uint8_t cipher_key[BCMFS_MAX_KEY_SIZE];
+	/* auth key */
+	uint8_t auth_key[BCMFS_MAX_KEY_SIZE];
+	/* iv key */
+	uint8_t iv[BCMFS_MAX_IV_SIZE];
+	/* digest data output from crypto h/w */
+	uint8_t digest[BCMFS_MAX_DIGEST_SIZE];
+	/* 2-Bytes response from crypto h/w */
+	uint8_t resp[2];
+	/*
+	 * Below are all iovas for above members
+	 * from top
+	 */
+	/* iova for fmd */
+	rte_iova_t fptr;
+	/* iova for cipher key */
+	rte_iova_t cptr;
+	/* iova for auth key */
+	rte_iova_t aptr;
+	/* iova for iv key */
+	rte_iova_t iptr;
+	/* iova for digest */
+	rte_iova_t dptr;
+	/* iova for response */
+	rte_iova_t rptr;
+
 	/* bcmfs qp message for h/w queues to process */
 	struct bcmfs_qp_message msgs;
 	/* crypto op */
drivers/crypto/bcmfs/meson.build +3 -1
index 2e86c733e..7aa0f05db 100644
@@ -14,5 +14,7 @@ sources = files(
 		'hw/bcmfs_rm_common.c',
 		'bcmfs_sym_pmd.c',
 		'bcmfs_sym_capabilities.c',
-		'bcmfs_sym_session.c'
+		'bcmfs_sym_session.c',
+		'bcmfs_sym.c',
+		'bcmfs_sym_engine.c'
 		)
Signature · 1 line
2.17.1
#74 lore raw

PATCH 8/8 crypto/bcmfs: add crypto pmd into cryptodev test

In reply to Vikas Gupta

Add test suites for supported algorithms by bcmfs crypto pmd

---
 app/test/test_cryptodev.c | 261 ++++++++++++++++++++++++++++++++++++++
 app/test/test_cryptodev.h |   1 +
 2 files changed, 262 insertions(+)
app/test/test_cryptodev.c +261 -0
index 70bf6fe2c..6e7d8471c 100644
@@ -12681,6 +12681,250 @@ static struct unit_test_suite cryptodev_nitrox_testsuite  = {
 	}
 };
 
+static struct unit_test_suite cryptodev_bcmfs_testsuite  = {
+	.suite_name = "Crypto BCMFS Unit Test Suite",
+	.setup = testsuite_setup,
+	.teardown = testsuite_teardown,
+	.unit_test_cases = {
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			     test_device_configure_invalid_dev_id),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+				test_device_configure_invalid_queue_pair_ids),
+
+		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
+
+		/** AES GCM Authenticated Encryption */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_7),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_test_case_8),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_J0_authenticated_encryption_test_case_1),
+
+		/** AES GCM Authenticated Decryption */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_7),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_test_case_8),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_J0_authenticated_decryption_test_case_1),
+
+		/** AES GCM Authenticated Encryption 192 bits key */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_192_7),
+
+		/** AES GCM Authenticated Decryption 192 bits key */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_192_7),
+
+		/** AES GCM Authenticated Encryption 256 bits key */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_256_7),
+
+		/** AES GCM Authenticated Decryption 256 bits key */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_6),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_256_7),
+
+		/** AES GCM Authenticated Encryption big aad size */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_aad_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_test_case_aad_2),
+
+		/** AES GCM Authenticated Decryption big aad size */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_aad_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_test_case_aad_2),
+
+		/** Out of place tests */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_encryption_oop_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_authenticated_decryption_oop_test_case_1),
+
+		/** AES GMAC Authentication */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_4),
+
+		/** Negative tests */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			authentication_verify_HMAC_SHA1_fail_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_iv_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_aad_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_encryption_fail_tag_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_iv_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_aad_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GCM_auth_decryption_fail_tag_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			authentication_verify_AES128_GMAC_fail_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			authentication_verify_AES128_GMAC_fail_tag_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
+
+		/** AES GMAC Authentication */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_3),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_AES_GMAC_authentication_verify_test_case_4),
+
+		/** HMAC_MD5 Authentication */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_MD5_HMAC_generate_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_MD5_HMAC_verify_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_MD5_HMAC_generate_case_2),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_MD5_HMAC_verify_case_2),
+
+		/** Mixed CIPHER + HASH algorithms */
+		/** AUTH AES CMAC + CIPHER AES CTR */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
+
+		/** AUTH NULL + CIPHER AES CTR */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_auth_null_cipher_aes_ctr_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_verify_auth_null_cipher_aes_ctr_test_case_1),
+
+		/** AUTH AES CMAC + CIPHER NULL */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_auth_aes_cmac_cipher_null_test_case_1),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_verify_auth_aes_cmac_cipher_null_test_case_1),
+
+		TEST_CASES_END() /**< NULL terminate unit test array */
+	}
+};
+
 static int
 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
 {
@@ -13041,6 +13285,22 @@ test_cryptodev_nitrox(void)
 	return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
 }
 
+static int
+test_cryptodev_bcmfs(void)
+{
+	gbl_driver_id =	rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
+
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded. Check if "
+				"CONFIG_RTE_LIBRTE_PMD_BCMFS is enabled "
+				"in config file to run this testsuite.\n");
+		return TEST_FAILED;
+	}
+
+	return unit_test_suite_runner(&cryptodev_bcmfs_testsuite);
+}
+
 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
@@ -13063,3 +13323,4 @@ REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
+REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
app/test/test_cryptodev.h +1 -0
index 41542e055..c58126368 100644
@@ -70,6 +70,7 @@
 #define CRYPTODEV_NAME_OCTEONTX2_PMD	crypto_octeontx2
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 #define CRYPTODEV_NAME_NITROX_PMD	crypto_nitrox_sym
+#define CRYPTODEV_NAME_BCMFS_PMD	crypto_bcmfs
 
 /**
  * Write (spread) data from buffer to mbuf data
Signature · 1 line
2.17.1