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.

svn path=/trunk/; revision=15429
This commit is contained in:
Art Yerkes 2005-05-20 08:06:27 +00:00
parent 188f2022f6
commit 4a15530e10
5 changed files with 115 additions and 76 deletions

View file

@ -8,7 +8,7 @@ TARGET_NAME = ndis
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

View file

@ -10,6 +10,7 @@
#include <ndissys.h>
struct _ADAPTER_BINDING;
typedef struct _HARDWARE_ADDRESS {
union {
@ -77,9 +78,9 @@ typedef struct _LOGICAL_ADAPTER
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 @@ MiniQueryInformation(
NDIS_STATUS
FASTCALL
MiniQueueWorkItem(
PLOGICAL_ADAPTER Adapter,
struct _ADAPTER_BINDING *AdapterBinding,
NDIS_WORK_ITEM_TYPE WorkItemType,
PVOID WorkItemContext);
@ -153,12 +154,13 @@ NDIS_STATUS
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

View file

@ -27,6 +27,14 @@ typedef struct _ATM_ADDRESS *PATM_ADDRESS;
#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"

View file

@ -327,6 +327,23 @@ MiniResetComplete(
}
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,
@ -615,7 +632,7 @@ MiniQueryInformation(
NDIS_STATUS
FASTCALL
MiniQueueWorkItem(
PLOGICAL_ADAPTER Adapter,
PADAPTER_BINDING AdapterBinding,
NDIS_WORK_ITEM_TYPE WorkItemType,
PVOID WorkItemContext)
/*
@ -630,49 +647,51 @@ MiniQueueWorkItem(
* Status of operation
*/
{
PNDIS_MINIPORT_WORK_ITEM Item;
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
ASSERT(Adapter);
ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
PINTERNAL_NDIS_MINIPORT_WORK_ITEM Item;
PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
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 @@ NDIS_STATUS
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 @@ MiniDequeueWorkItem(
* 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 @@ MiniDoRequest(
(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 @@ MiniDoRequest(
(PULONG)&NdisRequest->DATA.SET_INFORMATION.BytesRead,
(PULONG)&NdisRequest->DATA.SET_INFORMATION.BytesNeeded);
break;
default:
default:
return NDIS_STATUS_FAILURE;
}
}
@ -800,11 +824,14 @@ VOID STDCALL MiniportDpc(
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 @@ VOID STDCALL MiniportDpc(
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 @@ VOID STDCALL MiniportDpc(
{
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:

View file

@ -158,7 +158,7 @@ ProRequest(
/* 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 @@ ProRequest(
/* 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 @@ ProSend(
if (QueueWorkItem)
{
MiniQueueWorkItem(Adapter, NdisWorkItemSendLoopback, (PVOID)Packet);
MiniQueueWorkItem(AdapterBinding, NdisWorkItemSendLoopback, (PVOID)Packet);
return NDIS_STATUS_PENDING;
}
@ -315,7 +315,7 @@ ProSend(
/* 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;
}