nfp: handle SR-IOV already enabled when driver is probing
authorJakub Kicinski <jakub.kicinski@netronome.com>
Tue, 27 Jun 2017 07:50:25 +0000 (00:50 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 27 Jun 2017 19:48:49 +0000 (15:48 -0400)
We assumed that when we probe number of enabled VFs will be at 0.
This doesn't have to be the case for example if previous driver left
SR-IOV enabled due to some VFs being assigned.  Read the number of VFs
enabled.  Fail probe if it's above current FWs limit.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_main.c

index 748e54cc885e280405bf0e635089c7cb437f79d1..d47adb4c86d6b3d6ddc94f0358d2d91d13c5d83a 100644 (file)
@@ -414,6 +414,14 @@ static int nfp_pci_probe(struct pci_dev *pdev,
        if (err)
                goto err_fw_unload;
 
+       pf->num_vfs = pci_num_vf(pdev);
+       if (pf->num_vfs > pf->limit_vfs) {
+               dev_err(&pdev->dev,
+                       "Error: %d VFs already enabled, but loaded FW can only support %d\n",
+                       pf->num_vfs, pf->limit_vfs);
+               goto err_fw_unload;
+       }
+
        err = nfp_net_pci_probe(pf);
        if (err)
                goto err_sriov_unlimit;