EVT_NET_ADAPTER_RETURN_RX_BUFFER callback function

Warning

Some information in this topic relates to prereleased product, which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

NetAdapterCx is preview only in Windows 10, version 1903.

Implement this optional callback function to perform cleanup on a NET_FRAGMENT receive buffer for which you previously specified manual fragment allocation and attachment.

Syntax

EVT_NET_ADAPTER_RETURN_RX_BUFFER EvtNetAdapterReturnRxBuffer;

void EvtNetAdapterReturnRxBuffer(
  NETADAPTER Adapter,
  void *RxBufferVirtualAddress,
  void *RxBufferReturnContext
)
{...}

Parameters

Adapter

The network adapter object that the client created in a prior call to NetAdapterCreate.

RxBufferVirtualAddress

A pointer to the virtual address of the NET_FRAGMENT receive buffer. Cast this member to a PNET_PACKET_FRAGMENT to retrieve the fragment.

RxBufferReturnContext

A pointer to a driver-allocated context space structure.

Return Value

This callback function does not return a value.

Remarks

Register your implementation of this callback function by setting the appropriate member of NET_ADAPTER_RX_CAPABILITIES structure and then calling NetAdapterSetDatapathCapabilities. Client drivers typically call NetAdapterSetDatapathCapabilities when starting a net adapter, before calling NetAdapterStart.

This callback function is optional unless the net adapter client driver initializes its NET_ADAPTER_RX_CAPABILITIES structure using the NET_ADAPTER_RX_CAPABILITIES_INIT_DRIVER_MANAGED method. By using this initialization method, the driver tells the operating system that it is managing allocation and attachment of NET_FRAGMENT receive buffers manually, so it must provide this callback function in this case for the operating system to invoke once the system is finished with the buffer.

Example

In this callback function, the client driver can perform whatever cleanup or follow-up actions it needs now that the operating system has finished with this receive buffer. In the following example, the return context contains a member to track the number of indicated packets, as well as a memory object used for a lookaside buffer during receive processing. Error handling has been left out for clarity.

VOID
MyReturnRxBuffer(
	_In_	NETADAPTER	Adapter,
	_In_	PVOID		RxBufferVirtualAddress,
	_In_	PVOID		RxBufferReturnContext
)
{
	UNREFERENCED_PARAMETER(Adapter);
	UNREFERENCED_PARAMETER(RxBufferVirtualAddress);

	// Get the context
	PMY_RX_BUFFER_RETURN_CONTEXT context = (PMY_RX_BUFFER_RETURN_CONTEXT)RxBufferReturnContext;
	
	context->IndicatedPackets--;

	// Clean up the lookaside buffer if this is the last packet
	if(context->IndicatedPackets == 0)
	{
		WdfObjectDelete(context->LookasideBufferMemory);
	}
}

Requirements

   
Target Platform Universal
Minimum KMDF version 1.25
Header netadapter.h
IRQL <= DISPATCH_LEVEL

See Also

NET_ADAPTER_RX_CAPABILITIES