-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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: usbip: add initial support for USBIP server #74141
base: main
Are you sure you want to change the base?
usb: usbip: add initial support for USBIP server #74141
Conversation
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is missing include guards.
d123ee7
to
01328a1
Compare
This allows us to use the testusb Linux kernel tool again. All tests involving control and bulk transfers should pass. Additionally, add a shell command that allows the user to manually enqueue bulk transfers. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Lock the scheduler until the device is fully enabled, similar to usbd_init(); Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Do not necessarily call k_timer_init() in the uhc_bus_resume() implementation. Restart SOF timer after bus reset and in uhc_sof_enable() implementation. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The parameter should not be a pointer to type usbh_udev_cb_t. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Implement the dequeue function and remove the timeout parameter as it is no longer necessary and can be handled in the upper layer. The dequeue function is required for the USBIP implementation. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
With the current implementation, NACK claims all resources and prevents scheduling multiple transfers within a frame. Place a number of available transfers in a list at the beginning of a frame, and process the transfers in a limited number of slots. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
01328a1
to
9ef6b2c
Compare
9ef6b2c
to
e0dac48
Compare
This will allow the controller driver to access information about the device in the future. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Address parameter/argument is no longer needed because we have a pointer to the USB device. The Attrib parameter has never been used and will be replaced by the interval and start-frame parameters in the future. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add interrupt and start frame parameters and schedule transaction at specific frame. Implement for virtual driver only. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add an opaque pointer to store upper layer private data and initialize it with the USB host context during controller initialization. Use the pointer in event processing to get the correct context. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The transfers require enpoint MPS for proper transaction handling, assign it in the common place during transfer allsocation so that it can be reused. Some users, such as USBIP, may need to keep a reference to private data, add a parameter for completion callback data. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Handle them in separate contexts so that the request completion callback cannot be blocked, such as when a device connection is detected and requires configuration. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Allow dynamic allocation of USB devices on connected event. Add very basic USB device validation and configuration. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The server uses host support to export a USB device to a remote USBIP client. It supports control and bulk transfers, interrupt transfers may also work, but this depends on the host controller used. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Snippet that helps to build USB device samples with virtual device and host controllers and USBIP support. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add initial USB/IP documentation for the new USB support. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
e0dac48
to
57a7aab
Compare
If you don't mind me asking, what environment(s) did you test this on? I'm very interested in this and would like to try and replicate the results. |
struct usb_device_descriptor *const desc) | ||
{ | ||
const uint8_t type = USB_DESC_DEVICE; | ||
const uint16_t wLength = sizeof(struct usb_device_descriptor); | ||
const uint16_t wLength = MIN(len, sizeof(struct usb_device_descriptor)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this commit at all. If the only place where usbh_req_desc_dev()
is called, calls this with sizeof(struct usb_device_descriptor)
then this does not change anything at all.
The whole thing with bMaxPacketSize0
can be solved by just explicitly reading 8 bytes first. This will always result in single data stage packet regardless of bMaxPacketSize0
. Then the stack can remember the bMaxPacketSize0
and handle futher communication without having to guess "was it a short packet, or is bMaxPacketSize0 8".
goto xfer_alloc_error; | ||
} | ||
|
||
mps = ep_desc->wMaxPacketSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is ep_desc
stored in memory? If it has bytes as-is in the descriptor, then this is missing endian conversion.
I just want to put forward a huge thank you to @jfischer-no for your work on this! I'm really excited and looking forward to this being merged |
The server uses minimal host support to export a USB device to a remote
USBIP client. It supports control and bulk transfers, interrupt
transfers may also work, but this depends on the host controller used.
Only a single USB device can be exported yet.