>From a830a195fd89dc2c15c712141fbc7580589e60cb Mon Sep 17 00:00:00 2001 From: Vadim Rozenfeld <vrozenfe@xxxxxxxxxx> Date: Mon, 2 May 2011 15:57:10 +0300 Subject: [COMMIT] [viostor] add preliminary support for indirect buffers --- viostor/virtio_ring.c | 20 +++++--------------- viostor/virtio_stor.h | 10 +++++----- viostor/virtio_stor_hw_helper.c | 24 +----------------------- 3 files changed, 11 insertions(+), 43 deletions(-) diff --git a/viostor/virtio_ring.c b/viostor/virtio_ring.c index 1f1cca3..248ddb1 100644 --- a/viostor/virtio_ring.c +++ b/viostor/virtio_ring.c @@ -56,10 +56,10 @@ vring_add_indirect( struct vring_desc *desc = (struct vring_desc *)va; unsigned head; unsigned int i; - STOR_PHYSICAL_ADDRESS addr; + SCSI_PHYSICAL_ADDRESS addr; ULONG len; - addr = StorPortGetPhysicalAddress(vq->vq.DeviceExtension, NULL, desc, &len); + addr = ScsiPortGetPhysicalAddress(vq->vq.DeviceExtension, NULL, desc, &len); if (!addr.QuadPart) { return vq->vring.num; } @@ -126,8 +126,8 @@ vring_add_buf( vbr = (pblk_req) data; Srb = (PSCSI_REQUEST_BLOCK)vbr->req; srbExt = (PRHEL_SRB_EXTENSION)Srb->SrbExtension; - if (srbExt->addr && (out + in) > 1 && vq->num_free) { - head = vring_add_indirect(vq, sg, out, in, srbExt->addr); + if ((out + in) > 1 && vq->num_free) { + head = vring_add_indirect(vq, sg, out, in, srbExt->desc); if (head != vq->vring.num) goto add_head; } @@ -252,23 +252,13 @@ detach_buf( unsigned int head) { unsigned int i; - PVOID addr; -#if (INDIRECT_SUPPORTED) - STOR_PHYSICAL_ADDRESS pa; -#endif /* Clear data ptr. */ vq->data[head] = NULL; /* Put back on free list: find end */ i = head; -#if (INDIRECT_SUPPORTED) - if (vq->vring.desc[i].flags & VRING_DESC_F_INDIRECT) { - pa.QuadPart = vq->vring.desc[i].addr; - addr = StorPortGetVirtualAddress(vq->vq.DeviceExtension, pa); - StorPortFreePool(vq->vq.DeviceExtension, addr); - } -#endif + while (vq->vring.desc[i].flags & VRING_DESC_F_NEXT) { i = vq->vring.desc[i].next; vq->num_free++; diff --git a/viostor/virtio_stor.h b/viostor/virtio_stor.h index 286769d..86329a1 100644 --- a/viostor/virtio_stor.h +++ b/viostor/virtio_stor.h @@ -117,13 +117,13 @@ typedef struct _ADAPTER_EXTENSION { BOOLEAN msix_enabled; ULONG features; BOOLEAN flush_done; +#ifdef INDIRECT_SUPPORTED + BOOLEAN indirect; +#endif #ifdef USE_STORPORT LIST_ENTRY complete_list; STOR_DPC completion_dpc; BOOLEAN dpc_ok; -#if (INDIRECT_SUPPORTED) - BOOLEAN indirect; -#endif #endif }ADAPTER_EXTENSION, *PADAPTER_EXTENSION; @@ -134,8 +134,8 @@ typedef struct _RHEL_SRB_EXTENSION { #ifndef USE_STORPORT BOOLEAN call_next; #endif -#if (INDIRECT_SUPPORTED) - PVOID addr; +#if INDIRECT_SUPPORTED + struct vring_desc desc[VIRTIO_MAX_SG]; #endif }RHEL_SRB_EXTENSION, *PRHEL_SRB_EXTENSION; diff --git a/viostor/virtio_stor_hw_helper.c b/viostor/virtio_stor_hw_helper.c index 9cf6ded..8eb4324 100644 --- a/viostor/virtio_stor_hw_helper.c +++ b/viostor/virtio_stor_hw_helper.c @@ -157,29 +157,7 @@ BOOLEAN RhelDoReadWrite(PVOID DeviceExtension, PSCSI_REQUEST_BLOCK Srb) { - BOOLEAN res = FALSE; - PRHEL_SRB_EXTENSION srbExt = (PRHEL_SRB_EXTENSION)Srb->SrbExtension; -#if (INDIRECT_SUPPORTED) - NTSTATUS status = STATUS_SUCCESS; - struct vring_desc *desc = NULL; - srbExt->addr = NULL; -#endif - res = StorPortSynchronizeAccess(DeviceExtension, SynchronizedReadWriteRoutine, (PVOID)Srb); -#if (INDIRECT_SUPPORTED) - - if (!res) { - status = StorPortAllocatePool(DeviceExtension, - (srbExt->out + srbExt->in) * sizeof(struct vring_desc), - 'rdnI', (PVOID)&desc); - if (!NT_SUCCESS(status)) { - RhelDbgPrint(TRACE_LEVEL_ERROR, ("%s StorPortAllocatePool failed 0x%x\n", __FUNCTION__, status) ); - return FALSE; - } - srbExt->addr = desc; - res = StorPortSynchronizeAccess(DeviceExtension, SynchronizedReadWriteRoutine, (PVOID)Srb); - } -#endif - return res; + return StorPortSynchronizeAccess(DeviceExtension, SynchronizedReadWriteRoutine, (PVOID)Srb); } #else BOOLEAN -- 1.7.0.2.msysgit.0 -- To unsubscribe from this list: send the line "unsubscribe kvm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html