Skip to contentSkip to conversation

Add Marvell CNXK crypto PMDs

PATCH Applied Anoob Joseph 4 participants 26 messages Jun 25, 2021 – Jul 9, 2021 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): http://patches.dpdk.org/project/dpdk/cover/[email protected]/

#1 lore raw

v2 cover Add Marvell CNXK crypto PMDs

Add cnxk crypto PMDs supporting Marvell CN106XX SoC, based on 'common/cnxk'.

This series utilizes 'common/cnxk' to register cn9k & cn10k crypto PMDs and add symmetric cryptographic features for the same.

Depends-on: series-17482 ("Add CPT in Marvell CNXK common driver")

Changes in v2:
- Added documentation & updated release notes
- Reworked DP logs as suggested by Akhil
- Rearranged capability additions & feature flag updates as suggested by Akhil
- Rebased on v2 of dependant series

Ankur Dwivedi (5):
crypto/cnxk: add driver skeleton
crypto/cnxk: add probe and remove
crypto/cnxk: add device control ops
crypto/cnxk: add queue pair ops
crypto/cnxk: add symmetric crypto capabilities

Anoob Joseph (5):
crypto/cnxk: add session ops framework
crypto/cnxk: add enqueue burst op
crypto/cnxk: add dequeue burst op
crypto/cnxk: add cipher operation in session
crypto/cnxk: add auth operation in session

Archana Muniganti (5):
crypto/cnxk: add aead operation in session
crypto/cnxk: add chained operation in session
crypto/cnxk: add flexi crypto cipher encrypt
crypto/cnxk: add flexi crypto cipher decrypt
crypto/cnxk: add ZUC and SNOW3G encrypt

Tejasree Kondoj (5):
crypto/cnxk: add ZUC and SNOW3G decrypt
crypto/cnxk: add KASUMI encrypt
crypto/cnxk: add KASUMI decrypt
crypto/cnxk: add digest support
test/crypto: enable cnxk crypto PMDs

 MAINTAINERS                                       |    9 +
 app/test/meson.build                              |    2 +
 app/test/test_cryptodev.c                         |   14 +
 app/test/test_cryptodev.h                         |    2 +
 doc/guides/cryptodevs/cnxk.rst                    |  192 ++
 doc/guides/cryptodevs/features/cn10k.ini          |   66 +
 doc/guides/cryptodevs/features/cn9k.ini           |   66 +
 doc/guides/rel_notes/release_21_08.rst            |    7 +
 drivers/crypto/cnxk/cn10k_cryptodev.c             |  152 ++
 drivers/crypto/cnxk/cn10k_cryptodev.h             |   13 +
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c         |  357 +++
 drivers/crypto/cnxk/cn10k_cryptodev_ops.h         |   15 +
 drivers/crypto/cnxk/cn9k_cryptodev.c              |  150 ++
 drivers/crypto/cnxk/cn9k_cryptodev.h              |   13 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c          |  319 +++
 drivers/crypto/cnxk/cn9k_cryptodev_ops.h          |   14 +
 drivers/crypto/cnxk/cnxk_cryptodev.c              |   33 +
 drivers/crypto/cnxk/cnxk_cryptodev.h              |   26 +
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c |  699 ++++++
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h |   25 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c          |  551 +++++
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h          |  108 +
 drivers/crypto/cnxk/cnxk_se.h                     | 2675 +++++++++++++++++++++
 drivers/crypto/cnxk/meson.build                   |   21 +
 drivers/crypto/cnxk/version.map                   |    3 +
 drivers/crypto/meson.build                        |    1 +
 26 files changed, 5533 insertions(+)
 create mode 100644 doc/guides/cryptodevs/cnxk.rst
 create mode 100644 doc/guides/cryptodevs/features/cn10k.ini
 create mode 100644 doc/guides/cryptodevs/features/cn9k.ini
 create mode 100644 drivers/crypto/cnxk/cn10k_cryptodev.c
 create mode 100644 drivers/crypto/cnxk/cn10k_cryptodev.h
 create mode 100644 drivers/crypto/cnxk/cn10k_cryptodev_ops.c
 create mode 100644 drivers/crypto/cnxk/cn10k_cryptodev_ops.h
 create mode 100644 drivers/crypto/cnxk/cn9k_cryptodev.c
 create mode 100644 drivers/crypto/cnxk/cn9k_cryptodev.h
 create mode 100644 drivers/crypto/cnxk/cn9k_cryptodev_ops.c
 create mode 100644 drivers/crypto/cnxk/cn9k_cryptodev_ops.h
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev.h
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_ops.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_ops.h
 create mode 100644 drivers/crypto/cnxk/cnxk_se.h
 create mode 100644 drivers/crypto/cnxk/meson.build
 create mode 100644 drivers/crypto/cnxk/version.map
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/20 crypto/cnxk: add driver skeleton

From: Ankur Dwivedi <[email protected]>

Add driver skeleton for crypto_cn9k & crypto_cn10k PMDs leveraging cnxk common framework.

---
 MAINTAINERS                              |   9 +++
 doc/guides/cryptodevs/cnxk.rst           | 126 +++++++++++++++++++++++++++++++
 doc/guides/cryptodevs/features/cn10k.ini |  21 ++++++
 doc/guides/cryptodevs/features/cn9k.ini  |  21 ++++++
 drivers/crypto/cnxk/cn10k_cryptodev.c    |  42 +++++++++++
 drivers/crypto/cnxk/cn10k_cryptodev.h    |  13 ++++
 drivers/crypto/cnxk/cn9k_cryptodev.c     |  40 ++++++++++
 drivers/crypto/cnxk/cn9k_cryptodev.h     |  13 ++++
 drivers/crypto/cnxk/meson.build          |  16 ++++
 drivers/crypto/cnxk/version.map          |   3 +
 drivers/crypto/meson.build               |   1 +
 11 files changed, 305 insertions(+)
 create mode 100644 doc/guides/cryptodevs/cnxk.rst
 create mode 100644 doc/guides/cryptodevs/features/cn10k.ini
 create mode 100644 doc/guides/cryptodevs/features/cn9k.ini
 create mode 100644 drivers/crypto/cnxk/cn10k_cryptodev.c
 create mode 100644 drivers/crypto/cnxk/cn10k_cryptodev.h
 create mode 100644 drivers/crypto/cnxk/cn9k_cryptodev.c
 create mode 100644 drivers/crypto/cnxk/cn9k_cryptodev.h
 create mode 100644 drivers/crypto/cnxk/meson.build
 create mode 100644 drivers/crypto/cnxk/version.map
MAINTAINERS +9 -0
index 5877a16..851b408 100644
@@ -1080,6 +1080,15 @@ F: drivers/crypto/octeontx2/
 F: doc/guides/cryptodevs/octeontx2.rst
 F: doc/guides/cryptodevs/features/octeontx2.ini
 
+Marvell cnxk crypto
+M: Ankur Dwivedi <[email protected]>
+M: Anoob Joseph <[email protected]>
+M: Tejasree Kondoj <[email protected]>
+F: drivers/crypto/cnxk/
+F: doc/guides/cryptodevs/cnxk.rst
+F: doc/guides/cryptodevs/features/cn9k.ini
+F: doc/guides/cryptodevs/features/cn10k.ini
+
 Null Crypto
 M: Declan Doherty <[email protected]>
 F: drivers/crypto/null/
doc/guides/cryptodevs/cnxk.rst new file +126 -0

126 lines not on this page · raw message

doc/guides/cryptodevs/features/cn10k.ini new file +21 -0
new file mode 100644
index 0000000..0aa097d
@@ -0,0 +1,21 @@
+;
+; Supported features of the 'cn10k' crypto driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+
+;
+; Supported crypto algorithms of 'cn10k' crypto driver.
+;
+[Cipher]
+
+;
+; Supported authentication algorithms of 'cn10k' crypto driver.
+;
+[Auth]
+
+;
+; Supported AEAD algorithms of 'cn10k' crypto driver.
+;
+[AEAD]
doc/guides/cryptodevs/features/cn9k.ini new file +21 -0
new file mode 100644
index 0000000..64ee929
@@ -0,0 +1,21 @@
+;
+; Supported features of the 'cn9k' crypto driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+
+;
+; Supported crypto algorithms of 'cn9k' crypto driver.
+;
+[Cipher]
+
+;
+; Supported authentication algorithms of 'cn9k' crypto driver.
+;
+[Auth]
+
+;
+; Supported AEAD algorithms of 'cn9k' crypto driver.
+;
+[AEAD]
drivers/crypto/cnxk/cn10k_cryptodev.c new file +42 -0

42 lines not on this page · raw message

drivers/crypto/cnxk/cn10k_cryptodev.h new file +13 -0
new file mode 100644
index 0000000..61f62ef
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _CN10K_CRYPTODEV_H_
+#define _CN10K_CRYPTODEV_H_
+
+/* Marvell OCTEON CN10K Crypto PMD device name */
+#define CRYPTODEV_NAME_CN10K_PMD crypto_cn10k
+
+extern uint8_t cn10k_cryptodev_driver_id;
+
+#endif /* _CN10K_CRYPTODEV_H_ */
drivers/crypto/cnxk/cn9k_cryptodev.c new file +40 -0
new file mode 100644
index 0000000..7654c53
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_bus_pci.h>
+#include <rte_common.h>
+#include <rte_crypto.h>
+#include <rte_cryptodev.h>
+#include <rte_cryptodev_pmd.h>
+#include <rte_dev.h>
+#include <rte_pci.h>
+
+#include "cn9k_cryptodev.h"
+#include "roc_api.h"
+
+uint8_t cn9k_cryptodev_driver_id;
+
+static struct rte_pci_id pci_id_cpt_table[] = {
+	{
+	},
+	/* sentinel */
+	{
+		.device_id = 0
+	},
+};
+
+static struct rte_pci_driver cn9k_cryptodev_pmd = {
+	.id_table = pci_id_cpt_table,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
+	.probe = NULL,
+	.remove = NULL,
+};
+
+static struct cryptodev_driver cn9k_cryptodev_drv;
+
+RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_CN9K_PMD, cn9k_cryptodev_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_CN9K_PMD, pci_id_cpt_table);
+RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_CN9K_PMD, "vfio-pci");
+RTE_PMD_REGISTER_CRYPTO_DRIVER(cn9k_cryptodev_drv, cn9k_cryptodev_pmd.driver,
+			       cn9k_cryptodev_driver_id);
drivers/crypto/cnxk/cn9k_cryptodev.h new file +13 -0
new file mode 100644
index 0000000..f6e7965
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _CN9K_CRYPTODEV_H_
+#define _CN9K_CRYPTODEV_H_
+
+/* Marvell OCTEON CN9K Crypto PMD device name */
+#define CRYPTODEV_NAME_CN9K_PMD crypto_cn9k
+
+extern uint8_t cn9k_cryptodev_driver_id;
+
+#endif /* _CN9K_CRYPTODEV_H_ */
drivers/crypto/cnxk/meson.build new file +16 -0
new file mode 100644
index 0000000..197b94c
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2021 Marvell.
+#
+
+if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
+	build = false
+	reason = 'only supported on 64-bit Linux'
+	subdir_done()
+endif
+
+sources = files(
+        'cn9k_cryptodev.c',
+        'cn10k_cryptodev.c',
+)
+
+deps += ['bus_pci', 'common_cnxk']
drivers/crypto/cnxk/version.map new file +3 -0
new file mode 100644
index 0000000..ee80c51
@@ -0,0 +1,3 @@
+INTERNAL {
+	local: *;
+};
drivers/crypto/meson.build +1 -0
index b9fdf93..cb865aa 100644
@@ -12,6 +12,7 @@ drivers = [
         'bcmfs',
         'caam_jr',
         'ccp',
+        'cnxk',
         'dpaa_sec',
         'dpaa2_sec',
         'kasumi',
Signature · 1 line
2.7.4
#3 lore raw

Re: [dpdk-dev] [PATCH v2 01/20] crypto/cnxk: add driver skeleton

Hi,

Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Anoob Joseph
Sent: Friday, June 25, 2021 8:56 AM
To: Akhil Goyal <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>
Cc: Ankur Dwivedi <[email protected]>; Jerin Jacob <[email protected]>; Tejasree Kondoj <[email protected]>; [email protected]; Anoob Joseph <[email protected]>; Archana Muniganti <[email protected]>
Subject: [dpdk-dev] [PATCH v2 01/20] crypto/cnxk: add driver skeleton

This patch is causing the following exception with debug mode in main (02edbfab1e):
"""
meson --werror --buildtype=debug build && ninja -C build
...
ValueError: Buffer size too small (4 instead of at least 12 bytes)
...
"""

OS: Ubuntu 18.04.5
Meson: 0.58.1
Ninja: 1.8.2
Gcc: 7.5.0

Regards,
Ali

#4 lore raw

Re: [dpdk-dev] [PATCH v2 01/20] crypto/cnxk: add driver skeleton

Quoted 12 lines · Ali Alnubani
Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Anoob Joseph
Sent: Friday, June 25, 2021 8:56 AM
To: Akhil Goyal <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>
Cc: Ankur Dwivedi <[email protected]>; Jerin Jacob <[email protected]>; Tejasree Kondoj <[email protected]>; [email protected]; Anoob Joseph <[email protected]>; Archana Muniganti <[email protected]>
Subject: [dpdk-dev] [PATCH v2 01/20] crypto/cnxk: add driver skeleton

Quoted 7 lines

This patch is causing the following exception with debug mode in main (02edbfab1e):
"""
meson --werror --buildtype=debug build && ninja -C build
...
ValueError: Buffer size too small (4 instead of at least 12 bytes)
...
"""

- Reproduced the issue in Ubuntu 18.04 GHA vms:

FAILED: drivers/rte_crypto_cnxk.pmd.c
/usr/bin/python3 ../buildtools/gen-pmdinfo-cfile.py /home/runner/work/dpdk/dpdk/build/buildtools ar /home/runner/work/dpdk/dpdk/build/drivers/libtmp_rte_crypto_cnxk.a drivers/rte_crypto_cnxk.pmd.c /usr/bin/python3
../buildtools/pmdinfogen.py elf
Traceback (most recent call last):
File "../buildtools/pmdinfogen.py", line 274, in <module>
main()
File "../buildtools/pmdinfogen.py", line 269, in main
drivers = load_drivers(image)
File "../buildtools/pmdinfogen.py", line 203, in load_drivers drivers.append(Driver.load(image, symbol))
File "../buildtools/pmdinfogen.py", line 157, in load
driver.pci_ids = cls._load_pci_ids(image, pci_table_name_symbol)
File "../buildtools/pmdinfogen.py", line 177, in _load_pci_ids
pci_id = rte_pci_id.from_buffer_copy(data)
ValueError: Buffer size too small (4 instead of at least 12 bytes)
Traceback (most recent call last):
File "../buildtools/gen-pmdinfo-cfile.py", line 20, in <module> subprocess.run(pmdinfogen + paths + [output], check=True)
File "/usr/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '../buildtools/pmdinfogen.py', 'elf', '/home/runner/work/dpdk/dpdk/build/buildtools/tmp1ajyjflf/crypto_cnxk_cn9k_cryptodev.c.o', '/home/runner/work/dpdk/dpdk/build/buildtools/tmp1ajyjflf/crypto_cnxk_cn9k_cryptodev_ops.c.o', '/home/runner/work/dpdk/dpdk/build/buildtools/tmp1ajyjflf/crypto_cnxk_cn10k_cryptodev.c.o', '/home/runner/work/dpdk/dpdk/build/buildtools/tmp1ajyjflf/crypto_cnxk_cn10k_cryptodev_ops.c.o', '/home/runner/work/dpdk/dpdk/build/buildtools/tmp1ajyjflf/crypto_cnxk_cn10k_ipsec.c.o', '/home/runner/work/dpdk/dpdk/build/buildtools/tmp1ajyjflf/crypto_cnxk_cnxk_cryptodev.c.o', '/home/runner/work/dpdk/dpdk/build/buildtools/tmp1ajyjflf/crypto_cnxk_cnxk_cryptodev_capabilities.c.o', '/home/runner/work/dpdk/dpdk/build/buildtools/tmp1ajyjflf/crypto_cnxk_cnxk_cryptodev_ops.c.o', '/home/runner/work/dpdk/dpdk/build/buildtools/tmp1ajyjflf/crypto_cnxk_cnxk_cryptodev_sec.c.o', 'drivers/rte_crypto_cnxk.pmd.c']' returned non-zero exit status 1.

I don't get the relation with the debug mode, but there must be something different with the pci table symbols for this driver.

My bet is on drivers/crypto/cnxk/cn9k_cryptodev.c:

static struct rte_pci_id pci_id_cpt_table[] = {
        {
        },
        /* sentinel */
        {
                .device_id = 0
        },
};

Adding some pci id, like the cn9k vf cpt pci id, will likely fix the issue. And as a bonus, this will make this driver actually do something.

- There is also another issue with clang + debug.
This seems rather old, nobody complained.
Fixed with:

Author: David Marchand <[email protected]>
Date:   Thu Jul 8 22:10:11 2021 +0200

net/octeontx/base: fix debug build with clang

Remove conflicting declaration of this symbol.

Fixes d0d654986018 ("net/octeontx: support event Rx adapter")
(quoted diff) +0 -0

b/drivers/net/octeontx/base/octeontx_pkivf.h
index d41eaa57ed..8c86841ea6 100644

drivers/net/octeontx/base/octeontx_pkivf.h +0 -1
@@ -362,7 +362,6 @@ int octeontx_pki_port_open(int port);
 int octeontx_pki_port_hash_config(int port, pki_hash_cfg_t *hash_cfg);
 int octeontx_pki_port_pktbuf_config(int port, pki_pktbuf_cfg_t *buf_cfg);
 int octeontx_pki_port_create_qos(int port, pki_qos_cfg_t *qos_cfg);
-int octeontx_pki_port_close(int port);
 int octeontx_pki_port_errchk_config(int port, pki_errchk_cfg_t *cfg);
 int octeontx_pki_port_vlan_fltr_config(int port,
                                pki_port_vlan_filter_config_t *fltr_cfg);
Signature · 1 line
David Marchand
#5 lore raw

Re: [dpdk-dev] [PATCH v2 01/20] crypto/cnxk: add driver skeleton

Hello,

Quoted 12 lines · David Marchand

- Reproduced the issue in Ubuntu 18.04 GHA vms:

FAILED: drivers/rte_crypto_cnxk.pmd.c
/usr/bin/python3 ../buildtools/gen-pmdinfo-cfile.py /home/runner/work/dpdk/dpdk/build/buildtools ar /home/runner/work/dpdk/dpdk/build/drivers/libtmp_rte_crypto_cnxk.a drivers/rte_crypto_cnxk.pmd.c /usr/bin/python3 ../buildtools/pmdinfogen.py elf
Traceback (most recent call last):
File "../buildtools/pmdinfogen.py", line 274, in <module> main()
File "../buildtools/pmdinfogen.py", line 269, in main

Quoted 8 lines

drivers = load_drivers(image)
File "../buildtools/pmdinfogen.py", line 203, in load_drivers drivers.append(Driver.load(image, symbol))
File "../buildtools/pmdinfogen.py", line 157, in load driver.pci_ids = cls._load_pci_ids(image, pci_table_name_symbol) File "../buildtools/pmdinfogen.py", line 177, in _load_pci_ids pci_id = rte_pci_id.from_buffer_copy(data)
ValueError: Buffer size too small (4 instead of at least 12 bytes)

I spent some time trying to understand this error, there is probably multiple bug(s) somewhere between pyelftools/ctype/pmdinfogen.

In any case, on my f32, before
https://git.dpdk.org/dpdk/commit/?id=b146c30d3c0e (that hides the issue), with a more "recent" pyelftools + python than Ubuntu 18.04, I can see:

$ cat $HOME/builds/build-clang-shared/drivers/rte_crypto_cnxk.pmd.c
static __attribute__((unused)) const char *generator =
"../../dpdk/buildtools/pmdinfogen.py";
const char crypto_cn9k_pmd_info[] __attribute__((used)) =
"PMD_INFO_STRING= {\"name\": \"crypto_cn9k\", \"kmod\": \"vfio-pci\",
\"pci_ids\": [[10272, 25926, 28516, 24946], [11824, 11569, 11827,
25446]]}";
const char crypto_cn10k_pmd_info[] __attribute__((used)) =
"PMD_INFO_STRING= {\"name\": \"crypto_cn10k\", \"kmod\": \"vfio-pci\",
\"pci_ids\": [[6013, 41203, 65535, 65535]]}";
$ nm -S /home/dmarchan/builds/build-clang-shared/drivers/librte_crypto_cnxk.so
|grep cpt_table
000000000001d400 0000000000000018 b pci_id_cpt_table
000000000001d2f0 0000000000000018 d pci_id_cpt_table

You'll notice the former is located in bss.

$ hexdump -s $(($(printf "%d" 0x000000000001d400) - $(printf "%d"
0x1000))) -n $(printf "%d" 0x18)
/home/dmarchan/builds/build-clang-shared/drivers/librte_crypto_cnxk.so
001c400 6e61 2067 6576 7372 6f69 206e 3031 302e
001c410 312e 2820 6546 6f64
001c418
$ hexdump -s $(($(printf "%d" 0x000000000001d2f0) - $(printf "%d"
0x1000))) -n $(printf "%d" 0x18)
/home/dmarchan/builds/build-clang-shared/drivers/librte_crypto_cnxk.so
001c2f0 ffff 00ff 177d a0f3 ffff ffff 0000 0000
001c300 0000 0000 0000 0000
001c308

Those values match what the pmd.c file contains.

Are we missing a "memset()" for such symbols in pmdinfogen? Or maybe a warning that we are adding an empty pci ids table..

There is no urgency, but if you find some time to look at this. Thanks.

Signature · 1 line
David Marchand
#6 lore raw

PATCH v2 2/20 crypto/cnxk: add probe and remove

In reply to Anoob Joseph

From: Ankur Dwivedi <[email protected]>

Add probe & remove for cn9k & cn10k crypto PMDs.

---
 drivers/crypto/cnxk/cn10k_cryptodev.c     | 98 ++++++++++++++++++++++++++++++-
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 34 +++++++++++
 drivers/crypto/cnxk/cn10k_cryptodev_ops.h | 13 ++++
 drivers/crypto/cnxk/cn9k_cryptodev.c      | 98 ++++++++++++++++++++++++++++++-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 34 +++++++++++
 drivers/crypto/cnxk/cn9k_cryptodev_ops.h  | 12 ++++
 drivers/crypto/cnxk/cnxk_cryptodev.c      | 33 +++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev.h      | 21 +++++++
 drivers/crypto/cnxk/meson.build           |  3 +
 9 files changed, 342 insertions(+), 4 deletions(-)
 create mode 100644 drivers/crypto/cnxk/cn10k_cryptodev_ops.c
 create mode 100644 drivers/crypto/cnxk/cn10k_cryptodev_ops.h
 create mode 100644 drivers/crypto/cnxk/cn9k_cryptodev_ops.c
 create mode 100644 drivers/crypto/cnxk/cn9k_cryptodev_ops.h
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev.h
drivers/crypto/cnxk/cn10k_cryptodev.c +96 -2
index 4d2140c..a66b777 100644
@@ -11,6 +11,8 @@
 #include <rte_pci.h>
 
 #include "cn10k_cryptodev.h"
+#include "cn10k_cryptodev_ops.h"
+#include "cnxk_cryptodev.h"
 #include "roc_api.h"
 
 uint8_t cn10k_cryptodev_driver_id;
@@ -26,11 +28,103 @@ static struct rte_pci_id pci_id_cpt_table[] = {
 	},
 };
 
+static int
+cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+		    struct rte_pci_device *pci_dev)
+{
+	struct rte_cryptodev_pmd_init_params init_params = {
+		.name = "",
+		.socket_id = rte_socket_id(),
+		.private_data_size = sizeof(struct cnxk_cpt_vf)
+	};
+	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
+	struct rte_cryptodev *dev;
+	struct roc_cpt *roc_cpt;
+	struct cnxk_cpt_vf *vf;
+	int rc;
+
+	rc = roc_plt_init();
+	if (rc < 0) {
+		plt_err("Failed to initialize platform model");
+		return rc;
+	}
+
+	rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
+
+	dev = rte_cryptodev_pmd_create(name, &pci_dev->device, &init_params);
+	if (dev == NULL) {
+		rc = -ENODEV;
+		goto exit;
+	}
+
+	/* Get private data space allocated */
+	vf = dev->data->dev_private;
+
+	roc_cpt = &vf->cpt;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		roc_cpt->pci_dev = pci_dev;
+		rc = roc_cpt_dev_init(roc_cpt);
+		if (rc) {
+			plt_err("Failed to initialize roc cpt rc=%d", rc);
+			goto pmd_destroy;
+		}
+
+		rc = cnxk_cpt_eng_grp_add(roc_cpt);
+		if (rc) {
+			plt_err("Failed to add engine group rc=%d", rc);
+			goto dev_fini;
+		}
+	}
+
+	dev->dev_ops = &cn10k_cpt_ops;
+	dev->driver_id = cn10k_cryptodev_driver_id;
+
+	return 0;
+
+dev_fini:
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+		roc_cpt_dev_fini(roc_cpt);
+pmd_destroy:
+	rte_cryptodev_pmd_destroy(dev);
+exit:
+	plt_err("Could not create device (vendor_id: 0x%x device_id: 0x%x)",
+		pci_dev->id.vendor_id, pci_dev->id.device_id);
+	return rc;
+}
+
+static int
+cn10k_cpt_pci_remove(struct rte_pci_device *pci_dev)
+{
+	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+	int ret;
+
+	if (pci_dev == NULL)
+		return -EINVAL;
+
+	rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
+
+	dev = rte_cryptodev_pmd_get_named_dev(name);
+	if (dev == NULL)
+		return -ENODEV;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		vf = dev->data->dev_private;
+		ret = roc_cpt_dev_fini(&vf->cpt);
+		if (ret)
+			return ret;
+	}
+
+	return rte_cryptodev_pmd_destroy(dev);
+}
+
 static struct rte_pci_driver cn10k_cryptodev_pmd = {
 	.id_table = pci_id_cpt_table,
 	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
-	.probe = NULL,
-	.remove = NULL,
+	.probe = cn10k_cpt_pci_probe,
+	.remove = cn10k_cpt_pci_remove,
 };
 
 static struct cryptodev_driver cn10k_cryptodev_drv;
drivers/crypto/cnxk/cn10k_cryptodev_ops.c new file +34 -0
new file mode 100644
index 0000000..6f80f74
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_cryptodev.h>
+#include <rte_cryptodev_pmd.h>
+
+#include "cn10k_cryptodev.h"
+#include "cn10k_cryptodev_ops.h"
+
+struct rte_cryptodev_ops cn10k_cpt_ops = {
+	/* Device control ops */
+	.dev_configure = NULL,
+	.dev_start = NULL,
+	.dev_stop = NULL,
+	.dev_close = NULL,
+	.dev_infos_get = NULL,
+
+	.stats_get = NULL,
+	.stats_reset = NULL,
+	.queue_pair_setup = NULL,
+	.queue_pair_release = NULL,
+
+	/* Symmetric crypto ops */
+	.sym_session_get_size = NULL,
+	.sym_session_configure = NULL,
+	.sym_session_clear = NULL,
+
+	/* Asymmetric crypto ops */
+	.asym_session_get_size = NULL,
+	.asym_session_configure = NULL,
+	.asym_session_clear = NULL,
+
+};
drivers/crypto/cnxk/cn10k_cryptodev_ops.h new file +13 -0
new file mode 100644
index 0000000..24611bf
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _CN10K_CRYPTODEV_OPS_H_
+#define _CN10K_CRYPTODEV_OPS_H_
+
+#include <rte_cryptodev.h>
+#include <rte_cryptodev_pmd.h>
+
+extern struct rte_cryptodev_ops cn10k_cpt_ops;
+
+#endif /* _CN10K_CRYPTODEV_OPS_H_ */
drivers/crypto/cnxk/cn9k_cryptodev.c +96 -2

113 lines not on this page · raw message

drivers/crypto/cnxk/cn9k_cryptodev_ops.c new file +34 -0
new file mode 100644
index 0000000..51f9845
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_cryptodev.h>
+#include <rte_cryptodev_pmd.h>
+
+#include "cn9k_cryptodev.h"
+#include "cn9k_cryptodev_ops.h"
+
+struct rte_cryptodev_ops cn9k_cpt_ops = {
+	/* Device control ops */
+	.dev_configure = NULL,
+	.dev_start = NULL,
+	.dev_stop = NULL,
+	.dev_close = NULL,
+	.dev_infos_get = NULL,
+
+	.stats_get = NULL,
+	.stats_reset = NULL,
+	.queue_pair_setup = NULL,
+	.queue_pair_release = NULL,
+
+	/* Symmetric crypto ops */
+	.sym_session_get_size = NULL,
+	.sym_session_configure = NULL,
+	.sym_session_clear = NULL,
+
+	/* Asymmetric crypto ops */
+	.asym_session_get_size = NULL,
+	.asym_session_configure = NULL,
+	.asym_session_clear = NULL,
+
+};
drivers/crypto/cnxk/cn9k_cryptodev_ops.h new file +12 -0
new file mode 100644
index 0000000..72fc297
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _CN9K_CRYPTODEV_OPS_H_
+#define _CN9K_CRYPTODEV_OPS_H_
+
+#include <rte_cryptodev_pmd.h>
+
+extern struct rte_cryptodev_ops cn9k_cpt_ops;
+
+#endif /* _CN9K_CRYPTODEV_OPS_H_ */
drivers/crypto/cnxk/cnxk_cryptodev.c new file +33 -0
new file mode 100644
index 0000000..0ffe9d0
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "roc_cpt.h"
+
+#include "cnxk_cryptodev.h"
+
+int
+cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt)
+{
+	int ret;
+
+	ret = roc_cpt_eng_grp_add(roc_cpt, CPT_ENG_TYPE_SE);
+	if (ret < 0) {
+		plt_err("Could not add CPT SE engines");
+		return -ENOTSUP;
+	}
+
+	ret = roc_cpt_eng_grp_add(roc_cpt, CPT_ENG_TYPE_IE);
+	if (ret < 0) {
+		plt_err("Could not add CPT IE engines");
+		return -ENOTSUP;
+	}
+
+	ret = roc_cpt_eng_grp_add(roc_cpt, CPT_ENG_TYPE_AE);
+	if (ret < 0) {
+		plt_err("Could not add CPT AE engines");
+		return -ENOTSUP;
+	}
+
+	return 0;
+}
drivers/crypto/cnxk/cnxk_cryptodev.h new file +21 -0
new file mode 100644
index 0000000..5b84f0b
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _CNXK_CRYPTODEV_H_
+#define _CNXK_CRYPTODEV_H_
+
+#include <rte_cryptodev.h>
+
+#include "roc_cpt.h"
+
+/**
+ * Device private data
+ */
+struct cnxk_cpt_vf {
+	struct roc_cpt cpt;
+};
+
+int cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt);
+
+#endif /* _CNXK_CRYPTODEV_H_ */
drivers/crypto/cnxk/meson.build +3 -0
index 197b94c..4150ae6 100644
@@ -10,7 +10,10 @@ endif
 
 sources = files(
         'cn9k_cryptodev.c',
+        'cn9k_cryptodev_ops.c',
         'cn10k_cryptodev.c',
+        'cn10k_cryptodev_ops.c',
+        'cnxk_cryptodev.c',
 )
 
 deps += ['bus_pci', 'common_cnxk']
Signature · 1 line
2.7.4
#7 lore raw

PATCH v2 3/20 crypto/cnxk: add device control ops

In reply to Anoob Joseph

From: Ankur Dwivedi <[email protected]>

Add ops for
- dev_configure()
- dev_start()
- dev_stop()
- dev_close()
- dev_infos_get()

---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 21 +++++++--
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 21 +++++++--
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c  | 77 +++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h  | 24 ++++++++++
 drivers/crypto/cnxk/meson.build           |  1 +
 5 files changed, 134 insertions(+), 10 deletions(-)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_ops.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_ops.h
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +16 -5
index 6f80f74..b0eccb3 100644
@@ -7,14 +7,25 @@
 
 #include "cn10k_cryptodev.h"
 #include "cn10k_cryptodev_ops.h"
+#include "cnxk_cryptodev_ops.h"
+
+static void
+cn10k_cpt_dev_info_get(struct rte_cryptodev *dev,
+		       struct rte_cryptodev_info *info)
+{
+	if (info != NULL) {
+		cnxk_cpt_dev_info_get(dev, info);
+		info->driver_id = cn10k_cryptodev_driver_id;
+	}
+}
 
 struct rte_cryptodev_ops cn10k_cpt_ops = {
 	/* Device control ops */
-	.dev_configure = NULL,
-	.dev_start = NULL,
-	.dev_stop = NULL,
-	.dev_close = NULL,
-	.dev_infos_get = NULL,
+	.dev_configure = cnxk_cpt_dev_config,
+	.dev_start = cnxk_cpt_dev_start,
+	.dev_stop = cnxk_cpt_dev_stop,
+	.dev_close = cnxk_cpt_dev_close,
+	.dev_infos_get = cn10k_cpt_dev_info_get,
 
 	.stats_get = NULL,
 	.stats_reset = NULL,
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +16 -5
index 51f9845..acfb071 100644
@@ -7,14 +7,25 @@
 
 #include "cn9k_cryptodev.h"
 #include "cn9k_cryptodev_ops.h"
+#include "cnxk_cryptodev_ops.h"
+
+static void
+cn9k_cpt_dev_info_get(struct rte_cryptodev *dev,
+		      struct rte_cryptodev_info *info)
+{
+	if (info != NULL) {
+		cnxk_cpt_dev_info_get(dev, info);
+		info->driver_id = cn9k_cryptodev_driver_id;
+	}
+}
 
 struct rte_cryptodev_ops cn9k_cpt_ops = {
 	/* Device control ops */
-	.dev_configure = NULL,
-	.dev_start = NULL,
-	.dev_stop = NULL,
-	.dev_close = NULL,
-	.dev_infos_get = NULL,
+	.dev_configure = cnxk_cpt_dev_config,
+	.dev_start = cnxk_cpt_dev_start,
+	.dev_stop = cnxk_cpt_dev_stop,
+	.dev_close = cnxk_cpt_dev_close,
+	.dev_infos_get = cn9k_cpt_dev_info_get,
 
 	.stats_get = NULL,
 	.stats_reset = NULL,
drivers/crypto/cnxk/cnxk_cryptodev_ops.c new file +77 -0

77 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_ops.h new file +24 -0
new file mode 100644
index 0000000..05c2623
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _CNXK_CRYPTODEV_OPS_H_
+#define _CNXK_CRYPTODEV_OPS_H_
+
+#include <rte_cryptodev.h>
+
+#define CNXK_CPT_MIN_HEADROOM_REQ 24
+
+int cnxk_cpt_dev_config(struct rte_cryptodev *dev,
+			struct rte_cryptodev_config *conf);
+
+int cnxk_cpt_dev_start(struct rte_cryptodev *dev);
+
+void cnxk_cpt_dev_stop(struct rte_cryptodev *dev);
+
+int cnxk_cpt_dev_close(struct rte_cryptodev *dev);
+
+void cnxk_cpt_dev_info_get(struct rte_cryptodev *dev,
+			   struct rte_cryptodev_info *info);
+
+#endif /* _CNXK_CRYPTODEV_OPS_H_ */
drivers/crypto/cnxk/meson.build +1 -0
index 4150ae6..74b7795 100644
@@ -14,6 +14,7 @@ sources = files(
         'cn10k_cryptodev.c',
         'cn10k_cryptodev_ops.c',
         'cnxk_cryptodev.c',
+        'cnxk_cryptodev_ops.c',
 )
 
 deps += ['bus_pci', 'common_cnxk']
Signature · 1 line
2.7.4
#8 lore raw

PATCH v2 4/20 crypto/cnxk: add queue pair ops

In reply to Anoob Joseph

From: Ankur Dwivedi <[email protected]>

Add ops for
- queue_pair_setup()
- queue_pair_release()

---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c |   4 +-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  |   4 +-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c  | 253 ++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |  48 ++++++
 4 files changed, 305 insertions(+), 4 deletions(-)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +2 -2
index b0eccb3..007d449 100644
@@ -29,8 +29,8 @@ struct rte_cryptodev_ops cn10k_cpt_ops = {
 
 	.stats_get = NULL,
 	.stats_reset = NULL,
-	.queue_pair_setup = NULL,
-	.queue_pair_release = NULL,
+	.queue_pair_setup = cnxk_cpt_queue_pair_setup,
+	.queue_pair_release = cnxk_cpt_queue_pair_release,
 
 	/* Symmetric crypto ops */
 	.sym_session_get_size = NULL,
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +2 -2
index acfb071..73ccf5b 100644
@@ -29,8 +29,8 @@ struct rte_cryptodev_ops cn9k_cpt_ops = {
 
 	.stats_get = NULL,
 	.stats_reset = NULL,
-	.queue_pair_setup = NULL,
-	.queue_pair_release = NULL,
+	.queue_pair_setup = cnxk_cpt_queue_pair_setup,
+	.queue_pair_release = cnxk_cpt_queue_pair_release,
 
 	/* Symmetric crypto ops */
 	.sym_session_get_size = NULL,
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +253 -0

268 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_ops.h +48 -0

60 lines not on this page · raw message

Signature · 1 line
2.7.4
#9 lore raw

PATCH v2 5/20 crypto/cnxk: add session ops framework

In reply to Anoob Joseph

Add session ops
- sym_session_get_size
- sym_session_configure
- sym_session_clear

---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c |   6 +-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  |   6 +-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c  | 187 ++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |  27 +++++
 drivers/crypto/cnxk/cnxk_se.h             |  31 +++++
 5 files changed, 251 insertions(+), 6 deletions(-)
 create mode 100644 drivers/crypto/cnxk/cnxk_se.h
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +3 -3
index 007d449..34dc107 100644
@@ -33,9 +33,9 @@ struct rte_cryptodev_ops cn10k_cpt_ops = {
 	.queue_pair_release = cnxk_cpt_queue_pair_release,
 
 	/* Symmetric crypto ops */
-	.sym_session_get_size = NULL,
-	.sym_session_configure = NULL,
-	.sym_session_clear = NULL,
+	.sym_session_get_size = cnxk_cpt_sym_session_get_size,
+	.sym_session_configure = cnxk_cpt_sym_session_configure,
+	.sym_session_clear = cnxk_cpt_sym_session_clear,
 
 	/* Asymmetric crypto ops */
 	.asym_session_get_size = NULL,
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +3 -3
index 73ccf5b..bef6159 100644
@@ -33,9 +33,9 @@ struct rte_cryptodev_ops cn9k_cpt_ops = {
 	.queue_pair_release = cnxk_cpt_queue_pair_release,
 
 	/* Symmetric crypto ops */
-	.sym_session_get_size = NULL,
-	.sym_session_configure = NULL,
-	.sym_session_clear = NULL,
+	.sym_session_get_size = cnxk_cpt_sym_session_get_size,
+	.sym_session_configure = cnxk_cpt_sym_session_configure,
+	.sym_session_clear = cnxk_cpt_sym_session_clear,
 
 	/* Asymmetric crypto ops */
 	.asym_session_get_size = NULL,
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +187 -0

196 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_ops.h +27 -0
index f9440f9..0a3c705 100644
@@ -16,6 +16,16 @@ struct cpt_qp_meta_info {
 	int mlen;
 };
 
+enum sym_xform_type {
+	CNXK_CPT_CIPHER = 1,
+	CNXK_CPT_AUTH,
+	CNXK_CPT_AEAD,
+	CNXK_CPT_CIPHER_ENC_AUTH_GEN,
+	CNXK_CPT_AUTH_VRFY_CIPHER_DEC,
+	CNXK_CPT_AUTH_GEN_CIPHER_ENC,
+	CNXK_CPT_CIPHER_DEC_AUTH_VRFY
+};
+
 struct cpt_inflight_req {
 	union cpt_res_s res;
 	struct rte_crypto_op *cop;
@@ -69,4 +79,21 @@ int cnxk_cpt_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 
 int cnxk_cpt_queue_pair_release(struct rte_cryptodev *dev, uint16_t qp_id);
 
+unsigned int cnxk_cpt_sym_session_get_size(struct rte_cryptodev *dev);
+
+int cnxk_cpt_sym_session_configure(struct rte_cryptodev *dev,
+				   struct rte_crypto_sym_xform *xform,
+				   struct rte_cryptodev_sym_session *sess,
+				   struct rte_mempool *pool);
+
+int sym_session_configure(struct roc_cpt *roc_cpt, int driver_id,
+			  struct rte_crypto_sym_xform *xform,
+			  struct rte_cryptodev_sym_session *sess,
+			  struct rte_mempool *pool);
+
+void cnxk_cpt_sym_session_clear(struct rte_cryptodev *dev,
+				struct rte_cryptodev_sym_session *sess);
+
+void sym_session_clear(int driver_id, struct rte_cryptodev_sym_session *sess);
+
 #endif /* _CNXK_CRYPTODEV_OPS_H_ */
drivers/crypto/cnxk/cnxk_se.h new file +31 -0
new file mode 100644
index 0000000..9cccab0
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _CNXK_SE_H_
+#define _CNXK_SE_H_
+#include <stdbool.h>
+
+#include "roc_se.h"
+
+struct cnxk_se_sess {
+	uint16_t cpt_op : 4;
+	uint16_t zsk_flag : 4;
+	uint16_t aes_gcm : 1;
+	uint16_t aes_ctr : 1;
+	uint16_t chacha_poly : 1;
+	uint16_t is_null : 1;
+	uint16_t is_gmac : 1;
+	uint16_t rsvd1 : 3;
+	uint16_t aad_length;
+	uint8_t mac_len;
+	uint8_t iv_length;
+	uint8_t auth_iv_length;
+	uint16_t iv_offset;
+	uint16_t auth_iv_offset;
+	uint32_t salt;
+	uint64_t cpt_inst_w7;
+	struct roc_se_ctx roc_se_ctx;
+} __rte_cache_aligned;
+
+#endif /*_CNXK_SE_H_ */
Signature · 1 line
2.7.4
#10 lore raw

PATCH v2 6/20 crypto/cnxk: add enqueue burst op

In reply to Anoob Joseph

Add enqueue_burst op in cn9k & cn10k.

---
 drivers/crypto/cnxk/cn10k_cryptodev.c     |   2 +
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 189 ++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cn10k_cryptodev_ops.h |   2 +
 drivers/crypto/cnxk/cn9k_cryptodev.c      |   2 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 154 ++++++++++++++++++++++++
 drivers/crypto/cnxk/cn9k_cryptodev_ops.h  |   2 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |   9 ++
 7 files changed, 360 insertions(+)
drivers/crypto/cnxk/cn10k_cryptodev.c +2 -0
index a66b777..53f7a94 100644
@@ -80,6 +80,8 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	dev->dev_ops = &cn10k_cpt_ops;
 	dev->driver_id = cn10k_cryptodev_driver_id;
 
+	cn10k_cpt_set_enqdeq_fns(dev);
+
 	return 0;
 
 dev_fini:
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +189 -0

196 lines not on this page · raw message

drivers/crypto/cnxk/cn10k_cryptodev_ops.h +2 -0
index 24611bf..d500b7d 100644
@@ -10,4 +10,6 @@
 
 extern struct rte_cryptodev_ops cn10k_cpt_ops;
 
+void cn10k_cpt_set_enqdeq_fns(struct rte_cryptodev *dev);
+
 #endif /* _CN10K_CRYPTODEV_OPS_H_ */
drivers/crypto/cnxk/cn9k_cryptodev.c +2 -0
index 46ad33f..4dbb40d 100644
@@ -78,6 +78,8 @@ cn9k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	dev->dev_ops = &cn9k_cpt_ops;
 	dev->driver_id = cn9k_cryptodev_driver_id;
 
+	cn9k_cpt_set_enqdeq_fns(dev);
+
 	return 0;
 
 dev_fini:
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +154 -0

161 lines not on this page · raw message

drivers/crypto/cnxk/cn9k_cryptodev_ops.h +2 -0
index 72fc297..2277f6b 100644
@@ -9,4 +9,6 @@
 
 extern struct rte_cryptodev_ops cn9k_cpt_ops;
 
+void cn9k_cpt_set_enqdeq_fns(struct rte_cryptodev *dev);
+
 #endif /* _CN9K_CRYPTODEV_OPS_H_ */
drivers/crypto/cnxk/cnxk_cryptodev_ops.h +9 -0
index 0a3c705..7995959 100644
@@ -11,6 +11,11 @@
 
 #define CNXK_CPT_MIN_HEADROOM_REQ 24
 
+/* Default command timeout in seconds */
+#define DEFAULT_COMMAND_TIMEOUT 4
+
+#define MOD_INC(i, l) ((i) == (l - 1) ? (i) = 0 : (i)++)
+
 struct cpt_qp_meta_info {
 	struct rte_mempool *pool;
 	int mlen;
@@ -26,6 +31,10 @@ enum sym_xform_type {
 	CNXK_CPT_CIPHER_DEC_AUTH_VRFY
 };
 
+#define CPT_OP_FLAGS_METABUF	       (1 << 1)
+#define CPT_OP_FLAGS_AUTH_VERIFY       (1 << 0)
+#define CPT_OP_FLAGS_IPSEC_DIR_INBOUND (1 << 2)
+
 struct cpt_inflight_req {
 	union cpt_res_s res;
 	struct rte_crypto_op *cop;
Signature · 1 line
2.7.4
#11 lore raw

PATCH v2 7/20 crypto/cnxk: add dequeue burst op

In reply to Anoob Joseph

Add dequeue_burst op in cn9k & cn10k.

---
 doc/guides/cryptodevs/features/cn10k.ini  |   3 +
 doc/guides/cryptodevs/features/cn9k.ini   |   3 +
 drivers/crypto/cnxk/cn10k_cryptodev.c     |   4 ++
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 105 ++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cn9k_cryptodev.c      |   4 ++
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 103 +++++++++++++++++++++++++++++
 6 files changed, 222 insertions(+)
doc/guides/cryptodevs/features/cn10k.ini +3 -0
index 0aa097d..7f433fa 100644
@@ -4,6 +4,9 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Symmetric crypto       = Y
+HW Accelerated         = Y
+Symmetric sessionless  = Y
 
 ;
 ; Supported crypto algorithms of 'cn10k' crypto driver.
doc/guides/cryptodevs/features/cn9k.ini +3 -0
index 64ee929..9c9d54d 100644
@@ -4,6 +4,9 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Symmetric crypto       = Y
+HW Accelerated         = Y
+Symmetric sessionless  = Y
 
 ;
 ; Supported crypto algorithms of 'cn9k' crypto driver.
drivers/crypto/cnxk/cn10k_cryptodev.c +4 -0
index 53f7a94..31addc0 100644
@@ -80,6 +80,10 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	dev->dev_ops = &cn10k_cpt_ops;
 	dev->driver_id = cn10k_cryptodev_driver_id;
 
+	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
+			     RTE_CRYPTODEV_FF_HW_ACCELERATED |
+			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS;
+
 	cn10k_cpt_set_enqdeq_fns(dev);
 
 	return 0;
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +105 -0

115 lines not on this page · raw message

drivers/crypto/cnxk/cn9k_cryptodev.c +4 -0
index 4dbb40d..7908896 100644
@@ -78,6 +78,10 @@ cn9k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	dev->dev_ops = &cn9k_cpt_ops;
 	dev->driver_id = cn9k_cryptodev_driver_id;
 
+	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
+			     RTE_CRYPTODEV_FF_HW_ACCELERATED |
+			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS;
+
 	cn9k_cpt_set_enqdeq_fns(dev);
 
 	return 0;
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +103 -0

113 lines not on this page · raw message

Signature · 1 line
2.7.4
#12 lore raw

PATCH v2 8/20 crypto/cnxk: add cipher operation in session

In reply to Anoob Joseph

Add support for cipher operation in session.

---
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c |   3 +
 drivers/crypto/cnxk/cnxk_se.h            | 106 +++++++++++++++++++++++++++++++
 2 files changed, 109 insertions(+)
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +3 -0
index 8ef0e6f..b6d3076 100644
@@ -457,6 +457,9 @@ sym_session_configure(struct roc_cpt *roc_cpt, int driver_id,
 	sess_priv = priv;
 
 	switch (ret) {
+	case CNXK_CPT_CIPHER:
+		ret = fill_sess_cipher(xform, sess_priv);
+		break;
 	default:
 		ret = -1;
 	}
drivers/crypto/cnxk/cnxk_se.h +106 -0

110 lines not on this page · raw message

Signature · 1 line
2.7.4
#13 lore raw

PATCH v2 9/20 crypto/cnxk: add auth operation in session

In reply to Anoob Joseph

Add support for auth operations in session.

---
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c |  13 +++
 drivers/crypto/cnxk/cnxk_se.h            | 194 +++++++++++++++++++++++++++++++
 2 files changed, 207 insertions(+)
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +13 -0
index b6d3076..f2319df 100644
@@ -460,6 +460,12 @@ sym_session_configure(struct roc_cpt *roc_cpt, int driver_id,
 	case CNXK_CPT_CIPHER:
 		ret = fill_sess_cipher(xform, sess_priv);
 		break;
+	case CNXK_CPT_AUTH:
+		if (xform->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC)
+			ret = fill_sess_gmac(xform, sess_priv);
+		else
+			ret = fill_sess_auth(xform, sess_priv);
+		break;
 	default:
 		ret = -1;
 	}
@@ -467,6 +473,13 @@ sym_session_configure(struct roc_cpt *roc_cpt, int driver_id,
 	if (ret)
 		goto priv_put;
 
+	if ((sess_priv->roc_se_ctx.fc_type == ROC_SE_HASH_HMAC) &&
+	    cpt_mac_len_verify(&xform->auth)) {
+		plt_dp_err("MAC length is not supported");
+		ret = -ENOTSUP;
+		goto priv_put;
+	}
+
 	sess_priv->cpt_inst_w7 = cnxk_cpt_inst_w7_get(sess_priv, roc_cpt);
 
 	set_sym_session_private_data(sess, driver_id, sess_priv);
drivers/crypto/cnxk/cnxk_se.h +194 -0

204 lines not on this page · raw message

Signature · 1 line
2.7.4
#14 lore raw

PATCH v2 10/20 crypto/cnxk: add aead operation in session

In reply to Anoob Joseph

From: Archana Muniganti <[email protected]>

Add support for AEAD operations in session.

---
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c |  3 ++
 drivers/crypto/cnxk/cnxk_se.h            | 64 ++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +3 -0
index f2319df..acb9f1f 100644
@@ -466,6 +466,9 @@ sym_session_configure(struct roc_cpt *roc_cpt, int driver_id,
 		else
 			ret = fill_sess_auth(xform, sess_priv);
 		break;
+	case CNXK_CPT_AEAD:
+		ret = fill_sess_aead(xform, sess_priv);
+		break;
 	default:
 		ret = -1;
 	}
drivers/crypto/cnxk/cnxk_se.h +64 -0

70 lines not on this page · raw message

Signature · 1 line
2.7.4
#15 lore raw

PATCH v2 11/20 crypto/cnxk: add chained operation in session

In reply to Anoob Joseph

From: Archana Muniganti <[email protected]>

Add support for chained operations in session.

---
 doc/guides/cryptodevs/features/cn10k.ini |  2 ++
 doc/guides/cryptodevs/features/cn9k.ini  |  2 ++
 drivers/crypto/cnxk/cn10k_cryptodev.c    |  4 +++-
 drivers/crypto/cnxk/cn9k_cryptodev.c     |  4 +++-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 14 ++++++++++++++
 5 files changed, 24 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/features/cn10k.ini +2 -0
index 7f433fa..175fbf7 100644
@@ -5,8 +5,10 @@
 ;
 [Features]
 Symmetric crypto       = Y
+Sym operation chaining = Y
 HW Accelerated         = Y
 Symmetric sessionless  = Y
+Digest encrypted       = Y
 
 ;
 ; Supported crypto algorithms of 'cn10k' crypto driver.
doc/guides/cryptodevs/features/cn9k.ini +2 -0
index 9c9d54d..c22b25c 100644
@@ -5,8 +5,10 @@
 ;
 [Features]
 Symmetric crypto       = Y
+Sym operation chaining = Y
 HW Accelerated         = Y
 Symmetric sessionless  = Y
+Digest encrypted       = Y
 
 ;
 ; Supported crypto algorithms of 'cn9k' crypto driver.
drivers/crypto/cnxk/cn10k_cryptodev.c +3 -1
index 31addc0..8a31290 100644
@@ -82,7 +82,9 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
 			     RTE_CRYPTODEV_FF_HW_ACCELERATED |
-			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS;
+			     RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
+			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS |
+			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
 
 	cn10k_cpt_set_enqdeq_fns(dev);
 
drivers/crypto/cnxk/cn9k_cryptodev.c +3 -1
index 7908896..6b5c9e3 100644
@@ -80,7 +80,9 @@ cn9k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
 			     RTE_CRYPTODEV_FF_HW_ACCELERATED |
-			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS;
+			     RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
+			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS |
+			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
 
 	cn9k_cpt_set_enqdeq_fns(dev);
 
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +14 -0
index acb9f1f..10bb191 100644
@@ -469,6 +469,20 @@ sym_session_configure(struct roc_cpt *roc_cpt, int driver_id,
 	case CNXK_CPT_AEAD:
 		ret = fill_sess_aead(xform, sess_priv);
 		break;
+	case CNXK_CPT_CIPHER_ENC_AUTH_GEN:
+	case CNXK_CPT_CIPHER_DEC_AUTH_VRFY:
+		ret = fill_sess_cipher(xform, sess_priv);
+		if (ret < 0)
+			break;
+		ret = fill_sess_auth(xform->next, sess_priv);
+		break;
+	case CNXK_CPT_AUTH_VRFY_CIPHER_DEC:
+	case CNXK_CPT_AUTH_GEN_CIPHER_ENC:
+		ret = fill_sess_auth(xform, sess_priv);
+		if (ret < 0)
+			break;
+		ret = fill_sess_cipher(xform->next, sess_priv);
+		break;
 	default:
 		ret = -1;
 	}
Signature · 1 line
2.7.4
#16 lore raw

PATCH v2 12/20 crypto/cnxk: add flexi crypto cipher encrypt

In reply to Anoob Joseph

From: Archana Muniganti <[email protected]>

Add flexi crypto cipher encrypt in enqueue API. Flexi crypto opcode covers a broad set of ciphers including variants of AES.

---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c |  14 +-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  |  14 +-
 drivers/crypto/cnxk/cnxk_se.h             | 818 +++++++++++++++++++++++++++++-
 3 files changed, 833 insertions(+), 13 deletions(-)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +8 -6
index ec301f4..8af2ce9 100644
@@ -46,13 +46,15 @@ cpt_sym_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 		  struct cnxk_se_sess *sess, struct cpt_inflight_req *infl_req,
 		  struct cpt_inst_s *inst)
 {
-	RTE_SET_USED(qp);
-	RTE_SET_USED(op);
-	RTE_SET_USED(sess);
-	RTE_SET_USED(infl_req);
-	RTE_SET_USED(inst);
+	uint64_t cpt_op;
+	int ret;
+
+	cpt_op = sess->cpt_op;
+
+	if (cpt_op & ROC_SE_OP_CIPHER_MASK)
+		ret = fill_fc_params(op, sess, &qp->meta_info, infl_req, inst);
 
-	return -ENOTSUP;
+	return ret;
 }
 
 static inline int
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +8 -6
index 27076a8..e8189d0 100644
@@ -17,13 +17,15 @@ cn9k_cpt_sym_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 		       struct cpt_inflight_req *infl_req,
 		       struct cpt_inst_s *inst)
 {
-	RTE_SET_USED(qp);
-	RTE_SET_USED(op);
-	RTE_SET_USED(sess);
-	RTE_SET_USED(infl_req);
-	RTE_SET_USED(inst);
+	uint64_t cpt_op;
+	int ret;
+
+	cpt_op = sess->cpt_op;
+
+	if (cpt_op & ROC_SE_OP_CIPHER_MASK)
+		ret = fill_fc_params(op, sess, &qp->meta_info, infl_req, inst);
 
-	return -ENOTSUP;
+	return ret;
 }
 
 static inline struct cnxk_se_sess *
drivers/crypto/cnxk/cnxk_se.h +817 -1

834 lines not on this page · raw message

Signature · 1 line
2.7.4
#17 lore raw

PATCH v2 13/20 crypto/cnxk: add flexi crypto cipher decrypt

In reply to Anoob Joseph

From: Archana Muniganti <[email protected]>

Add flexi crypto cipher decrypt support in enqueue API. Flexi crypto opcode covers a broad set of ciphers including variants of AES.

---
 doc/guides/cryptodevs/features/cn10k.ini |  20 ++
 doc/guides/cryptodevs/features/cn9k.ini  |  20 ++
 drivers/crypto/cnxk/cn10k_cryptodev.c    |   4 +
 drivers/crypto/cnxk/cn9k_cryptodev.c     |   4 +
 drivers/crypto/cnxk/cnxk_se.h            | 324 ++++++++++++++++++++++++++++++-
 5 files changed, 371 insertions(+), 1 deletion(-)
doc/guides/cryptodevs/features/cn10k.ini +20 -0
index 175fbf7..7750d92 100644
@@ -7,6 +7,10 @@
 Symmetric crypto       = Y
 Sym operation chaining = Y
 HW Accelerated         = Y
+In Place SGL           = Y
+OOP SGL In LB  Out     = Y
+OOP SGL In SGL Out     = Y
+OOP LB  In LB  Out     = Y
 Symmetric sessionless  = Y
 Digest encrypted       = Y
 
@@ -14,6 +18,18 @@ Digest encrypted       = Y
 ; Supported crypto algorithms of 'cn10k' crypto driver.
 ;
 [Cipher]
+NULL           = Y
+3DES CBC       = Y
+3DES ECB       = Y
+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
+DES CBC        = Y
 
 ;
 ; Supported authentication algorithms of 'cn10k' crypto driver.
@@ -24,3 +40,7 @@ Digest encrypted       = Y
 ; Supported AEAD algorithms of 'cn10k' crypto driver.
 ;
 [AEAD]
+AES GCM (128)     = Y
+AES GCM (192)     = Y
+AES GCM (256)     = Y
+CHACHA20-POLY1305 = Y
doc/guides/cryptodevs/features/cn9k.ini +20 -0
index c22b25c..7007d11 100644
@@ -7,6 +7,10 @@
 Symmetric crypto       = Y
 Sym operation chaining = Y
 HW Accelerated         = Y
+In Place SGL           = Y
+OOP SGL In LB  Out     = Y
+OOP SGL In SGL Out     = Y
+OOP LB  In LB  Out     = Y
 Symmetric sessionless  = Y
 Digest encrypted       = Y
 
@@ -14,6 +18,18 @@ Digest encrypted       = Y
 ; Supported crypto algorithms of 'cn9k' crypto driver.
 ;
 [Cipher]
+NULL           = Y
+3DES CBC       = Y
+3DES ECB       = Y
+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
+DES CBC        = Y
 
 ;
 ; Supported authentication algorithms of 'cn9k' crypto driver.
@@ -24,3 +40,7 @@ Digest encrypted       = Y
 ; Supported AEAD algorithms of 'cn9k' crypto driver.
 ;
 [AEAD]
+AES GCM (128)     = Y
+AES GCM (192)     = Y
+AES GCM (256)     = Y
+CHACHA20-POLY1305 = Y
drivers/crypto/cnxk/cn10k_cryptodev.c +4 -0
index 8a31290..2ae61b5 100644
@@ -83,6 +83,10 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
 			     RTE_CRYPTODEV_FF_HW_ACCELERATED |
 			     RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
+			     RTE_CRYPTODEV_FF_IN_PLACE_SGL |
+			     RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT |
+			     RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
+			     RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |
 			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS |
 			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
 
drivers/crypto/cnxk/cn9k_cryptodev.c +4 -0
index 6b5c9e3..9a2d565 100644
@@ -81,6 +81,10 @@ cn9k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
 			     RTE_CRYPTODEV_FF_HW_ACCELERATED |
 			     RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
+			     RTE_CRYPTODEV_FF_IN_PLACE_SGL |
+			     RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT |
+			     RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
+			     RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |
 			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS |
 			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
 
drivers/crypto/cnxk/cnxk_se.h +323 -1

336 lines not on this page · raw message

Signature · 1 line
2.7.4
#18 lore raw

PATCH v2 14/20 crypto/cnxk: add ZUC and SNOW3G encrypt

In reply to Anoob Joseph

From: Archana Muniganti <[email protected]>

Add PDCP opcode which handles ZUC and SNOW3G.

---
 drivers/crypto/cnxk/cnxk_se.h | 268 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 267 insertions(+), 1 deletion(-)
drivers/crypto/cnxk/cnxk_se.h +267 -1
index e8be663..7d3bcbc 100644
@@ -817,6 +817,268 @@ cpt_dec_hmac_prep(uint32_t flags, uint64_t d_offs, uint64_t d_lens,
 }
 
 static __rte_always_inline int
+cpt_zuc_snow3g_enc_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,
+			struct roc_se_fc_params *params,
+			struct cpt_inst_s *inst)
+{
+	uint32_t size;
+	int32_t inputlen, outputlen;
+	struct roc_se_ctx *se_ctx;
+	uint32_t mac_len = 0;
+	uint8_t pdcp_alg_type, j;
+	uint32_t encr_offset = 0, auth_offset = 0;
+	uint32_t encr_data_len = 0, auth_data_len = 0;
+	int flags, iv_len = 16;
+	uint64_t offset_ctrl;
+	uint64_t *offset_vaddr;
+	uint32_t *iv_s, iv[4];
+	union cpt_inst_w4 cpt_inst_w4;
+
+	se_ctx = params->ctx_buf.vaddr;
+	flags = se_ctx->zsk_flags;
+	mac_len = se_ctx->mac_len;
+	pdcp_alg_type = se_ctx->pdcp_alg_type;
+
+	cpt_inst_w4.s.opcode_major = ROC_SE_MAJOR_OP_ZUC_SNOW3G;
+
+	/* indicates CPTR ctx, operation type, KEY & IV mode from DPTR */
+
+	cpt_inst_w4.s.opcode_minor = ((1 << 7) | (pdcp_alg_type << 5) |
+				      (0 << 4) | (0 << 3) | (flags & 0x7));
+
+	if (flags == 0x1) {
+		/*
+		 * Microcode expects offsets in bytes
+		 * TODO: Rounding off
+		 */
+		auth_data_len = ROC_SE_AUTH_DLEN(d_lens);
+
+		/* EIA3 or UIA2 */
+		auth_offset = ROC_SE_AUTH_OFFSET(d_offs);
+		auth_offset = auth_offset / 8;
+
+		/* consider iv len */
+		auth_offset += iv_len;
+
+		inputlen = auth_offset + (RTE_ALIGN(auth_data_len, 8) / 8);
+		outputlen = mac_len;
+
+		offset_ctrl = rte_cpu_to_be_64((uint64_t)auth_offset);
+
+	} else {
+		/* EEA3 or UEA2 */
+		/*
+		 * Microcode expects offsets in bytes
+		 * TODO: Rounding off
+		 */
+		encr_data_len = ROC_SE_ENCR_DLEN(d_lens);
+
+		encr_offset = ROC_SE_ENCR_OFFSET(d_offs);
+		encr_offset = encr_offset / 8;
+		/* consider iv len */
+		encr_offset += iv_len;
+
+		inputlen = encr_offset + (RTE_ALIGN(encr_data_len, 8) / 8);
+		outputlen = inputlen;
+
+		/* iv offset is 0 */
+		offset_ctrl = rte_cpu_to_be_64((uint64_t)encr_offset << 16);
+	}
+
+	if (unlikely((encr_offset >> 16) || (auth_offset >> 8))) {
+		plt_dp_err("Offset not supported");
+		plt_dp_err("enc_offset: %d", encr_offset);
+		plt_dp_err("auth_offset: %d", auth_offset);
+		return -1;
+	}
+
+	/* IV */
+	iv_s = (flags == 0x1) ? params->auth_iv_buf : params->iv_buf;
+
+	if (pdcp_alg_type == ROC_SE_PDCP_ALG_TYPE_SNOW3G) {
+		/*
+		 * DPDK seems to provide it in form of IV3 IV2 IV1 IV0
+		 * and BigEndian, MC needs it as IV0 IV1 IV2 IV3
+		 */
+
+		for (j = 0; j < 4; j++)
+			iv[j] = iv_s[3 - j];
+	} else {
+		/* ZUC doesn't need a swap */
+		for (j = 0; j < 4; j++)
+			iv[j] = iv_s[j];
+	}
+
+	/*
+	 * GP op header, lengths are expected in bits.
+	 */
+	cpt_inst_w4.s.param1 = encr_data_len;
+	cpt_inst_w4.s.param2 = auth_data_len;
+
+	/*
+	 * In cn9k, cn10k since we have a limitation of
+	 * IV & Offset control word not part of instruction
+	 * and need to be part of Data Buffer, we check if
+	 * head room is there and then only do the Direct mode processing
+	 */
+	if (likely((req_flags & ROC_SE_SINGLE_BUF_INPLACE) &&
+		   (req_flags & ROC_SE_SINGLE_BUF_HEADROOM))) {
+		void *dm_vaddr = params->bufs[0].vaddr;
+
+		/* Use Direct mode */
+
+		offset_vaddr = (uint64_t *)((uint8_t *)dm_vaddr -
+					    ROC_SE_OFF_CTRL_LEN - iv_len);
+
+		/* DPTR */
+		inst->dptr = (uint64_t)offset_vaddr;
+		/* RPTR should just exclude offset control word */
+		inst->rptr = (uint64_t)dm_vaddr - iv_len;
+
+		cpt_inst_w4.s.dlen = inputlen + ROC_SE_OFF_CTRL_LEN;
+
+		if (likely(iv_len)) {
+			uint32_t *iv_d = (uint32_t *)((uint8_t *)offset_vaddr +
+						      ROC_SE_OFF_CTRL_LEN);
+			memcpy(iv_d, iv, 16);
+		}
+
+		*offset_vaddr = offset_ctrl;
+	} else {
+		void *m_vaddr = params->meta_buf.vaddr;
+		uint32_t i, g_size_bytes, s_size_bytes;
+		struct roc_se_sglist_comp *gather_comp;
+		struct roc_se_sglist_comp *scatter_comp;
+		uint8_t *in_buffer;
+		uint32_t *iv_d;
+
+		/* save space for iv */
+		offset_vaddr = m_vaddr;
+
+		m_vaddr = (uint8_t *)m_vaddr + ROC_SE_OFF_CTRL_LEN + iv_len;
+
+		cpt_inst_w4.s.opcode_major |= (uint64_t)ROC_SE_DMA_MODE;
+
+		/* DPTR has SG list */
+		in_buffer = m_vaddr;
+
+		((uint16_t *)in_buffer)[0] = 0;
+		((uint16_t *)in_buffer)[1] = 0;
+
+		/* TODO Add error check if space will be sufficient */
+		gather_comp =
+			(struct roc_se_sglist_comp *)((uint8_t *)m_vaddr + 8);
+
+		/*
+		 * Input Gather List
+		 */
+		i = 0;
+
+		/* Offset control word followed by iv */
+
+		i = fill_sg_comp(gather_comp, i, (uint64_t)offset_vaddr,
+				 ROC_SE_OFF_CTRL_LEN + iv_len);
+
+		/* iv offset is 0 */
+		*offset_vaddr = offset_ctrl;
+
+		iv_d = (uint32_t *)((uint8_t *)offset_vaddr +
+				    ROC_SE_OFF_CTRL_LEN);
+		memcpy(iv_d, iv, 16);
+
+		/* input data */
+		size = inputlen - iv_len;
+		if (size) {
+			i = fill_sg_comp_from_iov(gather_comp, i,
+						  params->src_iov, 0, &size,
+						  NULL, 0);
+			if (unlikely(size)) {
+				plt_dp_err("Insufficient buffer space,"
+					   " size %d needed",
+					   size);
+				return -1;
+			}
+		}
+		((uint16_t *)in_buffer)[2] = rte_cpu_to_be_16(i);
+		g_size_bytes =
+			((i + 3) / 4) * sizeof(struct roc_se_sglist_comp);
+
+		/*
+		 * Output Scatter List
+		 */
+
+		i = 0;
+		scatter_comp =
+			(struct roc_se_sglist_comp *)((uint8_t *)gather_comp +
+						      g_size_bytes);
+
+		if (flags == 0x1) {
+			/* IV in SLIST only for EEA3 & UEA2 */
+			iv_len = 0;
+		}
+
+		if (iv_len) {
+			i = fill_sg_comp(scatter_comp, i,
+					 (uint64_t)offset_vaddr +
+						 ROC_SE_OFF_CTRL_LEN,
+					 iv_len);
+		}
+
+		/* Add output data */
+		if (req_flags & ROC_SE_VALID_MAC_BUF) {
+			size = outputlen - iv_len - mac_len;
+			if (size) {
+				i = fill_sg_comp_from_iov(scatter_comp, i,
+							  params->dst_iov, 0,
+							  &size, NULL, 0);
+
+				if (unlikely(size)) {
+					plt_dp_err("Insufficient buffer space,"
+						   " size %d needed",
+						   size);
+					return -1;
+				}
+			}
+
+			/* mac data */
+			if (mac_len) {
+				i = fill_sg_comp_from_buf(scatter_comp, i,
+							  &params->mac_buf);
+			}
+		} else {
+			/* Output including mac */
+			size = outputlen - iv_len;
+			if (size) {
+				i = fill_sg_comp_from_iov(scatter_comp, i,
+							  params->dst_iov, 0,
+							  &size, NULL, 0);
+
+				if (unlikely(size)) {
+					plt_dp_err("Insufficient buffer space,"
+						   " size %d needed",
+						   size);
+					return -1;
+				}
+			}
+		}
+		((uint16_t *)in_buffer)[3] = rte_cpu_to_be_16(i);
+		s_size_bytes =
+			((i + 3) / 4) * sizeof(struct roc_se_sglist_comp);
+
+		size = g_size_bytes + s_size_bytes + ROC_SE_SG_LIST_HDR_SIZE;
+
+		/* This is DPTR len in case of SG mode */
+		cpt_inst_w4.s.dlen = size;
+
+		inst->dptr = (uint64_t)in_buffer;
+	}
+
+	inst->w4.u64 = cpt_inst_w4.u64;
+
+	return 0;
+}
+
+static __rte_always_inline int
 cpt_fc_dec_hmac_prep(uint32_t flags, uint64_t d_offs, uint64_t d_lens,
 		     struct roc_se_fc_params *fc_params,
 		     struct cpt_inst_s *inst)
@@ -843,8 +1105,12 @@ cpt_fc_enc_hmac_prep(uint32_t flags, uint64_t d_offs, uint64_t d_lens,
 
 	fc_type = ctx->fc_type;
 
-	if (likely(fc_type == ROC_SE_FC_GEN))
+	if (likely(fc_type == ROC_SE_FC_GEN)) {
 		ret = cpt_enc_hmac_prep(flags, d_offs, d_lens, fc_params, inst);
+	} else if (fc_type == ROC_SE_PDCP) {
+		ret = cpt_zuc_snow3g_enc_prep(flags, d_offs, d_lens, fc_params,
+					      inst);
+	}
 
 	return ret;
 }
Signature · 1 line
2.7.4
#19 lore raw

PATCH v2 15/20 crypto/cnxk: add ZUC and SNOW3G decrypt

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add PDCP opcode which handles ZUC and SNOW3G.

---
 doc/guides/cryptodevs/features/cn10k.ini |   2 +
 doc/guides/cryptodevs/features/cn9k.ini  |   2 +
 drivers/crypto/cnxk/cnxk_se.h            | 209 ++++++++++++++++++++++++++++++-
 3 files changed, 212 insertions(+), 1 deletion(-)
doc/guides/cryptodevs/features/cn10k.ini +2 -0
index 7750d92..a90421a 100644
@@ -30,6 +30,8 @@ AES CTR (256)  = Y
 AES XTS (128)  = Y
 AES XTS (256)  = Y
 DES CBC        = Y
+SNOW3G UEA2    = Y
+ZUC EEA3       = Y
 
 ;
 ; Supported authentication algorithms of 'cn10k' crypto driver.
doc/guides/cryptodevs/features/cn9k.ini +2 -0
index 7007d11..fb0c09b 100644
@@ -30,6 +30,8 @@ AES CTR (256)  = Y
 AES XTS (128)  = Y
 AES XTS (256)  = Y
 DES CBC        = Y
+SNOW3G UEA2    = Y
+ZUC EEA3       = Y
 
 ;
 ; Supported authentication algorithms of 'cn9k' crypto driver.
drivers/crypto/cnxk/cnxk_se.h +208 -1

222 lines not on this page · raw message

Signature · 1 line
2.7.4
#20 lore raw

PATCH v2 16/20 crypto/cnxk: add KASUMI encrypt

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add KASUMI encrypt support.

---
 drivers/crypto/cnxk/cnxk_se.h | 196 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 196 insertions(+)
drivers/crypto/cnxk/cnxk_se.h +196 -0
index c483b95..34907c6 100644
@@ -1282,6 +1282,199 @@ cpt_zuc_snow3g_dec_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,
 }
 
 static __rte_always_inline int
+cpt_kasumi_enc_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,
+		    struct roc_se_fc_params *params, struct cpt_inst_s *inst)
+{
+	void *m_vaddr = params->meta_buf.vaddr;
+	uint32_t size;
+	int32_t inputlen = 0, outputlen = 0;
+	struct roc_se_ctx *se_ctx;
+	uint32_t mac_len = 0;
+	uint8_t i = 0;
+	uint32_t encr_offset, auth_offset;
+	uint32_t encr_data_len, auth_data_len;
+	int flags;
+	uint8_t *iv_s, *iv_d, iv_len = 8;
+	uint8_t dir = 0;
+	uint64_t *offset_vaddr;
+	union cpt_inst_w4 cpt_inst_w4;
+	uint8_t *in_buffer;
+	uint32_t g_size_bytes, s_size_bytes;
+	struct roc_se_sglist_comp *gather_comp;
+	struct roc_se_sglist_comp *scatter_comp;
+
+	encr_offset = ROC_SE_ENCR_OFFSET(d_offs) / 8;
+	auth_offset = ROC_SE_AUTH_OFFSET(d_offs) / 8;
+	encr_data_len = ROC_SE_ENCR_DLEN(d_lens);
+	auth_data_len = ROC_SE_AUTH_DLEN(d_lens);
+
+	se_ctx = params->ctx_buf.vaddr;
+	flags = se_ctx->zsk_flags;
+	mac_len = se_ctx->mac_len;
+
+	if (flags == 0x0)
+		iv_s = params->iv_buf;
+	else
+		iv_s = params->auth_iv_buf;
+
+	dir = iv_s[8] & 0x1;
+
+	cpt_inst_w4.s.opcode_major = ROC_SE_MAJOR_OP_KASUMI | ROC_SE_DMA_MODE;
+
+	/* indicates ECB/CBC, direction, ctx from cptr, iv from dptr */
+	cpt_inst_w4.s.opcode_minor = ((1 << 6) | (se_ctx->k_ecb << 5) |
+				      (dir << 4) | (0 << 3) | (flags & 0x7));
+
+	/*
+	 * GP op header, lengths are expected in bits.
+	 */
+	cpt_inst_w4.s.param1 = encr_data_len;
+	cpt_inst_w4.s.param2 = auth_data_len;
+
+	/* consider iv len */
+	if (flags == 0x0) {
+		encr_offset += iv_len;
+		auth_offset += iv_len;
+	}
+
+	/* save space for offset ctrl and iv */
+	offset_vaddr = m_vaddr;
+
+	m_vaddr = (uint8_t *)m_vaddr + ROC_SE_OFF_CTRL_LEN + iv_len;
+
+	/* DPTR has SG list */
+	in_buffer = m_vaddr;
+
+	((uint16_t *)in_buffer)[0] = 0;
+	((uint16_t *)in_buffer)[1] = 0;
+
+	/* TODO Add error check if space will be sufficient */
+	gather_comp = (struct roc_se_sglist_comp *)((uint8_t *)m_vaddr + 8);
+
+	/*
+	 * Input Gather List
+	 */
+	i = 0;
+
+	/* Offset control word followed by iv */
+
+	if (flags == 0x0) {
+		inputlen = encr_offset + (RTE_ALIGN(encr_data_len, 8) / 8);
+		outputlen = inputlen;
+		/* iv offset is 0 */
+		*offset_vaddr = rte_cpu_to_be_64((uint64_t)encr_offset << 16);
+		if (unlikely((encr_offset >> 16))) {
+			plt_dp_err("Offset not supported");
+			plt_dp_err("enc_offset: %d", encr_offset);
+			return -1;
+		}
+	} else {
+		inputlen = auth_offset + (RTE_ALIGN(auth_data_len, 8) / 8);
+		outputlen = mac_len;
+		/* iv offset is 0 */
+		*offset_vaddr = rte_cpu_to_be_64((uint64_t)auth_offset);
+		if (unlikely((auth_offset >> 8))) {
+			plt_dp_err("Offset not supported");
+			plt_dp_err("auth_offset: %d", auth_offset);
+			return -1;
+		}
+	}
+
+	i = fill_sg_comp(gather_comp, i, (uint64_t)offset_vaddr,
+			 ROC_SE_OFF_CTRL_LEN + iv_len);
+
+	/* IV */
+	iv_d = (uint8_t *)offset_vaddr + ROC_SE_OFF_CTRL_LEN;
+	memcpy(iv_d, iv_s, iv_len);
+
+	/* input data */
+	size = inputlen - iv_len;
+	if (size) {
+		i = fill_sg_comp_from_iov(gather_comp, i, params->src_iov, 0,
+					  &size, NULL, 0);
+
+		if (unlikely(size)) {
+			plt_dp_err("Insufficient buffer space,"
+				   " size %d needed",
+				   size);
+			return -1;
+		}
+	}
+	((uint16_t *)in_buffer)[2] = rte_cpu_to_be_16(i);
+	g_size_bytes = ((i + 3) / 4) * sizeof(struct roc_se_sglist_comp);
+
+	/*
+	 * Output Scatter List
+	 */
+
+	i = 0;
+	scatter_comp = (struct roc_se_sglist_comp *)((uint8_t *)gather_comp +
+						     g_size_bytes);
+
+	if (flags == 0x1) {
+		/* IV in SLIST only for F8 */
+		iv_len = 0;
+	}
+
+	/* IV */
+	if (iv_len) {
+		i = fill_sg_comp(scatter_comp, i,
+				 (uint64_t)offset_vaddr + ROC_SE_OFF_CTRL_LEN,
+				 iv_len);
+	}
+
+	/* Add output data */
+	if (req_flags & ROC_SE_VALID_MAC_BUF) {
+		size = outputlen - iv_len - mac_len;
+		if (size) {
+			i = fill_sg_comp_from_iov(scatter_comp, i,
+						  params->dst_iov, 0, &size,
+						  NULL, 0);
+
+			if (unlikely(size)) {
+				plt_dp_err("Insufficient buffer space,"
+					   " size %d needed",
+					   size);
+				return -1;
+			}
+		}
+
+		/* mac data */
+		if (mac_len) {
+			i = fill_sg_comp_from_buf(scatter_comp, i,
+						  &params->mac_buf);
+		}
+	} else {
+		/* Output including mac */
+		size = outputlen - iv_len;
+		if (size) {
+			i = fill_sg_comp_from_iov(scatter_comp, i,
+						  params->dst_iov, 0, &size,
+						  NULL, 0);
+
+			if (unlikely(size)) {
+				plt_dp_err("Insufficient buffer space,"
+					   " size %d needed",
+					   size);
+				return -1;
+			}
+		}
+	}
+	((uint16_t *)in_buffer)[3] = rte_cpu_to_be_16(i);
+	s_size_bytes = ((i + 3) / 4) * sizeof(struct roc_se_sglist_comp);
+
+	size = g_size_bytes + s_size_bytes + ROC_SE_SG_LIST_HDR_SIZE;
+
+	/* This is DPTR len in case of SG mode */
+	cpt_inst_w4.s.dlen = size;
+
+	inst->dptr = (uint64_t)in_buffer;
+	inst->w4.u64 = cpt_inst_w4.u64;
+
+	return 0;
+}
+
+static __rte_always_inline int
 cpt_fc_dec_hmac_prep(uint32_t flags, uint64_t d_offs, uint64_t d_lens,
 		     struct roc_se_fc_params *fc_params,
 		     struct cpt_inst_s *inst)
@@ -1317,6 +1510,9 @@ cpt_fc_enc_hmac_prep(uint32_t flags, uint64_t d_offs, uint64_t d_lens,
 	} else if (fc_type == ROC_SE_PDCP) {
 		ret = cpt_zuc_snow3g_enc_prep(flags, d_offs, d_lens, fc_params,
 					      inst);
+	} else if (fc_type == ROC_SE_KASUMI) {
+		ret = cpt_kasumi_enc_prep(flags, d_offs, d_lens, fc_params,
+					  inst);
 	}
 
 	return ret;
Signature · 1 line
2.7.4
#21 lore raw

PATCH v2 17/20 crypto/cnxk: add KASUMI decrypt

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add KASUMI decrypt support.

---
 doc/guides/cryptodevs/features/cn10k.ini |   1 +
 doc/guides/cryptodevs/features/cn9k.ini  |   1 +
 drivers/crypto/cnxk/cnxk_se.h            | 133 +++++++++++++++++++++++++++++++
 3 files changed, 135 insertions(+)
doc/guides/cryptodevs/features/cn10k.ini +1 -0
index a90421a..c611535 100644
@@ -30,6 +30,7 @@ AES CTR (256)  = Y
 AES XTS (128)  = Y
 AES XTS (256)  = Y
 DES CBC        = Y
+KASUMI F8      = Y
 SNOW3G UEA2    = Y
 ZUC EEA3       = Y
 
doc/guides/cryptodevs/features/cn9k.ini +1 -0
index fb0c09b..e833dc0 100644
@@ -30,6 +30,7 @@ AES CTR (256)  = Y
 AES XTS (128)  = Y
 AES XTS (256)  = Y
 DES CBC        = Y
+KASUMI F8      = Y
 SNOW3G UEA2    = Y
 ZUC EEA3       = Y
 
drivers/crypto/cnxk/cnxk_se.h +133 -0

145 lines not on this page · raw message

Signature · 1 line
2.7.4
#22 lore raw

PATCH v2 18/20 crypto/cnxk: add digest support

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add support for digest support for various algorithms.

---
 doc/guides/cryptodevs/features/cn10k.ini  |  17 ++
 doc/guides/cryptodevs/features/cn9k.ini   |  17 ++
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c |  18 +-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  |  17 +-
 drivers/crypto/cnxk/cnxk_se.h             | 340 ++++++++++++++++++++++++++++++
 5 files changed, 407 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/features/cn10k.ini +17 -0
index c611535..77c4a2d 100644
@@ -38,6 +38,23 @@ ZUC EEA3       = Y
 ; Supported authentication algorithms of 'cn10k' crypto driver.
 ;
 [Auth]
+NULL         = Y
+AES GMAC     = Y
+KASUMI F9    = Y
+MD5          = Y
+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
+SNOW3G UIA2  = Y
+ZUC EIA3     = Y
 
 ;
 ; Supported AEAD algorithms of 'cn10k' crypto driver.
doc/guides/cryptodevs/features/cn9k.ini +17 -0
index e833dc0..7b310e6 100644
@@ -38,6 +38,23 @@ ZUC EEA3       = Y
 ; Supported authentication algorithms of 'cn9k' crypto driver.
 ;
 [Auth]
+NULL         = Y
+AES GMAC     = Y
+KASUMI F9    = Y
+MD5          = Y
+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
+SNOW3G UIA2  = Y
+ZUC EIA3     = Y
 
 ;
 ; Supported AEAD algorithms of 'cn9k' crypto driver.
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +17 -1
index 8af2ce9..6207627 100644
@@ -53,6 +53,9 @@ cpt_sym_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 
 	if (cpt_op & ROC_SE_OP_CIPHER_MASK)
 		ret = fill_fc_params(op, sess, &qp->meta_info, infl_req, inst);
+	else
+		ret = fill_digest_params(op, sess, &qp->meta_info, infl_req,
+					 inst);
 
 	return ret;
 }
@@ -203,7 +206,10 @@ cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp,
 	if (likely(res->compcode == CPT_COMP_GOOD ||
 		   res->compcode == CPT_COMP_WARN)) {
 		if (unlikely(res->uc_compcode)) {
-			cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+			if (res->uc_compcode == ROC_SE_ERR_GC_ICV_MISCOMPARE)
+				cop->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+			else
+				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
 
 			plt_dp_info("Request failed with microcode error");
 			plt_dp_info("MC completion code 0x%x",
@@ -212,6 +218,16 @@ cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp,
 		}
 
 		cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+		if (cop->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+
+			/* Verify authentication data if required */
+			if (unlikely(infl_req->op_flags &
+				     CPT_OP_FLAGS_AUTH_VERIFY)) {
+				uintptr_t *rsp = infl_req->mdata;
+				compl_auth_verify(cop, (uint8_t *)rsp[0],
+						  rsp[1]);
+			}
+		}
 	} else {
 		cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
 		plt_dp_info("HW completion code 0x%x", res->compcode);
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +16 -1
index e8189d0..da13c7d 100644
@@ -24,6 +24,9 @@ cn9k_cpt_sym_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 
 	if (cpt_op & ROC_SE_OP_CIPHER_MASK)
 		ret = fill_fc_params(op, sess, &qp->meta_info, infl_req, inst);
+	else
+		ret = fill_digest_params(op, sess, &qp->meta_info, infl_req,
+					 inst);
 
 	return ret;
 }
@@ -166,7 +169,10 @@ cn9k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp, struct rte_crypto_op *cop,
 
 	if (likely(res->compcode == CPT_COMP_GOOD)) {
 		if (unlikely(res->uc_compcode)) {
-			cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+			if (res->uc_compcode == ROC_SE_ERR_GC_ICV_MISCOMPARE)
+				cop->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+			else
+				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
 
 			plt_dp_info("Request failed with microcode error");
 			plt_dp_info("MC completion code 0x%x",
@@ -175,6 +181,15 @@ cn9k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp, struct rte_crypto_op *cop,
 		}
 
 		cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+		if (cop->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			/* Verify authentication data if required */
+			if (unlikely(infl_req->op_flags &
+				     CPT_OP_FLAGS_AUTH_VERIFY)) {
+				uintptr_t *rsp = infl_req->mdata;
+				compl_auth_verify(cop, (uint8_t *)rsp[0],
+						  rsp[1]);
+			}
+		}
 	} else {
 		cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
 		plt_dp_info("HW completion code 0x%x", res->compcode);
drivers/crypto/cnxk/cnxk_se.h +340 -0

362 lines not on this page · raw message

Signature · 1 line
2.7.4
#23 lore raw

PATCH v2 19/20 crypto/cnxk: add symmetric crypto capabilities

In reply to Anoob Joseph

From: Ankur Dwivedi <[email protected]>

Add symmetric crypto capabilities for cn9k & cn10k.

---
 doc/guides/cryptodevs/cnxk.rst                    |  46 ++
 doc/guides/rel_notes/release_21_08.rst            |   7 +
 drivers/crypto/cnxk/cn10k_cryptodev.c             |   4 +
 drivers/crypto/cnxk/cn9k_cryptodev.c              |   4 +
 drivers/crypto/cnxk/cnxk_cryptodev.h              |   5 +
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 699 ++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h |  25 +
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c          |   3 +-
 drivers/crypto/cnxk/meson.build                   |   1 +
 9 files changed, 793 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h
doc/guides/cryptodevs/cnxk.rst +46 -0
index 8bac539..885d941 100644
@@ -21,6 +21,52 @@ Supported OCTEON cnxk SoCs
 - CN9XX
 - CN10XX
 
+Features
+--------
+
+The OCTEON cnxk crypto PMD has support for:
+
+Symmetric Crypto Algorithms
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Cipher algorithms:
+
+* ``RTE_CRYPTO_CIPHER_NULL``
+* ``RTE_CRYPTO_CIPHER_3DES_CBC``
+* ``RTE_CRYPTO_CIPHER_3DES_ECB``
+* ``RTE_CRYPTO_CIPHER_AES_CBC``
+* ``RTE_CRYPTO_CIPHER_AES_CTR``
+* ``RTE_CRYPTO_CIPHER_AES_XTS``
+* ``RTE_CRYPTO_CIPHER_DES_CBC``
+* ``RTE_CRYPTO_CIPHER_KASUMI_F8``
+* ``RTE_CRYPTO_CIPHER_SNOW3G_UEA2``
+* ``RTE_CRYPTO_CIPHER_ZUC_EEA3``
+
+Hash algorithms:
+
+* ``RTE_CRYPTO_AUTH_NULL``
+* ``RTE_CRYPTO_AUTH_AES_GMAC``
+* ``RTE_CRYPTO_AUTH_KASUMI_F9``
+* ``RTE_CRYPTO_AUTH_MD5``
+* ``RTE_CRYPTO_AUTH_MD5_HMAC``
+* ``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_SNOW3G_UIA2``
+* ``RTE_CRYPTO_AUTH_ZUC_EIA3``
+
+AEAD algorithms:
+
+* ``RTE_CRYPTO_AEAD_AES_GCM``
+* ``RTE_CRYPTO_AEAD_CHACHA20_POLY1305``
+
 Installation
 ------------
 
doc/guides/rel_notes/release_21_08.rst +7 -0
index a6ecfdf..52f2788 100644
@@ -136,3 +136,10 @@ 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 support for Marvell CN10K crypto driver.**
+
+  Added Marvell CN10K crypto PMD.
+
+  * Added crypto/cnxk driver which provides the support for the integrated
+    crypto device.
drivers/crypto/cnxk/cn10k_cryptodev.c +4 -0
index 2ae61b5..559aaef 100644
@@ -13,6 +13,8 @@
 #include "cn10k_cryptodev.h"
 #include "cn10k_cryptodev_ops.h"
 #include "cnxk_cryptodev.h"
+#include "cnxk_cryptodev_capabilities.h"
+
 #include "roc_api.h"
 
 uint8_t cn10k_cryptodev_driver_id;
@@ -77,6 +79,8 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		}
 	}
 
+	cnxk_cpt_caps_populate(vf);
+
 	dev->dev_ops = &cn10k_cpt_ops;
 	dev->driver_id = cn10k_cryptodev_driver_id;
 
drivers/crypto/cnxk/cn9k_cryptodev.c +4 -0
index 9a2d565..d3dc084 100644
@@ -13,6 +13,8 @@
 #include "cn9k_cryptodev.h"
 #include "cn9k_cryptodev_ops.h"
 #include "cnxk_cryptodev.h"
+#include "cnxk_cryptodev_capabilities.h"
+
 #include "roc_api.h"
 
 uint8_t cn9k_cryptodev_driver_id;
@@ -78,6 +80,8 @@ cn9k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	dev->dev_ops = &cn9k_cpt_ops;
 	dev->driver_id = cn9k_cryptodev_driver_id;
 
+	cnxk_cpt_caps_populate(vf);
+
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
 			     RTE_CRYPTODEV_FF_HW_ACCELERATED |
 			     RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
drivers/crypto/cnxk/cnxk_cryptodev.h +5 -0
index 5b84f0b..03af4af 100644
@@ -9,11 +9,16 @@
 
 #include "roc_cpt.h"
 
+#define CNXK_CPT_MAX_CAPS	 34
+#define CNXK_SEC_CRYPTO_MAX_CAPS 4
+#define CNXK_SEC_MAX_CAPS	 3
+
 /**
  * Device private data
  */
 struct cnxk_cpt_vf {
 	struct roc_cpt cpt;
+	struct rte_cryptodev_capabilities crypto_caps[CNXK_CPT_MAX_CAPS];
 };
 
 int cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt);
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c new file +699 -0

699 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h new file +25 -0
new file mode 100644
index 0000000..85f5ad2
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef _CNXK_CRYPTODEV_CAPABILITIES_H_
+#define _CNXK_CRYPTODEV_CAPABILITIES_H_
+
+#include <rte_cryptodev.h>
+
+#include "cnxk_cryptodev.h"
+
+/*
+ * Initialize crypto capabilities for the device
+ *
+ */
+void cnxk_cpt_caps_populate(struct cnxk_cpt_vf *vf);
+
+/*
+ * Get crypto capabilities list for the device
+ *
+ */
+const struct rte_cryptodev_capabilities *
+cnxk_crypto_capabilities_get(struct cnxk_cpt_vf *vf);
+
+#endif /* _CNXK_CRYPTODEV_CAPABILITIES_H_ */
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +2 -1
index 10bb191..0d81785 100644
@@ -10,6 +10,7 @@
 
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_ops.h"
+#include "cnxk_cryptodev_capabilities.h"
 #include "cnxk_se.h"
 
 static int
@@ -99,7 +100,7 @@ cnxk_cpt_dev_info_get(struct rte_cryptodev *dev,
 
 	info->max_nb_queue_pairs = roc_cpt->nb_lf_avail;
 	info->feature_flags = dev->feature_flags;
-	info->capabilities = NULL;
+	info->capabilities = cnxk_crypto_capabilities_get(vf);
 	info->sym.max_nb_sessions = 0;
 	info->min_mbuf_headroom_req = CNXK_CPT_MIN_HEADROOM_REQ;
 	info->min_mbuf_tailroom_req = 0;
drivers/crypto/cnxk/meson.build +1 -0
index 74b7795..fa6be06 100644
@@ -14,6 +14,7 @@ sources = files(
         'cn10k_cryptodev.c',
         'cn10k_cryptodev_ops.c',
         'cnxk_cryptodev.c',
+        'cnxk_cryptodev_capabilities.c',
         'cnxk_cryptodev_ops.c',
 )
 
Signature · 1 line
2.7.4
#24 lore raw

PATCH v2 20/20 test/crypto: enable cnxk crypto PMDs

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Enable tests for cn9k & cn10k crypto PMDs.

---
 app/test/meson.build           |  2 ++
 app/test/test_cryptodev.c      | 14 ++++++++++++++
 app/test/test_cryptodev.h      |  2 ++
 doc/guides/cryptodevs/cnxk.rst | 20 ++++++++++++++++++++
 4 files changed, 38 insertions(+)
app/test/meson.build +2 -0
index 0a5f425..2b4bddd 100644
@@ -311,6 +311,8 @@ perf_test_names = [
 driver_test_names = [
         'cryptodev_aesni_mb_autotest',
         'cryptodev_aesni_gcm_autotest',
+        'cryptodev_cn9k_autotest',
+        'cryptodev_cn10k_autotest',
         'cryptodev_dpaa_sec_autotest',
         'cryptodev_dpaa2_sec_autotest',
         'cryptodev_null_autotest',
app/test/test_cryptodev.c +14 -0
index 39db52b..ead8c6e 100644
@@ -14778,6 +14778,18 @@ test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
 	return ret;
 }
 
+static int
+test_cryptodev_cn9k(void)
+{
+	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
+}
+
+static int
+test_cryptodev_cn10k(void)
+{
+	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
+}
+
 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
 		test_cryptodev_qat_raw_api);
 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
@@ -14803,3 +14815,5 @@ 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);
+REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
+REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
app/test/test_cryptodev.h +2 -0
index f81f8e3..5bf1e88 100644
@@ -71,6 +71,8 @@
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 #define CRYPTODEV_NAME_NITROX_PMD	crypto_nitrox_sym
 #define CRYPTODEV_NAME_BCMFS_PMD	crypto_bcmfs
+#define CRYPTODEV_NAME_CN9K_PMD		crypto_cn9k
+#define CRYPTODEV_NAME_CN10K_PMD	crypto_cn10k
 
 enum cryptodev_api_test_type {
 	CRYPTODEV_API_TEST = 0,
doc/guides/cryptodevs/cnxk.rst +20 -0
index 885d941..66b0b63 100644
@@ -165,6 +165,26 @@ Debugging Options
     | 1 | CPT        | --log-level='pmd\.crypto\.cnxk,8'                     |
     +---+------------+-------------------------------------------------------+
 
+Testing
+-------
+
+The symmetric crypto operations on OCTEON cnxk crypto PMD may be verified by
+running the test application:
+
+``CN9K``
+
+.. code-block:: console
+
+    ./dpdk-test
+    RTE>>cryptodev_cn9k_autotest
+
+``CN10K``
+
+.. code-block:: console
+
+    ./dpdk-test
+    RTE>>cryptodev_cn10k_autotest
+
 Limitations
 -----------
 
Signature · 1 line
2.7.4
#25 lore raw
In reply to Anoob Joseph
Quoted 6 lines

Add cnxk crypto PMDs supporting Marvell CN106XX SoC, based on 'common/cnxk'.

This series utilizes 'common/cnxk' to register cn9k & cn10k crypto PMDs and add symmetric cryptographic features for the same.

Quoted 9 lines

Depends-on: series-17482 ("Add CPT in Marvell CNXK common driver")

Changes in v2:
- Added documentation & updated release notes
- Reworked DP logs as suggested by Akhil
- Rearranged capability additions & feature flag updates as suggested by Akhil
- Rebased on v2 of dependant series

Series Acked-by: Akhil Goyal <[email protected]>

Applied
#26 lore raw
Quoted 9 lines
Quoted 4 lines

Add cnxk crypto PMDs supporting Marvell CN106XX SoC, based on 'common/cnxk'.

This series utilizes 'common/cnxk' to register cn9k & cn10k crypto PMDs

and

Quoted 4 lines

add symmetric cryptographic features for the same.

Depends-on: series-17482 ("Add CPT in Marvell CNXK common driver")

Quoted 8 lines
Quoted 7 lines

Changes in v2:
- Added documentation & updated release notes
- Reworked DP logs as suggested by Akhil
- Rearranged capability additions & feature flag updates as suggested by Akhil
- Rebased on v2 of dependant series

Series Acked-by: Akhil Goyal <[email protected]>

Applied to dpdk-next-crypto
Fixed minor issues while merging.

Thanks.