Commit 13880f5b authored by Keith Busch's avatar Keith Busch Committed by Jens Axboe

nvme/pci: Provide SR-IOV support

This registers an sr-iov callback for nvme.
Signed-off-by: default avatarKeith Busch <keith.busch@intel.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent fa9a89fc
...@@ -2015,6 +2015,24 @@ static void nvme_remove(struct pci_dev *pdev) ...@@ -2015,6 +2015,24 @@ static void nvme_remove(struct pci_dev *pdev)
nvme_put_ctrl(&dev->ctrl); nvme_put_ctrl(&dev->ctrl);
} }
static int nvme_pci_sriov_configure(struct pci_dev *pdev, int numvfs)
{
int ret = 0;
if (numvfs == 0) {
if (pci_vfs_assigned(pdev)) {
dev_warn(&pdev->dev,
"Cannot disable SR-IOV VFs while assigned\n");
return -EPERM;
}
pci_disable_sriov(pdev);
return 0;
}
ret = pci_enable_sriov(pdev, numvfs);
return ret ? ret : numvfs;
}
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int nvme_suspend(struct device *dev) static int nvme_suspend(struct device *dev)
{ {
...@@ -2117,6 +2135,7 @@ static struct pci_driver nvme_driver = { ...@@ -2117,6 +2135,7 @@ static struct pci_driver nvme_driver = {
.driver = { .driver = {
.pm = &nvme_dev_pm_ops, .pm = &nvme_dev_pm_ops,
}, },
.sriov_configure = nvme_pci_sriov_configure,
.err_handler = &nvme_err_handler, .err_handler = &nvme_err_handler,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment