Author: cgutman
Date: Tue Jun 30 22:44:26 2009
New Revision: 41718
URL:
http://svn.reactos.org/svn/reactos?rev=41718&view=rev
Log:
- Restore a value that is lost in MiniportReset when AddressingReset is TRUE
- I need to do more investigation on which values need to be restored but I know
CurrentLookahead is one of them
- Add support for protocol-initiated miniport resets
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] Tue Jun 30 22:44:26
2009
@@ -188,6 +188,14 @@
PLOGICAL_ADAPTER Adapter,
NDIS_WORK_ITEM_TYPE Type);
+NDIS_STATUS
+MiniReset(
+ PLOGICAL_ADAPTER Adapter);
+
+VOID
+MiniDoAddressingReset(
+ PLOGICAL_ADAPTER Adapter);
+
#endif /* __MINIPORT_H */
/* 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] Tue Jun 30 22:44:26
2009
@@ -357,6 +357,9 @@
PADAPTER_BINDING AdapterBinding;
KIRQL OldIrql;
+ if (AddressingReset)
+ MiniDoAddressingReset(Adapter);
+
NdisMIndicateStatus(Adapter, NDIS_STATUS_RESET_END, NULL, 0);
NdisMIndicateStatusComplete(Adapter);
@@ -638,7 +641,45 @@
return Adapter;
}
-
+NDIS_STATUS
+MiniSetInformation(
+ PLOGICAL_ADAPTER Adapter,
+ NDIS_OID Oid,
+ ULONG Size,
+ PVOID Buffer,
+ PULONG BytesRead)
+{
+ NDIS_STATUS NdisStatus;
+ PNDIS_REQUEST NdisRequest;
+
+ NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
+
+ NdisRequest = ExAllocatePool(NonPagedPool, sizeof(NDIS_REQUEST));
+ if (!NdisRequest) {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
+ return NDIS_STATUS_RESOURCES;
+ }
+
+ RtlZeroMemory(NdisRequest, sizeof(NDIS_REQUEST));
+
+ NdisRequest->RequestType = NdisRequestSetInformation;
+ NdisRequest->DATA.SET_INFORMATION.Oid = Oid;
+ NdisRequest->DATA.SET_INFORMATION.InformationBuffer = Buffer;
+ NdisRequest->DATA.SET_INFORMATION.InformationBufferLength = Size;
+
+ NdisStatus = MiniDoRequest(Adapter, NdisRequest);
+
+ /* FIXME: Wait in pending case! */
+
+ ASSERT(NdisStatus != NDIS_STATUS_PENDING);
+
+ *BytesRead = NdisRequest->DATA.SET_INFORMATION.BytesRead;
+
+ ExFreePool(NdisRequest);
+
+ return NdisStatus;
+}
+
NDIS_STATUS
MiniQueryInformation(
PLOGICAL_ADAPTER Adapter,
@@ -712,21 +753,34 @@
return Ret;
}
+VOID
+MiniDoAddressingReset(PLOGICAL_ADAPTER Adapter)
+{
+ ULONG BytesRead;
+
+ MiniSetInformation(Adapter,
+ OID_GEN_CURRENT_LOOKAHEAD,
+ sizeof(ULONG),
+ &Adapter->NdisMiniportBlock.CurrentLookahead,
+ &BytesRead);
+
+ /* FIXME: Set more stuff */
+}
+
NDIS_STATUS
MiniReset(
- PLOGICAL_ADAPTER Adapter,
- PBOOLEAN AddressingReset)
+ PLOGICAL_ADAPTER Adapter)
/*
* FUNCTION: Resets the miniport
* ARGUMENTS:
* Adapter = Pointer to the logical adapter object
- * AddressingReset = Set to TRUE if we need to call MiniportSetInformation later
* RETURNS:
* Status of the operation
*/
{
NDIS_STATUS Status;
KIRQL OldIrql;
+ BOOLEAN AddressingReset = TRUE;
if (MiniIsBusy(Adapter, NdisWorkItemResetRequested)) {
MiniQueueWorkItem(Adapter, NdisWorkItemResetRequested, NULL, FALSE);
@@ -739,7 +793,7 @@
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
Status =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
- AddressingReset);
+ &AddressingReset);
KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
Adapter->NdisMiniportBlock.ResetStatus = Status;
@@ -748,6 +802,9 @@
KeLowerIrql(OldIrql);
if (Status != NDIS_STATUS_PENDING) {
+ if (AddressingReset)
+ MiniDoAddressingReset(Adapter);
+
NdisMIndicateStatus(Adapter, NDIS_STATUS_RESET_END, NULL, 0);
NdisMIndicateStatusComplete(Adapter);
}
@@ -763,15 +820,11 @@
PVOID SystemArgument2)
{
PLOGICAL_ADAPTER Adapter = DeferredContext;
- BOOLEAN AddressingReset = FALSE;
-
if (MiniCheckForHang(Adapter)) {
NDIS_DbgPrint(MIN_TRACE, ("Miniport detected adapter hang\n"));
- MiniReset(Adapter, &AddressingReset);
+ MiniReset(Adapter);
}
-
- /* FIXME: We should call MiniportSetInformation if AddressingReset is TRUE */
}
@@ -1133,12 +1186,9 @@
Adapter->NdisMiniportBlock.MiniportAdapterContext,
&AddressingReset);
- if (NdisStatus == NDIS_STATUS_PENDING)
- {
- KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
- Adapter->NdisMiniportBlock.ResetStatus = NDIS_STATUS_PENDING;
- KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
- }
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->NdisMiniportBlock.ResetStatus = NdisStatus;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
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] Tue Jun 30 22:44:26
2009
@@ -341,14 +341,16 @@
#endif
}
-
+
NDIS_STATUS NTAPI
ProReset(
IN NDIS_HANDLE MacBindingHandle)
{
- UNIMPLEMENTED
-
- return NDIS_STATUS_FAILURE;
+ PADAPTER_BINDING AdapterBinding = MacBindingHandle;
+
+ /* FIXME: Wait for all packets to be sent */
+
+ return MiniReset(AdapterBinding->Adapter);
}
VOID NTAPI