### Install XDP Runtime Components Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/usage.md Installs the base XDP runtime components using the PowerShell script. Ensure the NuGet package is restored or extracted first. ```Powershell xdp-setup.ps1 -Install xdp ``` -------------------------------- ### One-time Setup for Spinxsk Tests Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/development.md Prepare the machine for running spinxsk tests. ```powershell .\tools\prepare-machine.ps1 -ForSpinxskTest ``` -------------------------------- ### One-time Setup for Functional Tests Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/development.md Prepare the machine for running functional tests. ```powershell .\tools\prepare-machine.ps1 -ForFunctionalTest ``` -------------------------------- ### Install XDPMP Miniport Driver Source: https://github.com/microsoft/xdp-for-windows/blob/main/test/xdpmp/xdpmp.md Use this PowerShell script to install the XDPMP miniport driver. Ensure boot debugging is enabled and necessary driver files are copied. ```PowerShell bcdedit.exe /set bootdebug on copy .\test\fakendis\fndis.sys c:\windows\system32\drivers\fndis.sys sc.exe create fndis type= kernel start= boot binPath= c:\windows\system32\drivers\fndis.sys shutdown /r /f /t 0 cd test\xdpmp .\xdpmp.ps1 -Install ``` -------------------------------- ### Install XDP using MSI (v1.1 and older) Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/usage.md Installs XDP for Windows using an MSI package for versions 1.1 and older. This command should be run in a batch file context. ```Batch msiexec.exe /i xdp-for-windows.msi /quiet ``` -------------------------------- ### Install Test Version of XDP Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/usage.md Commands to install a test version of XDP. This involves extracting and importing a test signing certificate, enabling test signing, and rebooting. Secure boot must be disabled beforehand. ```Powershell $CertFileName = 'xdp.cer' Get-AuthenticodeSignature 'path\to\xdp.cat' | Select-Object -ExpandProperty SignerCertificate | Export-Certificate -Type CERT -FilePath $CertFileName Import-Certificate -FilePath $CertFileName -CertStoreLocation 'cert:\localmachine\root' Import-Certificate -FilePath $CertFileName -CertStoreLocation 'cert:\localmachine\trustedpublisher' bcdedit.exe /set testsigning on [reboot] ``` -------------------------------- ### Install Older XDP MSI (v1.3.0 and below) Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/usage.md Downloads and installs an older official MSI package for XDP for Windows. This method is for versions prior to v1.3.0. ```Powershell Invoke-WebRequest https://aka.ms/xdp-v1.msi -OutFile xdp.msi msiexec.exe /i xdp.msi /quiet ``` -------------------------------- ### Enable Experimental eBPF Support Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/usage.md Enables experimental eBPF support for XDP by installing the 'xdpebpf' component. This requires eBPF-for-Windows to be installed first. ```Powershell xdp-setup.ps1 -Install xdpebpf ``` -------------------------------- ### Start XDP Logging with log.ps1 Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/usage.md Use this command to initiate XDP logging. Requires administrator privileges and the tools directory copied to the target system. ```powershell .\tools\log.ps1 -Start ``` -------------------------------- ### Install XDP eBPF Export Component Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/usage.md Installs the 'xdpebpfexport' component, which is necessary for exporting eBPF components for XDP. ```Powershell xdp-setup.ps1 -Install xdpebpfexport ``` -------------------------------- ### XdpGuidCreate Function Signature Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpGuidCreate.md The XdpGuidCreate function initializes a GUID. It requires the IRQL to be at PASSIVE_LEVEL. ```APIDOC ## XdpGuidCreate ### Description Initializes a GUID. ### Syntax ```C _IRQL_requires_max_(PASSIVE_LEVEL) NTSTATUS XdpGuidCreate( _Out_ GUID *Guid ); ``` ### Parameters #### Out Parameters - **Guid** (_Out_ GUID *) - A pointer to a GUID structure that will be initialized. ``` -------------------------------- ### xdpcfg.exe SetDeviceSddl Commands Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/per-object-security.md Command-line examples for setting Security Descriptor Definition Language (SDDL) for XDP devices using xdpcfg.exe. Use the first command for the common device and the second for per-type devices. ```bash xdpcfg.exe SetDeviceSddl # Common device ``` ```bash xdpcfg.exe SetDeviceSddl # Per-type device ``` -------------------------------- ### Get RX Queue Target Queue Info Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-rxqueueconfig.md Gets the target queue information for a given RX queue configuration. This can be used to determine the actual queue on the NIC that will receive the traffic. ```c CONST XDP_QUEUE_INFO * XdpRxQueueGetTargetQueueInfo( _In_ XDP_RX_QUEUE_CONFIG_CREATE RxQueueConfig ); ``` -------------------------------- ### XdpInterfaceOpen Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpInterfaceOpen.md Opens a handle to a network interface to get or set offloads, configurations, and properties. This function is part of the XDP API for Windows. ```APIDOC ## XdpInterfaceOpen ### Description Opens a handle to a network interface to get or set offloads, configurations, and properties. This function is part of the XDP API for Windows. ### Syntax ```C XDP_STATUS XdpInterfaceOpen( _In_ UINT32 InterfaceIndex, _Out_ HANDLE *InterfaceHandle ); ``` ### Parameters #### Path Parameters - **InterfaceIndex** (UINT32) - Required - The interface index to attach the program. #### Output Parameters - **InterfaceHandle** (HANDLE *) - Required - If the interface object is created successfully, returns a Windows handle to the program. The interface object is removed by XDP when the handle is closed via `CloseHandle` and all configurations are reverted. ### Remarks This API is currently only used by experimental APIs, including RSS and QEO. ``` -------------------------------- ### Declare XDP_INTERFACE_CONFIG Handle Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XDP_INTERFACE_CONFIG.md This macro is used to declare an opaque handle for XDP interface configurations. No setup is required. ```c DECLARE_HANDLE(XDP_INTERFACE_CONFIG); ``` -------------------------------- ### Retrieve AF_XDP Ring Information Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Use XSK_SOCKOPT_RING_INFO to get details about all rings associated with a socket, including fill and completion rings from shared UMEMs. The retrieved information includes ring pointers, offsets, size, and element stride. ```C #define XSK_SOCKOPT_RING_INFO 6 typedef struct _XSK_RING_INFO { BYTE *Ring; UINT32 DescriptorsOffset; // XSK_FRAME_DESCRIPTOR[] for rx/tx, UINT64[] for fill/completion UINT32 ProducerIndexOffset; // UINT32 UINT32 ConsumerIndexOffset; // UINT32 UINT32 FlagsOffset; // UINT32 UINT32 Size; UINT32 ElementStride; UINT32 Reserved; } XSK_RING_INFO; typedef struct _XSK_RING_INFO_SET { XSK_RING_INFO Fill; XSK_RING_INFO Completion; XSK_RING_INFO Rx; XSK_RING_INFO Tx; } XSK_RING_INFO_SET; ``` -------------------------------- ### XDP Ring Buffer Helper Functions Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-datapath.md Provides inline functions for interacting with XDP ring buffers, such as getting an element at a specific index, counting non-empty elements, and calculating the number of free elements. Ensure the index is within the valid range [0, Ring->Mask]. ```C // // Returns a pointer to the ring element at the specified index. The index // must be within [0, Ring->Mask]. // inline VOID * XdpRingGetElement( _In_ XDP_RING *Ring, _In_ UINT32 Index ) { ASSERT(Index <= Ring->Mask); return (PUCHAR)&Ring[1] + (SIZE_T)Index * Ring->ElementStride; } // // Returns the number of non-empty elements in the ring. // inline UINT32 XdpRingCount( _In_ XDP_RING *Ring ) { return Ring->ProducerIndex - Ring->ConsumerIndex; } // // Returns the number of empty elements in the ring. // inline UINT32 XdpRingFree( _In_ XDP_RING *Ring ) { return Ring->Mask + 1 - XdpRingCount(Ring); } ``` -------------------------------- ### XSK_SOCKOPT_RING_INFO Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Retrieves detailed information about all rings associated with an AF_XDP socket, including those from shared UMEMs. This option supports the 'get' action and uses the XSK_RING_INFO_SET structure for its optval. ```APIDOC ## XSK_SOCKOPT_RING_INFO ### Description Gets info about all rings associated with a socket. This includes fill and completion rings from shared UMEMs. ### Supports get ### Optval Type XSK_RING_INFO_SET ### Structure Definitions ```C typedef struct _XSK_RING_INFO { BYTE *Ring; UINT32 DescriptorsOffset; // XSK_FRAME_DESCRIPTOR[] for rx/tx, UINT64[] for fill/completion UINT32 ProducerIndexOffset; // UINT32 UINT32 ConsumerIndexOffset; // UINT32 UINT32 FlagsOffset; // UINT32 UINT32 Size; UINT32 ElementStride; UINT32 Reserved; } XSK_RING_INFO; typedef struct _XSK_RING_INFO_SET { XSK_RING_INFO Fill; XSK_RING_INFO Completion; XSK_RING_INFO Rx; XSK_RING_INFO Tx; } XSK_RING_INFO_SET; ``` ``` -------------------------------- ### Initialize and Register XDP Extension (Driver) Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XDP_EXTENSION_INFO.md Demonstrates how XDP drivers initialize an XDP_EXTENSION_INFO structure and register it with the XDP platform during queue creation. This informs the XDP platform about the driver's extension requirements. ```C XDP_EXTENSION_INFO extensionInfo; XdpInitializeExtensionInfo( &extensionInfo, XDP_FRAME_EXTENSION_FRAGMENT_NAME, XDP_FRAME_EXTENSION_FRAGMENT_VERSION_1, XDP_EXTENSION_TYPE_FRAME); // Drivers register and query extensions via the XDP Driver API during queue creation ``` -------------------------------- ### XdpInitializeExtensionInfo function signature Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpInitializeExtensionInfo.md Initializes an XDP_EXTENSION_INFO struct with the given parameters. Use this function to set up the extension information before registering it. ```C inline VOID XdpInitializeExtensionInfo( _Out_ XDP_EXTENSION_INFO *ExtensionInfo, _In_z_ const WCHAR *ExtensionName, _In_ UINT32 ExtensionVersion, _In_ XDP_EXTENSION_TYPE ExtensionType ); ``` -------------------------------- ### Get RX Queue Frame Ring Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-rxqueueconfig.md Gets the XDP frame ring for an activated RX queue. Each element in the ring is an XDP_FRAME followed by any associated extensions. ```c XDP_RING * XdpRxQueueGetFrameRing( _In_ XDP_RX_QUEUE_CONFIG_ACTIVATE RxQueueConfig ); ``` -------------------------------- ### Get RX Queue Fragment Ring Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-rxqueueconfig.md Gets the XDP fragment (multi-buffer) ring for an activated RX queue. This ring is used when frames are split into multiple buffers. ```c XDP_RING * XdpRxQueueGetFragmentRing( _In_ XDP_RX_QUEUE_CONFIG_ACTIVATE RxQueueConfig ); ``` -------------------------------- ### XdpInitializeExtensionInfo Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpInitializeExtensionInfo.md Initializes an XDP_EXTENSION_INFO struct with the given parameters. ```APIDOC ## XdpInitializeExtensionInfo ### Description Initializes an [`XDP_EXTENSION_INFO`](XDP_EXTENSION_INFO.md) struct with the given parameters. ### Syntax ```c inline VOID XdpInitializeExtensionInfo( _Out_ XDP_EXTENSION_INFO *ExtensionInfo, _In_z_ const WCHAR *ExtensionName, _In_ UINT32 ExtensionVersion, _In_ XDP_EXTENSION_TYPE ExtensionType ); ``` ### Parameters TODO ### Remarks TODO ``` -------------------------------- ### Build XDP for Windows Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/development.md Run the build script from a Visual Studio Developer Command Prompt. ```powershell .\tools\build.ps1 ``` -------------------------------- ### XdpInitializeDmaCapabilitiesPdo Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpInitializeDmaCapabilitiesPdo.md Initializes the XDP_DMA_CAPABILITIES structure. ```APIDOC ## XdpInitializeDmaCapabilitiesPdo ### Description Initializes the [`XDP_DMA_CAPABILITIES`](XDP_DMA_CAPABILITIES.md) structure. ### Syntax ```C inline VOID XdpInitializeDmaCapabilitiesPdo( _Out_ XDP_DMA_CAPABILITIES *Capabilities, _In_ DEVICE_OBJECT *PhysicalDeviceObject ); ``` ### Parameters TODO ### Remarks TODO ``` -------------------------------- ### Initialize RX Descriptor Contexts Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-rxqueueconfig.md Initializes descriptor contexts for RX queues, enabling optional frame and buffer interface context extensions. ```c inline VOID XdpInitializeRxDescriptorContexts( _Out_ XDP_RX_DESCRIPTOR_CONTEXTS *DescriptorContexts ); ``` -------------------------------- ### XDP Hook ID Options Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Gets or sets the XDP (eXpress Data Path) hook ID for RX (Receive) and TX (Transmit) operations. These options support both 'get' and 'set' actions. If not explicitly set, AF_XDP defaults to specific hook IDs for RX and TX. This option can only be set before binding the socket. ```APIDOC ## XDP Hook ID Options ### Description Gets or sets the XDP hook ID for RX/TX binding. If unset, XSK defaults to {XDP_HOOK_L2_RX, XDP_HOOK_INSPECT} for RX and {XDP_HOOK_L2_TX, XDP_HOOK_INJECT} for TX. This option can only be set prior to binding. ### Supports get/set ### Optval Type XDP_HOOK_ID ### Options - XSK_SOCKOPT_RX_HOOK_ID - XSK_SOCKOPT_TX_HOOK_ID ``` -------------------------------- ### XdpInitializeRxDescriptorContexts Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-rxqueueconfig.md Initializes descriptor contexts for RX queues, defining optional context sizes and alignments for frame and buffer extensions. ```APIDOC ## XdpInitializeRxDescriptorContexts ### Description Initializes descriptor contexts for RX queues. This structure defines optional context sizes and alignments for frame and buffer interface extensions. ### Signature ```C inline VOID XdpInitializeRxDescriptorContexts( _Out_ XDP_RX_DESCRIPTOR_CONTEXTS *DescriptorContexts ); ``` ### Parameters * `DescriptorContexts` (_Out_ XDP_RX_DESCRIPTOR_CONTEXTS *) - Pointer to the XDP_RX_DESCRIPTOR_CONTEXTS structure to be initialized. ``` -------------------------------- ### Processor Affinity Options Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Manages the processor affinity for the kernel's RX (Receive) and TX (Transmit) data paths. These options support both 'set' and 'get' actions. For 'set', a UINT32 value is used to enable/disable ideal processor profiling (disabled by default). For 'get', the ideal processor number is returned, though it may return errors if the affinity is unknown. ```APIDOC ## Processor Affinity Options ### Description Manages the ideal processor affinity for the kernel RX/TX data path. For 'set', it enables or disables ideal processor profiling (disabled by default). For 'get', it returns the ideal processor number. This option may return errors when the ideal processor affinity is unknown or unknowable. ### Supports set/get ### Optval Type UINT32 (set) / PROCESSOR_NUMBER (get) ### Options - XSK_SOCKOPT_RX_PROCESSOR_AFFINITY - XSK_SOCKOPT_TX_PROCESSOR_AFFINITY ``` -------------------------------- ### XdpInitializeRxCapabilitiesDriverVa Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-rxqueueconfig.md Initializes RX queue capabilities for driver-allocated buffers with virtual addresses. ```APIDOC ## XdpInitializeRxCapabilitiesDriverVa ### Description Initializes RX queue capabilities for driver-allocated buffers with virtual addresses. This is the only supported RX model for XDP version 1. ### Signature ```C inline VOID XdpInitializeRxCapabilitiesDriverVa( _Out_ XDP_RX_CAPABILITIES *Capabilities ); ``` ### Parameters * `Capabilities` (_Out_ XDP_RX_CAPABILITIES *) - Pointer to the XDP_RX_CAPABILITIES structure to be initialized. ``` -------------------------------- ### XskGetSockopt Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XskGetSockopt.md Retrieves an AF_XDP socket option. This function allows you to get the value of a specific socket option for an AF_XDP socket. ```APIDOC ## XskGetSockopt ### Description Gets an AF_XDP socket option. ### Syntax ```C XDP_STATUS XskGetSockopt( _In_ HANDLE Socket, _In_ UINT32 OptionName, _Out_opt_writes_bytes_(*OptionLength) VOID *OptionValue, _Inout_ UINT32 *OptionLength ); ``` ### Parameters - **Socket** (_In_ HANDLE) - An AF_XDP socket handle. - **OptionName** (_In_ UINT32) - A socket option. - **OptionValue** (_Out_opt_writes_bytes_(*OptionLength) VOID *) - An optional buffer of size `OptionLength`. If `OptionLength` is nonzero, the buffer must not be `NULL`. - **OptionLength** (_Inout_ UINT32 *) - The size of the `OptionValue` output buffer. If the input value is `0` and `XskGetSockopt` returns `HRESULT_FROM_WIN32(ERROR_MORE_DATA)`, the output value is the required buffer size. If `XskGetSockopt` succeeds, the output value is the number of bytes written to the output buffer. ### Remarks None. ### See Also [AF_XDP](../afxdp.md) ``` -------------------------------- ### Get RX Queue Extension Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-rxqueueconfig.md Retrieves a registered and enabled XDP extension from an activated RX queue. This allows access to extension-specific data. ```c VOID XdpRxQueueGetExtension( _In_ XDP_RX_QUEUE_CONFIG_ACTIVATE RxQueueConfig, _In_ XDP_EXTENSION_INFO *ExtensionInfo, _Out_ XDP_EXTENSION *Extension ); ``` -------------------------------- ### XdpInitializeCapabilities Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-control.md Initializes XDP interface capabilities with the given minimum API version. This function sets up the necessary structures to declare an interface's support for the XDP platform. ```APIDOC ## XdpInitializeCapabilities ### Description Initializes XDP interface capabilities with the given minimum API version. ### Syntax ```C inline NTSTATUS XdpInitializeCapabilities( _Out_ XDP_CAPABILITIES *Capabilities, _In_ const XDP_VERSION *DriverApiVersion ); ``` ### Parameters * **Capabilities** (_Out_ XDP_CAPABILITIES *): A pointer to an XDP_CAPABILITIES structure to be initialized. * **DriverApiVersion** (_In_ const XDP_VERSION *): A pointer to the XDP_VERSION structure specifying the minimum API version supported by the driver. ``` -------------------------------- ### Initialize XDP Interface Capabilities Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-control.md Initializes the XDP_CAPABILITIES structure with the specified minimum API version. This function sets up the header, size, and version information for the interface's capabilities. ```C inline NTSTATUS XdpInitializeCapabilities( _Out_ XDP_CAPABILITIES *Capabilities, _In_ const XDP_VERSION *DriverApiVersion ) { const XDP_VERSION DdkDriverApiVersion = { XDP_DRIVER_API_MAJOR_VER, XDP_DRIVER_API_MINOR_VER, XDP_DRIVER_API_PATCH_VER }; RtlZeroMemory(Capabilities, sizeof(*Capabilities)); Capabilities->CapabilitiesEx.Header.Revision = XDP_CAPABILITIES_EX_REVISION_1; Capabilities->CapabilitiesEx.Header.Size = XDP_SIZEOF_CAPABILITIES_EX_REVISION_1; Capabilities->CapabilitiesEx.DriverApiVersionsOffset = FIELD_OFFSET(XDP_CAPABILITIES, DriverApiVersion); Capabilities->CapabilitiesEx.DriverApiVersionCount = 1; Capabilities->DriverApiVersion = *DriverApiVersion; Capabilities->CapabilitiesEx.DdkDriverApiVersion = DdkDriverApiVersion; return XdpGuidCreate(&Capabilities->CapabilitiesEx.InstanceId); } ``` -------------------------------- ### Get XDP Driver API Version Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpGetDriverApiVersion.md Call this function to retrieve the XDP_VERSION of an XDP interface binding. Ensure the InterfaceConfig parameter is correctly populated. ```C CONST XDP_VERSION * XdpGetDriverApiVersion( _In_ XDP_INTERFACE_CONFIG InterfaceConfig ); ``` -------------------------------- ### Configure Ring Buffer Sizes for AF_XDP Socket Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Set the size of ring buffers (RX, Fill, TX, Completion) using corresponding XSK_SOCKOPT_* macros. The size must be a power of 2. Each ring type can only be configured once per socket and must be configured before use. ```C #define XSK_SOCKOPT_RX_RING_SIZE 2 #define XSK_SOCKOPT_RX_FILL_RING_SIZE 3 #define XSK_SOCKOPT_TX_RING_SIZE 4 #define XSK_SOCKOPT_TX_COMPLETION_RING_SIZE 5 ``` -------------------------------- ### XSK_SOCKOPT_STATISTICS Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Retrieves statistics from an AF_XDP socket. This option supports the 'get' action and uses the XSK_STATISTICS structure for its optval, providing counts for dropped, truncated, and invalid descriptors. ```APIDOC ## XSK_SOCKOPT_STATISTICS ### Description Gets statistics from a socket. ### Supports get ### Optval Type XSK_STATISTICS ### Structure Definition ```C typedef struct _XSK_STATISTICS { UINT64 RxDropped; UINT64 RxTruncated; UINT64 RxInvalidDescriptors; UINT64 TxInvalidDescriptors; } XSK_STATISTICS; ``` ``` -------------------------------- ### XDP_CREATE_TX_QUEUE Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-control.md Creates an XDP transmit queue. The XDP platform ensures at most one XDP queue exists per hardware queue. The queue creation configuration object specifies the XDP queue parameters, including the target queue identifier, and allows interfaces to declare queue capabilities and their activation requirements. Upon successful queue creation, the interface returns its queue context and XDP dispatch table. ```APIDOC ## XDP_CREATE_TX_QUEUE ### Description Creates an XDP transmit queue. The XDP platform ensures at most one XDP queue exists per hardware queue. The queue creation configuration object specifies the XDP queue parameters, including the target queue identifier, and allows interfaces to declare queue capabilities and their activation requirements. Upon successful queue creation, the interface returns its queue context and XDP dispatch table. ### Parameters #### Path Parameters - **InterfaceContext** (XDP_INTERFACE_HANDLE) - Required - Provides the interface context from registration. - **Config** (XDP_TX_QUEUE_CONFIG_CREATE) - Required - Provides a transmit queue creation configuration object. This object is valid only within the scope of the XDP_CREATE_TX_QUEUE routine; interfaces must not use the Config object after returning from this routine. The interface must provide its TX capabilities prior to returning. For more details, see xdp/txqueueconfig.h. #### Output Parameters - **InterfaceTxQueue** (XDP_INTERFACE_HANDLE *) - Required - Upon success, the XDP interface returns its queue context. - **InterfaceTxQueueDispatch** (const XDP_INTERFACE_TX_QUEUE_DISPATCH **) - Required - Upon success, the XDP interface returns its queue dispatch table. ### Return Value - NTSTATUS - Indicates whether the operation was successful. ``` -------------------------------- ### Querying Extensions in XDP Drivers Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/descriptor-extensions.md XDP drivers query for extensions during queue initialization and use them during data path processing. Always specify the extension version you support. ```c // During queue initialization, query for supported extensions XDP_EXTENSION_INFO extensionInfo; XdpInitializeExtensionInfo( &extensionInfo, XDP_BUFFER_EXTENSION_VIRTUAL_ADDRESS_NAME, XDP_BUFFER_EXTENSION_VIRTUAL_ADDRESS_VERSION_1, XDP_EXTENSION_TYPE_BUFFER); // Get the extension from the queue XDP_EXTENSION virtualAddressExtension; // ... (driver API to get extension) ... // During RX processing, populate the extension XDP_BUFFER_VIRTUAL_ADDRESS *va = XdpGetVirtualAddressExtension(buffer, &virtualAddressExtension); va->VirtualAddress = bufferVa; ``` -------------------------------- ### Get XDP Frame Interface Context Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpGetFrameInterfaceContextExtension.md Use this function to retrieve the XDP_FRAME_INTERFACE_CONTEXT associated with an XDP frame and a specific extension. Ensure that the Frame and Extension parameters are valid. ```C inline XDP_FRAME_INTERFACE_CONTEXT * XdpGetFrameInterfaceContextExtension( _In_ XDP_FRAME *Frame, _In_ XDP_EXTENSION *Extension ); ``` -------------------------------- ### Clone XDP for Windows Repository Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/development.md Clone the repository and ensure all submodules are cloned recursively. ```bash git clone https://github.com/microsoft/xdp-for-windows.git --recursive ``` -------------------------------- ### Get Virtual Address of XDP Buffer Extension Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpGetVirtualAddressExtension.md Use this function to retrieve the virtual address of an extension associated with an XDP buffer. Ensure that both the buffer and extension pointers are valid. ```C inline XDP_BUFFER_VIRTUAL_ADDRESS * XdpGetVirtualAddressExtension( _In_ XDP_BUFFER *Buffer, _In_ XDP_EXTENSION *Extension ); ``` -------------------------------- ### Get AF_XDP Socket Statistics Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Retrieve statistics from an AF_XDP socket using XSK_SOCKOPT_STATISTICS. This provides counts for dropped packets, truncated packets, and invalid descriptors for both RX and TX operations. ```C #define XSK_SOCKOPT_STATISTICS 7 typedef struct _XSK_STATISTICS { UINT64 RxDropped; UINT64 RxTruncated; UINT64 RxInvalidDescriptors; UINT64 TxInvalidDescriptors; } XSK_STATISTICS; ``` -------------------------------- ### Deploy Tools and Artifacts to Remote Machine Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/remote-testing.md After building the project on the dev machine, use this command to push the tools and build artifacts to the remote test machine. This is typically done once after each build. ```powershell .\tools\remote.ps1 -Deploy -ComputerName test-vm-1 ``` -------------------------------- ### XDP_TX_CAPABILITIES Structure and Initialization Functions Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-txqueueconfig.md Defines the structure for common TX capabilities and provides functions to initialize it for different buffer types and DMA configurations. ```APIDOC ## XDP_TX_CAPABILITIES ### Description Structure defining common TX capabilities and activation requirements for an XDP transmit queue. ### Fields * **Header** (XDP_OBJECT_HEADER) - Header information. * **VirtualAddressEnabled** (BOOLEAN) - Indicates if the interface uses the virtual address buffer extension. * **MdlEnabled** (BOOLEAN) - Indicates if the interface uses the MDL buffer extension. * **DmaCapabilities** (XDP_DMA_CAPABILITIES *) - Optional. Indicates the interface DMA capabilities. * **TransmitFrameCountHint** (UINT16) - Hint for the ideal frame queue length. * **MaximumBufferSize** (UINT32) - Specifies the maximum TX buffer size. * **MaximumFrameSize** (UINT32) - Specifies the maximum TX frame size, including all fragment buffers. Ignored for GSO frames. * **MaximumFragments** (UINT8) - Specifies the maximum number of fragment buffers in an XDP frame. Ignored for GSO frames. * **OutOfOrderCompletionEnabled** (BOOLEAN) - Indicates if the interface is using out-of-order TX completion. ## Initialization Functions ### XdpInitializeTxCapabilities Initializes TX queue capabilities. ```C VOID XdpInitializeTxCapabilities( _Out_ XDP_TX_CAPABILITIES *Capabilities ); ``` ### XdpInitializeTxCapabilitiesSystemVa Initializes TX queue capabilities for system-allocated buffers with virtual addresses. ```C VOID XdpInitializeTxCapabilitiesSystemVa( _Out_ XDP_TX_CAPABILITIES *Capabilities ); ``` ### XdpInitializeTxCapabilitiesSystemMdl Initializes TX queue capabilities for system-allocated buffers with MDLs. ```C VOID XdpInitializeTxCapabilitiesSystemMdl( _Out_ XDP_TX_CAPABILITIES *Capabilities ); ``` ### XdpInitializeTxCapabilitiesSystemDma Initializes TX queue capabilities for system-allocated buffers and DMA. ```C VOID XdpInitializeTxCapabilitiesSystemDma( _Out_ XDP_TX_CAPABILITIES *Capabilities, _In_ XDP_DMA_CAPABILITIES *DmaCapabilities ); ``` ### Parameters * **Capabilities** (_Out_ XDP_TX_CAPABILITIES *) - Pointer to the XDP_TX_CAPABILITIES structure to initialize. * **DmaCapabilities** (_In_ XDP_DMA_CAPABILITIES *) - Pointer to the DMA capabilities structure (for SystemDma initialization). ``` -------------------------------- ### Get AF_XDP Ring Error Code Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Retrieve the error code for an AF_XDP ring using specific socket options for RX, Fill, TX, and Completion rings. This helps diagnose issues with ring operations. ```C #define XSK_SOCKOPT_RX_ERROR 10 #define XSK_SOCKOPT_RX_FILL_ERROR 11 #define XSK_SOCKOPT_TX_ERROR 12 #define XSK_SOCKOPT_TX_COMPLETION_ERROR 13 ``` -------------------------------- ### XSK_SOCKOPT_RX_FRAME_TIMESTAMP_EXTENSION Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Retrieves the offset for the XDP_FRAME_TIMESTAMP descriptor extension in the RX frame ring. This requires the socket to be bound and the RX ring size to be set. The value indicates the offset of the XDP_FRAME_TIMESTAMP structure from the start of each RX descriptor. ```APIDOC ## XSK_SOCKOPT_RX_FRAME_TIMESTAMP_EXTENSION ### Description Gets the `XDP_FRAME_TIMESTAMP` descriptor extension for the RX frame ring. This requires the socket is bound and the RX ring size is set. The returned value is the offset of the `XDP_FRAME_TIMESTAMP` structure from the start of each RX descriptor. The value of the timestamp is provided by the NIC and may be relative to a hardware or software clock. See "Overview of NDIS packet timestamping" on MSDN for details of how to interpret the timestamps. ### Supports Get ### Optval type `UINT16` ``` -------------------------------- ### XDP_TX_DESCRIPTOR_CONTEXTS Structure and Initialization Function Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-txqueueconfig.md Defines the structure for optional descriptor contexts and provides a function to initialize it for TX queues. ```APIDOC ## XDP_TX_DESCRIPTOR_CONTEXTS ### Description Structure defining optional descriptor contexts for XDP transmit queues. ### Fields * **Header** (XDP_OBJECT_HEADER) - Header information. * **FrameContextSize** (UINT8) - If non-zero, enables the XDP_FRAME_INTERFACE_CONTEXT frame extension. Stores arbitrary data. * **FrameContextAlignment** (UINT8) - Sets the XDP_FRAME_INTERFACE_CONTEXT frame extension alignment. Must be a power of two and <= SYSTEM_CACHE_ALIGNMENT_SIZE. * **BufferContextSize** (UINT8) - If non-zero, enables the XDP_BUFFER_INTERFACE_CONTEXT buffer extension. Stores arbitrary data. * **BufferContextAlignment** (UINT8) - Sets the XDP_BUFFER_INTERFACE_CONTEXT buffer extension alignment. Must be a power of two and <= SYSTEM_CACHE_ALIGNMENT_SIZE. ## XdpInitializeTxDescriptorContexts ### Description Initializes descriptor contexts for TX queues. ### Syntax ```C VOID XdpInitializeTxDescriptorContexts( _Out_ XDP_TX_DESCRIPTOR_CONTEXTS *DescriptorContexts ); ``` ### Parameters * **DescriptorContexts** (_Out_ XDP_TX_DESCRIPTOR_CONTEXTS *) - Pointer to the XDP_TX_DESCRIPTOR_CONTEXTS structure to initialize. ``` -------------------------------- ### XSK Ring Error Options Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Retrieves the error code for a specific AF_XDP ring. These options support the 'get' action and use the XSK_ERROR enumeration for their optval, indicating issues like interface detachment or invalid rings. ```APIDOC ## XSK Ring Error Options ### Description Gets the error code for an XSK ring. ### Supports get ### Optval Type XSK_ERROR ### Options - XSK_SOCKOPT_RX_ERROR - XSK_SOCKOPT_RX_FILL_ERROR - XSK_SOCKOPT_TX_ERROR - XSK_SOCKOPT_TX_COMPLETION_ERROR ### Error Codes ```C typedef enum _XSK_ERROR { XSK_NO_ERROR = 0, // The queue has been detached from the underlying interface. XSK_ERROR_INTERFACE_DETACH = 0x80000000, // The XDP driver detected an invalid ring. XSK_ERROR_INVALID_RING = 0xC0000000, } XSK_ERROR; ``` ``` -------------------------------- ### Create an AF_XDP Socket Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XskCreate.md Call XskCreate to create an AF_XDP socket object. A handle to the socket is returned in the Socket parameter. Remember to call CloseHandle to release the socket object when it is no longer needed. ```C XDP_STATUS XskCreate( _Out_ HANDLE* Socket ); ``` -------------------------------- ### Configure XDPMP Rate Simulation Source: https://github.com/microsoft/xdp-for-windows/blob/main/test/xdpmp/xdpmp.md Dynamically configure RX load generation and TX rate limiting for XDPMP using the `xdpmpratesim.ps1` script. ```PowerShell .\xdpmpratesim.ps1 ``` -------------------------------- ### XSK_SOCKOPT_TX_FRAME_TIMESTAMP_EXTENSION Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Retrieves the offset for the XDP_FRAME_TIMESTAMP descriptor extension in the TX completion ring. This requires the socket to be bound and the TX completion ring size to be set. The value indicates the offset of the XDP_FRAME_TIMESTAMP structure from the start of each TX completion descriptor. ```APIDOC ## XSK_SOCKOPT_TX_FRAME_TIMESTAMP_EXTENSION ### Description Gets the `XDP_FRAME_TIMESTAMP` descriptor extension for the TX completion ring. This requires the socket is bound and the TX completion ring size is set. The returned value is the offset of the `XDP_FRAME_TIMESTAMP` structure from the start of each TX completion descriptor. The value of the timestamp is provided by the NIC when the frame is transmitted and may be relative to a hardware or software clock. See "Overview of NDIS packet timestamping" on MSDN for details of how to interpret the timestamps. ### Supports Get ### Optval type `UINT16` ``` -------------------------------- ### Accessing Frame Fragment Extension Data Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/descriptor-extensions.md Demonstrates how to query for and access frame fragment extension data. Ensure the extension handle is correctly obtained via sockopt or driver API before accessing data. ```c XDP_EXTENSION_INFO extensionInfo; XdpInitializeExtensionInfo( &extensionInfo, XDP_FRAME_EXTENSION_FRAGMENT_NAME, XDP_FRAME_EXTENSION_FRAGMENT_VERSION_1, XDP_EXTENSION_TYPE_FRAME); XDP_EXTENSION fragmentExtension; // ... (obtain fragmentExtension via sockopt or driver API) ... XDP_FRAME_FRAGMENT *fragment = XdpGetFragmentExtension(frame, &fragmentExtension); if (fragment->FragmentBufferCount > 0) { // Frame has additional buffers } ``` -------------------------------- ### Initialize RX Capabilities for Driver VA Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-rxqueueconfig.md Initializes RX queue capabilities for driver-allocated buffers with virtual addresses. This is the only supported RX model for XDP version 1. ```c inline VOID XdpInitializeRxCapabilitiesDriverVa( _Out_ XDP_RX_CAPABILITIES *Capabilities ); ``` -------------------------------- ### Configure XDP Hook IDs for AF_XDP Socket Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Set or get the XDP hook ID for RX/TX binding using XSK_SOCKOPT_RX_HOOK_ID and XSK_SOCKOPT_TX_HOOK_ID. If unset, AF_XDP defaults to specific hook IDs for RX and TX. This option can only be set before binding. ```C #define XSK_SOCKOPT_RX_HOOK_ID 8 #define XSK_SOCKOPT_TX_HOOK_ID 9 ``` -------------------------------- ### XDP_CREATE_RX_QUEUE Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-control.md Creates an XDP receive queue for a given interface. This function configures queue parameters and returns interface-specific queue context and dispatch table. ```APIDOC ## XDP_CREATE_RX_QUEUE ### Description Creates an XDP receive queue. The XDP platform ensures at most one XDP queue exists per hardware queue. The queue creation configuration object specifies the XDP queue parameters, including the target queue identifier, and allows interfaces to declare queue capabilities and their activation requirements. Upon successful queue creation, the interface returns its queue context and XDP dispatch table. ### Parameters - **InterfaceContext** (XDP_INTERFACE_HANDLE) - Provides the interface context from registration. - **Config** (XDP_RX_QUEUE_CONFIG_CREATE) - Provides a receive queue creation configuration object. The interface must provide its RX capabilities prior to returning. - **InterfaceRxQueue** (XDP_INTERFACE_HANDLE *) - Upon success, the XDP interface returns its queue context. - **InterfaceRxQueueDispatch** (const XDP_INTERFACE_RX_QUEUE_DISPATCH **) - Upon success, the XDP interface returns its queue dispatch table. ### Return Value NTSTATUS indicating success or failure. ``` -------------------------------- ### Register UMEM with AF_XDP Socket Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Use XSK_SOCKOPT_UMEM_REG to register a UMEM with an AF_XDP socket. This must be done before activation. A socket sharing an existing UMEM should not register its own. ```C #define XSK_SOCKOPT_UMEM_REG 1 typedef struct _XSK_UMEM_REG { UINT64 TotalSize; UINT32 ChunkSize; UINT32 Headroom; VOID *Address; } XSK_UMEM_REG; ``` -------------------------------- ### Ring Size Options Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/xsk-sockopts.md Configures the size of various rings associated with an AF_XDP socket. These options support the 'set' action and expect a UINT32 value representing the number of descriptors. The size must be a power of 2. Each ring type can only be configured once per socket and must be configured before use. ```APIDOC ## Ring Size Options ### Description Sets the size of a ring for the socket. The size must be a power of 2. Only one ring of each type may be configured per socket. Rings must be configured in order to use them (the system does not provide a default size). ### Supports set ### Optval Type UINT32 (number of descriptors) ### Options - XSK_SOCKOPT_RX_RING_SIZE - XSK_SOCKOPT_TX_RING_SIZE - XSK_SOCKOPT_RX_FILL_RING_SIZE - XSK_SOCKOPT_TX_COMPLETION_RING_SIZE ``` -------------------------------- ### Define XDP_BUFFER_INTERFACE_CONTEXT and related macros Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XDP_BUFFER_INTERFACE_CONTEXT.md Defines the opaque XDP_BUFFER_INTERFACE_CONTEXT type and macros for its name and version. This context is for per-buffer storage used by XDP interface drivers. ```C // // Opaque, variable-sized context reserved for use by the XDP interface in each // XDP buffer; the XDP platform will not read/write this extension. // typedef VOID XDP_BUFFER_INTERFACE_CONTEXT; #define XDP_BUFFER_EXTENSION_INTERFACE_CONTEXT_NAME L"ms_buffer_interface_context" #define XDP_BUFFER_EXTENSION_INTERFACE_CONTEXT_VERSION_1 1U ``` -------------------------------- ### XdpTxQueueGetExtension Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-txqueueconfig.md Retrieves a registered and enabled XDP extension. ```APIDOC ## XdpTxQueueGetExtension ### Description Gets a registered and enabled XDP extension. ### Syntax VOID XdpTxQueueGetExtension( _In_ XDP_TX_QUEUE_CONFIG_ACTIVATE TxQueueConfig, _In_ XDP_EXTENSION_INFO *ExtensionInfo, _Out_ XDP_EXTENSION *Extension ); ### Parameters #### Input Parameters - **TxQueueConfig** (_In_ XDP_TX_QUEUE_CONFIG_ACTIVATE) - Configuration for the transmit queue. - **ExtensionInfo** (_In_ XDP_EXTENSION_INFO *) - Information about the desired extension. #### Output Parameters - **Extension** (_Out_ XDP_EXTENSION *) - Pointer to store the retrieved extension. ### Returns VOID ``` -------------------------------- ### Set RX Queue Capabilities Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/driver-rxqueueconfig.md Mandatory function to set the RX queue capabilities. This must be called before activating the queue. ```c VOID XdpRxQueueSetCapabilities( _In_ XDP_RX_QUEUE_CONFIG_CREATE RxQueueConfig, _In_ XDP_RX_CAPABILITIES *Capabilities ); ``` -------------------------------- ### XskCreate Function Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XskCreate.md Creates an AF_XDP socket object and returns a handle to it. To close the socket object, call CloseHandle. ```APIDOC ## XskCreate ### Description Creates an AF_XDP socket object and returns a handle to it. To close the socket object, call CloseHandle. ### Syntax ```C XDP_STATUS XskCreate( _Out_ HANDLE* Socket ); ``` ### Parameters TODO ### Remarks Creates an AF_XDP socket object and returns a handle to it. To close the socket object, call CloseHandle. ### See Also [AF_XDP](../afxdp.md) ``` -------------------------------- ### XdpInterfaceOpen Function Signature Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpInterfaceOpen.md This C function signature defines how to open a handle to an XDP interface. It requires the interface index and returns a handle upon success. The handle must be closed using CloseHandle to revert configurations. ```C XDP_STATUS XdpInterfaceOpen( _In_ UINT32 InterfaceIndex, _Out_ HANDLE *InterfaceHandle ); ``` -------------------------------- ### XdpMapCreate Function Signature Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpMapCreate.md This is the C syntax for the XdpMapCreate function. It creates a new XDP map of a specified type and returns a handle to it. ```C XDP_STATUS XdpMapCreate( _Out_ HANDLE *Map, _In_ XDP_MAP_TYPE Type ); ``` -------------------------------- ### Define XDP_BUFFER_LOGICAL_ADDRESS Structure and Constants Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XDP_BUFFER_LOGICAL_ADDRESS.md Defines the C structure for holding a device-logical buffer address and associated constants for identifying this extension. ```C typedef struct _XDP_BUFFER_LOGICAL_ADDRESS { // // Contains the device logical address of a buffer. // UINT64 LogicalAddress; } XDP_BUFFER_LOGICAL_ADDRESS; #define XDP_BUFFER_EXTENSION_LOGICAL_ADDRESS_NAME L"ms_buffer_logical_address" #define XDP_BUFFER_EXTENSION_LOGICAL_ADDRESS_VERSION_1 1U ``` -------------------------------- ### Define XDP_LOAD_API_CONTEXT Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XDP_LOAD_API_CONTEXT.md Defines the XDP_LOAD_API_CONTEXT as a pointer to an opaque structure. This is used for managing library loads and unloads. ```C typedef struct _XDP_LOAD_CONTEXT *XDP_LOAD_API_CONTEXT; ``` -------------------------------- ### Define XDP_QUIC_FLOW Structure Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XDP_MATCH_PATTERN.md Defines a structure for matching QUIC flows based on UDP port and connection ID. ```C typedef struct _XDP_QUIC_FLOW { UINT16 UdpPort; UCHAR CidLength; UCHAR CidOffset; UCHAR CidData[XDP_QUIC_MAX_CID_LENGTH]; // Max allowed per QUIC v1 RFC } XDP_QUIC_FLOW; ``` -------------------------------- ### Enable WinRM Remoting on Test Machine Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/remote-testing.md Run this command once on the test machine in an elevated PowerShell session to configure WinRM for remote access. It enables PowerShell remoting and applies necessary WinRM tweaks for clean deployments and long test runs. ```powershell .\tools\remote.ps1 -EnableRemoting ``` -------------------------------- ### XdpLoadApi Function Signature Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpLoadApi.md This function dynamically loads the `xdpapi.dll` library, then opens the API and returns an API function table with the rest of the API's functions. This function is provided inline in XDP headers. It is deprecated and should not be used in new applications. ```APIDOC ## XdpLoadApi ### Description Dynamically loads the `xdpapi.dll` library, then opens the API and returns an API function table with the rest of the API's functions. This function is provided inline in XDP headers. **This API is deprecated.** It is provided only for backward compatibility with applications using `XDP_API_VERSION_1` or `XDP_API_VERSION_2`. New applications should use `XDP_API_VERSION_3` or later, which provides header-only API implementations that do not require the `xdpapi.dll` library. ### Syntax ```C inline HRESULT XdpLoadApi( _In_ UINT32 XdpApiVersion, _Out_ XDP_LOAD_API_CONTEXT *XdpLoadApiContext, _Out_ const XDP_API_TABLE **XdpApiTable ); ``` ### Parameters `XdpApiVersion` The XDP API version required by the caller. `XdpLoadApiContext` An pointer to an [`XDP_LOAD_API_CONTEXT`](XDP_LOAD_API_CONTEXT.md) opaque structure tracking the load. `XdpApiTable` A double pointer to an [`XDP_API_TABLE`](XDP_API_TABLE.md) structure containing a set of API routines. ### Remarks This routine cannot be called from `DllMain`. Each `XdpLoadApi` must invoke a corresponding [`XdpUnloadApi`](XdpUnloadApi.md) when the API will no longer be used. ``` -------------------------------- ### View In-Kernel Circular Buffer Logs Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/usage.md Command to view the most recent log entries from the continuously running WPP logging session in the in-kernel circular buffer. This can be used with the kernel debugger. ```text !rcdrkd.rcdrlogdump xdp ``` -------------------------------- ### XdpMapCreate Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpMapCreate.md Creates a new XDP map of the specified type. It returns a handle to the newly created map. ```APIDOC ## XdpMapCreate ### Description Creates a new XDP map of the specified type. It returns a handle to the newly created map. ### Syntax ```C XDP_STATUS XdpMapCreate( _Out_ HANDLE *Map, _In_ XDP_MAP_TYPE Type ); ``` ### Parameters #### Map If the map is created successfully, returns a Windows handle to the map. The map is destroyed by XDP when the handle is closed via `CloseHandle`; all entry references held by the map are released at that time. #### Type The [`XDP_MAP_TYPE`](XDP_MAP_TYPE.md) of map to create. The type determines the key and value formats accepted by [`XdpMapInsert`](XdpMapInsert.md) and [`XdpMapDelete`](XdpMapDelete.md). ### Remarks The map handle returned by `XdpMapCreate` may be passed as a redirect target in an [`XDP_RULE`](XDP_RULE.md) using a map-aware [`XDP_REDIRECT_TARGET_TYPE`](XDP_REDIRECT_TARGET_TYPE.md). The XDP program takes its own reference on the map; closing the handle from user mode does not invalidate any program already attached to the map. ``` -------------------------------- ### XdpGetMdlExtension Function Signature Source: https://github.com/microsoft/xdp-for-windows/blob/main/docs/api/XdpGetMdlExtension.md Provides the C syntax for the XdpGetMdlExtension function. ```APIDOC ## XdpGetMdlExtension ### Description Returns the [`XDP_BUFFER_MDL`](XDP_BUFFER_MDL.md) of an XDP buffer. ### Syntax ```C inline XDP_BUFFER_MDL * XdpGetMdlExtension( _In_ XDP_BUFFER *Buffer, _In_ XDP_EXTENSION *Extension ); ``` ### Parameters TODO ### Remarks TODO ```