VirtualBox

Changeset 83165 in vbox for trunk/src/VBox/Devices/VirtIO


Ignore:
Timestamp:
Feb 26, 2020 8:47:09 PM (5 years ago)
Author:
vboxsync
Message:

Network/DevVirtioNet.cpp Found some issues after going back and studying the initial port of the code, and got ping to work, so integrating that. More to test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r83058 r83165  
    556556    if (pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK)
    557557        return virtqIsEmpty(pDevIns, pVirtio, idxQueue);
     558    LogFunc(("VirtIO not ready: Returning 'true' for queue empty\n"));
    558559    return true;
    559560}
     
    582583    uint16_t uDescIdx = uHeadIdx;
    583584
    584     Log3Func(("%s DESC CHAIN: (head) desc_idx=%u\n", pVirtq->szVirtqName, uHeadIdx));
     585    Log6Func(("%s DESC CHAIN: (head) desc_idx=%u\n", pVirtq->szVirtqName, uHeadIdx));
    585586    RT_NOREF(pVirtq);
    586587
     
    618619        if (desc.fFlags & VIRTQ_DESC_F_WRITE)
    619620        {
    620             Log3Func(("%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));
    621622            cbIn += desc.cb;
    622623            pSeg = &(paSegsIn[cSegsIn++]);
     
    624625        else
    625626        {
    626             Log3Func(("%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));
    627628            cbOut += desc.cb;
    628629            pSeg = &(paSegsOut[cSegsOut++]);
     
    635636    } while (desc.fFlags & VIRTQ_DESC_F_NEXT);
    636637
    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 
    647638    PVIRTIO_DESC_CHAIN_T pDescChain = (PVIRTIO_DESC_CHAIN_T)RTMemAllocZ(sizeof(VIRTIO_DESC_CHAIN_T));
    648639    AssertReturn(pDescChain, VERR_NO_MEMORY);
    649640
    650641    pDescChain->uHeadIdx      = uHeadIdx;
    651     pDescChain->cbPhysSend    = cbOut;
    652     pDescChain->pSgPhysSend   = pSgPhysOut;
    653     pDescChain->cbPhysReturn  = cbIn;
    654     pDescChain->pSgPhysReturn = pSgPhysIn;
    655642    *ppDescChain = pDescChain;
    656643
    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));
    658666
    659667    return VINF_SUCCESS;
     
    859867                    ("Guest driver not in ready state.\n"), VERR_INVALID_STATE);
    860868
    861     Log3Func(("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",
    862870              VIRTQNAME(pVirtio, idxQueue), virtioReadUsedRingIdx(pDevIns, pVirtio, idxQueue)));
    863871
     
    868876     * is handled by client */
    869877
    870     size_t cbCopy = 0;
     878    size_t cbCopy = 0, cbTotal, cbRemain;
    871879
    872880    if (pSgVirtReturn)
    873881    {
    874         size_t cbRemain = RTSgBufCalcTotalLength(pSgVirtReturn);
     882        cbRemain = cbTotal = RTSgBufCalcTotalLength(pSgVirtReturn);
    875883        virtioCoreSgBufReset(pSgPhysReturn); /* Reset ptr because req data may have already been written */
    876884        while (cbRemain)
     
    904912    virtioWriteUsedElem(pDevIns, pVirtio, idxQueue, pVirtq->uUsedIdx++, pDescChain->uHeadIdx, (uint32_t)cbCopy);
    905913
    906     Log3Func((".... Copied %zu bytes to %u byte buffer, residual=%zu\n",
    907               cbCopy, 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));
    908916
    909917    Log6Func(("Write ahead used_idx=%u, %s used_idx=%u\n",
    910918              pVirtq->uUsedIdx, VIRTQNAME(pVirtio, idxQueue), virtioReadUsedRingIdx(pDevIns, pVirtio, idxQueue)));
    911919
    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    }
    916930    RTMemFree(pDescChain);
    917931
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