summaryrefslogtreecommitdiffstats
path: root/hw/usb-hub.c
Commit message (Collapse)AuthorAgeFilesLines
* usb: the big renameGerd Hoffmann2012-03-131-549/+0Star
| | | | | | | | | | 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>
* Merge remote-tracking branch 'kraxel/usb.38' into stagingAnthony Liguori2012-02-161-44/+28Star
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * kraxel/usb.38: (28 commits) xhci: handle USB_RET_NAK xhci: remote wakeup support xhci: kill port arg from xhci_setup_packet xhci: stop on errors xhci: add trb type name lookup support. xhci: signal low- and fullspeed support usb: add USBBusOps->wakeup_endpoint usb: pass USBEndpoint to usb_wakeup usb: maintain async packet list per endpoint usb: Set USBEndpoint in usb_packet_setup(). usb: add USBEndpoint->{nr,pid} usb: USBPacket: add status, rename owner -> ep usb: fold usb_generic_handle_packet into usb_handle_packet usb: kill handle_packet callback usb-xhci: switch to usb_find_device() usb-musb: switch to usb_find_device() usb-ohci: switch to usb_find_device() usb-ehci: switch to usb_find_device() usb-uhci: switch to usb_find_device() usb: handle dev == NULL in usb_handle_packet() ...
| * usb: pass USBEndpoint to usb_wakeupGerd Hoffmann2012-02-101-3/+5
| | | | | | | | | | | | | | | | | | Devices must specify which endpoint has data to transfer now. The plan is to use the usb_wakeup() not only for remove wakeup support, but for "data ready" signaling in general, so we can move away from constant polling to event driven usb device emulation. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
| * usb: Set USBEndpoint in usb_packet_setup().Gerd Hoffmann2012-02-101-1/+1
| | | | | | | | | | | | | | | | | | | | With the separation of the device lookup (via usb_find_device) and packet processing we can lookup device and endpoint before setting up the usb packet. So we can initialize USBPacket->ep early and keep it valid for the whole lifecycle of the USBPacket. Also the devaddr and devep fields are not needed any more. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
| * usb: kill handle_packet callbackGerd Hoffmann2012-02-101-39/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | All drivers except usb-hub use usb_generic_handle_packet. The only reason the usb hub has its own function is that it used to be called with packets which are intended for downstream devices. With the new, separate device lookup step this doesn't happen any more, so the need for a different handle_packet callback is gone. So we can kill the handle_packet callback and just call usb_generic_handle_packet directly. The special hub handling in usb_handle_packet() can go away for the same reason. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
| * usb-hub: implement find_deviceGerd Hoffmann2012-02-101-0/+21
| | | | | | | | | | | | | | | | Implement the find_device callback for the usb hub. It'll loop over all ports, calling usb_find_device for all enabled ports until it finds a matching device. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
| * usb: kill USB_MSG_RESETGerd Hoffmann2012-02-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The USB subsystem pipes internal reset notifications through usb_handle_packet() with a special magic PID. This indirection is a pretty pointless excercise as it ends up being handled by usb_generic_handle_packet anyway. Replace the USB_MSG_RESET with a usb_device_reset() function which can be called directly. Also rename the existing usb_reset() function to usb_port_reset() to avoid confusion. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* | qom: Unify type registrationAndreas Färber2012-02-151-2/+3
|/ | | | | | | | | | | | | Replace device_init() with generalized type_init(). While at it, unify naming convention: type_init([$prefix_]register_types) Also, type_init() is a function, so add preceding blank line where necessary and don't put a semicolon after the closing brace. Signed-off-by: Andreas Färber <afaerber@suse.de> Cc: Anthony Liguori <anthony@codemonkey.ws> Cc: malc <av1474@comtv.ru> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: register all types natively through QEMU Object ModelAnthony Liguori2012-02-031-8/+10
| | | | | | | | | | | | | | | | | | | | | This was done in a mostly automated fashion. I did it in three steps and then rebased it into a single step which avoids repeatedly touching every file in the tree. The first step was a sed-based addition of the parent type to the subclass registration functions. The second step was another sed-based removal of subclass registration functions while also adding virtual functions from the base class into a class_init function as appropriate. Finally, a python script was used to convert the DeviceInfo structures and qdev_register_subclass functions to TypeInfo structures, class_init functions, and type_register_static calls. We are almost fully converted to QOM after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* usb: separate out legacy usb registration from type registrationAnthony Liguori2012-02-031-1/+1
| | | | | | | Type registeration is going to get turned into a QOM call so decouple the legacy support. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* usb: convert to QEMU Object ModelAnthony Liguori2012-01-271-14/+21
| | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* usb: track altsetting in USBDeviceGerd Hoffmann2012-01-131-7/+0Star
| | | | | | Also handle {GET,SET}_INTERFACE in common code (usb-desc.c). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb-hub: implement resetGerd Hoffmann2011-11-231-3/+17
| | | | | | based on a patch from hkran@linux.vnet.ibm.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb-hub: wakeup on detach too.Gerd Hoffmann2011-11-221-0/+2
| | | | | | | | | | | | When detaching devices from the usb hub we must wakeup too, otherwise the host misses the detach event. Commit 4a33a9ea06f6fbb08d8311a7cfed72975344f9ab does the same for device attach. Found by hkran@linux.vnet.ibm.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: change VID/PID for usb-hub and usb-msd to prevent conflictRoy Tam2011-11-011-2/+2
| | | | | | | | | Some USB drivers, for example USBASPI.SYS, will skip different type of device which has same VID/PID. The following patch helps preventing usb-msd being skipped by the driver. Signed-off-by: Roy Tam <roytam@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb-hub: wakeup on attachGerd Hoffmann2011-11-011-0/+1
| | | | | | | | When attaching a new device we must send a wakeup request to the root hub, otherwise the guest will not notice the new device in case the usb hub is suspended. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb-hub: don't trigger assert on packet completion.Gerd Hoffmann2011-10-131-2/+6
| | | | | | | | | | | Calling usb_packet_complete() recursively when passing up the completion event up the chain for devices connected via usb hub will trigger an assert. So don't do that, make the usb hub emulation call the upstream completion callback directly instead. Based on a patch from Stefan Hajnoczi <stefanha@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb-hub: need to check dev->attachedGerd Hoffmann2011-10-131-2/+2
| | | | | | | commit 891fb2cd4592b6fe76106a69e0ca40efbf82726a did that for all host controllers, the usb hub was left out by accident. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: claim port at device initialization time.Gerd Hoffmann2011-09-071-11/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | This patch makes qemu assign a port when creating the device, not when attaching it. For most usb devices this isn't a noticable difference because they are in attached state all the time. The change affects usb-host devices which live in detached state while the real device is unplugged from the host. They have a fixed port assigned all the time now instead of getting grabbing one on attach and releasing it at detach, i.e. they stop floating around at the usb bus. The change also allows to simplify usb-hub. It doesn't need the handle_attach() callback any more to configure the downstream ports. This can be done at device initialitation time now. The changed initialization order (first grab upstream port, then register downstream ports) also fixes some icky corner cases. For example it is not possible any more to plug the hub into one of its own downstream ports. The usb host adapters must care too. USBPort->dev being non-NULL doesn't imply any more the device is in attached state. The host adapters must additionally check the USBPort->dev->attached flag. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: use iovecs in USBPacketGerd Hoffmann2011-08-041-3/+5
| | | | | | | | | | | | | | | | | | Zap data pointer from USBPacket, add a QEMUIOVector instead. Add a bunch of helper functions to manage USBPacket data. Switch over users to the new interface. Note that USBPacket->len was used for two purposes: First to pass in the buffer size and second to return the number of transfered bytes or the status code on async transfers. There is a new result variable for the latter. A new status code was added to catch uninitialized result. Nobody creates iovecs with more than one element (yet). Some users are (temporarely) limited to iovecs with a single element to keep the patch size as small as possible. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb-hub: remove unused descriptor arraysGerd Hoffmann2011-07-081-68/+0Star
| | | | | | | Somehow they where left over when converting the hub to the new usb descriptor infrastructure ... Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: Replace device_destroy bus op with a child_detach port opHans de Goede2011-07-051-0/+12
| | | | | | | | | | | | | | | Note this fixes 2 things in one go, first of all the device_destroy bus op should be a device_detach bus op, as pending async packets from the device should be cancelled on detach not on destroy. Secondly having this as a bus op won't work with companion controllers, since then there will be 1 bus driven by the ehci controller and thus 1 set of bus ops, but the device being detached may be downstream of a handed over port. Making the detach of a downstream device a port op allows the ehci controller to forward this to the companion controller port for handed over ports. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: Make port wakeup and complete ops take a USBPort instead of a DeviceHans de Goede2011-07-051-5/+5
| | | | | | | | | | | This makes them consistent with the attach and detach ops, and in general it makes sense to make portops take a port as argument. This also makes adding support for a companion controller easier / cleaner. [ kraxel: fix usb-musb.c build ] Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: add usb_handle_packetGerd Hoffmann2011-05-261-1/+1
| | | | | | | | Add a usb_handle_packet function, put it into use everywhere. Right now it just calls dev->info->handle_packet(), that will change in future patches though. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: Pass the packet to the device's handle_control callbackHans de Goede2011-05-261-3/+3
| | | | | | | | This allows using the generic usb_generic_handle_packet function from device code which does ASYNC control requests (such as the linux host pass through code). Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: update config descriptors to identify number of interfacesBrad Hards2011-05-261-0/+1
| | | | | | | | Previously we relied on the .bNumInterfaces, but that won't always be accurate after the introduction of grouped interfaces. Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: move complete callback to port opsGerd Hoffmann2011-05-041-0/+14
|
* usb hub: add migration supportGerd Hoffmann2011-01-241-0/+24
| | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: zap pdev from usbportGerd Hoffmann2011-01-121-1/+1
| | | | | | It isn't needed any more. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: keep track of physical port address.Gerd Hoffmann2011-01-111-0/+11
| | | | | | | | | Add a path string to USBPort. Add usb_port_location() function to set the physical location of the usb port. Update all drivers implementing usb ports to call it. Update the monitor commands to print it. Wind it up in qdev. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: add speed mask to portsGerd Hoffmann2011-01-111-1/+2
| | | | | | | Add a field to usb ports indicating the speed(s) they are able to handle. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: hub: remote wakeup support.Gerd Hoffmann2011-01-111-0/+12
| | | | | | | | This patch makes the usb hub handle remote wakeup requests from devices properly by updating the port status register and forwarding the wakeup to the upstream port. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: rework attach/detach workflowGerd Hoffmann2011-01-111-26/+20Star
| | | | | | | | | | | | | | | Add separate detach callback to USBPortOps, split uhci/ohci/musb/usbhub attach functions into two. Move common code to the usb_attach() function, only the hardware-specific bits remain in the attach/detach callbacks. Keep track of the port it is attached to for each usb device. [ v3: fix tyops in usb-musb.c ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: create USBPortOps, move attach there.Gerd Hoffmann2011-01-111-1/+5
| | | | | | Create USBPortOps struct, move the attach function to that struct. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: move remote wakeup handling to common codeGerd Hoffmann2011-01-111-22/+0Star
| | | | | | | | This patch moves setting and clearing the remote_wakeup feature bit (via USB_REQ_{SET,CLEAR}_FEATURE) to common code. Also USB_REQ_GET_STATUS handling is moved to common code. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: move USB_REQ_{GET,SET}_CONFIGURATION handling to common codeGerd Hoffmann2011-01-111-8/+1Star
| | | | | | | | | | | | | | | | This patch adds fields to the USBDevice struct for the current speed (hard-wired to full speed for now) and current device configuration. Also a init function is added which inializes these fields. This allows USB_REQ_{GET,SET}_CONFIGURATION handling to be moved to common code. For most drivers the conversion is trivial ad they support a single configuration only anyway. One exception is bluetooth where some device-specific setup code runs after get/set configuration. The other is usb-net which actually has two configurations so the the code to check for the active configuration has been adapted. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: move USB_REQ_SET_ADDRESS handling to common codeGerd Hoffmann2011-01-111-4/+0Star
| | | | | | | USB_REQ_SET_ADDRESS handling is identical in *all* emulated devices. Move it to common code. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb hub: use new descriptor infrastructure.Gerd Hoffmann2011-01-111-63/+78
| | | | | | | | | | | Switch the usb hub driver over to the new descriptor infrastructure. It also removes the nr_ports variable and MAX_PORTS define and introduces a NUM_PORTS define instead. The numver of ports was (and still is) fixed at 8 anyway. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* Record which USBDevice USBPort belongs too.Gleb Natapov2010-12-111-1/+1
| | | | | | | | Ports on root hub will have NULL here. This is needed to reconstruct path from device to its root hub to build device path. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Introduce fw_name field to DeviceInfo structure.Gleb Natapov2010-12-111-0/+1
| | | | | | | | | Add "fw_name" to DeviceInfo to use in device path building. In contrast to "name" "fw_name" should refer to functionality device provides instead of particular device model like "name" does. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* usb: remove dead assignments, spotted by clang analyzerBlue Swirl2010-04-251-2/+1Star
| | | | | | Value stored is never read. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Make USB hid devices self-poweredRiku Voipio2009-12-181-1/+1
| | | | | | | Simplifies power budget negotiation. Signed-off-by: Riku Voipio <riku.voipio@nokia.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* qdev: Replace device names containing whitespaceMarkus Armbruster2009-12-121-1/+1
| | | | | | | | | | | | Device names with whitespace require quoting in the shell and in the monitor. Some of the offenders are also overly long. Some have a more convenient alias, some don't. The place for verbose device names is DeviceInfo member desc. The name should be short & sweet. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: Separate USB product description from qdev nameMarkus Armbruster2009-12-121-0/+1
| | | | | | | | | | | | Using the qdev name for the product description makes for inconvenient qdev names. Put the product description in new USBDeviceInfo member product_desc. Make usb_qdev_init() use it. No user or guest visible change, since the value is still the same. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* usb: hook unplug into qdev, cleanups + fixes.Gerd Hoffmann2009-10-051-1/+5
| | | | | | | | | | | | | | | Hook into DeviceInfo->exit(). handle_destroy() must not free the state struct, this is handled by the new usb_qdev_exit() function now. qdev_free(usb_device) works now. Fix usb hub to qdev_free() all connected devices on unplug. Unplugging a usb hub works now. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev/usb: make qemu aware of usb busses.Gerd Hoffmann2009-09-091-6/+2Star
| | | | | | | | | | | | | | Move usb code from vl.c to usb-bus.c and make it use the new data structures added by qdev conversion. qemu usb core should be able to handle multiple USB busses just fine now (untested though). Kill some usb_*_init() legacy functions, use usb_create_simple() instead. Kill some FIXMEs added by the first qdev/usb patch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev/usb: add usb bus support to qdev, convert drivers.Gerd Hoffmann2009-09-091-20/+29
| | | | | | | | | | | | | | * Add USBBus. * Add USBDeviceInfo, move device callbacks here. * Add usb-qdev helper functions. * Switch drivers to qdev. TODO: * make the rest of qemu aware of usb busses and kill the FIXMEs added by this patch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* hw: remove error handling from qemu_malloc() callers (Avi Kivity)aliguori2009-02-051-2/+0Star
| | | | | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6529 c046a42c-6fe2-441c-8c8c-71466251a162
* Break up vl.h.pbrook2007-11-171-1/+2
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3674 c046a42c-6fe2-441c-8c8c-71466251a162
* find -type f | xargs sed -i 's/[\t ]*$//g' # Yes, again. Note the star in ↵ths2007-09-171-4/+4
| | | | | | the regex. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3177 c046a42c-6fe2-441c-8c8c-71466251a162