[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [RFC PATCH 2/6] Rename XENVBD_RING -> XENVBD_PROTOCOL
Signed-off-by: owensm <owen.smith@xxxxxxxxxx> --- src/xenvbd/frontend.c | 30 +- src/xenvbd/frontend.h | 4 +- src/xenvbd/{ring.c => protocol.c} | 988 +++++++++++++++++++------------------- src/xenvbd/{ring.h => protocol.h} | 54 +-- src/xenvbd/target.c | 24 +- vs2015/xenvbd/xenvbd.vcxproj | 2 +- vs2017/xenvbd/xenvbd.vcxproj | 2 +- 7 files changed, 556 insertions(+), 548 deletions(-) rename src/xenvbd/{ring.c => protocol.c} (64%) rename src/xenvbd/{ring.h => protocol.h} (67%) diff --git a/src/xenvbd/frontend.c b/src/xenvbd/frontend.c index b7e61c2..f8e903e 100644 --- a/src/xenvbd/frontend.c +++ b/src/xenvbd/frontend.c @@ -43,7 +43,7 @@ #include "adapter.h" #include "srbext.h" #include "names.h" -#include "ring.h" +#include "protocol.h" #include "granter.h" #include "thread.h" #include "base64.h" @@ -84,7 +84,7 @@ struct _XENVBD_FRONTEND { PXENBUS_SUSPEND_CALLBACK SuspendCallback; // Ring - PXENVBD_RING Ring; + PXENVBD_PROTOCOL Protocol; PXENVBD_GRANTER Granter; // Backend State Watch @@ -1095,7 +1095,7 @@ FrontendConnect( if (!NT_SUCCESS(Status)) goto fail1; - Status = RingConnect(Frontend->Ring); + Status = ProtocolConnect(Frontend->Protocol); if (!NT_SUCCESS(Status)) goto fail2; @@ -1109,7 +1109,7 @@ FrontendConnect( if (!NT_SUCCESS(Status)) break; - Status = RingStoreWrite(Frontend->Ring, Transaction); + Status = ProtocolStoreWrite(Frontend->Protocol, Transaction); if (!NT_SUCCESS(Status)) goto abort; @@ -1211,7 +1211,7 @@ fail4: Error("Fail4\n"); fail3: Error("Fail3\n"); - RingDisconnect(Frontend->Ring); + ProtocolDisconnect(Frontend->Protocol); fail2: Error("Fail2\n"); GranterDisconnect(Frontend->Granter); @@ -1225,7 +1225,7 @@ FrontendDisconnect( __in PXENVBD_FRONTEND Frontend ) { - RingDisconnect(Frontend->Ring); + ProtocolDisconnect(Frontend->Protocol); GranterDisconnect(Frontend->Granter); Base64Free(Frontend->Page80.Data); @@ -1246,7 +1246,7 @@ FrontendEnable( KeMemoryBarrier(); GranterEnable(Frontend->Granter); - RingEnable(Frontend->Ring); + ProtocolEnable(Frontend->Protocol); } __drv_requiresIRQL(DISPATCH_LEVEL) static FORCEINLINE VOID @@ -1256,7 +1256,7 @@ FrontendDisable( { Frontend->Caps.Connected = FALSE; - RingDisable(Frontend->Ring); + ProtocolDisable(Frontend->Protocol); GranterDisable(Frontend->Granter); } @@ -1451,7 +1451,7 @@ FrontendSuspendCallback( ASSERT(FALSE); } - RingTrigger(Frontend->Ring); + ProtocolTrigger(Frontend->Protocol); Verbose("Target[%d] : <=== restored %s\n", Frontend->TargetId, __XenvbdStateName(Frontend->State)); } @@ -1767,7 +1767,7 @@ FrontendCreate( if (!NT_SUCCESS(status)) goto fail3; - status = RingCreate(Frontend, &Frontend->Ring); + status = ProtocolCreate(Frontend, &Frontend->Protocol); if (!NT_SUCCESS(status)) goto fail4; @@ -1792,8 +1792,8 @@ fail6: Frontend->Granter = NULL; fail5: Error("fail5\n"); - RingDestroy(Frontend->Ring); - Frontend->Ring = NULL; + ProtocolDestroy(Frontend->Protocol); + Frontend->Protocol = NULL; fail4: Error("fail4\n"); fail3: @@ -1831,8 +1831,8 @@ FrontendDestroy( GranterDestroy(Frontend->Granter); Frontend->Granter = NULL; - RingDestroy(Frontend->Ring); - Frontend->Ring = NULL; + ProtocolDestroy(Frontend->Protocol); + Frontend->Protocol = NULL; ASSERT3P(Frontend->BackendPath, ==, NULL); ASSERT3P(Frontend->BackendWatch, ==, NULL); @@ -1858,7 +1858,7 @@ FrontendGet ## _name ## ( \ } FRONTEND_GET_PROPERTY(Target, PXENVBD_TARGET) -FRONTEND_GET_PROPERTY(Ring, PXENVBD_RING) +FRONTEND_GET_PROPERTY(Protocol, PXENVBD_PROTOCOL) FRONTEND_GET_PROPERTY(Granter, PXENVBD_GRANTER) FRONTEND_GET_PROPERTY(TargetId, ULONG) FRONTEND_GET_PROPERTY(DeviceId, ULONG) diff --git a/src/xenvbd/frontend.h b/src/xenvbd/frontend.h index 1488476..dfd72b4 100644 --- a/src/xenvbd/frontend.h +++ b/src/xenvbd/frontend.h @@ -150,8 +150,8 @@ FrontendGet ## _name ## ( \ ); FRONTEND_GET_PROPERTY(Target, PXENVBD_TARGET) -#include "ring.h" -FRONTEND_GET_PROPERTY(Ring, PXENVBD_RING) +#include "protocol.h" +FRONTEND_GET_PROPERTY(Protocol, PXENVBD_PROTOCOL) #include "granter.h" FRONTEND_GET_PROPERTY(Granter, PXENVBD_GRANTER) FRONTEND_GET_PROPERTY(TargetId, ULONG) diff --git a/src/xenvbd/ring.c b/src/xenvbd/protocol.c similarity index 64% rename from src/xenvbd/ring.c rename to src/xenvbd/protocol.c index 33b346d..39767eb 100644 --- a/src/xenvbd/ring.c +++ b/src/xenvbd/protocol.c @@ -40,7 +40,7 @@ #include <evtchn_interface.h> #include <debug_interface.h> -#include "ring.h" +#include "protocol.h" #include "frontend.h" #include "target.h" #include "adapter.h" @@ -53,10 +53,10 @@ #include "debug.h" #include "assert.h" -#define XENVBD_MAX_RING_PAGE_ORDER (4) -#define XENVBD_MAX_RING_PAGES (1 << XENVBD_MAX_RING_PAGE_ORDER) +#define XENVBD_MAX_PROTOCOL_PAGE_ORDER (4) +#define XENVBD_MAX_PROTOCOL_PAGES (1 << XENVBD_MAX_PROTOCOL_PAGE_ORDER) -struct _XENVBD_RING { +struct _XENVBD_PROTOCOL { PXENVBD_FRONTEND Frontend; BOOLEAN Connected; BOOLEAN Enabled; @@ -73,7 +73,7 @@ struct _XENVBD_RING { blkif_sring_t* Shared; blkif_front_ring_t Front; ULONG Order; - PVOID Grants[XENVBD_MAX_RING_PAGES]; + PVOID Grants[XENVBD_MAX_PROTOCOL_PAGES]; PXENBUS_EVTCHN_CHANNEL Channel; KDPC Dpc; @@ -100,27 +100,27 @@ struct _XENVBD_RING { }; #define MAX_NAME_LEN 64 -#define RING_POOL_TAG 'gnRX' +#define PROTOCOL_POOL_TAG 'gnRX' #define XEN_IO_PROTO_ABI "x86_64-abi" static FORCEINLINE PVOID -__RingAllocate( +__ProtocolAllocate( IN ULONG Length ) { return __AllocatePoolWithTag(NonPagedPool, Length, - RING_POOL_TAG); + PROTOCOL_POOL_TAG); } static FORCEINLINE VOID -__RingFree( +__ProtocolFree( IN PVOID Buffer ) { if (Buffer) __FreePoolWithTag(Buffer, - RING_POOL_TAG); + PROTOCOL_POOL_TAG); } static FORCEINLINE VOID @@ -138,13 +138,13 @@ xen_wmb() } static FORCEINLINE VOID -__RingInsert( - IN PXENVBD_RING Ring, +__ProtocolInsert( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_REQUEST Request, IN blkif_request_t* req ) { - PXENVBD_GRANTER Granter = FrontendGetGranter(Ring->Frontend); + PXENVBD_GRANTER Granter = FrontendGetGranter(Protocol->Frontend); switch (Request->Operation) { case BLKIF_OP_READ: @@ -163,7 +163,7 @@ __RingInsert( req_indirect->nr_segments = Request->NrSegments; req_indirect->id = (ULONG64)(ULONG_PTR)Request; req_indirect->sector_number = Request->FirstSector; - req_indirect->handle = (USHORT)FrontendGetDeviceId(Ring->Frontend); + req_indirect->handle = (USHORT)FrontendGetDeviceId(Protocol->Frontend); for (PageIdx = 0, PageEntry = Request->Indirects.Flink, @@ -194,7 +194,7 @@ __RingInsert( req->operation = Request->Operation; req->nr_segments = (UCHAR)Request->NrSegments; - req->handle = (USHORT)FrontendGetDeviceId(Ring->Frontend); + req->handle = (USHORT)FrontendGetDeviceId(Protocol->Frontend); req->id = (ULONG64)(ULONG_PTR)Request; req->sector_number = Request->FirstSector; @@ -214,7 +214,7 @@ __RingInsert( case BLKIF_OP_FLUSH_DISKCACHE: req->operation = Request->Operation; req->nr_segments = 0; - req->handle = (USHORT)FrontendGetDeviceId(Ring->Frontend); + req->handle = (USHORT)FrontendGetDeviceId(Protocol->Frontend); req->id = (ULONG64)(ULONG_PTR)Request; req->sector_number = Request->FirstSector; break; @@ -224,7 +224,7 @@ __RingInsert( req_discard = (blkif_request_discard_t*)req; req_discard->operation = BLKIF_OP_DISCARD; req_discard->flag = Request->Flags; - req_discard->handle = (USHORT)FrontendGetDeviceId(Ring->Frontend); + req_discard->handle = (USHORT)FrontendGetDeviceId(Protocol->Frontend); req_discard->id = (ULONG64)(ULONG_PTR)Request; req_discard->sector_number = Request->FirstSector; req_discard->nr_sectors = Request->NrSectors; @@ -234,21 +234,21 @@ __RingInsert( ASSERT(FALSE); break; } - ++Ring->Submitted; + ++Protocol->Submitted; } static PXENVBD_INDIRECT -RingGetIndirect( - IN PXENVBD_RING Ring +ProtocolGetIndirect( + IN PXENVBD_PROTOCOL Protocol ) { PXENVBD_INDIRECT Indirect; NTSTATUS status; - PXENVBD_GRANTER Granter = FrontendGetGranter(Ring->Frontend); + PXENVBD_GRANTER Granter = FrontendGetGranter(Protocol->Frontend); Indirect = XENBUS_CACHE(Get, - &Ring->CacheInterface, - Ring->IndirectCache, + &Protocol->CacheInterface, + Protocol->IndirectCache, FALSE); if (Indirect == NULL) goto fail1; @@ -266,8 +266,8 @@ RingGetIndirect( fail2: XENBUS_CACHE(Put, - &Ring->CacheInterface, - Ring->IndirectCache, + &Protocol->CacheInterface, + Protocol->IndirectCache, Indirect, FALSE); fail1: @@ -275,12 +275,12 @@ fail1: } static VOID -RingPutIndirect( - IN PXENVBD_RING Ring, +ProtocolPutIndirect( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_INDIRECT Indirect ) { - PXENVBD_GRANTER Granter = FrontendGetGranter(Ring->Frontend); + PXENVBD_GRANTER Granter = FrontendGetGranter(Protocol->Frontend); if (Indirect->Grant) GranterPut(Granter, Indirect->Grant); @@ -289,30 +289,30 @@ RingPutIndirect( RtlZeroMemory(&Indirect->ListEntry, sizeof(LIST_ENTRY)); XENBUS_CACHE(Put, - &Ring->CacheInterface, - Ring->IndirectCache, + &Protocol->CacheInterface, + Protocol->IndirectCache, Indirect, FALSE); } static PXENVBD_SEGMENT -RingGetSegment( - IN PXENVBD_RING Ring +ProtocolGetSegment( + IN PXENVBD_PROTOCOL Protocol ) { return XENBUS_CACHE(Get, - &Ring->CacheInterface, - Ring->SegmentCache, + &Protocol->CacheInterface, + Protocol->SegmentCache, FALSE); } static VOID -RingPutSegment( - IN PXENVBD_RING Ring, +ProtocolPutSegment( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_SEGMENT Segment ) { - PXENVBD_GRANTER Granter = FrontendGetGranter(Ring->Frontend); + PXENVBD_GRANTER Granter = FrontendGetGranter(Protocol->Frontend); PXENVBD_BOUNCE Bounce = Segment->Bounce; if (Segment->Grant) @@ -329,7 +329,7 @@ RingPutSegment( Bounce->SourcePfn[0] = 0; Bounce->SourcePfn[1] = 0; - AdapterPutBounce(TargetGetAdapter(FrontendGetTarget(Ring->Frontend)), + AdapterPutBounce(TargetGetAdapter(FrontendGetTarget(Protocol->Frontend)), Bounce); } Segment->Bounce = NULL; @@ -339,26 +339,26 @@ RingPutSegment( RtlZeroMemory(&Segment->ListEntry, sizeof(LIST_ENTRY)); XENBUS_CACHE(Put, - &Ring->CacheInterface, - Ring->SegmentCache, + &Protocol->CacheInterface, + Protocol->SegmentCache, Segment, FALSE); } static PXENVBD_REQUEST -RingGetRequest( - IN PXENVBD_RING Ring +ProtocolGetRequest( + IN PXENVBD_PROTOCOL Protocol ) { return XENBUS_CACHE(Get, - &Ring->CacheInterface, - Ring->RequestCache, + &Protocol->CacheInterface, + Protocol->RequestCache, FALSE); } static VOID -RingPutRequest( - IN PXENVBD_RING Ring, +ProtocolPutRequest( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_REQUEST Request ) { @@ -371,7 +371,7 @@ RingPutRequest( if (ListEntry == &Request->Segments) break; Segment = CONTAINING_RECORD(ListEntry, XENVBD_SEGMENT, ListEntry); - RingPutSegment(Ring, Segment); + ProtocolPutSegment(Protocol, Segment); } for (;;) { @@ -381,7 +381,7 @@ RingPutRequest( if (ListEntry == &Request->Indirects) break; Indirect = CONTAINING_RECORD(ListEntry, XENVBD_INDIRECT, ListEntry); - RingPutIndirect(Ring, Indirect); + ProtocolPutIndirect(Protocol, Indirect); } Request->SrbExt = NULL; @@ -393,22 +393,22 @@ RingPutRequest( RtlZeroMemory(&Request->ListEntry, sizeof(LIST_ENTRY)); XENBUS_CACHE(Put, - &Ring->CacheInterface, - Ring->RequestCache, + &Protocol->CacheInterface, + Protocol->RequestCache, Request, FALSE); } static FORCEINLINE PXENVBD_REQUEST -RingFindRequest( - IN PXENVBD_RING Ring, +ProtocolFindRequest( + IN PXENVBD_PROTOCOL Protocol, IN ULONG64 Id ) { KIRQL Irql; PLIST_ENTRY ListEntry; PXENVBD_REQUEST Request; - PXENVBD_QUEUE Queue = &Ring->SubmittedReqs; + PXENVBD_QUEUE Queue = &Protocol->SubmittedReqs; KeAcquireSpinLock(&Queue->Lock, &Irql); @@ -426,39 +426,39 @@ RingFindRequest( KeReleaseSpinLock(&Queue->Lock, Irql); Warning("Target[%d] : Tag %llx not found in submitted list (%u items)\n", - FrontendGetTargetId(Ring->Frontend), + FrontendGetTargetId(Protocol->Frontend), Id, QueueCount(Queue)); return NULL; } static FORCEINLINE VOID -__RingIncBlkifOpCount( - IN PXENVBD_RING Ring, +__ProtocolIncBlkifOpCount( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_REQUEST Request ) { switch (Request->Operation) { case BLKIF_OP_READ: if (Request->NrSegments > BLKIF_MAX_SEGMENTS_PER_REQUEST) - ++Ring->BlkOpIndirectRead; + ++Protocol->BlkOpIndirectRead; else - ++Ring->BlkOpRead; + ++Protocol->BlkOpRead; break; case BLKIF_OP_WRITE: if (Request->NrSegments > BLKIF_MAX_SEGMENTS_PER_REQUEST) - ++Ring->BlkOpIndirectWrite; + ++Protocol->BlkOpIndirectWrite; else - ++Ring->BlkOpWrite; + ++Protocol->BlkOpWrite; break; case BLKIF_OP_WRITE_BARRIER: - ++Ring->BlkOpBarrier; + ++Protocol->BlkOpBarrier; break; case BLKIF_OP_DISCARD: - ++Ring->BlkOpDiscard; + ++Protocol->BlkOpDiscard; break; case BLKIF_OP_FLUSH_DISKCACHE: - ++Ring->BlkOpFlush; + ++Protocol->BlkOpFlush; break; default: ASSERT(FALSE); @@ -467,7 +467,7 @@ __RingIncBlkifOpCount( } static FORCEINLINE ULONG -__RingSectorsPerPage( +__ProtocolSectorsPerPage( IN ULONG SectorSize ) { @@ -476,19 +476,19 @@ __RingSectorsPerPage( } static FORCEINLINE VOID -__RingOperation( +__ProtocolOperation( IN UCHAR CdbOp, - OUT PUCHAR RingOp, + OUT PUCHAR ProtocolOp, OUT PBOOLEAN ReadOnly ) { switch (CdbOp) { case SCSIOP_READ: - *RingOp = BLKIF_OP_READ; + *ProtocolOp = BLKIF_OP_READ; *ReadOnly = FALSE; break; case SCSIOP_WRITE: - *RingOp = BLKIF_OP_WRITE; + *ProtocolOp = BLKIF_OP_WRITE; *ReadOnly = TRUE; break; default: @@ -497,11 +497,11 @@ __RingOperation( } static FORCEINLINE MM_PAGE_PRIORITY -__RingPriority( - IN PXENVBD_RING Ring +__ProtocolPriority( + IN PXENVBD_PROTOCOL Protocol ) { - PXENVBD_CAPS Caps = FrontendGetCaps(Ring->Frontend); + PXENVBD_CAPS Caps = FrontendGetCaps(Protocol->Frontend); if (!(Caps->Paging || Caps->Hibernation || Caps->DumpFile)) @@ -511,7 +511,7 @@ __RingPriority( } static FORCEINLINE VOID -RingRequestCopyOutput( +ProtocolRequestCopyOutput( IN PXENVBD_REQUEST Request ) { @@ -535,8 +535,8 @@ RingRequestCopyOutput( } static BOOLEAN -RingPrepareSegment( - IN PXENVBD_RING Ring, +ProtocolPrepareSegment( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_SEGMENT Segment, IN PXENVBD_SRBEXT SrbExt, IN BOOLEAN ReadOnly, @@ -548,10 +548,10 @@ RingPrepareSegment( ULONG Offset; ULONG Length; NTSTATUS Status; - PXENVBD_GRANTER Granter = FrontendGetGranter(Ring->Frontend); - const ULONG SectorSize = FrontendGetDiskInfo(Ring->Frontend)->SectorSize; - const ULONG SectorsPerPage = __RingSectorsPerPage(SectorSize); - PXENVBD_TARGET Target = FrontendGetTarget(Ring->Frontend); + PXENVBD_GRANTER Granter = FrontendGetGranter(Protocol->Frontend); + const ULONG SectorSize = FrontendGetDiskInfo(Protocol->Frontend)->SectorSize; + const ULONG SectorsPerPage = __ProtocolSectorsPerPage(SectorSize); + PXENVBD_TARGET Target = FrontendGetTarget(Protocol->Frontend); PXENVBD_ADAPTER Adapter = TargetGetAdapter(Target); Pfn = AdapterGetNextSGEntry(Adapter, @@ -561,7 +561,7 @@ RingPrepareSegment( &Length); if ((Offset & (SectorSize - 1)) == 0 && (Length & (SectorSize - 1)) == 0) { - ++Ring->SegsGranted; + ++Protocol->SegsGranted; // get first sector, last sector and count Segment->FirstSector = (UCHAR)((Offset + SectorSize - 1) / SectorSize); *SectorsNow = __min(SectorsLeft, SectorsPerPage - Segment->FirstSector); @@ -572,7 +572,7 @@ RingPrepareSegment( PXENVBD_BOUNCE Bounce; PMDL Mdl; - ++Ring->SegsBounced; + ++Protocol->SegsBounced; // get first sector, last sector and count Segment->FirstSector = 0; *SectorsNow = __min(SectorsLeft, SectorsPerPage); @@ -617,7 +617,7 @@ RingPrepareSegment( MmCached, NULL, FALSE, - __RingPriority(Ring)); + __ProtocolPriority(Protocol)); if (Bounce->SourcePtr == NULL) goto fail2; @@ -648,8 +648,8 @@ fail1: } static BOOLEAN -RingPrepareBlkifReadWrite( - IN PXENVBD_RING Ring, +ProtocolPrepareBlkifReadWrite( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_REQUEST Request, IN PXENVBD_SRBEXT SrbExt, IN ULONG MaxSegments, @@ -662,7 +662,7 @@ RingPrepareBlkifReadWrite( UCHAR Operation; BOOLEAN ReadOnly; ULONG Index; - __RingOperation(Cdb_OperationEx(Srb), &Operation, &ReadOnly); + __ProtocolOperation(Cdb_OperationEx(Srb), &Operation, &ReadOnly); Request->Operation = Operation; Request->NrSegments = 0; @@ -675,14 +675,14 @@ RingPrepareBlkifReadWrite( PXENVBD_SEGMENT Segment; ULONG SectorsNow; - Segment = RingGetSegment(Ring); + Segment = ProtocolGetSegment(Protocol); if (Segment == NULL) goto fail1; InsertTailList(&Request->Segments, &Segment->ListEntry); ++Request->NrSegments; - if (!RingPrepareSegment(Ring, + if (!ProtocolPrepareSegment(Protocol, Segment, SrbExt, ReadOnly, @@ -704,8 +704,8 @@ fail1: } static BOOLEAN -RingPrepareBlkifIndirect( - IN PXENVBD_RING Ring, +ProtocolPrepareBlkifIndirect( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_REQUEST Request ) { @@ -718,7 +718,7 @@ RingPrepareBlkifIndirect( ++Index) { PXENVBD_INDIRECT Indirect; - Indirect = RingGetIndirect(Ring); + Indirect = ProtocolGetIndirect(Protocol); if (Indirect == NULL) goto fail1; InsertTailList(&Request->Indirects, &Indirect->ListEntry); @@ -733,13 +733,13 @@ fail1: } static FORCEINLINE ULONG -RingUseIndirect( - IN PXENVBD_RING Ring, +ProtocolUseIndirect( + IN PXENVBD_PROTOCOL Protocol, IN ULONG SectorsLeft ) { - const ULONG SectorsPerPage = __RingSectorsPerPage(FrontendGetDiskInfo(Ring->Frontend)->SectorSize); - const ULONG MaxIndirectSegs = FrontendGetFeatures(Ring->Frontend)->Indirect; + const ULONG SectorsPerPage = __ProtocolSectorsPerPage(FrontendGetDiskInfo(Protocol->Frontend)->SectorSize); + const ULONG MaxIndirectSegs = FrontendGetFeatures(Protocol->Frontend)->Indirect; if (MaxIndirectSegs <= BLKIF_MAX_SEGMENTS_PER_REQUEST) return BLKIF_MAX_SEGMENTS_PER_REQUEST; // not supported @@ -751,9 +751,9 @@ RingUseIndirect( } static FORCEINLINE VOID -RingQueueRequestList( - IN PXENVBD_RING Ring, - IN PLIST_ENTRY List +ProtocolQueueRequestList( + IN PXENVBD_PROTOCOL Protocol, + IN PLIST_ENTRY List ) { for (;;) { @@ -765,14 +765,14 @@ RingQueueRequestList( break; Request = CONTAINING_RECORD(ListEntry, XENVBD_REQUEST, ListEntry); - __RingIncBlkifOpCount(Ring, Request); - QueueAppend(&Ring->PreparedReqs, &Request->ListEntry); + __ProtocolIncBlkifOpCount(Protocol, Request); + QueueAppend(&Protocol->PreparedReqs, &Request->ListEntry); } } static FORCEINLINE VOID -RingCancelRequestList( - IN PXENVBD_RING Ring, +ProtocolCancelRequestList( + IN PXENVBD_PROTOCOL Protocol, IN PLIST_ENTRY List ) { @@ -785,13 +785,13 @@ RingCancelRequestList( break; Request = CONTAINING_RECORD(ListEntry, XENVBD_REQUEST, ListEntry); - RingPutRequest(Ring, Request); + ProtocolPutRequest(Protocol, Request); } } static BOOLEAN -RingPrepareReadWrite( - IN PXENVBD_RING Ring, +ProtocolPrepareReadWrite( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_SRBEXT SrbExt ) { @@ -810,16 +810,16 @@ RingPrepareReadWrite( ULONG SectorsDone = 0; PXENVBD_REQUEST Request; - Request = RingGetRequest(Ring); + Request = ProtocolGetRequest(Protocol); if (Request == NULL) goto fail1; InsertTailList(&List, &Request->ListEntry); InterlockedIncrement(&SrbExt->RequestCount); Request->SrbExt = SrbExt; - MaxSegments = RingUseIndirect(Ring, SectorsLeft); + MaxSegments = ProtocolUseIndirect(Protocol, SectorsLeft); - if (!RingPrepareBlkifReadWrite(Ring, + if (!ProtocolPrepareBlkifReadWrite(Protocol, Request, SrbExt, MaxSegments, @@ -829,7 +829,7 @@ RingPrepareReadWrite( goto fail2; if (MaxSegments > BLKIF_MAX_SEGMENTS_PER_REQUEST) { - if (!RingPrepareBlkifIndirect(Ring, Request)) + if (!ProtocolPrepareBlkifIndirect(Protocol, Request)) goto fail3; } @@ -837,21 +837,21 @@ RingPrepareReadWrite( SectorStart += SectorsDone; } - RingQueueRequestList(Ring, &List); + ProtocolQueueRequestList(Protocol, &List); return TRUE; fail3: fail2: fail1: - RingCancelRequestList(Ring, &List); + ProtocolCancelRequestList(Protocol, &List); SrbExt->RequestCount = 0; Srb->SrbStatus = SRB_STATUS_ERROR; return FALSE; } static BOOLEAN -RingPrepareSyncCache( - IN PXENVBD_RING Ring, +ProtocolPrepareSyncCache( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_SRBEXT SrbExt ) { @@ -862,7 +862,7 @@ RingPrepareSyncCache( Srb->SrbStatus = SRB_STATUS_PENDING; - if (FrontendGetDiskInfo(Ring->Frontend)->FlushCache) + if (FrontendGetDiskInfo(Protocol->Frontend)->FlushCache) Operation = BLKIF_OP_FLUSH_DISKCACHE; else Operation = BLKIF_OP_WRITE_BARRIER; @@ -870,7 +870,7 @@ RingPrepareSyncCache( InitializeListHead(&List); SrbExt->RequestCount = 0; - Request = RingGetRequest(Ring); + Request = ProtocolGetRequest(Protocol); if (Request == NULL) goto fail1; InsertTailList(&List, &Request->ListEntry); @@ -880,19 +880,19 @@ RingPrepareSyncCache( Request->Operation = Operation; Request->FirstSector = Cdb_LogicalBlock(Srb); - RingQueueRequestList(Ring, &List); + ProtocolQueueRequestList(Protocol, &List); return TRUE; fail1: - RingCancelRequestList(Ring, &List); + ProtocolCancelRequestList(Protocol, &List); SrbExt->RequestCount = 0; Srb->SrbStatus = SRB_STATUS_ERROR; return FALSE; } static BOOLEAN -RingPrepareUnmap( - IN PXENVBD_RING Ring, +ProtocolPrepareUnmap( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_SRBEXT SrbExt ) { @@ -911,7 +911,7 @@ RingPrepareUnmap( PUNMAP_BLOCK_DESCRIPTOR Descr = &Unmap->Descriptors[Index]; PXENVBD_REQUEST Request; - Request = RingGetRequest(Ring); + Request = ProtocolGetRequest(Protocol); if (Request == NULL) goto fail1; InsertTailList(&List, &Request->ListEntry); @@ -924,32 +924,32 @@ RingPrepareUnmap( Request->Flags = 0; } - RingQueueRequestList(Ring, &List); + ProtocolQueueRequestList(Protocol, &List); return TRUE; fail1: - RingCancelRequestList(Ring, &List); + ProtocolCancelRequestList(Protocol, &List); SrbExt->RequestCount = 0; Srb->SrbStatus = SRB_STATUS_ERROR; return FALSE; } static FORCEINLINE BOOLEAN -RingPrepareRequest( - IN PXENVBD_RING Ring, +ProtocolPrepareRequest( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_SRBEXT SrbExt ) { switch (Cdb_OperationEx(SrbExt->Srb)) { case SCSIOP_READ: case SCSIOP_WRITE: - return RingPrepareReadWrite(Ring, SrbExt); + return ProtocolPrepareReadWrite(Protocol, SrbExt); case SCSIOP_SYNCHRONIZE_CACHE: - return RingPrepareSyncCache(Ring, SrbExt); + return ProtocolPrepareSyncCache(Protocol, SrbExt); case SCSIOP_UNMAP: - return RingPrepareUnmap(Ring, SrbExt); + return ProtocolPrepareUnmap(Protocol, SrbExt); default: ASSERT(FALSE); @@ -958,8 +958,8 @@ RingPrepareRequest( } static BOOLEAN -RingSubmit( - IN PXENVBD_RING Ring, +ProtocolSubmit( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_REQUEST Request ) { @@ -967,42 +967,42 @@ RingSubmit( blkif_request_t* req; BOOLEAN Notify; - KeAcquireSpinLock(&Ring->Lock, &Irql); - if (RING_FULL(&Ring->Front)) { - KeReleaseSpinLock(&Ring->Lock, Irql); + KeAcquireSpinLock(&Protocol->Lock, &Irql); + if (RING_FULL(&Protocol->Front)) { + KeReleaseSpinLock(&Protocol->Lock, Irql); return FALSE; } - req = RING_GET_REQUEST(&Ring->Front, Ring->Front.req_prod_pvt); - __RingInsert(Ring, Request, req); + req = RING_GET_REQUEST(&Protocol->Front, Protocol->Front.req_prod_pvt); + __ProtocolInsert(Protocol, Request, req); KeMemoryBarrier(); - ++Ring->Front.req_prod_pvt; + ++Protocol->Front.req_prod_pvt; - RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&Ring->Front, Notify); - KeReleaseSpinLock(&Ring->Lock, Irql); + RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&Protocol->Front, Notify); + KeReleaseSpinLock(&Protocol->Lock, Irql); if (Notify) { - if (!Ring->Enabled) + if (!Protocol->Enabled) return TRUE; XENBUS_EVTCHN(Send, - &Ring->EvtchnInterface, - Ring->Channel); + &Protocol->EvtchnInterface, + Protocol->Channel); } return TRUE; } static FORCEINLINE BOOLEAN -RingSubmitRequests( - IN PXENVBD_RING Ring +ProtocolSubmitRequests( + IN PXENVBD_PROTOCOL Protocol ) { - if (!Ring->Enabled) { - if (QueueCount(&Ring->PreparedReqs)) + if (!Protocol->Enabled) { + if (QueueCount(&Protocol->PreparedReqs)) Warning("Target[%d] : Paused, not submitting new requests (%u)\n", - FrontendGetTargetId(Ring->Frontend), - QueueCount(&Ring->PreparedReqs)); + FrontendGetTargetId(Protocol->Frontend), + QueueCount(&Protocol->PreparedReqs)); return FALSE; } @@ -1010,49 +1010,49 @@ RingSubmitRequests( PXENVBD_REQUEST Request; PLIST_ENTRY ListEntry; - ListEntry = QueuePop(&Ring->PreparedReqs); + ListEntry = QueuePop(&Protocol->PreparedReqs); if (ListEntry == NULL) break; Request = CONTAINING_RECORD(ListEntry, XENVBD_REQUEST, ListEntry); - QueueAppend(&Ring->SubmittedReqs, &Request->ListEntry); + QueueAppend(&Protocol->SubmittedReqs, &Request->ListEntry); KeMemoryBarrier(); - if (RingSubmit(Ring, Request)) + if (ProtocolSubmit(Protocol, Request)) continue; - QueueRemove(&Ring->SubmittedReqs, &Request->ListEntry); - QueueUnPop(&Ring->PreparedReqs, &Request->ListEntry); + QueueRemove(&Protocol->SubmittedReqs, &Request->ListEntry); + QueueUnPop(&Protocol->PreparedReqs, &Request->ListEntry); break; } - return QueueCount(&Ring->PreparedReqs) != 0; + return QueueCount(&Protocol->PreparedReqs) != 0; } static FORCEINLINE VOID -RingCompleteShutdown( - IN PXENVBD_RING Ring +ProtocolCompleteShutdown( + IN PXENVBD_PROTOCOL Protocol ) { PXENVBD_TARGET Target; PXENVBD_ADAPTER Adapter; - if (QueueCount(&Ring->ShutdownSrbs) == 0) + if (QueueCount(&Protocol->ShutdownSrbs) == 0) return; - if (QueueCount(&Ring->PreparedReqs) || - QueueCount(&Ring->SubmittedReqs)) + if (QueueCount(&Protocol->PreparedReqs) || + QueueCount(&Protocol->SubmittedReqs)) return; - Target = FrontendGetTarget(Ring->Frontend); + Target = FrontendGetTarget(Protocol->Frontend); Adapter = TargetGetAdapter(Target); for (;;) { PXENVBD_SRBEXT SrbExt; PSCSI_REQUEST_BLOCK Srb; PLIST_ENTRY ListEntry; - ListEntry = QueuePop(&Ring->ShutdownSrbs); + ListEntry = QueuePop(&Protocol->ShutdownSrbs); if (ListEntry == NULL) break; SrbExt = CONTAINING_RECORD(ListEntry, XENVBD_SRBEXT, ListEntry); @@ -1081,8 +1081,8 @@ __BlkifOperationName( } static VOID -RingCompleteResponse( - IN PXENVBD_RING Ring, +ProtocolCompleteResponse( + IN PXENVBD_PROTOCOL Protocol, IN ULONG64 Id, IN SHORT Status ) @@ -1091,7 +1091,7 @@ RingCompleteResponse( PSCSI_REQUEST_BLOCK Srb; PXENVBD_SRBEXT SrbExt; - Request = RingFindRequest(Ring, Id); + Request = ProtocolFindRequest(Protocol, Id); if (Request == NULL) return; @@ -1100,12 +1100,12 @@ RingCompleteResponse( switch (Status) { case BLKIF_RSP_OKAY: - RingRequestCopyOutput(Request); + ProtocolRequestCopyOutput(Request); break; case BLKIF_RSP_EOPNOTSUPP: // Remove appropriate feature support - FrontendRemoveFeature(Ring->Frontend, Request->Operation); + FrontendRemoveFeature(Protocol->Frontend, Request->Operation); // Succeed this SRB, subsiquent SRBs will be succeeded instead of being passed to the backend. Srb->SrbStatus = SRB_STATUS_SUCCESS; break; @@ -1113,18 +1113,18 @@ RingCompleteResponse( case BLKIF_RSP_ERROR: default: Warning("Target[%d] : %s BLKIF_RSP_ERROR (Tag %llx)\n", - FrontendGetTargetId(Ring->Frontend), + FrontendGetTargetId(Protocol->Frontend), __BlkifOperationName(Request->Operation), Id); Srb->SrbStatus = SRB_STATUS_ERROR; break; } - RingPutRequest(Ring, Request); + ProtocolPutRequest(Protocol, Request); // complete srb if (InterlockedDecrement(&SrbExt->RequestCount) == 0) { - PXENVBD_TARGET Target = FrontendGetTarget(Ring->Frontend); + PXENVBD_TARGET Target = FrontendGetTarget(Protocol->Frontend); PXENVBD_ADAPTER Adapter = TargetGetAdapter(Target); if (Srb->SrbStatus == SRB_STATUS_PENDING) { @@ -1142,18 +1142,18 @@ RingCompleteResponse( } static BOOLEAN -RingPoll( - IN PXENVBD_RING Ring +ProtocolPoll( + IN PXENVBD_PROTOCOL Protocol ) { BOOLEAN Retry = FALSE; ASSERT3U(KeGetCurrentIrql(), ==, DISPATCH_LEVEL); - KeAcquireSpinLockAtDpcLevel(&Ring->Lock); + KeAcquireSpinLockAtDpcLevel(&Protocol->Lock); // Guard against this locked region being called after the // lock on FrontendSetState - if (Ring->Enabled == FALSE) + if (Protocol->Enabled == FALSE) goto done; for (;;) { @@ -1162,8 +1162,8 @@ RingPoll( KeMemoryBarrier(); - rsp_prod = Ring->Shared->rsp_prod; - rsp_cons = Ring->Front.rsp_cons; + rsp_prod = Protocol->Shared->rsp_prod; + rsp_cons = Protocol->Front.rsp_cons; KeMemoryBarrier(); @@ -1173,95 +1173,95 @@ RingPoll( while (rsp_cons != rsp_prod && !Retry) { blkif_response_t* rsp; - rsp = RING_GET_RESPONSE(&Ring->Front, rsp_cons); + rsp = RING_GET_RESPONSE(&Protocol->Front, rsp_cons); ++rsp_cons; - ++Ring->Received; + ++Protocol->Received; - RingCompleteResponse(Ring, rsp->id, rsp->status); + ProtocolCompleteResponse(Protocol, rsp->id, rsp->status); RtlZeroMemory(rsp, sizeof(union blkif_sring_entry)); - if (rsp_cons - Ring->Front.rsp_cons > RING_SIZE(&Ring->Front) / 4) + if (rsp_cons - Protocol->Front.rsp_cons > RING_SIZE(&Protocol->Front) / 4) Retry = TRUE; } KeMemoryBarrier(); - Ring->Front.rsp_cons = rsp_cons; - Ring->Shared->rsp_event = rsp_cons + 1; + Protocol->Front.rsp_cons = rsp_cons; + Protocol->Shared->rsp_event = rsp_cons + 1; } done: - KeReleaseSpinLockFromDpcLevel(&Ring->Lock); + KeReleaseSpinLockFromDpcLevel(&Protocol->Lock); return Retry; } __drv_requiresIRQL(DISPATCH_LEVEL) static BOOLEAN -RingNotifyResponses( - IN PXENVBD_RING Ring +ProtocolNotifyResponses( + IN PXENVBD_PROTOCOL Protocol ) { BOOLEAN Retry = FALSE; - if (!Ring->Enabled) + if (!Protocol->Enabled) return FALSE; - Retry |= RingPoll(Ring); - Retry |= RingSubmitRequests(Ring); + Retry |= ProtocolPoll(Protocol); + Retry |= ProtocolSubmitRequests(Protocol); - RingCompleteShutdown(Ring); + ProtocolCompleteShutdown(Protocol); return Retry; } -KSERVICE_ROUTINE RingInterrupt; +KSERVICE_ROUTINE ProtocolInterrupt; BOOLEAN -RingInterrupt( +ProtocolInterrupt( IN PKINTERRUPT Interrupt, IN PVOID Context ) { - PXENVBD_RING Ring = Context; + PXENVBD_PROTOCOL Protocol = Context; UNREFERENCED_PARAMETER(Interrupt); - ASSERT(Ring != NULL); + ASSERT(Protocol != NULL); - ++Ring->Events; - if (!Ring->Connected) + ++Protocol->Events; + if (!Protocol->Connected) return TRUE; - if (KeInsertQueueDpc(&Ring->Dpc, NULL, NULL)) - ++Ring->Dpcs; + if (KeInsertQueueDpc(&Protocol->Dpc, NULL, NULL)) + ++Protocol->Dpcs; return TRUE; } -KDEFERRED_ROUTINE RingDpc; +KDEFERRED_ROUTINE ProtocolDpc; VOID -RingDpc( +ProtocolDpc( __in PKDPC Dpc, __in_opt PVOID Context, __in_opt PVOID Arg1, __in_opt PVOID Arg2 ) { - PXENVBD_RING Ring = Context; + PXENVBD_PROTOCOL Protocol = Context; UNREFERENCED_PARAMETER(Dpc); UNREFERENCED_PARAMETER(Arg1); UNREFERENCED_PARAMETER(Arg2); - ASSERT(Ring != NULL); + ASSERT(Protocol != NULL); for (;;) { KIRQL Irql; BOOLEAN Retry; KeRaiseIrql(DISPATCH_LEVEL, &Irql); - Retry = RingNotifyResponses(Ring); + Retry = ProtocolNotifyResponses(Protocol); KeLowerIrql(Irql); if (!Retry) @@ -1269,136 +1269,136 @@ RingDpc( } XENBUS_EVTCHN(Unmask, - &Ring->EvtchnInterface, - Ring->Channel, + &Protocol->EvtchnInterface, + Protocol->Channel, FALSE); } static DECLSPEC_NOINLINE VOID -RingDebugCallback( +ProtocolDebugCallback( IN PVOID Argument, IN BOOLEAN Crashing ) { - PXENVBD_RING Ring = Argument; - PXENVBD_GRANTER Granter = FrontendGetGranter(Ring->Frontend); + PXENVBD_PROTOCOL Protocol = Argument; + PXENVBD_GRANTER Granter = FrontendGetGranter(Protocol->Frontend); ULONG Index; UNREFERENCED_PARAMETER(Crashing); XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "Submitted: %u Received: %u\n", - Ring->Submitted, - Ring->Received); + Protocol->Submitted, + Protocol->Received); XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "Events: %u Dpcs: %u\n", - Ring->Events, - Ring->Dpcs); + Protocol->Events, + Protocol->Dpcs); XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "Shared : 0x%p\n", - Ring->Shared); + Protocol->Shared); - if (Ring->Shared) { + if (Protocol->Shared) { XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "Shared: %d / %d - %d / %d\n", - Ring->Shared->req_prod, - Ring->Shared->req_event, - Ring->Shared->rsp_prod, - Ring->Shared->rsp_event); + Protocol->Shared->req_prod, + Protocol->Shared->req_event, + Protocol->Shared->rsp_prod, + Protocol->Shared->rsp_event); } XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "Front: %d / %d (%d)\n", - Ring->Front.req_prod_pvt, - Ring->Front.rsp_cons, - Ring->Front.nr_ents); + Protocol->Front.req_prod_pvt, + Protocol->Front.rsp_cons, + Protocol->Front.nr_ents); XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "Order: %d\n", - Ring->Order); + Protocol->Order); - for (Index = 0; Index < (1ul << Ring->Order); ++Index) { + for (Index = 0; Index < (1ul << Protocol->Order); ++Index) { XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "Grants[%-2d]: 0x%p (%u)\n", Index, - Ring->Grants[Index], - GranterReference(Granter, Ring->Grants[Index])); + Protocol->Grants[Index], + GranterReference(Granter, Protocol->Grants[Index])); } - if (Ring->Channel) { + if (Protocol->Channel) { ULONG Port = XENBUS_EVTCHN(GetPort, - &Ring->EvtchnInterface, - Ring->Channel); + &Protocol->EvtchnInterface, + Protocol->Channel); XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "Channel : %p (%d)\n", - Ring->Channel, + Protocol->Channel, Port); } XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "BLKIF_OPs: READ=%u WRITE=%u\n", - Ring->BlkOpRead, - Ring->BlkOpWrite); + Protocol->BlkOpRead, + Protocol->BlkOpWrite); XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "BLKIF_OPs: INDIRECT_READ=%u INDIRECT_WRITE=%u\n", - Ring->BlkOpIndirectRead, - Ring->BlkOpIndirectWrite); + Protocol->BlkOpIndirectRead, + Protocol->BlkOpIndirectWrite); XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "BLKIF_OPs: BARRIER=%u DISCARD=%u FLUSH=%u\n", - Ring->BlkOpBarrier, - Ring->BlkOpDiscard, - Ring->BlkOpFlush); + Protocol->BlkOpBarrier, + Protocol->BlkOpDiscard, + Protocol->BlkOpFlush); XENBUS_DEBUG(Printf, - &Ring->DebugInterface, + &Protocol->DebugInterface, "Segments Granted=%llu Bounced=%llu\n", - Ring->SegsGranted, - Ring->SegsBounced); + Protocol->SegsGranted, + Protocol->SegsBounced); - QueueDebugCallback(&Ring->PreparedReqs, + QueueDebugCallback(&Protocol->PreparedReqs, "Prepared ", - &Ring->DebugInterface); - QueueDebugCallback(&Ring->SubmittedReqs, + &Protocol->DebugInterface); + QueueDebugCallback(&Protocol->SubmittedReqs, "Submitted", - &Ring->DebugInterface); - QueueDebugCallback(&Ring->ShutdownSrbs, + &Protocol->DebugInterface); + QueueDebugCallback(&Protocol->ShutdownSrbs, "Shutdown ", - &Ring->DebugInterface); + &Protocol->DebugInterface); } static DECLSPEC_NOINLINE VOID -RingAcquireLock( +ProtocolAcquireLock( IN PVOID Argument ) { - PXENVBD_RING Ring = Argument; - KeAcquireSpinLockAtDpcLevel(&Ring->Lock); + PXENVBD_PROTOCOL Protocol = Argument; + KeAcquireSpinLockAtDpcLevel(&Protocol->Lock); } static DECLSPEC_NOINLINE VOID -RingReleaseLock( +ProtocolReleaseLock( IN PVOID Argument ) { - PXENVBD_RING Ring = Argument; - KeReleaseSpinLockFromDpcLevel(&Ring->Lock); + PXENVBD_PROTOCOL Protocol = Argument; + KeReleaseSpinLockFromDpcLevel(&Protocol->Lock); } static DECLSPEC_NOINLINE NTSTATUS -RingRequestCtor( +ProtocolRequestCtor( IN PVOID Argument, IN PVOID Object ) @@ -1413,7 +1413,7 @@ RingRequestCtor( } static DECLSPEC_NOINLINE VOID -RingRequestDtor( +ProtocolRequestDtor( IN PVOID Argument, IN PVOID Object ) @@ -1423,7 +1423,7 @@ RingRequestDtor( } static DECLSPEC_NOINLINE NTSTATUS -RingSegmentCtor( +ProtocolSegmentCtor( IN PVOID Argument, IN PVOID Object ) @@ -1434,7 +1434,7 @@ RingSegmentCtor( } static DECLSPEC_NOINLINE VOID -RingSegmentDtor( +ProtocolSegmentDtor( IN PVOID Argument, IN PVOID Object ) @@ -1444,7 +1444,7 @@ RingSegmentDtor( } static DECLSPEC_NOINLINE NTSTATUS -RingIndirectCtor( +ProtocolIndirectCtor( IN PVOID Argument, IN PVOID Object ) @@ -1471,7 +1471,7 @@ fail1: } static DECLSPEC_NOINLINE VOID -RingIndirectDtor( +ProtocolIndirectDtor( IN PVOID Argument, IN PVOID Object ) @@ -1486,9 +1486,9 @@ RingIndirectDtor( } NTSTATUS -RingCreate( +ProtocolCreate( IN PXENVBD_FRONTEND Frontend, - OUT PXENVBD_RING* Ring + OUT PXENVBD_PROTOCOL* Protocol ) { PXENVBD_TARGET Target = FrontendGetTarget(Frontend); @@ -1496,24 +1496,24 @@ RingCreate( CHAR Name[MAX_NAME_LEN]; NTSTATUS status; - *Ring = __RingAllocate(sizeof(XENVBD_RING)); + *Protocol = __ProtocolAllocate(sizeof(XENVBD_PROTOCOL)); status = STATUS_NO_MEMORY; - if (*Ring == NULL) + if (*Protocol == NULL) goto fail1; - (*Ring)->Frontend = Frontend; - KeInitializeSpinLock(&(*Ring)->Lock); - KeInitializeThreadedDpc(&(*Ring)->Dpc, RingDpc, *Ring); - KeSetImportanceDpc(&(*Ring)->Dpc, MediumHighImportance); + (*Protocol)->Frontend = Frontend; + KeInitializeSpinLock(&(*Protocol)->Lock); + KeInitializeThreadedDpc(&(*Protocol)->Dpc, ProtocolDpc, *Protocol); + KeSetImportanceDpc(&(*Protocol)->Dpc, MediumHighImportance); - QueueInit(&(*Ring)->PreparedReqs); - QueueInit(&(*Ring)->SubmittedReqs); - QueueInit(&(*Ring)->ShutdownSrbs); + QueueInit(&(*Protocol)->PreparedReqs); + QueueInit(&(*Protocol)->SubmittedReqs); + QueueInit(&(*Protocol)->ShutdownSrbs); - AdapterGetCacheInterface(Adapter, &(*Ring)->CacheInterface); + AdapterGetCacheInterface(Adapter, &(*Protocol)->CacheInterface); - status = XENBUS_CACHE(Acquire, &(*Ring)->CacheInterface); + status = XENBUS_CACHE(Acquire, &(*Protocol)->CacheInterface); if (!NT_SUCCESS(status)) goto fail2; @@ -1525,16 +1525,16 @@ RingCreate( goto fail3; status = XENBUS_CACHE(Create, - &(*Ring)->CacheInterface, + &(*Protocol)->CacheInterface, Name, sizeof(XENVBD_REQUEST), 32, - RingRequestCtor, - RingRequestDtor, - RingAcquireLock, - RingReleaseLock, - *Ring, - &(*Ring)->RequestCache); + ProtocolRequestCtor, + ProtocolRequestDtor, + ProtocolAcquireLock, + ProtocolReleaseLock, + *Protocol, + &(*Protocol)->RequestCache); if (!NT_SUCCESS(status)) goto fail4; @@ -1546,16 +1546,16 @@ RingCreate( goto fail5; status = XENBUS_CACHE(Create, - &(*Ring)->CacheInterface, + &(*Protocol)->CacheInterface, Name, sizeof(XENVBD_SEGMENT), 32, - RingSegmentCtor, - RingSegmentDtor, - RingAcquireLock, - RingReleaseLock, - *Ring, - &(*Ring)->SegmentCache); + ProtocolSegmentCtor, + ProtocolSegmentDtor, + ProtocolAcquireLock, + ProtocolReleaseLock, + *Protocol, + &(*Protocol)->SegmentCache); if (!NT_SUCCESS(status)) goto fail6; @@ -1567,16 +1567,16 @@ RingCreate( goto fail7; status = XENBUS_CACHE(Create, - &(*Ring)->CacheInterface, + &(*Protocol)->CacheInterface, Name, sizeof(XENVBD_INDIRECT), 1, - RingIndirectCtor, - RingIndirectDtor, - RingAcquireLock, - RingReleaseLock, - *Ring, - &(*Ring)->IndirectCache); + ProtocolIndirectCtor, + ProtocolIndirectDtor, + ProtocolAcquireLock, + ProtocolReleaseLock, + *Protocol, + &(*Protocol)->IndirectCache); if (!NT_SUCCESS(status)) goto fail8; @@ -1587,127 +1587,127 @@ fail8: fail7: Error("fail7\n"); XENBUS_CACHE(Destroy, - &(*Ring)->CacheInterface, - (*Ring)->SegmentCache); - (*Ring)->SegmentCache = NULL; + &(*Protocol)->CacheInterface, + (*Protocol)->SegmentCache); + (*Protocol)->SegmentCache = NULL; fail6: Error("fail6\n"); fail5: Error("fail5\n"); XENBUS_CACHE(Destroy, - &(*Ring)->CacheInterface, - (*Ring)->RequestCache); - (*Ring)->RequestCache = NULL; + &(*Protocol)->CacheInterface, + (*Protocol)->RequestCache); + (*Protocol)->RequestCache = NULL; fail4: Error("fail4\n"); fail3: Error("fail3\n"); XENBUS_CACHE(Release, - &(*Ring)->CacheInterface); + &(*Protocol)->CacheInterface); fail2: Error("fail2\n"); - RtlZeroMemory(&(*Ring)->CacheInterface, + RtlZeroMemory(&(*Protocol)->CacheInterface, sizeof (XENBUS_CACHE_INTERFACE)); - RtlZeroMemory(&(*Ring)->PreparedReqs, sizeof(XENVBD_QUEUE)); - RtlZeroMemory(&(*Ring)->SubmittedReqs, sizeof(XENVBD_QUEUE)); - RtlZeroMemory(&(*Ring)->ShutdownSrbs, sizeof(XENVBD_QUEUE)); + RtlZeroMemory(&(*Protocol)->PreparedReqs, sizeof(XENVBD_QUEUE)); + RtlZeroMemory(&(*Protocol)->SubmittedReqs, sizeof(XENVBD_QUEUE)); + RtlZeroMemory(&(*Protocol)->ShutdownSrbs, sizeof(XENVBD_QUEUE)); - RtlZeroMemory(&(*Ring)->Dpc, sizeof(KDPC)); - RtlZeroMemory(&(*Ring)->Lock, sizeof(KSPIN_LOCK)); - (*Ring)->Frontend = NULL; + RtlZeroMemory(&(*Protocol)->Dpc, sizeof(KDPC)); + RtlZeroMemory(&(*Protocol)->Lock, sizeof(KSPIN_LOCK)); + (*Protocol)->Frontend = NULL; - ASSERT(IsZeroMemory(*Ring, sizeof(XENVBD_RING))); - __RingFree(*Ring); - *Ring = NULL; + ASSERT(IsZeroMemory(*Protocol, sizeof(XENVBD_PROTOCOL))); + __ProtocolFree(*Protocol); + *Protocol = NULL; fail1: Error("fail1 %08x\n", status); return status; } VOID -RingDestroy( - IN PXENVBD_RING Ring +ProtocolDestroy( + IN PXENVBD_PROTOCOL Protocol ) { XENBUS_CACHE(Destroy, - &Ring->CacheInterface, - Ring->IndirectCache); - Ring->IndirectCache = NULL; + &Protocol->CacheInterface, + Protocol->IndirectCache); + Protocol->IndirectCache = NULL; XENBUS_CACHE(Destroy, - &Ring->CacheInterface, - Ring->SegmentCache); - Ring->SegmentCache = NULL; + &Protocol->CacheInterface, + Protocol->SegmentCache); + Protocol->SegmentCache = NULL; XENBUS_CACHE(Destroy, - &Ring->CacheInterface, - Ring->RequestCache); - Ring->RequestCache = NULL; + &Protocol->CacheInterface, + Protocol->RequestCache); + Protocol->RequestCache = NULL; XENBUS_CACHE(Release, - &Ring->CacheInterface); + &Protocol->CacheInterface); - RtlZeroMemory(&Ring->CacheInterface, + RtlZeroMemory(&Protocol->CacheInterface, sizeof (XENBUS_CACHE_INTERFACE)); - RtlZeroMemory(&Ring->PreparedReqs, sizeof(XENVBD_QUEUE)); - RtlZeroMemory(&Ring->SubmittedReqs, sizeof(XENVBD_QUEUE)); - RtlZeroMemory(&Ring->ShutdownSrbs, sizeof(XENVBD_QUEUE)); - - RtlZeroMemory(&Ring->Dpc, sizeof(KDPC)); - RtlZeroMemory(&Ring->Lock, sizeof(KSPIN_LOCK)); - Ring->Frontend = NULL; - - Ring->BlkOpRead = 0; - Ring->BlkOpWrite = 0; - Ring->BlkOpIndirectRead = 0; - Ring->BlkOpIndirectWrite = 0; - Ring->BlkOpBarrier = 0; - Ring->BlkOpDiscard = 0; - Ring->BlkOpFlush = 0; - Ring->SegsGranted = 0; - Ring->SegsBounced = 0; - - ASSERT(IsZeroMemory(Ring, sizeof(XENVBD_RING))); - __RingFree(Ring); + RtlZeroMemory(&Protocol->PreparedReqs, sizeof(XENVBD_QUEUE)); + RtlZeroMemory(&Protocol->SubmittedReqs, sizeof(XENVBD_QUEUE)); + RtlZeroMemory(&Protocol->ShutdownSrbs, sizeof(XENVBD_QUEUE)); + + RtlZeroMemory(&Protocol->Dpc, sizeof(KDPC)); + RtlZeroMemory(&Protocol->Lock, sizeof(KSPIN_LOCK)); + Protocol->Frontend = NULL; + + Protocol->BlkOpRead = 0; + Protocol->BlkOpWrite = 0; + Protocol->BlkOpIndirectRead = 0; + Protocol->BlkOpIndirectWrite = 0; + Protocol->BlkOpBarrier = 0; + Protocol->BlkOpDiscard = 0; + Protocol->BlkOpFlush = 0; + Protocol->SegsGranted = 0; + Protocol->SegsBounced = 0; + + ASSERT(IsZeroMemory(Protocol, sizeof(XENVBD_PROTOCOL))); + __ProtocolFree(Protocol); } NTSTATUS -RingConnect( - IN PXENVBD_RING Ring +ProtocolConnect( + IN PXENVBD_PROTOCOL Protocol ) { - PXENVBD_TARGET Target = FrontendGetTarget(Ring->Frontend); + PXENVBD_TARGET Target = FrontendGetTarget(Protocol->Frontend); PXENVBD_ADAPTER Adapter = TargetGetAdapter(Target); - PXENVBD_GRANTER Granter = FrontendGetGranter(Ring->Frontend); + PXENVBD_GRANTER Granter = FrontendGetGranter(Protocol->Frontend); PCHAR Buffer; ULONG Index; NTSTATUS status; - ASSERT(Ring->Connected == FALSE); + ASSERT(Protocol->Connected == FALSE); - AdapterGetStoreInterface(Adapter, &Ring->StoreInterface); - AdapterGetEvtchnInterface(Adapter, &Ring->EvtchnInterface); - AdapterGetDebugInterface(Adapter, &Ring->DebugInterface); + AdapterGetStoreInterface(Adapter, &Protocol->StoreInterface); + AdapterGetEvtchnInterface(Adapter, &Protocol->EvtchnInterface); + AdapterGetDebugInterface(Adapter, &Protocol->DebugInterface); - status = XENBUS_STORE(Acquire, &Ring->StoreInterface); + status = XENBUS_STORE(Acquire, &Protocol->StoreInterface); if (!NT_SUCCESS(status)) goto fail1; - status = XENBUS_EVTCHN(Acquire, &Ring->EvtchnInterface); + status = XENBUS_EVTCHN(Acquire, &Protocol->EvtchnInterface); if (!NT_SUCCESS(status)) goto fail2; - status = XENBUS_DEBUG(Acquire, &Ring->DebugInterface); + status = XENBUS_DEBUG(Acquire, &Protocol->DebugInterface); if (!NT_SUCCESS(status)) goto fail3; status = XENBUS_STORE(Read, - &Ring->StoreInterface, + &Protocol->StoreInterface, NULL, - FrontendGetBackendPath(Ring->Frontend), + FrontendGetBackendPath(Protocol->Frontend), "max-ring-page-order", &Buffer); if (NT_SUCCESS(status)) { @@ -1715,156 +1715,156 @@ RingConnect( if (DriverGetFeatureOverride(FeatureMaxRingPageOrder, &MaxOrder)) { - MaxOrder = min(MaxOrder, XENVBD_MAX_RING_PAGE_ORDER); + MaxOrder = min(MaxOrder, XENVBD_MAX_PROTOCOL_PAGE_ORDER); } else { - MaxOrder = XENVBD_MAX_RING_PAGE_ORDER; + MaxOrder = XENVBD_MAX_PROTOCOL_PAGE_ORDER; } - Ring->Order = strtoul(Buffer, NULL, 10); - Ring->Order = min(Ring->Order, MaxOrder); + Protocol->Order = strtoul(Buffer, NULL, 10); + Protocol->Order = min(Protocol->Order, MaxOrder); XENBUS_STORE(Free, - &Ring->StoreInterface, + &Protocol->StoreInterface, Buffer); } else { - Ring->Order = 0; + Protocol->Order = 0; } - Ring->Mdl = __AllocatePages(1 << Ring->Order); + Protocol->Mdl = __AllocatePages(1 << Protocol->Order); status = STATUS_NO_MEMORY; - if (Ring->Mdl == NULL) + if (Protocol->Mdl == NULL) goto fail4; - Ring->Shared = MmGetSystemAddressForMdlSafe(Ring->Mdl, + Protocol->Shared = MmGetSystemAddressForMdlSafe(Protocol->Mdl, NormalPagePriority); - ASSERT(Ring->Shared != NULL); + ASSERT(Protocol->Shared != NULL); #pragma warning(push) #pragma warning(disable: 4305) #pragma warning(disable: 4311) // 'type cast' pointer truncation from 'blkif_sring_entry[1]' to 'long' - SHARED_RING_INIT(Ring->Shared); - FRONT_RING_INIT(&Ring->Front, Ring->Shared, PAGE_SIZE << Ring->Order); + SHARED_RING_INIT(Protocol->Shared); + FRONT_RING_INIT(&Protocol->Front, Protocol->Shared, PAGE_SIZE << Protocol->Order); #pragma warning(pop) - for (Index = 0; Index < (1ul << Ring->Order); ++Index) { + for (Index = 0; Index < (1ul << Protocol->Order); ++Index) { status = GranterGet(Granter, - MmGetMdlPfnArray(Ring->Mdl)[Index], + MmGetMdlPfnArray(Protocol->Mdl)[Index], FALSE, - &Ring->Grants[Index]); + &Protocol->Grants[Index]); if (!NT_SUCCESS(status)) goto fail5; } - Ring->Channel = XENBUS_EVTCHN(Open, - &Ring->EvtchnInterface, + Protocol->Channel = XENBUS_EVTCHN(Open, + &Protocol->EvtchnInterface, XENBUS_EVTCHN_TYPE_UNBOUND, - RingInterrupt, - Ring, - FrontendGetBackendDomain(Ring->Frontend), + ProtocolInterrupt, + Protocol, + FrontendGetBackendDomain(Protocol->Frontend), TRUE); status = STATUS_NO_MEMORY; - if (Ring->Channel == NULL) + if (Protocol->Channel == NULL) goto fail6; XENBUS_EVTCHN(Unmask, - &Ring->EvtchnInterface, - Ring->Channel, + &Protocol->EvtchnInterface, + Protocol->Channel, FALSE); status = XENBUS_DEBUG(Register, - &Ring->DebugInterface, - __MODULE__"|RING", - RingDebugCallback, - Ring, - &Ring->DebugCallback); + &Protocol->DebugInterface, + __MODULE__"|PROTOCOL", + ProtocolDebugCallback, + Protocol, + &Protocol->DebugCallback); if (!NT_SUCCESS(status)) goto fail7; - Ring->Connected = TRUE; + Protocol->Connected = TRUE; return STATUS_SUCCESS; fail7: Error("fail7\n"); XENBUS_EVTCHN(Close, - &Ring->EvtchnInterface, - Ring->Channel); - Ring->Channel = NULL; + &Protocol->EvtchnInterface, + Protocol->Channel); + Protocol->Channel = NULL; fail6: Error("fail6\n"); fail5: Error("fail5\n"); - for (Index = 0; Index < (1ul << Ring->Order); ++Index) { - if (Ring->Grants[Index] == NULL) + for (Index = 0; Index < (1ul << Protocol->Order); ++Index) { + if (Protocol->Grants[Index] == NULL) continue; - GranterPut(Granter, Ring->Grants[Index]); - Ring->Grants[Index] = NULL; + GranterPut(Granter, Protocol->Grants[Index]); + Protocol->Grants[Index] = NULL; } - RtlZeroMemory(&Ring->Front, sizeof(blkif_front_ring_t)); + RtlZeroMemory(&Protocol->Front, sizeof(blkif_front_ring_t)); - __FreePages(Ring->Mdl); - Ring->Shared = NULL; - Ring->Mdl = NULL; + __FreePages(Protocol->Mdl); + Protocol->Shared = NULL; + Protocol->Mdl = NULL; - Ring->Order = 0; + Protocol->Order = 0; fail4: Error("fail4\n"); - XENBUS_DEBUG(Release, &Ring->DebugInterface); + XENBUS_DEBUG(Release, &Protocol->DebugInterface); fail3: Error("fail3\n"); - XENBUS_EVTCHN(Release, &Ring->EvtchnInterface); + XENBUS_EVTCHN(Release, &Protocol->EvtchnInterface); fail2: Error("fail2\n"); - XENBUS_STORE(Release, &Ring->StoreInterface); + XENBUS_STORE(Release, &Protocol->StoreInterface); fail1: Error("fail1 %08x\n", status); - RtlZeroMemory(&Ring->DebugInterface, + RtlZeroMemory(&Protocol->DebugInterface, sizeof(XENBUS_DEBUG_INTERFACE)); - RtlZeroMemory(&Ring->EvtchnInterface, + RtlZeroMemory(&Protocol->EvtchnInterface, sizeof(XENBUS_EVTCHN_INTERFACE)); - RtlZeroMemory(&Ring->StoreInterface, + RtlZeroMemory(&Protocol->StoreInterface, sizeof(XENBUS_STORE_INTERFACE)); return status; } NTSTATUS -RingStoreWrite( - IN PXENVBD_RING Ring, +ProtocolStoreWrite( + IN PXENVBD_PROTOCOL Protocol, IN PVOID Transaction ) { - PXENVBD_GRANTER Granter = FrontendGetGranter(Ring->Frontend); + PXENVBD_GRANTER Granter = FrontendGetGranter(Protocol->Frontend); ULONG Port; NTSTATUS status; - if (Ring->Order == 0) { + if (Protocol->Order == 0) { status = XENBUS_STORE(Printf, - &Ring->StoreInterface, + &Protocol->StoreInterface, Transaction, - FrontendGetFrontendPath(Ring->Frontend), + FrontendGetFrontendPath(Protocol->Frontend), "ring-ref", "%u", - GranterReference(Granter, Ring->Grants[0])); + GranterReference(Granter, Protocol->Grants[0])); if (!NT_SUCCESS(status)) return status; } else { ULONG Index; status = XENBUS_STORE(Printf, - &Ring->StoreInterface, + &Protocol->StoreInterface, Transaction, - FrontendGetFrontendPath(Ring->Frontend), + FrontendGetFrontendPath(Protocol->Frontend), "ring-page-order", "%u", - Ring->Order); + Protocol->Order); if (!NT_SUCCESS(status)) return status; - for (Index = 0; Index < (1ul << Ring->Order); ++Index) { + for (Index = 0; Index < (1ul << Protocol->Order); ++Index) { CHAR Name[MAX_NAME_LEN+1]; status = RtlStringCchPrintfA(Name, @@ -1875,34 +1875,34 @@ RingStoreWrite( return status; status = XENBUS_STORE(Printf, - &Ring->StoreInterface, + &Protocol->StoreInterface, Transaction, - FrontendGetFrontendPath(Ring->Frontend), + FrontendGetFrontendPath(Protocol->Frontend), Name, "%u", - GranterReference(Granter, Ring->Grants[Index])); + GranterReference(Granter, Protocol->Grants[Index])); if (!NT_SUCCESS(status)) return status; } } status = XENBUS_STORE(Printf, - &Ring->StoreInterface, + &Protocol->StoreInterface, Transaction, - FrontendGetFrontendPath(Ring->Frontend), + FrontendGetFrontendPath(Protocol->Frontend), "protocol", XEN_IO_PROTO_ABI); if (!NT_SUCCESS(status)) return status; Port = XENBUS_EVTCHN(GetPort, - &Ring->EvtchnInterface, - Ring->Channel); + &Protocol->EvtchnInterface, + Protocol->Channel); status = XENBUS_STORE(Printf, - &Ring->StoreInterface, + &Protocol->StoreInterface, Transaction, - FrontendGetFrontendPath(Ring->Frontend), + FrontendGetFrontendPath(Protocol->Frontend), "event-channel", "%u", Port); @@ -1913,49 +1913,49 @@ RingStoreWrite( } VOID -RingEnable( - IN PXENVBD_RING Ring +ProtocolEnable( + IN PXENVBD_PROTOCOL Protocol ) { - ASSERT(Ring->Enabled == FALSE); - Ring->Enabled = TRUE; + ASSERT(Protocol->Enabled == FALSE); + Protocol->Enabled = TRUE; XENBUS_EVTCHN(Trigger, - &Ring->EvtchnInterface, - Ring->Channel); + &Protocol->EvtchnInterface, + Protocol->Channel); } VOID -RingDisable( - IN PXENVBD_RING Ring +ProtocolDisable( + IN PXENVBD_PROTOCOL Protocol ) { ULONG Count; KIRQL Irql; - PXENVBD_TARGET Target = FrontendGetTarget(Ring->Frontend); + PXENVBD_TARGET Target = FrontendGetTarget(Protocol->Frontend); PXENVBD_ADAPTER Adapter = TargetGetAdapter(Target); - ASSERT(Ring->Enabled == TRUE); - Ring->Enabled = FALSE; + ASSERT(Protocol->Enabled == TRUE); + Protocol->Enabled = FALSE; // poll ring and send event channel notification every 1ms (for up to 3 minutes) Count = 0; - while (QueueCount(&Ring->SubmittedReqs)) { + while (QueueCount(&Protocol->SubmittedReqs)) { if (Count > 180000) break; KeRaiseIrql(DISPATCH_LEVEL, &Irql); - RingPoll(Ring); + ProtocolPoll(Protocol); KeLowerIrql(Irql); XENBUS_EVTCHN(Send, - &Ring->EvtchnInterface, - Ring->Channel); + &Protocol->EvtchnInterface, + Protocol->Channel); StorPortStallExecution(1000); // 1000 micro-seconds ++Count; } Verbose("Target[%d] : %u Submitted requests left (%u iterrations)\n", - FrontendGetTargetId(Ring->Frontend), - QueueCount(&Ring->SubmittedReqs), + FrontendGetTargetId(Protocol->Frontend), + QueueCount(&Protocol->SubmittedReqs), Count); // Fail PreparedReqs @@ -1965,7 +1965,7 @@ RingDisable( PXENVBD_REQUEST Request; PLIST_ENTRY ListEntry; - ListEntry = QueuePop(&Ring->PreparedReqs); + ListEntry = QueuePop(&Protocol->PreparedReqs); if (ListEntry == NULL) break; Request = CONTAINING_RECORD(ListEntry, XENVBD_REQUEST, ListEntry); @@ -1975,7 +1975,7 @@ RingDisable( Srb->SrbStatus = SRB_STATUS_ABORTED; Srb->ScsiStatus = 0x40; // SCSI_ABORTED - RingPutRequest(Ring, Request); + ProtocolPutRequest(Protocol, Request); if (InterlockedDecrement(&SrbExt->RequestCount) == 0) AdapterCompleteSrb(Adapter, SrbExt); @@ -1983,91 +1983,91 @@ RingDisable( } VOID -RingDisconnect( - IN PXENVBD_RING Ring +ProtocolDisconnect( + IN PXENVBD_PROTOCOL Protocol ) { - PXENVBD_GRANTER Granter = FrontendGetGranter(Ring->Frontend); + PXENVBD_GRANTER Granter = FrontendGetGranter(Protocol->Frontend); ULONG Index; - ASSERT3U(Ring->Submitted, ==, Ring->Received); - ASSERT(Ring->Connected); - Ring->Connected = FALSE; + ASSERT3U(Protocol->Submitted, ==, Protocol->Received); + ASSERT(Protocol->Connected); + Protocol->Connected = FALSE; XENBUS_DEBUG(Deregister, - &Ring->DebugInterface, - Ring->DebugCallback); - Ring->DebugCallback = NULL; + &Protocol->DebugInterface, + Protocol->DebugCallback); + Protocol->DebugCallback = NULL; XENBUS_EVTCHN(Close, - &Ring->EvtchnInterface, - Ring->Channel); - Ring->Channel = NULL; + &Protocol->EvtchnInterface, + Protocol->Channel); + Protocol->Channel = NULL; - for (Index = 0; Index < (1ul << Ring->Order); ++Index) { - if (Ring->Grants[Index] == NULL) + for (Index = 0; Index < (1ul << Protocol->Order); ++Index) { + if (Protocol->Grants[Index] == NULL) continue; - GranterPut(Granter, Ring->Grants[Index]); - Ring->Grants[Index] = NULL; + GranterPut(Granter, Protocol->Grants[Index]); + Protocol->Grants[Index] = NULL; } - RtlZeroMemory(&Ring->Front, sizeof(blkif_front_ring_t)); + RtlZeroMemory(&Protocol->Front, sizeof(blkif_front_ring_t)); - __FreePages(Ring->Mdl); - Ring->Shared = NULL; - Ring->Mdl = NULL; + __FreePages(Protocol->Mdl); + Protocol->Shared = NULL; + Protocol->Mdl = NULL; - Ring->Order = 0; + Protocol->Order = 0; - XENBUS_DEBUG(Release, &Ring->DebugInterface); - XENBUS_EVTCHN(Release, &Ring->EvtchnInterface); - XENBUS_STORE(Release, &Ring->StoreInterface); + XENBUS_DEBUG(Release, &Protocol->DebugInterface); + XENBUS_EVTCHN(Release, &Protocol->EvtchnInterface); + XENBUS_STORE(Release, &Protocol->StoreInterface); - RtlZeroMemory(&Ring->DebugInterface, + RtlZeroMemory(&Protocol->DebugInterface, sizeof(XENBUS_DEBUG_INTERFACE)); - RtlZeroMemory(&Ring->EvtchnInterface, + RtlZeroMemory(&Protocol->EvtchnInterface, sizeof(XENBUS_EVTCHN_INTERFACE)); - RtlZeroMemory(&Ring->StoreInterface, + RtlZeroMemory(&Protocol->StoreInterface, sizeof(XENBUS_STORE_INTERFACE)); - Ring->Events = 0; - Ring->Dpcs = 0; - Ring->Submitted = 0; - Ring->Received = 0; + Protocol->Events = 0; + Protocol->Dpcs = 0; + Protocol->Submitted = 0; + Protocol->Received = 0; } VOID -RingTrigger( - IN PXENVBD_RING Ring +ProtocolTrigger( + IN PXENVBD_PROTOCOL Protocol ) { - if (!Ring->Enabled) + if (!Protocol->Enabled) return; XENBUS_EVTCHN(Trigger, - &Ring->EvtchnInterface, - Ring->Channel); + &Protocol->EvtchnInterface, + Protocol->Channel); } BOOLEAN -RingQueueRequest( - IN PXENVBD_RING Ring, +ProtocolQueueRequest( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_SRBEXT SrbExt ) { PSCSI_REQUEST_BLOCK Srb = SrbExt->Srb; - if (!Ring->Enabled) + if (!Protocol->Enabled) goto fail1; - if (!RingPrepareRequest(Ring, SrbExt)) + if (!ProtocolPrepareRequest(Protocol, SrbExt)) goto fail2; - if (RingSubmitRequests(Ring)) { + if (ProtocolSubmitRequests(Protocol)) { // more prepared-reqs to submit - if (KeInsertQueueDpc(&Ring->Dpc, NULL, NULL)) - ++Ring->Dpcs; + if (KeInsertQueueDpc(&Protocol->Dpc, NULL, NULL)) + ++Protocol->Dpcs; } return TRUE; @@ -2079,17 +2079,17 @@ fail1: } VOID -RingQueueShutdown( - IN PXENVBD_RING Ring, +ProtocolQueueShutdown( + IN PXENVBD_PROTOCOL Protocol, IN PXENVBD_SRBEXT SrbExt ) { - QueueAppend(&Ring->ShutdownSrbs, + QueueAppend(&Protocol->ShutdownSrbs, &SrbExt->ListEntry); - if (!Ring->Enabled) + if (!Protocol->Enabled) return; - if (KeInsertQueueDpc(&Ring->Dpc, NULL, NULL)) - ++Ring->Dpcs; + if (KeInsertQueueDpc(&Protocol->Dpc, NULL, NULL)) + ++Protocol->Dpcs; } diff --git a/src/xenvbd/ring.h b/src/xenvbd/protocol.h similarity index 67% rename from src/xenvbd/ring.h rename to src/xenvbd/protocol.h index 9b8a587..3126e19 100644 --- a/src/xenvbd/ring.h +++ b/src/xenvbd/protocol.h @@ -29,66 +29,66 @@ * SUCH DAMAGE. */ -#ifndef _XENVBD_RING_H -#define _XENVBD_RING_H +#ifndef _XENVBD_PROTOCOL_H +#define _XENVBD_PROTOCOL_H -typedef struct _XENVBD_RING XENVBD_RING, *PXENVBD_RING; +typedef struct _XENVBD_PROTOCOL XENVBD_PROTOCOL, *PXENVBD_PROTOCOL; #include "frontend.h" #include "srbext.h" extern NTSTATUS -RingCreate( +ProtocolCreate( IN PXENVBD_FRONTEND Frontend, - OUT PXENVBD_RING* Ring + OUT PXENVBD_PROTOCOL* Protocol ); extern VOID -RingDestroy( - IN PXENVBD_RING Ring +ProtocolDestroy( + IN PXENVBD_PROTOCOL Protocol ); extern NTSTATUS -RingConnect( - IN PXENVBD_RING Ring +ProtocolConnect( + IN PXENVBD_PROTOCOL Protocol ); extern NTSTATUS -RingStoreWrite( - IN PXENVBD_RING Ring, - IN PVOID Transaction +ProtocolStoreWrite( + IN PXENVBD_PROTOCOL Protocol, + IN PVOID Transaction ); extern VOID -RingEnable( - IN PXENVBD_RING Ring +ProtocolEnable( + IN PXENVBD_PROTOCOL Protocol ); extern VOID -RingDisable( - IN PXENVBD_RING Ring +ProtocolDisable( + IN PXENVBD_PROTOCOL Protocol ); extern VOID -RingDisconnect( - IN PXENVBD_RING Ring +ProtocolDisconnect( + IN PXENVBD_PROTOCOL Protocol ); extern VOID -RingTrigger( - IN PXENVBD_RING Ring +ProtocolTrigger( + IN PXENVBD_PROTOCOL Protocol ); extern BOOLEAN -RingQueueRequest( - IN PXENVBD_RING Ring, - IN PXENVBD_SRBEXT SrbExt +ProtocolQueueRequest( + IN PXENVBD_PROTOCOL Protocol, + IN PXENVBD_SRBEXT SrbExt ); extern VOID -RingQueueShutdown( - IN PXENVBD_RING Ring, - IN PXENVBD_SRBEXT SrbExt +ProtocolQueueShutdown( + IN PXENVBD_PROTOCOL Protocol, + IN PXENVBD_SRBEXT SrbExt ); -#endif // _XENVBD_RING_H +#endif // _XENVBD_PROTOCOL_H diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c index 54ffb93..f6519e3 100644 --- a/src/xenvbd/target.c +++ b/src/xenvbd/target.c @@ -217,7 +217,7 @@ TargetReadWrite( { PXENVBD_SRBEXT SrbExt = Srb->SrbExtension; PXENVBD_FRONTEND Frontend = Target->Frontend; - PXENVBD_RING Ring = FrontendGetRing(Frontend); + PXENVBD_PROTOCOL Protocol = FrontendGetProtocol(Frontend); ULONG64 SectorCount; ULONG64 SectorStart; ULONG NumSectors; @@ -242,7 +242,7 @@ TargetReadWrite( goto fail4; Srb->SrbStatus = SRB_STATUS_PENDING; - return RingQueueRequest(Ring, SrbExt); + return ProtocolQueueRequest(Protocol, SrbExt); fail4: Error("fail4\n"); @@ -263,7 +263,7 @@ TargetSyncCache( { PXENVBD_SRBEXT SrbExt = Srb->SrbExtension; PXENVBD_FRONTEND Frontend = Target->Frontend; - PXENVBD_RING Ring = FrontendGetRing(Frontend); + PXENVBD_PROTOCOL Protocol = FrontendGetProtocol(Frontend); Srb->SrbStatus = SRB_STATUS_ERROR; if (!FrontendGetConnected(Frontend)) @@ -278,7 +278,7 @@ TargetSyncCache( goto succeed; Srb->SrbStatus = SRB_STATUS_PENDING; - return RingQueueRequest(Ring, SrbExt); + return ProtocolQueueRequest(Protocol, SrbExt); succeed: Srb->SrbStatus = SRB_STATUS_SUCCESS; @@ -299,7 +299,7 @@ TargetUnmap( { PXENVBD_SRBEXT SrbExt = Srb->SrbExtension; PXENVBD_FRONTEND Frontend = Target->Frontend; - PXENVBD_RING Ring = FrontendGetRing(Frontend); + PXENVBD_PROTOCOL Protocol = FrontendGetProtocol(Frontend); Srb->SrbStatus = SRB_STATUS_ERROR; if (!FrontendGetConnected(Frontend)) @@ -312,7 +312,7 @@ TargetUnmap( goto succeed; Srb->SrbStatus = SRB_STATUS_PENDING; - return RingQueueRequest(Ring, SrbExt); + return ProtocolQueueRequest(Protocol, SrbExt); succeed: Srb->SrbStatus = SRB_STATUS_SUCCESS; @@ -980,7 +980,11 @@ TargetFlush( IN PXENVBD_SRBEXT SrbExt ) { - RingQueueShutdown(FrontendGetRing(Target->Frontend), SrbExt); + PXENVBD_PROTOCOL Protocol; + + Protocol = FrontendGetProtocol(Target->Frontend); + ProtocolQueueShutdown(Protocol, + SrbExt); } VOID @@ -989,7 +993,11 @@ TargetShutdown( IN PXENVBD_SRBEXT SrbExt ) { - RingQueueShutdown(FrontendGetRing(Target->Frontend), SrbExt); + PXENVBD_PROTOCOL Protocol; + + Protocol = FrontendGetProtocol(Target->Frontend); + ProtocolQueueShutdown(Protocol, + SrbExt); } VOID diff --git a/vs2015/xenvbd/xenvbd.vcxproj b/vs2015/xenvbd/xenvbd.vcxproj index a85e65b..0939769 100644 --- a/vs2015/xenvbd/xenvbd.vcxproj +++ b/vs2015/xenvbd/xenvbd.vcxproj @@ -72,7 +72,7 @@ <ClCompile Include="../../src/xenvbd/base64.c" /> <ClCompile Include="../../src/xenvbd/queue.c" /> <ClCompile Include="../../src/xenvbd/thread.c" /> - <ClCompile Include="../../src/xenvbd/ring.c" /> + <ClCompile Include="../../src/xenvbd/protocol.c" /> <ClCompile Include="../../src/xenvbd/granter.c" /> </ItemGroup> <ItemGroup> diff --git a/vs2017/xenvbd/xenvbd.vcxproj b/vs2017/xenvbd/xenvbd.vcxproj index 74af5fc..79e7c28 100644 --- a/vs2017/xenvbd/xenvbd.vcxproj +++ b/vs2017/xenvbd/xenvbd.vcxproj @@ -80,7 +80,7 @@ <ClCompile Include="../../src/xenvbd/base64.c" /> <ClCompile Include="../../src/xenvbd/queue.c" /> <ClCompile Include="../../src/xenvbd/thread.c" /> - <ClCompile Include="../../src/xenvbd/ring.c" /> + <ClCompile Include="../../src/xenvbd/protocol.c" /> <ClCompile Include="../../src/xenvbd/granter.c" /> </ItemGroup> <ItemGroup> -- 2.16.2.windows.1 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |