port: show how many MAC addresses each port has learned

The switch keeps a count of the dynamic L2 entries learned on every
port in L2_LRN_PORT_CONSTRT_CNT (0x53ac + 4 * port, 13 bits). `stat`
prints it in a new MACs column and /status.json carries it as "macs".

On a SWTGW218AS the count matched the L2 table port by port, static
entries are not included, and taking a port down drops it to 0.
This commit is contained in:
DrDoof committed 2026-10-10 01:11:11 +02:00
1 parent e67c928eb7
commit 706dea63a2
4 files changed
+27 -1

No files matched your search

+4 -1
View File
@@ -510,7 +510,7 @@ void port_media_show(uint8_t port) __banked
void port_stats_print(void) __banked
{
print_string("\nPort\tState\tLink\tTxGood\t\tTxBad\t\tRxGood\t\tRxBad\n");
print_string("\nPort\tState\tLink\tTxGood\t\tTxBad\t\tRxGood\t\tRxBad\t\tMACs\n");
for (uint8_t i = machine.min_port; i <= machine.max_port; i++) {
print_phys_port(i); write_char('\t');
@@ -584,6 +584,9 @@ void port_stats_print(void) __banked
STAT_GET(STAT_COUNTER_ERR_PKTS, i);
print_reg(RTL837X_STAT_V_HIGH); write_char('\t');
reg_read(RTL837X_L2_LRN_PORT_CONSTRT_CNT + (i << 2));
itoa_short(SFR_DATA_U16 & L2_LRN_PORT_CNT_MASK);
print_string("\n");
}
}