VirtualBox

Changeset 41407 in vbox


Ignore:
Timestamp:
May 22, 2012 5:53:33 PM (13 years ago)
Author:
vboxsync
Message:

Network: added LinkUpDelay parameter to e1000,pcnet,virtio-net

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

Legend:

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

    r41123 r41407  
    10461046
    10471047    bool        Alignment2[3];
    1048     uint32_t    Alignment3;
     1048    /** Link up delay (in milliseconds). */
     1049    uint32_t    uLinkUpDelay;
    10491050
    10501051    /** All: Device register storage. */
     
    21642165
    21652166
     2167/**
     2168 * Bring the link up after the configured delay, 5 seconds by default.
     2169 *
     2170 * @param   pState      The device state structure.
     2171 * @thread  any
     2172 */
     2173DECLINLINE(void) e1kBringLinkUpDelayed(E1KSTATE* pState)
     2174{
     2175    E1kLog(("%s Will bring up the link in %d seconds...\n",
     2176            INSTANCE(pState), pState->uLinkUpDelay / 1000));
     2177    e1kArmTimer(pState, pState->CTX_SUFF(pLUTimer), pState->uLinkUpDelay * 1000);
     2178}
     2179
    21662180#if 0 /* unused */
    21672181/**
     
    22322246        {
    22332247            /* The driver indicates that we should bring up the link */
    2234             /* Do so in 5 seconds. */
    2235             e1kArmTimer(pState, pState->CTX_SUFF(pLUTimer), 5000000);
     2248            /* Do so in 5 seconds (by default). */
     2249            e1kBringLinkUpDelayed(pState);
    22362250            /*
    22372251             * Change the status (but not PHY status) anyway as Windows expects
     
    28732887        return;
    28742888
     2889    E1kLog(("%s e1kLinkUpTimer: Link is up\n", INSTANCE(pState)));
    28752890    STATUS |= STATUS_LU;
    28762891    Phy::setLinkStatus(&pState->phy, true);
     
    58975912        if (fNewUp)
    58985913        {
    5899             E1kLog(("%s Link will be up in approximately 5 secs\n", INSTANCE(pState)));
     5914            E1kLog(("%s Link will be up in approximately %d secs\n",
     5915                    INSTANCE(pState), pState->uLinkUpDelay / 1000));
    59005916            pState->fCableConnected = true;
    59015917            STATUS &= ~STATUS_LU;
    59025918            Phy::setLinkStatus(&pState->phy, false);
    59035919            e1kRaiseInterrupt(pState, VERR_SEM_BUSY, ICR_LSC);
    5904             /* Restore the link back in 5 second. */
    5905             e1kArmTimer(pState, pState->pLUTimerR3, 5000000);
     5920            /* Restore the link back in 5 seconds (by default). */
     5921            e1kBringLinkUpDelayed(pState);
    59065922        }
    59075923        else
     
    62046220    */
    62056221    if (    (STATUS & STATUS_LU)
    6206         && !PDMDevHlpVMTeleportedAndNotFullyResumedYet(pDevIns))
     6222        && !PDMDevHlpVMTeleportedAndNotFullyResumedYet(pDevIns)
     6223        && pState->uLinkUpDelay)
    62076224    {
    62086225        E1kLog(("%s Link is down temporarily\n", INSTANCE(pState)));
     
    62106227        Phy::setLinkStatus(&pState->phy, false);
    62116228        e1kRaiseInterrupt(pState, VERR_SEM_BUSY, ICR_LSC);
    6212         /* Restore the link back in five seconds. */
    6213         e1kArmTimer(pState, pState->pLUTimerR3, 5000000);
     6229        /* Restore the link back in five seconds (default). */
     6230        e1kBringLinkUpDelayed(pState);
    62146231    }
    62156232    return VINF_SUCCESS;
     
    63196336        Phy::setLinkStatus(&pState->phy, false);
    63206337        e1kRaiseInterrupt(pState, VERR_SEM_BUSY, ICR_LSC);
    6321         /* Restore the link back in 5 second. */
    6322         e1kArmTimer(pState, pState->pLUTimerR3, 5000000);
     6338        /* Restore the link back in 5 seconds (default). */
     6339        e1kBringLinkUpDelayed(pState);
    63236340    }
    63246341
     
    66626679    if (!CFGMR3AreValuesValid(pCfg, "MAC\0" "CableConnected\0" "AdapterType\0"
    66636680                                    "LineSpeed\0" "GCEnabled\0" "R0Enabled\0"
    6664                                     "EthernetCRC\0"))
     6681                                    "EthernetCRC\0" "LinkUpDelay\0"))
    66656682        return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
    66666683                                N_("Invalid configuration for E1000 device"));
     
    67016718        return PDMDEV_SET_ERROR(pDevIns, rc,
    67026719                                N_("Configuration error: Failed to get the value of 'EthernetCRC'"));
    6703 
    6704     E1kLog(("%s Chip=%s\n", INSTANCE(pState), g_Chips[pState->eChip].pcszName));
     6720    rc = CFGMR3QueryU32Def(pCfg, "LinkUpDelay", (uint32_t*)&pState->uLinkUpDelay, 5000); /* ms */
     6721    if (RT_FAILURE(rc))
     6722        return PDMDEV_SET_ERROR(pDevIns, rc,
     6723                                N_("Configuration error: Failed to get the value of 'LinkUpDelay'"));
     6724    Assert(pState->uLinkUpDelay <= 300000); /* less than 5 minutes */
     6725    if (pState->uLinkUpDelay > 5000)
     6726    {
     6727        LogRel(("%s WARNING! Link up delay is set to %u seconds!\n",
     6728                INSTANCE(pState), pState->uLinkUpDelay / 1000));
     6729    }
     6730    else if (pState->uLinkUpDelay == 0)
     6731    {
     6732        LogRel(("%s WARNING! Link up delay is disabled!\n", INSTANCE(pState)));
     6733    }
     6734
     6735    E1kLog(("%s Chip=%s LinkUpDelay=%ums\n", INSTANCE(pState),
     6736            g_Chips[pState->eChip].pcszName, pState->uLinkUpDelay));
    67056737
    67066738    /* Initialize state structure */
  • trunk/src/VBox/Devices/Network/DevPCNet.cpp

    r40766 r41407  
    272272    bool                                fAm79C973;
    273273    uint32_t                            u32LinkSpeed;
     274    uint32_t                            uLinkUpDelay;
     275    uint32_t                            Alignment6;
    274276
    275277    STAMCOUNTER                         StatReceiveBytes;
     
    43334335        pThis->aCSR[0] |= RT_BIT(15) | RT_BIT(13); /* ERR | CERR (this is probably wrong) */
    43344336        pThis->Led.Asserted.s.fError = pThis->Led.Actual.s.fError = 1;
    4335         int rc = TMTimerSetMillies(pThis->pTimerRestore, 5000);
     4337        int rc = TMTimerSetMillies(pThis->pTimerRestore, pThis->uLinkUpDelay);
    43364338        AssertRC(rc);
    43374339    }
     
    47764778            pThis->aCSR[0] |= RT_BIT(15) | RT_BIT(13); /* ERR | CERR (this is probably wrong) */
    47774779            pThis->Led.Asserted.s.fError = pThis->Led.Actual.s.fError = 1;
    4778             int rc = TMTimerSetMillies(pThis->pTimerRestore, 5000);
     4780            int rc = TMTimerSetMillies(pThis->pTimerRestore, pThis->uLinkUpDelay);
    47794781            AssertRC(rc);
    47804782        }
     
    50225024     * Validate configuration.
    50235025     */
    5024     if (!CFGMR3AreValuesValid(pCfg, "MAC\0" "CableConnected\0" "Am79C973\0" "LineSpeed\0" "GCEnabled\0" "R0Enabled\0" "PrivIfEnabled\0"))
     5026    if (!CFGMR3AreValuesValid(pCfg, "MAC\0" "CableConnected\0" "Am79C973\0" "LineSpeed\0" "GCEnabled\0" "R0Enabled\0" "PrivIfEnabled\0" "LinkUpDelay\0"))
    50255027        return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
    50265028                                N_("Invalid configuration for pcnet device"));
     
    50635065    pThis->fR0Enabled = false;
    50645066#endif /* !PCNET_GC_ENABLED */
     5067
     5068    rc = CFGMR3QueryU32Def(pCfg, "LinkUpDelay", (uint32_t*)&pThis->uLinkUpDelay, 5000); /* ms */
     5069    if (RT_FAILURE(rc))
     5070        return PDMDEV_SET_ERROR(pDevIns, rc,
     5071                                N_("Configuration error: Failed to get the value of 'LinkUpDelay'"));
     5072    Assert(pThis->uLinkUpDelay <= 300000); /* less than 5 minutes */
     5073    if (pThis->uLinkUpDelay > 5000 || pThis->uLinkUpDelay < 100)
     5074    {
     5075        LogRel(("PCNet#%d WARNING! Link up delay is set to %u seconds!\n",
     5076                iInstance, pThis->uLinkUpDelay / 1000));
     5077    }
     5078    Log(("#%d Link up delay is set to %u seconds\n",
     5079         iInstance, pThis->uLinkUpDelay / 1000));
    50655080
    50665081
  • trunk/src/VBox/Devices/Network/DevVirtioNet.cpp

    r40282 r41407  
    161161    /** True if physical cable is attached in configuration. */
    162162    bool                    fCableConnected;
     163    /** Link up delay (in milliseconds). */
     164    uint32_t                uLinkUpDelay;
     165
     166    uint32_t                alignment;
    163167
    164168    /** Number of packet being sent/received to show in debug log. */
     
    15921596        vpciRaiseInterrupt(&pState->VPCI, VERR_SEM_BUSY, VPCI_ISR_CONFIG);
    15931597        /* Restore the link back in 5 seconds. */
    1594         int rc = TMTimerSetMillies(pState->pLinkUpTimer, 5000);
     1598        int rc = TMTimerSetMillies(pState->pLinkUpTimer, pState->uLinkUpDelay);
    15951599        AssertRC(rc);
    15961600    }
     
    19351939     * Validate configuration.
    19361940     */
    1937     if (!CFGMR3AreValuesValid(pCfg, "MAC\0" "CableConnected\0" "LineSpeed\0"))
     1941    if (!CFGMR3AreValuesValid(pCfg, "MAC\0" "CableConnected\0" "LineSpeed\0" "LinkUpDelay\0"))
    19381942                    return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
    19391943                                            N_("Invalid configuration for VirtioNet device"));
     
    19491953        return PDMDEV_SET_ERROR(pDevIns, rc,
    19501954                                N_("Configuration error: Failed to get the value of 'CableConnected'"));
     1955    rc = CFGMR3QueryU32Def(pCfg, "LinkUpDelay", (uint32_t*)&pState->uLinkUpDelay, 5000); /* ms */
     1956    if (RT_FAILURE(rc))
     1957        return PDMDEV_SET_ERROR(pDevIns, rc,
     1958                                N_("Configuration error: Failed to get the value of 'LinkUpDelay'"));
     1959    Assert(pState->uLinkUpDelay <= 300000); /* less than 5 minutes */
     1960    if (pState->uLinkUpDelay > 5000 || pState->uLinkUpDelay < 100)
     1961    {
     1962        LogRel(("%s WARNING! Link up delay is set to %u seconds!\n",
     1963                INSTANCE(pState), pState->uLinkUpDelay / 1000));
     1964    }
     1965    Log(("%s Link up delay is set to %u seconds\n",
     1966         INSTANCE(pState), pState->uLinkUpDelay / 1000));
    19511967
    19521968    /* Initialize PCI config space */
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