net/nfp: check whether the generated VF can be used
Checks
Commit Message
From: Peng Zhang <peng.zhang@corigine.com>
All the queue pairs are shared between VF and PF for NFP,
and there exist different assignment policy for different
firmware application.
The user can create VFs up to the max number of queue pairs,
which will cause the last few VFs has no queue pairs and
cannot be used, because PF must occupy some queue pairs by
default.
This commit add check to prevent this kind of VFs be used.
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/nfp_ethdev_vf.c | 7 +++++++
1 file changed, 7 insertions(+)
Comments
On 12/9/2022 1:35 AM, Chaoyong He wrote:
> From: Peng Zhang <peng.zhang@corigine.com>
>
> All the queue pairs are shared between VF and PF for NFP,
> and there exist different assignment policy for different
> firmware application.
>
> The user can create VFs up to the max number of queue pairs,
> which will cause the last few VFs has no queue pairs and
> cannot be used, because PF must occupy some queue pairs by
> default.
>
> This commit add check to prevent this kind of VFs be used.
>
> Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Applied to dpdk-next-net/main, thanks.
@@ -333,6 +333,13 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
hw->max_rx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_RXRINGS);
hw->max_tx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_TXRINGS);
+ if (hw->max_rx_queues == 0 || hw->max_tx_queues == 0) {
+ PMD_DRV_LOG(ERR,
+ "Device %s can not be used, there are no valid queue "
+ "pairs for use, please try to generate less VFs",
+ pci_dev->name);
+ return -ENODEV;
+ }
/* Work out where in the BAR the queues start. */
switch (pci_dev->id.device_id) {