Re: Direct Copying To Share Memory In NDIS ProtocolReceive
- From: "Thomas F. Divine" <tdivine@NOpcausaSPAM>
- Date: Fri, 2 Mar 2007 02:02:55 -0500
"Le Chaud Lapin" <jaibuduvin@xxxxxxxxx> wrote in message news:1172798341.812254.5470@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Mar 1, 1:17 pm, "Thomas F. Divine" <tdivine@NOpcausaSPAM> wrote:Surely with enough work and debugging you can get your scheme to work. Do sit back and seriously consider my personal motto: "Keep it simple, stupid!".Best approach is still to use standard DeviceIocontrol or Read instead of
shared memory. The effect you seek is achievable using this method.
Use Read with DO_DIRECT_IO. Application allocates large structured buffer
with room for seveveral (many) packets. Driver uses
MmGetSystemAddressForMdlSafe to map buffer to kernel memory. Then pends the
read and stashes buffer and IRP internally. Driver fills buffer with
multiple packets and eventually completes the read IRP.
This minimizes user-kernel transitions (i.e, number of I/O calls) - which is
a performance killer. Also, there is no memory copy between user-mode buffer
and kernel-mode buffer (because DO_DIRECT_IO was used). In addition, driver
is safely informed (via Cleanup/Close callbacks) when application leaves the
building.
Improvements on this include 1.) having multiple concurrent Reads in
progress so driver already has another Read buffer queued when current one
becomes filled and 2.) having a timer that will complete a Read eventually
even if buffer is not filled.
This, or variations on this, should work for you withoug having to have
shared memory and events that are not part of the standard I/O scheme.
Hi Thomas,
I thought this was essentially the same thing I was proposing. The
difference seems to be that, in your method, the large buffer is
specified in user-space before ReadFile is invoked. In the scheme I
was proposing, the large buffer is always available, in the shared
section consisting of frame slots, and the driver has to figure out
which of the frame slots in the section are free while inside
ProtocolReceive. Naturally, in my scheme, I would lock the shared
section from birth to death and exercise caution in cleanup.
A critical design criteria is that all received packets _must_
ultimately be written to the shared section, so ideally, I would like
to avoid a secondary copy, and write straight to the sections. But
there are 3 applications and N drivers that share the section, and
they compete for slots using global semaphore (by design), so if I pre-
allocated a chunk of slots in ReadFile, I could end up being overly
greedy, taking away valuable slots from the other two processes or
drivers that might need them. There would be waste if ReadFile
overallocates. This is why I was thinking about my original plan.
The driver can fill as many frame slots in the shared section as
possible, never consuming more slots than it actually needs, and when
the user-mode code cycles around to ReadFile, waiting for it will be a
chunk of frame slots ready to be read, but not by pulling up the
packets, but by pulling up the the array of indexes of slots that were
filled by ProtocolReceive.
-Le Chaud Lapin-
Good luck,
Thomas F. Divine
.
- Follow-Ups:
- Re: Direct Copying To Share Memory In NDIS ProtocolReceive
- From: Le Chaud Lapin
- Re: Direct Copying To Share Memory In NDIS ProtocolReceive
- References:
- Direct Copying To Share Memory In NDIS ProtocolReceive
- From: Le Chaud Lapin
- Re: Direct Copying To Share Memory In NDIS ProtocolReceive
- From: Thomas F. Divine
- Re: Direct Copying To Share Memory In NDIS ProtocolReceive
- From: Le Chaud Lapin
- Direct Copying To Share Memory In NDIS ProtocolReceive
- Prev by Date: Re: BUILD 6000 and dependecies
- Next by Date: Re: SetupDiCallClassInstaller(DIF_INSTALLDEVICE, ... fails installing
- Previous by thread: Re: Direct Copying To Share Memory In NDIS ProtocolReceive
- Next by thread: Re: Direct Copying To Share Memory In NDIS ProtocolReceive
- Index(es):
Relevant Pages
|