stp: trim the comments, and put one back on the variable it describes

Review asked for this across the other commits too. Gone are the blocks
that restate what doc/stp.md already says, the ones that explain what an
embedded programmer already knows, and one that had gone stale inside this
very branch: the CLI summary above stp_parse still described "cost <0-255>
(x1000)" while the parser has taken the raw 0 to 200000000 for some time,
and it never learned about p2p or trk at all. A usage list next to the
parser is the kind of thing that rots first, so it is out rather than
updated.

The review flagged one comment saying a variable is in xdata because the
internal RAM overlay is full, on the grounds that it may stop being true.
Four more of the same kind were in these files and are out as well, one of
them pointing at a file that does not exist in this branch at all. The
declarations still say __xdata, which is the part a reader needs.

Also out: the note on why three helpers are __reentrant, which was really
a paragraph about two bytes of DSEG, and the measurement story behind the
tick divider, which belongs with the other timer numbers in doc/stp.md.

One comment was not stale but simply wrong. "max BPDUs per port per second"
sat on stp_failsafe_tripped, having slid down two lines when the two
failsafe variables were inserted above it. It describes stp_txhold and is
back there now.

Short factual labels stay: they sit next to the magic number they explain
and the codebase uses them throughout. The generated code is byte for byte
what it was before this commit, both banks and xdata unchanged.
This commit is contained in:
d00f
2026-08-18 23:29:11 +02:00
committed by d00f
parent 4a78b2dc8c
commit 1ba1224644
3 changed files with 10 additions and 74 deletions
+3 -7
View File
@@ -9,11 +9,7 @@ void stp_off(void) __banked;
void stp_parse(void) __banked __reentrant; /* "stp ..." CLI handler (cmd_parser delegates here) */
void stp_defaults(void) __banked; /* boot init: 802.1D/w default configuration */
/* Tick rate of stp_timers(): the main loop idles on the 200 Hz system tick
* and rtlplayground.c calls us every (STP_TICK_DIVIDER + 1) = 4th pass.
* Measured on hardware: hello 2 s produced BPDUs exactly 2.560 s apart with
* the previous value of 64, i.e. 20 ms per tick - every configured timer ran
* 28 % long. Shared with the web UI, which ages the same counters. */
/* Tick rate of stp_timers(), also used by the web UI. */
#define STP_HZ 50
/* Bridge identifier as carried in a BPDU (priority, extension, MAC). */
@@ -30,9 +26,9 @@ extern __xdata uint8_t stp_hello_s; /* hello time, 1-10 s (default 2) */
extern __xdata uint8_t stp_maxage_s; /* max age, 6-40 s (default 20) */
extern __xdata uint8_t stp_fwddelay_s; /* forward delay, 4-30 s (default 15); our listen period */
extern __xdata uint8_t stp_rstp; /* 1 = RSTP BPDUs (v2), 0 = STP-compatible Config BPDUs (v0) */
extern __xdata uint8_t stp_txhold;
extern __xdata uint8_t stp_txhold; /* max BPDUs per port per second (default 6) */
extern __xdata uint8_t stp_failsafe_s; /* mgmt watchdog, seconds (0 = off) */
extern __xdata uint8_t stp_failsafe_tripped; /* max BPDUs per port per second (default 6) */
extern __xdata uint8_t stp_failsafe_tripped;
/* Per-port config/status flags (stp_pflags[]) */
#define STP_PF_ENABLED 0x01 /* port participates in STP (default on) */