Turned on -Werror
Propogate AdapterBinding rather than LogicalAdapter or MiniportBlock in
places
where we handle a request since we might need the protocol that did the
request
later on, get rid of LogicalAdapter completely as according to Filip,
it's
never needed.
Also, remove the Packet context hack in send complete if possible as
this is
now unnecessary (we now send all needed information in the work item
instead).
MiniQueueWorkItem, MiniDequeueWorkItem and MiniDoRequest were all
changed to
take an AdapterBinding.
Added MiniRequestComplete, which handles a request complete.
Fixed hang in ipconfig and the tcpip control panel.
Modified: trunk/reactos/drivers/net/ndis/Makefile
Modified: trunk/reactos/drivers/net/ndis/include/miniport.h
Modified: trunk/reactos/drivers/net/ndis/include/ndissys.h
Modified: trunk/reactos/drivers/net/ndis/ndis/miniport.c
Modified: trunk/reactos/drivers/net/ndis/ndis/protocol.c
_____
Modified: trunk/reactos/drivers/net/ndis/Makefile
--- trunk/reactos/drivers/net/ndis/Makefile 2005-05-20 06:21:01 UTC
(rev 15428)
+++ trunk/reactos/drivers/net/ndis/Makefile 2005-05-20 08:06:27 UTC
(rev 15429)
@@ -8,7 +8,7 @@
TARGET_PCH = include/ndissys.h
-TARGET_CFLAGS = -I./include -D__USE_W32API -Wall
+TARGET_CFLAGS = -I./include -D__USE_W32API -Wall -Werror
TARGET_CFLAGS += -DNDIS_WRAPPER -DNDIS50 -DNDIS50_MINIPORT
-DBINARY_COMPATIBLE
_____
Modified: trunk/reactos/drivers/net/ndis/include/miniport.h
--- trunk/reactos/drivers/net/ndis/include/miniport.h 2005-05-20
06:21:01 UTC (rev 15428)
+++ trunk/reactos/drivers/net/ndis/include/miniport.h 2005-05-20
08:06:27 UTC (rev 15429)
@@ -10,6 +10,7 @@
#include <ndissys.h>
+struct _ADAPTER_BINDING;
typedef struct _HARDWARE_ADDRESS {
union {
@@ -77,9 +78,9 @@
KDPC MiniportDpc; /* DPC routine
for adapter */
BOOLEAN MiniportBusy; /* A
MiniportXxx routine is executing */
ULONG WorkQueueLevel; /* Number of
used work item buffers */
- NDIS_MINIPORT_WORK_ITEM
WorkQueue[NDIS_MINIPORT_WORK_QUEUE_SIZE];
- PNDIS_MINIPORT_WORK_ITEM WorkQueueHead; /* Head of work
queue */
- PNDIS_MINIPORT_WORK_ITEM WorkQueueTail; /* Tail of work
queue */
+ INTERNAL_NDIS_MINIPORT_WORK_ITEM
WorkQueue[NDIS_MINIPORT_WORK_QUEUE_SIZE];
+ PINTERNAL_NDIS_MINIPORT_WORK_ITEM WorkQueueHead; /*
Head of work queue */
+ PINTERNAL_NDIS_MINIPORT_WORK_ITEM WorkQueueTail; /*
Tail of work queue */
LIST_ENTRY ListEntry; /* Entry on
global list */
LIST_ENTRY MiniportListEntry; /* Entry on
miniport driver list */
LIST_ENTRY ProtocolListHead; /* List of
bound protocols */
@@ -145,7 +146,7 @@
NDIS_STATUS
FASTCALL
MiniQueueWorkItem(
- PLOGICAL_ADAPTER Adapter,
+ struct _ADAPTER_BINDING *AdapterBinding,
NDIS_WORK_ITEM_TYPE WorkItemType,
PVOID WorkItemContext);
@@ -153,12 +154,13 @@
FASTCALL
MiniDequeueWorkItem(
PLOGICAL_ADAPTER Adapter,
+ struct _ADAPTER_BINDING **AdapterBinding,
NDIS_WORK_ITEM_TYPE *WorkItemType,
PVOID *WorkItemContext);
NDIS_STATUS
MiniDoRequest(
- PLOGICAL_ADAPTER Adapter,
+ struct _ADAPTER_BINDING *AdapterBinding,
PNDIS_REQUEST NdisRequest);
BOOLEAN
_____
Modified: trunk/reactos/drivers/net/ndis/include/ndissys.h
--- trunk/reactos/drivers/net/ndis/include/ndissys.h 2005-05-20
06:21:01 UTC (rev 15428)
+++ trunk/reactos/drivers/net/ndis/include/ndissys.h 2005-05-20
08:06:27 UTC (rev 15429)
@@ -27,6 +27,14 @@
#include <ddk/ntapi.h>
#endif /* _MSC_VER */
+struct _ADAPTER_BINDING;
+
+typedef struct _INTERNAL_NDIS_MINIPORT_WORK_ITEM {
+ SINGLE_LIST_ENTRY Link;
+ struct _ADAPTER_BINDING *AdapterBinding;
+ NDIS_MINIPORT_WORK_ITEM RealWorkItem;
+} INTERNAL_NDIS_MINIPORT_WORK_ITEM, *PINTERNAL_NDIS_MINIPORT_WORK_ITEM;
+
#include "miniport.h"
#include "protocol.h"
_____
Modified: trunk/reactos/drivers/net/ndis/ndis/miniport.c
--- trunk/reactos/drivers/net/ndis/ndis/miniport.c 2005-05-20
06:21:01 UTC (rev 15428)
+++ trunk/reactos/drivers/net/ndis/ndis/miniport.c 2005-05-20
08:06:27 UTC (rev 15429)
@@ -327,7 +327,24 @@
}
+
VOID STDCALL
+MiniRequestComplete(
+ IN PADAPTER_BINDING AdapterBinding,
+ IN PNDIS_REQUEST Request,
+ IN NDIS_STATUS Status)
+{
+ NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
+
+ if( AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler )
{
+
(*AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler)(
+
AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.ProtocolBindingContext
,
+ Request,
+ Status);
+ }
+}
+
+VOID STDCALL
MiniSendComplete(
IN NDIS_HANDLE MiniportAdapterHandle,
IN PNDIS_PACKET Packet,
@@ -615,7 +632,7 @@
NDIS_STATUS
FASTCALL
MiniQueueWorkItem(
- PLOGICAL_ADAPTER Adapter,
+ PADAPTER_BINDING AdapterBinding,
NDIS_WORK_ITEM_TYPE WorkItemType,
PVOID WorkItemContext)
/*
@@ -630,49 +647,51 @@
* Status of operation
*/
{
- PNDIS_MINIPORT_WORK_ITEM Item;
+ PINTERNAL_NDIS_MINIPORT_WORK_ITEM Item;
+ PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
- NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
-
- ASSERT(Adapter);
- ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
-
+ NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
+
+ ASSERT(Adapter);
+ ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
+
#if 0
- if (Adapter->WorkQueueLevel < NDIS_MINIPORT_WORK_QUEUE_SIZE - 1)
+ if (Adapter->WorkQueueLevel < NDIS_MINIPORT_WORK_QUEUE_SIZE - 1)
{
- Item = &Adapter->WorkQueue[Adapter->WorkQueueLevel];
- Adapter->WorkQueueLevel++;
+ Item = &Adapter->WorkQueue[Adapter->WorkQueueLevel];
+ Adapter->WorkQueueLevel++;
}
- else
+ else
#endif
{
- Item = ExAllocatePool(NonPagedPool,
sizeof(NDIS_MINIPORT_WORK_ITEM));
- if (Item == NULL)
+ Item = ExAllocatePool(NonPagedPool,
sizeof(INTERNAL_NDIS_MINIPORT_WORK_ITEM));
+ if (Item == NULL)
{
- NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
- return NDIS_STATUS_RESOURCES;
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
+ return NDIS_STATUS_RESOURCES;
}
}
-
- Item->WorkItemType = WorkItemType;
- Item->WorkItemContext = WorkItemContext;
-
- /* safe due to adapter lock held */
- Item->Link.Next = NULL;
- if (!Adapter->WorkQueueHead)
+
+ Item->AdapterBinding = AdapterBinding;
+ Item->RealWorkItem.WorkItemType = WorkItemType;
+ Item->RealWorkItem.WorkItemContext = WorkItemContext;
+
+ /* safe due to adapter lock held */
+ Item->Link.Next = NULL;
+ if (!Adapter->WorkQueueHead)
{
- Adapter->WorkQueueHead = Item;
- Adapter->WorkQueueTail = Item;
+ Adapter->WorkQueueHead = Item;
+ Adapter->WorkQueueTail = Item;
}
- else
+ else
{
- Adapter->WorkQueueTail->Link.Next = (PSINGLE_LIST_ENTRY)Item;
- Adapter->WorkQueueTail = Item;
+ Adapter->WorkQueueTail->Link.Next = (PSINGLE_LIST_ENTRY)Item;
+ Adapter->WorkQueueTail = Item;
}
-
- KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
-
- return NDIS_STATUS_SUCCESS;
+
+ KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
+
+ return NDIS_STATUS_SUCCESS;
}
@@ -680,12 +699,14 @@
FASTCALL
MiniDequeueWorkItem(
PLOGICAL_ADAPTER Adapter,
+ PADAPTER_BINDING *AdapterBinding,
NDIS_WORK_ITEM_TYPE *WorkItemType,
PVOID *WorkItemContext)
/*
* FUNCTION: Dequeues a work item from the work queue of a logical
adapter
* ARGUMENTS:
* Adapter = Pointer to the logical adapter object to
dequeue work item from
+ * AdapterBinding = Address of buffer for adapter binding for this
request
* WorkItemType = Address of buffer for work item type
* WorkItemContext = Address of buffer for pointer to context
information
* NOTES:
@@ -694,52 +715,55 @@
* Status of operation
*/
{
- PNDIS_MINIPORT_WORK_ITEM Item;
-
- NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
-
- Item = Adapter->WorkQueueHead;
-
- if (Item)
+ PINTERNAL_NDIS_MINIPORT_WORK_ITEM Item;
+
+ NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
+
+ Item = Adapter->WorkQueueHead;
+
+ if (Item)
{
- /* safe due to adapter lock held */
- Adapter->WorkQueueHead =
(PNDIS_MINIPORT_WORK_ITEM)Item->Link.Next;
-
- if (Item == Adapter->WorkQueueTail)
- Adapter->WorkQueueTail = NULL;
-
- *WorkItemType = Item->WorkItemType;
- *WorkItemContext = Item->WorkItemContext;
-
- ExFreePool(Item);
-
- return NDIS_STATUS_SUCCESS;
+ /* safe due to adapter lock held */
+ Adapter->WorkQueueHead =
(PINTERNAL_NDIS_MINIPORT_WORK_ITEM)Item->Link.Next;
+
+ if (Item == Adapter->WorkQueueTail)
+ Adapter->WorkQueueTail = NULL;
+
+ *AdapterBinding = Item->AdapterBinding;
+ *WorkItemType = Item->RealWorkItem.WorkItemType;
+ *WorkItemContext = Item->RealWorkItem.WorkItemContext;
+
+ ExFreePool(Item);
+
+ return NDIS_STATUS_SUCCESS;
}
-
- return NDIS_STATUS_FAILURE;
+
+ return NDIS_STATUS_FAILURE;
}
NDIS_STATUS
MiniDoRequest(
- PLOGICAL_ADAPTER Adapter,
+ PADAPTER_BINDING AdapterBinding,
PNDIS_REQUEST NdisRequest)
/*
* FUNCTION: Sends a request to a miniport
* ARGUMENTS:
- * Adapter = Pointer to logical adapter object
- * NdisRequest = Pointer to NDIS request structure describing
request
+ * AdapterBinding = Pointer to binding used in the request
+ * NdisRequest = Pointer to NDIS request structure describing
request
* RETURNS:
* Status of operation
*/
{
- NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
+ PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
- Adapter->NdisMiniportBlock.MediaRequest = NdisRequest;
-
- switch (NdisRequest->RequestType)
+ NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
+
+ Adapter->NdisMiniportBlock.MediaRequest = NdisRequest;
+
+ switch (NdisRequest->RequestType)
{
- case NdisRequestQueryInformation:
+ case NdisRequestQueryInformation:
return (*Adapter->Miniport->Chars.QueryInformationHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
NdisRequest->DATA.QUERY_INFORMATION.Oid,
@@ -748,8 +772,8 @@
(PULONG)&NdisRequest->DATA.QUERY_INFORMATION.BytesWritten,
(PULONG)&NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded);
break;
-
- case NdisRequestSetInformation:
+
+ case NdisRequestSetInformation:
return (*Adapter->Miniport->Chars.SetInformationHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
NdisRequest->DATA.SET_INFORMATION.Oid,
@@ -758,8 +782,8 @@
(PULONG)&NdisRequest->DATA.SET_INFORMATION.BytesRead,
(PULONG)&NdisRequest->DATA.SET_INFORMATION.BytesNeeded);
break;
-
- default:
+
+ default:
return NDIS_STATUS_FAILURE;
}
}
@@ -800,11 +824,14 @@
NDIS_STATUS NdisStatus;
PVOID WorkItemContext;
NDIS_WORK_ITEM_TYPE WorkItemType;
+ PADAPTER_BINDING AdapterBinding;
PLOGICAL_ADAPTER Adapter = GET_LOGICAL_ADAPTER(DeferredContext);
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
- NdisStatus = MiniDequeueWorkItem(Adapter, &WorkItemType,
&WorkItemContext);
+ NdisStatus =
+ MiniDequeueWorkItem
+ (Adapter, &AdapterBinding, &WorkItemType, &WorkItemContext);
if (NdisStatus == NDIS_STATUS_SUCCESS)
{
@@ -873,7 +900,7 @@
break;
case NdisWorkItemRequest:
- NdisStatus = MiniDoRequest(Adapter,
(PNDIS_REQUEST)WorkItemContext);
+ NdisStatus = MiniDoRequest(AdapterBinding,
(PNDIS_REQUEST)WorkItemContext);
if (NdisStatus == NDIS_STATUS_PENDING)
break;
@@ -882,10 +909,12 @@
{
case NdisRequestQueryInformation:
NdisMQueryInformationComplete((NDIS_HANDLE)Adapter,
NdisStatus);
+ MiniRequestComplete( AdapterBinding,
(PNDIS_REQUEST)WorkItemContext, NdisStatus );
break;
case NdisRequestSetInformation:
NdisMSetInformationComplete((NDIS_HANDLE)Adapter,
NdisStatus);
+ MiniRequestComplete( AdapterBinding,
(PNDIS_REQUEST)WorkItemContext, NdisStatus );
break;
default:
_____
Modified: trunk/reactos/drivers/net/ndis/ndis/protocol.c
--- trunk/reactos/drivers/net/ndis/ndis/protocol.c 2005-05-20
06:21:01 UTC (rev 15428)
+++ trunk/reactos/drivers/net/ndis/ndis/protocol.c 2005-05-20
08:06:27 UTC (rev 15429)
@@ -158,7 +158,7 @@
/* MiniQueueWorkItem must be called at IRQL >= DISPATCH_LEVEL */
if (QueueWorkItem)
{
- MiniQueueWorkItem(Adapter, NdisWorkItemRequest,
(PVOID)NdisRequest);
+ MiniQueueWorkItem(AdapterBinding, NdisWorkItemRequest,
(PVOID)NdisRequest);
KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
return NDIS_STATUS_PENDING;
}
@@ -169,7 +169,7 @@
/* TODO (?): move the irql raise into MiniDoRequest */
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
{
- NdisStatus = MiniDoRequest(Adapter, NdisRequest);
+ NdisStatus = MiniDoRequest(AdapterBinding, NdisRequest);
NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
@@ -278,7 +278,7 @@
if (QueueWorkItem)
{
- MiniQueueWorkItem(Adapter, NdisWorkItemSendLoopback,
(PVOID)Packet);
+ MiniQueueWorkItem(AdapterBinding, NdisWorkItemSendLoopback,
(PVOID)Packet);
return NDIS_STATUS_PENDING;
}
@@ -315,7 +315,7 @@
/* This is a normal send packet, not a loopback packet. */
if (QueueWorkItem)
{
- MiniQueueWorkItem(Adapter, NdisWorkItemSend, (PVOID)Packet);
+ MiniQueueWorkItem(AdapterBinding, NdisWorkItemSend,
(PVOID)Packet);
NDIS_DbgPrint(MAX_TRACE, ("Queued a work item and returning\n"));
return NDIS_STATUS_PENDING;
}