[PATCH] viostor driver. switch to full-duplex mode.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





repository: /home/vadimr/shares/kvm-guest-drivers-windows
branch: master
commit ed4b9ade27b56e9ee37461c2cf72e46d75633e9c
Author: Vadim Rozenfeld<vrozenfe@xxxxxxxxxx>
Date:   Wed Sep 23 11:28:48 2009 +0300

    [PATCH] viostor driver. switch to full-duplex mode.

    Signed-off-by: Vadim Rozenfeld<vrozenfe@xxxxxxxxxx>

diff --git a/viostor/virtio_stor.c b/viostor/virtio_stor.c
index e4acaa0..297949a 100644
--- a/viostor/virtio_stor.c
+++ b/viostor/virtio_stor.c
@@ -194,6 +194,7 @@ VirtIoFindAdapter(
     ConfigInfo->WmiDataProvider        = FALSE;
 #ifdef USE_STORPORT
     ConfigInfo->MapBuffers             = STOR_MAP_NON_READ_WRITE_BUFFERS;
+    ConfigInfo->SynchronizationModel   = StorSynchronizeFullDuplex;
 #else
     ConfigInfo->MapBuffers             = TRUE;
 #endif
@@ -323,6 +324,8 @@ VirtIoFindAdapter(
         return SP_RETURN_ERROR;
     }

+    InitializeListHead(&adaptExt->list_head);
+
     return SP_RETURN_FOUND;
 }

@@ -488,7 +491,7 @@ VirtIoStartIo(
         case SCSIOP_WRITE: {
             Srb->SrbStatus = SRB_STATUS_PENDING;
             if(!RhelDoReadWrite(DeviceExtension, Srb)) {
-                Srb->SrbStatus = SRB_STATUS_ABORTED;
+                Srb->SrbStatus = SRB_STATUS_BUSY;
                 CompleteSRB(DeviceExtension, Srb);
             }
             return TRUE;
@@ -561,7 +564,7 @@ VirtIoInterrupt(
                 Srb->SrbStatus = SRB_STATUS_ERROR;
                 break;
            }
-
+           RemoveEntryList(&vbr->list_entry);
            CompleteSRB(DeviceExtension, Srb);
         }
     }
diff --git a/viostor/virtio_stor.h b/viostor/virtio_stor.h
index 1c0dbb6..2d98738 100644
--- a/viostor/virtio_stor.h
+++ b/viostor/virtio_stor.h
@@ -78,12 +78,8 @@ typedef struct virtio_blk_outhdr {
     u64 sector;
 }blk_outhdr, *pblk_outhdr;

-struct list_head {
-    struct list_head *next, *prev;
-};
-
 typedef struct virtio_blk_req {
-    struct list_head list;
+    LIST_ENTRY list_entry;
     struct request *req;
     blk_outhdr out_hdr;
     u8     status;
@@ -98,6 +94,7 @@ typedef struct _ADAPTER_EXTENSION {
     blk_config            info;
     ULONG                 queue_depth;
     BOOLEAN               dump_mode;
+    LIST_ENTRY            list_head;
 }ADAPTER_EXTENSION, *PADAPTER_EXTENSION;

 typedef struct _RHEL_SRB_EXTENSION {
diff --git a/viostor/virtio_stor_hw_helper.c b/viostor/virtio_stor_hw_helper.c
index 43bde5a..3c09259 100644
--- a/viostor/virtio_stor_hw_helper.c
+++ b/viostor/virtio_stor_hw_helper.c
@@ -15,22 +15,33 @@
 #include "virtio_stor_hw_helper.h"

 #ifdef USE_STORPORT
-BOOLEAN
-RhelDoReadWrite(PVOID DeviceExtension,
-                PSCSI_REQUEST_BLOCK Srb)
+BOOLEAN
+SynchronizedAccessRoutine(
+    IN PVOID DeviceExtension,
+    IN PVOID Context
+    )
 {
     PADAPTER_EXTENSION  adaptExt = (PADAPTER_EXTENSION)DeviceExtension;
+    PSCSI_REQUEST_BLOCK Srb      = (PSCSI_REQUEST_BLOCK) Context;
     PRHEL_SRB_EXTENSION srbExt   = (PRHEL_SRB_EXTENSION)Srb->SrbExtension;
-
     if (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.sg[0],
+                     srbExt->out, srbExt->in,
+&srbExt->vbr) == 0){
+        InsertTailList(&adaptExt->list_head,&srbExt->vbr.list_entry);
         adaptExt->pci_vq_info.vq->vq_ops->kick(adaptExt->pci_vq_info.vq);
         return TRUE;
     }
+    StorPortBusy(DeviceExtension, 10);
     return FALSE;
 }
+
+BOOLEAN
+RhelDoReadWrite(PVOID DeviceExtension,
+                PSCSI_REQUEST_BLOCK Srb)
+{
+    return StorPortSynchronizeAccess(DeviceExtension,SynchronizedAccessRoutine, (PVOID)Srb);
+}
 #else
 BOOLEAN
 RhelDoReadWrite(PVOID DeviceExtension,
@@ -83,6 +94,8 @@ RhelDoReadWrite(PVOID DeviceExtension,
                                       &srbExt->vbr.sg[0],
                                       srbExt->out, srbExt->in,
                                       &srbExt->vbr) == 0) {
+//FIXME
+        InsertTailList(&adaptExt->list_head,&srbExt->vbr.list_entry);
         adaptExt->pci_vq_info.vq->vq_ops->kick(adaptExt->pci_vq_info.vq);
         return TRUE;
     }

diff --git a/viostor/virtio_stor.c b/viostor/virtio_stor.c
index e4acaa0..297949a 100644
--- a/viostor/virtio_stor.c
+++ b/viostor/virtio_stor.c
@@ -194,6 +194,7 @@ VirtIoFindAdapter(
     ConfigInfo->WmiDataProvider        = FALSE;
 #ifdef USE_STORPORT
     ConfigInfo->MapBuffers             = STOR_MAP_NON_READ_WRITE_BUFFERS;
+    ConfigInfo->SynchronizationModel   = StorSynchronizeFullDuplex;
 #else
     ConfigInfo->MapBuffers             = TRUE;
 #endif
@@ -323,6 +324,8 @@ VirtIoFindAdapter(
         return SP_RETURN_ERROR;
     }
 
+    InitializeListHead(&adaptExt->list_head);
+
     return SP_RETURN_FOUND;
 }
 
@@ -488,7 +491,7 @@ VirtIoStartIo(
         case SCSIOP_WRITE: {
             Srb->SrbStatus = SRB_STATUS_PENDING;
             if(!RhelDoReadWrite(DeviceExtension, Srb)) {
-                Srb->SrbStatus = SRB_STATUS_ABORTED;
+                Srb->SrbStatus = SRB_STATUS_BUSY;
                 CompleteSRB(DeviceExtension, Srb);
             }
             return TRUE;
@@ -561,7 +564,7 @@ VirtIoInterrupt(
                 Srb->SrbStatus = SRB_STATUS_ERROR;
                 break;
            }
-
+           RemoveEntryList(&vbr->list_entry);
            CompleteSRB(DeviceExtension, Srb);
         }
     }
diff --git a/viostor/virtio_stor.h b/viostor/virtio_stor.h
index 1c0dbb6..2d98738 100644
--- a/viostor/virtio_stor.h
+++ b/viostor/virtio_stor.h
@@ -78,12 +78,8 @@ typedef struct virtio_blk_outhdr {
     u64 sector;
 }blk_outhdr, *pblk_outhdr;
 
-struct list_head {
-    struct list_head *next, *prev;
-};
-
 typedef struct virtio_blk_req {
-    struct list_head list;
+    LIST_ENTRY list_entry;
     struct request *req;
     blk_outhdr out_hdr;
     u8     status;
@@ -98,6 +94,7 @@ typedef struct _ADAPTER_EXTENSION {
     blk_config            info;
     ULONG                 queue_depth;
     BOOLEAN               dump_mode;
+    LIST_ENTRY            list_head;
 }ADAPTER_EXTENSION, *PADAPTER_EXTENSION;
 
 typedef struct _RHEL_SRB_EXTENSION {
diff --git a/viostor/virtio_stor_hw_helper.c b/viostor/virtio_stor_hw_helper.c
index 43bde5a..3c09259 100644
--- a/viostor/virtio_stor_hw_helper.c
+++ b/viostor/virtio_stor_hw_helper.c
@@ -15,22 +15,33 @@
 #include "virtio_stor_hw_helper.h"
 
 #ifdef USE_STORPORT
-BOOLEAN 
-RhelDoReadWrite(PVOID DeviceExtension,
-                PSCSI_REQUEST_BLOCK Srb)
+BOOLEAN
+SynchronizedAccessRoutine(
+    IN PVOID DeviceExtension,
+    IN PVOID Context
+    )
 {
     PADAPTER_EXTENSION  adaptExt = (PADAPTER_EXTENSION)DeviceExtension;
+    PSCSI_REQUEST_BLOCK Srb      = (PSCSI_REQUEST_BLOCK) Context;
     PRHEL_SRB_EXTENSION srbExt   = (PRHEL_SRB_EXTENSION)Srb->SrbExtension;
-
     if (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.sg[0],
+                     srbExt->out, srbExt->in, 
+                     &srbExt->vbr) == 0){ 
+        InsertTailList(&adaptExt->list_head, &srbExt->vbr.list_entry);
         adaptExt->pci_vq_info.vq->vq_ops->kick(adaptExt->pci_vq_info.vq);
         return TRUE;
     }
+    StorPortBusy(DeviceExtension, 10);  
     return FALSE;
 }
+
+BOOLEAN 
+RhelDoReadWrite(PVOID DeviceExtension,
+                PSCSI_REQUEST_BLOCK Srb)
+{
+    return StorPortSynchronizeAccess(DeviceExtension,SynchronizedAccessRoutine, (PVOID)Srb);
+}
 #else
 BOOLEAN 
 RhelDoReadWrite(PVOID DeviceExtension,
@@ -83,6 +94,8 @@ RhelDoReadWrite(PVOID DeviceExtension,
                                       &srbExt->vbr.sg[0],
                                       srbExt->out, srbExt->in, 
                                       &srbExt->vbr) == 0) {
+//FIXME
+        InsertTailList(&adaptExt->list_head, &srbExt->vbr.list_entry);
         adaptExt->pci_vq_info.vq->vq_ops->kick(adaptExt->pci_vq_info.vq);
         return TRUE;
     }

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux