[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 2/2] Use a single locked receiver GetList
This avoids the need for any reference to the current CPU or need for MAXIMUM_PROCESSOR sized array. Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx> --- src/xennet/receiver.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/xennet/receiver.c b/src/xennet/receiver.c index dcd88af..98da49b 100644 --- a/src/xennet/receiver.c +++ b/src/xennet/receiver.c @@ -39,7 +39,8 @@ struct _XENNET_RECEIVER { PXENNET_ADAPTER Adapter; NDIS_HANDLE NetBufferListPool; PNET_BUFFER_LIST PutList; - PNET_BUFFER_LIST GetList[MAXIMUM_PROCESSORS]; + PNET_BUFFER_LIST GetList; + KSPIN_LOCK Lock; LONG InNDIS; LONG InNDISMax; XENVIF_VIF_OFFLOAD_OPTIONS OffloadOptions; @@ -56,22 +57,19 @@ __ReceiverAllocateNetBufferList( IN ULONG Length ) { - ULONG Cpu; PNET_BUFFER_LIST NetBufferList; - Cpu = KeGetCurrentProcessorNumber(); + ASSERT3U(KeGetCurrentIrql(), ==, DISPATCH_LEVEL); + KeAcquireSpinLockAtDpcLevel(&Receiver->Lock); - NetBufferList = Receiver->GetList[Cpu]; - - if (NetBufferList == NULL) - Receiver->GetList[Cpu] = InterlockedExchangePointer(&Receiver->PutList, NULL); - - NetBufferList = Receiver->GetList[Cpu]; + if (Receiver->GetList == NULL) + Receiver->GetList = InterlockedExchangePointer(&Receiver->PutList, NULL); + NetBufferList = Receiver->GetList; if (NetBufferList != NULL) { PNET_BUFFER NetBuffer; - Receiver->GetList[Cpu] = NET_BUFFER_LIST_NEXT_NBL(NetBufferList); + Receiver->GetList = NET_BUFFER_LIST_NEXT_NBL(NetBufferList); NET_BUFFER_LIST_NEXT_NBL(NetBufferList) = NULL; NetBuffer = NET_BUFFER_LIST_FIRST_NB(NetBufferList); @@ -90,6 +88,8 @@ __ReceiverAllocateNetBufferList( ASSERT(IMPLY(NetBufferList != NULL, NET_BUFFER_LIST_NEXT_NBL(NetBufferList) == NULL)); } + KeReleaseSpinLockFromDpcLevel(&Receiver->Lock); + return NetBufferList; } @@ -301,6 +301,8 @@ ReceiverInitialize( if ((*Receiver)->NetBufferListPool == NULL) goto fail2; + KeInitializeSpinLock(&(*Receiver)->Lock); + return NDIS_STATUS_SUCCESS; fail2: @@ -313,23 +315,20 @@ ReceiverTeardown( IN PXENNET_RECEIVER Receiver ) { - ULONG Cpu; - PNET_BUFFER_LIST NetBufferList; + PNET_BUFFER_LIST NetBufferList; ASSERT(Receiver != NULL); - for (Cpu = 0; Cpu < MAXIMUM_PROCESSORS; Cpu++) { - NetBufferList = Receiver->GetList[Cpu]; - while (NetBufferList != NULL) { - PNET_BUFFER_LIST Next; + NetBufferList = Receiver->GetList; + while (NetBufferList != NULL) { + PNET_BUFFER_LIST Next; - Next = NET_BUFFER_LIST_NEXT_NBL(NetBufferList); - NET_BUFFER_LIST_NEXT_NBL(NetBufferList) = NULL; + Next = NET_BUFFER_LIST_NEXT_NBL(NetBufferList); + NET_BUFFER_LIST_NEXT_NBL(NetBufferList) = NULL; - NdisFreeNetBufferList(NetBufferList); + NdisFreeNetBufferList(NetBufferList); - NetBufferList = Next; - } + NetBufferList = Next; } NetBufferList = Receiver->PutList; -- 2.1.1 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |