bhyve WLAN passthru

JohnnySorocil

Active Member

Reaction score: 27
Messages: 121

I want to pass my WLAN card to bhyve VM. Host is FreeBSD 13.0-RC5, tried on FreeBSD, OpenBSD and Linux guests.
WLAN card is M.2 device and works on host. Passing another PCIe card (PCIe x4 LAN) to guests works.

WLAN card on host:
Code:
Apr  7 12:11:55 zen-pobro kernel: ath0: <Atheros AR946x/AR948x> mem 0xfc500000-0xfc57ffff at device 0.0 on pci7
Apr  7 12:11:55 zen-pobro kernel: ath0: [HT] enabling HT modes
Apr  7 12:11:55 zen-pobro kernel: ath0: [HT] enabling short-GI in 20MHz mode
Apr  7 12:11:55 zen-pobro kernel: ath0: [HT] 1 stream STBC receive enabled
Apr  7 12:11:55 zen-pobro kernel: ath0: [HT] 1 stream STBC transmit enabled
Apr  7 12:11:55 zen-pobro kernel: ath0: [HT] LDPC transmit/receive enabled
Apr  7 12:11:55 zen-pobro kernel: ath0: [HT] 2 RX streams; 2 TX streams
Apr  7 12:11:55 zen-pobro kernel: ath0: AR9460 mac 640.3 RF5110 phy 73.0
Apr  7 12:11:55 zen-pobro kernel: ath0: 2GHz radio: 0x0000; 5GHz radio: 0x0000

WLAN card under FreeBSD guest:
Code:
# dmesg | grep -i ath
[ath_hal] loaded
ath0: <Atheros AR946x/AR948x> mem 0xc0080000-0xc00fffff at device 6.0 on pci0
ath0: could not map interrupt
device_attach: ath0 attach returned 6
ath0: <Atheros AR946x/AR948x> mem 0xc0080000-0xc00fffff at device 6.0 on pci0
ath0: could not map interrupt
device_attach: ath0 attach returned 6

Settings on host:
Code:
# vm passthru
DEVICE     BHYVE ID     READY        DESCRIPTION
...
ppt4       9/0/0        Yes          AR9462 Wireless Network Adapter
...

# pciconf -lv
...
ppt4@pci0:9:0:0:        class=0x028000 rev=0x01 hdr=0x00 vendor=0x168c device=0x0034 subvendor=0x11ad subdevice=0x0802
    vendor     = 'Qualcomm Atheros'
    device     = 'AR9462 Wireless Network Adapter'
    class      = network
...

# cat /mnt/vm/fbsd/fbsd.conf
...
passthru0="9/0/0"
...

Is is WLAN card problem? Motherboard BIOS problem (M.2 E-key slot vs normal PCIe)?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,255
Messages: 37,429

The device (and driver) has to support MSI/MSI-X interrupts. Not every PCI device does.


M.2 E-key slot vs normal PCIe
If I read things correctly M.2 E is technically 2 x PCIe x1, USB 2.0, I2C, SDIO and a UART on one single connector. Your WLAN card seems to be detected as a PCI device on the host, so I don't think the M.2 E slot is the issue here (it looks like it's connected to one of the PCIe x1 lanes).
 
OP
JohnnySorocil

JohnnySorocil

Active Member

Reaction score: 27
Messages: 121

Are both MSI and MSI-X requered?

WLAN cards which don't work:
Code:
# pciconf -lc ppt4 | grep MSI
    cap 05[50] = MSI supports 4 messages, 64 bit, vector masks
# pciconf -lc ppt6 | grep MSI
    cap 05[50] = MSI supports 8 messages, vector masks

LAN cards which do work:
Code:
 # pciconf -lc ppt0 | grep MSI
    cap 05[50] = MSI supports 1 message, 64 bit, vector masks
    cap 11[70] = MSI-X supports 10 messages
# pciconf -lc ppt1 | grep MSI
    cap 05[50] = MSI supports 1 message, 64 bit, vector masks
    cap 11[70] = MSI-X supports 10 messages
# pciconf -lc ppt2 | grep MSI
    cap 05[50] = MSI supports 1 message, 64 bit, vector masks
    cap 11[70] = MSI-X supports 10 messages
# pciconf -lc ppt3 | grep MSI
    cap 05[50] = MSI supports 1 message, 64 bit, vector masks
    cap 11[70] = MSI-X supports 10 messages
# pciconf -lc ppt5 | grep MSI
    cap 05[50] = MSI supports 1 message, 64 bit, vector masks enabled with 1 message
    cap 10[70] = PCI-Express 2 endpoint MSI 1 max data 128(256) RO
    cap 11[b0] = MSI-X supports 32 messages
 
OP
JohnnySorocil

JohnnySorocil

Active Member

Reaction score: 27
Messages: 121

Tried mentioned patches - still can't passthru WLAN card:
Code:
# uname -a
FreeBSD zen-pobro 13.0-RC5 FreeBSD 13.0-RC5 #16 my13.0-zen-n244731-6526f9af2e4: Wed Apr  7 20:35:08 CEST 2021     root@zen-pobro:/usr/obj/usr/src/amd64.amd64/sys/POBRO  amd64

# git -C /usr/src log -5 --format=format":%h %ad %s"
6526f9af2e4 Thu Apr 1 09:15:19 2021 +0800 AMD-vi: Mixed format IVHD block should replace fixed format IVHD block
2509bbf301f Thu Apr 1 03:30:21 2021 +0800 AMD-vi: Fix mismatched NULL checking in amdiommu teardown path
746fb28d061 Mon Mar 22 17:33:43 2021 +0800 AMD-vi: Fix IOMMU device interrupts being overridden
a4ecead0751 Mon Mar 22 17:33:43 2021 +0800 ivrs_drv: Fix IVHDs with duplicated BaseAddress
f8a134d0ef1 Thu Apr 1 20:26:03 2021 -0400 13.0: update to RC5

root@vm-fbsd:~ # dmesg | grep -i ath
[ath_hal] loaded
ath0: <Atheros AR946x/AR948x> mem 0xc0080000-0xc00fffff at device 6.0 on pci0
ath0: could not map interrupt
device_attach: ath0 attach returned 6
ath0: <Atheros AR946x/AR948x> mem 0xc0080000-0xc00fffff at device 6.0 on pci0
ath0: could not map interrupt
device_attach: ath0 attach returned 6
 
Top