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 53dacf2270b33721ea36a8b06343b5ed9bb3da68..2019df701721522f77cfb845b06d9e909ee2b63d 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 @@ -5,7 +5,11 @@ #include #define NIOCTL_GADDR 0x01 +#ifndef RT_LWIP_ETH_MTU #define ETHERNET_MTU 1500 +#else +#define ETHERNET_MTU RT_LWIP_ETH_MTU +#endif struct eth_device { diff --git a/components/net/lwip-1.4.1/src/lwipopts.h b/components/net/lwip-1.4.1/src/lwipopts.h index dd5a3ace96dc14b5465709c9aa7e435d327d18d5..bff172e280493cafdb27119c18c4418e82a7fd43 100644 --- a/components/net/lwip-1.4.1/src/lwipopts.h +++ b/components/net/lwip-1.4.1/src/lwipopts.h @@ -38,8 +38,9 @@ #define LWIP_PLATFORM_BYTESWAP 0 #define BYTE_ORDER LITTLE_ENDIAN -/* Enable SO_RCVTIMEO processing. */ +/* Enable SO_RCVTIMEO/LWIP_SO_SNDTIMEO processing. */ #define LWIP_SO_RCVTIMEO 1 +#define LWIP_SO_SNDTIMEO 1 /* #define RT_LWIP_DEBUG */ @@ -232,10 +233,15 @@ /* IP reassembly and segmentation.These are orthogonal even * if they both deal with IP fragments */ -#define IP_REASSEMBLY 0 +#ifdef RT_LWIP_REASSEMBLY_FRAG +#define IP_REASSEMBLY 1 +#define IP_FRAG 1 #define IP_REASS_MAX_PBUFS 10 #define MEMP_NUM_REASSDATA 10 +#else +#define IP_REASSEMBLY 0 #define IP_FRAG 0 +#endif /* ---------- ICMP options ---------- */ #define ICMP_TTL 255 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 2853fdcd7c538bb9d6a13bbf624cf0b25eca45e0..ab7743290aa4eb22d5618b4f030bfed71e1928e9 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -67,6 +67,7 @@ #define netifapi_netif_set_link_up(n) netifapi_netif_common(n, netif_set_link_up, NULL) #define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL) +#ifndef LWIP_NO_TX_THREAD /** * Tx message structure for Ethernet interface */ @@ -85,7 +86,9 @@ static char eth_tx_thread_stack[512]; static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4]; static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; #endif +#endif +#ifndef LWIP_NO_RX_THREAD static struct rt_mailbox eth_rx_thread_mb; static struct rt_thread eth_rx_thread; #ifndef RT_LWIP_ETHTHREAD_PRIORITY @@ -97,12 +100,15 @@ static char eth_rx_thread_stack[1024]; static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4]; static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; #endif +#endif static err_t ethernetif_linkoutput(struct netif *netif, struct pbuf *p) { +#ifndef LWIP_NO_TX_THREAD struct eth_tx_msg msg; struct eth_device* enetif; + RT_ASSERT(netif != RT_NULL); enetif = (struct eth_device*)netif->state; /* send a message to eth tx thread */ @@ -113,7 +119,17 @@ static err_t ethernetif_linkoutput(struct netif *netif, struct pbuf *p) /* waiting for ack */ rt_sem_take(&(enetif->tx_ack), RT_WAITING_FOREVER); } +#else + struct eth_device* enetif; + RT_ASSERT(netif != RT_NULL); + enetif = (struct eth_device*)netif->state; + + if (enetif->eth_tx(&(enetif->parent), p) != RT_EOK) + { + return ERR_IF; + } +#endif return ERR_OK; } @@ -241,6 +257,7 @@ rt_err_t eth_device_init(struct eth_device * dev, char *name) return eth_device_init_with_flag(dev, name, flags); } +#ifndef LWIP_NO_RX_THREAD rt_err_t eth_device_ready(struct eth_device* dev) { if (dev->netif) @@ -267,7 +284,20 @@ rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up) /* post message to ethernet thread */ return rt_mb_send(ð_rx_thread_mb, (rt_uint32_t)dev); } +#else +/* NOTE: please not use it in interrupt when no RxThread exist */ +rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up) +{ + if (up == RT_TRUE) + netifapi_netif_set_link_up(dev->netif); + else + netifapi_netif_set_link_down(dev->netif); + + return RT_EOK; +} +#endif +#ifndef LWIP_NO_TX_THREAD /* Ethernet Tx Thread */ static void eth_tx_thread_entry(void* parameter) { @@ -297,7 +327,9 @@ static void eth_tx_thread_entry(void* parameter) } } } +#endif +#ifndef LWIP_NO_RX_THREAD /* Ethernet Rx Thread */ static void eth_rx_thread_entry(void* parameter) { @@ -349,13 +381,15 @@ static void eth_rx_thread_entry(void* parameter) } } } +#endif int eth_system_device_init(void) { rt_err_t result = RT_EOK; - /* initialize Rx thread. - * initialize mailbox and create Ethernet Rx thread */ + /* initialize Rx thread. */ +#ifndef LWIP_NO_RX_THREAD + /* initialize mailbox and create Ethernet Rx thread */ result = rt_mb_init(ð_rx_thread_mb, "erxmb", ð_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/4, RT_IPC_FLAG_FIFO); @@ -367,8 +401,10 @@ int eth_system_device_init(void) RT_ASSERT(result == RT_EOK); result = rt_thread_startup(ð_rx_thread); RT_ASSERT(result == RT_EOK); +#endif /* initialize Tx thread */ +#ifndef LWIP_NO_TX_THREAD /* initialize mailbox and create Ethernet Tx thread */ result = rt_mb_init(ð_tx_thread_mb, "etxmb", ð_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/4, @@ -382,8 +418,9 @@ int eth_system_device_init(void) result = rt_thread_startup(ð_tx_thread); RT_ASSERT(result == RT_EOK); - - return 0; +#endif + + return (int)result; } INIT_DEVICE_EXPORT(eth_system_device_init);