VirtualBox

Changeset 61691 in vbox for trunk


Ignore:
Timestamp:
Jun 14, 2016 9:44:53 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
108049
Message:

bugref:8319: Devices/E1000: Interrupt throttling re-worked

File:
1 edited

Legend:

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

    r60775 r61691  
    6262 */
    6363#define E1K_LSC_ON_SLU
    64 /** @def E1K_ITR_ENABLED
    65  * E1K_ITR_ENABLED reduces the number of interrupts generated by E1000 if a
    66  * guest driver requested it by writing non-zero value to the Interrupt
    67  * Throttling Register (see section 13.4.18 in "8254x Family of Gigabit
    68  * Ethernet Controllers Software Developer’s Manual").
    69  */
    70 //#define E1K_ITR_ENABLED
    7164/** @def E1K_TX_DELAY
    7265 * E1K_TX_DELAY aims to improve guest-host transfer rate for TCP streams by
     
    181174
    182175#if 0
     176# define LOG_ENABLED
    183177# define E1kLogRel(a) LogRel(a)
     178# undef Log6
     179# define Log6(a) LogRel(a)
    184180#else
    185181# define E1kLogRel(a) do { } while (0)
     
    10851081    /** EMT: Compute Ethernet CRC for RX packets. */
    10861082    bool        fEthernetCRC;
    1087 
    1088     bool        Alignment2[3];
     1083    /** All: throttle interrupts. */
     1084    bool        fItrEnabled;
     1085    /** All: throttle RX interrupts. */
     1086    bool        fItrRxEnabled;
     1087
     1088    bool        Alignment2;
    10891089    /** Link up delay (in milliseconds). */
    10901090    uint32_t    cMsLinkUpDelay;
     
    18651865
    18661866/**
     1867 * Raise an interrupt later.
     1868 *
     1869 * @param   pThis       The device state structure.
     1870 */
     1871inline void e1kPostponeInterrupt(PE1KSTATE pThis, uint64_t uNanoseconds)
     1872{
     1873    if (!TMTimerIsActive(pThis->CTX_SUFF(pIntTimer)))
     1874        TMTimerSetNano(pThis->CTX_SUFF(pIntTimer), uNanoseconds);
     1875}
     1876
     1877/**
    18671878 * Raise interrupt if not masked.
    18681879 *
     
    18791890    if (ICR & IMS)
    18801891    {
    1881 #if 0
    1882         if (pThis->fDelayInts)
    1883         {
    1884             E1K_INC_ISTAT_CNT(pThis->uStatIntDly);
    1885             pThis->iStatIntLostOne = 1;
    1886             E1kLog2(("%s e1kRaiseInterrupt: Delayed. ICR=%08x\n",
    1887                     pThis->szPrf, ICR));
    1888 #define E1K_LOST_IRQ_THRSLD 20
    1889 //#define E1K_LOST_IRQ_THRSLD 200000000
    1890             if (pThis->iStatIntLost >= E1K_LOST_IRQ_THRSLD)
    1891             {
    1892                 E1kLog2(("%s WARNING! Disabling delayed interrupt logic: delayed=%d, delivered=%d\n",
    1893                         pThis->szPrf, pThis->uStatIntDly, pThis->uStatIntLate));
    1894                 pThis->fIntMaskUsed = false;
    1895                 pThis->uStatDisDly++;
    1896             }
    1897         }
    1898         else
    1899 #endif
    19001892        if (pThis->fIntRaised)
    19011893        {
     
    19061898        else
    19071899        {
    1908 #ifdef E1K_ITR_ENABLED
    1909             uint64_t tstamp = TMTimerGet(pThis->CTX_SUFF(pIntTimer));
    1910             /* interrupts/sec = 1 / (256 * 10E-9 * ITR) */
    1911             E1kLog2(("%s e1kRaiseInterrupt: tstamp - pThis->u64AckedAt = %d, ITR * 256 = %d\n",
    1912                         pThis->szPrf, (uint32_t)(tstamp - pThis->u64AckedAt), ITR * 256));
    1913             //if (!!ITR && pThis->fIntMaskUsed && tstamp - pThis->u64AckedAt < ITR * 256)
    1914             if (!!ITR && tstamp - pThis->u64AckedAt < ITR * 256 && !(ICR & ICR_RXT0))
     1900            uint64_t tsNow = TMTimerGet(pThis->CTX_SUFF(pIntTimer));
     1901            if (!!ITR && tsNow - pThis->u64AckedAt < ITR * 256
     1902                     && pThis->fItrEnabled && (pThis->fItrRxEnabled || !(ICR & ICR_RXT0)))
    19151903            {
    19161904                E1K_INC_ISTAT_CNT(pThis->uStatIntEarly);
    19171905                E1kLog2(("%s e1kRaiseInterrupt: Too early to raise again: %d ns < %d ns.\n",
    1918                         pThis->szPrf, (uint32_t)(tstamp - pThis->u64AckedAt), ITR * 256));
     1906                        pThis->szPrf, (uint32_t)(tsNow - pThis->u64AckedAt), ITR * 256));
     1907                e1kPostponeInterrupt(pThis, ITR * 256);
    19191908            }
    19201909            else
    1921 #endif
    19221910            {
    19231911
     
    28852873    if (RT_SUCCESS(rc))
    28862874    {
     2875        /* Do not return masked bits. */
     2876        value &= IMS;
    28872877        if (value)
    28882878        {
     
    29612951    E1kLogRel(("E1000: irq enabled, RDH=%x RDT=%x TDH=%x TDT=%x\n", RDH, RDT, TDH, TDT));
    29622952    E1kLog(("%s e1kRegWriteIMS: IRQ enabled\n", pThis->szPrf));
    2963     /* Mask changes, we need to raise pending interrupts. */
    2964     if ((ICR & IMS) && !pThis->fLocked)
    2965     {
    2966         E1kLog2(("%s e1kRegWriteIMS: IRQ pending (%08x), arming late int timer...\n",
    2967                  pThis->szPrf, ICR));
    2968         /* Raising an interrupt immediately causes win7 to hang upon NIC reconfiguration, see @bugref{5023}. */
    2969         TMTimerSet(pThis->CTX_SUFF(pIntTimer), TMTimerFromNano(pThis->CTX_SUFF(pIntTimer), ITR * 256) +
    2970                    TMTimerGet(pThis->CTX_SUFF(pIntTimer)));
    2971     }
     2953    e1kRaiseInterrupt(pThis, VINF_IOM_R3_MMIO_WRITE, 0);
    29722954
    29732955    return VINF_SUCCESS;
     
    74737455    if (!CFGMR3AreValuesValid(pCfg, "MAC\0" "CableConnected\0" "AdapterType\0"
    74747456                                    "LineSpeed\0" "GCEnabled\0" "R0Enabled\0"
     7457                                    "ItrEnabled\0" "ItrRxEnabled\0"
    74757458                                    "EthernetCRC\0" "GSOEnabled\0" "LinkUpDelay\0"))
    74767459        return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
     
    74797462    /** @todo: LineSpeed unused! */
    74807463
    7481     pThis->fR0Enabled   = true;
    7482     pThis->fRCEnabled   = true;
    7483     pThis->fEthernetCRC = true;
    7484     pThis->fGSOEnabled  = true;
     7464    pThis->fR0Enabled    = true;
     7465    pThis->fRCEnabled    = true;
     7466    pThis->fEthernetCRC  = true;
     7467    pThis->fGSOEnabled   = true;
     7468    pThis->fItrEnabled   = true;
     7469    pThis->fItrRxEnabled = true;
    74857470
    74867471    /* Get config params */
     
    75187503                                N_("Configuration error: Failed to get the value of 'GSOEnabled'"));
    75197504
     7505    rc = CFGMR3QueryBoolDef(pCfg, "ItrEnabled", &pThis->fItrEnabled, true);
     7506    if (RT_FAILURE(rc))
     7507        return PDMDEV_SET_ERROR(pDevIns, rc,
     7508                                N_("Configuration error: Failed to get the value of 'ItrEnabled'"));
     7509
     7510    rc = CFGMR3QueryBoolDef(pCfg, "ItrRxEnabled", &pThis->fItrRxEnabled, true);
     7511    if (RT_FAILURE(rc))
     7512        return PDMDEV_SET_ERROR(pDevIns, rc,
     7513                                N_("Configuration error: Failed to get the value of 'ItrRxEnabled'"));
     7514
    75207515    rc = CFGMR3QueryU32Def(pCfg, "LinkUpDelay", (uint32_t*)&pThis->cMsLinkUpDelay, 5000); /* ms */
    75217516    if (RT_FAILURE(rc))
     
    75287523        LogRel(("%s WARNING! Link up delay is disabled!\n", pThis->szPrf));
    75297524
    7530     E1kLog(("%s Chip=%s LinkUpDelay=%ums EthernetCRC=%s GSO=%s R0=%s GC=%s\n", pThis->szPrf,
     7525    LogRel(("%s Chip=%s LinkUpDelay=%ums EthernetCRC=%s GSO=%s Itr=%s ItrRx=%s R0=%s GC=%s\n", pThis->szPrf,
    75317526            g_Chips[pThis->eChip].pcszName, pThis->cMsLinkUpDelay,
    75327527            pThis->fEthernetCRC ? "on" : "off",
    75337528            pThis->fGSOEnabled ? "enabled" : "disabled",
     7529            pThis->fItrEnabled ? "enabled" : "disabled",
     7530            pThis->fItrRxEnabled ? "enabled" : "disabled",
    75347531            pThis->fR0Enabled ? "enabled" : "disabled",
    75357532            pThis->fRCEnabled ? "enabled" : "disabled"));
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