mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Add support for configuring SFP modules speeds
This commit is contained in:
+58
-12
@@ -48,6 +48,8 @@ __xdata uint16_t vlan_ptr;
|
||||
__xdata char port_names[9][PORT_NAME_SIZE];
|
||||
|
||||
extern __xdata uint16_t management_vlan;
|
||||
extern __xdata uint8_t sfp_speed[2];
|
||||
extern __xdata uint8_t sfp_pins_last;
|
||||
__xdata uint8_t gpio_last_value[8] = { 0 };
|
||||
|
||||
// Temporatly for str to hex convertion value.
|
||||
@@ -748,6 +750,61 @@ void sfp_print_measurements(uint8_t sfp)
|
||||
}
|
||||
|
||||
|
||||
void parse_sfp(void)
|
||||
{
|
||||
uint8_t slot;
|
||||
|
||||
if (cmd_words_len != 1 && cmd_words_len != 3)
|
||||
goto err;
|
||||
|
||||
if (cmd_words_len == 1) {
|
||||
for (slot = 0; slot < machine.n_sfp; slot++) {
|
||||
print_string("\nSlot "); write_char('1' + slot);
|
||||
if (gpio_pin_test(machine.sfp_port[slot].pin_detect)) {
|
||||
print_string(" - empty\n");
|
||||
continue;
|
||||
}
|
||||
print_string(" - Rate: "); print_byte(sfp_read_reg(slot, 12));
|
||||
print_string(" Encoding: "); print_byte(sfp_read_reg(slot, 11));
|
||||
write_char('\n');
|
||||
sfp_print_info(slot);
|
||||
sfp_print_measurements(slot);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (cmd_buffer[cmd_words_b[1]] < '1' || cmd_buffer[cmd_words_b[1]] > '2' || cmd_buffer[cmd_words_b[1] + 1] != ' ' ) {
|
||||
print_string("Illegal SFP slot number\n");
|
||||
return;
|
||||
}
|
||||
slot = cmd_buffer[cmd_words_b[1]] - '1';
|
||||
if (slot >= machine.n_sfp) {
|
||||
print_string("SFP slot not present\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd_compare(2, "10g")) {
|
||||
print_string(" 10G\n");
|
||||
sfp_speed[slot] = SFP_SPEED_10G;
|
||||
} else if (cmd_compare(2, "2g5")) {
|
||||
print_string(" 2.5G\n");
|
||||
sfp_speed[slot] = SFP_SPEED_2G5;
|
||||
} else if (cmd_compare(2, "1g")) {
|
||||
print_string(" 1G\n");
|
||||
sfp_speed[slot] = SFP_SPEED_1G;
|
||||
} else if (cmd_compare(2, "auto")) {
|
||||
print_string(" AUTO\n");
|
||||
sfp_speed[slot] = SFP_SPEED_AUTO;
|
||||
} else {
|
||||
goto err;
|
||||
}
|
||||
sfp_pins_last |= 0x1 << (slot << 2);
|
||||
handle_sfp();
|
||||
return;
|
||||
err:
|
||||
print_string("\nUsage:\n\tsfp\n\tsfp [1|2] [1g|2g5|10g]\n");
|
||||
}
|
||||
|
||||
|
||||
void parse_regget(void)
|
||||
{
|
||||
uint16_t reg = 0;
|
||||
@@ -1355,18 +1412,7 @@ void cmd_parser(void) __banked
|
||||
print_string("\nRESET\n\n");
|
||||
reset_chip();
|
||||
} else if (cmd_compare(0, "sfp")) {
|
||||
print_string("\nSlot 1 - Rate: "); print_byte(sfp_read_reg(0, 12));
|
||||
print_string(" Encoding: "); print_byte(sfp_read_reg(0, 11));
|
||||
print_string("\n");
|
||||
sfp_print_info(0);
|
||||
sfp_print_measurements(0);
|
||||
if (machine.n_sfp == 2) {
|
||||
print_string("\nSlot 2 - Rate: "); print_byte(sfp_read_reg(1, 12));
|
||||
print_string(" Encoding: "); print_byte(sfp_read_reg(1, 11));
|
||||
print_string("\n");
|
||||
sfp_print_info(1);
|
||||
sfp_print_measurements(1);
|
||||
}
|
||||
parse_sfp();
|
||||
} else if (cmd_compare(0, "stat")) {
|
||||
port_stats_print();
|
||||
} else if (cmd_compare(0, "flash") && cmd_words_len == 2) {
|
||||
|
||||
Reference in New Issue
Block a user