Author: cgutman
Date: Sat Sep 27 16:25:27 2008
New Revision: 36559
URL:
http://svn.reactos.org/svn/reactos?rev=36559&view=rev
Log:
- Merge aicom-network-fixes up to r36558
Modified:
trunk/reactos/drivers/network/afd/afd/tdiconn.c
trunk/reactos/drivers/network/dd/ne2000/ne2000/8390.c
trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c
trunk/reactos/drivers/network/ndis/include/miniport.h
trunk/reactos/drivers/network/ndis/ndis/miniport.c
trunk/reactos/drivers/network/ndis/ndis/protocol.c
trunk/reactos/drivers/network/tcpip/datalink/lan.c
trunk/reactos/lib/drivers/ip/network/ip.c
Modified: trunk/reactos/drivers/network/afd/afd/tdiconn.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/td…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/tdiconn.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/tdiconn.c [iso-8859-1] Sat Sep 27 16:25:27 2008
@@ -194,6 +194,8 @@
ULONG TdiAddressSize;
PTDI_CONNECTION_INFORMATION FromTdiConn, ToTdiConn;
+ if (!From) return STATUS_INVALID_PARAMETER;
+
/* FIXME: Get from socket information */
TdiAddressSize = TdiAddressSizeFromType(From->Address[0].AddressType);
SizeOfEntry = TdiAddressSize + sizeof(TDI_CONNECTION_INFORMATION);
@@ -207,15 +209,10 @@
RtlZeroMemory( LayoutFrame, 2 * SizeOfEntry );
- FromTdiConn = (PTDI_CONNECTION_INFORMATION)LayoutFrame;
- ToTdiConn = (PTDI_CONNECTION_INFORMATION)LayoutFrame + SizeOfEntry;
-
- if (From != NULL) {
- TdiBuildConnectionInfoInPlace( FromTdiConn, From );
- } else {
- TdiBuildNullConnectionInfoInPlace( FromTdiConn,
- From->Address[0].AddressType );
- }
+ FromTdiConn = (PTDI_CONNECTION_INFORMATION)LayoutFrame;
+ ToTdiConn = (PTDI_CONNECTION_INFORMATION)LayoutFrame + SizeOfEntry;
+
+ TdiBuildConnectionInfoInPlace( FromTdiConn, From );
TdiBuildConnectionInfoInPlace( ToTdiConn, To );
Modified: trunk/reactos/drivers/network/dd/ne2000/ne2000/8390.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/ne2000/…
==============================================================================
--- trunk/reactos/drivers/network/dd/ne2000/ne2000/8390.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/ne2000/ne2000/8390.c [iso-8859-1] Sat Sep 27 16:25:27
2008
@@ -543,6 +543,8 @@
UCHAR Tmp;
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
+
+ if (Adapter->TXCurrent < 0) return;
//FrameStart = Adapter->TXStart + Adapter->TXCurrent * DRIVER_BLOCK_SIZE;
//FrameStart = Adapter->TXStart;
Modified: trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/ne2000/…
==============================================================================
--- trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c [iso-8859-1] Sat Sep 27 16:25:27
2008
@@ -669,13 +669,9 @@
ASSERT_IRQL_EQUAL(DISPATCH_LEVEL);
+#ifndef NOCARD
NDIS_DbgPrint(MID_TRACE, ("Queueing packet.\n"));
-#ifdef NOCARD
- NdisMSendComplete(Adapter->MiniportAdapterHandle,
- Packet,
- NDIS_STATUS_SUCCESS);
-#else
/* Queue the packet on the transmit queue */
RESERVED(Packet)->Next = NULL;
if (Adapter->TXQueueHead == NULL) {
@@ -688,8 +684,11 @@
/* Transmit the packet */
NICTransmit(Adapter);
+
+ return NDIS_STATUS_PENDING;
+#else
+ return NDIS_STATUS_SUCCESS;
#endif
- return NDIS_STATUS_PENDING;
}
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] Sat Sep 27 16:25:27
2008
@@ -146,7 +146,7 @@
NDIS_STATUS
MiniDoRequest(
- PNDIS_MINIPORT_BLOCK Adapter,
+ PLOGICAL_ADAPTER Adapter,
PNDIS_REQUEST NdisRequest);
BOOLEAN
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] Sat Sep 27 16:25:27
2008
@@ -326,8 +326,10 @@
Request,
Status);
}
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
- Adapter->MiniportBusy = FALSE;
}
VOID NTAPI
@@ -357,8 +359,10 @@
AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet,
Status);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
- Adapter->MiniportBusy = FALSE;
}
@@ -392,8 +396,10 @@
AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet,
Status);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
- Adapter->MiniportBusy = FALSE;
}
@@ -619,14 +625,18 @@
* Status of the operation
*/
{
- NDIS_STATUS Status = NDIS_STATUS_FAILURE;
+ NDIS_STATUS Status;
KIRQL OldIrql;
- /* FIXME: What should we return if there isn't a reset handler? */
+ if (Adapter->MiniportBusy) {
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+ MiniQueueWorkItem(Adapter, NdisWorkItemResetRequested, NULL);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+ return NDIS_STATUS_PENDING;
+ }
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
- if
(Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)
- Status =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
+ Status =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
AddressingReset);
KeLowerIrql(OldIrql);
@@ -763,7 +773,7 @@
NDIS_STATUS
MiniDoRequest(
- PNDIS_MINIPORT_BLOCK Adapter,
+ PLOGICAL_ADAPTER Adapter,
PNDIS_REQUEST NdisRequest)
/*
* FUNCTION: Sends a request to a miniport
@@ -778,14 +788,14 @@
KIRQL OldIrql;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
- Adapter->MediaRequest = NdisRequest;
+ Adapter->NdisMiniportBlock.MediaRequest = NdisRequest;
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
switch (NdisRequest->RequestType)
{
case NdisRequestQueryInformation:
- Status =
(*Adapter->DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
- Adapter->MiniportAdapterContext,
+ Status =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
NdisRequest->DATA.QUERY_INFORMATION.Oid,
NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
@@ -794,8 +804,8 @@
break;
case NdisRequestSetInformation:
- Status =
(*Adapter->DriverHandle->MiniportCharacteristics.SetInformationHandler)(
- Adapter->MiniportAdapterContext,
+ Status =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SetInformationHandler)(
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
NdisRequest->DATA.SET_INFORMATION.Oid,
NdisRequest->DATA.SET_INFORMATION.InformationBuffer,
NdisRequest->DATA.SET_INFORMATION.InformationBufferLength,
@@ -805,6 +815,12 @@
default:
Status = NDIS_STATUS_FAILURE;
+ }
+
+ if (Status == NDIS_STATUS_PENDING) {
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->MiniportBusy = TRUE;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
}
KeLowerIrql(OldIrql);
@@ -829,8 +845,10 @@
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
if( Adapter->NdisMiniportBlock.QueryCompleteHandler )
(Adapter->NdisMiniportBlock.QueryCompleteHandler)(MiniportAdapterHandle, Status);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
- Adapter->MiniportBusy = FALSE;
}
VOID NTAPI MiniportWorker(IN PVOID WorkItem)
@@ -841,6 +859,7 @@
NDIS_STATUS NdisStatus;
PVOID WorkItemContext;
NDIS_WORK_ITEM_TYPE WorkItemType;
+ BOOLEAN AddressingReset;
KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
@@ -938,6 +957,16 @@
break;
case NdisWorkItemResetRequested:
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ NdisStatus =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
+ &AddressingReset);
+ KeLowerIrql(OldIrql);
+
+ if (NdisStatus == NDIS_STATUS_PENDING)
+ break;
+
+ MiniResetComplete(Adapter, NdisStatus, AddressingReset);
break;
case NdisWorkItemResetInProgress:
@@ -947,7 +976,7 @@
break;
case NdisWorkItemRequest:
- NdisStatus = MiniDoRequest(&Adapter->NdisMiniportBlock,
(PNDIS_REQUEST)WorkItemContext);
+ NdisStatus = MiniDoRequest(Adapter, (PNDIS_REQUEST)WorkItemContext);
if (NdisStatus == NDIS_STATUS_PENDING)
break;
@@ -976,8 +1005,11 @@
}
}
- if( NdisStatus != NDIS_STATUS_PENDING )
- Adapter->MiniportBusy = FALSE;
+ if( NdisStatus != NDIS_STATUS_PENDING ) {
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+ }
ExFreePool(WorkItem);
}
@@ -1004,6 +1036,7 @@
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
NdisWorkItem = ExAllocatePool(NonPagedPool, sizeof(NDIS_WORK_ITEM));
+ if (!NdisWorkItem) return;
WorkItem = (PWORK_QUEUE_ITEM)NdisWorkItem->WrapperReserved;
@@ -1496,7 +1529,7 @@
if (Stack->Parameters.StartDevice.AllocatedResourcesTranslated != NULL)
{
- ResourceCount = Stack->Parameters.StartDevice.AllocatedResources->List[0].
+ ResourceCount =
Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].
PartialResourceList.Count;
ResourceListSize =
FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
@@ -2108,8 +2141,10 @@
ASSERT(Adapter);
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
(Adapter->NdisMiniportBlock.SetCompleteHandler)(MiniportAdapterHandle, Status);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
- Adapter->MiniportBusy = FALSE;
}
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] Sat Sep 27 16:25:27
2008
@@ -43,6 +43,8 @@
{
PROTOCOL_BINDING *Protocol = (PROTOCOL_BINDING *)BindAdapterContext;
+ if (!NT_SUCCESS(Status)) return;
+
/* Put protocol binding struct on global list */
ExInterlockedInsertTailList(&ProtocolListHead, &Protocol->ListEntry,
&ProtocolListLock);
}
@@ -119,8 +121,6 @@
*/
{
KIRQL OldIrql;
- BOOLEAN QueueWorkItem = FALSE;
- NDIS_STATUS NdisStatus;
PADAPTER_BINDING AdapterBinding;
PLOGICAL_ADAPTER Adapter;
PNDIS_REQUEST_MAC_BLOCK MacBlock =
(PNDIS_REQUEST_MAC_BLOCK)NdisRequest->MacReserved;
@@ -141,26 +141,15 @@
NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
{
- if(Adapter->MiniportBusy)
- QueueWorkItem = TRUE;
- }
-
- /* MiniQueueWorkItem must be called at IRQL >= DISPATCH_LEVEL */
- if (QueueWorkItem)
- {
- MiniQueueWorkItem(Adapter, NdisWorkItemRequest, (PVOID)NdisRequest);
- KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
- return NDIS_STATUS_PENDING;
- }
-
+ if (Adapter->MiniportBusy) {
+ MiniQueueWorkItem(Adapter, NdisWorkItemRequest, (PVOID)NdisRequest);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+ return NDIS_STATUS_PENDING;
+ }
+ }
KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
- NdisStatus = MiniDoRequest(&Adapter->NdisMiniportBlock, NdisRequest);
-
- if( NdisStatus == NDIS_STATUS_PENDING )
- Adapter->MiniportBusy = TRUE;
-
- return NdisStatus;
+ return MiniDoRequest(Adapter, NdisRequest);
}
Modified: trunk/reactos/drivers/network/tcpip/datalink/lan.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/data…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/datalink/lan.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/datalink/lan.c [iso-8859-1] Sat Sep 27 16:25:27
2008
@@ -485,16 +485,9 @@
}
else
{
- if (NdisStatus == NDIS_STATUS_SUCCESS)
- {
- NdisTransferData(&NdisStatus, Adapter->NdisHandle,
- MacReceiveContext, 0, PacketSize,
- NdisPacket, &BytesTransferred);
- }
- else
- {
- BytesTransferred = 0;
- }
+ NdisTransferData(&NdisStatus, Adapter->NdisHandle,
+ MacReceiveContext, 0, PacketSize,
+ NdisPacket, &BytesTransferred);
}
TI_DbgPrint(DEBUG_DATALINK, ("Calling complete\n"));
Modified: trunk/reactos/lib/drivers/ip/network/ip.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/ip.…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] Sat Sep 27 16:25:27 2008
@@ -242,12 +242,14 @@
NUD_PERMANENT);
if (!NCE) {
TI_DbgPrint(MIN_TRACE, ("Could not create NCE.\n"));
+ return;
}
AddrWidenAddress( &NetworkAddress, &IF->Unicast, &IF->Netmask );
if (!RouterAddRoute(&NetworkAddress, &IF->Netmask, NCE, 1)) {
TI_DbgPrint(MIN_TRACE, ("Could not add route due to insufficient
resources.\n"));
+ return;
}
/* Allow TCP to hang some configuration on this interface */
@@ -352,10 +354,10 @@
* To unregister a protocol handler, call this function with Handler = NULL
*/
{
-#ifdef DBG
- if (ProtocolNumber >= IP_PROTOCOL_TABLE_SIZE)
+ if (ProtocolNumber >= IP_PROTOCOL_TABLE_SIZE) {
TI_DbgPrint(MIN_TRACE, ("Protocol number is out of range (%d).\n",
ProtocolNumber));
-#endif
+ return;
+ }
ProtocolTable[ProtocolNumber] = Handler;
}