Deemwar Monads & Abstractions

Router SDR Pack

Source: W1700K SDR, by h0m3us3r

The w1700k-sdr project turns a Gemtek W1700K Wi-Fi 7 router into a 320 Msps radio receiver. At that rate the samples need about 3% more than its 10 GbE port carries. The radio’s own cores pack away bits no sample uses, and the stream fits.

320 Msps 14-bit I/Q
1.28 / 1.24 GB/s needed / link
8 → 7 KiB per packed chunk
~97% link load

The near miss

Each sample pair is an I value and a Q value, 16 bits each: 32 bits per pair. 320 million pairs a second × 32 bits is 1.28 GB/s from the radio. One 10 GbE link carries about 1.24 GB/s of payload.

Radio1.28 GB/s
Link~1.24 GB/s
Pack half8 → 7 KiB
Fits~97% load

The usual fixes cost data. A lower sample rate shows less of the band. Dropped packets leave gaps in the stream.

Count the bits

Bits used: 14Each I and each Q value is a 14-bit sample.
Bits stored: 16Each value travels in a 16-bit slot; 2 bits are empty.
Packed: 28 per pairDrop the 4 empty bits of a pair: 8 words become 7.

Packing every chunk is not needed. Packing half of them, 8 of every 16, brings the stream under the link.

The data path

  1. 1

    Capture

    MT7996 radio

    The capture engine writes 14-bit I/Q into a ring over 1 MiB of the radio’s on-chip memory.

  2. 2

    Publish chunks

    WM core, project firmware

    The producer follows the capture pointer and publishes 8 KiB chunks.

  3. 3

    Pack half

    WM and WA cores

    At 320 Msps the WM packs 4 and the WA packs 4 of every 16 chunks to 7 KiB each.

  4. 4

    Ring in DRAM

    AN7581 SoC

    DMA writes into one 1 GiB ring of 131,072 × 8 KiB slices. It absorbs short stalls, about 0.8 s at full rate.

  5. 5

    Send

    kernel module

    Every slice leaves as one UDP datagram, zero-copy, on the 10 GbE port.

  6. 6

    Unpack

    host, w1700k-stream

    The host unpacks, tags any gaps, and serves complex int16 samples to every consumer.

Samples flow down; the filled diamond is where half the chunks shrink.

What it teaches

SituationLessonRule now
1.28 GB/s into ~1.24 GB/sValues stored wider than their precision waste the pipe.Before paying for a bigger pipe, count the bits each value uses and the bits it is stored in.
Half the chunks packedPack only as much as the link needs.Measure the gap, then close it, not more.

Fences

Read more

The project: h0m3us3r/w1700k-sdr on GitHub, with its README, docs/architecture.md and firmware README.

Hacker News discussion.

Sources: every number is from the h0m3us3r/w1700k-sdr README, docs/architecture.md (“Throughput”) and firmware/README.md.