Re: NdisMAllocateNetBufferSGList Question by Alireza
Alireza
Sun Mar 16 16:47:45 CDT 2008
Yes, you must call NdisMAllocateNetBufferSGList at DISPATCH as spec
requested. NdisMAllocateNetBufferSGList is a wrapper around
BuildScatterGatherList or
GetScatterGatherList that DDK requires to be called at DISPATCH. I don't
remember why these two APIs themselves needed to be called at DISPATCH.
Maybe so they can take advantage of DISPATCH level and doing some lock free
per processor synchronization. Maybe something else.
-ali
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter" <ImInSoquel@nospam.nospam> wrote in message
news:uU20u24hIHA.536@TK2MSFTNGP06.phx.gbl...
>I added the following code to the callback:
>
> ULONG DispatchLevel = NDIS_CURRENT_IRQL();
> ASSERT(DispatchLevel == DISPATCH_LEVEL);
>
> When I hit the assert in the callback, DispatchLevel was 0
> (PASSIVE_LEVEL).
>
> I have since gotten around this by adding the following code in my
> MiniportSendNetBufferLists function:
>
> if (NDIS_TEST_SEND_AT_DISPATCH_LEVEL(SendFlags))
> {
> OldIrql = KeRaiseIrqlToDpcLevel();
> }
>
> SendStatus = NdisMAllocateNetBufferSGList(
> Adapter->NdisMiniportDmaHandle,
> NetBufferToSend,
> pMpTcb,
> NDIS_SG_LIST_WRITE_TO_DEVICE,
> pMpTcb->ScatterGatherListBuffer,
> Adapter->ScatterGatherListSize);
>
> if (NDIS_TEST_SEND_AT_DISPATCH_LEVEL(SendFlags))
> {
> KeLowerIrql(OldIrql);
> }
>
> So, it appears that neither BuildScatterGatehList or GetScatterGatherList
> raises the IRQL to DISPATCH and the caller needs to insure that the IRQL
> is raised before calling NdisMAllocateNetBufferSGList. While the WDK says
> that NdisMAllocateNetBufferSGList needs to be called at DISPATCH, it is
> not explicit as to why this is needed. We have been calling
> NdisMAllocateNetBufferSGList from PASSIVE in our SendNBL function and did
> not see any side-effects until recently when we tried to change
> NdisAcquireSpinLock to NdisDprAcquireSpinLock in our callback.
>
> Thanks!
>
>
> "Alireza Dabagh [MS]" <alid@online.microsoft.com> wrote in message
> news:u501bozhIHA.5204@TK2MSFTNGP02.phx.gbl...
>> NdisMAllocateNetBufferSGList is a wrapper around BuildScatterGatherList
>> or GetScatterGatherList and the callbacks passed to these functions
>> according to DDK would be called at DISPATCH level. How do you know your
>> callback is called at PASSIVE?
>>
>> from MSDN:
>> ExecutionRoutine
>> Pointer to a driver-supplied AdapterListControl routine, which is called
>> at IRQL = DISPATCH_LEVEL when the system DMA controller or bus-master
>> adapter is available
>>
>> -ali
>>
>> --
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>> "Peter" <ImInSoquel@nospam.nospam> wrote in message
>> news:epqzCpZhIHA.3940@TK2MSFTNGP05.phx.gbl...
>>> Sorry...this is really a question about MiniportProcessSGList on NDIS
>>> 6.1.
>>>
>>> "Peter" <ImInSoquel@nospam.nospam> wrote in message
>>> news:eLu0GmZhIHA.3780@TK2MSFTNGP06.phx.gbl...
>>>> The WDK says that this callback will be made at IRSL==DISPATCH.
>>>> However, I'm
>>>> seeing this can be called at IRQL==PASSIVE. Here's the output from
>>>> vertarget
>>>> to show the version of the OS I'm seeing this on:
>>>>
>>>> Windows Kernel Version 6001 (Service Pack 1) MP (1 procs) Free x86
>>>> compatible
>>>> Product: Server, suite: Enterprise TerminalServer SingleUserTS
>>>> Built by: 6001.18000.x86fre.longhorn_rtm.080118-1840
>>>> Kernel base = 0x81617000 PsLoadedModuleList = 0x8172ec70
>>>>
>>>> So, is the WDK wrong about this?
>>>>
>>>>
>>>>
>>>
>>>
>>
>
>