[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 30/31] usb-redir: Allow to attach USB 2.0 devices to
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 30/31] usb-redir: Allow to attach USB 2.0 devices to 1.1 host controller |
Date: |
Thu, 1 Nov 2012 16:54:43 +0100 |
From: Jan Kiszka <address@hidden>
This follows the logic of host-linux: If a 2.0 device has no ISO
endpoint and no interrupt endpoint with a packet size > 64, we can
attach it also to an 1.1 host controller. In case the redir server does
not report endpoint sizes, play safe and remove the 1.1 compatibility as
well. Moreover, if we detect a conflicting change in the configuration
after the device was already attached, it will be disconnected
immediately.
HdG: Several small cleanups and fixes
Signed-off-by: Jan Kiszka <address@hidden>
Signed-off-by: Hans de Goede <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb/redirect.c | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 5c2d185..8d4d3f4 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -106,6 +106,7 @@ struct USBRedirDevice {
struct usb_redir_interface_info_header interface_info;
struct usbredirfilter_rule *filter_rules;
int filter_rules_count;
+ int compatible_speedmask;
};
static void usbredir_hello(void *priv, struct usb_redir_hello_header *h);
@@ -962,6 +963,7 @@ static void usbredir_do_attach(void *opaque)
}
if (usb_device_attach(&dev->dev) != 0) {
+ WARNING("rejecting device due to speed mismatch\n");
usbredir_reject_device(dev);
}
}
@@ -1068,6 +1070,9 @@ static int usbredir_initfn(USBDevice *udev)
/* We'll do the attach once we receive the speed from the usb-host */
udev->auto_attach = 0;
+ /* Will be cleared during setup when we find conflicts */
+ dev->compatible_speedmask = USB_SPEED_MASK_FULL;
+
/* Let the backend know we are ready */
qemu_chr_fe_open(dev->cs);
qemu_chr_add_handlers(dev->cs, usbredir_chardev_can_read,
@@ -1208,6 +1213,7 @@ static void usbredir_device_connect(void *priv,
case usb_redir_speed_low:
speed = "low speed";
dev->dev.speed = USB_SPEED_LOW;
+ dev->compatible_speedmask &= ~USB_SPEED_MASK_FULL;
break;
case usb_redir_speed_full:
speed = "full speed";
@@ -1241,7 +1247,7 @@ static void usbredir_device_connect(void *priv,
device_connect->device_class);
}
- dev->dev.speedmask = (1 << dev->dev.speed);
+ dev->dev.speedmask = (1 << dev->dev.speed) | dev->compatible_speedmask;
dev->device_info = *device_connect;
if (usbredir_check_filter(dev)) {
@@ -1281,6 +1287,7 @@ static void usbredir_device_disconnect(void *priv)
dev->interface_info.interface_count = NO_INTERFACE_INFO;
dev->dev.addr = 0;
dev->dev.speed = 0;
+ dev->compatible_speedmask = USB_SPEED_MASK_FULL;
}
static void usbredir_interface_info(void *priv,
@@ -1302,6 +1309,12 @@ static void usbredir_interface_info(void *priv,
}
}
+static void usbredir_mark_speed_incompatible(USBRedirDevice *dev, int speed)
+{
+ dev->compatible_speedmask &= ~(1 << speed);
+ dev->dev.speedmask = (1 << dev->dev.speed) | dev->compatible_speedmask;
+}
+
static void usbredir_set_pipeline(USBRedirDevice *dev, struct USBEndpoint *uep)
{
if (uep->type != USB_ENDPOINT_XFER_BULK) {
@@ -1350,7 +1363,14 @@ static void usbredir_ep_info(void *priv,
case usb_redir_type_invalid:
break;
case usb_redir_type_iso:
+ usbredir_mark_speed_incompatible(dev, USB_SPEED_FULL);
+ /* Fall through */
case usb_redir_type_interrupt:
+ if (!usbredirparser_peer_has_cap(dev->parser,
+ usb_redir_cap_ep_info_max_packet_size) ||
+ ep_info->max_packet_size[i] > 64) {
+ usbredir_mark_speed_incompatible(dev, USB_SPEED_FULL);
+ }
if (dev->endpoint[i].interval == 0) {
ERROR("Received 0 interval for isoc or irq endpoint\n");
usbredir_reject_device(dev);
@@ -1368,6 +1388,14 @@ static void usbredir_ep_info(void *priv,
return;
}
}
+ /* The new ep info may have caused a speed incompatibility, recheck */
+ if (dev->dev.attached &&
+ !(dev->dev.port->speedmask & dev->dev.speedmask)) {
+ ERROR("Device no longer matches speed after endpoint info change, "
+ "disconnecting!\n");
+ usbredir_reject_device(dev);
+ return;
+ }
usbredir_setup_usb_eps(dev);
}
--
1.7.1
- [Qemu-devel] [PATCH 11/31] usb/ehci: seperate out PCIisms, (continued)
- [Qemu-devel] [PATCH 11/31] usb/ehci: seperate out PCIisms, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 29/31] usb-redir: Use reject rather the disconnect on bad ep info, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 01/31] xhci: add {get, set}_field macros & enum for pls, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 18/31] uhci: add ich9 00:1a.* variants, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 26/31] usb-redir: Add support for 32 bits bulk packet length, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 28/31] usb-redir: Add an usbredir_setup_usb_eps() helper function, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 05/31] xhci: add xhci_port_reset, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 12/31] usb/ehci: Guard definition of EHCI_DEBUG, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 16/31] uhci: dynamic type generation, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 31/31] usb-redir: Allow redirecting super speed devices to high speed controllers, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 30/31] usb-redir: Allow to attach USB 2.0 devices to 1.1 host controller,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 24/31] usb: Add packet combining functions, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 14/31] usb/ehci: add sysbus variant, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 22/31] uhci: Add a uhci_handle_td_error() helper function, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 27/31] usb-redir: Add support for input pipelining, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 19/31] usb/ehci-pci: dynamic type generation, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 13/31] usb/ehci: split into multiple source files, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 15/31] xilinx_zynq: add USB controllers, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 23/31] uhci: Don't crash on device disconnect, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 17/31] uhci: stick irq routing info into UHCIInfo too., Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 25/31] combined-packet: Add a workaround for Linux usbfs + live migration, Gerd Hoffmann, 2012/11/01