DrvSCSI.cpp revision 4eb7f6613b45a75ffafc1f5f0f05f942ad36d727
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * VBox storage drivers: Generic SCSI command parser and execution driver
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2006-2012 Oracle Corporation
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * available from http://www.virtualbox.org. This file is free software;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * you can redistribute it and/or modify it under the terms of the GNU
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * General Public License (GPL) as published by the Free Software
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/*******************************************************************************
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync* Header Files *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync*******************************************************************************/
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync//#define DEBUG
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync/** The maximum number of release log entries per device. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * SCSI driver instance data.
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements PDMISCSICONNECTOR
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements PDMIBLOCKASYNCPORT
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements PDMIMOUNTNOTIFY
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsynctypedef struct DRVSCSI
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer driver instance. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the attached driver's base interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the attached driver's block interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the attached driver's async block interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the attached driver's block bios interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the attached driver's mount interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the SCSI port interface of the device above. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** pointer to the Led port interface of the dveice above. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The scsi connector interface .*/
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The block port interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The optional block async port interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The mount notify interface. */
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync /** Fallback status LED state for this drive.
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * This is used in case the device doesn't has a LED interface. */
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync /** Pointer to the status LED for this drive. */
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /** VSCSI device handle. */
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /** VSCSI LUN handle. */
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /** I/O callbacks. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The dedicated I/O thread for the non async approach. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Queue for passing the requests to the thread. */
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync /** Request that we've left pending on wakeup or reset. */
0c4004948fca34f2db87e7b38013137e9472c306vboxsync /** Indicates whether PDMDrvHlpAsyncNotificationCompleted should be called by
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * any of the dummy functions. */
0c4004948fca34f2db87e7b38013137e9472c306vboxsync bool volatile fDummySignal;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Release statistics: number of bytes written. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Release statistics: number of bytes read. */
44a2ecaf2d0fc196ab76cab13b3f909299e386d1vboxsync /** Release statistics: Current I/O depth. */
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync /** Errors printed in the release log. */
65697a26b524640b83828b715160c798c43a0424vboxsync /** Mark the drive as having a non-rotational medium (i.e. as a SSD). */
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync /** Medium is readonly */
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync/** Converts a pointer to DRVSCSI::ISCSIConnector to a PDRVSCSI. */
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync#define PDMISCSICONNECTOR_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, ISCSIConnector)) )
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync/** Converts a pointer to DRVSCSI::IPortAsync to a PDRVSCSI. */
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync#define PDMIBLOCKASYNCPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPortAsync)) )
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync/** Converts a pointer to DRVSCSI::IMountNotify to PDRVSCSI. */
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync#define PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IMountNotify)) )
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync/** Converts a pointer to DRVSCSI::IPort to a PDRVSCSI. */
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync#define PDMIBLOCKPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPort)) )
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync return true;
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync return false;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsyncstatic int drvscsiProcessRequestOne(PDRVSCSI pThis, VSCSIIOREQ hVScsiIoReq)
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync unsigned cSeg = 0;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIIoReqParamsGet(hVScsiIoReq, &uOffset, &cbTransfer, &cSeg, &cbSeg,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync size_t cbProcess = (cbTransfer < paSeg->cbSeg) ? cbTransfer : paSeg->cbSeg;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync Log(("%s: uOffset=%llu cbProcess=%u\n", __FUNCTION__, uOffset, cbProcess));
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Asserted.s.fReading = pThis->pLed->Actual.s.fReading = 1;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = pThis->pDrvBlock->pfnRead(pThis->pDrvBlock, uOffset,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync STAM_REL_COUNTER_ADD(&pThis->StatBytesRead, cbProcess);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = pThis->pDrvBlock->pfnWrite(pThis->pDrvBlock, uOffset,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync STAM_REL_COUNTER_ADD(&pThis->StatBytesWritten, cbProcess);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /* Go to the next entry. */
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync LogRel(("SCSI#%u: %s at offset %llu (%u bytes left) returned rc=%Rrc\n",
65697a26b524640b83828b715160c798c43a0424vboxsync rc = VSCSIIoReqUnmapParamsGet(hVScsiIoReq, &paRanges, &cRanges);
65697a26b524640b83828b715160c798c43a0424vboxsync pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync rc = pThis->pDrvBlock->pfnDiscard(pThis->pDrvBlock, paRanges, cRanges);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertMsgFailed(("Invalid transfer direction %d\n", enmTxDir));
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, rc, false /* fRedoPossible */);
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, rc, drvscsiIsRedoPossible(rc));
65697a26b524640b83828b715160c798c43a0424vboxsyncstatic DECLCALLBACK(int) drvscsiGetSize(VSCSILUN hVScsiLun, void *pvScsiLunUser, uint64_t *pcbSize)
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync *pcbSize = pThis->pDrvBlock->pfnGetSize(pThis->pDrvBlock);
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsyncstatic DECLCALLBACK(int) drvscsiGetSectorSize(VSCSILUN hVScsiLun, void *pvScsiLunUser, uint32_t *pcbSectorSize)
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync *pcbSectorSize = pThis->pDrvBlock->pfnGetSectorSize(pThis->pDrvBlock);
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsyncstatic DECLCALLBACK(int) drvscsiSetLock(VSCSILUN hVScsiLun, void *pvScsiLunUser, bool fLocked)
f687f34bd232be13744edbc0cc5155fa5d4540edvboxsyncstatic int drvscsiTransferCompleteNotify(PPDMIBLOCKASYNCPORT pInterface, void *pvUser, int rc)
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync PDRVSCSI pThis = PDMIBLOCKASYNCPORT_2_DRVSCSI(pInterface);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync VSCSIIOREQTXDIR enmTxDir = VSCSIIoReqTxDirGet(hVScsiIoReq);
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync LogFlowFunc(("Request hVScsiIoReq=%#p completed\n", hVScsiIoReq));
ead016c68c61b5f2e1fe4d237054eebea9327d4bvboxsync AssertMsg(enmTxDir == VSCSIIOREQTXDIR_FLUSH, ("Invalid transfer direction %u\n", enmTxDir));
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, rc, false /* fRedoPossible */);
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync unsigned cSeg = 0;
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync VSCSIIoReqParamsGet(hVScsiIoReq, &uOffset, &cbTransfer,
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync LogRel(("SCSI#%u: %s at offset %llu (%u bytes left) returned rc=%Rrc\n",
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, rc, drvscsiIsRedoPossible(rc));
65697a26b524640b83828b715160c798c43a0424vboxsyncstatic DECLCALLBACK(int) drvscsiReqTransferEnqueue(VSCSILUN hVScsiLun,
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync /* async I/O path. */
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync LogFlowFunc(("Enqueuing hVScsiIoReq=%#p\n", hVScsiIoReq));
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync rc = pThis->pDrvBlockAsync->pfnStartFlush(pThis->pDrvBlockAsync, hVScsiIoReq);
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync rc = VSCSIIoReqUnmapParamsGet(hVScsiIoReq, &paRanges, &cRanges);
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync rc = pThis->pDrvBlockAsync->pfnStartDiscard(pThis->pDrvBlockAsync, paRanges, cRanges, hVScsiIoReq);
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync unsigned cSeg = 0;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIIoReqParamsGet(hVScsiIoReq, &uOffset, &cbTransfer,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Asserted.s.fReading = pThis->pLed->Actual.s.fReading = 1;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = pThis->pDrvBlockAsync->pfnStartRead(pThis->pDrvBlockAsync, uOffset,
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync STAM_REL_COUNTER_ADD(&pThis->StatBytesRead, cbTransfer);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = pThis->pDrvBlockAsync->pfnStartWrite(pThis->pDrvBlockAsync, uOffset,
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync STAM_REL_COUNTER_ADD(&pThis->StatBytesWritten, cbTransfer);
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync LogRel(("SCSI#%u: %s at offset %llu (%u bytes left) returned rc=%Rrc\n",
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertMsgFailed(("Invalid transfer direction %u\n", enmTxDir));
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync AssertMsg(enmTxDir == VSCSIIOREQTXDIR_FLUSH, ("Invalid transfer direction %u\n", enmTxDir));
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, VINF_SUCCESS, false);
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync AssertMsg(enmTxDir == VSCSIIOREQTXDIR_FLUSH, ("Invalid transfer direction %u\n", enmTxDir));
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, rc, drvscsiIsRedoPossible(rc));
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync AssertMsgFailed(("Invalid return code rc=%Rrc\n", rc));
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /* I/O thread. */
36411046d85fccaa66061120a064225fd1b5ae01vboxsync rc = RTReqQueueCallEx(pThis->hQueueRequests, NULL, 0, RTREQFLAGS_NO_WAIT,
36411046d85fccaa66061120a064225fd1b5ae01vboxsync (PFNRT)drvscsiProcessRequestOne, 2, pThis, hVScsiIoReq);
65697a26b524640b83828b715160c798c43a0424vboxsyncstatic DECLCALLBACK(int) drvscsiGetFeatureFlags(VSCSILUN hVScsiLun,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsyncstatic void drvscsiVScsiReqCompleted(VSCSIDEVICE hVScsiDevice, void *pVScsiDeviceUser,
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync void *pVScsiReqUser, int rcScsiCode, bool fRedoPossible,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pDevScsiPort->pfnSCSIRequestCompleted(pThis->pDevScsiPort, (PPDMSCSIREQUEST)pVScsiReqUser,
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (RT_UNLIKELY(pThis->fDummySignal) && !pThis->StatIoDepth)
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync PDMDrvHlpAsyncNotificationCompleted(pThis->pDrvIns);
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * Dummy request function used by drvscsiReset to wait for all pending requests
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * to complete prior to the device reset.
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * @param pThis Pointer to the instance data.
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync * @returns VINF_SUCCESS.
0c4004948fca34f2db87e7b38013137e9472c306vboxsyncstatic int drvscsiAsyncIOLoopSyncCallback(PDRVSCSI pThis)
0c4004948fca34f2db87e7b38013137e9472c306vboxsync PDMDrvHlpAsyncNotificationCompleted(pThis->pDrvIns);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Request function to wakeup the thread.
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * @param pThis Pointer to the instance data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns VWRN_STATE_CHANGED.
0c4004948fca34f2db87e7b38013137e9472c306vboxsyncstatic int drvscsiAsyncIOLoopWakeupFunc(PDRVSCSI pThis)
0c4004948fca34f2db87e7b38013137e9472c306vboxsync PDMDrvHlpAsyncNotificationCompleted(pThis->pDrvIns);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The thread function which processes the requests asynchronously.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns VBox status code.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pDrvIns Pointer to the driver instance data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pThread Pointer to the thread instance data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic int drvscsiAsyncIOLoop(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync while (pThread->enmState == PDMTHREADSTATE_RUNNING)
36411046d85fccaa66061120a064225fd1b5ae01vboxsync rc = RTReqQueueProcess(pThis->hQueueRequests, RT_INDEFINITE_WAIT);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsg(rc == VWRN_STATE_CHANGED, ("Left RTReqProcess and error code is not VWRN_STATE_CHANGED rc=%Rrc\n", rc));
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * Deals with any pending dummy request
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * @returns true if no pending dummy request, false if still pending.
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * @param pThis The instance data.
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * @param cMillies The number of milliseconds to wait for any
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * pending request to finish.
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsyncstatic bool drvscsiAsyncIOLoopNoPendingDummy(PDRVSCSI pThis, uint32_t cMillies)
8a339f91959bb7a3315b51a23461b68c7b0cb50evboxsync return true;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync int rc = RTReqWait(pThis->pPendingDummyReq, cMillies);
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync return false;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync return true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic int drvscsiAsyncIOLoopWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
36411046d85fccaa66061120a064225fd1b5ae01vboxsync AssertMsgReturn(pThis->hQueueRequests != NIL_RTREQQUEUE, ("hQueueRequests is NULL\n"), VERR_INVALID_STATE);
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 10000 /* 10 sec */))
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync LogRel(("drvscsiAsyncIOLoopWakeup#%u: previous dummy request is still pending\n", pDrvIns->iInstance));
36411046d85fccaa66061120a064225fd1b5ae01vboxsync rc = RTReqQueueCall(pThis->hQueueRequests, &pReq, 10000 /* 10 sec. */, (PFNRT)drvscsiAsyncIOLoopWakeupFunc, 1, pThis);
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync LogRel(("drvscsiAsyncIOLoopWakeup#%u: %Rrc pReq=%p\n", pDrvIns->iInstance, rc, pReq));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/* -=-=-=-=- ISCSIConnector -=-=-=-=- */
b0db50948c349fa76655abf252f7946b515e8204vboxsync * Dumps a SCSI request structure for debugging purposes.
b0db50948c349fa76655abf252f7946b515e8204vboxsync * @returns nothing.
b0db50948c349fa76655abf252f7946b515e8204vboxsync * @param pRequest Pointer to the request to dump.
b0db50948c349fa76655abf252f7946b515e8204vboxsyncstatic void drvscsiDumpScsiRequest(PPDMSCSIREQUEST pRequest)
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("Dump for pRequest=%#p Command: %s\n", pRequest, SCSICmdText(pRequest->pbCDB[0])));
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("cbScatterGather=%u\n", pRequest->cbScatterGather));
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("cScatterGatherEntries=%u\n", pRequest->cScatterGatherEntries));
b0db50948c349fa76655abf252f7946b515e8204vboxsync /* Print all scatter gather entries. */
b0db50948c349fa76655abf252f7946b515e8204vboxsync for (uint32_t i = 0; i < pRequest->cScatterGatherEntries; i++)
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("ScatterGatherEntry[%u].cbSeg=%u\n", i, pRequest->paScatterGatherHead[i].cbSeg));
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("ScatterGatherEntry[%u].pvSeg=%#p\n", i, pRequest->paScatterGatherHead[i].pvSeg));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/** @copydoc PDMISCSICONNECTOR::pfnSCSIRequestSend. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic DECLCALLBACK(int) drvscsiRequestSend(PPDMISCSICONNECTOR pInterface, PPDMSCSIREQUEST pSCSIRequest)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDRVSCSI pThis = PDMISCSICONNECTOR_2_DRVSCSI(pInterface);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIDeviceReqCreate(pThis->hVScsiDevice, &hVScsiReq,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIDeviceReqEnqueue(pThis->hVScsiDevice, hVScsiReq);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/* -=-=-=-=- IBase -=-=-=-=- */
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @interface_method_impl{PDMIBASE,pfnQueryInterface}
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsyncstatic DECLCALLBACK(void *) drvscsiQueryInterface(PPDMIBASE pInterface, const char *pszIID)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNT, pThis->pDrvMount);
4eb7f6613b45a75ffafc1f5f0f05f942ad36d727vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKBIOS, pThis->pDrvBlockBios);
a39ea3668b7019c23a68936259545f9b71bce1aavboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
0db6a029780d9f9b347500e117320a8d5661efe5vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMISCSICONNECTOR, &pThis->ISCSIConnector);
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKPORT, &pThis->IPort);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNTNOTIFY, &pThis->IMountNotify);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKASYNCPORT, &pThis->IPortAsync);
cab115cfa31c584def7069312a1e23c3fc88533bvboxsyncstatic DECLCALLBACK(int) drvscsiQueryDeviceLocation(PPDMIBLOCKPORT pInterface, const char **ppcszController,
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync PDRVSCSI pThis = PDMIBLOCKPORT_2_DRVSCSI(pInterface);
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync return pThis->pDevScsiPort->pfnQueryDeviceLocation(pThis->pDevScsiPort, ppcszController,
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync * Called when media is mounted.
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync * @param pInterface Pointer to the interface structure containing the called function pointer.
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsyncstatic DECLCALLBACK(void) drvscsiMountNotify(PPDMIMOUNTNOTIFY pInterface)
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync PDRVSCSI pThis = PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync LogFlowFunc(("mounting LUN#%p\n", pThis->hVScsiLun));
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync /* Ignore the call if we're called while being attached. */
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync /* Let the LUN know that a medium was mounted. */
1e9e76e4273dcc2e3d560a0f3605c46f0013eb7bvboxsync * Called when media is unmounted
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync * @param pInterface Pointer to the interface structure containing the called function pointer.
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsyncstatic DECLCALLBACK(void) drvscsiUnmountNotify(PPDMIMOUNTNOTIFY pInterface)
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync PDRVSCSI pThis = PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync LogFlowFunc(("unmounting LUN#%p\n", pThis->hVScsiLun));
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync /* Let the LUN know that the medium was unmounted. */
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync * Worker for drvscsiReset, drvscsiSuspend and drvscsiPowerOff.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pDrvIns The driver instance.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pfnAsyncNotify The async callback.
0c4004948fca34f2db87e7b38013137e9472c306vboxsyncstatic void drvscsiR3ResetOrSuspendOrPowerOff(PPDMDRVINS pDrvIns, PFNPDMDRVASYNCNOTIFY pfnAsyncNotify)
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
36411046d85fccaa66061120a064225fd1b5ae01vboxsync int rc = RTReqQueueCall(pThis->hQueueRequests, &pReq, 0 /*ms*/, (PFNRT)drvscsiAsyncIOLoopSyncCallback, 1, pThis);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync PDMDrvHlpSetAsyncNotification(pDrvIns, pfnAsyncNotify);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * Callback employed by drvscsiSuspend and drvscsiPowerOff.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @returns true if we've quiesced, false if we're still working.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pDrvIns The driver instance.
0c4004948fca34f2db87e7b38013137e9472c306vboxsyncstatic DECLCALLBACK(bool) drvscsiIsAsyncSuspendOrPowerOffDone(PPDMDRVINS pDrvIns)
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return false;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return true;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return false;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return true;
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync * @copydoc FNPDMDRVPOWEROFF
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsyncstatic DECLCALLBACK(void) drvscsiPowerOff(PPDMDRVINS pDrvIns)
0c4004948fca34f2db87e7b38013137e9472c306vboxsync drvscsiR3ResetOrSuspendOrPowerOff(pDrvIns, drvscsiIsAsyncSuspendOrPowerOffDone);
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync * @copydoc FNPDMDRVSUSPEND
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsyncstatic DECLCALLBACK(void) drvscsiSuspend(PPDMDRVINS pDrvIns)
0c4004948fca34f2db87e7b38013137e9472c306vboxsync drvscsiR3ResetOrSuspendOrPowerOff(pDrvIns, drvscsiIsAsyncSuspendOrPowerOffDone);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * Callback employed by drvscsiReset.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @returns true if we've quiesced, false if we're still working.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pDrvIns The driver instance.
0c4004948fca34f2db87e7b38013137e9472c306vboxsyncstatic DECLCALLBACK(bool) drvscsiIsAsyncResetDone(PPDMDRVINS pDrvIns)
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return false;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return true;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return false;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return true;
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync * @copydoc FNPDMDRVRESET
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsyncstatic DECLCALLBACK(void) drvscsiReset(PPDMDRVINS pDrvIns)
0c4004948fca34f2db87e7b38013137e9472c306vboxsync drvscsiR3ResetOrSuspendOrPowerOff(pDrvIns, drvscsiIsAsyncResetDone);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Destruct a driver instance.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Most VM resources are freed by the VM. This callback is provided so that any non-VM
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * resources can be freed correctly.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pDrvIns The driver instance data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic DECLCALLBACK(void) drvscsiDestruct(PPDMDRVINS pDrvIns)
8cd2f2e64725096acb682f34a5568b7fb816eda7vboxsync if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 100 /*ms*/))
8cd2f2e64725096acb682f34a5568b7fb816eda7vboxsync LogRel(("drvscsiDestruct#%u: previous dummy request is still pending\n", pDrvIns->iInstance));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgRC(rc, ("Failed to destroy queue rc=%Rrc\n", rc));
26947320577c481b4afefdb0afbb855181e5b2e8vboxsync /* Free the VSCSI device and LUN handle. */
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync int rc = VSCSIDeviceLunDetach(pThis->hVScsiDevice, 0, &hVScsiLun);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Construct a block driver instance.
cba6719bd64ec749967bbe931230452664109857vboxsync * @copydoc FNPDMDRVCONSTRUCT
c28fa006ba669ad8f26ae31d00a338379c04ea1bvboxsyncstatic DECLCALLBACK(int) drvscsiConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
c28fa006ba669ad8f26ae31d00a338379c04ea1bvboxsync LogFlowFunc(("pDrvIns=%#p pCfg=%#p\n", pDrvIns, pCfg));
a8139954a84d6e9090dd3a8371aa788351d45bc3vboxsync * Initialize the instance data.
36411046d85fccaa66061120a064225fd1b5ae01vboxsync pThis->ISCSIConnector.pfnSCSIRequestSend = drvscsiRequestSend;
36411046d85fccaa66061120a064225fd1b5ae01vboxsync pDrvIns->IBase.pfnQueryInterface = drvscsiQueryInterface;
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync pThis->IMountNotify.pfnMountNotify = drvscsiMountNotify;
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync pThis->IMountNotify.pfnUnmountNotify = drvscsiUnmountNotify;
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync pThis->IPort.pfnQueryDeviceLocation = drvscsiQueryDeviceLocation;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->IPortAsync.pfnTransferCompleteNotify = drvscsiTransferCompleteNotify;
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync /* Query the SCSI port interface above. */
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync pThis->pDevScsiPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMISCSIPORT);
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync AssertMsgReturn(pThis->pDevScsiPort, ("Missing SCSI port interface above\n"), VERR_PDM_MISSING_INTERFACE);
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync /* Query the optional LED interface above. */
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync pThis->pLedPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS);
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync /* Get The Led. */
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync rc = pThis->pLedPort->pfnQueryStatusLed(pThis->pLedPort, 0, &pThis->pLed);
36411046d85fccaa66061120a064225fd1b5ae01vboxsync * Validate and read configuration.
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync if (!CFGMR3AreValuesValid(pCfg, "NonRotationalMedium\0Readonly\0"))
36411046d85fccaa66061120a064225fd1b5ae01vboxsync return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
36411046d85fccaa66061120a064225fd1b5ae01vboxsync N_("SCSI configuration error: unknown option specified"));
36411046d85fccaa66061120a064225fd1b5ae01vboxsync rc = CFGMR3QueryBoolDef(pCfg, "NonRotationalMedium", &pThis->fNonRotational, false);
36411046d85fccaa66061120a064225fd1b5ae01vboxsync N_("SCSI configuration error: failed to read \"NonRotationalMedium\" as boolean"));
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync rc = CFGMR3QueryBoolDef(pCfg, "Readonly", &pThis->fReadonly, false);
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync N_("SCSI configuration error: failed to read \"Readonly\" as boolean"));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Try attach driver below and query it's block interface.
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync rc = PDMDrvHlpAttach(pDrvIns, fFlags, &pThis->pDrvBase);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Attaching driver below failed rc=%Rrc\n", rc), rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Query the block and blockbios interfaces.
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync pThis->pDrvBlock = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCK);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgFailed(("Configuration error: No block interface!\n"));
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync pThis->pDrvBlockBios = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKBIOS);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgFailed(("Configuration error: No block BIOS interface!\n"));
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync pThis->pDrvMount = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMOUNT);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Try to get the optional async block interface. */
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync pThis->pDrvBlockAsync = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKASYNC);
cba6719bd64ec749967bbe931230452664109857vboxsync PDMBLOCKTYPE enmType = pThis->pDrvBlock->pfnGetType(pThis->pDrvBlock);
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_UNSUPPORTED_BLOCK_TYPE, RT_SRC_POS,
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync N_("Only hard disks and CD/DVD-ROMs are currently supported as SCSI devices (enmType=%d)"),
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync AssertMsgFailed(("Internal error: cdrom without a mountable interface\n"));
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /* Create VSCSI device and LUN. */
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync pThis->VScsiIoCallbacks.pfnVScsiLunMediumGetSize = drvscsiGetSize;
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync pThis->VScsiIoCallbacks.pfnVScsiLunMediumGetSectorSize = drvscsiGetSectorSize;
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync pThis->VScsiIoCallbacks.pfnVScsiLunReqTransferEnqueue = drvscsiReqTransferEnqueue;
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync pThis->VScsiIoCallbacks.pfnVScsiLunGetFeatureFlags = drvscsiGetFeatureFlags;
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync pThis->VScsiIoCallbacks.pfnVScsiLunMediumSetLock = drvscsiSetLock;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIDeviceCreate(&pThis->hVScsiDevice, drvscsiVScsiReqCompleted, pThis);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create VSCSI device rc=%Rrc\n"), rc);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync rc = VSCSILunCreate(&pThis->hVScsiLun, enmLunType, &pThis->VScsiIoCallbacks,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create VSCSI LUN rc=%Rrc\n"), rc);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIDeviceLunAttach(pThis->hVScsiDevice, pThis->hVScsiLun, 0);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to attached the LUN to the SCSI device\n"), rc);
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync //@todo: This is a very hacky way of telling the LUN whether a medium was mounted.
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync // The mount/unmount interface doesn't work in a very sensible manner!
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync if (pThis->pDrvBlock->pfnGetSize(pThis->pDrvBlock))
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync rc = VINF_SUCCESS; VSCSILunMountNotify(pThis->hVScsiLun);
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to notify the LUN of media being mounted\n"), rc);
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync rc = VINF_SUCCESS; VSCSILunUnmountNotify(pThis->hVScsiLun);
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to notify the LUN of media being unmounted\n"), rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Register statistics counter. */
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync /** @todo aeichner: Find a way to put the instance number of the attached
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync * controller device when we support more than one controller of the same type.
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync * At the moment we have the 0 hardcoded. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatBytesRead, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,
c91345f92b829d3fba05ce7a97206d83c5183ce0vboxsync "Amount of data read.", "/Devices/SCSI0/%d/ReadBytes", pDrvIns->iInstance);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatBytesWritten, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,
c91345f92b829d3fba05ce7a97206d83c5183ce0vboxsync "Amount of data written.", "/Devices/SCSI0/%d/WrittenBytes", pDrvIns->iInstance);
44a2ecaf2d0fc196ab76cab13b3f909299e386d1vboxsync PDMDrvHlpSTAMRegisterF(pDrvIns, (void *)&pThis->StatIoDepth, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
44a2ecaf2d0fc196ab76cab13b3f909299e386d1vboxsync "Number of active tasks.", "/Devices/SCSI0/%d/IoDepth", pDrvIns->iInstance);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync /* Create request queue. */
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create request queue rc=%Rrc\n"), rc);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync /* Create I/O thread. */
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsiAsyncIOLoop,
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync drvscsiAsyncIOLoopWakeup, 0, RTTHREADTYPE_IO, "SCSI async IO");
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create async I/O thread rc=%Rrc\n"), rc);
b0db50948c349fa76655abf252f7946b515e8204vboxsync LogRel(("SCSI#%d: using normal I/O\n", pDrvIns->iInstance));
b0db50948c349fa76655abf252f7946b515e8204vboxsync LogRel(("SCSI#%d: using async I/O\n", pDrvIns->iInstance));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * SCSI driver registration record.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* u32Version */
5b465a7c1237993faf8bb50120d247f3f0319adavboxsync /* szName */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /* szRCMod */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /* szR0Mod */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pszDescription */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync "Generic SCSI driver.",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* fFlags */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* fClass. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* cMaxInstances */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* cbInstance */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnConstruct */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnDestruct */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /* pfnRelocate */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnIOCtl */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnPowerOn */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnReset */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnSuspend */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnResume */
cba6719bd64ec749967bbe931230452664109857vboxsync /* pfnAttach */
cba6719bd64ec749967bbe931230452664109857vboxsync /* pfnDetach */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnPowerOff */
cba6719bd64ec749967bbe931230452664109857vboxsync /* pfnSoftReset */
cba6719bd64ec749967bbe931230452664109857vboxsync /* u32EndVersion */