fix-link-speed

This commit is contained in:
chriz
2026-02-10 23:17:04 +01:00
parent 0099c2a03a
commit 859a50bd82
3 changed files with 42 additions and 12 deletions
+14 -2
View File
@@ -627,12 +627,24 @@ void send_status(void)
slen += strtox(outbuf + slen, ",\"link\":"); slen += strtox(outbuf + slen, ",\"link\":");
uint8_t b = 0;
// Determine link state
reg_read_m(RTL837X_REG_LINKS_STS);
if(!((sfr_data[(i / 8) + 1] >> (i % 8 ) & 1)))
{
b = 0; //link down
}
else
{
//Determine link speed
if (i < 8) if (i < 8)
reg_read_m(RTL837X_REG_LINKS); reg_read_m(RTL837X_REG_LINKS);
else else
reg_read_m(RTL837X_REG_LINKS_89); reg_read_m(RTL837X_REG_LINKS_89);
uint8_t b = sfr_data[3 - ((i & 7) >> 1)];
b = (i & 1) ? b >> 4 : b & 0xf; b = sfr_data[3 - ((i & 7) >> 1)];
b = ((i & 1) ? b >> 4 : b & 0xf) + 1;
}
char_to_html('0' + b); char_to_html('0' + b);
STAT_GET(STAT_COUNTER_TX_PKTS, i); STAT_GET(STAT_COUNTER_TX_PKTS, i);
+18 -2
View File
@@ -369,15 +369,28 @@ void port_stats_print(void) __banked
} }
} }
uint8_t b = 0;
// Determine link state
reg_read_m(RTL837X_REG_LINKS_STS);
if(!((sfr_data[(i / 8) + 1] >> ( i % 8 ) & 1)))
{
b = 99;
}
else
{
if (i < 8) if (i < 8)
reg_read_m(RTL837X_REG_LINKS); reg_read_m(RTL837X_REG_LINKS);
else else
reg_read_m(RTL837X_REG_LINKS_89); reg_read_m(RTL837X_REG_LINKS_89);
uint8_t b = sfr_data[3 - ((i & 7) >> 1)];
b = sfr_data[3 - ((i & 7) >> 1)];
b = (i & 1) ? b >> 4 : b & 0xf; b = (i & 1) ? b >> 4 : b & 0xf;
}
switch (b) { switch (b) {
case 0: case 0:
print_string("Down\t"); print_string("10M\t");
break; break;
case 1: case 1:
print_string("100M\t"); print_string("100M\t");
@@ -391,6 +404,9 @@ void port_stats_print(void) __banked
case 5: case 5:
print_string("2.5G\t"); print_string("2.5G\t");
break; break;
case 99:
print_string("Down\t");
break;
default: default:
print_string("Up\t"); print_string("Up\t");
break; break;
+2
View File
@@ -66,6 +66,8 @@
#define RTL837X_REG_LINKS 0x63f0 #define RTL837X_REG_LINKS 0x63f0
#define RTL837X_REG_LINKS_89 0x63f4 #define RTL837X_REG_LINKS_89 0x63f4
#define RTL837X_REG_LINKS_STS 0x63E8
/* Each nibble encodes the link state of a port. /* Each nibble encodes the link state of a port.
Port 0 appears to be the CPU port Port 0 appears to be the CPU port
The RTL8372 serves ports 4-7, port 3 is the RTL8221 The RTL8372 serves ports 4-7, port 3 is the RTL8221