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 [ - + ]: 302 : 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 : 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 : : int ret = 0;
455 : : struct rte_bbdev_driver_info dev_info;
456 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
457 : : const struct rte_bbdev_op_cap *p;
458 : : struct rte_bbdev_queue_conf *stored_conf;
459 : : const char *op_type_str;
460 : : unsigned int max_priority;
461 : :
462 [ # # # # : 0 : rte_bbdev_trace_queue_configure(dev_id, queue_id,
# # ]
463 : 0 : conf != NULL ? rte_bbdev_op_type_str(conf->op_type) : NULL,
464 : 0 : conf != NULL ? conf->priority : 0);
465 : :
466 [ # # ]: 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
467 : :
468 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
469 : :
470 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
471 : :
472 [ # # # # ]: 0 : if (dev->data->queues[queue_id].started || dev->data->started) {
473 : 0 : rte_bbdev_log(ERR,
474 : : "Queue %u of device %u cannot be configured when started",
475 : : queue_id, dev_id);
476 : 0 : return -EBUSY;
477 : : }
478 : :
479 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_release, dev_id);
480 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_setup, dev_id);
481 : :
482 : : /* Get device driver information to verify config is valid */
483 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->info_get, dev_id);
484 : : memset(&dev_info, 0, sizeof(dev_info));
485 : 0 : dev->dev_ops->info_get(dev, &dev_info);
486 : :
487 : : /* Check configuration is valid */
488 [ # # ]: 0 : if (conf != NULL) {
489 [ # # ]: 0 : if ((conf->op_type == RTE_BBDEV_OP_NONE) &&
490 [ # # ]: 0 : (dev_info.capabilities[0].type ==
491 : : RTE_BBDEV_OP_NONE)) {
492 : : ret = 1;
493 : : } else {
494 : 0 : for (p = dev_info.capabilities;
495 [ # # ]: 0 : p->type != RTE_BBDEV_OP_NONE; p++) {
496 [ # # ]: 0 : if (conf->op_type == p->type) {
497 : : ret = 1;
498 : : break;
499 : : }
500 : : }
501 : : }
502 [ # # ]: 0 : if (ret == 0) {
503 : 0 : rte_bbdev_log(ERR, "Invalid operation type");
504 : 0 : return -EINVAL;
505 : : }
506 [ # # ]: 0 : if (conf->queue_size > dev_info.queue_size_lim) {
507 : 0 : rte_bbdev_log(ERR,
508 : : "Size (%u) of queue %u of device %u must be: <= %u",
509 : : conf->queue_size, queue_id, dev_id,
510 : : dev_info.queue_size_lim);
511 : 0 : return -EINVAL;
512 : : }
513 : : if (!rte_is_power_of_2(conf->queue_size)) {
514 : 0 : rte_bbdev_log(ERR,
515 : : "Size (%u) of queue %u of device %u must be a power of 2",
516 : : conf->queue_size, queue_id, dev_id);
517 : 0 : return -EINVAL;
518 : : }
519 [ # # ]: 0 : if ((uint8_t)conf->op_type >= RTE_BBDEV_OP_TYPE_SIZE_MAX) {
520 : 0 : rte_bbdev_log(ERR,
521 : : "Invalid operation type (%u) ", conf->op_type);
522 : 0 : return -EINVAL;
523 : : }
524 : 0 : max_priority = dev_info.queue_priority[conf->op_type];
525 [ # # ]: 0 : if (conf->priority > max_priority) {
526 : 0 : rte_bbdev_log(ERR,
527 : : "Priority (%u) of queue %u of bbdev %u must be <= %u",
528 : : conf->priority, queue_id, dev_id, max_priority);
529 : 0 : return -EINVAL;
530 : : }
531 : : }
532 : :
533 : : /* Release existing queue (in case of queue reconfiguration) */
534 [ # # ]: 0 : if (dev->data->queues[queue_id].queue_private != NULL) {
535 : 0 : ret = dev->dev_ops->queue_release(dev, queue_id);
536 [ # # ]: 0 : if (ret < 0) {
537 : 0 : rte_bbdev_log(ERR, "Device %u queue %u release failed",
538 : : dev_id, queue_id);
539 : 0 : return ret;
540 : : }
541 : : }
542 : :
543 : : /* Get driver to setup the queue */
544 [ # # ]: 0 : ret = dev->dev_ops->queue_setup(dev, queue_id, (conf != NULL) ?
545 : : conf : &dev_info.default_queue_conf);
546 [ # # ]: 0 : if (ret < 0) {
547 : : /* This may happen when trying different priority levels */
548 : 0 : rte_bbdev_log(INFO,
549 : : "Device %u queue %u setup failed",
550 : : dev_id, queue_id);
551 : 0 : return ret;
552 : : }
553 : :
554 : : /* Store configuration */
555 : 0 : stored_conf = &dev->data->queues[queue_id].conf;
556 : : memcpy(stored_conf,
557 : : (conf != NULL) ? conf : &dev_info.default_queue_conf,
558 : : sizeof(*stored_conf));
559 : :
560 : 0 : op_type_str = rte_bbdev_op_type_str(stored_conf->op_type);
561 [ # # ]: 0 : if (op_type_str == NULL)
562 : : return -EINVAL;
563 : :
564 : 0 : rte_bbdev_log_debug("Configured dev%uq%u (size=%u, type=%s, prio=%u)",
565 : : dev_id, queue_id, stored_conf->queue_size, op_type_str,
566 : : stored_conf->priority);
567 : :
568 : 0 : return 0;
569 : : }
570 : :
571 : : RTE_EXPORT_SYMBOL(rte_bbdev_start)
572 : : int
573 : 0 : rte_bbdev_start(uint16_t dev_id)
574 : : {
575 : : int i;
576 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
577 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
578 : :
579 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
580 : :
581 [ # # ]: 0 : rte_bbdev_trace_start(dev_id);
582 : :
583 [ # # ]: 0 : if (dev->data->started) {
584 : 0 : rte_bbdev_log_debug("Device %u is already started", dev_id);
585 : 0 : return 0;
586 : : }
587 : :
588 [ # # ]: 0 : if (dev->dev_ops->start) {
589 : 0 : int ret = dev->dev_ops->start(dev);
590 [ # # ]: 0 : if (ret < 0) {
591 : 0 : rte_bbdev_log(ERR, "Device %u start failed", dev_id);
592 : 0 : return ret;
593 : : }
594 : : }
595 : :
596 : : /* Store new state */
597 [ # # ]: 0 : for (i = 0; i < dev->data->num_queues; i++)
598 [ # # ]: 0 : if (!dev->data->queues[i].conf.deferred_start)
599 : 0 : dev->data->queues[i].started = true;
600 : 0 : dev->data->started = true;
601 : :
602 : 0 : rte_bbdev_log_debug("Started device %u", dev_id);
603 : 0 : return 0;
604 : : }
605 : :
606 : : RTE_EXPORT_SYMBOL(rte_bbdev_stop)
607 : : int
608 : 0 : rte_bbdev_stop(uint16_t dev_id)
609 : : {
610 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
611 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
612 : :
613 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
614 : :
615 [ # # ]: 0 : rte_bbdev_trace_stop(dev_id);
616 : :
617 [ # # ]: 0 : if (!dev->data->started) {
618 : 0 : rte_bbdev_log_debug("Device %u is already stopped", dev_id);
619 : 0 : return 0;
620 : : }
621 : :
622 [ # # ]: 0 : if (dev->dev_ops->stop)
623 : 0 : dev->dev_ops->stop(dev);
624 : 0 : dev->data->started = false;
625 : :
626 : 0 : rte_bbdev_log_debug("Stopped device %u", dev_id);
627 : 0 : return 0;
628 : : }
629 : :
630 : : RTE_EXPORT_SYMBOL(rte_bbdev_close)
631 : : int
632 : 0 : rte_bbdev_close(uint16_t dev_id)
633 : : {
634 : : int ret;
635 : : uint16_t i;
636 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
637 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
638 : :
639 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
640 : :
641 [ # # ]: 0 : rte_bbdev_trace_close(dev_id);
642 : :
643 [ # # ]: 0 : if (dev->data->started) {
644 : 0 : ret = rte_bbdev_stop(dev_id);
645 [ # # ]: 0 : if (ret < 0) {
646 : 0 : rte_bbdev_log(ERR, "Device %u stop failed", dev_id);
647 : 0 : return ret;
648 : : }
649 : : }
650 : :
651 : : /* Free memory used by queues */
652 [ # # ]: 0 : for (i = 0; i < dev->data->num_queues; i++) {
653 : 0 : ret = dev->dev_ops->queue_release(dev, i);
654 [ # # ]: 0 : if (ret < 0) {
655 : 0 : rte_bbdev_log(ERR, "Device %u queue %u release failed",
656 : : dev_id, i);
657 : 0 : return ret;
658 : : }
659 : : }
660 : 0 : rte_free(dev->data->queues);
661 : :
662 [ # # ]: 0 : if (dev->dev_ops->close) {
663 : 0 : ret = dev->dev_ops->close(dev);
664 [ # # ]: 0 : if (ret < 0) {
665 : 0 : rte_bbdev_log(ERR, "Device %u close failed", dev_id);
666 : 0 : return ret;
667 : : }
668 : : }
669 : :
670 : : /* Clear configuration */
671 : 0 : dev->data->queues = NULL;
672 : 0 : dev->data->num_queues = 0;
673 : :
674 : 0 : rte_bbdev_log_debug("Closed device %u", dev_id);
675 : 0 : return 0;
676 : : }
677 : :
678 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_start)
679 : : int
680 : 0 : rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id)
681 : : {
682 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
683 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
684 : :
685 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
686 : :
687 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
688 : :
689 [ # # ]: 0 : rte_bbdev_trace_queue_start(dev_id, queue_id);
690 : :
691 [ # # ]: 0 : if (dev->data->queues[queue_id].started) {
692 : 0 : rte_bbdev_log_debug("Queue %u of device %u already started",
693 : : queue_id, dev_id);
694 : 0 : return 0;
695 : : }
696 : :
697 [ # # ]: 0 : if (dev->dev_ops->queue_start) {
698 : 0 : int ret = dev->dev_ops->queue_start(dev, queue_id);
699 [ # # ]: 0 : if (ret < 0) {
700 : 0 : rte_bbdev_log(ERR, "Device %u queue %u start failed",
701 : : dev_id, queue_id);
702 : 0 : return ret;
703 : : }
704 : : }
705 : 0 : dev->data->queues[queue_id].started = true;
706 : :
707 : 0 : rte_bbdev_log_debug("Started queue %u of device %u", queue_id, dev_id);
708 : 0 : return 0;
709 : : }
710 : :
711 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_stop)
712 : : int
713 : 0 : rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
714 : : {
715 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
716 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
717 : :
718 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
719 : :
720 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
721 : :
722 [ # # ]: 0 : rte_bbdev_trace_queue_stop(dev_id, queue_id);
723 : :
724 [ # # ]: 0 : if (!dev->data->queues[queue_id].started) {
725 : 0 : rte_bbdev_log_debug("Queue %u of device %u already stopped",
726 : : queue_id, dev_id);
727 : 0 : return 0;
728 : : }
729 : :
730 [ # # ]: 0 : if (dev->dev_ops->queue_stop) {
731 : 0 : int ret = dev->dev_ops->queue_stop(dev, queue_id);
732 [ # # ]: 0 : if (ret < 0) {
733 : 0 : rte_bbdev_log(ERR, "Device %u queue %u stop failed",
734 : : dev_id, queue_id);
735 : 0 : return ret;
736 : : }
737 : : }
738 : 0 : dev->data->queues[queue_id].started = false;
739 : :
740 : 0 : rte_bbdev_log_debug("Stopped queue %u of device %u", queue_id, dev_id);
741 : 0 : return 0;
742 : : }
743 : :
744 : : /* Get device statistics */
745 : : static void
746 : 0 : get_stats_from_queues(struct rte_bbdev *dev, struct rte_bbdev_stats *stats)
747 : : {
748 : : unsigned int q_id;
749 [ # # ]: 0 : for (q_id = 0; q_id < dev->data->num_queues; q_id++) {
750 : : struct rte_bbdev_stats *q_stats =
751 : 0 : &dev->data->queues[q_id].queue_stats;
752 : :
753 : 0 : stats->enqueued_count += q_stats->enqueued_count;
754 : 0 : stats->dequeued_count += q_stats->dequeued_count;
755 : 0 : stats->enqueue_err_count += q_stats->enqueue_err_count;
756 : 0 : stats->dequeue_err_count += q_stats->dequeue_err_count;
757 : 0 : stats->enqueue_warn_count += q_stats->enqueue_warn_count;
758 : 0 : stats->dequeue_warn_count += q_stats->dequeue_warn_count;
759 : : }
760 : 0 : rte_bbdev_log_debug("Got stats on %u", dev->data->dev_id);
761 : 0 : }
762 : :
763 : : static void
764 : 0 : reset_stats_in_queues(struct rte_bbdev *dev)
765 : : {
766 : : unsigned int q_id;
767 [ # # ]: 0 : for (q_id = 0; q_id < dev->data->num_queues; q_id++) {
768 : 0 : struct rte_bbdev_stats *q_stats =
769 : 0 : &dev->data->queues[q_id].queue_stats;
770 : :
771 : : memset(q_stats, 0, sizeof(*q_stats));
772 : : }
773 : 0 : rte_bbdev_log_debug("Reset stats on %u", dev->data->dev_id);
774 : 0 : }
775 : :
776 : : RTE_EXPORT_SYMBOL(rte_bbdev_stats_get)
777 : : int
778 : 0 : rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats)
779 : : {
780 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
781 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
782 : :
783 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
784 : :
785 [ # # ]: 0 : if (stats == NULL) {
786 : 0 : rte_bbdev_log(ERR, "NULL stats structure");
787 : 0 : return -EINVAL;
788 : : }
789 : :
790 : : memset(stats, 0, sizeof(*stats));
791 [ # # ]: 0 : if (dev->dev_ops->stats_get != NULL)
792 : 0 : dev->dev_ops->stats_get(dev, stats);
793 : : else
794 : 0 : get_stats_from_queues(dev, stats);
795 : :
796 : 0 : rte_bbdev_log_debug("Retrieved stats of device %u", dev_id);
797 : 0 : return 0;
798 : : }
799 : :
800 : : RTE_EXPORT_SYMBOL(rte_bbdev_stats_reset)
801 : : int
802 : 0 : rte_bbdev_stats_reset(uint16_t dev_id)
803 : : {
804 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
805 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
806 : :
807 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
808 : :
809 [ # # ]: 0 : if (dev->dev_ops->stats_reset != NULL)
810 : 0 : dev->dev_ops->stats_reset(dev);
811 : : else
812 : 0 : reset_stats_in_queues(dev);
813 : :
814 : 0 : rte_bbdev_log_debug("Reset stats of device %u", dev_id);
815 : 0 : return 0;
816 : : }
817 : :
818 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bbdev_queue_stats_get, 26.07)
819 : 0 : int rte_bbdev_queue_stats_get(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_stats *stats)
820 : : {
821 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
822 : :
823 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
824 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
825 : :
826 [ # # ]: 0 : if (stats == NULL) {
827 : 0 : rte_bbdev_log(ERR, "NULL stats structure");
828 : 0 : return -EINVAL;
829 : : }
830 : :
831 : 0 : *stats = dev->data->queues[queue_id].queue_stats;
832 : :
833 : 0 : rte_bbdev_log_debug("Retrieved stats for queue %u of device %u",
834 : : queue_id, dev_id);
835 : 0 : return 0;
836 : : }
837 : :
838 : : RTE_EXPORT_SYMBOL(rte_bbdev_info_get)
839 : : int
840 : 0 : rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info)
841 : : {
842 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
843 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
844 : :
845 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->info_get, dev_id);
846 : :
847 [ # # ]: 0 : if (dev_info == NULL) {
848 : 0 : rte_bbdev_log(ERR, "NULL dev info structure");
849 : 0 : return -EINVAL;
850 : : }
851 : :
852 : : /* Copy data maintained by device interface layer */
853 : : memset(dev_info, 0, sizeof(*dev_info));
854 : 0 : dev_info->dev_name = dev->data->name;
855 : 0 : dev_info->num_queues = dev->data->num_queues;
856 : 0 : dev_info->device = dev->device;
857 : 0 : dev_info->socket_id = dev->data->socket_id;
858 : 0 : dev_info->started = dev->data->started;
859 : :
860 : : /* Copy data maintained by device driver layer */
861 : 0 : dev->dev_ops->info_get(dev, &dev_info->drv);
862 : :
863 : 0 : rte_bbdev_log_debug("Retrieved info of device %u", dev_id);
864 : 0 : return 0;
865 : : }
866 : :
867 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_info_get)
868 : : int
869 : 0 : rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
870 : : struct rte_bbdev_queue_info *queue_info)
871 : : {
872 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
873 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
874 : :
875 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
876 : :
877 [ # # ]: 0 : if (queue_info == NULL) {
878 : 0 : rte_bbdev_log(ERR, "NULL queue info structure");
879 : 0 : return -EINVAL;
880 : : }
881 : :
882 : : /* Copy data to output */
883 : : memset(queue_info, 0, sizeof(*queue_info));
884 : 0 : queue_info->conf = dev->data->queues[queue_id].conf;
885 : 0 : queue_info->started = dev->data->queues[queue_id].started;
886 : :
887 : 0 : rte_bbdev_log_debug("Retrieved info of queue %u of device %u",
888 : : queue_id, dev_id);
889 : 0 : return 0;
890 : : }
891 : :
892 : : /* Calculate size needed to store bbdev_op, depending on type */
893 : : static unsigned int
894 : : get_bbdev_op_size(enum rte_bbdev_op_type type)
895 : : {
896 : : unsigned int result = 0;
897 : : switch (type) {
898 : : case RTE_BBDEV_OP_NONE:
899 : : result = RTE_MAX(sizeof(struct rte_bbdev_dec_op),
900 : : sizeof(struct rte_bbdev_enc_op));
901 : : break;
902 : : case RTE_BBDEV_OP_TURBO_DEC:
903 : : result = sizeof(struct rte_bbdev_dec_op);
904 : : break;
905 : : case RTE_BBDEV_OP_TURBO_ENC:
906 : : result = sizeof(struct rte_bbdev_enc_op);
907 : : break;
908 : : case RTE_BBDEV_OP_LDPC_DEC:
909 : : result = sizeof(struct rte_bbdev_dec_op);
910 : : break;
911 : : case RTE_BBDEV_OP_LDPC_ENC:
912 : : result = sizeof(struct rte_bbdev_enc_op);
913 : : break;
914 : : case RTE_BBDEV_OP_FFT:
915 : : result = sizeof(struct rte_bbdev_fft_op);
916 : : break;
917 : : case RTE_BBDEV_OP_MLDTS:
918 : : result = sizeof(struct rte_bbdev_mldts_op);
919 : : break;
920 : : default:
921 : : break;
922 : : }
923 : :
924 : : return result;
925 : : }
926 : :
927 : : /* Initialise a bbdev_op structure */
928 : : static void
929 : 0 : bbdev_op_init(struct rte_mempool *mempool, void *arg, void *element,
930 : : __rte_unused unsigned int n)
931 : : {
932 : 0 : enum rte_bbdev_op_type type = *(enum rte_bbdev_op_type *)arg;
933 : :
934 [ # # ]: 0 : if (type == RTE_BBDEV_OP_TURBO_DEC || type == RTE_BBDEV_OP_LDPC_DEC) {
935 : : struct rte_bbdev_dec_op *op = element;
936 : 0 : memset(op, 0, mempool->elt_size);
937 : 0 : op->mempool = mempool;
938 : 0 : } else if (type == RTE_BBDEV_OP_TURBO_ENC ||
939 [ # # ]: 0 : type == RTE_BBDEV_OP_LDPC_ENC) {
940 : : struct rte_bbdev_enc_op *op = element;
941 : 0 : memset(op, 0, mempool->elt_size);
942 : 0 : op->mempool = mempool;
943 [ # # ]: 0 : } else if (type == RTE_BBDEV_OP_FFT) {
944 : : struct rte_bbdev_fft_op *op = element;
945 : 0 : memset(op, 0, mempool->elt_size);
946 : 0 : op->mempool = mempool;
947 [ # # ]: 0 : } else if (type == RTE_BBDEV_OP_MLDTS) {
948 : : struct rte_bbdev_mldts_op *op = element;
949 : 0 : memset(op, 0, mempool->elt_size);
950 : 0 : op->mempool = mempool;
951 : : }
952 : 0 : }
953 : :
954 : : RTE_EXPORT_SYMBOL(rte_bbdev_op_pool_create)
955 : : struct rte_mempool *
956 : 0 : rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
957 : : unsigned int num_elements, unsigned int cache_size,
958 : : int socket_id)
959 : : {
960 : : struct rte_bbdev_op_pool_private *priv;
961 : : struct rte_mempool *mp;
962 : : const char *op_type_str;
963 : :
964 [ # # ]: 0 : if (name == NULL) {
965 : 0 : rte_bbdev_log(ERR, "NULL name for op pool");
966 : 0 : return NULL;
967 : : }
968 : :
969 [ # # ]: 0 : if (type >= BBDEV_OP_TYPE_COUNT) {
970 : 0 : rte_bbdev_log(ERR,
971 : : "Invalid op type (%u), should be less than %u",
972 : : type, BBDEV_OP_TYPE_COUNT);
973 : 0 : return NULL;
974 : : }
975 : :
976 : 0 : mp = rte_mempool_create(name, num_elements, get_bbdev_op_size(type),
977 : : cache_size, sizeof(struct rte_bbdev_op_pool_private),
978 : : NULL, NULL, bbdev_op_init, &type, socket_id, 0);
979 [ # # ]: 0 : if (mp == NULL) {
980 [ # # ]: 0 : rte_bbdev_log(ERR,
981 : : "Failed to create op pool %s (num ops=%u, op size=%u) with error: %s",
982 : : name, num_elements, get_bbdev_op_size(type),
983 : : rte_strerror(rte_errno));
984 : 0 : return NULL;
985 : : }
986 : :
987 : 0 : op_type_str = rte_bbdev_op_type_str(type);
988 [ # # ]: 0 : if (op_type_str == NULL)
989 : : return NULL;
990 : :
991 [ # # ]: 0 : rte_bbdev_log_debug(
992 : : "Op pool %s created for %u ops (type=%s, cache=%u, socket=%u, size=%u)",
993 : : name, num_elements, op_type_str, cache_size, socket_id,
994 : : get_bbdev_op_size(type));
995 : :
996 : : priv = (struct rte_bbdev_op_pool_private *)rte_mempool_get_priv(mp);
997 : 0 : priv->type = type;
998 : :
999 : 0 : return mp;
1000 : : }
1001 : :
1002 : : RTE_EXPORT_SYMBOL(rte_bbdev_callback_register)
1003 : : int
1004 : 0 : rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
1005 : : rte_bbdev_cb_fn cb_fn, void *cb_arg)
1006 : : {
1007 : : struct rte_bbdev_callback *user_cb;
1008 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
1009 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
1010 : :
1011 [ # # ]: 0 : if (event >= RTE_BBDEV_EVENT_MAX) {
1012 : 0 : rte_bbdev_log(ERR,
1013 : : "Invalid event type (%u), should be less than %u",
1014 : : event, RTE_BBDEV_EVENT_MAX);
1015 : 0 : return -EINVAL;
1016 : : }
1017 : :
1018 [ # # ]: 0 : if (cb_fn == NULL) {
1019 : 0 : rte_bbdev_log(ERR, "NULL callback function");
1020 : 0 : return -EINVAL;
1021 : : }
1022 : :
1023 : : rte_spinlock_lock(&rte_bbdev_cb_lock);
1024 : :
1025 [ # # ]: 0 : TAILQ_FOREACH(user_cb, &(dev->list_cbs), next) {
1026 [ # # ]: 0 : if (user_cb->cb_fn == cb_fn &&
1027 [ # # ]: 0 : user_cb->cb_arg == cb_arg &&
1028 [ # # ]: 0 : user_cb->event == event)
1029 : : break;
1030 : : }
1031 : :
1032 : : /* create a new callback. */
1033 [ # # ]: 0 : if (user_cb == NULL) {
1034 : 0 : user_cb = rte_zmalloc("INTR_USER_CALLBACK",
1035 : : sizeof(struct rte_bbdev_callback), 0);
1036 [ # # ]: 0 : if (user_cb != NULL) {
1037 : 0 : user_cb->cb_fn = cb_fn;
1038 : 0 : user_cb->cb_arg = cb_arg;
1039 : 0 : user_cb->event = event;
1040 : 0 : TAILQ_INSERT_TAIL(&(dev->list_cbs), user_cb, next);
1041 : : }
1042 : : }
1043 : :
1044 : : rte_spinlock_unlock(&rte_bbdev_cb_lock);
1045 [ # # ]: 0 : return (user_cb == NULL) ? -ENOMEM : 0;
1046 : : }
1047 : :
1048 : : RTE_EXPORT_SYMBOL(rte_bbdev_callback_unregister)
1049 : : int
1050 : 0 : rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
1051 : : rte_bbdev_cb_fn cb_fn, void *cb_arg)
1052 : : {
1053 : : int ret = 0;
1054 : : struct rte_bbdev_callback *cb, *next;
1055 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
1056 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
1057 : :
1058 [ # # ]: 0 : if (event >= RTE_BBDEV_EVENT_MAX) {
1059 : 0 : rte_bbdev_log(ERR,
1060 : : "Invalid event type (%u), should be less than %u",
1061 : : event, RTE_BBDEV_EVENT_MAX);
1062 : 0 : return -EINVAL;
1063 : : }
1064 : :
1065 [ # # ]: 0 : if (cb_fn == NULL) {
1066 : 0 : rte_bbdev_log(ERR,
1067 : : "NULL callback function cannot be unregistered");
1068 : 0 : return -EINVAL;
1069 : : }
1070 : :
1071 : : dev = &rte_bbdev_devices[dev_id];
1072 : : rte_spinlock_lock(&rte_bbdev_cb_lock);
1073 : :
1074 [ # # ]: 0 : for (cb = TAILQ_FIRST(&dev->list_cbs); cb != NULL; cb = next) {
1075 : :
1076 : 0 : next = TAILQ_NEXT(cb, next);
1077 : :
1078 [ # # # # : 0 : if (cb->cb_fn != cb_fn || cb->event != event ||
# # ]
1079 [ # # ]: 0 : (cb_arg != (void *)-1 && cb->cb_arg != cb_arg))
1080 : 0 : continue;
1081 : :
1082 : : /* If this callback is not executing right now, remove it. */
1083 [ # # ]: 0 : if (cb->active == 0) {
1084 [ # # ]: 0 : TAILQ_REMOVE(&(dev->list_cbs), cb, next);
1085 : 0 : rte_free(cb);
1086 : : } else
1087 : : ret = -EAGAIN;
1088 : : }
1089 : :
1090 : : rte_spinlock_unlock(&rte_bbdev_cb_lock);
1091 : 0 : return ret;
1092 : : }
1093 : :
1094 : : RTE_EXPORT_SYMBOL(rte_bbdev_pmd_callback_process)
1095 : : void
1096 : 0 : rte_bbdev_pmd_callback_process(struct rte_bbdev *dev,
1097 : : enum rte_bbdev_event_type event, void *ret_param)
1098 : : {
1099 : : struct rte_bbdev_callback *cb_lst;
1100 : : struct rte_bbdev_callback dev_cb;
1101 : :
1102 [ # # ]: 0 : if (dev == NULL) {
1103 : 0 : rte_bbdev_log(ERR, "NULL device");
1104 : 0 : return;
1105 : : }
1106 : :
1107 [ # # ]: 0 : if (dev->data == NULL) {
1108 : 0 : rte_bbdev_log(ERR, "NULL data structure");
1109 : 0 : return;
1110 : : }
1111 : :
1112 [ # # ]: 0 : if (event >= RTE_BBDEV_EVENT_MAX) {
1113 : 0 : rte_bbdev_log(ERR,
1114 : : "Invalid event type (%u), should be less than %u",
1115 : : event, RTE_BBDEV_EVENT_MAX);
1116 : 0 : return;
1117 : : }
1118 : :
1119 : : rte_spinlock_lock(&rte_bbdev_cb_lock);
1120 [ # # ]: 0 : TAILQ_FOREACH(cb_lst, &(dev->list_cbs), next) {
1121 [ # # # # ]: 0 : if (cb_lst->cb_fn == NULL || cb_lst->event != event)
1122 : 0 : continue;
1123 : 0 : dev_cb = *cb_lst;
1124 : 0 : cb_lst->active = 1;
1125 [ # # ]: 0 : if (ret_param != NULL)
1126 : : dev_cb.ret_param = ret_param;
1127 : :
1128 : : rte_spinlock_unlock(&rte_bbdev_cb_lock);
1129 : 0 : dev_cb.cb_fn(dev->data->dev_id, dev_cb.event,
1130 : : dev_cb.cb_arg, dev_cb.ret_param);
1131 : : rte_spinlock_lock(&rte_bbdev_cb_lock);
1132 : 0 : cb_lst->active = 0;
1133 : : }
1134 : : rte_spinlock_unlock(&rte_bbdev_cb_lock);
1135 : : }
1136 : :
1137 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_intr_enable)
1138 : : int
1139 : 0 : rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id)
1140 : : {
1141 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
1142 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
1143 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
1144 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
1145 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_intr_enable, dev_id);
1146 : 0 : return dev->dev_ops->queue_intr_enable(dev, queue_id);
1147 : : }
1148 : :
1149 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_intr_disable)
1150 : : int
1151 : 0 : rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id)
1152 : : {
1153 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
1154 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
1155 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
1156 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
1157 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_intr_disable, dev_id);
1158 : 0 : return dev->dev_ops->queue_intr_disable(dev, queue_id);
1159 : : }
1160 : :
1161 : : RTE_EXPORT_SYMBOL(rte_bbdev_queue_intr_ctl)
1162 : : int
1163 : 0 : rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
1164 : : void *data)
1165 : : {
1166 : : uint32_t vec;
1167 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
1168 : : struct rte_intr_handle *intr_handle;
1169 : : int ret;
1170 : :
1171 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
1172 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
1173 : :
1174 : 0 : intr_handle = dev->intr_handle;
1175 [ # # ]: 0 : if (intr_handle == NULL) {
1176 : 0 : rte_bbdev_log(ERR, "Device %u intr handle unset", dev_id);
1177 : 0 : return -ENOTSUP;
1178 : : }
1179 : :
1180 [ # # ]: 0 : if (queue_id >= RTE_MAX_RXTX_INTR_VEC_ID) {
1181 : 0 : rte_bbdev_log(ERR, "Device %u queue_id %u is too big",
1182 : : dev_id, queue_id);
1183 : 0 : return -ENOTSUP;
1184 : : }
1185 : :
1186 : 0 : vec = rte_intr_vec_list_index_get(intr_handle, queue_id);
1187 : 0 : ret = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
1188 [ # # ]: 0 : if (ret && (ret != -EEXIST)) {
1189 : 0 : rte_bbdev_log(ERR,
1190 : : "dev %u q %u int ctl error op %d epfd %d vec %u",
1191 : : dev_id, queue_id, op, epfd, vec);
1192 : 0 : return ret;
1193 : : }
1194 : :
1195 : : return 0;
1196 : : }
1197 : :
1198 : :
1199 : : RTE_EXPORT_SYMBOL(rte_bbdev_op_type_str)
1200 : : const char *
1201 : 0 : rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type)
1202 : : {
1203 : : static const char * const op_types[] = {
1204 : : "RTE_BBDEV_OP_NONE",
1205 : : "RTE_BBDEV_OP_TURBO_DEC",
1206 : : "RTE_BBDEV_OP_TURBO_ENC",
1207 : : "RTE_BBDEV_OP_LDPC_DEC",
1208 : : "RTE_BBDEV_OP_LDPC_ENC",
1209 : : "RTE_BBDEV_OP_FFT",
1210 : : "RTE_BBDEV_OP_MLDTS",
1211 : : };
1212 : :
1213 [ # # ]: 0 : if (op_type < BBDEV_OP_TYPE_COUNT)
1214 : 0 : return op_types[op_type];
1215 : :
1216 : 0 : rte_bbdev_log(ERR, "Invalid operation type");
1217 : 0 : return NULL;
1218 : : }
1219 : :
1220 : : RTE_EXPORT_SYMBOL(rte_bbdev_device_status_str)
1221 : : const char *
1222 : 0 : rte_bbdev_device_status_str(enum rte_bbdev_device_status status)
1223 : : {
1224 : : static const char * const dev_sta_string[] = {
1225 : : "RTE_BBDEV_DEV_NOSTATUS",
1226 : : "RTE_BBDEV_DEV_NOT_SUPPORTED",
1227 : : "RTE_BBDEV_DEV_RESET",
1228 : : "RTE_BBDEV_DEV_CONFIGURED",
1229 : : "RTE_BBDEV_DEV_ACTIVE",
1230 : : "RTE_BBDEV_DEV_FATAL_ERR",
1231 : : "RTE_BBDEV_DEV_RESTART_REQ",
1232 : : "RTE_BBDEV_DEV_RECONFIG_REQ",
1233 : : "RTE_BBDEV_DEV_CORRECT_ERR",
1234 : : };
1235 : :
1236 : : /* Cast from enum required for clang. */
1237 [ # # ]: 0 : if ((uint8_t)status < sizeof(dev_sta_string) / sizeof(char *))
1238 : 0 : return dev_sta_string[status];
1239 : :
1240 : 0 : rte_bbdev_log(ERR, "Invalid device status");
1241 : 0 : return NULL;
1242 : : }
1243 : :
1244 : : RTE_EXPORT_SYMBOL(rte_bbdev_enqueue_status_str)
1245 : : const char *
1246 : 0 : rte_bbdev_enqueue_status_str(enum rte_bbdev_enqueue_status status)
1247 : : {
1248 : : static const char * const enq_sta_string[] = {
1249 : : "RTE_BBDEV_ENQ_STATUS_NONE",
1250 : : "RTE_BBDEV_ENQ_STATUS_QUEUE_FULL",
1251 : : "RTE_BBDEV_ENQ_STATUS_RING_FULL",
1252 : : "RTE_BBDEV_ENQ_STATUS_INVALID_OP",
1253 : : };
1254 : :
1255 : : /* Cast from enum required for clang. */
1256 [ # # ]: 0 : if ((uint8_t)status < sizeof(enq_sta_string) / sizeof(char *))
1257 : 0 : return enq_sta_string[status];
1258 : :
1259 : 0 : rte_bbdev_log(ERR, "Invalid enqueue status");
1260 : 0 : return NULL;
1261 : : }
1262 : :
1263 : :
1264 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bbdev_queue_ops_dump, 24.11)
1265 : : int
1266 : 0 : rte_bbdev_queue_ops_dump(uint16_t dev_id, uint16_t queue_id, FILE *f)
1267 : : {
1268 : : struct rte_bbdev_queue_data *q_data;
1269 : : struct rte_bbdev_stats *stats;
1270 : : enum rte_bbdev_enqueue_status i;
1271 : 0 : struct rte_bbdev *dev = get_dev(dev_id);
1272 : :
1273 : 0 : VALID_DEV_OR_RET_ERR(dev, dev_id);
1274 [ # # ]: 0 : VALID_QUEUE_OR_RET_ERR(queue_id, dev);
1275 [ # # ]: 0 : VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
1276 [ # # ]: 0 : VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_ops_dump, dev_id);
1277 : :
1278 : 0 : q_data = &dev->data->queues[queue_id];
1279 : :
1280 [ # # ]: 0 : if (f == NULL)
1281 : : return -EINVAL;
1282 : :
1283 : 0 : fprintf(f, "Dump of operations on %s queue %d\n",
1284 : 0 : dev->data->name, queue_id);
1285 : 0 : fprintf(f, " Last Enqueue Status %s\n",
1286 : : rte_bbdev_enqueue_status_str(q_data->enqueue_status));
1287 [ # # ]: 0 : for (i = 0; i < RTE_BBDEV_ENQ_STATUS_SIZE_MAX; i++) {
1288 : 0 : const char *status_str = rte_bbdev_enqueue_status_str(i);
1289 [ # # ]: 0 : if (status_str == NULL)
1290 : 0 : continue;
1291 [ # # ]: 0 : if (q_data->queue_stats.enqueue_status_count[i] > 0)
1292 : : fprintf(f, " Enqueue Status Counters %s %" PRIu64 "\n",
1293 : : status_str,
1294 : : q_data->queue_stats.enqueue_status_count[i]);
1295 : : }
1296 : 0 : stats = &dev->data->queues[queue_id].queue_stats;
1297 : :
1298 : 0 : fprintf(f, " Enqueue Count %" PRIu64 " Warning %" PRIu64 " Error %" PRIu64 "\n",
1299 : : stats->enqueued_count, stats->enqueue_warn_count,
1300 : : stats->enqueue_err_count);
1301 : 0 : fprintf(f, " Dequeue Count %" PRIu64 " Warning %" PRIu64 " Error %" PRIu64 "\n",
1302 : : stats->dequeued_count, stats->dequeue_warn_count,
1303 : : stats->dequeue_err_count);
1304 : :
1305 : 0 : return dev->dev_ops->queue_ops_dump(dev, queue_id, f);
1306 : : }
1307 : :
1308 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bbdev_ops_trace, 25.03)
1309 : : void
1310 [ # # # # : 0 : rte_bbdev_ops_trace(void *op, enum rte_bbdev_op_type op_type)
# # # ]
1311 : : {
1312 : : struct rte_bbdev_dec_op *op_dec = op;
1313 : : struct rte_bbdev_enc_op *op_enc = op;
1314 : : struct rte_bbdev_fft_op *op_fft = op;
1315 : : struct rte_bbdev_mldts_op *op_mldts = op;
1316 : :
1317 : : if (op_type == RTE_BBDEV_OP_LDPC_DEC)
1318 : 0 : rte_bbdev_trace_op_ldpc_dec(op_dec->ldpc_dec);
1319 : : else if (op_type == RTE_BBDEV_OP_LDPC_ENC)
1320 : 0 : rte_bbdev_trace_op_ldpc_enc(op_enc->ldpc_enc);
1321 : : else if (op_type == RTE_BBDEV_OP_FFT)
1322 : 0 : rte_bbdev_trace_op_fft(op_fft->fft);
1323 : : else if (op_type == RTE_BBDEV_OP_MLDTS)
1324 : 0 : rte_bbdev_trace_op_mldts(op_mldts->mldts);
1325 : : else if (op_type == RTE_BBDEV_OP_TURBO_DEC)
1326 : 0 : rte_bbdev_trace_op_turbo_dec(op_dec->turbo_dec);
1327 : : else if (op_type == RTE_BBDEV_OP_TURBO_ENC)
1328 : 0 : rte_bbdev_trace_op_turbo_enc(op_enc->turbo_enc);
1329 : 0 : }
1330 : :
1331 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bbdev_ops_param_string, 24.11)
1332 : : char *
1333 : 0 : rte_bbdev_ops_param_string(void *op, enum rte_bbdev_op_type op_type, char *str, uint32_t len)
1334 : : {
1335 : : static char partial[1024];
1336 : : struct rte_bbdev_dec_op *op_dec;
1337 : : struct rte_bbdev_enc_op *op_enc;
1338 : : struct rte_bbdev_fft_op *op_fft;
1339 : : struct rte_bbdev_mldts_op *op_mldts;
1340 : :
1341 : : rte_iova_t add0 = 0, add1 = 0, add2 = 0, add3 = 0, add4 = 0;
1342 : :
1343 [ # # ]: 0 : if (op == NULL) {
1344 : 0 : snprintf(str, len, "Invalid Operation pointer\n");
1345 : 0 : return str;
1346 : : }
1347 : :
1348 : : if (op_type == RTE_BBDEV_OP_LDPC_DEC) {
1349 : : op_dec = op;
1350 [ # # ]: 0 : if (op_dec->ldpc_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
1351 : 0 : snprintf(partial, sizeof(partial), "C %d Cab %d Ea %d Eb %d r %d",
1352 : 0 : op_dec->ldpc_dec.tb_params.c,
1353 : 0 : op_dec->ldpc_dec.tb_params.cab,
1354 : : op_dec->ldpc_dec.tb_params.ea,
1355 : : op_dec->ldpc_dec.tb_params.eb,
1356 : 0 : op_dec->ldpc_dec.tb_params.r);
1357 : : else
1358 : 0 : snprintf(partial, sizeof(partial), "E %d", op_dec->ldpc_dec.cb_params.e);
1359 [ # # ]: 0 : if (op_dec->ldpc_dec.input.data != NULL)
1360 : 0 : add0 = rte_pktmbuf_iova_offset(op_dec->ldpc_dec.input.data, 0);
1361 [ # # ]: 0 : if (op_dec->ldpc_dec.hard_output.data != NULL)
1362 : 0 : add1 = rte_pktmbuf_iova_offset(op_dec->ldpc_dec.hard_output.data, 0);
1363 [ # # ]: 0 : if (op_dec->ldpc_dec.soft_output.data != NULL)
1364 : 0 : add2 = rte_pktmbuf_iova_offset(op_dec->ldpc_dec.soft_output.data, 0);
1365 [ # # ]: 0 : if (op_dec->ldpc_dec.harq_combined_input.data != NULL)
1366 : 0 : add3 = rte_pktmbuf_iova_offset(op_dec->ldpc_dec.harq_combined_input.data,
1367 : : 0);
1368 [ # # ]: 0 : if (op_dec->ldpc_dec.harq_combined_output.data != NULL)
1369 : 0 : add4 = rte_pktmbuf_iova_offset(op_dec->ldpc_dec.harq_combined_output.data,
1370 : : 0);
1371 : 0 : snprintf(str, len, "op %x st %x BG %d Zc %d Ncb %d qm %d F %d Rv %d It %d It %d "
1372 : : "HARQin %d in %" PRIx64 " ho %" PRIx64 " so %" PRIx64 " hi %" PRIx64 " "
1373 : : "ho %" PRIx64 " %s\n",
1374 : : op_dec->ldpc_dec.op_flags, op_dec->status,
1375 : 0 : op_dec->ldpc_dec.basegraph, op_dec->ldpc_dec.z_c,
1376 : 0 : op_dec->ldpc_dec.n_cb, op_dec->ldpc_dec.q_m,
1377 : 0 : op_dec->ldpc_dec.n_filler, op_dec->ldpc_dec.rv_index,
1378 : 0 : op_dec->ldpc_dec.iter_max, op_dec->ldpc_dec.iter_count,
1379 : : op_dec->ldpc_dec.harq_combined_input.length,
1380 : : add0, add1, add2, add3, add4, partial);
1381 : : } else if (op_type == RTE_BBDEV_OP_TURBO_DEC) {
1382 : : op_dec = op;
1383 [ # # ]: 0 : if (op_dec->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
1384 : 0 : snprintf(partial, sizeof(partial), "C %d Cab %d Ea %d Eb %d r %d K %d",
1385 : 0 : op_dec->turbo_dec.tb_params.c,
1386 : 0 : op_dec->turbo_dec.tb_params.cab,
1387 : : op_dec->turbo_dec.tb_params.ea,
1388 : : op_dec->turbo_dec.tb_params.eb,
1389 : 0 : op_dec->turbo_dec.tb_params.r,
1390 : 0 : op_dec->turbo_dec.tb_params.k_neg);
1391 : : else
1392 : 0 : snprintf(partial, sizeof(partial), "E %d K %d",
1393 : : op_dec->turbo_dec.cb_params.e,
1394 : 0 : op_dec->turbo_dec.cb_params.k);
1395 [ # # ]: 0 : if (op_dec->turbo_dec.input.data != NULL)
1396 : 0 : add0 = rte_pktmbuf_iova_offset(op_dec->turbo_dec.input.data, 0);
1397 [ # # ]: 0 : if (op_dec->turbo_dec.hard_output.data != NULL)
1398 : 0 : add1 = rte_pktmbuf_iova_offset(op_dec->turbo_dec.hard_output.data, 0);
1399 [ # # ]: 0 : if (op_dec->turbo_dec.soft_output.data != NULL)
1400 : 0 : add2 = rte_pktmbuf_iova_offset(op_dec->turbo_dec.soft_output.data, 0);
1401 : 0 : snprintf(str, len, "op %x st %x CBM %d Iter %d map %d Rv %d ext %d "
1402 : : "in %" PRIx64 " ho %" PRIx64 " so %" PRIx64 " %s\n",
1403 : : op_dec->turbo_dec.op_flags, op_dec->status,
1404 : 0 : op_dec->turbo_dec.code_block_mode,
1405 : 0 : op_dec->turbo_dec.iter_max, op_dec->turbo_dec.num_maps,
1406 : 0 : op_dec->turbo_dec.rv_index, op_dec->turbo_dec.ext_scale,
1407 : : add0, add1, add2, partial);
1408 : : } else if (op_type == RTE_BBDEV_OP_LDPC_ENC) {
1409 : : op_enc = op;
1410 [ # # ]: 0 : if (op_enc->ldpc_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
1411 : 0 : snprintf(partial, sizeof(partial), "C %d Cab %d Ea %d Eb %d r %d",
1412 : 0 : op_enc->ldpc_enc.tb_params.c,
1413 : 0 : op_enc->ldpc_enc.tb_params.cab,
1414 : : op_enc->ldpc_enc.tb_params.ea,
1415 : : op_enc->ldpc_enc.tb_params.eb,
1416 : 0 : op_enc->ldpc_enc.tb_params.r);
1417 : : else
1418 : 0 : snprintf(partial, sizeof(partial), "E %d",
1419 : : op_enc->ldpc_enc.cb_params.e);
1420 [ # # ]: 0 : if (op_enc->ldpc_enc.input.data != NULL)
1421 : 0 : add0 = rte_pktmbuf_iova_offset(op_enc->ldpc_enc.input.data, 0);
1422 [ # # ]: 0 : if (op_enc->ldpc_enc.output.data != NULL)
1423 : 0 : add1 = rte_pktmbuf_iova_offset(op_enc->ldpc_enc.output.data, 0);
1424 : 0 : snprintf(str, len, "op %x st %x BG %d Zc %d Ncb %d q_m %d F %d Rv %d "
1425 : : "in %" PRIx64 " out %" PRIx64 " %s\n",
1426 : : op_enc->ldpc_enc.op_flags, op_enc->status,
1427 : 0 : op_enc->ldpc_enc.basegraph, op_enc->ldpc_enc.z_c,
1428 : 0 : op_enc->ldpc_enc.n_cb, op_enc->ldpc_enc.q_m,
1429 : 0 : op_enc->ldpc_enc.n_filler, op_enc->ldpc_enc.rv_index,
1430 : : add0, add1, partial);
1431 : : } else if (op_type == RTE_BBDEV_OP_TURBO_ENC) {
1432 : : op_enc = op;
1433 [ # # ]: 0 : if (op_enc->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
1434 : 0 : snprintf(partial, sizeof(partial),
1435 : : "C %d Cab %d Ea %d Eb %d r %d K %d Ncb %d",
1436 : 0 : op_enc->turbo_enc.tb_params.c,
1437 : 0 : op_enc->turbo_enc.tb_params.cab,
1438 : : op_enc->turbo_enc.tb_params.ea,
1439 : : op_enc->turbo_enc.tb_params.eb,
1440 : 0 : op_enc->turbo_enc.tb_params.r,
1441 : 0 : op_enc->turbo_enc.tb_params.k_neg,
1442 : 0 : op_enc->turbo_enc.tb_params.ncb_neg);
1443 : : else
1444 : 0 : snprintf(partial, sizeof(partial), "E %d K %d",
1445 : : op_enc->turbo_enc.cb_params.e,
1446 : 0 : op_enc->turbo_enc.cb_params.k);
1447 [ # # ]: 0 : if (op_enc->turbo_enc.input.data != NULL)
1448 : 0 : add0 = rte_pktmbuf_iova_offset(op_enc->turbo_enc.input.data, 0);
1449 [ # # ]: 0 : if (op_enc->turbo_enc.output.data != NULL)
1450 : 0 : add1 = rte_pktmbuf_iova_offset(op_enc->turbo_enc.output.data, 0);
1451 : 0 : snprintf(str, len, "op %x st %x CBM %d Rv %d In %" PRIx64 " Out %" PRIx64 " %s\n",
1452 : : op_enc->turbo_enc.op_flags, op_enc->status,
1453 : 0 : op_enc->turbo_enc.code_block_mode, op_enc->turbo_enc.rv_index,
1454 : : add0, add1, partial);
1455 : : } else if (op_type == RTE_BBDEV_OP_FFT) {
1456 : : op_fft = op;
1457 [ # # ]: 0 : if (op_fft->fft.base_input.data != NULL)
1458 : 0 : add0 = rte_pktmbuf_iova_offset(op_fft->fft.base_input.data, 0);
1459 [ # # ]: 0 : if (op_fft->fft.base_output.data != NULL)
1460 : 0 : add1 = rte_pktmbuf_iova_offset(op_fft->fft.base_output.data, 0);
1461 [ # # ]: 0 : if (op_fft->fft.dewindowing_input.data != NULL)
1462 : 0 : add2 = rte_pktmbuf_iova_offset(op_fft->fft.dewindowing_input.data, 0);
1463 [ # # ]: 0 : if (op_fft->fft.power_meas_output.data != NULL)
1464 : 0 : add3 = rte_pktmbuf_iova_offset(op_fft->fft.power_meas_output.data, 0);
1465 : 0 : snprintf(str, len, "op %x st %x in %d inl %d out %d outl %d cs %x ants %d "
1466 : : "idft %d dft %d cst %d ish %d dsh %d ncs %d pwsh %d fp16 %d fr %d "
1467 : : "outde %d in %" PRIx64 " out %" PRIx64 " dw %" PRIx64 " "
1468 : : "pm %" PRIx64 "\n",
1469 : : op_fft->fft.op_flags, op_fft->status,
1470 : 0 : op_fft->fft.input_sequence_size, op_fft->fft.input_leading_padding,
1471 : 0 : op_fft->fft.output_sequence_size,
1472 : 0 : op_fft->fft.output_leading_depadding,
1473 : 0 : op_fft->fft.cs_bitmap, op_fft->fft.num_antennas_log2,
1474 : 0 : op_fft->fft.idft_log2, op_fft->fft.dft_log2,
1475 : 0 : op_fft->fft.cs_time_adjustment,
1476 : 0 : op_fft->fft.idft_shift, op_fft->fft.dft_shift,
1477 : 0 : op_fft->fft.ncs_reciprocal, op_fft->fft.power_shift,
1478 : 0 : op_fft->fft.fp16_exp_adjust, op_fft->fft.freq_resample_mode,
1479 : 0 : op_fft->fft.output_depadded_size, add0, add1, add2, add3);
1480 : : } else if (op_type == RTE_BBDEV_OP_MLDTS) {
1481 : : op_mldts = op;
1482 [ # # ]: 0 : if (op_mldts->mldts.qhy_input.data != NULL)
1483 : 0 : add0 = rte_pktmbuf_iova_offset(op_mldts->mldts.qhy_input.data, 0);
1484 [ # # ]: 0 : if (op_mldts->mldts.r_input.data != NULL)
1485 : 0 : add1 = rte_pktmbuf_iova_offset(op_mldts->mldts.r_input.data, 0);
1486 [ # # ]: 0 : if (op_mldts->mldts.output.data != NULL)
1487 : 0 : add2 = rte_pktmbuf_iova_offset(op_mldts->mldts.output.data, 0);
1488 : 0 : snprintf(str, len,
1489 : : "op %x st %x rbs %d lay %d rrep %d crep%d qm %d %d %d %d "
1490 : : "qhy %" PRIx64 " r %" PRIx64 " out %" PRIx64 "\n",
1491 : : op_mldts->mldts.op_flags, op_mldts->status,
1492 : 0 : op_mldts->mldts.num_rbs, op_mldts->mldts.num_layers,
1493 : 0 : op_mldts->mldts.r_rep, op_mldts->mldts.c_rep,
1494 : 0 : op_mldts->mldts.q_m[0], op_mldts->mldts.q_m[1],
1495 : 0 : op_mldts->mldts.q_m[2], op_mldts->mldts.q_m[3],
1496 : : add0, add1, add2);
1497 : :
1498 : : } else {
1499 : 0 : snprintf(str, len, "Invalid Operation type %d\n", op_type);
1500 : : }
1501 : :
1502 : : return str;
1503 : : }
|