From owner-freebsd-virtualization@freebsd.org Tue Mar 17 12:58:21 2020 Return-Path: Delivered-To: freebsd-virtualization@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 44182265520 for ; Tue, 17 Mar 2020 12:58:21 +0000 (UTC) (envelope-from grehan@freebsd.org) Received: from vito.onthenet.com.au (vito.onthenet.com.au [203.22.124.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48hYBN5rKdz48Jp for ; Tue, 17 Mar 2020 12:58:20 +0000 (UTC) (envelope-from grehan@freebsd.org) Received: from alto.onthenet.com.au (alto2.onthenet.com.au [203.13.68.14]) by vito.onthenet.com.au (Postfix) with ESMTPS id 266D820B5B60 for ; Tue, 17 Mar 2020 22:58:16 +1000 (AEST) Received: from iredmail.onthenet.com.au (iredmail.onthenet.com.au [203.13.68.150]) by alto.onthenet.com.au (Postfix) with ESMTPS id 0AB6720B49B0 for ; Tue, 17 Mar 2020 22:58:16 +1000 (AEST) Received: from iredmail.onthenet.com.au (iredmail.onthenet.com.au [127.0.0.1]) by iredmail.onthenet.com.au (Postfix) with ESMTP id 00FC820E467C for ; Tue, 17 Mar 2020 22:58:16 +1000 (AEST) Received: from iredmail.onthenet.com.au ([127.0.0.1]) by iredmail.onthenet.com.au (iredmail.onthenet.com.au [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id vlDQu4SkvZQY for ; Tue, 17 Mar 2020 22:58:15 +1000 (AEST) Received: from MacBook-Air-4.local (otn-120-29-62-248.broadband.onthenet.net [120.29.62.248]) by iredmail.onthenet.com.au (Postfix) with ESMTPSA id 84B7220E467A; Tue, 17 Mar 2020 22:58:14 +1000 (AEST) Subject: Re: USB device passthrough implementation To: Daniel Nicolescu Cc: freebsd-virtualization@freebsd.org, patrascu.naina14@gmail.com, Mihai Carabas References: From: Peter Grehan Message-ID: <7043f9f6-448d-a76e-920d-9fa17cb0a2be@freebsd.org> Date: Tue, 17 Mar 2020 22:58:12 +1000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=UIBp4xXy c=1 sm=1 tr=0 a=A6CF0fG5TOl4vs6YHvqXgw==:117 a=DPSYfp6L38iglyTf480Cpw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=IkcTkHD0fZMA:10 a=SS2py6AdgQ4A:10 a=8pif782wAAAA:8 a=jivqAgzXTCdQkgaRuWEA:9 a=QEXdDO2ut3YA:10 a=nhrbFlTIud0A:10 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=d81BNirE c=1 sm=1 tr=0 a=eF5wA05EhuPcU0j7PNT2Vg==:117 a=DPSYfp6L38iglyTf480Cpw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=IkcTkHD0fZMA:10 a=SS2py6AdgQ4A:10 a=8pif782wAAAA:8 a=jivqAgzXTCdQkgaRuWEA:9 a=QEXdDO2ut3YA:10 a=nhrbFlTIud0A:10 X-Rspamd-Queue-Id: 48hYBN5rKdz48Jp X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-0.01 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_LONG(-0.97)[-0.965,0]; TAGGED_RCPT(0.00)[]; NEURAL_SPAM_MEDIUM(0.96)[0.958,0]; ASN(0.00)[asn:9313, ipnet:203.22.124.0/23, country:AU] X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Mar 2020 12:58:21 -0000 Hi Daniel, > * We need to disconnect the USB device from host: we are currently not very > familiar with the kernel API to perform this See usbconfig(8) and the detach_kernel_driver command. It's probably fine to request a user to issue that command, similar to how external commands are required to detach a PCI driver before using it for passthru in bhyve. > * 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. pci_xhci.c is an implementation of a USB XHCI host controller so should be the place to start: it either has the functionality that is needed, or requires slight modifications. (Lots of info and pointer to the spec at https://en.wikipedia.org/wiki/Extensible_Host_Controller_Interface) usb_mouse.c is just an example of a USB device interface, that in turn passes through VNC mouse-movement events to the guest o/s. > * 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. ACRN uses libusb as the interface to USB devices on the host (see devicemodel/hw/platform/usb_pmapper.c). later, Peter.