mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-23 20:11:49 +00:00
Merge pull request #3044 from cesanta/eth-drivers-rx
ETH driver: use the same scheme for RX
This commit is contained in:
4 files changed
+10
-16
No files matched your search
+5
-8
@@ -21875,7 +21875,7 @@ void EMAC_RX_IRQHandler(void) {
|
|||||||
uint32_t i;
|
uint32_t i;
|
||||||
//MG_INFO(("RX interrupt"));
|
//MG_INFO(("RX interrupt"));
|
||||||
for (i = 0; i < 10; i++) { // read as they arrive but not forever
|
for (i = 0; i < 10; i++) { // read as they arrive but not forever
|
||||||
if ((s_rxdesc[s_rxno][3] & SWAP32(MG_BIT(29))) == 0) {
|
if (s_rxdesc[s_rxno][3] & SWAP32(MG_BIT(29))) break;
|
||||||
uint32_t len = SWAP32(s_rxdesc[s_rxno][3]) & 0xffff;
|
uint32_t len = SWAP32(s_rxdesc[s_rxno][3]) & 0xffff;
|
||||||
//MG_INFO(("recv len: %d", len));
|
//MG_INFO(("recv len: %d", len));
|
||||||
//mg_hexdump(s_rxbuf[s_rxno], len);
|
//mg_hexdump(s_rxbuf[s_rxno], len);
|
||||||
@@ -21888,7 +21888,6 @@ void EMAC_RX_IRQHandler(void) {
|
|||||||
//MG_INFO(("EOQ detected"));
|
//MG_INFO(("EOQ detected"));
|
||||||
EMAC->RXHDP[0] = (uint32_t) &s_rxdesc[0][0];
|
EMAC->RXHDP[0] = (uint32_t) &s_rxdesc[0][0];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22311,8 +22310,8 @@ void ETH0_0_IRQHandler(void) {
|
|||||||
|
|
||||||
// check if a frame was received
|
// check if a frame was received
|
||||||
if (irq_status & MG_BIT(6)) {
|
if (irq_status & MG_BIT(6)) {
|
||||||
for (uint8_t i = 0; i < ETH_DESC_CNT; i++) {
|
for (uint8_t i = 0; i < 10; i++) { // read as they arrive, but not forever
|
||||||
if ((s_rxdesc[s_rxno][0] & MG_BIT(31)) == 0) {
|
if (s_rxdesc[s_rxno][0] & MG_BIT(31)) break;
|
||||||
size_t len = (s_rxdesc[s_rxno][0] & 0x3fff0000) >> 16;
|
size_t len = (s_rxdesc[s_rxno][0] & 0x3fff0000) >> 16;
|
||||||
mg_tcpip_qwrite(s_rxbuf[s_rxno], len, s_ifp);
|
mg_tcpip_qwrite(s_rxbuf[s_rxno], len, s_ifp);
|
||||||
s_rxdesc[s_rxno][0] = MG_BIT(31); // OWN bit: handle control to DMA
|
s_rxdesc[s_rxno][0] = MG_BIT(31); // OWN bit: handle control to DMA
|
||||||
@@ -22321,7 +22320,6 @@ void ETH0_0_IRQHandler(void) {
|
|||||||
ETH0->RECEIVE_POLL_DEMAND = 0;
|
ETH0->RECEIVE_POLL_DEMAND = 0;
|
||||||
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ETH0->STATUS = MG_BIT(6);
|
ETH0->STATUS = MG_BIT(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22565,15 +22563,14 @@ static bool mg_tcpip_driver_xmc7_up(struct mg_tcpip_if *ifp) {
|
|||||||
void ETH_IRQHandler(void) {
|
void ETH_IRQHandler(void) {
|
||||||
uint32_t irq_status = ETH0->INT_STATUS;
|
uint32_t irq_status = ETH0->INT_STATUS;
|
||||||
if (irq_status & MG_BIT(1)) {
|
if (irq_status & MG_BIT(1)) {
|
||||||
for (uint8_t i = 0; i < ETH_DESC_CNT; i++) {
|
for (uint8_t i = 0; i < 10; i++) { // read as they arrive, but not forever
|
||||||
if (s_rxdesc[s_rxno][0] & MG_BIT(0)) {
|
if ((s_rxdesc[s_rxno][0] & MG_BIT(0)) == 0) break;
|
||||||
size_t len = s_rxdesc[s_rxno][1] & (MG_BIT(13) - 1);
|
size_t len = s_rxdesc[s_rxno][1] & (MG_BIT(13) - 1);
|
||||||
mg_tcpip_qwrite(s_rxbuf[s_rxno], len, s_ifp);
|
mg_tcpip_qwrite(s_rxbuf[s_rxno], len, s_ifp);
|
||||||
s_rxdesc[s_rxno][0] &= ~MG_BIT(0); // OWN bit: handle control to DMA
|
s_rxdesc[s_rxno][0] &= ~MG_BIT(0); // OWN bit: handle control to DMA
|
||||||
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ETH0->INT_STATUS = irq_status;
|
ETH0->INT_STATUS = irq_status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ void EMAC_RX_IRQHandler(void) {
|
|||||||
uint32_t i;
|
uint32_t i;
|
||||||
//MG_INFO(("RX interrupt"));
|
//MG_INFO(("RX interrupt"));
|
||||||
for (i = 0; i < 10; i++) { // read as they arrive but not forever
|
for (i = 0; i < 10; i++) { // read as they arrive but not forever
|
||||||
if ((s_rxdesc[s_rxno][3] & SWAP32(MG_BIT(29))) == 0) {
|
if (s_rxdesc[s_rxno][3] & SWAP32(MG_BIT(29))) break;
|
||||||
uint32_t len = SWAP32(s_rxdesc[s_rxno][3]) & 0xffff;
|
uint32_t len = SWAP32(s_rxdesc[s_rxno][3]) & 0xffff;
|
||||||
//MG_INFO(("recv len: %d", len));
|
//MG_INFO(("recv len: %d", len));
|
||||||
//mg_hexdump(s_rxbuf[s_rxno], len);
|
//mg_hexdump(s_rxbuf[s_rxno], len);
|
||||||
@@ -219,7 +219,6 @@ void EMAC_RX_IRQHandler(void) {
|
|||||||
//MG_INFO(("EOQ detected"));
|
//MG_INFO(("EOQ detected"));
|
||||||
EMAC->RXHDP[0] = (uint32_t) &s_rxdesc[0][0];
|
EMAC->RXHDP[0] = (uint32_t) &s_rxdesc[0][0];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -199,8 +199,8 @@ void ETH0_0_IRQHandler(void) {
|
|||||||
|
|
||||||
// check if a frame was received
|
// check if a frame was received
|
||||||
if (irq_status & MG_BIT(6)) {
|
if (irq_status & MG_BIT(6)) {
|
||||||
for (uint8_t i = 0; i < ETH_DESC_CNT; i++) {
|
for (uint8_t i = 0; i < 10; i++) { // read as they arrive, but not forever
|
||||||
if ((s_rxdesc[s_rxno][0] & MG_BIT(31)) == 0) {
|
if (s_rxdesc[s_rxno][0] & MG_BIT(31)) break;
|
||||||
size_t len = (s_rxdesc[s_rxno][0] & 0x3fff0000) >> 16;
|
size_t len = (s_rxdesc[s_rxno][0] & 0x3fff0000) >> 16;
|
||||||
mg_tcpip_qwrite(s_rxbuf[s_rxno], len, s_ifp);
|
mg_tcpip_qwrite(s_rxbuf[s_rxno], len, s_ifp);
|
||||||
s_rxdesc[s_rxno][0] = MG_BIT(31); // OWN bit: handle control to DMA
|
s_rxdesc[s_rxno][0] = MG_BIT(31); // OWN bit: handle control to DMA
|
||||||
@@ -209,7 +209,6 @@ void ETH0_0_IRQHandler(void) {
|
|||||||
ETH0->RECEIVE_POLL_DEMAND = 0;
|
ETH0->RECEIVE_POLL_DEMAND = 0;
|
||||||
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ETH0->STATUS = MG_BIT(6);
|
ETH0->STATUS = MG_BIT(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -219,15 +219,14 @@ static bool mg_tcpip_driver_xmc7_up(struct mg_tcpip_if *ifp) {
|
|||||||
void ETH_IRQHandler(void) {
|
void ETH_IRQHandler(void) {
|
||||||
uint32_t irq_status = ETH0->INT_STATUS;
|
uint32_t irq_status = ETH0->INT_STATUS;
|
||||||
if (irq_status & MG_BIT(1)) {
|
if (irq_status & MG_BIT(1)) {
|
||||||
for (uint8_t i = 0; i < ETH_DESC_CNT; i++) {
|
for (uint8_t i = 0; i < 10; i++) { // read as they arrive, but not forever
|
||||||
if (s_rxdesc[s_rxno][0] & MG_BIT(0)) {
|
if ((s_rxdesc[s_rxno][0] & MG_BIT(0)) == 0) break;
|
||||||
size_t len = s_rxdesc[s_rxno][1] & (MG_BIT(13) - 1);
|
size_t len = s_rxdesc[s_rxno][1] & (MG_BIT(13) - 1);
|
||||||
mg_tcpip_qwrite(s_rxbuf[s_rxno], len, s_ifp);
|
mg_tcpip_qwrite(s_rxbuf[s_rxno], len, s_ifp);
|
||||||
s_rxdesc[s_rxno][0] &= ~MG_BIT(0); // OWN bit: handle control to DMA
|
s_rxdesc[s_rxno][0] &= ~MG_BIT(0); // OWN bit: handle control to DMA
|
||||||
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
if (++s_rxno >= ETH_DESC_CNT) s_rxno = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ETH0->INT_STATUS = irq_status;
|
ETH0->INT_STATUS = irq_status;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user