Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Mar 2020 14:12:19 +0100
From:      Hans Petter Selasky <hps@selasky.org>
To:        Daniel Nicolescu <daniel.nicolescu10@gmail.com>, freebsd-virtualization@freebsd.org, freebsd-hackers@freebsd.org
Cc:        patrascu.naina14@gmail.com, Mihai Carabas <mihai.carabas@cs.pub.ro>
Subject:   Re: USB device passthrough implementation
Message-ID:  <f26e42e0-4419-1c88-e8b0-e97dba412c37@selasky.org>
In-Reply-To: <CAG9wUUNFOX-nt6FP1K0hcXycE1AvfzXpa9UdD9%2BQvZeBfY5KJA@mail.gmail.com>
References:  <CAG9wUUNFOX-nt6FP1K0hcXycE1AvfzXpa9UdD9%2BQvZeBfY5KJA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

On 2020-03-17 13:41, Daniel Nicolescu wrote:
> Hi,
> 
> We want to implement the USB pass through feature for bhyve so that users
> will be able to pass through individual USB devices like in QEMU. We are
> trying to emulate the USB controller and pass to the virtual machine only
> one port.
> 
> * We need to disconnect the USB device from host: we are currently not very
> familiar with the kernel API to perform this

See:
libusb_detach_kernel_driver().

> * We need to emulate a USB device controller: we are currently looking into
> pci_xhci.c and usb_mouse.c to reuse some of the code from there and we
> would like to know if there is some sort of in depth documentation
> regarding these.
> * We need to pass the USB device to the guest through an emulated port of
> the device controller: we know that project ACRN implements USB device
> passthrough and we are trying to figure out how they do it.
> 
> Could you give us a few suggestions on how to tackle these?

USB has four transfer types:

1) Control transfers
2) Interrupt transfers
3) Bulk transfers
4) Isochronous transfers

If your implementation is supposed to be fully USB compliant you need to 
support and test all transfer types.

Please also pay attention to error conditions.

USB has different speeds, LOW, HIGH, FULL, SUPER, which impose different 
characteristics on the USB wMaxPacketSize for example.

You should know about the principle of short-terminated USB transfers.

Is the wrapper supposed to be implemented in the kernel or in user-space?

--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f26e42e0-4419-1c88-e8b0-e97dba412c37>