1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2017 Intel Corporation
8 #include <rte_bus_vdev.h>
9 #include <rte_kvargs.h>
11 #include <rte_errno.h>
12 #include <rte_event_ring.h>
13 #include <rte_service_component.h>
18 #define EVENTDEV_NAME_SW_PMD event_sw
19 #define NUMA_NODE_ARG "numa_node"
20 #define SCHED_QUANTA_ARG "sched_quanta"
21 #define CREDIT_QUANTA_ARG "credit_quanta"
24 sw_info_get(struct rte_eventdev *dev, struct rte_event_dev_info *info);
27 sw_port_link(struct rte_eventdev *dev, void *port, const uint8_t queues[],
28 const uint8_t priorities[], uint16_t num)
30 struct sw_port *p = port;
31 struct sw_evdev *sw = sw_pmd_priv(dev);
34 RTE_SET_USED(priorities);
35 for (i = 0; i < num; i++) {
36 struct sw_qid *q = &sw->qids[queues[i]];
39 /* check for qid map overflow */
40 if (q->cq_num_mapped_cqs >= RTE_DIM(q->cq_map)) {
45 if (p->is_directed && p->num_qids_mapped > 0) {
50 for (j = 0; j < q->cq_num_mapped_cqs; j++) {
51 if (q->cq_map[j] == p->id)
55 /* check if port is already linked */
56 if (j < q->cq_num_mapped_cqs)
59 if (q->type == SW_SCHED_TYPE_DIRECT) {
60 /* check directed qids only map to one port */
61 if (p->num_qids_mapped > 0) {
65 /* check port only takes a directed flow */
72 p->num_qids_mapped = 1;
73 } else if (q->type == RTE_SCHED_TYPE_ORDERED) {
74 p->num_ordered_qids++;
76 } else if (q->type == RTE_SCHED_TYPE_ATOMIC ||
77 q->type == RTE_SCHED_TYPE_PARALLEL) {
81 q->cq_map[q->cq_num_mapped_cqs] = p->id;
83 q->cq_num_mapped_cqs++;
89 sw_port_unlink(struct rte_eventdev *dev, void *port, uint8_t queues[],
92 struct sw_port *p = port;
93 struct sw_evdev *sw = sw_pmd_priv(dev);
97 for (i = 0; i < nb_unlinks; i++) {
98 struct sw_qid *q = &sw->qids[queues[i]];
99 for (j = 0; j < q->cq_num_mapped_cqs; j++) {
100 if (q->cq_map[j] == p->id) {
102 q->cq_map[q->cq_num_mapped_cqs - 1];
104 q->cq_num_mapped_cqs--;
107 p->num_qids_mapped--;
109 if (q->type == RTE_SCHED_TYPE_ORDERED)
110 p->num_ordered_qids--;
120 sw_port_setup(struct rte_eventdev *dev, uint8_t port_id,
121 const struct rte_event_port_conf *conf)
123 struct sw_evdev *sw = sw_pmd_priv(dev);
124 struct sw_port *p = &sw->ports[port_id];
125 char buf[RTE_RING_NAMESIZE];
128 struct rte_event_dev_info info;
129 sw_info_get(dev, &info);
131 /* detect re-configuring and return credits to instance if needed */
132 if (p->initialized) {
133 /* taking credits from pool is done one quanta at a time, and
134 * credits may be spend (counted in p->inflights) or still
135 * available in the port (p->inflight_credits). We must return
136 * the sum to no leak credits
138 int possible_inflights = p->inflight_credits + p->inflights;
139 rte_atomic32_sub(&sw->inflights, possible_inflights);
142 *p = (struct sw_port){0}; /* zero entire structure */
146 /* check to see if rings exists - port_setup() can be called multiple
147 * times legally (assuming device is stopped). If ring exists, free it
148 * to so it gets re-created with the correct size
150 snprintf(buf, sizeof(buf), "sw%d_p%u_%s", dev->data->dev_id,
151 port_id, "rx_worker_ring");
152 struct rte_event_ring *existing_ring = rte_event_ring_lookup(buf);
154 rte_event_ring_free(existing_ring);
156 p->rx_worker_ring = rte_event_ring_create(buf, MAX_SW_PROD_Q_DEPTH,
157 dev->data->socket_id,
158 RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ);
159 if (p->rx_worker_ring == NULL) {
160 SW_LOG_ERR("Error creating RX worker ring for port %d\n",
165 p->inflight_max = conf->new_event_threshold;
167 /* check if ring exists, same as rx_worker above */
168 snprintf(buf, sizeof(buf), "sw%d_p%u, %s", dev->data->dev_id,
169 port_id, "cq_worker_ring");
170 existing_ring = rte_event_ring_lookup(buf);
172 rte_event_ring_free(existing_ring);
174 p->cq_worker_ring = rte_event_ring_create(buf, conf->dequeue_depth,
175 dev->data->socket_id,
176 RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ);
177 if (p->cq_worker_ring == NULL) {
178 rte_event_ring_free(p->rx_worker_ring);
179 SW_LOG_ERR("Error creating CQ worker ring for port %d\n",
183 sw->cq_ring_space[port_id] = conf->dequeue_depth;
185 /* set hist list contents to empty */
186 for (i = 0; i < SW_PORT_HIST_LIST; i++) {
187 p->hist_list[i].fid = -1;
188 p->hist_list[i].qid = -1;
190 dev->data->ports[port_id] = p;
198 sw_port_release(void *port)
200 struct sw_port *p = (void *)port;
204 rte_event_ring_free(p->rx_worker_ring);
205 rte_event_ring_free(p->cq_worker_ring);
206 memset(p, 0, sizeof(*p));
210 qid_init(struct sw_evdev *sw, unsigned int idx, int type,
211 const struct rte_event_queue_conf *queue_conf)
214 int dev_id = sw->data->dev_id;
215 int socket_id = sw->data->socket_id;
216 char buf[IQ_ROB_NAMESIZE];
217 struct sw_qid *qid = &sw->qids[idx];
219 for (i = 0; i < SW_IQS_MAX; i++)
220 iq_init(sw, &qid->iq[i]);
222 /* Initialize the FID structures to no pinning (-1), and zero packets */
223 const struct sw_fid_t fid = {.cq = -1, .pcount = 0};
224 for (i = 0; i < RTE_DIM(qid->fids); i++)
229 qid->priority = queue_conf->priority;
231 if (qid->type == RTE_SCHED_TYPE_ORDERED) {
232 char ring_name[RTE_RING_NAMESIZE];
233 uint32_t window_size;
235 /* rte_ring and window_size_mask require require window_size to
238 window_size = rte_align32pow2(
239 queue_conf->nb_atomic_order_sequences);
241 qid->window_size = window_size - 1;
245 "invalid reorder_window_size for ordered queue\n"
250 snprintf(buf, sizeof(buf), "sw%d_iq_%d_rob", dev_id, i);
251 qid->reorder_buffer = rte_zmalloc_socket(buf,
252 window_size * sizeof(qid->reorder_buffer[0]),
254 if (!qid->reorder_buffer) {
255 SW_LOG_DBG("reorder_buffer malloc failed\n");
259 memset(&qid->reorder_buffer[0],
261 window_size * sizeof(qid->reorder_buffer[0]));
263 snprintf(ring_name, sizeof(ring_name), "sw%d_q%d_freelist",
266 /* lookup the ring, and if it already exists, free it */
267 struct rte_ring *cleanup = rte_ring_lookup(ring_name);
269 rte_ring_free(cleanup);
271 qid->reorder_buffer_freelist = rte_ring_create(ring_name,
274 RING_F_SP_ENQ | RING_F_SC_DEQ);
275 if (!qid->reorder_buffer_freelist) {
276 SW_LOG_DBG("freelist ring create failed");
280 /* Populate the freelist with reorder buffer entries. Enqueue
281 * 'window_size - 1' entries because the rte_ring holds only
284 for (i = 0; i < window_size - 1; i++) {
285 if (rte_ring_sp_enqueue(qid->reorder_buffer_freelist,
286 &qid->reorder_buffer[i]) < 0)
290 qid->reorder_buffer_index = 0;
294 qid->initialized = 1;
299 for (i = 0; i < SW_IQS_MAX; i++) {
301 iq_free_chunk(sw, qid->iq[i].head);
304 if (qid->reorder_buffer) {
305 rte_free(qid->reorder_buffer);
306 qid->reorder_buffer = NULL;
309 if (qid->reorder_buffer_freelist) {
310 rte_ring_free(qid->reorder_buffer_freelist);
311 qid->reorder_buffer_freelist = NULL;
318 sw_queue_release(struct rte_eventdev *dev, uint8_t id)
320 struct sw_evdev *sw = sw_pmd_priv(dev);
321 struct sw_qid *qid = &sw->qids[id];
324 for (i = 0; i < SW_IQS_MAX; i++) {
325 if (!qid->iq[i].head)
327 iq_free_chunk(sw, qid->iq[i].head);
330 if (qid->type == RTE_SCHED_TYPE_ORDERED) {
331 rte_free(qid->reorder_buffer);
332 rte_ring_free(qid->reorder_buffer_freelist);
334 memset(qid, 0, sizeof(*qid));
338 sw_queue_setup(struct rte_eventdev *dev, uint8_t queue_id,
339 const struct rte_event_queue_conf *conf)
343 type = conf->schedule_type;
345 if (RTE_EVENT_QUEUE_CFG_SINGLE_LINK & conf->event_queue_cfg) {
346 type = SW_SCHED_TYPE_DIRECT;
347 } else if (RTE_EVENT_QUEUE_CFG_ALL_TYPES
348 & conf->event_queue_cfg) {
349 SW_LOG_ERR("QUEUE_CFG_ALL_TYPES not supported\n");
353 struct sw_evdev *sw = sw_pmd_priv(dev);
355 if (sw->qids[queue_id].initialized)
356 sw_queue_release(dev, queue_id);
358 return qid_init(sw, queue_id, type, conf);
362 sw_queue_def_conf(struct rte_eventdev *dev, uint8_t queue_id,
363 struct rte_event_queue_conf *conf)
366 RTE_SET_USED(queue_id);
368 static const struct rte_event_queue_conf default_conf = {
369 .nb_atomic_flows = 4096,
370 .nb_atomic_order_sequences = 1,
371 .schedule_type = RTE_SCHED_TYPE_ATOMIC,
372 .priority = RTE_EVENT_DEV_PRIORITY_NORMAL,
375 *conf = default_conf;
379 sw_port_def_conf(struct rte_eventdev *dev, uint8_t port_id,
380 struct rte_event_port_conf *port_conf)
383 RTE_SET_USED(port_id);
385 port_conf->new_event_threshold = 1024;
386 port_conf->dequeue_depth = 16;
387 port_conf->enqueue_depth = 16;
391 sw_dev_configure(const struct rte_eventdev *dev)
393 struct sw_evdev *sw = sw_pmd_priv(dev);
394 const struct rte_eventdev_data *data = dev->data;
395 const struct rte_event_dev_config *conf = &data->dev_conf;
398 sw->qid_count = conf->nb_event_queues;
399 sw->port_count = conf->nb_event_ports;
400 sw->nb_events_limit = conf->nb_events_limit;
401 rte_atomic32_set(&sw->inflights, 0);
403 /* Number of chunks sized for worst-case spread of events across IQs */
404 num_chunks = ((SW_INFLIGHT_EVENTS_TOTAL/SW_EVS_PER_Q_CHUNK)+1) +
405 sw->qid_count*SW_IQS_MAX*2;
407 /* If this is a reconfiguration, free the previous IQ allocation */
409 rte_free(sw->chunks);
411 sw->chunks = rte_malloc_socket(NULL,
412 sizeof(struct sw_queue_chunk) *
415 sw->data->socket_id);
419 sw->chunk_list_head = NULL;
420 for (i = 0; i < num_chunks; i++)
421 iq_free_chunk(sw, &sw->chunks[i]);
423 if (conf->event_dev_cfg & RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT)
432 sw_eth_rx_adapter_caps_get(const struct rte_eventdev *dev,
433 const struct rte_eth_dev *eth_dev,
437 RTE_SET_USED(eth_dev);
438 *caps = RTE_EVENT_ETH_RX_ADAPTER_SW_CAP;
443 sw_info_get(struct rte_eventdev *dev, struct rte_event_dev_info *info)
447 static const struct rte_event_dev_info evdev_sw_info = {
448 .driver_name = SW_PMD_NAME,
449 .max_event_queues = RTE_EVENT_MAX_QUEUES_PER_DEV,
450 .max_event_queue_flows = SW_QID_NUM_FIDS,
451 .max_event_queue_priority_levels = SW_Q_PRIORITY_MAX,
452 .max_event_priority_levels = SW_IQS_MAX,
453 .max_event_ports = SW_PORTS_MAX,
454 .max_event_port_dequeue_depth = MAX_SW_CONS_Q_DEPTH,
455 .max_event_port_enqueue_depth = MAX_SW_PROD_Q_DEPTH,
456 .max_num_events = SW_INFLIGHT_EVENTS_TOTAL,
457 .event_dev_cap = (RTE_EVENT_DEV_CAP_QUEUE_QOS |
458 RTE_EVENT_DEV_CAP_BURST_MODE |
459 RTE_EVENT_DEV_CAP_EVENT_QOS),
462 *info = evdev_sw_info;
466 sw_dump(struct rte_eventdev *dev, FILE *f)
468 const struct sw_evdev *sw = sw_pmd_priv(dev);
470 static const char * const q_type_strings[] = {
471 "Ordered", "Atomic", "Parallel", "Directed"
474 fprintf(f, "EventDev %s: ports %d, qids %d\n", "todo-fix-name",
475 sw->port_count, sw->qid_count);
477 fprintf(f, "\trx %"PRIu64"\n\tdrop %"PRIu64"\n\ttx %"PRIu64"\n",
478 sw->stats.rx_pkts, sw->stats.rx_dropped, sw->stats.tx_pkts);
479 fprintf(f, "\tsched calls: %"PRIu64"\n", sw->sched_called);
480 fprintf(f, "\tsched cq/qid call: %"PRIu64"\n", sw->sched_cq_qid_called);
481 fprintf(f, "\tsched no IQ enq: %"PRIu64"\n", sw->sched_no_iq_enqueues);
482 fprintf(f, "\tsched no CQ enq: %"PRIu64"\n", sw->sched_no_cq_enqueues);
483 uint32_t inflights = rte_atomic32_read(&sw->inflights);
484 uint32_t credits = sw->nb_events_limit - inflights;
485 fprintf(f, "\tinflight %d, credits: %d\n", inflights, credits);
487 #define COL_RED "\x1b[31m"
488 #define COL_RESET "\x1b[0m"
490 for (i = 0; i < sw->port_count; i++) {
492 const struct sw_port *p = &sw->ports[i];
493 if (!p->initialized) {
494 fprintf(f, " %sPort %d not initialized.%s\n",
495 COL_RED, i, COL_RESET);
498 fprintf(f, " Port %d %s\n", i,
499 p->is_directed ? " (SingleCons)" : "");
500 fprintf(f, "\trx %"PRIu64"\tdrop %"PRIu64"\ttx %"PRIu64
501 "\t%sinflight %d%s\n", sw->ports[i].stats.rx_pkts,
502 sw->ports[i].stats.rx_dropped,
503 sw->ports[i].stats.tx_pkts,
504 (p->inflights == p->inflight_max) ?
506 sw->ports[i].inflights, COL_RESET);
508 fprintf(f, "\tMax New: %u"
509 "\tAvg cycles PP: %"PRIu64"\tCredits: %u\n",
510 sw->ports[i].inflight_max,
511 sw->ports[i].avg_pkt_ticks,
512 sw->ports[i].inflight_credits);
513 fprintf(f, "\tReceive burst distribution:\n");
514 float zp_percent = p->zero_polls * 100.0 / p->total_polls;
515 fprintf(f, zp_percent < 10 ? "\t\t0:%.02f%% " : "\t\t0:%.0f%% ",
517 for (max = (int)RTE_DIM(p->poll_buckets); max-- > 0;)
518 if (p->poll_buckets[max] != 0)
520 for (j = 0; j <= max; j++) {
521 if (p->poll_buckets[j] != 0) {
522 float poll_pc = p->poll_buckets[j] * 100.0 /
524 fprintf(f, "%u-%u:%.02f%% ",
525 ((j << SW_DEQ_STAT_BUCKET_SHIFT) + 1),
526 ((j+1) << SW_DEQ_STAT_BUCKET_SHIFT),
532 if (p->rx_worker_ring) {
533 uint64_t used = rte_event_ring_count(p->rx_worker_ring);
534 uint64_t space = rte_event_ring_free_count(
536 const char *col = (space == 0) ? COL_RED : COL_RESET;
537 fprintf(f, "\t%srx ring used: %4"PRIu64"\tfree: %4"
538 PRIu64 COL_RESET"\n", col, used, space);
540 fprintf(f, "\trx ring not initialized.\n");
542 if (p->cq_worker_ring) {
543 uint64_t used = rte_event_ring_count(p->cq_worker_ring);
544 uint64_t space = rte_event_ring_free_count(
546 const char *col = (space == 0) ? COL_RED : COL_RESET;
547 fprintf(f, "\t%scq ring used: %4"PRIu64"\tfree: %4"
548 PRIu64 COL_RESET"\n", col, used, space);
550 fprintf(f, "\tcq ring not initialized.\n");
553 for (i = 0; i < sw->qid_count; i++) {
554 const struct sw_qid *qid = &sw->qids[i];
555 if (!qid->initialized) {
556 fprintf(f, " %sQueue %d not initialized.%s\n",
557 COL_RED, i, COL_RESET);
560 int affinities_per_port[SW_PORTS_MAX] = {0};
561 uint32_t inflights = 0;
563 fprintf(f, " Queue %d (%s)\n", i, q_type_strings[qid->type]);
564 fprintf(f, "\trx %"PRIu64"\tdrop %"PRIu64"\ttx %"PRIu64"\n",
565 qid->stats.rx_pkts, qid->stats.rx_dropped,
567 if (qid->type == RTE_SCHED_TYPE_ORDERED) {
568 struct rte_ring *rob_buf_free =
569 qid->reorder_buffer_freelist;
571 fprintf(f, "\tReorder entries in use: %u\n",
572 rte_ring_free_count(rob_buf_free));
575 "\tReorder buffer not initialized\n");
579 for (flow = 0; flow < RTE_DIM(qid->fids); flow++)
580 if (qid->fids[flow].cq != -1) {
581 affinities_per_port[qid->fids[flow].cq]++;
582 inflights += qid->fids[flow].pcount;
586 fprintf(f, "\tPer Port Stats:\n");
587 for (port = 0; port < sw->port_count; port++) {
588 fprintf(f, "\t Port %d: Pkts: %"PRIu64, port,
590 fprintf(f, "\tFlows: %d\n", affinities_per_port[port]);
594 uint32_t iq_printed = 0;
595 for (iq = 0; iq < SW_IQS_MAX; iq++) {
596 if (!qid->iq[iq].head) {
597 fprintf(f, "\tiq %d is not initialized.\n", iq);
601 uint32_t used = iq_count(&qid->iq[iq]);
602 const char *col = COL_RESET;
604 fprintf(f, "\t%siq %d: Used %d"
605 COL_RESET"\n", col, iq, used);
610 fprintf(f, "\t-- iqs empty --\n");
615 sw_start(struct rte_eventdev *dev)
618 struct sw_evdev *sw = sw_pmd_priv(dev);
620 rte_service_component_runstate_set(sw->service_id, 1);
622 /* check a service core is mapped to this service */
623 if (!rte_service_runstate_get(sw->service_id)) {
624 SW_LOG_ERR("Warning: No Service core enabled on service %s\n",
629 /* check all ports are set up */
630 for (i = 0; i < sw->port_count; i++)
631 if (sw->ports[i].rx_worker_ring == NULL) {
632 SW_LOG_ERR("Port %d not configured\n", i);
636 /* check all queues are configured and mapped to ports*/
637 for (i = 0; i < sw->qid_count; i++)
638 if (sw->qids[i].iq[0].head == NULL ||
639 sw->qids[i].cq_num_mapped_cqs == 0) {
640 SW_LOG_ERR("Queue %d not configured\n", i);
644 /* build up our prioritized array of qids */
645 /* We don't use qsort here, as if all/multiple entries have the same
646 * priority, the result is non-deterministic. From "man 3 qsort":
647 * "If two members compare as equal, their order in the sorted
648 * array is undefined."
651 for (j = 0; j <= RTE_EVENT_DEV_PRIORITY_LOWEST; j++) {
652 for (i = 0; i < sw->qid_count; i++) {
653 if (sw->qids[i].priority == j) {
654 sw->qids_prioritized[qidx] = &sw->qids[i];
660 if (sw_xstats_init(sw) < 0)
670 sw_stop(struct rte_eventdev *dev)
672 struct sw_evdev *sw = sw_pmd_priv(dev);
673 sw_xstats_uninit(sw);
679 sw_close(struct rte_eventdev *dev)
681 struct sw_evdev *sw = sw_pmd_priv(dev);
684 for (i = 0; i < sw->qid_count; i++)
685 sw_queue_release(dev, i);
688 for (i = 0; i < sw->port_count; i++)
689 sw_port_release(&sw->ports[i]);
692 memset(&sw->stats, 0, sizeof(sw->stats));
693 sw->sched_called = 0;
694 sw->sched_no_iq_enqueues = 0;
695 sw->sched_no_cq_enqueues = 0;
696 sw->sched_cq_qid_called = 0;
702 assign_numa_node(const char *key __rte_unused, const char *value, void *opaque)
704 int *socket_id = opaque;
705 *socket_id = atoi(value);
706 if (*socket_id >= RTE_MAX_NUMA_NODES)
712 set_sched_quanta(const char *key __rte_unused, const char *value, void *opaque)
714 int *quanta = opaque;
715 *quanta = atoi(value);
716 if (*quanta < 0 || *quanta >= 4096)
722 set_credit_quanta(const char *key __rte_unused, const char *value, void *opaque)
724 int *credit = opaque;
725 *credit = atoi(value);
726 if (*credit < 0 || *credit >= 128)
732 static int32_t sw_sched_service_func(void *args)
734 struct rte_eventdev *dev = args;
735 sw_event_schedule(dev);
740 sw_probe(struct rte_vdev_device *vdev)
742 static const struct rte_eventdev_ops evdev_sw_ops = {
743 .dev_configure = sw_dev_configure,
744 .dev_infos_get = sw_info_get,
745 .dev_close = sw_close,
746 .dev_start = sw_start,
750 .queue_def_conf = sw_queue_def_conf,
751 .queue_setup = sw_queue_setup,
752 .queue_release = sw_queue_release,
753 .port_def_conf = sw_port_def_conf,
754 .port_setup = sw_port_setup,
755 .port_release = sw_port_release,
756 .port_link = sw_port_link,
757 .port_unlink = sw_port_unlink,
759 .eth_rx_adapter_caps_get = sw_eth_rx_adapter_caps_get,
761 .xstats_get = sw_xstats_get,
762 .xstats_get_names = sw_xstats_get_names,
763 .xstats_get_by_name = sw_xstats_get_by_name,
764 .xstats_reset = sw_xstats_reset,
767 static const char *const args[] = {
775 struct rte_eventdev *dev;
777 int socket_id = rte_socket_id();
778 int sched_quanta = SW_DEFAULT_SCHED_QUANTA;
779 int credit_quanta = SW_DEFAULT_CREDIT_QUANTA;
781 name = rte_vdev_device_name(vdev);
782 params = rte_vdev_device_args(vdev);
783 if (params != NULL && params[0] != '\0') {
784 struct rte_kvargs *kvlist = rte_kvargs_parse(params, args);
788 "Ignoring unsupported parameters when creating device '%s'\n",
791 int ret = rte_kvargs_process(kvlist, NUMA_NODE_ARG,
792 assign_numa_node, &socket_id);
795 "%s: Error parsing numa node parameter",
797 rte_kvargs_free(kvlist);
801 ret = rte_kvargs_process(kvlist, SCHED_QUANTA_ARG,
802 set_sched_quanta, &sched_quanta);
805 "%s: Error parsing sched quanta parameter",
807 rte_kvargs_free(kvlist);
811 ret = rte_kvargs_process(kvlist, CREDIT_QUANTA_ARG,
812 set_credit_quanta, &credit_quanta);
815 "%s: Error parsing credit quanta parameter",
817 rte_kvargs_free(kvlist);
821 rte_kvargs_free(kvlist);
826 "Creating eventdev sw device %s, numa_node=%d, sched_quanta=%d, credit_quanta=%d\n",
827 name, socket_id, sched_quanta, credit_quanta);
829 dev = rte_event_pmd_vdev_init(name,
830 sizeof(struct sw_evdev), socket_id);
832 SW_LOG_ERR("eventdev vdev init() failed");
835 dev->dev_ops = &evdev_sw_ops;
836 dev->enqueue = sw_event_enqueue;
837 dev->enqueue_burst = sw_event_enqueue_burst;
838 dev->enqueue_new_burst = sw_event_enqueue_burst;
839 dev->enqueue_forward_burst = sw_event_enqueue_burst;
840 dev->dequeue = sw_event_dequeue;
841 dev->dequeue_burst = sw_event_dequeue_burst;
843 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
846 sw = dev->data->dev_private;
847 sw->data = dev->data;
849 /* copy values passed from vdev command line to instance */
850 sw->credit_update_quanta = credit_quanta;
851 sw->sched_quanta = sched_quanta;
853 /* register service with EAL */
854 struct rte_service_spec service;
855 memset(&service, 0, sizeof(struct rte_service_spec));
856 snprintf(service.name, sizeof(service.name), "%s_service", name);
857 snprintf(sw->service_name, sizeof(sw->service_name), "%s_service",
859 service.socket_id = socket_id;
860 service.callback = sw_sched_service_func;
861 service.callback_userdata = (void *)dev;
863 int32_t ret = rte_service_component_register(&service, &sw->service_id);
865 SW_LOG_ERR("service register() failed");
869 dev->data->service_inited = 1;
870 dev->data->service_id = sw->service_id;
876 sw_remove(struct rte_vdev_device *vdev)
880 name = rte_vdev_device_name(vdev);
884 SW_LOG_INFO("Closing eventdev sw device %s\n", name);
886 return rte_event_pmd_vdev_uninit(name);
889 static struct rte_vdev_driver evdev_sw_pmd_drv = {
894 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_SW_PMD, evdev_sw_pmd_drv);
895 RTE_PMD_REGISTER_PARAM_STRING(event_sw, NUMA_NODE_ARG "=<int> "
896 SCHED_QUANTA_ARG "=<int>" CREDIT_QUANTA_ARG "=<int>");