Skip to content

jaguar2: 2.4G at 20/40/80 turns the CCK block back on after a 5G narrowband tune; RF18 comment credits the vendor - #615

Merged
josephnef merged 3 commits into
OpenIPC:masterfrom
snokvist:pr/band-change-followups
Dec 3, 2026
Merged

josephnef merged 3 commits into
OpenIPC:masterfrom
snokvist:pr/band-change-followups

Conversation

@snokvist

@snokvist snokvist commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

What this is

This PR addresses the two non-blocking comments from the review of #612.

  1. CCK after a 5G narrowband tune (the comment at HalJaguar2.cpp:979). On the 8822B, set_channel_bw writes the CCK trio (0x808[28], 0x454[7], 0xa80[18]) and the CCA mask (0x814[15:10]) in its 5/10 MHz branch only. A 5G 5/10 MHz tune turns CCK off, and a later 20 MHz change to 2.4G kept it off. CCK frames and CCK beacons were then lost. It reproduces as predicted.
  2. RF18 provenance (the comment at HalJaguar2.cpp:1155). The band-bit comment now cites config_phydm_switch_band_8822b in reference/rtl88x2bu/hal/phydm/rtl8822b/phydm_hal_api8822b.c, not rtw88. The paragraph on keeping the 5G bits from the read, which described the behaviour before jaguar2: a band change re-applies the coex antenna switch and RF18's 5G band bits #612, is gone.

What changed

  • set_channel_bw, 8822B, 2.4G at 20/40/80: writes 0x808[28] = 1, 0x454[7] = 0, 0x814[15:10] = 15. These are the values a 2.4G bring-up leaves (read back on this unit after 1 1), so outside this state the writes change nothing. 5G at 20/40/80 keeps the bring-up's CCK block, as before.
  • The 2.4G narrowband branch also resets 0x814 to 15, as the vendor routine does. After a 5G narrowband tune it had been left at 34.
  • tests/band_change_rxcheck.cpp:
    • accepts CH/5 and CH/10 channels, and stops between from and to (e.g. 36 36/5 1);
    • prints the CRC-good CCK frames (data_rate 0-3) and the CCK block registers after the switch.
    • The existing from to [fast] form is unchanged.
  • src/jaguar2/CLAUDE.md: the fact, with its counterparts.

Cost: three BB writes per 2.4G set_channel_bw at 20/40/80, and one more in the 2.4G narrowband branch.

Verification

One RTL8812BU (T4U), USB 3. On ch 1 there are two CCK-beaconing APs. band_change_rxcheck, 2 runs per cell. Base: master c7e96fe.

cell master this PR
1 1 (bring-up on ch 1) 127 / 133 CCK frames, both APs, RSSI 74.5-74.7 140 / 138, RSSI 74.5-74.6
36 1 172 / 199, RSSI 74.8-74.9 184 / 158, RSSI 74.8
36 36/5 1 (5 MHz tune on 36, then ch 1) 0 / 0 CCK frames, no beacons; 808[28]=0 454[7]=1 814=34 177 / 177, both APs, RSSI 74.7-74.8; 808[28]=1 454[7]=0 814=15
36/5 1 (bring-up at 5 MHz on 36) 0 / 0, no beacons 153 / 170, RSSI 74.8-74.9
36 36/10 1 not run 164 / 156, RSSI 74.9
1 36 not run ch-36 AP RSSI 60.9-61.0 / 64.6-64.8, cbc=1, RF18 0x10d24, as #612

2.4G narrowband, with a 5 MHz transmitter. An RTL8812CU ran txdemo with DEVOURER_NB_BW=5 on ch 1, at 100 frames/s:

cell master this PR
1/5 1/5 (bring-up) 88-96 frames/s, 814=15 91-97 frames/s, 814=15
36 36/5 1/5 90-97 frames/s, 814=34 88-98 frames/s, 814=15

The CCA mask change made no difference to reception here.

ctest: 99 of 99 pass (build, Linux, GCC 15).

Against it / not verified

  • 0xa80[18] (BB CCK check) is left alone. A 2.4G bring-up leaves it at 1, where config_phydm_switch_band_8822b writes 0, and CCK receives with it at 1 in every cell above. Writing 0 would change the normal 2.4G state, so this PR doesn't.
  • Not measured:
    • 40 MHz on 2.4G;
    • reaching this state through FastRetune or fast_bw;
    • TX after it;
    • more than one unit.
  • 8821C: not affected. set_channel_bw_8821c writes its CCK block at every width.

🤖 Generated with Claude Code

https://claude.ai/code/session_011dRefzq1jjxHVRwtAWjJqL

…owband tune; RF18 comment credits the vendor

The two non-blocking review comments on OpenIPC#612.

set_channel_bw (8822B) wrote the CCK trio (0x808[28], 0x454[7],
0xa80[18]) and the CCA mask (0x814[15:10]) in its 5/10 MHz branch only.
A 5G narrowband tune turned CCK off, and a later 20 MHz change to 2.4G
kept it off: one 8812BU, `band_change_rxcheck 36 36/5 1` and `36/5 1`,
0 CCK frames and no beacons on ch 1 (2 of 2 runs each), against 153-199
CCK frames with the fix. 2.4G at 20/40/80 now writes the values a 2.4G
bring-up leaves (0x808[28] 1, 0x454[7] 0, 0x814 15); the 2.4G
narrowband branch also resets 0x814 to 15, as the vendor routine does.

The RF18 band-bit comment now cites config_phydm_switch_band_8822b in
reference/rtl88x2bu, and the paragraph on keeping the 5G bits from the
read (the behaviour before OpenIPC#612) is gone.

band_change_rxcheck: CH/5 and CH/10 channels, stops between from and to,
CRC-good CCK frames and the CCK block registers after the switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011dRefzq1jjxHVRwtAWjJqL
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

8822B: restore 2.4G CCK block after 5G narrowband tune; fix RF18 comment

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• 2.4G at 20/40/80 now rewrites the CCK block, fixing lost CCK after a 5G narrowband tune.
• The 2.4G narrowband branch resets CCA mask 0x814 to 15, matching the vendor routine.
• RF18 band-bit comment now cites the vendor config_phydm_switch_band_8822b; rxcheck tool extended.
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 changed writes are in the single Jaguar2 channel/bandwidth tuning routine and govern the end-to-end receiver state for 2.4 GHz CCK frames after retunes; they are not independent storage or deployment behaviors.
Sources

src/jaguar2/HalJaguar2.cpp[1153-1156]

  if (g2 && bw != 5 && bw != 6) {
    _device.phy_set_bb_reg(0x0808, (1u << 28), 0x1); /* CCK block on */
    _device.phy_set_bb_reg(0x0454, (1u << 7), 0x0);  /* MAC CCK check off */
    _device.phy_set_bb_reg(0x0814, 0x0000FC00, 15);  /* CCA mask default */

src/jaguar2/HalJaguar2.cpp[1128-1131]

      _device.phy_set_bb_reg(0x0808, (1u << 28), 0x1); /* CCK block on */
      _device.phy_set_bb_reg(0x0454, (1u << 7), 0x0);  /* MAC CCK check off */
      _device.phy_set_bb_reg(0x0a80, (1u << 18), 0x0); /* BB CCK check off */
      _device.phy_set_bb_reg(0x0814, 0x0000FC00, 15);  /* CCA mask default (a 5G tune left 34) */
Behavioral complexity 🟡 Medium 🧩 Interacting branches

  • Before, full retunes did not consistently restore the CCK/CCA state after a prior narrowband or 5 GHz configuration.
  • After, the routine restores different register values based on band and width, including a separate narrowband branch.
  • The new correctness condition is that every relevant transition into 2.4 GHz must produce the compatible CCK and CCA state without disturbing 5 GHz or narrowband behavior.
  • This is a state-dependent branch interaction, not a new algorithm or concurrency protocol.
  • The fast bandwidth path was inspected and its existing register sequence is unchanged by the production additions.
Sources

src/jaguar2/HalJaguar2.cpp[1153-1156]

  if (g2 && bw != 5 && bw != 6) {
    _device.phy_set_bb_reg(0x0808, (1u << 28), 0x1); /* CCK block on */
    _device.phy_set_bb_reg(0x0454, (1u << 7), 0x0);  /* MAC CCK check off */
    _device.phy_set_bb_reg(0x0814, 0x0000FC00, 15);  /* CCA mask default */

src/jaguar2/HalJaguar2.cpp[1128-1131]

      _device.phy_set_bb_reg(0x0808, (1u << 28), 0x1); /* CCK block on */
      _device.phy_set_bb_reg(0x0454, (1u << 7), 0x0);  /* MAC CCK check off */
      _device.phy_set_bb_reg(0x0a80, (1u << 18), 0x0); /* BB CCK check off */
      _device.phy_set_bb_reg(0x0814, 0x0000FC00, 15);  /* CCA mask default (a 5G tune left 34) */
Potential damage 🟡 Medium 🩹 Recoverable

  • If the new state restoration regresses, 2.4 GHz CCK frames or beacons can be missed after an affected retune while other PHY modes may continue working.
  • A later correct full tune or device reinitialization can restore the register state; reverting the code prevents new occurrences but does not itself repair already-programmed hardware state.
  • The affected state is volatile hardware configuration.
  • Recovery requires another successful full tune, bandwidth transition, or device restart; no automatic repair worker is established by this change.
Sources

src/jaguar2/HalJaguar2.cpp[1153-1156]

  if (g2 && bw != 5 && bw != 6) {
    _device.phy_set_bb_reg(0x0808, (1u << 28), 0x1); /* CCK block on */
    _device.phy_set_bb_reg(0x0454, (1u << 7), 0x0);  /* MAC CCK check off */
    _device.phy_set_bb_reg(0x0814, 0x0000FC00, 15);  /* CCA mask default */

src/jaguar2/HalJaguar2.cpp[1128-1131]

      _device.phy_set_bb_reg(0x0808, (1u << 28), 0x1); /* CCK block on */
      _device.phy_set_bb_reg(0x0454, (1u << 7), 0x0);  /* MAC CCK check off */
      _device.phy_set_bb_reg(0x0a80, (1u << 18), 0x0); /* BB CCK check off */
      _device.phy_set_bb_reg(0x0814, 0x0000FC00, 15);  /* CCA mask default (a 5G tune left 34) */
Assessed commit 1751f90
Diagram

graph TD
  A["set_channel_bw 8822B"] --> B["5/10 MHz branch"] --> C[("CCK regs 0x808 0x454 0x814")]
  A --> D["2.4G 20/40/80 branch"] --> C
  A --> E["RF18 band bits"]
  G["band_change_rxcheck"] --> A
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Write the CCK block unconditionally at every width, as set_channel_bw_8821c does
  • ➕ Simpler: no band or width gate, and it mirrors the 8821C path
  • ➕ Restores CCK after any 5G narrowband tune, including future paths that skip this branch
  • ➖ Also rewrites the CCK block on 5G at 20/40/80, which the PR keeps as the bring-up left it and has not measured in that state
  • ➖ Adds BB writes to every channel change, not just the affected 2.4G case
2. Call the full vendor config_phydm_switch_band_8822b routine
  • ➕ Matches vendor register state, including 0xa80[18] and RF18 bits
  • ➕ Removes the need to track individual registers by hand
  • ➖ Larger behavioural change; the PR notes that writing 0xa80[18]=0 alters the normal 2.4G state
  • ➖ Harder to verify against the measured bring-up state on one unit

Recommendation: The PR's approach is the best fit for now. It gates the CCK writes to 2.4G at 20/40/80, the only state the measurements show is broken, and leaves 5G and 0xa80[18] unchanged. The unconditional 8821C-style write is simpler, but it changes 5G 20 MHz state that the PR has not measured. Porting the full vendor routine is a larger change to test on hardware, so it can follow later if more registers prove to differ.

Files changed (3) +84 / -25

Bug fix (1) +24 / -12
HalJaguar2.cppRestore 2.4G CCK block at 20/40/80 and reset CCA mask in narrowband branch +24/-12

Restore 2.4G CCK block at 20/40/80 and reset CCA mask in narrowband branch

• On 2.4G at 20/40/80, set_channel_bw now writes 0x808[28]=1, 0x454[7]=0 and 0x814[15:10]=15, the values a 2.4G bring-up leaves. The 2.4G narrowband branch also resets 0x814 to 15 (a 5G narrowband tune had left it at 34). The RF18 band-bit comment now cites config_phydm_switch_band_8822b, and the old paragraph on keeping 5G bits from the read is removed.

src/jaguar2/HalJaguar2.cpp

Tests (1) +44 / -13
band_change_rxcheck.cppAdd CH/5 and CH/10 hops and CCK frame and register output +44/-13

Add CH/5 and CH/10 hops and CCK frame and register output

• The tool now parses CH/5 and CH/10 channels and accepts intermediate stops between from and to, such as '36 36/5 1'. It counts CRC-good CCK frames (data_rate 0-3) and prints the 8822B CCK block registers after the switch. The existing 'from to [fast]' form is unchanged.

tests/band_change_rxcheck.cpp

Documentation (1) +16 / -0
CLAUDE.mdDocument the 8822B CCK block band-dependency fact and its measurements +16/-0

Document the 8822B CCK block band-dependency fact and its measurements

• Adds a note that the 8822B CCK block is written only in the 5/10 MHz branch, with the reproduction numbers and the fix. It also records what was left alone (0xa80[18]), what was not measured, and that the 8821C writes its CCK block at every width.

src/jaguar2/CLAUDE.md

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

qodo-free-for-open-source-projects Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Fast tests can measure the wrong bandwidth ✓ Resolved Bug Correctness
Description
band_change_rxcheck accepts a final channel width but calls FastRetune with only the channel
number when fast is selected. If the final width differs from the current width, the radio keeps
its current width—or does nothing when the channel number is unchanged—while the tool labels the
result with the requested width.

2. Target CCK counts can omit received frames ✓ Resolved Bug Correctness
Description
band_change_rxcheck enables target-frame collection before resetting g_cck. An RX callback
between those operations can count a valid target CCK frame whose increment is then erased, making
the reported count depend on thread scheduling.

Grey Divider

Tip of the day
💡 Did you know, you can move or hide resolved findings to focus on what still needs action

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

…the CCK count before counting starts

Both from the Qodo review on OpenIPC#615.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011dRefzq1jjxHVRwtAWjJqL
@snokvist

snokvist commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Both Qodo findings were valid; both are fixed in the test tool in a937f6b:

  1. Fast mode and width: fast with a last hop whose width differs from the hop before it is now refused (exit 2), instead of reporting a width FastRetune never set.
  2. CCK count race: the count is zeroed before g_after is set.

Re-run after the change: 36 36/5 1 gave 152 CCK frames, with the CCK block registers at the 2.4G bring-up values, as before.

josephnef
josephnef previously approved these changes Dec 2, 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.

Approving. The fix reproduces on a second 8812BU, and the three writes are the 2.4G values of the vendor's config_phydm_switch_band_8822b.

Checked on hardware (Archer T3U, 2357:012d, USB 2, head a937f6b against master c7e96fe, the PR's band_change_rxcheck built against both libraries; two CCK-beaconing APs on ch 1; CCK frames in the 8 s after the switch):

cell master this PR
1 1 256 / 235 240 / 175 / 270
36 1 234 / 260 224 / 244
36 36/5 1 0 / 0, no beacons; 808[28]=0 454[7]=1 814=34 262 / 247; 1 / 0 / 15
36/5 1 0 / 0, no beacons 233 / 287
36 36/10 1 0, no beacons 271

AP RSSI on ch 1 is the same in every cell that receives (52.3-54.3 for the stronger AP).

Cells the description lists as not measured (one run each):

  • Firmware cross-band hop (DEVOURER_FASTRETUNE_FW=2, 36 36/5 36 1 fast): 287 CCK frames on master, 261 here. The firmware writes the band block itself (808[28]=1, 454[7]=0, a80[18]=0, 814=15 after the hop, the same as its 36 1 fast control), so that path never had the fault.
  • a80[18] = 0 (1 1/5 1, the state a 2.4G narrowband tune leaves): 252 CCK frames on master, 302 here. CCK receives with the bit at either value, which supports leaving it alone.
  • 5G after 2.4G (1 36, 1 1/5 36): beacon RSSI 82-84 / 74-76 and SNR 55-59 / 52-55 on both builds, cbc=1, RF18 0x10d24. No change from master.

ctest on the head: 99 of 99, with the MediaTek generator checks skipped.

Non-blocking

  • fast_set_bandwidth's 2.4G narrowband branch says "exactly as the full narrowband branch" and now differs from it by the 0x814 write. It is harmless: the fast toggle needs a full set on the same channel first, and that set now leaves 15. The comment could say so.
  • CI: build (macos-latest, Release, gcc) was cancelled, not failed; the other 28 jobs are green.

Limits: one unit, one run per cell beyond the first four, RX only. I did not measure 40 MHz on 2.4G or TX after the switch either.

@josephnef
josephnef enabled auto-merge (squash) December 2, 2026 14:43
…write

From the review on OpenIPC#615.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011dRefzq1jjxHVRwtAWjJqL
@snokvist

snokvist commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the second unit and the extra cells. The fast_set_bandwidth comment now says why its 2.4G branch needs no 0x814 write (1751f90): it replays the last full set, a full 2.4G set now leaves 15 at every width, and the firmware hop writes 15 itself, as you read back. Comment only; the pushed commit also re-runs the cancelled macOS gcc job.

@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.

Approving again at 1751f90. The push dismissed the approval at a937f6b; the delta since then is the fast_set_bandwidth comment only, so the hardware results from that review still apply and I did not re-run them.

The comment is right: a fast toggle needs the cache a full set_channel_bw primes, and a full set on 2.4G now leaves 0x814[15:10] at 15 at every width.

Non-blocking

  • The comment ends with #615. Code comments here carry no PR or issue numbers; git has the provenance.
  • The clause on the firmware cross-band hop is true but does not bear on this branch: the firmware hop sets _fbw_cache_valid = false, so the fast toggle is declined until the next full set.

CI: 28 jobs green. build (macos-latest, Release, clang) was cancelled because no hosted runner picked it up; I have re-run it. It passed at a937f6b.

@josephnef
josephnef merged commit c281088 into OpenIPC:master Dec 3, 2026
59 of 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