aboutsummaryrefslogtreecommitdiff
path: root/src/include/ipxe/usb.h
AgeCommit message (Collapse)AuthorFilesLines
2020-10-30[efi] Avoid dragging in USB subsystem via efi_usb_path()Michael Brown1-1/+17
Commit 87e39a9c9 ("[efi] Split efi_usb_path() out to a separate function") unintentionally introduced an undefined symbol reference from efi_path.o to usb_depth(), causing the USB subsystem to become a dependency of all EFI builds. Fix by converting usb_depth() to a static inline function. Reported-by: Pico Mitchell <pico@randomapplications.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-10-13[usb] Move usbio driver to end of USB driver listMichael Brown1-0/+3
iPXE will often have multiple drivers available for a USB device. For example: some USB network devices will support both RNDIS and CDC-ECM, and any device may be consumed by the fallback "usbio" driver under UEFI in order to expose an EFI_USB_IO_PROTOCOL instance. The driver scoring mechanism is used to select a device configuration based on the availability of drivers for the interfaces exposed in each configuration. For the case of RNDIS versus CDC-ECM, this mechanism will always produce the correct result since RNDIS and CDC-ECM will not exist within the same configuration and so each configuration will receive a score based on the relevant driver. This guarantee does not hold for the "usbio" driver, which will match against any device. It is a surprising coincidence that the "usbio" driver seems to usually end up at the tail end of the USB drivers list, thereby resulting in the expected behaviour. Guarantee the expected behaviour by explicitly placing the "usbio" driver at the end of the USB drivers list. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-10-12[usb] Allow endpoints to be refilled to a specified upper limitMichael Brown1-0/+1
For USB mass storage devices, we do not want to submit more bulk IN packets than are required for the inbound data, since this will waste memory. Allow an upper limit to be specified on each refill attempt. The endpoint will be refilled to the lower of this limit or the limit specified by usb_refill_init(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-10-12[usb] Allow device halt to be cleared independently of host controllerMichael Brown1-0/+1
Closing and reopening a USB endpoint will clear any halt status recorded by the host controller, but may leave the endpoint halted at the device. This will cause the first packet submitted to the reopened endpoint to be lost, before the automatic stall recovery mechanism detects the halt and resets the endpoint. This is relatively harmless for USB network or HID devices, since the wire protocols will recover gracefully from dropped packets. Some protocols (e.g. for USB mass storage devices) assume zero packet loss and so would be adversely affected. Fix by allowing any device endpoint halt status to be cleared on a freshly opened endpoint. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-07-03[usb] Use non-zero language ID to retrieve stringsMichael Brown1-0/+6
We currently use a zero language ID to retrieve strings such as the ECM/NCM MAC address. This works on most hardware devices, but is known to fail on some software emulated CDC-NCM devices. Fix by using the first supported language ID, falling back to English (0x0409) if any error occurs when fetching the list of supported languages. This matches the behaviour of the Linux kernel. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-19[usb] Allow USB endpoints to specify a reserved header length for refillsMichael Brown1-3/+8
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-12-07[usb] Allow USB device IDs to include arbitrary driver-specific dataMichael Brown1-0/+4
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-12-07[usb] Record USB device speed separately from current port speedMichael Brown1-0/+2
Record the speed of a USB device based on the port's speed at the time that the device was enabled. This allows us to remember the device's speed even after the device has been disconnected (and so the port's current speed has changed). In particular, this allows us to correctly identify the transaction translator for a low-speed or full-speed device after the device has been disconnected. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-14[usb] Allow for wildcard USB class IDsMichael Brown1-3/+42
Make the class ID a property of the USB driver (rather than a property of the USB device ID), and allow USB drivers to specify a wildcard ID for any of the three component IDs (class, subclass, or protocol). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-14[usb] Select preferred USB device configuration based on driver scoreMichael Brown1-9/+39
Generate a score for each possible USB device configuration based on the available driver support, and select the configuration with the highest score. This will allow us to prefer ECM over RNDIS (for devices which support both) and will allow us to meaningfully select a configuration even when we have drivers available for all functions (e.g. when exposing unused functions via EFI_USB_IO_PROTOCOL). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-13[usb] Generalise zero-length packet generation logicMichael Brown1-2/+2
The decision on whether or not a zero-length packet needs to be transmitted is independent of the host controller and belongs in the USB core. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-07[efi] Add a USB host controller driver based on EFI_USB_IO_PROTOCOLMichael Brown1-1/+4
Allow iPXE to coexist with other USB device drivers, by attaching to the EFI_USB_IO_PROTOCOL instances provided by the UEFI platform firmware. The EFI_USB_IO_PROTOCOL is an unsurprisingly badly designed abstraction of a USB device. The poor design choices intrinsic in the UEFI specification prevent efficient operation as a network device, with the result that devices operated using the EFI_USB_IO_PROTOCOL operate approximately two orders of magnitude slower than devices operated using our native EHCI or xHCI host controller drivers. Since the performance is so abysmally slow, and since the underlying problems are due to fundamental architectural mistakes in the UEFI specification, support for the EFI_USB_IO_PROTOCOL host controller driver is left as disabled by default. Users are advised to use the native iPXE host controller drivers instead. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-06[usb] Expose usb_find_driver()Michael Brown1-0/+5
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-11[usb] Add USB_INTERRUPT_OUT internal typeMichael Brown1-2/+5
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-09[usb] Provide usb_endpoint_name() for use by host controller driversMichael Brown1-0/+1
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-09[uhci] Add support for UHCI host controllersMichael Brown1-0/+10
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-09[usb] Add find_usb_bus_by_location() helper functionMichael Brown1-0/+2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-09[usb] Maintain single lists of halted endpoints and changed portsMichael Brown1-6/+0
When an EHCI hotplug action results in the controller disowning the port, it will result in a hotplug action on the corresponding UHCI or OHCI controller. Allow such hotplug actions to be carried out as part of the same call to usb_step() or usb_register_bus(), by maintaining a single central list of changed ports. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-09[usb] Maintain a list of all USB busesMichael Brown1-0/+8
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-08[usb] Detect missed disconnectionsMichael Brown1-0/+6
The USB core will currently fail to detect disconnections if a new device has attached by the time the port is examined in usb_hotplug(). Fix by recording the fact that a disconnection has taken place whenever the "connection status changed" (CSC) bit is observed to be set. (Whether the change represents a disconnection or a reconnection, it indicates that the port has experienced some time of being disconnected.) Note that the time at which a disconnection can be detected varies by hub type. In particular: root hubs can observe the CSC bit when polling, and so will record the disconnection before calling usb_port_changed(), but USB hubs read the port status (and hence the CSC bit) only during the call to hub_speed(), long after the call to usb_port_changed(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-05-01[usb] Include setup packet within I/O buffer for message transfersMichael Brown1-3/+1
The USB API currently assumes that host controllers will have immediate data buffer space available in which to store the setup packet. This is true for xHCI, partially true for EHCI (which happens to have 12 bytes of padding in each transfer descriptor due to alignment requirements), and not true at all for UHCI. Include the setup packet within the I/O buffer passed to the host controller's message() method, thereby eliminating the requirement for host controllers to provide immediate data buffers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23[xhci] Support USB1 devices attached via transaction translatorsMichael Brown1-2/+21
xHCI provides a somewhat convoluted mechanism for specifying details of a transaction translator. Hubs must be marked as such in the device slot context. The only opportunity to do so is as part of a Configure Endpoint command, which can be executed only when opening the hub's interrupt endpoint. We add a mechanism for host controllers to intercept the opening of hub devices, providing xHCI with an opportunity to update the internal device slot structure for the corresponding USB device to indicate that the device is a hub. We then include the hub-specific details in the input context whenever any Configure Endpoint command is issued. When a device is opened, we record the device slot and port for its transaction translator (if any), and supply these as part of the Address Device command. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23[usb] Clear transaction translator buffers when applicableMichael Brown1-0/+4
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23[usb] Add clear_tt() hub method to clear transaction translator bufferMichael Brown1-0/+9
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23[usb] Reset endpoints without waiting for a new transfer to be enqueuedMichael Brown1-3/+6
The current endpoint reset logic defers the reset until the caller attempts to enqueue a new transfer to that endpoint. This is insufficient when dealing with endpoints behind a transaction translator, since the transaction translator is a resource shared between multiple endpoints. We cannot reset the endpoint as part of the completion handling, since that would introduce recursive calls to usb_poll(). Instead, we add the endpoint to a list of halted endpoints, and perform the reset on the next call to usb_step(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-18[usb] Fix USB timeouts to match specificationMichael Brown1-5/+27
Several of the USB timeouts were chosen on the principle of "pick an arbitrary but ridiculously large value, just to be safe". It turns out that some of the timeouts permitted by the USB specification are even larger: for example, control transactions are allowed to take up to five seconds to complete. Fix up these USB timeout values to match those found in the USB2 specification. Debugged-by: Robin Smidsrød <robin@smidsrod.no> Tested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-18[ehci] Add support for EHCI host controllersMichael Brown1-0/+3
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-16[usb] Add functions for manual device address assignmentMichael Brown1-0/+26
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-16[usb] Add the concept of a USB bus maximum transfer sizeMichael Brown1-1/+5
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-09[dm96xx] Add driver for Davicom DM96xx USB Ethernet NICsMichael Brown1-0/+3
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02[legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown1-1/+1
Relicense files for which I am the sole author (as identified by util/relicense.pl). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-13[usb] Provide generic framework for refilling receive endpointsMichael Brown1-0/+40
Provide a generic framework for allocating, refilling, and optionally recycling I/O buffers used by bulk IN and interrupt endpoints. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-12[usb] Handle port status changes received after failing to find a driverMichael Brown1-1/+7
Commit a60f2dd ("[usb] Try multiple USB device configurations") changed the behaviour of register_usb() such that if no drivers are found then the device will be closed and the memory used will be freed. If a port status change subsequently occurs while the device is still physically attached, then usb_hotplug() will see this as a new device having been attached, since there is no device recorded as being currently attached to the port. This can lead to spurious hotplug events (or even endless loops of hotplug events, if the process of opening and closing the device happens to generate a port status change). Fix by using a separate flag to indicate that a device is physically attached (even if we have no corresponding struct usb_device). Reported-by: Dan Ellis <Dan.Ellis@displaylink.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-10[usb] Allow usb_stream() to enforce a terminating short packetMichael Brown1-3/+5
Some USB endpoints require that a short packet be used to terminate transfers, since they have no other way to determine message boundaries. If the message length happens to be an exact multiple of the USB packet size, then this requires the use of an additional zero-length packet. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-10[usb] Parse endpoint descriptor bInterval fieldMichael Brown1-1/+8
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-09[usb] Try multiple USB device configurationsMichael Brown1-3/+3
Iterate over a USB device's available configurations until we find one for which we have working drivers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-03[usb] Add basic support for USB devicesMichael Brown1-0/+1149
Signed-off-by: Michael Brown <mcb30@ipxe.org>