[PATCH] net/nfp: check whether the generated VF can be used

Chaoyong He chaoyong.he at corigine.com
Fri Dec 9 02:35:12 CET 2022


From: Peng Zhang <peng.zhang at 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 at corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund at corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he at corigine.com>
---
 drivers/net/nfp/nfp_ethdev_vf.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index d1427b63bc..3aa0e46150 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -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) {
-- 
2.27.0



More information about the dev mailing list