Author: cmihail
Date: Mon Jul 11 17:33:17 2011
New Revision: 52637
URL:
http://svn.reactos.org/svn/reactos?rev=52637&view=rev
Log:
[lwIP]
- 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
Modified:
branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h
branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rosip.c
branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c
branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/sys_arch.c
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h [iso-8859-1] Mon
Jul 11 17:33:17 2011
@@ -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);
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rosip.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rosip.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rosip.c [iso-8859-1] Mon Jul 11
17:33:17 2011
@@ -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;
@@ -25,6 +25,8 @@
ASSERT(p1);
RtlCopyMemory(p1->payload, ((PUCHAR)data) + i, p1->len);
}
+
+ DbgPrint("LibIPInsertPacket: called 0x%x\n", *((struct netif
*)ifarg)->input);
((struct netif *)ifarg)->input(p, ifarg);
}
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] Mon Jul 11
17:33:17 2011
@@ -56,7 +56,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
}
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 @@
}
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 @@
}
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 @@
}
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 @@
}
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 @@
}
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);
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/sys_arch.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/sys_arch.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/sys_arch.c [iso-8859-1] Mon Jul 11
17:33:17 2011
@@ -94,6 +94,10 @@
LargeTimeout.QuadPart = Int32x32To64(timeout, -10000);
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,
@@ -103,11 +107,17 @@
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 @@
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 @@
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 @@
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,17 +223,19 @@
if (IsListEmpty(&mbox->ListHead))
KeClearEvent(&mbox->Event);
KeReleaseSpinLock(&mbox->Lock, OldIrql);
+
+ Container = CONTAINING_RECORD(Entry, LWIP_MESSAGE_CONTAINER, ListEntry);
+ Message = Container->Message;
+ ExFreePool(Container);
+
+ if (msg)
+ *msg = Message;
KeQuerySystemTime(&PostWaitTime);
TimeDiff = PostWaitTime.QuadPart - PreWaitTime.QuadPart;
TimeDiff /= 10000;
-
- Container = CONTAINING_RECORD(Entry, LWIP_MESSAGE_CONTAINER, ListEntry);
- Message = Container->Message;
- ExFreePool(Container);
-
- if (msg)
- *msg = Message;
+
+ //DbgPrint("[ [ [ [ sys_arch_mbox_fetch ] ] ] ] TimeDiff = %llu\n",
TimeDiff);
return TimeDiff;
}
@@ -229,8 +249,10 @@
return 0;
}
- else
- return SYS_ARCH_TIMEOUT;
+
+ //DbgPrint("[ [ [ [ sys_arch_mbox_fetch ] ] ] ] SYS_ARCH_TIMEOUT\n");
+
+ return SYS_ARCH_TIMEOUT;
}
u32_t