From 4fe793e6076f55fca604ce97e4e5141d16695f42 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 1 Sep 2011 21:30:11 +0200 Subject: [PATCH 1/6] use tcpip_callback(netif_set_link_up, netif) to set the flag NETIF_FLAG_LINK_UP --- drivers/net/rckemac.c | 4 +++- drivers/net/rtl8139.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/rckemac.c b/drivers/net/rckemac.c index 13a29bd7..5509105b 100644 --- a/drivers/net/rckemac.c +++ b/drivers/net/rckemac.c @@ -755,12 +755,14 @@ err_t rckemacif_init(struct netif* netif) /* maximum transfer unit */ netif->mtu = 1500; /* broadcast capability */ - netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; + netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP; /* hardware address length */ netif->hwaddr_len = 6; rckemacif->ethaddr = (struct eth_addr *)netif->hwaddr; + tcpip_callback(netif_set_link_up, netif); + return ERR_OK; } #endif diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index c7978fdf..cc3ab28d 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -440,12 +441,14 @@ err_t rtl8139if_init(struct netif* netif) /* maximum transfer unit */ netif->mtu = 1500; /* broadcast capability */ - netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; + netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP; /* hardware address length */ netif->hwaddr_len = 6; rtl8139if->ethaddr = (struct eth_addr *)netif->hwaddr; + tcpip_callback(netif_set_link_up, netif); + return ERR_OK; } #endif From 470039bd176a039ff28888ee65a4d18a25293b9a Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 1 Sep 2011 21:31:44 +0200 Subject: [PATCH 2/6] remove wrong code to realize a fast lane for driver tasks --- arch/x86/kernel/irq.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 53aad1a4..d93b2a55 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -283,7 +283,4 @@ leave_handler: // timer interrupt? if ((s->int_no == 32) || (s->int_no == 123)) scheduler(); // switch to a new task - // exists a new (driver) task with a higher priority? - else if ((s->int_no >= 32) && (get_highest_priority(CORE_ID) > per_core(current_task)->prio)) - scheduler(); } From 38d0451b0db4ea784fac3b4a546e6353a2df49fe Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 1 Sep 2011 21:33:02 +0200 Subject: [PATCH 3/6] use LWIP_DEBUGF to dump debug messages --- lwip/src/arch/sys_arch.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lwip/src/arch/sys_arch.c b/lwip/src/arch/sys_arch.c index 781e3bdd..88b9e26b 100644 --- a/lwip/src/arch/sys_arch.c +++ b/lwip/src/arch/sys_arch.c @@ -83,10 +83,11 @@ void sys_msleep(u32_t ms) sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio) { + int err; sys_thread_t tmp; - create_kernel_task(&tmp, thread, arg, prio); - kprintf("Created LWIP task %s with id %u\n", name, tmp); + err = create_kernel_task(&tmp, thread, arg, prio); + LWIP_DEBUGF(SYS_DEBUG, ("sys_thread_new: create_kernel_task %d, id = %u", err, tmp)); return tmp; } @@ -166,6 +167,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t * mbox, void **msg, u32_t timeout) int err; err = mailbox_ptr_fetch(&mbox->mailbox, msg, timeout); + LWIP_DEBUGF(SYS_DEBUG, ("sys_arch_mbox_fetch: %d\n", err)); if (!err) return 0; @@ -186,7 +188,7 @@ void sys_mbox_free(sys_mbox_t* mbox) */ u32_t sys_arch_mbox_tryfetch(sys_mbox_t* mbox, void** msg) { - mailbox_ptr_tryfetch(&mbox->mailbox, msg); + return mailbox_ptr_tryfetch(&mbox->mailbox, msg); } /* sys_mbox_new(): create a new mailbox with a minimum size of "size" @@ -207,14 +209,14 @@ void sys_mbox_set_invalid(sys_mbox_t* mbox) } /* sys_mbox_trypost(): try to post data to the mailbox - * Note: There is at the moment no try post implemented - * so we use the normal post instead + * */ err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg) { int err; err = mailbox_ptr_trypost(&mbox->mailbox, msg); + LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_trypost: %d"\n, err)); return err; } From 497856d5d97d620ae50243edadb95630e464779d Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 1 Sep 2011 21:33:40 +0200 Subject: [PATCH 4/6] fine tuning to optimize LwIP --- lwip/src/include/lwipopts.h | 59 +++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 4ecdc944..c0a50e0a 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -62,7 +62,7 @@ /** * TCP_SND_BUF: TCP sender buffer space (bytes). */ -#define TCP_SND_BUF 2048 +#define TCP_SND_BUF (16*1024) /** * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) @@ -118,15 +118,68 @@ */ #define DEFAULT_THREAD_PRIO NORMAL_PRIO +/** + * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default, + * you might want to increase this.) + * For the receive side, this MSS is advertised to the remote side + * when opening a connection. For the transmit size, this MSS sets + * an upper limit on the MSS advertised by the remote host. + */ +#define TCP_MSS 2048 + +/** + * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. + */ +#define PBUF_POOL_SIZE 0x80 + +/** + * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One + * per active UDP "connection". + * (requires the LWIP_UDP option) + */ +#define MEMP_NUM_UDP_PCB 0x30 + +/** + * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. + * (requires the LWIP_TCP option) + */ +#define MEMP_NUM_TCP_PCB 0x30 + +/** + * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. + * (requires the LWIP_TCP option) + */ +#define MEMP_NUM_TCP_PCB_LISTEN 0x30 + +/** + * MEM_SIZE: the size of the heap memory. If the application will send + * a lot of data that needs to be copied, this should be set high. + */ +#define MEM_SIZE (4*0x100000) + +/** + * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used + * for callback/timeout API communication. + * (only needed if you use tcpip.c) + */ +#define MEMP_NUM_TCPIP_MSG_API 0x40 + +/** + * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used + * for incoming packets. + * (only needed if you use tcpip.c) + */ +#define MEMP_NUM_TCPIP_MSG_INPKT 0x40 + /* DEBUG options */ #define LWIP_DEBUG 1 #define DHCP_DEBUG LWIP_DBG_OFF #define ETHARP_DEBUG LWIP_DBG_OFF #define TCPIP_DEBUG LWIP_DBG_OFF -#define SYS_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_ON #define RAW_DEBUG LWIP_DBG_OFF #define MEM_DEBUG LWIP_DBG_OFF -#define IP_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_ON #define INET_DEBUG LWIP_DBG_OFF #define NETIF_DEBUG LWIP_DBG_ON #define TIMERS_DEBUG LWIP_DBG_OFF From 0ac3404f4630205dd2d00c696319e679a4fb7022 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 1 Sep 2011 13:02:08 -0700 Subject: [PATCH 5/6] add missing header "tcpip.h" --- drivers/net/rckemac.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/rckemac.c b/drivers/net/rckemac.c index 5509105b..69f4bdba 100644 --- a/drivers/net/rckemac.c +++ b/drivers/net/rckemac.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include From 8f005102502a8506292b83e0fe4a788c68da2dce Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 1 Sep 2011 13:10:32 -0700 Subject: [PATCH 6/6] reduce the number of LwIP debugging messages --- lwip/src/include/lwipopts.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index c0a50e0a..0e1b40c7 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -176,10 +176,10 @@ #define DHCP_DEBUG LWIP_DBG_OFF #define ETHARP_DEBUG LWIP_DBG_OFF #define TCPIP_DEBUG LWIP_DBG_OFF -#define SYS_DEBUG LWIP_DBG_ON +#define SYS_DEBUG LWIP_DBG_OFF #define RAW_DEBUG LWIP_DBG_OFF #define MEM_DEBUG LWIP_DBG_OFF -#define IP_DEBUG LWIP_DBG_ON +#define IP_DEBUG LWIP_DBG_OFF #define INET_DEBUG LWIP_DBG_OFF #define NETIF_DEBUG LWIP_DBG_ON #define TIMERS_DEBUG LWIP_DBG_OFF