stp: take the review notes on types and register reads

stp_enabled is a flag, so say bool. cmpBytes() returns a comparison
result, so say int8_t. The three busy waits this branch adds read the
status straight out of the SFR instead of copying four bytes to xdata
first.
This commit is contained in:
d00f
2026-08-31 21:50:19 +02:00
parent bd06f7f5e5
commit c0d9bf7f0d
5 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -26,7 +26,7 @@
#pragma constseg BANK2 #pragma constseg BANK2
extern __code struct machine machine; extern __code struct machine machine;
extern __xdata uint8_t stp_enabled; extern __xdata bool stp_enabled;
extern __code uint8_t log_to_phys_port[9]; extern __code uint8_t log_to_phys_port[9];
extern volatile __xdata uint32_t ticks; extern volatile __xdata uint32_t ticks;
+1 -1
View File
@@ -119,7 +119,7 @@ struct flash_region_t {
extern __xdata char port_names[9][PORT_NAME_SIZE]; extern __xdata char port_names[9][PORT_NAME_SIZE];
extern __xdata uint8_t stp_enabled; extern __xdata bool stp_enabled;
/* System hostname (device identity). Set via `hostname <text>` and the System /* System hostname (device identity). Set via `hostname <text>` and the System
* Settings page, reported in /information.json. Other modules (e.g. LLDP, which * Settings page, reported in /information.json. Other modules (e.g. LLDP, which
+6 -6
View File
@@ -323,8 +323,8 @@ void port_l2_forget_port(uint8_t port) __banked
REG_SET(RTL837x_L2_TBL_FLUSH_CTRL, L2_TBL_FLUSH_EXEC | (((uint16_t)1) << port)); REG_SET(RTL837x_L2_TBL_FLUSH_CTRL, L2_TBL_FLUSH_EXEC | (((uint16_t)1) << port));
do { do {
reg_read_m(RTL837x_L2_TBL_FLUSH_CTRL); reg_read(RTL837x_L2_TBL_FLUSH_CTRL);
} while (sfr_data[1]); } while (SFR_DATA_16);
} }
@@ -421,16 +421,16 @@ void port_l2_learned(void) __banked
void port_l2mc_set(uint8_t mac_last, __xdata uint16_t vid, __xdata uint16_t pmask) __banked void port_l2mc_set(uint8_t mac_last, __xdata uint16_t vid, __xdata uint16_t pmask) __banked
{ {
do { do {
reg_read_m(RTL837X_TBL_CTRL); reg_read(RTL837X_TBL_CTRL);
} while (sfr_data[3] & TBL_EXECUTE); } while (SFR_DATA_0 & TBL_EXECUTE);
REG_WRITE(RTL837x_TBL_DATA_IN_A, 0xc2, 0x00, 0x00, mac_last); 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_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_DATA_IN_C, 0, 0, 0, pmask >> 2);
REG_WRITE(RTL837X_TBL_CTRL, 0, 0, TBL_L2_UNICAST, TBL_WRITE | TBL_EXECUTE); REG_WRITE(RTL837X_TBL_CTRL, 0, 0, TBL_L2_UNICAST, TBL_WRITE | TBL_EXECUTE);
do { do {
reg_read_m(RTL837X_TBL_CTRL); reg_read(RTL837X_TBL_CTRL);
} while (sfr_data[3] & TBL_EXECUTE); } while (SFR_DATA_0 & TBL_EXECUTE);
} }
+1 -1
View File
@@ -254,7 +254,7 @@ static void stp_record_designated(uint8_t port) __reentrant
/* Lexicographic compare of n bytes. A MAC is 6 of them; a Bridge Identifier /* Lexicographic compare of n bytes. A MAC is 6 of them; a Bridge Identifier
* is 8, the two priority octets ahead of the MAC, compared as one unsigned * is 8, the two priority octets ahead of the MAC, compared as one unsigned
* number per 802.1D. */ * number per 802.1D. */
signed char cmpBytes(__xdata uint8_t *m1, __xdata uint8_t *m2, uint8_t n) __reentrant int8_t cmpBytes(__xdata uint8_t *m1, __xdata uint8_t *m2, uint8_t n) __reentrant
{ {
for (uint8_t i = 0; i < n; i++) { for (uint8_t i = 0; i < n; i++) {
if (m1[i] == m2[i]) if (m1[i] == m2[i])
+1 -1
View File
@@ -121,7 +121,7 @@ __xdata uint16_t management_vlan;
__xdata bool frame_tagged; __xdata bool frame_tagged;
__xdata uint8_t tx_seq; __xdata uint8_t tx_seq;
__xdata uint8_t stp_enabled; __xdata bool stp_enabled;
__xdata uint8_t igmpEnabled; __xdata uint8_t igmpEnabled;
__xdata char hostname[24]; /* device hostname, default set at boot, see rtl837x_common.h */ __xdata char hostname[24]; /* device hostname, default set at boot, see rtl837x_common.h */