VirtualBox

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


Ignore:
Timestamp:
Apr 13, 2021 10:55:07 AM (4 years ago)
Author:
vboxsync
Message:

Network: Do not bring up links for "not attached" adapters.

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

Legend:

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

    r88426 r88490  
    28902890
    28912891/**
     2892 * A helper function to detect the link state to the other side of "the wire".
     2893 *
     2894 * When deciding to bring up the link we need to take into account both if the
     2895 * cable is connected and if our device is actually connected to the outside
     2896 * world. If no driver is attached we won't be able to allocate TX buffers,
     2897 * which will prevent us from TX descriptor processing, which will result in
     2898 * "TX unit hang" in the guest.
     2899 *
     2900 * @returns true if the device is connected to something.
     2901 *
     2902 * @param   pDevIns     The device instance.
     2903 */
     2904DECLINLINE(bool) e1kIsConnected(PPDMDEVINS pDevIns)
     2905{
     2906    PE1KSTATE     pThis   = PDMDEVINS_2_DATA(pDevIns, PE1KSTATE);
     2907    PE1KSTATECC   pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PE1KSTATECC);
     2908    return pThis->fCableConnected && pThisCC->CTX_SUFF(pDrv);
     2909}
     2910
     2911/**
    28922912 * A callback used by PHY to indicate that the link needs to be updated due to
    28932913 * reset of PHY.
     
    29012921
    29022922    /* Make sure we have cable connected and MAC can talk to PHY */
    2903     if (pThis->fCableConnected && (CTRL & CTRL_SLU))
     2923    if (e1kIsConnected(pDevIns) && (CTRL & CTRL_SLU))
    29042924        e1kArmTimer(pDevIns, pThis, pThis->hLUTimer, E1K_INIT_LINKUP_DELAY_US);
    29052925}
     
    29482968        if (   (value & CTRL_SLU)
    29492969            && !(CTRL & CTRL_SLU)
    2950             && pThis->fCableConnected
     2970            && e1kIsConnected(pDevIns)
    29512971            && !PDMDevHlpTimerIsActive(pDevIns, pThis->hLUTimer))
    29522972        {
     
    36543674     * on reset even if the cable is unplugged (see @bugref{8942}).
    36553675     */
    3656     if (pThis->fCableConnected)
     3676    if (e1kIsConnected(pDevIns))
    36573677    {
    36583678        /* 82543GC does not have an internal PHY */
  • trunk/src/VBox/Devices/Network/DevPCNet.cpp

    r87773 r88490  
    32923292                | 0x0004    /* Link up. */
    32933293                | 0x0001;   /* Extended Capability, i.e. registers 4+ valid. */
    3294             if (!pThis->fLinkUp || pThis->fLinkTempDown || isolate) {
     3294            if (!pcnetIsLinkUp(pThis) || isolate) {
    32953295                val &= ~(0x0020 | 0x0004);
    32963296                pThis->cLinkDownReported++;
     
    33383338        case 5:
    33393339            /* Link partner ability register. */
    3340             if (pThis->fLinkUp && !pThis->fLinkTempDown && !isolate)
     3340            if (pcnetIsLinkUp(pThis) && !isolate)
    33413341                val =   0x8000  /* Next page bit. */
    33423342                      | 0x4000  /* Link partner acked us. */
     
    33533353        case 6:
    33543354            /* Auto negotiation expansion register. */
    3355             if (pThis->fLinkUp && !pThis->fLinkTempDown && !isolate)
     3355            if (pcnetIsLinkUp(pThis) && !isolate)
    33563356                val =   0x0008  /* Link partner supports npage. */
    33573357                      | 0x0004  /* Enable npage words. */
     
    33663366        case 18:
    33673367            /* Diagnostic Register (FreeBSD pcn/ac101 driver reads this). */
    3368             if (pThis->fLinkUp && !pThis->fLinkTempDown && !isolate)
     3368            if (pcnetIsLinkUp(pThis) && !isolate)
    33693369            {
    33703370                val =   0x0100  /* Receive PLL locked. */
  • trunk/src/VBox/Devices/Network/DevVirtioNet.cpp

    r87773 r88490  
    359359
    360360#ifdef IN_RING3
     361/**
     362 * A helper function to detect the link state to the other side of "the wire".
     363 *
     364 * When deciding to bring up the link we need to take into account both if the
     365 * cable is connected and if our device is actually connected to the outside
     366 * world. If no driver is attached we won't start the TX thread nor we will
     367 * initialize the TX semaphore, which is a problem for the TX queue handler.
     368 *
     369 * @returns true if the device is connected to something.
     370 *
     371 * @param   pDevIns     The device instance.
     372 */
     373DECLINLINE(bool) vnetR3IsConnected(PPDMDEVINS pDevIns)
     374{
     375    PVNETSTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVNETSTATE);
     376    PVNETSTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVNETSTATECC);
     377    return pThis->fCableConnected && pThisCC->pDrv;
     378}
     379
    361380/**
    362381 * Dump a packet to debug log.
     
    524543static DECLCALLBACK(int) vnetIoCb_Reset(PPDMDEVINS pDevIns)
    525544{
     545#ifndef IN_RING3
     546    RT_NOREF(pDevIns);
     547    return VINF_IOM_R3_IOPORT_WRITE;
     548#else
    526549    PVNETSTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVNETSTATE);
    527 #ifdef IN_RING3
    528550    PVNETSTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVNETSTATECC);
    529 #endif
     551
    530552    Log(("%s Reset triggered\n", INSTANCE(pThis)));
    531553
     
    540562
    541563    /// @todo Implement reset
    542     if (pThis->fCableConnected)
     564    if (vnetR3IsConnected(pDevIns))
    543565        pThis->config.uStatus = VNET_S_LINK_UP;
    544566    else
    545567        pThis->config.uStatus = 0;
    546     Log(("%s vnetIoCb_Reset: Link is %s\n", INSTANCE(pThis), pThis->fCableConnected ? "up" : "down"));
     568    Log(("%s vnetIoCb_Reset: Link is %s\n", INSTANCE(pThis), vnetR3IsConnected(pDevIns) ? "up" : "down"));
    547569
    548570    /*
     
    556578    memset(pThis->aVlanFilter, 0, sizeof(pThis->aVlanFilter));
    557579    pThis->uIsTransmitting   = 0;
    558 #ifndef IN_RING3
    559     return VINF_IOM_R3_IOPORT_WRITE;
    560 #else
    561580    if (pThisCC->pDrv)
    562581        pThisCC->pDrv->pfnSetPromiscuousMode(pThisCC->pDrv, true);
     
    11311150        if (fNewUp)
    11321151        {
    1133             Log(("%s Link is up\n", INSTANCE(pThis)));
    11341152            pThis->fCableConnected = true;
    1135             pThis->config.uStatus |= VNET_S_LINK_UP;
    1136             vnetR3RaiseInterrupt(pDevIns, pThis, VERR_SEM_BUSY, VPCI_ISR_CONFIG);
     1153            /* The link state depends both on the cable connected and device attached. */
     1154            if (vnetR3IsConnected(pDevIns))
     1155            {
     1156                Log(("%s Link is up\n", INSTANCE(pThis)));
     1157                pThis->config.uStatus |= VNET_S_LINK_UP;
     1158                vnetR3RaiseInterrupt(pDevIns, pThis, VERR_SEM_BUSY, VPCI_ISR_CONFIG);
     1159            }
    11371160        }
    11381161        else
     
    13441367    }
    13451368
    1346     if (!pThis->fCableConnected)
     1369    if (!vnetR3IsConnected(pDevIns))
    13471370    {
    13481371        Log(("%s Ignoring transmit requests while cable is disconnected.\n", INSTANCE(pThis)));
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