Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2017 Intel Corporation
3 : : */
4 : :
5 : : #include <stdint.h>
6 : : #include <string.h>
7 : : #include <stdbool.h>
8 : : #include <sys/queue.h>
9 : :
10 : : #include <eal_export.h>
11 : : #include <rte_common.h>
12 : : #include <rte_errno.h>
13 : : #include <rte_log.h>
14 : : #include <rte_eal.h>
15 : : #include <rte_malloc.h>
16 : : #include <rte_mempool.h>
17 : : #include <rte_memzone.h>
18 : : #include <rte_lcore.h>
19 : : #include <rte_spinlock.h>
20 : : #include <rte_interrupts.h>
21 : :
22 : : #include "rte_bbdev_op.h"
23 : : #include "rte_bbdev.h"
24 : : #include "rte_bbdev_pmd.h"
25 : : #include "bbdev_trace.h"
26 : :
27 : : #define DEV_NAME "BBDEV"
28 : :
29 : : /* Number of supported operation types in *rte_bbdev_op_type*. */
30 : : #define BBDEV_OP_TYPE_COUNT 7
31 : :
32 : : /* BBDev library logging ID */
33 [ - + ]: 252 : RTE_LOG_REGISTER_DEFAULT(bbdev_logtype, NOTICE);
34 : : #define RTE_LOGTYPE_BBDEV bbdev_logtype
35 : :
36 : : /* Helper macro for logging */
37 : : #define rte_bbdev_log(level, ...) \
38 : : RTE_LOG_LINE(level, BBDEV, "" __VA_ARGS__)
39 : :
40 : : #define rte_bbdev_log_debug(fmt, ...) \
41 : : rte_bbdev_log(DEBUG, RTE_STR(__LINE__) ":%s() " fmt, __func__, \
42 : : ##__VA_ARGS__)
43 : :
44 : : /* Helper macro to check dev_id is valid */
45 : : #define VALID_DEV_OR_RET_ERR(dev, dev_id) do { \
46 : : if (dev == NULL) { \
47 : : rte_bbdev_log(ERR, "device %u is invalid", dev_id); \
48 : : return -ENODEV; \
49 : : } \
50 : : } while (0)
51 : :
52 : : /* Helper macro to check dev_ops is valid */
53 : : #define VALID_DEV_OPS_OR_RET_ERR(dev, dev_id) do { \
54 : : if (dev->dev_ops == NULL) { \
55 : : rte_bbdev_log(ERR, "NULL dev_ops structure in device %u", \
56 : : dev_id); \
57 : : return -ENODEV; \
58 : : } \
59 : : } while (0)
60 : :
61 : : /* Helper macro to check that driver implements required function pointer */
62 : : #define VALID_FUNC_OR_RET_ERR(func, dev_id) do { \
63 : : if (func == NULL) { \
64 : : rte_bbdev_log(ERR, "device %u does not support %s", \
65 : : dev_id, #func); \
66 : : return -ENOTSUP; \
67 : : } \
68 : : } while (0)
69 : :
70 : : /* Helper macro to check that queue is valid */
71 : : #define VALID_QUEUE_OR_RET_ERR(queue_id, dev) do { \
72 : : if (queue_id >= dev->data->num_queues) { \
73 : : rte_bbdev_log(ERR, "Invalid queue_id %u for device %u", \
74 : : queue_id, dev->data->dev_id); \
75 : : return -ERANGE; \
76 : : } \
77 : : } while (0)
78 : :
79 : : /* List of callback functions registered by an application */
80 : : struct rte_bbdev_callback {
81 : : TAILQ_ENTRY(rte_bbdev_callback) next; /* Callbacks list */
82 : : rte_bbdev_cb_fn cb_fn; /* Callback address */
83 : : void *cb_arg; /* Parameter for callback */
84 : : void *ret_param; /* Return parameter */
85 : : enum rte_bbdev_event_type event; /* Interrupt event type */
86 : : uint32_t active; /* Callback is executing */
87 : : };
88 : :
89 : : /* spinlock for bbdev device callbacks */
90 : : static rte_spinlock_t rte_bbdev_cb_lock = RTE_SPINLOCK_INITIALIZER;
91 : :
92 : : /*
93 : : * Global array of all devices. This is not static because it's used by the
94 : : * inline enqueue and dequeue functions
95 : : */
96 : : RTE_EXPORT_SYMBOL(rte_bbdev_devices)
97 : : struct rte_bbdev rte_bbdev_devices[RTE_BBDEV_MAX_DEVS];
98 : :
99 : : /* Global array with rte_bbdev_data structures */
100 : : static struct rte_bbdev_data *rte_bbdev_data;
101 : :
102 : : /* Memzone name for global bbdev data pool */
103 : : static const char *MZ_RTE_BBDEV_DATA = "rte_bbdev_data";
104 : :
105 : : /* Number of currently valid devices */
106 : : static uint16_t num_devs;
107 : :
108 : : /* Return pointer to device structure, with validity check */
109 : : static struct rte_bbdev *
110 : : get_dev(uint16_t dev_id)
111 : : {
112 [ # # # # : 0 : if (rte_bbdev_is_valid(dev_id))
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # ]
113 : 0 : return &rte_bbdev_devices[dev_id];
114 : : return NULL;
115 : : }
116 : :
117 : : /* Allocate global data array */
118 : : static int
119 : 0 : rte_bbdev_data_alloc(void)
120 : : {
121 : : const unsigned int flags = 0;
122 : : const struct rte_memzone *mz;
123 : :
124 [ # # ]: 0 : if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
125 : 0 : mz = rte_memzone_reserve(MZ_RTE_BBDEV_DATA,
126 : : RTE_BBDEV_MAX_DEVS * sizeof(*rte_bbdev_data),
127 : 0 : rte_socket_id(), flags);
128 : : } else
129 : 0 : mz = rte_memzone_lookup(MZ_RTE_BBDEV_DATA);
130 [ # # ]: 0 : if (mz == NULL) {
131 : 0 : rte_bbdev_log(CRIT,
132 : : "Cannot allocate memzone for bbdev port data");
133 : 0 : return -ENOMEM;
134 : : }
135 : :
136 : 0 : rte_bbdev_data = mz->addr;
137 [ # # ]: 0 : if (rte_eal_process_type() == RTE_PROC_PRIMARY)
138 : 0 : memset(rte_bbdev_data, 0,
139 : : RTE_BBDEV_MAX_DEVS * sizeof(*rte_bbdev_data));
140 : : return 0;
141 : : }
142 : :
143 : : /*
144 : : * Find data allocated for the device or if not found return first unused bbdev
145 : : * data. If all structures are in use and none is used by the device return
146 : : * NULL.
147 : : */
148 : : static struct rte_bbdev_data *
149 : 0 : find_bbdev_data(const char *name)
150 : : {
151 : : uint16_t data_id;
152 : :
153 [ # # ]: 0 : for (data_id = 0; data_id < RTE_BBDEV_MAX_DEVS; ++data_id) {
154 [ # # ]: 0 : if (strlen(rte_bbdev_data[data_id].name) == 0) {
155 : : memset(&rte_bbdev_data[data_id], 0,
156 : : sizeof(struct rte_bbdev_data));
157 : 0 : return &rte_bbdev_data[data_id];
158 [ # # ]: 0 : } else if (strncmp(rte_bbdev_data[data_id].name, name,
159 : : RTE_BBDEV_NAME_MAX_LEN) == 0)
160 : 0 : return &rte_bbdev_data[data_id];
161 : : }
162 : :
163 : : return NULL;
164 : : }
165 : :
166 : : /* Find lowest device id with no attached device */
167 : : static uint16_t
168 : : find_free_dev_id(void)
169 : : {
170 : : uint16_t i;
171 [ # # ]: 0 : for (i = 0; i < RTE_BBDEV_MAX_DEVS; i++) {
172 [ # # ]: 0 : if (rte_bbdev_devices[i].state == RTE_BBDEV_UNUSED)
173 : : return i;
174 : : }
175 : : return RTE_BBDEV_MAX_DEVS;
176 : : }
177 : :
178 : : RTE_EXPORT_SYMBOL(rte_bbdev_allocate)
179 : : struct rte_bbdev *
180 : 0 : rte_bbdev_allocate(const char *name)
181 : : {
182 : : int ret;
183 : : struct rte_bbdev *bbdev;
184 : : uint16_t dev_id;
185 : :
186 [ # # ]: 0 : if (name == NULL) {
187 : 0 : rte_bbdev_log(ERR, "Invalid null device name");
188 : 0 : return NULL;
189 : : }
190 : :
191 [ # # ]: 0 : if (rte_bbdev_get_named_dev(name) != NULL) {
192 : 0 : rte_bbdev_log(ERR, "Device \"%s\" is already allocated", name);
193 : 0 : return NULL;
194 : : }
195 : :
196 : : dev_id = find_free_dev_id();
197 [ # # ]: 0 : if (dev_id == RTE_BBDEV_MAX_DEVS) {
198 : 0 : rte_bbdev_log(ERR, "Reached maximum number of devices");
199 : 0 : return NULL;
200 : : }
201 : :
202 : 0 : bbdev = &rte_bbdev_devices[dev_id];
203 : :
204 [ # # ]: 0 : if (rte_bbdev_data == NULL) {
205 : 0 : ret = rte_bbdev_data_alloc();
206 [ # # ]: 0 : if (ret != 0)
207 : : return NULL;
208 : : }
209 : :
210 : 0 : bbdev->data = find_bbdev_data(name);
211 [ # # ]: 0 : if (bbdev->data == NULL) {
212 : 0 : rte_bbdev_log(ERR,
213 : : "Max BBDevs already allocated in multi-process environment!");
214 : 0 : return NULL;
215 : : }
216 : :
217 : 0 : rte_atomic_fetch_add_explicit(&bbdev->data->process_cnt, 1, rte_memory_order_relaxed);
218 : 0 : bbdev->data->dev_id = dev_id;
219 : 0 : bbdev->state = RTE_BBDEV_INITIALIZED;
220 : :
221 [ # # ]: 0 : ret = snprintf(bbdev->data->name, RTE_BBDEV_NAME_MAX_LEN, "%s", name);
222 [ # # ]: 0 : if ((ret < 0) || (ret >= RTE_BBDEV_NAME_MAX_LEN)) {
223 : 0 : rte_bbdev_log(ERR, "Copying device name \"%s\" failed", name);
224 : 0 : return NULL;
225 : : }
226 : :
227 : : /* init user callbacks */
228 : 0 : TAILQ_INIT(&(bbdev->list_cbs));
229 : :
230 : 0 : num_devs++;
231 : :
232 : 0 : rte_bbdev_log_debug("Initialised device %s (id = %u). Num devices = %u",
233 : : name, dev_id, num_devs);
234 : :
235 : 0 : return bbdev;
236 : : }
237 : :
238 : : RTE_EXPORT_SYMBOL(rte_bbdev_release)
239 : : int
240 : 0 : rte_bbdev_release(struct rte_bbdev *bbdev)
241 : : {
242 : : uint16_t dev_id;
243 : : struct rte_bbdev_callback *cb, *next;
244 : :
245 [ # # ]: 0 : if (bbdev == NULL) {
246 : 0 : rte_bbdev_log(ERR, "NULL bbdev");
247 : 0 : return -ENODEV;
248 : : }
249 : 0 : dev_id = bbdev->data->dev_id;
250 : :
251 : : /* free all callbacks from the device's list */
252 [ # # ]: 0 : for (cb = TAILQ_FIRST(&bbdev->list_cbs); cb != NULL; cb = next) {
253 : :
254 : 0 : next = TAILQ_NEXT(cb, next);
255 [ # # ]: 0 : TAILQ_REMOVE(&(bbdev->list_cbs), cb, next);
256 : 0 : rte_free(cb);
257 : : }
258 : :
259 : : /* clear shared BBDev Data if no process is using the device anymore */
260 [ # # ]: 0 : if (rte_atomic_fetch_sub_explicit(&bbdev->data->process_cnt, 1,
261 : : rte_memory_order_relaxed) - 1 == 0)
262 : 0 : memset(bbdev->data, 0, sizeof(*bbdev->data));
263 : :
264 : : memset(bbdev, 0, sizeof(*bbdev));
265 : 0 : num_devs--;
266 : : bbdev->state = RTE_BBDEV_UNUSED;
267 : :
268 : 0 : rte_bbdev_log_debug(
269 : : "Un-initialised device id = %u. Num devices = %u",
270 : : dev_id, num_devs);
271 : 0 : return 0;
272 : : }
273 : :
274 : : RTE_EXPORT_SYMBOL(rte_bbdev_get_named_dev)
275 : : struct rte_bbdev *
276 : 0 : rte_bbdev_get_named_dev(const char *name)
277 : : {
278 : : unsigned int i;
279 : :
280 [ # # ]: 0 : if (name == NULL) {
281 : 0 : rte_bbdev_log(ERR, "NULL driver name");
282 : 0 : return NULL;
283 : : }
284 : :
285 [ # # ]: 0 : for (i = 0; i < RTE_BBDEV_MAX_DEVS; i++) {
286 : 0 : struct rte_bbdev *dev = get_dev(i);
287 [ # # ]: 0 : if (dev && (strncmp(dev->data->name,
288 : : name, RTE_BBDEV_NAME_MAX_LEN) == 0))
289 : 0 : return dev;
290 : : }
291 : :
292 : : return NULL;
293 : : }
294 : :
295 : : RTE_EXPORT_SYMBOL(rte_bbdev_count)
296 : : uint16_t
297 : 0 : rte_bbdev_count(void)
298 : : {
299 : 0 : return num_devs;
300 : : }
301 : :
302 : : RTE_EXPORT_SYMBOL(rte_bbdev_is_valid)
303 : : bool
304 : 0 : rte_bbdev_is_valid(uint16_t dev_id)
305 : : {
306 [ # # ]: 0 : if ((dev_id < RTE_BBDEV_MAX_DEVS) &&
307 [ # # ]: 0 : rte_bbdev_devices[dev_id].state == RTE_BBDEV_INITIALIZED)
308 : 0 : return true;
309 : : return false;
310 : : }
311 : :
312 : : RTE_EXPORT_SYMBOL(rte_bbdev_find_next)
313 : : uint16_t
314 : 0 : rte_bbdev_find_next(uint16_t dev_id)
315 : : {
316 : 0 : dev_id++;
317 [ # # ]: 0 : for (; dev_id < RTE_BBDEV_MAX_DEVS; dev_id++)
318 [ # # ]: 0 : if (rte_bbdev_is_valid(dev_id))
319 : : break;
320 : 0 : return dev_id;
321 : : }
322 : :
323 : : RTE_EXPORT_SYMBOL(rte_bbdev_setup_queues)
324 : : int
325 : 0 : rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)
326 : : {
327 : : unsigned int i;
328 : : int ret;
329 : : struct rte_bbdev_driver_info dev_info;
330 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
331 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
332 : :
333 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
334 : :
335 [ # # ]: 0 : rte_bbdev_trace_setup_queues(dev_id, num_queues, socket_id);
336 : :
337 [ # # ]: 0 : if (dev->data->started) {
338 : 0 : rte_bbdev_log(ERR,
339 : : "Device %u cannot be configured when started",
340 : : dev_id);
341 : 0 : return -EBUSY;
342 : : }
343 : :
344 : : /* Get device driver information to get max number of queues */
345 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->info_get, dev_id);
346 : : memset(&dev_info, 0, sizeof(dev_info));
347 : 0 : dev->dev_ops->info_get(dev, &dev_info);
348 : :
349 [ # # # # ]: 0 : if ((num_queues == 0) || (num_queues > dev_info.max_num_queues)) {
350 : 0 : rte_bbdev_log(ERR,
351 : : "Device %u supports 0 < N <= %u queues, not %u",
352 : : dev_id, dev_info.max_num_queues, num_queues);
353 : 0 : return -EINVAL;
354 : : }
355 : :
356 : : /* If re-configuration, get driver to free existing internal memory */
357 [ # # ]: 0 : if (dev->data->queues != NULL) {
358 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_release, dev_id);
359 [ # # ]: 0 : for (i = 0; i < dev->data->num_queues; i++) {
360 : 0 : int ret = dev->dev_ops->queue_release(dev, i);
361 [ # # ]: 0 : if (ret < 0) {
362 : 0 : rte_bbdev_log(ERR,
363 : : "Device %u queue %u release failed",
364 : : dev_id, i);
365 : 0 : return ret;
366 : : }
367 : : }
368 : : /* Call optional device close */
369 [ # # ]: 0 : if (dev->dev_ops->close) {
370 : 0 : ret = dev->dev_ops->close(dev);
371 [ # # ]: 0 : if (ret < 0) {
372 : 0 : rte_bbdev_log(ERR,
373 : : "Device %u couldn't be closed",
374 : : dev_id);
375 : 0 : return ret;
376 : : }
377 : : }
378 : 0 : rte_free(dev->data->queues);
379 : : }
380 : :
381 : : /* Allocate queue pointers */
382 : 0 : dev->data->queues = rte_calloc_socket(DEV_NAME, num_queues,
383 : : sizeof(dev->data->queues[0]), RTE_CACHE_LINE_SIZE,
384 : 0 : dev->data->socket_id);
385 [ # # ]: 0 : if (dev->data->queues == NULL) {
386 : 0 : rte_bbdev_log(ERR,
387 : : "calloc of %u queues for device %u on socket %i failed",
388 : : num_queues, dev_id, dev->data->socket_id);
389 : 0 : return -ENOMEM;
390 : : }
391 : :
392 : 0 : dev->data->num_queues = num_queues;
393 : :
394 : : /* Call optional device configuration */
395 [ # # ]: 0 : if (dev->dev_ops->setup_queues) {
396 : 0 : ret = dev->dev_ops->setup_queues(dev, num_queues, socket_id);
397 [ # # ]: 0 : if (ret < 0) {
398 : 0 : rte_bbdev_log(ERR,
399 : : "Device %u memory configuration failed",
400 : : dev_id);
401 : 0 : goto error;
402 : : }
403 : : }
404 : :
405 : 0 : rte_bbdev_log_debug("Device %u set up with %u queues", dev_id,
406 : : num_queues);
407 : 0 : return 0;
408 : :
409 : : error:
410 : 0 : dev->data->num_queues = 0;
411 : 0 : rte_free(dev->data->queues);
412 : 0 : dev->data->queues = NULL;
413 : 0 : return ret;
414 : : }
415 : :
416 : : RTE_EXPORT_SYMBOL(rte_bbdev_intr_enable)
417 : : int
418 : 0 : rte_bbdev_intr_enable(uint16_t dev_id)
419 : : {
420 : : int ret;
421 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
422 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
423 : :
424 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
425 : :
426 [ # # ]: 0 : if (dev->data->started) {
427 : 0 : rte_bbdev_log(ERR,
428 : : "Device %u cannot be configured when started",
429 : : dev_id);
430 : 0 : return -EBUSY;
431 : : }
432 : :
433 [ # # ]: 0 : if (dev->dev_ops->intr_enable) {
434 : 0 : ret = dev->dev_ops->intr_enable(dev);
435 [ # # ]: 0 : if (ret < 0) {
436 : 0 : rte_bbdev_log(ERR,
437 : : "Device %u interrupts configuration failed",
438 : : dev_id);
439 : 0 : return ret;
440 : : }
441 : 0 : rte_bbdev_log_debug("Enabled interrupts for dev %u", dev_id);
442 : 0 : return 0;
443 : : }
444 : :
445 : 0 : rte_bbdev_log(ERR, "Device %u doesn't support interrupts", dev_id);
446 : 0 : return -ENOTSUP;
447 : : }
448 : :
449 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_configure)
450 : : int
451 : 0 : rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
452 : : const struct rte_bbdev_queue_conf *conf)
453 : : {
454 : :
455 [ # # ]: 0 : rte_bbdev_trace_queue_configure(dev_id, queue_id, rte_bbdev_op_type_str(conf->op_type),
456 : 0 : conf->priority);
457 : :
458 : : int ret = 0;
459 : : struct rte_bbdev_driver_info dev_info;
460 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
461 : : const struct rte_bbdev_op_cap *p;
462 : : struct rte_bbdev_queue_conf *stored_conf;
463 : : const char *op_type_str;
464 : : unsigned int max_priority;
465 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
466 : :
467 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
468 : :
469 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
470 : :
471 [ # # # # ]: 0 : if (dev->data->queues[queue_id].started || dev->data->started) {
472 : 0 : rte_bbdev_log(ERR,
473 : : "Queue %u of device %u cannot be configured when started",
474 : : queue_id, dev_id);
475 : 0 : return -EBUSY;
476 : : }
477 : :
478 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_release, dev_id);
479 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_setup, dev_id);
480 : :
481 : : /* Get device driver information to verify config is valid */
482 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->info_get, dev_id);
483 : : memset(&dev_info, 0, sizeof(dev_info));
484 : 0 : dev->dev_ops->info_get(dev, &dev_info);
485 : :
486 : : /* Check configuration is valid */
487 : : if (conf != NULL) {
488 [ # # ]: 0 : if ((conf->op_type == RTE_BBDEV_OP_NONE) &&
489 [ # # ]: 0 : (dev_info.capabilities[0].type ==
490 : : RTE_BBDEV_OP_NONE)) {
491 : : ret = 1;
492 : : } else {
493 : 0 : for (p = dev_info.capabilities;
494 [ # # ]: 0 : p->type != RTE_BBDEV_OP_NONE; p++) {
495 [ # # ]: 0 : if (conf->op_type == p->type) {
496 : : ret = 1;
497 : : break;
498 : : }
499 : : }
500 : : }
501 [ # # ]: 0 : if (ret == 0) {
502 : 0 : rte_bbdev_log(ERR, "Invalid operation type");
503 : 0 : return -EINVAL;
504 : : }
505 [ # # ]: 0 : if (conf->queue_size > dev_info.queue_size_lim) {
506 : 0 : rte_bbdev_log(ERR,
507 : : "Size (%u) of queue %u of device %u must be: <= %u",
508 : : conf->queue_size, queue_id, dev_id,
509 : : dev_info.queue_size_lim);
510 : 0 : return -EINVAL;
511 : : }
512 : : if (!rte_is_power_of_2(conf->queue_size)) {
513 : 0 : rte_bbdev_log(ERR,
514 : : "Size (%u) of queue %u of device %u must be a power of 2",
515 : : conf->queue_size, queue_id, dev_id);
516 : 0 : return -EINVAL;
517 : : }
518 [ # # ]: 0 : if ((uint8_t)conf->op_type >= RTE_BBDEV_OP_TYPE_SIZE_MAX) {
519 : 0 : rte_bbdev_log(ERR,
520 : : "Invalid operation type (%u) ", conf->op_type);
521 : 0 : return -EINVAL;
522 : : }
523 : 0 : max_priority = dev_info.queue_priority[conf->op_type];
524 [ # # ]: 0 : if (conf->priority > max_priority) {
525 : 0 : rte_bbdev_log(ERR,
526 : : "Priority (%u) of queue %u of bbdev %u must be <= %u",
527 : : conf->priority, queue_id, dev_id, max_priority);
528 : 0 : return -EINVAL;
529 : : }
530 : : }
531 : :
532 : : /* Release existing queue (in case of queue reconfiguration) */
533 [ # # ]: 0 : if (dev->data->queues[queue_id].queue_private != NULL) {
534 : 0 : ret = dev->dev_ops->queue_release(dev, queue_id);
535 [ # # ]: 0 : if (ret < 0) {
536 : 0 : rte_bbdev_log(ERR, "Device %u queue %u release failed",
537 : : dev_id, queue_id);
538 : 0 : return ret;
539 : : }
540 : : }
541 : :
542 : : /* Get driver to setup the queue */
543 : 0 : ret = dev->dev_ops->queue_setup(dev, queue_id, (conf != NULL) ?
544 : : conf : &dev_info.default_queue_conf);
545 [ # # ]: 0 : if (ret < 0) {
546 : : /* This may happen when trying different priority levels */
547 : 0 : rte_bbdev_log(INFO,
548 : : "Device %u queue %u setup failed",
549 : : dev_id, queue_id);
550 : 0 : return ret;
551 : : }
552 : :
553 : : /* Store configuration */
554 : 0 : stored_conf = &dev->data->queues[queue_id].conf;
555 : : memcpy(stored_conf,
556 : : (conf != NULL) ? conf : &dev_info.default_queue_conf,
557 : : sizeof(*stored_conf));
558 : :
559 : 0 : op_type_str = rte_bbdev_op_type_str(stored_conf->op_type);
560 [ # # ]: 0 : if (op_type_str == NULL)
561 : : return -EINVAL;
562 : :
563 : 0 : rte_bbdev_log_debug("Configured dev%uq%u (size=%u, type=%s, prio=%u)",
564 : : dev_id, queue_id, stored_conf->queue_size, op_type_str,
565 : : stored_conf->priority);
566 : :
567 : 0 : return 0;
568 : : }
569 : :
570 : : RTE_EXPORT_SYMBOL(rte_bbdev_start)
571 : : int
572 : 0 : rte_bbdev_start(uint16_t dev_id)
573 : : {
574 : : int i;
575 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
576 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
577 : :
578 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
579 : :
580 [ # # ]: 0 : rte_bbdev_trace_start(dev_id);
581 : :
582 [ # # ]: 0 : if (dev->data->started) {
583 : 0 : rte_bbdev_log_debug("Device %u is already started", dev_id);
584 : 0 : return 0;
585 : : }
586 : :
587 [ # # ]: 0 : if (dev->dev_ops->start) {
588 : 0 : int ret = dev->dev_ops->start(dev);
589 [ # # ]: 0 : if (ret < 0) {
590 : 0 : rte_bbdev_log(ERR, "Device %u start failed", dev_id);
591 : 0 : return ret;
592 : : }
593 : : }
594 : :
595 : : /* Store new state */
596 [ # # ]: 0 : for (i = 0; i < dev->data->num_queues; i++)
597 [ # # ]: 0 : if (!dev->data->queues[i].conf.deferred_start)
598 : 0 : dev->data->queues[i].started = true;
599 : 0 : dev->data->started = true;
600 : :
601 : 0 : rte_bbdev_log_debug("Started device %u", dev_id);
602 : 0 : return 0;
603 : : }
604 : :
605 : : RTE_EXPORT_SYMBOL(rte_bbdev_stop)
606 : : int
607 : 0 : rte_bbdev_stop(uint16_t dev_id)
608 : : {
609 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
610 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
611 : :
612 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
613 : :
614 [ # # ]: 0 : rte_bbdev_trace_stop(dev_id);
615 : :
616 [ # # ]: 0 : if (!dev->data->started) {
617 : 0 : rte_bbdev_log_debug("Device %u is already stopped", dev_id);
618 : 0 : return 0;
619 : : }
620 : :
621 [ # # ]: 0 : if (dev->dev_ops->stop)
622 : 0 : dev->dev_ops->stop(dev);
623 : 0 : dev->data->started = false;
624 : :
625 : 0 : rte_bbdev_log_debug("Stopped device %u", dev_id);
626 : 0 : return 0;
627 : : }
628 : :
629 : : RTE_EXPORT_SYMBOL(rte_bbdev_close)
630 : : int
631 : 0 : rte_bbdev_close(uint16_t dev_id)
632 : : {
633 : : int ret;
634 : : uint16_t i;
635 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
636 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
637 : :
638 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
639 : :
640 [ # # ]: 0 : rte_bbdev_trace_close(dev_id);
641 : :
642 [ # # ]: 0 : if (dev->data->started) {
643 : 0 : ret = rte_bbdev_stop(dev_id);
644 [ # # ]: 0 : if (ret < 0) {
645 : 0 : rte_bbdev_log(ERR, "Device %u stop failed", dev_id);
646 : 0 : return ret;
647 : : }
648 : : }
649 : :
650 : : /* Free memory used by queues */
651 [ # # ]: 0 : for (i = 0; i < dev->data->num_queues; i++) {
652 : 0 : ret = dev->dev_ops->queue_release(dev, i);
653 [ # # ]: 0 : if (ret < 0) {
654 : 0 : rte_bbdev_log(ERR, "Device %u queue %u release failed",
655 : : dev_id, i);
656 : 0 : return ret;
657 : : }
658 : : }
659 : 0 : rte_free(dev->data->queues);
660 : :
661 [ # # ]: 0 : if (dev->dev_ops->close) {
662 : 0 : ret = dev->dev_ops->close(dev);
663 [ # # ]: 0 : if (ret < 0) {
664 : 0 : rte_bbdev_log(ERR, "Device %u close failed", dev_id);
665 : 0 : return ret;
666 : : }
667 : : }
668 : :
669 : : /* Clear configuration */
670 : 0 : dev->data->queues = NULL;
671 : 0 : dev->data->num_queues = 0;
672 : :
673 : 0 : rte_bbdev_log_debug("Closed device %u", dev_id);
674 : 0 : return 0;
675 : : }
676 : :
677 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_start)
678 : : int
679 : 0 : rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id)
680 : : {
681 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
682 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
683 : :
684 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
685 : :
686 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
687 : :
688 [ # # ]: 0 : rte_bbdev_trace_queue_start(dev_id, queue_id);
689 : :
690 [ # # ]: 0 : if (dev->data->queues[queue_id].started) {
691 : 0 : rte_bbdev_log_debug("Queue %u of device %u already started",
692 : : queue_id, dev_id);
693 : 0 : return 0;
694 : : }
695 : :
696 [ # # ]: 0 : if (dev->dev_ops->queue_start) {
697 : 0 : int ret = dev->dev_ops->queue_start(dev, queue_id);
698 [ # # ]: 0 : if (ret < 0) {
699 : 0 : rte_bbdev_log(ERR, "Device %u queue %u start failed",
700 : : dev_id, queue_id);
701 : 0 : return ret;
702 : : }
703 : : }
704 : 0 : dev->data->queues[queue_id].started = true;
705 : :
706 : 0 : rte_bbdev_log_debug("Started queue %u of device %u", queue_id, dev_id);
707 : 0 : return 0;
708 : : }
709 : :
710 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_stop)
711 : : int
712 : 0 : rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
713 : : {
714 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
715 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
716 : :
717 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
718 : :
719 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
720 : :
721 [ # # ]: 0 : rte_bbdev_trace_queue_stop(dev_id, queue_id);
722 : :
723 [ # # ]: 0 : if (!dev->data->queues[queue_id].started) {
724 : 0 : rte_bbdev_log_debug("Queue %u of device %u already stopped",
725 : : queue_id, dev_id);
726 : 0 : return 0;
727 : : }
728 : :
729 [ # # ]: 0 : if (dev->dev_ops->queue_stop) {
730 : 0 : int ret = dev->dev_ops->queue_stop(dev, queue_id);
731 [ # # ]: 0 : if (ret < 0) {
732 : 0 : rte_bbdev_log(ERR, "Device %u queue %u stop failed",
733 : : dev_id, queue_id);
734 : 0 : return ret;
735 : : }
736 : : }
737 : 0 : dev->data->queues[queue_id].started = false;
738 : :
739 : 0 : rte_bbdev_log_debug("Stopped queue %u of device %u", queue_id, dev_id);
740 : 0 : return 0;
741 : : }
742 : :
743 : : /* Get device statistics */
744 : : static void
745 : 0 : get_stats_from_queues(struct rte_bbdev *dev, struct rte_bbdev_stats *stats)
746 : : {
747 : : unsigned int q_id;
748 [ # # ]: 0 : for (q_id = 0; q_id < dev->data->num_queues; q_id++) {
749 : : struct rte_bbdev_stats *q_stats =
750 : 0 : &dev->data->queues[q_id].queue_stats;
751 : :
752 : 0 : stats->enqueued_count += q_stats->enqueued_count;
753 : 0 : stats->dequeued_count += q_stats->dequeued_count;
754 : 0 : stats->enqueue_err_count += q_stats->enqueue_err_count;
755 : 0 : stats->dequeue_err_count += q_stats->dequeue_err_count;
756 : 0 : stats->enqueue_warn_count += q_stats->enqueue_warn_count;
757 : 0 : stats->dequeue_warn_count += q_stats->dequeue_warn_count;
758 : : }
759 : 0 : rte_bbdev_log_debug("Got stats on %u", dev->data->dev_id);
760 : 0 : }
761 : :
762 : : static void
763 : 0 : reset_stats_in_queues(struct rte_bbdev *dev)
764 : : {
765 : : unsigned int q_id;
766 [ # # ]: 0 : for (q_id = 0; q_id < dev->data->num_queues; q_id++) {
767 : 0 : struct rte_bbdev_stats *q_stats =
768 : 0 : &dev->data->queues[q_id].queue_stats;
769 : :
770 : : memset(q_stats, 0, sizeof(*q_stats));
771 : : }
772 : 0 : rte_bbdev_log_debug("Reset stats on %u", dev->data->dev_id);
773 : 0 : }
774 : :
775 : : RTE_EXPORT_SYMBOL(rte_bbdev_stats_get)
776 : : int
777 : 0 : rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats)
778 : : {
779 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
780 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
781 : :
782 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
783 : :
784 [ # # ]: 0 : if (stats == NULL) {
785 : 0 : rte_bbdev_log(ERR, "NULL stats structure");
786 : 0 : return -EINVAL;
787 : : }
788 : :
789 : : memset(stats, 0, sizeof(*stats));
790 [ # # ]: 0 : if (dev->dev_ops->stats_get != NULL)
791 : 0 : dev->dev_ops->stats_get(dev, stats);
792 : : else
793 : 0 : get_stats_from_queues(dev, stats);
794 : :
795 : 0 : rte_bbdev_log_debug("Retrieved stats of device %u", dev_id);
796 : 0 : return 0;
797 : : }
798 : :
799 : : RTE_EXPORT_SYMBOL(rte_bbdev_stats_reset)
800 : : int
801 : 0 : rte_bbdev_stats_reset(uint16_t dev_id)
802 : : {
803 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
804 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
805 : :
806 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
807 : :
808 [ # # ]: 0 : if (dev->dev_ops->stats_reset != NULL)
809 : 0 : dev->dev_ops->stats_reset(dev);
810 : : else
811 : 0 : reset_stats_in_queues(dev);
812 : :
813 : 0 : rte_bbdev_log_debug("Reset stats of device %u", dev_id);
814 : 0 : return 0;
815 : : }
816 : :
817 : : RTE_EXPORT_SYMBOL(rte_bbdev_info_get)
818 : : int
819 : 0 : rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info)
820 : : {
821 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
822 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
823 : :
824 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->info_get, dev_id);
825 : :
826 [ # # ]: 0 : if (dev_info == NULL) {
827 : 0 : rte_bbdev_log(ERR, "NULL dev info structure");
828 : 0 : return -EINVAL;
829 : : }
830 : :
831 : : /* Copy data maintained by device interface layer */
832 : : memset(dev_info, 0, sizeof(*dev_info));
833 : 0 : dev_info->dev_name = dev->data->name;
834 : 0 : dev_info->num_queues = dev->data->num_queues;
835 : 0 : dev_info->device = dev->device;
836 : 0 : dev_info->socket_id = dev->data->socket_id;
837 : 0 : dev_info->started = dev->data->started;
838 : :
839 : : /* Copy data maintained by device driver layer */
840 : 0 : dev->dev_ops->info_get(dev, &dev_info->drv);
841 : :
842 : 0 : rte_bbdev_log_debug("Retrieved info of device %u", dev_id);
843 : 0 : return 0;
844 : : }
845 : :
846 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_info_get)
847 : : int
848 : 0 : rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
849 : : struct rte_bbdev_queue_info *queue_info)
850 : : {
851 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
852 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
853 : :
854 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
855 : :
856 [ # # ]: 0 : if (queue_info == NULL) {
857 : 0 : rte_bbdev_log(ERR, "NULL queue info structure");
858 : 0 : return -EINVAL;
859 : : }
860 : :
861 : : /* Copy data to output */
862 : : memset(queue_info, 0, sizeof(*queue_info));
863 : 0 : queue_info->conf = dev->data->queues[queue_id].conf;
864 : 0 : queue_info->started = dev->data->queues[queue_id].started;
865 : :
866 : 0 : rte_bbdev_log_debug("Retrieved info of queue %u of device %u",
867 : : queue_id, dev_id);
868 : 0 : return 0;
869 : : }
870 : :
871 : : /* Calculate size needed to store bbdev_op, depending on type */
872 : : static unsigned int
873 : : get_bbdev_op_size(enum rte_bbdev_op_type type)
874 : : {
875 : : unsigned int result = 0;
876 : : switch (type) {
877 : : case RTE_BBDEV_OP_NONE:
878 : : result = RTE_MAX(sizeof(struct rte_bbdev_dec_op),
879 : : sizeof(struct rte_bbdev_enc_op));
880 : : break;
881 : : case RTE_BBDEV_OP_TURBO_DEC:
882 : : result = sizeof(struct rte_bbdev_dec_op);
883 : : break;
884 : : case RTE_BBDEV_OP_TURBO_ENC:
885 : : result = sizeof(struct rte_bbdev_enc_op);
886 : : break;
887 : : case RTE_BBDEV_OP_LDPC_DEC:
888 : : result = sizeof(struct rte_bbdev_dec_op);
889 : : break;
890 : : case RTE_BBDEV_OP_LDPC_ENC:
891 : : result = sizeof(struct rte_bbdev_enc_op);
892 : : break;
893 : : case RTE_BBDEV_OP_FFT:
894 : : result = sizeof(struct rte_bbdev_fft_op);
895 : : break;
896 : : case RTE_BBDEV_OP_MLDTS:
897 : : result = sizeof(struct rte_bbdev_mldts_op);
898 : : break;
899 : : default:
900 : : break;
901 : : }
902 : :
903 : : return result;
904 : : }
905 : :
906 : : /* Initialise a bbdev_op structure */
907 : : static void
908 : 0 : bbdev_op_init(struct rte_mempool *mempool, void *arg, void *element,
909 : : __rte_unused unsigned int n)
910 : : {
911 : 0 : enum rte_bbdev_op_type type = *(enum rte_bbdev_op_type *)arg;
912 : :
913 [ # # ]: 0 : if (type == RTE_BBDEV_OP_TURBO_DEC || type == RTE_BBDEV_OP_LDPC_DEC) {
914 : : struct rte_bbdev_dec_op *op = element;
915 : 0 : memset(op, 0, mempool->elt_size);
916 : 0 : op->mempool = mempool;
917 : 0 : } else if (type == RTE_BBDEV_OP_TURBO_ENC ||
918 [ # # ]: 0 : type == RTE_BBDEV_OP_LDPC_ENC) {
919 : : struct rte_bbdev_enc_op *op = element;
920 : 0 : memset(op, 0, mempool->elt_size);
921 : 0 : op->mempool = mempool;
922 [ # # ]: 0 : } else if (type == RTE_BBDEV_OP_FFT) {
923 : : struct rte_bbdev_fft_op *op = element;
924 : 0 : memset(op, 0, mempool->elt_size);
925 : 0 : op->mempool = mempool;
926 [ # # ]: 0 : } else if (type == RTE_BBDEV_OP_MLDTS) {
927 : : struct rte_bbdev_mldts_op *op = element;
928 : 0 : memset(op, 0, mempool->elt_size);
929 : 0 : op->mempool = mempool;
930 : : }
931 : 0 : }
932 : :
933 : : RTE_EXPORT_SYMBOL(rte_bbdev_op_pool_create)
934 : : struct rte_mempool *
935 : 0 : rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
936 : : unsigned int num_elements, unsigned int cache_size,
937 : : int socket_id)
938 : : {
939 : : struct rte_bbdev_op_pool_private *priv;
940 : : struct rte_mempool *mp;
941 : : const char *op_type_str;
942 : :
943 [ # # ]: 0 : if (name == NULL) {
944 : 0 : rte_bbdev_log(ERR, "NULL name for op pool");
945 : 0 : return NULL;
946 : : }
947 : :
948 [ # # ]: 0 : if (type >= BBDEV_OP_TYPE_COUNT) {
949 : 0 : rte_bbdev_log(ERR,
950 : : "Invalid op type (%u), should be less than %u",
951 : : type, BBDEV_OP_TYPE_COUNT);
952 : 0 : return NULL;
953 : : }
954 : :
955 : 0 : mp = rte_mempool_create(name, num_elements, get_bbdev_op_size(type),
956 : : cache_size, sizeof(struct rte_bbdev_op_pool_private),
957 : : NULL, NULL, bbdev_op_init, &type, socket_id, 0);
958 [ # # ]: 0 : if (mp == NULL) {
959 [ # # ]: 0 : rte_bbdev_log(ERR,
960 : : "Failed to create op pool %s (num ops=%u, op size=%u) with error: %s",
961 : : name, num_elements, get_bbdev_op_size(type),
962 : : rte_strerror(rte_errno));
963 : 0 : return NULL;
964 : : }
965 : :
966 : 0 : op_type_str = rte_bbdev_op_type_str(type);
967 [ # # ]: 0 : if (op_type_str == NULL)
968 : : return NULL;
969 : :
970 [ # # ]: 0 : rte_bbdev_log_debug(
971 : : "Op pool %s created for %u ops (type=%s, cache=%u, socket=%u, size=%u)",
972 : : name, num_elements, op_type_str, cache_size, socket_id,
973 : : get_bbdev_op_size(type));
974 : :
975 : : priv = (struct rte_bbdev_op_pool_private *)rte_mempool_get_priv(mp);
976 : 0 : priv->type = type;
977 : :
978 : 0 : return mp;
979 : : }
980 : :
981 : : RTE_EXPORT_SYMBOL(rte_bbdev_callback_register)
982 : : int
983 : 0 : rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
984 : : rte_bbdev_cb_fn cb_fn, void *cb_arg)
985 : : {
986 : : struct rte_bbdev_callback *user_cb;
987 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
988 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
989 : :
990 [ # # ]: 0 : if (event >= RTE_BBDEV_EVENT_MAX) {
991 : 0 : rte_bbdev_log(ERR,
992 : : "Invalid event type (%u), should be less than %u",
993 : : event, RTE_BBDEV_EVENT_MAX);
994 : 0 : return -EINVAL;
995 : : }
996 : :
997 [ # # ]: 0 : if (cb_fn == NULL) {
998 : 0 : rte_bbdev_log(ERR, "NULL callback function");
999 : 0 : return -EINVAL;
1000 : : }
1001 : :
1002 : : rte_spinlock_lock(&rte_bbdev_cb_lock);
1003 : :
1004 [ # # ]: 0 : TAILQ_FOREACH(user_cb, &(dev->list_cbs), next) {
1005 [ # # ]: 0 : if (user_cb->cb_fn == cb_fn &&
1006 [ # # ]: 0 : user_cb->cb_arg == cb_arg &&
1007 [ # # ]: 0 : user_cb->event == event)
1008 : : break;
1009 : : }
1010 : :
1011 : : /* create a new callback. */
1012 [ # # ]: 0 : if (user_cb == NULL) {
1013 : 0 : user_cb = rte_zmalloc("INTR_USER_CALLBACK",
1014 : : sizeof(struct rte_bbdev_callback), 0);
1015 [ # # ]: 0 : if (user_cb != NULL) {
1016 : 0 : user_cb->cb_fn = cb_fn;
1017 : 0 : user_cb->cb_arg = cb_arg;
1018 : 0 : user_cb->event = event;
1019 : 0 : TAILQ_INSERT_TAIL(&(dev->list_cbs), user_cb, next);
1020 : : }
1021 : : }
1022 : :
1023 : : rte_spinlock_unlock(&rte_bbdev_cb_lock);
1024 [ # # ]: 0 : return (user_cb == NULL) ? -ENOMEM : 0;
1025 : : }
1026 : :
1027 : : RTE_EXPORT_SYMBOL(rte_bbdev_callback_unregister)
1028 : : int
1029 : 0 : rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
1030 : : rte_bbdev_cb_fn cb_fn, void *cb_arg)
1031 : : {
1032 : : int ret = 0;
1033 : : struct rte_bbdev_callback *cb, *next;
1034 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
1035 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
1036 : :
1037 [ # # ]: 0 : if (event >= RTE_BBDEV_EVENT_MAX) {
1038 : 0 : rte_bbdev_log(ERR,
1039 : : "Invalid event type (%u), should be less than %u",
1040 : : event, RTE_BBDEV_EVENT_MAX);
1041 : 0 : return -EINVAL;
1042 : : }
1043 : :
1044 [ # # ]: 0 : if (cb_fn == NULL) {
1045 : 0 : rte_bbdev_log(ERR,
1046 : : "NULL callback function cannot be unregistered");
1047 : 0 : return -EINVAL;
1048 : : }
1049 : :
1050 : : dev = &rte_bbdev_devices[dev_id];
1051 : : rte_spinlock_lock(&rte_bbdev_cb_lock);
1052 : :
1053 [ # # ]: 0 : for (cb = TAILQ_FIRST(&dev->list_cbs); cb != NULL; cb = next) {
1054 : :
1055 : 0 : next = TAILQ_NEXT(cb, next);
1056 : :
1057 [ # # # # : 0 : if (cb->cb_fn != cb_fn || cb->event != event ||
# # ]
1058 [ # # ]: 0 : (cb_arg != (void *)-1 && cb->cb_arg != cb_arg))
1059 : 0 : continue;
1060 : :
1061 : : /* If this callback is not executing right now, remove it. */
1062 [ # # ]: 0 : if (cb->active == 0) {
1063 [ # # ]: 0 : TAILQ_REMOVE(&(dev->list_cbs), cb, next);
1064 : 0 : rte_free(cb);
1065 : : } else
1066 : : ret = -EAGAIN;
1067 : : }
1068 : :
1069 : : rte_spinlock_unlock(&rte_bbdev_cb_lock);
1070 : 0 : return ret;
1071 : : }
1072 : :
1073 : : RTE_EXPORT_SYMBOL(rte_bbdev_pmd_callback_process)
1074 : : void
1075 : 0 : rte_bbdev_pmd_callback_process(struct rte_bbdev *dev,
1076 : : enum rte_bbdev_event_type event, void *ret_param)
1077 : : {
1078 : : struct rte_bbdev_callback *cb_lst;
1079 : : struct rte_bbdev_callback dev_cb;
1080 : :
1081 [ # # ]: 0 : if (dev == NULL) {
1082 : 0 : rte_bbdev_log(ERR, "NULL device");
1083 : 0 : return;
1084 : : }
1085 : :
1086 [ # # ]: 0 : if (dev->data == NULL) {
1087 : 0 : rte_bbdev_log(ERR, "NULL data structure");
1088 : 0 : return;
1089 : : }
1090 : :
1091 [ # # ]: 0 : if (event >= RTE_BBDEV_EVENT_MAX) {
1092 : 0 : rte_bbdev_log(ERR,
1093 : : "Invalid event type (%u), should be less than %u",
1094 : : event, RTE_BBDEV_EVENT_MAX);
1095 : 0 : return;
1096 : : }
1097 : :
1098 : : rte_spinlock_lock(&rte_bbdev_cb_lock);
1099 [ # # ]: 0 : TAILQ_FOREACH(cb_lst, &(dev->list_cbs), next) {
1100 [ # # # # ]: 0 : if (cb_lst->cb_fn == NULL || cb_lst->event != event)
1101 : 0 : continue;
1102 : 0 : dev_cb = *cb_lst;
1103 : 0 : cb_lst->active = 1;
1104 [ # # ]: 0 : if (ret_param != NULL)
1105 : : dev_cb.ret_param = ret_param;
1106 : :
1107 : : rte_spinlock_unlock(&rte_bbdev_cb_lock);
1108 : 0 : dev_cb.cb_fn(dev->data->dev_id, dev_cb.event,
1109 : : dev_cb.cb_arg, dev_cb.ret_param);
1110 : : rte_spinlock_lock(&rte_bbdev_cb_lock);
1111 : 0 : cb_lst->active = 0;
1112 : : }
1113 : : rte_spinlock_unlock(&rte_bbdev_cb_lock);
1114 : : }
1115 : :
1116 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_intr_enable)
1117 : : int
1118 : 0 : rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id)
1119 : : {
1120 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
1121 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
1122 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
1123 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
1124 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_intr_enable, dev_id);
1125 : 0 : return dev->dev_ops->queue_intr_enable(dev, queue_id);
1126 : : }
1127 : :
1128 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_intr_disable)
1129 : : int
1130 : 0 : rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id)
1131 : : {
1132 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
1133 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
1134 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
1135 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
1136 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_intr_disable, dev_id);
1137 : 0 : return dev->dev_ops->queue_intr_disable(dev, queue_id);
1138 : : }
1139 : :
1140 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_intr_ctl)
1141 : : int
1142 : 0 : rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
1143 : : void *data)
1144 : : {
1145 : : uint32_t vec;
1146 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
1147 : : struct rte_intr_handle *intr_handle;
1148 : : int ret;
1149 : :
1150 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
1151 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
1152 : :
1153 : 0 : intr_handle = dev->intr_handle;
1154 [ # # ]: 0 : if (intr_handle == NULL) {
1155 : 0 : rte_bbdev_log(ERR, "Device %u intr handle unset", dev_id);
1156 : 0 : return -ENOTSUP;
1157 : : }
1158 : :
1159 [ # # ]: 0 : if (queue_id >= RTE_MAX_RXTX_INTR_VEC_ID) {
1160 : 0 : rte_bbdev_log(ERR, "Device %u queue_id %u is too big",
1161 : : dev_id, queue_id);
1162 : 0 : return -ENOTSUP;
1163 : : }
1164 : :
1165 : 0 : vec = rte_intr_vec_list_index_get(intr_handle, queue_id);
1166 : 0 : ret = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
1167 [ # # ]: 0 : if (ret && (ret != -EEXIST)) {
1168 : 0 : rte_bbdev_log(ERR,
1169 : : "dev %u q %u int ctl error op %d epfd %d vec %u",
1170 : : dev_id, queue_id, op, epfd, vec);
1171 : 0 : return ret;
1172 : : }
1173 : :
1174 : : return 0;
1175 : : }
1176 : :
1177 : :
1178 : : RTE_EXPORT_SYMBOL(rte_bbdev_op_type_str)
1179 : : const char *
1180 : 0 : rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type)
1181 : : {
1182 : : static const char * const op_types[] = {
1183 : : "RTE_BBDEV_OP_NONE",
1184 : : "RTE_BBDEV_OP_TURBO_DEC",
1185 : : "RTE_BBDEV_OP_TURBO_ENC",
1186 : : "RTE_BBDEV_OP_LDPC_DEC",
1187 : : "RTE_BBDEV_OP_LDPC_ENC",
1188 : : "RTE_BBDEV_OP_FFT",
1189 : : "RTE_BBDEV_OP_MLDTS",
1190 : : };
1191 : :
1192 [ # # ]: 0 : if (op_type < BBDEV_OP_TYPE_COUNT)
1193 : 0 : return op_types[op_type];
1194 : :
1195 : 0 : rte_bbdev_log(ERR, "Invalid operation type");
1196 : 0 : return NULL;
1197 : : }
1198 : :
1199 : : RTE_EXPORT_SYMBOL(rte_bbdev_device_status_str)
1200 : : const char *
1201 : 0 : rte_bbdev_device_status_str(enum rte_bbdev_device_status status)
1202 : : {
1203 : : static const char * const dev_sta_string[] = {
1204 : : "RTE_BBDEV_DEV_NOSTATUS",
1205 : : "RTE_BBDEV_DEV_NOT_SUPPORTED",
1206 : : "RTE_BBDEV_DEV_RESET",
1207 : : "RTE_BBDEV_DEV_CONFIGURED",
1208 : : "RTE_BBDEV_DEV_ACTIVE",
1209 : : "RTE_BBDEV_DEV_FATAL_ERR",
1210 : : "RTE_BBDEV_DEV_RESTART_REQ",
1211 : : "RTE_BBDEV_DEV_RECONFIG_REQ",
1212 : : "RTE_BBDEV_DEV_CORRECT_ERR",
1213 : : };
1214 : :
1215 : : /* Cast from enum required for clang. */
1216 [ # # ]: 0 : if ((uint8_t)status < sizeof(dev_sta_string) / sizeof(char *))
1217 : 0 : return dev_sta_string[status];
1218 : :
1219 : 0 : rte_bbdev_log(ERR, "Invalid device status");
1220 : 0 : return NULL;
1221 : : }
1222 : :
1223 : : RTE_EXPORT_SYMBOL(rte_bbdev_enqueue_status_str)
1224 : : const char *
1225 : 0 : rte_bbdev_enqueue_status_str(enum rte_bbdev_enqueue_status status)
1226 : : {
1227 : : static const char * const enq_sta_string[] = {
1228 : : "RTE_BBDEV_ENQ_STATUS_NONE",
1229 : : "RTE_BBDEV_ENQ_STATUS_QUEUE_FULL",
1230 : : "RTE_BBDEV_ENQ_STATUS_RING_FULL",
1231 : : "RTE_BBDEV_ENQ_STATUS_INVALID_OP",
1232 : : };
1233 : :
1234 : : /* Cast from enum required for clang. */
1235 [ # # ]: 0 : if ((uint8_t)status < sizeof(enq_sta_string) / sizeof(char *))
1236 : 0 : return enq_sta_string[status];
1237 : :
1238 : 0 : rte_bbdev_log(ERR, "Invalid enqueue status");
1239 : 0 : return NULL;
1240 : : }
1241 : :
1242 : :
1243 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bbdev_queue_ops_dump, 24.11)
1244 : : int
1245 : 0 : rte_bbdev_queue_ops_dump(uint16_t dev_id, uint16_t queue_id, FILE *f)
1246 : : {
1247 : : struct rte_bbdev_queue_data *q_data;
1248 : : struct rte_bbdev_stats *stats;
1249 : : uint16_t i;
1250 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
1251 : :
1252 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
1253 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
1254 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
1255 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_ops_dump, dev_id);
1256 : :
1257 : 0 : q_data = &dev->data->queues[queue_id];
1258 : :
1259 [ # # ]: 0 : if (f == NULL)
1260 : : return -EINVAL;
1261 : :
1262 : 0 : fprintf(f, "Dump of operations on %s queue %d\n",
1263 : 0 : dev->data->name, queue_id);
1264 : 0 : fprintf(f, " Last Enqueue Status %s\n",
1265 : : rte_bbdev_enqueue_status_str(q_data->enqueue_status));
1266 [ # # ]: 0 : for (i = 0; i < RTE_BBDEV_ENQ_STATUS_SIZE_MAX; i++)
1267 [ # # ]: 0 : if (q_data->queue_stats.enqueue_status_count[i] > 0)
1268 : 0 : fprintf(f, " Enqueue Status Counters %s %" PRIu64 "\n",
1269 : : rte_bbdev_enqueue_status_str(i),
1270 : : q_data->queue_stats.enqueue_status_count[i]);
1271 : 0 : stats = &dev->data->queues[queue_id].queue_stats;
1272 : :
1273 : 0 : fprintf(f, " Enqueue Count %" PRIu64 " Warning %" PRIu64 " Error %" PRIu64 "\n",
1274 : : stats->enqueued_count, stats->enqueue_warn_count,
1275 : : stats->enqueue_err_count);
1276 : 0 : fprintf(f, " Dequeue Count %" PRIu64 " Warning %" PRIu64 " Error %" PRIu64 "\n",
1277 : : stats->dequeued_count, stats->dequeue_warn_count,
1278 : : stats->dequeue_err_count);
1279 : :
1280 : 0 : return dev->dev_ops->queue_ops_dump(dev, queue_id, f);
1281 : : }
1282 : :
1283 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bbdev_ops_param_string, 24.11)
1284 : : char *
1285 : 0 : rte_bbdev_ops_param_string(void *op, enum rte_bbdev_op_type op_type, char *str, uint32_t len)
1286 : : {
1287 : : static char partial[1024];
1288 : : struct rte_bbdev_dec_op *op_dec;
1289 : : struct rte_bbdev_enc_op *op_enc;
1290 : : struct rte_bbdev_fft_op *op_fft;
1291 : : struct rte_bbdev_mldts_op *op_mldts;
1292 : :
1293 : : rte_iova_t add0 = 0, add1 = 0, add2 = 0, add3 = 0, add4 = 0;
1294 : :
1295 [ # # ]: 0 : if (op == NULL) {
1296 : 0 : snprintf(str, len, "Invalid Operation pointer\n");
1297 : 0 : return str;
1298 : : }
1299 : :
1300 : : if (op_type == RTE_BBDEV_OP_LDPC_DEC) {
1301 : : op_dec = op;
1302 [ # # ]: 0 : if (op_dec->ldpc_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
1303 : 0 : snprintf(partial, sizeof(partial), "C %d Cab %d Ea %d Eb %d r %d",
1304 : 0 : op_dec->ldpc_dec.tb_params.c,
1305 : 0 : op_dec->ldpc_dec.tb_params.cab,
1306 : : op_dec->ldpc_dec.tb_params.ea,
1307 : : op_dec->ldpc_dec.tb_params.eb,
1308 : 0 : op_dec->ldpc_dec.tb_params.r);
1309 : : else
1310 : 0 : snprintf(partial, sizeof(partial), "E %d", op_dec->ldpc_dec.cb_params.e);
1311 [ # # ]: 0 : if (op_dec->ldpc_dec.input.data != NULL)
1312 : 0 : add0 = rte_pktmbuf_iova_offset(op_dec->ldpc_dec.input.data, 0);
1313 [ # # ]: 0 : if (op_dec->ldpc_dec.hard_output.data != NULL)
1314 : 0 : add1 = rte_pktmbuf_iova_offset(op_dec->ldpc_dec.hard_output.data, 0);
1315 [ # # ]: 0 : if (op_dec->ldpc_dec.soft_output.data != NULL)
1316 : 0 : add2 = rte_pktmbuf_iova_offset(op_dec->ldpc_dec.soft_output.data, 0);
1317 [ # # ]: 0 : if (op_dec->ldpc_dec.harq_combined_input.data != NULL)
1318 : 0 : add3 = rte_pktmbuf_iova_offset(op_dec->ldpc_dec.harq_combined_input.data,
1319 : : 0);
1320 [ # # ]: 0 : if (op_dec->ldpc_dec.harq_combined_output.data != NULL)
1321 : 0 : add4 = rte_pktmbuf_iova_offset(op_dec->ldpc_dec.harq_combined_output.data,
1322 : : 0);
1323 : 0 : snprintf(str, len, "op %x st %x BG %d Zc %d Ncb %d qm %d F %d Rv %d It %d It %d "
1324 : : "HARQin %d in %" PRIx64 " ho %" PRIx64 " so %" PRIx64 " hi %" PRIx64 " "
1325 : : "ho %" PRIx64 " %s\n",
1326 : : op_dec->ldpc_dec.op_flags, op_dec->status,
1327 : 0 : op_dec->ldpc_dec.basegraph, op_dec->ldpc_dec.z_c,
1328 : 0 : op_dec->ldpc_dec.n_cb, op_dec->ldpc_dec.q_m,
1329 : 0 : op_dec->ldpc_dec.n_filler, op_dec->ldpc_dec.rv_index,
1330 : 0 : op_dec->ldpc_dec.iter_max, op_dec->ldpc_dec.iter_count,
1331 : : op_dec->ldpc_dec.harq_combined_input.length,
1332 : : add0, add1, add2, add3, add4, partial);
1333 : : } else if (op_type == RTE_BBDEV_OP_TURBO_DEC) {
1334 : : op_dec = op;
1335 [ # # ]: 0 : if (op_dec->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
1336 : 0 : snprintf(partial, sizeof(partial), "C %d Cab %d Ea %d Eb %d r %d K %d",
1337 : 0 : op_dec->turbo_dec.tb_params.c,
1338 : 0 : op_dec->turbo_dec.tb_params.cab,
1339 : : op_dec->turbo_dec.tb_params.ea,
1340 : : op_dec->turbo_dec.tb_params.eb,
1341 : 0 : op_dec->turbo_dec.tb_params.r,
1342 : 0 : op_dec->turbo_dec.tb_params.k_neg);
1343 : : else
1344 : 0 : snprintf(partial, sizeof(partial), "E %d K %d",
1345 : : op_dec->turbo_dec.cb_params.e,
1346 : 0 : op_dec->turbo_dec.cb_params.k);
1347 [ # # ]: 0 : if (op_dec->turbo_dec.input.data != NULL)
1348 : 0 : add0 = rte_pktmbuf_iova_offset(op_dec->turbo_dec.input.data, 0);
1349 [ # # ]: 0 : if (op_dec->turbo_dec.hard_output.data != NULL)
1350 : 0 : add1 = rte_pktmbuf_iova_offset(op_dec->turbo_dec.hard_output.data, 0);
1351 [ # # ]: 0 : if (op_dec->turbo_dec.soft_output.data != NULL)
1352 : 0 : add2 = rte_pktmbuf_iova_offset(op_dec->turbo_dec.soft_output.data, 0);
1353 : 0 : snprintf(str, len, "op %x st %x CBM %d Iter %d map %d Rv %d ext %d "
1354 : : "in %" PRIx64 " ho %" PRIx64 " so %" PRIx64 " %s\n",
1355 : : op_dec->turbo_dec.op_flags, op_dec->status,
1356 : 0 : op_dec->turbo_dec.code_block_mode,
1357 : 0 : op_dec->turbo_dec.iter_max, op_dec->turbo_dec.num_maps,
1358 : 0 : op_dec->turbo_dec.rv_index, op_dec->turbo_dec.ext_scale,
1359 : : add0, add1, add2, partial);
1360 : : } else if (op_type == RTE_BBDEV_OP_LDPC_ENC) {
1361 : : op_enc = op;
1362 [ # # ]: 0 : if (op_enc->ldpc_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
1363 : 0 : snprintf(partial, sizeof(partial), "C %d Cab %d Ea %d Eb %d r %d",
1364 : 0 : op_enc->ldpc_enc.tb_params.c,
1365 : 0 : op_enc->ldpc_enc.tb_params.cab,
1366 : : op_enc->ldpc_enc.tb_params.ea,
1367 : : op_enc->ldpc_enc.tb_params.eb,
1368 : 0 : op_enc->ldpc_enc.tb_params.r);
1369 : : else
1370 : 0 : snprintf(partial, sizeof(partial), "E %d",
1371 : : op_enc->ldpc_enc.cb_params.e);
1372 [ # # ]: 0 : if (op_enc->ldpc_enc.input.data != NULL)
1373 : 0 : add0 = rte_pktmbuf_iova_offset(op_enc->ldpc_enc.input.data, 0);
1374 [ # # ]: 0 : if (op_enc->ldpc_enc.output.data != NULL)
1375 : 0 : add1 = rte_pktmbuf_iova_offset(op_enc->ldpc_enc.output.data, 0);
1376 : 0 : snprintf(str, len, "op %x st %x BG %d Zc %d Ncb %d q_m %d F %d Rv %d "
1377 : : "in %" PRIx64 " out %" PRIx64 " %s\n",
1378 : : op_enc->ldpc_enc.op_flags, op_enc->status,
1379 : 0 : op_enc->ldpc_enc.basegraph, op_enc->ldpc_enc.z_c,
1380 : 0 : op_enc->ldpc_enc.n_cb, op_enc->ldpc_enc.q_m,
1381 : 0 : op_enc->ldpc_enc.n_filler, op_enc->ldpc_enc.rv_index,
1382 : : add0, add1, partial);
1383 : : } else if (op_type == RTE_BBDEV_OP_TURBO_ENC) {
1384 : : op_enc = op;
1385 [ # # ]: 0 : if (op_enc->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
1386 : 0 : snprintf(partial, sizeof(partial),
1387 : : "C %d Cab %d Ea %d Eb %d r %d K %d Ncb %d",
1388 : 0 : op_enc->turbo_enc.tb_params.c,
1389 : 0 : op_enc->turbo_enc.tb_params.cab,
1390 : : op_enc->turbo_enc.tb_params.ea,
1391 : : op_enc->turbo_enc.tb_params.eb,
1392 : 0 : op_enc->turbo_enc.tb_params.r,
1393 : 0 : op_enc->turbo_enc.tb_params.k_neg,
1394 : 0 : op_enc->turbo_enc.tb_params.ncb_neg);
1395 : : else
1396 : 0 : snprintf(partial, sizeof(partial), "E %d K %d",
1397 : : op_enc->turbo_enc.cb_params.e,
1398 : 0 : op_enc->turbo_enc.cb_params.k);
1399 [ # # ]: 0 : if (op_enc->turbo_enc.input.data != NULL)
1400 : 0 : add0 = rte_pktmbuf_iova_offset(op_enc->turbo_enc.input.data, 0);
1401 [ # # ]: 0 : if (op_enc->turbo_enc.output.data != NULL)
1402 : 0 : add1 = rte_pktmbuf_iova_offset(op_enc->turbo_enc.output.data, 0);
1403 : 0 : snprintf(str, len, "op %x st %x CBM %d Rv %d In %" PRIx64 " Out %" PRIx64 " %s\n",
1404 : : op_enc->turbo_enc.op_flags, op_enc->status,
1405 : 0 : op_enc->turbo_enc.code_block_mode, op_enc->turbo_enc.rv_index,
1406 : : add0, add1, partial);
1407 : : } else if (op_type == RTE_BBDEV_OP_FFT) {
1408 : : op_fft = op;
1409 [ # # ]: 0 : if (op_fft->fft.base_input.data != NULL)
1410 : 0 : add0 = rte_pktmbuf_iova_offset(op_fft->fft.base_input.data, 0);
1411 [ # # ]: 0 : if (op_fft->fft.base_output.data != NULL)
1412 : 0 : add1 = rte_pktmbuf_iova_offset(op_fft->fft.base_output.data, 0);
1413 [ # # ]: 0 : if (op_fft->fft.dewindowing_input.data != NULL)
1414 : 0 : add2 = rte_pktmbuf_iova_offset(op_fft->fft.dewindowing_input.data, 0);
1415 [ # # ]: 0 : if (op_fft->fft.power_meas_output.data != NULL)
1416 : 0 : add3 = rte_pktmbuf_iova_offset(op_fft->fft.power_meas_output.data, 0);
1417 : 0 : snprintf(str, len, "op %x st %x in %d inl %d out %d outl %d cs %x ants %d "
1418 : : "idft %d dft %d cst %d ish %d dsh %d ncs %d pwsh %d fp16 %d fr %d "
1419 : : "outde %d in %" PRIx64 " out %" PRIx64 " dw %" PRIx64 " "
1420 : : "pm %" PRIx64 "\n",
1421 : : op_fft->fft.op_flags, op_fft->status,
1422 : 0 : op_fft->fft.input_sequence_size, op_fft->fft.input_leading_padding,
1423 : 0 : op_fft->fft.output_sequence_size,
1424 : 0 : op_fft->fft.output_leading_depadding,
1425 : 0 : op_fft->fft.cs_bitmap, op_fft->fft.num_antennas_log2,
1426 : 0 : op_fft->fft.idft_log2, op_fft->fft.dft_log2,
1427 : 0 : op_fft->fft.cs_time_adjustment,
1428 : 0 : op_fft->fft.idft_shift, op_fft->fft.dft_shift,
1429 : 0 : op_fft->fft.ncs_reciprocal, op_fft->fft.power_shift,
1430 : 0 : op_fft->fft.fp16_exp_adjust, op_fft->fft.freq_resample_mode,
1431 : 0 : op_fft->fft.output_depadded_size, add0, add1, add2, add3);
1432 : : } else if (op_type == RTE_BBDEV_OP_MLDTS) {
1433 : : op_mldts = op;
1434 [ # # ]: 0 : if (op_mldts->mldts.qhy_input.data != NULL)
1435 : 0 : add0 = rte_pktmbuf_iova_offset(op_mldts->mldts.qhy_input.data, 0);
1436 [ # # ]: 0 : if (op_mldts->mldts.r_input.data != NULL)
1437 : 0 : add1 = rte_pktmbuf_iova_offset(op_mldts->mldts.r_input.data, 0);
1438 [ # # ]: 0 : if (op_mldts->mldts.output.data != NULL)
1439 : 0 : add2 = rte_pktmbuf_iova_offset(op_mldts->mldts.output.data, 0);
1440 : 0 : snprintf(str, len,
1441 : : "op %x st %x rbs %d lay %d rrep %d crep%d qm %d %d %d %d "
1442 : : "qhy %" PRIx64 " r %" PRIx64 " out %" PRIx64 "\n",
1443 : : op_mldts->mldts.op_flags, op_mldts->status,
1444 : 0 : op_mldts->mldts.num_rbs, op_mldts->mldts.num_layers,
1445 : 0 : op_mldts->mldts.r_rep, op_mldts->mldts.c_rep,
1446 : 0 : op_mldts->mldts.q_m[0], op_mldts->mldts.q_m[1],
1447 : 0 : op_mldts->mldts.q_m[2], op_mldts->mldts.q_m[3],
1448 : : add0, add1, add2);
1449 : :
1450 : : } else {
1451 : 0 : snprintf(str, len, "Invalid Operation type %d\n", op_type);
1452 : : }
1453 : :
1454 : : return str;
1455 : : }
|