Use uip for mac-address, enable STP packages

This commit is contained in:
logicog
2025-08-30 18:43:31 +02:00
parent 326d94f48d
commit 829fbf707a
2 changed files with 18 additions and 13 deletions
+7 -7
View File
@@ -14,7 +14,7 @@ extern __xdata uint8_t outbuf[TCP_OUTBUF_SIZE];
extern __xdata uint16_t slen; extern __xdata uint16_t slen;
extern __code uint8_t * __code hex; extern __code uint8_t * __code hex;
extern __xdata uip_ipaddr_t uip_hostaddr, uip_draddr, uip_netmask; extern __xdata uip_ipaddr_t uip_hostaddr, uip_draddr, uip_netmask;
extern __code uint8_t ownMAC[]; extern __code struct uip_eth_addr uip_ethaddr;
extern __code uint8_t log_to_phys_port[9]; extern __code uint8_t log_to_phys_port[9];
extern __code uint8_t phys_to_log_port[6]; extern __code uint8_t phys_to_log_port[6];
@@ -128,12 +128,12 @@ uint16_t html_index(void)
itoa_html(uip_netmask[1]); char_to_html('.'); itoa_html(uip_netmask[1]); char_to_html('.');
itoa_html(uip_netmask[1] >> 8); itoa_html(uip_netmask[1] >> 8);
slen += strtox(outbuf + slen, "</td></tr><tr><td>MAC Address</td><td>"); slen += strtox(outbuf + slen, "</td></tr><tr><td>MAC Address</td><td>");
byte_to_html(ownMAC[0]); char_to_html(':'); byte_to_html(uip_ethaddr.addr[0]); char_to_html(':');
byte_to_html(ownMAC[1]); char_to_html(':'); byte_to_html(uip_ethaddr.addr[1]); char_to_html(':');
byte_to_html(ownMAC[2]); char_to_html(':'); byte_to_html(uip_ethaddr.addr[2]); char_to_html(':');
byte_to_html(ownMAC[3]); char_to_html(':'); byte_to_html(uip_ethaddr.addr[3]); char_to_html(':');
byte_to_html(ownMAC[4]); char_to_html(':'); byte_to_html(uip_ethaddr.addr[4]); char_to_html(':');
byte_to_html(ownMAC[5]); byte_to_html(uip_ethaddr.addr[5]);
slen += strtox(outbuf + slen, "</td></tr>"); slen += strtox(outbuf + slen, "</td></tr>");
return 0; return 0;
} }
+11 -6
View File
@@ -10,6 +10,7 @@
#include "rtl837x_flash.h" #include "rtl837x_flash.h"
#include "rtl837x_phy.h" #include "rtl837x_phy.h"
#include "rtl837x_port.h" #include "rtl837x_port.h"
#include "rtl837x_stp.h"
#include "cmd_parser.h" #include "cmd_parser.h"
#include "uip/uipopt.h" #include "uip/uipopt.h"
#include "uip/uip.h" #include "uip/uip.h"
@@ -45,7 +46,6 @@ __xdata uint8_t idle_ready;
__code uint8_t ownIP[] = { 192, 168, 2, 2 }; __code uint8_t ownIP[] = { 192, 168, 2, 2 };
__code struct uip_eth_addr uip_ethaddr = {{ 0x1c, 0x2a, 0xa3, 0x23, 0x00, 0x02 }}; __code struct uip_eth_addr uip_ethaddr = {{ 0x1c, 0x2a, 0xa3, 0x23, 0x00, 0x02 }};
__code uint8_t ownMAC[] = { 0x1c, 0x2a, 0xa3, 0x23, 0x00, 0x02 };
__code uint8_t gatewayIP[] = { 192, 168, 2, 22}; __code uint8_t gatewayIP[] = { 192, 168, 2, 22};
__code uint8_t netmask[] = { 255, 255, 255, 0}; __code uint8_t netmask[] = { 255, 255, 255, 0};
@@ -741,8 +741,7 @@ uint8_t sfp_read_reg(uint8_t slot, uint8_t reg)
*/ */
void tcpip_output(void) void tcpip_output(void)
{ {
__xdata uint8_t *ptr = &uip_buf[0]; // Add TX-TAG
// Add RTL-TAG
uip_buf[VLAN_TAG_SIZE] = tx_seq++; uip_buf[VLAN_TAG_SIZE] = tx_seq++;
uip_buf[VLAN_TAG_SIZE + 1] = 0x07; // Enable all checksums uip_buf[VLAN_TAG_SIZE + 1] = 0x07; // Enable all checksums
uip_buf[VLAN_TAG_SIZE + 5] = uip_len >> 8; uip_buf[VLAN_TAG_SIZE + 5] = uip_len >> 8;
@@ -753,12 +752,13 @@ void tcpip_output(void)
reg_read_m(0x7890); reg_read_m(0x7890);
uint16_t ring_ptr = ((uint16_t)sfr_data[2]) << 8; uint16_t ring_ptr = ((uint16_t)sfr_data[2]) << 8;
ring_ptr |= sfr_data[3]; ring_ptr |= sfr_data[3];
/*
print_string("TX: \n");
for (uint8_t i = 0; i < 120; i++) { for (uint8_t i = 0; i < 120; i++) {
print_byte(*ptr++); print_byte(uip_buf[i]);
write_char(' '); write_char(' ');
} }
*/ write_char('\n');
// Move data over from xmem buffer to ASIC side using DMA // Move data over from xmem buffer to ASIC side using DMA
nic_tx_packet(ring_ptr); nic_tx_packet(ring_ptr);
@@ -820,6 +820,11 @@ void handle_rx(void)
print_byte(uip_buf[i]); print_byte(uip_buf[i]);
write_char(' '); write_char(' ');
} }
write_char('\n');
for (uint8_t i = minPort; i <=maxPort; i++ ) {
stp_cnf_send(i);
tcpip_output();
}
} else if (uip_buf[ETHERTYPE_OFFSET] == 0x08 && uip_buf[ETHERTYPE_OFFSET + 1] == 0x06) { // ARP? } else if (uip_buf[ETHERTYPE_OFFSET] == 0x08 && uip_buf[ETHERTYPE_OFFSET + 1] == 0x06) { // ARP?
uip_arp_arpin(); uip_arp_arpin();
if (uip_len) { if (uip_len) {