[RFC PATCH] PCI pass-through fixups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm wondering if we need a spot for device specific fixups for PCI
pass-through.  In the example below, I want to expose a single port of
an Intel 82571EB quad port copper NIC to a guest.  It works great until
I shutdown the guest, at which point the guest e1000e driver knows by
the device ID that the NIC is a quad port, and blindly attempts to
twiddle some bits on the bridge above it (that doesn't exist).
Obviously some robustness could be added to the driver, but would it
make sense to do something like below and automatically remap these
devices to identical single port device IDs?  Thanks,

Alex

Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
--

diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index b7f9fa6..1c6d1e8 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -427,6 +427,35 @@ static int assigned_dev_register_regions(PCIRegion *io_regions,
     return 0;
 }
 
+static void assigned_device_fixup(AssignedDevice *pci_dev)
+{
+    uint16_t vendor_id, device_id;
+
+    vendor_id = pci_dev->dev.config[0] | pci_dev->dev.config[1] << 8;
+    device_id = pci_dev->dev.config[2] | pci_dev->dev.config[3] << 8;
+
+    switch (vendor_id) {
+        case 0x8086:
+            switch (device_id) {
+                case 0x10A4:
+                case 0x10BC:
+                    /* quad port copper -> single port copper */
+                    pci_dev->dev.config[2] = 0x5E;
+                    break;
+                case 0x10A5:
+                    /* quad port fiber -> single port fiber */
+                    pci_dev->dev.config[2] = 0x5F;
+                    break;
+                case 0x10DA:
+                case 0x10D9:
+                    /* dual/quad port serdes -> single port serdes */
+                    pci_dev->dev.config[2] = 0x60;
+                    break;
+            }
+            break;
+    }
+}
+
 static int get_real_device(AssignedDevice *pci_dev, uint8_t r_bus,
                            uint8_t r_dev, uint8_t r_func)
 {
@@ -524,6 +553,8 @@ again:
     }
     fclose(f);
 
+    assigned_device_fixup(pci_dev);
+
     /* dealing with virtual function device */
     snprintf(name, sizeof(name), "%sphysfn/", dir);
     if (!stat(name, &statbuf))


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux