VirtualBox

Changeset 28628 in vbox


Ignore:
Timestamp:
Apr 23, 2010 8:23:39 AM (15 years ago)
Author:
vboxsync
Message:

e1000: Promiscuous mode support.

File:
1 edited

Legend:

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

    r28338 r28628  
    15101510    }
    15111511}
     1512
     1513/**
     1514 * Hardware reset. Revert all registers to initial values.
     1515 *
     1516 * @param   pState      The device state structure.
     1517 */
     1518PDMBOTHCBDECL(void) e1kHardReset(E1KSTATE *pState)
     1519{
     1520    E1kLog(("%s Hard reset triggered\n", INSTANCE(pState)));
     1521    memset(pState->auRegs,        0, sizeof(pState->auRegs));
     1522    memset(pState->aRecAddr.au32, 0, sizeof(pState->aRecAddr.au32));
     1523#ifdef E1K_INIT_RA0
     1524    memcpy(pState->aRecAddr.au32, pState->macConfigured.au8,
     1525           sizeof(pState->macConfigured.au8));
     1526    pState->aRecAddr.array[0].ctl |= RA_CTL_AV;
     1527#endif /* E1K_INIT_RA0 */
     1528    STATUS = 0x0081;    /* SPEED=10b (1000 Mb/s), FD=1b (Full Duplex) */
     1529    EECD   = 0x0100;    /* EE_PRES=1b (EEPROM present) */
     1530    CTRL   = 0x0a09;    /* FRCSPD=1b SPEED=10b LRST=1b FD=1b */
     1531    TSPMT  = 0x01000400;/* TSMT=0400h TSPBP=0100h */
     1532    Assert(GET_BITS(RCTL, BSIZE) == 0);
     1533    pState->u16RxBSize = 2048;
     1534
     1535    /* Reset promiscous mode */
     1536    if (pState->pDrvR3)
     1537        pState->pDrvR3->pfnSetPromiscuousMode(pState->pDrvR3, false);
     1538}
    15121539#endif
    15131540
     
    16961723
    16971724/**
    1698  * Hardware reset. Revert all registers to initial values.
    1699  *
    1700  * @param   pState      The device state structure.
    1701  */
    1702 PDMBOTHCBDECL(void) e1kHardReset(E1KSTATE *pState)
    1703 {
    1704     E1kLog(("%s Hard reset triggered\n", INSTANCE(pState)));
    1705     memset(pState->auRegs,        0, sizeof(pState->auRegs));
    1706     memset(pState->aRecAddr.au32, 0, sizeof(pState->aRecAddr.au32));
    1707 #ifdef E1K_INIT_RA0
    1708     memcpy(pState->aRecAddr.au32, pState->macConfigured.au8,
    1709            sizeof(pState->macConfigured.au8));
    1710     pState->aRecAddr.array[0].ctl |= RA_CTL_AV;
    1711 #endif /* E1K_INIT_RA0 */
    1712     STATUS = 0x0081;    /* SPEED=10b (1000 Mb/s), FD=1b (Full Duplex) */
    1713     EECD   = 0x0100;    /* EE_PRES=1b (EEPROM present) */
    1714     CTRL   = 0x0a09;    /* FRCSPD=1b SPEED=10b LRST=1b FD=1b */
    1715     TSPMT  = 0x01000400;/* TSMT=0400h TSPBP=0100h */
    1716     Assert(GET_BITS(RCTL, BSIZE) == 0);
    1717     pState->u16RxBSize = 2048;
    1718 }
    1719 
    1720 /**
    17211725 * Raise interrupt if not masked.
    17221726 *
     
    21732177    if (value & CTRL_RESET)
    21742178    { /* RST */
     2179#ifndef IN_RING3
     2180        return VINF_IOM_HC_IOPORT_WRITE;
     2181#else
    21752182        e1kHardReset(pState);
     2183#endif
    21762184    }
    21772185    else
     
    25612569static int e1kRegWriteRCTL(E1KSTATE* pState, uint32_t offset, uint32_t index, uint32_t value)
    25622570{
     2571    /* Update promiscous mode */
     2572    bool fBecomePromiscous = !!(value & (RCTL_UPE | RCTL_MPE));
     2573    if (fBecomePromiscous != !!( RCTL & (RCTL_UPE | RCTL_MPE)))
     2574    {
     2575        /* Promiscuity has changed, pass the knowledge on. */
     2576#ifndef IN_RING3
     2577        return VINF_IOM_HC_IOPORT_WRITE;
     2578#else
     2579        if (pState->pDrvR3)
     2580            pState->pDrvR3->pfnSetPromiscuousMode(pState->pDrvR3, fBecomePromiscous);
     2581#endif
     2582    }
     2583    /* Adjust receive buffer size */
     2584    if (GET_BITS(RCTL, BSIZE) != GET_BITS_V(value, RCTL, BSIZE))
     2585    {
     2586        pState->u16RxBSize = 2048 >> GET_BITS(RCTL, BSIZE);
     2587        if (RCTL & RCTL_BSEX)
     2588            pState->u16RxBSize *= 16;
     2589        E1kLog2(("%s e1kRegWriteRCTL: Setting receive buffer size to %d\n",
     2590                 INSTANCE(pState), pState->u16RxBSize));
     2591    }
    25632592    e1kRegWriteDefault(pState, offset, index, value);
    2564     pState->u16RxBSize = 2048 >> GET_BITS(RCTL, BSIZE);
    2565     if (RCTL & RCTL_BSEX)
    2566         pState->u16RxBSize *= 16;
    2567     E1kLog2(("%s e1kRegWriteRCTL: Setting receive buffer size to %d\n",
    2568             INSTANCE(pState), pState->u16RxBSize));
    25692593
    25702594    return VINF_SUCCESS;
     
    52355259    if (RT_UNLIKELY(rc != VINF_SUCCESS))
    52365260        return rc;
     5261
     5262    /* Update promiscous mode */
     5263    if (pState->pDrvR3)
     5264        pState->pDrvR3->pfnSetPromiscuousMode(pState->pDrvR3,
     5265                                             !!(RCTL & (RCTL_UPE | RCTL_MPE)));
     5266
    52375267    /*
    52385268    * Force the link down here, since PDMNETWORKLINKSTATE_DOWN_RESUME is never
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