summaryrefslogtreecommitdiffstats
path: root/hw/usb.h
Commit message (Collapse)AuthorAgeFilesLines
* usb: Add an int_req flag to USBPacketHans de Goede2012-10-251-1/+2
| | | | | Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: Move short-not-ok handling to the coreHans de Goede2012-10-251-1/+3
| | | | | | | | | | | | | 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>
* usb: Move clearing of queue on halt to the coreHans de Goede2012-10-251-0/+1
| | | | | | | | | | | | | hcds which queue up more then one packet at once (uhci, ehci and xhci), must clear the queue after an error which has caused the queue to halt. Currently this is handled as a special case inside the hcd code, this patch instead adds an USB_RET_REMOVE_FROM_QUEUE packet result code, teaches the 3 hcds about this and moves the clearing of the queue on a halt into the USB core. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: Add USB_RET_ADD_TO_QUEUE packet result codeHans de Goede2012-10-251-6/+15
| | | | | | | | | | This can be used by usb-device code which wishes to process an entire endpoint queue at once, to do this the usb-device code returns USB_RET_ADD_TO_QUEUE from its handle_data class method and defines a flush_ep_queue class method to call when the hcd is done queuing up packets. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: Rename __usb_packet_complete to usb_packet_complete_oneHans de Goede2012-10-251-0/+1
| | | | | | | And make it available for use outside of core.c Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb3: bos decriptorGerd Hoffmann2012-09-111-0/+6
| | | | | | | Add support for creating BOS descriptor and device cappability descriptors. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb3: superspeed endpoint companionGerd Hoffmann2012-09-111-0/+1
| | | | | | | Add support for building superspeed endpoint companion descriptors, create them for superspeed usb devices. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb-core: Add a usb_ep_find_packet_by_id() helper functionHans de Goede2012-09-111-0/+2
| | | | | Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: unique packet idsGerd Hoffmann2012-08-311-1/+2
| | | | | | | | | | | | | | | | This patch adds IDs to usb packets. Those IDs are (a) supposed to be unique for the lifecycle of a packet (from packet setup until the packet is either completed or canceled) and (b) stable across migration. uhci, ohci, ehci and xhci use the guest physical address of the transfer descriptor for this. musb needs a different approach because there is no transfer descriptor. But musb also doesn't support pipelining, so we have never more than one packet per endpoint in flight. So we go create an ID based on endpoint and device address. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: Halt ep queue en cancel pending packets on a packet errorHans de Goede2012-08-311-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For controllers which queue up more then 1 packet at a time, we must halt the ep queue, and inside the controller code cancel all pending packets on an error. There are multiple reasons for this: 1) Guests expect the controllers to halt ep queues on error, so that they get the opportunity to cancel transfers which the scheduled after the failing one, before processing continues 2) Not cancelling queued up packets after a failed transfer also messes up the controller state machine, in the case of EHCI causing the following assert to trigger: "assert(p->qtdaddr == q->qtdaddr)" at hcd-ehci.c:2075 3) For bulk endpoints with pipelining enabled (redirection to a real USB device), we must cancel all the transfers after this a failed one so that: a) If they've completed already, they are not processed further causing more stalls to be reported, originating from the same failed transfer b) If still in flight, they are cancelled before the guest does a clear stall, otherwise the guest and device can loose sync! Note this patch only touches the ehci and uhci controller changes, since AFAIK no other controllers actually queue up multiple transfer. If I'm wrong on this other controllers need to be updated too! Also note that this patch was heavily tested with the ehci code, where I had a reproducer for a device causing a transfer to fail. The uhci code is not tested with actually failing transfers and could do with a thorough review! Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* hw/block-common: Move BlockConf & friends from block.hMarkus Armbruster2012-07-171-1/+0
| | | | | | | | This stuff doesn't belong to block layer, and was put there only because a better home didn't exist then. Now it does. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* usb: fix interface initializationGerd Hoffmann2012-07-091-0/+2
| | | | | | | zero is a valid interface number, so don't use it when resetting the endpoints. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: split endpoint init and resetGerd Hoffmann2012-07-091-0/+1
| | | | | | | | Create a new usb_ep_reset() function to reset endpoint state, without re-initialiting the queues, so we don't unlink in-flight packets just because usb-host has to re-parse the descriptor tables. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: Convert usb_packet_{map, unmap} to universal DMA helpersDavid Gibson2012-06-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The USB UHCI and EHCI drivers were converted some time ago to use the pci_dma_*() helper functions. However, this conversion was not complete because in some places both these drivers do DMA via the usb_packet_map() function in usb-libhw.c. That function directly used cpu_physical_memory_map(). Now that the sglist code uses DMA wrappers properly, we can convert the functions in usb-libhw.c, thus conpleting the conversion of UHCI and EHCI to use the DMA wrappers. Note that usb_packet_map() invokes dma_memory_map() with a NULL invalidate callback function. When IOMMU support is added, this will mean that usb_packet_map() and the corresponding usb_packet_unmap() must be called in close proximity without dropping the qemu device lock - otherwise the guest might invalidate IOMMU mappings while they are still in use by the device code. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: Convert busses to QEMU Object ModelAnthony Liguori2012-06-181-0/+3
| | | | | | | | | | | | | | | This is far less interesting than it sounds. We simply add an Object to each BusState and then register the types appropriately. Most of the interesting refactoring will follow in the next patches. Since we're changing fundamental type names (BusInfo -> BusClass), it all needs to convert at once. Fortunately, not a lot of code is affected. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> [AF: Made all new bus TypeInfos static const.] [AF: Made qbus_free() call object_delete(), required {qom,glib}_allocated] Signed-off-by: Andreas Färber <afaerber@suse.de>
* usb/vmstate: add parent dev pathGerd Hoffmann2012-04-171-0/+5
| | | | | | | | | | | | | ... to make vmstate id string truely unique with multiple host controllers, i.e. move from "1/usb-ptr" to "0000:00:01.3/1/usb-ptr" (usb tabled connected to piix3 uhci). This obviously breaks migration. To handle this the usb bus property "full-path" is added. When setting this to false old behavior is maintained. This way current qemu will be compatible with old versions when started using '-M pc-$oldversion'. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: improve packet state sanity checksGerd Hoffmann2012-03-131-0/+1
| | | | | | | Add a new function to check whenever the packet state is as expected, log more informations in case it isn't. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: add shortcut for control transfersGerd Hoffmann2012-03-071-0/+1
| | | | | | | | | | Add a more direct code path to submit control transfers. Instead of feeding three usb packets (setup, data, ack) to usb_handle_packet and have the do_token_* functions in usb.c poke the control transfer parameters out of it just submit a single packet carrying the actual data with the control xfer parameters filled into USBPacket->parameters. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: add pipelining option to usb endpointsGerd Hoffmann2012-03-071-0/+2
| | | | | | | | | With this patch applied USB drivers can enable pipelining per endpoint. With pipelining enabled the usb core will continue submitting packets even when there are still async transfers in flight instead of passing them on one by one. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: add USB_RET_IOERRORHans de Goede2012-03-071-5/+6
| | | | | | | | | | | | | | | | | | | | We already have USB_RET_NAK, but that means that a device does not want to send/receive right now. But with host / network redirection we can actually have a transaction fail due to some io error, rather then ie the device just not having any data atm. This patch adds a new error code named USB_RET_IOERROR for this, and uses it were appropriate. Notes: -Currently all usb-controllers handle this the same as NODEV, but that may change in the future, OHCI could indicate a CRC error instead for example. -This patch does not touch hw/usb-musb.c, that is because the code in there handles STALL and NAK specially and has a if status < 0 generic catch all for all other errors Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: Resolve warnings about unassigned bus on usb device creationJan Kiszka2012-02-271-3/+4
| | | | | | | | | | | | When creating an USB device the old way, there is no way to specify the target bus. Thus the warning issued by usb_create makes no sense and rather confuses our users. Resolve this by passing a bus reference to the usbdevice_init handler and letting those handlers forward it to usb_create. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: add USBBusOps->wakeup_endpointGerd Hoffmann2012-02-101-0/+1
| | | | | | | Add usb bus op which is called whenever a usb endpoint becomes ready, so the host adapter emulation can react on that event. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: pass USBEndpoint to usb_wakeupGerd Hoffmann2012-02-101-1/+1
| | | | | | | | | 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: maintain async packet list per endpointGerd Hoffmann2012-02-101-2/+7
| | | | | | | | Maintain a list of async packets per endpoint. With the current code the list will never receive more than a single item. I think you can guess what the future plan is though ;) Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: Set USBEndpoint in usb_packet_setup().Gerd Hoffmann2012-02-101-3/+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: add USBEndpoint->{nr,pid}Gerd Hoffmann2012-02-101-0/+2
| | | | | | | Add a "nr" and "pid" fields to USBEndpoint so you can easily figure the endpoint number and direction of any given endpoint. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: USBPacket: add status, rename owner -> epGerd Hoffmann2012-02-101-3/+16
| | | | | | | | | Add enum to track the status of USBPackets, use that instead of the owner pointer to figure whenever a usb packet is currently in flight or not. Add some more packet status sanity checks. Also rename the USBEndpoint pointer from "owner" to "ep". Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: kill handle_packet callbackGerd Hoffmann2012-02-101-12/+0
| | | | | | | | | | | | | | 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: add usb_find_device()Gerd Hoffmann2012-02-101-0/+10
| | | | | | | | | | | | | | | | | | | | Add usb_find_device(). This function will check whenever a device with a specific address is connected to the specified port. Usually this will just check state and address of the device hooked up to the port, but in case of a hub it will ask the hub to check all hub ports for a matching device. This patch doesn't put the code into use yet, see the following patches for details. The master plan is to separate device lookup and packet processing. Right now the usb code simply walks all devices, calls usb_handle_packet() on each until one accepts the packet (by returning something different that USB_RET_NODEV). I want to have a device lookup first, then call usb_handle_packet() once, for the device which actually processes the packet. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: kill usb_send_msgGerd Hoffmann2012-02-101-1/+0
| | | | | | No users left. Zap it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: kill USB_MSG_RESETGerd Hoffmann2012-02-101-4/+2
| | | | | | | | | | | | | 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>
* usb: kill USB_MSG_{ATTACH,DETACH}Gerd Hoffmann2012-02-101-2/+0
| | | | | | | | | The USB subsystem pipes internal attach/detach 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. Remove it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* qdev: register all types natively through QEMU Object ModelAnthony Liguori2012-02-031-1/+0
| | | | | | | | | | | | | | | | | | | | | 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-3/+3
| | | | | | | 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-11/+39
| | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Merge remote-tracking branch 'kraxel/usb.37' into stagingAnthony Liguori2012-01-191-1/+43
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * kraxel/usb.37: usb-redir: Improve some debugging messages usb-redir: Try to keep our buffer size near the target size usb-redir: Pre-fill our isoc input buffer before sending pkts to the host usb-redir: Dynamically adjust iso buffering size based on ep interval usb-redir: Clear iso / irq error when stopping the stream usb: link packets to endpoints not devices usb: add max_packet_size to USBEndpoint usb/debug: add usb_ep_dump usb-desc: USBEndpoint support usb: add ifnum to USBEndpoint usb: add USBEndpoint xhci: Initial xHCI implementation usb: add audio device model usb-desc: audio endpoint support usb: track altsetting in USBDevice usb: track configuration and interface count in USBDevice. usb-host: rip out legacy procfs support
| * usb: link packets to endpoints not devicesGerd Hoffmann2012-01-171-1/+3
| | | | | | | | | | | | | | Add USBEndpoint for the control endpoint to USBDevices. Link async packets to the USBEndpoint instead of the USBDevice. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
| * usb: add max_packet_size to USBEndpointGerd Hoffmann2012-01-171-0/+4
| | | | | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
| * usb/debug: add usb_ep_dumpGerd Hoffmann2012-01-171-0/+1
| | | | | | | | | | | | Add function to dump endpoint data, for debugging purposes. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
| * usb: add ifnum to USBEndpointGerd Hoffmann2012-01-171-0/+3
| | | | | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
| * usb: add USBEndpointGerd Hoffmann2012-01-171-0/+14
| | | | | | | | | | | | | | | | Start maintaining endpoint state at USBDevice level. Add USBEndpoint struct and some helper functions to deal with it. For now it contains the endpoint type only. Moved over some bits from usb-linux.c Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
| * usb: add audio device modelH. Peter Anvin2012-01-131-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This brings a usb audio device to qemu. Output only, fixed at 16bit stereo @ 480000 Hz. Based on a patch from H. Peter Anvin <hpa@linux.intel.com> Usage: add '-device usb-audio' to your qemu command line. Works sorta ok on a idle machine. Known issues: * Is *very* sensitive to latencies. * Burns quite some CPU due to usb polling. In short: It brings the qemu usb emulation to its limits. Enjoy! Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
| * usb: track altsetting in USBDeviceGerd Hoffmann2012-01-131-0/+8
| | | | | | | | | | | | Also handle {GET,SET}_INTERFACE in common code (usb-desc.c). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
| * usb: track configuration and interface count in USBDevice.Gerd Hoffmann2012-01-131-0/+3
| | | | | | | | | | | | | | | | Move fields from USBHostDevice to USBDevice. Add bits to usb-desc.c to fill them for emulated devices too. Also allow to set configuration 0 (== None) for emulated devices. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* | vmstate: extract declarations out of hw/hw.hPaolo Bonzini2012-01-131-0/+12
|/ | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* usb: fix port resetGerd Hoffmann2011-10-131-0/+1
| | | | | | | | | | | | | | commit 891fb2cd4592b6fe76106a69e0ca40efbf82726a removed the implicit detach before (re-)attaching in usb_attach(). Some usb host controllers used that behavior though to do a port reset by a detach+attach sequence. This patch establishes old behavior by adding a new usb_reset() function for port resets and putting it into use, thereby also unifying port reset behavior of all host controllers. The patch also adds asserts to usb_attach() and usb_detach() to make sure the calls are symmetrical. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb-musb: Add reset functionJuha Riihimäki2011-09-071-0/+1
| | | | | | | | | | | | | Add a separate reset function musb_reset() to the usb-musb interface, so that users who implement a reset function can also reset usb-musb. Use this in tusb6010. Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com> [Riku Voipio: Fixes and restructuring patchset] Signed-off-by: Riku Voipio <riku.voipio@iki.fi> [Peter Maydell: More fixes and cleanups for upstream submission] Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb-musb: Take a DeviceState* in init functionPeter Maydell2011-09-071-1/+1
| | | | | | | | | | Initialise usb-musb by passing it a DeviceState* and the offset of the IRQs in its gpio array, rather than a plain pointer to an irq array. This is simpler for callers and also allows us to pass in a valid parent to usb_bus_new(), so the USB bus actually appears in the qdev tree. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: Remove leading underscores from __musb_irq_maxPeter Maydell2011-09-071-1/+2
| | | | | | | | Identifiers with double leading underscore are reserved, so rename __musb_irq_max so we don't encroach on reserved namespace. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: claim port at device initialization time.Gerd Hoffmann2011-09-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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>
OpenPOWER on IntegriCloud