From: Paul Durrant Date: Fri, 20 Mar 2015 13:19:16 +0000 (+0000) Subject: Make XENNET processor group aware X-Git-Tag: 8.1.0-rc1~12 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=fa882ee305a9663503080fdee9762d3ae1896f5c;p=pvdrivers%2Fwin%2Fxennet.git Make XENNET processor group aware Processor groups have been around for a long time in Windows and contnuing to ignore them becomes ever more painful when trying to pass the HCK multiple processor group device test. This patch, therefore, modifies all the code that uses the non-group-aware kernel calls to use the newer group aware calls. Signed-off-by: Paul Durrant --- diff --git a/src/xennet/driver.c b/src/xennet/driver.c index c6a4896..e77ae6e 100644 --- a/src/xennet/driver.c +++ b/src/xennet/driver.c @@ -32,6 +32,7 @@ #define INITGUID 1 #include +#include #include "adapter.h" #include #include "dbg_print.h" @@ -411,6 +412,7 @@ DriverEntry ( ULONG FailDeviceControl; ExInitializeDriverRuntime(DrvRtPoolNxOptIn); + WdmlibProcgrpInitialize(); Trace("====>\n"); diff --git a/src/xennet/receiver.c b/src/xennet/receiver.c index dcd88af..95285cd 100644 --- a/src/xennet/receiver.c +++ b/src/xennet/receiver.c @@ -29,6 +29,8 @@ * SUCH DAMAGE. */ +#include +#include #include "receiver.h" #include "adapter.h" #include @@ -39,7 +41,8 @@ struct _XENNET_RECEIVER { PXENNET_ADAPTER Adapter; NDIS_HANDLE NetBufferListPool; PNET_BUFFER_LIST PutList; - PNET_BUFFER_LIST GetList[MAXIMUM_PROCESSORS]; + PNET_BUFFER_LIST *GetList; + ULONG GetListCount; LONG InNDIS; LONG InNDISMax; XENVIF_VIF_OFFLOAD_OPTIONS OffloadOptions; @@ -56,22 +59,23 @@ __ReceiverAllocateNetBufferList( IN ULONG Length ) { - ULONG Cpu; + ULONG Index; PNET_BUFFER_LIST NetBufferList; - Cpu = KeGetCurrentProcessorNumber(); + Index = KeGetCurrentProcessorNumberEx(NULL); + ASSERT3U(Index, <, Receiver->GetListCount); - NetBufferList = Receiver->GetList[Cpu]; + NetBufferList = Receiver->GetList[Index]; - if (NetBufferList == NULL) - Receiver->GetList[Cpu] = InterlockedExchangePointer(&Receiver->PutList, NULL); - - NetBufferList = Receiver->GetList[Cpu]; + if (NetBufferList == NULL) { + Receiver->GetList[Index] = InterlockedExchangePointer(&Receiver->PutList, NULL); + NetBufferList = Receiver->GetList[Index]; + } if (NetBufferList != NULL) { PNET_BUFFER NetBuffer; - Receiver->GetList[Cpu] = NET_BUFFER_LIST_NEXT_NBL(NetBufferList); + Receiver->GetList[Index] = NET_BUFFER_LIST_NEXT_NBL(NetBufferList); NET_BUFFER_LIST_NEXT_NBL(NetBufferList) = NULL; NetBuffer = NET_BUFFER_LIST_FIRST_NB(NetBufferList); @@ -285,6 +289,16 @@ ReceiverInitialize( RtlZeroMemory(*Receiver, sizeof(XENNET_RECEIVER)); (*Receiver)->Adapter = Adapter; + (*Receiver)->GetListCount = KeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS); + (*Receiver)->GetList = ExAllocatePoolWithTag(NonPagedPool, + sizeof(PNET_BUFFER_LIST) * + (*Receiver)->GetListCount, + RECEIVER_POOL_TAG); + + status = NDIS_STATUS_RESOURCES; + if ((*Receiver)->GetList == NULL) + goto fail2; + RtlZeroMemory(&Params, sizeof(NET_BUFFER_LIST_POOL_PARAMETERS)); Params.Header.Type = NDIS_OBJECT_TYPE_DEFAULT; Params.Header.Revision = NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1; @@ -299,11 +313,18 @@ ReceiverInitialize( status = NDIS_STATUS_RESOURCES; if ((*Receiver)->NetBufferListPool == NULL) - goto fail2; + goto fail3; return NDIS_STATUS_SUCCESS; +fail3: + ExFreePoolWithTag((*Receiver)->GetList, RECEIVER_POOL_TAG); + (*Receiver)->GetListCount = 0; + fail2: + ExFreePoolWithTag(*Receiver, RECEIVER_POOL_TAG); + *Receiver = NULL; + fail1: return status; } @@ -313,13 +334,14 @@ ReceiverTeardown( IN PXENNET_RECEIVER Receiver ) { - ULONG Cpu; - PNET_BUFFER_LIST NetBufferList; + ULONG Index; + PNET_BUFFER_LIST NetBufferList; ASSERT(Receiver != NULL); - for (Cpu = 0; Cpu < MAXIMUM_PROCESSORS; Cpu++) { - NetBufferList = Receiver->GetList[Cpu]; + for (Index = 0; Index < Receiver->GetListCount; Index++) { + NetBufferList = Receiver->GetList[Index]; + while (NetBufferList != NULL) { PNET_BUFFER_LIST Next; @@ -347,6 +369,9 @@ ReceiverTeardown( NdisFreeNetBufferListPool(Receiver->NetBufferListPool); Receiver->NetBufferListPool = NULL; + ExFreePoolWithTag(Receiver->GetList, RECEIVER_POOL_TAG); + Receiver->GetListCount = 0; + Receiver->Adapter = NULL; ExFreePoolWithTag(Receiver, RECEIVER_POOL_TAG); diff --git a/vs2012/xennet/xennet.vcxproj b/vs2012/xennet/xennet.vcxproj index 03ddf91..0e2fc22 100644 --- a/vs2012/xennet/xennet.vcxproj +++ b/vs2012/xennet/xennet.vcxproj @@ -42,7 +42,7 @@ ..\..\src\xennet.inf;..\..\include\version.hx - __MODULE__="XENNET";NDIS_MINIPORT_DRIVER;NDIS60_MINIPORT=1;POOL_NX_OPTIN=1;%(PreprocessorDefinitions) + __MODULE__="XENNET";NDIS_MINIPORT_DRIVER;NDIS60_MINIPORT=1;POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions) EnableAllWarnings 4711;4548;4820;4668;4255;6001;6054;28196;%(DisableSpecificWarnings) true @@ -50,7 +50,7 @@ false - $(DDK_LIB_PATH)\ndis.lib;%(AdditionalDependencies) + $(DDK_LIB_PATH)\ndis.lib;$(DDK_LIB_PATH)\procgrp.lib;%(AdditionalDependencies) false diff --git a/vs2013/xennet/xennet.vcxproj b/vs2013/xennet/xennet.vcxproj index 6cb09d2..2eaf191 100644 --- a/vs2013/xennet/xennet.vcxproj +++ b/vs2013/xennet/xennet.vcxproj @@ -74,7 +74,7 @@ ..\..\src\xennet.inf;..\..\include\version.hx - __MODULE__="XENNET";NDIS_MINIPORT_DRIVER;NDIS60_MINIPORT=1;POOL_NX_OPTIN=1;%(PreprocessorDefinitions) + __MODULE__="XENNET";NDIS_MINIPORT_DRIVER;NDIS60_MINIPORT=1;POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions) EnableAllWarnings 4711;4548;4820;4668;4255;6001;6054;28196;%(DisableSpecificWarnings) true @@ -82,7 +82,7 @@ false - $(DDK_LIB_PATH)\ndis.lib;%(AdditionalDependencies) + $(DDK_LIB_PATH)\ndis.lib;$(DDK_LIB_PATH)\procgrp.lib;%(AdditionalDependencies) false