mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
handle_sfp() called sfp_module_read() as soon as it saw a module appear, and that path opened with delay(100). delay() spins on PCON until the tick counter runs down, so the main loop stood still for 100 ticks - half a second at SYS_TICK_HZ 200. Nothing else ran in that window: no STP, no LACP, no packet handling. A diagnostic build measured the sfp phase at up to 107 ticks, the longest stall of any phase in the loop. Remember when the module showed up and let the loop continue. The I2C read happens on a later pass, once the wake-up period has elapsed. Pulling a module cancels a pending read, and a failed read still restores the detect bit, so the existing retry-on-the-next-poll behaviour is unchanged. The comparison is written out rather than using a helper so that this does not depend on anything outside the current tree. The pending flag is an array indexed by slot, like the other per-slot state in this file. Cost on SWTGW218AS, measured against the branch point: BANK3 11173 -> 11264, CSEG, BANK1 and BANK2 unchanged, plus 4 bytes of xdata.
22 lines
669 B
C
22 lines
669 B
C
#ifndef SFP_H
|
|
#define SFP_H
|
|
|
|
#define SFP_WAKE_TICKS 100
|
|
|
|
extern __xdata uint8_t sfp_pins_last;
|
|
extern __xdata char sfp_module_vendor[2][17];
|
|
extern __xdata char sfp_module_model[2][17];
|
|
extern __xdata char sfp_module_serial[2][17];
|
|
extern __xdata uint8_t sfp_options[2];
|
|
extern __xdata uint8_t sfp_speed[2];
|
|
extern __xdata uint8_t sfp_quirks[2];
|
|
|
|
bool sfp_print_info(uint8_t sfp) __banked;
|
|
bool sfp_read_field(__xdata char *dst, uint8_t sfp, uint8_t start, uint8_t length) __banked __reentrant;
|
|
bool sfp_get_info(uint8_t sfp) __banked;
|
|
void sfp_apply_quirks(uint8_t sfp) __banked __reentrant;
|
|
void setup_sfp_gpio(void) __banked;
|
|
void handle_sfp(void) __banked;
|
|
|
|
#endif
|