summaryrefslogtreecommitdiff
path: root/hw/usb/redirect.c
AgeCommit message (Collapse)AuthorFilesLines
2012-11-08usb-redir: Allow packets to have both data and an error-statusHans de Goede1-36/+20
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-08usb: split packet result into actual_length + statusHans de Goede1-68/+89
Since with the ehci and xhci controllers a single packet can be larger then maxpacketsize, it is possible for the result of a single packet to be both having transferred some data as well as the transfer to have an error. An example would be an input transfer from a bulk endpoint successfully receiving 1 or more maxpacketsize packets from the device, followed by a packet signalling halt. While already touching all the devices and controllers handle_packet / handle_data / handle_control code, also change the return type of these functions to void, solely storing the status in the packet. To make the code paths for regular versus async packet handling more uniform. This patch unfortunately is somewhat invasive, since makeing the qemu usb core deal with this requires changes everywhere. This patch only prepares the usb core for this, all the hcd / device changes are done in such a way that there are no functional changes. This patch has been tested with uhci and ehci hcds, together with usb-audio, usb-hid and usb-storage devices, as well as with usb-redir redirection with a wide variety of real devices. Note that there is usually no need to directly set packet->actual_length form devices handle_data callback, as that is done by usb_packet_copy() Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01usb-redir: Allow redirecting super speed devices to high speed controllersHans de Goede1-2/+21
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01usb-redir: Allow to attach USB 2.0 devices to 1.1 host controllerJan Kiszka1-1/+29
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 <jan.kiszka@siemens.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01usb-redir: Use reject rather the disconnect on bad ep infoHans de Goede1-2/+3
So that the client gets a notification about us disconnecting the device. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01usb-redir: Add an usbredir_setup_usb_eps() helper functionHans de Goede1-23/+22
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01usb-redir: Add support for input pipeliningHans de Goede1-10/+53
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01usb-redir: Add support for 32 bits bulk packet lengthHans de Goede1-1/+6
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-25usb: Move short-not-ok handling to the coreHans de Goede1-6/+12
After a short-not-ok packet ending short, we should not advance the queue. Move enforcing this to the core, rather then handling it in the hcd code. This may result in the queue now actually containing multiple input packets (which would not happen before), and this requires special handling in combination with pipelining, so disable pipleining for input endpoints (for now). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-11usb-redir: Don't make migration fail in none seamless caseHans de Goede1-4/+9
Instead simple disconnect the device like host redirection does on migration. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-10-11usb-redir: Change usbredir_open_chardev into usbredir_create_parserHans de Goede1-6/+5
As we need to create the parser at more places. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13usb-redir: Revert usb-redir part of commit 93bfef4cHans de Goede1-5/+3
Commit 93bfef4c6e4b23caea9d51e1099d06433d8835a4 makes qemu-devices which report the qemu version string to the guest in some way use a qemu_get_version function which reports a machine-specific version string. However usb-redir does not expose the qemu version to the guest, only to the usbredir-host as part of the initial handshake. This can then be logged on the usbredir-host side for debugging purposes and is otherwise completely unused! For debugging purposes it is important to have the real qemu version in there, rather then the machine-specific version. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13usb-redir: Add chardev open / close debug loggingHans de Goede1-0/+6
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13usb-redir: Add support for migrationHans de Goede1-3/+346
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13usb-redir: Store max_packet_size in endp_dataHans de Goede1-1/+3
So that we've a place to migrate it to / from to allow restoring it after migration. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13usb-redir: Add an already_in_flight packet-id queueHans de Goede1-0/+43
After a live migration, the usb-hcd will re-queue all packets by walking over the schedule in the guest memory again, but requests which were encountered on the migration source before will already be in flight, so these should *not* be re-send to the usbredir-host. This patch adds an already in flight packet ud queue, which will be filled by the source before migration and then moved over to the migration dest, any async handled packets are then checked against this queue to avoid sending the same packet to the usbredir-host twice. Signed-off-by: Hans de Goede <hdegoede@redhat,com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-13usb-redir: Change cancelled packet code into a generic packet-id queueHans de Goede1-31/+71
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Enable pipelining for bulk endpointsHans de Goede1-0/+3
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Ensure our peer has the necessary caps when redirecting to XHCIHans de Goede1-0/+11
In order for redirection to work properly when redirecting to an emulated XHCI controller, the usb-redir-host must support both usb_redir_cap_ep_info_max_packet_size and usb_redir_cap_64bits_ids, reject any devices redirected to an XHCI controller when these are not supported. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Add a usbredir_reject_device helper functionHans de Goede1-10/+11
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Set ep max_packet_size if availableHans de Goede1-0/+5
This is needed for usb-redir to work properly with the xhci emulation. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Convert to new libusbredirparser 0.5 APIHans de Goede1-31/+31
This gives us support for 64 bit ids which is needed for using XHCI with the new hcd generated ids. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Return babble when getting more bulk data then requestedHans de Goede1-3/+3
Babble is the appropriate error in this case (rather then signalling a stall). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Move to core packet id and queue handlingHans de Goede1-134/+92
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Get rid of unused async-struct dev memberHans de Goede1-2/+0
This is a preparation patch for completely getting rid of the async-packet struct in usb-redir, instead relying on the (new) per ep queues in the qemu usb core. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Get rid of local shadow copy of packet headersHans de Goede1-27/+0
The shadow copy only serves as an extra check (besides the packet-id) to ensure the packet we get back is a reply to the packet we think it is. This check has never triggered in all the time usb-redir is in use now, and since the verified data in the returned packet-header is not used otherwise, removing the check does not open any possibilities for the usbredirhost to confuse us. This is a preparation patch for completely getting rid of the async-packet struct in usb-redir, instead relying on the (new) per ep queues in the qemu usb core. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Get rid of async-struct get memberHans de Goede1-6/+3
This is a preparation patch for completely getting rid of the async-packet struct in usb-redir, instead relying on the (new) per ep queues in the qemu usb core. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Don't delay handling of open events to a bottom halfHans de Goede1-47/+53
There is no need for this, and doing so means that a backend trying to write immediately after an open event will see qemu_chr_be_can_write returning 0, which not all backends handle well as there is no wakeup mechanism to detect when the frontend does become writable. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-09-11usb-redir: Never return USB_RET_NAK for async handled packetsHans de Goede1-3/+6
USB_RET_NAK is not a valid response for async handled packets (and will trigger an assert as such). Also drop the warning when receiving a status of cancelled for packets not cancelled by qemu itself, this can happen when a device gets unredirected by the usbredir-host while transfers are pending. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-07-09usb-redir: Correctly handle the usb_redir_babble usbredir statusHans de Goede1-0/+2
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-19Allow machines to configure the QEMU_VERSION that's exposed via hardwareCrístian Viana1-3/+5
QEMU exposes its version to the guest's hardware and in some cases that is wrong (e.g. Windows prints messages about driver updates when you switch the QEMU version). There is a new field now on the struct QEmuMachine, hw_version, which may contain the version that the specific machine should report. If that field is set, then that machine will report that version to the guest. Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-04-26usb-redir: Not finding an async urb id is not an errorHans de Goede1-1/+1
We clear our pending async urb list on device disconnect and we may still receive "packet complete" packets from our peer after this, which will then refer to packet ids no longer in our list. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-04-26usb-redir: Reset device address and speed on disconnectHans de Goede1-0/+2
Without this disconnected devices look like the last redirected device in the monitor in "info usb". Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-04-26usb-redir: An interface count of 0 is a valid valueHans de Goede1-2/+3
An interface-count of 0 happens when a device is in unconfigured state when it gets redirected. So we should not use 0 to detect not having received interface info from our peer. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-04-17usb-redir: Notify our peer when we reject a device due to a speed mismatchHans de Goede1-1/+7
Also cleanup (reset) our device state when we reject a device due to a speed mismatch. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-04-17Add bootindex support to usb-host and usb-redirGerd Hoffmann1-0/+3
When passing through a usb pendrive seabios will present it in the F12 boot menu and will happily boot from it. This patch adds bootorder support so you can even make it the default boot device. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-13usb: the big renameGerd Hoffmann1-0/+1485
Reorganize usb source files. Create a new hw/usb/ directory and move all usb source code to that place. Also make filenames a bit more descriptive. Host adapters are prefixed with "hch-" now, usb device emulations are prefixed with "dev-". Fixup paths Makefile and include paths to make it compile. No code changes. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>