baseband/la12xx: add devargs option for max queues
authorHemant Agrawal <hemant.agrawal@nxp.com>
Sun, 17 Oct 2021 06:53:26 +0000 (12:23 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Mon, 18 Oct 2021 18:11:56 +0000 (20:11 +0200)
This patch adds dev args to take  max queues as input

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Nicolas Chautru <nicolas.chautru@intel.com>
doc/guides/bbdevs/la12xx.rst
drivers/baseband/la12xx/bbdev_la12xx.c

index 294585e..5862db0 100644 (file)
@@ -58,6 +58,10 @@ Currently supported by DPDK:
 
 - Follow the DPDK :ref:`Getting Started Guide for Linux <linux_gsg>` to setup the basic DPDK environment.
 
+* Use dev arg option ``max_nb_queues=x`` to specify the maximum number of queues
+  to be used for communication with offload device i.e. modem. default is 16.
+  e.g. ``--vdev=baseband_la12xx,max_nb_queues=4``
+
 Enabling logs
 -------------
 
index d3d7a4d..f5c835e 100644 (file)
 
 #define DRIVER_NAME baseband_la12xx
 
+/*  Initialisation params structure that can be used by LA12xx BBDEV driver */
+struct bbdev_la12xx_params {
+       uint8_t queues_num; /*< LA12xx BBDEV queues number */
+};
+
+#define LA12XX_MAX_NB_QUEUES_ARG       "max_nb_queues"
+
+static const char * const bbdev_la12xx_valid_params[] = {
+       LA12XX_MAX_NB_QUEUES_ARG,
+};
+
 /* private data structure */
 struct bbdev_la12xx_private {
        unsigned int max_nb_queues;  /**< Max number of queues */
 };
+static inline int
+parse_u16_arg(const char *key, const char *value, void *extra_args)
+{
+       uint16_t *u16 = extra_args;
+
+       uint64_t result;
+       if ((value == NULL) || (extra_args == NULL))
+               return -EINVAL;
+       errno = 0;
+       result = strtoul(value, NULL, 0);
+       if ((result >= (1 << 16)) || (errno != 0)) {
+               rte_bbdev_log(ERR, "Invalid value %" PRIu64 " for %s",
+                             result, key);
+               return -ERANGE;
+       }
+       *u16 = (uint16_t)result;
+       return 0;
+}
+
+/* Parse parameters used to create device */
+static int
+parse_bbdev_la12xx_params(struct bbdev_la12xx_params *params,
+               const char *input_args)
+{
+       struct rte_kvargs *kvlist = NULL;
+       int ret = 0;
+
+       if (params == NULL)
+               return -EINVAL;
+       if (input_args) {
+               kvlist = rte_kvargs_parse(input_args,
+                               bbdev_la12xx_valid_params);
+               if (kvlist == NULL)
+                       return -EFAULT;
+
+               ret = rte_kvargs_process(kvlist, bbdev_la12xx_valid_params[0],
+                                       &parse_u16_arg, &params->queues_num);
+               if (ret < 0)
+                       goto exit;
+
+       }
+
+exit:
+       if (kvlist)
+               rte_kvargs_free(kvlist);
+       return ret;
+}
+
 /* Create device */
 static int
-la12xx_bbdev_create(struct rte_vdev_device *vdev)
+la12xx_bbdev_create(struct rte_vdev_device *vdev,
+               struct bbdev_la12xx_params *init_params __rte_unused)
 {
        struct rte_bbdev *bbdev;
        const char *name = rte_vdev_device_name(vdev);
@@ -60,7 +120,11 @@ la12xx_bbdev_create(struct rte_vdev_device *vdev)
 static int
 la12xx_bbdev_probe(struct rte_vdev_device *vdev)
 {
+       struct bbdev_la12xx_params init_params = {
+               8
+       };
        const char *name;
+       const char *input_args;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -71,7 +135,10 @@ la12xx_bbdev_probe(struct rte_vdev_device *vdev)
        if (name == NULL)
                return -EINVAL;
 
-       return la12xx_bbdev_create(vdev);
+       input_args = rte_vdev_device_args(vdev);
+       parse_bbdev_la12xx_params(&init_params, input_args);
+
+       return la12xx_bbdev_create(vdev, &init_params);
 }
 
 /* Uninitialise device */
@@ -105,4 +172,6 @@ static struct rte_vdev_driver bbdev_la12xx_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(DRIVER_NAME, bbdev_la12xx_pmd_drv);
+RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
+       LA12XX_MAX_NB_QUEUES_ARG"=<int>");
 RTE_LOG_REGISTER_DEFAULT(bbdev_la12xx_logtype, NOTICE);