1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020-2021 NXP
7 #include <rte_common.h>
8 #include <rte_bus_vdev.h>
9 #include <rte_malloc.h>
11 #include <rte_kvargs.h>
13 #include <rte_bbdev.h>
14 #include <rte_bbdev_pmd.h>
16 #include <bbdev_la12xx_pmd_logs.h>
18 #define DRIVER_NAME baseband_la12xx
20 /* Initialisation params structure that can be used by LA12xx BBDEV driver */
21 struct bbdev_la12xx_params {
22 uint8_t queues_num; /*< LA12xx BBDEV queues number */
25 #define LA12XX_MAX_NB_QUEUES_ARG "max_nb_queues"
27 static const char * const bbdev_la12xx_valid_params[] = {
28 LA12XX_MAX_NB_QUEUES_ARG,
31 /* private data structure */
32 struct bbdev_la12xx_private {
33 unsigned int max_nb_queues; /**< Max number of queues */
36 parse_u16_arg(const char *key, const char *value, void *extra_args)
38 uint16_t *u16 = extra_args;
41 if ((value == NULL) || (extra_args == NULL))
44 result = strtoul(value, NULL, 0);
45 if ((result >= (1 << 16)) || (errno != 0)) {
46 rte_bbdev_log(ERR, "Invalid value %" PRIu64 " for %s",
50 *u16 = (uint16_t)result;
54 /* Parse parameters used to create device */
56 parse_bbdev_la12xx_params(struct bbdev_la12xx_params *params,
57 const char *input_args)
59 struct rte_kvargs *kvlist = NULL;
65 kvlist = rte_kvargs_parse(input_args,
66 bbdev_la12xx_valid_params);
70 ret = rte_kvargs_process(kvlist, bbdev_la12xx_valid_params[0],
71 &parse_u16_arg, ¶ms->queues_num);
79 rte_kvargs_free(kvlist);
85 la12xx_bbdev_create(struct rte_vdev_device *vdev,
86 struct bbdev_la12xx_params *init_params __rte_unused)
88 struct rte_bbdev *bbdev;
89 const char *name = rte_vdev_device_name(vdev);
91 PMD_INIT_FUNC_TRACE();
93 bbdev = rte_bbdev_allocate(name);
97 bbdev->data->dev_private = rte_zmalloc(name,
98 sizeof(struct bbdev_la12xx_private),
100 if (bbdev->data->dev_private == NULL) {
101 rte_bbdev_release(bbdev);
105 bbdev->dev_ops = NULL;
106 bbdev->device = &vdev->device;
107 bbdev->data->socket_id = 0;
108 bbdev->intr_handle = NULL;
110 /* register rx/tx burst functions for data path */
111 bbdev->dequeue_enc_ops = NULL;
112 bbdev->dequeue_dec_ops = NULL;
113 bbdev->enqueue_enc_ops = NULL;
114 bbdev->enqueue_dec_ops = NULL;
119 /* Initialise device */
121 la12xx_bbdev_probe(struct rte_vdev_device *vdev)
123 struct bbdev_la12xx_params init_params = {
127 const char *input_args;
129 PMD_INIT_FUNC_TRACE();
134 name = rte_vdev_device_name(vdev);
138 input_args = rte_vdev_device_args(vdev);
139 parse_bbdev_la12xx_params(&init_params, input_args);
141 return la12xx_bbdev_create(vdev, &init_params);
144 /* Uninitialise device */
146 la12xx_bbdev_remove(struct rte_vdev_device *vdev)
148 struct rte_bbdev *bbdev;
151 PMD_INIT_FUNC_TRACE();
156 name = rte_vdev_device_name(vdev);
160 bbdev = rte_bbdev_get_named_dev(name);
164 rte_free(bbdev->data->dev_private);
166 return rte_bbdev_release(bbdev);
169 static struct rte_vdev_driver bbdev_la12xx_pmd_drv = {
170 .probe = la12xx_bbdev_probe,
171 .remove = la12xx_bbdev_remove
174 RTE_PMD_REGISTER_VDEV(DRIVER_NAME, bbdev_la12xx_pmd_drv);
175 RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
176 LA12XX_MAX_NB_QUEUES_ARG"=<int>");
177 RTE_LOG_REGISTER_DEFAULT(bbdev_la12xx_logtype, NOTICE);