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