mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
+41
-12
@@ -43,6 +43,9 @@ extern __xdata struct dhcp_state dhcp_state;
|
|||||||
|
|
||||||
__xdata uint8_t vlan_names[VLAN_NAMES_SIZE];
|
__xdata uint8_t vlan_names[VLAN_NAMES_SIZE];
|
||||||
__xdata uint16_t vlan_ptr;
|
__xdata uint16_t vlan_ptr;
|
||||||
|
|
||||||
|
__xdata char port_names[9][PORT_NAME_SIZE];
|
||||||
|
|
||||||
extern __xdata uint16_t management_vlan;
|
extern __xdata uint16_t management_vlan;
|
||||||
__xdata uint8_t gpio_last_value[8] = { 0 };
|
__xdata uint8_t gpio_last_value[8] = { 0 };
|
||||||
|
|
||||||
@@ -582,20 +585,47 @@ void parse_mirror(void)
|
|||||||
|
|
||||||
void parse_port(void)
|
void parse_port(void)
|
||||||
{
|
{
|
||||||
print_string("\nPORT ");
|
if (cmd_words_b[3] <= 0) {
|
||||||
|
print_string("\nUsage:");
|
||||||
|
print_string("\nport <port> [show|on|off]");
|
||||||
|
print_string("\nport <port> [10m|100m|1g|2g5|duplex] [half|full]");
|
||||||
|
print_string("\nport <port> name [custom port name]\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd_buffer[cmd_words_b[1]] < '1' || cmd_buffer[cmd_words_b[1]] > '9' || cmd_buffer[cmd_words_b[1] + 1] != ' ' ) {
|
||||||
|
print_string("Illegal port number\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
phy_settings.port = cmd_buffer[cmd_words_b[1]] - '1';
|
phy_settings.port = cmd_buffer[cmd_words_b[1]] - '1';
|
||||||
phy_settings.port = machine.phys_to_log_port[phy_settings.port];
|
phy_settings.port = machine.phys_to_log_port[phy_settings.port];
|
||||||
print_byte(phy_settings.port);
|
if (phy_settings.port > machine.max_port || phy_settings.port < machine.min_port) {
|
||||||
if (machine.is_sfp[phy_settings.port]) {
|
print_string("This machine has no port with the specified number\n");
|
||||||
print_string(" is SFP no PHY information available.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (cmd_words_b[2] <= 0) {
|
|
||||||
print_string("\nport <port> [show|on|off|10m|100m|1g|2g5] [half|full]");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_string("Logical Port: "); print_byte(phy_settings.port); write_char('\n');
|
||||||
phy_settings.duplex = PHY_DUPLEX_BOTH;
|
phy_settings.duplex = PHY_DUPLEX_BOTH;
|
||||||
if (cmd_compare(2, "10m")) {
|
|
||||||
|
if (cmd_compare(2, "show")) {
|
||||||
|
print_string("Name: ");
|
||||||
|
print_string_x(port_names[phy_settings.port]);
|
||||||
|
if (!machine.is_sfp[phy_settings.port]) {
|
||||||
|
phy_show(phy_settings.port);
|
||||||
|
}
|
||||||
|
} else if (cmd_compare(2, "name")) {
|
||||||
|
uint8_t i = 0;
|
||||||
|
while ( (i < PORT_NAME_SIZE-1) && (cmd_buffer[cmd_words_b[3] + i] != '\0') ) {
|
||||||
|
port_names[phy_settings.port][i] = cmd_buffer[cmd_words_b[3] + i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
port_names[phy_settings.port][i] = '\0';
|
||||||
|
print_string("\nName set to: \"");
|
||||||
|
print_string_x(port_names[phy_settings.port]);
|
||||||
|
print_string("\"\n");
|
||||||
|
} else if (machine.is_sfp[phy_settings.port]) {
|
||||||
|
print_string(" is SFP no PHY information available.\n");
|
||||||
|
} else if (cmd_compare(2, "10m")) {
|
||||||
print_string(" 10M\n");
|
print_string(" 10M\n");
|
||||||
phy_settings.speed = PHY_SPEED_10M;
|
phy_settings.speed = PHY_SPEED_10M;
|
||||||
if (cmd_compare(3, "half"))
|
if (cmd_compare(3, "half"))
|
||||||
@@ -638,9 +668,8 @@ void parse_port(void)
|
|||||||
else
|
else
|
||||||
phy_settings.speed = PHY_DUPLEX_HALF;
|
phy_settings.speed = PHY_DUPLEX_HALF;
|
||||||
phy_set_duplex();
|
phy_set_duplex();
|
||||||
}
|
} else {
|
||||||
if (cmd_compare(2, "show")) {
|
print_string("Unknown port command\n");
|
||||||
phy_show(phy_settings.port);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -9,6 +9,7 @@ var pAdvertised = new Int8Array(10);
|
|||||||
var numPorts = 0;
|
var numPorts = 0;
|
||||||
var logToPhysPort = new Int8Array(10);
|
var logToPhysPort = new Int8Array(10);
|
||||||
var physToLogPort = new Int8Array(10);
|
var physToLogPort = new Int8Array(10);
|
||||||
|
var portNames = new Array(10);
|
||||||
var currentRequests = [];
|
var currentRequests = [];
|
||||||
var currentCallback;
|
var currentCallback;
|
||||||
function drawPorts() {
|
function drawPorts() {
|
||||||
@@ -136,6 +137,7 @@ function update(callback) {
|
|||||||
let n = p.portNum;
|
let n = p.portNum;
|
||||||
logToPhysPort[p.logPort] = n;
|
logToPhysPort[p.logPort] = n;
|
||||||
physToLogPort[n-1] = p.logPort;
|
physToLogPort[n-1] = p.logPort;
|
||||||
|
portNames[p.logPort] = p.name;
|
||||||
let pid = "port" + n;
|
let pid = "port" + n;
|
||||||
let ttid = "tt_" + n;
|
let ttid = "tt_" + n;
|
||||||
n--;
|
n--;
|
||||||
@@ -148,12 +150,17 @@ function update(callback) {
|
|||||||
var leds = psvg.contentDocument.getElementsByClassName("led");
|
var leds = psvg.contentDocument.getElementsByClassName("led");
|
||||||
if (leds[0] == null || leds[0].style == null)
|
if (leds[0] == null || leds[0].style == null)
|
||||||
continue;
|
continue;
|
||||||
|
const portName = p.name || portNames[p.logPort] || '';
|
||||||
|
var iHTML = "<table border=\"0\" class=\"tt_table\">";
|
||||||
|
if (portName) iHTML += "<tr><td align=\"left\">Name</td><td>:</td><td>" + portName + "</td></tr>";
|
||||||
if (p.enabled == 0) {
|
if (p.enabled == 0) {
|
||||||
pState[n] = -1;
|
pState[n] = -1;
|
||||||
bgs[0].style.fill = "red";
|
bgs[0].style.fill = "red";
|
||||||
leds[0].style.fill = "black"; leds[1].style.fill = "black";
|
leds[0].style.fill = "black"; leds[1].style.fill = "black";
|
||||||
psvg.style.opacity = 0.4;
|
psvg.style.opacity = 0.4;
|
||||||
tt.innerHTML = "Not enabled.";
|
iHTML += "<tr><td align=\"left\">Status</td><td>:</td><td>Not enabled.</td></tr>";
|
||||||
|
iHTML += "</table>";
|
||||||
|
tt.innerHTML = iHTML;
|
||||||
} else {
|
} else {
|
||||||
psvg.style.opacity = 1.0;
|
psvg.style.opacity = 1.0;
|
||||||
pState[n] = p.link;
|
pState[n] = p.link;
|
||||||
@@ -165,7 +172,6 @@ function update(callback) {
|
|||||||
leds[0].style.fill = "black"; leds[1].style.fill = "black";
|
leds[0].style.fill = "black"; leds[1].style.fill = "black";
|
||||||
psvg.style.opacity = 0.4
|
psvg.style.opacity = 0.4
|
||||||
}
|
}
|
||||||
var iHTML = "<table border=\"0\" class=\"tt_table\">";
|
|
||||||
iHTML += "<tr><td align=\"left\">Link speed</td><td>:</td><td>" + linkS[p.link + 1] + "</td></tr>";
|
iHTML += "<tr><td align=\"left\">Link speed</td><td>:</td><td>" + linkS[p.link + 1] + "</td></tr>";
|
||||||
if (p.isSFP) {
|
if (p.isSFP) {
|
||||||
pAdvertised[n] = 0;
|
pAdvertised[n] = 0;
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
<h1>Port Configuration</h1>
|
<h1>Port Configuration</h1>
|
||||||
<form id="vform" action="/vlan.html">
|
<form id="vform" action="/vlan.html">
|
||||||
<table id="speedtable">
|
<table id="speedtable">
|
||||||
<tr> <th>Port</th> <th>Current Link Speed</th><th>Set Speed</th><th>Disabled</th><th>Apply</th></tr>
|
<tr> <th>Port</th> <th>Name</th> <th>Current Link Speed</th><th>Set Speed</th><th>Disabled</th><th>Apply</th></tr>
|
||||||
</table>
|
</table>
|
||||||
<h2 style="margin-top:3em">Configure Maximum Frame Size (MTU) forwarded at Port</h2>
|
<h2 style="margin-top:3em">Configure Maximum Frame Size (MTU) forwarded at Port</h2>
|
||||||
<table id="mtutable" style="margin-top:1em">
|
<table id="mtutable" style="margin-top:1em">
|
||||||
|
|||||||
+3
-1
@@ -19,6 +19,8 @@ function createPortTable() {
|
|||||||
console.log("Table row: " + i + "pState: " + pState[i-2]);
|
console.log("Table row: " + i + "pState: " + pState[i-2]);
|
||||||
const tr = tbl.insertRow();
|
const tr = tbl.insertRow();
|
||||||
let td = tr.insertCell(); td.appendChild(document.createTextNode(`Port ${i}`));
|
let td = tr.insertCell(); td.appendChild(document.createTextNode(`Port ${i}`));
|
||||||
|
let portName = portNames[physToLogPort[i-1]] || '';
|
||||||
|
td = tr.insertCell(); td.appendChild(document.createTextNode(portName));
|
||||||
td = tr.insertCell(); td.innerHTML = linkS[pState[i] + 1];
|
td = tr.insertCell(); td.innerHTML = linkS[pState[i] + 1];
|
||||||
td = tr.insertCell(); td.innerHTML = sSelect.replaceAll("speed_sel", "speed_sel_" + i);
|
td = tr.insertCell(); td.innerHTML = sSelect.replaceAll("speed_sel", "speed_sel_" + i);
|
||||||
td = tr.insertCell(); td.innerHTML = dSwitch.replaceAll("disable_port", "disable_port_" + i)
|
td = tr.insertCell(); td.innerHTML = dSwitch.replaceAll("disable_port", "disable_port_" + i)
|
||||||
@@ -66,7 +68,7 @@ function updatePortTable() {
|
|||||||
for (let i = 1; i <= numPorts ; i++) {
|
for (let i = 1; i <= numPorts ; i++) {
|
||||||
if (pIsSFP[i-1])
|
if (pIsSFP[i-1])
|
||||||
continue;
|
continue;
|
||||||
tbl.rows[i].cells[1].innerHTML = `${linkS[pState[i-1]+1]}`;
|
tbl.rows[i].cells[2].innerHTML = `${linkS[pState[i-1]+1]}`;
|
||||||
if (!clicked[i] && pState[i - 1] < 0) {
|
if (!clicked[i] && pState[i - 1] < 0) {
|
||||||
document.getElementById('speed_sel_' + i).disabled = true;
|
document.getElementById('speed_sel_' + i).disabled = true;
|
||||||
document.getElementById('disable_port_' + i).checked = true;
|
document.getElementById('disable_port_' + i).checked = true;
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<h1>Port Statistics</h1>
|
<h1>Port Statistics</h1>
|
||||||
<table id="statstable">
|
<table id="statstable">
|
||||||
<tr> <th>Port</th> <th>link</th> <th>TX Good</th> <th>TX Bad</th> <th>RX Good</th> <th>RX Bad</th> <th> All Counters </th></tr>
|
<tr> <th>Port</th> <th>Name</th> <th>link</th> <th>TX Good</th> <th>TX Bad</th> <th>RX Good</th> <th>RX Bad</th> <th> All Counters </th></tr>
|
||||||
<script src="/stat.js"></script>
|
<script src="/stat.js"></script>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+7
-5
@@ -162,17 +162,19 @@ function fillStats() {
|
|||||||
if (tbl.rows.length > 1) {
|
if (tbl.rows.length > 1) {
|
||||||
for (let i = 0; i < numPorts; i++) {
|
for (let i = 0; i < numPorts; i++) {
|
||||||
console.log("Table Update row: " + i + " state " + pState[i] + " is " + linkS[pState[i] +1]);
|
console.log("Table Update row: " + i + " state " + pState[i] + " is " + linkS[pState[i] +1]);
|
||||||
tbl.rows[i+1].cells[1].innerHTML = `${linkS[pState[i]+1]}`;
|
tbl.rows[i+1].cells[2].innerHTML = `${linkS[pState[i]+1]}`;
|
||||||
tbl.rows[i+1].cells[2].innerHTML = `${txG[i]} pkts`;
|
tbl.rows[i+1].cells[3].innerHTML = `${txG[i]} pkts`;
|
||||||
tbl.rows[i+1].cells[3].innerHTML = `${txB[i]} pkts`;
|
tbl.rows[i+1].cells[4].innerHTML = `${txB[i]} pkts`;
|
||||||
tbl.rows[i+1].cells[4].innerHTML = `${rxG[i]} pkts`;
|
tbl.rows[i+1].cells[5].innerHTML = `${rxG[i]} pkts`;
|
||||||
tbl.rows[i+1].cells[5].innerHTML = `${rxB[i]} pkts`;
|
tbl.rows[i+1].cells[6].innerHTML = `${rxB[i]} pkts`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < numPorts; i++) {
|
for (let i = 0; i < numPorts; i++) {
|
||||||
console.log("Table row: " + i);
|
console.log("Table row: " + i);
|
||||||
const tr = tbl.insertRow();
|
const tr = tbl.insertRow();
|
||||||
let td = tr.insertCell(); td.appendChild(document.createTextNode(`Port ${i+1}`));
|
let td = tr.insertCell(); td.appendChild(document.createTextNode(`Port ${i+1}`));
|
||||||
|
let portName = portNames[physToLogPort[i]] || '';
|
||||||
|
td = tr.insertCell(); td.appendChild(document.createTextNode(portName));
|
||||||
td = tr.insertCell(); td.appendChild(document.createTextNode(`${linkS[pState[i]+1]}`));
|
td = tr.insertCell(); td.appendChild(document.createTextNode(`${linkS[pState[i]+1]}`));
|
||||||
td = tr.insertCell(); td.appendChild(document.createTextNode(`${txG[i]} pkts`));
|
td = tr.insertCell(); td.appendChild(document.createTextNode(`${txG[i]} pkts`));
|
||||||
td = tr.insertCell();td.appendChild(document.createTextNode(`${txB[i]} pkts`));
|
td = tr.insertCell();td.appendChild(document.createTextNode(`${txB[i]} pkts`));
|
||||||
|
|||||||
@@ -633,6 +633,11 @@ void send_status(void)
|
|||||||
itoa_html(machine.log_to_phys_port[i]);
|
itoa_html(machine.log_to_phys_port[i]);
|
||||||
slen += strtox(outbuf + slen, ",\"logPort\":");
|
slen += strtox(outbuf + slen, ",\"logPort\":");
|
||||||
itoa_html(i);
|
itoa_html(i);
|
||||||
|
slen += strtox(outbuf + slen, ",\"name\":\"");
|
||||||
|
for (uint8_t j = 0; j < PORT_NAME_SIZE && port_names[i][j]; j++) {
|
||||||
|
char_to_html(port_names[i][j]);
|
||||||
|
}
|
||||||
|
slen += strtox(outbuf + slen, "\"");
|
||||||
|
|
||||||
if (machine.is_sfp[i]) {
|
if (machine.is_sfp[i]) {
|
||||||
slen += strtox(outbuf + slen, ",\"isSFP\":1,\"enabled\":");
|
slen += strtox(outbuf + slen, ",\"isSFP\":1,\"enabled\":");
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ extern __xdata uint8_t sbuf[SBUF_SIZE];
|
|||||||
// Size of the TCP Output buffer
|
// Size of the TCP Output buffer
|
||||||
#define TCP_OUTBUF_SIZE 2500
|
#define TCP_OUTBUF_SIZE 2500
|
||||||
|
|
||||||
|
// Size of the port name, including the terminating null byte
|
||||||
|
#define PORT_NAME_SIZE 32
|
||||||
|
|
||||||
// Size of the memory area dedicated to VLAN-names
|
// Size of the memory area dedicated to VLAN-names
|
||||||
#define VLAN_NAMES_SIZE 1024
|
#define VLAN_NAMES_SIZE 1024
|
||||||
|
|
||||||
@@ -95,6 +98,8 @@ struct flash_region_t {
|
|||||||
uint16_t len;
|
uint16_t len;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern __xdata char port_names[9][PORT_NAME_SIZE];
|
||||||
|
|
||||||
extern __xdata uint8_t uip_buf[UIP_CONF_BUFFER_SIZE+2];
|
extern __xdata uint8_t uip_buf[UIP_CONF_BUFFER_SIZE+2];
|
||||||
extern __xdata struct uip_eth_addr uip_ethaddr;
|
extern __xdata struct uip_eth_addr uip_ethaddr;
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -367,12 +367,15 @@ void phy_show(uint8_t port) __banked
|
|||||||
print_string("5G");
|
print_string("5G");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print_string("10M");
|
print_string("Down");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( (((v & 0x0600) >> 7) | ((v & 0x0030) >> 4)) <= 6) { // Link is up
|
||||||
if (v & 0x8)
|
if (v & 0x8)
|
||||||
print_string(" full duplex");
|
print_string(" full duplex");
|
||||||
else
|
else
|
||||||
print_string(" half duplex");
|
print_string(" half duplex");
|
||||||
|
}
|
||||||
|
|
||||||
phy_read(port, PHY_MMD_AN, PHY_ANEG_CTRL);
|
phy_read(port, PHY_MMD_AN, PHY_ANEG_CTRL);
|
||||||
v = SFR_DATA_U16;
|
v = SFR_DATA_U16;
|
||||||
|
|||||||
+1
-1
@@ -1974,7 +1974,7 @@ void check_and_flash_update_image(void)
|
|||||||
__xdata uint16_t i = 0;
|
__xdata uint16_t i = 0;
|
||||||
__xdata uint16_t j = 0;
|
__xdata uint16_t j = 0;
|
||||||
__xdata uint8_t * __xdata bptr;
|
__xdata uint8_t * __xdata bptr;
|
||||||
print_string("found update image! Checking integrity");
|
print_string("found update image!\nChecking integrity");
|
||||||
flash_init(0); // Re-initialize flash for non-DIO operation, otherwise flashing will fail
|
flash_init(0); // Re-initialize flash for non-DIO operation, otherwise flashing will fail
|
||||||
set_sys_led_state(SYS_LED_FAST);
|
set_sys_led_state(SYS_LED_FAST);
|
||||||
crc_value = 0x0000;
|
crc_value = 0x0000;
|
||||||
|
|||||||
Reference in New Issue
Block a user