Author: cgutman
Date: Sat Sep 13 19:48:32 2008
New Revision: 36204
URL:
http://svn.reactos.org/svn/reactos?rev=36204&view=rev
Log:
- Merge aicom-network-fixes up to r36198
Modified:
trunk/reactos/drivers/network/ndis/ndis/buffer.c
trunk/reactos/drivers/network/ndis/ndis/efilter.c
trunk/reactos/drivers/network/ndis/ndis/io.c
trunk/reactos/drivers/network/ndis/ndis/miniport.c
trunk/reactos/drivers/network/ndis/ndis/protocol.c
Modified: trunk/reactos/drivers/network/ndis/ndis/buffer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/buffer.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/buffer.c [iso-8859-1] Sat Sep 13 19:48:32
2008
@@ -465,7 +465,7 @@
/*
- * @unimplemented
+ * @implemented
*/
VOID
EXPORT
@@ -694,7 +694,7 @@
/*
- * @unimplemented
+ * @implemented
*/
VOID
EXPORT
@@ -710,12 +710,42 @@
* PoolHandle = Handle returned by NdisAllocatePacketPool
*/
{
- *Status = NDIS_STATUS_FAILURE;
-}
-
-
-/*
- * @unimplemented
+ PNDIS_PACKET Temp;
+ PNDISI_PACKET_POOL Pool = (PNDISI_PACKET_POOL)PoolHandle;
+
+ NDIS_DbgPrint(MAX_TRACE, ("Status (0x%X) Packet (0x%X) PoolHandle
(0x%X).\n",
+ Status, Packet, PoolHandle));
+
+ *Packet = NULL;
+
+ if (Pool == NULL)
+ {
+ *Status = NDIS_STATUS_FAILURE;
+ return;
+ }
+
+ KeAcquireSpinLockAtDpcLevel(&Pool->SpinLock.SpinLock);
+
+ if (Pool->FreeList) {
+ Temp = Pool->FreeList;
+ Pool->FreeList = (PNDIS_PACKET)Temp->Private.Head;
+
+ KeReleaseSpinLockFromDpcLevel(&Pool->SpinLock.SpinLock);
+
+ RtlZeroMemory(&Temp->Private, sizeof(NDIS_PACKET_PRIVATE));
+ Temp->Private.Pool = Pool;
+
+ *Packet = Temp;
+ *Status = NDIS_STATUS_SUCCESS;
+ } else {
+ *Status = NDIS_STATUS_RESOURCES;
+ KeReleaseSpinLockFromDpcLevel(&Pool->SpinLock.SpinLock);
+ }
+}
+
+
+/*
+ * @implemented
*/
VOID
EXPORT
@@ -731,12 +761,37 @@
* PoolHandle = Handle returned by NdisAllocatePacketPool
*/
{
- *Status = NDIS_STATUS_FAILURE;
-}
-
-
-/*
- * @unimplemented
+ PNDIS_PACKET Temp;
+ PNDISI_PACKET_POOL Pool = (PNDISI_PACKET_POOL)PoolHandle;
+
+ NDIS_DbgPrint(MAX_TRACE, ("Status (0x%X) Packet (0x%X) PoolHandle
(0x%X).\n",
+ Status, Packet, PoolHandle));
+
+ *Packet = NULL;
+
+ if (Pool == NULL)
+ {
+ *Status = NDIS_STATUS_FAILURE;
+ return;
+ }
+
+ if (Pool->FreeList) {
+ Temp = Pool->FreeList;
+ Pool->FreeList = (PNDIS_PACKET)Temp->Private.Head;
+
+ RtlZeroMemory(&Temp->Private, sizeof(NDIS_PACKET_PRIVATE));
+ Temp->Private.Pool = Pool;
+
+ *Packet = Temp;
+ *Status = NDIS_STATUS_SUCCESS;
+ } else {
+ *Status = NDIS_STATUS_RESOURCES;
+ }
+}
+
+
+/*
+ * @implemented
*/
VOID
EXPORT
@@ -748,11 +803,17 @@
* Packet = Pointer to packet to free
*/
{
-}
-
-
-/*
- * @unimplemented
+ NDIS_DbgPrint(MAX_TRACE, ("Packet (0x%X).\n", Packet));
+
+
KeAcquireSpinLockAtDpcLevel(&((NDISI_PACKET_POOL*)Packet->Private.Pool)->SpinLock.SpinLock);
+ Packet->Private.Head =
(PNDIS_BUFFER)((NDISI_PACKET_POOL*)Packet->Private.Pool)->FreeList;
+ ((NDISI_PACKET_POOL*)Packet->Private.Pool)->FreeList = Packet;
+
KeReleaseSpinLockFromDpcLevel(&((NDISI_PACKET_POOL*)Packet->Private.Pool)->SpinLock.SpinLock);
+}
+
+
+/*
+ * @implemented
*/
VOID
EXPORT
@@ -764,6 +825,10 @@
* Packet = Pointer to packet to free
*/
{
+ NDIS_DbgPrint(MAX_TRACE, ("Packet (0x%X).\n", Packet));
+
+ Packet->Private.Head =
(PNDIS_BUFFER)((NDISI_PACKET_POOL*)Packet->Private.Pool)->FreeList;
+ ((NDISI_PACKET_POOL*)Packet->Private.Pool)->FreeList = Packet;
}
@@ -891,13 +956,15 @@
Buffer = _Packet->Private.Head;
*_FirstBuffer = Buffer;
- *_FirstBufferVA = MmGetMdlVirtualAddress(Buffer);
if (Buffer != NULL) {
*_FirstBufferLength = MmGetMdlByteCount(Buffer);
+ *_FirstBufferVA = MmGetSystemAddressForMdl(Buffer);
Buffer = Buffer->Next;
- } else
+ } else {
*_FirstBufferLength = 0;
+ *_FirstBufferVA = NULL;
+ }
*_TotalBufferLength = *_FirstBufferLength;
Modified: trunk/reactos/drivers/network/ndis/ndis/efilter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/efilter.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/efilter.c [iso-8859-1] Sat Sep 13 19:48:32
2008
@@ -59,7 +59,7 @@
/*
- * @unimplemented
+ * @implemented
*/
VOID
EXPORT
@@ -100,7 +100,7 @@
/*
- * @unimplemented
+ * @implemented
*/
VOID
EXPORT
@@ -112,7 +112,6 @@
* Filter = Pointer to Ethernet filter
*/
{
- KIRQL OldIrql;
PLIST_ENTRY CurrentEntry;
PLOGICAL_ADAPTER Adapter;
PADAPTER_BINDING AdapterBinding;
@@ -124,7 +123,7 @@
Adapter = (PLOGICAL_ADAPTER)((PETHI_FILTER)Filter)->Miniport;
NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
- KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
{
CurrentEntry = Adapter->ProtocolListHead.Flink;
@@ -138,7 +137,7 @@
CurrentEntry = CurrentEntry->Flink;
}
}
- KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
}
/* EOF */
Modified: trunk/reactos/drivers/network/ndis/ndis/io.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/io.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/io.c [iso-8859-1] Sat Sep 13 19:48:32 2008
@@ -198,7 +198,7 @@
/*
- * @unimplemented
+ * @implemented
*/
VOID
EXPORT
@@ -819,7 +819,7 @@
/*
- * @unimplemented
+ * @implemented
*/
NDIS_STATUS
EXPORT
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 13 19:48:32
2008
@@ -767,15 +767,16 @@
PVOID WorkItemContext;
NDIS_WORK_ITEM_TYPE WorkItemType;
PLOGICAL_ADAPTER Adapter = GET_LOGICAL_ADAPTER(DeferredContext);
- KIRQL OldIrql;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
- KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
NdisStatus =
MiniDequeueWorkItem
(Adapter, &WorkItemType, &WorkItemContext);
+
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
if (NdisStatus == NDIS_STATUS_SUCCESS)
{
@@ -869,8 +870,6 @@
break;
}
}
-
- KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
}
@@ -1205,6 +1204,17 @@
{
NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_CURRENT_LOOKAHEAD failed. NdisStatus
(0x%X).\n", NdisStatus));
return NdisStatus;
+ }
+
+ NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAXIMUM_SEND_PACKETS,
sizeof(ULONG),
+ &Adapter->NdisMiniportBlock.MaxSendPackets,
&BytesWritten);
+
+ if (NdisStatus != NDIS_STATUS_SUCCESS)
+ {
+ NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_MAXIMUM_SEND_PACKETS failed. NdisStatus
(0x%X).\n", NdisStatus));
+
+ /* Set it to 1 if it fails because some drivers don't support this (?)*/
+ Adapter->NdisMiniportBlock.MaxSendPackets = 1;
}
NDIS_DbgPrint(DEBUG_MINIPORT, ("CurLookaheadLength (0x%X).\n",
Adapter->NdisMiniportBlock.CurrentLookahead));
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 13 19:48:32
2008
@@ -63,7 +63,6 @@
* - XXX ATM, this only handles loopback packets - is that its designed function?
*/
{
- KIRQL OldIrql;
UINT BufferedLength;
UINT PacketLength;
@@ -76,12 +75,12 @@
NdisQueryPacket(Packet, NULL, NULL, NULL, &PacketLength);
NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
- KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
{
Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()] =
Packet;
BufferedLength = CopyPacketToBuffer(Adapter->LookaheadBuffer, Packet, 0,
Adapter->NdisMiniportBlock.CurrentLookahead);
}
- KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
if (BufferedLength > Adapter->MediumHeaderSize)
{
@@ -96,11 +95,11 @@
}
NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
- KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
{
Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()] =
NULL;
}
- KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
return STATUS_SUCCESS;
}