- add a small hack in sys_arch.c to boost throughput; we forcefully make the timeout value a foxed constant to boost speed
- add small language optimizations

svn path=/branches/GSoC_2011/TcpIpDriver/; revision=52637
This commit is contained in:
Claudiu Mihail 2011-07-11 17:33:17 +00:00
parent 02013a2c67
commit b5a8722b5e
4 changed files with 57 additions and 33 deletions

View file

@ -6,26 +6,26 @@
#include "lwip/ip_addr.h"
/* External TCP event handlers */
extern void TCPConnectEventHandler(void *arg, err_t err);
extern void TCPConnectEventHandler(void *arg, const err_t err);
extern void TCPAcceptEventHandler(void *arg, struct tcp_pcb *newpcb);
extern void TCPSendEventHandler(void *arg, u16_t space);
extern void TCPFinEventHandler(void *arg, err_t err);
extern void TCPSendEventHandler(void *arg, const u16_t space);
extern void TCPFinEventHandler(void *arg, const err_t err);
extern u32_t TCPRecvEventHandler(void *arg, struct pbuf *p);
/* TCP functions */
struct tcp_pcb *LibTCPSocket(void *arg);
err_t LibTCPBind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port);
struct tcp_pcb *LibTCPListen(struct tcp_pcb *pcb, u8_t backlog);
err_t LibTCPSend(struct tcp_pcb *pcb, const void *dataptr, const u16_t len, const int safe);
err_t LibTCPConnect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port);
err_t LibTCPShutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx);
err_t LibTCPBind(struct tcp_pcb *pcb, struct ip_addr *const ipaddr, const u16_t port);
struct tcp_pcb *LibTCPListen(struct tcp_pcb *pcb, const u8_t backlog);
err_t LibTCPSend(struct tcp_pcb *pcb, void *const dataptr, const u16_t len, const int safe);
err_t LibTCPConnect(struct tcp_pcb *pcb, struct ip_addr *const ipaddr, const u16_t port);
err_t LibTCPShutdown(struct tcp_pcb *pcb, const int shut_rx, const int shut_tx);
err_t LibTCPClose(struct tcp_pcb *pcb, const int safe);
err_t LibTCPGetPeerName(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t *port);
err_t LibTCPGetHostName(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t *port);
err_t LibTCPGetPeerName(struct tcp_pcb *pcb, struct ip_addr *const ipaddr, u16_t *const port);
err_t LibTCPGetHostName(struct tcp_pcb *pcb, struct ip_addr *const ipaddr, u16_t *const port);
void LibTCPAccept(struct tcp_pcb *pcb, struct tcp_pcb *listen_pcb, void *arg);
/* IP functions */
void LibIPInsertPacket(void *ifarg, void *data, u32_t size);
void LibIPInsertPacket(void *ifarg, const void *const data, const u32_t size);
void LibIPInitialize(void);
void LibIPShutdown(void);

View file

@ -7,8 +7,8 @@
void
LibIPInsertPacket(void *ifarg,
void *data,
u32_t size)
const void *const data,
const u32_t size)
{
struct pbuf *p, *p1;
u32_t i;
@ -26,6 +26,8 @@ LibIPInsertPacket(void *ifarg,
RtlCopyMemory(p1->payload, ((PUCHAR)data) + i, p1->len);
}
DbgPrint("LibIPInsertPacket: called 0x%x\n", *((struct netif *)ifarg)->input);
((struct netif *)ifarg)->input(p, ifarg);
}
}

View file

@ -56,7 +56,7 @@ WaitForEventSafely(PRKEVENT Event)
static
err_t
InternalSendEventHandler(void *arg, struct tcp_pcb *pcb, u16_t space)
InternalSendEventHandler(void *arg, struct tcp_pcb *pcb, const u16_t space)
{
DbgPrint("[lwIP, InternalSendEventHandler] SendEvent (0x%x, 0x%x, %d)\n",
arg, pcb, (unsigned int)space);
@ -73,7 +73,7 @@ InternalSendEventHandler(void *arg, struct tcp_pcb *pcb, u16_t space)
static
err_t
InternalRecvEventHandler(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
InternalRecvEventHandler(void *arg, struct tcp_pcb *pcb, struct pbuf *p, const err_t err)
{
u32_t len;
@ -141,7 +141,7 @@ InternalRecvEventHandler(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t e
static
err_t
InternalAcceptEventHandler(void *arg, struct tcp_pcb *newpcb, err_t err)
InternalAcceptEventHandler(void *arg, struct tcp_pcb *newpcb, const err_t err)
{
DbgPrint("[lwIP, InternalAcceptEventHandler] AcceptEvent arg = 0x%x, newpcb = 0x%x, err = %d\n",
arg, newpcb, (unsigned int)err);
@ -164,7 +164,7 @@ InternalAcceptEventHandler(void *arg, struct tcp_pcb *newpcb, err_t err)
static
err_t
InternalConnectEventHandler(void *arg, struct tcp_pcb *pcb, err_t err)
InternalConnectEventHandler(void *arg, struct tcp_pcb *pcb, const err_t err)
{
DbgPrint("[lwIP, InternalConnectEventHandler] ConnectEvent (0x%x, pcb = 0x%x, err = %d)\n",
arg, pcb, (unsigned int)err);
@ -182,7 +182,7 @@ InternalConnectEventHandler(void *arg, struct tcp_pcb *pcb, err_t err)
static
void
InternalErrorEventHandler(void *arg, err_t err)
InternalErrorEventHandler(void *arg, const err_t err)
{
DbgPrint("[lwIP, InternalErrorEventHandler] ErrorEvent(0x%x, %d)\n",
arg, (unsigned int)err);
@ -290,7 +290,7 @@ LibTCPBindCallback(void *arg)
}
err_t
LibTCPBind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
LibTCPBind(struct tcp_pcb *pcb, struct ip_addr *const ipaddr, const u16_t port)
{
struct bind_callback_msg *msg;
err_t ret;
@ -363,7 +363,7 @@ LibTCPListenCallback(void *arg)
}
struct tcp_pcb *
LibTCPListen(struct tcp_pcb *pcb, u8_t backlog)
LibTCPListen(struct tcp_pcb *pcb, const u8_t backlog)
{
struct listen_callback_msg *msg;
void *ret;
@ -437,7 +437,7 @@ LibTCPSendCallback(void *arg)
}
err_t
LibTCPSend(struct tcp_pcb *pcb, const void *dataptr, const u16_t len, const int safe)
LibTCPSend(struct tcp_pcb *pcb, void *const dataptr, const u16_t len, const int safe)
{
err_t ret;
@ -529,7 +529,7 @@ LibTCPConnectCallback(void *arg)
}
err_t
LibTCPConnect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
LibTCPConnect(struct tcp_pcb *pcb, struct ip_addr *const ipaddr, const u16_t port)
{
struct connect_callback_msg *msg;
err_t ret;
@ -594,7 +594,7 @@ LibTCPShutdownCallback(void *arg)
}
err_t
LibTCPShutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx)
LibTCPShutdown(struct tcp_pcb *pcb, const int shut_rx, const int shut_tx)
{
struct shutdown_callback_msg *msg;
err_t ret;
@ -779,7 +779,7 @@ LibTCPAccept(struct tcp_pcb *pcb, struct tcp_pcb *listen_pcb, void *arg)
}
err_t
LibTCPGetHostName(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t *port)
LibTCPGetHostName(struct tcp_pcb *pcb, struct ip_addr *const ipaddr, u16_t *const port)
{
DbgPrint("[lwIP, LibTCPGetHostName] Called. pcb = (0x%x)\n", pcb);
@ -797,7 +797,7 @@ LibTCPGetHostName(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t *port)
}
err_t
LibTCPGetPeerName(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t *port)
LibTCPGetPeerName(struct tcp_pcb *pcb, struct ip_addr * const ipaddr, u16_t * const port)
{
DbgPrint("[lwIP, LibTCPGetPeerName] pcb = (0x%x)\n", pcb);

View file

@ -95,6 +95,10 @@ sys_arch_sem_wait(sys_sem_t* sem, u32_t timeout)
KeQuerySystemTime(&PreWaitTime);
// FIXME: This is a hack to increase the throughput. Once this is done
// the right way it should definately be removed.
timeout = 5;
Status = KeWaitForMultipleObjects(2,
WaitObjects,
WaitAny,
@ -103,11 +107,17 @@ sys_arch_sem_wait(sys_sem_t* sem, u32_t timeout)
FALSE,
timeout != 0 ? &LargeTimeout : NULL,
NULL);
//DbgPrint("[+[+[+[ sys_arch_sem_wait ]+]+]+] timeout = %d\n", timeout);
if (Status == STATUS_WAIT_0)
{
KeQuerySystemTime(&PostWaitTime);
TimeDiff = PostWaitTime.QuadPart - PreWaitTime.QuadPart;
TimeDiff /= 10000;
//DbgPrint("[+[+[+[ sys_arch_sem_wait ]+]+]+] TimeDiff = %llu\n", TimeDiff);
return TimeDiff;
}
else if (Status == STATUS_WAIT_1)
@ -120,8 +130,10 @@ sys_arch_sem_wait(sys_sem_t* sem, u32_t timeout)
return 0;
}
else
return SYS_ARCH_TIMEOUT;
//DbgPrint("[+[+[+[ sys_arch_sem_wait ]+]+]+] SYS_ARCH_TIMEOUT\n");
return SYS_ARCH_TIMEOUT;
}
err_t
@ -184,6 +196,9 @@ sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
PLIST_ENTRY Entry;
KIRQL OldIrql;
PVOID WaitObjects[] = {&mbox->Event, &TerminationEvent};
//timeout = 0;
//DbgPrint("[[[[[ sys_arch_mbox_fetch ]]]]] %d\n", timeout);
LargeTimeout.QuadPart = Int32x32To64(timeout, -10000);
@ -197,6 +212,9 @@ sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
FALSE,
timeout != 0 ? &LargeTimeout : NULL,
NULL);
//DbgPrint("[ [ [ [ sys_arch_mbox_fetch ] ] ] ] timeout = %d\n", timeout);
if (Status == STATUS_WAIT_0)
{
KeAcquireSpinLock(&mbox->Lock, &OldIrql);
@ -205,10 +223,6 @@ sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
if (IsListEmpty(&mbox->ListHead))
KeClearEvent(&mbox->Event);
KeReleaseSpinLock(&mbox->Lock, OldIrql);
KeQuerySystemTime(&PostWaitTime);
TimeDiff = PostWaitTime.QuadPart - PreWaitTime.QuadPart;
TimeDiff /= 10000;
Container = CONTAINING_RECORD(Entry, LWIP_MESSAGE_CONTAINER, ListEntry);
Message = Container->Message;
@ -216,6 +230,12 @@ sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
if (msg)
*msg = Message;
KeQuerySystemTime(&PostWaitTime);
TimeDiff = PostWaitTime.QuadPart - PreWaitTime.QuadPart;
TimeDiff /= 10000;
//DbgPrint("[ [ [ [ sys_arch_mbox_fetch ] ] ] ] TimeDiff = %llu\n", TimeDiff);
return TimeDiff;
}
@ -229,8 +249,10 @@ sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
return 0;
}
else
return SYS_ARCH_TIMEOUT;
//DbgPrint("[ [ [ [ sys_arch_mbox_fetch ] ] ] ] SYS_ARCH_TIMEOUT\n");
return SYS_ARCH_TIMEOUT;
}
u32_t