RE: NT Deserial driver and MiniportReturnPacket

As you’ve written, deserialized NDIS drivers aren’t documented for NT and
there can be some differences. I wrote my driver several years before when
the only documentation for deserialized drivers was ImSamp code and short
document attached. So I used the same method as for serialized drivers i.e.
examine packet status after NdisMIndicateReceive() return and when isn’t
pending, regain ownership of the packet. When pending, let it be until
MiniportReceivePacket() is called. We did many stress tests with this driver
and never encountered a problem. Also, I’ve never received a report about a
crash caused by this driver from customers. Well, this means virtually
nothing about correctness of this method. I wasn’t aware about any problem
there until read w2k DDK docs. Yes, there are race conditions if
MiniportReturnPacket() is called before NdisMIndicateReceive() returns and
frees packet. Examining status would touch non-existent packet and this is
probably the reason why we must not touch it. However, this project was
already closed and I decided to not change it until real problem occurs
(don’t fix what is working…).

There is probably a difference between NT4 and w2k NDIS implementation and
the first one doesn’t depend on Status field on input. I only guess, correct
answer could give you somebody from m$ or somebody who disassembled this
part of NDIS. This is what I recommend you: disassemble NDIS or trace
through NdisMIndicateReceive() function to see how the packet status is
processed (a memory breakpoint on Status field should be enough). Or maybe
anybody else has experience with it and give us better method.

BTW, I’ve found that only one of MiniportReturnPacket() and
MiniportTransferData() can be set in NT4 IM driver. NDIS makes some
assumptions based on these values and setting both handlers causes problems.
It implies that driver can use only one method for packet indication (which
is normally sufficient).

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]


From: Ramit Bhalla[SMTP:xxxxx@wipro.com]
Sent: Tuesday, February 27, 2001 9:56 AM
To: NT Developers Interest List
Subject: NT Deserial driver and MiniportReturnPacket

Hi,

I’m developing a NT Deserial driver.
I’m using a version of ndis.h and ndis.lib that was given to me by someone
at microsoft. I’m also using sp6.

The problem is no matter what i try the MiniportReturnPacket function is
not being called by NDIS.
I’m going by the documentation of Win2K since there is no documentation
for NT and deserial support.

I have tried setting the packet status to everything and nothing seems to
work. No matter what I try it doesn’t call my miniportreturnpacket
function.
The only way i’ve found around this is setting the packet status to
RESOURCES, but this hits the performance drastically.

The same driver is also adapter to run as a serial driver that is when the
DESERIAL flag is not set. Then it function fine and the
minportreturnpacket is called, as soon as I specify the DESERIAL flag, it
stops calling the miniportreturn packet.

This driver has a common source code for NDIS 4 and NDIS 5, that is it
also runs on win2K and it runs absolutely perfectly and the
miniportreturnpacket function is called.
I’m only facing this problem on WINNT.

Has anyone seen this problem and I’ll appreciate any help/clue to this
problem.
Does anyone know about any documentation related to this???

Thanks
Ramit.


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

I just found out that there are some issues in the return packet logic of
NDIS in NT4.0. You should implement your code based on the logic given in
the “Multipacket Receives from Connectionless and Connection-Oriented
Miniports” section.

According to that:

The driver keeps two addtional flags in its receive packet reserved area.
these are fInRcvDpc and fReturnPacketsCalled.

Before you indicate a packet to ndis you do the following. This code will
note that a packet is in the context of a receive indication. It will also
check when the receive indication returns if the packet was completed
synchronously or if the packet was returned to the miniport while it was in
the indication routine. If any of these cases are true then you requeue the
packet for later use as it has been returned to me.

NdisAcquireSpinLock(&RcvLock);
Packet->fInRcvDpc = TRUE;
Packet->fReturnPacketsCalled = FALSE;
NdisReleaseSpinLock(&RcvLock);

NdisMIndicateReceivePacket();

NdisAcquireSpinLock(&RcvLock);
Packet->fInRcvDpc = FALSE;

Status = NDIS_GET_PACKET_STATUS(Packet);
if ((NDIS_STATUS_SUCCESS == Status) || (NDIS_STATUS_RESOURCES == Status) ||
((NDIS_STATUS_PENDING == Status) && Packet->fReturnPacketsCalled))
{
ProcessReturnPacket(packet);
}

NdisReleaseSpinLock(&RcvLock);

In your MiniportReturnPacket routine you do the following. This checks to
see if a packet that is being returned by the protocol is returned in the
context of the indication. If so then it simply sets a flag noting that the
protocol’s processing of the packet is complete and returns so that the
miniport’s indication code can do the clean up on it. If we are not in the
context of the indication then we will do the clean up here.

NdisAcquireSpinLock(&RcvLock);
if (Packet->fInRcvDpc)
{
Packet->fReturnPacketsCalled = TRUE;
NdisReleaseSpinLock(&RcvLock);
return;
}

NdisReleaseSpinLock(&RcvLock);

ProcessReturnPacket(Packet);

-Eliyas

-----Original Message-----
From: Ramit Bhalla [mailto:xxxxx@wipro.com]
Sent: Tuesday, February 27, 2001 12:57 AM
To: NT Developers Interest List
Subject: NT Deserial driver and MiniportReturnPacket

Hi,

I’m developing a NT Deserial driver.
I’m using a version of ndis.h and ndis.lib that was given to me by someone
at microsoft. I’m also using sp6.

The problem is no matter what i try the MiniportReturnPacket function is not
being called by NDIS.
I’m going by the documentation of Win2K since there is no documentation for
NT and deserial support.

I have tried setting the packet status to everything and nothing seems to
work. No matter what I try it doesn’t call my miniportreturnpacket function.
The only way i’ve found around this is setting the packet status to
RESOURCES, but this hits the performance drastically.

The same driver is also adapter to run as a serial driver that is when the
DESERIAL flag is not set. Then it function fine and the minportreturnpacket
is called, as soon as I specify the DESERIAL flag, it stops calling the
miniportreturn packet.

This driver has a common source code for NDIS 4 and NDIS 5, that is it also
runs on win2K and it runs absolutely perfectly and the miniportreturnpacket
function is called.
I’m only facing this problem on WINNT.

Has anyone seen this problem and I’ll appreciate any help/clue to this
problem.
Does anyone know about any documentation related to this???

Thanks
Ramit.


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