linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] usb: gadget: User space URBs for FunctionFS
@ 2020-11-11 17:07 Ingo Rohloff
  2020-11-11 17:07 ` [PATCH 1/2] usb: gadget: ffs: Implement user URBs for USB bulk endpoints Ingo Rohloff
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ingo Rohloff @ 2020-11-11 17:07 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, Ingo Rohloff

I am working on a platform (Xilinx Zynq Ultrascale+), which
is supposed to work as a pure USB Device (not dual-role).

To get fast USB bulk transfers I wanted to have something similar
like USBDEVFS_SUBMITURB/USBDEVFS_REAPURB, but for an USB Device.

I now implement two new ioctls for FunctionFS:
  FUNCTIONFS_SUBMITBULKURB
  FUNCTIONFS_REAPBULKURB
which provide simliar functionality.

A similar functionality is already implemented via AIO. But: To use this
API, your user space environment needs to know how to use these system
calls.
Additionally the semantics of the ioctls is slightly different:
Usually you can only access a FunctionFS file if the FunctionFS is
already bound to an UDC (USB Device Controller) and the USB Device is
connected to a USB Host (which then enables the appropriate configuration
and USB endpoints).
These new ioctls behave different: You already can submit URBs before the
Function is bound to an UDC and before the USB Device is connected.
These "pending" URBs will be activated once the endpoints become active.

When the endpoints become deactivated (either by a disconnect from the
USB Host or by unbinding the UDC), active URBs are cancelled.

A user space program will then get a notification, that the URBs have
been cancelled and the status will indicate to the user space program,
that the connection was lost.
Via this mechanism a user space program can keep precise track, which
URBs succeeded and which URBs failed.

The final goal here is to be able to directly let user space provide data
buffers (via mmap I guess), which are then transferred via USB; but this
is the next step.

I implemented test code to demonstrate how to use these new ioctls.

Ingo Rohloff (2):
  usb: gadget: ffs: Implement user URBs for USB bulk endpoints
  usb: gadget: ffs: tools: test applications for user URBs.

 drivers/usb/gadget/function/f_fs.c            | 478 ++++++++++++++++++
 include/uapi/linux/usb/functionfs.h           |  14 +
 .../device_app/usb_func_echo.c                | 474 +++++++++++++++++
 .../ffs-urb-example/device_app/usb_gadget_mk  |  79 +++
 .../ffs-urb-example/host_app/usb_test_echo.c  | 370 ++++++++++++++
 5 files changed, 1415 insertions(+)
 create mode 100644 tools/usb/ffs-urb-example/device_app/usb_func_echo.c
 create mode 100644 tools/usb/ffs-urb-example/device_app/usb_gadget_mk
 create mode 100644 tools/usb/ffs-urb-example/host_app/usb_test_echo.c

-- 
2.17.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-11-15 11:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-11 17:07 [PATCH 0/2] usb: gadget: User space URBs for FunctionFS Ingo Rohloff
2020-11-11 17:07 ` [PATCH 1/2] usb: gadget: ffs: Implement user URBs for USB bulk endpoints Ingo Rohloff
2020-11-15 10:59   ` kernel test robot
2020-11-15 10:59   ` [RFC PATCH] usb: gadget: ffs: async_bulkurb_active_lock can be static kernel test robot
2020-11-11 17:07 ` [PATCH 2/2] usb: gadget: ffs: tools: test applications for user URBs Ingo Rohloff
2020-11-11 18:40 ` [PATCH 0/2] usb: gadget: User space URBs for FunctionFS Greg KH
2020-11-12 17:05   ` Ingo Rohloff
2020-11-13 14:20     ` Greg KH
2020-11-13 15:20       ` Ingo Rohloff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).