It is a loopback, in the sense that data sent by the virtual host
controller is received by the virtual peripheral controller on the same
physical machine, and vice versa. It's a lot like having a USB
peripheral controller, such as a net2280 PCI card, in your computer and
connecting it with a normal USB cable to one of the computer's USB host
ports.
dummy-hcd was written as a development tool. It provides a way to test
gadget drivers without the need for setting up a separate computer to
be the gadget device and without the need for any special
USB-peripheral hardware.
On the other hand, dummy-hcd is not perfect. Its biggest weakness is
that it does not support isochronous transactions.
> > Right now whenever I mount gadgetfs I see a dummy_udc file. This
> > basically means that I have gadgetfs set up in a loopback mode (since
> > I have CONFIG_USB_DUMMY_HCD=y). Now I can write USB device description
> > to dummy_udc and the kernel will find an appropriate driver and
> > loopback the communication with this driver to the exposed epN files.
> > Is my understanding of this correct?
>
> kinda, yeah.
>
> >>> Is there some way to emulate USB devices from a userspace application
> >>> via some kernel interface?
> >>
> >> Yes, use functionfs.
> >
> > As I understand, the way to write gadget drivers with functionfs is to
> > describe something that's called a function by mounting functionfs and
> > writing to the files it provides. Then you need to use configfs to
> > actually compose these functions into a device.
> >
> > Is this correct?
>
> right
>
> > What does a function stands for in this context? A USB configuration?
>
> USB CDC ACM, USB Mass Storage, USB NCM, etc. A class.
>
> > How do I enable loopback with functionfs?
>
> you don't need functionfs for g_zero's loopback. just load g_zero
You may not be using the word "loopback" in the same way. g_zero (a
gadget driver) provides a loopback mode, in which any data sent by the
host to the gadget gets echoed back, over a different endpoint, from
the gadget to the host. Earlier, Andrey used described dummy-hcd as
providing a loopback connection, in which the USB gadget and the USB
host are the same physical computer.
functionfs can be used with dummy-hcd, just as gadgetfs can.
> > Are there any advantages of using functionfs over gadgetfs for fuzzing?
>
> nope, from your point of view, you can use either.
There may be one difference: gadgetfs only supports one configuration.
I haven't worked with functionfs, but doesn't it support multiple
configurations?
Alan Stern