diff --git a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h index 1c969e6e25..b3ca8e2ffb 100644 --- a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h +++ b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h @@ -27,6 +27,7 @@ struct eth_device rt_uint16_t flags; rt_uint8_t link_changed; rt_uint8_t link_status; + rt_uint8_t rx_notice; /* avoid send the same mail to mailbox */ /* eth device interface */ struct pbuf* (*eth_rx)(rt_device_t dev); diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c index 4f01c407a8..30e7ee5f6d 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -550,10 +550,16 @@ rt_err_t eth_device_init(struct eth_device * dev, const char *name) rt_err_t eth_device_ready(struct eth_device* dev) { if (dev->netif) + { + if(dev->rx_notice == RT_FALSE) + { + dev->rx_notice = RT_TRUE; + return rt_mb_send(ð_rx_thread_mb, (rt_uint32_t)dev); + } /* post message to Ethernet thread */ - return rt_mb_send(ð_rx_thread_mb, (rt_uint32_t)dev); - else - return ERR_OK; /* netif is not initialized yet, just return. */ + } + + return ERR_OK; /* netif is not initialized yet, just return. */ } rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up) @@ -646,9 +652,10 @@ static void eth_rx_thread_entry(void* parameter) else netifapi_netif_set_link_down(device->netif); } + device->rx_notice = RT_FALSE; /* receive all of buffer */ - do + while(1) { if(device->eth_rx == RT_NULL) break; @@ -664,7 +671,7 @@ static void eth_rx_thread_entry(void* parameter) } } else break; - }while(rt_mb_recv(ð_rx_thread_mb, (rt_ubase_t *)&device, RT_WAITING_NO) == RT_EOK); + } } else { diff --git a/components/net/lwip-2.0.2/src/include/netif/ethernetif.h b/components/net/lwip-2.0.2/src/include/netif/ethernetif.h index 244bafdd1b..d294c36813 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ethernetif.h +++ b/components/net/lwip-2.0.2/src/include/netif/ethernetif.h @@ -27,6 +27,7 @@ struct eth_device rt_uint16_t flags; rt_uint8_t link_changed; rt_uint8_t link_status; + rt_uint8_t rx_notice; /* avoid send the same mail to mailbox */ /* eth device interface */ struct pbuf* (*eth_rx)(rt_device_t dev); diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c index 47146f0b3b..0146286b2a 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -599,10 +599,16 @@ void eth_device_deinit(struct eth_device *dev) rt_err_t eth_device_ready(struct eth_device* dev) { if (dev->netif) + { + if(dev->rx_notice == RT_FALSE) + { + dev->rx_notice = RT_TRUE; + return rt_mb_send(ð_rx_thread_mb, (rt_uint32_t)dev); + } /* post message to Ethernet thread */ - return rt_mb_send(ð_rx_thread_mb, (rt_ubase_t)dev); - else - return ERR_OK; /* netif is not initialized yet, just return. */ + } + + return ERR_OK; /* netif is not initialized yet, just return. */ } rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up) @@ -695,9 +701,10 @@ static void eth_rx_thread_entry(void* parameter) else netifapi_netif_set_link_down(device->netif); } + device->rx_notice = RT_FALSE; /* receive all of buffer */ - do + while(1) { if(device->eth_rx == RT_NULL) break; @@ -713,7 +720,7 @@ static void eth_rx_thread_entry(void* parameter) } } else break; - }while(rt_mb_recv(ð_rx_thread_mb, (rt_ubase_t *)&device, RT_WAITING_NO) == RT_EOK); + } } else { diff --git a/components/net/lwip-2.1.2/src/include/netif/ethernetif.h b/components/net/lwip-2.1.2/src/include/netif/ethernetif.h index 244bafdd1b..d294c36813 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ethernetif.h +++ b/components/net/lwip-2.1.2/src/include/netif/ethernetif.h @@ -27,6 +27,7 @@ struct eth_device rt_uint16_t flags; rt_uint8_t link_changed; rt_uint8_t link_status; + rt_uint8_t rx_notice; /* avoid send the same mail to mailbox */ /* eth device interface */ struct pbuf* (*eth_rx)(rt_device_t dev); diff --git a/components/net/lwip-2.1.2/src/netif/ethernetif.c b/components/net/lwip-2.1.2/src/netif/ethernetif.c index df3f7cd6ce..e2f8512d53 100644 --- a/components/net/lwip-2.1.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.1.2/src/netif/ethernetif.c @@ -601,10 +601,16 @@ void eth_device_deinit(struct eth_device *dev) rt_err_t eth_device_ready(struct eth_device* dev) { if (dev->netif) + { + if(dev->rx_notice == RT_FALSE) + { + dev->rx_notice = RT_TRUE; + return rt_mb_send(ð_rx_thread_mb, (rt_uint32_t)dev); + } /* post message to Ethernet thread */ - return rt_mb_send(ð_rx_thread_mb, (rt_uint32_t)dev); - else - return ERR_OK; /* netif is not initialized yet, just return. */ + } + + return ERR_OK; /* netif is not initialized yet, just return. */ } rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up) @@ -697,9 +703,10 @@ static void eth_rx_thread_entry(void* parameter) else netifapi_netif_set_link_down(device->netif); } + device->rx_notice = RT_FALSE; /* receive all of buffer */ - do + while(1) { if(device->eth_rx == RT_NULL) break; @@ -715,7 +722,7 @@ static void eth_rx_thread_entry(void* parameter) } } else break; - }while(rt_mb_recv(ð_rx_thread_mb, (rt_ubase_t *)&device, RT_WAITING_NO) == RT_EOK); + } } else {