> diff --git a/doc/guides/compressdevs/zsda.rst
> b/doc/guides/compressdevs/zsda.rst
> index 25b7884535..34cbf235af 100644
> --- a/doc/guides/compressdevs/zsda.rst
> +++ b/doc/guides/compressdevs/zsda.rst
> @@ -174,6 +174,15 @@ e.g. for the 1cf2 device::
>  Use ``modprobe vfio-pci disable_denylist=1`` from kernel 5.9 onwards.
> 
> 
> +Building DPDK
> +-------------
> +
> +The following commands can be used to build DPDK on a system::
> +
> +  meson setup build
> +  ninja -C build
> +
> +

Above change should not be part of this patch. It is part of compression driver.
Please submit a separate patch.


>  Testing
>  -------
> 
> diff --git a/doc/guides/cryptodevs/features/zsda.ini
> b/doc/guides/cryptodevs/features/zsda.ini
> new file mode 100644
> index 0000000000..55c573adb0
> --- /dev/null
> +++ b/doc/guides/cryptodevs/features/zsda.ini
> @@ -0,0 +1,38 @@
> +;
> +; Supported features of the 'zsda' crypto driver.
> +;
> +; Refer to default.ini for the full list of available PMD features.
> +;
> +[Features]
> +
> +
> +;
> +; Supported crypto algorithms of the 'zsda' crypto driver.
> +;
> +[Cipher]
> +
> +
> +;
> +; Supported authentication algorithms of the 'zsda' crypto driver.
> +;
> +[Auth]
> +
> +
> +
> +;
> +; Supported AEAD algorithms of the 'zsda' crypto driver.
> +;
> +[AEAD]
> +
> +
> +;
> +; Supported Asymmetric algorithms of the 'zsda' crypto driver.
> +;
> +[Asymmetric]
> +
> +
> +;
> +; Supported Operating systems of the 'zsda' crypto driver.
> +;
> +[OS]
> +Linux = Y
> diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst
> index 1e57a9fe86..be2620f185 100644
> --- a/doc/guides/cryptodevs/index.rst
> +++ b/doc/guides/cryptodevs/index.rst
> @@ -34,3 +34,4 @@ Crypto Device Drivers
>      uadk
>      virtio
>      zuc
> +    zsda
> diff --git a/doc/guides/cryptodevs/zsda.rst b/doc/guides/cryptodevs/zsda.rst
> new file mode 100644
> index 0000000000..5373b39a2a
> --- /dev/null
> +++ b/doc/guides/cryptodevs/zsda.rst
> @@ -0,0 +1,26 @@
> +..  SPDX-License-Identifier: BSD-3-Clause
> +    Copyright(c) 2025 ZTE Corporation.
> +
> +ZTE Storage Data Accelerator (ZSDA) Poll Mode Driver
> +======================================================
> +
> +The ZSDA crypto PMD provides poll mode Cipher and Hash driver
> +support for the following hardware accelerator devices:
> +
> +* ``ZTE Processing accelerators 1cf2``
> +
> +
> +Features
> +--------
> +
> +
> +Limitations
> +------------
Above has 1 extra '-'

> +
> +
> +Installation
> +------------
> +
> +The ZSDA crypto PMD is built by default with a standard DPDK build.
> +
> +For more details, such as testing and debugging, please see
> :doc:`../compressdevs/zsda`.

Why this is being referred to compressdev. Is it dependent on that?

> diff --git a/drivers/common/zsda/meson.build
> b/drivers/common/zsda/meson.build
> index be4fbaedb3..fdfbab29cf 100644
> --- a/drivers/common/zsda/meson.build
> +++ b/drivers/common/zsda/meson.build
> @@ -7,7 +7,7 @@ if is_windows
>      subdir_done()
>  endif
> 
> -deps += ['bus_pci', 'mbuf', 'compressdev']
> +deps += ['bus_pci', 'compressdev', 'cryptodev']
>  sources += files(
>          'zsda_device.c',
>          'zsda_logs.c',
> @@ -24,3 +24,13 @@ if zsda_compress
>          sources += files(join_paths(zsda_compress_relpath, f))
>      endforeach
>  endif
> +
> +zsda_crypto = true
> +zsda_crypto_path = 'crypto/zsda'
> +zsda_crypto_relpath = '../../' + zsda_crypto_path
> +includes += include_directories(zsda_crypto_relpath)
> +if zsda_crypto
> +    foreach f: ['zsda_sym_pmd.c']
> +        sources += files(join_paths(zsda_crypto_relpath, f))
> +    endforeach
> +endif
> diff --git a/drivers/common/zsda/zsda_device.c
> b/drivers/common/zsda/zsda_device.c
> index 8a89dc7fc9..438932ef2f 100644
> --- a/drivers/common/zsda/zsda_device.c
> +++ b/drivers/common/zsda/zsda_device.c
> @@ -152,6 +152,7 @@ zsda_pci_dev_destroy(struct zsda_pci_device
> *zsda_pci_dev,
>  {
> 
>      zsda_comp_dev_destroy(zsda_pci_dev);
> +    zsda_sym_dev_destroy(zsda_pci_dev);
> 
>      return zsda_pci_device_release(pci_dev);
>  }
> @@ -177,7 +178,13 @@ zsda_pci_probe(struct rte_pci_driver *pci_drv
> __rte_unused,
> 
>      ret = zsda_comp_dev_create(zsda_pci_dev);
>      if (ret)
> -        ZSDA_LOG(ERR, "Failed! dev create.");
> +        ZSDA_LOG(ERR, "Failed! comp_dev create.");
> +
> +    ret = zsda_sym_dev_create(zsda_pci_dev);
> +    if (ret) {
> +        ZSDA_LOG(ERR, "Failed! sym_dev create.");
> +        zsda_comp_dev_destroy(zsda_pci_dev);
> +    }

Can you use goto to destroy comp device?

> 
>      return ret;
>  }
> diff --git a/drivers/common/zsda/zsda_device.h
> b/drivers/common/zsda/zsda_device.h
> index dd0fa35ba6..49f0e56431 100644
> --- a/drivers/common/zsda/zsda_device.h
> +++ b/drivers/common/zsda/zsda_device.h
> @@ -7,6 +7,7 @@
> 
>  #include "zsda_qp_common.h"
>  #include "zsda_comp_pmd.h"
> +#include "zsda_sym_pmd.h"
> 
>  #define MAX_QPS_ON_FUNCTION            128
>  #define ZSDA_DEV_NAME_MAX_LEN        64
> @@ -21,6 +22,11 @@ struct zsda_device_info {
>       * Register with this rather than with the one in
>       * pci_dev so that its driver can have a compression-specific name
>       */
> +    struct rte_device sym_rte_dev;
> +    /**< This represents the crypto sym subset of this pci device.
> +     * Register with this rather than with the one in
> +     * pci_dev so that its driver can have a crypto-specific name
> +     */
>      struct rte_pci_device *pci_dev;
>  };
> 
> @@ -52,6 +58,10 @@ struct zsda_pci_device {
>      struct zsda_comp_dev_private *comp_dev;
>      /**< link back to compressdev private data */
> 
> +    /* Data relating to symmetric service */
> +    struct zsda_sym_dev_private *sym_dev_priv;
> +    /**< link back to cryptodev private data */
> +
>      struct zsda_qp_hw zsda_hw_qps[ZSDA_MAX_SERVICES];
>      uint16_t zsda_qp_hw_num[ZSDA_MAX_SERVICES];
>  };
> diff --git a/drivers/common/zsda/zsda_qp.c b/drivers/common/zsda/zsda_qp.c
> index 0ef7cac585..9c83c6c882 100644
> --- a/drivers/common/zsda/zsda_qp.c
> +++ b/drivers/common/zsda/zsda_qp.c
> @@ -15,6 +15,9 @@ static uint8_t zsda_num_used_qps;
>  static struct ring_size zsda_qp_hw_ring_size[ZSDA_MAX_SERVICES] = {
>      [ZSDA_SERVICE_COMPRESSION] = {32, 16},
>      [ZSDA_SERVICE_DECOMPRESSION] = {32, 16},
> +    [ZSDA_SERVICE_SYMMETRIC_ENCRYPT] = {128, 16},
> +    [ZSDA_SERVICE_SYMMETRIC_DECRYPT] = {128, 16},
> +    [ZSDA_SERVICE_HASH_ENCODE] = {32, 16},
>  };
> 
>  static const uint8_t crc8_table[256] = {
> @@ -480,6 +483,12 @@ zsda_nb_qps_get(const struct zsda_pci_device
> *zsda_pci_dev)
>          zsda_num_qps_get(zsda_pci_dev, ZSDA_SERVICE_COMPRESSION);
>      zsda_nb_qps.decomp =
>          zsda_num_qps_get(zsda_pci_dev, ZSDA_SERVICE_DECOMPRESSION);
> +    zsda_nb_qps.encrypt =
> +        zsda_num_qps_get(zsda_pci_dev, ZSDA_SERVICE_SYMMETRIC_ENCRYPT);
> +    zsda_nb_qps.decrypt =
> +        zsda_num_qps_get(zsda_pci_dev, ZSDA_SERVICE_SYMMETRIC_DECRYPT);
> +    zsda_nb_qps.hash =
> +        zsda_num_qps_get(zsda_pci_dev, ZSDA_SERVICE_HASH_ENCODE);
>  }
> 
>  int
> diff --git a/drivers/common/zsda/zsda_qp_common.h
> b/drivers/common/zsda/zsda_qp_common.h
> index 941278c6d2..62cb04b499 100644
> --- a/drivers/common/zsda/zsda_qp_common.h
> +++ b/drivers/common/zsda/zsda_qp_common.h
> @@ -24,9 +24,12 @@
>  enum zsda_service_type {
>      ZSDA_SERVICE_COMPRESSION = 0,
>      ZSDA_SERVICE_DECOMPRESSION = 1,
> +    ZSDA_SERVICE_SYMMETRIC_ENCRYPT = 2,
> +    ZSDA_SERVICE_SYMMETRIC_DECRYPT = 3,
> +    ZSDA_SERVICE_HASH_ENCODE = 6,
>      ZSDA_SERVICE_INVALID,
>  };
> -#define ZSDA_MAX_SERVICES (2)
> +#define ZSDA_MAX_SERVICES (ZSDA_SERVICE_INVALID)
> 
>  #define ZSDA_CSR_READ32(addr)          rte_read32((addr))
>  #define ZSDA_CSR_WRITE32(addr, value) rte_write32((value), (addr))
> @@ -43,10 +46,22 @@ enum zsda_service_type {
>  #define MAX_NUM_OPS            0x1FF
>  #define ZSDA_SGL_FRAGMENT_SIZE    32
> 
> +#define ZSDA_OPC_EC_AES_XTS_256 0x0  /* Encry AES-XTS-256 */
> +#define ZSDA_OPC_EC_AES_XTS_512 0x01 /* Encry AES-XTS-512 */
> +#define ZSDA_OPC_EC_SM4_XTS_256 0x02 /* Encry SM4-XTS-256 */
> +#define ZSDA_OPC_DC_AES_XTS_256 0x08 /* Decry AES-XTS-256 */
> +#define ZSDA_OPC_DC_AES_XTS_512 0x09 /* Decry AES-XTS-512 */
> +#define ZSDA_OPC_DC_SM4_XTS_256 0x0A /* Decry SM4-XTS-256 */
>  #define ZSDA_OPC_COMP_GZIP        0x10 /* Encomp deflate-Gzip */
>  #define ZSDA_OPC_COMP_ZLIB        0x11 /* Encomp deflate-Zlib */
>  #define ZSDA_OPC_DECOMP_GZIP    0x18 /* Decomp inflate-Gzip */
>  #define ZSDA_OPC_DECOMP_ZLIB    0x19 /* Decomp inflate-Zlib */
> +#define ZSDA_OPC_HASH_SHA1        0x20 /* Hash-SHA1 */
> +#define ZSDA_OPC_HASH_SHA2_224    0x21 /* Hash-SHA2-224 */
> +#define ZSDA_OPC_HASH_SHA2_256    0x22 /* Hash-SHA2-256 */
> +#define ZSDA_OPC_HASH_SHA2_384    0x23 /* Hash-SHA2-384 */
> +#define ZSDA_OPC_HASH_SHA2_512    0x24 /* Hash-SHA2-512 */
> +#define ZSDA_OPC_HASH_SM3        0x25 /* Hash-SM3 */
>  #define ZSDA_OPC_INVALID        0xff

Can you move these crypto specific defines in crypto pmd directory?
In fact compression specific ones should also be moved. 
The Idea is to have minimal stuff in common folder which is being used by both 
PMDs.


> 
>  #define CQE_VALID(value) (value & 0x8000)
> diff --git a/drivers/crypto/zsda/zsda_sym_pmd.c
> b/drivers/crypto/zsda/zsda_sym_pmd.c
> new file mode 100644
> index 0000000000..0f4bf41958
> --- /dev/null
> +++ b/drivers/crypto/zsda/zsda_sym_pmd.c
> @@ -0,0 +1,116 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2025 ZTE Corporation
> + */
> +
> +#include <rte_cryptodev.h>
> +
> +#include "zsda_sym_pmd.h"
> +
> +uint8_t zsda_sym_driver_id;
> +
> +static struct rte_cryptodev_ops crypto_zsda_ops = {
> +
Remove extra line

> +    .dev_configure = NULL,
> +    .dev_start = NULL,
> +    .dev_stop = NULL,
> +    .dev_close = NULL,
> +    .dev_infos_get = NULL,
> +
> +    .stats_get = NULL,
> +    .stats_reset = NULL,
> +    .queue_pair_setup = NULL,
> +    .queue_pair_release = NULL,
> +
> +    .sym_session_get_size = NULL,
> +    .sym_session_configure = NULL,
> +    .sym_session_clear = NULL,
> +
Remove extra line

> +};
> +
> +static const char zsda_sym_drv_name[] =
> RTE_STR(CRYPTODEV_NAME_ZSDA_SYM_PMD);
> +static const struct rte_driver cryptodev_zsda_sym_driver = {
> +    .name = zsda_sym_drv_name, .alias = zsda_sym_drv_name};

Closing brace should be in next line and move .alias also in next line.

> +
> +int
> +zsda_sym_dev_create(struct zsda_pci_device *zsda_pci_dev)
> +{
> +    struct zsda_device_info *dev_info =
> +        &zsda_devs[zsda_pci_dev->zsda_dev_id];
> +
> +    struct rte_cryptodev_pmd_init_params init_params = {
> +        .name = "",
> +        .socket_id = (int)rte_socket_id(),
> +        .private_data_size = sizeof(struct zsda_sym_dev_private)};
> +
> +    char name[RTE_CRYPTODEV_NAME_MAX_LEN];
> +    struct rte_cryptodev *cryptodev;
> +    struct zsda_sym_dev_private *sym_dev_priv;
> +
> +    snprintf(name, RTE_CRYPTODEV_NAME_MAX_LEN, "%s_%s", zsda_pci_dev-
> >name,
> +         "sym_encrypt");
> +    ZSDA_LOG(DEBUG, "Creating ZSDA SYM device %s", name);
> +
> +    if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> +        return ZSDA_SUCCESS;

This check can be before above snprintf so that debug log will not be 
misinterpreted 
that the device is created in case of secondary.

> +
> +    dev_info->sym_rte_dev.driver = &cryptodev_zsda_sym_driver;
> +    dev_info->sym_rte_dev.numa_node = dev_info->pci_dev-
> >device.numa_node;
> +
> +    cryptodev = rte_cryptodev_pmd_create(name, &(dev_info->sym_rte_dev),
> +                         &init_params);
> +
> +    if (cryptodev == NULL) {
> +        ZSDA_LOG(ERR, "Failed! rte_cryptodev_pmd_create");
> +        goto error;
> +    }
> +
> +    dev_info->sym_rte_dev.name = cryptodev->data->name;
> +    cryptodev->driver_id = zsda_sym_driver_id;
> +
> +    cryptodev->dev_ops = &crypto_zsda_ops;
> +
> +    cryptodev->enqueue_burst = NULL;
> +    cryptodev->dequeue_burst = NULL;
> +    cryptodev->feature_flags = 0;
> +
> +    sym_dev_priv = cryptodev->data->dev_private;
> +    sym_dev_priv->zsda_pci_dev = zsda_pci_dev;
> +    sym_dev_priv->cryptodev = cryptodev;
> +
> +    zsda_pci_dev->sym_dev_priv = sym_dev_priv;
> +
> +    return ZSDA_SUCCESS;
> +
> +error:
> +
> +    rte_cryptodev_pmd_destroy(cryptodev);
> +    memset(&dev_info->sym_rte_dev, 0, sizeof(dev_info->sym_rte_dev));
> +
> +    return -EFAULT;
> +}
> +
> +int
> +zsda_sym_dev_destroy(struct zsda_pci_device *zsda_pci_dev)
> +{
> +    struct zsda_sym_dev_private *sym_dev_priv;
> +
> +    if (zsda_pci_dev == NULL)
> +        return -ENODEV;
> +
> +    sym_dev_priv = zsda_pci_dev->sym_dev_priv;
> +    if (sym_dev_priv == NULL)
> +        return ZSDA_SUCCESS;
> +
> +    if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> +        rte_memzone_free(sym_dev_priv->capa_mz);
> +
> +    rte_cryptodev_pmd_destroy(sym_dev_priv->cryptodev);
> +    zsda_devs[zsda_pci_dev->zsda_dev_id].sym_rte_dev.name = NULL;
> +    zsda_pci_dev->sym_dev_priv = NULL;
> +
> +    return ZSDA_SUCCESS;
> +}
> +
> +static struct cryptodev_driver zsda_crypto_drv;
> +RTE_PMD_REGISTER_CRYPTO_DRIVER(zsda_crypto_drv,
> cryptodev_zsda_sym_driver,
> +                   zsda_sym_driver_id);
> diff --git a/drivers/crypto/zsda/zsda_sym_pmd.h
> b/drivers/crypto/zsda/zsda_sym_pmd.h
> new file mode 100644
> index 0000000000..3d08be68f3
> --- /dev/null
> +++ b/drivers/crypto/zsda/zsda_sym_pmd.h
> @@ -0,0 +1,37 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2025 ZTE Corporation
> + */
> +
> +#ifndef _ZSDA_SYM_PMD_H_
> +#define _ZSDA_SYM_PMD_H_
> +
> +#include "cryptodev_pmd.h"
> +
> +#include "zsda_qp.h"
> +
> +/** ZSDA Symmetric Crypto PMD driver name */
> +#define CRYPTODEV_NAME_ZSDA_SYM_PMD crypto_zsda
> +#define ZSDA_CIPHER_KEY_MAX_LEN 64
> +
> +/** private data structure for a ZSDA device.
> + * This ZSDA device is a device offering only symmetric crypto service,
> + * there can be one of these on each zsda_pci_device (VF).
> + */
> +struct zsda_sym_dev_private {
> +    struct zsda_pci_device *zsda_pci_dev;
> +    /**< The zsda pci device hosting the service */
> +    struct rte_cryptodev *cryptodev;
> +    /**< The pointer to this compression device structure */
> +    const struct rte_cryptodev_capabilities *zsda_dev_capabilities;
> +    /* ZSDA device symmetric crypto capabilities */
> +    const struct rte_memzone *capa_mz;
> +    /* Shared memzone for storing capabilities */

Please be consistent with the comments style.
/* -> /**<

> +};
> +
> +extern uint8_t zsda_sym_driver_id;

Why is this extern needed in this patch.
It is used in a single file where it is defined.

> +
> +int zsda_sym_dev_create(struct zsda_pci_device *zsda_pci_dev);
> +
> +int zsda_sym_dev_destroy(struct zsda_pci_device *zsda_pci_dev);
> +
> +#endif /* _ZSDA_SYM_PMD_H_ */
> --
> 2.27.0

Reply via email to