* Rx queue presetup checks. * * @param dev * Pointer to Ethernet device structure. * @param idx * RX queue index. * @param desc * Number of descriptors to configure in queue. * @param[out] rxq_ctrl * Address of pointer to shared Rx queue control. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */
| 654 | * 0 on success, a negative errno value otherwise and rte_errno is set. |
| 655 | */ |
| 656 | static int |
| 657 | mlx5_rx_queue_pre_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t *desc, |
| 658 | struct mlx5_rxq_ctrl **rxq_ctrl) |
| 659 | { |
| 660 | struct mlx5_priv *priv = dev->data->dev_private; |
| 661 | struct mlx5_rxq_priv *rxq; |
| 662 | bool empty; |
| 663 | |
| 664 | if (*desc > mlx5_dev_get_max_wq_size(priv->sh)) { |
| 665 | DRV_LOG(ERR, |
| 666 | "port %u number of descriptors requested for Rx queue" |
| 667 | " %u is more than supported", |
| 668 | dev->data->port_id, idx); |
| 669 | rte_errno = EINVAL; |
| 670 | return -EINVAL; |
| 671 | } |
| 672 | if (!rte_is_power_of_2(*desc)) { |
| 673 | *desc = 1 << log2above(*desc); |
| 674 | DRV_LOG(WARNING, |
| 675 | "port %u increased number of descriptors in Rx queue %u" |
| 676 | " to the next power of two (%d)", |
| 677 | dev->data->port_id, idx, *desc); |
| 678 | } |
| 679 | DRV_LOG(DEBUG, "port %u configuring Rx queue %u for %u descriptors", |
| 680 | dev->data->port_id, idx, *desc); |
| 681 | if (idx >= priv->rxqs_n) { |
| 682 | DRV_LOG(ERR, "port %u Rx queue index out of range (%u >= %u)", |
| 683 | dev->data->port_id, idx, priv->rxqs_n); |
| 684 | rte_errno = EOVERFLOW; |
| 685 | return -rte_errno; |
| 686 | } |
| 687 | if (rxq_ctrl == NULL || *rxq_ctrl == NULL) |
| 688 | return 0; |
| 689 | if (!(*rxq_ctrl)->rxq.shared) { |
| 690 | if (!mlx5_rxq_releasable(dev, idx)) { |
| 691 | DRV_LOG(ERR, "port %u unable to release queue index %u", |
| 692 | dev->data->port_id, idx); |
| 693 | rte_errno = EBUSY; |
| 694 | return -rte_errno; |
| 695 | } |
| 696 | mlx5_rxq_release(dev, idx); |
| 697 | } else { |
| 698 | if ((*rxq_ctrl)->obj != NULL) |
| 699 | /* Some port using shared Rx queue has been started. */ |
| 700 | return 0; |
| 701 | /* Release all owner RxQ to reconfigure Shared RxQ. */ |
| 702 | do { |
| 703 | rxq = LIST_FIRST(&(*rxq_ctrl)->owners); |
| 704 | LIST_REMOVE(rxq, owner_entry); |
| 705 | empty = LIST_EMPTY(&(*rxq_ctrl)->owners); |
| 706 | mlx5_rxq_release(ETH_DEV(rxq->priv), rxq->idx); |
| 707 | } while (!empty); |
| 708 | *rxq_ctrl = NULL; |
| 709 | } |
| 710 | return 0; |
| 711 | } |
| 712 | |
| 713 | /** |
no test coverage detected