From eb4a6ac27553d8304bf729dbae2d59aff8d6b4d9 Mon Sep 17 00:00:00 2001 From: d00f Date: Wed, 12 Aug 2026 15:13:15 +0200 Subject: [PATCH] stp: drop the bounds on the L2 flush and L2MC table waits The review asked for these to come out and the reasoning holds. A guard that gives up mid-transaction lets the code carry on with whatever the engine left behind, and that is what cost me an SPI clip twice. An unbounded wait on a wedged engine still hangs, but it hangs in a known place instead of writing garbage into the L2 table. BANK1 loses 45 bytes and xdata one. BANK2 and the common bank do not move. --- rtl837x_port.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/rtl837x_port.c b/rtl837x_port.c index f9168bf..7cff91e 100644 --- a/rtl837x_port.c +++ b/rtl837x_port.c @@ -28,8 +28,6 @@ extern __xdata struct machine_runtime machine_detected; __xdata uint32_t l2_head; -__xdata uint8_t l2mc_guard; - __xdata struct vlan_settings vlan_settings; void port_mirror_set(register uint8_t port, __xdata uint16_t rx_pmask, __xdata uint16_t tx_pmask) __banked @@ -324,10 +322,9 @@ void port_l2_forget_port(uint8_t port) __banked REG_SET(RTL837x_L2_TBL_FLUSH_CNF, 0x0); /* port-based, dynamic entries */ REG_SET(RTL837x_L2_TBL_FLUSH_CTRL, L2_TBL_FLUSH_EXEC | (((uint16_t)1) << port)); - l2mc_guard = 0; do { reg_read_m(RTL837x_L2_TBL_FLUSH_CTRL); - } while (sfr_data[1] && ++l2mc_guard); + } while (sfr_data[1]); } @@ -426,19 +423,17 @@ void port_l2_learned(void) __banked void port_l2mc_set(uint8_t mac_last, __xdata uint16_t vid, __xdata uint16_t pmask) __banked { - l2mc_guard = 0; do { reg_read_m(RTL837X_TBL_CTRL); - } while ((sfr_data[3] & TBL_EXECUTE) && ++l2mc_guard); + } while (sfr_data[3] & TBL_EXECUTE); REG_WRITE(RTL837x_TBL_DATA_IN_A, 0xc2, 0x00, 0x00, mac_last); REG_WRITE(RTL837x_TBL_DATA_IN_B, 0x20 | (vid >> 8) | ((pmask & 0x3) << 6), vid, 0x01, 0x80); REG_WRITE(RTL837x_TBL_DATA_IN_C, 0, 0, 0, pmask >> 2); REG_WRITE(RTL837X_TBL_CTRL, 0, 0, TBL_L2_UNICAST, TBL_WRITE | TBL_EXECUTE); - l2mc_guard = 0; do { reg_read_m(RTL837X_TBL_CTRL); - } while ((sfr_data[3] & TBL_EXECUTE) && ++l2mc_guard); + } while (sfr_data[3] & TBL_EXECUTE); }