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