VirtualBox

Changeset 80528 in vbox


Ignore:
Timestamp:
Sep 1, 2019 10:28:39 PM (5 years ago)
Author:
vboxsync
Message:

Storage/DevVirtioSCSI.cpp: This is being integrated to stop burns. I pasted in and modified some hexdump code I wrote at Sun many years ago, and apparently my editor isn't smart enough to apply the tab and CRLF filters it does when things are entered via keystrokes

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/scsi.h

    r80527 r80528  
    219219#define SCSI_ASC_MEDIUM_NOT_PRESENT                         0x3a
    220220#define SCSI_ASC_SAVING_PARAMETERS_NOT_SUPPORTED            0x39
     221#define SCSI_ASC_INTERNAL_TARGET_FAILURE                    0x44
    221222#define SCSI_ASC_INVALID_MESSAGE                            0x49
    222223#define SCSI_ASC_MEDIA_LOAD_OR_EJECT_FAILED                 0x53
     
    224225#define SCSI_ASC_SYSTEM_RESOURCE_FAILURE                    0x55
    225226#define SCSI_ASC_ILLEGAL_MODE_FOR_THIS_TRACK                0x64
     227#define SCSI_ASC_COMMAND_TO_LOGICAL_UNIT_FAILED             0x6E
    226228
    227229/** Additional sense code qualifiers (ASCQ). */
  • trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp

    r80527 r80528  
    513513        }
    514514        for (int j = 0; j < 16; j++ ) {
    515                 if (i * 16 + j >= cb)
     515            if (i * 16 + j >= cb)
    516516                Log2((" "));
    517                 else
    518                 {
    519                     uint8_t u8 = pv[i * 16 + j];
     517            else
     518            {
     519                uint8_t u8 = pv[i * 16 + j];
    520520                Log2(("%c", u8 >= 0x20 && u8 <= 0x7e ? u8 : '.'));
    521521            }
    522             }
     522        }
    523523        Log2(("\n"));
    524    }
    525    Log2(("\n"));
     524    }
     525    Log2(("\n"));
    526526}
    527527DECLINLINE(const char *) virtioGetTMFTypeText(uint32_t uSubType)
     
    590590    switch (uScsiStatusCode)
    591591    {
    592         case 0x00:  return "Good";
    593         case 0x02:  return "Check Condition";
    594         case 0x04:  return "Condition Met";
    595         case 0x08:  return "Busy";
    596         case 0x10:  return "Intermediate (obsolete)";
    597         case 0x14:  return "Condition Met (obsolete)";
    598         case 0x18:  return "Reservation Conflict";
    599         case 0x22:  return "Command Terminated";
    600         case 0x28:  return "Task Set Full";
    601         case 0x30:  return "ACA Active";
    602         case 0x40:  return "Task Aborted";
    603         default:    return "<unknown>";
     592        case 0x00:  return "GOOD";
     593        case 0x02:  return "CHECK CONDITION";
     594        case 0x04:  return "CONDITION MET";
     595        case 0x08:  return "BUSY";
     596        case 0x10:  return "INTERMEDIATE";
     597        case 0x14:  return "CONDITION MET";
     598        case 0x18:  return "RESERVATION CONFLICT";
     599        case 0x22:  return "COMMAND TERMINATED";
     600        case 0x28:  return "TASK SET FULL";
     601        case 0x30:  return "ACA ACTIVE";
     602        case 0x40:  return "TASK ABORTED";
     603        default:    return "<UNKNOWN CODE>";
    604604    }
    605605}
     
    732732
    733733    /** DrvSCSI.cpp, that issues this callback, just sticks one segment in the buffer */
     734//    memset(pReq->pbDataIn + offDst, 0, cbCopy);
     735LogFunc(("*** pSgBuf->cbSegLeft=%d\n", pSgBuf->cbSegLeft));
    734736    memcpy(pReq->pbDataIn + offDst, pSgBuf->paSegs[0].pvSeg, cbCopy);
    735737    return VINF_SUCCESS;
     
    749751    PVIRTIOSCSIREQ pReq = (PVIRTIOSCSIREQ)pvIoReqAlloc;
    750752    /** DrvSCSI.cpp, that issues this callback, just sticks one segment in the buffer */
     753
    751754    memcpy(pSgBuf->paSegs[0].pvSeg, pReq->pbDataOut + offSrc, cbCopy);
    752755
     
    828831    ASMAtomicDecU32(&pTarget->cReqsInProgress);
    829832
    830     size_t cbResidual = 0;
     833    size_t cbResidual = 0, cbXfer = 0;
    831834    int rc = pIMediaEx->pfnIoReqQueryResidual(pIMediaEx, pReq->hIoReq, &cbResidual);
    832     AssertRC(rc); Assert(cbResidual == (uint32_t)cbResidual);
     835    AssertRC(rc);
     836
     837    rc = pIMediaEx->pfnIoReqQueryXferSize(pIMediaEx, pReq->hIoReq, &cbXfer);
     838    AssertRC(rc);
    833839
    834840    /**
     
    845851    respHdr.uStatusQualifier = 0;
    846852
    847     LogFunc(("Status: %s (0x%x%x)      Response: %s (0x%x%x)\n",
    848                 virtioGetScsiStatusText(pReq->uStatus), pReq->uStatus >> 4 & 0xf, pReq->uStatus & 0xf,
    849                 virtioGetReqRespText(respHdr.uResponse), respHdr.uResponse >> 4 & 0xf, respHdr.uResponse & 0xf));
     853    LogFunc(("status: %s  response: %s  0x%x%x/0x%x%x  cbXfer=%d, cbResidual: %u\n",
     854                virtioGetScsiStatusText(pReq->uStatus),  virtioGetReqRespText(respHdr.uResponse),
     855                pReq->uStatus >> 4 & 0xf, pReq->uStatus & 0xf,
     856                respHdr.uResponse >> 4 & 0xf, respHdr.uResponse & 0xf,
     857                cbXfer, cbResidual));
    850858
    851859    if (pReq->cbSense)
    852860    {
    853     pReq->pbSense[12] = 0x25;
    854     pReq->pbSense[13] = 0x00;
    855861        Log2Func(("Sense: %s\n", SCSISenseText(pReq->pbSense[2])));
    856862        Log2Func(("Sense Ext3: %s\n", SCSISenseExtText(pReq->pbSense[12], pReq->pbSense[13])));
     
    986992    uint32_t uLUN = (pVirtqReq->cmdHdr.uLUN[2] << 8 | pVirtqReq->cmdHdr.uLUN[3]) & 0x3fff;
    987993
    988     LogFunc(("[%s]%*s (Target: %d LUN: %d)  CDB: %.*Rhxs\n",
     994    LogFunc(("[%s] (Target: %d LUN: %d)  CDB: %.*Rhxs\n",
    989995         SCSICmdText(pbCdb[0]), uTarget, uLUN,
    990996            virtioScsiEstimateCdbLen(pbCdb[0], pThis->virtioScsiConfig.uCdbSize), pbCdb));
     
    992998    Log3Func(("   id: %RX64, attr: %x, prio: %d, crn: %x\n",
    993999        pVirtqReq->cmdHdr.uId, pVirtqReq->cmdHdr.uTaskAttr, pVirtqReq->cmdHdr.uPrio, pVirtqReq->cmdHdr.uCrn));
    994 
    9951000
    9961001    off_t    uPiOutOff = 0;
     
    10801085        pReq->pbDataOut = pbDataOut;
    10811086        pReq->cbPiIn    = cbPiIn;
     1087
    10821088        if (cbPiIn)
    10831089        {
     
    11091115        if (rc != VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS)
    11101116        {
     1117            /**
     1118             * This rc value from DrvSCSI/send SCSI cmd means the request failed early
     1119             * (no mem, buf copy callback, request buffer creation, or req enqueue),
     1120             * and not submitted to lower layers, error it out.
     1121             */
     1122            LogRel(("Error submitting request!\n"));
    11111123            size_t cbResidual;
    11121124            pIMediaEx->pfnIoReqQueryResidual(pIMediaEx, pReq->hIoReq, &cbResidual);
    1113             respHdr.cbSense = 0;
    1114             respHdr.uResidual = (uint32_t)cbResidual;
    1115             respHdr.uStatus   = SCSI_STATUS_OK;
    1116             respHdr.uResponse = VIRTIOSCSI_S_OK;
     1125            uint8_t uASC, uASCQ = 0;
     1126            switch (rc)
     1127            {
     1128                case VERR_NO_MEMORY:
     1129                    uASC = SCSI_ASC_SYSTEM_RESOURCE_FAILURE;
     1130                    break;
     1131                default:
     1132                    uASC = SCSI_ASC_INTERNAL_TARGET_FAILURE;
     1133                    break;
     1134            }
     1135            uint8_t pbSense[] = { RT_BIT(7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED, 0, SCSI_SENSE_VENDOR_SPECIFIC,
     1136                                  0, 0, 0, 0, 10, uASC, uASCQ, 0 };
     1137            respHdr.cbSense = sizeof(pbSense);
     1138            respHdr.uResidual = cbDataIn + cbDataOut;
     1139            respHdr.uStatus   = SCSI_STATUS_CHECK_CONDITION;
     1140            respHdr.uResponse = VIRTIOSCSI_S_FAILURE;
    11171141            respHdr.uStatusQualifier = 0;
    11181142            virtioScsiReqFinish(pThis, qIdx, &respHdr,  NULL /* pbSense */);
     
    11201144        }
    11211145    } else {
    1122         respHdr.cbSense = 0;
    1123         respHdr.uResidual = cbDataOut + cbDataIn;
    1124         respHdr.uStatus   = SCSI_STATUS_OK;
     1146        LogRel(("Error submitting request, target not present!!\n"));
     1147        uint8_t pbSense[] = { RT_BIT(7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED, 0, SCSI_SENSE_NOT_READY,
     1148                              0, 0, 0, 0, 10, 0, 0, 0 };
     1149        respHdr.cbSense = sizeof(pbSense);
     1150        respHdr.uResidual = cbDataIn + cbDataOut;
     1151        respHdr.uStatus   = SCSI_STATUS_CHECK_CONDITION;
    11251152        respHdr.uResponse = VIRTIOSCSI_S_TARGET_FAILURE;
    11261153        respHdr.uStatusQualifier = 0;
    1127         virtioScsiReqFinish(pThis, qIdx, &respHdr, NULL /* pbSense */);
     1154        virtioScsiReqFinish(pThis, qIdx, &respHdr,  NULL /* pbSense */);
    11281155        return VINF_SUCCESS;
    1129 
    11301156    }
    11311157
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r80527 r80528  
    826826    {
    827827        pVirtio->uISR = *(uint8_t *)pv;
    828         Log2Func(("Setting uISR = 0x%02x (virtq interrupt: %d, dev confg interrupt: %d)\n",
     828        Log3Func(("Setting uISR = 0x%02x (virtq interrupt: %d, dev confg interrupt: %d)\n",
    829829              pVirtio->uISR & 0xff,
    830830              pVirtio->uISR & VIRTIO_ISR_VIRTQ_INTERRUPT,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette