Changeset 82042 in vbox
- Timestamp:
- Nov 20, 2019 7:04:20 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp
r82023 r82042 109 109 #define VIRTQ_REQ_BASE 2 /**< Spec-defined base index of request queues */ 110 110 111 #define QUEUENAME(qIdx) (pThis->aszQueueNames[qIdx]) /**< Macro to get queue name from its index */112 #define CB QUEUENAME(qIdx) RTStrNLen(QUEUENAME(qIdx), sizeof(QUEUENAME(qIdx)))111 #define VIRTQNAME(qIdx) (pThis->aszVIRTQNAMEs[qIdx]) /**< Macro to get queue name from its index */ 112 #define CBVIRTQNAME(qIdx) RTStrNLen(VIRTQNAME(qIdx), sizeof(VIRTQNAME(qIdx))) 113 113 114 114 #define IS_REQ_QUEUE(qIdx) (qIdx >= VIRTQ_REQ_BASE && qIdx < VIRTIOSCSI_QUEUE_CNT) … … 426 426 char szInstance[16]; 427 427 428 /** Device-specific spec-based VirtIO queuenames */429 char asz QueueNames[VIRTIOSCSI_QUEUE_CNT][VIRTIO_MAX_QUEUE_NAME_SIZE];428 /** Device-specific spec-based VirtIO VIRTQNAMEs */ 429 char aszVIRTQNAMEs[VIRTIOSCSI_QUEUE_CNT][VIRTIO_MAX_QUEUE_NAME_SIZE]; 430 430 431 431 /** Track which VirtIO queues we've attached to */ … … 577 577 #ifdef IN_RING3 /* spans most of the file, at the moment. */ 578 578 579 580 DECLINLINE(void) virtioScsiSetVirtqNames(PVIRTIOSCSI pThis) 581 { 582 RTStrCopy(pThis->aszVIRTQNAMEs[CONTROLQ_IDX], VIRTIO_MAX_QUEUE_NAME_SIZE, "controlq"); 583 RTStrCopy(pThis->aszVIRTQNAMEs[EVENTQ_IDX], VIRTIO_MAX_QUEUE_NAME_SIZE, "eventq"); 584 for (uint16_t qIdx = VIRTQ_REQ_BASE; qIdx < VIRTQ_REQ_BASE + VIRTIOSCSI_REQ_QUEUE_CNT; qIdx++) 585 RTStrPrintf(pThis->aszVIRTQNAMEs[qIdx], VIRTIO_MAX_QUEUE_NAME_SIZE, 586 "requestq<%d>", qIdx - VIRTQ_REQ_BASE); 587 } 588 579 589 #ifdef LOG_ENABLED 590 580 591 581 592 DECLINLINE(const char *) virtioGetTxDirText(uint32_t enmTxDir) … … 1325 1336 | pScsiCtrlUnion->scsiCtrlTmf.abScsiLun[3]) & 0x3fff; 1326 1337 Log2Func(("[%s] (Target: %d LUN: %d) Task Mgt Function: %s\n", 1327 QUEUENAME(qIdx), uTarget, uScsiLun, virtioGetTMFTypeText(pScsiCtrlUnion->scsiCtrlTmf.uSubtype)));1338 VIRTQNAME(qIdx), uTarget, uScsiLun, virtioGetTMFTypeText(pScsiCtrlUnion->scsiCtrlTmf.uSubtype))); 1328 1339 1329 1340 if (uTarget >= pThis->cTargets || !pThisCC->paTargetInstances[uTarget].fPresent) … … 1393 1404 virtioGetControlAsyncMaskText(szTypeText, sizeof(szTypeText), pScsiCtrlAnQuery->fEventsRequested); 1394 1405 Log2Func(("[%s] (Target: %d LUN: %d) Async. Notification Query: %s\n", 1395 QUEUENAME(qIdx), uTarget, uScsiLun, szTypeText));1406 VIRTQNAME(qIdx), uTarget, uScsiLun, szTypeText)); 1396 1407 } 1397 1408 #endif … … 1424 1435 virtioGetControlAsyncMaskText(szTypeText, sizeof(szTypeText), pScsiCtrlAnSubscribe->fEventsRequested); 1425 1436 Log2Func(("[%s] (Target: %d LUN: %d) Async. Notification Subscribe: %s\n", 1426 QUEUENAME(qIdx), uTarget, uScsiLun, szTypeText));1437 VIRTQNAME(qIdx), uTarget, uScsiLun, szTypeText)); 1427 1438 } 1428 1439 #endif … … 1452 1463 default: 1453 1464 { 1454 LogFunc(("Unknown control type extracted from %s: %u\n", QUEUENAME(qIdx), pScsiCtrlUnion->scsiCtrl.uType));1465 LogFunc(("Unknown control type extracted from %s: %u\n", VIRTQNAME(qIdx), pScsiCtrlUnion->scsiCtrl.uType)); 1455 1466 1456 1467 bResponse = VIRTIOSCSI_S_FAILURE; … … 1508 1519 if (!fNotificationSent) 1509 1520 { 1510 Log6Func(("%s worker sleeping...\n", QUEUENAME(qIdx)));1521 Log6Func(("%s worker sleeping...\n", VIRTQNAME(qIdx))); 1511 1522 Assert(ASMAtomicReadBool(&pWorkerR3->fSleeping)); 1512 1523 int rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pWorker->hEvtProcess, RT_INDEFINITE_WAIT); … … 1514 1525 if (RT_UNLIKELY(pThread->enmState != PDMTHREADSTATE_RUNNING)) 1515 1526 return VINF_SUCCESS; 1516 Log6Func(("%s worker woken\n", QUEUENAME(qIdx)));1527 Log6Func(("%s worker woken\n", VIRTQNAME(qIdx))); 1517 1528 ASMAtomicWriteBool(&pWorkerR3->fNotified, false); 1518 1529 } … … 1522 1533 if (!pThis->afQueueAttached[qIdx]) 1523 1534 { 1524 LogFunc(("%s queue not attached, worker aborting...\n", QUEUENAME(qIdx)));1535 LogFunc(("%s queue not attached, worker aborting...\n", VIRTQNAME(qIdx))); 1525 1536 break; 1526 1537 } … … 1542 1553 pWorkerR3->cRedoDescs = 0; 1543 1554 1544 Log6Func(("fetching next descriptor chain from %s\n", QUEUENAME(qIdx)));1555 Log6Func(("fetching next descriptor chain from %s\n", VIRTQNAME(qIdx))); 1545 1556 PVIRTIO_DESC_CHAIN_T pDescChain; 1546 1557 int rc = virtioCoreR3QueueGet(pDevIns, &pThis->Virtio, qIdx, &pDescChain, true); 1547 1558 if (rc == VERR_NOT_AVAILABLE) 1548 1559 { 1549 Log6Func(("Nothing found in %s\n", QUEUENAME(qIdx)));1560 Log6Func(("Nothing found in %s\n", VIRTQNAME(qIdx))); 1550 1561 continue; 1551 1562 } … … 1664 1675 if (qIdx == CONTROLQ_IDX || IS_REQ_QUEUE(qIdx)) 1665 1676 { 1666 Log6Func(("%s has available data\n", QUEUENAME(qIdx)));1677 Log6Func(("%s has available data\n", VIRTQNAME(qIdx))); 1667 1678 /* Wake queue's worker thread up if sleeping */ 1668 1679 if (!ASMAtomicXchgBool(&pWorkerR3->fNotified, true)) … … 1670 1681 if (ASMAtomicReadBool(&pWorkerR3->fSleeping)) 1671 1682 { 1672 Log6Func(("waking %s worker.\n", QUEUENAME(qIdx)));1683 Log6Func(("waking %s worker.\n", VIRTQNAME(qIdx))); 1673 1684 int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pWorker->hEvtProcess); 1674 1685 AssertRC(rc); … … 1678 1689 else if (qIdx == EVENTQ_IDX) 1679 1690 { 1680 Log3Func(("Driver queued buffer(s) to %s\n", QUEUENAME(qIdx)));1691 Log3Func(("Driver queued buffer(s) to %s\n", VIRTQNAME(qIdx))); 1681 1692 if (ASMAtomicXchgBool(&pThis->fEventsMissed, false)) 1682 1693 virtioScsiR3ReportEventsMissed(pDevIns, pThis, 0); … … 1960 1971 AssertLogRelMsgReturn(uVersion == VIRTIOSCSI_SAVED_STATE_VERSION, 1961 1972 ("uVersion=%u\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION); 1962 // re-calculate names in aszQueueNames 1963 1973 1974 virtioScsiSetVirtqNames(pThis); 1964 1975 for (int qIdx = 0; qIdx < VIRTIOSCSI_QUEUE_CNT; qIdx++) 1965 1976 pHlp->pfnSSMGetBool(pSSM, &pThis->afQueueAttached[qIdx]); 1977 1966 1978 1967 1979 pHlp->pfnSSMGetU32(pSSM, &pThis->virtioScsiConfig.uNumQueues); … … 1984 1996 pHlp->pfnSSMGetU32(pSSM, &pThis->fResetting); 1985 1997 1986 /* TODO: Ask a iechner about BIOS-related changes */1998 /* TODO: Ask aeichner about BIOS-related changes */ 1987 1999 pHlp->pfnSSMGetU32(pSSM, &pThis->cTargets); 1988 2000 … … 2004 2016 2005 2017 pHlp->pfnSSMGetU16(pSSM, &qIdx); 2006 2007 2018 pHlp->pfnSSMGetU16(pSSM, &uHeadIdx); 2008 2019 LogFunc((" loaded redo req: qIdx=%d, headIdx=%d\n", qIdx, uHeadIdx)); … … 2025 2036 if (pThis->afQueueAttached[qIdx]) 2026 2037 { 2027 LogFunc(("Waking %s worker.\n", QUEUENAME(qIdx)));2038 LogFunc(("Waking %s worker.\n", VIRTQNAME(qIdx))); 2028 2039 rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->aWorkers[qIdx].hEvtProcess); 2029 2040 AssertRCReturn(rc, rc); … … 2328 2339 if (ASMAtomicReadBool(&pThisCC->aWorkers[qIdx].fSleeping)) 2329 2340 { 2330 Log6Func(("waking %s worker.\n", QUEUENAME(qIdx)));2341 Log6Func(("waking %s worker.\n", VIRTQNAME(qIdx))); 2331 2342 int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->aWorkers[qIdx].hEvtProcess); 2332 2343 AssertRC(rc); … … 2494 2505 */ 2495 2506 2496 /* Name the queues: */ 2497 RTStrCopy(pThis->aszQueueNames[CONTROLQ_IDX], VIRTIO_MAX_QUEUE_NAME_SIZE, "controlq"); 2498 RTStrCopy(pThis->aszQueueNames[EVENTQ_IDX], VIRTIO_MAX_QUEUE_NAME_SIZE, "eventq"); 2499 for (uint16_t qIdx = VIRTQ_REQ_BASE; qIdx < VIRTQ_REQ_BASE + VIRTIOSCSI_REQ_QUEUE_CNT; qIdx++) 2500 RTStrPrintf(pThis->aszQueueNames[qIdx], VIRTIO_MAX_QUEUE_NAME_SIZE, 2501 "requestq<%d>", qIdx - VIRTQ_REQ_BASE); 2507 virtioScsiSetVirtqNames(pThis); 2502 2508 2503 2509 /* Attach the queues and create worker threads for them: */ 2504 2510 for (uint16_t qIdx = 0; qIdx < VIRTIOSCSI_QUEUE_CNT; qIdx++) 2505 2511 { 2506 rc = virtioCoreR3QueueAttach(&pThis->Virtio, qIdx, QUEUENAME(qIdx));2512 rc = virtioCoreR3QueueAttach(&pThis->Virtio, qIdx, VIRTQNAME(qIdx)); 2507 2513 if (RT_FAILURE(rc)) 2508 2514 continue; … … 2511 2517 rc = PDMDevHlpThreadCreate(pDevIns, &pThisCC->aWorkers[qIdx].pThread, 2512 2518 (void *)(uintptr_t)qIdx, virtioScsiR3WorkerThread, 2513 virtioScsiR3WorkerWakeUp, 0, RTTHREADTYPE_IO, QUEUENAME(qIdx));2519 virtioScsiR3WorkerWakeUp, 0, RTTHREADTYPE_IO, VIRTQNAME(qIdx)); 2514 2520 if (rc != VINF_SUCCESS) 2515 2521 { 2516 LogRel(("Error creating thread for Virtual Queue %s: %Rrc\n", QUEUENAME(qIdx), rc));2522 LogRel(("Error creating thread for Virtual Queue %s: %Rrc\n", VIRTQNAME(qIdx), rc)); 2517 2523 return rc; 2518 2524 }
Note:
See TracChangeset
for help on using the changeset viewer.