NDK_FN_BUILD_LAM callback function

The NdkBuildLam (NDK_FN_BUILD_LAM) function gets an adapter logical address mapping (LAM) from the NDK provider for a virtually contiguous memory region.



  NDK_ADAPTER *pNdkAdapter,
  MDL *Mdl,
  SIZE_T Length,
  PVOID RequestContext,
  ULONG *pLAMSize,



A pointer to an NDK adapter object (NDK_ADAPTER).


A memory descriptor list (MDL) or chain of MDLs. The portion of the MDL chain from the starting virtual address up to the number of bytes in the Length parameter must represent a virtually contiguous memory region.


The number of bytes to map starting from the first MDL's virtual address. The MDL virtual address can be obtained with the MmGetMdlVirtualAddress macro. Length must not exceed the total number of bytes represented by the MDL chain.


A pointer to a NdkRequestCompletion (NDK_FN_REQUEST_COMPLETION) callback function.


A context value for the provider to pass back to the NdkRequestCompletion callback function that is specified in the RequestCompletion parameter.


A pointer to a buffer that will hold an NDK_LOGICAL_ADDRESS_MAPPING structure that contains an adapter page array. The adapter page array is stored in the AdapterPageArray member and the AdapterPageCount member contains the number of adapter page elements.


The size, in bytes, of the buffer at the pNdkLAM parameter for input, or the actual number of bytes written for output.


The first byte offset (FBO) value is returned in this location. The FBO is the starting offset within the first adapter page.

Return Value

The NdkBuildLam function returns one of the following NTSTATUS codes.

Return code Description
The operation completed successfully.
The request is pending, the function specified at the RequestCompletion parameter(NDK_FN_REQUEST_COMPLETION) will be called when the LAM build operation is complete.
The portion of the MDL chain from the starting virtual address up to the number of bytes specified in the Length parameter does not represent a virtually contiguous memory region.
The request failed due to insufficient resources.
Important  The request can fail inline as well as asynchronously with this status code.
The buffer size indicated by the *pLAMSize parameter is too small to hold the LAM. In this case, the value of *pLAMSize is updated with the required buffer size.
Other status codes
An error occurred.


The part of the MDL chain from the starting virtual address up to the number of bytes specified in the Length parameter must represent a virtually contiguous memory region. Otherwise, the NDK provider must fail the request. It is the responsibility of the NDK consumer to ensure that the MDL chain is locked. That is, the pages of the MDL change are pinned in physical memory.

Important  The NDK consumer must not use the MDL chain while NdkBuildLam is pending completion.
An adapter accesses physical memory with logical addresses. This is similar to a CPU accessing physical memory with virtual addresses. If an NDK consumer will use physical memory pages directly as local data buffers in send, receive, read, or write requests, it must get an NDK adapter logical address mapping from the NDK provider and use the logical addresses rather than physical addresses. Similarly, an NDK consumer must also use logical addresses in fast-register requests.

An NDK consumer can call the NdkGetPrivilegedMemoryRegionToken (NDK_FN_GET_PRIVILEGED_MEMORY_REGION_TOKEN) function to get a privileged memory region token from an NDK provider.

All adapter pages returned by an NDK provider must be of PAGE_SIZE bytes in length, where PAGE_SIZE is the memory page size that is supported by the host platform as defined in wdm.h.

The provider must treat the virtual address value that the MmGetMdlVirtualAddress macro returns for the MDL as an index to the start of the memory region being mapped. The provider must not use the virtual address value as a valid virtual address for reading or writing buffer contents.

If a provider has an error while processing an NdkBuildLam request, the provider must release any partial mappings it built internally thus far before completing the request with failure.


Minimum supported client None supported,Supported in NDIS 6.30 and later.
Minimum supported server Windows Server 2012
Target Platform Windows
Header ndkpi.h (include Ndkpi.h)

See Also


NDKPI Object Lifetime Requirements