2026-02-13 03:35:30 +01:00

Seekwave SV6160 / Rockchip RK915 — Linux WiFi Driver

Repository: codeberg.org/aenertia/sv6160-rk915 Target Platform: Rockchip RK3326 (PX30) / ROCKNIX Kernel: Linux 6.18+ (Mainline) Status: Usable. Associates with WPA2, gets a DHCP lease, roams between APs, survives suspend/resume, and sustains bidirectional traffic for hours — an 8-hour soak moved 2,149,692 TX descriptors with every one completed. The SDIO wedge that used to end a session now recovers automatically in about ten seconds.

Not yet prime-time: throughput is ~1.75-1.9 MB/s TX against a 2.5 MB/s vendor reference, and the wedge still happens (it is recovered from, not prevented). See KNOWN-ISSUES.md.

Overview

A mac80211-based WiFi driver for the Seekwave SV6160 (also branded as Rockchip RK915) SoftMAC 802.11b/g chip. Found in budget RK3326 handhelds (XiFan XF40H and similar).

The chip uses a RISC-V RV32IMC MCU running proprietary firmware, communicating with the host via SDIO using a mailbox/FIFO protocol. The driver uploads firmware, initializes the LMAC, and interfaces with Linux's mac80211 subsystem.

See firmware/README.md for complete firmware reverse engineering documentation and SDIO_ARCHITECTURE.md for the SDIO protocol specification.

Current State

Feature Status
SDIO enumeration Working
Firmware upload (48056 B) + patch (16716 B) Working
Firmware state machine (M0_READY) Working
mac80211 registration Working — note the interface index increments on every reload, so it is rarely wlan0
SDIO CMD53 bidirectional data path Working
RPU command/event protocol Working
RPU_CMD_RESET → RESET_COMPLETE Working
FW_PRIV_INIT (SET_CONFIG) Working
NOP ping (FW_PRIV_NOP) Implemented but unused — sv6160_rpu_fw_priv_nop() has no callers; the data path is verified by real traffic now
VIF add/remove Working
Channel programming Working
WiFi scanning (native RPU_CMD_SCAN) Working — finds all APs, beacons reach cfg80211
Frame TX Working — every frame completes (TX_DONE 1:1)
Frame RX (broadcast + unicast) Working
WiFi authentication Working — authenticated ~10ms after the auth frame
WiFi association Working — RX AssocResp status=0, associated
WPA2 key management Working — 4-way handshake, CCMP group + pairwise keys
DHCP / usable connection Working — carries ssh, the link this was developed over
Sustained link Working — measured: 8h soak, 2,149,692 TX descriptors, all completed 1:1
Suspend / resume Working — measured once: same BSS and IP across a real deep suspend. Measured before the 2026-09-18 change that dropped IRQF_NO_SUSPEND from the host-wake IRQ; re-verify (see KNOWN-ISSUES §5)
Roaming Working — measured on a real walk: 2 cross-channel roams, 40ms and 82ms handoffs, IP kept
CQM (RSSI thresholds) Working — raised from RX-frame RSSI; drives iwd's roam trigger
Wedge recovery Working — both failure modes self-recover unattended (see below)
Lifecycle under ifdown/ifup Soaked 2026-09-19: 472 cycles in one module lifetime, 1.09 M descriptors 1:1, zero credit leaks, zero wedges, recovery ladder never fired
Power save Measured and deliberately rejected — ~8mA of a ~365mA budget, PS measured worse
A-MSDU Not engaged — root-caused to a missing SUPPORT_FAST_XMIT; adding it does aggregate but the chip cannot carry the result. Dead end, see below
MAC address Stable and per-device — the factory MAC, via U-Boot into the DT; see below

A-MSDU: chased down, and it is a dead end

Root-caused rather than assumed, because the obvious explanations were all wrong.

Why it never engaged: we do not set IEEE80211_HW_SUPPORT_FAST_XMIT. ieee80211_amsdu_aggregate() has exactly one call site, inside ieee80211_xmit_fast(); mac80211 only builds sta->fast_tx when the driver advertises that flag, and ieee80211_check_fast_xmit() returns at its first line without it. So the aggregation code was structurally unreachable. We advertised TX_AMSDU -- "we can accept an A-MSDU" -- without the flag that makes mac80211 take the path that builds one.

Adding the flag does work: tx_max_frame went from 1542 to 3080, i.e. two MSDUs in one frame, the first A-MSDU this driver has ever sent.

And it is unusable. Throughput collapsed from 0.77 MB/s to 0.02-0.08 MB/s, with sdio_write_data(...) failed: -16 in the log and the host-rebind recovery firing. The chip cannot carry the larger frame bodies -- consistent with what is already known about this SDIO path, where padding a CMD53 to the block size kills the link and the vendor records that concatenating does too.

So A-MSDU is closed as a throughput lever, for a better reason than before.

Two earlier explanations, both refuted on hardware:

  • "the peer does not advertise a usable max_amsdu_len" -- it does: iw decodes the AP's HT capabilities as Max AMSDU length: 7935 bytes.
  • "the ADDBA Response clears the A-MSDU bit, so mac80211 latches IEEE80211_TXQ_NO_AMSDU on the TID" -- refusing TX BlockAck entirely left tx_max_frame at 1542 while collapsing throughput 5x.

And the pull-model rewrite (txq=1) was built to unblock A-MSDU on the theory that the push shim drains the txq before mac80211 can aggregate. That theory was untestable: with fast-xmit off, no TX model could have produced an A-MSDU. The rewrite costs throughput and is correctly left off, but it was never the blocker.

Testing note. SUPPORT_FAST_XMIT is latched at probe from the amsdu parameter, so it must be passed to insmod -- setting it by sysfs afterwards silently measures the unflagged driver. Three runs were invalidated that way before the probe build was made to log its own flag state and the harness to discard any arm that could not prove it.

Where the MAC comes from

It is the factory MAC and it is per device, despite the driver having a random fallback that never runs here.

The factory address lives in Rockchip vendor storage (tag 0x524B5644, sector 7296, item id 3) -- the same place the BSP read it from via rockchip_wifi_mac_addr(). Vendor U-Boot reads that, exports ethaddr, and fdt_fixup_ethernet() writes it into whatever /aliases/ethernet0 resolves to; ROCKNIX points that alias at the wifi node. So the node arrives carrying local-mac-address and of_get_mac_address() picks it up:

sv6160 mmc2:0001:1: MAC 1e:28:78:e8:94:15 from device tree

ethtool -P reports the same value, and it survives reloads and reboots. The 1e:28:78: prefix is common to the family; the low three bytes are per unit. Check it with:

od -tx1 /sys/firmware/devicetree/base/mmc@ff380000/wifi@1/local-mac-address

(/proc/device-tree is a symlink, so a plain find will not see that file.)

The driver's order is DT -> hash of the RK3326 OTP serial -> eth_random_addr(). Only the first step runs on this board.

Reading the SV6160's own eFuse is not implemented, and would gain nothing here. The registers are mapped (EFUSE_CTRL 0xC0000134, offset in bits 0-5, busy in bit 7; EFUSE_RDATA 0xC0000138; MAC at eFuse offset 0x10) and fw_peek's rw=0 is a plain load with no address validation in the firmware, so the MMIO is reachable -- our 0x10000000..0x1000BBB8 guard is self-imposed. It would need that guard widened, a write path for EFUSE_CTRL (only rw=0 has ever been exercised), and busy-polling. The reason not to bother: the factory put the MAC in vendor storage, not in the chip's eFuse, which is why the BSP reads vendor storage too -- so the likely result is a blank eFuse and a fallback to the address we already have. It would only matter on a board with neither a vendor-storage MAC nor a DT property.

Recovery ladder

The driver rescues itself from both wedge modes rather than needing a human:

condition action
3 fruitless TX resyncs restart the hw (tx_resync_giveup)
3 bus recoveries in 60s re-create the SDIO host (host_rebind)

In the 8-hour soak these fired 16 and 1 times respectively, and all 55 wedge events recovered without intervention — 50 of them within 10-11 seconds. Before it, each one needed an unbind/bind typed in over a serial console.

Two details fixed in the 2026-09-18 review, not yet re-soaked:

  • The second rung counts only -16/-110 bus faults. It used to count every recovery, so three TX-link deaths inside a minute (the wedge mode's median gap is 28 s) escalated to a host re-create instead of the restart_hw that was measured to fix that failure.
  • ieee80211_restart_hw() re-enters .start without calling .stop, so mac_start now quiesces the driver's own state first (TX worker, resync, command gate, descriptor pool). Before, the TX worker kept writing descriptors to SDIO address 0 while the firmware image was being uploaded to the same address, which is the likely reason restart_hw "made things worse" in KNOWN-ISSUES.

echo 1|2 > /sys/kernel/debug/ieee80211/phy*/sv6160/recover drives the two rungs by hand. It returns -EINVAL on any other input rather than silently running the shallow rung, -EBUSY when the host re-create one-shot is already spent or host_rebind=0, and -ENODEV for level 1 when the interface is down.

History: how the encrypted data path was unblocked

This section used to describe the then-current blocker — association and the WPA handshake completed, but DHCP never did and the supplicant gave up. That is fixed; the driver now carries the ssh session it is developed over. The bugs behind it are recorded below because the techniques that found them (byte-diffing our command stream against the vendor's, and dumping raw bytes instead of reasoning about them) keep paying off.

How association was unblocked

Four bugs. The first two were found by diffing our control-command stream against the vendor's byte for byte (tools/rk915-wiredump.patch); the last two by dumping raw bytes rather than reasoning about them:

  1. sv6160_rpu_vif_cfg() never populated vif_addr, so every VIF_CFG told the firmware our MAC was 00:00:00:00:00:00. FW_PRIV_INIT carries only the first octet of the MAC, so VIF_CFG/VIF_CTRL are the only way the firmware learns the whole address — and without it the LMAC cannot address-match a unicast frame. Broadcast beacons arrived; our auth response never did.
  2. sv6160_mac_tx() stashed the TX descriptor id at skb->cb, which is struct ieee80211_tx_info — overwriting mac80211's TX flags on every frame. Harmless-looking until the first data frame after association panicked the kernel in skb_complete_wifi_ack.
  3. The RX chain followed an RX_SERIAS batch header's next-length, which is really the length of the batch's own first sub-packet. That read a packet that never existed, and the CMD53 timeout wedged the DW MMC controller.
  4. TX descriptor ids came from a free-running counter. The firmware's table has 12 entries and it rejects anything beyond — saying so in an FW_ERROR event, "[3243 F] Invalid desc id" — then stops delivering every kind of event. The -16 bus wedge was eleven seconds downstream of that fault, which is why it looked like a bus problem. Ids are now pooled tokens, freed on TX_DONE, as in the vendor's get_token().

Superseded: the scan-gating theory

Measured from the firmware's own counters (fwpeek=1 sweep_base=0x1000BA98 sweep_len=32, which reads its TX/RX statistics block): reception starts when a scan starts and stops the instant SCAN_COMPLETE fires. RPU_CMD_CHANNEL tunes the radio but does not arm the receiver — in one capture the target AP's beacons arrived on channel 6 during a scan, CH_PROG_DONE(ch=6) completed 250ms later, and nothing was received again on that same channel.

So mac80211's authentication frame is transmitted into a window where nothing can be heard. The control path stays healthy throughout (cmd_send/event_recv keep climbing) and TX completes normally — only 802.11 reception is dead.

This is not a firmware limitation: the vendor driver's receiver is equally off when idle, yet it goes from idle to authenticated in 17ms with no scan anywhere in that window. firmware/README.md §12 has the captures.

Known instability

Both faults that used to live here are fixed: the stale-RECV_LEN -110 wedge (the guard that caused it now defaults off) and the per-beacon WARN in ieee80211_rx_list. What remains open — with the evidence and the ruled-out hypotheses — is in KNOWN-ISSUES.md, chiefly that the wedge arrives in bursts whose trigger is still unidentified.

Required Kernel Patch

The DW MMC host controller needs a patch to prevent CMD52/CMD53 bus collisions:

patches/010-dw-mmc-sv6160-sdio-compat.patch

This adds SDMMC_CMD_PRV_DAT_WAIT to all SD_IO_RW_DIRECT (CMD52) commands in dw_mci_prepare_command(). Without it, CMD52 register reads can collide with in-flight CMD53 data transfers, corrupting the DW MMC controller state.

For ROCKNIX, install to projects/ROCKNIX/devices/RK3326/patches/linux/.

This driver was developed in New Zealand under the New Zealand Copyright Act 1994 (Sections 80A-80D), which permits decompilation and analysis of computer programs for achieving interoperability with other software or hardware.

The firmware RE documentation in firmware/README.md describes the interface protocol for interoperability purposes. This is a transformative cleanroom work providing hardware support for devices abandoned by original vendors.

Supported Hardware

SDIO Vendor SDIO Device Variant
0x3030 0x3030 Standard SV6160/RK915
0x0296 0x5348 XF40H (Eagle BASEX)
0x0296 0x5347 Eagle BASE

Firmware

Place in /lib/firmware/ (or kernel-overlays firmware path):

  • ssv6160-fw.bin — Main firmware (48056 bytes, RISC-V RV32IMC MCU binary with 32-byte header)
  • ssv6160-patch.bin — Patch/calibration table (16716 bytes, 0xBADABAAB scatter-load header)

These are functionally identical to rk915_fw.bin / rk915_patch.bin from vendor BSPs.

Firmware Architecture

The SV6160 MCU is a RISC-V RV32IMC core (Little-Endian) running ~160 identified functions. The firmware handles:

  • WiFi PHY/MAC timing, ACK/CTS, retransmits
  • RF calibration and channel programming
  • Power management (LPW linear/PWM mode switching)
  • SDIO DMA for host data exchange

See firmware/README.md for the complete reverse engineering documentation including memory maps, register definitions, packet protocol, and decompiled function analysis.

Building

As ROCKNIX package

export PROJECT=ROCKNIX DEVICE=RK3326 ARCH=aarch64
./scripts/build sv6160

Standalone (against built kernel tree)

cd drivers/net/wireless/seekwave/sv6160
make -C /path/to/kernel M=$PWD CONFIG_SV6160=m modules

Module Parameters

31 in total; modinfo sv6160 lists them all with descriptions. The ones that change behaviour rather than instrument it:

Parameter Default Description
tx_stall_ms 3000 Declare a TX descriptor stalled after this long and resync the pool
tx_quarantine_ms 3000 Hold a resync-reclaimed descriptor id back this long before reuse
tx_resync_giveup 3 Restart the hw after N fruitless resyncs (0 = never)
host_rebind 3 Re-create the SDIO host after N bus recoveries in 60s (0 = off)
tx_batch 8 Max frames per TX descriptor — 9 is the firmware's real ceiling, see below
tx_dma 1 Bounce TX bodies through an aligned buffer so dw_mmc can DMA them
descs_per_ac 2 Descriptors in flight per AC
cqm 2 Declare BEACON_FILTER/SUPPORTS_CQM_RSSI so RSSI events drive roaming
ba_rx 1 Program RX BlockAck sessions to the firmware
coalescing true Enable RX IRQ coalescing
rx_bundle 16 Max RX packets processed per interrupt
patch ssv6160-patch.bin Firmware patch file name

The rest (fwpeek, fwinfo, sweep_base, sweep_len, fwpoke, wiredump, trace, wt_trace, scan_passive, scan_single_ch, fixed_mcs, cmd_gate, vendor_bringup, rf_arm, txq, amsdu, chan_settle, sdio_blksize, fwpoke_when) are diagnostics and experiments; several exist to keep a measured answer switchable rather than lost. fwpoke and fwpoke_when are insmod-only (mode 0400): they write firmware memory. wiredump and wt_trace>=2 never dump the SETKEY payload, so no dmesg carries session keys, and the WBODY/RXDATA frame dumps stop after the 802.11 header plus IV.

RXTAIL is the exception and is deliberate: it prints the last 8 bytes of a decrypted frame, which is the only way to tell whether the firmware left a CCMP MIC there or ate 8 bytes of real payload. When the MIC is absent those 8 bytes ARE payload. It needs wt_trace=1, so it is opt-in, but scrub a capture taken with it before sharing.

Older documents reference parameters that no longer exist. firmware/README.md and VENDOR-DRIVER-FINDINGS.md mention rx_chain, rf_keep, int_gen, system_rev, stale_guard, mac_program and others. Those are records of experiments, not current knobs — each one's answer is now a comment next to the code it settled, and the parameter was culled. modinfo is the source of truth for what exists today.

tx_batch warning. It is clamped by min3(mod_tx_batch, SV6160_TX_BATCH_MAX, …), so on a stock build it accepts 16, reads back 16, and runs at 8. Verify frames-per-descriptor in debugfs before trusting any tx_batch measurement — that trap invalidated ~1173 transfers of evidence once already.

Architecture

sv6160_sdio.c  — SDIO probe, device init, DW MMC register mapping, PM
sv6160_core.c  — SDIO I/O, firmware boot, RPU command protocol, mac80211 ops
sv6160.h       — SDIO register map, RPU command/event structs, driver state

SDIO Protocol

The chip uses a mailbox/FIFO protocol over SDIO:

  • Byte-wide control registers (0-64) via sdio_readb/sdio_writeb
  • Data FIFO at SDIO address 0 (firmware, patches, commands, packets)
  • Command port at SDIO address 0x10000 (firmware start command)
  • Only SDIO function 1 is used (function 2 is skipped)
  • Block size: 512 bytes (configurable)

Firmware Packet Types

Commands are sent as packed structs to SDIO address 0. The firmware routes packets by the type field at header offset 0x10:

Type Name Direction Description
0x00 INIT/CONFIG Host→FW Reset, channel config, BSSID setup
0x16 SCAN Host→FW Trigger WiFi scan
0x17 MGMT_FRAME Host→FW Management frame TX
0x1C RESPONSE FW→Host Command responses, events
0x2A HOST_CMD Host→FW Sub-commands (PHY, BSS, CONFIG, KEY)
0x2C HOST_DATA Host→FW Data frame TX

DW MMC Integration

The driver maps the DW MMC controller's MMIO registers to manage SDIO DMA readiness. The firmware writes RECV_LEN before configuring its DMA source address — a brief delay or RINTSTS check prevents premature CMD53 reads.

Reference Implementations

Known Issues

See KNOWN-ISSUES.md for the open bugs, the evidence behind them, and — most usefully — the hypotheses already ruled out with sample sizes, so none of them gets re-run by accident.

In short: the SDIO wedge still occurs in bursts whose trigger is unidentified (six hypotheses eliminated), it is recovered from automatically rather than prevented, and throughput sits below the vendor reference with the obvious levers exhausted.

The three issues that used to be listed here — no beacons/probe frames, SDIO in-band IRQ not firing, and -110 stale-RECV_LEN recovery — are all resolved. The first was uncalibrated rf_params; the last was the RX aggregate cap being 4096 where the vendor uses 33280.

See VENDOR-DRIVER-FINDINGS.md for measurements from the vendor-based driver on the same silicon.

License

GPLv2. Firmware blobs are proprietary and subject to their own license terms.

S
Description
Cloned from https://codeberg.org/aenertia/sv6160-rk915 - clean-room mainline mac80211 driver for the Seekwave SV6160 / Rockchip RK915 WiFi chip (GPL-2.0). Upstream source of truth lives on Codeberg; this is a mirror.
https://codeberg.org/aenertia/sv6160-rk915
Readme GPL-2.0
887 KiB
0 Stars 1 Watchers 0 Forks
Languages
C 94.6%
Python 3.4%
Shell 1.9%