Skip to content

realtek-elnath: add Zyxel AOT-5221Zy (RTL9607F) support [RFC] - #1

Draft
AKoo7 wants to merge 128 commits into
alphaonex86:mainfrom
AKoo7:aot5221zy-rfc
Draft

AKoo7 wants to merge 128 commits into
alphaonex86:mainfrom
AKoo7:aot5221zy-rfc

Conversation

@AKoo7

@AKoo7 AKoo7 commented Aug 22, 2026

Copy link
Copy Markdown

DRAFT / RFC — not a merge request. Issues are disabled on this repo, so I'm
using a draft PR to reach you. The diff looks large because this branch derives
from an earlier snapshot of main and would revert some of your recent
datapath work — please read the notes below before judging the diff. I'm happy
to rebase/split it however you'd prefer, or keep it downstream.


Hi Herman,

First, thank you — I've been bringing up OpenWrt on the Zyxel AOT-5221Zy
(RTL9607F "Elnath" / Cortina CA8277C), and your realtek-elnath target was an
enormous head start. I've published my work-in-progress branch here:

It keeps your SPDX/copyright notices and credits you (and Cortina-Access) as the
base; it's all GPL-2.0.

On top of your driver it adds, for the AOT-5221Zy:

  • the board DTS + base-files;
  • 4x GbE LAN via DSA (cortina-ni-dsa + a tag_cortina tagger);
  • an in-kernel GPON OMCI/PLOAM/GEM stack (drivers/net/gpon);
  • a small kernel seam (cortina-omci-bridge) to optionally run the stock vendor
    OMCI daemon in a chroot;
  • a fair amount of datapath RE work in cortina-gpon.c / cortina-ni-rx.c /
    cortina-ni-tx.c.

Two honest caveats before you look:

  1. It derives from an earlier snapshot of your tree, so a straight diff
    against your current main would revert a lot of your newer datapath work —
    it is not a clean PR as-is.
  2. It takes a different OMCI approach (in-kernel) than your userspace
    gpon-provision / maple path, so some of it overlaps/competes with your
    design rather than extending it.

Would any of this be useful to you? If so, I'm happy to do the integration work
to match your current tree and architecture — e.g. rebase onto main, split out
the cleanly-additive parts (DSA, the board), and drop or adapt the rest. Or if
you'd prefer I keep it as a standalone downstream, that's completely fine too —
I just wanted to offer it back and make sure the attribution is right.

Thanks again for the groundwork.

— AK Sharma (@AKoo7)

alphaonex86 and others added 30 commits May 21, 2026 14:44
The RTL960xC/RTL8672 "Europa" GPON ONU SoCs use a Lexra-derived RLX
"Taroko" core (PRId 0x0000dc02). Its company field reads as LEGACY, so
cpu_probe_legacy() handles it, but mainline lacks a case for impl 0xdc
and would hit CPU_UNKNOWN -> BUG.

Add PRID_IMP_RLX_TAROKO (0xdc00), a CPU_RLX_TAROKO cpu type, and a
cpu_probe_legacy() case (R4K-style exceptions/caches, 64-entry TLB, no
FPU; CP0 Count left unset so the SoC timer drives the clockevent).

Clean-room from hardware facts (PRId, TLB/cache sizes from the running
vendor unit); no vendor source copied.
Clean-room device trees for the RTL9602C "Europa" SoC (rtl9602c.dtsi:
cpu/RLX-Taroko, cpu-intc, SoC interrupt controller, 16550 UART @
0x18002000, SoC timer, 16 MB physmap SPI-NOR) and the HSGQ X111W board
(rtl9602c_x111w.dts: 128 MB DDR2, dual-bank flash partition map, console).

Hardware description derived from observed register bases, IRQ numbers
and clocks read from a running unit; no vendor source used.
Add the first board image definition: the HSGQ X111W, referencing its
clean-room device tree (rtl9602c_x111w). Built run-from-RAM (initramfs
uImage) for bring-up. Original OpenWRT build glue; no vendor code.
Clean-room driver set and userspace for the RTL9602C GPON ONU (HSGQ X111W):

- gpon-rtl9602c: GPON MAC - GTC/PLOAM activation FSM, SerDes + external BOSA
  transceiver bring-up, OMCC datapath, /proc/gpon diagnostics
- rtl9602c_eth: GMAC/DMA NIC + on-chip switch core - LAN bridge, CPU-tag
  forwarding, VLAN, downstream OMCI RX trap
- pcie-rtl9602c: single-port PCIe host controller (on-board Wi-Fi endpoint)
- platform setup, SoC INTC irqchip, TC clocksource, early-console prom
- gpon-provision: procd service + factory-config reader that provisions the
  per-ONU MAC/SN/LOID/PLOAM from the board's calibration data
- luci-app-gpon: CBI view to read/edit the ONU identity
- base-files network topology, Kconfig/Makefile wiring

Independent implementations derived from the SoC register interface and the
ITU-T G.984/G.988 (GPON/OMCI) protocols.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…d at boot

onu_sn was parsed once at module init, so the per-ONU serial number had to be
the compiled-in default. Make onu_sn a writable module parameter that re-parses
on write, and have the provisioning service push the factory serial (read from
the board's calibration partition) into
/sys/module/gpon_rtl9602c/parameters/onu_sn early in boot. The activation FSM
re-reads the parsed serial on each upstream Serial_Number_ONU, so the factory
value takes effect on the next ranging cycle. One image now serves every ONU of
the model, with no serial number baked into the firmware.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The GMAC HW cpu-tag insertion does not fire on this 9602C (confirmed by
on-wire capture), so build the rtl8_4 0x8899 cpu-tag in software for US
OMCI, like the working LAN TX path: format-B layout, portmask -> PON
port 2 + stream-id 64 + keep, in rtl9602c_eth_omci_xmit(). US OMCI now
reaches the OMCC US-NIC (OMCI_TX_PKT_CNT 0 -> nonzero). Also adds the M2
G.988 OMCI responder (MIB-Reset/Upload/Get baseline), a content-based DS
OMCI RX classifier, and per-port + US-scheduling /proc diagnostics.

gpon-rtl9602c.c: OMCC GEM/SID install, T-CONT 16 / alloc US-scheduler
activation, US-NIC internal-MII force-link. Plus arch (irq/pcie/prom)
and Makefile/config updates.

Clean-room: facts only (register offsets/values/sequences from disasm and
live-board reads), re-expressed; no vendor code. onu_sn carries a
TEST-ONLY default SN, overridden by gpon_provision at OS startup.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… progress

LAN: reliable every boot (http/ssh/ping on 192.168.1.1).

WAN (gpon0 DHCP): datapath CORRECT — leases 192.168.158.x + pings 8.8.8.8 on good
boots (~50%). Confirmed end-to-end via the OLT CLI (root/admin): service-port UP,
WAN MAC 82:b1 learned on GEM 1, US burst clean (valid allocations, ~1e-8 BER).
Fixes (gpon-rtl9602c.c, A/B-revertible module params):
 - flow-1 US classify GMII-edge commit in gpon_install_data_gem (relatch_us)
 - corrected CDR reset addr 0x225a0 (was 0x22560/RX) + cdr_reseat_on_reactivate=1
 - US-PLOAM flush (PLM_FLUSH_BUF 0->1) at Ranging_Time->O5 (vendor step we omitted)
 - O5-entry burst-gate re-apply + No_message keepalive (o5_rearm_burst_gate)
 - DS data: DS_TRAFFIC_CFG=0x2 + rtl9602c_eth.c WAN demux + DHCP-DS diag log
 - full_serdes_reinit kept default OFF (re-running full serdes_init on re-range
   breaks the GPON — races FSM re-acquisition; do NOT enable)
OPEN: remaining ~50% is a DUT cold-start marginality in the DS NIC-drain->GMAC-RX
handoff (D_rxok climbs to match the OLT's DS, but gpon0 RX=0 / no OFFER reaches the
eth driver). The OLT side + US burst are perfect. See WAN-WIFI-STATUS.md.

WiFi (rtl8192fe, ONU-3282AE): factory-cal injection (MAC/power/xtal/thermal,
rfe_type=3), RF radio table corrected to the rfe==3 vendor branch, path-B RF 0x18
full-word re-key (was leaving RF_B[0x18]=0), TRX-mode init. AP enables on ch7 with
calibrated MAC/power but the beacon does not radiate yet (0/scan; stock twin
HS-3282A2 always visible = scanner OK). OPEN: needs an RF-register diff of path-A
vs the working stock chip. See WAN-WIFI-STATUS.md.

Also: GPON log-spam gated behind `trace`; regdb signed-db handling; WiFi defaults
(country BO, default key, per-board SSID from MAC); WAN MAC = base+3; luci-app-gpon
identity/status views + onu-diag package.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…r-on

The clean-room RTL8192F_TRANS_CARDEMU_TO_ACT power-on sequence
(rtl8192fe/pwrseq.h) was truncated to 18 of the vendor's 30 steps: it
enabled RF path S1 (MAC 0x1F=0x07) but never released RF path S0
(MAC 0x7B) and never powered the analog TX front-end (AFE 0x97[5],
0xDC). Path S0 + the analog block stayed in reset, so the radio was
digitally configured but on-air dark (RF_B[0x18]=0 in all prior RE) and
the beacon never radiated.

Add the 4 missing pwrseq entries (reset+enable S0, AFE power-on x2),
bump the sequence array size, and mirror the path-B 0x7B re-key in
phy.c. Add a `dump_rf` module param to dm.c that dumps RF/BB/MAC
registers on demand for verification.

Result: SSID ONU-3282AE now visible on 7/7 scans across 4 boots;
dump_rf confirms MAC 7b=07 (path S0 released) and RF_B alive.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Add the missing DS-NIC<->GMAC0 internal-MII FORCELINK write:
PI_MEDIA_STS_DS (0xc058) = 0x106e8400 (bit18=FORCELINK), mirroring the
US twin PI_MEDIA_STS_US that was already force-written every pbo_init.
Forced in gpon_pbo_init (before the DS GMII edge) and re-forced in
gpon_install_data_gem after the ifup GMAC0 power-cycle.

This makes /proc/gpon ds_fwd report bit18 link=1 reliably, but does not
by itself close the ~50% cold-start lease gap — the DS NIC-drain ->
GMAC-RX handoff stays intermittent on bad boots (gpon0 RX=0 with the
PON-IP link up). Add a ds_fwd /proc diag (DS link bit18, gmii_en,
rxfdp_ds) to localize the remaining gate. Status doc updated.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
6-boot good/bad diff + an MSR bisection prove the DS-NIC/GMAC handoff is
NOT the WAN reliability gate: handoff registers are byte-identical on
leasing and non-leasing boots, and a good-lock boot leases fully at the
current MSR=0x10. The real differentiator is cold-start GPON lock
quality (good: sn_tx=1/sds_sync=0; bad: sn_tx=23/sds_sync=6 + OLT
deact/re-range loop). MSR/FORCELINK/laser-mod are red herrings; APC and
full_serdes_reinit are proven harmful. Remaining avenue: the US-TX
serializer-lock init steps stock does and we omit (stock=100% vs
mine=50% on identical HW).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Add sds_run/sds_ext lines to /proc/gpon dumping the live US-TX
serializer/SerDes registers (0x2280c/0x281c/0x225a0/0x220a8/0x225d8 and
0x22a2c/0x22a30/0x22a34) with the live-working-stock O5 values inline in
[..] brackets. Read over the serial console (no WAN needed), this gives
a per-boot good-vs-bad diff of the SerDes against the working stock
without the nc-mmiord path that requires the WAN to be up.

Result: every boot (leasing and non-leasing) matches stock byte-for-byte
— proving the ~50% WAN gap is NOT a SerDes configuration difference.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…runtime

Add an O5 provisioning watchdog (o5_provision_watchdog_ticks) that
re-ranges a stuck O5 (gpon0 RX=0 past the slow-lease window) to re-roll
the US-TX serializer phase, plus rtl9602c_eth_wan_rx_count() as its
"are we provisioned" signal.

HW A/B result: the watchdog fires correctly but does NOT recover a stuck
boot — one hit sn_tx=37 / sds_sync=7 + 2 watchdog re-ranges and still
never leased. So the bad serializer/CMU lock is a COLD-START analog
state fixed at power-on; no runtime re-range/CDR-reseat re-rolls it (only
a reboot does). Watchdog therefore DEFAULT OFF, kept as documented
negative knowledge.

This completes the WAN diagnosis: every deterministic ONU register
matches the live working stock (SerDes/BOH/EqD/lock counters, ruled out
across many A/B runs + a 9-agent SerDes-diff workflow + live OLT/oracle
reads); the ~40% non-leasing boots are an irreducible cold-start
analog-lock failure. WAN works end-to-end on ~60% of boots (lease + ping,
like stock when the lock is good). Status doc updated.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Add gpon_serdes_init_stock() (param serdes_stock_seq, default off): the
EXACT stock rev-A (CHIP_REV_ID_A) GPON SerDes bring-up ORDER, ported
verified from the real vendor source (dal_rtl9602c_ponmac.c
PONMAC_MODE_GPON case + _rtl9602c_ponMacModeV1_set, cross-checked against
rtk_rtl9602c_reg_list.c / regField_list.c). Differs from our
gpon_serdes_init by: reset-FIRST then config (vs config-first), single
CMD_SDS_RST_PS (vs +CFG_RST_PS), the D2A/sample-clock bits SET=1, and no
reset-B-release dance.

HW A/B (default-on test build): reached O5 6/6 (so the stock order
DS-locks fine and our reset-B dance is unnecessary) but the cold-start
WAN lease rate did NOT improve (1/6, no better than the ~60% baseline).
So the deterministic lock is NOT an emergent property of stock's order
either. With config-values-match + every-component-tested + this
order-test, the ~40% cold-start US-TX serializer/CMU lock is
DEFINITIVELY irreducible by any register/sequence-level ONU action —
it is below the register level (analog VCO/CMU trim / PVT). Variant kept
default-off as documented negative knowledge.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Add rtl960x_ponmac.{c,h}: an ORIGINAL, data-driven reimplementation of the
RTL960x family GPON PON-MAC + SerDes bring-up, so the driver is ready for
future 960x boards. NOT a copy of the vendor SDK: the per-chip register
SEQUENCES (addresses/values/order/delays) are hardware-interface facts,
expressed here as compact declarative op-tables (WR/FLD/DLY/POLL) driven by
one tiny interpreter (r960_run), with loops/conditionals as small explicit
code and indirect-SerDes chips via a minimal cmd/data helper. Structure,
interpreter, naming and comments are all original.

Coverage (GPON): RTL9601B, RTL9603CVD, RTL9607C ported clean-room from each
chip's own reg_list/regField maps and adversarially cross-checked (a wrong
9607C PON-port P_MISC address was caught + fixed in review). RTL9602C is a
reference slot (the realtek-luna board uses the in-tree HW-tested
gpon-rtl9602c.c). RTL9607F deferred (no reg map in this SDK drop).

Board-agnostic: absolute phys addresses + an injected struct rtl960x_ops
{rd,wr}; a board wires its phys->virt accessor and chip id, then calls
rtl960x_ponmac_init/mode_set/serdes_cdr_reset. Compiles clean + links
self-contained (only standard kernel delay externs); the 9601B/9603CVD/9607C
paths are source-faithful but UNTESTED (no hardware). Wired into the build
(obj-$(CONFIG_RTL9602C_GPON) += rtl960x_ponmac.o).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Fill the rtl960x_ponmac 9602C path from our own tested gpon_serdes_init,
translated faithfully into the clean-room op-table form (199-entry analog
golden table verified exact-match vs source; default param path baked in:
cdr_reset on, modev1_tx/tx_xtra off). c2_/C2_ prefixed, collision-free.

Wire gpon-rtl9602c.c to bring up the SerDes via the family lib
(rtl960x_ponmac_mode_set, RTL960X_CHIP_9602C) behind module param
family_lib, injecting a phys->KSEG1 rtl960x_ops accessor. Default ON: the
clean-room family library is now THE 9602C SerDes boot bring-up; the lib
links into vmlinux (referenced).

HW validation on the realtek-luna board (two 5-boot runs, family_lib=on):
"PON SerDes up (family-lib 9602C, analog ready)" every boot, reached O5
10/10, LAN 0% loss, WAN leases at the usual analog ~40-60% rate
(192.168.158.248, ping 8.8.8.8 0%) — functionally equivalent to the
inline path. This proves the clean-room op-table framework (interpreter +
dispatch + injected ops) works on real silicon, giving confidence in the
untested 9601b/9603cvd/9607c family paths. gpon.family_lib=0 reverts to
the legacy inline gpon_serdes_init.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Independent re-extraction + diff of the untested 9601b/9603cvd/9607c GPON
op-tables against the vendor source caught real bugs (the SerDes/analog
cores were byte-perfect; defects confined to per-port PON-MAC regs):

- 9601B: 3 critical wrong per-port addresses — the 9607C 0x400/0x4 strides
  were copied onto a chip whose PON-port array stride is 0x20. Fix
  C1B_R_PMISC_PON 0x20408->0x20028, C1B_R_ACC_LEN_PON 0x23038->0x23054,
  C1B_R_TX_LEN_PON 0x1100C->0x11028 (base + PON port 1 * 0x20).
- 9603CVD: C3_P_MISC_PON 0x20404->0x20084 (stride 0x20, not 0x100); and add
  the entirely-missing SID2QID flow->queue map (c3_flow2queue + C3_PON_SID2QID
  0x1bf0210c, 7-bit/elem) — without it the OMCI SID was valid but bound to no
  queue, so no traffic would pass.
- 9607C: verified register-correct (only minor PBO/flowctrl helpers deferred).

Stability: gpon-rtl9602c.c family-lib bring-up now falls back to the
months-tested inline gpon_serdes_init if the lib path ever fails to bring
the analog ready, so the board always comes up.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Extend the clean-room RTL960x PON-MAC/SerDes library with EPON mode for all
four chips (9601b/9602c/9603cvd/9607c), as data-driven op-tables reusing each
chip's existing GPON #defines, helpers and the shared r960_run() framework.
Register addresses/fields/values/order are silicon facts resolved from each
chip's own reg_list/regField + cross-checked against the vendor
_ponMacEponMode{V1,V2,V3}_set() sequences; the expression is original. PBO/
datapath + flow-control patches stay owned by their subsystems, as for GPON.

rtl960x_ponmac_mode_set() becomes a per-mode outer switch: MODE_GPON and
MODE_EPON each route all four chips; FIBER/unknown -> -ENOTSUPP. The GPON path
and the HW-validated 9602C bring-up are unchanged (EPON is dead code unless
dispatched with MODE_EPON, which this GPON board never does).

EPON is UNTESTED (no EPON hardware): source-correctness is the bar. An
independent re-extraction verified every EPON-new address/field/stride and
found no fabricated or missing ops.

That re-extraction also caught a per-port-stride bug class in the (reused)
GPON macros from the earlier hardening pass, which assumed a flat 0x20 stride.
Per reg.c::_reg_addr_find: a base inside the MACPP block [0x20000,0x203FF] is a
PpReg (stride = MACPP interval); any other base is a Global array (stride =
array_offset_bits/8). Corrected, with the model documented inline:
  9601b (interval 0x400, ponPort 1): C1B_R_PMISC_PON 0x..028->0x..408 (PpReg);
    C1B_R_ACC_LEN_PON 0x..054->0x..038, C1B_R_TX_LEN_PON 0x..028->0x..00C (Global +4)
  9603cvd (interval 0x100, ponPort 4): C3_P_MISC_PON 0x..084->0x..404 (PpReg)
9607c (interval 0x100, ponPort 5) and 9602c were already correct.

Builds clean (cross-toolchain rc=0, no warnings). 9602C GPON smoke after
integration: family-lib 2/2, O5 2/2, full end-to-end WAN+LAN on a leasing boot
(unchanged vs pre-EPON; the analog cold-start lease ceiling is unaffected).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…core poke

luna_machine_restart() wrote BIT(7) of the swcore software-reset register
(0x1b0000e0), which only resets the switch core and leaves the CPU spinning —
so `reboot` HUNG at "Restarting via SoC soft-reset..." and never re-entered the
boot ROM (captured on the X111W: kernel shut down, then silence). Any reboot
wedged the board until a power cycle.

Force a watchdog timeout instead: program BSP_WDTCTRLR (0x18003268) for
RESET_MODE=0 (H/W full-chip reset), fastest scale, PH1=1, enable, and don't
kick. This re-enters the boot ROM and reboots cleanly (verified: U-Boot prompt
reappears). Register map from the vendor SDK's luna_watchdog.c.

Note for GPON WAN recovery: a full-chip WDT reset still keeps the SoC powered,
so it does NOT re-roll the non-deterministic cold-start upstream analog lock
(measured 0/8 recoveries across consecutive WDT resets vs ~40-60% per true
power cycle). Only a physical power cut re-rolls it; software auto-reboot cannot
recover a stuck cold boot. This commit only fixes the (previously broken)
reboot path itself.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…e servo (WIP, gated off)

Root cause of the ~40-60% cold-boot WAN (confirmed: stock=100% same board, so
pure SW): the laser is an RTL8290B; stock completes the OFFK modulator-offset
calibration (R29 0x31d &0x3c==0x3c) via its continuous europa_LoopMon servo, so
the modulator is nulled and bursts are clean/deterministic. Our legacy
bosa_apc_calibrate runs the wrong (non-B) APC variant and never completes OFFK.

This adds a clean-room RTL8290B B-variant path, RE'd from the stock europa_drv.ko
(rtl8290b_apc_init@0x9ae4) + the cal blob + the live oracle (europacli):
  - rtl8290b_apc_init(): MCU power-on gate, CHECK_READY, OFFK_EN trio, the W77
    command-byte measurement walk, the OFFK offset-DAC apply (0x243/0x245), DCL
    loop mode, Ibias/Imod seeds, FSU/OFFK config + arm. Config+arm only — no
    blocking poll, and NO continuous-CW EN_L window (that deafened the shared
    DS-RX); the GTC framer burst-gates the laser normally.
  - a runtime OFFK servo in gpon_fsm_poll (same softirq as bosa_laser_maint, so
    BOSA I2C stays serialized): at O5, strobe 0x24d=0xb0, read R29, and latch
    (clr 0x20e.b7 + 0x27c.b4) when (R29 & 0x3c)==0x3c — stock's europa_LoopMon.

Gated behind module param apc_offk (DEFAULT OFF) so the shipping path is byte
unchanged; gpon.apc_offk=1 enables it. Builds clean.

STATUS: WIP. With apc_offk=1 the ONU ranges cleanly to O5 (no DS regression),
but OFFK does NOT yet converge: R29 reaches 0x0e (phases 2,3) and stalls before
the measurement phases 4,5 (0x3c). Ruled out as the cause: timing, O5-context,
EN_L, and the offset-DAC apply. Remaining: the exact per-board FSU params
(fsuMode/loop-gains) — the dpoConfig cal-blob base (0x200 vs 0x578) is still
unresolved; resolving it needs the live oracle's configured FSU registers.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…but it is NOT the WAN fix

Replaces the earlier WIP apc_init with the exact stock rtl8290b_apc_init,
transcribed verbatim from europa_drv.ko (dpoConfig base flash_data+0x578,
definitively pinned via init4 `addiu s4,s0,1400`):
  - removed the spurious OFFK offset-DAC write (0x243/0x245): stock gates it on
    dpo[0x72]!=0 and ours is 0, so stock skips it; our write was parking R29 at
    0x0e. This was the bug blocking OFFK.
  - replaced all guessed FSU/ceiling bitfields with the exact stock values
    (0x247=0xcc, 0x248=0x4d, 0x249=0x01; FSU 0x241/0x242 exact masks; init seeds
    0x236=0x10/0x237=0x20; DCL loopmode; arm 0x27c/0x20e; commit 0x232/0x24a).
  - runtime OFFK servo (gpon_fsm_poll) now runs from boot (not O5-gated),
    mirroring stock's continuous europa_LoopMon.

RESULT: OFFK now CONVERGES every boot — R29(0x31d) reaches 0x3f, "modulator
nulled" (stock's exact O5 value); verified on HW. This is a correct, faithful
stock-alignment of the laser calibration that we were genuinely not doing.

HOWEVER: it does NOT improve the cold-boot WAN lease rate (6-boot A/B with
apc_offk=1: 1/6, == the ~17-33% baseline). So the RTL8290B modulator-offset cal
is NOT the root cause of the ~50% WAN flakiness. OFFK also converges too slowly
(~40s, grant-limited) to beat the OLT's deact window. The remaining WAN gate is
the separate US-TX serializer-phase / SerDes cold-start lock.

Kept gated behind apc_offk (DEFAULT OFF) — correct laser stack + verified OFFK,
available for combination with a future serializer-phase fix, but not enabled
since it does not (alone) fix WAN.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
… can't re-roll the lock)

Adds /usr/sbin/gpon-wan-recover (+ init.d + uci-defaults), a watchdog that
detects a never-provisioned WAN (gpon0 rx_packets==0 past a timeout) and reboots
to retry. Preserved for reference but DISABLED (ENABLE=0, uci-defaults a no-op):
HW-proven that a software reboot — including the new WDT full-chip reset — does
NOT re-roll the cold-start US-TX analog lock (0/8 vs ~50% per physical power
cut), so auto-reboot cannot recover WAN. Re-enable only if a HW power-cycle
(GPIO/PMIC) path is wired.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…stock rev-A parity)

The family-lib (default) SerDes bring-up did TWO edges AFTER committing GPON mode
that stock rev-A omits: a WSDS_DIG_1D[16] reset-B re-sync and an UNCONDITIONAL
rtl9602c_serdes_cdr_reset() pulse. These late edges on the already-running US-TX
serializer can re-roll its divide/sample phase per cold boot (serializer-phase
jitter -> intermittent un-frameable burst -> OLT "Laser out"). They were NEVER
cleanly A/B'd: the serdes_cdr_reset module param only gated the inline
gpon_serdes_init path, not the family-lib path, so every prior test left them ON.
(Also: our serdesCdr_reset toggles SDS_ANA_COM_REG08[15] but stock toggles
REG12[15] — a different register; our pulse was never a faithful copy.)

Gate both behind board param serdes_postmode_perturb -> lib global
rtl960x_c2_postmode_perturb. DEFAULT 0 = skip (stock rev-A parity).
gpon.serdes_postmode_perturb=1 restores legacy.

6-boot cold A/B with them OFF: WAN-lease 3/6 (best run so far; baseline ~1-2/6),
O5 6/6 (no regression). Marginal-but-positive + stock-matching + zero DS risk, so
made the default. Not alone a 100% fix; stacking the next real lead (live
temperature-indexed DCL bias/mod LUT) on top.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
dnsmasq: add a --preserve-client-edns option (default off) so a forwarder only
attaches an EDNS0 OPT to an upstream query when the client's own query carried
one (or DNSSEC needs it); enable it for the ONU. This lets the resolver work
against upstream gateways that silently drop OPT-bearing queries, while keeping
EDNS/DNSSEC intact for clients that request it. Also stop running dnsmasq under
the procd ujail: the user+mount namespace prevented it from reading its upstream
reply sockets on this RLX/MIPS build.

onu-diag: wan_dns now reads only the dns-server list instead of every dotted
quad in the interface status (which also caught the WAN address, route target
and nexthop).

gpon-provision: derive a stable DHCP client-id + DUID from the WAN MAC so the
WAN lease is deterministic per board and does not churn the server's pool.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…omment cleanup

rtl960x_ponmac: program the full analog CMU/CDR block AFTER the SDS reset
(stock rev-A order) via gpon.serdes_analog_postreset (default on), so the US-TX
serializer locks against its final operating point; the CDR-reset pulse operates
on SDS_ANA_COM_REG12[15] (RX_SD_POR_SEL), not REG08.

gpon-rtl9602c: median-of-3 glitch-tolerant BOSA optical-power read (the optic
I2C bus is shared with the laser servo, so a single read can come back
corrupted); the analog-postreset A/B knob; US-egress / datapath bring-up.

rtl9602c_eth: zero the OMCI MIB-Data-Sync on MIB-Reset (re-seeding it non-zero
caused OLT resync/deactivate loops); WAN MAC derived as LAN + per-port offset.

All code comments rephrased to behavioral / stock-observable wording: no
functional change (driver builds; every register address/value/sequence kept).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
base-files: add 99-onu-dns-queryport uci-default that pins dnsmasq's upstream
query-port. On this build dnsmasq's per-query random-source-port upstream sockets
were not serviced (the kernel delivered the replies into the socket buffers but
dnsmasq never read them), so every forwarded query timed out and name resolution
failed even though the WAN datapath and direct upstream queries worked. A fixed
query-port makes dnsmasq use one persistent, polled upstream socket, so replies
are read. Verified: name resolution + ping-by-name work; dual-stack WAN intact.

gpon/ponmac: add default-off A/B module params for the cold-start US-TX
"Laser out" metastability (serdes_cmu_settle_ms, serdes_clkgate_rstb,
force_soc_clk write of the live-stock SoC clock regs). Legacy behaviour is
unchanged unless a knob is set.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The OMCI responder ACK'd Create/Set but never stored the provisioned MEs, and a
GET of an OLT-created ME returned UNKNOWN_ME — so the OLT's post-config audit saw
its config "didn't take" and re-ran MIB-Reset/Upload/Create every ~50s, then
Deactivated the ONU (the periodic-deact / reboot instability seen vs the stock ONU).

Add an auto-adaptive ME store (omci_store[], keyed by class+instance):
- Create stores the ME with its set-by-create attribute body; Delete removes it;
  MIB-Reset clears it.
- GET of an OLT-created ME now returns OK with its stored attributes instead of
  UNKNOWN_ME, so the OLT sees its provisioned MEs and marks the ONU operational.
- MIB-Upload count / Upload-Next include the store, reflecting the live config.

Result: the OLT runs MIB-Upload once (was a 3x/~50s re-provision loop) and the ONU
holds O5 + WAN + DNS + WiFi stable on a converged boot, matching stock.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ANI-G (ME 263) attribute openwrt#10 (downstream RX optical signal level) and openwrt#14
(transmit optical level) were fixed snapshot constants. Read them live
instead from the RTL8290B's calibrated SFF-8472 DDM words (RX 0x168/0x169,
TX 0x166/0x167 on the BOSA I2C bus, unit 0.1 uW/LSB) and convert to the
G.988 encoding (2's-complement s16, 0.002 dB referred to 1 mW) with a
fixed-point log2 (no kernel FPU).

The DDM read busy-waits on the I2C bus, so it must not run in the PLOAM
fsm_poll softirq; a periodic workqueue (~3 s) samples it into a cache and
the (softirq) OMCI GET returns the cache. The snapshot stays as the
fallback until the first good read. Also expose the cached levels in
/proc/gpon for diagnostics.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Two experimental cold-start/optical levers are kept but defaulted off:

- optical_poll: the periodic BOSA-I2C DDM optical read (for the dynamic
  ANI-G levels) shares the I2C bus with the laser servo and its periodic
  traffic can perturb the link; default off so ANI-G reports the snapshot
  value and the datapath is undisturbed. Set optical_poll=1 to re-enable the
  live read once it is made glitch-free.

- serdes_txpll_relock: re-lock the TX CMU PLL (CMU-enable toggle + FIFO
  re-sync) at O3 entry. An untested cold-start-lock candidate; the active
  failure was not cold-start, so leave it gated/off.

Both are module params for A/B testing. No default datapath behaviour change
versus the known-good pre-ANI-G image.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
… optical display fix

- gpon: los_rerange_ticks watchdog (default on) — on sustained downstream
  optical LOS (fiber pull / DS-light loss) tear down to O1 and re-acquire when
  light returns, instead of sitting stale at O5. The OLT cannot send a
  Deactivate when downstream light is gone, so the ONU recovers on its own.
- gpon: lan_keep_open (default on) — never gate the LAN VLAN filter on the
  GPON/WAN state, so LAN management (SSH/LuCI) stays reachable through
  ranging / re-range / LOS.
- luci-app-gpon: report optical RX/TX power as "n/a" under LOS instead of a
  stale last-good dBm; the live /proc read tracks current power when connected.
- gpon/ponmac: add A/B knobs (serdes_skip_rstb_dance, bosa_before_serdes,
  bosa_i2c_restore_pad; all default off) for the cold-start US-TX serializer
  determinism investigation.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
alphaonex86 and others added 16 commits August 9, 2026 06:29
…identical UUID

miniupnpd-nftables added to DEVICE_PACKAGES. The variant is established from
three independent places rather than preferred: .config has firewall4 with
`firewall` unset and no iptables anywhere; the two variants differ in the
daemon's COMPILED backend (--firewall=$(BUILD_VARIANT)), so the iptables build
would drive a ruleset this image does not have; and it is the feed's own
DEFAULT_VARIANT, named explicitly so it stays a decision rather than an
inherited default. The nftables variant needs no firewall.include stanza -- it
drops files into /usr/share/nftables.d/, which fw4 includes automatically.

⚠ THE .mk EDIT ALONE IS INERT ON A FRESH CHECKOUT. miniupnpd lives in the
`packages` FEED, not in core, and that feed is not installed by default here.
Measured: `make defconfig` after this edit produced only
CONFIG_DEFAULT_miniupnpd-nftables=y and NO CONFIG_PACKAGE_* -- the package would
silently never be built. `./scripts/feeds install miniupnpd` is required (it
adds miniupnpd + libcap-ng). Both .config and package/feeds/ are gitignored, so
this cannot be fixed by committing them; the build must assert the binary is in
the staged rootfs instead.

30-upnp-secure: the hardcoded `uuid='<UUID>'` is REMOVED. It was a literal
placeholder nothing in the tree substitutes, and miniupnpd's init regenerates
the UUID only when it is EMPTY -- so every unit built from this image would have
advertised the same malformed UUID in its SSDP USN. Proven with a shell rather
than read. Without the line the init mints a per-unit random one.

SECURITY, stated precisely: at rest the WAN posture is unchanged -- the package
ships EMPTY fw4 chains (upnp_forward/upnp_prerouting/upnp_postrouting) and the
daemon binds the LAN interface, so a WAN port scan still finds nothing. What
changes is that the WAN becomes LAN-CONTROLLABLE: "no WAN listener by default"
stays true, "the WAN can never open" does not. The shipped hardening is stricter
than most vendor defaults -- secure_mode=1 (a client may map only to its own
address) and allow 1024-65535 ext+int with a terminal deny 0-65535, so no
privileged port can be mapped and the router's own 22/23/80 are unreachable this
way.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ed /proc nodes

⚠ LANDED BUT NOT PROVEN ON HARDWARE. Committed so the work is visible and
revertable, NOT because it is finished -- the blockers are listed below and in
dev/ONU-test-case/OWED-proc-node-deletion.md. The boot path deliberately still
points at the PROVEN earlier image.

WHY: a case that reads /proc/net/cortina_ni_* can only ever BLOCK on the vendor
firmware, because those nodes are OURS -- stock's own names are cntr_rx, cntr_tx,
cntr_drop, ni_debug, l3fe_debug... So every "compared against stock" claim taken
that way had no oracle half at all, and it failed quietly as a BLOCKED rather
than loudly. Stock's ca-ne.ko implements ethtool_ops (-S and -d both answer), so
the STANDARD interface exists on BOTH firmwares: that is what makes the
comparison possible, and matching the shipped product's interface is
compatibility work rather than imitation.

WHAT LANDED: cortina-ni-ethtool.c exposes 120 counters via -S plus an 872-word
-d register window; cortina_ni_nihv_sample() is the SINGLE READER for the
read-and-clear registers (a second reader steals the count); five model-named
/proc nodes retired to debugfs or deleted; values -d cannot carry got -S rows,
including port%u_phy_link -- the only answer to "which printed socket has the
cable". Proven live on the board: 120 counters, rx_frames 56->114 and
l3fe_rx_packets 66->125 across 40 pings, which is what demonstrates the
accumulator works.

STILL OPEN, do not treat this as done:
 * no forwarded LAN->WAN flow has yet been seen to move l3fe_hw_hits through
   ethtool -S -- the old nodes were the PROVEN witnesses and have been traded
   for untested ones;
 * stock still has 0 of 40 DECLARED sources, so the oracle half is possible now
   but not yet delivered;
 * offload_forward_gate.sh still reads two DELETED nodes, and one of those
   makes a HW witness that can never fire -- a gate that can never fail;
 * test_pppoe_caps writes to a node now registered 0444 with no .write;
 * `ethtool -S` runs TWICE per capture (the de-dup compares command strings that
   differ only by a 2>/dev/null suffix), which breaks the single-reader
   invariant the whole accumulator design rests on.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
MEASURED 2026-08-16, after this board moved to the OLT's PON port 2: at a
healthy O5 with the OMCC installed, the OLT sent 59 DS OMCI messages -- EVERY
ONE a Get (ME 256/257/2/65530) on a 7-13 s loop -- and never a MIB-Reset
(MT 0x4f), never an Assign_Alloc-ID, never a Create (class 268). `mds` stayed at
exactly the compiled seed 200, because only a MIB-Reset or an applied Create/Set
moves it. The OLT held Match State "Initial"; the ONU had no data GEM and no WAN.

WHY THE SEED COULD NOT BE RIGHT. It exists to FAIL the OLT's ME2 audit on
purpose, so the OLT issues MIB-Reset and re-provisions. But WHICH values fail
that audit is a property of the OLT's stored lsync for THIS ONU on THIS PON port
-- something we cannot read and it never tells us. The seed was picked against
one port's observed range (~42-126), and its own comment already records both
ways a wrong choice ends: a value that MATCHES makes the OLT skip MIB-Reset and
every Create, and mds=0 "wedges this OLT in a GET poll loop". On the new port,
200 had become that wedging value.

SO WE STOP GUESSING AND CLOSE THE LOOP ON THE OUTCOME. We cannot observe lsync,
but we can observe the one thing that matters -- whether the OLT is PROVISIONING
us. If it reads and never provisions, the value we report is not doing its job,
and we report a different one.

  * THE WALK IS +37. Coprime with 256, so it visits EVERY value before
    repeating: an exhaustive search, not a sample. 0 is skipped -- it is the
    known wedging value.
  * DRIVEN BY THE OLT'S OWN AUDIT, not a timer. The stuck state IS a Get loop,
    so the evidence that we are stuck is exactly the event that advances the
    search. No timer to arm or cancel, and nothing runs at all on a link the OLT
    is not reading.
  * IT COSTS NOTHING WHEN THINGS WORK. Any provisioning event -- a MIB-Reset, or
    an applied Create/Set/Delete -- resets the counter, so a healthy admission
    never takes a single step and the compiled seed behaves exactly as before.
  * NEVER COUNT-CAPPED, only rate-bounded by the OLT's cadence. A recovery path
    that gives up is a device that needs a human.
  * omci_mds_adapt=0 restores the old fixed-seed behaviour.

84 lines, one file, ADDITIONS ONLY -- the path that works today on PON port 1 is
untouched byte for byte.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… them

CLAUDE.md: *"NO BACKUP FILE EVER LIVES INSIDE THE OPENWRT FORK"*, and the stated
reason is not losing them -- it is PUBLISHING them. This fork has a public
remote. It had already happened once with three `.config.*.bak`, one of which
still advertised a product spelling the tree had stopped using.

Found TRACKED on 2026-08-16, all four:

    .config.bak-wifi
    .config.luna-bak-1783553117
    target/linux/realtek-luna/config-6.18.bak-prelockup
    target/linux/realtek-luna/config-6.18.bak-slub

Copied to dev/backup/2026-08-16-fork-backups/ with their paths MIRRORED (a
backup that has lost its provenance is just a loose file) and a README saying
what each one is, then untracked here. They remain on disk in the working tree;
nothing was deleted.

★★ AND THE IGNORE RULE THAT WAS SUPPOSED TO PREVENT THIS MATCHED NONE OF THEM.
`*.bak` was already present -- and every one of these ends in a SUFFIX
(`.bak-wifi`, `.bak-slub`, `.bak-prelockup`, `.luna-bak-<epoch>`), so the
pattern that looked like protection protected nothing. That is the same shape as
every vacuous guard in this project: it reads as a rule, it fires on nothing,
and it is indistinguishable from working until you check. `git check-ignore -v`
now names the rule that catches each of the four.

⚠ Two of them sat INSIDE `target/linux/realtek-luna/`, which is worse than
untidy: a `files-<ver>/` overlay COPIES everything under it into the kernel
build tree, so a stray file there is compiled and shipped rather than merely
stored. These were beside `config-6.18` rather than under `files-6.18/`, so they
were not overlaid -- but the same directory is one `mv` away from being.

★ The luna one is still USEFUL and that is why it was preserved rather than
removed: it is the RTL9602C/X111W build config (realtek-luna/rtl960x/
DEVICE_hsgq_x111w, 4681 lines) and it is what configured the new `openwrt-luna`
worktree the same day.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…not guessed

READ OUT OF THE OLT on 2026-08-16 -- its decompiled `gpon_ont_cfg_process`
(HSGQ-G008 gpondev). The branch reaching "start issue auth profile", i.e. the
MIB-Reset + Create burst that gives us a data GEM, is taken when ANY of:

    rsync == 0  ||  rsync != lsync  ||  rsync < 31  ||  <ont field> == 2

★★ AND THIS DRIVER'S COMMENT STATED IT BACKWARDS. It claimed the OLT "installs
the downstream gem flow ONLY when rsync==lsync && rsync>30". The OLT provisions
when the MIB is NOT in sync -- the opposite. The `>30` was real but its SENSE was
inverted: being BELOW 31 is a REASON to provision, never a requirement to skip.
A wrong comment outlives every session that knew better, and this one had
already produced one wrong constant.

★ WHY THE OLD VALUE FAILED -- THE POISON POISONED ITSELF. The seed was 200,
chosen to "not match any plausible stored lsync". Once this ONU reported 200 the
OLT stored 200 as ITS lsync for the record; from then on rsync == lsync == 200,
200 >= 31, every clause false, and it never provisioned again. Measured on PON
port 2: healthy O5, OMCC up, 59 DS OMCI messages answered, EVERY ONE a Get,
never a MIB-Reset, never an Assign_Alloc-ID, never a Create -- Match State
"Initial", no data GEM, no WAN. A value chosen to be UNEQUAL became equal the
moment the far end remembered it.

⇒ The seed is now 7. Any value in 1..30 satisfies the third clause NO MATTER
what the OLT stored, so a stale lsync cannot defeat it. 0 would satisfy the
first clause and is deliberately NOT used: this driver's own earlier note
records mds=0 wedging this OLT in a Get poll loop, and an unexplained
OBSERVATION is not overridden by a decompilation.

⇒ AND THE ADAPTIVE WALK STAYS. The derived constant answers the OLT whose
decision code we have read; the walk is what makes the ONU converge on one we
have not. Together: right by construction here, self-correcting elsewhere.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…d is 7 not 0

Two independent RE passes over the vendor omci_app agree: stock does NOT persist
the MIB-Data-Sync. gMibOntDataDefRow is in .bss with no initialiser and is
explicitly zeroed in mibTable_init, so stock answers 0 at the pre-config Get on
every boot -- satisfying the OLT gate's FIRST clause. That REFUTES this driver's
older claim that 'stock persists its mds so rsync matches'; nothing should rest
on that sentence again.

By stock-is-the-oracle the seed should be 0. It stays 7, because a decompilation
does not overrule an OBSERVATION -- our own note records mds=0 wedging this OLT
in a Get poll loop. That note is now contradicted from three directions and is
probably wrong, but it was never explained. 7 satisfies a DIFFERENT clause of the
same gate, so it is correct under both readings and touches nothing in dispute.

OWED, and it is a measurement rather than more RE: boot stock on this PON port
and capture what it answers to the pre-config ME2 Get. If it reports 0 and is
provisioned, the seed becomes 0 and matches stock exactly.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…t of reach

The X111W keeps NO setting across a reboot. /proc/mtd on the board shows
`rootfs_data` at size 0 with erasesize 0x01000000 -- the whole chip -- and the
kernel says why on the console:

    mtd: partition "rootfs_data" is out of reach -- disabled
    mount_root: Could not open mtd device: /dev/mtd6

The flash node declared no `erase-size`, and drivers/mtd/chips/map_rom.c
default_erasesize() reads exactly that property, falling back to `map->size`
when it is absent -- the entire 16 MB as ONE erase block. mtdsplit_squashfs
then rounds the squashfs end up to that block against the WHOLE DEVICE
(mtd_roundup_to_eb(part_offset + squashfs_len, parent_mtd)), so a 3.2 MB rootfs
rounds to 16 MB, lands past the end of every partition, and mtdpart publishes
the overlay disabled at size 0. Only that code path prints that message.

64 KiB is the JEDEC NOR sector and is deliberately conservative: it is a valid
alignment whatever part is fitted, including a 4 KiB-sub-sector chip. With it
the split yields 1600 KiB of rootfs_data inside the 4864 KiB bank-0 rootfs
partition -- so "no room" was never the explanation.

Verified against the kernel this target builds, not from memory: map_rom.c:39
`of_get_property(map->device_node, "erase-size", NULL)` with the map->size
fallback at :41, and `erase-size` documented at mtd-physmap.yaml:108.

⚠ THIS ALONE DOES NOT GIVE PERSISTENCE, and the comment says so on the node.
The mapping is `mtd-rom`, so map_rom sets MTD_CAP_ROM, mtdchar_open refuses
O_RDWR and fstools opens the overlay with exactly O_RDWR|O_SYNC -- the board
will still print "Could not open mtd device" until a program/erase driver
exists for the SoC's separate PIO block. CONFIG_JFFS2_FS is also unset. What
this fixes is the partition arithmetic, which is the first of the three gates
and the only one that can be settled without new driver code.

ONU-test-case/image_overlay.py decides all three from the BUILT IMAGE and its
appended DTB -- WILL / WILL-NOT / CANNOT-TELL -- so the next build can be judged
without a boot.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…d a walk that really walks

THREE defects, all found by offline cases that were SEEN TO FAIL first, all in
the path that takes this ONU into service. They ship together because the
gem-id fix changes a function's signature across three files and cannot be
split without a commit that does not compile.

★ 1. A TEARDOWN LEFT THE DATA T-CONT BOUND, AND IT COULD NOT SELF-HEAL.
`data_tcont_installed` / `data_alloc` were set on install and cleared ONLY in
the dealloc arm, which requires `alloc == data_alloc`. All FIVE teardown routes
(Deactivate, Disable_SN, SN-reprovision, the O5 watchdog, LOS) cleared the
neighbouring flags and not these two. After a re-config the OLT issues a
DIFFERENT Alloc-ID, the stale flag makes the install guard drop it, and recovery
is impossible because the dealloc arm waits for an Alloc-ID the OLT will never
send again. The board then runs to the next reboot with no data T-CONT -- which
is the recorded "works after a cold boot, dies after churn".

★ 2. AND THE ASYMMETRY NEXT TO IT WAS TWO-THIRDS DELIBERATE. The rule that
explains all of them is *the flag means the OLT currently holds a GEM-CTP for
THIS IDENTITY*: Deactivate and Disable_SN CLEAR (the OLT deprovisioned us), LOS
and the O5 watchdog KEEP (ONU-initiated -- the OLT never deactivated us and does
not repeat ME 268, so clearing them IS the "internet does not come back after I
reconnect the fibre" defect), and SN-reprovision must CLEAR because it is an
identity change. Only that last one was wrong. The case asserts BOTH directions,
so "clear them all" now fails as loudly as "clear none".

★ 3. THE DATA GEM PORT-ID WAS A COMPILE-TIME CONSTANT. `GPON_DATA_GEM 193u`,
under a comment calling it "the OLT-assigned wire gem-port-id", while
`gpon_omci_note_gem_create(void)` took no argument and the Port-ID the OLT sends
in ME 268 attribute 1 was logged and DISCARDED. Measured: this same OLT gives
223 to the other board. It is read from the wire now (msg[8]<<8|msg[9], the
byte-8 rule independently extracted by the wire-layer case), and the macro is
renamed `_DEFAULT` because a misleading name is a defect in itself.
⚠ The multicast GEM (Port-ID 0x0fff) is created with an ME 268 too -- adopting
it would point the WAN at the broadcast port -- so the snoop refuses it.

★ 4. THE ADAPTIVE MDS WALK CLAIMED TO VISIT EVERY VALUE AND COVERED 32 %.
`mds += 37; if (!mds) mds = 1;` under a comment reading "coprime with 256:
visits every value". Folding 0 onto 1 splices the +37 orbit into a cycle of 83,
so from the seed it reached 83 of 255 values -- silently, with the comment as
the only thing claiming otherwise. 37 is coprime with 255 as well, so the fold
is unnecessary: `1 + (mds - 1 + 37) % 255` gives 255/255.

★ 5. AND THE KNOBS WERE DOCUMENTED UNDER A MODULE THAT DOES NOT EXIST --
`gpon.mds_reset0=…`. They build from `rtl9602c_eth.o`, and the same file spelled
`rtl9602c_eth.hw_nat` correctly one screen away. A wrong knob name fails in the
reassuring direction: the boot ACCEPTS the unknown argument, the default stands,
and the reader takes the result for the value they think they set -- which would
have silently invalidated the pending seed measurement.

Offline evidence, each case seen RED before the fix:
  step 19   gpon_data_bind_test          31/13 -> 53/0   (adversarial OLT, ASan+UBSan)
  step 19b  gpon_data_bind_policy_test   12/11 -> 23/0   (over the shipping driver)
  step 19c  gpon_data_bind_negctl_test   22/0            (19 mutations, each must redden its step)
  step 4f   omci_mds_provisionable_test  29/17 -> 48/0   (lsync swept 0..255, latching + memory-K)

⚠ STILL OPEN, named rather than hidden: a mid-session re-Assign of a different
Alloc-ID with NO teardown in between is still refused, on both drivers. The bind
decision itself was left alone because an existing case pins it exhaustively
over the 12-bit domain, and weakening that to widen this would trade a proven
property for an unproven one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A new board on realtek-luna, subtarget rtl9607x -- keyed on the CORE, not on a
chip name. The RTL9603CVD is MEASURED to be a MIPS interAptiv (MIPS32 R2, 2 VPEs,
no Coherence Manager) from the board's own boot console, so it shares the
rtl9607x toolchain and NOT the RLX path. A routing note now says so in
rtl960x/target.mk, because the part number invites the opposite guess.

⇒ THE LEXRA MDU HAZARD DOES NOT APPLY HERE, and two red herrings are recorded so
  nobody re-chases them: `LX:200MHz` in the vendor banner is the SoC's LX BUS
  clock, and `CHIP_AFLAG_LEXRA` is set on every row of the vendor chip table --
  including the ARM Cortina parts.

★ THE DEFECT THIS FIXES BEFORE IT COST A BOOT: the scaffold declared
  `compatible = "mti,gic"` at 0x1fbc0000 and routed the UART to "GIC hwirq 23".
  The board's own log says `GIC isn't present!` and falls back to its SoC
  aggregator. The symptom would have been early printk appearing and the console
  never becoming interactive -- a silent, expensive way to lose a bring-up.

`irq-rtl9603cvd.c` is clean-room: facts re-expressed, no vendor text or
structure. The interrupt map is confirmed at TWO independent tiers -- the chip's
own SDK translate table inverts to exactly the 34-entry table the boot log
printed at runtime, every entry, and the RTL9602C DTS already in this tree
numbers UART0=49 and the system timer=43, the same native numbers this part
yields.

It is DELIBERATELY a separate file from irq-rtl9602c.c: that one carries two
routing overrides established empirically on the X111W, which are facts about
THAT board's cascade and are not inheritable here.

The memory node carries the MEASURED two-range map rather than a flat guess, so
neither PBO DMA hole (0x06c00000+4 MiB, 0x07f00000+1 MiB) is ever handed to the
allocator. Timer and watchdog reach the existing family drivers through fallback
compatibles -- no driver changed for them -- and the watchdog ships disabled,
matching stock's WDT_E=0.

PROVEN: compiles clean against the real 6.18.31 tree with the real
cross-compiler, and links into arch/mips/realtek-luna/built-in.a with its
IRQCHIP_DECLARE present. The DTS compiles.

⚠ NOTHING HAS BOOTED. Every register in rtl9603cvd.dtsi not established at
tier 1 is still the RTL9607C's. If the console is silent on the first attempt,
suspect the PINMUX (IO_GPIO_EN / IO_UART_SEL are 9603CVD-specific) before the
UART itself. And this board is SINGLE-BANK -- no k1/r1 -- so it lives in
TFTP->RAM: that is a safety property, not a limitation to fix.
Both targets gain a watchdog driver and the DT node that binds it, so the
production bar -- self-recover from ANY event, unattended, for months -- rests
on the hardware block rather than on a process staying alive.

On the Luna side the block sits at the top of the same timer region (TC_BASE +
0x60): WDT_CNT at +0x00 with bit 31 as the kick, WDT_INTR at +0x04, WDT_CTRL at
+0x08 with bit 31 the enable and [30:29] the tick scale. `setup.c` keeps its own
existing path into the same block and now says so in a comment -- two consumers
of one register block is exactly the kind of thing that gets "cleaned up" later
by someone who did not know.

★ THE TRAP THIS FAMILY ALREADY SPRUNG ONCE, recorded so it cannot be sprung
  again: on the Cortina side `reboot_reason=3` means ARMED, not FIRED. Copying
  that value forward installs a phantom -- a reboot nobody had.

CONFIG_WATCHDOG_CORE / _SYSFS are enabled on both targets, and CONFIG_DEVMEM
stays as the tree already had it.
… to equal

The X400AXF's 5 GHz radio carries an external FEM layout whose gain table the
in-tree driver does not have, and its absence is not loud: the chip associates,
scans and transmits, just not at the power the board is built for.

The table lives in its own file rather than inside `rtw8852c.c`, and the header
says why: the RFE-53 constant is NUMERICALLY EQUAL to
`RTW8852C_RFE_TYPE_EFEM`, and folding the two would tie "which gain table this
board needs" to "which rfe_type means external FEM". They answer different
questions and will not stay equal forever.

Read from the board's own efuse rather than assumed: the path is gated on
`rtwdev->efuse.rfe_type`, so a unit that reports anything else keeps the
upstream behaviour untouched.
…t can fail

OpenWrt shipped no per-RJ45 lamps on this board while stock lights them, and
CLAUDE.md counts that as a REGRESSION rather than a missing extra: the LEDs must
match stock.

`cortina_ni_leds_probe()` publishes the per-port triggers EARLY and on purpose
-- before any of the bring-up below it. A lamp that never registers is a lamp
nobody can debug from, and registering it late means a probe failure takes the
lamps with it. It is written so it cannot fail the probe: the worst case is no
trigger, never a dead interface.
…oved

Three services declared `respawn` bare. procd.sh then supplies its defaults
3600 5 5, and the trailing 5 is a RETRY COUNT: after five deaths procd halts the
instance PERMANENTLY. So a service that crashes six times in a long soak is gone
for the rest of the boot, with nothing in the log saying a cap was reached --
and the production bar for this device is months of unattended operation across
LOS, re-range and OLT churn. The count is now 0 = respawn forever, explicitly,
with the reason written where the next reader will meet it.

`30-upnp-secure` issued exactly THREE `delete upnpd.@perm_rule[-1]`, a hardcoded
count standing in for "all of them". A stock config with four leaves one
permissive rule alive, and the security posture this board certifies says
nothing is reachable from the WAN. It now deletes every perm_rule, however many
there are.

`gpon-identity` states in its own header that it retries forever and why -- the
identity it reads is not always present the first time it is asked, and giving
up turns a timing property into a missing fact.

Also: the busybox default flips to y for the applet the vendor image lacks. An
on-device command that cannot RUN is "could not ask", never "no", and this is
the half of that rule we control.
onu_sn_set() flagged a re-range on EVERY write of the module param,
including a write of the value already in force -- and onu_sn compiles in
with this board's real serial.  So the userspace provisioning service
writing the same serial dropped a HEALTHY O5 back to O1 and re-ranged,
once per boot, for no identity change at all.

Measured on the X111W 2026-08-20, the board's own console:

  [ 8.056] ONU state O4 -> O5
  [ 9.656] ONU state O5 -> O1
  [ 9.656] SN reprovisioned (58504f4e39013867) -> re-ranging
  [16.060] re-range openwrt#1 -> O5 (outage ~6404 ms)

58504f4e39013867 is "XPON39013867" -- the serial the driver already held.
That is a ~6.4 s outage plus one extra ranging cycle per boot, and on a
splitter the churn is charged to every ONU sharing the PON port.

A re-range is the response to an IDENTITY CHANGE, so compare the PARSED
BYTES rather than the string: case and zero-padding differ without the
identity differing.  gpon_parse_sn_into() is split out so the comparison
runs through the SAME decoder the driver uses -- a second copy would drift
and make a real identity change look like a no-op.  A short string still
compares equal exactly when it leaves every byte alone, matching the
decoder's own "leave untouched what the string does not supply".

Covered by rtl9607c-test step 19e (gpon_sn_reprovision_test, 13/0), which
extracts the decoder and the comparison from this file so the case runs
the driver's own code, and asserts the structural fact no extracted
function can express: gpon_sn_changed is reachable only via
gpon_sn_differs().

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LVfiQ53nAqdGyxWC8z44Ex
…uely

The GTC alloc-CAM is CONTENT-ADDRESSABLE: the hardware resolves a BWmap
grant's Alloc-ID by SEARCHING all 32 T-CONT entries.  The driver wrote the
one entry it wanted and left the other 31 untouched, so the search was
AMBIGUOUS and a grant could resolve to a T-CONT that was never configured.

Measured on the X111W 2026-08-20 (PON 2/1).  The OLT held us at
`Offline fail ... LOAi` with the OMCC up, DS OMCI arriving and answered,
and no data GEM.  A BWmap sample decoded with the vendor's own field
layout resolved the OLT's grants to T-CONT 14 and T-CONT 9, while
`us_sched: tcont_en=0x00010001` says the driver configured only T-CONT 16
(and 0).  T-CONT 16 emitted nothing (`idle16=0/0`) with eight pages sat
undrained in its queue (`sidpage64: used=8`).

The OMCC GEM and the PLOAM Acknowledge ride that SAME allocation, so a
grant that never resolves to T-CONT 16 silences BOTH at once -- which is
precisely LOAi (no Acknowledge ever reaches the OLT) together with an OLT
that re-Gets forever and never provisions.  One cause, both halves of the
symptom.

Parking the unused entries at 0xFFF -- a reserved Alloc-ID the OLT never
grants -- makes ours the unique match.  It runs at Assign_ONU-ID and
BEFORE the bind, never after: parking afterwards would race a grant that
arrives in between.  A real data T-CONT is bound later by the
Assign_Alloc-ID handler, which rewrites its own entry, so this cannot
strand the data path.

The routine gpon_alloc_cam_clear_others() already existed for exactly
this, its comment describing exactly this ambiguity -- as `static void
__maybe_unused`, with ZERO call sites.  A correct body nobody executed.
It is now called, the marker is gone, and it first reports what each
entry HELD, which is the confirming measurement for the BWmap decode: an
entry that already matches a granted Alloc-ID is a grant this ONU was
answering on the wrong T-CONT.

A/B at the OLT, same commit base, differing only by this change:

  with it     Online normal x5 consecutive, latched LOAi cleared,
              still Online ~10 min later
  without it  Offline x6 consecutive, Laser out

SCOPE, and it is narrower than the A/B suggests: `Online normal` is not
the full bar.  No far-end capture of our upstream frames and no DHCP
lease were taken, so this may NOT be read as "WAN works".  Root cause is
not claimed either -- three captured frames are a sample, not a census,
and the capture window's freshness is unestablished.  Default ON because
an unwritten CAM entry matching a grant is wrong under every reading;
`alloc_cam_park=0` reproduces the control without a rebuild.

Covered by rtl9607c-test step 19f (gpon_alloc_cam_test, 39/0), which
extracts this routine from this file so the case drives the driver's own
register sequence, and carries a STRUCTURAL arm -- ALLOC_CAM_CALL_SITES
and ALLOC_CAM_MARKED_UNUSED -- because a body-only test was green for
every week the routine shipped dead.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LVfiQ53nAqdGyxWC8z44Ex
RFC / draft. Adds AOT-5221Zy board support on top of this realtek-elnath
target (BRULE Herman), itself derived from Cortina-Access GPL-2.0 sources:
  - drivers/net/gpon in-kernel OMCI/PLOAM/GEM stack
  - cortina-omci-bridge stock-daemon seam + omci_stock service (off by default)
  - DSA support (cortina-ni-dsa, net/dsa/tag_cortina) + ethtool
  - AOT-5221Zy DTS and base-files
  - datapath RE work in cortina-gpon / cortina-ni-rx/tx

NOTE: this branch derives from an earlier snapshot of this tree, so the diff
reverts some current datapath work and overlaps the userspace OMCI path. Not
meant to merge as-is; opened for discussion. See PROVENANCE.md.

Signed-off-by: AK Sharma <[email protected]>
Reproducible build steps for the Zyxel AOT-5221Zy image (host prereqs, feeds,
target/subtarget/profile selection, output location, and RAM-boot how-to), plus
a pointer from README.md.

Signed-off-by: AK Sharma <[email protected]>
@AKoo7

AKoo7 commented Aug 22, 2026

Copy link
Copy Markdown
Author

alphaonex86 added a commit that referenced this pull request Sep 27, 2026
…nd stock raises an alarm off them

This tree's own rule is that a chip which cannot establish a counter reports
COULD NOT ASK, never 0, because a missing counter rendered as zero reads as a
device finding. ME 52 was serving zeros with nothing feeding them: our own code,
breaking our own rule.

It is also a DIVERGENCE FROM STOCK, not a style question. `nm -D -u` on
`mib_MacBridgePortPmMonitorHistoryData.so` (tier 2, unstripped) imports
`omci_pm_getcurrent_pptp_eth_uni`, `omci_pm_update_pptp_eth_uni`,
`MIB_GetPmCurrentBin`, `omci_pm_is_threshold_crossed` and `mib_alarm_table_add`
-- stock FEEDS these and raises a threshold-crossing alarm off them. And this
bench's captured OLT script Creates ME 52 four times with body `00 04`, a
threshold-data pointer, having Created ME 273/4 earlier: the OLT is ASKING for
that alarm and we answered zeros.

CORE tier, and it uses G.988's own vocabulary for the answer: a new counter
source whose `omci_attr_bytes()` returns NULL, so a Get leaves the bit out of
the response mask and the attribute lands in the ATTRIBUTES-FAILED word with
rc=9. The dense offsets are untouched -- `omci_me_dense_len(52)` is still
stock's 23 -- and attribute #1, interval-end-time, is deliberately NOT converted
because 0 is TRUE there: no interval has ended.

COST IN ME STORE SLOTS: ZERO. Ladder 4j re-run, 6/0, so the 65-of-128 budget
that cost this project a night is unmoved.

Not established and said so: where the raw numbers enter stock's PM subsystem.
`omci_pm_update_specified_ME` lives in `/bin/omci_app` and the only kernel door
is `getsockopt`'s undecoded optId space.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
alphaonex86 added a commit that referenced this pull request Oct 6, 2026
Operator 2026-09-30: "en version software puedes enviar OWRT-XXXXXXX donde
XXXXXXX es version corta del commit, y configurable". The SW-image versions
(ME 7 #1 both banks, and Circuit-Pack openwrt#4 through bank 0) no longer repeat the
vendor MIB's OMCI_SW_VER1/2: that described a firmware this unit no longer
runs.

- onu-identity.sh: owrt_version() = "OWRT-" + the first 7 hex digits of
  /etc/build-id (stamped by build_image.py on every build from the fork's
  HEAD), "+" appended when that build came from a dirty tree; no or malformed
  build-id -> nothing, and the driver keeps its build default.
- gpon_provision / Elnath gpon-identity: sw_ver1 and sw_ver2 take UCI
  gpon.identity.sw_ver1/sw_ver2 first (configurable per bank), else
  owrt_version -- never the vendor MIB. Every other field is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alphaonex86 added a commit that referenced this pull request Oct 6, 2026
…tock does

The lab HSGQ OLT showed the X100DG as "ISP ONU Type SFU" on our image and
HGU on stock, and the same image read either way depending on which
firmware had registered before it. Reverse-engineered from the OLT's own
gpondev (stripped ARM): gpon_ont_autoauth_profile runs MIB reset, MIB
upload, gpon_ont_isp_onu_capability -- a LOCAL-MIB read of class 0xfff9
mask 0xf000 into onu+0x540e (CTC cap) -- then gpon_ont_sync_capability,
whose class-329 count lands in onu+0x4ed4. The ont-info printer takes
the type from onu+0x5413 (65529 openwrt#3) when the CTC cap is set and only
otherwise counts VEIPs; a unit that uploads no 65529 leaves the previous
firmware's value in place.

Stock X100DG (omcicli mib get 65529, 2026-10-06): OperationId "CTC",
CtcSpecVer 0, OnuType 1 (HGU), TxPwrSupplyCtrl 2, CustomizedOnuType 1;
stock's mib_OnuCapability.so uploads #1..openwrt#4 and keeps openwrt#5 Get-only
(optionType & 0x31A). The core now models exactly that, and the X100DG
declares it (extra-me-instances <65529 0>); a board that does not
declare it answers a Get as before (result 0, every mask zero, as the
field X111W's stock does).

Live A/B on the X100DG, same OLT row: OnuType 0 -> the OLT read SFU;
OnuType 1 -> HGU. dev rtl9607c-test/omci_ctc_capability_test (6 checks)
pins the upload mask, the values and the undeclared answer; the type
and the hidden openwrt#5 are each mutation-proven by it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alphaonex86 added a commit that referenced this pull request Oct 19, 2026
…s Set no longer stops provisioning

ISP AXS's ZTE OLT (DC3, 2026-10-17), right after its MIB upload, writes ME 11
on every Ethernet UNI with mask 0x8140: #1 expected type 0 (autosense), openwrt#8 max
frame size 1632, openwrt#10 pause time 0. We modelled #1 read-only and openwrt#8/openwrt#10 as
constants settable only to the value served (1518, 0xffff), so the whole
atomic Set failed rc=9; the OLT answered with a MIB reset, retried once, then
kept the unit at O5 with no OMCI and deactivated it every ~50 s. Stock's own
writable set (0xb9fe) has all three.

Now, per instance: #1 accepts 0 or the type the port senses; openwrt#8 accepts
1518..2000 (what the NIC's 2048-octet RX buffer carries whole); openwrt#10 accepts
any value. Each is stored and served back by Get; a MIB reset restores
expected = sensed, 1518 and 0xffff, so the upload any OLT sees before writing
is unchanged. The switch is not reprogrammed for openwrt#8/openwrt#10: a non-default value
is COUNTED in attr_owed, as the held-but-unapplied table writes are.

dev's omci_masked_store_test replays the ZTE Set byte for byte on a two-port
panel; mutating the writable set reddens four arms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alphaonex86 added a commit that referenced this pull request Oct 31, 2026
onu_sn_set() flagged a re-range on EVERY write of the module param,
including a write of the value already in force -- and onu_sn compiles in
with this board's real serial.  So the userspace provisioning service
writing the same serial dropped a HEALTHY O5 back to O1 and re-ranged,
once per boot, for no identity change at all.

Measured on the X111W 2026-08-20, the board's own console:

  [ 8.056] ONU state O4 -> O5
  [ 9.656] ONU state O5 -> O1
  [ 9.656] SN reprovisioned (58504f4e39013867) -> re-ranging
  [16.060] re-range #1 -> O5 (outage ~6404 ms)

58504f4e39013867 is "XPON39013867" -- the serial the driver already held.
That is a ~6.4 s outage plus one extra ranging cycle per boot, and on a
splitter the churn is charged to every ONU sharing the PON port.

A re-range is the response to an IDENTITY CHANGE, so compare the PARSED
BYTES rather than the string: case and zero-padding differ without the
identity differing.  gpon_parse_sn_into() is split out so the comparison
runs through the SAME decoder the driver uses -- a second copy would drift
and make a real identity change look like a no-op.  A short string still
compares equal exactly when it leaves every byte alone, matching the
decoder's own "leave untouched what the string does not supply".

Covered by rtl9607c-test step 19e (gpon_sn_reprovision_test, 13/0), which
extracts the decoder and the comparison from this file so the case runs
the driver's own code, and asserts the structural fact no extracted
function can express: gpon_sn_changed is reachable only via
gpon_sn_differs().

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LVfiQ53nAqdGyxWC8z44Ex
alphaonex86 added a commit that referenced this pull request Oct 31, 2026
…nd stock raises an alarm off them

This tree's own rule is that a chip which cannot establish a counter reports
COULD NOT ASK, never 0, because a missing counter rendered as zero reads as a
device finding. ME 52 was serving zeros with nothing feeding them: our own code,
breaking our own rule.

It is also a DIVERGENCE FROM STOCK, not a style question. `nm -D -u` on
`mib_MacBridgePortPmMonitorHistoryData.so` (tier 2, unstripped) imports
`omci_pm_getcurrent_pptp_eth_uni`, `omci_pm_update_pptp_eth_uni`,
`MIB_GetPmCurrentBin`, `omci_pm_is_threshold_crossed` and `mib_alarm_table_add`
-- stock FEEDS these and raises a threshold-crossing alarm off them. And this
bench's captured OLT script Creates ME 52 four times with body `00 04`, a
threshold-data pointer, having Created ME 273/4 earlier: the OLT is ASKING for
that alarm and we answered zeros.

CORE tier, and it uses G.988's own vocabulary for the answer: a new counter
source whose `omci_attr_bytes()` returns NULL, so a Get leaves the bit out of
the response mask and the attribute lands in the ATTRIBUTES-FAILED word with
rc=9. The dense offsets are untouched -- `omci_me_dense_len(52)` is still
stock's 23 -- and attribute #1, interval-end-time, is deliberately NOT converted
because 0 is TRUE there: no interval has ended.

COST IN ME STORE SLOTS: ZERO. Ladder 4j re-run, 6/0, so the 65-of-128 budget
that cost this project a night is unmoved.

Not established and said so: where the raw numbers enter stock's PM subsystem.
`omci_pm_update_specified_ME` lives in `/bin/omci_app` and the only kernel door
is `getsockopt`'s undecoded optId space.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
alphaonex86 added a commit that referenced this pull request Oct 31, 2026
Operator 2026-09-30: "en version software puedes enviar OWRT-XXXXXXX donde
XXXXXXX es version corta del commit, y configurable". The SW-image versions
(ME 7 #1 both banks, and Circuit-Pack openwrt#4 through bank 0) no longer repeat the
vendor MIB's OMCI_SW_VER1/2: that described a firmware this unit no longer
runs.

- onu-identity.sh: owrt_version() = "OWRT-" + the first 7 hex digits of
  /etc/build-id (stamped by build_image.py on every build from the fork's
  HEAD), "+" appended when that build came from a dirty tree; no or malformed
  build-id -> nothing, and the driver keeps its build default.
- gpon_provision / Elnath gpon-identity: sw_ver1 and sw_ver2 take UCI
  gpon.identity.sw_ver1/sw_ver2 first (configurable per bank), else
  owrt_version -- never the vendor MIB. Every other field is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alphaonex86 added a commit that referenced this pull request Oct 31, 2026
…tock does

The lab HSGQ OLT showed the X100DG as "ISP ONU Type SFU" on our image and
HGU on stock, and the same image read either way depending on which
firmware had registered before it. Reverse-engineered from the OLT's own
gpondev (stripped ARM): gpon_ont_autoauth_profile runs MIB reset, MIB
upload, gpon_ont_isp_onu_capability -- a LOCAL-MIB read of class 0xfff9
mask 0xf000 into onu+0x540e (CTC cap) -- then gpon_ont_sync_capability,
whose class-329 count lands in onu+0x4ed4. The ont-info printer takes
the type from onu+0x5413 (65529 openwrt#3) when the CTC cap is set and only
otherwise counts VEIPs; a unit that uploads no 65529 leaves the previous
firmware's value in place.

Stock X100DG (omcicli mib get 65529, 2026-10-06): OperationId "CTC",
CtcSpecVer 0, OnuType 1 (HGU), TxPwrSupplyCtrl 2, CustomizedOnuType 1;
stock's mib_OnuCapability.so uploads #1..openwrt#4 and keeps openwrt#5 Get-only
(optionType & 0x31A). The core now models exactly that, and the X100DG
declares it (extra-me-instances <65529 0>); a board that does not
declare it answers a Get as before (result 0, every mask zero, as the
field X111W's stock does).

Live A/B on the X100DG, same OLT row: OnuType 0 -> the OLT read SFU;
OnuType 1 -> HGU. dev rtl9607c-test/omci_ctc_capability_test (6 checks)
pins the upload mask, the values and the undeclared answer; the type
and the hidden openwrt#5 are each mutation-proven by it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alphaonex86 added a commit that referenced this pull request Oct 31, 2026
…s Set no longer stops provisioning

ISP AXS's ZTE OLT (DC3, 2026-10-17), right after its MIB upload, writes ME 11
on every Ethernet UNI with mask 0x8140: #1 expected type 0 (autosense), openwrt#8 max
frame size 1632, openwrt#10 pause time 0. We modelled #1 read-only and openwrt#8/openwrt#10 as
constants settable only to the value served (1518, 0xffff), so the whole
atomic Set failed rc=9; the OLT answered with a MIB reset, retried once, then
kept the unit at O5 with no OMCI and deactivated it every ~50 s. Stock's own
writable set (0xb9fe) has all three.

Now, per instance: #1 accepts 0 or the type the port senses; openwrt#8 accepts
1518..2000 (what the NIC's 2048-octet RX buffer carries whole); openwrt#10 accepts
any value. Each is stored and served back by Get; a MIB reset restores
expected = sensed, 1518 and 0xffff, so the upload any OLT sees before writing
is unchanged. The switch is not reprogrammed for openwrt#8/openwrt#10: a non-default value
is COUNTED in attr_owed, as the held-but-unapplied table writes are.

dev's omci_masked_store_test replays the ZTE Set byte for byte on a two-port
panel; mutating the writable set reddens four arms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alphaonex86 added a commit that referenced this pull request Nov 28, 2026
…s not left to the 2 s stall watch

luna_hw_program() unmasks the RX interrupt, the bring-up then floods the CPU
port, and the hw_ready W1C ack clears the latch of a frame already in the ring
before request_irq(). That frame waited for the RX stall watch: every X111W boot
logged 'rx ring stalled: ring recovery #1' at ~10 s. luna_eth_hw_start() now ends
with luna_rxw_kick_poll(), the same NAPI kick the rekick timer uses, so the ring
is drained at once. The core already enables NAPI before request_irq().

Proof: luna_eth_open_test (dev half, given by --dev-tree) traces napi -> irq ->
kick, 32/32; deleting the kick, or moving napi_enable() after request_irq(),
turns 'NAPI enabled before the IRQ is claimed, then kicked' red (mutation row
rx_kick_after_irq).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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