Add support for unmanaged SR-IOV
Subsystems (7)
v7 cover Add support for unmanaged SR-IOV
This series is meant to add support for SR-IOV on devices when the VFs are not managed by the kernel. Examples of recent patches attempting to do this include:
virto - https://patchwork.kernel.org/patch/10241225/
pci-stub - https://patchwork.kernel.org/patch/10109935/
vfio - https://patchwork.kernel.org/patch/10103353/
uio - https://patchwork.kernel.org/patch/9974031/
Since this is quickly blowing up into a multi-driver problem it is probably best to implement this solution as generically as possible.
This series is an attempt to do that. What we do with this patch set is provide a generic framework to enable SR-IOV in the case that the PF driver doesn't support managing the VFs itself.
I based my patch set originally on the patch by Mark Rustad but there isn't much left after going through and cleaning out the bits that were no longer needed, and after incorporating the feedback from David Miller. At this point the only items to be fully reused was his patch description which is now present in patch 3 of the set.
This solution is limited in scope to just adding support for devices that provide no functionality for SR-IOV other than allocating the VFs by calling pci_enable_sriov. Previous sets had included patches for VFIO, but for now I am dropping that as the scope of that work is larger then I think I can take on at this time.
v2: Reduced scope back to just virtio_pci and vfio-pci
Broke into 3 patch set from single patch
Changed autoprobe behavior to always set when num_vfs is set non-zero
v3: Updated Documentation to clarify when sriov_unmanaged_autoprobe is used
Wrapped vfio_pci_sriov_configure to fix build errors w/o SR-IOV in kernel
v4: Dropped vfio-pci patch
Added ena and nvme to drivers now using pci_sriov_configure_unmanaged Dropped pci_disable_sriov call in virtio_pci to be consistent with ena
v5: Dropped sriov_unmanaged_autoprobe and pci_sriov_conifgure_unmanaged
Added new patch that enables pci_sriov_configure_simple Updated drivers to use pci_sriov_configure_simple
v6: Defined pci_sriov_configure_simple as NULL when SR-IOV is not enabled
Updated drivers to drop "#ifdef" checks for IOV
Added pci-pf-stub as place for PF-only drivers to add support
v7: Dropped pci_id table explanation from pci-pf-stub driver
Updated pci_sriov_configure_simple to drop need for err value Fixed comment explaining why pci_sriov_configure_simple is NULL
---
Alexander Duyck (5):
pci: Add pci_sriov_configure_simple for PFs that don't manage VF resources
virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
ena: Migrate over to unmanaged SR-IOV support
nvme: Migrate over to unmanaged SR-IOV support
pci-pf-stub: Add PF driver stub for PFs that function only to enable VFs
drivers/net/ethernet/amazon/ena/ena_netdev.c | 28 ------------- drivers/nvme/host/pci.c | 20 ---------- drivers/pci/Kconfig | 12 ++++++ drivers/pci/Makefile | 2 + drivers/pci/iov.c | 31 +++++++++++++++ drivers/pci/pci-pf-stub.c | 54 ++++++++++++++++++++++++++ drivers/virtio/virtio_pci_common.c | 1 include/linux/pci.h | 3 + include/linux/pci_ids.h | 2 + 9 files changed, 107 insertions(+), 46 deletions(-) create mode 100644 drivers/pci/pci-pf-stub.c
--
PATCH v7 1/5 pci: Add pci_sriov_configure_simple for PFs that don't manage VF resources
From: Alexander Duyck <[email protected]>
This patch adds a common configuration function called pci_sriov_configure_simple that will allow for managing VFs on devices where the PF is not capable of managing VF resources.
---
v5: New patch replacing pci_sriov_configure_unmanaged with
pci_sriov_configure_simple
Dropped bits related to autoprobe changes
v6: Defined pci_sriov_configure_simple as NULL if IOV is disabled
v7: Updated pci_sriov_configure_simple to drop need for err value
Fixed comment explaining why pci_sriov_configure_simple is NULL
drivers/pci/iov.c | 31 +++++++++++++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 34 insertions(+)
drivers/pci/iov.c +31 -0
@@ -807,3 +807,34 @@ int pci_sriov_get_totalvfs(struct pci_dev *dev)return dev->sriov->total_VFs; }EXPORT_SYMBOL_GPL (pci_sriov_get_totalvfs); + +/** +* pci_sriov_configure_simple - helper to configure unmanaged SR-IOV +* @dev: the PCI device +* @nr_virtfn: number of virtual functions to enable, 0 to disable +* +* Used to provide generic enable/disable SR-IOV option for devices +* that do not manage the VFs generated by their driver. Return value +* is negative on error, or number of VFs allocated on success. +*/ +int pci_sriov_configure_simple (struct pci_dev *dev,int nr_virtfn) +{ +might_sleep (); + +if (!dev->is_physfn) +return -ENODEV ; + +if (pci_vfs_assigned (dev)) { +pci_warn (dev, +"Cannot modify SR-IOV while VFs are assigned\n" ); +return -EPERM ; + } + +if (!nr_virtfn) { +sriov_disable (dev); +return 0 ; + } + +return sriov_enable (dev, nr_virtfn) ? : nr_virtfn; +} +EXPORT_SYMBOL_GPL (pci_sriov_configure_simple);
include/linux/pci.h +3 -0
@@ -1953,6 +1953,7 @@ static inline void pci_mmcfg_late_init(void) { }int pci_vfs_assigned (struct pci_dev *dev);int pci_sriov_set_totalvfs (struct pci_dev *dev,u16 numvfs);int pci_sriov_get_totalvfs (struct pci_dev *dev); +int pci_sriov_configure_simple (struct pci_dev *dev,int nr_virtfn);resource_size_t pci_iov_resource_size (struct pci_dev *dev,int resno);void pci_vf_drivers_autoprobe (struct pci_dev *dev,bool probe);#else
@@ -1980,6 +1981,8 @@ static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs) {return 0 ; }static inline int pci_sriov_get_totalvfs (struct pci_dev *dev) {return 0 ; } +/* this is expected to be used as a function pointer, just define as NULL */ +#define pci_sriov_configure_simple NULLstatic inline resource_size_t pci_iov_resource_size (struct pci_dev *dev,int resno) {return 0 ; }static inline void pci_vf_drivers_autoprobe (struct pci_dev *dev,bool probe) { }
Re: [virtio-dev] [pci PATCH v7 1/5] pci: Add pci_sriov_configure_simple for PFs that don't manage VF resources
Quoted 16 lines · Alexander Duyck
From: Alexander Duyck <[email protected]>
This patch adds a common configuration function called
pci_sriov_configure_simplethat will allow for managing VFs on devices where the PF is not capable of managing VF resources.Signed-off-by Alexander Duyck <[email protected]>---
v5: New patch replacing
pci_sriov_configure_unmanagedwith
pci_sriov_configure_simple
Dropped bits related to autoprobe changes
v6: Definedpci_sriov_configure_simpleas NULL if IOV is disabled
v7: Updatedpci_sriov_configure_simpleto drop need for err value
Fixed comment explaining whypci_sriov_configure_simpleis NULL
Quoted 3 lines
drivers/pci/iov.c | 31 +++++++++++++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 34 insertions(+)
Tested with the device identified in patch #2.
--
Mark Rustad, Networking Division, Intel Corporation
PATCH v7 2/5 virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
In reply to Alexander DuyckFrom: Alexander Duyck <[email protected]>
Hardware-realized virtio_pci devices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both a virtio_net PF and virtio_net VFs. These are hardware realizations of what has been up to now been a software interface.
The device in question has the following 4-part PCI IDs:
PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe
VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05fe
The patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV.
One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning virtio_net PF create the VFs. This patch makes that possible.
---
v4: Dropped call to pci_disable_sriov in virtio_pci_remove function
v5: Replaced call to pci_sriov_configure_unmanaged with
pci_sriov_configure_simple
v6: Dropped "#ifdef" checks for IOV wrapping sriov_configure definition
v7: No code change, added Reviewed-by
drivers/virtio/virtio_pci_common.c | 1 + 1 file changed, 1 insertion(+)
drivers/virtio/virtio_pci_common.c +1 -0
@@ -596,6 +596,7 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)#ifdef CONFIG_PM_SLEEP .driver.pm = &virtio_pci_pm_ops, #endif + .sriov_configure = pci_sriov_configure_simple, };module_pci_driver (virtio_pci_driver);
Michael S. Tsirkin
maintainerRe: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
Quoted 17 lines · Alexander Duyck
From: Alexander Duyck <[email protected]>
Hardware-realized
virtio_pcidevices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both avirtio_netPF andvirtio_netVFs. These are hardware realizations of what has been up to now been a software interface.The device in question has the following 4-part PCI IDs:
PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe
VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05feThe patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV.
Quoted 8 lines
One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning
virtio_netPF create the VFs. This patch makes that possible.Reviewed-by Christoph Hellwig <[email protected]>Signed-off-by Mark Rustad <[email protected]>Signed-off-by Alexander Duyck <[email protected]>
So if and when virtio PFs can manage the VFs, then we can add a feature bit for that?
Seems reasonable.
Also, I am guessing that hardware implementations will want to add things like stong memory barriers - I guess we will add new feature bits for that too down the road?
Quoted 28 lines
---
v4: Dropped call to
pci_disable_sriovinvirtio_pci_removefunction
v5: Replaced call topci_sriov_configure_unmanagedwith
pci_sriov_configure_simple
v6: Dropped "#ifdef" checks for IOV wrappingsriov_configuredefinition
v7: No code change, added Reviewed-bydrivers/virtio/virtio_pci_common.c | 1 + 1 file changed, 1 insertion(+)drivers/virtio/virtio_pci_common.c +1
-1@@ -596,6 +596,7 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)#ifdef CONFIG_PM_SLEEP .driver.pm = &virtio_pci_pm_ops, #endif + .sriov_configure = pci_sriov_configure_simple, };module_pci_driver (virtio_pci_driver); ---------------------------------------------------------------------To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
Quoted 23 lines · Michael S. Tsirkin
Quoted 22 lines · Alexander Duyck
From: Alexander Duyck <[email protected]>
Hardware-realized
virtio_pcidevices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both avirtio_netPF andvirtio_netVFs. These are hardware realizations of what has been up to now been a software interface.The device in question has the following 4-part PCI IDs:
PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe
VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05feThe patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV.
One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning
virtio_netPF create the VFs. This patch makes that possible.
Quoted 7 lines
Quoted 3 lines
Reviewed-by Christoph Hellwig <[email protected]>Signed-off-by Mark Rustad <[email protected]>Signed-off-by Alexander Duyck <[email protected]>So if and when virtio PFs can manage the VFs, then we can add a feature bit for that?
Seems reasonable.
Yes. If nothing else you may not even need a feature bit depending on how things go. One of the reasons why Mark called out the subvendor/subdevice was because that might be able to be used to identify the specific hardware that is providing the SR-IOV feature so in the future if it is added to virtio itself then you could exclude devices like this by just limiting things based on subvendor/subdevice IDs.
Quoted 3 lines
Also, I am guessing that hardware implementations will want to add things like stong memory barriers - I guess we will add new feature bits for that too down the road?
That piece I don't have visibility into at this time. Perhaps Dan might have more visibility into future plans on what this might need.
Thanks.
- Alex
Michael S. Tsirkin
maintainerRe: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
Quoted 28 lines · Alexander Duyck
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Alexander Duyck
From: Alexander Duyck <[email protected]>
Hardware-realized
virtio_pcidevices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both avirtio_netPF andvirtio_netVFs. These are hardware realizations of what has been up to now been a software interface.The device in question has the following 4-part PCI IDs:
PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe
VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05feThe patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV.
One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning
virtio_netPF create the VFs. This patch makes that possible.Reviewed-by Christoph Hellwig <[email protected]>Signed-off-by Mark Rustad <[email protected]>Signed-off-by Alexander Duyck <[email protected]>
Quoted 6 lines
Quoted 3 lines
So if and when virtio PFs can manage the VFs, then we can add a feature bit for that?
Seems reasonable.Yes. If nothing else you may not even need a feature bit depending on how things go.
OTOH if the interface is changed in an incompatible way, and old Linux will attempt to drive the new device since there is no check.
I think we should add a feature bit right away.
Quoted 17 lines
One of the reasons why Mark called out the subvendor/subdevice was because that might be able to be used to identify the specific hardware that is providing the SR-IOV feature so in the future if it is added to virtio itself then you could exclude devices like this by just limiting things based on subvendor/subdevice IDs.
Quoted 3 lines
Also, I am guessing that hardware implementations will want to add things like stong memory barriers - I guess we will add new feature bits for that too down the road?
That piece I don't have visibility into at this time. Perhaps Dan might have more visibility into future plans on what this might need.
Thanks.
- Alex
Re: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
Quoted 33 lines · Michael S. Tsirkin
Quoted 32 lines · Alexander Duyck
Quoted 30 lines · Michael S. Tsirkin
Quoted 17 lines · Alexander Duyck
From: Alexander Duyck <[email protected]>
Hardware-realized
virtio_pcidevices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both avirtio_netPF andvirtio_netVFs. These are hardware realizations of what has been up to now been a software interface.The device in question has the following 4-part PCI IDs:
PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe
VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05feThe patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV.
Quoted 8 lines
One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning
virtio_netPF create the VFs. This patch makes that possible.Reviewed-by Christoph Hellwig <[email protected]>Signed-off-by Mark Rustad <[email protected]>Signed-off-by Alexander Duyck <[email protected]>So if and when virtio PFs can manage the VFs, then we can add a feature bit for that?
Seems reasonable.
Quoted 8 lines
Quoted 2 lines
Yes. If nothing else you may not even need a feature bit depending on how things go.
OTOH if the interface is changed in an incompatible way, and old Linux will attempt to drive the new device since there is no check.
I think we should add a feature bit right away.
I'm not sure why you would need a feature bit. The capability is controlled via PCI configuration space. If it is present the device has the capability. If it is not then it does not.
Basically if the PCI configuration space is not present then the sysfs entries will not be spawned and nothing will attempt to use this function.
- ALex
Michael S. Tsirkin
maintainerRe: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
Quoted 47 lines · Alexander Duyck
Quoted 33 lines · Michael S. Tsirkin
Quoted 32 lines · Alexander Duyck
Quoted 30 lines · Michael S. Tsirkin
Quoted 17 lines · Alexander Duyck
From: Alexander Duyck <[email protected]>
Hardware-realized
virtio_pcidevices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both avirtio_netPF andvirtio_netVFs. These are hardware realizations of what has been up to now been a software interface.The device in question has the following 4-part PCI IDs:
PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe
VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05feThe patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV.
Quoted 8 lines
One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning
virtio_netPF create the VFs. This patch makes that possible.Reviewed-by Christoph Hellwig <[email protected]>Signed-off-by Mark Rustad <[email protected]>Signed-off-by Alexander Duyck <[email protected]>So if and when virtio PFs can manage the VFs, then we can add a feature bit for that?
Seems reasonable.Quoted 8 lines
Quoted 2 lines
Yes. If nothing else you may not even need a feature bit depending on how things go.
OTOH if the interface is changed in an incompatible way, and old Linux will attempt to drive the new device since there is no check.
I think we should add a feature bit right away.
I'm not sure why you would need a feature bit. The capability is controlled via PCI configuration space. If it is present the device has the capability. If it is not then it does not.
Quoted 5 lines
Basically if the PCI configuration space is not present then the sysfs entries will not be spawned and nothing will attempt to use this function.
- ALex
It's about compability with older guests which ignore the capability.
The feature is thus helpful so host knows whether guest supports VFs.
Signature · 1 line
MSR
Re: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
Quoted 52 lines · Michael S. Tsirkin
Quoted 51 lines · Alexander Duyck
Quoted 33 lines · Michael S. Tsirkin
Quoted 32 lines · Alexander Duyck
Quoted 30 lines · Michael S. Tsirkin
Quoted 17 lines · Alexander Duyck
From: Alexander Duyck <[email protected]>
Hardware-realized
virtio_pcidevices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both avirtio_netPF andvirtio_netVFs. These are hardware realizations of what has been up to now been a software interface.The device in question has the following 4-part PCI IDs:
PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe
VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05feThe patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV.
Quoted 8 lines
One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning
virtio_netPF create the VFs. This patch makes that possible.Reviewed-by Christoph Hellwig <[email protected]>Signed-off-by Mark Rustad <[email protected]>Signed-off-by Alexander Duyck <[email protected]>So if and when virtio PFs can manage the VFs, then we can add a feature bit for that?
Seems reasonable.Quoted 8 lines
Quoted 2 lines
Yes. If nothing else you may not even need a feature bit depending on how things go.
OTOH if the interface is changed in an incompatible way, and old Linux will attempt to drive the new device since there is no check.
I think we should add a feature bit right away.
I'm not sure why you would need a feature bit. The capability is controlled via PCI configuration space. If it is present the device has the capability. If it is not then it does not.
Basically if the PCI configuration space is not present then the sysfs entries will not be spawned and nothing will attempt to use this function.
Quoted 6 lines
Quoted 1 line
- ALex
It's about compability with older guests which ignore the capability.
The feature is thus helpful so host knows whether guest supports VFs.
The thing is if the capability is ignored then the feature isn't used. So for SR-IOV it isn't an uncommon thing for there to be drivers for the PF floating around that do not support SR-IOV. In such cases SR-IOV just isn't used while the hardware could support it.
I would think in the case of virtio it would be the same kind of thing. Basically if SR-IOV is supported by the host then the capability would be present. If SR-IOV is supported by the guest then it would make use of the capability to spawn VFs. If either the capability isn't present, or the driver doesn't use it then you won't be able to spawn VFs in the guest.
Maybe I am missing something. Do you support dynamically changing the PCI configuration space for Virtio devices based on the presence of feature bits provided by the guest?
Also are you saying this patch set should wait on the feature bit to be added, or are you talking about doing this as some sort of follow-up?
- Alex
Michael S. Tsirkin
maintainerRe: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
Quoted 58 lines · Alexander Duyck
Quoted 57 lines · Michael S. Tsirkin
Quoted 47 lines · Alexander Duyck
Quoted 33 lines · Michael S. Tsirkin
Quoted 32 lines · Alexander Duyck
Quoted 30 lines · Michael S. Tsirkin
Quoted 17 lines · Alexander Duyck
From: Alexander Duyck <[email protected]>
Hardware-realized
virtio_pcidevices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both avirtio_netPF andvirtio_netVFs. These are hardware realizations of what has been up to now been a software interface.The device in question has the following 4-part PCI IDs:
PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe
VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05feThe patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV.
Quoted 8 lines
One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning
virtio_netPF create the VFs. This patch makes that possible.Reviewed-by Christoph Hellwig <[email protected]>Signed-off-by Mark Rustad <[email protected]>Signed-off-by Alexander Duyck <[email protected]>So if and when virtio PFs can manage the VFs, then we can add a feature bit for that?
Seems reasonable.Quoted 8 lines
Quoted 2 lines
Yes. If nothing else you may not even need a feature bit depending on how things go.
OTOH if the interface is changed in an incompatible way, and old Linux will attempt to drive the new device since there is no check.
I think we should add a feature bit right away.
I'm not sure why you would need a feature bit. The capability is controlled via PCI configuration space. If it is present the device has the capability. If it is not then it does not.
Quoted 5 lines
Basically if the PCI configuration space is not present then the sysfs entries will not be spawned and nothing will attempt to use this function.
- ALex
It's about compability with older guests which ignore the capability.
Quoted 6 lines
Quoted 1 line
The feature is thus helpful so host knows whether guest supports VFs.
The thing is if the capability is ignored then the feature isn't used. So for SR-IOV it isn't an uncommon thing for there to be drivers for the PF floating around that do not support SR-IOV. In such cases SR-IOV just isn't used while the hardware could support it.
Right but how come there are VF drivers but PF driver does not know about these?
And are there PF drivers that intentially do not enable SRIOV because it's known to be broken in some way?
Case in point I do think virtio want to limit this depending on a feature bit on general principles (the principle being that all extensions have feature bits).
There are security implications here - we previously relied on whitelisting after all.
Wouldn't it be safer to be a bit more careful and update the actual PF drivers? It's just one line per driver, but it can be done with an ack by driver maintainer. If/once we find out all drivers do have it, we can then change the default.
Quoted 10 lines
I would think in the case of virtio it would be the same kind of thing. Basically if SR-IOV is supported by the host then the capability would be present. If SR-IOV is supported by the guest then it would make use of the capability to spawn VFs. If either the capability isn't present, or the driver doesn't use it then you won't be able to spawn VFs in the guest.
Maybe I am missing something. Do you support dynamically changing the PCI configuration space for Virtio devices based on the presence of feature bits provided by the guest?
No. The point is that IMHO at least virtio - in absence of feature bit - to ignore VFs rather than assume they are safe to drive
in an unmanaged way.
Quoted 5 lines
Also are you saying this patch set should wait on the feature bit to be added, or are you talking about doing this as some sort of follow-up?
- Alex
I think for virtio it should include the feature bit, yes. Adding feature bit is very easy - post a patch to the virtio TC mailing list, wait about a week to give people time to respond (two weeks if it is around holidays and such).
Signature · 1 line
MST
Re: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
Quoted 61 lines · Michael S. Tsirkin
Quoted 60 lines · Alexander Duyck
Quoted 58 lines · Michael S. Tsirkin
Quoted 47 lines · Alexander Duyck
Quoted 33 lines · Michael S. Tsirkin
Quoted 32 lines · Alexander Duyck
Quoted 30 lines · Michael S. Tsirkin
Quoted 17 lines · Alexander Duyck
From: Alexander Duyck <[email protected]>
Hardware-realized
virtio_pcidevices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both avirtio_netPF andvirtio_netVFs. These are hardware realizations of what has been up to now been a software interface.The device in question has the following 4-part PCI IDs:
PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe
VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05feThe patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV.
Quoted 8 lines
One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning
virtio_netPF create the VFs. This patch makes that possible.Reviewed-by Christoph Hellwig <[email protected]>Signed-off-by Mark Rustad <[email protected]>Signed-off-by Alexander Duyck <[email protected]>So if and when virtio PFs can manage the VFs, then we can add a feature bit for that?
Seems reasonable.Quoted 8 lines
Quoted 2 lines
Yes. If nothing else you may not even need a feature bit depending on how things go.
OTOH if the interface is changed in an incompatible way, and old Linux will attempt to drive the new device since there is no check.
I think we should add a feature bit right away.
I'm not sure why you would need a feature bit. The capability is controlled via PCI configuration space. If it is present the device has the capability. If it is not then it does not.
Quoted 5 lines
Basically if the PCI configuration space is not present then the sysfs entries will not be spawned and nothing will attempt to use this function.
- ALex
It's about compability with older guests which ignore the capability.
The feature is thus helpful so host knows whether guest supports VFs.
Quoted 7 lines
Quoted 4 lines
The thing is if the capability is ignored then the feature isn't used. So for SR-IOV it isn't an uncommon thing for there to be drivers for the PF floating around that do not support SR-IOV. In such cases SR-IOV just isn't used while the hardware could support it.
Right but how come there are VF drivers but PF driver does not know about these?
I'm not sure what you mean here. The VF and PF drivers are the same driver. The only difference is that the PF has the extra SR-IOV configuration space.
What this code is meant to enable is a form of SR-IOV where the VFs are essentially pre-allocated resources. So for example in our case the MMIO space is identical for a PF versus any of the VFs. It doesn't have any special controls in place to allow the PF to manipulate any of the resources belonging to the VFs.
Quoted 2 lines
And are there PF drivers that intentially do not enable SRIOV because it's known to be broken in some way?
In the Virtio IO case right now are there any devices that support SR-IOV? For now this is just an add-on bit to a function that is already emulating the Virtio in hardware.
Quoted 3 lines
Case in point I do think virtio want to limit this depending on a feature bit on general principles (the principle being that all extensions have feature bits).
This part has me kind of scratching my head. In our setup the "PF" is really nothing more than a "VF" with the SR-IOV configuration space attached to it. There are already examples of similar designs for NVMe and the Amazon ENA devices. Giving the "PF" any functionality in MMIO space that controls the SR-IOV kind of defeats the whole point of allowing this function in the first place. Basically the PF isn't really controlling things, it is the kernel that is doing it.
Quoted 2 lines
There are security implications here - we previously relied on whitelisting after all.
Yes and no. The original patch set had issues as you could have a PF assigned to user space and the VFs managed by the host. When I changed things so that the function had to be in a kernel driver that issue went away.
Quoted 5 lines
Wouldn't it be safer to be a bit more careful and update the actual PF drivers? It's just one line per driver, but it can be done with an ack by driver maintainer. If/once we find out all drivers do have it, we can then change the default.
I have no clue what you are talking about here. This is the more careful approach. Are you sure you are reviewing the v7 of the patches?
My understanding is that no paravirtual interfaces currently expose SR-IOV. What we are looking at is hardware will want to emulate Virtio, specifically virtio_net in the future and as a part of that the PF ends up emulating it as well. What we would need to watch for going forward is that any device that enables SR-IOV support would need to also provide a 4 tuple ID so that if something goes wrong with it we could disable SR-IOV on the device via a PCI quirk later.
Quoted 19 lines
Quoted 10 lines
I would think in the case of virtio it would be the same kind of thing. Basically if SR-IOV is supported by the host then the capability would be present. If SR-IOV is supported by the guest then it would make use of the capability to spawn VFs. If either the capability isn't present, or the driver doesn't use it then you won't be able to spawn VFs in the guest.
Maybe I am missing something. Do you support dynamically changing the PCI configuration space for Virtio devices based on the presence of feature bits provided by the guest?
No. The point is that IMHO at least virtio - in absence of feature bit - to ignore VFs rather than assume they are safe to drive
in an unmanaged way.Quoted 4 lines
Also are you saying this patch set should wait on the feature bit to be added, or are you talking about doing this as some sort of follow-up?
Quoted 6 lines
Quoted 1 line
- Alex
I think for virtio it should include the feature bit, yes. Adding feature bit is very easy - post a patch to the virtio TC mailing list, wait about a week to give people time to respond (two weeks if it is around holidays and such).
The problem is we are talking about hardware/FPGA, not software. Adding a feature bit means going back and updating RTL. The software side of things is easy, re-validating things after a hardware/FPGA change not so much.
If this is a hard requirement I may just drop the virtio patch, push what I have, and leave it to Mark/Dan to deal with the necessary RTL and code changes needed to support Virtio as I don't expect the turnaround to be as easy as just a patch.
Thanks.
- Alex
Michael S. Tsirkin
maintainerRe: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
Quoted 10 lines · Alexander Duyck
Quoted 4 lines
I think for virtio it should include the feature bit, yes. Adding feature bit is very easy - post a patch to the virtio TC mailing list, wait about a week to give people time to respond (two weeks if it is around holidays and such).
The problem is we are talking about hardware/FPGA, not software. Adding a feature bit means going back and updating RTL. The software side of things is easy, re-validating things after a hardware/FPGA change not so much.
Quoted 8 lines
If this is a hard requirement I may just drop the virtio patch, push what I have, and leave it to Mark/Dan to deal with the necessary RTL and code changes needed to support Virtio as I don't expect the turnaround to be as easy as just a patch.
Thanks.
- Alex
Let's focus on virtio in this thread.
Involving the virtio TC in host/guest interface changes is a hard requirement. It's just too easy to create conflicts otherwise.
So you guys should have just sent the proposal to the TC when you were doing your RTL and you would have been in the clear.
Generally adding a feature bit with any extension is a good idea:
this way you merely reserve a feature bit for your feature through the TC and are more or less sure of forward and backward compatibility. It's incredibly easy.
But maybe it's not needed here. I am not making the decisions myself. Not too late: post to the TC list and let's see what the response is. Without a feature bit you are making a change affecting all future implementations without exception so the bar is a bit higher: you need to actually post a spec text proposal not just a patch showing how to use the feature, and TC needs to vote on it. Voting takes a week, review a week or two depending on change complexity.
Hope this helps,
Signature · 1 line
MST
Re: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
Quoted 16 lines · Michael S. Tsirkin
Quoted 15 lines · Alexander Duyck
Quoted 4 lines
I think for virtio it should include the feature bit, yes. Adding feature bit is very easy - post a patch to the virtio TC mailing list, wait about a week to give people time to respond (two weeks if it is around holidays and such).
The problem is we are talking about hardware/FPGA, not software. Adding a feature bit means going back and updating RTL. The software side of things is easy, re-validating things after a hardware/FPGA change not so much.
If this is a hard requirement I may just drop the virtio patch, push what I have, and leave it to Mark/Dan to deal with the necessary RTL and code changes needed to support Virtio as I don't expect the turnaround to be as easy as just a patch.
Quoted 5 lines
Quoted 3 lines
Thanks.
- Alex
Let's focus on virtio in this thread.
That is kind of what I was thinking, and why I was thinking it might make sense to make the virtio specific changes a separate patch set. I could get the PCI bits taken care of in the meantime since they effect genetic PCI, NVMe, and the Amazon ENA interfaces.
Quoted 5 lines
Involving the virtio TC in host/guest interface changes is a hard requirement. It's just too easy to create conflicts otherwise.
So you guys should have just sent the proposal to the TC when you were doing your RTL and you would have been in the clear.
Agreed. I believe I brought this up when I was originally asked to look into the coding for this.
Quoted 4 lines
Generally adding a feature bit with any extension is a good idea:
this way you merely reserve a feature bit for your feature through the TC and are more or less sure of forward and backward compatibility. It's incredibly easy.
Agreed, though in this case I am not sure it makes sense since this isn't necessarily something that is a Virtio feature itself. It is just a side effect of the fact that they are adding SR-IOV support to a device that happens to emulate Virtio NET and apparently their PF has to be identical to the VF other than the PCIe extended config space.
Quoted 8 lines
But maybe it's not needed here. I am not making the decisions myself. Not too late: post to the TC list and let's see what the response is. Without a feature bit you are making a change affecting all future implementations without exception so the bar is a bit higher: you need to actually post a spec text proposal not just a patch showing how to use the feature, and TC needs to vote on it. Voting takes a week, review a week or two depending on change complexity.
Quoted 4 lines
Hope this helps,
--
MST
I think I will leave this for Dan and Mark to handle since I am still not all that familiar with the hardware in use here. Once a decision has been made him and Mark could look at pushing either the one line patch or something more complex involving a feature flag.
Thanks.
Alex
Michael S. Tsirkin
maintainerRe: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
Quoted 42 lines · Alexander Duyck
Quoted 16 lines · Michael S. Tsirkin
Quoted 15 lines · Alexander Duyck
Quoted 4 lines
I think for virtio it should include the feature bit, yes. Adding feature bit is very easy - post a patch to the virtio TC mailing list, wait about a week to give people time to respond (two weeks if it is around holidays and such).
The problem is we are talking about hardware/FPGA, not software. Adding a feature bit means going back and updating RTL. The software side of things is easy, re-validating things after a hardware/FPGA change not so much.
If this is a hard requirement I may just drop the virtio patch, push what I have, and leave it to Mark/Dan to deal with the necessary RTL and code changes needed to support Virtio as I don't expect the turnaround to be as easy as just a patch.
Quoted 5 lines
Quoted 3 lines
Thanks.
- Alex
Let's focus on virtio in this thread.
That is kind of what I was thinking, and why I was thinking it might make sense to make the virtio specific changes a separate patch set. I could get the PCI bits taken care of in the meantime since they effect genetic PCI, NVMe, and the Amazon ENA interfaces.
Quoted 5 lines
Involving the virtio TC in host/guest interface changes is a hard requirement. It's just too easy to create conflicts otherwise.
So you guys should have just sent the proposal to the TC when you were doing your RTL and you would have been in the clear.
Agreed. I believe I brought this up when I was originally asked to look into the coding for this.
Quoted 4 lines
Generally adding a feature bit with any extension is a good idea:
this way you merely reserve a feature bit for your feature through the TC and are more or less sure of forward and backward compatibility. It's incredibly easy.
Quoted 6 lines
Agreed, though in this case I am not sure it makes sense since this isn't necessarily something that is a Virtio feature itself. It is just a side effect of the fact that they are adding SR-IOV support to a device that happens to emulate Virtio NET and apparently their PF has to be identical to the VF other than the PCIe extended config space.
I got that. My point is not everyone implementing SR-IOV will want to do it like this. Others might want to have VFs be different from PFs somehow. Feature bits ensure forward not just backward compatibility.
Quoted 13 lines
Quoted 8 lines
But maybe it's not needed here. I am not making the decisions myself. Not too late: post to the TC list and let's see what the response is. Without a feature bit you are making a change affecting all future implementations without exception so the bar is a bit higher: you need to actually post a spec text proposal not just a patch showing how to use the feature, and TC needs to vote on it. Voting takes a week, review a week or two depending on change complexity.
Quoted 4 lines
Hope this helps,
--
MST
Quoted 8 lines
I think I will leave this for Dan and Mark to handle since I am still not all that familiar with the hardware in use here. Once a decision has been made him and Mark could look at pushing either the one line patch or something more complex involving a feature flag.
Thanks.
Alex
As long as the TC is involved.
I know it's a bit of a strange thing to block it at the driver level, the issue is with the device, but it's literally the only handle I have to prevent people from doing out of spec hacks then pushing it all on us to maintain.
Signature · 1 line
MST
Christoph Hellwig
maintainerRe: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
In reply to Michael S. TsirkinQuoted 7 lines · Michael S. Tsirkin
But maybe it's not needed here. I am not making the decisions myself. Not too late: post to the TC list and let's see what the response is. Without a feature bit you are making a change affecting all future implementations without exception so the bar is a bit higher: you need to actually post a spec text proposal not just a patch showing how to use the feature, and TC needs to vote on it. Voting takes a week, review a week or two depending on change complexity.
Also IFF the hardware already is out we can quirk it in the PCI ID table to manually set the feature in the driver as a workaround.
Re: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
In reply to Michael S. TsirkinQuoted 8 lines · Michael S. Tsirkin
Quoted 8 lines
I'm not sure why you would need a feature bit. The capability is controlled via PCI configuration space. If it is present the device has the capability. If it is not then it does not.
Basically if the PCI configuration space is not present then the sysfs entries will not be spawned and nothing will attempt to use this function.
Quoted 6 lines
Quoted 1 line
- ALex
It's about compability with older guests which ignore the capability.
The feature is thus helpful so host knows whether guest supports VFs.
This is not about a guest creating its own VFs. This is about a host PF that happens to have a virtio interface to be able to create virtio VFs that can be assigned to guests. Nothing changes at all from a guest perspective. Or maybe I am not understanding what you mean by "whether guest supports VFs".
--
Mark Rustad, Networking Division, Intel Corporation
Re: [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
In reply to Alexander DuyckQuoted 27 lines · Alexander Duyck
From: Alexander Duyck <[email protected]>
Hardware-realized
virtio_pcidevices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both avirtio_netPF andvirtio_netVFs. These are hardware realizations of what has been up to now been a software interface.The device in question has the following 4-part PCI IDs:
PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe
VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05feThe patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV.
One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning
virtio_netPF create the VFs. This patch makes that possible.Reviewed-by Christoph Hellwig <[email protected]>Signed-off-by Mark Rustad <[email protected]>Signed-off-by Alexander Duyck <[email protected]>---
Quoted 8 lines
v4: Dropped call to
pci_disable_sriovinvirtio_pci_removefunction
v5: Replaced call topci_sriov_configure_unmanagedwith
pci_sriov_configure_simple
v6: Dropped "#ifdef" checks for IOV wrappingsriov_configuredefinition
v7: No code change, added Reviewed-bydrivers/virtio/virtio_pci_common.c | 1 + 1 file changed, 1 insertion(+)
Tested with the identified device.
--
Mark Rustad, Networking Division, Intel Corporation
Michael S. Tsirkin
maintainerRe: [virtio-dev] [pci PATCH v7 2/5] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices
In reply to Alexander DuyckQuoted 17 lines · Alexander Duyck
From: Alexander Duyck <[email protected]>
Hardware-realized
virtio_pcidevices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both avirtio_netPF andvirtio_netVFs. These are hardware realizations of what has been up to now been a software interface.The device in question has the following 4-part PCI IDs:
PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe
VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05feThe patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV.
Quoted 8 lines
One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning
virtio_netPF create the VFs. This patch makes that possible.Reviewed-by Christoph Hellwig <[email protected]>Signed-off-by Mark Rustad <[email protected]>Signed-off-by Alexander Duyck <[email protected]>
I thought hard about this, and I think we need a feature bit for this. This way host can detect support, and we can also change our minds later if we need to modify the interface and manage VFs after all.
It seems PCI specific so non pci transports would disable the feature for now.
Quoted 28 lines
---
v4: Dropped call to
pci_disable_sriovinvirtio_pci_removefunction
v5: Replaced call topci_sriov_configure_unmanagedwith
pci_sriov_configure_simple
v6: Dropped "#ifdef" checks for IOV wrappingsriov_configuredefinition
v7: No code change, added Reviewed-bydrivers/virtio/virtio_pci_common.c | 1 + 1 file changed, 1 insertion(+)drivers/virtio/virtio_pci_common.c +1
-1@@ -596,6 +596,7 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)#ifdef CONFIG_PM_SLEEP .driver.pm = &virtio_pci_pm_ops, #endif + .sriov_configure = pci_sriov_configure_simple, };module_pci_driver (virtio_pci_driver); ---------------------------------------------------------------------To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
PATCH v7 3/5 ena: Migrate over to unmanaged SR-IOV support
In reply to Alexander DuyckFrom: Alexander Duyck <[email protected]>
Instead of implementing our own version of a SR-IOV configuration stub in the ena driver we can just reuse the existing pci_sriov_configure_simple function.
---
v5: Replaced call to pci_sriov_configure_unmanaged with
pci_sriov_configure_simple
v6: Dropped "#ifdef" checks for IOV wrapping sriov_configure definition
v7: No change
drivers/net/ethernet/amazon/ena/ena_netdev.c | 28 +------------------------- 1 file changed, 1 insertion(+), 27 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +1 -27
@@ -3385,32 +3385,6 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) }/*****************************************************************************/ -static int ena_sriov_configure (struct pci_dev *dev,int numvfs) -{ -int rc; - -if (numvfs >0 ) { - rc =pci_enable_sriov (dev, numvfs); -if (rc !=0 ) { -dev_err (&dev->dev, -"pci_enable_sriov failed to enable: %d vfs with the error: %d\n" , - numvfs, rc); -return rc; - } - -return numvfs; - } - -if (numvfs ==0 ) { -pci_disable_sriov (dev); -return 0 ; - } - -return -EINVAL ; -} - -/*****************************************************************************/ -/*****************************************************************************/ /* ena_remove - Device Removal Routine * @pdev: PCI device information struct
@@ -3525,7 +3499,7 @@ static int ena_resume(struct pci_dev *pdev) .suspend = ena_suspend, .resume = ena_resume, #endif - .sriov_configure = ena_sriov_configure, + .sriov_configure = pci_sriov_configure_simple, };static int __init ena_init (void )
PATCH v7 4/5 nvme: Migrate over to unmanaged SR-IOV support
In reply to Alexander DuyckFrom: Alexander Duyck <[email protected]>
Instead of implementing our own version of a SR-IOV configuration stub in the nvme driver we can just reuse the existing pci_sriov_configure_simple function.
---
v5: Replaced call to pci_sriov_configure_unmanaged with
pci_sriov_configure_simple
v6: Dropped "#ifdef" checks for IOV wrapping sriov_configure definition
v7: No code change, added Reviewed-by
drivers/nvme/host/pci.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
drivers/nvme/host/pci.c +1 -19
@@ -2580,24 +2580,6 @@ static void nvme_remove(struct pci_dev *pdev)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 static int nvme_suspend (struct device *dev) {
@@ -2716,7 +2698,7 @@ static void nvme_error_resume(struct pci_dev *pdev) .driver = { .pm = &nvme_dev_pm_ops, }, - .sriov_configure = nvme_pci_sriov_configure, + .sriov_configure = pci_sriov_configure_simple, .err_handler = &nvme_err_handler, };
PATCH v7 5/5 pci-pf-stub: Add PF driver stub for PFs that function only to enable VFs
In reply to Alexander DuyckFrom: Alexander Duyck <[email protected]>
Add a new driver called "pci-pf-stub" to act as a "white-list" for PF devices that provide no other functionality other then acting as a means of allocating a set of VFs. For now I only have one example ID provided by Amazon in terms of devices that require this functionality. The general idea is that in the future we will see other devices added as vendors come up with devices where the PF is more or less just a lightweight shim used to allocate VFs.
---
v6: New driver to address concerns about Amazon devices left unsupported
v7: Dropped pci_id table explanation from pci-pf-stub driver
drivers/pci/Kconfig | 12 ++++++++++ drivers/pci/Makefile | 2 ++ drivers/pci/pci-pf-stub.c | 54 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 2 ++ 4 files changed, 70 insertions(+) create mode 100644 drivers/pci/pci-pf-stub.c
drivers/pci/Kconfig +12 -0
@@ -71,6 +71,18 @@ config PCI_STUB When in doubt, say N. +config PCI_PF_STUB + tristate "PCI PF Stub driver" + depends on PCI + depends on PCI_IOV + help + Say Y or M here if you want to enable support for devices that + require SR-IOV support, while at the same time the PF itself is + not providing any actual services on the host itself such as + storage or networking. + + When in doubt, say N. + config XEN_PCIDEV_FRONTEND tristate "Xen PCI Frontend" depends on PCI && X86 && XEN
drivers/pci/Makefile +2 -0
@@ -43,6 +43,8 @@ obj-$(CONFIG_PCI_SYSCALL) += syscall.o obj-$(CONFIG_PCI_STUB) += pci-stub.o +obj-$(CONFIG_PCI_PF_STUB) += pci-pf-stub.o + obj-$(CONFIG_PCI_ECAM) += ecam.o obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o
drivers/pci/pci-pf-stub.c new file +54 -0
54 lines not on this page · raw message
include/linux/pci_ids.h +2 -0
@@ -2548,6 +2548,8 @@#define PCI_VENDOR_ID_CIRCUITCO 0x1cc8#define PCI_SUBSYSTEM_ID_CIRCUITCO_MINNOWBOARD 0x0001 +#define PCI_VENDOR_ID_AMAZON 0x1d0f +#define PCI_VENDOR_ID_TEKRAM 0x1de1#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29
Quoted 70 lines · Alexander Duyck
This series is meant to add support for SR-IOV on devices when the VFs are not managed by the kernel. Examples of recent patches attempting to do this include:
virto - https://patchwork.kernel.org/patch/10241225/
pci-stub - https://patchwork.kernel.org/patch/10109935/
vfio - https://patchwork.kernel.org/patch/10103353/
uio - https://patchwork.kernel.org/patch/9974031/Since this is quickly blowing up into a multi-driver problem it is probably best to implement this solution as generically as possible.
This series is an attempt to do that. What we do with this patch set is provide a generic framework to enable SR-IOV in the case that the PF driver doesn't support managing the VFs itself.
I based my patch set originally on the patch by Mark Rustad but there isn't much left after going through and cleaning out the bits that were no longer needed, and after incorporating the feedback from David Miller. At this point the only items to be fully reused was his patch description which is now present in patch 3 of the set.
This solution is limited in scope to just adding support for devices that provide no functionality for SR-IOV other than allocating the VFs by calling
pci_enable_sriov. Previous sets had included patches for VFIO, but for now I am dropping that as the scope of that work is larger then I think I can take on at this time.v2: Reduced scope back to just
virtio_pciand vfio-pci
Broke into 3 patch set from single patch
Changed autoprobe behavior to always set whennum_vfsis set non-zero
v3: Updated Documentation to clarify whensriov_unmanaged_autoprobeis used
Wrappedvfio_pci_sriov_configureto fix build errors w/o SR-IOV in kernel
v4: Dropped vfio-pci patch
Added ena and nvme to drivers now usingpci_sriov_configure_unmanagedDroppedpci_disable_sriovcall invirtio_pcito be consistent with ena
v5: Droppedsriov_unmanaged_autoprobeandpci_sriov_conifgure_unmanaged
Added new patch that enablespci_sriov_configure_simpleUpdated drivers to usepci_sriov_configure_simple
v6: Definedpci_sriov_configure_simpleas NULL when SR-IOV is not enabled
Updated drivers to drop "#ifdef" checks for IOV
Added pci-pf-stub as place for PF-only drivers to add support
v7: Droppedpci_idtable explanation from pci-pf-stub driver
Updatedpci_sriov_configure_simpleto drop need for err value Fixed comment explaining whypci_sriov_configure_simpleis NULLCc Mark Rustad <[email protected]>Cc Maximilian Heyne <[email protected]>Cc Liang-Min Wang <[email protected]>Cc David Woodhouse <[email protected]>---
Alexander Duyck (5):
pci: Addpci_sriov_configure_simplefor PFs that don't manage VF resources
virtio_pci: Add support for unmanaged SR-IOV onvirtio_pcidevices
ena: Migrate over to unmanaged SR-IOV support
nvme: Migrate over to unmanaged SR-IOV support
pci-pf-stub: Add PF driver stub for PFs that function only to enable VFsdrivers/net/ethernet/amazon/ena/ena_netdev.c | 28 ------------- drivers/nvme/host/pci.c | 20 ---------- drivers/pci/Kconfig | 12 ++++++ drivers/pci/Makefile | 2 + drivers/pci/iov.c | 31 +++++++++++++++ drivers/pci/pci-pf-stub.c | 54 ++++++++++++++++++++++++++ drivers/virtio/virtio_pci_common.c | 1 include/linux/pci.h | 3 + include/linux/pci_ids.h | 2 + 9 files changed, 107 insertions(+), 46 deletions(-)
Quoted 4 lines
create mode 100644
drivers/pci/pci-pf-stub.c--
For what it's worth.
Good, simpler start for this type of support/effort. Thanks for the multiple versions to get to this point.
Quoted 36 lines · Alexander Duyck
This series is meant to add support for SR-IOV on devices when the VFs are not managed by the kernel. Examples of recent patches attempting to do this include:
virto - https://patchwork.kernel.org/patch/10241225/
pci-stub - https://patchwork.kernel.org/patch/10109935/
vfio - https://patchwork.kernel.org/patch/10103353/
uio - https://patchwork.kernel.org/patch/9974031/Since this is quickly blowing up into a multi-driver problem it is probably best to implement this solution as generically as possible.
This series is an attempt to do that. What we do with this patch set is provide a generic framework to enable SR-IOV in the case that the PF driver doesn't support managing the VFs itself.
I based my patch set originally on the patch by Mark Rustad but there isn't much left after going through and cleaning out the bits that were no longer needed, and after incorporating the feedback from David Miller. At this point the only items to be fully reused was his patch description which is now present in patch 3 of the set.
This solution is limited in scope to just adding support for devices that provide no functionality for SR-IOV other than allocating the VFs by calling
pci_enable_sriov. Previous sets had included patches for VFIO, but for now I am dropping that as the scope of that work is larger then I think I can take on at this time.v2: Reduced scope back to just
virtio_pciand vfio-pci
Broke into 3 patch set from single patch
Changed autoprobe behavior to always set whennum_vfsis set non-zero
v3: Updated Documentation to clarify whensriov_unmanaged_autoprobeis used
Wrappedvfio_pci_sriov_configureto fix build errors w/o SR-IOV in kernel
v4: Dropped vfio-pci patch
Added ena and nvme to drivers now usingpci_sriov_configure_unmanagedDroppedpci_disable_sriovcall invirtio_pcito be consistent with ena
v5: Droppedsriov_unmanaged_autoprobeandpci_sriov_conifgure_unmanaged
Quoted 9 lines
Added new patch that enables
pci_sriov_configure_simpleUpdated drivers to usepci_sriov_configure_simple
v6: Definedpci_sriov_configure_simpleas NULL when SR-IOV is not enabled
Updated drivers to drop "#ifdef" checks for IOV
Added pci-pf-stub as place for PF-only drivers to add support
v7: Droppedpci_idtable explanation from pci-pf-stub driver
Updatedpci_sriov_configure_simpleto drop need for err value Fixed comment explaining whypci_sriov_configure_simpleis NULL
Just following up since this has been sitting in patchwork for just over a month now
(https://patchwork.ozlabs.org/project/linux-pci/list/?series=34034).
I'm just wondering what the expectation is on getting these pulled into the pci tree? I'm assuming that is the best place for these patches. Are there any concerns I still need to address or are these going to be pulled in at some point, and if so is there any ETA on when that will be?
Thanks.
- Alex
Michael S. Tsirkin
maintainerQuoted 57 lines · Alexander Duyck
Quoted 36 lines · Alexander Duyck
This series is meant to add support for SR-IOV on devices when the VFs are not managed by the kernel. Examples of recent patches attempting to do this include:
virto - https://patchwork.kernel.org/patch/10241225/
pci-stub - https://patchwork.kernel.org/patch/10109935/
vfio - https://patchwork.kernel.org/patch/10103353/
uio - https://patchwork.kernel.org/patch/9974031/Since this is quickly blowing up into a multi-driver problem it is probably best to implement this solution as generically as possible.
This series is an attempt to do that. What we do with this patch set is provide a generic framework to enable SR-IOV in the case that the PF driver doesn't support managing the VFs itself.
I based my patch set originally on the patch by Mark Rustad but there isn't much left after going through and cleaning out the bits that were no longer needed, and after incorporating the feedback from David Miller. At this point the only items to be fully reused was his patch description which is now present in patch 3 of the set.
This solution is limited in scope to just adding support for devices that provide no functionality for SR-IOV other than allocating the VFs by calling
pci_enable_sriov. Previous sets had included patches for VFIO, but for now I am dropping that as the scope of that work is larger then I think I can take on at this time.v2: Reduced scope back to just
virtio_pciand vfio-pci
Broke into 3 patch set from single patch
Changed autoprobe behavior to always set whennum_vfsis set non-zero
v3: Updated Documentation to clarify whensriov_unmanaged_autoprobeis used
Wrappedvfio_pci_sriov_configureto fix build errors w/o SR-IOV in kernel
v4: Dropped vfio-pci patch
Added ena and nvme to drivers now usingpci_sriov_configure_unmanagedDroppedpci_disable_sriovcall invirtio_pcito be consistent with ena
v5: Droppedsriov_unmanaged_autoprobeandpci_sriov_conifgure_unmanagedQuoted 9 lines
Added new patch that enables
pci_sriov_configure_simpleUpdated drivers to usepci_sriov_configure_simple
v6: Definedpci_sriov_configure_simpleas NULL when SR-IOV is not enabled
Updated drivers to drop "#ifdef" checks for IOV
Added pci-pf-stub as place for PF-only drivers to add support
v7: Droppedpci_idtable explanation from pci-pf-stub driver
Updatedpci_sriov_configure_simpleto drop need for err value Fixed comment explaining whypci_sriov_configure_simpleis NULLJust following up since this has been sitting in patchwork for just over a month now
(https://patchwork.ozlabs.org/project/linux-pci/list/?series=34034).
I'm just wondering what the expectation is on getting these pulled into the pci tree? I'm assuming that is the best place for these patches. Are there any concerns I still need to address or are these going to be pulled in at some point, and if so is there any ETA on when that will be?
Quoted 3 lines
Thanks.
- Alex
Sorry I didn't notice you had more questions. I have responded hopefully explaining my concerns. Summary:
- For virtio we should add this with a feature bit.
- I am worried about security of this for the stub, but I am not the maintainer there.
Signature · 1 line
MST