Re: [PATCH net-next v6 3/8] net/funeth: probing and netdev ops
From: Jakub Kicinski <kuba@kernel.org>
Date: 2022-01-12 22:51:14
From: Jakub Kicinski <kuba@kernel.org>
Date: 2022-01-12 22:51:14
On Sun, 9 Jan 2022 17:56:31 -0800 Dimitris Michailidis wrote:
+static int funeth_sriov_configure(struct pci_dev *pdev, int nvfs)
+{
+ struct fun_dev *fdev = pci_get_drvdata(pdev);
+ struct fun_ethdev *ed = to_fun_ethdev(fdev);
+ int rc;
+
+ if (nvfs == 0) {
+ if (pci_vfs_assigned(pdev)) {
+ dev_warn(&pdev->dev,
+ "Cannot disable SR-IOV while VFs are assigned\n");
+ return -EPERM;
+ }
+
+ pci_disable_sriov(pdev);
+ fun_free_vports(ed);
+ return 0;
+ }
+
+ rc = fun_init_vports(ed, nvfs);
+ if (rc)
+ return rc;Also likely needs locking, not that sriov callback is called with device lock held and VF configuration with rtnl_lock(), they can run in parallel.