VirtualBox

Changeset 83058 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Feb 12, 2020 12:10:49 PM (5 years ago)
Author:
vboxsync
Message:

Network/DevVirtioNet_1_0.cpp: Starting to receive Rx packets from now. Continuing to test and debug. See BugRef(8651) Comment #60

Location:
trunk/src/VBox/Devices
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevVirtioNet_1_0.cpp

    r83028 r83058  
    10561056static int virtioNetR3IsRxQueuePrimed(PPDMDEVINS pDevIns, PVIRTIONET pThis, uint16_t idxQueue)
    10571057{
    1058     int rc;
    1059 
    1060     LogFunc(("%s %s\n", INSTANCE(pThis), VIRTQNAME(idxQueue)));
     1058#define LOGPARAMS INSTANCE(pThis), VIRTQNAME(idxQueue)
    10611059
    10621060    if (!pThis->fVirtioReady)
    1063         rc = VERR_NET_NO_BUFFER_SPACE;
    1064 
     1061    {
     1062        LogFunc(("%s %s VirtIO not ready (rc = VERR_NET_NO_BUFFER_SPACE)\n", LOGPARAMS));
     1063    }
    10651064    else if (!virtioCoreIsQueueEnabled(&pThis->Virtio, RXQIDX_QPAIR(idxQueue)))
    1066         rc = VERR_NET_NO_BUFFER_SPACE;
    1067 
     1065    {
     1066        LogFunc(("%s %s queue not enabled (rc = VERR_NET_NO_BUFFER_SPACE)\n", LOGPARAMS));
     1067    }
    10681068    else if (virtioCoreQueueIsEmpty(pDevIns, &pThis->Virtio, RXQIDX_QPAIR(idxQueue)))
    10691069    {
     1070        LogFunc(("%s %s queue is empty (rc = VERR_NET_NO_BUFFER_SPACE)\n", LOGPARAMS));
    10701071        virtioCoreQueueSetNotify(&pThis->Virtio, RXQIDX_QPAIR(idxQueue), true);
    1071         rc = VERR_NET_NO_BUFFER_SPACE;
    10721072    }
    10731073    else
    10741074    {
     1075        LogFunc(("%s %s ready with available buffers\n", LOGPARAMS));
    10751076        virtioCoreQueueSetNotify(&pThis->Virtio, RXQIDX_QPAIR(idxQueue), false);
    1076         rc = VINF_SUCCESS;
    1077     }
    1078 
    1079     LogFlowFunc(("%s idxQueue = %d -> %Rrc\n", INSTANCE(pThis), idxQueue, rc));
    1080     return rc;
    1081 }
    1082 
     1077        return VINF_SUCCESS;
     1078    }
     1079    return VERR_NET_NO_BUFFER_SPACE;
     1080}
     1081
     1082
     1083static bool virtioNetR3AreRxBufsAvail(PPDMDEVINS pDevIns, PVIRTIONET pThis)
     1084{
     1085    /** @todo If we ever start using more than one Rx/Tx queue pair, is a random queue
     1086              selection algorithm feasible or even necessary to prevent starvation? */
     1087    for (int idxQueue = 0; idxQueue < pThis->cVirtQueues; idxQueue += 2) /* Skip odd queue #'s because Rx queues only! */
     1088    {
     1089        if (!IS_RX_QUEUE(idxQueue))
     1090            continue;
     1091
     1092        if (RT_SUCCESS(virtioNetR3IsRxQueuePrimed(pDevIns, pThis, idxQueue)))
     1093            return true;
     1094    }
     1095    return false;
     1096}
    10831097/*
    10841098 * Returns true if VirtIO core and device are in a running and operational state
     
    11081122    PVIRTIONET   pThis   = PDMDEVINS_2_DATA(pDevIns, PVIRTIONET);
    11091123
    1110     if (!virtioNetAllSystemsGo(pThis, pDevIns))
    1111     {
    1112         LogFunc(("%s VirtIO not ready\n", INSTANCE(pThis)));
    1113         return VERR_NET_NO_BUFFER_SPACE;
    1114     }
    1115 
     1124    if (virtioNetR3AreRxBufsAvail(pDevIns, pThis))
     1125    {
     1126            LogFunc(("%s Rx bufs now available, releasing waiter...\n", INSTANCE(pThis)));
     1127            return VINF_SUCCESS;
     1128    }
    11161129    if (!timeoutMs)
    11171130        return VERR_NET_NO_BUFFER_SPACE;
     
    11211134    ASMAtomicXchgBool(&pThis->fLeafWantsRxBuffers, true);
    11221135
    1123     /** @todo If we ever start using more than one Rx/Tx queue pair, is a random queue
    1124               selection algorithm feasible or even necessary to prevent starvation? */
    11251136    do {
    1126         for (int idxQueue = 0; idxQueue < pThis->cVirtQueues; idxQueue += 2) /* Skip odd queue #'s because Rx queues only! */
     1137        if (virtioNetR3AreRxBufsAvail(pDevIns, pThis))
    11271138        {
    1128             if (!IS_RX_QUEUE(idxQueue))
    1129                 continue;
    1130 
    1131             if (RT_SUCCESS(virtioNetR3IsRxQueuePrimed(pDevIns, pThis, idxQueue)))
    1132             {
    1133                 LogFunc(("%s Rx bufs now available, releasing waiter...", INSTANCE(pThis)));
     1139                LogFunc(("%s Rx bufs now available, releasing waiter...\n", INSTANCE(pThis)));
    11341140                return VINF_SUCCESS;
    1135             }
    11361141        }
    11371142        LogFunc(("%s Starved for guest Rx bufs, waiting %u ms ...\n",
    11381143                 INSTANCE(pThis), timeoutMs));
    11391144
    1140         int rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns,
    1141                         pThis->hEventRxDescAvail, timeoutMs);
     1145        int rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->hEventRxDescAvail, timeoutMs);
    11421146
    11431147        if (rc == VERR_TIMEOUT || rc == VERR_INTERRUPTED)
     
    14551459                                               size_t cb, PCPDMNETWORKGSO pGso)
    14561460{
     1461LogFunc(("\n"));
    14571462    PVIRTIONETCC    pThisCC = RT_FROM_MEMBER(pInterface, VIRTIONETCC, INetworkDown);
    14581463    PPDMDEVINS      pDevIns = pThisCC->pDevIns;
    14591464    PVIRTIONET      pThis   = PDMDEVINS_2_DATA(pDevIns, PVIRTIONET);
    1460 
    1461     LogFunc(("%s\n", pThis));
    14621465
    14631466    if (!pThis->fVirtioReady)
     
    20682071    /** @todo If we ever start using more than one Rx/Tx queue pair, is a random queue
    20692072          selection algorithm feasible or even necessary */
    2070 
     2073    LogFunc(("\n"));
    20712074    virtioNetR3TransmitPendingPackets(pDevIns, pThis, pThisCC, TXQIDX_QPAIR(0), false /*fOnWorkerThread*/);
    20722075}
     
    26252628    /* Initialize the generic Virtio core: */
    26262629    pThisCC->Virtio.pfnStatusChanged        = virtioNetR3StatusChanged;
    2627     pThisCC->Virtio.pfnQueueNotified        = virtioNetR3QueueNotified
    2628     ;
     2630    pThisCC->Virtio.pfnQueueNotified        = virtioNetR3QueueNotified;
    26292631    pThisCC->Virtio.pfnDevCapRead           = virtioNetR3DevCapRead;
    26302632    pThisCC->Virtio.pfnDevCapWrite          = virtioNetR3DevCapWrite;
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r83028 r83058  
    226226}
    227227
    228 DECLINLINE(void) virtioWriteUsedFlags(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue, uint16_t fFlags)
     228DECLINLINE(void) virtioWriteUsedRingFlags(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue, uint16_t fFlags)
    229229{
    230230    AssertMsg(pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK, ("Called with guest driver not ready\n"));
     
    256256#endif
    257257
    258 DECLINLINE(uint16_t) virtioReadUsedFlags(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue)
     258DECLINLINE(uint16_t) virtioReadUsedRingFlags(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue)
    259259{
    260260    uint16_t fFlags = 0;
     
    681681    if (pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK)
    682682    {
    683         uint16_t fFlags = virtioReadUsedFlags(pVirtio->pDevIns, pVirtio, idxQueue);
     683        uint16_t fFlags = virtioReadUsedRingFlags(pVirtio->pDevIns, pVirtio, idxQueue);
    684684
    685685        if (fEnabled)
     
    688688            fFlags |= VIRTQ_USED_F_NO_NOTIFY;
    689689
    690         virtioWriteUsedFlags(pVirtio->pDevIns, pVirtio, idxQueue, fFlags);
     690        virtioWriteUsedRingFlags(pVirtio->pDevIns, pVirtio, idxQueue, fFlags);
    691691    }
    692692}
     
    10141014    {
    10151015        /** If guest driver hasn't suppressed interrupts, interrupt  */
    1016         if (fForce || !(virtioReadUsedFlags(pDevIns, pVirtio, idxQueue) & VIRTQ_AVAIL_F_NO_INTERRUPT))
     1016        if (fForce || !(virtioReadUsedRingFlags(pDevIns, pVirtio, idxQueue) & VIRTQ_AVAIL_F_NO_INTERRUPT))
    10171017        {
    10181018            virtioKick(pDevIns, pVirtio, VIRTIO_ISR_VIRTQ_INTERRUPT, pVirtio->uQueueMsixVector[idxQueue], fForce);
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