mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Added print_port() helper to print physical port number.
This commit is contained in:
+8
-13
@@ -27,7 +27,6 @@
|
||||
|
||||
extern __code struct machine machine;
|
||||
extern __xdata uint8_t stpEnabled;
|
||||
extern __code uint8_t log_to_phys_port[9];
|
||||
|
||||
extern volatile __xdata uint32_t ticks;
|
||||
extern volatile __xdata uint8_t sfr_data[4];
|
||||
@@ -356,7 +355,7 @@ void parse_lag(void)
|
||||
print_string(" member ports: ");
|
||||
for (uint8_t j = 0; j < 10; j++) {
|
||||
if (members & 1) {
|
||||
write_char('0' + machine.log_to_phys_port[j]);
|
||||
print_port(j);
|
||||
write_char(' ');
|
||||
}
|
||||
members >>= 1;
|
||||
@@ -545,10 +544,7 @@ void parse_isolate(void)
|
||||
members = port_isolation_get(port_configured);
|
||||
for (uint8_t i = 0; i < 10; i++) {
|
||||
if (members & 1) {
|
||||
if (i < 9)
|
||||
write_char(machine.log_to_phys_port[i] + '0');
|
||||
else
|
||||
print_string("CPU");
|
||||
print_port(i);
|
||||
write_char(' ');
|
||||
}
|
||||
members >>= 1;
|
||||
@@ -613,7 +609,7 @@ void parse_ingress(void)
|
||||
// Setting mode for all ports at once
|
||||
for (log_port = machine.min_port; log_port <= machine.max_port; log_port++) {
|
||||
if (!port_ingress_filter(log_port, mode)) {
|
||||
print_string("Error setting ingress filter for port "); print_byte(machine.log_to_phys_port[log_port]); write_char('\n');
|
||||
print_string("Error setting ingress filter for port "); print_port(log_port); write_char('\n');
|
||||
return;
|
||||
}
|
||||
print_string("All ports ingress filter set to: ");
|
||||
@@ -622,7 +618,6 @@ void parse_ingress(void)
|
||||
} else {
|
||||
for(uint8_t w = 1; w < cmd_words_len; w++) {
|
||||
idx = cmd_words_b[w];
|
||||
char p = cmd_buffer[idx];
|
||||
uint8_t ret = cmd_parse_port(idx);
|
||||
if (ret != 1) {
|
||||
print_string("Invalid physical port number\n");
|
||||
@@ -632,14 +627,14 @@ void parse_ingress(void)
|
||||
idx += ret;
|
||||
|
||||
if (!vlan_ingress_mode_parse(cmd_buffer[idx++], &mode) || !cmd_is_space_or_null(idx)) {
|
||||
print_string("Invalid ingress mode for port "); write_char(p); print_string(" in ingress command\n");
|
||||
print_string("Invalid ingress mode for port "); print_port(log_port); print_string(" in ingress command\n");
|
||||
goto err;
|
||||
}
|
||||
if (!port_ingress_filter(log_port, mode)) {
|
||||
print_string("Error setting ingress filter for port "); write_char(p); write_char('\n');
|
||||
print_string("Error setting ingress filter for port "); print_port(log_port); write_char('\n');
|
||||
return;
|
||||
}
|
||||
print_string("Port "); write_char(p);
|
||||
print_string("Port "); print_port(log_port);
|
||||
print_string(" ingress filter set to: ");
|
||||
print_port_ingress_filter_mode(mode); write_char('\n');
|
||||
}
|
||||
@@ -664,7 +659,7 @@ void parse_mirror(void)
|
||||
print_string("NOT Enabled: ");
|
||||
}
|
||||
print_string("Mirroring port: ");
|
||||
write_char('0' + machine.log_to_phys_port[mPort >> 1]);
|
||||
print_port(mirroring_port);
|
||||
reg_read_m(RTL837x_MIRROR_CONF);
|
||||
uint16_t m = sfr_data[0];
|
||||
m = (m << 8) | sfr_data[1];
|
||||
@@ -818,7 +813,7 @@ void parse_mtu(void)
|
||||
for (p = machine.min_port; p <= machine.max_port; p++) {
|
||||
reg_read_m(RTL8373_REG_MAC_L2_PORT_MAX_LEN + ((uint16_t) p << 8));
|
||||
uint16_t mtu = SFR_DATA_U16 & 0x3fff;
|
||||
print_string("Port "); print_byte(machine.log_to_phys_port[p]);
|
||||
print_string("Port "); print_port(p);
|
||||
write_char(' '); print_short(mtu); write_char('\n');
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -135,6 +135,7 @@ void itoa(uint8_t v);
|
||||
void print_sfr_data(void);
|
||||
void print_phy_data(void);
|
||||
void print_cmd_prompt(void);
|
||||
void print_port(uint8_t port);
|
||||
void phy_write_mask(uint16_t phy_mask, uint8_t dev_id, uint16_t reg, uint16_t v);
|
||||
void phy_write(uint8_t phy_id, uint8_t dev_id, uint16_t reg, uint16_t v);
|
||||
void phy_read(uint8_t phy_id, uint8_t dev_id, uint16_t reg);
|
||||
|
||||
+2
-2
@@ -262,7 +262,7 @@ void phy_set_speed(void) __banked
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
print_string("Setting port "); write_char(machine.log_to_phys_port[phy_settings.port] + '0');
|
||||
print_string("Setting port "); print_port(phy_settings.port);
|
||||
if (machine.n_10g && phy_settings.port == 3)
|
||||
phy_settings.is10g_port = 1;
|
||||
if (machine.n_10g == 2 && phy_settings.port == 8)
|
||||
@@ -381,7 +381,7 @@ void phy_set_duplex(void) __banked
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
print_string("Setting port "); write_char(machine.log_to_phys_port[phy_settings.port] + '0');
|
||||
print_string("Setting port "); print_port(phy_settings.port);
|
||||
if (phy_settings.duplex)
|
||||
print_string(" to full duplex");
|
||||
else
|
||||
|
||||
+4
-17
@@ -390,10 +390,7 @@ void port_l2_learned(void) __banked
|
||||
print_string("\tlearned\t");
|
||||
|
||||
port |= (sfr_data[3] & 0x3) << 2;
|
||||
if (port < 9)
|
||||
write_char(machine.log_to_phys_port[port] + '0');
|
||||
else
|
||||
print_string("CPU");
|
||||
print_port(port);
|
||||
}
|
||||
|
||||
entry++;
|
||||
@@ -431,7 +428,7 @@ void port_stats_print(void) __banked
|
||||
{
|
||||
print_string("\nPort\tState\tLink\tTxGood\t\tTxBad\t\tRxGood\t\tRxBad\n");
|
||||
for (uint8_t i = machine.min_port; i <= machine.max_port; i++) {
|
||||
write_char('0' + machine.log_to_phys_port[i]); write_char('\t');
|
||||
print_port(i); write_char('\t');
|
||||
|
||||
if (!machine.is_sfp[i]) {
|
||||
phy_read(i, PHY_MMD31, 0xa610);
|
||||
@@ -606,7 +603,7 @@ void port_eee_disable(uint8_t port) __banked
|
||||
|
||||
void port_eee_status(uint8_t port) __banked
|
||||
{
|
||||
print_string("Port: "); write_char('0' + machine.log_to_phys_port[port]);
|
||||
print_string("Port: "); print_port(port);
|
||||
print_string(": ");
|
||||
if (machine.is_sfp[port]) {
|
||||
print_string("SFP\n");
|
||||
@@ -801,19 +798,9 @@ void print_port_ingress_filter_mode(vlan_ingress_mode_t mode) __banked
|
||||
}
|
||||
}
|
||||
|
||||
static void print_phys_port(uint8_t port) __banked
|
||||
{
|
||||
if (port >= machine.min_port && port <= machine.max_port)
|
||||
write_char(machine.log_to_phys_port[port] + '0');
|
||||
else if (port == 9)
|
||||
write_char('9');
|
||||
else
|
||||
write_char('?');
|
||||
}
|
||||
|
||||
void print_vlan_ingress_port(uint8_t log_port) __banked
|
||||
{
|
||||
print_phys_port(log_port);write_char('\t');
|
||||
print_port(log_port);write_char('\t');
|
||||
print_short(port_pvid_get(log_port));write_char('\t');
|
||||
print_port_ingress_filter_mode(port_ingress_filter_get(log_port));write_char('\t');
|
||||
port_ingress_vlan_filter_get(log_port) ? print_string("Enabled") : print_string("Disabled");
|
||||
|
||||
@@ -813,6 +813,19 @@ void print_reg(uint16_t reg)
|
||||
print_sfr_data();
|
||||
}
|
||||
|
||||
// Print the phy port for a log port number.
|
||||
void print_port(uint8_t port)
|
||||
{
|
||||
if (port < 9)
|
||||
write_char(machine.log_to_phys_port[port] + '0');
|
||||
else if (port == 9)
|
||||
print_string("CPU");
|
||||
else {
|
||||
print_string("UNKNOWN ");
|
||||
write_char(port + '0');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// TODO: This uses 2 DSEG bytes and is not used!
|
||||
|
||||
Reference in New Issue
Block a user