From: Haiyang Zhang <[email protected]>

Add callback function for the pci_driver / sriov_configure.

It asks the NIC to provide certain number of VFs, or disable
VFs if the request is zero.

Signed-off-by: Haiyang Zhang <[email protected]>
---
v2:
  No longer change VF autoprobe as discussed with Leon Romanovsky and Bjorn 
Helgaas.

---
 drivers/net/ethernet/microsoft/mana/gdma_main.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c 
b/drivers/net/ethernet/microsoft/mana/gdma_main.c
index a0fdd052d7f1..0b7380fd1da8 100644
--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
+++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
@@ -2446,6 +2446,20 @@ static void mana_gd_shutdown(struct pci_dev *pdev)
        pci_disable_device(pdev);
 }
 
+static int mana_sriov_configure(struct pci_dev *pdev, int numvfs)
+{
+       int err = 0;
+
+       dev_info(&pdev->dev, "Requested num VFs: %d\n", numvfs);
+
+       if (numvfs > 0)
+               err = pci_enable_sriov(pdev, numvfs);
+       else
+               pci_disable_sriov(pdev);
+
+       return err ? err : numvfs;
+}
+
 static const struct pci_device_id mana_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_MICROSOFT, MANA_PF_DEVICE_ID) },
        { PCI_DEVICE(PCI_VENDOR_ID_MICROSOFT, MANA_PF2_DEVICE_ID) },
@@ -2461,6 +2475,7 @@ static struct pci_driver mana_driver = {
        .suspend        = mana_gd_suspend,
        .resume         = mana_gd_resume,
        .shutdown       = mana_gd_shutdown,
+       .sriov_configure = mana_sriov_configure,
 };
 
 static int __init mana_driver_init(void)
-- 
2.34.1


Reply via email to