Changeset 83165 in vbox for trunk/src/VBox/Devices/VirtIO
- Timestamp:
- Feb 26, 2020 8:47:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp
r83058 r83165 556 556 if (pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK) 557 557 return virtqIsEmpty(pDevIns, pVirtio, idxQueue); 558 LogFunc(("VirtIO not ready: Returning 'true' for queue empty\n")); 558 559 return true; 559 560 } … … 582 583 uint16_t uDescIdx = uHeadIdx; 583 584 584 Log 3Func(("%s DESC CHAIN: (head) desc_idx=%u\n", pVirtq->szVirtqName, uHeadIdx));585 Log6Func(("%s DESC CHAIN: (head) desc_idx=%u\n", pVirtq->szVirtqName, uHeadIdx)); 585 586 RT_NOREF(pVirtq); 586 587 … … 618 619 if (desc.fFlags & VIRTQ_DESC_F_WRITE) 619 620 { 620 Log 3Func(("%s IN desc_idx=%u seg=%u addr=%RGp cb=%u\n", VIRTQNAME(pVirtio, idxQueue), uDescIdx, cSegsIn, desc.GCPhysBuf, desc.cb));621 Log6Func(("%s IN desc_idx=%u seg=%u addr=%RGp cb=%u\n", VIRTQNAME(pVirtio, idxQueue), uDescIdx, cSegsIn, desc.GCPhysBuf, desc.cb)); 621 622 cbIn += desc.cb; 622 623 pSeg = &(paSegsIn[cSegsIn++]); … … 624 625 else 625 626 { 626 Log 3Func(("%s OUT desc_idx=%u seg=%u addr=%RGp cb=%u\n", VIRTQNAME(pVirtio, idxQueue), uDescIdx, cSegsOut, desc.GCPhysBuf, desc.cb));627 Log6Func(("%s OUT desc_idx=%u seg=%u addr=%RGp cb=%u\n", VIRTQNAME(pVirtio, idxQueue), uDescIdx, cSegsOut, desc.GCPhysBuf, desc.cb)); 627 628 cbOut += desc.cb; 628 629 pSeg = &(paSegsOut[cSegsOut++]); … … 635 636 } while (desc.fFlags & VIRTQ_DESC_F_NEXT); 636 637 637 PVIRTIOSGBUF pSgPhysIn = (PVIRTIOSGBUF)RTMemAllocZ(sizeof(VIRTIOSGBUF));638 AssertReturn(pSgPhysIn, VERR_NO_MEMORY);639 640 virtioCoreSgBufInit(pSgPhysIn, paSegsIn, cSegsIn);641 642 PVIRTIOSGBUF pSgPhysOut = (PVIRTIOSGBUF)RTMemAllocZ(sizeof(VIRTIOSGBUF));643 AssertReturn(pSgPhysOut, VERR_NO_MEMORY);644 645 virtioCoreSgBufInit(pSgPhysOut, paSegsOut, cSegsOut);646 647 638 PVIRTIO_DESC_CHAIN_T pDescChain = (PVIRTIO_DESC_CHAIN_T)RTMemAllocZ(sizeof(VIRTIO_DESC_CHAIN_T)); 648 639 AssertReturn(pDescChain, VERR_NO_MEMORY); 649 640 650 641 pDescChain->uHeadIdx = uHeadIdx; 651 pDescChain->cbPhysSend = cbOut;652 pDescChain->pSgPhysSend = pSgPhysOut;653 pDescChain->cbPhysReturn = cbIn;654 pDescChain->pSgPhysReturn = pSgPhysIn;655 642 *ppDescChain = pDescChain; 656 643 657 Log3Func(("%s -- segs OUT: %u (%u bytes) IN: %u (%u bytes) --\n", pVirtq->szVirtqName, cSegsOut, cbOut, cSegsIn, cbIn)); 644 if (cSegsIn) 645 { 646 PVIRTIOSGBUF pSgPhysIn = (PVIRTIOSGBUF)RTMemAllocZ(sizeof(VIRTIOSGBUF)); 647 AssertReturn(pSgPhysIn, VERR_NO_MEMORY); 648 649 virtioCoreSgBufInit(pSgPhysIn, paSegsIn, cSegsIn); 650 pDescChain->pSgPhysReturn = pSgPhysIn; 651 pDescChain->cbPhysReturn = cbIn; 652 } 653 654 if (cSegsOut) 655 { 656 PVIRTIOSGBUF pSgPhysOut = (PVIRTIOSGBUF)RTMemAllocZ(sizeof(VIRTIOSGBUF)); 657 AssertReturn(pSgPhysOut, VERR_NO_MEMORY); 658 659 virtioCoreSgBufInit(pSgPhysOut, paSegsOut, cSegsOut); 660 pDescChain->pSgPhysSend = pSgPhysOut; 661 pDescChain->cbPhysSend = cbOut; 662 } 663 664 665 Log6Func(("%s -- segs OUT: %u (%u bytes) IN: %u (%u bytes) --\n", pVirtq->szVirtqName, cSegsOut, cbOut, cSegsIn, cbIn)); 658 666 659 667 return VINF_SUCCESS; … … 859 867 ("Guest driver not in ready state.\n"), VERR_INVALID_STATE); 860 868 861 Log 3Func(("Copying client data to %s, desc chain (head desc_idx %d)\n",869 Log6Func(("Copying client data to %s, desc chain (head desc_idx %d)\n", 862 870 VIRTQNAME(pVirtio, idxQueue), virtioReadUsedRingIdx(pDevIns, pVirtio, idxQueue))); 863 871 … … 868 876 * is handled by client */ 869 877 870 size_t cbCopy = 0 ;878 size_t cbCopy = 0, cbTotal, cbRemain; 871 879 872 880 if (pSgVirtReturn) 873 881 { 874 size_t cbRemain= RTSgBufCalcTotalLength(pSgVirtReturn);882 cbRemain = cbTotal = RTSgBufCalcTotalLength(pSgVirtReturn); 875 883 virtioCoreSgBufReset(pSgPhysReturn); /* Reset ptr because req data may have already been written */ 876 884 while (cbRemain) … … 904 912 virtioWriteUsedElem(pDevIns, pVirtio, idxQueue, pVirtq->uUsedIdx++, pDescChain->uHeadIdx, (uint32_t)cbCopy); 905 913 906 Log 3Func((".... Copied %zu bytes to %u byte buffer, residual=%zu\n",907 cb Copy, pDescChain->cbPhysReturn, pDescChain->cbPhysReturn - cbCopy));914 Log6Func((".... Copied %zu bytes in %d segs to %u byte buffer, residual=%zu\n", 915 cbTotal - cbRemain, pSgVirtReturn->cSegs, pDescChain->cbPhysReturn, pDescChain->cbPhysReturn - cbCopy)); 908 916 909 917 Log6Func(("Write ahead used_idx=%u, %s used_idx=%u\n", 910 918 pVirtq->uUsedIdx, VIRTQNAME(pVirtio, idxQueue), virtioReadUsedRingIdx(pDevIns, pVirtio, idxQueue))); 911 919 912 RTMemFree((void *)pDescChain->pSgPhysSend->paSegs); 913 RTMemFree(pDescChain->pSgPhysSend); 914 RTMemFree((void *)pSgPhysReturn->paSegs); 915 RTMemFree(pSgPhysReturn); 920 if (pDescChain->pSgPhysSend) 921 { 922 RTMemFree((void *)pDescChain->pSgPhysSend->paSegs); 923 RTMemFree(pDescChain->pSgPhysSend); 924 } 925 if (pDescChain->pSgPhysReturn) 926 { 927 RTMemFree((void *)pSgPhysReturn->paSegs); 928 RTMemFree(pSgPhysReturn); 929 } 916 930 RTMemFree(pDescChain); 917 931
Note:
See TracChangeset
for help on using the changeset viewer.