NdisMAllocateSharedMemory

Hi,
Could anybody explain the correct usage of the NdisMAllocateSharedMemory?
DDK says that MiniportInitialize must call NdisMAllocateMapRegisters before
it calls NdisMAllocateSharedMemory; otherwise, no memory can be allocated.
I don’t realy understand what this NdisMAllocateMapRegisters is and why do
we need map registers for busmaster NIC DMA?
thanks in advance.
RG


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

You need to call NdisMAllocateMapRegisters from your driver, but it may not
always be from miniport initialize, the function must be called from passive
level.

It basically keep track which area’s of the memory are being accessed by the
BudMaster DMA NIC, it also gives you the physical addresses and the
fragments for the nic.

This needs to be done before allocation shared memory since these map
register must be used for the Tx side using NdisMStartBufferPhysicalMapping
and NdisMCompletePhysicalMapping of the Tx side and the SharedMemory is used
for teh receive side.

This is only required for serial drivers, for deserial driver of bus
mastering NICs, they don’t need to use map registers, they can use the out
of band data to extract the data for the packet to be given to the nic, you
must indicate to the OS using NdisMInitializeScatterGatherDMA.

Ramit.

----- Original Message -----
From: “Roman Geller”
To: “NT Developers Interest List”
Sent: Tuesday, June 12, 2001 3:24 PM
Subject: [ntdev] NdisMAllocateSharedMemory

> Hi,
> Could anybody explain the correct usage of the NdisMAllocateSharedMemory?
> DDK says that MiniportInitialize must call NdisMAllocateMapRegisters
before
> it calls NdisMAllocateSharedMemory; otherwise, no memory can be allocated.
> I don’t realy understand what this NdisMAllocateMapRegisters is and why do
> we need map registers for busmaster NIC DMA?
> thanks in advance.
> RG
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@wipro.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Ramit,
what is the number of map registers in general that should be allocated?
What does this number depend on?

thx
RG

-----Original Message-----
From: Ramit Bhalla [mailto:xxxxx@wipro.com]
Sent: Tuesday, June 12, 2001 12:14 PM
To: NT Developers Interest List
Subject: [ntdev] Re: NdisMAllocateSharedMemory

You need to call NdisMAllocateMapRegisters from your driver, but it may not
always be from miniport initialize, the function must be called from passive
level.

It basically keep track which area’s of the memory are being accessed by the
BudMaster DMA NIC, it also gives you the physical addresses and the
fragments for the nic.

This needs to be done before allocation shared memory since these map
register must be used for the Tx side using NdisMStartBufferPhysicalMapping
and NdisMCompletePhysicalMapping of the Tx side and the SharedMemory is used
for teh receive side.

This is only required for serial drivers, for deserial driver of bus
mastering NICs, they don’t need to use map registers, they can use the out
of band data to extract the data for the packet to be given to the nic, you
must indicate to the OS using NdisMInitializeScatterGatherDMA.

Ramit.

----- Original Message -----
From: “Roman Geller”
To: “NT Developers Interest List”
Sent: Tuesday, June 12, 2001 3:24 PM
Subject: [ntdev] NdisMAllocateSharedMemory

> Hi,
> Could anybody explain the correct usage of the NdisMAllocateSharedMemory?
> DDK says that MiniportInitialize must call NdisMAllocateMapRegisters
before
> it calls NdisMAllocateSharedMemory; otherwise, no memory can be allocated.
> I don’t realy understand what this NdisMAllocateMapRegisters is and why do
> we need map registers for busmaster NIC DMA?
> thanks in advance.
> RG
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@wipro.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@envara.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

You require one map register for each buffer in a packet, and you must not
reuse map registers without returning them, that is to say once you do a
NdisMStartBufferPhysicalMapping you should not reuse the map register before
calling NdisMCompleteBufferPhysicalMapping, which comes with the packet Tx.
complete interrupt.

U can allocate a few map registers ( like required by XP, anything more the
40 map registers will cause an assertion for XP in a the check build version
after enabling certain registry keys ), the limit being 64K, but the fewer
the better.

It actually depends upon the card speed, for instance I have developed a
driver for a Gig Card and I’m using about 1000 map register in Gig mode.

For lower speeds u can calculate how many u need.

For instance - assuming you are using the sendpackets handler -

Map Register required = Number of packets in an array * Number of
buffers in a packet * Delay factor for interrupt.

The number of packets in an array is decided by how much you indicate to
NDIS and how many packets you can process at one shot from the array that
NDIS sends you.

The Buffer is an average count, you can print average number of buffers you
are gettting per packet.

The Delay factor is the number of packet that the card will send before
generating a Tx Completion interrupt. This can be programmed ( as in my case
I have programmed it to 100 us ) or it can taken an average from the card.
That is meaning to say that the delay factor is basically the time for which
the packets lie with the card/driver and not returned to NDIS with by
calling NdisMCompleteBufferPhysicalMapping. This can vary from card to card
and also depends upon the speed of operation. That is during this time the
map register that have been used are blocked and cannot be used again till
they are freed, so you must have some more map registers ( IF YOU ARE USING
AN ASYNCHRONOUS SEND ) so that if NDIS given you any more packets, then you
have map registers to send them. For a synchronous send, that is you DON’T
call NdisMSendCompete, then your delay factor is 1 since you cannot have
more than one send at a time.

One last word of caution, map registers are a very painful thing, if you
lose them or resuse them improperly then you have many panics, I have faced
innumerable problems with them at veyr high speeds of Tx. Try to use them
scarcely and keep a very good tab on them.
Best still would be to go over to deserial drivers, as I think Microsoft is
pushing for them from XP onwards, it has no concept of map registers.

But those are my comments anyway,

Best Of Luck

Ramit.

----- Original Message -----
From: “Roman Geller”
To: “NT Developers Interest List”
Sent: Tuesday, June 12, 2001 7:56 PM
Subject: [ntdev] Re: NdisMAllocateSharedMemory

> Ramit,
> what is the number of map registers in general that should be allocated?
> What does this number depend on?
>
>
> thx
> RG
>
> -----Original Message-----
> From: Ramit Bhalla [mailto:xxxxx@wipro.com]
> Sent: Tuesday, June 12, 2001 12:14 PM
> To: NT Developers Interest List
> Subject: [ntdev] Re: NdisMAllocateSharedMemory
>
>
> You need to call NdisMAllocateMapRegisters from your driver, but it may
not
> always be from miniport initialize, the function must be called from
passive
> level.
>
> It basically keep track which area’s of the memory are being accessed by
the
> BudMaster DMA NIC, it also gives you the physical addresses and the
> fragments for the nic.
>
> This needs to be done before allocation shared memory since these map
> register must be used for the Tx side using
NdisMStartBufferPhysicalMapping
> and NdisMCompletePhysicalMapping of the Tx side and the SharedMemory is
used
> for teh receive side.
>
> This is only required for serial drivers, for deserial driver of bus
> mastering NICs, they don’t need to use map registers, they can use the out
> of band data to extract the data for the packet to be given to the nic,
you
> must indicate to the OS using NdisMInitializeScatterGatherDMA.
>
> Ramit.
>
> ----- Original Message -----
> From: “Roman Geller”
> To: “NT Developers Interest List”
> Sent: Tuesday, June 12, 2001 3:24 PM
> Subject: [ntdev] NdisMAllocateSharedMemory
>
>
> > Hi,
> > Could anybody explain the correct usage of the
NdisMAllocateSharedMemory?
> > DDK says that MiniportInitialize must call NdisMAllocateMapRegisters
> before
> > it calls NdisMAllocateSharedMemory; otherwise, no memory can be
allocated.
> > I don’t realy understand what this NdisMAllocateMapRegisters is and why
do
> > we need map registers for busmaster NIC DMA?
> > thanks in advance.
> > RG
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@wipro.com
> > To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@envara.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
> —
> You are currently subscribed to ntdev as: xxxxx@wipro.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Ramit,

You require one map register for each buffer in a packet, and you must not
reuse map registers without returning them, that is to say once you do a
NdisMStartBufferPhysicalMapping you should not reuse the map register before
calling NdisMCompleteBufferPhysicalMapping, which comes with the packet Tx.
complete interrupt.

Why do you refer only to Tx side? Why don’t we need map registers for Rx
side?

One last word of caution, map registers are a very painful thing, if you
lose them or resuse them improperly then you have many panics, I have faced
innumerable problems with them at veyr high speeds of Tx. Try to use them
scarcely and keep a very good tab on them.
Best still would be to go over to deserial drivers, as I think Microsoft is
pushing for them from XP onwards, it has no concept of map registers.

Isn’t the DDK’ s E100Bex example deserialized driver? Even being deserial
driver E100Bex still uses map registers on its Tx side. Could you explain
that?

thx

RG


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com