Changeset 28328 in vbox for trunk/src/VBox
- Timestamp:
- Apr 14, 2010 8:46:56 PM (15 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevE1000.cpp
r28324 r28328 952 952 PDMCRITSECT csRx; /**< RX Critical section. */ 953 953 // PDMCRITSECT csTx; /**< TX Critical section. */ 954 #endif955 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES956 /** Transmit thread blocker. */957 # ifdef E1K_USE_SUPLIB_SEMEVENT958 SUPSEMEVENT hTxSem;959 # else960 RTSEMEVENT hTxSem;961 # endif962 #endif963 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES964 PPDMTHREAD pTxThread; /**< Transmit thread. */965 954 #endif 966 955 /** Base address of memory-mapped registers. */ … … 3820 3809 } 3821 3810 3822 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES3823 3824 /**3825 * Wake up callback for transmission thread.3826 *3827 * @returns VBox status code. Returning failure will naturally terminate the thread.3828 * @param pDevIns The pcnet device instance.3829 * @param pThread The thread.3830 */3831 static DECLCALLBACK(int) e1kTxThreadWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread)3832 {3833 E1KSTATE *pState = PDMINS_2_DATA(pDevIns, E1KSTATE *);3834 #ifdef E1K_USE_SUPLIB_SEMEVENT3835 int rc = SUPSemEventSignal(PDMDevHlpGetVM(pDevIns)->pSession, pState->hTxSem);3836 #else3837 int rc = RTSemEventSignal(pState->hTxSem);3838 #endif3839 AssertRC(rc);3840 return VINF_SUCCESS;3841 }3842 3843 /**3844 * I/O thread for packet transmission.3845 *3846 * @returns VBox status code. Returning failure will naturally terminate the thread.3847 * @param pDevIns Pointer to device instance structure.3848 * @param pThread The thread.3849 * @thread E1000_TX3850 */3851 static DECLCALLBACK(int) e1kTxThread(PPDMDEVINS pDevIns, PPDMTHREAD pThread)3852 {3853 E1KSTATE *pState = PDMINS_2_DATA(pDevIns, E1KSTATE *);3854 3855 while (pThread->enmState == PDMTHREADSTATE_RUNNING)3856 {3857 #ifdef E1K_USE_SUPLIB_SEMEVENT3858 int rc = SUPSemEventWaitNoResume(PDMDevHlpGetVM(pDevIns)->pSession, pState->hTxSem, RT_INDEFINITE_WAIT);3859 #else3860 int rc = RTSemEventWaitNoResume(pState->hTxSem, RT_INDEFINITE_WAIT);3861 #endif3862 if (rc == VERR_INTERRUPTED)3863 continue;3864 AssertRCReturn(rc, rc);3865 if (RT_UNLIKELY(pThread->enmState != PDMTHREADSTATE_RUNNING))3866 break;3867 3868 if (pThread->enmState == PDMTHREADSTATE_RUNNING)3869 {3870 rc = e1kXmitPending(pState, true /*fOnWorkerThread*/);3871 AssertMsgReturn(RT_SUCCESS(rc) || rc == VERR_TRY_AGAIN, ("%Rrc\n", rc), rc);3872 }3873 }3874 return VINF_SUCCESS;3875 }3876 3877 #endif /* VBOX_WITH_TX_THREAD_IN_NET_DEVICES */3878 3879 3811 /** 3880 3812 * Callback for consuming from transmit queue. It gets called in R3 whenever … … 3892 3824 E1kLog2(("%s e1kTxQueueConsumer: Waking up TX thread...\n", INSTANCE(pState))); 3893 3825 3894 #ifndef VBOX_WITH_TX_THREAD_IN_NET_DEVICES3895 3826 int rc = e1kXmitPending(pState, false /*fOnWorkerThread*/); 3896 3827 AssertMsg(RT_SUCCESS(rc) || rc == VERR_TRY_AGAIN, ("%Rrc\n", rc)); 3897 #else3898 # ifdef E1K_USE_SUPLIB_SEMEVENT3899 int rc = SUPSemEventSignal(PDMDevHlpGetVM(pDevIns)->pSession, pState->hTxSem);3900 # else3901 int rc = RTSemEventSignal(pState->hTxSem);3902 # endif3903 AssertRC(rc);3904 #endif3905 3828 3906 3829 return true; … … 3946 3869 E1kLog(("%s e1kRegWriteTDT: %d descriptors to process, waking up E1000_TX thread\n", 3947 3870 INSTANCE(pState), e1kGetTxLen(pState))); 3948 #ifndef VBOX_WITH_TX_THREAD_IN_NET_DEVICES3949 3871 e1kCsTxLeave(pState); 3950 3872 … … 3966 3888 AssertRC(rc); 3967 3889 } 3968 #else3969 # if (defined(IN_RING3) || defined(IN_RING0)) && defined(E1K_USE_SUPLIB_SEMEVENT)3970 rc = SUPSemEventSignal(PDMDevHlpGetVM(pState->CTX_SUFF(pDevIns))->pSession, pState->hTxSem);3971 AssertRC(rc);3972 # elif defined(IN_RING3)3973 rc = RTSemEventSignal(pState->hTxSem);3974 AssertRC(rc);3975 # else3976 PPDMQUEUEITEMCORE pItem = PDMQueueAlloc(pState->CTX_SUFF(pTxQueue));3977 if (RT_UNLIKELY(pItem))3978 PDMQueueInsert(pState->CTX_SUFF(pTxQueue), pItem);3979 # endif /* !IN_RING3 */3980 #endif3981 3982 3890 } 3983 3891 else … … 5534 5442 pState->hEventMoreRxDescAvail = NIL_RTSEMEVENT; 5535 5443 } 5536 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES5537 # ifdef E1K_USE_SUPLIB_SEMEVENT5538 if (pState->hTxSem != NIL_SUPSEMEVENT)5539 {5540 SUPSemEventClose(PDMDevHlpGetVM(pDevIns)->pSession, pState->hTxSem);5541 pState->hTxSem = NIL_SUPSEMEVENT;5542 }5543 # else5544 if (pState->hTxSem != NIL_RTSEMEVENT)5545 {5546 RTSemEventDestroy(pState->hTxSem);5547 pState->hTxSem = NIL_RTSEMEVENT;5548 }5549 # endif5550 #endif5551 5444 #ifndef E1K_GLOBAL_MUTEX 5552 5445 PDMR3CritSectDelete(&pState->csRx); … … 5675 5568 RTStrPrintf(pState->szInstance, sizeof(pState->szInstance), "E1000#%d", iInstance); 5676 5569 E1kLog(("%s Constructing new instance sizeof(E1KRXDESC)=%d\n", INSTANCE(pState), sizeof(E1KRXDESC))); 5677 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES5678 # ifdef E1K_USE_SUPLIB_SEMEVENT5679 pState->hTxSem = NIL_SUPSEMEVENT;5680 # else5681 pState->hTxSem = NIL_RTSEMEVENT;5682 # endif5683 #endif5684 5570 pState->hEventMoreRxDescAvail = NIL_RTSEMEVENT; 5685 5571 … … 5921 5807 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to attach the network LUN")); 5922 5808 5923 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES5924 # ifdef E1K_USE_SUPLIB_SEMEVENT5925 rc = SUPSemEventCreate(PDMDevHlpGetVM(pDevIns)->pSession, &pState->hTxSem);5926 # else5927 rc = RTSemEventCreate(&pState->hTxSem);5928 # endif5929 if (RT_FAILURE(rc))5930 return rc;5931 #endif5932 5809 rc = RTSemEventCreate(&pState->hEventMoreRxDescAvail); 5933 5810 if (RT_FAILURE(rc)) … … 5935 5812 5936 5813 e1kHardReset(pState); 5937 5938 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES5939 rc = PDMDevHlpThreadCreate(pDevIns, &pState->pTxThread, pState, e1kTxThread, e1kTxThreadWakeUp, 0, RTTHREADTYPE_IO, "E1000_TX");5940 if (RT_FAILURE(rc))5941 return rc;5942 #endif5943 5814 5944 5815 #if defined(VBOX_WITH_STATISTICS) || defined(E1K_REL_STATS) -
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r28320 r28328 241 241 /** Partner of ILeds. */ 242 242 R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector; 243 244 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES245 /** Async send thread */246 RTSEMEVENT hSendEventSem;247 /** The Async send thread. */248 PPDMTHREAD pSendThread;249 #endif250 243 251 244 /** Access critical section. */ … … 2067 2060 NOREF(pItem); 2068 2061 2069 #ifndef VBOX_WITH_TX_THREAD_IN_NET_DEVICES2070 2062 /* 2071 2063 * Transmit as much as we can. 2072 2064 */ 2073 2065 pcnetXmitPending(pThis, true /*fOnWorkerThread*/); 2074 #else 2075 /* 2076 * Wake up the TX thread. 2077 */ 2078 int rc = RTSemEventSignal(pThis->hSendEventSem); 2079 AssertRC(rc); 2080 #endif 2066 2081 2067 return true; 2082 2068 } … … 2372 2358 pThis->aCSR[0] &= ~0x0008; 2373 2359 2374 #ifndef VBOX_WITH_TX_THREAD_IN_NET_DEVICES2375 2360 /* 2376 2361 * Transmit pending packets if possible, defere it if we cannot do it 2377 2362 * in the current context. 2378 2363 */ 2379 # 2364 #if defined(IN_RING0) || defined(IN_RC) 2380 2365 if (!pThis->CTX_SUFF(pDrv)) 2381 2366 { … … 2385 2370 } 2386 2371 else 2387 # 2372 #endif 2388 2373 { 2389 2374 int rc = pcnetXmitPending(pThis, false /*fOnWorkerThread*/); … … 2392 2377 AssertRC(rc); 2393 2378 } 2394 #else /* VBOX_WITH_TX_THREAD_IN_NET_DEVICES */2395 /*2396 * If we're in Ring-3 we should flush the queue now, in GC/R0 we'll queue a flush job.2397 */2398 # ifdef IN_RING32399 int rc = RTSemEventSignal(pThis->hSendEventSem);2400 AssertRC(rc);2401 # else2402 PPDMQUEUEITEMCORE pItem = PDMQueueAlloc(pThis->CTX_SUFF(pXmitQueue));2403 if (RT_UNLIKELY(pItem))2404 PDMQueueInsert(pThis->CTX_SUFF(pXmitQueue), pItem);2405 # endif2406 #endif /* VBOX_WITH_TX_THREAD_IN_NET_DEVICES */2407 2379 } 2408 2380 … … 2711 2683 } 2712 2684 2713 #ifdef IN_RING32714 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES2715 2716 /**2717 * Async I/O thread for delayed sending of packets.2718 *2719 * @returns VBox status code. Returning failure will naturally terminate the thread.2720 * @param pDevIns The pcnet device instance.2721 * @param pThread The thread.2722 */2723 static DECLCALLBACK(int) pcnetAsyncSendThread(PPDMDEVINS pDevIns, PPDMTHREAD pThread)2724 {2725 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);2726 2727 /*2728 * We can enter this function in two states, initializing or resuming.2729 *2730 * The idea about the initializing bit is that we can do per-thread2731 * initialization while the creator thread can still pick up errors.2732 * At present, there is nothing to init, or at least nothing that2733 * need initing in the thread.2734 */2735 if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)2736 return VINF_SUCCESS;2737 2738 /*2739 * Stay in the run-loop until we're supposed to leave the2740 * running state. If something really bad happens, we'll2741 * quit the loop while in the running state and return2742 * an error status to PDM and let it terminate the thread.2743 */2744 while (pThread->enmState == PDMTHREADSTATE_RUNNING)2745 {2746 /*2747 * Block until we've got something to send or is supposed2748 * to leave the running state.2749 */2750 int rc = RTSemEventWait(pThis->hSendEventSem, RT_INDEFINITE_WAIT);2751 AssertRCReturn(rc, rc);2752 if (RT_UNLIKELY(pThread->enmState != PDMTHREADSTATE_RUNNING))2753 break;2754 2755 /*2756 * Perform async send.2757 */2758 rc = pcnetXmitPending(pThis, true /*fOnWorkerThread*/);2759 AssertMsg(rc == VINF_SUCCESS || rc == VERR_TRY_AGAIN, ("%Rrc\n", rc));2760 }2761 2762 /* The thread is being suspended or terminated. */2763 return VINF_SUCCESS;2764 }2765 2766 2767 /**2768 * Unblock the send thread so it can respond to a state change.2769 *2770 * @returns VBox status code.2771 * @param pDevIns The pcnet device instance.2772 * @param pThread The send thread.2773 */2774 static DECLCALLBACK(int) pcnetAsyncSendThreadWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread)2775 {2776 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *);2777 return RTSemEventSignal(pThis->hSendEventSem);2778 }2779 2780 # endif /* VBOX_WITH_TX_THREAD_IN_NET_DEVICES*/2781 #endif /* IN_RING3 */2782 2685 2783 2686 /** … … 5081 4984 if (PDMCritSectIsInitialized(&pThis->CritSect)) 5082 4985 { 5083 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES5084 /*5085 * At this point the send thread is suspended and will not enter5086 * this module again. So, no coordination is needed here and PDM5087 * will take care of terminating and cleaning up the thread.5088 */5089 RTSemEventDestroy(pThis->hSendEventSem);5090 pThis->hSendEventSem = NIL_RTSEMEVENT;5091 #endif5092 4986 RTSemEventSignal(pThis->hEventOutOfRxSpace); 5093 4987 RTSemEventDestroy(pThis->hEventOutOfRxSpace); … … 5121 5015 */ 5122 5016 pThis->hEventOutOfRxSpace = NIL_RTSEMEVENT; 5123 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES5124 pThis->hSendEventSem = NIL_RTSEMEVENT;5125 #endif5126 5017 5127 5018 /* … … 5393 5284 */ 5394 5285 pcnetHardReset(pThis); 5395 5396 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES5397 /* Create send queue for the async send thread. */5398 rc = RTSemEventCreate(&pThis->hSendEventSem);5399 AssertRC(rc);5400 5401 /* Create asynchronous thread */5402 rc = PDMDevHlpThreadCreate(pDevIns, &pThis->pSendThread, pThis, pcnetAsyncSendThread, pcnetAsyncSendThreadWakeUp, 0, RTTHREADTYPE_IO, "PCNET_TX");5403 AssertRCReturn(rc, rc);5404 #endif5405 5286 5406 5287 #ifdef VBOX_WITH_STATISTICS -
trunk/src/VBox/Devices/Network/DrvIntNet.cpp
r28325 r28328 31 31 #include <VBox/intnetinline.h> 32 32 #include <VBox/vmm.h> 33 #include <VBox/sup.h> 33 34 #include <VBox/err.h> 34 35 … … 109 110 /** The thread state. */ 110 111 ASYNCSTATE volatile enmState; 111 /** Reader thread. */ 112 RTTHREAD hRxThread; 113 /** Event semaphore the Thread waits on while the VM is suspended. */ 114 RTSEMEVENT hEvtSuspended; 112 /** The receive thread. */ 113 RTTHREAD hRecvThread; 114 /** The event semaphore that the receive thread waits on. */ 115 RTSEMEVENT hRecvEvt; 116 /** The transmit thread. */ 117 PPDMTHREAD pXmitThread; 118 /** The event semaphore that the transmit thread waits on. */ 119 SUPSEMEVENT hXmitEvt; 120 /** The support driver session handle. */ 121 PSUPDRVSESSION pSupDrvSession; 115 122 /** Scatter/gather descriptor cache. */ 116 123 RTMEMCACHE hSgCache; … … 118 125 * When the link is down all incoming packets will be dropped. */ 119 126 bool volatile fLinkDown; 127 /** Set when the xmit thread has been signalled. (atomic) */ 128 bool volatile fXmitSignalled; 129 /** Set if the transmit thread the one busy transmitting. */ 130 bool volatile fXmitOnXmitThread; 120 131 /** Set if data transmission should start immediately and deactivate 121 132 * as late as possible. */ 122 133 bool fActivateEarlyDeactivateLate; 134 #if HC_ARCH_BITS == 64 123 135 /** Padding. */ 124 bool afReserved[HC_ARCH_BITS == 64 ? 2+4 : 2]; 136 bool afReserved[HC_ARCH_BITS == 64 ? 4 : 0]; 137 #endif 125 138 /** The network name. */ 126 139 char szNetwork[INTNET_MAX_NETWORK_NAME]; … … 207 220 208 221 209 210 222 /* -=-=-=-=- PDMINETWORKUP -=-=-=-=- */ 211 223 … … 216 228 { 217 229 PDRVINTNET pThis = RT_FROM_MEMBER(pInterface, DRVINTNET, INetworkUpR3); 230 #if 1 218 231 int rc = PDMCritSectTryEnter(&pThis->XmitLock); 219 if (RT_UNLIKELY(rc == VERR_SEM_BUSY)) 232 #else 233 int rc = fOnWorkerThread ? PDMCritSectTryEnter(&pThis->XmitLock) : VERR_SEM_BUSY; 234 #endif 235 if (RT_SUCCESS(rc)) 236 { 237 if (fOnWorkerThread) 238 { 239 ASMAtomicUoWriteBool(&pThis->fXmitOnXmitThread, true); 240 ASMAtomicWriteBool(&pThis->fXmitSignalled, false); 241 } 242 } 243 else if (rc == VERR_SEM_BUSY) 244 { 245 /** @todo Does this actually make sense if the other dude is an EMT and so 246 * forth? I seriously think this is ring-0 only... */ 247 if ( !fOnWorkerThread 248 && !ASMAtomicUoReadBool(&pThis->fXmitOnXmitThread) 249 && ASMAtomicCmpXchgBool(&pThis->fXmitSignalled, true, false)) 250 { 251 rc = SUPSemEventSignal(pThis->pSupDrvSession, pThis->hXmitEvt); 252 AssertRC(rc); 253 } 220 254 rc = VERR_TRY_AGAIN; 255 } 221 256 return rc; 222 257 } … … 248 283 &pHdr, &pSgBuf->aSegs[0].pvSeg); 249 284 250 #if 1 /** @todo implement VERR_TRY_AGAIN once this moves to EMT .*/285 #if 1 /** @todo implement VERR_TRY_AGAIN once this moves to EMT? -- Not needed unless we make the consumer side (ring-0) asynchronous. */ 251 286 if ( RT_FAILURE(rc) 252 287 && pThis->pBufR3->cbSend >= cbMin * 2 + sizeof(INTNETHDR)) … … 362 397 { 363 398 PDRVINTNET pThis = RT_FROM_MEMBER(pInterface, DRVINTNET, INetworkUpR3); 399 ASMAtomicUoWriteBool(&pThis->fXmitOnXmitThread, false); 364 400 PDMCritSectLeave(&pThis->XmitLock); 365 401 } … … 408 444 409 445 446 /* -=-=-=-=- Transmit Thread -=-=-=-=- */ 447 448 /** 449 * Async I/O thread for defered packet transmission. 450 * 451 * @returns VBox status code. Returning failure will naturally terminate the thread. 452 * @param pDrvIns The internal networking driver instance. 453 * @param pThread The thread. 454 */ 455 static DECLCALLBACK(int) drvR3IntNetXmitThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) 456 { 457 PDRVINTNET pThis = PDMINS_2_DATA(pDrvIns, PDRVINTNET); 458 459 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 460 { 461 /* 462 * Block until we've got something to send or is supposed 463 * to leave the running state. 464 */ 465 int rc = SUPSemEventWaitNoResume(pThis->pSupDrvSession, pThis->hXmitEvt, RT_INDEFINITE_WAIT); 466 AssertLogRelMsgReturn(RT_SUCCESS(rc) || rc == VERR_INTERRUPTED, ("%Rrc\n", rc), rc); 467 if (RT_UNLIKELY(pThread->enmState != PDMTHREADSTATE_RUNNING)) 468 break; 469 470 /* 471 * Transmit any pending packets. 472 */ 473 pThis->pIAboveNet->pfnXmitPending(pThis->pIAboveNet); 474 } 475 476 /* The thread is being initialized, suspended or terminated. */ 477 return VINF_SUCCESS; 478 } 479 480 481 /** 482 * @copydoc FNPDMTHREADWAKEUPDRV 483 */ 484 static DECLCALLBACK(int) drvR3IntNetXmitWakeUp(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) 485 { 486 PDRVINTNET pThis = PDMINS_2_DATA(pDrvIns, PDRVINTNET); 487 return SUPSemEventSignal(pThis->pSupDrvSession, pThis->hXmitEvt); 488 } 489 490 491 /* -=-=-=-=- Receive Thread -=-=-=-=- */ 492 410 493 /** 411 494 * Wait for space to become available up the driver/device chain. … … 416 499 * @param pThis Pointer to the instance data. 417 500 */ 418 static int drvR3IntNet AsyncIoWaitForSpace(PDRVINTNET pThis)419 { 420 LogFlow(("drvR3IntNet AsyncIoWaitForSpace:\n"));501 static int drvR3IntNetRecvWaitForSpace(PDRVINTNET pThis) 502 { 503 LogFlow(("drvR3IntNetRecvWaitForSpace:\n")); 421 504 STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a); 422 505 int rc = pThis->pIAboveNet->pfnWaitReceiveAvail(pThis->pIAboveNet, RT_INDEFINITE_WAIT); 423 506 STAM_PROFILE_ADV_START(&pThis->StatReceive, a); 424 LogFlow(("drvR3IntNet AsyncIoWaitForSpace: returns %Rrc\n", rc));507 LogFlow(("drvR3IntNetRecvWaitForSpace: returns %Rrc\n", rc)); 425 508 return rc; 426 509 } … … 434 517 * @param pThis The driver instance data. 435 518 */ 436 static int drvR3IntNet AsyncIoRun(PDRVINTNET pThis)519 static int drvR3IntNetRecvRun(PDRVINTNET pThis) 437 520 { 438 521 PPDMDRVINS pDrvIns = pThis->pDrvInsR3; 439 LogFlow(("drvR3IntNet AsyncIoRun: pThis=%p\n", pThis));522 LogFlow(("drvR3IntNetRecvRun: pThis=%p\n", pThis)); 440 523 441 524 /* … … 459 542 { 460 543 STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a); 461 LogFlow(("drvR3IntNet AsyncIoRun: returns VERR_STATE_CHANGED (state changed - #0)\n"));544 LogFlow(("drvR3IntNetRecvRun: returns VERR_STATE_CHANGED (state changed - #0)\n")); 462 545 return VERR_STATE_CHANGED; 463 546 } … … 485 568 { 486 569 uint64_t u64Now = RTTimeProgramNanoTS(); 487 LogFlow(("drvR3IntNet AsyncIoRun: %-4d bytes at %llu ns deltas: r=%llu t=%llu\n",570 LogFlow(("drvR3IntNetRecvRun: %-4d bytes at %llu ns deltas: r=%llu t=%llu\n", 488 571 cbFrame, u64Now, u64Now - pThis->u64LastReceiveTS, u64Now - pThis->u64LastTransferTS)); 489 572 pThis->u64LastReceiveTS = u64Now; 490 Log2(("drvR3IntNet AsyncIoRun: cbFrame=%#x\n"573 Log2(("drvR3IntNetRecvRun: cbFrame=%#x\n" 491 574 "%.*Rhxd\n", 492 575 cbFrame, cbFrame, INTNETHdrGetFramePtr(pHdr, pBuf))); … … 519 602 { 520 603 uint64_t u64Now = RTTimeProgramNanoTS(); 521 LogFlow(("drvR3IntNet AsyncIoRun: %-4d bytes at %llu ns deltas: r=%llu t=%llu; GSO - %u segs\n",604 LogFlow(("drvR3IntNetRecvRun: %-4d bytes at %llu ns deltas: r=%llu t=%llu; GSO - %u segs\n", 522 605 cbFrame, u64Now, u64Now - pThis->u64LastReceiveTS, u64Now - pThis->u64LastTransferTS, cSegs)); 523 606 pThis->u64LastReceiveTS = u64Now; 524 Log2(("drvR3IntNet AsyncIoRun: cbFrame=%#x type=%d cbHdrs=%#x Hdr1=%#x Hdr2=%#x MMS=%#x\n"607 Log2(("drvR3IntNetRecvRun: cbFrame=%#x type=%d cbHdrs=%#x Hdr1=%#x Hdr2=%#x MMS=%#x\n" 525 608 "%.*Rhxd\n", 526 609 cbFrame, pGso->u8Type, pGso->cbHdrs, pGso->offHdr1, pGso->offHdr2, pGso->cbMaxSeg, … … 533 616 void *pvSegFrame = PDMNetGsoCarveSegmentQD(pGso, (uint8_t *)(pGso + 1), cbFrame, abHdrScratch, 534 617 iSeg, cSegs, &cbSegFrame); 535 rc = drvR3IntNet AsyncIoWaitForSpace(pThis);618 rc = drvR3IntNetRecvWaitForSpace(pThis); 536 619 if (RT_FAILURE(rc)) 537 620 { 538 Log(("drvR3IntNet AsyncIoRun: drvR3IntNetAsyncIoWaitForSpace -> %Rrc; iSeg=%u cSegs=%u\n", iSeg, cSegs));621 Log(("drvR3IntNetRecvRun: drvR3IntNetRecvWaitForSpace -> %Rrc; iSeg=%u cSegs=%u\n", iSeg, cSegs)); 539 622 break; /* we drop the rest. */ 540 623 } … … 558 641 * Wait for sufficient space to become available and then retry. 559 642 */ 560 rc = drvR3IntNet AsyncIoWaitForSpace(pThis);643 rc = drvR3IntNetRecvWaitForSpace(pThis); 561 644 if (RT_FAILURE(rc)) 562 645 { … … 572 655 { 573 656 STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a); 574 LogFlow(("drvR3IntNet AsyncIoRun: returns %Rrc (wait-for-space)\n", rc));657 LogFlow(("drvR3IntNetRecvRun: returns %Rrc (wait-for-space)\n", rc)); 575 658 return rc; 576 659 } … … 595 678 { 596 679 STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a); 597 LogFlow(("drvR3IntNet AsyncIoRun: returns VINF_SUCCESS (state changed - #1)\n"));680 LogFlow(("drvR3IntNetRecvRun: returns VINF_SUCCESS (state changed - #1)\n")); 598 681 return VERR_STATE_CHANGED; 599 682 } … … 610 693 && rc != VERR_INTERRUPTED) 611 694 { 612 LogFlow(("drvR3IntNet AsyncIoRun: returns %Rrc\n", rc));695 LogFlow(("drvR3IntNetRecvRun: returns %Rrc\n", rc)); 613 696 return rc; 614 697 } … … 625 708 * @param pvUser Pointer to a DRVINTNET structure. 626 709 */ 627 static DECLCALLBACK(int) drvR3IntNet AsyncIoThread(RTTHREAD ThreadSelf, void *pvUser)710 static DECLCALLBACK(int) drvR3IntNetRecvThread(RTTHREAD ThreadSelf, void *pvUser) 628 711 { 629 712 PDRVINTNET pThis = (PDRVINTNET)pvUser; 630 LogFlow(("drvR3IntNet AsyncIoThread: pThis=%p\n", pThis));713 LogFlow(("drvR3IntNetRecvThread: pThis=%p\n", pThis)); 631 714 STAM_PROFILE_ADV_START(&pThis->StatReceive, a); 632 715 … … 641 724 case ASYNCSTATE_SUSPENDED: 642 725 { 643 int rc = RTSemEventWait(pThis->h EvtSuspended, 30000);726 int rc = RTSemEventWait(pThis->hRecvEvt, 30000); 644 727 if ( RT_FAILURE(rc) 645 728 && rc != VERR_TIMEOUT) 646 729 { 647 LogFlow(("drvR3IntNet AsyncIoThread: returns %Rrc\n", rc));730 LogFlow(("drvR3IntNetRecvThread: returns %Rrc\n", rc)); 648 731 return rc; 649 732 } … … 653 736 case ASYNCSTATE_RUNNING: 654 737 { 655 int rc = drvR3IntNet AsyncIoRun(pThis);738 int rc = drvR3IntNetRecvRun(pThis); 656 739 if ( rc != VERR_STATE_CHANGED 657 740 && RT_FAILURE(rc)) 658 741 { 659 LogFlow(("drvR3IntNet AsyncIoThread: returns %Rrc\n", rc));742 LogFlow(("drvR3IntNetRecvThread: returns %Rrc\n", rc)); 660 743 return rc; 661 744 } … … 666 749 AssertMsgFailed(("Invalid state %d\n", enmState)); 667 750 case ASYNCSTATE_TERMINATE: 668 LogFlow(("drvR3IntNet AsyncIoThread: returns VINF_SUCCESS\n"));751 LogFlow(("drvR3IntNetRecvThread: returns VINF_SUCCESS\n")); 669 752 return VINF_SUCCESS; 670 753 } 671 754 } 672 755 } 756 673 757 674 758 /* -=-=-=-=- PDMIBASERC -=-=-=-=- */ … … 686 770 return NIL_RTRCPTR; 687 771 } 772 688 773 689 774 /* -=-=-=-=- PDMIBASER0 -=-=-=-=- */ … … 701 786 } 702 787 788 703 789 /* -=-=-=-=- PDMIBASE -=-=-=-=- */ 704 790 … … 717 803 return NULL; 718 804 } 805 719 806 720 807 /* -=-=-=-=- PDMDRVREG -=-=-=-=- */ … … 786 873 { 787 874 ASMAtomicXchgSize(&pThis->enmState, ASYNCSTATE_RUNNING); 788 RTSemEventSignal(pThis->h EvtSuspended);875 RTSemEventSignal(pThis->hRecvEvt); 789 876 drvR3IntNetUpdateMacAddress(pThis); /* (could be a state restore) */ 790 877 drvR3IntNetSetActive(pThis, true /* fActive */); … … 848 935 { 849 936 ASMAtomicXchgSize(&pThis->enmState, ASYNCSTATE_RUNNING); 850 RTSemEventSignal(pThis->h EvtSuspended);937 RTSemEventSignal(pThis->hRecvEvt); 851 938 drvR3IntNetUpdateMacAddress(pThis); 852 939 drvR3IntNetSetActive(pThis, true /* fActive */); … … 883 970 ASMAtomicXchgSize(&pThis->enmState, ASYNCSTATE_TERMINATE); 884 971 ASMAtomicXchgSize(&pThis->fLinkDown, true); 885 RTSEMEVENT h EvtSuspended = pThis->hEvtSuspended;886 pThis->h EvtSuspended= NIL_RTSEMEVENT;972 RTSEMEVENT hRecvEvt = pThis->hRecvEvt; 973 pThis->hRecvEvt = NIL_RTSEMEVENT; 887 974 888 975 /* … … 904 991 * Wait for the thread to terminate. 905 992 */ 906 if (pThis->hR xThread != NIL_RTTHREAD)907 { 908 if (h EvtSuspended!= NIL_RTSEMEVENT)909 RTSemEventSignal(h EvtSuspended);910 int rc = RTThreadWait(pThis->hR xThread, 5000, NULL);993 if (pThis->hRecvThread != NIL_RTTHREAD) 994 { 995 if (hRecvEvt != NIL_RTSEMEVENT) 996 RTSemEventSignal(hRecvEvt); 997 int rc = RTThreadWait(pThis->hRecvThread, 5000, NULL); 911 998 AssertRC(rc); 912 pThis->hR xThread = NIL_RTTHREAD;999 pThis->hRecvThread = NIL_RTTHREAD; 913 1000 } 914 1001 … … 916 1003 * Destroy the semaphore, S/G cache and xmit lock. 917 1004 */ 918 if (h EvtSuspended!= NIL_RTSEMEVENT)919 RTSemEventDestroy(h EvtSuspended);1005 if (hRecvEvt != NIL_RTSEMEVENT) 1006 RTSemEventDestroy(hRecvEvt); 920 1007 921 1008 RTMemCacheDestroy(pThis->hSgCache); … … 966 1053 pThis->pDrvInsR3 = pDrvIns; 967 1054 pThis->hIf = INTNET_HANDLE_INVALID; 968 pThis->hRxThread = NIL_RTTHREAD; 969 pThis->hEvtSuspended = NIL_RTSEMEVENT; 1055 pThis->hRecvThread = NIL_RTTHREAD; 1056 pThis->hRecvEvt = NIL_RTSEMEVENT; 1057 pThis->pXmitThread = NULL; 1058 pThis->hXmitEvt = NIL_SUPSEMEVENT; 1059 pThis->pSupDrvSession = PDMDrvHlpGetSupDrvSession(pDrvIns); 970 1060 pThis->hSgCache = NIL_RTMEMCACHE; 971 1061 pThis->enmState = ASYNCSTATE_SUSPENDED; … … 1249 1339 * Create the event semaphore, S/G cache and xmit critsect. 1250 1340 */ 1251 rc = RTSemEventCreate(&pThis->h EvtSuspended);1341 rc = RTSemEventCreate(&pThis->hRecvEvt); 1252 1342 if (RT_FAILURE(rc)) 1253 1343 return rc; … … 1258 1348 if (RT_FAILURE(rc)) 1259 1349 return rc; 1260 1261 1350 1262 1351 /* … … 1289 1378 1290 1379 /* 1291 * Create the async I/O thread .1380 * Create the async I/O threads. 1292 1381 * Note! Using a PDM thread here doesn't fit with the IsService=true operation. 1293 1382 */ 1294 rc = RTThreadCreate(&pThis->hRxThread, drvR3IntNetAsyncIoThread, pThis, _128K, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "INTNET"); 1383 rc = RTThreadCreate(&pThis->hRecvThread, drvR3IntNetRecvThread, pThis, 0, 1384 RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "INTNET-RECV"); 1295 1385 if (RT_FAILURE(rc)) 1296 1386 { … … 1298 1388 return rc; 1299 1389 } 1390 1391 rc = SUPSemEventCreate(pThis->pSupDrvSession, &pThis->hXmitEvt); 1392 AssertRCReturn(rc, rc); 1393 1394 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pXmitThread, pThis, 1395 drvR3IntNetXmitThread, drvR3IntNetXmitWakeUp, 0, RTTHREADTYPE_IO, "INTNET-XMIT"); 1396 AssertRCReturn(rc, rc); 1397 1398 /* 1399 * Register statistics. 1400 */ 1300 1401 PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->Recv.cbStatWritten, "Bytes/Received", STAMUNIT_BYTES, "Number of received bytes."); 1301 1402 PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->Send.cbStatWritten, "Bytes/Sent", STAMUNIT_BYTES, "Number of sent bytes."); … … 1322 1423 { 1323 1424 ASMAtomicXchgSize(&pThis->enmState, ASYNCSTATE_RUNNING); 1324 RTSemEventSignal(pThis->hEvtSuspended); 1425 RTSemEventSignal(pThis->hRecvEvt); 1426 1325 1427 drvR3IntNetUpdateMacAddress(pThis); 1326 1428 drvR3IntNetSetActive(pThis, true /* fActive */); … … 1329 1431 return rc; 1330 1432 } 1433 1331 1434 1332 1435 -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r28320 r28328 413 413 GEN_CHECK_OFF(PCNetState, ILeds); 414 414 GEN_CHECK_OFF(PCNetState, pLedsConnector); 415 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES416 GEN_CHECK_OFF(PCNetState, hSendEventSem);417 GEN_CHECK_OFF(PCNetState, pSendThread);418 #endif419 415 GEN_CHECK_OFF(PCNetState, CritSect); 420 416 #ifdef PCNET_NO_POLLING … … 1309 1305 GEN_CHECK_OFF(E1KSTATE, csRx); 1310 1306 #endif 1311 #ifdef VBOX_WITH_TX_THREAD_IN_NET_DEVICES1312 GEN_CHECK_OFF(E1KSTATE, hTxSem);1313 GEN_CHECK_OFF(E1KSTATE, pTxThread);1314 #endif1315 1307 GEN_CHECK_OFF(E1KSTATE, addrMMReg); 1316 1308 GEN_CHECK_OFF(E1KSTATE, macConfigured);
Note:
See TracChangeset
for help on using the changeset viewer.