From: Andre Richter <andre.o.richter@gmail.com>
To: Alex Williamson <alex.williamson@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Andre Richter <andre.o.richter@gmail.com>
Subject: [PATCH 1/1] vfio-pci: Add SR-IOV VF configuration via sysfs
Date: Wed, 1 Oct 2014 15:38:53 +0200 [thread overview]
Message-ID: <1412170733-7187-1-git-send-email-andre.o.richter@gmail.com> (raw)
If a PCIe device bound to vfio-pci happens to be SR-IOV capabale,
there is no possibility to bring up/shutdown the device's VFs.
This patch adds a generic callback for the sysfs sriov_numvfs attribute.
The attribute will only show up for SR-IOV devices. Additionally,
each utilized pci_* function checks if the device is a PF.
Signed-off-by: Andre Richter <andre.o.richter@gmail.com>
---
drivers/vfio/pci/vfio_pci.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index f782533..2f6dfb3 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -919,12 +919,27 @@ static struct pci_error_handlers vfio_err_handlers = {
.error_detected = vfio_pci_aer_err_detected,
};
+static int vfio_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
+{
+ int ret = 0;
+
+ if (num_vfs > 0) {
+ ret = pci_enable_sriov(pdev, num_vfs);
+ if (!ret)
+ ret = pci_num_vf(pdev);
+ } else
+ pci_disable_sriov(pdev);
+
+ return ret;
+}
+
static struct pci_driver vfio_pci_driver = {
- .name = "vfio-pci",
- .id_table = NULL, /* only dynamic ids */
- .probe = vfio_pci_probe,
- .remove = vfio_pci_remove,
- .err_handler = &vfio_err_handlers,
+ .name = "vfio-pci",
+ .id_table = NULL, /* only dynamic ids */
+ .probe = vfio_pci_probe,
+ .remove = vfio_pci_remove,
+ .sriov_configure = vfio_pci_sriov_configure,
+ .err_handler = &vfio_err_handlers,
};
/*
--
1.9.1
next reply other threads:[~2014-10-01 13:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-01 13:38 Andre Richter [this message]
2014-10-01 14:03 ` Alex Williamson
2014-10-01 14:28 ` Andre Richter
2014-10-01 14:47 ` Alex Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1412170733-7187-1-git-send-email-andre.o.richter@gmail.com \
--to=andre.o.richter@gmail.com \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®