Author: cgutman
Date: Wed Nov 19 18:08:26 2008
New Revision: 37479
URL:
http://svn.reactos.org/svn/reactos?rev=37479&view=rev
Log:
- Queue a work item for each packet instead of looping all packets currently on the work
list
- Round trip ping time to the loopback adapter is now about 1 ms
Modified:
branches/aicom-network-fixes/lib/drivers/ip/network/loopback.c
Modified: branches/aicom-network-fixes/lib/drivers/ip/network/loopback.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/lib/drivers…
==============================================================================
--- branches/aicom-network-fixes/lib/drivers/ip/network/loopback.c [iso-8859-1]
(original)
+++ branches/aicom-network-fixes/lib/drivers/ip/network/loopback.c [iso-8859-1] Wed Nov 19
18:08:26 2008
@@ -22,7 +22,6 @@
KSPIN_LOCK LoopWorkLock;
LIST_ENTRY LoopWorkList;
WORK_QUEUE_ITEM LoopWorkItem;
-BOOLEAN LoopReceiveWorkerBusy = FALSE;
VOID STDCALL LoopReceiveWorker( PVOID Context ) {
PLIST_ENTRY ListEntry;
@@ -35,46 +34,43 @@
TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
- while( (ListEntry =
- ExInterlockedRemoveHeadList( &LoopWorkList, &LoopWorkLock )) ) {
- WorkItem = CONTAINING_RECORD(ListEntry, LAN_WQ_ITEM, ListEntry);
-
- TI_DbgPrint(DEBUG_DATALINK, ("WorkItem: %x\n", WorkItem));
-
- Packet = WorkItem->Packet;
- Adapter = WorkItem->Adapter;
- BytesTransferred = WorkItem->BytesTransferred;
-
- ExFreePool( WorkItem );
-
- IPPacket.NdisPacket = Packet;
-
- TI_DbgPrint(DEBUG_DATALINK, ("Packet %x Adapter %x Trans %x\n",
- Packet, Adapter, BytesTransferred));
-
- NdisGetFirstBufferFromPacket(Packet,
- &NdisBuffer,
- &IPPacket.Header,
- &IPPacket.ContigSize,
- &IPPacket.TotalSize);
-
- IPPacket.ContigSize = IPPacket.TotalSize = BytesTransferred;
- /* Determine which upper layer protocol that should receive
- this packet and pass it to the correct receive handler */
-
- TI_DbgPrint(MID_TRACE,
- ("ContigSize: %d, TotalSize: %d, BytesTransferred: %d\n",
- IPPacket.ContigSize, IPPacket.TotalSize,
- BytesTransferred));
-
- IPPacket.Position = 0;
-
- IPReceive(Loopback, &IPPacket);
-
- FreeNdisPacket( Packet );
- }
+ ListEntry = ExInterlockedRemoveHeadList( &LoopWorkList, &LoopWorkLock );
+ WorkItem = CONTAINING_RECORD(ListEntry, LAN_WQ_ITEM, ListEntry);
+
+ TI_DbgPrint(DEBUG_DATALINK, ("WorkItem: %x\n", WorkItem));
+
+ Packet = WorkItem->Packet;
+ Adapter = WorkItem->Adapter;
+ BytesTransferred = WorkItem->BytesTransferred;
+
+ ExFreePool( WorkItem );
+
+ IPPacket.NdisPacket = Packet;
+
+ TI_DbgPrint(DEBUG_DATALINK, ("Packet %x Adapter %x Trans %x\n",
+ Packet, Adapter, BytesTransferred));
+
+ NdisGetFirstBufferFromPacket(Packet,
+ &NdisBuffer,
+ &IPPacket.Header,
+ &IPPacket.ContigSize,
+ &IPPacket.TotalSize);
+
+ IPPacket.ContigSize = IPPacket.TotalSize = BytesTransferred;
+ /* Determine which upper layer protocol that should receive
+ this packet and pass it to the correct receive handler */
+
+ TI_DbgPrint(MID_TRACE,
+ ("ContigSize: %d, TotalSize: %d, BytesTransferred: %d\n",
+ IPPacket.ContigSize, IPPacket.TotalSize,
+ BytesTransferred));
+
+ IPPacket.Position = 0;
+
+ IPReceive(Loopback, &IPPacket);
+
+ FreeNdisPacket( Packet );
TI_DbgPrint(DEBUG_DATALINK, ("Leaving\n"));
- LoopReceiveWorkerBusy = FALSE;
}
VOID LoopSubmitReceiveWork(
@@ -84,34 +80,19 @@
UINT BytesTransferred) {
PLAN_WQ_ITEM WQItem;
PLAN_ADAPTER Adapter = (PLAN_ADAPTER)BindingContext;
- KIRQL OldIrql;
-
- TcpipAcquireSpinLock( &LoopWorkLock, &OldIrql );
WQItem = ExAllocatePool( NonPagedPool, sizeof(LAN_WQ_ITEM) );
- if( !WQItem ) {
- TcpipReleaseSpinLock( &LoopWorkLock, OldIrql );
- return;
- }
+ if( !WQItem ) return;
WQItem->Packet = Packet;
WQItem->Adapter = Adapter;
WQItem->BytesTransferred = BytesTransferred;
- InsertTailList( &LoopWorkList, &WQItem->ListEntry );
+ ExInterlockedInsertTailList( &LoopWorkList, &WQItem->ListEntry,
&LoopWorkLock );
TI_DbgPrint(DEBUG_DATALINK, ("Packet %x Adapter %x BytesTrans %x\n",
Packet, Adapter, BytesTransferred));
- if( !LoopReceiveWorkerBusy ) {
- LoopReceiveWorkerBusy = TRUE;
- ExQueueWorkItem( &LoopWorkItem, CriticalWorkQueue );
- TI_DbgPrint(DEBUG_DATALINK,
- ("Work item inserted %x %x\n", &LoopWorkItem, WQItem));
- } else {
- TI_DbgPrint(DEBUG_DATALINK,
- ("LOOP WORKER BUSY %x %x\n", &LoopWorkItem, WQItem));
- }
- TcpipReleaseSpinLock( &LoopWorkLock, OldIrql );
+ ExQueueWorkItem( &LoopWorkItem, CriticalWorkQueue );
}
VOID LoopTransmit(