-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
usb session renewal: fully asynchronous & interface level access #5021
Comments
Commit 7b05ce4 shows the current state of the new USB session & client API. It moreover adapts the Genode C-API for USB server side, and the implementation of the DDE Linux USB host controller driver. |
Today I took the time to dive into 7b05ce4 and very much enjoyed the ride. I'm impressed by the clearness of the (hierarchical) session interfaces for USB bus, devices, and interfaces as well as the C API. It's has become quite tangible how the implementation will evolve and solves the issues stated above. Nevertheless, I have a small collection of questions and remarks. GENERAL Can usb_session/urb_handler.h be removed? The file does not contain any code. |
Thanks @chelmuth for your valueable review!
Sure, it is a development artefact.
Yes
Yes
I agree.
Thanks for the pointer, I'll have a look into this.
Okay.
Yes, this was probably too much influenced by the Block Job API.
I have to proof this.
Good point! Yet another artefact from the Job API. In the first place, I tried to keep it as similar as possible to potentially extract a common pattern. But during development it was no realistic option anymore.
There is no good rationale behind it. I was trying to simplify the callbacks, and during different iterations, I assume` it got removed without need. I can re-insert it.
Okay.
We had an offline discussion about this in preparation of this issue's re-design ambition, and my understanding of the outcome was that we only support per-device (named), and at maximum per-vendor-product (for development run-scripts) assigments, because the current approach is too inflexible. |
Don't get me wrong, I could remember our discussion but also that we had no concrete solution for Sculpt (or a USB HID test that supports not yet known mice). Thus, I added this open question to the list as we have to find a solution before a final merge. |
@chelmuth I've realized all your comments within two additional fixup commits, and rebased it to staging. It is still work-in-progress, but so you can have a separate look at the changes, if you like to. |
Newer Qemu variants quit with an error about already existing devices if the same device-id is add and removed in a loop fast. To circumvent this strange behaviour, simply use consecutive device id numbers. Ref genodelabs#5021
Replace the USB session API by one that provides a devices ROM only, which contains information about all USB devices available for this client, as well as methods to acquire and release a single device. The acquisition of an USB device returns the capability to a device session that includes a packet stream buffer to communicate control transfers in between the client and the USB host controller driver. Moreover, additional methods to acquire and release an USB interface can be used. The acquisition of an USB interface returns the capability to an interface session that includes a packet stream buffer to communicate either bulk, interrupt, or isochronous transfers in between the client and the USB host controller driver. This commit implements the API changes in behalf of the Genode C API's USB server and client side. Addtionally, it provides Usb::Device, Usb::Interface, and Usb::Endpoint utilities that can be used by native C++ clients to use the new API and hide the sophisticated packet stream API. The adaptations necessary target the following areas: * lx_emul layer for USB host and client side * Linux USB host controller driver port for PC * Linux USB client ports: usb_hid_drv and usb_net_drv, additionally reduce the Linux tasks used inside these drivers * Native usb_block_drv * black_hole component * Port of libusb, including smartcard and usb_webcam driver depending on it * Port of Qemu XHCI model library, including vbox5 & vbox6 depending on it * Adapt all run-scripts and drivers_interactive recipes to work with the new policy rules of the USB host controller driver Fix genodelabs#5021
Replace the USB session API by one that provides a devices ROM only, which contains information about all USB devices available for this client, as well as methods to acquire and release a single device. The acquisition of an USB device returns the capability to a device session that includes a packet stream buffer to communicate control transfers in between the client and the USB host controller driver. Moreover, additional methods to acquire and release an USB interface can be used. The acquisition of an USB interface returns the capability to an interface session that includes a packet stream buffer to communicate either bulk, interrupt, or isochronous transfers in between the client and the USB host controller driver. This commit implements the API changes in behalf of the Genode C API's USB server and client side. Addtionally, it provides Usb::Device, Usb::Interface, and Usb::Endpoint utilities that can be used by native C++ clients to use the new API and hide the sophisticated packet stream API. The adaptations necessary target the following areas: * lx_emul layer for USB host and client side * Linux USB host controller driver port for PC * Linux USB client ports: usb_hid_drv and usb_net_drv, additionally reduce the Linux tasks used inside these drivers * Native usb_block_drv * black_hole component * Port of libusb, including smartcard and usb_webcam driver depending on it * Port of Qemu XHCI model library, including vbox5 & vbox6 depending on it * Adapt all run-scripts and drivers_interactive recipes to work with the new policy rules of the USB host controller driver Fix genodelabs#5021
Replace the USB session API by one that provides a devices ROM only, which contains information about all USB devices available for this client, as well as methods to acquire and release a single device. The acquisition of an USB device returns the capability to a device session that includes a packet stream buffer to communicate control transfers in between the client and the USB host controller driver. Moreover, additional methods to acquire and release an USB interface can be used. The acquisition of an USB interface returns the capability to an interface session that includes a packet stream buffer to communicate either bulk, interrupt, or isochronous transfers in between the client and the USB host controller driver. This commit implements the API changes in behalf of the Genode C API's USB server and client side. Addtionally, it provides Usb::Device, Usb::Interface, and Usb::Endpoint utilities that can be used by native C++ clients to use the new API and hide the sophisticated packet stream API. The adaptations necessary target the following areas: * lx_emul layer for USB host and client side * Linux USB host controller driver port for PC * Linux USB client ports: usb_hid_drv and usb_net_drv, additionally reduce the Linux tasks used inside these drivers * Native usb_block_drv * black_hole component * Port of libusb, including smartcard and usb_webcam driver depending on it * Port of Qemu XHCI model library, including vbox5 & vbox6 depending on it * Adapt all run-scripts and drivers_interactive recipes to work with the new policy rules of the USB host controller driver Fix genodelabs#5021
Replace the USB session API by one that provides a devices ROM only, which contains information about all USB devices available for this client, as well as methods to acquire and release a single device. The acquisition of an USB device returns the capability to a device session that includes a packet stream buffer to communicate control transfers in between the client and the USB host controller driver. Moreover, additional methods to acquire and release an USB interface can be used. The acquisition of an USB interface returns the capability to an interface session that includes a packet stream buffer to communicate either bulk, interrupt, or isochronous transfers in between the client and the USB host controller driver. This commit implements the API changes in behalf of the Genode C API's USB server and client side. Addtionally, it provides Usb::Device, Usb::Interface, and Usb::Endpoint utilities that can be used by native C++ clients to use the new API and hide the sophisticated packet stream API. The adaptations necessary target the following areas: * lx_emul layer for USB host and client side * Linux USB host controller driver port for PC * Linux USB client ports: usb_hid_drv and usb_net_drv, additionally reduce the Linux tasks used inside these drivers * Native usb_block_drv * black_hole component * Port of libusb, including smartcard and usb_webcam driver depending on it * Port of Qemu XHCI model library, including vbox5 & vbox6 depending on it * Adapt all run-scripts and drivers_interactive recipes to work with the new policy rules of the USB host controller driver Fix genodelabs#5021
Replace the USB session API by one that provides a devices ROM only, which contains information about all USB devices available for this client, as well as methods to acquire and release a single device. The acquisition of an USB device returns the capability to a device session that includes a packet stream buffer to communicate control transfers in between the client and the USB host controller driver. Moreover, additional methods to acquire and release an USB interface can be used. The acquisition of an USB interface returns the capability to an interface session that includes a packet stream buffer to communicate either bulk, interrupt, or isochronous transfers in between the client and the USB host controller driver. This commit implements the API changes in behalf of the Genode C API's USB server and client side. Addtionally, it provides Usb::Device, Usb::Interface, and Usb::Endpoint utilities that can be used by native C++ clients to use the new API and hide the sophisticated packet stream API. The adaptations necessary target the following areas: * lx_emul layer for USB host and client side * Linux USB host controller driver port for PC * Linux USB client ports: usb_hid_drv and usb_net_drv, additionally reduce the Linux tasks used inside these drivers * Native usb_block_drv * black_hole component * Port of libusb, including smartcard and usb_webcam driver depending on it * Port of Qemu XHCI model library, including vbox5 & vbox6 depending on it * Adapt all run-scripts and drivers_interactive recipes to work with the new policy rules of the USB host controller driver Fix genodelabs#5021
Replace the USB session API by one that provides a devices ROM only, which contains information about all USB devices available for this client, as well as methods to acquire and release a single device. The acquisition of an USB device returns the capability to a device session that includes a packet stream buffer to communicate control transfers in between the client and the USB host controller driver. Moreover, additional methods to acquire and release an USB interface can be used. The acquisition of an USB interface returns the capability to an interface session that includes a packet stream buffer to communicate either bulk, interrupt, or isochronous transfers in between the client and the USB host controller driver. This commit implements the API changes in behalf of the Genode C API's USB server and client side. Addtionally, it provides Usb::Device, Usb::Interface, and Usb::Endpoint utilities that can be used by native C++ clients to use the new API and hide the sophisticated packet stream API. The adaptations necessary target the following areas: * lx_emul layer for USB host and client side * Linux USB host controller driver port for PC * Linux USB client ports: usb_hid_drv and usb_net_drv, additionally reduce the Linux tasks used inside these drivers * Native usb_block_drv * black_hole component * Port of libusb, including smartcard and usb_webcam driver depending on it * Port of Qemu XHCI model library, including vbox5 & vbox6 depending on it * Adapt all run-scripts and drivers_interactive recipes to work with the new policy rules of the USB host controller driver Fix genodelabs#5021
Commit 451a726 implements reporting of device manufacturer and product strings as well as interface description string. Output like follows. <device name="usb-1-2" class="0x0" manufacturer="Logitech" product="USB Laser Mouse" vendor_id="0x46d" product_id="0xc062" speed="low" acquired="true">
...
</device>
<device name="usb-1-7" class="0x0" manufacturer="Apple Inc." product="Magic Trackpad" vendor_id="0x5ac" product_id="0x265" speed="full">
<config active="true" value="0x1">
<interface active="true" number="0x0" info="Device Management" alt_setting="0x0" class="0x3" subclass="0x0" protocol="0x0">
<endpoint address="0x81" attributes="0x3" max_packet_size="0x10"/>
</interface>
<interface active="true" number="0x1" info="Trackpad / Boot" alt_setting="0x0" class="0x3" subclass="0x1" protocol="0x2">
<endpoint address="0x83" attributes="0x3" max_packet_size="0x40"/>
</interface>
<interface active="true" number="0x2" info="Actuator" alt_setting="0x0" class="0x3" subclass="0x0" protocol="0x0">
<endpoint address="0x84" attributes="0x3" max_packet_size="0x10"/>
<endpoint address="0x4" attributes="0x3" max_packet_size="0x40"/>
</interface>
<interface active="true" number="0x3" info="Accelerometer" alt_setting="0x0" class="0x3" subclass="0x0" protocol="0x0">
<endpoint address="0x85" attributes="0x3" max_packet_size="0x40"/>
</interface>
</config>
</device> |
@chelmuth a feature, which is very welcome! |
avoid page fault, iface may be 0 Issue genodelabs#5021
avoid page fault, iface may be 0 Issue #5021
Instead of returning an invalid capability whenever an interface is requested that does not exist, create a disconnected interface component. It is also possible that a client requests an interface that got removed at the same time. When an invalid capability gets returned, a client can stumble about invoking it. Moreover, this commit marks either invalid interface or device components as disconnected objects to optimize their handling. Ref genodelabs#5021
Instead of returning an invalid capability whenever an interface is requested that does not exist, create a disconnected interface component. It is also possible that a client requests an interface that got removed at the same time. When an invalid capability gets returned, a client can stumble about invoking it. Moreover, this commit marks either invalid interface or device components as disconnected objects to optimize their handling. Ref #5021
Instead of returning an invalid capability whenever an interface is requested that does not exist, create a disconnected interface component. It is also possible that a client requests an interface that got removed at the same time. When an invalid capability gets returned, a client can stumble about invoking it. Moreover, this commit marks either invalid interface or device components as disconnected objects to optimize their handling. Ref #5021
Within the past years we've observed certain limitations of the adhoc developed original USB session RPC API. First and foremost there were still several synchronous RPC calls in place to e.g. ask for USB descriptors. The problem here is the server side - an USB multiplexer, which interacts with multiple clients and serves different requests at once should not block during individual RPC calls. The other limitation regards USB devices with multiple interfaces of different classes, e.g. an USB headset with audio interfaces and HID interface to realize volume, play/stop buttons. Here, we would like to give access to the different interfaces to different USB clients resp. drivers.
The new design is inspired by the platform session API. An USB session now only provides a ROM dataspace, which reports all devices this USB session has access to. The USB device information includes its interfaces and endpoint descriptions. Therefore, an USB client does not necessarily need to access different USB descriptors during initialiyation, but can extract most information by the XML representation of its devices ROM. Morover, the USB session itself only provides two RPC calls to
acquire
andrelease
an USB device. Theacquire
call returns a capability to a new USB device session.The device session includes RPC calls to register a signal context and request a dataspace. Both together form a packet stream, wereby packets here are always interpreted as USB control transfers. If a client has full control over the device, it can send any form of control transfer here. If the client has only limited access to a certain interface, it can only send control transfers to get information over the device, and to set an alternate interface regarding the interface it has access to. Moreover, the device session includes two RPC call to
acquire
orrelease
an interface of the device. Theacquire
call returns a capability to a new USB interface session.The interface session again includes RPC calls to register signal context and retrieve a dataspace for its packet stream access. The packets of this stream represent either interrupt, bulk, or isochronous transfers to an endpoint of this interface, or a flush command to cancel all ongoing transfers regarding this interface.
Beside the pure USB session renewal, a client API for device and interface access is envisioned that loosely corresponds to the existent block job API. Thereby, we hide the ancient packet stream API from developers, and enforce that signaling is done on a less eagerly base to increase throughput.
The text was updated successfully, but these errors were encountered: