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