diff options
| author | Yang You (UU) <[email protected]> | 2025-12-08 11:38:51 -0800 |
|---|---|---|
| committer | Yang You (UU) <[email protected]> | 2025-12-08 11:38:51 -0800 |
| commit | 5d296ca7451db754f37261df544a032bf23b12fb (patch) | |
| tree | 75105627da02acd4c71724459502534496668f29 | |
| parent | e6d3536e4873fb928f2cc9683df05718fddc8923 (diff) | |
Remove NETCX2.6 depend features
7 files changed, 6 insertions, 256 deletions
diff --git a/network/netadaptercx/netvadapterlibrary/Interface/netvadapter.h b/network/netadaptercx/netvadapterlibrary/Interface/netvadapter.h index d8e4294f..f4160dfa 100644 --- a/network/netadaptercx/netvadapterlibrary/Interface/netvadapter.h +++ b/network/netadaptercx/netvadapterlibrary/Interface/netvadapter.h @@ -66,12 +66,6 @@ public: WDFDEVICE m_device = WDF_NO_HANDLE; -#if ((NETADAPTER_VERSION_MAJOR == 2) && (NETADAPTER_VERSION_MINOR >= 6)) - BOOLEAN PreallocatedRxBuffers; - NETMEMORYCOLLECTION - m_preallocatedRxBuffers = WDF_NO_HANDLE; -#endif //NETCX 2.6 only - // configuration NET_ADAPTER_LINK_LAYER_ADDRESS PermanentAddress; NET_ADAPTER_LINK_LAYER_ADDRESS CurrentAddress; diff --git a/network/netadaptercx/netvadapterlibrary/code/adapter.cpp b/network/netadaptercx/netvadapterlibrary/code/adapter.cpp index a047f163..5dc530ea 100644 --- a/network/netadaptercx/netvadapterlibrary/code/adapter.cpp +++ b/network/netadaptercx/netvadapterlibrary/code/adapter.cpp @@ -431,57 +431,14 @@ NetvAdapterSetUsoUroOffloadCapabilities( _Use_decl_annotations_ NTSTATUS NetvAdapter::ConfigureDataCapabilities() { -#if ((NETADAPTER_VERSION_MAJOR == 2) && (NETADAPTER_VERSION_MINOR >= 6)) - if (PreallocatedRxBuffers) - { - WDF_OBJECT_ATTRIBUTES attributes; - WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, Memory); - attributes.EvtDestroyCallback = [](WDFOBJECT Object) - { - Memory* memory = GetMemoryFromHandle(Object); - memory->~Memory(); - }; - - attributes.EvtCleanupCallback = [](WDFOBJECT Object) - { - Memory* memory = GetMemoryFromHandle(Object); - memory->ReleaseAllMappings(); - }; - - NET_MEMORY_COLLECTION_CONFIG collectionConfig; - NET_MEMORY_COLLECTION_CONFIG_INIT( - &collectionConfig, - PREALLOCATED_BUFFERS_COUNT); - - RETURN_IF_NOT_STATUS_SUCCESS( - NetMemoryCollectionCreate( - m_device, - &attributes, - &collectionConfig, - &m_preallocatedRxBuffers)); - Memory* memory = new (GetMemoryFromHandle(m_preallocatedRxBuffers)) Memory(); - RETURN_IF_NOT_STATUS_SUCCESS( - memory->Initialize( - m_preallocatedRxBuffers, - MAX_RX_BUFFER_SIZE - )); - } -#endif //NETCX 2.6 only NET_ADAPTER_TX_CAPABILITIES txCapabilities; NET_ADAPTER_TX_CAPABILITIES_INIT(&txCapabilities, MAX_TX_QUEUES); NET_ADAPTER_RX_CAPABILITIES rxCapabilities; NET_ADAPTER_RX_CAPABILITIES_INIT_SYSTEM_MANAGED(&rxCapabilities, MAX_RX_BUFFER_SIZE, MAX_RX_QUEUES); -#if ((NETADAPTER_VERSION_MAJOR == 2) && (NETADAPTER_VERSION_MINOR >= 6)) - if (PreallocatedRxBuffers) - { - rxCapabilities.AllocationMode = NetRxFragmentBufferAllocationModeDriverV2; - rxCapabilities.AttachmentMode = NetRxFragmentBufferAttachmentModeDriver; - rxCapabilities.MemoryCollection = m_preallocatedRxBuffers; - } -#endif //NETCX 2.6 only + NET_ADAPTER_LINK_LAYER_CAPABILITIES linkLayerCapabilities; NET_ADAPTER_LINK_LAYER_CAPABILITIES_INIT(&linkLayerCapabilities, MAX_LINK_SPEED, MAX_LINK_SPEED); diff --git a/network/netadaptercx/netvadapterlibrary/code/enl.cpp b/network/netadaptercx/netvadapterlibrary/code/enl.cpp index 4d4120b8..0a7d53d3 100644 --- a/network/netadaptercx/netvadapterlibrary/code/enl.cpp +++ b/network/netadaptercx/netvadapterlibrary/code/enl.cpp @@ -348,52 +348,13 @@ EnlpIterationRoutine( auto fragment = NetFragmentIteratorGetFragment(&rxFi); BYTE* fragmentBuffer = nullptr; -#if ((NETADAPTER_VERSION_MAJOR == 2) && (NETADAPTER_VERSION_MINOR >= 6)) - if (rxq->RxQueue->m_adapter.PreallocatedRxBuffers) - { - MemoryBuffer* bufferToUse = GetMemoryFromHandle(rxq->RxQueue->m_adapter.m_preallocatedRxBuffers)->PopAvailableBuffer(); - if (bufferToUse == nullptr) - { - // No more buffers available, stop processing packets - rxq->QueueNext = NetFragmentIteratorGetIndex(&rxFi); - break; - } - - NET_FRAGMENT_NET_MEMORY* netMemoryId = - NetExtensionGetFragmentNetMemory( - &rxq->RxQueue->NetMemoryExtension, - NetFragmentIteratorGetIndex(&rxFi)); - - NET_FRAGMENT_RETURN_CONTEXT* fragmentReturnContext = - NetExtensionGetFragmentReturnContext( - &rxq->RxQueue->NetMemoryReturnContextExtensionIn, - NetFragmentIteratorGetIndex(&rxFi)); - - netMemoryId->NetMemoryId = bufferToUse->MemoryId; - fragmentReturnContext->Handle = reinterpret_cast<NET_FRAGMENT_RETURN_CONTEXT_HANDLE>(bufferToUse); - fragmentBuffer = bufferToUse->VirtualAddress; - auto const rxVirtualAddress = - NetExtensionGetFragmentVirtualAddress( - &rxq->RxQueue->VirtualAddressExtension, - NetFragmentIteratorGetIndex(&rxFi)); + auto const rxVirtualAddress = + NetExtensionGetFragmentVirtualAddress( + &rxq->RxQueue->VirtualAddressExtension, + NetFragmentIteratorGetIndex(&rxFi)); - rxVirtualAddress->VirtualAddress = bufferToUse->VirtualAddress; - - fragment->Capacity = MAX_RX_BUFFER_SIZE; - fragment->Offset = 0; - fragment->Scratch = 0; - } - else -#endif //NETCX 2.6 only - { - auto const rxVirtualAddress = - NetExtensionGetFragmentVirtualAddress( - &rxq->RxQueue->VirtualAddressExtension, - NetFragmentIteratorGetIndex(&rxFi)); - - fragmentBuffer = static_cast<BYTE *>(rxVirtualAddress->VirtualAddress); - } + fragmentBuffer = static_cast<BYTE *>(rxVirtualAddress->VirtualAddress); fragment->Offset = 0; fragment->ValidLength = diff --git a/network/netadaptercx/netvadapterlibrary/code/memory.cpp b/network/netadaptercx/netvadapterlibrary/code/memory.cpp index b7536531..35a3f2c5 100644 --- a/network/netadaptercx/netvadapterlibrary/code/memory.cpp +++ b/network/netadaptercx/netvadapterlibrary/code/memory.cpp @@ -1,95 +1,8 @@ // Copyright (C) Microsoft Corporation. All rights reserved. #include "pch.hpp" #include "memory.h" -#include <netadaptercx.h> -#include "trace.h" #include "memory.tmh" -#if ((NETADAPTER_VERSION_MAJOR == 2) && (NETADAPTER_VERSION_MINOR >= 6)) - -NTSTATUS -Memory::Initialize( - NETMEMORYCOLLECTION MemoryCollection, - size_t BufferSize -) -{ - m_memoryCollection = MemoryCollection; - - for (size_t i = 0; i < PREALLOCATED_BUFFERS_COUNT; i++) - { - NET_MEMORY_CONFIG memoryConfig{}; - NET_MEMORY_CONFIG_INIT( - &memoryConfig, - m_buffers[i].VirtualAddress, - BufferSize); - - RETURN_IF_NOT_STATUS_SUCCESS( - NetMemoryCreate( - MemoryCollection, - &memoryConfig, - &m_buffers[i].MemoryId - )); - - m_buffersReadyToUse[i] = &m_buffers[i]; - } - - m_lastBufferToUse = PREALLOCATED_BUFFERS_COUNT; - // Create WDF spinlock for the queue, parent to the queue's WDF handle - { - WDF_OBJECT_ATTRIBUTES attributes; - WDF_OBJECT_ATTRIBUTES_INIT(&attributes); - status = WdfSpinLockCreate(&attributes, &m_spinLock); - NT_ASSERT(NT_SUCCESS(status)); - } - return STATUS_SUCCESS; -} - -void -Memory::ReleaseAllMappings( - void -) -{ - for (size_t i = 0; i < PREALLOCATED_BUFFERS_COUNT; i++) - { - NetMemoryDestroy(m_memoryCollection, m_buffers[i].MemoryId); - } - - m_lastBufferToUse = 0; - RtlZeroMemory(m_buffersReadyToUse, sizeof(m_buffersReadyToUse)); -} - -MemoryBuffer* -Memory::PopAvailableBuffer( - void -) -{ - WdfSpinLockAcquire(m_spinLock); - - if (m_lastBufferToUse == 0) - { - WdfSpinLockRelease(m_spinLock); - return nullptr; - } - auto returnbuffer = m_buffersReadyToUse[--m_lastBufferToUse]; - WdfSpinLockRelease(m_spinLock); - - return returnbuffer; -} - -void -Memory::ReturnBuffer( - MemoryBuffer* Buffer -) -{ - WdfSpinLockAcquire(m_spinLock); - - NT_FRE_ASSERT(m_lastBufferToUse < PREALLOCATED_BUFFERS_COUNT); - - m_buffersReadyToUse[m_lastBufferToUse++] = Buffer; - WdfSpinLockRelease(m_spinLock); -} -#endif //NETCX 2.6 only - // for wil::make_unique_nothrow void* operator new(size_t s, std::nothrow_t const&) diff --git a/network/netadaptercx/netvadapterlibrary/code/memory.h b/network/netadaptercx/netvadapterlibrary/code/memory.h index 4c19fc39..1200c72c 100644 --- a/network/netadaptercx/netvadapterlibrary/code/memory.h +++ b/network/netadaptercx/netvadapterlibrary/code/memory.h @@ -2,61 +2,3 @@ #pragma once #define MAX_RX_BUFFER_SIZE 65535 - -#if ((NETADAPTER_VERSION_MAJOR == 2) && (NETADAPTER_VERSION_MINOR >= 6)) - -static const size_t PREALLOCATED_BUFFERS_COUNT = 128; - -struct MemoryBuffer -{ - NET_MEMORY_ID - MemoryId; - - BYTE - VirtualAddress[MAX_RX_BUFFER_SIZE]; -}; - -class Memory -{ -public: - - NTSTATUS - Initialize( - NETMEMORYCOLLECTION MemoryCollection, - size_t BufferSize - ); - - MemoryBuffer* - PopAvailableBuffer( - void - ); - - void - ReturnBuffer( - MemoryBuffer* Buffer - ); - - void - ReleaseAllMappings( - void - ); - -private: - NETMEMORYCOLLECTION - m_memoryCollection; - - MemoryBuffer - m_buffers[PREALLOCATED_BUFFERS_COUNT]; - - MemoryBuffer* - m_buffersReadyToUse[PREALLOCATED_BUFFERS_COUNT]; - - size_t - m_lastBufferToUse; - - WDFSPINLOCK - m_spinLock{}; -}; - -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(Memory, GetMemoryFromHandle); -#endif //NETCX 2.6 only
\ No newline at end of file diff --git a/network/netadaptercx/netvadapterlibrary/code/queue.cpp b/network/netadaptercx/netvadapterlibrary/code/queue.cpp index cf2aa586..667d59f7 100644 --- a/network/netadaptercx/netvadapterlibrary/code/queue.cpp +++ b/network/netadaptercx/netvadapterlibrary/code/queue.cpp @@ -32,13 +32,3 @@ NetvQueue::GetFragmentRing( { return NetRingCollectionGetFragmentRing(m_rings); } - -#if ((NETADAPTER_VERSION_MAJOR == 2) && (NETADAPTER_VERSION_MINOR >= 6)) -NET_RING * -NetvQueue::GetNetMemoryReturnRing( - void -) -{ - return NetRingCollectionGetFragmentReturnContextRing(m_rings); -} -#endif // NETCX 2.6 only
\ No newline at end of file diff --git a/network/netadaptercx/netvadapterlibrary/code/queue.h b/network/netadaptercx/netvadapterlibrary/code/queue.h index da101fd3..becb72ce 100644 --- a/network/netadaptercx/netvadapterlibrary/code/queue.h +++ b/network/netadaptercx/netvadapterlibrary/code/queue.h @@ -26,13 +26,6 @@ public: void ); -#if ((NETADAPTER_VERSION_MAJOR == 2) && (NETADAPTER_VERSION_MINOR >= 6)) - NET_RING * - GetNetMemoryReturnRing( - void - ); -#endif // NETCX 2.6 only - NETPACKETQUEUE const m_handle{WDF_NO_HANDLE}; |
