virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [RFC] virtio-net: support modern-transtional devices
@ 2023-05-26 18:15 Zhu Lingshan
  2023-05-28 11:28 ` Michael S. Tsirkin
  0 siblings, 1 reply; 10+ messages in thread
From: Zhu Lingshan @ 2023-05-26 18:15 UTC (permalink / raw)
  To: mst, jasowang; +Cc: virtualization

Current virtio-net only probes a device with VIRITO_ID_NET == 1.

For a modern-transtional virtio-net device which has a transtional
device id 0x1000 and acts as a modern device, current virtio-pci
modern driver will assign the sub-device-id to its mdev->id.device,
which may not be 0x1, this sub-device-id is up to the vendor.

That means virtio-net driver doesn't probe a modern-transitonal
virtio-net with a sub-device-id other than 0x1, which is a bug.

Other types of devices also have similar issues, like virito-blk.

I propose to fix this problem of modern-transitonal device
whith this solution, all in the modern code path:
1) assign the device id to mdev->id.device
2) add transitional device ids in the virtio-net(and others) probe table.

Comments are welcome!

Thanks!

Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
---
 drivers/net/virtio_net.c               | 1 +
 drivers/virtio/virtio_pci_modern_dev.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 56ca1d270304..6b45d8602a6b 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -4250,6 +4250,7 @@ static __maybe_unused int virtnet_restore(struct virtio_device *vdev)
 
 static struct virtio_device_id id_table[] = {
 	{ VIRTIO_ID_NET, VIRTIO_DEV_ANY_ID },
+	{ VIRTIO_TRANS_ID_NET, VIRTIO_DEV_ANY_ID },
 	{ 0 },
 };
 
diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virtio_pci_modern_dev.c
index 869cb46bef96..80846e1195ce 100644
--- a/drivers/virtio/virtio_pci_modern_dev.c
+++ b/drivers/virtio/virtio_pci_modern_dev.c
@@ -229,7 +229,7 @@ int vp_modern_probe(struct virtio_pci_modern_device *mdev)
 		/* Transitional devices: use the PCI subsystem device id as
 		 * virtio device id, same as legacy driver always did.
 		 */
-		mdev->id.device = pci_dev->subsystem_device;
+		mdev->id.device = pci_dev->device;
 	} else {
 		/* Modern devices: simply use PCI device id, but start from 0x1040. */
 		mdev->id.device = pci_dev->device - 0x1040;
-- 
2.39.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-05-29 13:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-26 18:15 [RFC] virtio-net: support modern-transtional devices Zhu Lingshan
2023-05-28 11:28 ` Michael S. Tsirkin
2023-05-29  6:19   ` Zhu, Lingshan
2023-05-29  6:38     ` Michael S. Tsirkin
2023-05-29  8:07       ` Zhu, Lingshan
2023-05-29 10:12         ` Michael S. Tsirkin
2023-05-29 10:41           ` Zhu, Lingshan
2023-05-29 12:04             ` Michael S. Tsirkin
2023-05-29 13:13               ` Zhu, Lingshan
2023-05-29 13:36                 ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).