Allow zero rx/tx queues to be passed to rte_eth_dev_configure(). This way PF might be used only for configuration purpose when no receive and/or transmit functionality is needed.
Rationale: in SRIOV mode PF use first free VF to RX/TX (at least ixgbe based NICs). For example: if using 82599EB based NIC and VF count is 16, 32 or 64 all recources are assigned to VFs so PF might be used only for configuration purpose. Signed-off-by: Pawel Wodkowski <pawelx.wodkowski at intel.com> --- lib/librte_ether/rte_ethdev.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index ea3a1fb..2e814db 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -333,7 +333,7 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) dev->data->rx_queues = rte_zmalloc("ethdev->rx_queues", sizeof(dev->data->rx_queues[0]) * nb_queues, RTE_CACHE_LINE_SIZE); - if (dev->data->rx_queues == NULL) { + if (dev->data->rx_queues == NULL && nb_queues > 0) { dev->data->nb_rx_queues = 0; return -(ENOMEM); } @@ -475,7 +475,7 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) dev->data->tx_queues = rte_zmalloc("ethdev->tx_queues", sizeof(dev->data->tx_queues[0]) * nb_queues, RTE_CACHE_LINE_SIZE); - if (dev->data->tx_queues == NULL) { + if (dev->data->tx_queues == NULL && nb_queues > 0) { dev->data->nb_tx_queues = 0; return -(ENOMEM); } @@ -731,7 +731,10 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, } if (nb_rx_q == 0) { PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_q == 0\n", port_id); - return (-EINVAL); + /* In SRIOV there can be no free resource for PF. So permit use only + * for configuration. */ + if (RTE_ETH_DEV_SRIOV(dev).active == 0) + return (-EINVAL); } if (nb_tx_q > dev_info.max_tx_queues) { @@ -739,9 +742,13 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, port_id, nb_tx_q, dev_info.max_tx_queues); return (-EINVAL); } + if (nb_tx_q == 0) { PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_q == 0\n", port_id); - return (-EINVAL); + /* In SRIOV there can be no free resource for PF. So permit use only + * for configuration. */ + if (RTE_ETH_DEV_SRIOV(dev).active == 0) + return (-EINVAL); } /* Copy the dev_conf parameter into the dev structure */ -- 1.9.1