mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-24 11:54:49 +00:00
Patched XMC7 eth
This commit is contained in:
1 parent
959fcfdf1d
commit
4f15392440
2 files changed
+19
-13
No files matched your search
+13
-10
@@ -7608,7 +7608,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
|
||||
size_t max = 1;
|
||||
for (struct mg_connection *c = mgr->conns; c != NULL; c = c->next) {
|
||||
c->is_readable = c->is_writable = 0;
|
||||
if (mg_tls_pending(c) > 0) ms = 1, c->is_readable = 1;
|
||||
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) ms = 1, c->is_readable = 1;
|
||||
if (can_write(c)) MG_EPOLL_MOD(c, 1);
|
||||
if (c->is_closing) ms = 1;
|
||||
max++;
|
||||
@@ -7624,7 +7624,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
|
||||
bool wr = evs[i].events & EPOLLOUT;
|
||||
c->is_readable = can_read(c) && rd ? 1U : 0;
|
||||
c->is_writable = can_write(c) && wr ? 1U : 0;
|
||||
if (mg_tls_pending(c) > 0) c->is_readable = 1;
|
||||
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) c->is_readable = 1;
|
||||
}
|
||||
}
|
||||
(void) skip_iotest;
|
||||
@@ -7638,7 +7638,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
|
||||
c->is_readable = c->is_writable = 0;
|
||||
if (skip_iotest(c)) {
|
||||
// Socket not valid, ignore
|
||||
} else if (mg_tls_pending(c) > 0) {
|
||||
} else if (c->rtls.len > 0 || mg_tls_pending(c) > 0) {
|
||||
ms = 1; // Don't wait if TLS is ready
|
||||
} else {
|
||||
fds[n].fd = FD(c);
|
||||
@@ -7660,7 +7660,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
|
||||
for (struct mg_connection *c = mgr->conns; c != NULL; c = c->next) {
|
||||
if (skip_iotest(c)) {
|
||||
// Socket not valid, ignore
|
||||
} else if (mg_tls_pending(c) > 0) {
|
||||
} else if (c->rtls.len > 0 || mg_tls_pending(c) > 0) {
|
||||
c->is_readable = 1;
|
||||
} else {
|
||||
if (fds[n].revents & POLLERR) {
|
||||
@@ -7669,7 +7669,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
|
||||
c->is_readable =
|
||||
(unsigned) (fds[n].revents & (POLLIN | POLLHUP) ? 1 : 0);
|
||||
c->is_writable = (unsigned) (fds[n].revents & POLLOUT ? 1 : 0);
|
||||
if (mg_tls_pending(c) > 0) c->is_readable = 1;
|
||||
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) c->is_readable = 1;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
@@ -7691,7 +7691,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
|
||||
FD_SET(FD(c), &eset);
|
||||
if (can_read(c)) FD_SET(FD(c), &rset);
|
||||
if (can_write(c)) FD_SET(FD(c), &wset);
|
||||
if (mg_tls_pending(c) > 0) tvp = &tv_zero;
|
||||
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) tvp = &tv_zero;
|
||||
if (FD(c) > maxfd) maxfd = FD(c);
|
||||
if (c->is_closing) ms = 1;
|
||||
}
|
||||
@@ -7713,7 +7713,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
|
||||
} else {
|
||||
c->is_readable = FD(c) != MG_INVALID_SOCKET && FD_ISSET(FD(c), &rset);
|
||||
c->is_writable = FD(c) != MG_INVALID_SOCKET && FD_ISSET(FD(c), &wset);
|
||||
if (mg_tls_pending(c) > 0) c->is_readable = 1;
|
||||
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) c->is_readable = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -17378,11 +17378,10 @@ static bool mg_tcpip_driver_xmc7_init(struct mg_tcpip_if *ifp) {
|
||||
ETH0->CTL = MG_BIT(31) | 2;
|
||||
|
||||
uint32_t cr = get_clock_rate(d);
|
||||
// set NSP change, ignore RX FCS, data bus width, clock rate, Gigabit mode,
|
||||
// set NSP change, ignore RX FCS, data bus width, clock rate
|
||||
// frame length 1536, full duplex, speed
|
||||
// TODO: enable Gigabit mode (bit 10) only if PHY uses Gigabit link
|
||||
ETH0->NETWORK_CONFIG = MG_BIT(29) | MG_BIT(26) | MG_BIT(21) |
|
||||
((cr & 7) << 18) | MG_BIT(10) | MG_BIT(8) | MG_BIT(4) |
|
||||
((cr & 7) << 18) | MG_BIT(8) | MG_BIT(4) |
|
||||
MG_BIT(1) | MG_BIT(0);
|
||||
|
||||
// config DMA settings: Force TX burst, Discard on Error, set RX buffer size
|
||||
@@ -17454,6 +17453,7 @@ static size_t mg_tcpip_driver_xmc7_tx(const void *buf, size_t len,
|
||||
|
||||
MG_DSB();
|
||||
ETH0->TRANSMIT_STATUS = ETH0->TRANSMIT_STATUS;
|
||||
ETH0->NETWORK_CONTROL |= MG_BIT(9); // enable transmission
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -17466,6 +17466,9 @@ static bool mg_tcpip_driver_xmc7_up(struct mg_tcpip_if *ifp) {
|
||||
struct mg_phy phy = {eth_read_phy, eth_write_phy};
|
||||
up = mg_phy_up(&phy, d->phy_addr, &full_duplex, &speed);
|
||||
if ((ifp->state == MG_TCPIP_STATE_DOWN) && up) { // link state just went up
|
||||
if (speed == MG_PHY_SPEED_1000M) {
|
||||
ETH0->NETWORK_CONFIG |= MG_BIT(10);
|
||||
}
|
||||
MG_DEBUG(("Link is %uM %s-duplex",
|
||||
speed == MG_PHY_SPEED_10M ? 10 :
|
||||
(speed == MG_PHY_SPEED_100M ? 100 : 1000),
|
||||
|
||||
+6
-3
@@ -98,11 +98,10 @@ static bool mg_tcpip_driver_xmc7_init(struct mg_tcpip_if *ifp) {
|
||||
ETH0->CTL = MG_BIT(31) | 2;
|
||||
|
||||
uint32_t cr = get_clock_rate(d);
|
||||
// set NSP change, ignore RX FCS, data bus width, clock rate, Gigabit mode,
|
||||
// set NSP change, ignore RX FCS, data bus width, clock rate
|
||||
// frame length 1536, full duplex, speed
|
||||
// TODO: enable Gigabit mode (bit 10) only if PHY uses Gigabit link
|
||||
ETH0->NETWORK_CONFIG = MG_BIT(29) | MG_BIT(26) | MG_BIT(21) |
|
||||
((cr & 7) << 18) | MG_BIT(10) | MG_BIT(8) | MG_BIT(4) |
|
||||
((cr & 7) << 18) | MG_BIT(8) | MG_BIT(4) |
|
||||
MG_BIT(1) | MG_BIT(0);
|
||||
|
||||
// config DMA settings: Force TX burst, Discard on Error, set RX buffer size
|
||||
@@ -174,6 +173,7 @@ static size_t mg_tcpip_driver_xmc7_tx(const void *buf, size_t len,
|
||||
|
||||
MG_DSB();
|
||||
ETH0->TRANSMIT_STATUS = ETH0->TRANSMIT_STATUS;
|
||||
ETH0->NETWORK_CONTROL |= MG_BIT(9); // enable transmission
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -186,6 +186,9 @@ static bool mg_tcpip_driver_xmc7_up(struct mg_tcpip_if *ifp) {
|
||||
struct mg_phy phy = {eth_read_phy, eth_write_phy};
|
||||
up = mg_phy_up(&phy, d->phy_addr, &full_duplex, &speed);
|
||||
if ((ifp->state == MG_TCPIP_STATE_DOWN) && up) { // link state just went up
|
||||
if (speed == MG_PHY_SPEED_1000M) {
|
||||
ETH0->NETWORK_CONFIG |= MG_BIT(10);
|
||||
}
|
||||
MG_DEBUG(("Link is %uM %s-duplex",
|
||||
speed == MG_PHY_SPEED_10M ? 10 :
|
||||
(speed == MG_PHY_SPEED_100M ? 100 : 1000),
|
||||
|
||||
Reference in new issue
Block a user