Skip to content

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

Open
gilankpam wants to merge 1 commit into
OpenIPC:masterfrom
gilankpam:pr/tx-queue-pages
Open

gilankpam wants to merge 1 commit 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

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 🟢 Low

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The changed behavior is one bounded diagnostic operation: reading and decoding the Jaguar3 PUB TX queue page counters.
  • The interface declaration and Jaguar3 implementation are two hops of this same operation, not separate capabilities.
  • No repository consumer establishes another independent end-to-end behavior.
Behavioral complexity 🟢 Low 🧩 Straightforward

  • Before the change, IRtlRadio had no queue-page accessor.
  • After the change, Jaguar3 performs one already-established serialized register read and applies direct masks/shifts matching the existing DumpChipState decoding: low 12 bits for configured pages and bits 27:16 for available pages.
  • The new correctness condition is limited to selecting the correct PUB register and preserving those bit-field mappings; there are no new branches, state transitions, writes, retries, concurrency protocols, or coordinated invariants beyond routine reuse of the existing _reg_mu serialization.
Potential damage 🟡 Medium 🩹 Incorrect results

  • If the changed register address, bit extraction, or returned values regress, a caller can receive incorrect TX queue telemetry and misdiagnose a stalled transmitter.
  • The source also states that the TX path itself does not consult these counters, so no direct transmission behavior or persistent device state is affected by a bad diagnostic result.
  • This consequence is confined to the diagnostic capability; no downstream production consumer is present in the repository.
  • The method has no persistent side effects.
  • A transient USB read failure can be handled by the caller as specified by the API and a later read can obtain a fresh sample.
  • If the implementation returns systematically incorrect values, restoring the code is sufficient; no persistent state repair or external compensation is required.
Assessed commit a1f323a
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.

const uint32_t v = _device.rtw_read<uint32_t>(0x0240);
total_pages = v & 0x0fff;
free_pages = (v >> 16) & 0x0fff;
return true;

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.

Before bring-up this returns true with garbage. Called between CreateRadio and InitWrite on an 8812EU it reported free=2794 total=2794, which is 0xaea from the unpowered chip's 0xeaeaeaea read pattern. A caller computing backlog from that sees a plausible, fully-free queue.

SetCcaGates / GetCcaGates already refuse in this state with if (!_brought_up) return false; under _reg_mu. The same check here, leaving the outputs untouched, would match the "returns false … outputs are untouched" contract in the header.

Comment thread src/IRtlRadio.h
* (REG_FIFOPAGE_INFO_5: bits 27:16 free, 11:0 configured). One control
* read. A stalled TX path shows as free_pages stuck well below total_pages
* while bulk-OUT sends still return. Callable from any thread at the
* caller's own cadence (never per frame), including while a sender is

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.

Non-blocking: worth one sentence that the reading only discriminates below the TX ceiling. Under a no-gap flood on a healthy link (2745–2780 frames/s, no failed sends) it read ~17 free of 1745 for the whole run, because the sender is what keeps the queue full. "Stuck well below total_pages" is the stalled state only when the offered load is under what the air can carry.

Also non-blocking: once the pre-bring-up refusal is in, "returns false where unsupported" should mention it too.

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