port: report link role and negotiated pause per port

Two per-port MAC status registers that nothing in the firmware reads:
0x6408 says which end is master on a BASE-T link, 0x63FC and 0x6400 say
whether pause was negotiated in each direction. port <n> show prints
both at the end.

The read sits in rtl837x_port.c rather than phy_show(), because these
are MAC registers and phy_show() is skipped for SFP ports. Master/slave
keys off machine.is_sfp[] so it stays off the fibre ports, where the
notion does not apply.

Bit N of each register is chip port N, which is not how
RTL837X_REG_LINKS_STS indexes its bytes a few lines above in the same
header.
This commit is contained in:
d00f committed 2026-09-22 20:28:54 +02:00
1 parent 55431b39f6
commit 340fdd97e5
4 files changed
+40

No files matched your search

+32
View File
@@ -487,6 +487,38 @@ void port_l2_setup(void) __banked
}
void port_media_show(uint8_t port) __banked
{
uint8_t pause;
if (!machine.is_sfp[port]) {
reg_read_m(RTL837X_REG_LINKS_STS);
if (sfr_data[(port / 8) + 1] >> (port % 8) & 1) {
print_string("Link role: ");
reg_read_m(RTL837X_MAC_MSTR_SLV_STS);
if (sfr_data[3 - (port >> 3)] & (1 << (port & 7)))
print_string("master\n");
else
print_string("slave\n");
}
}
print_string("Pause negotiated:");
reg_read_m(RTL837X_MAC_TX_PAUSE_STS);
pause = sfr_data[3 - (port >> 3)] & (1 << (port & 7));
if (pause)
print_string(" TX");
reg_read_m(RTL837X_MAC_RX_PAUSE_STS);
if (sfr_data[3 - (port >> 3)] & (1 << (port & 7))) {
print_string(" RX");
pause = 1;
}
if (!pause)
print_string(" none");
write_char('\n');
}
void port_stats_print(void) __banked
{
print_string("\nPort\tState\tLink\tTxGood\t\tTxBad\t\tRxGood\t\tRxBad\n");