Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2017 Intel Corporation
3 : : */
4 : :
5 : : #include <inttypes.h>
6 : : #include <stdlib.h>
7 : : #include <string.h>
8 : :
9 : : #include <bus_vdev_driver.h>
10 : : #include <rte_lcore.h>
11 : : #include <rte_memzone.h>
12 : : #include <rte_kvargs.h>
13 : : #include <rte_errno.h>
14 : : #include <rte_cycles.h>
15 : :
16 : : #include "opdl_evdev.h"
17 : : #include "opdl_ring.h"
18 : : #include "opdl_log.h"
19 : :
20 : : #define EVENTDEV_NAME_OPDL_PMD event_opdl
21 : : #define NUMA_NODE_ARG "numa_node"
22 : : #define DO_VALIDATION_ARG "do_validation"
23 : : #define DO_TEST_ARG "self_test"
24 : :
25 : :
26 : : static void
27 : : opdl_info_get(struct rte_eventdev *dev, struct rte_event_dev_info *info);
28 : :
29 : : uint16_t
30 : 0 : opdl_event_enqueue_burst(void *port,
31 : : const struct rte_event ev[],
32 : : uint16_t num)
33 : : {
34 : : struct opdl_port *p = port;
35 : :
36 [ # # ]: 0 : if (unlikely(!p->opdl->data->dev_started))
37 : : return 0;
38 : :
39 : :
40 : : /* either rx_enqueue or disclaim*/
41 : 0 : return p->enq(p, ev, num);
42 : : }
43 : :
44 : : uint16_t
45 : 0 : opdl_event_enqueue(void *port, const struct rte_event *ev)
46 : : {
47 : : struct opdl_port *p = port;
48 : :
49 [ # # ]: 0 : if (unlikely(!p->opdl->data->dev_started))
50 : : return 0;
51 : :
52 : :
53 : 0 : return p->enq(p, ev, 1);
54 : : }
55 : :
56 : : uint16_t
57 : 0 : opdl_event_dequeue_burst(void *port,
58 : : struct rte_event *ev,
59 : : uint16_t num,
60 : : uint64_t wait)
61 : : {
62 : : struct opdl_port *p = (void *)port;
63 : :
64 : : RTE_SET_USED(wait);
65 : :
66 [ # # ]: 0 : if (unlikely(!p->opdl->data->dev_started))
67 : : return 0;
68 : :
69 : : /* This function pointer can point to tx_dequeue or claim*/
70 : 0 : return p->deq(p, ev, num);
71 : : }
72 : :
73 : : uint16_t
74 : 0 : opdl_event_dequeue(void *port,
75 : : struct rte_event *ev,
76 : : uint64_t wait)
77 : : {
78 : : struct opdl_port *p = (void *)port;
79 : :
80 [ # # ]: 0 : if (unlikely(!p->opdl->data->dev_started))
81 : : return 0;
82 : :
83 : : RTE_SET_USED(wait);
84 : :
85 : 0 : return p->deq(p, ev, 1);
86 : : }
87 : :
88 : : static int
89 : 0 : opdl_port_link(struct rte_eventdev *dev,
90 : : void *port,
91 : : const uint8_t queues[],
92 : : const uint8_t priorities[],
93 : : uint16_t num)
94 : : {
95 : : struct opdl_port *p = port;
96 : :
97 : : RTE_SET_USED(priorities);
98 : : RTE_SET_USED(dev);
99 : :
100 [ # # ]: 0 : if (unlikely(dev->data->dev_started)) {
101 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
102 : : "Attempt to link queue (%u) to port %d while device started\n",
103 : : dev->data->dev_id,
104 : : queues[0],
105 : : p->id);
106 : 0 : rte_errno = EINVAL;
107 : 0 : return 0;
108 : : }
109 : :
110 : : /* Max of 1 queue per port */
111 [ # # ]: 0 : if (num > 1) {
112 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
113 : : "Attempt to link more than one queue (%u) to port %d requested\n",
114 : : dev->data->dev_id,
115 : : num,
116 : : p->id);
117 : 0 : rte_errno = EDQUOT;
118 : 0 : return 0;
119 : : }
120 : :
121 [ # # ]: 0 : if (!p->configured) {
122 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
123 : : "port %d not configured, cannot link to %u\n",
124 : : dev->data->dev_id,
125 : : p->id,
126 : : queues[0]);
127 : 0 : rte_errno = EINVAL;
128 : 0 : return 0;
129 : : }
130 : :
131 [ # # ]: 0 : if (p->external_qid != OPDL_INVALID_QID) {
132 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
133 : : "port %d already linked to queue %u, cannot link to %u\n",
134 : : dev->data->dev_id,
135 : : p->id,
136 : : p->external_qid,
137 : : queues[0]);
138 : 0 : rte_errno = EINVAL;
139 : 0 : return 0;
140 : : }
141 : :
142 : 0 : p->external_qid = queues[0];
143 : :
144 : 0 : return 1;
145 : : }
146 : :
147 : : static int
148 : 0 : opdl_port_unlink(struct rte_eventdev *dev,
149 : : void *port,
150 : : uint8_t queues[],
151 : : uint16_t nb_unlinks)
152 : : {
153 : : struct opdl_port *p = port;
154 : :
155 : : RTE_SET_USED(queues);
156 : : RTE_SET_USED(nb_unlinks);
157 : :
158 [ # # ]: 0 : if (unlikely(dev->data->dev_started)) {
159 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
160 : : "Attempt to unlink queue (%u) to port %d while device started\n",
161 : : dev->data->dev_id,
162 : : queues[0],
163 : : p->id);
164 : 0 : rte_errno = EINVAL;
165 : 0 : return 0;
166 : : }
167 : : RTE_SET_USED(nb_unlinks);
168 : :
169 : : /* Port Stuff */
170 : 0 : p->queue_id = OPDL_INVALID_QID;
171 : 0 : p->p_type = OPDL_INVALID_PORT;
172 : 0 : p->external_qid = OPDL_INVALID_QID;
173 : :
174 : : /* always unlink 0 queue due to statice pipeline */
175 : 0 : return 0;
176 : : }
177 : :
178 : : static int
179 [ # # ]: 0 : opdl_port_setup(struct rte_eventdev *dev,
180 : : uint8_t port_id,
181 : : const struct rte_event_port_conf *conf)
182 : : {
183 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
184 : 0 : struct opdl_port *p = &device->ports[port_id];
185 : :
186 : : RTE_SET_USED(conf);
187 : :
188 : : /* Check if port already configured */
189 [ # # ]: 0 : if (p->configured) {
190 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
191 : : "Attempt to setup port %d which is already setup\n",
192 : : dev->data->dev_id,
193 : : p->id);
194 : 0 : return -EDQUOT;
195 : : }
196 : :
197 : 0 : *p = (struct opdl_port){0}; /* zero entire structure */
198 : 0 : p->id = port_id;
199 : 0 : p->opdl = device;
200 : 0 : p->queue_id = OPDL_INVALID_QID;
201 : 0 : p->external_qid = OPDL_INVALID_QID;
202 : 0 : dev->data->ports[port_id] = p;
203 : 0 : rte_smp_wmb();
204 : 0 : p->configured = 1;
205 : 0 : device->nb_ports++;
206 : 0 : return 0;
207 : : }
208 : :
209 : : static void
210 : 0 : opdl_port_release(void *port)
211 : : {
212 : : struct opdl_port *p = (void *)port;
213 : :
214 [ # # ]: 0 : if (p == NULL ||
215 [ # # ]: 0 : p->opdl->data->dev_started) {
216 : : return;
217 : : }
218 : :
219 : 0 : p->configured = 0;
220 : 0 : p->initialized = 0;
221 : : }
222 : :
223 : : static void
224 : 0 : opdl_port_def_conf(struct rte_eventdev *dev, uint8_t port_id,
225 : : struct rte_event_port_conf *port_conf)
226 : : {
227 : : RTE_SET_USED(dev);
228 : : RTE_SET_USED(port_id);
229 : :
230 : 0 : port_conf->new_event_threshold = MAX_OPDL_CONS_Q_DEPTH;
231 : 0 : port_conf->dequeue_depth = MAX_OPDL_CONS_Q_DEPTH;
232 : 0 : port_conf->enqueue_depth = MAX_OPDL_CONS_Q_DEPTH;
233 : 0 : }
234 : :
235 : : static int
236 [ # # ]: 0 : opdl_queue_setup(struct rte_eventdev *dev,
237 : : uint8_t queue_id,
238 : : const struct rte_event_queue_conf *conf)
239 : : {
240 : : enum queue_type type;
241 : :
242 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
243 : :
244 : : /* Extra sanity check, probably not needed */
245 [ # # ]: 0 : if (queue_id == OPDL_INVALID_QID) {
246 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
247 : : "Invalid queue id %u requested\n",
248 : : dev->data->dev_id,
249 : : queue_id);
250 : 0 : return -EINVAL;
251 : : }
252 : :
253 [ # # ]: 0 : if (device->nb_q_md > device->max_queue_nb) {
254 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
255 : : "Max number of queues %u exceeded by request %u\n",
256 : : dev->data->dev_id,
257 : : device->max_queue_nb,
258 : : device->nb_q_md);
259 : 0 : return -EINVAL;
260 : : }
261 : :
262 : 0 : if (RTE_EVENT_QUEUE_CFG_ALL_TYPES
263 [ # # ]: 0 : & conf->event_queue_cfg) {
264 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
265 : : "QUEUE_CFG_ALL_TYPES not supported\n",
266 : : dev->data->dev_id);
267 : 0 : return -ENOTSUP;
268 [ # # ]: 0 : } else if (RTE_EVENT_QUEUE_CFG_SINGLE_LINK
269 : : & conf->event_queue_cfg) {
270 : : type = OPDL_Q_TYPE_SINGLE_LINK;
271 : : } else {
272 [ # # # ]: 0 : switch (conf->schedule_type) {
273 : : case RTE_SCHED_TYPE_ORDERED:
274 : : type = OPDL_Q_TYPE_ORDERED;
275 : : break;
276 : 0 : case RTE_SCHED_TYPE_ATOMIC:
277 : : type = OPDL_Q_TYPE_ATOMIC;
278 : 0 : break;
279 : : case RTE_SCHED_TYPE_PARALLEL:
280 : : type = OPDL_Q_TYPE_ORDERED;
281 : : break;
282 : 0 : default:
283 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
284 : : "Unknown queue type %d requested\n",
285 : : dev->data->dev_id,
286 : : conf->event_queue_cfg);
287 : 0 : return -EINVAL;
288 : : }
289 : : }
290 : : /* Check if queue id has been setup already */
291 : : uint32_t i;
292 [ # # ]: 0 : for (i = 0; i < device->nb_q_md; i++) {
293 [ # # ]: 0 : if (device->q_md[i].ext_id == queue_id) {
294 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
295 : : "queue id %u already setup\n",
296 : : dev->data->dev_id,
297 : : queue_id);
298 : 0 : return -EINVAL;
299 : : }
300 : : }
301 : :
302 : 0 : device->q_md[device->nb_q_md].ext_id = queue_id;
303 : 0 : device->q_md[device->nb_q_md].type = type;
304 : 0 : device->q_md[device->nb_q_md].setup = 1;
305 : 0 : device->nb_q_md++;
306 : :
307 : 0 : return 1;
308 : : }
309 : :
310 : : static void
311 : 0 : opdl_queue_release(struct rte_eventdev *dev, uint8_t queue_id)
312 : : {
313 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
314 : :
315 : : RTE_SET_USED(queue_id);
316 : :
317 : : if (device->data->dev_started)
318 : : return;
319 : :
320 : : }
321 : :
322 : : static void
323 : 0 : opdl_queue_def_conf(struct rte_eventdev *dev,
324 : : uint8_t queue_id,
325 : : struct rte_event_queue_conf *conf)
326 : : {
327 : : RTE_SET_USED(dev);
328 : : RTE_SET_USED(queue_id);
329 : :
330 : : static const struct rte_event_queue_conf default_conf = {
331 : : .nb_atomic_flows = 1024,
332 : : .nb_atomic_order_sequences = 1,
333 : : .event_queue_cfg = 0,
334 : : .schedule_type = RTE_SCHED_TYPE_ORDERED,
335 : : .priority = RTE_EVENT_DEV_PRIORITY_NORMAL,
336 : : };
337 : :
338 : 0 : *conf = default_conf;
339 : 0 : }
340 : :
341 : :
342 : : static int
343 [ # # ]: 0 : opdl_dev_configure(const struct rte_eventdev *dev)
344 : : {
345 : : struct opdl_evdev *opdl = opdl_pmd_priv(dev);
346 : : const struct rte_eventdev_data *data = dev->data;
347 : : const struct rte_event_dev_config *conf = &data->dev_conf;
348 : :
349 : 0 : opdl->max_queue_nb = conf->nb_event_queues;
350 : 0 : opdl->max_port_nb = conf->nb_event_ports;
351 : 0 : opdl->nb_events_limit = conf->nb_events_limit;
352 : :
353 [ # # ]: 0 : if (conf->event_dev_cfg & RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT) {
354 : 0 : PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
355 : : "DEQUEUE_TIMEOUT not supported\n",
356 : : dev->data->dev_id);
357 : 0 : return -ENOTSUP;
358 : : }
359 : :
360 : : return 0;
361 : : }
362 : :
363 : : static void
364 : 0 : opdl_info_get(struct rte_eventdev *dev, struct rte_event_dev_info *info)
365 : : {
366 : : RTE_SET_USED(dev);
367 : :
368 : : static const struct rte_event_dev_info evdev_opdl_info = {
369 : : .driver_name = OPDL_PMD_NAME,
370 : : .max_event_queues = RTE_EVENT_MAX_QUEUES_PER_DEV,
371 : : .max_event_queue_flows = OPDL_QID_NUM_FIDS,
372 : : .max_event_queue_priority_levels = OPDL_Q_PRIORITY_MAX,
373 : : .max_event_priority_levels = OPDL_IQS_MAX,
374 : : .max_event_ports = OPDL_PORTS_MAX,
375 : : .max_event_port_dequeue_depth = MAX_OPDL_CONS_Q_DEPTH,
376 : : .max_event_port_enqueue_depth = MAX_OPDL_CONS_Q_DEPTH,
377 : : .max_num_events = OPDL_INFLIGHT_EVENTS_TOTAL,
378 : : .event_dev_cap = RTE_EVENT_DEV_CAP_BURST_MODE |
379 : : RTE_EVENT_DEV_CAP_CARRY_FLOW_ID |
380 : : RTE_EVENT_DEV_CAP_MAINTENANCE_FREE,
381 : : .max_profiles_per_port = 1,
382 : : };
383 : :
384 : 0 : *info = evdev_opdl_info;
385 : 0 : }
386 : :
387 : : static void
388 [ # # ]: 0 : opdl_dump(struct rte_eventdev *dev, FILE *f)
389 : : {
390 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
391 : :
392 [ # # ]: 0 : if (!device->do_validation)
393 : : return;
394 : :
395 : : fprintf(f,
396 : : "\n\n -- RING STATISTICS --\n");
397 : : uint32_t i;
398 [ # # ]: 0 : for (i = 0; i < device->nb_opdls; i++)
399 : 0 : opdl_ring_dump(device->opdl[i], f);
400 : :
401 : : fprintf(f,
402 : : "\n\n -- PORT STATISTICS --\n"
403 : : "Type Port Index Port Id Queue Id Av. Req Size "
404 : : "Av. Grant Size Av. Cycles PP"
405 : : " Empty DEQs Non Empty DEQs Pkts Processed\n");
406 : :
407 [ # # ]: 0 : for (i = 0; i < device->max_port_nb; i++) {
408 : : char queue_id[64];
409 : : char total_cyc[64];
410 : : const char *p_type;
411 : :
412 : : uint64_t cne, cpg;
413 : : struct opdl_port *port = &device->ports[i];
414 : :
415 [ # # ]: 0 : if (port->initialized) {
416 : 0 : cne = port->port_stat[claim_non_empty];
417 : 0 : cpg = port->port_stat[claim_pkts_granted];
418 [ # # ]: 0 : if (port->p_type == OPDL_REGULAR_PORT)
419 : : p_type = "REG";
420 : : else if (port->p_type == OPDL_PURE_RX_PORT)
421 : : p_type = " RX";
422 : : else if (port->p_type == OPDL_PURE_TX_PORT)
423 : : p_type = " TX";
424 : : else if (port->p_type == OPDL_ASYNC_PORT)
425 : : p_type = "SYNC";
426 : : else
427 : : p_type = "????";
428 : :
429 : 0 : snprintf(queue_id, sizeof(queue_id), "%02u",
430 [ # # ]: 0 : port->external_qid);
431 [ # # ]: 0 : if (port->p_type == OPDL_REGULAR_PORT ||
432 : : port->p_type == OPDL_ASYNC_PORT)
433 [ # # ]: 0 : snprintf(total_cyc, sizeof(total_cyc),
434 : : " %'16"PRIu64"",
435 : : (cpg != 0 ?
436 : 0 : port->port_stat[total_cycles] / cpg
437 : : : 0));
438 : : else
439 : : snprintf(total_cyc, sizeof(total_cyc),
440 : : " ----");
441 [ # # # # ]: 0 : fprintf(f,
442 : : "%4s %10u %8u %9s %'16"PRIu64" %'16"PRIu64" %s "
443 : : "%'16"PRIu64" %'16"PRIu64" %'16"PRIu64"\n",
444 : : p_type,
445 : : i,
446 : 0 : port->id,
447 [ # # ]: 0 : (port->external_qid == OPDL_INVALID_QID ? "---"
448 : : : queue_id),
449 : : (cne != 0 ?
450 : 0 : port->port_stat[claim_pkts_requested] / cne
451 : : : 0),
452 : : (cne != 0 ?
453 : : port->port_stat[claim_pkts_granted] / cne
454 : : : 0),
455 : : total_cyc,
456 : : port->port_stat[claim_empty],
457 : : port->port_stat[claim_non_empty],
458 : : port->port_stat[claim_pkts_granted]);
459 : : }
460 : : }
461 : : fprintf(f, "\n");
462 : : }
463 : :
464 : :
465 : : static void
466 : 0 : opdl_stop(struct rte_eventdev *dev)
467 : : {
468 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
469 : :
470 : 0 : opdl_xstats_uninit(dev);
471 : :
472 : 0 : destroy_queues_and_rings(dev);
473 : :
474 : :
475 : 0 : device->started = 0;
476 : :
477 : 0 : rte_smp_wmb();
478 : 0 : }
479 : :
480 : : static int
481 : 0 : opdl_start(struct rte_eventdev *dev)
482 : : {
483 : : int err = 0;
484 : :
485 : : if (!err)
486 : 0 : err = create_queues_and_rings(dev);
487 : :
488 : :
489 [ # # ]: 0 : if (!err)
490 : 0 : err = assign_internal_queue_ids(dev);
491 : :
492 : :
493 [ # # ]: 0 : if (!err)
494 : 0 : err = initialise_queue_zero_ports(dev);
495 : :
496 : :
497 [ # # ]: 0 : if (!err)
498 : 0 : err = initialise_all_other_ports(dev);
499 : :
500 : :
501 [ # # ]: 0 : if (!err)
502 : 0 : err = check_queues_linked(dev);
503 : :
504 : :
505 [ # # ]: 0 : if (!err)
506 : 0 : err = opdl_add_event_handlers(dev);
507 : :
508 : :
509 [ # # ]: 0 : if (!err)
510 : 0 : err = build_all_dependencies(dev);
511 : :
512 [ # # ]: 0 : if (!err) {
513 : 0 : opdl_xstats_init(dev);
514 : :
515 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
516 : :
517 : 0 : PMD_DRV_LOG(INFO, "DEV_ID:[%02d] : "
518 : : "SUCCESS : Created %u total queues (%u ex, %u in),"
519 : : " %u opdls, %u event_dev ports, %u input ports",
520 : : opdl_pmd_dev_id(device),
521 : : device->nb_queues,
522 : : (device->nb_queues - device->nb_opdls),
523 : : device->nb_opdls,
524 : : device->nb_opdls,
525 : : device->nb_ports,
526 : : device->queue[0].nb_ports);
527 : : } else
528 : 0 : opdl_stop(dev);
529 : :
530 : 0 : return err;
531 : : }
532 : :
533 : : static int
534 : 0 : opdl_close(struct rte_eventdev *dev)
535 : : {
536 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
537 : : uint32_t i;
538 : :
539 [ # # ]: 0 : for (i = 0; i < device->max_port_nb; i++) {
540 : 0 : memset(&device->ports[i],
541 : : 0,
542 : : sizeof(struct opdl_port));
543 : : }
544 : :
545 : 0 : memset(&device->s_md,
546 : : 0x0,
547 : : sizeof(struct opdl_stage_meta_data)*OPDL_PORTS_MAX);
548 : :
549 : 0 : memset(&device->q_md,
550 : : 0xFF,
551 : : sizeof(struct opdl_queue_meta_data)*OPDL_MAX_QUEUES);
552 : :
553 : :
554 : 0 : memset(device->q_map_ex_to_in,
555 : : 0,
556 : : sizeof(uint8_t)*OPDL_INVALID_QID);
557 : :
558 : 0 : opdl_xstats_uninit(dev);
559 : :
560 : 0 : device->max_port_nb = 0;
561 : :
562 : 0 : device->max_queue_nb = 0;
563 : :
564 : 0 : device->nb_opdls = 0;
565 : :
566 : 0 : device->nb_queues = 0;
567 : :
568 : 0 : device->nb_ports = 0;
569 : :
570 : 0 : device->nb_q_md = 0;
571 : :
572 : 0 : dev->data->nb_queues = 0;
573 : :
574 : 0 : dev->data->nb_ports = 0;
575 : :
576 : :
577 : 0 : return 0;
578 : : }
579 : :
580 : : static int
581 : 0 : assign_numa_node(const char *key __rte_unused, const char *value, void *opaque)
582 : : {
583 : : int *socket_id = opaque;
584 : 0 : *socket_id = atoi(value);
585 [ # # ]: 0 : if (*socket_id >= RTE_MAX_NUMA_NODES)
586 : 0 : return -1;
587 : : return 0;
588 : : }
589 : :
590 : : static int
591 : 0 : set_do_validation(const char *key __rte_unused, const char *value, void *opaque)
592 : : {
593 : : int *do_val = opaque;
594 : 0 : *do_val = atoi(value);
595 [ # # ]: 0 : if (*do_val != 0)
596 : 0 : *do_val = 1;
597 : :
598 : 0 : return 0;
599 : : }
600 : : static int
601 : 0 : set_do_test(const char *key __rte_unused, const char *value, void *opaque)
602 : : {
603 : : int *do_test = opaque;
604 : :
605 : 0 : *do_test = atoi(value);
606 : :
607 [ # # ]: 0 : if (*do_test != 0)
608 : 0 : *do_test = 1;
609 : 0 : return 0;
610 : : }
611 : :
612 : : static int
613 : 0 : opdl_probe(struct rte_vdev_device *vdev)
614 : : {
615 : : static struct eventdev_ops evdev_opdl_ops = {
616 : : .dev_configure = opdl_dev_configure,
617 : : .dev_infos_get = opdl_info_get,
618 : : .dev_close = opdl_close,
619 : : .dev_start = opdl_start,
620 : : .dev_stop = opdl_stop,
621 : : .dump = opdl_dump,
622 : :
623 : : .queue_def_conf = opdl_queue_def_conf,
624 : : .queue_setup = opdl_queue_setup,
625 : : .queue_release = opdl_queue_release,
626 : : .port_def_conf = opdl_port_def_conf,
627 : : .port_setup = opdl_port_setup,
628 : : .port_release = opdl_port_release,
629 : : .port_link = opdl_port_link,
630 : : .port_unlink = opdl_port_unlink,
631 : :
632 : :
633 : : .xstats_get = opdl_xstats_get,
634 : : .xstats_get_names = opdl_xstats_get_names,
635 : : .xstats_get_by_name = opdl_xstats_get_by_name,
636 : : .xstats_reset = opdl_xstats_reset,
637 : : };
638 : :
639 : : static const char *const args[] = {
640 : : NUMA_NODE_ARG,
641 : : DO_VALIDATION_ARG,
642 : : DO_TEST_ARG,
643 : : NULL
644 : : };
645 : : const char *name;
646 : : const char *params;
647 : : struct rte_eventdev *dev;
648 : : struct opdl_evdev *opdl;
649 : 0 : int socket_id = rte_socket_id();
650 : 0 : int do_validation = 0;
651 [ # # ]: 0 : int do_test = 0;
652 : : int str_len;
653 : : int test_result = 0;
654 : :
655 : : name = rte_vdev_device_name(vdev);
656 : : params = rte_vdev_device_args(vdev);
657 [ # # # # ]: 0 : if (params != NULL && params[0] != '\0') {
658 : 0 : struct rte_kvargs *kvlist = rte_kvargs_parse(params, args);
659 : :
660 [ # # ]: 0 : if (!kvlist) {
661 : 0 : PMD_DRV_LOG(INFO,
662 : : "Ignoring unsupported parameters when creating device '%s'\n",
663 : : name);
664 : : } else {
665 : 0 : int ret = rte_kvargs_process(kvlist, NUMA_NODE_ARG,
666 : : assign_numa_node, &socket_id);
667 [ # # ]: 0 : if (ret != 0) {
668 : 0 : PMD_DRV_LOG(ERR,
669 : : "%s: Error parsing numa node parameter",
670 : : name);
671 : :
672 : 0 : rte_kvargs_free(kvlist);
673 : 0 : return ret;
674 : : }
675 : :
676 : 0 : ret = rte_kvargs_process(kvlist, DO_VALIDATION_ARG,
677 : : set_do_validation, &do_validation);
678 [ # # ]: 0 : if (ret != 0) {
679 : 0 : PMD_DRV_LOG(ERR,
680 : : "%s: Error parsing do validation parameter",
681 : : name);
682 : 0 : rte_kvargs_free(kvlist);
683 : 0 : return ret;
684 : : }
685 : :
686 : 0 : ret = rte_kvargs_process(kvlist, DO_TEST_ARG,
687 : : set_do_test, &do_test);
688 [ # # ]: 0 : if (ret != 0) {
689 : 0 : PMD_DRV_LOG(ERR,
690 : : "%s: Error parsing do test parameter",
691 : : name);
692 : 0 : rte_kvargs_free(kvlist);
693 : 0 : return ret;
694 : : }
695 : :
696 : 0 : rte_kvargs_free(kvlist);
697 : : }
698 : : }
699 : 0 : dev = rte_event_pmd_vdev_init(name,
700 : : sizeof(struct opdl_evdev), socket_id, vdev);
701 : :
702 [ # # ]: 0 : if (dev == NULL) {
703 : 0 : PMD_DRV_LOG(ERR, "eventdev vdev init() failed");
704 : 0 : return -EFAULT;
705 : : }
706 : :
707 [ # # # # ]: 0 : PMD_DRV_LOG(INFO, "DEV_ID:[%02d] : "
708 : : "Success - creating eventdev device %s, numa_node:[%d], do_validation:[%s]"
709 : : " , self_test:[%s]\n",
710 : : dev->data->dev_id,
711 : : name,
712 : : socket_id,
713 : : (do_validation ? "true" : "false"),
714 : : (do_test ? "true" : "false"));
715 : :
716 : 0 : dev->dev_ops = &evdev_opdl_ops;
717 : :
718 : 0 : dev->enqueue = opdl_event_enqueue;
719 : 0 : dev->enqueue_burst = opdl_event_enqueue_burst;
720 : 0 : dev->enqueue_new_burst = opdl_event_enqueue_burst;
721 : 0 : dev->enqueue_forward_burst = opdl_event_enqueue_burst;
722 : 0 : dev->dequeue = opdl_event_dequeue;
723 : 0 : dev->dequeue_burst = opdl_event_dequeue_burst;
724 : :
725 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
726 : 0 : goto done;
727 : :
728 : 0 : opdl = dev->data->dev_private;
729 : 0 : opdl->data = dev->data;
730 : 0 : opdl->socket = socket_id;
731 : 0 : opdl->do_validation = do_validation;
732 : 0 : opdl->do_test = do_test;
733 : 0 : str_len = strlen(name);
734 [ # # ]: 0 : memcpy(opdl->service_name, name, str_len);
735 : :
736 [ # # ]: 0 : if (do_test == 1)
737 : 0 : test_result = opdl_selftest();
738 : :
739 : 0 : done:
740 : 0 : event_dev_probing_finish(dev);
741 : 0 : return test_result;
742 : : }
743 : :
744 : : static int
745 [ # # ]: 0 : opdl_remove(struct rte_vdev_device *vdev)
746 : : {
747 : : const char *name;
748 : :
749 : : name = rte_vdev_device_name(vdev);
750 : : if (name == NULL)
751 : : return -EINVAL;
752 : :
753 : 0 : PMD_DRV_LOG(INFO, "Closing eventdev opdl device %s\n", name);
754 : :
755 : 0 : return rte_event_pmd_vdev_uninit(name);
756 : : }
757 : :
758 : : static struct rte_vdev_driver evdev_opdl_pmd_drv = {
759 : : .probe = opdl_probe,
760 : : .remove = opdl_remove
761 : : };
762 : :
763 [ - + ]: 235 : RTE_LOG_REGISTER_SUFFIX(opdl_logtype_driver, driver, INFO);
764 : :
765 : 235 : RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_OPDL_PMD, evdev_opdl_pmd_drv);
766 : : RTE_PMD_REGISTER_PARAM_STRING(event_opdl, NUMA_NODE_ARG "=<int>"
767 : : DO_VALIDATION_ARG "=<int>" DO_TEST_ARG "=<int>");
|