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

Message ID 20221209013512.34630-1-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/nfp: check whether the generated VF can be used |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS

Commit Message

Chaoyong He Dec. 9, 2022, 1:35 a.m. UTC
  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

Ferruh Yigit Jan. 19, 2023, 9:09 a.m. UTC | #1
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.
  

Patch

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) {