Add backend support for bandwidth control

This commit is contained in:
logicog
2026-03-08 20:55:50 +01:00
parent 1374272db6
commit 7949975191
3 changed files with 47 additions and 0 deletions
+2
View File
@@ -586,6 +586,8 @@ void httpd_appcall(void)
send_counters(q[20]-'0');
} else if (is_word(q, "/eee.json")) {
send_eee();
} else if (is_word(q, "/bandwidth.json")) {
send_bandwidth();
} else if (is_word(q, "/l2.json")) {
parse_short(q + 13); // e.g.: /l2.json?idx=10
send_l2(short_parsed);
+44
View File
@@ -546,6 +546,50 @@ void send_eee(void)
}
}
void send_bandwidth(void)
{
dbg_string("send_bandwidth called\n");
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
char_to_html('[');
for (uint8_t i = machine.min_port; i <= machine.max_port; i++) {
slen += strtox(outbuf + slen, "{\"portNum\":");
itoa_html(machine.log_to_phys_port[i]);
slen += strtox(outbuf + slen, ",\"iLimited\":");
reg_read_m(RTL837X_IGBW_PORT_CTRL + i * 4);
if (sfr_data[1] & 0x10)
char_to_html('1');
else
char_to_html('0');
slen += strtox(outbuf + slen, ",\"iBW\":\"");
byte_to_html(sfr_data[1] & 0x0f);
byte_to_html(sfr_data[2]);
byte_to_html(sfr_data[3]);
slen += strtox(outbuf + slen, "\",\"iFC\":");
if (reg_bit_test(RTL837X_IGBW_PORT_FC_CTRL, i))
char_to_html('1');
else
char_to_html('0');
reg_read_m(RTL837X_EGBW_PORT_CTRL + i * 1024);
slen += strtox(outbuf + slen, ",\"eLimited\":");
if (sfr_data[1] & 0x10)
char_to_html('1');
else
char_to_html('0');
slen += strtox(outbuf + slen, ",\"eBW\":\"");
byte_to_html(sfr_data[1] & 0x0f);
byte_to_html(sfr_data[2]);
byte_to_html(sfr_data[3]);
char_to_html('"');
char_to_html('}');
if (i < machine.max_port)
char_to_html(',');
else
char_to_html(']');
}
}
void send_mtu(void)
{
dbg_string("send_mtu called\n");
+1
View File
@@ -5,6 +5,7 @@ void send_counters(char port);
void send_status(void);
void send_vlan(uint16_t vlan);
void send_basic_info(void);
void send_bandwidth(void);
void send_eee(void);
void send_l2(uint16_t idx);
void l2_delete(uint16_t idx);