Re: NDIS functionality details
- From: "Thomas F. Divine [DDK MVP]" <tdivine@xxxxxxxxxxxxxxxx>
- Date: Tue, 21 Jun 2005 17:25:05 -0400
<v_mirgorodsky@xxxxxxxxx> wrote in message news:1119386236.130332.158100@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello Maxim,
Thanks for your answer.
Maxim S. Shatskih wrote:Depends on module kind. In protocol - yes. In filter/IM - yes. In adapter
driver talking directly to hardware (like PCI) - the so-called miniport - no.
In adapter driver talking to underlying software (like USB) - the so-called
NDIS-WDM miniport - yes.
Is there any strict rule, which defines what functions may be used within NDIS driver and which should/must be avoided? Or this is just a matter of experience?
If it is a true NDIS miniport, then NDIS functions only.
All others - try to use NDIS unless there is no alternative.
A NDIS protocol or the lower "protocol edge" of a NDIS IM driver has two possible callbacks for receiving packets:> What actually happen during NdisTransferData() call? Does the function > actually copy data from source packet to destination packet or it just > copies the pointers to data buffers from source packet to destination > packet?
It calls the miniport's TransferDataHandler. The latter copies the data from
the hardware to the protocol-provided NDIS_PACKET.
So, in time I got the packet into my ProtocolReceivePacket() handler it may not be even in physical memory? I am planning to do most of the work through ProtocolReceivePacket() handler. Will it be optimal to copy data to some bigger intermidiate buffer right away? The second approach is to delay copying and overlap it with data processing later. I expect to receive about 100MB of compressed data per second. Then I need either decompress them in kernel thread or store them in compressed form to disk. In any case saving on 200MB memory bandwidth would be a big deel.
1.) ProtocolReceive 2.) ProtocolReceivePacket
NdisTransferData is ONLY involved in the ProtocolReceive path. And even then only in cases where the underlying miniport really sucks. In ProtocolReceive you should first check to see if LookaheadBufferSize == PacketSize; if so, then you have the whole packet already available (combine HeaderBuffer+LookaheadBuffer) and there will be no need to call NdisTransferData at all.
On some old adapters (actually, old miniport drivers) you will find cases where LookaheadBufferSize < ProtocolSize. You must deal with this case by calling NdisTransferData.
A word or warning: Never assume that NdisGetReceivedPacket will be successful.
Packet data presented at the ProtocolReceive handler is ephemeral. If you want the data, you must make a copy before returning from your ProtocolReceive handler.
Now, when you are handling packets in the (optional) ProtocolReceivePacket handler you do NOT deal with NdisTransferData at all. You have the entire packet. And you can temporarily acquire possesion of the original packet by returning a non-zero value as described in the DDK.
Hope this helps.
Thomas F. Divine, Windows DDK MVP http://www.pcausa.com
-- Maxim Shatskih, Windows DDK MVP StorageCraft Corporation maxim@xxxxxxxxxxxxxxxx http://www.storagecraft.com
.
- Follow-Ups:
- Re: NDIS functionality details
- From: v_mirgorodsky
- Re: NDIS functionality details
- References:
- NDIS functionality details
- From: v_mirgorodsky
- Re: NDIS functionality details
- From: Maxim S. Shatskih
- Re: NDIS functionality details
- From: v_mirgorodsky
- NDIS functionality details
- Prev by Date: Re: NDIS functionality details
- Next by Date: Mapping kernel memory to user space
- Previous by thread: Re: NDIS functionality details
- Next by thread: Re: NDIS functionality details
- Index(es):
Relevant Pages
|