Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Account of MDLs in NetBuffer

ArsenArsen Member Posts: 189

Hi all.
To the receive path of NDIS filter driver arrives NetBufferLists, that consists of only one NetBuffer (as documented).
But what about MDLs.
Is it one or maybe several MDLs inside that NetBuffer?
If there are several, then the reason for this is not clear to me․ After all, MDL can have any length․
And the same question about NetBufferLists. It is one or maybe several NetBufferLists in a chain.
Thanks

Comments

  • Gregory_G._DyessGregory_G._Dyess Member - All Emails Posts: 386
    via Email
    That will depend upon how you have structured the buffers filled in by hardware.
    If you have a single, physically-contiguous buffer for each NetBuffer, then it is a single MDL.
    If your receive buffer is not physically-contiguous for the network frame, then you will have to build multiple MDLs for each fragment.

    In the NDIS driver I did for WEC7/WEC2013 I structured it such that every received packet was placed into a physically-contiguous buffer so I only needed a single MDL for each NetBuffer.

    Greg


    On Thu, 19 Jan 2023 15:40:35 +0000 (UTC), Arsen wrote:

    OSR https://community.osr.com/

    Arsen Started a new discussion. Account of MDLs in NetBuffer

    Hi all.

    To the receive path of NDIS filter driver arrives NetBufferLists, that consists of only one NetBuffer (as documented).

    But what about MDLs.

    Is it one or maybe several MDLs inside that NetBuffer?

    If there are several, then the reason for this is not clear to me․ After all, MDL can have any length․

    And the same question about NetBufferLists. It is one or maybe several NetBufferLists in a chain.

    Thanks
  • ArsenArsen Member Posts: 189

    Thank You Mr. Gregory.
    Thank you Mr Gregory. I understand that it depends on the settings of my network card.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,727
    edited January 19

    If you have a single, physically-contiguous buffer for each NetBuffer, then it is a single MDL.
    If your receive buffer is not physically-contiguous for the network frame, then you will have to build multiple MDLs for each fragment.

    That's not correct. Most buffers are not physically contiguous, but an MDL must be VIRTUALLY contiguous. The whole point of an MDL is to gather physically disparate pages into a single unit.

    If there are several, then the reason for this is not clear to me․ After all, MDL can have any length․

    That's also not true. An MDL is limited to 4 gigabytes. Until Windows 7, an MDL was limited to 32 megabytes, because the "Size" parameter that gives the total size of the MDL is a 16-bit field. Since each page entry is 8 bytes, that's 65536 / 8 x 4096, or 32MB. (It's a little bit less than that, because the 65536 has to include the size of the MDL structure.)

    Post edited by Tim_Roberts on

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • ArsenArsen Member Posts: 189

    Mr. Tim-Roberts. Thank you. In any case, I think that network packets cannot be larger than 4 gigabytes, so there can be one mdl in one NetBuffer in the receive path, one NetBuffer and several NetBufferLists.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 26 Feb - 1 Mar 2024 Live, Online