Author: cgutman
Date: Mon Apr 29 10:01:39 2013
New Revision: 58888
URL:
http://svn.reactos.org/svn/reactos?rev=58888&view=rev
Log:
[NDIS]
- Queue the miniport worker only after a previous operation has completed
CORE-5734 #resolve #comment Fixed in r58888
Modified:
trunk/reactos/drivers/network/ndis/include/miniport.h
trunk/reactos/drivers/network/ndis/ndis/miniport.c
trunk/reactos/drivers/network/ndis/ndis/protocol.c
Modified: trunk/reactos/drivers/network/ndis/include/miniport.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/inclu…
==============================================================================
--- trunk/reactos/drivers/network/ndis/include/miniport.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/include/miniport.h [iso-8859-1] Mon Apr 29 10:01:39
2013
@@ -197,4 +197,9 @@
MiniDoAddressingReset(
PLOGICAL_ADAPTER Adapter);
+VOID
+MiniWorkItemComplete(
+ PLOGICAL_ADAPTER Adapter,
+ NDIS_WORK_ITEM_TYPE WorkItemType);
+
/* EOF */
Modified: trunk/reactos/drivers/network/ndis/ndis/miniport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] Mon Apr 29 10:01:39
2013
@@ -127,7 +127,7 @@
while (CurrentEntry)
{
- if (CurrentEntry->WorkItemType == Type)
+ if (CurrentEntry->WorkItemType == Type || Type == NdisMaxWorkItems)
return CurrentEntry;
CurrentEntry = (PNDIS_MINIPORT_WORK_ITEM)CurrentEntry->Link.Next;
@@ -146,18 +146,20 @@
KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
- if (Type == NdisWorkItemRequest &&
- (Adapter->NdisMiniportBlock.PendingRequest || MiniGetFirstWorkItem(Adapter,
NdisWorkItemRequest)))
+ if (MiniGetFirstWorkItem(Adapter, Type))
+ {
+ Busy = TRUE;
+ }
+ else if (Type == NdisWorkItemRequest &&
Adapter->NdisMiniportBlock.PendingRequest)
{
Busy = TRUE;
}
- else if (Type == NdisWorkItemSend &&
- (Adapter->NdisMiniportBlock.FirstPendingPacket ||
MiniGetFirstWorkItem(Adapter, NdisWorkItemSend)))
+ else if (Type == NdisWorkItemSend &&
Adapter->NdisMiniportBlock.FirstPendingPacket)
{
Busy = TRUE;
}
- else if (Type == NdisWorkItemResetRequested &&
- (Adapter->NdisMiniportBlock.ResetStatus == NDIS_STATUS_PENDING ||
MiniGetFirstWorkItem(Adapter, NdisWorkItemResetRequested)))
+ else if (Type == NdisWorkItemResetRequested &&
+ Adapter->NdisMiniportBlock.ResetStatus == NDIS_STATUS_PENDING)
{
Busy = TRUE;
}
@@ -501,8 +503,9 @@
KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
Adapter->NdisMiniportBlock.PendingRequest = NULL;
KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
-
KeLowerIrql(OldIrql);
+
+ MiniWorkItemComplete(Adapter, NdisWorkItemRequest);
}
VOID NTAPI
@@ -553,6 +556,8 @@
Status);
KeLowerIrql(OldIrql);
+
+ MiniWorkItemComplete(Adapter, NdisWorkItemSend);
}
@@ -560,9 +565,8 @@
MiniSendResourcesAvailable(
IN NDIS_HANDLE MiniportAdapterHandle)
{
-/*
- UNIMPLEMENTED
-*/
+ /* Run the work if anything is waiting */
+ MiniWorkItemComplete((PLOGICAL_ADAPTER)MiniportAdapterHandle, NdisWorkItemSend);
}
@@ -896,6 +900,8 @@
NdisMIndicateStatus(Adapter, NDIS_STATUS_RESET_END, NULL, 0);
NdisMIndicateStatusComplete(Adapter);
+
+ MiniWorkItemComplete(Adapter, NdisWorkItemResetRequested);
}
return Status;
@@ -914,6 +920,23 @@
NDIS_DbgPrint(MIN_TRACE, ("Miniport detected adapter hang\n"));
MiniReset(Adapter);
}
+}
+
+VOID
+MiniWorkItemComplete(
+ PLOGICAL_ADAPTER Adapter,
+ NDIS_WORK_ITEM_TYPE WorkItemType)
+{
+ PIO_WORKITEM IoWorkItem;
+
+ /* Check if there's anything queued to run after this work item */
+ if (!MiniIsBusy(Adapter, WorkItemType))
+ return;
+
+ /* There is, so fire the worker */
+ IoWorkItem = IoAllocateWorkItem(Adapter->NdisMiniportBlock.DeviceObject);
+ if (IoWorkItem)
+ IoQueueWorkItem(IoWorkItem, MiniportWorker, DelayedWorkQueue, IoWorkItem);
}
VOID
@@ -934,7 +957,6 @@
*/
{
PNDIS_MINIPORT_WORK_ITEM MiniportWorkItem;
- PIO_WORKITEM IoWorkItem;
KIRQL OldIrql;
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
@@ -982,10 +1004,6 @@
}
}
- IoWorkItem = IoAllocateWorkItem(Adapter->NdisMiniportBlock.DeviceObject);
- if (IoWorkItem)
- IoQueueWorkItem(IoWorkItem, MiniportWorker, DelayedWorkQueue, IoWorkItem);
-
KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
}
@@ -1114,6 +1132,11 @@
}
KeLowerIrql(OldIrql);
+
+ if (Status != NDIS_STATUS_PENDING) {
+ MiniWorkItemComplete(Adapter, NdisWorkItemRequest);
+ }
+
return Status;
}
Modified: trunk/reactos/drivers/network/ndis/ndis/protocol.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/protocol.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/protocol.c [iso-8859-1] Mon Apr 29 10:01:39
2013
@@ -424,6 +424,10 @@
NdisStatus = NDIS_STATUS_PENDING;
}
}
+
+ if (NdisStatus != NDIS_STATUS_PENDING) {
+ MiniWorkItemComplete(Adapter, NdisWorkItemSend);
+ }
return NdisStatus;
} else {
@@ -446,6 +450,10 @@
MiniQueueWorkItem(Adapter, NdisWorkItemSend, Packet, TRUE);
NdisStatus = NDIS_STATUS_PENDING;
}
+ }
+
+ if (NdisStatus != NDIS_STATUS_PENDING) {
+ MiniWorkItemComplete(Adapter, NdisWorkItemSend);
}
return NdisStatus;