[PATCH] viostor driver. Xp driver performance.
repository: /home/vadimr/shares/kvm-guest-drivers-windows branch: XP commit 3b2926a281a769499944a23cc3c9b905593e6838 Author: Vadim Rozenfeld Date: Thu Nov 19 09:14:38 2009 +0200 [PATCH] viostor driver. Xp driver performance. Signed-off-by: Vadim Rozenfeld diff --git a/viostor/virtio_stor.c b/viostor/virtio_stor.c index c36b85b..e674dff 100644 --- a/viostor/virtio_stor.c +++ b/viostor/virtio_stor.c @@ -215,6 +215,7 @@ VirtIoFindAdapter( ConfigInfo->Dma32BitAddresses = TRUE; ConfigInfo->Dma64BitAddresses = TRUE; ConfigInfo->WmiDataProvider= FALSE; + #ifdef USE_STORPORT ConfigInfo->MapBuffers = STOR_MAP_NON_READ_WRITE_BUFFERS; ConfigInfo->SynchronizationModel = StorSynchronizeFullDuplex; @@ -286,7 +287,7 @@ VirtIoFindAdapter( if(adaptExt->dump_mode) { ConfigInfo->NumberOfPhysicalBreaks = 8; } else { -ConfigInfo->NumberOfPhysicalBreaks = 16; +ConfigInfo->NumberOfPhysicalBreaks = MAX_PHYS_SEGMENTS-1; } ConfigInfo->MaximumTransferLength = ConfigInfo->NumberOfPhysicalBreaks * PAGE_SIZE; @@ -316,7 +317,6 @@ VirtIoFindAdapter( InitializeListHead(&adaptExt->list_head); InitializeListHead(&adaptExt->complete_list); - return SP_RETURN_FOUND; } @@ -470,9 +470,7 @@ VirtIoStartIo( { PCDB cdb = (PCDB)&Srb->Cdb[0]; -PADAPTER_EXTENSION adaptExt; - -adaptExt = (PADAPTER_EXTENSION)DeviceExtension; +PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension; switch (Srb->Function) { case SRB_FUNCTION_EXECUTE_SCSI: @@ -591,7 +589,6 @@ VirtIoStartIo( return TRUE; } - BOOLEAN VirtIoInterrupt( IN PVOID DeviceExtension @@ -600,12 +597,10 @@ VirtIoInterrupt( pblk_reqvbr; unsigned intlen; unsigned long flags; -PADAPTER_EXTENSION adaptExt; +PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension; BOOLEAN isInterruptServiced = FALSE; PSCSI_REQUEST_BLOCK Srb; -adaptExt = (PADAPTER_EXTENSION)DeviceExtension; - RhelDbgPrint(TRACE_LEVEL_VERBOSE, ("%s (%d)\n", __FUNCTION__, KeGetCurrentIrql())); if (VirtIODeviceISR(DeviceExtension)> 0) { @@ -1019,7 +1014,6 @@ RhelGetLba( PCDB Cdb ) { - EIGHT_BYTE lba; switch (Cdb->CDB6GENERIC.OperationCode) { @@ -1094,7 +1088,7 @@ CompleteDPC( { PSCSI_REQUEST_BLOCK Srb = (PSCSI_REQUEST_BLOCK)vbr->req; PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension; - +PRHEL_SRB_EXTENSION srbExt = (PRHEL_SRB_EXTENSION)Srb->SrbExtension; RemoveEntryList(&vbr->list_entry); #ifdef USE_STORPORT @@ -1106,13 +1100,22 @@ CompleteDPC( NULL); return; } -#endif CompleteSRB(DeviceExtension, Srb); -#ifndef USE_STORPORT ---adaptExt->requests; +#else +ScsiPortNotification(RequestComplete, + DeviceExtension, + Srb); +if(srbExt->call_next) { +ScsiPortNotification(NextLuRequest, + DeviceExtension, + Srb->PathId, + Srb->TargetId, + Srb->Lun); +} #endif } + #ifdef USE_STORPORT VOID CompleteDpcRoutine( diff --git a/viostor/virtio_stor.h b/viostor/virtio_stor.h index c00600c..ac143ea 100644 --- a/viostor/virtio_stor.h +++ b/viostor/virtio_stor.h @@ -52,7 +52,7 @@ typedef struct VirtIOBufferDescriptor VIO_SG, *PVIO_SG; #define VIRTIO_BLK_S_UNSUPP2 #define SECTOR_SIZE 512 -#define MAX_PHYS_SEGMENTS 128 +#define MAX_PHYS_SEGMENTS 17 //128 #define VIRTIO_MAX_SG (3+MAX_PHYS_SEGMENTS) #define IO_PORT_LENGTH 0x40 @@ -105,8 +105,6 @@ typedef struct _ADAPTER_EXTENSION { LIST_ENTRYcomplete_list; #ifdef USE_STORPORT STOR_DPC completion_dpc; -#else -ULONG requests; #endif BOOLEAN has_sn; ULONG msix_vectors; @@ -116,6 +114,10 @@ typedef struct _RHEL_SRB_EXTENSION { blk_req vbr; ULONG out; ULONG in; +PSCSI_REQUEST_BLOCK srb; +#ifndef USE_STORPORT +BOOLEAN call_next; +#endif }RHEL_SRB_EXTENSION, *PRHEL_SRB_EXTENSION; ULONGLONG diff --git a/viostor/virtio_stor.c b/viostor/virtio_stor.c index c36b85b..e674dff 100644 --- a/viostor/virtio_stor.c +++ b/viostor/virtio_stor.c @@ -215,6 +215,7 @@ VirtIoFindAdapter( ConfigInfo->Dma32BitAddresses = TRUE; ConfigInfo->Dma64BitAddresses = TRUE; ConfigInfo->WmiDataProvider= FALSE; + #ifdef USE_STORPORT ConfigInfo->MapBuffers = STOR_MAP_NON_READ_WRITE_BUFFERS; ConfigInfo->SynchronizationModel = StorSynchronizeFullDuplex; @@ -286,7 +287
[PATCH] viostor driver. XP driver performance improvement.
repository: /home/vadimr/shares/kvm-guest-drivers-windows branch: XP commit e58183a0df0fd398e31e3f079b6c301520b2a5a2 Author: Vadim Rozenfeld Date: Sun Nov 15 22:50:55 2009 +0200 [PATCH] viostor driver. XP driver performance improvement. Signed-off-by: Vadim Rozenfeld diff --git a/viostor/virtio_ring.c b/viostor/virtio_ring.c index 2911cef..de69557 100644 --- a/viostor/virtio_ring.c +++ b/viostor/virtio_ring.c @@ -39,7 +39,6 @@ initialize_virtqueue( IN VOID (*notify)(struct virtqueue *)); -//#define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq) #define to_vvq(_vq) (struct vring_virtqueue *)_vq static @@ -119,7 +118,7 @@ vring_add_buf( RhelDbgPrint(TRACE_LEVEL_VERBOSE, ("%s: Added buffer head %i to %p\n", __FUNCTION__, head, vq) ); -return 0; +return vq->num_free; } static diff --git a/viostor/virtio_stor_hw_helper.c b/viostor/virtio_stor_hw_helper.c index 21d27cd..2e61b30 100644 --- a/viostor/virtio_stor_hw_helper.c +++ b/viostor/virtio_stor_hw_helper.c @@ -54,6 +54,8 @@ RhelDoReadWrite(PVOID DeviceExtension, PVOID DataBuffer; PADAPTER_EXTENSIONadaptExt; PRHEL_SRB_EXTENSION srbExt; +int num_free; + cdb = (PCDB)&Srb->Cdb[0]; srbExt = (PRHEL_SRB_EXTENSION)Srb->SrbExtension; adaptExt = (PADAPTER_EXTENSION)DeviceExtension; @@ -88,20 +90,21 @@ RhelDoReadWrite(PVOID DeviceExtension, srbExt->vbr.sg[sgElement].physAddr = ScsiPortGetPhysicalAddress(DeviceExtension, NULL,&srbExt->vbr.status,&fragLen); srbExt->vbr.sg[sgElement].ulSize = sizeof(srbExt->vbr.status); - - -if (adaptExt->pci_vq_info.vq->vq_ops->add_buf(adaptExt->pci_vq_info.vq, +num_free = adaptExt->pci_vq_info.vq->vq_ops->add_buf(adaptExt->pci_vq_info.vq, &srbExt->vbr.sg[0], srbExt->out, srbExt->in, -&srbExt->vbr) == 0) { +&srbExt->vbr); +if ( num_free>= 0) { InsertTailList(&adaptExt->list_head,&srbExt->vbr.list_entry); adaptExt->pci_vq_info.vq->vq_ops->kick(adaptExt->pci_vq_info.vq); -if(++adaptExt->requests< adaptExt->queue_depth) { +srbExt->call_next = FALSE; +if(num_free< VIRTIO_MAX_SG) { + srbExt->call_next = TRUE; +} else { ScsiPortNotification(NextLuRequest, DeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun); } -return TRUE; } -return FALSE; +return TRUE; } #endif diff --git a/viostor/virtio_ring.c b/viostor/virtio_ring.c index 2911cef..de69557 100644 --- a/viostor/virtio_ring.c +++ b/viostor/virtio_ring.c @@ -39,7 +39,6 @@ initialize_virtqueue( IN VOID (*notify)(struct virtqueue *)); -//#define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq) #define to_vvq(_vq) (struct vring_virtqueue *)_vq static @@ -119,7 +118,7 @@ vring_add_buf( RhelDbgPrint(TRACE_LEVEL_VERBOSE, ("%s: Added buffer head %i to %p\n", __FUNCTION__, head, vq) ); -return 0; +return vq->num_free; } static diff --git a/viostor/virtio_stor_hw_helper.c b/viostor/virtio_stor_hw_helper.c index 21d27cd..2e61b30 100644 --- a/viostor/virtio_stor_hw_helper.c +++ b/viostor/virtio_stor_hw_helper.c @@ -54,6 +54,8 @@ RhelDoReadWrite(PVOID DeviceExtension, PVOID DataBuffer; PADAPTER_EXTENSIONadaptExt; PRHEL_SRB_EXTENSION srbExt; +int num_free; + cdb = (PCDB)&Srb->Cdb[0]; srbExt = (PRHEL_SRB_EXTENSION)Srb->SrbExtension; adaptExt = (PADAPTER_EXTENSION)DeviceExtension; @@ -88,20 +90,21 @@ RhelDoReadWrite(PVOID DeviceExtension, srbExt->vbr.sg[sgElement].physAddr = ScsiPortGetPhysicalAddress(DeviceExtension, NULL, &srbExt->vbr.status, &fragLen); srbExt->vbr.sg[sgElement].ulSize = sizeof(srbExt->vbr.status); - - -if (adaptExt->pci_vq_info.vq->vq_ops->add_buf(adaptExt->pci_vq_info.vq, +num_free = adaptExt->pci_vq_info.vq->vq_ops->add_buf(adaptExt->pci_vq_info.vq, &srbExt->vbr.sg[0], srbExt->out, srbExt->in, - &srbExt->vbr) == 0) { + &srbExt->vbr); +if ( num_free >= 0) { InsertTailList(&adaptExt->list_head, &srbExt->vbr.list_entry); adaptExt->pci_vq_info.vq->vq_ops->kick(adaptExt->pci_vq_info.vq); -if(++adaptExt->requests < adaptExt->queue_depth) { +srbExt->call_next = FALSE; +if(num_free < VIRTIO_MAX_SG) { + srbExt->call_next = TRUE; +} else { ScsiPortNotification(NextLuRequest, DeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun); } -return TRUE; } -return FALSE; +return TRUE; } #endif