Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2016 Cavium, Inc
3 : : */
4 : :
5 : : #include <stdalign.h>
6 : : #include <ctype.h>
7 : : #include <stdio.h>
8 : : #include <stdlib.h>
9 : : #include <string.h>
10 : : #include <errno.h>
11 : : #include <stdint.h>
12 : : #include <inttypes.h>
13 : :
14 : : #include <eal_export.h>
15 : : #include <rte_string_fns.h>
16 : : #include <rte_log.h>
17 : : #include <dev_driver.h>
18 : : #include <rte_memzone.h>
19 : : #include <rte_eal.h>
20 : : #include <rte_common.h>
21 : : #include <rte_malloc.h>
22 : : #include <rte_errno.h>
23 : : #include <ethdev_driver.h>
24 : : #include <rte_cryptodev.h>
25 : : #include <rte_dmadev.h>
26 : : #include <cryptodev_pmd.h>
27 : : #include <rte_telemetry.h>
28 : :
29 : : #include "rte_eventdev.h"
30 : : #include "eventdev_pmd.h"
31 : : #include "eventdev_trace.h"
32 : :
33 : : RTE_EXPORT_INTERNAL_SYMBOL(rte_event_logtype)
34 [ - + ]: 254 : RTE_LOG_REGISTER_DEFAULT(rte_event_logtype, INFO);
35 : :
36 : : static struct rte_eventdev rte_event_devices[RTE_EVENT_MAX_DEVS];
37 : :
38 : : RTE_EXPORT_INTERNAL_SYMBOL(rte_eventdevs)
39 : : struct rte_eventdev *rte_eventdevs = rte_event_devices;
40 : :
41 : : static struct rte_eventdev_global eventdev_globals = {
42 : : .nb_devs = 0
43 : : };
44 : :
45 : : /* Public fastpath APIs. */
46 : : RTE_EXPORT_SYMBOL(rte_event_fp_ops)
47 : : struct rte_event_fp_ops rte_event_fp_ops[RTE_EVENT_MAX_DEVS];
48 : :
49 : : /* Event dev north bound API implementation */
50 : :
51 : : RTE_EXPORT_SYMBOL(rte_event_dev_count)
52 : : uint8_t
53 : 4 : rte_event_dev_count(void)
54 : : {
55 : 4 : return eventdev_globals.nb_devs;
56 : : }
57 : :
58 : : RTE_EXPORT_SYMBOL(rte_event_dev_get_dev_id)
59 : : int
60 : 5 : rte_event_dev_get_dev_id(const char *name)
61 : : {
62 : : int i;
63 : : uint8_t cmp;
64 : :
65 [ + - ]: 5 : if (!name)
66 : : return -EINVAL;
67 : :
68 [ + + ]: 6 : for (i = 0; i < eventdev_globals.nb_devs; i++) {
69 : 8 : cmp = (strncmp(rte_event_devices[i].data->name, name,
70 [ + + ]: 4 : RTE_EVENTDEV_NAME_MAX_LEN) == 0) ||
71 [ + - ]: 1 : (rte_event_devices[i].dev ? (strncmp(
72 [ + - ]: 1 : rte_event_devices[i].dev->driver->name, name,
73 : : RTE_EVENTDEV_NAME_MAX_LEN) == 0) : 0);
74 [ + + + - ]: 4 : if (cmp && (rte_event_devices[i].attached ==
75 : : RTE_EVENTDEV_ATTACHED)) {
76 : 3 : rte_eventdev_trace_get_dev_id(name, i);
77 : 3 : return i;
78 : : }
79 : : }
80 : : return -ENODEV;
81 : : }
82 : :
83 : : RTE_EXPORT_SYMBOL(rte_event_dev_socket_id)
84 : : int
85 : 2 : rte_event_dev_socket_id(uint8_t dev_id)
86 : : {
87 : : struct rte_eventdev *dev;
88 : :
89 [ + + ]: 2 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
90 : : dev = &rte_eventdevs[dev_id];
91 : :
92 [ - + ]: 1 : rte_eventdev_trace_socket_id(dev_id, dev, dev->data->socket_id);
93 : :
94 : 1 : return dev->data->socket_id;
95 : : }
96 : :
97 : : RTE_EXPORT_SYMBOL(rte_event_dev_info_get)
98 : : int
99 : 62 : rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
100 : : {
101 : : struct rte_eventdev *dev;
102 : :
103 [ + - ]: 62 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
104 : : dev = &rte_eventdevs[dev_id];
105 : :
106 [ + + ]: 62 : if (dev_info == NULL)
107 : : return -EINVAL;
108 : :
109 : : memset(dev_info, 0, sizeof(struct rte_event_dev_info));
110 : :
111 [ + - ]: 61 : if (dev->dev_ops->dev_infos_get == NULL)
112 : : return -ENOTSUP;
113 : 61 : dev->dev_ops->dev_infos_get(dev, dev_info);
114 : :
115 : 61 : dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
116 : :
117 : 61 : dev_info->dev = dev->dev;
118 [ + - + - ]: 61 : if (dev->dev != NULL && dev->dev->driver != NULL)
119 : 61 : dev_info->driver_name = dev->dev->driver->name;
120 : :
121 : 61 : rte_eventdev_trace_info_get(dev_id, dev_info, dev_info->dev);
122 : :
123 : 61 : return 0;
124 : : }
125 : :
126 : : RTE_EXPORT_SYMBOL(rte_event_eth_rx_adapter_caps_get)
127 : : int
128 : 0 : rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
129 : : uint32_t *caps)
130 : : {
131 : : struct rte_eventdev *dev;
132 : :
133 [ # # # # ]: 0 : rte_eventdev_trace_eth_rx_adapter_caps_get(dev_id, eth_port_id);
134 : :
135 : 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
136 [ # # ]: 0 : RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_port_id, -EINVAL);
137 : :
138 : 0 : dev = &rte_eventdevs[dev_id];
139 : :
140 [ # # ]: 0 : if (caps == NULL)
141 : : return -EINVAL;
142 : :
143 [ # # ]: 0 : if (dev->dev_ops->eth_rx_adapter_caps_get == NULL)
144 : 0 : *caps = RTE_EVENT_ETH_RX_ADAPTER_SW_CAP;
145 : : else
146 : 0 : *caps = 0;
147 : :
148 : : return dev->dev_ops->eth_rx_adapter_caps_get ?
149 : 0 : dev->dev_ops->eth_rx_adapter_caps_get(dev, &rte_eth_devices[eth_port_id], caps)
150 [ # # ]: 0 : : 0;
151 : : }
152 : :
153 : : RTE_EXPORT_SYMBOL(rte_event_timer_adapter_caps_get)
154 : : int
155 : 0 : rte_event_timer_adapter_caps_get(uint8_t dev_id, uint32_t *caps)
156 : : {
157 : : struct rte_eventdev *dev;
158 : : const struct event_timer_adapter_ops *ops;
159 : :
160 [ # # # # ]: 0 : rte_eventdev_trace_timer_adapter_caps_get(dev_id);
161 : :
162 : 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
163 : :
164 : : dev = &rte_eventdevs[dev_id];
165 : :
166 [ # # ]: 0 : if (caps == NULL)
167 : : return -EINVAL;
168 : :
169 [ # # ]: 0 : if (dev->dev_ops->timer_adapter_caps_get == NULL)
170 : 0 : *caps = RTE_EVENT_TIMER_ADAPTER_SW_CAP;
171 : : else
172 : 0 : *caps = 0;
173 : :
174 : : return dev->dev_ops->timer_adapter_caps_get ?
175 : 0 : dev->dev_ops->timer_adapter_caps_get(dev, 0, caps, &ops)
176 [ # # ]: 0 : : 0;
177 : : }
178 : :
179 : : RTE_EXPORT_SYMBOL(rte_event_crypto_adapter_caps_get)
180 : : int
181 : 0 : rte_event_crypto_adapter_caps_get(uint8_t dev_id, uint8_t cdev_id,
182 : : uint32_t *caps)
183 : : {
184 : : struct rte_eventdev *dev;
185 : : struct rte_cryptodev *cdev;
186 : :
187 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
188 [ # # ]: 0 : if (!rte_cryptodev_is_valid_dev(cdev_id))
189 : : return -EINVAL;
190 : :
191 : 0 : dev = &rte_eventdevs[dev_id];
192 : 0 : cdev = rte_cryptodev_pmd_get_dev(cdev_id);
193 : :
194 : 0 : rte_eventdev_trace_crypto_adapter_caps_get(dev_id, dev, cdev_id, cdev);
195 : :
196 [ # # ]: 0 : if (caps == NULL)
197 : : return -EINVAL;
198 : :
199 [ # # ]: 0 : if (dev->dev_ops->crypto_adapter_caps_get == NULL)
200 : 0 : *caps = RTE_EVENT_CRYPTO_ADAPTER_SW_CAP;
201 : : else
202 : 0 : *caps = 0;
203 : :
204 : : return dev->dev_ops->crypto_adapter_caps_get ?
205 [ # # ]: 0 : dev->dev_ops->crypto_adapter_caps_get(dev, cdev, caps) : 0;
206 : : }
207 : :
208 : : RTE_EXPORT_SYMBOL(rte_event_eth_tx_adapter_caps_get)
209 : : int
210 : 18 : rte_event_eth_tx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
211 : : uint32_t *caps)
212 : : {
213 : : struct rte_eventdev *dev;
214 : : struct rte_eth_dev *eth_dev;
215 : :
216 [ + - ]: 18 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
217 [ - + ]: 18 : RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_port_id, -EINVAL);
218 : :
219 : 18 : dev = &rte_eventdevs[dev_id];
220 [ - + ]: 18 : eth_dev = &rte_eth_devices[eth_port_id];
221 : :
222 : 18 : rte_eventdev_trace_eth_tx_adapter_caps_get(dev_id, dev, eth_port_id, eth_dev);
223 : :
224 [ + - ]: 18 : if (caps == NULL)
225 : : return -EINVAL;
226 : :
227 [ + - ]: 18 : if (dev->dev_ops->eth_tx_adapter_caps_get == NULL)
228 : 18 : *caps = RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR;
229 : : else
230 : 0 : *caps = 0;
231 : :
232 : : return dev->dev_ops->eth_tx_adapter_caps_get ?
233 : 0 : dev->dev_ops->eth_tx_adapter_caps_get(dev, eth_dev, caps)
234 [ - + ]: 18 : : 0;
235 : : }
236 : :
237 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_event_dma_adapter_caps_get, 23.11)
238 : : int
239 : 0 : rte_event_dma_adapter_caps_get(uint8_t dev_id, uint8_t dma_dev_id, uint32_t *caps)
240 : : {
241 : : struct rte_eventdev *dev;
242 : :
243 [ # # # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
244 [ # # ]: 0 : if (!rte_dma_is_valid(dma_dev_id))
245 : : return -EINVAL;
246 : :
247 : 0 : dev = &rte_eventdevs[dev_id];
248 : :
249 [ # # ]: 0 : if (caps == NULL)
250 : : return -EINVAL;
251 : :
252 : 0 : *caps = 0;
253 : :
254 [ # # ]: 0 : if (dev->dev_ops->dma_adapter_caps_get)
255 : 0 : return dev->dev_ops->dma_adapter_caps_get(dev, dma_dev_id, caps);
256 : :
257 : : return 0;
258 : : }
259 : :
260 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_event_vector_adapter_caps_get, 25.07)
261 : : int
262 : 4 : rte_event_vector_adapter_caps_get(uint8_t dev_id, uint32_t *caps)
263 : : {
264 : : const struct event_vector_adapter_ops *ops;
265 : : struct rte_eventdev *dev;
266 : :
267 [ + - ]: 4 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
268 : :
269 : : dev = &rte_eventdevs[dev_id];
270 : :
271 [ + - ]: 4 : if (caps == NULL)
272 : : return -EINVAL;
273 : :
274 [ + - ]: 4 : if (dev->dev_ops->vector_adapter_caps_get == NULL)
275 : 4 : *caps = RTE_EVENT_VECTOR_ADAPTER_SW_CAP;
276 : : else
277 : 0 : *caps = 0;
278 : :
279 : : return dev->dev_ops->vector_adapter_caps_get ?
280 [ - + ]: 4 : dev->dev_ops->vector_adapter_caps_get(dev, caps, &ops) :
281 : : 0;
282 : : }
283 : :
284 : : static inline int
285 : 79 : event_dev_queue_config(struct rte_eventdev *dev, uint8_t nb_queues)
286 : : {
287 : 79 : uint8_t old_nb_queues = dev->data->nb_queues;
288 : : struct rte_event_queue_conf *queues_cfg;
289 : : unsigned int i;
290 : :
291 : : RTE_EDEV_LOG_DEBUG("Setup %d queues on device %u", nb_queues,
292 : : dev->data->dev_id);
293 : :
294 [ + - ]: 79 : if (nb_queues != 0) {
295 : 79 : queues_cfg = dev->data->queues_cfg;
296 [ + - ]: 79 : if (dev->dev_ops->queue_release == NULL)
297 : : return -ENOTSUP;
298 : :
299 [ + + ]: 119 : for (i = nb_queues; i < old_nb_queues; i++)
300 : 40 : dev->dev_ops->queue_release(dev, i);
301 : :
302 : :
303 [ + + ]: 79 : if (nb_queues > old_nb_queues) {
304 : 11 : uint8_t new_qs = nb_queues - old_nb_queues;
305 : :
306 : 11 : memset(queues_cfg + old_nb_queues, 0,
307 : : sizeof(queues_cfg[0]) * new_qs);
308 : : }
309 : : } else {
310 [ # # ]: 0 : if (dev->dev_ops->queue_release == NULL)
311 : : return -ENOTSUP;
312 : :
313 [ # # ]: 0 : for (i = nb_queues; i < old_nb_queues; i++)
314 : 0 : dev->dev_ops->queue_release(dev, i);
315 : : }
316 : :
317 : 79 : dev->data->nb_queues = nb_queues;
318 : 79 : return 0;
319 : : }
320 : :
321 : : #define EVENT_QUEUE_SERVICE_PRIORITY_INVALID (0xdead)
322 : :
323 : : static inline int
324 : 79 : event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports)
325 : : {
326 : 79 : uint8_t old_nb_ports = dev->data->nb_ports;
327 : : void **ports;
328 : : uint16_t *links_map;
329 : : struct rte_event_port_conf *ports_cfg;
330 : : unsigned int i, j;
331 : :
332 : : RTE_EDEV_LOG_DEBUG("Setup %d ports on device %u", nb_ports,
333 : : dev->data->dev_id);
334 : :
335 [ + - ]: 79 : if (nb_ports != 0) { /* re-config */
336 [ + - ]: 79 : if (dev->dev_ops->port_release == NULL)
337 : : return -ENOTSUP;
338 : :
339 : 79 : ports = dev->data->ports;
340 : 79 : ports_cfg = dev->data->ports_cfg;
341 : :
342 [ + + ]: 115 : for (i = nb_ports; i < old_nb_ports; i++)
343 : 36 : (dev->dev_ops->port_release)(ports[i]);
344 : :
345 [ + + ]: 79 : if (nb_ports > old_nb_ports) {
346 : 28 : uint8_t new_ps = nb_ports - old_nb_ports;
347 : 28 : unsigned int old_links_map_end =
348 : 28 : old_nb_ports * RTE_EVENT_MAX_QUEUES_PER_DEV;
349 : 28 : unsigned int links_map_end =
350 : 28 : nb_ports * RTE_EVENT_MAX_QUEUES_PER_DEV;
351 : :
352 : 28 : memset(ports + old_nb_ports, 0,
353 : : sizeof(ports[0]) * new_ps);
354 : 28 : memset(ports_cfg + old_nb_ports, 0,
355 : : sizeof(ports_cfg[0]) * new_ps);
356 [ + + ]: 252 : for (i = 0; i < RTE_EVENT_MAX_PROFILES_PER_PORT; i++) {
357 : 224 : links_map = dev->data->links_map[i];
358 [ + + ]: 165464 : for (j = old_links_map_end; j < links_map_end; j++)
359 : 165240 : links_map[j] = EVENT_QUEUE_SERVICE_PRIORITY_INVALID;
360 : : }
361 : : }
362 : : } else {
363 [ # # ]: 0 : if (dev->dev_ops->port_release == NULL)
364 : : return -ENOTSUP;
365 : :
366 : 0 : ports = dev->data->ports;
367 [ # # ]: 0 : for (i = nb_ports; i < old_nb_ports; i++) {
368 : 0 : (dev->dev_ops->port_release)(ports[i]);
369 : 0 : ports[i] = NULL;
370 : : }
371 : : }
372 : :
373 : 79 : dev->data->nb_ports = nb_ports;
374 : 79 : return 0;
375 : : }
376 : :
377 : : RTE_EXPORT_SYMBOL(rte_event_dev_configure)
378 : : int
379 : 87 : rte_event_dev_configure(uint8_t dev_id,
380 : : const struct rte_event_dev_config *dev_conf)
381 : : {
382 : : struct rte_event_dev_info info;
383 : : struct rte_eventdev *dev;
384 : : int diag;
385 : :
386 [ + - ]: 87 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
387 : : dev = &rte_eventdevs[dev_id];
388 : :
389 [ + - ]: 87 : if (dev->dev_ops->dev_infos_get == NULL)
390 : : return -ENOTSUP;
391 [ + - ]: 87 : if (dev->dev_ops->dev_configure == NULL)
392 : : return -ENOTSUP;
393 : :
394 [ - + ]: 87 : if (dev->data->dev_started) {
395 : 0 : RTE_EDEV_LOG_ERR(
396 : : "device %d must be stopped to allow configuration", dev_id);
397 : 0 : return -EBUSY;
398 : : }
399 : :
400 [ + + ]: 87 : if (dev_conf == NULL)
401 : : return -EINVAL;
402 : :
403 : 86 : dev->dev_ops->dev_infos_get(dev, &info);
404 : :
405 : : /* Check dequeue_timeout_ns value is in limit */
406 [ + - ]: 86 : if (!(dev_conf->event_dev_cfg & RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT)) {
407 [ + + ]: 86 : if (dev_conf->dequeue_timeout_ns &&
408 [ + - ]: 35 : (dev_conf->dequeue_timeout_ns < info.min_dequeue_timeout_ns
409 : 35 : || dev_conf->dequeue_timeout_ns >
410 [ + + ]: 35 : info.max_dequeue_timeout_ns)) {
411 : 1 : RTE_EDEV_LOG_ERR("dev%d invalid dequeue_timeout_ns=%d"
412 : : " min_dequeue_timeout_ns=%d max_dequeue_timeout_ns=%d",
413 : : dev_id, dev_conf->dequeue_timeout_ns,
414 : : info.min_dequeue_timeout_ns,
415 : : info.max_dequeue_timeout_ns);
416 : 1 : return -EINVAL;
417 : : }
418 : : }
419 : :
420 : : /* Check nb_events_limit is in limit */
421 [ + + ]: 85 : if (dev_conf->nb_events_limit > info.max_num_events) {
422 : 1 : RTE_EDEV_LOG_ERR("dev%d nb_events_limit=%d > max_num_events=%d",
423 : : dev_id, dev_conf->nb_events_limit, info.max_num_events);
424 : 1 : return -EINVAL;
425 : : }
426 : :
427 : : /* Check nb_event_queues is in limit */
428 [ - + ]: 84 : if (!dev_conf->nb_event_queues) {
429 : 0 : RTE_EDEV_LOG_ERR("dev%d nb_event_queues cannot be zero",
430 : : dev_id);
431 : 0 : return -EINVAL;
432 : : }
433 : 84 : if (dev_conf->nb_event_queues > info.max_event_queues +
434 [ + + ]: 84 : info.max_single_link_event_port_queue_pairs) {
435 : 1 : RTE_EDEV_LOG_ERR("%d nb_event_queues=%d > max_event_queues=%d + max_single_link_event_port_queue_pairs=%d",
436 : : dev_id, dev_conf->nb_event_queues,
437 : : info.max_event_queues,
438 : : info.max_single_link_event_port_queue_pairs);
439 : 1 : return -EINVAL;
440 : : }
441 : 83 : if (dev_conf->nb_event_queues -
442 [ - + ]: 83 : dev_conf->nb_single_link_event_port_queues >
443 : : info.max_event_queues) {
444 : 0 : RTE_EDEV_LOG_ERR("id%d nb_event_queues=%d - nb_single_link_event_port_queues=%d > max_event_queues=%d",
445 : : dev_id, dev_conf->nb_event_queues,
446 : : dev_conf->nb_single_link_event_port_queues,
447 : : info.max_event_queues);
448 : 0 : return -EINVAL;
449 : : }
450 [ - + ]: 83 : if (dev_conf->nb_single_link_event_port_queues >
451 : : dev_conf->nb_event_queues) {
452 : 0 : RTE_EDEV_LOG_ERR("dev%d nb_single_link_event_port_queues=%d > nb_event_queues=%d",
453 : : dev_id,
454 : : dev_conf->nb_single_link_event_port_queues,
455 : : dev_conf->nb_event_queues);
456 : 0 : return -EINVAL;
457 : : }
458 : :
459 : : /* Check nb_event_ports is in limit */
460 [ - + ]: 83 : if (!dev_conf->nb_event_ports) {
461 : 0 : RTE_EDEV_LOG_ERR("dev%d nb_event_ports cannot be zero", dev_id);
462 : 0 : return -EINVAL;
463 : : }
464 [ + + ]: 83 : if (dev_conf->nb_event_ports > info.max_event_ports +
465 : : info.max_single_link_event_port_queue_pairs) {
466 : 1 : RTE_EDEV_LOG_ERR("id%d nb_event_ports=%d > max_event_ports=%d + max_single_link_event_port_queue_pairs=%d",
467 : : dev_id, dev_conf->nb_event_ports,
468 : : info.max_event_ports,
469 : : info.max_single_link_event_port_queue_pairs);
470 : 1 : return -EINVAL;
471 : : }
472 [ - + ]: 82 : if (dev_conf->nb_event_ports -
473 : : dev_conf->nb_single_link_event_port_queues
474 : : > info.max_event_ports) {
475 : 0 : RTE_EDEV_LOG_ERR("id%d nb_event_ports=%d - nb_single_link_event_port_queues=%d > max_event_ports=%d",
476 : : dev_id, dev_conf->nb_event_ports,
477 : : dev_conf->nb_single_link_event_port_queues,
478 : : info.max_event_ports);
479 : 0 : return -EINVAL;
480 : : }
481 : :
482 [ - + ]: 82 : if (dev_conf->nb_single_link_event_port_queues >
483 : : dev_conf->nb_event_ports) {
484 : 0 : RTE_EDEV_LOG_ERR(
485 : : "dev%d nb_single_link_event_port_queues=%d > nb_event_ports=%d",
486 : : dev_id,
487 : : dev_conf->nb_single_link_event_port_queues,
488 : : dev_conf->nb_event_ports);
489 : 0 : return -EINVAL;
490 : : }
491 : :
492 : : /* Check nb_event_queue_flows is in limit */
493 [ - + ]: 82 : if (!dev_conf->nb_event_queue_flows) {
494 : 0 : RTE_EDEV_LOG_ERR("dev%d nb_flows cannot be zero", dev_id);
495 : 0 : return -EINVAL;
496 : : }
497 [ + + ]: 82 : if (dev_conf->nb_event_queue_flows > info.max_event_queue_flows) {
498 : 1 : RTE_EDEV_LOG_ERR("dev%d nb_flows=%x > max_flows=%x",
499 : : dev_id, dev_conf->nb_event_queue_flows,
500 : : info.max_event_queue_flows);
501 : 1 : return -EINVAL;
502 : : }
503 : :
504 : : /* Check nb_event_port_dequeue_depth is in limit */
505 [ - + ]: 81 : if (!dev_conf->nb_event_port_dequeue_depth) {
506 : 0 : RTE_EDEV_LOG_ERR("dev%d nb_dequeue_depth cannot be zero",
507 : : dev_id);
508 : 0 : return -EINVAL;
509 : : }
510 [ + - ]: 81 : if ((info.event_dev_cap & RTE_EVENT_DEV_CAP_BURST_MODE) &&
511 : 81 : (dev_conf->nb_event_port_dequeue_depth >
512 [ + + ]: 81 : info.max_event_port_dequeue_depth)) {
513 : 1 : RTE_EDEV_LOG_ERR("dev%d nb_dq_depth=%d > max_dq_depth=%d",
514 : : dev_id, dev_conf->nb_event_port_dequeue_depth,
515 : : info.max_event_port_dequeue_depth);
516 : 1 : return -EINVAL;
517 : : }
518 : :
519 : : /* Check nb_event_port_enqueue_depth is in limit */
520 [ - + ]: 80 : if (!dev_conf->nb_event_port_enqueue_depth) {
521 : 0 : RTE_EDEV_LOG_ERR("dev%d nb_enqueue_depth cannot be zero",
522 : : dev_id);
523 : 0 : return -EINVAL;
524 : : }
525 [ + - ]: 80 : if ((info.event_dev_cap & RTE_EVENT_DEV_CAP_BURST_MODE) &&
526 : : (dev_conf->nb_event_port_enqueue_depth >
527 [ + + ]: 80 : info.max_event_port_enqueue_depth)) {
528 : 1 : RTE_EDEV_LOG_ERR("dev%d nb_enq_depth=%d > max_enq_depth=%d",
529 : : dev_id, dev_conf->nb_event_port_enqueue_depth,
530 : : info.max_event_port_enqueue_depth);
531 : 1 : return -EINVAL;
532 : : }
533 : :
534 : : /* Copy the dev_conf parameter into the dev structure */
535 : 79 : memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
536 : :
537 : : /* Setup new number of queues and reconfigure device. */
538 : 79 : diag = event_dev_queue_config(dev, dev_conf->nb_event_queues);
539 [ - + ]: 79 : if (diag != 0) {
540 : 0 : RTE_EDEV_LOG_ERR("dev%d event_dev_queue_config = %d", dev_id,
541 : : diag);
542 : 0 : return diag;
543 : : }
544 : :
545 : : /* Setup new number of ports and reconfigure device. */
546 : 79 : diag = event_dev_port_config(dev, dev_conf->nb_event_ports);
547 [ - + ]: 79 : if (diag != 0) {
548 : 0 : event_dev_queue_config(dev, 0);
549 : 0 : RTE_EDEV_LOG_ERR("dev%d event_dev_port_config = %d", dev_id,
550 : : diag);
551 : 0 : return diag;
552 : : }
553 : :
554 : 79 : event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
555 : :
556 : : /* Configure the device */
557 : 79 : diag = (dev->dev_ops->dev_configure)(dev);
558 [ - + ]: 79 : if (diag != 0) {
559 : 0 : RTE_EDEV_LOG_ERR("dev%d dev_configure = %d", dev_id, diag);
560 : 0 : event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
561 : 0 : event_dev_queue_config(dev, 0);
562 : 0 : event_dev_port_config(dev, 0);
563 : : }
564 : :
565 [ - + ]: 79 : dev->data->event_dev_cap = info.event_dev_cap;
566 : 79 : rte_eventdev_trace_configure(dev_id, dev_conf, diag);
567 : 79 : return diag;
568 : : }
569 : :
570 : : static inline int
571 : : is_valid_queue(struct rte_eventdev *dev, uint8_t queue_id)
572 : : {
573 [ # # ]: 0 : if (queue_id < dev->data->nb_queues && queue_id <
574 : : RTE_EVENT_MAX_QUEUES_PER_DEV)
575 : : return 1;
576 : : else
577 : : return 0;
578 : : }
579 : :
580 : : RTE_EXPORT_SYMBOL(rte_event_queue_default_conf_get)
581 : : int
582 : 135 : rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
583 : : struct rte_event_queue_conf *queue_conf)
584 : : {
585 : : struct rte_eventdev *dev;
586 : :
587 [ + - ]: 135 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
588 : : dev = &rte_eventdevs[dev_id];
589 : :
590 [ + + ]: 135 : if (queue_conf == NULL)
591 : : return -EINVAL;
592 : :
593 [ - + ]: 134 : if (!is_valid_queue(dev, queue_id)) {
594 : 0 : RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
595 : 0 : return -EINVAL;
596 : : }
597 : :
598 [ + - ]: 134 : if (dev->dev_ops->queue_def_conf == NULL)
599 : : return -ENOTSUP;
600 : : memset(queue_conf, 0, sizeof(struct rte_event_queue_conf));
601 : 134 : dev->dev_ops->queue_def_conf(dev, queue_id, queue_conf);
602 : :
603 : 134 : rte_eventdev_trace_queue_default_conf_get(dev_id, dev, queue_id, queue_conf);
604 : :
605 : 134 : return 0;
606 : : }
607 : :
608 : : static inline int
609 : : is_valid_atomic_queue_conf(const struct rte_event_queue_conf *queue_conf)
610 : : {
611 [ + + ]: 976 : if (queue_conf &&
612 [ + + ]: 593 : !(queue_conf->event_queue_cfg &
613 : 520 : RTE_EVENT_QUEUE_CFG_SINGLE_LINK) &&
614 [ + + ]: 520 : ((queue_conf->event_queue_cfg &
615 : 325 : RTE_EVENT_QUEUE_CFG_ALL_TYPES) ||
616 [ + + ]: 325 : (queue_conf->schedule_type
617 : : == RTE_SCHED_TYPE_ATOMIC)
618 : : ))
619 : : return 1;
620 : : else
621 : : return 0;
622 : : }
623 : :
624 : : static inline int
625 : : is_valid_ordered_queue_conf(const struct rte_event_queue_conf *queue_conf)
626 : : {
627 [ + + ]: 975 : if (queue_conf &&
628 [ + + ]: 592 : !(queue_conf->event_queue_cfg &
629 : 519 : RTE_EVENT_QUEUE_CFG_SINGLE_LINK) &&
630 [ + + ]: 519 : ((queue_conf->event_queue_cfg &
631 : 325 : RTE_EVENT_QUEUE_CFG_ALL_TYPES) ||
632 [ + + ]: 325 : (queue_conf->schedule_type
633 : : == RTE_SCHED_TYPE_ORDERED)
634 : : ))
635 : : return 1;
636 : : else
637 : : return 0;
638 : : }
639 : :
640 : :
641 : : RTE_EXPORT_SYMBOL(rte_event_queue_setup)
642 : : int
643 : 977 : rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
644 : : const struct rte_event_queue_conf *queue_conf)
645 : : {
646 : : struct rte_eventdev *dev;
647 : : struct rte_event_queue_conf def_conf;
648 : :
649 [ + - ]: 977 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
650 : : dev = &rte_eventdevs[dev_id];
651 : :
652 [ + + ]: 977 : if (!is_valid_queue(dev, queue_id)) {
653 : 1 : RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
654 : 1 : return -EINVAL;
655 : : }
656 : :
657 : : /* Check nb_atomic_flows limit */
658 : : if (is_valid_atomic_queue_conf(queue_conf)) {
659 [ + - ]: 251 : if (queue_conf->nb_atomic_flows == 0 ||
660 : : queue_conf->nb_atomic_flows >
661 [ + + ]: 251 : dev->data->dev_conf.nb_event_queue_flows) {
662 : 1 : RTE_EDEV_LOG_ERR(
663 : : "dev%d queue%d Invalid nb_atomic_flows=%d max_flows=%d",
664 : : dev_id, queue_id, queue_conf->nb_atomic_flows,
665 : : dev->data->dev_conf.nb_event_queue_flows);
666 : 1 : return -EINVAL;
667 : : }
668 : : }
669 : :
670 : : /* Check nb_atomic_order_sequences limit */
671 : : if (is_valid_ordered_queue_conf(queue_conf)) {
672 [ + - ]: 206 : if (queue_conf->nb_atomic_order_sequences == 0 ||
673 : : queue_conf->nb_atomic_order_sequences >
674 [ + + ]: 206 : dev->data->dev_conf.nb_event_queue_flows) {
675 : 1 : RTE_EDEV_LOG_ERR(
676 : : "dev%d queue%d Invalid nb_atomic_order_seq=%d max_flows=%d",
677 : : dev_id, queue_id, queue_conf->nb_atomic_order_sequences,
678 : : dev->data->dev_conf.nb_event_queue_flows);
679 : 1 : return -EINVAL;
680 : : }
681 : : }
682 : :
683 [ - + ]: 974 : if (dev->data->dev_started) {
684 : 0 : RTE_EDEV_LOG_ERR(
685 : : "device %d must be stopped to allow queue setup", dev_id);
686 : 0 : return -EBUSY;
687 : : }
688 : :
689 [ + - ]: 974 : if (dev->dev_ops->queue_setup == NULL)
690 : : return -ENOTSUP;
691 : :
692 [ + + ]: 974 : if (queue_conf == NULL) {
693 [ + - ]: 383 : if (dev->dev_ops->queue_def_conf == NULL)
694 : : return -ENOTSUP;
695 : 383 : dev->dev_ops->queue_def_conf(dev, queue_id, &def_conf);
696 : : queue_conf = &def_conf;
697 : : }
698 : :
699 [ - + ]: 974 : dev->data->queues_cfg[queue_id] = *queue_conf;
700 : 974 : rte_eventdev_trace_queue_setup(dev_id, queue_id, queue_conf);
701 : 974 : return dev->dev_ops->queue_setup(dev, queue_id, queue_conf);
702 : : }
703 : :
704 : : static inline int
705 : : is_valid_port(struct rte_eventdev *dev, uint8_t port_id)
706 : : {
707 [ - + ]: 2 : if (port_id < dev->data->nb_ports)
708 : : return 1;
709 : : else
710 : : return 0;
711 : : }
712 : :
713 : : RTE_EXPORT_SYMBOL(rte_event_port_default_conf_get)
714 : : int
715 : 47 : rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
716 : : struct rte_event_port_conf *port_conf)
717 : : {
718 : : struct rte_eventdev *dev;
719 : :
720 [ + - ]: 47 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
721 : : dev = &rte_eventdevs[dev_id];
722 : :
723 [ + + ]: 47 : if (port_conf == NULL)
724 : : return -EINVAL;
725 : :
726 [ - + ]: 45 : if (!is_valid_port(dev, port_id)) {
727 : 0 : RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
728 : 0 : return -EINVAL;
729 : : }
730 : :
731 [ + - ]: 45 : if (dev->dev_ops->port_def_conf == NULL)
732 : : return -ENOTSUP;
733 : : memset(port_conf, 0, sizeof(struct rte_event_port_conf));
734 : 45 : dev->dev_ops->port_def_conf(dev, port_id, port_conf);
735 : :
736 : 45 : rte_eventdev_trace_port_default_conf_get(dev_id, dev, port_id, port_conf);
737 : :
738 : 45 : return 0;
739 : : }
740 : :
741 : : RTE_EXPORT_SYMBOL(rte_event_port_setup)
742 : : int
743 : 325 : rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
744 : : const struct rte_event_port_conf *port_conf)
745 : : {
746 : : struct rte_eventdev *dev;
747 : : struct rte_event_port_conf def_conf;
748 : : int diag;
749 : :
750 [ + - ]: 325 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
751 : : dev = &rte_eventdevs[dev_id];
752 : :
753 [ + + ]: 325 : if (!is_valid_port(dev, port_id)) {
754 : 1 : RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
755 : 1 : return -EINVAL;
756 : : }
757 : :
758 : : /* Check new_event_threshold limit */
759 [ + + + - ]: 324 : if ((port_conf && !port_conf->new_event_threshold) ||
760 : : (port_conf && port_conf->new_event_threshold >
761 [ + + ]: 124 : dev->data->dev_conf.nb_events_limit)) {
762 : 1 : RTE_EDEV_LOG_ERR(
763 : : "dev%d port%d Invalid event_threshold=%d nb_events_limit=%d",
764 : : dev_id, port_id, port_conf->new_event_threshold,
765 : : dev->data->dev_conf.nb_events_limit);
766 : 1 : return -EINVAL;
767 : : }
768 : :
769 : : /* Check dequeue_depth limit */
770 [ + + + - ]: 323 : if ((port_conf && !port_conf->dequeue_depth) ||
771 : 123 : (port_conf && port_conf->dequeue_depth >
772 [ + + ]: 123 : dev->data->dev_conf.nb_event_port_dequeue_depth)) {
773 : 1 : RTE_EDEV_LOG_ERR(
774 : : "dev%d port%d Invalid dequeue depth=%d max_dequeue_depth=%d",
775 : : dev_id, port_id, port_conf->dequeue_depth,
776 : : dev->data->dev_conf.nb_event_port_dequeue_depth);
777 : 1 : return -EINVAL;
778 : : }
779 : :
780 : : /* Check enqueue_depth limit */
781 [ + + + - ]: 322 : if ((port_conf && !port_conf->enqueue_depth) ||
782 : 122 : (port_conf && port_conf->enqueue_depth >
783 [ + + ]: 122 : dev->data->dev_conf.nb_event_port_enqueue_depth)) {
784 : 1 : RTE_EDEV_LOG_ERR(
785 : : "dev%d port%d Invalid enqueue depth=%d max_enqueue_depth=%d",
786 : : dev_id, port_id, port_conf->enqueue_depth,
787 : : dev->data->dev_conf.nb_event_port_enqueue_depth);
788 : 1 : return -EINVAL;
789 : : }
790 : :
791 [ + + ]: 321 : if (port_conf &&
792 [ + + ]: 121 : (port_conf->event_port_cfg & RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL) &&
793 [ + - ]: 1 : !(dev->data->event_dev_cap &
794 : : RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE)) {
795 : 1 : RTE_EDEV_LOG_ERR(
796 : : "dev%d port%d Implicit release disable not supported",
797 : : dev_id, port_id);
798 : 1 : return -EINVAL;
799 : : }
800 : :
801 [ - + ]: 320 : if (dev->data->dev_started) {
802 : 0 : RTE_EDEV_LOG_ERR(
803 : : "device %d must be stopped to allow port setup", dev_id);
804 : 0 : return -EBUSY;
805 : : }
806 : :
807 [ + - ]: 320 : if (dev->dev_ops->port_setup == NULL)
808 : : return -ENOTSUP;
809 : :
810 [ + + ]: 320 : if (port_conf == NULL) {
811 [ + - ]: 200 : if (dev->dev_ops->port_def_conf == NULL)
812 : : return -ENOTSUP;
813 : 200 : dev->dev_ops->port_def_conf(dev, port_id, &def_conf);
814 : : port_conf = &def_conf;
815 : : }
816 : :
817 : 320 : dev->data->ports_cfg[port_id] = *port_conf;
818 : :
819 : 320 : diag = dev->dev_ops->port_setup(dev, port_id, port_conf);
820 : :
821 : : /* Unlink all the queues from this port(default state after setup) */
822 [ + - ]: 320 : if (!diag)
823 : 320 : diag = rte_event_port_unlink(dev_id, port_id, NULL, 0);
824 : :
825 : 320 : rte_eventdev_trace_port_setup(dev_id, port_id, port_conf, diag);
826 : : if (diag < 0)
827 : : return diag;
828 : :
829 : : return 0;
830 : : }
831 : :
832 : : RTE_EXPORT_SYMBOL(rte_event_port_quiesce)
833 : : void
834 : 0 : rte_event_port_quiesce(uint8_t dev_id, uint8_t port_id,
835 : : rte_eventdev_port_flush_t release_cb, void *args)
836 : : {
837 : : struct rte_eventdev *dev;
838 : :
839 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id);
840 : : dev = &rte_eventdevs[dev_id];
841 : :
842 [ # # # # ]: 0 : rte_eventdev_trace_port_quiesce(dev_id, dev, port_id, args);
843 : :
844 : : if (!is_valid_port(dev, port_id)) {
845 : 0 : RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
846 : 0 : return;
847 : : }
848 : :
849 [ # # ]: 0 : if (dev->dev_ops->port_quiesce)
850 : 0 : dev->dev_ops->port_quiesce(dev, dev->data->ports[port_id], release_cb, args);
851 : : }
852 : :
853 : : RTE_EXPORT_SYMBOL(rte_event_dev_attr_get)
854 : : int
855 : 25 : rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
856 : : uint32_t *attr_value)
857 : : {
858 : : struct rte_eventdev *dev;
859 : :
860 [ + - ]: 25 : if (!attr_value)
861 : : return -EINVAL;
862 [ + - ]: 25 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
863 : : dev = &rte_eventdevs[dev_id];
864 : :
865 [ + + - - ]: 25 : switch (attr_id) {
866 : 9 : case RTE_EVENT_DEV_ATTR_PORT_COUNT:
867 : 9 : *attr_value = dev->data->nb_ports;
868 : 9 : break;
869 : 16 : case RTE_EVENT_DEV_ATTR_QUEUE_COUNT:
870 : 16 : *attr_value = dev->data->nb_queues;
871 : 16 : break;
872 : 0 : case RTE_EVENT_DEV_ATTR_STARTED:
873 : 0 : *attr_value = dev->data->dev_started;
874 : 0 : break;
875 : : default:
876 : : return -EINVAL;
877 : : }
878 : :
879 [ - + ]: 25 : rte_eventdev_trace_attr_get(dev_id, dev, attr_id, *attr_value);
880 : :
881 : 25 : return 0;
882 : : }
883 : :
884 : : RTE_EXPORT_SYMBOL(rte_event_port_attr_get)
885 : : int
886 : 3 : rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
887 : : uint32_t *attr_value)
888 : : {
889 : : struct rte_eventdev *dev;
890 : :
891 [ + - ]: 3 : if (!attr_value)
892 : : return -EINVAL;
893 : :
894 [ + - ]: 3 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
895 : : dev = &rte_eventdevs[dev_id];
896 [ - + ]: 3 : if (!is_valid_port(dev, port_id)) {
897 : 0 : RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
898 : 0 : return -EINVAL;
899 : : }
900 : :
901 [ + + + - : 3 : switch (attr_id) {
- - ]
902 : 1 : case RTE_EVENT_PORT_ATTR_ENQ_DEPTH:
903 : 1 : *attr_value = dev->data->ports_cfg[port_id].enqueue_depth;
904 : 1 : break;
905 : 1 : case RTE_EVENT_PORT_ATTR_DEQ_DEPTH:
906 : 1 : *attr_value = dev->data->ports_cfg[port_id].dequeue_depth;
907 : 1 : break;
908 : 1 : case RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD:
909 : 1 : *attr_value = dev->data->ports_cfg[port_id].new_event_threshold;
910 : 1 : break;
911 : 0 : case RTE_EVENT_PORT_ATTR_IMPLICIT_RELEASE_DISABLE:
912 : : {
913 : : uint32_t config;
914 : :
915 : 0 : config = dev->data->ports_cfg[port_id].event_port_cfg;
916 : 0 : *attr_value = !!(config & RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL);
917 : 0 : break;
918 : : }
919 : 0 : case RTE_EVENT_PORT_ATTR_INDEPENDENT_ENQ:
920 : : {
921 : : uint32_t config;
922 : :
923 : 0 : config = dev->data->ports_cfg[port_id].event_port_cfg;
924 : 0 : *attr_value = !!(config & RTE_EVENT_PORT_CFG_INDEPENDENT_ENQ);
925 : 0 : break;
926 : : }
927 : : default:
928 : : return -EINVAL;
929 : : };
930 : :
931 [ - + ]: 3 : rte_eventdev_trace_port_attr_get(dev_id, dev, port_id, attr_id, *attr_value);
932 : :
933 : 3 : return 0;
934 : : }
935 : :
936 : : RTE_EXPORT_SYMBOL(rte_event_queue_attr_get)
937 : : int
938 : 256 : rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
939 : : uint32_t *attr_value)
940 : : {
941 : : struct rte_event_queue_conf *conf;
942 : : struct rte_eventdev *dev;
943 : :
944 [ + - ]: 256 : if (!attr_value)
945 : : return -EINVAL;
946 : :
947 [ + - ]: 256 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
948 : : dev = &rte_eventdevs[dev_id];
949 [ - + ]: 256 : if (!is_valid_queue(dev, queue_id)) {
950 : 0 : RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
951 : 0 : return -EINVAL;
952 : : }
953 : :
954 : : conf = &dev->data->queues_cfg[queue_id];
955 : :
956 [ + + + + : 256 : switch (attr_id) {
- - - - ]
957 : 64 : case RTE_EVENT_QUEUE_ATTR_PRIORITY:
958 : 64 : *attr_value = RTE_EVENT_DEV_PRIORITY_NORMAL;
959 [ + - ]: 64 : if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
960 : 64 : *attr_value = conf->priority;
961 : : break;
962 : 64 : case RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS:
963 : 64 : *attr_value = conf->nb_atomic_flows;
964 : 64 : break;
965 : 64 : case RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES:
966 : 64 : *attr_value = conf->nb_atomic_order_sequences;
967 : 64 : break;
968 : 64 : case RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG:
969 : 64 : *attr_value = conf->event_queue_cfg;
970 : 64 : break;
971 : 0 : case RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE:
972 [ # # ]: 0 : if (conf->event_queue_cfg & RTE_EVENT_QUEUE_CFG_ALL_TYPES)
973 : : return -EOVERFLOW;
974 : :
975 : 0 : *attr_value = conf->schedule_type;
976 : 0 : break;
977 : 0 : case RTE_EVENT_QUEUE_ATTR_WEIGHT:
978 : 0 : *attr_value = RTE_EVENT_QUEUE_WEIGHT_LOWEST;
979 [ # # ]: 0 : if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
980 : 0 : *attr_value = conf->weight;
981 : : break;
982 : 0 : case RTE_EVENT_QUEUE_ATTR_AFFINITY:
983 : 0 : *attr_value = RTE_EVENT_QUEUE_AFFINITY_LOWEST;
984 [ # # ]: 0 : if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
985 : 0 : *attr_value = conf->affinity;
986 : : break;
987 : : default:
988 : : return -EINVAL;
989 : : };
990 : :
991 [ - + ]: 256 : rte_eventdev_trace_queue_attr_get(dev_id, dev, queue_id, attr_id, *attr_value);
992 : :
993 : 256 : return 0;
994 : : }
995 : :
996 : : RTE_EXPORT_SYMBOL(rte_event_queue_attr_set)
997 : : int
998 : 0 : rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
999 : : uint64_t attr_value)
1000 : : {
1001 : : struct rte_eventdev *dev;
1002 : :
1003 [ # # # # ]: 0 : rte_eventdev_trace_queue_attr_set(dev_id, queue_id, attr_id, attr_value);
1004 : :
1005 : 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1006 : : dev = &rte_eventdevs[dev_id];
1007 : : if (!is_valid_queue(dev, queue_id)) {
1008 : 0 : RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
1009 : 0 : return -EINVAL;
1010 : : }
1011 : :
1012 [ # # ]: 0 : if (!(dev->data->event_dev_cap &
1013 : : RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR)) {
1014 : 0 : RTE_EDEV_LOG_ERR(
1015 : : "Device %" PRIu8 "does not support changing queue attributes at runtime",
1016 : : dev_id);
1017 : 0 : return -ENOTSUP;
1018 : : }
1019 : :
1020 [ # # ]: 0 : if (dev->dev_ops->queue_attr_set == NULL)
1021 : : return -ENOTSUP;
1022 : 0 : return dev->dev_ops->queue_attr_set(dev, queue_id, attr_id, attr_value);
1023 : : }
1024 : :
1025 : : RTE_EXPORT_SYMBOL(rte_event_port_link)
1026 : : int
1027 : 101 : rte_event_port_link(uint8_t dev_id, uint8_t port_id,
1028 : : const uint8_t queues[], const uint8_t priorities[],
1029 : : uint16_t nb_links)
1030 : : {
1031 : 101 : return rte_event_port_profile_links_set(dev_id, port_id, queues, priorities, nb_links, 0);
1032 : : }
1033 : :
1034 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_event_port_profile_links_set, 23.11)
1035 : : int
1036 : 101 : rte_event_port_profile_links_set(uint8_t dev_id, uint8_t port_id, const uint8_t queues[],
1037 : : const uint8_t priorities[], uint16_t nb_links, uint8_t profile_id)
1038 : : {
1039 : : uint8_t priorities_list[RTE_EVENT_MAX_QUEUES_PER_DEV];
1040 : : uint8_t queues_list[RTE_EVENT_MAX_QUEUES_PER_DEV];
1041 : : struct rte_event_dev_info info;
1042 : : struct rte_eventdev *dev;
1043 : : uint16_t *links_map;
1044 : : int i, diag;
1045 : :
1046 [ + - ]: 101 : RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, EINVAL, 0);
1047 : : dev = &rte_eventdevs[dev_id];
1048 : :
1049 [ + - ]: 101 : if (dev->dev_ops->dev_infos_get == NULL)
1050 : : return -ENOTSUP;
1051 : :
1052 : 101 : dev->dev_ops->dev_infos_get(dev, &info);
1053 [ + - ]: 101 : if (profile_id >= RTE_EVENT_MAX_PROFILES_PER_PORT ||
1054 [ - + ]: 101 : profile_id >= info.max_profiles_per_port) {
1055 : 0 : RTE_EDEV_LOG_ERR("Invalid profile_id=%" PRIu8, profile_id);
1056 : 0 : return -EINVAL;
1057 : : }
1058 : :
1059 [ - + ]: 101 : if (dev->dev_ops->port_link == NULL) {
1060 : 0 : RTE_EDEV_LOG_ERR("Function not supported");
1061 : 0 : rte_errno = ENOTSUP;
1062 : 0 : return 0;
1063 : : }
1064 : :
1065 [ - + - - ]: 101 : if (profile_id && dev->dev_ops->port_link_profile == NULL) {
1066 : 0 : RTE_EDEV_LOG_ERR("Function not supported");
1067 : 0 : rte_errno = ENOTSUP;
1068 : 0 : return 0;
1069 : : }
1070 : :
1071 [ - + ]: 101 : if (!is_valid_port(dev, port_id)) {
1072 : 0 : RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
1073 : 0 : rte_errno = EINVAL;
1074 : 0 : return 0;
1075 : : }
1076 : :
1077 [ + + ]: 101 : if (queues == NULL) {
1078 [ + + ]: 868 : for (i = 0; i < dev->data->nb_queues; i++)
1079 : 815 : queues_list[i] = i;
1080 : :
1081 : : queues = queues_list;
1082 : 53 : nb_links = dev->data->nb_queues;
1083 : : }
1084 : :
1085 [ + + ]: 101 : if (priorities == NULL) {
1086 [ + + ]: 940 : for (i = 0; i < nb_links; i++)
1087 : 851 : priorities_list[i] = RTE_EVENT_DEV_PRIORITY_NORMAL;
1088 : :
1089 : : priorities = priorities_list;
1090 : : }
1091 : :
1092 [ + + ]: 1093 : for (i = 0; i < nb_links; i++)
1093 [ - + ]: 992 : if (queues[i] >= dev->data->nb_queues) {
1094 : 0 : rte_errno = EINVAL;
1095 : 0 : return 0;
1096 : : }
1097 : :
1098 [ - + ]: 101 : if (profile_id)
1099 : 0 : diag = dev->dev_ops->port_link_profile(dev, dev->data->ports[port_id], queues,
1100 : : priorities, nb_links, profile_id);
1101 : : else
1102 : 101 : diag = dev->dev_ops->port_link(dev, dev->data->ports[port_id], queues,
1103 : : priorities, nb_links);
1104 [ + - ]: 101 : if (diag < 0)
1105 : : return diag;
1106 : :
1107 : 101 : links_map = dev->data->links_map[profile_id];
1108 : : /* Point links_map to this port specific area */
1109 : 101 : links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
1110 [ + + ]: 1093 : for (i = 0; i < diag; i++)
1111 : 992 : links_map[queues[i]] = (uint8_t)priorities[i];
1112 : :
1113 : 101 : rte_eventdev_trace_port_profile_links_set(dev_id, port_id, nb_links, profile_id, diag);
1114 : 101 : return diag;
1115 : : }
1116 : :
1117 : : RTE_EXPORT_SYMBOL(rte_event_port_unlink)
1118 : : int
1119 : 328 : rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
1120 : : uint8_t queues[], uint16_t nb_unlinks)
1121 : : {
1122 : 328 : return rte_event_port_profile_unlink(dev_id, port_id, queues, nb_unlinks, 0);
1123 : : }
1124 : :
1125 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_event_port_profile_unlink, 23.11)
1126 : : int
1127 : 328 : rte_event_port_profile_unlink(uint8_t dev_id, uint8_t port_id, uint8_t queues[],
1128 : : uint16_t nb_unlinks, uint8_t profile_id)
1129 : : {
1130 : : uint8_t all_queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
1131 : : struct rte_event_dev_info info;
1132 : : struct rte_eventdev *dev;
1133 : : uint16_t *links_map;
1134 : : int i, diag, j;
1135 : :
1136 [ + - ]: 328 : RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, EINVAL, 0);
1137 : : dev = &rte_eventdevs[dev_id];
1138 : :
1139 [ + - ]: 328 : if (dev->dev_ops->dev_infos_get == NULL)
1140 : : return -ENOTSUP;
1141 : :
1142 : 328 : dev->dev_ops->dev_infos_get(dev, &info);
1143 [ + - ]: 328 : if (profile_id >= RTE_EVENT_MAX_PROFILES_PER_PORT ||
1144 [ - + ]: 328 : profile_id >= info.max_profiles_per_port) {
1145 : 0 : RTE_EDEV_LOG_ERR("Invalid profile_id=%" PRIu8, profile_id);
1146 : 0 : return -EINVAL;
1147 : : }
1148 : :
1149 [ - + ]: 328 : if (dev->dev_ops->port_unlink == NULL) {
1150 : 0 : RTE_EDEV_LOG_ERR("Function not supported");
1151 : 0 : rte_errno = ENOTSUP;
1152 : 0 : return 0;
1153 : : }
1154 : :
1155 [ - + - - ]: 328 : if (profile_id && dev->dev_ops->port_unlink_profile == NULL) {
1156 : 0 : RTE_EDEV_LOG_ERR("Function not supported");
1157 : 0 : rte_errno = ENOTSUP;
1158 : 0 : return 0;
1159 : : }
1160 : :
1161 [ - + ]: 328 : if (!is_valid_port(dev, port_id)) {
1162 : 0 : RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
1163 : 0 : rte_errno = EINVAL;
1164 : 0 : return 0;
1165 : : }
1166 : :
1167 : 328 : links_map = dev->data->links_map[profile_id];
1168 : : /* Point links_map to this port specific area */
1169 : 328 : links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
1170 : :
1171 [ + + ]: 328 : if (queues == NULL) {
1172 : : j = 0;
1173 [ + + ]: 15440 : for (i = 0; i < dev->data->nb_queues; i++) {
1174 [ + + ]: 15116 : if (links_map[i] !=
1175 : : EVENT_QUEUE_SERVICE_PRIORITY_INVALID) {
1176 : 349 : all_queues[j] = i;
1177 : 349 : j++;
1178 : : }
1179 : : }
1180 : : queues = all_queues;
1181 : : } else {
1182 [ + + ]: 135 : for (j = 0; j < nb_unlinks; j++) {
1183 [ + - ]: 131 : if (links_map[queues[j]] ==
1184 : : EVENT_QUEUE_SERVICE_PRIORITY_INVALID)
1185 : : break;
1186 : : }
1187 : : }
1188 : :
1189 : 328 : nb_unlinks = j;
1190 [ + + ]: 808 : for (i = 0; i < nb_unlinks; i++)
1191 [ - + ]: 480 : if (queues[i] >= dev->data->nb_queues) {
1192 : 0 : rte_errno = EINVAL;
1193 : 0 : return 0;
1194 : : }
1195 : :
1196 [ - + ]: 328 : if (profile_id)
1197 : 0 : diag = dev->dev_ops->port_unlink_profile(dev, dev->data->ports[port_id], queues,
1198 : : nb_unlinks, profile_id);
1199 : : else
1200 : 328 : diag = dev->dev_ops->port_unlink(dev, dev->data->ports[port_id], queues,
1201 : : nb_unlinks);
1202 [ + - ]: 328 : if (diag < 0)
1203 : : return diag;
1204 : :
1205 [ + + ]: 722 : for (i = 0; i < diag; i++)
1206 : 394 : links_map[queues[i]] = EVENT_QUEUE_SERVICE_PRIORITY_INVALID;
1207 : :
1208 : 328 : rte_eventdev_trace_port_profile_unlink(dev_id, port_id, nb_unlinks, profile_id, diag);
1209 : 328 : return diag;
1210 : : }
1211 : :
1212 : : RTE_EXPORT_SYMBOL(rte_event_port_unlinks_in_progress)
1213 : : int
1214 : 2 : rte_event_port_unlinks_in_progress(uint8_t dev_id, uint8_t port_id)
1215 : : {
1216 : : struct rte_eventdev *dev;
1217 : :
1218 [ - + + - ]: 2 : rte_eventdev_trace_port_unlinks_in_progress(dev_id, port_id);
1219 : :
1220 : 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1221 : : dev = &rte_eventdevs[dev_id];
1222 : : if (!is_valid_port(dev, port_id)) {
1223 : 0 : RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
1224 : 0 : return -EINVAL;
1225 : : }
1226 : :
1227 : : /* Return 0 if the PMD does not implement unlinks in progress.
1228 : : * This allows PMDs which handle unlink synchronously to not implement
1229 : : * this function at all.
1230 : : */
1231 [ + - ]: 2 : if (dev->dev_ops->port_unlinks_in_progress == NULL)
1232 : : return 0;
1233 : :
1234 : 2 : return dev->dev_ops->port_unlinks_in_progress(dev, dev->data->ports[port_id]);
1235 : : }
1236 : :
1237 : : RTE_EXPORT_SYMBOL(rte_event_port_links_get)
1238 : : int
1239 : 5 : rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
1240 : : uint8_t queues[], uint8_t priorities[])
1241 : : {
1242 : : struct rte_eventdev *dev;
1243 : : uint16_t *links_map;
1244 : : int i, count = 0;
1245 : :
1246 [ + - ]: 5 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1247 : : dev = &rte_eventdevs[dev_id];
1248 [ - + ]: 5 : if (!is_valid_port(dev, port_id)) {
1249 : 0 : RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
1250 : 0 : return -EINVAL;
1251 : : }
1252 : :
1253 : : /* Use the default profile_id. */
1254 : 5 : links_map = dev->data->links_map[0];
1255 : : /* Point links_map to this port specific area */
1256 : 5 : links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
1257 [ + + ]: 263 : for (i = 0; i < dev->data->nb_queues; i++) {
1258 [ + + ]: 258 : if (links_map[i] != EVENT_QUEUE_SERVICE_PRIORITY_INVALID) {
1259 : 68 : queues[count] = i;
1260 : 68 : priorities[count] = (uint8_t)links_map[i];
1261 : 68 : ++count;
1262 : : }
1263 : : }
1264 : :
1265 : 5 : rte_eventdev_trace_port_links_get(dev_id, port_id, count);
1266 : :
1267 : 5 : return count;
1268 : : }
1269 : :
1270 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_event_port_profile_links_get, 23.11)
1271 : : int
1272 : 0 : rte_event_port_profile_links_get(uint8_t dev_id, uint8_t port_id, uint8_t queues[],
1273 : : uint8_t priorities[], uint8_t profile_id)
1274 : : {
1275 : : struct rte_event_dev_info info;
1276 : : struct rte_eventdev *dev;
1277 : : uint16_t *links_map;
1278 : : int i, count = 0;
1279 : :
1280 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1281 : :
1282 : : dev = &rte_eventdevs[dev_id];
1283 [ # # ]: 0 : if (dev->dev_ops->dev_infos_get == NULL)
1284 : : return -ENOTSUP;
1285 : :
1286 : 0 : dev->dev_ops->dev_infos_get(dev, &info);
1287 [ # # ]: 0 : if (profile_id >= RTE_EVENT_MAX_PROFILES_PER_PORT ||
1288 [ # # ]: 0 : profile_id >= info.max_profiles_per_port) {
1289 : 0 : RTE_EDEV_LOG_ERR("Invalid profile_id=%" PRIu8, profile_id);
1290 : 0 : return -EINVAL;
1291 : : }
1292 : :
1293 [ # # ]: 0 : if (!is_valid_port(dev, port_id)) {
1294 : 0 : RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
1295 : 0 : return -EINVAL;
1296 : : }
1297 : :
1298 : 0 : links_map = dev->data->links_map[profile_id];
1299 : : /* Point links_map to this port specific area */
1300 : 0 : links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
1301 [ # # ]: 0 : for (i = 0; i < dev->data->nb_queues; i++) {
1302 [ # # ]: 0 : if (links_map[i] != EVENT_QUEUE_SERVICE_PRIORITY_INVALID) {
1303 : 0 : queues[count] = i;
1304 : 0 : priorities[count] = (uint8_t)links_map[i];
1305 : 0 : ++count;
1306 : : }
1307 : : }
1308 : :
1309 : 0 : rte_eventdev_trace_port_profile_links_get(dev_id, port_id, profile_id, count);
1310 : :
1311 : 0 : return count;
1312 : : }
1313 : :
1314 : : RTE_EXPORT_SYMBOL(rte_event_dequeue_timeout_ticks)
1315 : : int
1316 : 1 : rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
1317 : : uint64_t *timeout_ticks)
1318 : : {
1319 : : struct rte_eventdev *dev;
1320 : :
1321 [ - + + - ]: 1 : rte_eventdev_trace_dequeue_timeout_ticks(dev_id, ns, timeout_ticks);
1322 : :
1323 : 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1324 : : dev = &rte_eventdevs[dev_id];
1325 [ + - ]: 1 : if (dev->dev_ops->timeout_ticks == NULL)
1326 : : return -ENOTSUP;
1327 : :
1328 [ + - ]: 1 : if (timeout_ticks == NULL)
1329 : : return -EINVAL;
1330 : :
1331 : 1 : return dev->dev_ops->timeout_ticks(dev, ns, timeout_ticks);
1332 : : }
1333 : :
1334 : : RTE_EXPORT_SYMBOL(rte_event_dev_service_id_get)
1335 : : int
1336 : 4 : rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id)
1337 : : {
1338 : : struct rte_eventdev *dev;
1339 : :
1340 [ + - ]: 4 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1341 : : dev = &rte_eventdevs[dev_id];
1342 : :
1343 [ + - ]: 4 : if (service_id == NULL)
1344 : : return -EINVAL;
1345 : :
1346 [ + - ]: 4 : if (dev->data->service_inited)
1347 : 4 : *service_id = dev->data->service_id;
1348 : :
1349 [ - + ]: 4 : rte_eventdev_trace_service_id_get(dev_id, *service_id);
1350 : :
1351 [ - + ]: 4 : return dev->data->service_inited ? 0 : -ESRCH;
1352 : : }
1353 : :
1354 : : RTE_EXPORT_SYMBOL(rte_event_dev_dump)
1355 : : int
1356 : 0 : rte_event_dev_dump(uint8_t dev_id, FILE *f)
1357 : : {
1358 : : struct rte_eventdev *dev;
1359 : :
1360 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1361 : : dev = &rte_eventdevs[dev_id];
1362 [ # # ]: 0 : if (dev->dev_ops->dump == NULL)
1363 : : return -ENOTSUP;
1364 [ # # ]: 0 : if (f == NULL)
1365 : : return -EINVAL;
1366 : :
1367 : 0 : dev->dev_ops->dump(dev, f);
1368 : 0 : return 0;
1369 : :
1370 : : }
1371 : :
1372 : : static int
1373 : : xstats_get_count(uint8_t dev_id, enum rte_event_dev_xstats_mode mode,
1374 : : uint8_t queue_port_id)
1375 : : {
1376 : : struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1377 : 776 : if (dev->dev_ops->xstats_get_names != NULL)
1378 : 776 : return dev->dev_ops->xstats_get_names(dev, mode, queue_port_id, NULL, NULL, 0);
1379 : : return 0;
1380 : : }
1381 : :
1382 : : RTE_EXPORT_SYMBOL(rte_event_dev_xstats_names_get)
1383 : : int
1384 : 776 : rte_event_dev_xstats_names_get(uint8_t dev_id,
1385 : : enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
1386 : : struct rte_event_dev_xstats_name *xstats_names,
1387 : : uint64_t *ids, unsigned int size)
1388 : : {
1389 [ + - ]: 776 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -ENODEV);
1390 [ + - ]: 776 : const int cnt_expected_entries = xstats_get_count(dev_id, mode,
1391 : : queue_port_id);
1392 [ + - ]: 776 : if (xstats_names == NULL || cnt_expected_entries < 0 ||
1393 [ + - ]: 776 : (int)size < cnt_expected_entries)
1394 : : return cnt_expected_entries;
1395 : :
1396 : : /* dev_id checked above */
1397 : 776 : const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1398 : :
1399 [ + - ]: 776 : if (dev->dev_ops->xstats_get_names != NULL)
1400 : 776 : return dev->dev_ops->xstats_get_names(dev, mode, queue_port_id,
1401 : : xstats_names, ids, size);
1402 : :
1403 : : return -ENOTSUP;
1404 : : }
1405 : :
1406 : : /* retrieve eventdev extended statistics */
1407 : : RTE_EXPORT_SYMBOL(rte_event_dev_xstats_get)
1408 : : int
1409 : 778 : rte_event_dev_xstats_get(uint8_t dev_id, enum rte_event_dev_xstats_mode mode,
1410 : : uint8_t queue_port_id, const uint64_t ids[],
1411 : : uint64_t values[], unsigned int n)
1412 : : {
1413 [ + - ]: 778 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -ENODEV);
1414 : : const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1415 : :
1416 : : /* implemented by the driver */
1417 [ + - ]: 778 : if (dev->dev_ops->xstats_get != NULL)
1418 : 778 : return dev->dev_ops->xstats_get(dev, mode, queue_port_id,
1419 : : ids, values, n);
1420 : : return -ENOTSUP;
1421 : : }
1422 : :
1423 : : RTE_EXPORT_SYMBOL(rte_event_dev_xstats_by_name_get)
1424 : : uint64_t
1425 : 2427 : rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
1426 : : uint64_t *id)
1427 : : {
1428 [ + - ]: 2427 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, 0);
1429 : : const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1430 : 2427 : uint64_t temp = -1;
1431 : :
1432 [ + + ]: 2427 : if (id != NULL)
1433 : 2345 : *id = (unsigned int)-1;
1434 : : else
1435 : : id = &temp; /* ensure driver never gets a NULL value */
1436 : :
1437 : : /* implemented by driver */
1438 [ + - ]: 2427 : if (dev->dev_ops->xstats_get_by_name != NULL)
1439 : 2427 : return dev->dev_ops->xstats_get_by_name(dev, name, id);
1440 : : return -ENOTSUP;
1441 : : }
1442 : :
1443 : : RTE_EXPORT_SYMBOL(rte_event_dev_xstats_reset)
1444 : 48 : int rte_event_dev_xstats_reset(uint8_t dev_id,
1445 : : enum rte_event_dev_xstats_mode mode, int16_t queue_port_id,
1446 : : const uint64_t ids[], uint32_t nb_ids)
1447 : : {
1448 [ + - ]: 48 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1449 : : struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1450 : :
1451 [ + - ]: 48 : if (dev->dev_ops->xstats_reset != NULL)
1452 : 48 : return dev->dev_ops->xstats_reset(dev, mode, queue_port_id, ids, nb_ids);
1453 : : return -ENOTSUP;
1454 : : }
1455 : :
1456 : : RTE_EXPORT_INTERNAL_SYMBOL(rte_event_pmd_selftest_seqn_dynfield_offset)
1457 : : int rte_event_pmd_selftest_seqn_dynfield_offset = -1;
1458 : :
1459 : : RTE_EXPORT_SYMBOL(rte_event_dev_selftest)
1460 : 1 : int rte_event_dev_selftest(uint8_t dev_id)
1461 : : {
1462 [ + - ]: 1 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1463 : : static const struct rte_mbuf_dynfield test_seqn_dynfield_desc = {
1464 : : .name = "rte_event_pmd_selftest_seqn_dynfield",
1465 : : .size = sizeof(rte_event_pmd_selftest_seqn_t),
1466 : : .align = alignof(rte_event_pmd_selftest_seqn_t),
1467 : : };
1468 : : struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1469 : :
1470 [ + - ]: 1 : if (dev->dev_ops->dev_selftest != NULL) {
1471 : 1 : rte_event_pmd_selftest_seqn_dynfield_offset =
1472 : 1 : rte_mbuf_dynfield_register(&test_seqn_dynfield_desc);
1473 [ + - ]: 1 : if (rte_event_pmd_selftest_seqn_dynfield_offset < 0)
1474 : : return -ENOMEM;
1475 : 1 : return dev->dev_ops->dev_selftest();
1476 : : }
1477 : : return -ENOTSUP;
1478 : : }
1479 : :
1480 : : RTE_EXPORT_SYMBOL(rte_event_vector_pool_create)
1481 : : struct rte_mempool *
1482 : 9 : rte_event_vector_pool_create(const char *name, unsigned int n,
1483 : : unsigned int cache_size, uint16_t nb_elem,
1484 : : int socket_id)
1485 : : {
1486 : : const char *mp_ops_name;
1487 : : struct rte_mempool *mp;
1488 : : unsigned int elt_sz;
1489 : : int ret;
1490 : :
1491 [ - + ]: 9 : if (!nb_elem) {
1492 : 0 : RTE_EDEV_LOG_ERR("Invalid number of elements=%d requested",
1493 : : nb_elem);
1494 : 0 : rte_errno = EINVAL;
1495 : 0 : return NULL;
1496 : : }
1497 : :
1498 : 9 : elt_sz =
1499 : 9 : sizeof(struct rte_event_vector) + (nb_elem * sizeof(uintptr_t));
1500 : 9 : mp = rte_mempool_create_empty(name, n, elt_sz, cache_size, 0, socket_id,
1501 : : 0);
1502 [ + - ]: 9 : if (mp == NULL)
1503 : : return NULL;
1504 : :
1505 : 9 : mp_ops_name = rte_mbuf_best_mempool_ops();
1506 : 9 : ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL);
1507 [ - + ]: 9 : if (ret != 0) {
1508 : 0 : RTE_EDEV_LOG_ERR("error setting mempool handler");
1509 : 0 : goto err;
1510 : : }
1511 : :
1512 : 9 : ret = rte_mempool_populate_default(mp);
1513 [ - + ]: 9 : if (ret < 0)
1514 : 0 : goto err;
1515 : :
1516 [ - + ]: 9 : rte_eventdev_trace_vector_pool_create(mp, mp->name, mp->socket_id,
1517 : : mp->size, mp->cache_size, mp->elt_size);
1518 : :
1519 : 9 : return mp;
1520 : 0 : err:
1521 : 0 : rte_mempool_free(mp);
1522 : 0 : rte_errno = -ret;
1523 : 0 : return NULL;
1524 : : }
1525 : :
1526 : : RTE_EXPORT_SYMBOL(rte_event_dev_start)
1527 : : int
1528 : 73 : rte_event_dev_start(uint8_t dev_id)
1529 : : {
1530 : : struct rte_eventdev *dev;
1531 : : int diag;
1532 : :
1533 : : RTE_EDEV_LOG_DEBUG("Start dev_id=%" PRIu8, dev_id);
1534 : :
1535 [ + - ]: 73 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1536 : : dev = &rte_eventdevs[dev_id];
1537 [ + - ]: 73 : if (dev->dev_ops->dev_start == NULL)
1538 : : return -ENOTSUP;
1539 : :
1540 [ - + ]: 73 : if (dev->data->dev_started != 0) {
1541 : 0 : RTE_EDEV_LOG_ERR("Device with dev_id=%" PRIu8 "already started",
1542 : : dev_id);
1543 : 0 : return 0;
1544 : : }
1545 : :
1546 : 73 : diag = (dev->dev_ops->dev_start)(dev);
1547 : 73 : rte_eventdev_trace_start(dev_id, diag);
1548 [ + - ]: 73 : if (diag == 0)
1549 : 73 : dev->data->dev_started = 1;
1550 : : else
1551 : : return diag;
1552 : :
1553 : 73 : event_dev_fp_ops_set(rte_event_fp_ops + dev_id, dev);
1554 : :
1555 : 73 : return 0;
1556 : : }
1557 : :
1558 : : RTE_EXPORT_SYMBOL(rte_event_dev_stop_flush_callback_register)
1559 : : int
1560 : 2 : rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
1561 : : rte_eventdev_stop_flush_t callback,
1562 : : void *userdata)
1563 : : {
1564 : : struct rte_eventdev *dev;
1565 : :
1566 : : RTE_EDEV_LOG_DEBUG("Stop flush register dev_id=%" PRIu8, dev_id);
1567 : :
1568 [ - + + - ]: 2 : rte_eventdev_trace_stop_flush_callback_register(dev_id, callback, userdata);
1569 : :
1570 : 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1571 : : dev = &rte_eventdevs[dev_id];
1572 : :
1573 : 2 : dev->dev_ops->dev_stop_flush = callback;
1574 : 2 : dev->data->dev_stop_flush_arg = userdata;
1575 : :
1576 : 2 : return 0;
1577 : : }
1578 : :
1579 : : RTE_EXPORT_SYMBOL(rte_event_dev_stop)
1580 : : void
1581 : 77 : rte_event_dev_stop(uint8_t dev_id)
1582 : : {
1583 : : struct rte_eventdev *dev;
1584 : :
1585 : : RTE_EDEV_LOG_DEBUG("Stop dev_id=%" PRIu8, dev_id);
1586 : :
1587 [ + - ]: 77 : RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id);
1588 : : dev = &rte_eventdevs[dev_id];
1589 [ + - ]: 77 : if (dev->dev_ops->dev_stop == NULL)
1590 : : return;
1591 : :
1592 [ + + ]: 77 : if (dev->data->dev_started == 0) {
1593 : 4 : RTE_EDEV_LOG_ERR("Device with dev_id=%" PRIu8 "already stopped",
1594 : : dev_id);
1595 : 4 : return;
1596 : : }
1597 : :
1598 : 73 : dev->data->dev_started = 0;
1599 : 73 : dev->dev_ops->dev_stop(dev);
1600 : 73 : rte_eventdev_trace_stop(dev_id);
1601 : 73 : event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
1602 : : }
1603 : :
1604 : : RTE_EXPORT_SYMBOL(rte_event_dev_close)
1605 : : int
1606 : 34 : rte_event_dev_close(uint8_t dev_id)
1607 : : {
1608 : : struct rte_eventdev *dev;
1609 : :
1610 [ + - ]: 34 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1611 : : dev = &rte_eventdevs[dev_id];
1612 [ + - ]: 34 : if (dev->dev_ops->dev_close == NULL)
1613 : : return -ENOTSUP;
1614 : :
1615 : : /* Device must be stopped before it can be closed */
1616 [ - + ]: 34 : if (dev->data->dev_started == 1) {
1617 : 0 : RTE_EDEV_LOG_ERR("Device %u must be stopped before closing",
1618 : : dev_id);
1619 : 0 : return -EBUSY;
1620 : : }
1621 : :
1622 : 34 : event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
1623 : 34 : rte_eventdev_trace_close(dev_id);
1624 : 34 : return dev->dev_ops->dev_close(dev);
1625 : : }
1626 : :
1627 : : static inline int
1628 : 5 : eventdev_data_alloc(uint8_t dev_id, struct rte_eventdev_data **data,
1629 : : int socket_id)
1630 : : {
1631 : : char mz_name[RTE_EVENTDEV_NAME_MAX_LEN];
1632 : : const struct rte_memzone *mz;
1633 : : int i, n;
1634 : :
1635 : : /* Generate memzone name */
1636 [ + - ]: 5 : n = snprintf(mz_name, sizeof(mz_name), "rte_eventdev_data_%u", dev_id);
1637 [ + - ]: 5 : if (n >= (int)sizeof(mz_name))
1638 : : return -EINVAL;
1639 : :
1640 [ + - ]: 5 : if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
1641 : 5 : mz = rte_memzone_reserve(mz_name,
1642 : : sizeof(struct rte_eventdev_data),
1643 : : socket_id, 0);
1644 : : } else
1645 : 0 : mz = rte_memzone_lookup(mz_name);
1646 : :
1647 [ + - ]: 5 : if (mz == NULL)
1648 : : return -ENOMEM;
1649 : :
1650 : 5 : *data = mz->addr;
1651 [ + - ]: 5 : if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
1652 : 5 : memset(*data, 0, sizeof(struct rte_eventdev_data));
1653 [ + + ]: 45 : for (i = 0; i < RTE_EVENT_MAX_PROFILES_PER_PORT; i++)
1654 [ + + ]: 2601040 : for (n = 0; n < RTE_EVENT_MAX_PORTS_PER_DEV * RTE_EVENT_MAX_QUEUES_PER_DEV;
1655 : 2601000 : n++)
1656 : 2601000 : (*data)->links_map[i][n] = EVENT_QUEUE_SERVICE_PRIORITY_INVALID;
1657 : : }
1658 : :
1659 : : return 0;
1660 : : }
1661 : :
1662 : : static inline uint8_t
1663 : : eventdev_find_free_device_index(void)
1664 : : {
1665 : : uint8_t dev_id;
1666 : :
1667 [ + - ]: 5 : for (dev_id = 0; dev_id < RTE_EVENT_MAX_DEVS; dev_id++) {
1668 [ - + ]: 5 : if (rte_eventdevs[dev_id].attached ==
1669 : : RTE_EVENTDEV_DETACHED)
1670 : : return dev_id;
1671 : : }
1672 : : return RTE_EVENT_MAX_DEVS;
1673 : : }
1674 : :
1675 : : RTE_EXPORT_INTERNAL_SYMBOL(rte_event_pmd_allocate)
1676 : : struct rte_eventdev *
1677 : 5 : rte_event_pmd_allocate(const char *name, int socket_id)
1678 : : {
1679 : : struct rte_eventdev *eventdev;
1680 : : uint8_t dev_id;
1681 : :
1682 [ - + ]: 5 : if (rte_event_pmd_get_named_dev(name) != NULL) {
1683 : 0 : RTE_EDEV_LOG_ERR("Event device with name %s already "
1684 : : "allocated!", name);
1685 : 0 : return NULL;
1686 : : }
1687 : :
1688 : : dev_id = eventdev_find_free_device_index();
1689 [ - + ]: 5 : if (dev_id == RTE_EVENT_MAX_DEVS) {
1690 : 0 : RTE_EDEV_LOG_ERR("Reached maximum number of event devices");
1691 : 0 : return NULL;
1692 : : }
1693 : :
1694 : 5 : eventdev = &rte_eventdevs[dev_id];
1695 : :
1696 [ + - ]: 5 : if (eventdev->data == NULL) {
1697 : 5 : struct rte_eventdev_data *eventdev_data = NULL;
1698 : :
1699 : : int retval =
1700 : 5 : eventdev_data_alloc(dev_id, &eventdev_data, socket_id);
1701 : :
1702 [ + - - + ]: 5 : if (retval < 0 || eventdev_data == NULL)
1703 : 0 : return NULL;
1704 : :
1705 : 5 : eventdev->data = eventdev_data;
1706 : :
1707 [ + - ]: 5 : if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
1708 : :
1709 : 5 : strlcpy(eventdev->data->name, name,
1710 : : RTE_EVENTDEV_NAME_MAX_LEN);
1711 : :
1712 : 5 : eventdev->data->dev_id = dev_id;
1713 : 5 : eventdev->data->socket_id = socket_id;
1714 : 5 : eventdev->data->dev_started = 0;
1715 : : }
1716 : :
1717 : 5 : eventdev->attached = RTE_EVENTDEV_ATTACHED;
1718 : 5 : eventdev_globals.nb_devs++;
1719 : : }
1720 : :
1721 : : return eventdev;
1722 : : }
1723 : :
1724 : : RTE_EXPORT_INTERNAL_SYMBOL(rte_event_pmd_release)
1725 : : int
1726 : 5 : rte_event_pmd_release(struct rte_eventdev *eventdev)
1727 : : {
1728 : : int ret;
1729 : : char mz_name[RTE_EVENTDEV_NAME_MAX_LEN];
1730 : : const struct rte_memzone *mz;
1731 : :
1732 [ + - ]: 5 : if (eventdev == NULL)
1733 : : return -EINVAL;
1734 : :
1735 : 5 : event_dev_fp_ops_reset(rte_event_fp_ops + eventdev->data->dev_id);
1736 : 5 : eventdev->attached = RTE_EVENTDEV_DETACHED;
1737 : 5 : eventdev_globals.nb_devs--;
1738 : :
1739 [ + - ]: 5 : if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
1740 : 5 : rte_free(eventdev->data->dev_private);
1741 : :
1742 : : /* Generate memzone name */
1743 : 5 : ret = snprintf(mz_name, sizeof(mz_name), "rte_eventdev_data_%u",
1744 [ + - ]: 5 : eventdev->data->dev_id);
1745 [ + - ]: 5 : if (ret >= (int)sizeof(mz_name))
1746 : : return -EINVAL;
1747 : :
1748 : 5 : mz = rte_memzone_lookup(mz_name);
1749 [ + - ]: 5 : if (mz == NULL)
1750 : : return -ENOMEM;
1751 : :
1752 : 5 : ret = rte_memzone_free(mz);
1753 [ + - ]: 5 : if (ret)
1754 : : return ret;
1755 : : }
1756 : :
1757 : 5 : eventdev->data = NULL;
1758 : 5 : return 0;
1759 : : }
1760 : :
1761 : : RTE_EXPORT_INTERNAL_SYMBOL(event_dev_probing_finish)
1762 : : void
1763 : 5 : event_dev_probing_finish(struct rte_eventdev *eventdev)
1764 : : {
1765 [ + - ]: 5 : if (eventdev == NULL)
1766 : : return;
1767 : :
1768 : 5 : event_dev_fp_ops_set(rte_event_fp_ops + eventdev->data->dev_id,
1769 : : eventdev);
1770 : : }
1771 : :
1772 : : static int
1773 : 0 : handle_dev_list(const char *cmd __rte_unused,
1774 : : const char *params __rte_unused,
1775 : : struct rte_tel_data *d)
1776 : : {
1777 : : uint8_t dev_id;
1778 : 0 : int ndev = rte_event_dev_count();
1779 : :
1780 [ # # ]: 0 : if (ndev < 1)
1781 : : return -1;
1782 : :
1783 : 0 : rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
1784 [ # # ]: 0 : for (dev_id = 0; dev_id < RTE_EVENT_MAX_DEVS; dev_id++) {
1785 [ # # ]: 0 : if (rte_eventdevs[dev_id].attached ==
1786 : : RTE_EVENTDEV_ATTACHED)
1787 : 0 : rte_tel_data_add_array_int(d, dev_id);
1788 : : }
1789 : :
1790 : : return 0;
1791 : : }
1792 : :
1793 : : static int
1794 : 0 : handle_dev_info(const char *cmd __rte_unused,
1795 : : const char *params,
1796 : : struct rte_tel_data *d)
1797 : : {
1798 : : uint8_t dev_id;
1799 : : struct rte_eventdev *dev;
1800 : : char *end_param;
1801 : :
1802 [ # # # # : 0 : if (params == NULL || strlen(params) == 0 || !isdigit(*params))
# # ]
1803 : : return -1;
1804 : :
1805 : 0 : dev_id = strtoul(params, &end_param, 10);
1806 : : if (*end_param != '\0')
1807 : : RTE_EDEV_LOG_DEBUG(
1808 : : "Extra parameters passed to eventdev telemetry command, ignoring");
1809 : :
1810 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1811 : : dev = &rte_eventdevs[dev_id];
1812 : :
1813 : 0 : rte_tel_data_start_dict(d);
1814 : 0 : rte_tel_data_add_dict_int(d, "dev_id", dev_id);
1815 : 0 : rte_tel_data_add_dict_string(d, "dev_name", dev->dev->name);
1816 : 0 : rte_tel_data_add_dict_string(d, "dev_driver", dev->dev->driver->name);
1817 : 0 : rte_tel_data_add_dict_string(d, "state",
1818 [ # # ]: 0 : dev->data->dev_started ? "started" : "stopped");
1819 : 0 : rte_tel_data_add_dict_int(d, "socket_id", dev->data->socket_id);
1820 : 0 : rte_tel_data_add_dict_int(d, "nb_queues", dev->data->nb_queues);
1821 : 0 : rte_tel_data_add_dict_int(d, "nb_ports", dev->data->nb_ports);
1822 : 0 : rte_tel_data_add_dict_uint_hex(d, "capabilities", dev->data->event_dev_cap,
1823 : : sizeof(dev->data->event_dev_cap) * CHAR_BIT);
1824 : :
1825 : 0 : return 0;
1826 : : }
1827 : :
1828 : : static int
1829 : 0 : handle_port_list(const char *cmd __rte_unused,
1830 : : const char *params,
1831 : : struct rte_tel_data *d)
1832 : : {
1833 : : int i;
1834 : : uint8_t dev_id;
1835 : : struct rte_eventdev *dev;
1836 : : char *end_param;
1837 : :
1838 [ # # # # : 0 : if (params == NULL || strlen(params) == 0 || !isdigit(*params))
# # ]
1839 : : return -1;
1840 : :
1841 : 0 : dev_id = strtoul(params, &end_param, 10);
1842 : : if (*end_param != '\0')
1843 : : RTE_EDEV_LOG_DEBUG(
1844 : : "Extra parameters passed to eventdev telemetry command, ignoring");
1845 : :
1846 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1847 : : dev = &rte_eventdevs[dev_id];
1848 : :
1849 : 0 : rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
1850 [ # # ]: 0 : for (i = 0; i < dev->data->nb_ports; i++)
1851 : 0 : rte_tel_data_add_array_int(d, i);
1852 : :
1853 : : return 0;
1854 : : }
1855 : :
1856 : : static int
1857 : 0 : handle_queue_list(const char *cmd __rte_unused,
1858 : : const char *params,
1859 : : struct rte_tel_data *d)
1860 : : {
1861 : : int i;
1862 : : uint8_t dev_id;
1863 : : struct rte_eventdev *dev;
1864 : : char *end_param;
1865 : :
1866 [ # # # # : 0 : if (params == NULL || strlen(params) == 0 || !isdigit(*params))
# # ]
1867 : : return -1;
1868 : :
1869 : 0 : dev_id = strtoul(params, &end_param, 10);
1870 : : if (*end_param != '\0')
1871 : : RTE_EDEV_LOG_DEBUG(
1872 : : "Extra parameters passed to eventdev telemetry command, ignoring");
1873 : :
1874 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1875 : : dev = &rte_eventdevs[dev_id];
1876 : :
1877 : 0 : rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
1878 [ # # ]: 0 : for (i = 0; i < dev->data->nb_queues; i++)
1879 : 0 : rte_tel_data_add_array_int(d, i);
1880 : :
1881 : : return 0;
1882 : : }
1883 : :
1884 : : static int
1885 : 0 : handle_queue_links(const char *cmd __rte_unused,
1886 : : const char *params,
1887 : : struct rte_tel_data *d)
1888 : : {
1889 : : int i, ret, port_id = 0;
1890 : : char *end_param;
1891 : : uint8_t dev_id;
1892 : : uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
1893 : : uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV];
1894 : : const char *p_param;
1895 : :
1896 [ # # # # : 0 : if (params == NULL || strlen(params) == 0 || !isdigit(*params))
# # ]
1897 : : return -1;
1898 : :
1899 : : /* Get dev ID from parameter string */
1900 : 0 : dev_id = strtoul(params, &end_param, 10);
1901 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
1902 : :
1903 : 0 : p_param = strtok(end_param, ",");
1904 [ # # # # : 0 : if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param))
# # ]
1905 : : return -1;
1906 : :
1907 : 0 : port_id = strtoul(p_param, &end_param, 10);
1908 : 0 : p_param = strtok(NULL, "\0");
1909 : : if (p_param != NULL)
1910 : : RTE_EDEV_LOG_DEBUG(
1911 : : "Extra parameters passed to eventdev telemetry command, ignoring");
1912 : :
1913 : 0 : ret = rte_event_port_links_get(dev_id, port_id, queues, priorities);
1914 [ # # ]: 0 : if (ret < 0)
1915 : : return -1;
1916 : :
1917 : 0 : rte_tel_data_start_dict(d);
1918 [ # # ]: 0 : for (i = 0; i < ret; i++) {
1919 : : char qid_name[32];
1920 : :
1921 : 0 : snprintf(qid_name, 31, "qid_%u", queues[i]);
1922 : 0 : rte_tel_data_add_dict_uint(d, qid_name, priorities[i]);
1923 : : }
1924 : :
1925 : : return 0;
1926 : : }
1927 : :
1928 : : static int
1929 : 0 : eventdev_build_telemetry_data(int dev_id,
1930 : : enum rte_event_dev_xstats_mode mode,
1931 : : int port_queue_id,
1932 : : struct rte_tel_data *d)
1933 : : {
1934 : : struct rte_event_dev_xstats_name *xstat_names;
1935 : : uint64_t *ids;
1936 : : uint64_t *values;
1937 : : int i, ret, num_xstats;
1938 : :
1939 : 0 : num_xstats = rte_event_dev_xstats_names_get(dev_id,
1940 : : mode,
1941 : : port_queue_id,
1942 : : NULL,
1943 : : NULL,
1944 : : 0);
1945 : :
1946 [ # # ]: 0 : if (num_xstats < 0)
1947 : : return -1;
1948 : :
1949 : : /* use one malloc for names */
1950 : 0 : xstat_names = malloc((sizeof(struct rte_event_dev_xstats_name))
1951 : : * num_xstats);
1952 [ # # ]: 0 : if (xstat_names == NULL)
1953 : : return -1;
1954 : :
1955 : 0 : ids = malloc((sizeof(uint64_t)) * num_xstats);
1956 [ # # ]: 0 : if (ids == NULL) {
1957 : 0 : free(xstat_names);
1958 : 0 : return -1;
1959 : : }
1960 : :
1961 : 0 : values = malloc((sizeof(uint64_t)) * num_xstats);
1962 [ # # ]: 0 : if (values == NULL) {
1963 : 0 : free(xstat_names);
1964 : 0 : free(ids);
1965 : 0 : return -1;
1966 : : }
1967 : :
1968 : 0 : ret = rte_event_dev_xstats_names_get(dev_id, mode, port_queue_id,
1969 : : xstat_names, ids, num_xstats);
1970 [ # # ]: 0 : if (ret < 0 || ret > num_xstats) {
1971 : 0 : free(xstat_names);
1972 : 0 : free(ids);
1973 : 0 : free(values);
1974 : 0 : return -1;
1975 : : }
1976 : :
1977 : 0 : ret = rte_event_dev_xstats_get(dev_id, mode, port_queue_id,
1978 : : ids, values, num_xstats);
1979 [ # # ]: 0 : if (ret < 0 || ret > num_xstats) {
1980 : 0 : free(xstat_names);
1981 : 0 : free(ids);
1982 : 0 : free(values);
1983 : 0 : return -1;
1984 : : }
1985 : :
1986 : 0 : rte_tel_data_start_dict(d);
1987 [ # # ]: 0 : for (i = 0; i < num_xstats; i++)
1988 : 0 : rte_tel_data_add_dict_uint(d, xstat_names[i].name, values[i]);
1989 : :
1990 : 0 : free(xstat_names);
1991 : 0 : free(ids);
1992 : 0 : free(values);
1993 : 0 : return 0;
1994 : : }
1995 : :
1996 : : static int
1997 : 0 : handle_dev_xstats(const char *cmd __rte_unused,
1998 : : const char *params,
1999 : : struct rte_tel_data *d)
2000 : : {
2001 : : int dev_id;
2002 : : enum rte_event_dev_xstats_mode mode;
2003 : : char *end_param;
2004 : :
2005 [ # # # # : 0 : if (params == NULL || strlen(params) == 0 || !isdigit(*params))
# # ]
2006 : : return -1;
2007 : :
2008 : : /* Get dev ID from parameter string */
2009 : 0 : dev_id = strtoul(params, &end_param, 10);
2010 : : if (*end_param != '\0')
2011 : : RTE_EDEV_LOG_DEBUG(
2012 : : "Extra parameters passed to eventdev telemetry command, ignoring");
2013 : :
2014 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
2015 : :
2016 : : mode = RTE_EVENT_DEV_XSTATS_DEVICE;
2017 : 0 : return eventdev_build_telemetry_data(dev_id, mode, 0, d);
2018 : : }
2019 : :
2020 : : static int
2021 : 0 : handle_port_xstats(const char *cmd __rte_unused,
2022 : : const char *params,
2023 : : struct rte_tel_data *d)
2024 : : {
2025 : : int dev_id;
2026 : : int port_queue_id = 0;
2027 : : enum rte_event_dev_xstats_mode mode;
2028 : : char *end_param;
2029 : : const char *p_param;
2030 : :
2031 [ # # # # : 0 : if (params == NULL || strlen(params) == 0 || !isdigit(*params))
# # ]
2032 : : return -1;
2033 : :
2034 : : /* Get dev ID from parameter string */
2035 : 0 : dev_id = strtoul(params, &end_param, 10);
2036 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
2037 : :
2038 : 0 : p_param = strtok(end_param, ",");
2039 : : mode = RTE_EVENT_DEV_XSTATS_PORT;
2040 : :
2041 [ # # # # : 0 : if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param))
# # ]
2042 : : return -1;
2043 : :
2044 : 0 : port_queue_id = strtoul(p_param, &end_param, 10);
2045 : :
2046 : 0 : p_param = strtok(NULL, "\0");
2047 : : if (p_param != NULL)
2048 : : RTE_EDEV_LOG_DEBUG(
2049 : : "Extra parameters passed to eventdev telemetry command, ignoring");
2050 : :
2051 : 0 : return eventdev_build_telemetry_data(dev_id, mode, port_queue_id, d);
2052 : : }
2053 : :
2054 : : static int
2055 : 0 : handle_queue_xstats(const char *cmd __rte_unused,
2056 : : const char *params,
2057 : : struct rte_tel_data *d)
2058 : : {
2059 : : int dev_id;
2060 : : int port_queue_id = 0;
2061 : : enum rte_event_dev_xstats_mode mode;
2062 : : char *end_param;
2063 : : const char *p_param;
2064 : :
2065 [ # # # # : 0 : if (params == NULL || strlen(params) == 0 || !isdigit(*params))
# # ]
2066 : : return -1;
2067 : :
2068 : : /* Get dev ID from parameter string */
2069 : 0 : dev_id = strtoul(params, &end_param, 10);
2070 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
2071 : :
2072 : 0 : p_param = strtok(end_param, ",");
2073 : : mode = RTE_EVENT_DEV_XSTATS_QUEUE;
2074 : :
2075 [ # # # # : 0 : if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param))
# # ]
2076 : : return -1;
2077 : :
2078 : 0 : port_queue_id = strtoul(p_param, &end_param, 10);
2079 : :
2080 : 0 : p_param = strtok(NULL, "\0");
2081 : : if (p_param != NULL)
2082 : : RTE_EDEV_LOG_DEBUG(
2083 : : "Extra parameters passed to eventdev telemetry command, ignoring");
2084 : :
2085 : 0 : return eventdev_build_telemetry_data(dev_id, mode, port_queue_id, d);
2086 : : }
2087 : :
2088 : : static int
2089 : 0 : handle_dev_dump(const char *cmd __rte_unused,
2090 : : const char *params,
2091 : : struct rte_tel_data *d)
2092 : : {
2093 : : char *buf, *end_param;
2094 : : int dev_id, ret;
2095 : : FILE *f;
2096 : :
2097 [ # # # # : 0 : if (params == NULL || strlen(params) == 0 || !isdigit(*params))
# # ]
2098 : : return -1;
2099 : :
2100 : : /* Get dev ID from parameter string */
2101 : 0 : dev_id = strtoul(params, &end_param, 10);
2102 : : if (*end_param != '\0')
2103 : : RTE_EDEV_LOG_DEBUG(
2104 : : "Extra parameters passed to eventdev telemetry command, ignoring");
2105 : :
2106 [ # # ]: 0 : RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
2107 : :
2108 : 0 : buf = calloc(RTE_TEL_MAX_SINGLE_STRING_LEN, sizeof(char));
2109 [ # # ]: 0 : if (buf == NULL)
2110 : : return -ENOMEM;
2111 : :
2112 : 0 : f = fmemopen(buf, RTE_TEL_MAX_SINGLE_STRING_LEN - 1, "w+");
2113 [ # # ]: 0 : if (f == NULL) {
2114 : 0 : free(buf);
2115 : 0 : return -EINVAL;
2116 : : }
2117 : :
2118 : 0 : ret = rte_event_dev_dump(dev_id, f);
2119 : 0 : fclose(f);
2120 [ # # ]: 0 : if (ret == 0) {
2121 : 0 : rte_tel_data_start_dict(d);
2122 : 0 : rte_tel_data_string(d, buf);
2123 : : }
2124 : :
2125 : 0 : free(buf);
2126 : 0 : return ret;
2127 : : }
2128 : :
2129 : 254 : RTE_INIT(eventdev_init_telemetry)
2130 : : {
2131 : 254 : rte_telemetry_register_cmd("/eventdev/dev_list", handle_dev_list,
2132 : : "Returns list of available eventdevs. Takes no parameters");
2133 : 254 : rte_telemetry_register_cmd("/eventdev/dev_info", handle_dev_info,
2134 : : "Returns basic info about an eventdev. Parameter: DevID");
2135 : :
2136 : : /* alias "dev_list" and "dev_info" as just "list" and "info" to match
2137 : : * other categories, such as ethdev, ring, mempool etc.
2138 : : */
2139 : 254 : rte_telemetry_register_cmd("/eventdev/list", handle_dev_list,
2140 : : "Returns list of available eventdevs. Takes no parameters");
2141 : 254 : rte_telemetry_register_cmd("/eventdev/info", handle_dev_info,
2142 : : "Returns basic info about an eventdev. Parameter: DevID");
2143 : :
2144 : 254 : rte_telemetry_register_cmd("/eventdev/port_list", handle_port_list,
2145 : : "Returns list of available ports. Parameter: DevID");
2146 : 254 : rte_telemetry_register_cmd("/eventdev/queue_list", handle_queue_list,
2147 : : "Returns list of available queues. Parameter: DevID");
2148 : :
2149 : 254 : rte_telemetry_register_cmd("/eventdev/dev_xstats", handle_dev_xstats,
2150 : : "Returns stats for an eventdev. Parameter: DevID");
2151 : 254 : rte_telemetry_register_cmd("/eventdev/port_xstats", handle_port_xstats,
2152 : : "Returns stats for an eventdev port. Params: DevID,PortID");
2153 : 254 : rte_telemetry_register_cmd("/eventdev/queue_xstats",
2154 : : handle_queue_xstats,
2155 : : "Returns stats for an eventdev queue. Params: DevID,QueueID");
2156 : 254 : rte_telemetry_register_cmd("/eventdev/dev_dump", handle_dev_dump,
2157 : : "Returns dump information for an eventdev. Parameter: DevID");
2158 : 254 : rte_telemetry_register_cmd("/eventdev/queue_links", handle_queue_links,
2159 : : "Returns links for an eventdev port. Params: DevID,QueueID");
2160 : 254 : }
|