Currently, bwn(4) relies on the siba_bwn(4) bus driver to provide support for the on-chip SSB interconnect found in Broadcom's older PCI(e) Wi-Fi adapters. Non-PCI Wi-Fi adapters, as well as the newer BCMA interconnect found in post-2009 Broadcom Wi-Fi hardware, are not supported by siba_bwn(4),
The bhnd(4) bus driver (also used by the FreeBSD/MIPS Broadcom port, and intended for use by a future FreeBSD/ARM Broadcom port) provides a unified kernel interface to a superset of the hardware supported by siba_bwn; by attaching bwn(4) via bhnd(4), we can support both modern PCI(e) Wi-Fi devices based on the BCMA backplane interconnect, as well as Broadcom MIPS WiSoCs that include a D11 MAC core directly attached to their SSB or BCMA backplane.
This diff introduces opt-in bwn(4) support for bhnd(4) by providing:
- A small bwn(4) driver subclass, `if_bwn_bhnd`, that attaches via bhnd(4) instead of siba_bwn(4).
- A bhndb(4)-based PCI host bridge driver, `if_bwn_pci`, that optionally probes at a higher priority than the siba_bwn(4) PCI driver.
- A set of compatibility shims that perform translation of bwn(4)'s siba_bwn function calls into their bhnd(9) API equivalents when bwn(4) is attached via a bhnd(4) bus parent.
- When bwn(4) is attached via siba_bwn(4), all siba_bwn function calls are simply passed through to their original implementations.
The compatibility shims allow us to test bwn(4) with bhnd(4) while requiring almost no changes to the bwn(4) driver, and use of bhnd(4) can be enabled at boot time by setting the `hw.bwn_pci.preferred` system tunable. Once we're comfortable with bhnd(4)-based bwn(4), we can replace the compatibility shims with direct calls into the native bhnd(9) driver programming interface, and drop the legacy siba_bwn driver.
To test bwn(4) with bhnd(4), place the following lines in loader.conf(5):
hw.bwn_pci.preferred="1"
if_bwn_pci_load="YES
bwn_v4_ucode_load="YES"
bwn_v4_lp_ucode_load="YES"
The range of D11 (Wi-Fi) core revisions that bwn(4) will successfully probe may be modified by adjusting the 'BHND_MATCH_CORE_REV' match requirement in the if_bwn_bhnd.c `bwn_devices` table. This will very likely be necessary if you're testing bwn(4) on previously unsupported hardware (e.g. a BCMA device).
To verify that bwn(4) is using bhnd(4), you can check dmesg:
bwn0: <Broadcom 802.11 MAC/PHY/Radio, rev 15> mem 0x18001000-0x18001dff,0x18001f00-0x18001fff,0x18001e00-0x18001eff irq 1 at core 1 on bhnd0
... or devinfo(8):
pcib2
pci2
bwn_pci0
bhndb0
bhnd0
bhnd_chipc0
bhnd_pmu0
gpio0
bwn0
bhnd_hostb0
bhnd_nvram0