none
Problem with NDIS Miniport RRS feed

  • Question

  • I am developing a NDIS driver.  The application is to take packets from the bottom of the protocol stack and send them by an experimental transport system to another node and to reintroduce them at the bottom of the stack there for NDIS to process.

    So I put together a driver using the netvmini example and some other sample code.  I create the miniport with a medium type of NdisMediumIP.  I create a device that when read gets a packet from the driver and when written injects a packet into the system.

    We want to run with NdisMediumIP for several reasons.  First, we don’t have addressing that matches Ethernet’s very well and second the system is most efficient with very long packets, so we want to support MSL longer than 1500 bytes.  Right now we are only trying to deal with IPV4, we will consider IPV6 later.

    So, the read side is working well, if I ping or I send UDP packets my driver gets them, they get to user level and they get sent.  The receive side, well that’s the problem… I get the packets send down to the device; I have set the device for “DO_BUFFERED_IO” so I get the whole packet image in AssociatedIrp.SystemBuffer.  In the debugger I can see the whole packet in memory, as part of debugging, I check the IP checksum at this point and it passes.

    I use NdisAllocateMdl to get an MDL and then NdisAllocateNetBufferAndNetBufferList to get the NBL and then use NdisMIndicateReceiveNetBufferLists to send it up.

    Nothing happens, my ReturnNetBufferListsHandler is called before NdisMIndicateReceiveNetBufferLists returns and nothing else happens.  The ping is not answered. UDP datagrams are not received.  I have sent it packets at high speed while watching all of the IPv4 counters in perfmon and nothing gets counted anywhere.

    So I though I would see what NDIS tracing showed.  I set it up as described (on a web page I am not allowed to post a link to) and I get plenty of trace information, just nothing when the receive is processed.  Here’s the whole thing:

     

    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [mp]==>ndisDummyIrpHandler: DeviceObject 872C2818, Irp 8534C0C0
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis][850A2240] ---> deviceWrite
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]datalength is 128
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]buffer is at 0x85414800
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]first byte of data is 0x45
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]second byte of data is 0x0
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]mdl.Next: 0x0
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]mdl.Size: 32
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]mdl.MdlFlags: 0xC
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]mdl.MappedSystemVa: 0x85414800
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]mdl.StartVa: 0x85414000
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]mdl.ByteCount: 128
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]mdl.ByteOffset: 2048
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]address: 0x85414800
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]ACTIVE RECVS IS NOW 1
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis][850A2240] ---> mndMiniportReturnNetBufferLists
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]---> mndCompleteWrite status 0
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]<--- mndCompleteWrite status 0
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis]ACTIVE RECVS IS NOW 0
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis][850A2240] <--- mndMiniportReturnNetBufferLists
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [MprNdis][850A2240] <--- deviceWrite status 259
    [0]0E8C.0D7C::03/12/2013-13:01:48.793 [mp]<==ndisDummyIrpHandler: DeviceObject 872C2818, Irp 8534C0C0

    ---------------------------------

    NdisMIndicateReceiveNetBufferLists does not even log that it is called.  (The call occurs right after the log of ACTIVE RECVS IS NOW 1.

    So, first question, does anyone have any idea what is wrong?  Why NdisMIndicateReceiveNetBufferLists doesn’t give my buffers to the IP layer.

    Second I have tried tracing receive operations with a standard NDIS driver (it’s a Realtek RTL8168C).  I set the tracing up with flags of 0x00000008 for Receive.  I blast away with UDP, I successfully receive the packets, but don’t get anything in the log file.  Anybody know why?

    BTW: if I use 0xC for the flags I get lots of messages about processing transmits.

    Thanks in advance for any help.

    Gene

    Tuesday, March 12, 2013 9:33 PM

Answers

All replies

  • Hi,

    Do you set NDIS_NBL_FLAGS_IS_IPV4 for the NBL before NdisMIndicateReceiveNetBufferLists()? Check this document on MSDN MB Raw IP Packet Processing Support, it is WWAN related, but applies to NdisMediumIP too.

    For the NDIS6 receive path tracing, see this this discussion thread.

    BR, Antti

    • Marked as answer by Gene Latham Wednesday, March 13, 2013 4:04 PM
    Wednesday, March 13, 2013 9:30 AM
  • Thank you ever so much.

    I don't know why I could not find this article, I searched a lot.

    I did as the article describes (Set NDIS_NBL_FLAGS_IS_IPV4 and NetBufferListFrameType to 0x0800) and it started working.

    Thanks again.


    • Edited by Gene Latham Wednesday, March 13, 2013 4:18 PM
    Wednesday, March 13, 2013 4:18 PM