| 605 | |
| 606 | |
| 607 | int |
| 608 | rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, |
| 609 | const struct rte_event_queue_conf *queue_conf) |
| 610 | { |
| 611 | struct rte_eventdev *dev; |
| 612 | struct rte_event_queue_conf def_conf; |
| 613 | |
| 614 | RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); |
| 615 | dev = &rte_eventdevs[dev_id]; |
| 616 | |
| 617 | if (!is_valid_queue(dev, queue_id)) { |
| 618 | RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id); |
| 619 | return -EINVAL; |
| 620 | } |
| 621 | |
| 622 | /* Check nb_atomic_flows limit */ |
| 623 | if (is_valid_atomic_queue_conf(queue_conf)) { |
| 624 | if (queue_conf->nb_atomic_flows == 0 || |
| 625 | queue_conf->nb_atomic_flows > |
| 626 | dev->data->dev_conf.nb_event_queue_flows) { |
| 627 | RTE_EDEV_LOG_ERR( |
| 628 | "dev%d queue%d Invalid nb_atomic_flows=%d max_flows=%d", |
| 629 | dev_id, queue_id, queue_conf->nb_atomic_flows, |
| 630 | dev->data->dev_conf.nb_event_queue_flows); |
| 631 | return -EINVAL; |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | /* Check nb_atomic_order_sequences limit */ |
| 636 | if (is_valid_ordered_queue_conf(queue_conf)) { |
| 637 | if (queue_conf->nb_atomic_order_sequences == 0 || |
| 638 | queue_conf->nb_atomic_order_sequences > |
| 639 | dev->data->dev_conf.nb_event_queue_flows) { |
| 640 | RTE_EDEV_LOG_ERR( |
| 641 | "dev%d queue%d Invalid nb_atomic_order_seq=%d max_flows=%d", |
| 642 | dev_id, queue_id, queue_conf->nb_atomic_order_sequences, |
| 643 | dev->data->dev_conf.nb_event_queue_flows); |
| 644 | return -EINVAL; |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | if (dev->data->dev_started) { |
| 649 | RTE_EDEV_LOG_ERR( |
| 650 | "device %d must be stopped to allow queue setup", dev_id); |
| 651 | return -EBUSY; |
| 652 | } |
| 653 | |
| 654 | if (*dev->dev_ops->queue_setup == NULL) |
| 655 | return -ENOTSUP; |
| 656 | |
| 657 | if (queue_conf == NULL) { |
| 658 | if (*dev->dev_ops->queue_def_conf == NULL) |
| 659 | return -ENOTSUP; |
| 660 | (*dev->dev_ops->queue_def_conf)(dev, queue_id, &def_conf); |
| 661 | queue_conf = &def_conf; |
| 662 | } |
| 663 | |
| 664 | dev->data->queues_cfg[queue_id] = *queue_conf; |