VirtualBox

Changeset 23979 in vbox for trunk/src


Ignore:
Timestamp:
Oct 22, 2009 1:21:46 PM (15 years ago)
Author:
vboxsync
Message:

#3987: Virtio: Fixed RX thread blocking on early RX packets. Guest context support (not tested).

File:
1 edited

Legend:

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

    r23970 r23979  
    197197PDMBOTHCBDECL(int)      vnetSetConfig(void *pState, uint32_t port, uint32_t cb, void *data);
    198198PDMBOTHCBDECL(void)     vnetReset(void *pState);
     199PDMBOTHCBDECL(void)     vnetReady(void *pState);
    199200#ifdef DEBUG
    200201static const char *vnetGetQueueName(void *pvState, PVQUEUE pQueue);
     
    220221    int       (*pfnSetConfig)(void *pvState, uint32_t port, uint32_t cb, void *data);
    221222    void      (*pfnReset)(void *pvState);
     223    void      (*pfnReady)(void *pvState);
    222224#ifdef DEBUG
    223225    const char *(*pfnGetQueueName)(void *pvState, PVQUEUE pQueue);
     
    229231        0x1AF4, 0x1000, 0x1AF4, 1 + VIRTIO_NET_ID, 0x0200, 3, "virtio-net", "vnet%d",
    230232        vnetGetHostFeatures, vnetGetHostMinimalFeatures, vnetSetHostFeatures,
    231         vnetGetConfig, vnetSetConfig, vnetReset
     233        vnetGetConfig, vnetSetConfig, vnetReset, vnetReady
    232234#ifdef DEBUG
    233235        , vnetGetQueueName
     
    236238    { /* Virtio Block Device */
    237239        0x1AF4, 0x1001, 0x1AF4, 1 + VIRTIO_BLK_ID, 0x0180, 2, "virtio-blk", "vblk%d",
    238         NULL, NULL, NULL, NULL, NULL, NULL
     240        NULL, NULL, NULL, NULL, NULL, NULL, NULL
    239241#ifdef DEBUG
    240242        , NULL
     
    654656    int         rc     = VINF_SUCCESS;
    655657    const char *szInst = INSTANCE(pState);
     658    bool        fHasBecomeReady;
    656659    STAM_PROFILE_ADV_START(&pState->CTXSUFF(StatIOWrite), a);
    657660
     
    665668            if (VPCI_F_BAD_FEATURE & u32)
    666669            {
    667                 Log(("%s Guest failed to negotiate properly! (guest=%x)\n",
     670                Log(("%s WARNING! Guest failed to negotiate properly (guest=%x)\n",
    668671                     INSTANCE(pState), u32));
    669672                pState->uGuestFeatures = g_VPCIDevices[pState->enmDevType].pfnGetHostMinimalFeatures(pState);
     
    720723            Assert(cb == 1);
    721724            u32 &= 0xFF;
     725            fHasBecomeReady = !(pState->uStatus & VPCI_STATUS_DRV_OK) && (u32 & VPCI_STATUS_DRV_OK);
    722726            pState->uStatus = u32;
    723727            /* Writing 0 to the status port triggers device reset. */
    724728            if (u32 == 0)
    725729                g_VPCIDevices[pState->enmDevType].pfnReset(pState);
     730            else if (fHasBecomeReady)
     731                g_VPCIDevices[pState->enmDevType].pfnReady(pState);
    726732            break;
    727733
     
    11111117    R3PTRTYPE(PPDMINETWORKCONNECTOR) pDrv;    /**< Connector of attached network driver. */
    11121118
     1119    R3PTRTYPE(PPDMQUEUE)    pCanRxQueueR3;           /**< Rx wakeup signaller - R3. */
     1120    R0PTRTYPE(PPDMQUEUE)    pCanRxQueueR0;           /**< Rx wakeup signaller - R0. */
     1121    RCPTRTYPE(PPDMQUEUE)    pCanRxQueueRC;           /**< Rx wakeup signaller - RC. */
     1122
    11131123    PTMTIMERR3  pLinkUpTimer;                             /**< Link Up(/Restore) Timer. */
    11141124
     
    12881298
    12891299#endif /* IN_RING3 */
     1300
     1301/**
     1302 * This function is called when the driver becomes ready.
     1303 *
     1304 * @param   pState      The device state structure.
     1305 */
     1306PDMBOTHCBDECL(void) vnetReady(void *pvState)
     1307{
     1308    VNETSTATE *pState = (VNETSTATE*)pvState;
     1309    Log(("%s Driver became ready, waking up RX thread...\n", INSTANCE(pState)));
     1310#ifdef IN_RING3
     1311    vnetWakeupReceive(pState->VPCI.CTX_SUFF(pDevIns));
     1312#else
     1313    PPDMQUEUEITEMCORE pItem = PDMQueueAlloc(pState->CTX_SUFF(pCanRxQueue));
     1314    if (pItem)
     1315        PDMQueueInsert(pState->CTX_SUFF(pCanRxQueue), pItem);
     1316#endif
     1317}
    12901318
    12911319
     
    16991727    return rc;*/
    17001728
     1729    /* Create the RX notifier signaller. */
     1730    rc = PDMDevHlpPDMQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 1, 0,
     1731                                 vnetCanRxQueueConsumer, true, "VNet-Rcv", &pState->pCanRxQueueR3);
     1732    if (RT_FAILURE(rc))
     1733        return rc;
     1734    pState->pCanRxQueueR0 = PDMQueueR0Ptr(pState->pCanRxQueueR3);
     1735    pState->pCanRxQueueRC = PDMQueueRCPtr(pState->pCanRxQueueR3);
    17011736
    17021737    /* Create Link Up Timer */
     
    17931828    VNETSTATE* pState = PDMINS_2_DATA(pDevIns, VNETSTATE*);
    17941829    vpciRelocate(pDevIns, offDelta);
     1830    pState->pCanRxQueueRC = PDMQueueRCPtr(pState->pCanRxQueueR3);
    17951831    // TBD
    17961832}
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