Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ all: create_build_dir $(VERSION_HEADER) $(SUBDIRS) $(BUILDDIR)rtlplayground.bin
create_build_dir:
mkdir -p $(BUILDDIR)

SRCS = rtlplayground.c rtl837x_flash.c rtl837x_phy.c rtl837x_port.c cmd_parser.c html_data.c rtl837x_igmp.c rtl837x_stp.c
SRCS = rtlplayground.c rtl837x_flash.c rtl837x_phy.c rtl837x_port.c cmd_parser.c html_data.c rtl837x_igmp.c rtl837x_stp.c machine.c
OBJS = ${SRCS:%.c=$(BUILDDIR)%.rel}
OBJS += uip/$(BUILDDIR)/timer.rel uip/$(BUILDDIR)/uip-fw.rel uip/$(BUILDDIR)/uip-neighbor.rel uip/$(BUILDDIR)/uip-split.rel uip/$(BUILDDIR)/uip.rel uip/$(BUILDDIR)/uip_arp.rel uip/$(BUILDDIR)/uiplib.rel httpd/$(BUILDDIR)/httpd.rel httpd/$(BUILDDIR)/page_impl.rel

Expand Down
129 changes: 70 additions & 59 deletions cmd_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
#include "uip/uip.h"
#include "version.h"

#include "machine.h"

#pragma codeseg BANK1
#pragma constseg BANK1

extern __xdata uint8_t minPort;
extern __xdata uint8_t maxPort;
extern __xdata uint8_t nSFPPorts;
extern __xdata uint8_t isRTL8373;
extern __code struct machine machine;
extern __xdata uint16_t mpos;
extern __xdata uint8_t stpEnabled;
extern __code uint8_t log_to_phys_port[9];
Expand Down Expand Up @@ -63,11 +62,6 @@ __xdata signed char cmd_words_b[N_WORDS];
__xdata uint8_t cmd_history[CMD_HISTORY_SIZE];
__xdata uint16_t cmd_history_ptr;

// Maps the physical port (starting from 0) to the logical port
__code uint8_t phys_to_log_port[6] = {
4, 5, 6, 7, 3, 8
};


inline uint8_t isletter(uint8_t l)
{
Expand Down Expand Up @@ -205,10 +199,7 @@ void parse_lag(void)
print_string(" member ports: ");
for (uint8_t j = 0; j < 10; j++) {
if (members & 1) {
if (!isRTL8373)
write_char('0' + log_to_phys_port[j]);
else
write_char('1' + j);
write_char('0' + machine.log_to_phys_port[j]);
write_char(' ');
}
members >>= 1;
Expand All @@ -233,12 +224,11 @@ void parse_lag(void)
port = cmd_buffer[cmd_words_b[w]] - '1';
if (isnumber(cmd_buffer[cmd_words_b[w] + 1]))
port = (port + 1) * 10 + cmd_buffer[cmd_words_b[w] + 1] - '1';
if (!isRTL8373)
port = phys_to_log_port[port];
port = machine.phys_to_log_port[port];
} else {
goto err;
}
if (port > maxPort)
if (port > machine.max_port)
goto err;
members |= ((uint16_t)1) << port;
w++;
Expand Down Expand Up @@ -321,12 +311,11 @@ void parse_vlan(void)
if (cmd_buffer[cmd_words_b[w] + 2] == 't')
tagged |= ((uint16_t)1) << port;
} else {
if (!isRTL8373)
port = phys_to_log_port[port];
port = machine.phys_to_log_port[port];
if (cmd_buffer[cmd_words_b[w] + 1] == 't')
tagged |= ((uint16_t)1) << port;
}
if (port > maxPort)
if (port > machine.max_port)
goto err;
members |= ((uint16_t)1) << port;
}
Expand Down Expand Up @@ -359,10 +348,7 @@ void parse_mirror(void)
print_string("NOT Enabled: ");
}
print_string("Mirroring port: ");
if (!isRTL8373)
write_char('0' + log_to_phys_port[mPort >> 1]);
else
write_char('0' + (mPort >> 1) + 1);
write_char('0' + machine.log_to_phys_port[mPort >> 1]);
reg_read_m(RTL837x_MIRROR_CONF);
uint16_t m = sfr_data[0];
m = (m << 8) | sfr_data[1];
Expand All @@ -387,8 +373,7 @@ void parse_mirror(void)
mirroring_port = cmd_buffer[cmd_words_b[1]] - '1';
if (isnumber(cmd_buffer[cmd_words_b[1] + 1]))
mirroring_port = (mirroring_port + 1) * 10 + cmd_buffer[cmd_words_b[1] + 1] - '1';
if (!isRTL8373)
mirroring_port = phys_to_log_port[mirroring_port];
mirroring_port = machine.phys_to_log_port[mirroring_port];

uint8_t w = 2;
while (cmd_words_b[w] > 0) {
Expand All @@ -397,8 +382,7 @@ void parse_mirror(void)
port = cmd_buffer[cmd_words_b[w]] - '1';
if (isnumber(cmd_buffer[cmd_words_b[w] + 1])) {
port = (port + 1) * 10 + cmd_buffer[cmd_words_b[w] + 1] - '1';
if (!isRTL8373)
port = phys_to_log_port[port];
port = machine.phys_to_log_port[port];
if (cmd_buffer[cmd_words_b[w] + 2] == 'r')
rx_pmask |= ((uint16_t)1) << port;
else if (cmd_buffer[cmd_words_b[w] + 2] == 't')
Expand All @@ -408,8 +392,7 @@ void parse_mirror(void)
tx_pmask |= ((uint16_t)1) << port;
}
} else {
if (!isRTL8373)
port = phys_to_log_port[port];
port = machine.phys_to_log_port[port];
if (cmd_buffer[cmd_words_b[w] + 1] == 'r')
rx_pmask |= ((uint16_t)1) << port;
else if (cmd_buffer[cmd_words_b[w] + 1] == 't')
Expand All @@ -426,6 +409,53 @@ void parse_mirror(void)
}


void parse_port(void)
{
print_string("\nPORT ");
uint8_t p = cmd_buffer[cmd_words_b[1]] - '1';
p = machine.phys_to_log_port[p];
print_byte(p);
if (machine.is_sfp[p]) {
print_string(" is SFP no PHY information available.\n");
return;
}
if (cmd_words_b[2] > 0 && cmd_compare(2, "10m")) {
print_string(" 10M\n");
phy_set_speed(p, PHY_SPEED_10M);
}
if (cmd_words_b[2] > 0 && cmd_compare(2, "100m")) {
print_string(" 100M\n");
phy_set_speed(p, PHY_SPEED_100M);
}
if (cmd_words_b[2] > 0 && cmd_compare(2, "2g5")) {
print_string(" 2.5G\n");
phy_set_speed(p, PHY_SPEED_2G5);
}
if (cmd_words_b[2] > 0 && cmd_compare(2, "1g")) {
print_string(" 1G\n");
phy_set_speed(p, PHY_SPEED_1G);
}
if (cmd_words_b[2] > 0 && cmd_compare(2, "auto")) {
print_string(" AUTO\n");
phy_set_speed(p, PHY_SPEED_AUTO);
}
if (cmd_words_b[2] > 0 && cmd_compare(2, "off")) {
print_string(" OFF\n");
phy_set_speed(p, PHY_OFF);
}
if (cmd_words_b[2] > 0 && cmd_compare(2, "duplex")) {
print_string(" DUPLEX\n");
if (cmd_words_b[3] > 0 && cmd_compare(3, "full"))
phy_set_duplex(p, 1);
else
phy_set_duplex(p, 0);
}
if (cmd_words_b[2] > 0 && cmd_compare(2, "show")) {
phy_show(p);
}
}


void parse_regget(void)
{
uint16_t reg = 0;
Expand Down Expand Up @@ -627,18 +657,19 @@ void cmd_parser(void) __banked
print_string("\nRESET\n\n");
reset_chip();
} else if (cmd_compare(0, "sfp")) {
uint8_t rate = sfp_read_reg(0, 12);
print_string("\nRate: "); print_byte(rate);
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");
for (uint8_t i = 20; i < 60; i++) {
uint8_t c = sfp_read_reg(0, i);
if (c)
write_char(c);
sfp_print_info(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);
}
} else if (cmd_compare(0, "stat")) {
port_stats_print();
} else if (cmd_compare(0, "flash") && cmd_words_b[1] > 0 && cmd_buffer[cmd_words_b[1]] == 'r') {
} else if (cmd_compare(0, "flash") && cmd_words_b[1] > 0 && cmd_buffer[cmd_words_b[1]] == 'r') {
print_string("\nPRINT SECURITY REGISTERS\n");
// The following will only show something else than 0xff if it was programmed for a managed switch
flash_region.addr = 0x0001000;
Expand Down Expand Up @@ -680,25 +711,7 @@ void cmd_parser(void) __banked
flash_region.len = 20;
flash_write_bytes(flash_buf);
} else if (cmd_compare(0, "port") && cmd_words_b[1] > 0) {
print_string("\nPORT ");
uint8_t p = cmd_buffer[cmd_words_b[1]] - '1';
print_byte(p);
if (cmd_words_b[2] > 0 && cmd_compare(2, "2g5")) {
print_string(" 2.5G\n");
phy_set_mode(p, PHY_SPEED_2G5, 0, 0);
}
if (cmd_words_b[2] > 0 && cmd_compare(2, "1g")) {
print_string(" 1G\n");
phy_set_mode(p, PHY_SPEED_1G, 0, 0);
}
if (cmd_words_b[2] > 0 && cmd_compare(2, "auto")) {
print_string(" AUTO\n");
phy_set_mode(p, PHY_SPEED_AUTO, 0, 0);
}
if (cmd_words_b[2] > 0 && cmd_compare(2, "off")) {
print_string(" OFF\n");
phy_set_mode(p, PHY_OFF, 0, 0);
}
parse_port();
} else if (cmd_compare(0, "ip")) {
print_string("Got ip command: ");
if (!parse_ip(cmd_words_b[1]))
Expand Down Expand Up @@ -742,8 +755,7 @@ void cmd_parser(void) __banked
__xdata uint16_t pvid;
uint8_t port;
port = cmd_buffer[cmd_words_b[1]] - '1';
if (!isRTL8373)
port = phys_to_log_port[port];
port = machine.phys_to_log_port[port];
if (!atoi_short(&pvid, cmd_words_b[2]))
port_pvid_set(port, pvid);
} else if (cmd_compare(0, "vlan")) {
Expand All @@ -770,8 +782,7 @@ void cmd_parser(void) __banked
int8_t port = -1;
if (cmd_words_b[3] > 0) {
port = cmd_buffer[cmd_words_b[2]] - '1';
if (!isRTL8373)
port = phys_to_log_port[port];
port = machine.phys_to_log_port[port];
}
if (cmd_words_b[1] > 0 && cmd_compare(1, "on")) {
if (port >= 0)
Expand Down
11 changes: 11 additions & 0 deletions doc/devices/SWTG024AS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ Changes I found with my board vs [Managed version](https://github.com/up-n-atom/
We need to make a `Best`-BOM variant so we can use all the featues.

# Connectors

## J4

* Location: Left SFP connector `J4`.
* Connected to: 10GMAC number 8, second SDS.

|`J4` SFP1 PINs | Signal | Component | GPIO | Notes |
|---|---|---|---|---|
|2| TX_FAULT | B-R262 | --- | |
Expand All @@ -45,6 +51,11 @@ Changes I found with my board vs [Managed version](https://github.com/up-n-atom/
|8| LOS | B-R258, T-R270 | GPIO37 | |
|9| TO? | B-R256 | --- | |

## J2

* Location: Right SFP connector `J2`.
* Connected to: 10GMAC number 3, first SDS.

|`J2` SFP2 PINs | Signal | Component | GPIO | Notes |
|---|---|---|---|---|
|2| TX_FAULT | B-R70 | --- | |
Expand Down
6 changes: 3 additions & 3 deletions html/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var txG = new BigInt64Array(10);
var txB = new BigInt64Array(10);
var rxG = new BigInt64Array(10);
var rxB = new BigInt64Array(10);
const linkS = ["Disabled", "No Link", "100M", "1000M", "NO", "NO", "2.5G"];
const linkS = ["Disabled", "No Link", "100M", "1000M", "500M", "10G", "2.5G", "5G"];
var pState = new Int8Array(10);
var pIsSFP = new Int8Array(10);
var numPorts = 0;
Expand Down Expand Up @@ -40,9 +40,9 @@ function update() {
} else {
psvg.style.opacity = 1.0;
pState[n] = p.link;
if (p.link == 5) {
if (p.link == 4 || p.link == 5 || p.link == 6) {
leds[0].style.fill = "green"; leds[1].style.fill = "orange";
} else if (p.link == 2) {
} else if (p.link == 1 || p.link == 2 || p.link == 3) {
leds[0].style.fill = "green"; leds[1].style.fill = "green";
} else {
leds[0].style.fill = "black"; leds[1].style.fill = "black";
Expand Down
Loading