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

[win-pv-devel] [PATCH 02/10] Move StorPort*() calls to adapter.c



From: Owen Smith <owen.smith@xxxxxxxxxx>

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenvbd/adapter.c | 38 ++++++++++++++++++++++++++++++++------
 src/xenvbd/adapter.h | 11 +++++++++++
 src/xenvbd/target.c  | 19 ++++++-------------
 3 files changed, 49 insertions(+), 19 deletions(-)

diff --git a/src/xenvbd/adapter.c b/src/xenvbd/adapter.c
index 2e85f9f..ec6711a 100644
--- a/src/xenvbd/adapter.c
+++ b/src/xenvbd/adapter.c
@@ -58,7 +58,8 @@
 #include "debug.h"
 #include "assert.h"
 
-#define MAXNAMELEN  128
+#define XENVBD_MAX_QUEUE_DEPTH  254
+#define MAXNAMELEN              128
 #define ADAPTER_POOL_TAG        'adAX'
 
 struct _XENVBD_ADAPTER {
@@ -498,9 +499,7 @@ __AdapterEnumerate(
     }
 
     if (NeedInvalidate)
-        StorPortNotification(BusChangeDetected,
-                             Adapter,
-                             NULL);
+        AdapterTargetListChanged(Adapter);
     if (NeedReboot)
         DriverRequestReboot();
 }
@@ -1408,6 +1407,31 @@ AdapterCompleteSrb(
     StorPortNotification(RequestComplete, Adapter, Srb);
 }
 
+VOID
+AdapterTargetListChanged(
+    IN  PXENVBD_ADAPTER Adapter
+    )
+{
+    StorPortNotification(BusChangeDetected,
+                         Adapter,
+                         NULL);
+}
+
+VOID
+AdapterSetDeviceQueueDepth(
+    IN  PXENVBD_ADAPTER Adapter,
+    IN  ULONG           TargetId
+    )
+{
+    if (!StorPortSetDeviceQueueDepth(Adapter,
+                                     0,
+                                     (UCHAR)TargetId,
+                                     0,
+                                     XENVBD_MAX_QUEUE_DEPTH))
+        Verbose("Target[%d] : Failed to set queue depth\n",
+                TargetId);
+}
+
 static VOID
 AdapterUnplugRequest(
     IN  PXENVBD_ADAPTER Adapter,
@@ -1713,15 +1737,16 @@ AdapterHwBuildIo(
         Srb->SrbStatus = SRB_STATUS_ABORT_FAILED;
         break;
     case SRB_FUNCTION_RESET_BUS:
-        Srb->SrbStatus = SRB_STATUS_SUCCESS;
         AdapterHwResetBus(Adapter, Srb->PathId);
+        Srb->SrbStatus = SRB_STATUS_SUCCESS;
         break;
 
     default:
+        Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
         break;
     }
 
-    StorPortNotification(RequestComplete, Adapter, Srb);
+    AdapterCompleteSrb(Adapter, Srb);
     return FALSE;
 }
 
@@ -1747,6 +1772,7 @@ AdapterHwStartIo(
     return TRUE;
 
 fail1:
+    Srb->SrbStatus = SRB_STATUS_INVALID_TARGET_ID;
     AdapterCompleteSrb(Adapter, Srb);
     return TRUE;
 }
diff --git a/src/xenvbd/adapter.h b/src/xenvbd/adapter.h
index 5dd2e62..b8706fd 100644
--- a/src/xenvbd/adapter.h
+++ b/src/xenvbd/adapter.h
@@ -70,6 +70,17 @@ AdapterCompleteSrb(
     IN  PSCSI_REQUEST_BLOCK Srb
     );
 
+extern VOID
+AdapterTargetListChanged(
+    IN  PXENVBD_ADAPTER Adapter
+    );
+
+extern VOID
+AdapterSetDeviceQueueDepth(
+    IN  PXENVBD_ADAPTER Adapter,
+    IN  ULONG           TargetId
+    );
+
 extern NTSTATUS
 AdapterDispatchPnp(
     IN  PXENVBD_ADAPTER Adapter,
diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index c5dffa9..5bab440 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -49,8 +49,6 @@
 #include <suspend_interface.h>
 #include <stdlib.h>
 
-#define XENVBD_MAX_QUEUE_DEPTH          (254)
-
 typedef struct _XENVBD_SG_LIST {
     // SGList from SRB
     PSTOR_SCATTER_GATHER_LIST   SGList;
@@ -2021,13 +2019,8 @@ __TargetExecuteScsi(
         break;
 
     case SCSIOP_INQUIRY:
-        if (!StorPortSetDeviceQueueDepth(TargetGetAdapter(Target),
-                                         0,
-                                         (UCHAR)TargetGetTargetId(Target),
-                                         0,
-                                         XENVBD_MAX_QUEUE_DEPTH))
-            Verbose("Target[%d] : Failed to set queue depth\n",
-                    TargetGetTargetId(Target));
+        AdapterSetDeviceQueueDepth(TargetGetAdapter(Target),
+                                   TargetGetTargetId(Target));
         PdoInquiry(TargetGetTargetId(Target), 
FrontendGetInquiry(Target->Frontend), Srb);
         break;
     case SCSIOP_MODE_SENSE:
@@ -2305,13 +2298,13 @@ __TargetRemoveDevice(
     case SurpriseRemovePending:
         TargetSetMissing(Target, "Surprise Remove");
         TargetSetDevicePnpState(Target, Deleted);
-        StorPortNotification(BusChangeDetected, TargetGetAdapter(Target), 0);
+        AdapterTargetListChanged(TargetGetAdapter(Target));
         break;
 
     default:
         TargetSetMissing(Target, "Removed");
         TargetSetDevicePnpState(Target, Deleted);
-        StorPortNotification(BusChangeDetected, TargetGetAdapter(Target), 0);
+        AdapterTargetListChanged(TargetGetAdapter(Target));
         break;
     }
 }
@@ -2323,7 +2316,7 @@ __TargetEject(
 {
     TargetSetMissing(Target, "Ejected");
     TargetSetDevicePnpState(Target, Deleted);
-    StorPortNotification(BusChangeDetected, TargetGetAdapter(Target), 0);
+    AdapterTargetListChanged(TargetGetAdapter(Target));
 }
 
 __checkReturn
@@ -2417,7 +2410,7 @@ TargetIssueDeviceEject(
         IoRequestDeviceEject(Target->DeviceObject);
     } else {
         Verbose("Target[%d] : Triggering BusChangeDetected to detect 
device\n", TargetGetTargetId(Target));
-        StorPortNotification(BusChangeDetected, TargetGetAdapter(Target), 0);
+        AdapterTargetListChanged(TargetGetAdapter(Target));
     }
 }
 
-- 
2.8.3


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.