summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_bwfm_pci.c
AgeCommit message (Collapse)Author
2022-01-01Use correct defines for random seed magic/length.Patrick Wildt
Spotted by Andreas Schnebinger
2021-12-31Newer Apple firmware on chipsets without a hardware RNG require the host toPatrick Wildt
provide a buffer of random bytes to the device on initialization.
2021-12-27Not only BCM4378, but all PCIe core revisions >= 64 need to be accessedPatrick Wildt
using the new sets of registers.
2021-12-27Map the chip ids used on Apple M1 Pro/Max and Apple T2 Macs to firmwarePatrick Wildt
names.
2021-12-27Support reading OTP information from a few more chips, necessary to learnPatrick Wildt
firmare names on Apple M1 Pro/Max and Apple T2 Macs.
2021-12-27Send TxCap and WiFi calibration blobs to the chip.Patrick Wildt
2021-12-27Switch module codename retrieval to use the newly proposed device treePatrick Wildt
bindings.
2021-12-27Bump rxpost and rxcomplete ring size to 1024 for newer chips.Patrick Wildt
2021-12-20bus_dmamem_unmap() should not be called from interrupt context, so freePatrick Wildt
and close flowrings using bwfm_do_async(). Reported by and ok kettenis@
2021-10-23Make sure we have enough space to add padding and final token to the nvramMark Kettenis
data. Also add the MAC address to the nvram data when there is a "local-mac-address" property in the device tree. This makes bwfm(4) work with the firmware/nvram/clm_blob files provided with MacOS on the Apple M1 Macs. ok patrick@
2021-08-31Implement suspend/resume for bwfm(4) with PCIe backend. We try to send thePatrick Wildt
device into D3 and do a hot-resume if possible. Otherwise we need to clean up the resources to allow complete HW re-initialization to take place.
2021-08-31Properly deallocate some more structures upon detach, and make sure we'rePatrick Wildt
not considered initialized anymore.
2021-08-31Initialize some struct variables to make sure that upon reinit, caused byPatrick Wildt
a suspend/resume cycle, the values are set to a sane default.
2021-08-31Initialize ring read/write pointers to make sure that upon reinit, causedPatrick Wildt
by a suspend/resume cycle, the pointers are set to a sane default.
2021-06-22bwfm(4) on PCI isn't really MPSAFE, and I'm not sure how this flagPatrick Wildt
even got there in the first place. I've been wondering why I have seen a bit of mbuf corruption here and there since I put the bwfm(4) M.2 PCIe card into my arm64 machine. Well, duh.
2021-02-26Read and parse OTP on the BCM4378. There are quite a few firmware andPatrick Wildt
nvram files used for the different Apple devices. The device tree and the OTP hold the information which of those we will have to use. For now this information will simply be printed, but depending on how we choose to do the firmare distribution we could use it for loadfirmware().
2021-02-26Attach to BCM4378.Patrick Wildt
2021-02-26Add support for BCM4378 as implemented on the Apple M1. This chip seemsPatrick Wildt
to use a different set of PCIE2REG registers. Accessing the "old" ones even leads to faults. There are two surprises though. One is that it seems that the interrupt status register always returns 0, and the other one is that we receive the interrupts way too early, but both can be worked around for now.
2021-02-26Increase the amount of RX buffers given to the bwfm(4) chip. We haave seenPatrick Wildt
this already on previous chips, which only started giving us packets when handing over at least 128 of them. Apparently some now require 256, which seems to get the Apple M1's WiFi going.
2021-02-26Increase the buffer size for the ioctl response buffers to the same asPatrick Wildt
used in the wifi firmware to ensure responses can be received.
2021-02-26Indicate hostready signal to inform the firmware that the rings have beenPatrick Wildt
initialized.
2021-02-26Refactor bwfm(4) firmware loading. The PCIe backend will need to be ablePatrick Wildt
to load the CLM blob like the SDIO backend already does. Additionally it is also helpful for the PCIe backend to try a file named after the device tree compatible. Thus refactor the SDIO code and make it available for both SDIO and PCIe.
2021-02-26Fix prio2fifo mapping table.Patrick Wildt
2021-02-25The firmware replaces the last 32-bit on RAM with a shared DRAM address.Patrick Wildt
While the for-loop checks that thie value has changed since we wrote to it, the timeout-condition checked for non-zero, which is wrong. This means that we didn't realize the firmware wasn't started. While there, make sure the shared DRAM address is inside the chip's address space.
2021-02-25Some newer chips have two D11/802.11 cores, and we need to reset both atPatrick Wildt
the same time.
2021-02-25Support for version 7 of the bwfm(4) PCIe interface. The size of the itemsPatrick Wildt
on the rx/tx complete rings has increased slightly to accomodate possible new features.
2021-02-25we don't have to cast to caddr_t when calling m_copydata anymore.David Gwynne
the first cut of this diff was made with coccinelle using this spatch: @rule@ type caddr_t; expression m, off, len, cp; @@ -m_copydata(m, off, len, (caddr_t)cp) +m_copydata(m, off, len, cp) i had fix it's opinionated idea of formatting by hand though, so i'm not sure it was worth it. ok deraadt@ bluhm@
2021-01-31Add basic support for BCM4378 as found on the Apple M1 SoCs. There's aPatrick Wildt
little bit more to do though before it can be enabled.
2020-12-12Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.jan
OK dlg@, bluhm@ No Opinion mpi@ Not against it claudio@
2020-06-22use ifiq_input and use it's return value to apply backpressure to rxrs.David Gwynne
this is a step toward deprecating softclock based livelock detection.
2020-03-07Use snprintf(9) to create the names for the firmware and NVRAM files. ThisPatrick Wildt
reduces the amount of duplicated lines per chip, and allows us to ship per- board files in the future. Based on a diff from jsg@ ok kurt@
2020-03-06Process the NVRAM in bwfm(4) itself. So far we have relied on somePatrick Wildt
external tool to pre-process the NVRAM, even though it's simple to do ourselves. This allows easier firmware distribution, especially since on some x86 machines the NVRAM is stored in an EFI variable.
2020-02-25Make bwfm(4) call if_input() only once per interrupt.Patrick Wildt
This reduces drops caused by the ifq pressure drop mechanism and hence increases throughput. ok tobhe@
2020-01-15Sprinkle splnet() around the ringbuffer accesses, otherwise thePatrick Wildt
task and interrupt try to concurrently submit messages on the control ring.
2020-01-15Some PCIe firmwares drop TX packets when the pktid is 0. AddPatrick Wildt
an offset to make sure they start from 1.
2020-01-15Fix off-by-one in ringbuffer code. When we insert items faster thanPatrick Wildt
the hardware is processing them, the write index can catch up to the read index. We must make sure that our write index stays smaller than the hardware's read index, thus the difference between both has to be bigger than 1. ok tobhe@
2020-01-09Convert sleeps of 1sec or more to tsleep_nsec(9).Martin Pieuchot
ok bluhm@
2019-02-07Consistently use m_freem(9). This fixes possible leaks in a fewPatrick Wildt
error cases.
2019-01-17Enable bwfm(4) in RAMDISK_CDMike Larkin
ok deraadt
2018-08-20Attach bwfm(4) to Broadcom BCM4371.Patrick Wildt
ok kettenis@
2018-07-25Implement a MSGBUF control packet mechanism based on the commandPatrick Wildt
request ids. So far we were only able to have one command in flight at a time and race conditions could easily lead to unexpected behaviour. With this rework we send and enqueue a control packet command and wait for replies to happen. Thus we can have multiple control packets in flight and a reply with the correct id will wake us up.
2018-07-06Add bus_dmamap_sync(9) calls to bwfm(4) so that we make sure the dataPatrick Wildt
is synced properly before the CPU or the WiFi chip access the supplied memory. Makes PCIe-connected bwfm(4) work on ARM-based machines.
2018-07-05Cast physical addresses to 64-bits so we can shift them by 32-bit onPatrick Wildt
32-bit platforms without the compiler complaining. In the end the value will turn out as 0 anyway. Allows enabling bwfm(4) on 32-bit platforms. ok stsp@
2018-06-07Attach bwfm(4) to the Broadcom 4356 found in the GPD Pocket.Patrick Wildt
Tested by mlarkin@
2018-06-07Some PCIe-based bwfm(4) chips also require that we supply an NVRAMPatrick Wildt
binary. In case we have an (optional) NVRAM binary, copy it to the end of the chip's memory. Tested by mlarkin@ on his GPD Pocket.
2018-05-23Implement a separate initialization stage so that we can still usePatrick Wildt
and initialize bwfm(4) later in the case that the firmware was not available on bootup and was only later installed. ok stsp@
2018-05-23Map the second bwfm(4) BAR first. The bwfm(4) PCIe devices have twoPatrick Wildt
BARs, where the second one is much larger than the first. Both need to be properly aligned in the given extent. Since the first one is smaller, it will "unalign" the next free space and thus create a gap so that the second BAR cannot be properly aligned in the given space. By mapping the second BAR first, it will automatically have proper alignment. The first BAR, which has fewer alignment requirements, fits well after the initial allocation. Fixes bwfm(4) on APU 1. Debugged and solved by kettenis@
2018-05-16Implement a BCDC control packet mechanism based on the command requestPatrick Wildt
ids. So far we were only able to have one command in flight at a time and race conditions could easily lead to unexpected behaviour, especia- lly combined with a slow bus and timeouts. With this rework we send or enqueue a control packet command and wait for replies to happen. Thus we can have multiple control packets in flight and a reply with the correct id will wake us up.
2018-02-08Move bwfm(4) from ifq begin/commit/rollback semantics to the newerPatrick Wildt
ifq dequeue semantics. This basically means we need to check for available space before dequeuing a packet. As soon as we dequeue a packet we commit to it. On the PCIe backend this check can not be done easily since the flowring depends on the packet contents and we cannot take a peek. When there is no flowring we cache the mbuf and send it out as soon as the flowring opened up. Then the ifq can be restarted and traffic can flow. Typically we usually run out of packet ids, which can be checked without consulting the packet. The flowring probably never becomes full as the bwfm(4) firmware takes the packets off the ring without actually sending them out. Discussed with dlg@
2018-02-07Move parsing the BCDC header on RX into a protocol specific RXPatrick Wildt
function so it can be shared with the SDIO attachment driver.