[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 2/3] Stop caching MaxQueues, NumQueues and Split in Transmitter and Receiver
Just call the Frontend accessor when the values are required. Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx> --- src/xenvif/receiver.c | 72 +++++++++++++++++++++++--------------------- src/xenvif/transmitter.c | 77 +++++++++++++++++++++++++----------------------- 2 files changed, 79 insertions(+), 70 deletions(-) diff --git a/src/xenvif/receiver.c b/src/xenvif/receiver.c index 36557b7..030f84f 100644 --- a/src/xenvif/receiver.c +++ b/src/xenvif/receiver.c @@ -111,9 +111,6 @@ struct _XENVIF_RECEIVER { XENBUS_GNTTAB_INTERFACE GnttabInterface; XENBUS_EVTCHN_INTERFACE EvtchnInterface; PXENVIF_RECEIVER_RING *Ring; - LONG MaxQueues; - LONG NumQueues; - BOOLEAN Split; LONG Loaned; LONG Returned; KEVENT Event; @@ -1737,10 +1734,12 @@ ReceiverRingDebugCallback( { PXENVIF_RECEIVER_RING Ring = Argument; PXENVIF_RECEIVER Receiver; + PXENVIF_FRONTEND Frontend; UNREFERENCED_PARAMETER(Crashing); Receiver = Ring->Receiver; + Frontend = Receiver->Frontend; XENBUS_DEBUG(Printf, &Receiver->DebugInterface, @@ -1779,7 +1778,7 @@ ReceiverRingDebugCallback( XENBUS_DEBUG(Printf, &Receiver->DebugInterface, "[%s]: Events = %lu Dpcs = %lu\n", - Receiver->Split ? "RX" : "COMBINED", + FrontendIsSplit(Frontend) ? "RX" : "COMBINED", Ring->Events, Ring->Dpcs); } @@ -2014,7 +2013,7 @@ ReceiverRingDpc( if (Ring->Enabled) { __ReceiverRingNotify(Ring); - if (!Receiver->Split) + if (!FrontendIsSplit(Frontend)) TransmitterNotify(FrontendGetTransmitter(Frontend), Ring->Index); } @@ -2441,7 +2440,7 @@ __ReceiverRingStoreWrite( Receiver = Ring->Receiver; Frontend = Receiver->Frontend; - Path = (Receiver->NumQueues == 1) ? + Path = (FrontendGetNumQueues(Frontend) == 1) ? FrontendGetPath(Frontend) : Ring->Path; @@ -2465,7 +2464,7 @@ __ReceiverRingStoreWrite( &Receiver->StoreInterface, Transaction, Path, - Receiver->Split ? "event-channel-rx" : "event-channel", + FrontendIsSplit(Frontend) ? "event-channel-rx" : "event-channel", "%u", Port); if (!NT_SUCCESS(status)) @@ -2695,6 +2694,7 @@ ReceiverInitialize( ) { HANDLE ParametersKey; + LONG MaxQueues; LONG Index; NTSTATUS status; @@ -2777,16 +2777,16 @@ ReceiverInitialize( (*Receiver)->Frontend = Frontend; - (*Receiver)->MaxQueues = FrontendGetMaxQueues(Frontend); + MaxQueues = FrontendGetMaxQueues(Frontend); (*Receiver)->Ring = __ReceiverAllocate(sizeof (PXENVIF_RECEIVER_RING) * - (*Receiver)->MaxQueues); + MaxQueues); status = STATUS_NO_MEMORY; if ((*Receiver)->Ring == NULL) goto fail2; Index = 0; - while (Index < (*Receiver)->MaxQueues) { + while (Index < MaxQueues) { PXENVIF_RECEIVER_RING Ring; status = __ReceiverRingInitialize(*Receiver, Index, &Ring); @@ -2816,7 +2816,6 @@ fail3: fail2: Error("fail2\n"); - (*Receiver)->MaxQueues = 0; (*Receiver)->Frontend = NULL; RtlZeroMemory(&(*Receiver)->EvtchnInterface, @@ -2885,13 +2884,8 @@ ReceiverConnect( if (!NT_SUCCESS(status)) goto fail5; - Receiver->Split = FrontendIsSplit(Frontend); - - Receiver->NumQueues = FrontendGetNumQueues(Frontend); - ASSERT3U(Receiver->NumQueues, <=, Receiver->MaxQueues); - Index = 0; - while (Index < Receiver->NumQueues) { + while (Index < (LONG)FrontendGetNumQueues(Frontend)) { PXENVIF_RECEIVER_RING Ring = Receiver->Ring[Index]; status = __ReceiverRingConnect(Ring); @@ -2916,7 +2910,7 @@ ReceiverConnect( fail7: Error("fail7\n"); - Index = Receiver->NumQueues; + Index = FrontendGetNumQueues(Frontend); fail6: Error("fail6\n"); @@ -2927,8 +2921,6 @@ fail6: __ReceiverRingDisconnect(Ring); } - Receiver->NumQueues = 0; - XENBUS_GNTTAB(Release, &Receiver->GnttabInterface); fail5: @@ -3092,7 +3084,7 @@ ReceiverStoreWrite( goto fail5; Index = 0; - while (Index < Receiver->NumQueues) { + while (Index < (LONG)FrontendGetNumQueues(Frontend)) { PXENVIF_RECEIVER_RING Ring = Receiver->Ring[Index]; status = __ReceiverRingStoreWrite(Ring, Transaction); @@ -3130,13 +3122,16 @@ ReceiverEnable( IN PXENVIF_RECEIVER Receiver ) { + PXENVIF_FRONTEND Frontend; LONG Index; NTSTATUS status; Trace("====>\n"); + Frontend = Receiver->Frontend; + Index = 0; - while (Index < Receiver->NumQueues) { + while (Index < (LONG)FrontendGetNumQueues(Frontend)) { PXENVIF_RECEIVER_RING Ring = Receiver->Ring[Index]; status = __ReceiverRingEnable(Ring); @@ -3170,11 +3165,14 @@ ReceiverDisable( IN PXENVIF_RECEIVER Receiver ) { + PXENVIF_FRONTEND Frontend; LONG Index; Trace("====>\n"); - Index = Receiver->NumQueues; + Frontend = Receiver->Frontend; + + Index = FrontendGetNumQueues(Frontend); while (--Index >= 0) { PXENVIF_RECEIVER_RING Ring = Receiver->Ring[Index]; @@ -3201,16 +3199,13 @@ ReceiverDisconnect( Receiver->DebugCallback); Receiver->DebugCallback = NULL; - Index = Receiver->NumQueues; + Index = FrontendGetNumQueues(Frontend); while (--Index >= 0) { PXENVIF_RECEIVER_RING Ring = Receiver->Ring[Index]; __ReceiverRingDisconnect(Ring); } - Receiver->NumQueues = 0; - Receiver->Split = FALSE; - XENBUS_GNTTAB(Release, &Receiver->GnttabInterface); XENBUS_CACHE(Release, &Receiver->CacheInterface); @@ -3229,8 +3224,11 @@ ReceiverTeardown( IN PXENVIF_RECEIVER Receiver ) { + PXENVIF_FRONTEND Frontend; LONG Index; + Frontend = Receiver->Frontend; + ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); KeFlushQueuedDpcs(); @@ -3238,7 +3236,7 @@ ReceiverTeardown( Receiver->Loaned = 0; Receiver->Returned = 0; - Index = Receiver->MaxQueues; + Index = FrontendGetMaxQueues(Frontend); while (--Index >= 0) { PXENVIF_RECEIVER_RING Ring = Receiver->Ring[Index]; @@ -3248,7 +3246,6 @@ ReceiverTeardown( __ReceiverFree(Receiver->Ring); Receiver->Ring = NULL; - Receiver->MaxQueues = 0; Receiver->Frontend = NULL; @@ -3286,15 +3283,20 @@ ReceiverSetOffloadOptions( IN XENVIF_VIF_OFFLOAD_OPTIONS Options ) { + PXENVIF_FRONTEND Frontend; LONG Index; + Frontend = Receiver->Frontend; + if (Receiver->AllowGsoPackets == 0) { Warning("RECEIVER GSO DISALLOWED\n"); Options.OffloadIpVersion4LargePacket = 0; Options.OffloadIpVersion6LargePacket = 0; } - for (Index = 0; Index < Receiver->MaxQueues; ++Index) { + for (Index = 0; + Index < (LONG)FrontendGetMaxQueues(Frontend); + ++Index) { PXENVIF_RECEIVER_RING Ring; Ring = Receiver->Ring[Index]; @@ -3311,11 +3313,16 @@ ReceiverSetBackfillSize( IN ULONG Size ) { - LONG Index; + PXENVIF_FRONTEND Frontend; + LONG Index; + + Frontend = Receiver->Frontend; ASSERT3U(Size, <, PAGE_SIZE); - for (Index = 0; Index < Receiver->MaxQueues; ++Index) { + for (Index = 0; + Index < (LONG)FrontendGetMaxQueues(Frontend); + ++Index) { PXENVIF_RECEIVER_RING Ring; Ring = Receiver->Ring[Index]; @@ -3419,7 +3426,6 @@ ReceiverSend( { PXENVIF_RECEIVER_RING Ring; - ASSERT3U(Index, <, (ULONG)Receiver->NumQueues); Ring = Receiver->Ring[Index]; __ReceiverRingSend(Ring, FALSE); diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c index 615d2d0..35ec80a 100644 --- a/src/xenvif/transmitter.c +++ b/src/xenvif/transmitter.c @@ -199,9 +199,6 @@ struct _XENVIF_TRANSMITTER { XENBUS_RANGE_SET_INTERFACE RangeSetInterface; XENBUS_EVTCHN_INTERFACE EvtchnInterface; PXENVIF_TRANSMITTER_RING *Ring; - LONG MaxQueues; - LONG NumQueues; - BOOLEAN Split; BOOLEAN MulticastControl; ULONG DisableIpVersion4Gso; ULONG DisableIpVersion6Gso; @@ -645,10 +642,12 @@ TransmitterRingDebugCallback( { PXENVIF_TRANSMITTER_RING Ring = Argument; PXENVIF_TRANSMITTER Transmitter; + PXENVIF_FRONTEND Frontend; UNREFERENCED_PARAMETER(Crashing); Transmitter = Ring->Transmitter; + Frontend = Transmitter->Frontend; XENBUS_DEBUG(Printf, &Transmitter->DebugInterface, @@ -711,7 +710,7 @@ TransmitterRingDebugCallback( Ring->PacketsSent, Ring->PacketsCompleted); - if (Transmitter->Split) { + if (FrontendIsSplit(Frontend)) { // Dump event channel XENBUS_DEBUG(Printf, &Transmitter->DebugInterface, @@ -2498,13 +2497,15 @@ __TransmitterRingSend( ) { PXENVIF_TRANSMITTER Transmitter; + PXENVIF_FRONTEND Frontend; Transmitter = Ring->Transmitter; + Frontend = Transmitter->Frontend; if (!Ring->Connected) return; - if (Transmitter->Split) { + if (FrontendIsSplit(Frontend)) { ASSERT(Ring->Channel != NULL); (VOID) XENBUS_EVTCHN(Send, @@ -2918,7 +2919,6 @@ TransmitterRingDpc( ASSERT(Ring != NULL); Transmitter = Ring->Transmitter; - ASSERT(Transmitter->Split); if (Ring->Enabled) __TransmitterRingNotify(Ring); @@ -2942,7 +2942,6 @@ TransmitterRingEvtchnCallback( ASSERT(Ring != NULL); Transmitter = Ring->Transmitter; - ASSERT(Transmitter->Split); Ring->Events++; @@ -3289,7 +3288,7 @@ __TransmitterRingConnect( ASSERT3U(KeGetCurrentIrql(), ==, DISPATCH_LEVEL); - if (Transmitter->Split) { + if (FrontendIsSplit(Frontend)) { Ring->Channel = XENBUS_EVTCHN(Open, &Transmitter->EvtchnInterface, XENBUS_EVTCHN_TYPE_UNBOUND, @@ -3461,7 +3460,7 @@ __TransmitterRingStoreWrite( Transmitter = Ring->Transmitter; Frontend = Transmitter->Frontend; - Path = (Transmitter->NumQueues == 1) ? + Path = (FrontendGetNumQueues(Frontend) == 1) ? FrontendGetPath(Frontend) : Ring->Path; @@ -3477,7 +3476,7 @@ __TransmitterRingStoreWrite( if (!NT_SUCCESS(status)) goto fail1; - if (!Transmitter->Split) + if (!FrontendIsSplit(Frontend)) goto done; Port = XENBUS_EVTCHN(GetPort, @@ -3512,15 +3511,17 @@ __TransmitterRingEnable( ) { PXENVIF_TRANSMITTER Transmitter; + PXENVIF_FRONTEND Frontend; Transmitter = Ring->Transmitter; + Frontend = Transmitter->Frontend; __TransmitterRingAcquireLock(Ring); ASSERT(!Ring->Enabled); Ring->Enabled = TRUE; - if (Transmitter->Split && + if (FrontendIsSplit(Frontend) && KeInsertQueueDpc(&Ring->Dpc, NULL, NULL)) Ring->Dpcs++; @@ -3995,6 +3996,7 @@ TransmitterInitialize( ) { HANDLE ParametersKey; + LONG MaxQueues; LONG Index; NTSTATUS status; @@ -4055,16 +4057,16 @@ TransmitterInitialize( (*Transmitter)->Frontend = Frontend; KeInitializeSpinLock(&(*Transmitter)->Lock); - (*Transmitter)->MaxQueues = FrontendGetMaxQueues(Frontend); + MaxQueues = FrontendGetMaxQueues(Frontend); (*Transmitter)->Ring = __TransmitterAllocate(sizeof (PXENVIF_TRANSMITTER_RING) * - (*Transmitter)->MaxQueues); + MaxQueues); status = STATUS_NO_MEMORY; if ((*Transmitter)->Ring == NULL) goto fail2; Index = 0; - while (Index < (*Transmitter)->MaxQueues) { + while (Index < MaxQueues) { PXENVIF_TRANSMITTER_RING Ring; status = __TransmitterRingInitialize(*Transmitter, Index, &Ring); @@ -4093,8 +4095,6 @@ fail3: fail2: Error("fail2\n"); - (*Transmitter)->MaxQueues = 0; - (*Transmitter)->Frontend = NULL; RtlZeroMemory(&(*Transmitter)->Lock, @@ -4208,13 +4208,8 @@ TransmitterConnect( Buffer); } - Transmitter->Split = FrontendIsSplit(Frontend); - - Transmitter->NumQueues = FrontendGetNumQueues(Frontend); - ASSERT3U(Transmitter->NumQueues, <=, Transmitter->MaxQueues); - Index = 0; - while (Index < Transmitter->NumQueues) { + while (Index < (LONG)FrontendGetNumQueues(Frontend)) { PXENVIF_TRANSMITTER_RING Ring = Transmitter->Ring[Index]; status = __TransmitterRingConnect(Ring); @@ -4239,7 +4234,7 @@ TransmitterConnect( fail10: Error("fail10\n"); - Index = Transmitter->NumQueues; + Index = FrontendGetNumQueues(Frontend); fail9: Error("fail9\n"); @@ -4252,8 +4247,6 @@ fail9: __TransmitterRingDisconnect(Ring); } - Transmitter->NumQueues = 0; - Transmitter->Split = FALSE; Transmitter->MulticastControl = FALSE; XENBUS_CACHE(Destroy, @@ -4323,7 +4316,7 @@ TransmitterStoreWrite( goto fail1; Index = 0; - while (Index < Transmitter->NumQueues) { + while (Index < (LONG)FrontendGetNumQueues(Frontend)) { PXENVIF_TRANSMITTER_RING Ring = Transmitter->Ring[Index]; status = __TransmitterRingStoreWrite(Ring, Transaction); @@ -4349,12 +4342,15 @@ TransmitterEnable( IN PXENVIF_TRANSMITTER Transmitter ) { + PXENVIF_FRONTEND Frontend; LONG Index; Trace("====>\n"); + Frontend = Transmitter->Frontend; + Index = 0; - while (Index < Transmitter->NumQueues) { + while (Index < (LONG)FrontendGetNumQueues(Frontend)) { PXENVIF_TRANSMITTER_RING Ring = Transmitter->Ring[Index]; __TransmitterRingEnable(Ring); @@ -4370,11 +4366,14 @@ TransmitterDisable( IN PXENVIF_TRANSMITTER Transmitter ) { + PXENVIF_FRONTEND Frontend; LONG Index; Trace("====>\n"); - Index = Transmitter->NumQueues; + Frontend = Transmitter->Frontend; + + Index = FrontendGetNumQueues(Frontend); while (--Index >= 0) { PXENVIF_TRANSMITTER_RING Ring = Transmitter->Ring[Index]; @@ -4401,16 +4400,14 @@ TransmitterDisconnect( Transmitter->DebugCallback); Transmitter->DebugCallback = NULL; - Index = Transmitter->NumQueues; + Index = FrontendGetNumQueues(Frontend); while (--Index >= 0) { PXENVIF_TRANSMITTER_RING Ring = Transmitter->Ring[Index]; __TransmitterRingDisconnect(Ring); } - Transmitter->NumQueues = 0; Transmitter->MulticastControl = FALSE; - Transmitter->Split = FALSE; XENBUS_CACHE(Destroy, &Transmitter->CacheInterface, @@ -4437,12 +4434,15 @@ TransmitterTeardown( IN PXENVIF_TRANSMITTER Transmitter ) { + PXENVIF_FRONTEND Frontend; LONG Index; + Frontend = Transmitter->Frontend; + ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL); KeFlushQueuedDpcs(); - Index = Transmitter->MaxQueues; + Index = FrontendGetMaxQueues(Frontend); while (--Index >= 0) { PXENVIF_TRANSMITTER_RING Ring = Transmitter->Ring[Index]; @@ -4452,7 +4452,6 @@ TransmitterTeardown( __TransmitterFree(Transmitter->Ring); Transmitter->Ring = NULL; - Transmitter->MaxQueues = 0; Transmitter->Frontend = NULL; @@ -4583,10 +4582,12 @@ TransmitterQueuePackets( { PXENVIF_TRANSMITTER_RING Ring; PXENVIF_FRONTEND Frontend; + LONG NumQueues; Frontend = Transmitter->Frontend; + NumQueues = FrontendGetNumQueues(Frontend); - if (Transmitter->NumQueues == 1) { + if (NumQueues == 1) { Ring = Transmitter->Ring[0]; __TransmitterRingQueuePackets(Ring, List); @@ -4610,7 +4611,7 @@ TransmitterQueuePackets( Packet = CONTAINING_RECORD(ListEntry, XENVIF_TRANSMITTER_PACKET, ListEntry); - Hash = Packet->Value % Transmitter->NumQueues; + Hash = Packet->Value % NumQueues; if (Hash != Index) { if (!IsListEmpty(&HashList)) { Ring = Transmitter->Ring[Index]; @@ -4644,12 +4645,15 @@ TransmitterAbortPackets( IN PXENVIF_TRANSMITTER Transmitter ) { + PXENVIF_FRONTEND Frontend; KIRQL Irql; LONG Index; + Frontend = Transmitter->Frontend; + KeRaiseIrql(DISPATCH_LEVEL, &Irql); - Index = Transmitter->NumQueues; + Index = FrontendGetNumQueues(Frontend); while (--Index >= 0) { PXENVIF_TRANSMITTER_RING Ring = Transmitter->Ring[Index]; @@ -4712,7 +4716,6 @@ TransmitterNotify( { PXENVIF_TRANSMITTER_RING Ring; - ASSERT3U(Index, <, (ULONG)Transmitter->NumQueues); Ring = Transmitter->Ring[Index]; __TransmitterRingNotify(Ring); -- 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 |