Expand description
Traffic counters for the PROP_STAT_* properties.
StatsLedger is the one place a device tallies what its radio did.
It sits in a static and is written by whichever parts of the stack
are in a position to see each event exactly once — on a firmware that
is the radio multiplexer for frames on the air, the PHY runner for
receptions the demodulator rejected, and the device node’s pump for
what the MAC decided — and it is read by the ULCP session, by the
device’s own display, and by anything else that wants the same
numbers rather than its own.
§Every producer adds
Each counter is a pair of u32s: a raw tally that only ever grows
(wrapping, never resetting) and a base that a host’s write moves.
What a host reads is raw - base, and clearing a counter is
base = raw.
Zeroing raw instead would be wrong twice over. Two of the producers
mirror tallies the ledger does not own — the MAC’s counters and the
PHY’s — so a zeroed cell would be overwritten by the next mirror pass
and the clear would visibly bounce back; and a cell another task is
concurrently fetch_add-ing cannot be zeroed without losing whatever
landed in between. Mirroring producers therefore feed the difference
since their last pass, which makes every write to the ledger an
addition and leaves the base as the only thing a reset touches.
Counters wrap rather than saturate. Wrapping arithmetic is what makes
raw - base right across the boundary; a saturating counter would
pin at the maximum and never move again, which is worse than starting
over.
Structs§
- Mirror
- A mirror of a monotone tally kept somewhere else.
- Stats
Ledger - The shared traffic ledger.
Enums§
- Counter
- The counters a device keeps.
Constants§
- COUNTERS
- How many counters a ledger holds.