Page MenuHomeFreeBSD

Introduce bwn(4) support for the bhnd(4) bus.
ClosedPublic

Authored by landonf on Nov 11 2017, 1:32 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Feb 29, 3:04 AM
Unknown Object (File)
Feb 17 2024, 2:42 PM
Unknown Object (File)
Feb 8 2024, 10:20 PM
Unknown Object (File)
Feb 2 2024, 8:37 AM
Unknown Object (File)
Dec 28 2023, 6:29 PM
Unknown Object (File)
Dec 20 2023, 3:39 AM
Unknown Object (File)
Dec 20 2023, 2:38 AM
Unknown Object (File)
Dec 2 2023, 5:10 PM
Subscribers

Details

Summary

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

Depends on D13039

Test Plan

Tested against the following devices currently supported by bwn(4)/siba_bwn(4):

BCM4312
BCM4318
BCM4321

With minimal changes to the DMA code, was able to bring up working Wi-Fi on following BCMA-based devices:

BCM43224
BCM43225

Once committed to HEAD, request that existing bwn(4) users tracking HEAD switch to if_bwn_pci, enable hw.bwn_pci.preferred="1", and report any regressions they hit.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 13187
Build 13429: arc lint + arc unit

Event Timeline

  • Fix incorrect NVRAM variable type.
  • Handle typecasting of pa0b* NVRAM variables for compatibility with the existing bwn(4) APIs.
  • Fix 32-bit DMA mask assertion.
  • Add SPDX-License-Identifier, update copyright statements, normalize licenses on sources to which I hold copyright.
  • Add missing __FBSDID()
  • Fixed incorrect PCI ID in if_bwn_pci device table.
  • Removed PCI device ID's from bwn_pci(4)'s device table that are not actually supported by bwn(4).
  • Added PCI device ID for the BCM43224.
  • Delete bwn_pci(4)'s children on detach; otherwise, we're left with stale children on module unload.
  • Use DRIVER_MODULE_ORDERED() to ensure that the bwn_pci-specific bhndb driver is registered before the bwn_pci driver.
This revision is now accepted and ready to land.Dec 2 2017, 9:11 PM

This was closed by rS326454 (phabricator doesn't seem to want to import the commit).