Add mtu command

This commit is contained in:
logicog
2025-12-22 23:28:50 +01:00
parent 67439efd2b
commit 67fbad38ce
2 changed files with 35 additions and 0 deletions
+33
View File
@@ -457,6 +457,37 @@ void parse_port(void)
}
void parse_mtu(void)
{
__xdata uint16_t mtu;
uint8_t p;
print_string("\nMTU ");
if (cmd_words_b[1] > 0 && cmd_compare(1, "show")) {
for (p = machine.min_port; p <= machine.max_port; p++) {
reg_read_m(RTL8373_REG_MAC_L2_PORT_MAX_LEN + ((uint16_t) p << 8));
mtu = SFR_DATA_U16 & 0x3fff;
print_string("Port "); print_byte(machine.log_to_phys_port[p]);
print_string(" MTU: 0x"); print_short(mtu); write_char('\n');
}
}
p = cmd_buffer[cmd_words_b[1]] - '1';
p = machine.phys_to_log_port[p];
print_byte(p);
if (cmd_words_b[2] <= 0) {
print_string("mtu [port] [size]");
return;
}
atoi_short(&mtu, cmd_words_b[2]);
if (mtu > 0x3fff) {
print_string("Maximum MTU is 16383\n");
return;
}
REG_WRITE(RTL8373_REG_MAC_L2_PORT_MAX_LEN + ((uint16_t) p << 8), (mtu >> 10) & 0xf, (mtu >> 2) & 0xff,
((mtu & 0x3) << 6) | ((mtu >> 8) & 0x3f), mtu & 0xff);
}
void sfp_print_measurements(uint8_t sfp)
{
print_string("Options: "); print_byte(sfp_read_reg(sfp, 92)); write_char('\n');
@@ -730,6 +761,8 @@ void cmd_parser(void) __banked
flash_write_bytes(flash_buf);
} else if (cmd_compare(0, "port") && cmd_words_b[1] > 0) {
parse_port();
} else if (cmd_compare(0, "mtu") && cmd_words_b[1] > 0) {
parse_mtu();
} else if (cmd_compare(0, "ip")) {
print_string("Got ip command: ");
if (!parse_ip(cmd_words_b[1]))
+2
View File
@@ -136,6 +136,8 @@
#define RTL837x_L2_TBL_FLUSH_CNF 0x53dc
#define RTL837X_L2_LRN_PORT_CONSTRAINT 0x5384
#define RTL837X_L2_LRN_PORT_CONSTRT_ACT 0x4f80
#define RTL8373_REG_MAC_L2_PORT_MAX_LEN 0x1250
/*
* VLAN configuration
*/