VirtualBox

Ignore:
Timestamp:
Jun 21, 2012 5:21:12 PM (12 years ago)
Author:
vboxsync
Message:

PCNet,NetShaper: PCNet exact packet len counting + wrong lock order fix in NetShaper (#5582)

File:
1 edited

Legend:

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

    r41774 r41864  
    296296    STAMPROFILE                         StatTransmitSendR3;
    297297    STAMPROFILE                         StatTransmitSendRZ;
     298    STAMPROFILEADV                      StatTxLenCalcRZ;
     299    STAMPROFILEADV                      StatTxLenCalcR3;
    298300    STAMPROFILEADV                      StatTdtePollRZ;
    299301    STAMPROFILEADV                      StatTdtePollR3;
     
    18211823
    18221824/**
     1825 * Poll Transmit Descriptor Table Entry
     1826 * @return true if transmit descriptors available
     1827 */
     1828static int pcnetCalcPacketLen(PCNetState *pThis, unsigned cb)
     1829{
     1830    TMD tmd;
     1831    unsigned cbPacket = cb;
     1832    uint32_t iDesc = CSR_XMTRC(pThis);
     1833
     1834    STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatTxLenCalc), a);
     1835    do
     1836    {
     1837        /* Advance the ring counter */
     1838        if (iDesc < 2)
     1839            iDesc = CSR_XMTRL(pThis);
     1840        else
     1841            iDesc--;
     1842
     1843        RTGCPHYS32 addrDesc = pcnetTdraAddr(pThis, iDesc);
     1844
     1845        if (!pcnetTmdLoad(pThis, &tmd, PHYSADDR(pThis, addrDesc), true))
     1846        {
     1847            STAM_PROFILE_ADV_STOP(&pThis->CTX_SUFF_Z(StatTxLenCalc), a);
     1848            /*
     1849             * No need to count further since this packet won't be sent anyway
     1850             * due to underflow.
     1851             */
     1852            Log3(("#%d pcnetCalcPacketLen: underflow, return %u\n", PCNET_INST_NR, cbPacket));
     1853            return cbPacket;
     1854        }
     1855        if (RT_UNLIKELY(tmd.tmd1.ones != 15))
     1856        {
     1857            STAM_PROFILE_ADV_STOP(&pThis->CTX_SUFF_Z(StatTxLenCalc), a);
     1858            LogRel(("PCNet#%d: BAD TMD XDA=%#010x\n",
     1859                    PCNET_INST_NR, PHYSADDR(pThis, addrDesc)));
     1860            Log3(("#%d pcnetCalcPacketLen: bad TMD, return %u\n", PCNET_INST_NR, cbPacket));
     1861            return cbPacket;
     1862        }
     1863        Log3(("#%d pcnetCalcPacketLen: got valid TMD, cb=%u\n", PCNET_INST_NR, 4096 - tmd.tmd1.bcnt));
     1864        cbPacket += 4096 - tmd.tmd1.bcnt;
     1865    } while (!tmd.tmd1.enp);
     1866    STAM_PROFILE_ADV_STOP(&pThis->CTX_SUFF_Z(StatTxLenCalc), a);
     1867
     1868    Log3(("#%d pcnetCalcPacketLen: return %u\n", PCNET_INST_NR, cbPacket));
     1869    return cbPacket;
     1870}
     1871
     1872
     1873/**
    18231874 * Write data into guest receive buffers.
    18241875 */
     
    25032554             */
    25042555            unsigned cb = 4096 - tmd.tmd1.bcnt;
    2505             rc = pcnetXmitAllocBuf(pThis, RT_MAX(MAX_FRAME, cb), fLoopback, &SgLoop, &pSgBuf);
     2556            rc = pcnetXmitAllocBuf(pThis, pcnetCalcPacketLen(pThis, cb), fLoopback, &SgLoop, &pSgBuf);
    25062557            if (rc == VERR_TRY_AGAIN)
    25072558            {
     
    53315382    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitSendRZ,     STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet send transmit in RZ","/Devices/PCNet%d/Transmit/SendRZ", iInstance);
    53325383    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitSendR3,     STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet send transmit in R3","/Devices/PCNet%d/Transmit/SendR3", iInstance);
     5384    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTxLenCalcRZ,        STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet TX len calc in RZ",  "/Devices/PCNet%d/Transmit/LenCalcRZ", iInstance);
     5385    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTxLenCalcR3,        STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet TX len calc in R3",  "/Devices/PCNet%d/Transmit/LenCalcR3", iInstance);
    53335386    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTdtePollRZ,         STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet TdtePoll in RZ",     "/Devices/PCNet%d/TdtePollRZ", iInstance);
    53345387    PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTdtePollR3,         STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet TdtePoll in R3",     "/Devices/PCNet%d/TdtePollR3", iInstance);
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