Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Dec 2024 10:41:05 +0100
From:      Mario Marietto <marietto2008@gmail.com>
To:        Steven Friedrich <freebsdlouisville@gmail.com>
Cc:        freebsd-virtualization@freebsd.org
Subject:   Re: usb devices passthrough in bhyve
Message-ID:  <CA%2B1FSiipSxt-Og1t_cOvy%2BXMavECDb_byScoWU2C5tw8SPr=LQ@mail.gmail.com>
In-Reply-To: <5cd601ba-560d-4252-9f17-7c450cf5d66d@gmail.com>
References:  <7dabef84-a572-4ded-a676-c73011b37e3c@gmail.com> <5cd601ba-560d-4252-9f17-7c450cf5d66d@gmail.com>

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

[-- Attachment #1 --]
Hello.

I have a situation similar to yours. This is my USB controller integrated
with the motherboard (INTEL AORUS PRO) :

00:14.0 USB controller: Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host
Controller (rev 10)

I have attached a lot of USB disks to that USB controller,but I never
reserved it, placing it on the /boot/loader.

Let's take this disk for example,that's attached there :

=>        40  3907029095  da5  GPT  (1.8T)
          40      532480    1  efi  (260M)
      532520        1024    2  freebsd-boot  (512K)
      533544         984       - free -  (492K)
      534528     4194304    3  freebsd-swap  (2.0G)
     4728832  3902300160    4  freebsd-zfs  (1.8T)
  3907028992         143       - free -  (72K)

If I want to use it with bhyve,I do :

bhyve-lin -S -c sockets=2,cores=1,threads=1 -m 4G -w -H -A \
-s 0,hostbridge \
-s 1,ahci-hd,/dev/da5 \

Easy,isn't it ? But this technique works only with the disks. If you have a
different kind of device,you should use an additional USB to PCI
controller....

On Sat, Dec 28, 2024 at 3:13 AM Steven Friedrich <
freebsdlouisville@gmail.com> wrote:

> I have an HP Envy running FreeBSD 14.2.
>
> I am a bhyve noob, but I am able to create a bhyve guest, and installed
> freebsd 14.2 on it.
>
> Here's my host pci devices:
>
> xhci1@pci0:0:20:0:      class=0x0c0330 rev=0x00 hdr=0x00 vendor=0x8086
> device=0x06ed subvendor=0x103c subdevice=0x8767
>     vendor     = 'Intel Corporation'
>     device     = 'Comet Lake USB 3.1 xHCI Host Controller'
>     class      = serial bus
>     subclass   = USB
>
> xhci0@pci0:1:0:0:       class=0x0c0330 rev=0x00 hdr=0x00 vendor=0x1b21
> device=0x3242 subvendor=0x1b21 subdevice=0x3242
>     vendor     = 'ASMedia Technology Inc.'
>     device     = 'ASM3242 USB 3.2 Host Controller'
>     class      = serial bus
>     subclass   = USB
>
> Here's my usbconfig:
>
> usbconfig
> ugen1.1: <Intel XHCI root HUB> at usbus1, cfg=0 md=HOST spd=SUPER
> (5.0Gbps) pwr=SAVE (0mA)
> ugen0.1: <(0x1b21) XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER
> (5.0Gbps) pwr=SAVE (0mA)
> ugen0.2: <Hub Genesys Logic, Inc.> at usbus0, cfg=0 md=HOST spd=SUPER
> (5.0Gbps) pwr=SAVE (0mA)
> ugen1.2: <PixArt HP USB Optical Mouse> at usbus1, cfg=0 md=HOST spd=LOW
> (1.5Mbps) pwr=ON (100mA)
> ugen1.3: <Chicony HP USB Keyboard> at usbus1, cfg=0 md=HOST spd=LOW
> (1.5Mbps) pwr=ON (100mA)
> ugen1.4: <Realtek Bluetooth Radio> at usbus1, cfg=0 md=HOST spd=FULL
> (12Mbps) pwr=ON (500mA)
> ugen0.3: <PNY USB 3.2.1 FD> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps)
> pwr=ON (126mA)
> ugen0.4: <Hub Genesys Logic, Inc.> at usbus0, cfg=0 md=HOST spd=HIGH
> (480Mbps) pwr=SAVE (100mA)
>
> Originally, my PNY flash drive was on usbus1, but when I added pptdevs="0/20/0"
> to  /boot/loader.conf, I lost my mouse and keyboard.
>
> Fortunately, I recently added a pcie card supporting usb 20 gbps rates.
>
> So I changed /boot/loader.conf to  pptdevs="1/0/0"
>
> But I don't know how to see the PNY flash drive in the guest.  I was
> hoping I could use gpart show -l and see a /dev/da0 or /dev/da1 drive, but
> I don't.
>
> In the guest, usbconfig:
>
> usbconfig
> No device match or lack of permissions.
>
> and pciconf -v -l:
>
> pciconf -v -l
> hostb0@pci0:0:0:0:      class=0x060000 rev=0x00 hdr=0x00 vendor=0x1275
> device=0x1275 subvendor=0x0000 subdevice=0x0000
>     vendor     = 'Network Appliance Corporation'
>     class      = bridge
>     subclass   = HOST-PCI
> isab0@pci0:0:1:0:       class=0x060100 rev=0x00 hdr=0x00 vendor=0x8086
> device=0x7000 subvendor=0x0000 subdevice=0x0000
>     vendor     = 'Intel Corporation'
>     device     = '82371SB PIIX3 ISA [Natoma/Triton II]'
>     class      = bridge
>     subclass   = PCI-ISA
> virtio_pci0@pci0:0:2:0: class=0x020000 rev=0x00 hdr=0x00 vendor=0x1af4
> device=0x1000 subvendor=0x1af4 subdevice=0x0001
>     vendor     = 'Red Hat, Inc.'
>     device     = 'Virtio network device'
>     class      = network
>     subclass   = ethernet
> virtio_pci1@pci0:0:3:0: class=0x010000 rev=0x00 hdr=0x00 vendor=0x1af4
> device=0x1001 subvendor=0x1af4 subdevice=0x0002
>     vendor     = 'Red Hat, Inc.'
>     device     = 'Virtio block device'
>     class      = mass storage
>     subclass   = SCSI
>
> How do I fix this?
>


-- 
Mario.

[-- Attachment #2 --]
<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hello.</div><div><br></div><div>I have a situation similar to yours. This is my USB controller integrated with the motherboard (INTEL AORUS PRO) :<br></div><div><br></div><div>00:14.0 USB controller: Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host Controller (rev 10)</div></div><div><br></div><div>I have attached a lot of USB disks to that USB controller,but I never reserved it, placing it on the /boot/loader.</div><div><br></div><div>Let&#39;s take this disk for example,that&#39;s attached there :</div><div><br></div><div>=&gt;        40  3907029095  da5  GPT  (1.8T)<br>          40      532480    1  efi  (260M)<br>      532520        1024    2  freebsd-boot  (512K)<br>      533544         984       - free -  (492K)<br>      534528     4194304    3  freebsd-swap  (2.0G)<br>     4728832  3902300160    4  freebsd-zfs  (1.8T)<br>  3907028992         143       - free -  (72K) <br></div><div><br></div><div>If I want to use it with bhyve,I do :</div><div><br></div><div>bhyve-lin -S -c sockets=2,cores=1,threads=1 -m 4G -w -H -A \<br>-s 0,hostbridge \<br>-s 1,ahci-hd,/dev/da5 \<br></div><div><br></div><div>Easy,isn&#39;t it ? But this technique works only with the disks. If you have a different kind of device,you should use an additional USB to PCI controller....<br></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 28, 2024 at 3:13 AM Steven Friedrich &lt;<a href="mailto:freebsdlouisville@gmail.com" target="_blank">freebsdlouisville@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

  

    
  
  <div>
    <div>
      <p>I have an HP Envy running FreeBSD 14.2.</p>
      <p>I am a bhyve noob, but I am able to create a bhyve guest, and
        installed freebsd 14.2 on it.</p>
      <p>Here&#39;s my host pci devices:</p>
      <p>xhci1@<a>pci0:0:20:0</a>:      class=0x0c0330
        rev=0x00 hdr=0x00 vendor=0x8086 device=0x06ed subvendor=0x103c
        subdevice=0x8767<br>
            vendor     = &#39;Intel Corporation&#39;<br>
            device     = &#39;Comet Lake USB 3.1 xHCI Host Controller&#39;<br>
            class      = serial bus<br>
            subclass   = USB<br>
      </p>
      <p>xhci0@<a>pci0:1:0:0</a>:       class=0x0c0330
        rev=0x00 hdr=0x00 vendor=0x1b21 device=0x3242 subvendor=0x1b21
        subdevice=0x3242<br>
            vendor     = &#39;ASMedia Technology Inc.&#39;<br>
            device     = &#39;ASM3242 USB 3.2 Host Controller&#39;<br>
            class      = serial bus<br>
            subclass   = USB<br>
        <br>
      </p>
      <p>Here&#39;s my usbconfig:</p>
      <p>usbconfig <span style="font-family:monospace"><br>
          ugen1.1: &lt;Intel XHCI root HUB&gt; at usbus1, cfg=0 md=HOST
          spd=SUPER (5.0Gbps) pwr=SAVE (0mA) <br>
          ugen0.1: &lt;(0x1b21) XHCI root HUB&gt; at usbus0, cfg=0
          md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA) <br>
          ugen0.2: &lt;Hub Genesys Logic, Inc.&gt; at usbus0, cfg=0
          md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA) <br>
          ugen1.2: &lt;PixArt HP USB Optical Mouse&gt; at usbus1, cfg=0
          md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA) <br>
          ugen1.3: &lt;Chicony HP USB Keyboard&gt; at usbus1, cfg=0
          md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA) <br>
          ugen1.4: &lt;Realtek Bluetooth Radio&gt; at usbus1, cfg=0
          md=HOST spd=FULL (12Mbps) pwr=ON (500mA) <br>
          ugen0.3: &lt;PNY USB 3.2.1 FD&gt; at usbus0, cfg=0 md=HOST
          spd=SUPER (5.0Gbps) pwr=ON (126mA) <br>
          ugen0.4: &lt;Hub Genesys Logic, Inc.&gt; at usbus0, cfg=0
          md=HOST spd=HIGH (480Mbps) pwr=SAVE (100mA)<br>
          <br>
          Originally, my </span><span style="font-family:monospace">PNY
        </span><span style="font-family:monospace">flash drive was on
          usbus1, but when I added </span>pptdevs=&quot;0/20/0&quot; to 
        /boot/loader.conf, I lost my mouse and keyboard.</p>
      <p>Fortunately, I recently added a pcie card supporting usb 20
        gbps rates.</p>
      <p>So I changed /boot/loader.conf to  pptdevs=&quot;1/0/0&quot;<span style="font-family:monospace"><br>
        </span></p>
      <p><span style="font-family:monospace">But I don&#39;t know how to see
          the PNY flash drive in the guest.  I was hoping I could use
          gpart show -l and see a /dev/da0 or /dev/da1 drive, but I
          don&#39;t.</span></p>
      <p><span style="font-family:monospace">In the guest, usbconfig:</span></p>
      <p>usbconfig <br>
        No device match or lack of permissions.<br>
        <br>
        and pciconf -v -l:</p>
      <p>pciconf -v -l<br>
        hostb0@<a>pci0:0:0:0</a>:      class=0x060000
        rev=0x00 hdr=0x00 vendor=0x1275 device=0x1275 subvendor=0x0000
        subdevice=0x0000<br>
            vendor     = &#39;Network Appliance Corporation&#39;<br>
            class      = bridge<br>
            subclass   = HOST-PCI<br>
        isab0@<a>pci0:0:1:0</a>:       class=0x060100
        rev=0x00 hdr=0x00 vendor=0x8086 device=0x7000 subvendor=0x0000
        subdevice=0x0000<br>
            vendor     = &#39;Intel Corporation&#39;<br>
            device     = &#39;82371SB PIIX3 ISA [Natoma/Triton II]&#39;<br>
            class      = bridge<br>
            subclass   = PCI-ISA<br>
        virtio_pci0@<a>pci0:0:2:0</a>: class=0x020000 rev=0x00
        hdr=0x00 vendor=0x1af4 device=0x1000 subvendor=0x1af4
        subdevice=0x0001<br>
            vendor     = &#39;Red Hat, Inc.&#39;<br>
            device     = &#39;Virtio network device&#39;<br>
            class      = network<br>
            subclass   = ethernet<br>
        virtio_pci1@<a>pci0:0:3:0</a>: class=0x010000 rev=0x00
        hdr=0x00 vendor=0x1af4 device=0x1001 subvendor=0x1af4
        subdevice=0x0002<br>
            vendor     = &#39;Red Hat, Inc.&#39;<br>
            device     = &#39;Virtio block device&#39;<br>
            class      = mass storage<br>
            subclass   = SCSI<br>
      </p>
      <p>How do I fix this?<br>
      </p>
    </div>
  </div>

</blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Mario.<br></div></div>
</div>

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2B1FSiipSxt-Og1t_cOvy%2BXMavECDb_byScoWU2C5tw8SPr=LQ>