VirtualBox

Changeset 41809 in vbox


Ignore:
Timestamp:
Jun 18, 2012 6:39:51 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
78627
Message:

virtio: netshaper support (#5582)

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

Legend:

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

    r41409 r41809  
    10741074
    10751075    VQUEUEELEM elem;
    1076     while (vqueueGet(&pState->VPCI, pQueue, &elem))
     1076    /*
     1077     * Do not remove descriptors from available ring yet, try to allocate the
     1078     * buffer first.
     1079     */
     1080    while (vqueuePeek(&pState->VPCI, pQueue, &elem))
    10771081    {
    10781082        unsigned int uOffset = 0;
     
    11651169                }
    11661170                else
    1167                     LogRel(("virtio-net: failed to allocate SG buffer: size=%u rc=%Rrc\n", uSize, rc));
     1171                {
     1172                    Log4(("virtio-net: failed to allocate SG buffer: size=%u rc=%Rrc\n", uSize, rc));
     1173                    STAM_PROFILE_STOP(&pState->StatTransmitSend, a);
     1174                    STAM_PROFILE_ADV_STOP(&pState->StatTransmit, a);
     1175                    /* Stop trying to fetch TX descriptors until we get more bandwidth. */
     1176                    break;
     1177                }
    11681178
    11691179                STAM_PROFILE_STOP(&pState->StatTransmitSend, a);
     
    11711181            }
    11721182        }
     1183        /* Remove this descriptor chain from the available ring */
     1184        vqueueSkip(&pState->VPCI, pQueue);
    11731185        vqueuePut(&pState->VPCI, pQueue, &elem, sizeof(VNETHDR) + uOffset);
    11741186        vqueueSync(&pState->VPCI, pQueue);
  • trunk/src/VBox/Devices/VirtIO/Virtio.cpp

    r40280 r41809  
    111111}
    112112
    113 bool vqueueGet(PVPCISTATE pState, PVQUEUE pQueue, PVQUEUEELEM pElem)
     113bool vqueueSkip(PVPCISTATE pState, PVQUEUE pQueue)
    114114{
    115115    if (vqueueIsEmpty(pState, pQueue))
    116116        return false;
    117117
     118    Log2(("%s vqueueSkip: %s avail_idx=%u\n", INSTANCE(pState),
     119          QUEUENAME(pState, pQueue), pQueue->uNextAvailIndex));
     120    pQueue->uNextAvailIndex++;
     121    return true;
     122}
     123
     124bool vqueueGet(PVPCISTATE pState, PVQUEUE pQueue, PVQUEUEELEM pElem, bool fRemove)
     125{
     126    if (vqueueIsEmpty(pState, pQueue))
     127        return false;
     128
    118129    pElem->nIn = pElem->nOut = 0;
    119130
     
    122133
    123134    VRINGDESC desc;
    124     uint16_t  idx = vringReadAvail(pState, &pQueue->VRing, pQueue->uNextAvailIndex++);
     135    uint16_t  idx = vringReadAvail(pState, &pQueue->VRing, pQueue->uNextAvailIndex);
     136    if (fRemove)
     137        pQueue->uNextAvailIndex++;
    125138    pElem->uIndex = idx;
    126139    do
  • trunk/src/VBox/Devices/VirtIO/Virtio.h

    r39091 r41809  
    304304}
    305305
    306 bool vqueueGet(PVPCISTATE pState, PVQUEUE pQueue, PVQUEUEELEM pElem);
     306bool vqueueSkip(PVPCISTATE pState, PVQUEUE pQueue);
     307bool vqueueGet(PVPCISTATE pState, PVQUEUE pQueue, PVQUEUEELEM pElem, bool fRemove = true);
    307308void vqueuePut(PVPCISTATE pState, PVQUEUE pQueue, PVQUEUEELEM pElem, uint32_t uLen, uint32_t uReserved = 0);
    308309void vqueueNotify(PVPCISTATE pState, PVQUEUE pQueue);
    309310void vqueueSync(PVPCISTATE pState, PVQUEUE pQueue);
    310311
     312DECLINLINE(bool) vqueuePeek(PVPCISTATE pState, PVQUEUE pQueue, PVQUEUEELEM pElem)
     313{
     314    return vqueueGet(pState, pQueue, pElem, /* fRemove */ false);
     315}
    311316
    312317DECLINLINE(bool) vqueueIsReady(PVPCISTATE pState, PVQUEUE pQueue)
Note: See TracChangeset for help on using the changeset viewer.

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