From owner-freebsd-virtualization@freebsd.org Tue Mar 17 15:34:18 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 6593626999E; Tue, 17 Mar 2020 15:34:18 +0000 (UTC) (envelope-from daniel.nicolescu10@gmail.com) Received: from mail-vs1-xe30.google.com (mail-vs1-xe30.google.com [IPv6:2607:f8b0:4864:20::e30]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48hcfJ4mmYz3LFg; Tue, 17 Mar 2020 15:34:16 +0000 (UTC) (envelope-from daniel.nicolescu10@gmail.com) Received: by mail-vs1-xe30.google.com with SMTP id a63so4182816vsa.8; Tue, 17 Mar 2020 08:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LDWk+3LJtnWLYySzyxUFjoOIs/+0ssowJSncWfOqnk4=; b=udHZAmCyS1+5ETFb2Xl6uu9gsx6VdPFZjMbj//7mWbjHFRwBDcPQWOOjdHDrjMmESx hH+JR3CLHKyFGx6Ldm1LomkGyOc6XnXxVpORDI633h7DfTsA6UToFf7ekmV5t1qFvcIu 3jE+jtJysxM1DBd8jtzmHUgqnJ6S2eP/thBGxXV8dCFgH/PD1sSxIlaNFBejTmPzIVAo xC9mDjpTgmIyjoGlkB4W0GrCaZ+UOYpZ6ziuSyO4wANCjTHYjWyz2Ux7Zhql+JD8k7J5 ALk+gy86Fe5r+e1Zcjn2HXO+FmyNPPNH7kKuiZ+k5lraeRjMwi28V5r5644nm2jfPRMF 5cBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LDWk+3LJtnWLYySzyxUFjoOIs/+0ssowJSncWfOqnk4=; b=DUxuSfSum3TLYl/VBcdxF1gS642+JrQX2/dPDU87EFkEhZkHzdmwK4I8V3SbQAHYSC jE+A5p2ggTnwgD+XFIMTrZ2uCfK9pzkEqPf8L50q2TzAwfaCh3UFBY+iRNQhRKHztfR3 reWHfrZGVFq2b/P1cXA5ltxIXGnO5e+Vps6bHlrF5xOOrp0sVfh8J7bqOXM2wMt3DDq8 TXFSEHoNDaF2KWFCLdEHIuEeHOqesNh6cAJQT/Hj1FmCpqy1xFpr9uTkYd+q1yBkMyao jM+9R5DJKeDvpXWKEav2shuUfbtghIlcm72UIrzyb9ATdAQNkYQqlXz+B1ujMKLFO7xg CBXg== X-Gm-Message-State: ANhLgQ3qN+LFKjUlmiMBH/cjjvzIOhxZRH2pO6xF1r09lusPLbY1pftR 1nJiQIWDNtrat4rWYRDKbw8NmPgM1zu5glRiZMI= X-Google-Smtp-Source: ADFU+vsMsbfxuQ4TaFM+PVbo2Z2X+65Cf34v6C9BzcAb1mgn9vShjX58YZ1PaqNyi685GMUXlMnDqlr+s1m5BRvXefo= X-Received: by 2002:a67:f6c9:: with SMTP id v9mr4123070vso.48.1584459254930; Tue, 17 Mar 2020 08:34:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Daniel Nicolescu Date: Tue, 17 Mar 2020 17:34:03 +0200 Message-ID: Subject: Re: USB device passthrough implementation To: Hans Petter Selasky Cc: freebsd-virtualization@freebsd.org, freebsd-hackers@freebsd.org, patrascu.naina14@gmail.com, Mihai Carabas X-Rspamd-Queue-Id: 48hcfJ4mmYz3LFg X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=udHZAmCy; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of danielnicolescu10@gmail.com designates 2607:f8b0:4864:20::e30 as permitted sender) smtp.mailfrom=danielnicolescu10@gmail.com X-Spamd-Result: default: False [-1.50 / 15.00]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; FROM_EQ_ENVFROM(0.00)[]; IP_SCORE(0.00)[ip: (-9.61), ipnet: 2607:f8b0::/32(-1.85), asn: 15169(-1.65), country: US(-0.05)]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; TAGGED_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; IP_SCORE_FREEMAIL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[0.3.e.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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 15:34:18 -0000 Hi, We would like to implement it in user-space. On Tue, Mar 17, 2020 at 3:13 PM Hans Petter Selasky wrote: > 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 >