crypto/cnxk: add max queue pairs limit option
authorAnkur Dwivedi <adwivedi@marvell.com>
Thu, 30 Sep 2021 13:20:43 +0000 (18:50 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Sat, 16 Oct 2021 12:57:14 +0000 (14:57 +0200)
Adds max queue pairs limit devargs for crypto cnxk driver. This
can be used to set a limit on the number of maximum queue pairs
supported by the device. The default value is 63.

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
Reviewed-by: Anoob Joseph <anoobj@marvell.com>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
doc/guides/cryptodevs/cnxk.rst
drivers/crypto/cnxk/cn10k_cryptodev.c
drivers/crypto/cnxk/cn9k_cryptodev.c
drivers/crypto/cnxk/cnxk_cryptodev.h
drivers/crypto/cnxk/cnxk_cryptodev_devargs.c [new file with mode: 0644]
drivers/crypto/cnxk/cnxk_cryptodev_ops.c
drivers/crypto/cnxk/meson.build

index 752316f..85171a5 100644 (file)
@@ -158,6 +158,21 @@ Bind the CPT VF device to the vfio_pci driver:
     ./usertools/dpdk-devbind.py -u 0002:20:00.1
     ./usertools/dpdk-devbind.py -b vfio-pci 0002:20:00.1
 
+Runtime Config Options
+----------------------
+
+- ``Maximum queue pairs limit`` (default ``63``)
+
+   The number of maximum queue pairs supported by the device, can be limited
+   during runtime by using ``max_qps_limit`` ``devargs`` parameter.
+
+   For example::
+
+      -a 0002:20:00.1,max_qps_limit=4
+
+   With the above configuration, the number of maximum queue pairs supported
+   by the device is limited to 4.
+
 Debugging Options
 -----------------
 
index 012eb0c..869d322 100644 (file)
@@ -68,6 +68,13 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 
        if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
                roc_cpt->pci_dev = pci_dev;
+
+               rc = cnxk_cpt_parse_devargs(dev->device->devargs, vf);
+               if (rc) {
+                       plt_err("Failed to parse devargs rc=%d", rc);
+                       goto pmd_destroy;
+               }
+
                rc = roc_cpt_dev_init(roc_cpt);
                if (rc) {
                        plt_err("Failed to initialize roc cpt rc=%d", rc);
index 6b8cb01..54df06e 100644 (file)
@@ -68,6 +68,13 @@ cn9k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 
        if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
                roc_cpt->pci_dev = pci_dev;
+
+               rc = cnxk_cpt_parse_devargs(dev->device->devargs, vf);
+               if (rc) {
+                       plt_err("Failed to parse devargs rc=%d", rc);
+                       goto pmd_destroy;
+               }
+
                rc = roc_cpt_dev_init(roc_cpt);
                if (rc) {
                        plt_err("Failed to initialize roc cpt rc=%d", rc);
index 8e051fa..cfb9d29 100644 (file)
@@ -25,9 +25,11 @@ struct cnxk_cpt_vf {
        struct rte_security_capability sec_caps[CNXK_SEC_MAX_CAPS];
        uint64_t cnxk_fpm_iova[CNXK_AE_EC_ID_MAX];
        struct roc_ae_ec_group *ec_grp[CNXK_AE_EC_ID_MAX];
+       uint16_t max_qps_limit;
 };
 
 uint64_t cnxk_cpt_default_ff_get(void);
 int cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt);
+int cnxk_cpt_parse_devargs(struct rte_devargs *devargs, struct cnxk_cpt_vf *vf);
 
 #endif /* _CNXK_CRYPTODEV_H_ */
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_devargs.c b/drivers/crypto/cnxk/cnxk_cryptodev_devargs.c
new file mode 100644 (file)
index 0000000..c3e9bdb
--- /dev/null
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_devargs.h>
+
+#include "cnxk_cryptodev.h"
+
+#define CNXK_MAX_QPS_LIMIT     "max_qps_limit"
+#define CNXK_MAX_QPS_LIMIT_MIN 1
+#define CNXK_MAX_QPS_LIMIT_MAX (ROC_CPT_MAX_LFS - 1)
+
+static int
+parse_max_qps_limit(const char *key, const char *value, void *extra_args)
+{
+       RTE_SET_USED(key);
+       uint32_t val;
+
+       val = atoi(value);
+
+       if (val < CNXK_MAX_QPS_LIMIT_MIN || val > CNXK_MAX_QPS_LIMIT_MAX)
+               return -EINVAL;
+
+       *(uint16_t *)extra_args = val;
+
+       return 0;
+}
+
+int
+cnxk_cpt_parse_devargs(struct rte_devargs *devargs, struct cnxk_cpt_vf *vf)
+{
+       uint16_t max_qps_limit = CNXK_MAX_QPS_LIMIT_MAX;
+       struct rte_kvargs *kvlist;
+       int rc;
+
+       if (devargs == NULL)
+               goto null_devargs;
+
+       kvlist = rte_kvargs_parse(devargs->args, NULL);
+       if (kvlist == NULL)
+               goto exit;
+
+       rc = rte_kvargs_process(kvlist, CNXK_MAX_QPS_LIMIT,
+                               &parse_max_qps_limit, &max_qps_limit);
+       if (rc < 0) {
+               plt_err("max_qps_limit should in the range <%d-%d>",
+                       CNXK_MAX_QPS_LIMIT_MIN, CNXK_MAX_QPS_LIMIT_MAX);
+               rte_kvargs_free(kvlist);
+               goto exit;
+       }
+       rte_kvargs_free(kvlist);
+
+null_devargs:
+       vf->max_qps_limit = max_qps_limit;
+       return 0;
+
+exit:
+       return -EINVAL;
+}
+
+RTE_PMD_REGISTER_PARAM_STRING(crypto_cnxk, CNXK_MAX_QPS_LIMIT "=<1-63>");
index 41d8fe4..e49f826 100644 (file)
@@ -150,7 +150,10 @@ cnxk_cpt_dev_info_get(struct rte_cryptodev *dev,
        struct cnxk_cpt_vf *vf = dev->data->dev_private;
        struct roc_cpt *roc_cpt = &vf->cpt;
 
-       info->max_nb_queue_pairs = roc_cpt->nb_lf_avail;
+       info->max_nb_queue_pairs =
+               RTE_MIN(roc_cpt->nb_lf_avail, vf->max_qps_limit);
+       plt_cpt_dbg("max_nb_queue_pairs %u", info->max_nb_queue_pairs);
+
        info->feature_flags = cnxk_cpt_default_ff_get();
        info->capabilities = cnxk_crypto_capabilities_get(vf);
        info->sym.max_nb_sessions = 0;
index 437d208..024109f 100644 (file)
@@ -17,6 +17,7 @@ sources = files(
         'cn10k_ipsec.c',
         'cnxk_cryptodev.c',
         'cnxk_cryptodev_capabilities.c',
+        'cnxk_cryptodev_devargs.c',
         'cnxk_cryptodev_ops.c',
         'cnxk_cryptodev_sec.c',
 )