[dpdk-dev] [PATCH v1 0/1] update documentation file

2020-10-27 Thread Vikas Gupta
Hi,
 This patchset update the bcmfs.rst file.

Regards,
Vikas

Vikas Gupta (1):
  crypto/bcmfs: update documentation file

 doc/guides/cryptodevs/bcmfs.rst | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

-- 
2.17.1



[dpdk-dev] [PATCH v1 1/1] crypto/bcmfs: update documentation file

2020-10-27 Thread Vikas Gupta
Update bcmfs.rst file with supported features and devices.

Signed-off-by: Vikas Gupta 
Reviewed-by: Ajit Khaparde 
Reviewed-by: JP Lee 
---
 doc/guides/cryptodevs/bcmfs.rst | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
index 8afece3b4b..f5dcd59c87 100644
--- a/doc/guides/cryptodevs/bcmfs.rst
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -5,7 +5,7 @@ Broadcom FlexSparc Crypto Poll Mode Driver
 ==
 
 The FlexSparc crypto poll mode driver (BCMFS PMD) provides support for 
offloading
-cryptographic operations to the Broadcom SoCs having FlexSparc4/FlexSparc5 
unit.
+cryptographic operations to the Broadcom SoCs having FlexSparc4 unit.
 Detailed information about SoCs can be found at `Broadcom Official Website
 
<https://www.broadcom.com/products/ethernet-connectivity/network-adapters/smartnic>`__.
 
@@ -13,12 +13,11 @@ Supported Broadcom SoCs
 ---
 
 * Stingray
-* Stingray2
 
 Features
 
 
-The BCMFS SYM PMD has support for:
+The BCMFS PMD has support for below symmetric algorithms:
 
 Cipher algorithms:
 
@@ -46,7 +45,6 @@ Hash algorithms:
 * ``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``
@@ -54,7 +52,6 @@ Hash algorithms:
 Supported AEAD algorithms:
 
 * ``RTE_CRYPTO_AEAD_AES_GCM``
-* ``RTE_CRYPTO_AEAD_AES_CCM``
 
 Installation
 
@@ -66,7 +63,7 @@ Information about kernel, rootfs and toolchain can be found at
 To execute BCMFS PMD, it must be compiled with VFIO_PRESENT flag on the
 compiling platform and same gets enabled in rte_vfio.h.
 
-The BCMFS crypto PMD may be compiled natively on a Stingray/Stingray2 platform 
or
+The BCMFS PMD may be compiled natively on a Stingray platform or
 cross-compiled on an x86 platform. For example, below commands can be executed
 for cross compiling on x86 platform.
 
@@ -94,13 +91,13 @@ For example, below commands can be run to get hold of a 
device node by VFIO.
 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.
+* The session-oriented APIs are supported but the session-less APIs are not.
+* CCM is not supported.
 
 Testing
 ---
 
-The symmetric crypto operations on BCMFS crypto PMD may be verified by running 
the test
+The symmetric crypto operations on BCMFS PMD may be verified by running the 
test
 application:
 
 .. code-block:: console
-- 
2.17.1



[dpdk-dev] MSI interrupts

2020-11-09 Thread Vikas Gupta
Hi,

 In vfio_enable_msi api the count value passed to the kernel is hardcoded
to ‘1’. Is there any specific reason behind this?

  I believe this can be set to more than 1.

  Any information on this would be helpful.



Thanks,

Vikas


[dpdk-dev] [PATCH v1 1/1] crypto/bcmfs: fix documentation error

2020-10-16 Thread Vikas Gupta
Fix documentation error in bcmfs.ini. Add a section for
asymmetric algorithms.

Signed-off-by: Vikas Gupta 
Reviewed-by: Ajit Khaparde 
---
 doc/guides/cryptodevs/features/bcmfs.ini | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/guides/cryptodevs/features/bcmfs.ini 
b/doc/guides/cryptodevs/features/bcmfs.ini
index 6a718856b..f7fb2ed88 100644
--- a/doc/guides/cryptodevs/features/bcmfs.ini
+++ b/doc/guides/cryptodevs/features/bcmfs.ini
@@ -41,7 +41,6 @@ SHA512   = Y
 SHA512 HMAC  = Y
 AES GMAC = Y
 AES CMAC (128) = Y
-AES CBC MAC = Y
 AES XCBC MAC = Y
 
 ;
@@ -54,3 +53,8 @@ AES GCM (256) = Y
 AES CCM (128) = Y
 AES CCM (192) = Y
 AES CCM (256) = Y
+
+;
+; Supported Asymmetric algorithms of the 'bcmfs' crypto driver.
+;
+[Asymmetric]
-- 
2.17.1



[dpdk-dev] [PATCH v1 0/1] documentation error fix

2020-10-16 Thread Vikas Gupta
Hi,
 This patch fixes documentation error in bcmfs.init

Regards,
Vikas

Vikas Gupta (1):
  crypto/bcmfs: fix documentation error

 doc/guides/cryptodevs/features/bcmfs.ini | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

-- 
2.17.1



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

2020-09-29 Thread Vikas Gupta
Hi Akhil,

On Tue, Sep 29, 2020 at 12:19 AM Akhil Goyal  wrote:
>
> Hi Vikas,
>
> > +BCMFS crypto PMD depend upon the devices present in the path
> > +/sys/bus/platform/devices/fs/ 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.
>
> > diff --git a/doc/guides/cryptodevs/index.rst 
> > b/doc/guides/cryptodevs/index.rst
> > index a67ed5a28..5d7e028bd 100644
> > --- a/doc/guides/cryptodevs/index.rst
> > +++ b/doc/guides/cryptodevs/index.rst
> > @@ -29,3 +29,4 @@ Crypto Device Drivers
> >  qat
> >  virtio
> >  zuc
> > +bcmfs
>
> It is better to maintain an alphabetical order.
Sure.
>
> > diff --git a/drivers/crypto/bcmfs/bcmfs_device.c
> > b/drivers/crypto/bcmfs/bcmfs_device.c
> > new file mode 100644
> > index 0..47c776de6
> > --- /dev/null
> > +++ b/drivers/crypto/bcmfs/bcmfs_device.c
> > @@ -0,0 +1,256 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(C) 2020 Broadcom.
> > + * All rights reserved.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#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,
> > +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.
>
> > + 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;
> > +}
> > +
>
> 
>
> > diff --git a/drivers/crypto/meson.build b/drivers/crypto/meson.build
> > index a2423507a..8e06d0533 100644
> > --- a/drivers/crypto/meson.build
> > +++ b/drivers/crypto/meson.build
> > @@ -23,7 +23,8 @@ drivers = ['aesni_gcm',
> >  'scheduler',
> >  'snow3g',
> >  'virtio',
> > -'zuc']
> > +'zuc',
> > +'bcmfs']
>
> Please maintain an alphabetical order.
Sure.


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

2020-09-29 Thread Vikas Gupta
Hi Akhil,

On Tue, Sep 29, 2020 at 12:30 AM Akhil Goyal  wrote:
>
> Hi Vikas,
>
> > Subject: [PATCH v2 2/8] crypto/bcmfs: add vfio support
> >
> > Add vfio support for device.
> >
> > Signed-off-by: Vikas Gupta 
> > Signed-off-by: Raveendra Padasalagi 
> > Reviewed-by: Ajit Khaparde 
> > ---
> >  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
> >
> > diff --git a/drivers/crypto/bcmfs/bcmfs_device.c
> > b/drivers/crypto/bcmfs/bcmfs_device.c
> > index 47c776de6..3b5cc9e98 100644
> > --- a/drivers/crypto/bcmfs/bcmfs_device.c
> > +++ b/drivers/crypto/bcmfs/bcmfs_device.c
> > @@ -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;
> > diff --git a/drivers/crypto/bcmfs/bcmfs_device.h
> > b/drivers/crypto/bcmfs/bcmfs_device.h
> > index cc64a8df2..c41cc0031 100644
> > --- a/drivers/crypto/bcmfs/bcmfs_device.h
> > +++ b/drivers/crypto/bcmfs/bcmfs_device.h
> > @@ -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_ */
> > diff --git a/drivers/crypto/bcmfs/bcmfs_vfio.c
> > b/drivers/crypto/bcmfs/bcmfs_vfio.c
> > new file mode 100644
> > index 0..dc2def580
> > --- /dev/null
> > +++ b/drivers/crypto/bcmfs/bcmfs_vfio.c
> > @@ -0,0 +1,107 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(C) 2020 Broadcom.
> > + * All rights reserved.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#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.
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?
>
> > +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


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

2020-09-29 Thread Vikas Gupta
Hi Akhil,

On Tue, Sep 29, 2020 at 12:59 AM Akhil Goyal  wrote:
>
> > Subject: [PATCH v2 3/8] crypto/bcmfs: add apis for queue pair management
> >
> > diff --git a/drivers/crypto/bcmfs/bcmfs_hw_defs.h
> > b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
> > new file mode 100644
> > index 0..ecb0c09ba
> > --- /dev/null
> > +++ b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
> > @@ -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.
>
Will fix it next patch set. Thank you for catching this.

Thanks,
Vikas


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

2020-09-29 Thread Vikas Gupta
Hi Akhil,

On Tue, Sep 29, 2020 at 1:16 AM Akhil Goyal  wrote:
>
> Hi Vikas,
>
> > diff --git a/doc/guides/cryptodevs/features/bcmfs.ini
> > b/doc/guides/cryptodevs/features/bcmfs.ini
> > new file mode 100644
> > index 0..82d2c639d
> > --- /dev/null
> > +++ b/doc/guides/cryptodevs/features/bcmfs.ini
> > @@ -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
> > +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.
>
> > +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//
>
> > + {
> > + /* 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.
I`ll go through all the list again. Thanks for catching.
>
> > + },
> > + .digest_size = {
> > + .min = 20,
> > + .max = 20,
> > + .increment = 0
> > + },
> > + .aad_size = { 0 }
> > + }, }
> > + }, }
> > + },
>
> //snipp//
>
> > + {
> > + /* 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.
Will review the list and fix it accordingly.
>
> > + },
> > + .digest_size = {
> > + .min = 16,
> > + .max = 16,
> > + .increment = 0
> > + },
> > + .aad_size = { 0 }
> > + }, }
> > + }, }
> > + },
> > + {
>
> //snip//
>
>
> > +
> > +const struct rte_cryptodev_capabilities *
> > +bcmfs_sym_get_capabilities(void)
> > +{
> > + return bcmfs_sym_capabilities;
> > +}
> > diff --git a/drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
> > b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
> > new file mode 100644
> > index 0..3ff61b7d2
> > --- /dev/null
> > +++ b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.h
> > @@ -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__ */
> > +
> > diff --git a/drivers/crypto/bcmfs/bcmfs_sym_defs.h
> > b/drivers/crypto/bcmfs/bcmfs_sym_defs.h
> > n

[dpdk-dev] [PATCH v3 0/8] Add Crypto PMD for Broadcom`s FlexSparc devices

2020-10-05 Thread 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/cry

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

2020-10-05 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index c9865ee6a5..1ea6c3b13e 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index cc64a8df2c..c41cc00318 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_vfio.c 
b/drivers/crypto/bcmfs/bcmfs_vfio.c
new file mode 100644
index 00..dc2def580f
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_vfio.c
@@ -0,0 +1,107 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "bcmfs_device.h"
+#include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
+
+#ifdef VFIO_PRESENT
+static int
+vfio_map_dev_obj(const char *path, const char *dev_obj,
+uint32_t *size, void **addr, int *dev_fd)
+{
+   int32_t ret;
+   struct vfio_group_status status = { .argsz = sizeof(status) };
+
+   struct vfio_device_info d_info = { .argsz = sizeof(d_info) };
+   struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
+
+   ret = rte_vfio_setup_device(path, dev_obj, dev_fd, &d_info);
+   if (ret) {
+   BCMFS_LOG(ERR, "VFIO Setting for device failed");
+   return ret;
+   }
+
+   /* getting device region info*/
+   ret = ioctl(*dev_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "Error in VFIO getting REGION_INFO");
+   goto map_failed;
+   }
+
+   *addr = mmap(NULL, reg_info.size,
+PROT_WRITE | PROT_READ, MAP_SHARED,
+*dev_fd, reg_info.offset);
+   if (*addr == MAP_FAILED) {
+   BCMFS_LOG(ERR, "Error mapping region (errno = %d)", errno);
+   ret = errno;
+   goto map_failed;
+   }
+   *size = reg_info.size;
+
+   return 0;
+
+map_failed:
+   rte_vfio_release_device(path, dev_obj, *dev_fd);
+
+   return ret;
+}
+
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+   int vfio_dev_fd;
+   void  *v_addr = NULL;
+   uint32_t size = 0;
+
+   ret = vfio_map_dev_obj(dev->dirname, dev->name,
+  &size, &v_addr, &vfio_dev_fd);
+   if (ret)
+   return -1;
+
+   dev->mmap_size = size;
+   dev->mmap_addr = v_addr;
+   dev->vfio_dev_fd = vfio_dev_fd;
+
+   return 0;
+}
+
+void
+bcmfs_release_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+
+   if (dev == NULL)
+   return;
+
+   /* unmap the addr */
+   munmap(dev->mmap_addr, dev->mmap_size);
+   /* release the device */
+   ret = rte_vfio_release_device(dev->dirname, dev->name,
+ dev->vfio_dev_fd);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "cannot release device");
+   return;
+   }
+}
+#else
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev __rte_unused)
+{
+   return -1;
+}
+
+void
+bcmfs_release_vfio(struct bcmfs_device *dev __rte_unused)
+{
+}
+#endif
diff --git a/dr

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

2020-10-05 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 1ea6c3b13e..7622720a40 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index c41cc00318..a475373324 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -11,6 +11,7 @@
 #include 
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES4
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_hw_defs.h 
b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
new file mode 100644
index 00..7d5bb5d8fe
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
@@ -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 
+#include 
+#include 
+#include 
+
+#ifndef BIT
+#define BIT(nr) (1UL << (nr))
+#endif
+
+#define FS_RING_REGS_SIZE  0x1
+#define FS_RING_DESC_SIZE  8
+#define FS_RING_BD_ALIGN_ORDER 12
+#define FS_RING_BD_DESC_PER_REQ32
+#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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
new file mode 100644
index 00..864e7bb746
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -0,0 +1,345 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
+#include "bcmfs_hw_defs.h"
+
+/* TX or submission queue name */
+static const char *txq_name = "tx";
+/* Completion or receive queue name */
+static const char *cmplq_name = "cmpl";
+
+/* Helper function */
+static int
+bcmfs_qp_check_queue_alignment(uint64_t phys_addr,
+  uint32_t align)
+{
+   if (((align - 1) & phys_addr) != 0)
+   return -EINVAL;
+   return 0;
+}
+
+static void
+bcmfs_queue_delete(struct bcmfs_queue *queue,
+  uint16_t queue_pair_id)
+{
+   const struct rte_memzone *mz;
+   int status = 0;
+
+   if (queue == NULL) {
+   BCMFS_LOG(DEBUG, "Invalid queue");
+   return;
+   }
+   BCMFS_LOG(DEBUG, "Free ring %d type %d, memzone: %s",
+ queue_pair_id, queue->q_type, queue->memz_name);
+
+   mz = rte_memzone_lookup(queue->memz_name);
+   if (mz != NULL) {
+   /* Write an unused pattern to the queue memory. */
+   memset(queue->base_addr, 0x9B, queue-

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

2020-10-05 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/MAINTAINERS b/MAINTAINERS
index c0abbe0fc8..ab849ac1d1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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  
+M: Raveendra Padasalagi 
+M: Ajit Khaparde 
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 ---
diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
new file mode 100644
index 00..dc21bf60cc
--- /dev/null
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -0,0 +1,51 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+Copyright(C) 2020 Broadcom
+
+Broadcom FlexSparc Crypto Poll Mode Driver
+==
+
+The FlexSparc crypto poll mode driver (BCMFS PMD) provides support for 
offloading
+cryptographic operations to the Broadcom SoCs having FlexSparc4/FlexSparc5 
unit.
+Detailed information about SoCs can be found at `Broadcom Official Website
+<https://www.broadcom.com/products/ethernet-connectivity/network-adapters/smartnic>`__.
+
+Supported Broadcom SoCs
+---
+
+* Stingray
+* Stingray2
+
+Installation
+
+Information about kernel, rootfs and toolchain can be found at
+`Broadcom Official Website 
<https://www.broadcom.com/products/ethernet-connectivity
+/network-adapters/smartnic/stingray-software>`__.
+
+.. Note::
+To execute BCMFS PMD, it must be compiled with VFIO_PRESENT flag on the
+compiling platform and same gets enabled in rte_vfio.h.
+
+The BCMFS crypto PMD may be compiled natively on a Stingray/Stingray2 platform 
or
+cross-compiled on an x86 platform. For example, below commands can be executed
+for cross compiling on on x86 platform.
+
+.. code-block:: console
+
+cd 
+meson  --cross-file config/arm/arm64_stingray_linux_gcc
+cd 
+ninja
+
+Initialization
+--
+The supported platfom devices should be present in the
+*/sys/bus/platform/devices/fs/* path on the booted kernel.
+To get BCMFS PMD executing, device node must be owned by VFIO platform module 
only.
+For example, below commands can be run to get hold of a device node by VFIO.
+
+.. code-block:: console
+ 
+SETUP_SYSFS_DEV_NAME=6700.crypto_mbox
+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
diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst
index a67ed5a282..279f56a002 100644
--- a/doc/guides/cryptodevs/index.rst
+++ b/doc/guides/cryptodevs/index.rst
@@ -13,6 +13,7 @@ Crypto Device Drivers
 aesni_mb
 aesni_gcm
 armv8
+bcmfs
 caam_jr
 ccp
 dpaa2_sec
diff --git a/doc/guides/rel_notes/release_20_11.rst 
b/doc/guides/rel_notes/release_20_11.rst
index 73ac08fb0e..8643330321 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -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.
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
new file mode 100644
index 00..c9865ee6a5

[dpdk-dev] [PATCH v3 4/8] crypto/bcmfs: add hw queue pair operations

2020-10-05 Thread Vikas Gupta
Add queue pair operations exported by supported devices.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_dev_msg.h 
b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
new file mode 100644
index 00..5b50bde35a
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
@@ -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_BUFFERS8
+#define MAX_DST_ADDR_BUFFERS3
+
+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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 7622720a40..6ff65adfc7 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -44,6 +44,47 @@ static struct bcmfs_device_attr dev_table[] = {
}
 };
 
+struct bcmfs_hw_queue_pair_ops_table bcmfs_hw_queue_pair_ops_table = {
+   .tl =  RTE_SPINLOCK_INITIALIZER,
+   .num_ops = 0
+};
+
+int bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops *h)
+{
+   struct bcmfs_hw_queue_pair_ops *ops;
+   int16_t ops_index;
+
+   rte_spinlock_lock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   if (h->enq_one_req == NULL || h->dequeue == NULL ||
+   h->ring_db == NULL || h->startq == NULL || h->stopq == NULL) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR,
+ "Missing callback while registering device ops");
+   return -EINVAL;
+   }
+
+   if (strlen(h->name) >= sizeof(ops->name) - 1) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR, "%s(): fs device_ops <%s>: name too long",
+   __func__, h->name);
+   return -EEXIST;
+   }
+
+   ops_index = bcmfs_hw_queue_pair_ops_table.num_ops++;
+   ops = &bcmfs_hw_queue_pair_ops_table.qp_ops[ops_index];
+   strlcpy(ops->name, h->name, sizeof(ops->name));
+   ops->enq_one_req = h->enq_one_req;
+   ops->dequeue = h->dequeue;
+   ops->ring_db = h->ring_db;
+   ops->startq = h->startq;
+   ops->stopq = h->stopq;
+
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   return ops_index;
+}
+
 TAILQ_HEAD(fsdev_list, bcmfs_device);
 static struct fsdev_list fsdev_list = TAILQ_HEAD_INITIALIZER(fsdev_list);
 
@@ -54,6 +95,7 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
   enum bcmfs_device_type dev_type __rte_unused)
 {
struct bcmfs_device *fsdev;
+   uint32_t i;
 
fsdev = rte_calloc(__func__, 1, sizeof(*fsdev), 0);
if (!fsdev)
@@ -69,6 +111,15 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
goto cleanup;
}
 
+   /* check if registered ops name is present in directory path */
+   for (i = 0; i < bcmfs_hw_queue_pair_ops_table.num_ops; i++)
+   if (strstr(dirpath,
+  bcmfs_hw_queue_pair_ops_table.qp_ops[i].name))
+   fsdev->sym_hw_qp_ops =
+   &bcmfs_hw_queue_pair_ops_table.qp_ops[i];
+   if (!fsdev->sym_hw_qp_ops)
+   goto cleanup;
+
strcpy(fsdev->dirname, dirpath);

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

2020-10-05 Thread Vikas Gupta
Add session handling and capabilities supported by crypto h/w
accelerator

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
index dc21bf60cc..aaa6e1af70 100644
--- a/doc/guides/cryptodevs/bcmfs.rst
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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.
diff --git a/doc/guides/cryptodevs/features/bcmfs.ini 
b/doc/guides/cryptodevs/features/bcmfs.ini
new file mode 100644
index 00..6a718856b9
--- /dev/null
+++ b/doc/guides/cryptodevs/features/bcmfs.ini
@@ -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
+OOP LB  In LB  Out = 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
+AES GMAC = Y
+AES CMAC (128) = Y
+AES CBC MAC = Y
+AES XCBC MAC = 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
diff --git a/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c 
b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
new file mode 100644
index 00..afed7696a6
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
@@ -0,0 +1,764 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include "bcmfs_sym_capabilities.h"
+
+static const struct rte_cryptodev_capabilities bcmfs_sym_capabilities[] = {
+   {
+   /* SHA1 */
+   .op = RTE_CRYPTO_OP_TYPE_SYMMET

[dpdk-dev] [PATCH v3 5/8] crypto/bcmfs: create a symmetric cryptodev

2020-10-05 Thread Vikas Gupta
Create a symmetric crypto device and add supported cryptodev ops.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 6ff65adfc7..0c99cc7adf 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 9e40c5d747..e8a9c40910 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
index ec1327b780..cb5ff6c61b 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.c
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -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));
+   }
+}
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.h b/drivers/crypto/bcmfs/bcmfs_qp.h
index 59785865b0..57fe0a93a3 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.h
+++ b/drivers/crypto/bcmfs/bcmfs_qp.h
@@ -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_BUFF64
+
+/* 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

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

2020-10-05 Thread Vikas Gupta
Add global test suite for bcmfs crypto pmd

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 app/test/test_cryptodev.c   | 17 +
 app/test/test_cryptodev.h   |  1 +
 doc/guides/cryptodevs/bcmfs.rst | 11 +++
 3 files changed, 29 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 70bf6fe2c1..9157115ab3 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -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);
diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h
index 41542e0552..c58126368c 100644
--- a/app/test/test_cryptodev.h
+++ b/app/test/test_cryptodev.h
@@ -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
diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
index aaa6e1af70..f7b7cde6d7 100644
--- a/doc/guides/cryptodevs/bcmfs.rst
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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
-- 
2.17.1



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

2020-10-05 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_sym.c b/drivers/crypto/bcmfs/bcmfs_sym.c
new file mode 100644
index 00..2d164a1ec8
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym.c
@@ -0,0 +1,289 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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 {
+

Re: [dpdk-dev] [PATCH v2 0/8] Add Crypto PMD for Broadcom`s FlexSparc devices

2020-10-05 Thread Vikas Gupta
Hi Akhil,

On Mon, Oct 5, 2020 at 10:17 PM Ajit Khaparde
 wrote:
>
> On Mon, Oct 5, 2020 at 8:39 AM Akhil Goyal  wrote:
> >
> > Hi Vikas
> >
> > >
> > > >
> > > > 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.
> > > >
> >
> >
> > > 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


[dpdk-dev] [PATCH v4 0/8] Add Crypto PMD for Broadcom`s FlexSparc devices

2020-10-07 Thread 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/

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

2020-10-07 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index f1050ff112..0ccddea202 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 1a4d0cf365..f99d57d4bd 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_vfio.c 
b/drivers/crypto/bcmfs/bcmfs_vfio.c
new file mode 100644
index 00..dc2def580f
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_vfio.c
@@ -0,0 +1,107 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "bcmfs_device.h"
+#include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
+
+#ifdef VFIO_PRESENT
+static int
+vfio_map_dev_obj(const char *path, const char *dev_obj,
+uint32_t *size, void **addr, int *dev_fd)
+{
+   int32_t ret;
+   struct vfio_group_status status = { .argsz = sizeof(status) };
+
+   struct vfio_device_info d_info = { .argsz = sizeof(d_info) };
+   struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
+
+   ret = rte_vfio_setup_device(path, dev_obj, dev_fd, &d_info);
+   if (ret) {
+   BCMFS_LOG(ERR, "VFIO Setting for device failed");
+   return ret;
+   }
+
+   /* getting device region info*/
+   ret = ioctl(*dev_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "Error in VFIO getting REGION_INFO");
+   goto map_failed;
+   }
+
+   *addr = mmap(NULL, reg_info.size,
+PROT_WRITE | PROT_READ, MAP_SHARED,
+*dev_fd, reg_info.offset);
+   if (*addr == MAP_FAILED) {
+   BCMFS_LOG(ERR, "Error mapping region (errno = %d)", errno);
+   ret = errno;
+   goto map_failed;
+   }
+   *size = reg_info.size;
+
+   return 0;
+
+map_failed:
+   rte_vfio_release_device(path, dev_obj, *dev_fd);
+
+   return ret;
+}
+
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+   int vfio_dev_fd;
+   void  *v_addr = NULL;
+   uint32_t size = 0;
+
+   ret = vfio_map_dev_obj(dev->dirname, dev->name,
+  &size, &v_addr, &vfio_dev_fd);
+   if (ret)
+   return -1;
+
+   dev->mmap_size = size;
+   dev->mmap_addr = v_addr;
+   dev->vfio_dev_fd = vfio_dev_fd;
+
+   return 0;
+}
+
+void
+bcmfs_release_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+
+   if (dev == NULL)
+   return;
+
+   /* unmap the addr */
+   munmap(dev->mmap_addr, dev->mmap_size);
+   /* release the device */
+   ret = rte_vfio_release_device(dev->dirname, dev->name,
+ dev->vfio_dev_fd);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "cannot release device");
+   return;
+   }
+}
+#else
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev __rte_unused)
+{
+   return -1;
+}
+
+void
+bcmfs_release_vfio(struct bcmfs_device *dev __rte_unused)
+{
+}
+#endif
diff --git a/dr

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

2020-10-07 Thread Vikas Gupta
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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/MAINTAINERS b/MAINTAINERS
index c0abbe0fc8..49c015ebbe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 
+M: Raveendra Padasalagi 
+M: Vikas Gupta 
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 ---
diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
new file mode 100644
index 00..6b68673df0
--- /dev/null
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -0,0 +1,51 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+Copyright(C) 2020 Broadcom
+
+Broadcom FlexSparc Crypto Poll Mode Driver
+==
+
+The FlexSparc crypto poll mode driver (BCMFS PMD) provides support for 
offloading
+cryptographic operations to the Broadcom SoCs having FlexSparc4/FlexSparc5 
unit.
+Detailed information about SoCs can be found at `Broadcom Official Website
+<https://www.broadcom.com/products/ethernet-connectivity/network-adapters/smartnic>`__.
+
+Supported Broadcom SoCs
+---
+
+* Stingray
+* Stingray2
+
+Installation
+
+Information about kernel, rootfs and toolchain can be found at
+`Broadcom Official Website 
<https://www.broadcom.com/products/ethernet-connectivity
+/network-adapters/smartnic/stingray-software>`__.
+
+.. Note::
+To execute BCMFS PMD, it must be compiled with VFIO_PRESENT flag on the
+compiling platform and same gets enabled in rte_vfio.h.
+
+The BCMFS crypto PMD may be compiled natively on a Stingray/Stingray2 platform 
or
+cross-compiled on an x86 platform. For example, below commands can be executed
+for cross compiling on on x86 platform.
+
+.. code-block:: console
+
+cd 
+meson  --cross-file config/arm/arm64_stingray_linux_gcc
+cd 
+ninja
+
+Initialization
+--
+The supported platform devices should be present in the
+*/sys/bus/platform/devices/fs/* path on the booted kernel.
+To get BCMFS PMD executing, device node must be owned by VFIO platform module 
only.
+For example, below commands can be run to get hold of a device node by VFIO.
+
+.. code-block:: console
+
+SETUP_SYSFS_DEV_NAME=6700.crypto_mbox
+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
diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst
index a67ed5a282..279f56a002 100644
--- a/doc/guides/cryptodevs/index.rst
+++ b/doc/guides/cryptodevs/index.rst
@@ -13,6 +13,7 @@ Crypto Device Drivers
 aesni_mb
 aesni_gcm
 armv8
+bcmfs
 caam_jr
 ccp
 dpaa2_sec
diff --git a/doc/guides/rel_notes/release_20_11.rst 
b/doc/guides/rel_notes/release_20_11.rst
index 73ac08fb0e..8643330321 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -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.
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
new file mode 100644
index 00..f1050ff112

[dpdk-dev] [PATCH v4 4/8] crypto/bcmfs: add HW queue pair operations

2020-10-07 Thread Vikas Gupta
Add queue pair operations exported by supported devices.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_dev_msg.h 
b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
new file mode 100644
index 00..5b50bde35a
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
@@ -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_BUFFERS8
+#define MAX_DST_ADDR_BUFFERS3
+
+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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index a01a5c79d5..07423d3cc1 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -44,6 +44,47 @@ static struct bcmfs_device_attr dev_table[] = {
}
 };
 
+struct bcmfs_hw_queue_pair_ops_table bcmfs_hw_queue_pair_ops_table = {
+   .tl =  RTE_SPINLOCK_INITIALIZER,
+   .num_ops = 0
+};
+
+int bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops *h)
+{
+   struct bcmfs_hw_queue_pair_ops *ops;
+   int16_t ops_index;
+
+   rte_spinlock_lock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   if (h->enq_one_req == NULL || h->dequeue == NULL ||
+   h->ring_db == NULL || h->startq == NULL || h->stopq == NULL) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR,
+ "Missing callback while registering device ops");
+   return -EINVAL;
+   }
+
+   if (strlen(h->name) >= sizeof(ops->name) - 1) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR, "%s(): fs device_ops <%s>: name too long",
+   __func__, h->name);
+   return -EEXIST;
+   }
+
+   ops_index = bcmfs_hw_queue_pair_ops_table.num_ops++;
+   ops = &bcmfs_hw_queue_pair_ops_table.qp_ops[ops_index];
+   strlcpy(ops->name, h->name, sizeof(ops->name));
+   ops->enq_one_req = h->enq_one_req;
+   ops->dequeue = h->dequeue;
+   ops->ring_db = h->ring_db;
+   ops->startq = h->startq;
+   ops->stopq = h->stopq;
+
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   return ops_index;
+}
+
 TAILQ_HEAD(fsdev_list, bcmfs_device);
 static struct fsdev_list fsdev_list = TAILQ_HEAD_INITIALIZER(fsdev_list);
 
@@ -54,6 +95,7 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
   enum bcmfs_device_type dev_type __rte_unused)
 {
struct bcmfs_device *fsdev;
+   uint32_t i;
 
fsdev = rte_calloc(__func__, 1, sizeof(*fsdev), 0);
if (!fsdev)
@@ -69,6 +111,15 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
goto cleanup;
}
 
+   /* check if registered ops name is present in directory path */
+   for (i = 0; i < bcmfs_hw_queue_pair_ops_table.num_ops; i++)
+   if (strstr(dirpath,
+  bcmfs_hw_queue_pair_ops_table.qp_ops[i].name))
+   fsdev->sym_hw_qp_ops =
+   &bcmfs_hw_queue_pair_ops_table.qp_ops[i];
+   if (!fsdev->sym_hw_qp_ops)
+   goto cleanup;
+
strcpy(fsdev->dirname, dirpath);

[dpdk-dev] [PATCH v4 3/8] crypto/bcmfs: add queue pair management API

2020-10-07 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 0ccddea202..a01a5c79d5 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index f99d57d4bd..dede5b82dc 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -11,6 +11,7 @@
 #include 
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES4
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_hw_defs.h 
b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
new file mode 100644
index 00..7d5bb5d8fe
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
@@ -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 
+#include 
+#include 
+#include 
+
+#ifndef BIT
+#define BIT(nr) (1UL << (nr))
+#endif
+
+#define FS_RING_REGS_SIZE  0x1
+#define FS_RING_DESC_SIZE  8
+#define FS_RING_BD_ALIGN_ORDER 12
+#define FS_RING_BD_DESC_PER_REQ32
+#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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
new file mode 100644
index 00..864e7bb746
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -0,0 +1,345 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
+#include "bcmfs_hw_defs.h"
+
+/* TX or submission queue name */
+static const char *txq_name = "tx";
+/* Completion or receive queue name */
+static const char *cmplq_name = "cmpl";
+
+/* Helper function */
+static int
+bcmfs_qp_check_queue_alignment(uint64_t phys_addr,
+  uint32_t align)
+{
+   if (((align - 1) & phys_addr) != 0)
+   return -EINVAL;
+   return 0;
+}
+
+static void
+bcmfs_queue_delete(struct bcmfs_queue *queue,
+  uint16_t queue_pair_id)
+{
+   const struct rte_memzone *mz;
+   int status = 0;
+
+   if (queue == NULL) {
+   BCMFS_LOG(DEBUG, "Invalid queue");
+   return;
+   }
+   BCMFS_LOG(DEBUG, "Free ring %d type %d, memzone: %s",
+ queue_pair_id, queue->q_type, queue->memz_name);
+
+   mz = rte_memzone_lookup(queue->memz_name);
+   if (mz != NULL) {
+   /* Write an unused pattern to the queue memory. */
+   memset(queue->base_addr, 0x9B, queue-

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

2020-10-07 Thread Vikas Gupta
Add session handling and capabilities supported by crypto h/w
accelerator

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
index 6b68673df0..f7e15f4cfb 100644
--- a/doc/guides/cryptodevs/bcmfs.rst
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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.
diff --git a/doc/guides/cryptodevs/features/bcmfs.ini 
b/doc/guides/cryptodevs/features/bcmfs.ini
new file mode 100644
index 00..6a718856b9
--- /dev/null
+++ b/doc/guides/cryptodevs/features/bcmfs.ini
@@ -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
+OOP LB  In LB  Out = 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
+AES GMAC = Y
+AES CMAC (128) = Y
+AES CBC MAC = Y
+AES XCBC MAC = 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
diff --git a/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c 
b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
new file mode 100644
index 00..afed7696a6
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
@@ -0,0 +1,764 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include "bcmfs_sym_capabilities.h"
+
+static const struct rte_cryptodev_capabilities bcmfs_sym_capabilities[] = {
+   {
+   /* SHA1 */
+   .op = RTE_CRYPTO_OP_TYPE_SYMMET

[dpdk-dev] [PATCH v4 5/8] crypto/bcmfs: create a symmetric cryptodev

2020-10-07 Thread Vikas Gupta
Create a symmetric crypto device and add supported cryptodev ops.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 07423d3cc1..27720e4eb8 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 2fb8eed143..e5ca866977 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
index ec1327b780..cb5ff6c61b 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.c
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -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));
+   }
+}
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.h b/drivers/crypto/bcmfs/bcmfs_qp.h
index 59785865b0..57fe0a93a3 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.h
+++ b/drivers/crypto/bcmfs/bcmfs_qp.h
@@ -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_BUFF64
+
+/* 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_h

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

2020-10-07 Thread Vikas Gupta
Add global test suite for bcmfs crypto pmd

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 app/test/test_cryptodev.c   | 17 +
 app/test/test_cryptodev.h   |  1 +
 doc/guides/cryptodevs/bcmfs.rst | 11 +++
 3 files changed, 29 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 70bf6fe2c1..9157115ab3 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -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);
diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h
index 41542e0552..c58126368c 100644
--- a/app/test/test_cryptodev.h
+++ b/app/test/test_cryptodev.h
@@ -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
diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
index f7e15f4cfb..5a7eb23c0f 100644
--- a/doc/guides/cryptodevs/bcmfs.rst
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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
-- 
2.17.1



[dpdk-dev] [PATCH v4 7/8] crypto/bcmfs: add crypto HW module

2020-10-07 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_sym.c b/drivers/crypto/bcmfs/bcmfs_sym.c
new file mode 100644
index 00..2d164a1ec8
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym.c
@@ -0,0 +1,289 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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 {
+

[dpdk-dev] [PATCH v5 0/8] Add Crypto PMD for Broadcom`s FlexSparc devices

2020-10-07 Thread 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

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

2020-10-07 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index f1050ff112..0ccddea202 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 1a4d0cf365..f99d57d4bd 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_vfio.c 
b/drivers/crypto/bcmfs/bcmfs_vfio.c
new file mode 100644
index 00..dc2def580f
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_vfio.c
@@ -0,0 +1,107 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "bcmfs_device.h"
+#include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
+
+#ifdef VFIO_PRESENT
+static int
+vfio_map_dev_obj(const char *path, const char *dev_obj,
+uint32_t *size, void **addr, int *dev_fd)
+{
+   int32_t ret;
+   struct vfio_group_status status = { .argsz = sizeof(status) };
+
+   struct vfio_device_info d_info = { .argsz = sizeof(d_info) };
+   struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
+
+   ret = rte_vfio_setup_device(path, dev_obj, dev_fd, &d_info);
+   if (ret) {
+   BCMFS_LOG(ERR, "VFIO Setting for device failed");
+   return ret;
+   }
+
+   /* getting device region info*/
+   ret = ioctl(*dev_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "Error in VFIO getting REGION_INFO");
+   goto map_failed;
+   }
+
+   *addr = mmap(NULL, reg_info.size,
+PROT_WRITE | PROT_READ, MAP_SHARED,
+*dev_fd, reg_info.offset);
+   if (*addr == MAP_FAILED) {
+   BCMFS_LOG(ERR, "Error mapping region (errno = %d)", errno);
+   ret = errno;
+   goto map_failed;
+   }
+   *size = reg_info.size;
+
+   return 0;
+
+map_failed:
+   rte_vfio_release_device(path, dev_obj, *dev_fd);
+
+   return ret;
+}
+
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+   int vfio_dev_fd;
+   void  *v_addr = NULL;
+   uint32_t size = 0;
+
+   ret = vfio_map_dev_obj(dev->dirname, dev->name,
+  &size, &v_addr, &vfio_dev_fd);
+   if (ret)
+   return -1;
+
+   dev->mmap_size = size;
+   dev->mmap_addr = v_addr;
+   dev->vfio_dev_fd = vfio_dev_fd;
+
+   return 0;
+}
+
+void
+bcmfs_release_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+
+   if (dev == NULL)
+   return;
+
+   /* unmap the addr */
+   munmap(dev->mmap_addr, dev->mmap_size);
+   /* release the device */
+   ret = rte_vfio_release_device(dev->dirname, dev->name,
+ dev->vfio_dev_fd);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "cannot release device");
+   return;
+   }
+}
+#else
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev __rte_unused)
+{
+   return -1;
+}
+
+void
+bcmfs_release_vfio(struct bcmfs_device *dev __rte_unused)
+{
+}
+#endif
diff --git a/dr

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

2020-10-07 Thread Vikas Gupta
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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/MAINTAINERS b/MAINTAINERS
index c0abbe0fc8..49c015ebbe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 
+M: Raveendra Padasalagi 
+M: Vikas Gupta 
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 ---
diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
new file mode 100644
index 00..6b68673df0
--- /dev/null
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -0,0 +1,51 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+Copyright(C) 2020 Broadcom
+
+Broadcom FlexSparc Crypto Poll Mode Driver
+==
+
+The FlexSparc crypto poll mode driver (BCMFS PMD) provides support for 
offloading
+cryptographic operations to the Broadcom SoCs having FlexSparc4/FlexSparc5 
unit.
+Detailed information about SoCs can be found at `Broadcom Official Website
+<https://www.broadcom.com/products/ethernet-connectivity/network-adapters/smartnic>`__.
+
+Supported Broadcom SoCs
+---
+
+* Stingray
+* Stingray2
+
+Installation
+
+Information about kernel, rootfs and toolchain can be found at
+`Broadcom Official Website 
<https://www.broadcom.com/products/ethernet-connectivity
+/network-adapters/smartnic/stingray-software>`__.
+
+.. Note::
+To execute BCMFS PMD, it must be compiled with VFIO_PRESENT flag on the
+compiling platform and same gets enabled in rte_vfio.h.
+
+The BCMFS crypto PMD may be compiled natively on a Stingray/Stingray2 platform 
or
+cross-compiled on an x86 platform. For example, below commands can be executed
+for cross compiling on on x86 platform.
+
+.. code-block:: console
+
+cd 
+meson  --cross-file config/arm/arm64_stingray_linux_gcc
+cd 
+ninja
+
+Initialization
+--
+The supported platform devices should be present in the
+*/sys/bus/platform/devices/fs/* path on the booted kernel.
+To get BCMFS PMD executing, device node must be owned by VFIO platform module 
only.
+For example, below commands can be run to get hold of a device node by VFIO.
+
+.. code-block:: console
+
+SETUP_SYSFS_DEV_NAME=6700.crypto_mbox
+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
diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst
index a67ed5a282..279f56a002 100644
--- a/doc/guides/cryptodevs/index.rst
+++ b/doc/guides/cryptodevs/index.rst
@@ -13,6 +13,7 @@ Crypto Device Drivers
 aesni_mb
 aesni_gcm
 armv8
+bcmfs
 caam_jr
 ccp
 dpaa2_sec
diff --git a/doc/guides/rel_notes/release_20_11.rst 
b/doc/guides/rel_notes/release_20_11.rst
index 73ac08fb0e..8643330321 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -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.
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
new file mode 100644
index 00..f1050ff112

[dpdk-dev] [PATCH v5 3/8] crypto/bcmfs: add queue pair management API

2020-10-07 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 0ccddea202..a01a5c79d5 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index f99d57d4bd..dede5b82dc 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -11,6 +11,7 @@
 #include 
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES4
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_hw_defs.h 
b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
new file mode 100644
index 00..7d5bb5d8fe
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
@@ -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 
+#include 
+#include 
+#include 
+
+#ifndef BIT
+#define BIT(nr) (1UL << (nr))
+#endif
+
+#define FS_RING_REGS_SIZE  0x1
+#define FS_RING_DESC_SIZE  8
+#define FS_RING_BD_ALIGN_ORDER 12
+#define FS_RING_BD_DESC_PER_REQ32
+#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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
new file mode 100644
index 00..864e7bb746
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -0,0 +1,345 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
+#include "bcmfs_hw_defs.h"
+
+/* TX or submission queue name */
+static const char *txq_name = "tx";
+/* Completion or receive queue name */
+static const char *cmplq_name = "cmpl";
+
+/* Helper function */
+static int
+bcmfs_qp_check_queue_alignment(uint64_t phys_addr,
+  uint32_t align)
+{
+   if (((align - 1) & phys_addr) != 0)
+   return -EINVAL;
+   return 0;
+}
+
+static void
+bcmfs_queue_delete(struct bcmfs_queue *queue,
+  uint16_t queue_pair_id)
+{
+   const struct rte_memzone *mz;
+   int status = 0;
+
+   if (queue == NULL) {
+   BCMFS_LOG(DEBUG, "Invalid queue");
+   return;
+   }
+   BCMFS_LOG(DEBUG, "Free ring %d type %d, memzone: %s",
+ queue_pair_id, queue->q_type, queue->memz_name);
+
+   mz = rte_memzone_lookup(queue->memz_name);
+   if (mz != NULL) {
+   /* Write an unused pattern to the queue memory. */
+   memset(queue->base_addr, 0x9B, queue-

[dpdk-dev] [PATCH v5 5/8] crypto/bcmfs: create a symmetric cryptodev

2020-10-07 Thread Vikas Gupta
Create a symmetric crypto device and add supported cryptodev ops.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 07423d3cc1..27720e4eb8 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 2fb8eed143..e5ca866977 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
index ec1327b780..cb5ff6c61b 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.c
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -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));
+   }
+}
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.h b/drivers/crypto/bcmfs/bcmfs_qp.h
index 59785865b0..57fe0a93a3 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.h
+++ b/drivers/crypto/bcmfs/bcmfs_qp.h
@@ -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_BUFF64
+
+/* 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_h

[dpdk-dev] [PATCH v5 4/8] crypto/bcmfs: add HW queue pair operations

2020-10-07 Thread Vikas Gupta
Add queue pair operations exported by supported devices.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_dev_msg.h 
b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
new file mode 100644
index 00..5b50bde35a
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
@@ -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_BUFFERS8
+#define MAX_DST_ADDR_BUFFERS3
+
+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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index a01a5c79d5..07423d3cc1 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -44,6 +44,47 @@ static struct bcmfs_device_attr dev_table[] = {
}
 };
 
+struct bcmfs_hw_queue_pair_ops_table bcmfs_hw_queue_pair_ops_table = {
+   .tl =  RTE_SPINLOCK_INITIALIZER,
+   .num_ops = 0
+};
+
+int bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops *h)
+{
+   struct bcmfs_hw_queue_pair_ops *ops;
+   int16_t ops_index;
+
+   rte_spinlock_lock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   if (h->enq_one_req == NULL || h->dequeue == NULL ||
+   h->ring_db == NULL || h->startq == NULL || h->stopq == NULL) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR,
+ "Missing callback while registering device ops");
+   return -EINVAL;
+   }
+
+   if (strlen(h->name) >= sizeof(ops->name) - 1) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR, "%s(): fs device_ops <%s>: name too long",
+   __func__, h->name);
+   return -EEXIST;
+   }
+
+   ops_index = bcmfs_hw_queue_pair_ops_table.num_ops++;
+   ops = &bcmfs_hw_queue_pair_ops_table.qp_ops[ops_index];
+   strlcpy(ops->name, h->name, sizeof(ops->name));
+   ops->enq_one_req = h->enq_one_req;
+   ops->dequeue = h->dequeue;
+   ops->ring_db = h->ring_db;
+   ops->startq = h->startq;
+   ops->stopq = h->stopq;
+
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   return ops_index;
+}
+
 TAILQ_HEAD(fsdev_list, bcmfs_device);
 static struct fsdev_list fsdev_list = TAILQ_HEAD_INITIALIZER(fsdev_list);
 
@@ -54,6 +95,7 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
   enum bcmfs_device_type dev_type __rte_unused)
 {
struct bcmfs_device *fsdev;
+   uint32_t i;
 
fsdev = rte_calloc(__func__, 1, sizeof(*fsdev), 0);
if (!fsdev)
@@ -69,6 +111,15 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
goto cleanup;
}
 
+   /* check if registered ops name is present in directory path */
+   for (i = 0; i < bcmfs_hw_queue_pair_ops_table.num_ops; i++)
+   if (strstr(dirpath,
+  bcmfs_hw_queue_pair_ops_table.qp_ops[i].name))
+   fsdev->sym_hw_qp_ops =
+   &bcmfs_hw_queue_pair_ops_table.qp_ops[i];
+   if (!fsdev->sym_hw_qp_ops)
+   goto cleanup;
+
strcpy(fsdev->dirname, dirpath);

[dpdk-dev] [PATCH v5 7/8] crypto/bcmfs: add crypto HW module

2020-10-07 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_sym.c b/drivers/crypto/bcmfs/bcmfs_sym.c
new file mode 100644
index 00..2d164a1ec8
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym.c
@@ -0,0 +1,289 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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 {
+

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

2020-10-07 Thread Vikas Gupta
Add session handling and capabilities supported by crypto HW
accelerator

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
index 6b68673df0..f7e15f4cfb 100644
--- a/doc/guides/cryptodevs/bcmfs.rst
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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.
diff --git a/doc/guides/cryptodevs/features/bcmfs.ini 
b/doc/guides/cryptodevs/features/bcmfs.ini
new file mode 100644
index 00..6a718856b9
--- /dev/null
+++ b/doc/guides/cryptodevs/features/bcmfs.ini
@@ -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
+OOP LB  In LB  Out = 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
+AES GMAC = Y
+AES CMAC (128) = Y
+AES CBC MAC = Y
+AES XCBC MAC = 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
diff --git a/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c 
b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
new file mode 100644
index 00..afed7696a6
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
@@ -0,0 +1,764 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include "bcmfs_sym_capabilities.h"
+
+static const struct rte_cryptodev_capabilities bcmfs_sym_capabilities[] = {
+   {
+   /* SHA1 */
+   .op = RTE_CRYPTO_OP_TYPE_SYMMET

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

2020-10-07 Thread Vikas Gupta
Add global test suite for bcmfs crypto pmd

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 app/test/test_cryptodev.c   | 17 +
 app/test/test_cryptodev.h   |  1 +
 doc/guides/cryptodevs/bcmfs.rst | 11 +++
 3 files changed, 29 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 70bf6fe2c1..9157115ab3 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -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);
diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h
index 41542e0552..c58126368c 100644
--- a/app/test/test_cryptodev.h
+++ b/app/test/test_cryptodev.h
@@ -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
diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
index f7e15f4cfb..5a7eb23c0f 100644
--- a/doc/guides/cryptodevs/bcmfs.rst
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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
-- 
2.17.1



[dpdk-dev] [PATCH v1 0/1] optimization for crypto request processing

2020-10-12 Thread Vikas Gupta
Hi,
 This patch optimizes for crypto request processing in crypto engine
 by reducing the number of source BDs for Broadcom FlexSparc device.

The patch has been tested on FlexSparc device.

Regards,
Vikas

Vikas Gupta (1):
  crypto/bcmfs: optimize crypto request processing

 drivers/crypto/bcmfs/bcmfs_sym_defs.h   |   5 +
 drivers/crypto/bcmfs/bcmfs_sym_engine.c | 220 +---
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c|   6 +-
 drivers/crypto/bcmfs/bcmfs_sym_req.h|  29 ++--
 4 files changed, 138 insertions(+), 122 deletions(-)

-- 
2.17.1



[dpdk-dev] [PATCH v1 1/1] crypto/bcmfs: optimize crypto request processing

2020-10-12 Thread Vikas Gupta
Reduce number of source BDs to submit a request to crypto engine.
This improves the performance as crypto engine fetches all the BDs in
single cycle. Adjust optional metadata (OMD) in continuation of
fixed meta data (FMD).

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 drivers/crypto/bcmfs/bcmfs_sym_defs.h   |   5 +
 drivers/crypto/bcmfs/bcmfs_sym_engine.c | 220 +---
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c|   6 +-
 drivers/crypto/bcmfs/bcmfs_sym_req.h|  29 ++--
 4 files changed, 138 insertions(+), 122 deletions(-)

diff --git a/drivers/crypto/bcmfs/bcmfs_sym_defs.h 
b/drivers/crypto/bcmfs/bcmfs_sym_defs.h
index aea1f281e4..eaefe97e26 100644
--- a/drivers/crypto/bcmfs/bcmfs_sym_defs.h
+++ b/drivers/crypto/bcmfs/bcmfs_sym_defs.h
@@ -27,6 +27,11 @@ struct bcmfs_sym_request;
 /** Crypot Request processing hash tag check error. */
 #define BCMFS_SYM_RESPONSE_HASH_TAG_ERROR(3)
 
+/** Maximum threshold length to adjust AAD in continuation
+ *  with source BD of (FMD + OMD)
+ */
+#define BCMFS_AAD_THRESH_LEN   64
+
 int
 bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
struct bcmfs_sym_session *sess,
diff --git a/drivers/crypto/bcmfs/bcmfs_sym_engine.c 
b/drivers/crypto/bcmfs/bcmfs_sym_engine.c
index 537bfbec8b..458acd0966 100644
--- a/drivers/crypto/bcmfs/bcmfs_sym_engine.c
+++ b/drivers/crypto/bcmfs/bcmfs_sym_engine.c
@@ -565,6 +565,7 @@ bcmfs_crypto_build_auth_req(struct bcmfs_sym_request *sreq,
int src_index = 0;
struct spu2_fmd *fmd;
uint64_t payload_len;
+   uint32_t src_msg_len = 0;
enum spu2_hash_mode spu2_auth_mode;
enum spu2_hash_type spu2_auth_type = SPU2_HASH_TYPE_NONE;
uint64_t iv_size = (iv != NULL) ? fsattr_sz(iv) : 0;
@@ -613,26 +614,25 @@ bcmfs_crypto_build_auth_req(struct bcmfs_sym_request 
*sreq,
 
spu2_fmd_ctrl3_write(fmd, fsattr_sz(src));
 
-   /* Source metadata and data pointers */
+   /* FMD */
sreq->msgs.srcs_addr[src_index] = sreq->fptr;
-   sreq->msgs.srcs_len[src_index] = sizeof(struct spu2_fmd);
-   src_index++;
-
-   if (auth_key != NULL && fsattr_sz(auth_key) != 0) {
-   memcpy(sreq->auth_key, fsattr_va(auth_key),
-  fsattr_sz(auth_key));
+   src_msg_len += sizeof(*fmd);
 
-   sreq->msgs.srcs_addr[src_index] = sreq->aptr;
-   sreq->msgs.srcs_len[src_index] = fsattr_sz(auth_key);
-   src_index++;
+   /* Start of OMD */
+   if (auth_ksize != 0) {
+   memcpy((uint8_t *)fmd + src_msg_len, fsattr_va(auth_key),
+  auth_ksize);
+   src_msg_len += auth_ksize;
}
 
-   if (iv != NULL && fsattr_sz(iv) != 0) {
-   memcpy(sreq->iv, fsattr_va(iv), fsattr_sz(iv));
-   sreq->msgs.srcs_addr[src_index] = sreq->iptr;
-   sreq->msgs.srcs_len[src_index] = iv_size;
-   src_index++;
-   }
+   if (iv_size != 0) {
+   memcpy((uint8_t *)fmd + src_msg_len, fsattr_va(iv),
+  iv_size);
+   src_msg_len += iv_size;
+   } /* End of OMD */
+
+   sreq->msgs.srcs_len[src_index] = src_msg_len;
+   src_index++;
 
sreq->msgs.srcs_addr[src_index] = fsattr_pa(src);
sreq->msgs.srcs_len[src_index] = fsattr_sz(src);
@@ -683,7 +683,7 @@ bcmfs_crypto_build_cipher_req(struct bcmfs_sym_request 
*sreq,
int ret = 0;
int src_index = 0;
struct spu2_fmd *fmd;
-   unsigned int xts_keylen;
+   uint32_t src_msg_len = 0;
enum spu2_cipher_mode spu2_ciph_mode = 0;
enum spu2_cipher_type spu2_ciph_type = SPU2_CIPHER_TYPE_NONE;
bool is_inbound = (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT);
@@ -714,36 +714,36 @@ bcmfs_crypto_build_cipher_req(struct bcmfs_sym_request 
*sreq,
 
spu2_fmd_ctrl3_write(fmd, fsattr_sz(src));
 
-   /* Source metadata and data pointers */
+   /* FMD */
sreq->msgs.srcs_addr[src_index] = sreq->fptr;
-   sreq->msgs.srcs_len[src_index] = sizeof(struct spu2_fmd);
-   src_index++;
+   src_msg_len += sizeof(*fmd);
 
+   /* Start of OMD */
if (cipher_key != NULL && fsattr_sz(cipher_key) != 0) {
+   uint8_t *cipher_buf = (uint8_t *)fmd + src_msg_len;
if (calgo == RTE_CRYPTO_CIPHER_AES_XTS) {
-   xts_keylen = fsattr_sz(cipher_key) / 2;
-   memcpy(sreq->cipher_key,
+   uint32_t xts_keylen = fsattr_sz(cipher_key) / 2;
+   memcpy(cipher_buf,
   (uint8_t *)fsattr_va(cipher_key) + xts_keylen,
   xts_keylen);
-   memcpy(sreq->cipher_key + xts_keylen,
+   memcpy(cipher_b

[dpdk-dev] [PATCH v2 1/1] crypto/bcmfs: optimize crypto request processing

2020-10-13 Thread Vikas Gupta
Reduce number of source BDs to submit a request to crypto engine.
This improves the performance as crypto engine fetches all the BDs in
single cycle. Adjust optional metadata (OMD) in continuation of
fixed meta data (FMD).

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 drivers/crypto/bcmfs/bcmfs_sym_defs.h   |   5 +
 drivers/crypto/bcmfs/bcmfs_sym_engine.c | 220 +---
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c|   6 +-
 drivers/crypto/bcmfs/bcmfs_sym_req.h|  29 ++--
 4 files changed, 138 insertions(+), 122 deletions(-)

diff --git a/drivers/crypto/bcmfs/bcmfs_sym_defs.h 
b/drivers/crypto/bcmfs/bcmfs_sym_defs.h
index aea1f281e..eaefe97e2 100644
--- a/drivers/crypto/bcmfs/bcmfs_sym_defs.h
+++ b/drivers/crypto/bcmfs/bcmfs_sym_defs.h
@@ -27,6 +27,11 @@ struct bcmfs_sym_request;
 /** Crypot Request processing hash tag check error. */
 #define BCMFS_SYM_RESPONSE_HASH_TAG_ERROR(3)
 
+/** Maximum threshold length to adjust AAD in continuation
+ *  with source BD of (FMD + OMD)
+ */
+#define BCMFS_AAD_THRESH_LEN   64
+
 int
 bcmfs_process_sym_crypto_op(struct rte_crypto_op *op,
struct bcmfs_sym_session *sess,
diff --git a/drivers/crypto/bcmfs/bcmfs_sym_engine.c 
b/drivers/crypto/bcmfs/bcmfs_sym_engine.c
index 537bfbec8..458acd096 100644
--- a/drivers/crypto/bcmfs/bcmfs_sym_engine.c
+++ b/drivers/crypto/bcmfs/bcmfs_sym_engine.c
@@ -565,6 +565,7 @@ bcmfs_crypto_build_auth_req(struct bcmfs_sym_request *sreq,
int src_index = 0;
struct spu2_fmd *fmd;
uint64_t payload_len;
+   uint32_t src_msg_len = 0;
enum spu2_hash_mode spu2_auth_mode;
enum spu2_hash_type spu2_auth_type = SPU2_HASH_TYPE_NONE;
uint64_t iv_size = (iv != NULL) ? fsattr_sz(iv) : 0;
@@ -613,26 +614,25 @@ bcmfs_crypto_build_auth_req(struct bcmfs_sym_request 
*sreq,
 
spu2_fmd_ctrl3_write(fmd, fsattr_sz(src));
 
-   /* Source metadata and data pointers */
+   /* FMD */
sreq->msgs.srcs_addr[src_index] = sreq->fptr;
-   sreq->msgs.srcs_len[src_index] = sizeof(struct spu2_fmd);
-   src_index++;
-
-   if (auth_key != NULL && fsattr_sz(auth_key) != 0) {
-   memcpy(sreq->auth_key, fsattr_va(auth_key),
-  fsattr_sz(auth_key));
+   src_msg_len += sizeof(*fmd);
 
-   sreq->msgs.srcs_addr[src_index] = sreq->aptr;
-   sreq->msgs.srcs_len[src_index] = fsattr_sz(auth_key);
-   src_index++;
+   /* Start of OMD */
+   if (auth_ksize != 0) {
+   memcpy((uint8_t *)fmd + src_msg_len, fsattr_va(auth_key),
+  auth_ksize);
+   src_msg_len += auth_ksize;
}
 
-   if (iv != NULL && fsattr_sz(iv) != 0) {
-   memcpy(sreq->iv, fsattr_va(iv), fsattr_sz(iv));
-   sreq->msgs.srcs_addr[src_index] = sreq->iptr;
-   sreq->msgs.srcs_len[src_index] = iv_size;
-   src_index++;
-   }
+   if (iv_size != 0) {
+   memcpy((uint8_t *)fmd + src_msg_len, fsattr_va(iv),
+  iv_size);
+   src_msg_len += iv_size;
+   } /* End of OMD */
+
+   sreq->msgs.srcs_len[src_index] = src_msg_len;
+   src_index++;
 
sreq->msgs.srcs_addr[src_index] = fsattr_pa(src);
sreq->msgs.srcs_len[src_index] = fsattr_sz(src);
@@ -683,7 +683,7 @@ bcmfs_crypto_build_cipher_req(struct bcmfs_sym_request 
*sreq,
int ret = 0;
int src_index = 0;
struct spu2_fmd *fmd;
-   unsigned int xts_keylen;
+   uint32_t src_msg_len = 0;
enum spu2_cipher_mode spu2_ciph_mode = 0;
enum spu2_cipher_type spu2_ciph_type = SPU2_CIPHER_TYPE_NONE;
bool is_inbound = (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT);
@@ -714,36 +714,36 @@ bcmfs_crypto_build_cipher_req(struct bcmfs_sym_request 
*sreq,
 
spu2_fmd_ctrl3_write(fmd, fsattr_sz(src));
 
-   /* Source metadata and data pointers */
+   /* FMD */
sreq->msgs.srcs_addr[src_index] = sreq->fptr;
-   sreq->msgs.srcs_len[src_index] = sizeof(struct spu2_fmd);
-   src_index++;
+   src_msg_len += sizeof(*fmd);
 
+   /* Start of OMD */
if (cipher_key != NULL && fsattr_sz(cipher_key) != 0) {
+   uint8_t *cipher_buf = (uint8_t *)fmd + src_msg_len;
if (calgo == RTE_CRYPTO_CIPHER_AES_XTS) {
-   xts_keylen = fsattr_sz(cipher_key) / 2;
-   memcpy(sreq->cipher_key,
+   uint32_t xts_keylen = fsattr_sz(cipher_key) / 2;
+   memcpy(cipher_buf,
   (uint8_t *)fsattr_va(cipher_key) + xts_keylen,
   xts_keylen);
-   memcpy(sreq->cipher_key + xts_keylen,
+   memcpy(cipher_buf + xts_keylen,

[dpdk-dev] [PATCH v2 0/1] optimization for crypto request processing

2020-10-13 Thread Vikas Gupta
Hi,
 This patch optimizes for crypto request processing in crypto engine
 by reducing the number of source BDs for Broadcom FlexSparc device.

The patch has been tested on FlexSparc device.

Regards,
Vikas

Changes from: v1->v2 
Rebase the patch with latest dpdk-next-crypto

Vikas Gupta (1):
  crypto/bcmfs: optimize crypto request processing

 drivers/crypto/bcmfs/bcmfs_sym_defs.h   |   5 +
 drivers/crypto/bcmfs/bcmfs_sym_engine.c | 220 +---
 drivers/crypto/bcmfs/bcmfs_sym_pmd.c|   6 +-
 drivers/crypto/bcmfs/bcmfs_sym_req.h|  29 ++--
 4 files changed, 138 insertions(+), 122 deletions(-)

-- 
2.17.1



[dpdk-dev] [PATCH v1 0/8] Add Crypto PMD for Broadcom`s FlexSparc devices

2020-08-12 Thread 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 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

-- 
2.17.1



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

2020-08-12 Thread Vikas Gupta
Add vfio support for device.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/Makefile b/drivers/crypto/bcmfs/Makefile
index 781ee6efa..5f691f7ba 100644
--- a/drivers/crypto/bcmfs/Makefile
+++ b/drivers/crypto/bcmfs/Makefile
@@ -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
 
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 47c776de6..3b5cc9e98 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 4b0c6d3ca..5232bdea5 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_vfio.c 
b/drivers/crypto/bcmfs/bcmfs_vfio.c
new file mode 100644
index 0..9138f96eb
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_vfio.c
@@ -0,0 +1,94 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "bcmfs_device.h"
+#include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
+
+static int
+vfio_map_dev_obj(const char *path, const char *dev_obj,
+uint32_t *size, void **addr, int *dev_fd)
+{
+   int32_t ret;
+   struct vfio_group_status status = { .argsz = sizeof(status) };
+
+   struct vfio_device_info d_info = { .argsz = sizeof(d_info) };
+   struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
+
+   ret = rte_vfio_setup_device(path, dev_obj, dev_fd, &d_info);
+   if (ret) {
+   BCMFS_LOG(ERR, "VFIO Setting for device failed");
+   return ret;
+   }
+
+   /* getting device region info*/
+   ret = ioctl(*dev_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "Error in VFIO getting REGION_INFO");
+   goto map_failed;
+   }
+
+   *addr = mmap(NULL, reg_info.size,
+PROT_WRITE | PROT_READ, MAP_SHARED,
+*dev_fd, reg_info.offset);
+   if (*addr == MAP_FAILED) {
+   BCMFS_LOG(ERR, "Error mapping region (errno = %d)", errno);
+   ret = errno;
+   goto map_failed;
+   }
+   *size = reg_info.size;
+
+   return 0;
+
+map_failed:
+   rte_vfio_release_device(path, dev_obj, *dev_fd);
+
+   return ret;
+}
+
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+   int vfio_dev_fd;
+   void  *v_addr = NULL;
+   uint32_t size = 0;
+
+   ret = vfio_map_dev_obj(dev->dirname, dev->name,
+  &size, &v_addr, &vfio_dev_fd);
+   if (ret)
+   return -1;
+
+   dev->mmap_size = size;
+   dev->mmap_addr = v_addr;
+   dev->vfio_dev_fd = vfio_dev_fd;
+
+   return 0;
+}
+
+void
+bcmfs_release_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+
+   if (dev == NULL)
+   return;
+
+   /* unmap the addr */
+   munmap(dev->mmap_addr, dev->mmap_size);
+   /* release the device */
+   ret = rte_vfio_release_device(dev->dirname, dev->name,
+ dev->vfio_dev_fd);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "cannot release device");
+   return;
+   }
+}
diff --git a/drivers/crypto/bcmfs/bcmfs_vfio.h 
b/dr

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

2020-08-12 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/MAINTAINERS b/MAINTAINERS
index 3cd402b34..7c2d7ff1b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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  
+M: Raveendra Padasalagi 
+M: Ajit Khaparde 
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 ---
diff --git a/config/common_base b/config/common_base
index f7a8824f5..21daadcdd 100644
--- a/config/common_base
+++ b/config/common_base
@@ -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
 #
diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
new file mode 100644
index 0..752ce028a
--- /dev/null
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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/ on the platform.
+Each cryptodev PMD instance can be attached to the nodes present
+in the mentioned path.
diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst
index a67ed5a28..5d7e028bd 100644
--- a/doc/guides/cryptodevs/index.rst
+++ b/doc/guides/cryptodevs/index.rst
@@ -29,3 +29,4 @@ Crypto Device Drivers
 qat
 virtio
 zuc
+bcmfs
diff --git a/drivers/crypto/bcmfs/Makefile b/drivers/crypto/bcmfs/Makefile
new file mode 100644
index 0..781ee6efa
--- /dev/null
+++ b/drivers/crypto/bcmfs/Makefile
@@ -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
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
new file mode 100644
index 0..47c776de6
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -0,0 +1,256 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#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 vers

[dpdk-dev] [PATCH v1 5/8] crypto/bcmfs: create a symmetric cryptodev

2020-08-12 Thread Vikas Gupta
Create a symmetric crypto device and supported cryptodev ops.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index bd2d64acf..c9263ec28 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 96beb10fa..37907b91f 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
index ec1327b78..cb5ff6c61 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.c
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -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));
+   }
+}
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.h b/drivers/crypto/bcmfs/bcmfs_qp.h
index e4b0c3f2f..fec58ca71 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.h
+++ b/drivers/crypto/bcmfs/bcmfs_qp.h
@@ -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_BUFF64
+
+/* 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 */
  

[dpdk-dev] [PATCH v1 4/8] crypto/bcmfs: add hw queue pair operations

2020-08-12 Thread Vikas Gupta
Add queue pair operations exported by supported devices.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_dev_msg.h 
b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
new file mode 100644
index 0..5b50bde35
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
@@ -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_BUFFERS8
+#define MAX_DST_ADDR_BUFFERS3
+
+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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index b475c2933..bd2d64acf 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -43,6 +43,47 @@ static struct bcmfs_device_attr dev_table[] = {
}
 };
 
+struct bcmfs_hw_queue_pair_ops_table bcmfs_hw_queue_pair_ops_table = {
+   .tl =  RTE_SPINLOCK_INITIALIZER,
+   .num_ops = 0
+};
+
+int bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops *h)
+{
+   struct bcmfs_hw_queue_pair_ops *ops;
+   int16_t ops_index;
+
+   rte_spinlock_lock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   if (h->enq_one_req == NULL || h->dequeue == NULL ||
+   h->ring_db == NULL || h->startq == NULL || h->stopq == NULL) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR,
+ "Missing callback while registering device ops");
+   return -EINVAL;
+   }
+
+   if (strlen(h->name) >= sizeof(ops->name) - 1) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR, "%s(): fs device_ops <%s>: name too long",
+   __func__, h->name);
+   return -EEXIST;
+   }
+
+   ops_index = bcmfs_hw_queue_pair_ops_table.num_ops++;
+   ops = &bcmfs_hw_queue_pair_ops_table.qp_ops[ops_index];
+   strlcpy(ops->name, h->name, sizeof(ops->name));
+   ops->enq_one_req = h->enq_one_req;
+   ops->dequeue = h->dequeue;
+   ops->ring_db = h->ring_db;
+   ops->startq = h->startq;
+   ops->stopq = h->stopq;
+
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   return ops_index;
+}
+
 TAILQ_HEAD(fsdev_list, bcmfs_device);
 static struct fsdev_list fsdev_list = TAILQ_HEAD_INITIALIZER(fsdev_list);
 
@@ -53,6 +94,7 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
   enum bcmfs_device_type dev_type __rte_unused)
 {
struct bcmfs_device *fsdev;
+   uint32_t i;
 
fsdev = calloc(1, sizeof(*fsdev));
if (!fsdev)
@@ -68,6 +110,15 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
goto cleanup;
}
 
+   /* check if registered ops name is present in directory path */
+   for (i = 0; i < bcmfs_hw_queue_pair_ops_table.num_ops; i++)
+   if (strstr(dirpath,
+  bcmfs_hw_queue_pair_ops_table.qp_ops[i].name))
+   fsdev->sym_hw_qp_ops =
+   &bcmfs_hw_queue_pair_ops_table.qp_ops[i];
+   if (!fsdev->sym_hw_qp_ops)
+   goto cleanup;
+
strcpy(fsdev->dirname, dirpath);
strcpy(

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

2020-08-12 Thread Vikas Gupta
Add session handling and capabilities supported by crypto h/w
accelerator.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
index 752ce028a..2488b19f7 100644
--- a/doc/guides/cryptodevs/bcmfs.rst
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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/ 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.
diff --git a/doc/guides/cryptodevs/features/bcmfs.ini 
b/doc/guides/cryptodevs/features/bcmfs.ini
new file mode 100644
index 0..82d2c639d
--- /dev/null
+++ b/doc/guides/cryptodevs/features/bcmfs.ini
@@ -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
+AES GMAC = Y
+AES CMAC (128) = Y
+AES CBC = Y
+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
diff --git a/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c 
b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
new file mode 100644
index 0..bb8fa9f81
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
@@ -0,0 +1,764 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include "bcmfs_sym_capabilities.h"
+
+static const struct rte_cryptodev_capabilities bcmfs_sym_capabilities[] = {
+   {
+   /* SHA1 */
+   .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+   {.sym = {
+   .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+   {.auth = {
+ 

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

2020-08-12 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/Makefile b/drivers/crypto/bcmfs/Makefile
deleted file mode 100644
index 5f691f7ba..0
--- a/drivers/crypto/bcmfs/Makefile
+++ /dev/null
@@ -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
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 3b5cc9e98..b475c2933 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 5232bdea5..e03ce5b5b 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -11,6 +11,7 @@
 #include 
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES4
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_hw_defs.h 
b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
new file mode 100644
index 0..ecb0c09ba
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
@@ -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 
+#include 
+#include 
+#include 
+
+/* 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  0x1
+#define FS_RING_DESC_SIZE  8
+#define FS_RING_BD_ALIGN_ORDER 12
+#define FS_RING_BD_DESC_PER_REQ32
+#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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
new file mode 100644
index 0..864e7bb74
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -0,0 +1,345 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
+#include "bcmfs_hw_defs.h"
+
+/* TX or submission queue name */
+static const char *txq_name = &q

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

2020-08-12 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_sym.c b/drivers/crypto/bcmfs/bcmfs_sym.c
new file mode 100644
index 0..8f9415b5e
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym.c
@@ -0,0 +1,316 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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

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

2020-08-12 Thread Vikas Gupta
Add test suites for supported algorithms by bcmfs crypto pmd

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 app/test/test_cryptodev.c | 261 ++
 app/test/test_cryptodev.h |   1 +
 2 files changed, 262 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 70bf6fe2c..6e7d8471c 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -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, u

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

2020-08-13 Thread Vikas Gupta
Add vfio support for device.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 47c776de6..3b5cc9e98 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index cc64a8df2..c41cc0031 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_vfio.c 
b/drivers/crypto/bcmfs/bcmfs_vfio.c
new file mode 100644
index 0..dc2def580
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_vfio.c
@@ -0,0 +1,107 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "bcmfs_device.h"
+#include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
+
+#ifdef VFIO_PRESENT
+static int
+vfio_map_dev_obj(const char *path, const char *dev_obj,
+uint32_t *size, void **addr, int *dev_fd)
+{
+   int32_t ret;
+   struct vfio_group_status status = { .argsz = sizeof(status) };
+
+   struct vfio_device_info d_info = { .argsz = sizeof(d_info) };
+   struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
+
+   ret = rte_vfio_setup_device(path, dev_obj, dev_fd, &d_info);
+   if (ret) {
+   BCMFS_LOG(ERR, "VFIO Setting for device failed");
+   return ret;
+   }
+
+   /* getting device region info*/
+   ret = ioctl(*dev_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "Error in VFIO getting REGION_INFO");
+   goto map_failed;
+   }
+
+   *addr = mmap(NULL, reg_info.size,
+PROT_WRITE | PROT_READ, MAP_SHARED,
+*dev_fd, reg_info.offset);
+   if (*addr == MAP_FAILED) {
+   BCMFS_LOG(ERR, "Error mapping region (errno = %d)", errno);
+   ret = errno;
+   goto map_failed;
+   }
+   *size = reg_info.size;
+
+   return 0;
+
+map_failed:
+   rte_vfio_release_device(path, dev_obj, *dev_fd);
+
+   return ret;
+}
+
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+   int vfio_dev_fd;
+   void  *v_addr = NULL;
+   uint32_t size = 0;
+
+   ret = vfio_map_dev_obj(dev->dirname, dev->name,
+  &size, &v_addr, &vfio_dev_fd);
+   if (ret)
+   return -1;
+
+   dev->mmap_size = size;
+   dev->mmap_addr = v_addr;
+   dev->vfio_dev_fd = vfio_dev_fd;
+
+   return 0;
+}
+
+void
+bcmfs_release_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+
+   if (dev == NULL)
+   return;
+
+   /* unmap the addr */
+   munmap(dev->mmap_addr, dev->mmap_size);
+   /* release the device */
+   ret = rte_vfio_release_device(dev->dirname, dev->name,
+ dev->vfio_dev_fd);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "cannot release device");
+   return;
+   }
+}
+#else
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev __rte_unused)
+{
+   return -1;
+}
+
+void
+bcmfs_release_vfio(struct bcmfs_device *dev __rte_unused)
+{
+}
+#endif
diff --git a/drivers/crypto/bcmfs/bcmfs_vfio.h 
b/drivers/crypto/bcmfs/bcmfs_vfio.h
new file mode 100644
index 0..d0fdf6483
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_vfio.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: BSD-3-Clau

[dpdk-dev] [PATCH v2 0/8] Add Crypto PMD for Broadcom`s FlexSparc devices

2020-08-13 Thread 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

-- 
2.17.1



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

2020-08-13 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/MAINTAINERS b/MAINTAINERS
index 3cd402b34..7c2d7ff1b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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  
+M: Raveendra Padasalagi 
+M: Ajit Khaparde 
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 ---
diff --git a/config/common_base b/config/common_base
index f7a8824f5..21daadcdd 100644
--- a/config/common_base
+++ b/config/common_base
@@ -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
 #
diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
new file mode 100644
index 0..752ce028a
--- /dev/null
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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/ on the platform.
+Each cryptodev PMD instance can be attached to the nodes present
+in the mentioned path.
diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst
index a67ed5a28..5d7e028bd 100644
--- a/doc/guides/cryptodevs/index.rst
+++ b/doc/guides/cryptodevs/index.rst
@@ -29,3 +29,4 @@ Crypto Device Drivers
 qat
 virtio
 zuc
+bcmfs
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
new file mode 100644
index 0..47c776de6
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -0,0 +1,256 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#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,
+ 

[dpdk-dev] [PATCH v2 5/8] crypto/bcmfs: create a symmetric cryptodev

2020-08-13 Thread Vikas Gupta
Create a symmetric crypto device and supported cryptodev ops.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index bd2d64acf..c9263ec28 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 9e40c5d74..e8a9c4091 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
index ec1327b78..cb5ff6c61 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.c
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -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));
+   }
+}
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.h b/drivers/crypto/bcmfs/bcmfs_qp.h
index e4b0c3f2f..fec58ca71 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.h
+++ b/drivers/crypto/bcmfs/bcmfs_qp.h
@@ -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_BUFF64
+
+/* 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 */
  

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

2020-08-13 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 3b5cc9e98..b475c2933 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index c41cc0031..a47537332 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -11,6 +11,7 @@
 #include 
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES4
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_hw_defs.h 
b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
new file mode 100644
index 0..ecb0c09ba
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
@@ -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 
+#include 
+#include 
+#include 
+
+/* 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  0x1
+#define FS_RING_DESC_SIZE  8
+#define FS_RING_BD_ALIGN_ORDER 12
+#define FS_RING_BD_DESC_PER_REQ32
+#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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
new file mode 100644
index 0..864e7bb74
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -0,0 +1,345 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
+#include "bcmfs_hw_defs.h"
+
+/* TX or submission queue name */
+static const char *txq_name = "tx";
+/* Completion or receive queue name */
+static const char *cmplq_name = "cmpl";
+
+/* Helper function */
+static int
+bcmfs_qp_check_queue_alignment(uint64_t phys_addr,
+  uint32_t align)
+{
+   if (((align - 1) & phys_addr) != 0)
+   return -EINVAL;
+   return 0;
+}
+
+static void
+bcmfs_queue_delete(struct bcmfs_queue *queue,
+  uint16_t queue_pair_id)
+{
+   const struct rte_memzone *mz;
+   int status = 0;
+
+   if (queue == NULL) {
+   BCMFS_LOG(DEBUG, "Invalid queue");
+   return;
+   }
+   BCMFS_LOG(DEBUG, "Free ring %d type %d, memzone: %s",
+ queue_pair_id, queue->q_type, queue->memz_name);
+
+   mz = rte_memzone_lookup(queue-&g

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

2020-08-13 Thread 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.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_sym.c b/drivers/crypto/bcmfs/bcmfs_sym.c
new file mode 100644
index 0..8f9415b5e
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym.c
@@ -0,0 +1,316 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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

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

2020-08-13 Thread Vikas Gupta
Add session handling and capabilities supported by crypto h/w
accelerator.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
index 752ce028a..2488b19f7 100644
--- a/doc/guides/cryptodevs/bcmfs.rst
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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/ 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.
diff --git a/doc/guides/cryptodevs/features/bcmfs.ini 
b/doc/guides/cryptodevs/features/bcmfs.ini
new file mode 100644
index 0..82d2c639d
--- /dev/null
+++ b/doc/guides/cryptodevs/features/bcmfs.ini
@@ -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
+AES GMAC = Y
+AES CMAC (128) = Y
+AES CBC = Y
+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
diff --git a/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c 
b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
new file mode 100644
index 0..dee88ed4a
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
@@ -0,0 +1,764 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include "bcmfs_sym_capabilities.h"
+
+static const struct rte_cryptodev_capabilities bcmfs_sym_capabilities[] = {
+   {
+   /* SHA1 */
+   .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+   {.sym = {
+   .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+   {.auth = {
+ 

[dpdk-dev] [PATCH v2 4/8] crypto/bcmfs: add hw queue pair operations

2020-08-13 Thread Vikas Gupta
Add queue pair operations exported by supported devices.

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_dev_msg.h 
b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
new file mode 100644
index 0..5b50bde35
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
@@ -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_BUFFERS8
+#define MAX_DST_ADDR_BUFFERS3
+
+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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index b475c2933..bd2d64acf 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -43,6 +43,47 @@ static struct bcmfs_device_attr dev_table[] = {
}
 };
 
+struct bcmfs_hw_queue_pair_ops_table bcmfs_hw_queue_pair_ops_table = {
+   .tl =  RTE_SPINLOCK_INITIALIZER,
+   .num_ops = 0
+};
+
+int bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops *h)
+{
+   struct bcmfs_hw_queue_pair_ops *ops;
+   int16_t ops_index;
+
+   rte_spinlock_lock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   if (h->enq_one_req == NULL || h->dequeue == NULL ||
+   h->ring_db == NULL || h->startq == NULL || h->stopq == NULL) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR,
+ "Missing callback while registering device ops");
+   return -EINVAL;
+   }
+
+   if (strlen(h->name) >= sizeof(ops->name) - 1) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR, "%s(): fs device_ops <%s>: name too long",
+   __func__, h->name);
+   return -EEXIST;
+   }
+
+   ops_index = bcmfs_hw_queue_pair_ops_table.num_ops++;
+   ops = &bcmfs_hw_queue_pair_ops_table.qp_ops[ops_index];
+   strlcpy(ops->name, h->name, sizeof(ops->name));
+   ops->enq_one_req = h->enq_one_req;
+   ops->dequeue = h->dequeue;
+   ops->ring_db = h->ring_db;
+   ops->startq = h->startq;
+   ops->stopq = h->stopq;
+
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   return ops_index;
+}
+
 TAILQ_HEAD(fsdev_list, bcmfs_device);
 static struct fsdev_list fsdev_list = TAILQ_HEAD_INITIALIZER(fsdev_list);
 
@@ -53,6 +94,7 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
   enum bcmfs_device_type dev_type __rte_unused)
 {
struct bcmfs_device *fsdev;
+   uint32_t i;
 
fsdev = calloc(1, sizeof(*fsdev));
if (!fsdev)
@@ -68,6 +110,15 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
goto cleanup;
}
 
+   /* check if registered ops name is present in directory path */
+   for (i = 0; i < bcmfs_hw_queue_pair_ops_table.num_ops; i++)
+   if (strstr(dirpath,
+  bcmfs_hw_queue_pair_ops_table.qp_ops[i].name))
+   fsdev->sym_hw_qp_ops =
+   &bcmfs_hw_queue_pair_ops_table.qp_ops[i];
+   if (!fsdev->sym_hw_qp_ops)
+   goto cleanup;
+
strcpy(fsdev->dirname, dirpath);
strcpy(

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

2020-08-13 Thread Vikas Gupta
Add global test suite for bcmfs crypto pmd

Signed-off-by: Vikas Gupta 
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ajit Khaparde 
---
 app/test/test_cryptodev.c | 17 +
 app/test/test_cryptodev.h |  1 +
 2 files changed, 18 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 70bf6fe2c..9157115ab 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -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);
diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h
index 41542e055..c58126368 100644
--- a/app/test/test_cryptodev.h
+++ b/app/test/test_cryptodev.h
@@ -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
-- 
2.17.1



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

2020-08-18 Thread Vikas Gupta
Add vfio support for device.

Signed-off-by: Vikas Gupta 
---
 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

diff --git a/drivers/crypto/bcmfs/Makefile b/drivers/crypto/bcmfs/Makefile
index 781ee6efa..5f691f7ba 100644
--- a/drivers/crypto/bcmfs/Makefile
+++ b/drivers/crypto/bcmfs/Makefile
@@ -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
 
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 47c776de6..3b5cc9e98 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 4b0c6d3ca..5232bdea5 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_vfio.c 
b/drivers/crypto/bcmfs/bcmfs_vfio.c
new file mode 100644
index 0..9138f96eb
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_vfio.c
@@ -0,0 +1,94 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "bcmfs_device.h"
+#include "bcmfs_logs.h"
+#include "bcmfs_vfio.h"
+
+static int
+vfio_map_dev_obj(const char *path, const char *dev_obj,
+uint32_t *size, void **addr, int *dev_fd)
+{
+   int32_t ret;
+   struct vfio_group_status status = { .argsz = sizeof(status) };
+
+   struct vfio_device_info d_info = { .argsz = sizeof(d_info) };
+   struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
+
+   ret = rte_vfio_setup_device(path, dev_obj, dev_fd, &d_info);
+   if (ret) {
+   BCMFS_LOG(ERR, "VFIO Setting for device failed");
+   return ret;
+   }
+
+   /* getting device region info*/
+   ret = ioctl(*dev_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "Error in VFIO getting REGION_INFO");
+   goto map_failed;
+   }
+
+   *addr = mmap(NULL, reg_info.size,
+PROT_WRITE | PROT_READ, MAP_SHARED,
+*dev_fd, reg_info.offset);
+   if (*addr == MAP_FAILED) {
+   BCMFS_LOG(ERR, "Error mapping region (errno = %d)", errno);
+   ret = errno;
+   goto map_failed;
+   }
+   *size = reg_info.size;
+
+   return 0;
+
+map_failed:
+   rte_vfio_release_device(path, dev_obj, *dev_fd);
+
+   return ret;
+}
+
+int
+bcmfs_attach_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+   int vfio_dev_fd;
+   void  *v_addr = NULL;
+   uint32_t size = 0;
+
+   ret = vfio_map_dev_obj(dev->dirname, dev->name,
+  &size, &v_addr, &vfio_dev_fd);
+   if (ret)
+   return -1;
+
+   dev->mmap_size = size;
+   dev->mmap_addr = v_addr;
+   dev->vfio_dev_fd = vfio_dev_fd;
+
+   return 0;
+}
+
+void
+bcmfs_release_vfio(struct bcmfs_device *dev)
+{
+   int ret;
+
+   if (dev == NULL)
+   return;
+
+   /* unmap the addr */
+   munmap(dev->mmap_addr, dev->mmap_size);
+   /* release the device */
+   ret = rte_vfio_release_device(dev->dirname, dev->name,
+ dev->vfio_dev_fd);
+   if (ret < 0) {
+   BCMFS_LOG(ERR, "cannot release device");
+   return;
+   }
+}
diff --git a/drivers/crypto/bcmfs/bcmfs_vfio.h 
b/drivers/crypto/bcmfs/bcmfs_vfio.h
new file mode 100644
index 0

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

2020-08-18 Thread 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.

Signed-off-by: Vikas Gupta 
---
 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

diff --git a/MAINTAINERS b/MAINTAINERS
index 3cd402b34..7c2d7ff1b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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  
+M: Raveendra Padasalagi 
+M: Ajit Khaparde 
+F: drivers/crypto/bcmfs/
+F: doc/guides/cryptodevs/bcmfs.rst
+F: doc/guides/cryptodevs/features/bcmfs.ini
 
 Compression Drivers
 ---
diff --git a/config/common_base b/config/common_base
index f7a8824f5..21daadcdd 100644
--- a/config/common_base
+++ b/config/common_base
@@ -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
 #
diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
new file mode 100644
index 0..752ce028a
--- /dev/null
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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/ on the platform.
+Each cryptodev PMD instance can be attached to the nodes present
+in the mentioned path.
diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst
index a67ed5a28..5d7e028bd 100644
--- a/doc/guides/cryptodevs/index.rst
+++ b/doc/guides/cryptodevs/index.rst
@@ -29,3 +29,4 @@ Crypto Device Drivers
 qat
 virtio
 zuc
+bcmfs
diff --git a/drivers/crypto/bcmfs/Makefile b/drivers/crypto/bcmfs/Makefile
new file mode 100644
index 0..781ee6efa
--- /dev/null
+++ b/drivers/crypto/bcmfs/Makefile
@@ -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
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
new file mode 100644
index 0..47c776de6
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -0,0 +1,256 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#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_d

[dpdk-dev] [PATCH 0 0/8] Add Crypto PMD for Broadcom`s FlexSparc devices

2020-08-18 Thread 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


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

-- 
2.17.1



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

2020-08-18 Thread 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.

Signed-off-by: Vikas Gupta 
---
 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

diff --git a/drivers/crypto/bcmfs/Makefile b/drivers/crypto/bcmfs/Makefile
deleted file mode 100644
index 5f691f7ba..0
--- a/drivers/crypto/bcmfs/Makefile
+++ /dev/null
@@ -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
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index 3b5cc9e98..b475c2933 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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;
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 5232bdea5..e03ce5b5b 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -11,6 +11,7 @@
 #include 
 
 #include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
 
 /* max number of dev nodes */
 #define BCMFS_MAX_NODES4
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_hw_defs.h 
b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
new file mode 100644
index 0..ecb0c09ba
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_hw_defs.h
@@ -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 
+#include 
+#include 
+#include 
+
+/* 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  0x1
+#define FS_RING_DESC_SIZE  8
+#define FS_RING_BD_ALIGN_ORDER 12
+#define FS_RING_BD_DESC_PER_REQ32
+#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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
new file mode 100644
index 0..864e7bb74
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -0,0 +1,345 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Broadcom.
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "bcmfs_logs.h"
+#include "bcmfs_qp.h"
+#include "bcmfs_hw_defs.h"
+
+/* TX or submission queue name */
+static const char *txq_name = "tx";
+/* Completion or receive queue name */
+static cons

[dpdk-dev] [PATCH 0 5/8] crypto/bcmfs: create a symmetric cryptodev

2020-08-18 Thread Vikas Gupta
Create a symmetric crypto device and supported cryptodev ops.

Signed-off-by: Vikas Gupta 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index bd2d64acf..c9263ec28 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -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
diff --git a/drivers/crypto/bcmfs/bcmfs_device.h 
b/drivers/crypto/bcmfs/bcmfs_device.h
index 96beb10fa..37907b91f 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.h
+++ b/drivers/crypto/bcmfs/bcmfs_device.h
@@ -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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c
index ec1327b78..cb5ff6c61 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.c
+++ b/drivers/crypto/bcmfs/bcmfs_qp.c
@@ -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));
+   }
+}
diff --git a/drivers/crypto/bcmfs/bcmfs_qp.h b/drivers/crypto/bcmfs/bcmfs_qp.h
index e4b0c3f2f..fec58ca71 100644
--- a/drivers/crypto/bcmfs/bcmfs_qp.h
+++ b/drivers/crypto/bcmfs/bcmfs_qp.h
@@ -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_BUFF64
+
+/* 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 

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

2020-08-18 Thread Vikas Gupta
Add session handling and capabilities supported by crypto h/w
accelerator.

Signed-off-by: Vikas Gupta 
---
 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

diff --git a/doc/guides/cryptodevs/bcmfs.rst b/doc/guides/cryptodevs/bcmfs.rst
index 752ce028a..2488b19f7 100644
--- a/doc/guides/cryptodevs/bcmfs.rst
+++ b/doc/guides/cryptodevs/bcmfs.rst
@@ -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/ 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.
diff --git a/doc/guides/cryptodevs/features/bcmfs.ini 
b/doc/guides/cryptodevs/features/bcmfs.ini
new file mode 100644
index 0..82d2c639d
--- /dev/null
+++ b/doc/guides/cryptodevs/features/bcmfs.ini
@@ -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
+AES GMAC = Y
+AES CMAC (128) = Y
+AES CBC = Y
+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
diff --git a/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c 
b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
new file mode 100644
index 0..bb8fa9f81
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym_capabilities.c
@@ -0,0 +1,764 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include "bcmfs_sym_capabilities.h"
+
+static const struct rte_cryptodev_capabilities bcmfs_sym_capabilities[] = {
+   {
+   /* SHA1 */
+   .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+   {.sym = {
+   .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+   {.auth = {
+   .algo = RTE_CRYPTO_AUTH_SHA1

[dpdk-dev] [PATCH 0 4/8] crypto/bcmfs: add hw queue pair operations

2020-08-18 Thread Vikas Gupta
Add queue pair operations exported by supported devices.

Signed-off-by: Vikas Gupta 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_dev_msg.h 
b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
new file mode 100644
index 0..5b50bde35
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_dev_msg.h
@@ -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_BUFFERS8
+#define MAX_DST_ADDR_BUFFERS3
+
+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_ */
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index b475c2933..bd2d64acf 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -43,6 +43,47 @@ static struct bcmfs_device_attr dev_table[] = {
}
 };
 
+struct bcmfs_hw_queue_pair_ops_table bcmfs_hw_queue_pair_ops_table = {
+   .tl =  RTE_SPINLOCK_INITIALIZER,
+   .num_ops = 0
+};
+
+int bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops *h)
+{
+   struct bcmfs_hw_queue_pair_ops *ops;
+   int16_t ops_index;
+
+   rte_spinlock_lock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   if (h->enq_one_req == NULL || h->dequeue == NULL ||
+   h->ring_db == NULL || h->startq == NULL || h->stopq == NULL) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR,
+ "Missing callback while registering device ops");
+   return -EINVAL;
+   }
+
+   if (strlen(h->name) >= sizeof(ops->name) - 1) {
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+   BCMFS_LOG(ERR, "%s(): fs device_ops <%s>: name too long",
+   __func__, h->name);
+   return -EEXIST;
+   }
+
+   ops_index = bcmfs_hw_queue_pair_ops_table.num_ops++;
+   ops = &bcmfs_hw_queue_pair_ops_table.qp_ops[ops_index];
+   strlcpy(ops->name, h->name, sizeof(ops->name));
+   ops->enq_one_req = h->enq_one_req;
+   ops->dequeue = h->dequeue;
+   ops->ring_db = h->ring_db;
+   ops->startq = h->startq;
+   ops->stopq = h->stopq;
+
+   rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+   return ops_index;
+}
+
 TAILQ_HEAD(fsdev_list, bcmfs_device);
 static struct fsdev_list fsdev_list = TAILQ_HEAD_INITIALIZER(fsdev_list);
 
@@ -53,6 +94,7 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
   enum bcmfs_device_type dev_type __rte_unused)
 {
struct bcmfs_device *fsdev;
+   uint32_t i;
 
fsdev = calloc(1, sizeof(*fsdev));
if (!fsdev)
@@ -68,6 +110,15 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
goto cleanup;
}
 
+   /* check if registered ops name is present in directory path */
+   for (i = 0; i < bcmfs_hw_queue_pair_ops_table.num_ops; i++)
+   if (strstr(dirpath,
+  bcmfs_hw_queue_pair_ops_table.qp_ops[i].name))
+   fsdev->sym_hw_qp_ops =
+   &bcmfs_hw_queue_pair_ops_table.qp_ops[i];
+   if (!fsdev->sym_hw_qp_ops)
+   goto cleanup;
+
strcpy(fsdev->dirname, dirpath);
strcpy(fsdev->name, devname);
 
diff --git a/drivers/crypto/bcmfs/bcmf

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

2020-08-18 Thread 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.

Signed-off-by: Vikas Gupta 
---
 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

diff --git a/drivers/crypto/bcmfs/bcmfs_sym.c b/drivers/crypto/bcmfs/bcmfs_sym.c
new file mode 100644
index 0..8f9415b5e
--- /dev/null
+++ b/drivers/crypto/bcmfs/bcmfs_sym.c
@@ -0,0 +1,316 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Broadcom
+ * All rights reserved.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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

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

2020-08-18 Thread Vikas Gupta
Add test suites for supported algorithms by bcmfs crypto pmd

Signed-off-by: Vikas Gupta 
---
 app/test/test_cryptodev.c | 261 ++
 app/test/test_cryptodev.h |   1 +
 2 files changed, 262 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 70bf6fe2c..6e7d8471c 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -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_S

[dpdk-dev] Issue with VFIO/IOMMU

2020-09-03 Thread Vikas Gupta
Hi,

  I observe an issue with IOVA address returned by api
rte_memzone_reserve_aligned (flags= RTE_MEMZONE_IOVA_CONTIG) used for queue
memory allocation. With high level debugging, I notice that IOVA address
returned in mz->iova is not mapped by VFIO_IOMMU_MAP_DMA so in turn SMMU
exception is seen.



*Details for the setup*

Platform: Armv8 (Broadcom Stingray)

DPDK release: DPDK 20.08 

PMD patch:

https://patches.dpdk.org/project/dpdk/list/?series=&submitter=1907&state=&q=&archive=&delegate=

dpdk-test is launched using below command

*dpdk-test --vdev  -w :00:00.0 --iova-mode pa *



The test suite is launched over dpdk-test application command prompt using
command ‘cryptodev__autotest’

The issue is seen when several iterations of above test_suite is executed
which in turn do multiple calls to rte_memzone_reserve_aligned,
rte_mempool_create and rte_memzone_free, rte_mempool_free.

 Function *vfio_type1_dma_mem_map* with map/unmap event is executed several
times during test_suite run.



Any inputs would be helpful.



Thanks,

Vikas


Re: [dpdk-dev] Issue with VFIO/IOMMU

2020-09-07 Thread Vikas Gupta
 RE: [dpdk-dev] Issue with VFIO/IOMMU

Hi Burakov,

-Original Message-
From: Burakov, Anatoly [mailto:anatoly.bura...@intel.com
]
Sent: Friday, September 04, 2020 7:20 PM
To: Vikas Gupta ; dev@dpdk.org
Cc: Ajit Kumar Khaparde ; Vikram Prakash <
vikram.prak...@broadcom.com>
Subject: Re: [dpdk-dev] Issue with VFIO/IOMMU

On 03-Sep-20 12:09 PM, Vikas Gupta wrote:

> Hi,

>

>I observe an issue with IOVA address returned by api

> rte_memzone_reserve_aligned (flags= RTE_MEMZONE_IOVA_CONTIG) used for

> queue memory allocation. With high level debugging, I notice that IOVA

> address returned in mz->iova is not mapped by VFIO_IOMMU_MAP_DMA so in

> turn SMMU exception is seen.

I'm not sure i follow.

How did you determine that to be the case, given that, by your own
admission below, `vfio_type1_dma_mem_map` function is executed several
times?

[Vikas]:

I`ll mention map and unmap as below in explaining through one of the example

map = function vfio_type1_dma_mem_map called with argument do_map = 1

unamp = function  type1_dma_mem_map  called with argument do_map = 0

What I notice that for some particular address received in mz->iova, after
rte_memzone_reserve_aligned is successfully returned, the map function
(vfio_type1_dma_mem_map do_map =1) was not called prior to return of
function rte_memzone_reserve_aligned.

Below is one of the sequence to understand.

Let’s say there is an address ‘*iova_fail’*, for which exception is raised
by SMMU while dpdk-test runs with Crypto PMD.

When dpdk-test is run with Crypto test suit I see that for an address*
iova_fail* several times vfio_type1_dma_mem_map is called with (do_map =
0/1 with length = 2MB). I believe this happens due to call for memory
allocation/free for buffers/queues. The test runs fine as long as the map
is called before rte_memzone_reserve_aligned returns and similarly for
unmap when same memory is freed. But after several times with map/unmap for*
iova_fail*, map is NOT called before rte_memzone_reserve_aligned is retuned
though iova_fail was previously unmapped. Since it’s not mapped, SMMU
raises an exception.

Please note issue is not frequently visible and might reproduce after
pmd_crypto_autotest is run multiple times over dpdk-test.

If you are not able to follow I`ll try to send the debug printfs for test.

Thanks,

Vikas

>

>

>

> *Details for the setup*

>

> Platform: Armv8 (Broadcom Stingray)

>

> DPDK release: DPDK 20.08 <http://fast.dpdk.org/rel/dpdk-20.08.tar.xz>

>

> PMD patch:

>

> https://patches.dpdk.org/project/dpdk/list/?series=&submitter=1907&sta

> te=&q=&archive=&delegate=

>

> dpdk-test is launched using below command

>

> *dpdk-test --vdev  -w :00:00.0 --iova-mode pa *

>

>

>

> The test suite is launched over dpdk-test application command prompt

> using command ‘cryptodev__autotest’

>

> The issue is seen when several iterations of above test_suite is

> executed which in turn do multiple calls to

> rte_memzone_reserve_aligned, rte_mempool_create and rte_memzone_free,
rte_mempool_free.

>

>   Function *vfio_type1_dma_mem_map* with map/unmap event is executed

> several times during test_suite run.

>

>

>

> Any inputs would be helpful.

>

>

>

> Thanks,

>

> Vikas

>

--

Thanks,

Anatoly