Skip to content

jaguar3: GetTxQueuePages, the PUB TX queue's free and configured pages - #610

Merged
josephnef merged 8 commits into
OpenIPC:masterfrom
gilankpam:pr/tx-queue-pages
Dec 5, 2026
Merged

josephnef merged 8 commits into
OpenIPC:masterfrom
gilankpam:pr/tx-queue-pages

Conversation

@gilankpam

@gilankpam gilankpam commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The gap

When a Jaguar3 transmitter holds 40 MHz frames (low IGI on a quiet channel, docs/experiments/8822c-ht40-tx-stall.md), the frames back up inside the chip. A bulk-OUT send blocks only once the chip's queue is full, so a caller that watches send timing sees the stall late or never. The PUB queue's free-page count does show it, but today only DumpChipState reads it, as a log line.

The change

IRtlRadio::GetTxQueuePages(uint16_t& free_pages, uint16_t& total_pages) (Jaguar3) reads REG_FIFOPAGE_INFO_5 (0x0240; free pages in bits 27:16, configured pages in 11:0), the same field DumpChipState prints.

  • One control read under _reg_mu. Callable from any thread at a supervisory cadence (never per frame), including while a sender is blocked in bulk-OUT, since EP0 is separate from the bulk pipe.
  • Throws on a failed USB transfer.
  • Other generations return false and leave the outputs untouched (default virtual).

Measured

One 8812EU, MCS2/40, 1400-byte frames at a fixed offered load, silent 144(-) with no other traffic, IGI pinned, 10 s per cell, sampled every 200 ms. "Empty" means free pages at the idle value 1745.

offered IGI sent queue empty in lowest free pages longest blocked send
790 frames/s (28 % air) 0x22, 0x20 100 % 100 % of samples 1745 0-9 ms
790 frames/s 0x1e 94-100 % 12-45 % 17-1197 0-124 ms
1980 frames/s (70 % air) 0x22 100 % 100 % 1713 0 ms
1980 frames/s 0x1e 60 % 0 % 17 154 ms

At 790 frames/s and 0x1e, one run had no blocked send at all, yet it sent 98 %, its worst 200 ms carried 68 % of the offered load, and the queue was empty in only 14 % of samples. The free count separates the stalled state where send timing does not.

The same reading drove a run-time floor controller (with SetWideTxIgiFloor, #609). Once per second it took the deepest backlog: healthy seconds reached 40 % backlog in 1 % of seconds, seconds at IGI 0x1e in 90 %.

Build: full, no-Jaguar3 and Jaguar3-only configure + build; ctest 91/91 (82/82 Jaguar3-only). No selftest: the method is one register read and a field split.

Not covered

  • One 8812EU; no 8812CU reading.
  • Only the PUB page pool (INFO_5); the per-queue reservations (INFO_1..4) are not read.
  • No caller in this tree.

🤖 Generated with Claude Code

gilankpam and others added 2 commits November 26, 2026 00:02
DeviceConfig::Tuning::wide_tx_igi_floor is fixed at construction. The edge
below which a Jaguar3 transmitter loses 40 MHz capacity differs per unit and
per channel, and the 0x35 default costs uplink sensitivity, so a caller that
wants the lowest safe floor has to move it while the radio runs.

IRtlRadio::SetWideTxIgiFloor(floor) records the new floor and re-applies it
under _reg_mu, under the same rule as the construction-time value (after the
session's first >= 40 MHz frame, while tuned that wide; every retune
re-applies it). It is callable while another thread is blocked in bulk-OUT,
and it can throw on a failed USB transfer; the floor is recorded first, so
the DIG tick enforces it either way. Default: false (unsupported).

PhydmRuntimeJaguar3::set_igi_floor now clamps IGI at once whenever the floor
is lowered, not only when it is dropped to 0: a lowered non-zero floor pulls
IGI down to max(floor, top of the channel's DIG window). The rule is a pure
function (jaguar3/IgiFloor.h) with an igi_floor selftest.

The TX arm in build_tx_block now runs on the first wide frame even when the
floor is 0, so a floor set later still applies; with a floor of 0 the apply
writes no register, and it takes _reg_mu once per session as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IRtlRadio::GetTxQueuePages(free, total) reads REG_FIFOPAGE_INFO_5 (PUB:
bits 27:16 free, 11:0 configured) in one control read under _reg_mu. Frames
the MAC holds back fill the PUB queue long before a bulk-OUT send blocks, so
the free count shows a TX stall that send timing alone misses. Callable from
any thread while a sender is blocked in bulk-OUT; throws on a failed USB
transfer. Default: false (unsupported, outputs untouched).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Expose Jaguar3 PUB TX queue page counts

✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Add a Jaguar3 API for polling PUB queue capacity and detecting TX backlog before sends block.
• Return unsupported without changing outputs on other generations; propagate failed USB reads to
 callers.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The API reads the Jaguar3 PUB queue state and the in-tree probe consumes that reading to diagnose the same TX-stall behavior.
  • They form one bounded diagnostic capability; no separate production transmission outcome is changed.
Behavioral complexity 🔴 High 🧩 Concurrent ordering

  • Before, no PUB queue observation or concurrent sampler existed.
  • After, Jaguar3 must refuse reads before bring-up, decode two fields from one register read, serialize access with _reg_mu, and support sampling while the sender uses bulk-OUT.
  • The new correctness condition is that sampler reads remain safe and diagnostic counters are consumed only after the sampler joins, including exception paths.
  • The probe uses an established mutex and thread join pattern; no new persistent protocol or transmit-state transition is introduced.
Potential damage 🟢 Low 🩹 Reversible

  • If activated and the reading regresses, the probe can misdiagnose or fail to reveal a TX stall.
  • The affected outcome is diagnostic information, not packet transmission or persistent state.
  • Reverting restores the previous diagnostic behavior; no stored state or external effect requires repair.
  • Code rollback restores the prior probe and API behavior.
  • A misleading report may require rerunning the hardware experiment, but no persistent data repair or compensation is required.
Assessed commit da49a30
Diagram

graph TD
  A["Supervisory caller"] --> B["IRtlRadio API"] --> C["Jaguar3 backend"] --> D["PUB page register"]
  B --> E["Unsupported default"]
Loading
High-Level Assessment

The existing radio interface is the appropriate place for a generation-specific supervisory query. Reusing DumpChipState would require consuming diagnostic logs, while polling on the send path would add a USB register read per frame.

Files changed (3) +24 / -0

Enhancement (3) +24 / -0
IRtlRadio.hDefine an optional PUB queue page query +12/-0

Define an optional PUB queue page query

• Adds GetTxQueuePages to the radio interface and documents its polling, failure, and unsupported-generation contracts. The default returns false without changing either output.

src/IRtlRadio.h

RtlJaguar3Device.cppRead and decode Jaguar3 PUB page counts +11/-0

Read and decode Jaguar3 PUB page counts

• Reads register 0x0240 once under the register mutex and extracts the configured and free 12-bit page counts. A failed register read propagates its exception.

src/jaguar3/RtlJaguar3Device.cpp

RtlJaguar3Device.hDeclare the Jaguar3 queue-page override +1/-0

Declare the Jaguar3 queue-page override

• Declares the Jaguar3 implementation of the new IRtlRadio query.

src/jaguar3/RtlJaguar3Device.h

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@josephnef josephnef left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reading does what the PR says. I reproduced it on a second 8812EU (bare BL-M8812EU2, 0bda:a81a), channel 157(+) at 40 MHz, MCS2/40/LDPC, 1400-byte frames, with this PR merged together with #609 (clean merge, full build, ctest 96/96 with the two MT7612U generator checks skipped).

Reproduced

  • Idle: 1745 / 1745.
  • Polling at 10 Hz from a second thread during a no-gap flood costs nothing: 2739–2788 frames/s with the poller, 2742–2783 without.
  • At ~795 frames/s offered and IGI 0x1e, every frame was sent and no send took over 2 ms, yet free pages dipped to 449–1305 and the queue was empty in only 16–25 of 40 samples. At IGI 0x20 and above it read 1745 in all 40. So the page count shows the stalled state where send timing does not.

Requested before merge

  1. Refuse before bring-up (inline).
  2. An in-tree caller. Nothing in the repo calls this, so the table above and the one in the description cannot be reproduced from the tree. tests/cca_gates_probe.cpp was added for the same reason for the gate split; one small probe could cover this and SetWideTxIgiFloor together.

Also

  • Fork CI has not run on this PR; it needs a green run.

Limits of my check: one unit, one channel, one run per arm, TX power at −20 dB (this module's bench supply sags at full power under a no-gap flood, on master too), and host-side submitted rates rather than frames counted by a witness receiver.

Comment thread src/jaguar3/RtlJaguar3Device.cpp Resolved
Comment thread src/IRtlRadio.h Resolved
gilankpam and others added 3 commits November 30, 2026 20:37
tests/igi_floor_probe.cpp (IgiFloorProbe) is the in-tree caller for
IRtlRadio::SetWideTxIgiFloor: it floods a 40 MHz tune, walks the floor
through a list and prints the rate, failed sends, longest send and IGI per
step; --rx-ta counts a second card's frames and their RSSI per step, for
the receiver-cost table.

The per-channel edge and the receiver cost measured on one 8812EU now live
in docs/experiments/8822c-ht40-tx-stall.md and the
DeviceConfig::Tuning::wide_tx_igi_floor comment, with their scope, in place
of the "per unit" / "estimated, not measured" text.

PhydmRuntimeJaguar3::set_igi_floor reads IGI before it records the new
floor: a throw on that read now changes nothing, so a retry of the same
lowered floor still clamps (before, it saw prev == floor and skipped the
clamp, which stuck under skip_dig).

The SetWideTxIgiFloor comment now says only the read throws (BB writes
drop their result), that a floor at or below the DIG window bottom acts
like no floor, and that the live value outlives Stop / Init / InitWrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ds it

Before bring-up the PUB page read is the unpowered chip's 0xeaeaeaea
pattern, which decodes as a full, all-free queue (2794 / 2794). It now
returns false with the outputs untouched, under _reg_mu, as GetCcaGates
does.

The header says the reading discriminates only below the TX ceiling: under
a no-gap flood the sender keeps the queue full on a healthy link.

tests/igi_floor_probe.cpp samples GetTxQueuePages at 10 Hz from a second
thread during each floor step (configured pages, fewest free, samples
empty), checks the pre-bring-up refusal, and takes --gap-us to hold the
offered load under the air's ceiling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gilankpam

Copy link
Copy Markdown
Contributor Author

Pushed 2d53500 + d198b51.

Stacked on #609. This branch now merges pr/igi-floor-setter, so until #609 lands the diff here includes it. After #609 squash-merges, this reduces to its own two commits.

  1. Refuse before bring-up: done (inline).

  2. In-tree caller: tests/igi_floor_probe.cpp from jaguar3: SetWideTxIgiFloor, the wide-TX IGI floor at run time #609 now covers both, as you suggested. On each floor step a second thread samples GetTxQueuePages at 10 Hz and the step line adds pub_total, pub_min (fewest free) and pub_empty (samples with free == total). --gap-us holds the offered load under the air's ceiling. It also checks the pre-bring-up refusal.

    Run on the original 8812EU, 157(+), MCS2/40, 1400 B, 8 s per step, 80 samples:

    offered floor (IGI) sent / failed empty in lowest free
    ~854 frames/s 0x22 all / 0 80/80 (x4) 1745
    ~854 frames/s 0x1e all / 0 78-79/80 (x3) 1653-1737
    ~2458 frames/s 0x22 all / 0 60, 68 /80 1689
    ~2458 frames/s 0x1e all / 0 45, 49 /80 1529-1577
    no gap, 2796 frames/s 0x22 all / 0 1/50 17

    157 is this unit's mild channel: it keeps ~95 % of the ceiling at 0x1e, so the separation here is small next to the description's 144(-) rows. Those need IGI pinned at 0x1e, below that DFS channel's DIG window, which the setter cannot reach. Single runs.

  3. CI: the runs for this branch are action_required too and need a maintainer to approve the workflows. Locally: full, no-Jaguar3 and Jaguar3-only configure + build; ctest 92/92, 92/92, 83/83.

@josephnef josephnef left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of 2d53500 + d198b51. Both first-round points are addressed; the one remaining blocker is inherited from #609.

Blocking

  • The MSVC job fails on tests/igi_floor_probe.cpp (std::max against the Windows max macro; details on #609). This branch adds two more affected lines, see the inline comment. Fixing it in #609 and merging forward covers both.

Resolved

  • GetTxQueuePages refuses before bring-up with the outputs untouched, under _reg_mu.
  • The header states the below-the-ceiling limit and the pre-bring-up refusal.
  • The probe is the in-tree caller.

Checked on hardware (BL-M8812EU2, ch 157(+), MCS2/40/LDPC, 1400 B, this head):

  • Before bring-up: refused, poisoned outputs left alone (probe exit 0, two runs).

  • Offered ~650 frames/s (--gap-us 1100), 8 s per step, 80 samples:

    floor (IGI) sent / failed empty in lowest free
    0x22 5238 / 0 80/80 1745
    0x1e 5241 / 0 78/80 1725
    0x22 5227 / 0 80/80 1745
    0x1e 4954 / 18 65/80 17
  • No gap, 2792-2813 frames/s, 0 failed: lowest free 17 at every floor, empty in 0-1 of 40 samples. That matches your control and the header's wording.

  • The two 0x1e steps differ a lot (78/80 against 65/80 with 18 failed sends), so on this unit the reading at 0x1e varies within one session.

Non-blocking

  • The probe needed a local -20 dB power offset to run on my bench (inline comment on #609).

Limits: one unit, one channel, one run, TX power at -20 dB through a local patch to the probe.

Comment thread tests/igi_floor_probe.cpp Resolved
gilankpam and others added 2 commits December 5, 2026 22:25
NOMINMAX before the libusb include, as the other libusb tools do, so
windows.h does not turn std::max into its macro (C2589).

--pwr-qdb N applies SetTxPowerOffsetQdb(N) after bring-up, so the probe
reproduces the doc's -20 dB run-time row and runs on a bench whose supply
sags under a full-power flood.

A step whose register access throws prints a FAIL line and the walk goes
on, as the setter's contract tells callers to catch, instead of an
uncaught terminate.

The doc's run-time paragraph adds the second session on the same unit,
which kept full rate at 0x1e.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… FAIL on a throw

The probe's step loop now catches a throwing step; the PUB sampler thread
is joined on that path too, so the throw cannot destroy a joinable thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
josephnef
josephnef previously approved these changes Dec 5, 2026

@josephnef josephnef left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of 8a89e68. The inherited MSVC blocker is fixed (build (windows-latest, Release, cl) passes, CI 30/30), and the sampler thread is now joined when a step throws.

Checked on hardware (BL-M8812EU2, ch 157(+), MCS2/40/LDPC, 1400 B, this head, the probe unpatched with --pwr-qdb -80, exit 0):

Offered ~750 frames/s (--gap-us 1100), 8 s per step, 80 samples:

floor (IGI) sent / failed empty in lowest free
0x22 5956 / 0 80/80 1745
0x1e 6126 / 0 51/80 765
0x22 6182 / 0 80/80 1745
0x1e 5464 / 44 29/80 17

No gap, 2221-2818 frames/s: lowest free 17 at every floor, empty in 0-1 of 40 samples.

The first 0x1e step shows the page count catching the stalled state with no failed send, which is the point of the reading.

Limits: one unit, one channel, one run per arm, host-side submitted rates only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@josephnef
josephnef merged commit fc8d828 into OpenIPC:master Dec 5, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants