Changeset 592 in vbox
- Timestamp:
- Feb 4, 2007 2:38:52 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 18218
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r587 r592 69 69 #ifdef IN_RING3 70 70 #include <iprt/mem.h> 71 #include <iprt/ semaphore.h>71 #include <iprt/req.h> 72 72 #endif 73 73 … … 231 231 #ifdef PCNET_ASYNC_SEND 232 232 /** Async send thread */ 233 RTSEMEVENT hEventSemSend;233 PRTREQQUEUE pSendQueue; 234 234 RTTHREAD hSendThread; 235 235 #endif … … 296 296 STAMCOUNTER StatRingWriteOutsideRangeR0; 297 297 STAMCOUNTER StatRingWriteOutsideRangeGC; 298 # endif299 # ifdef PCNET_ASYNC_SEND300 STAMCOUNTER StatSyncSend;301 STAMCOUNTER StatAsyncSend;302 298 # endif 303 299 #endif /* VBOX_WITH_STATISTICS */ … … 1787 1783 1788 1784 #ifdef IN_RING3 1785 1786 # ifdef PCNET_ASYNC_SEND 1787 /** 1788 * Send packet to the network driver. 1789 */ 1790 DECLCALLBACK(void) pcnetSendAsyncPacket(PCNetState *pData, const void *pvBuf, unsigned cb) 1791 { 1792 Assert(pData && pData->pDrv && pData->pDrv->pfnSend); 1793 1794 pData->pDrv->pfnSend(pData->pDrv, pvBuf, cb); 1795 } 1796 # endif 1797 1789 1798 /** 1790 1799 * Transmit queue consumer … … 1801 1810 int rc; 1802 1811 1803 #ifdef PCNET_ASYNC_SEND1804 /* If the calling threads isn't the async send thread and our queue isn't yet full, then kick off async sending. */1805 if ( pData->iFrame != ELEMENTS(pData->aFrames)1806 && RTThreadSelf() != pData->hSendThread)1807 {1808 STAM_COUNTER_INC(&pData->StatAsyncSend);1809 rc = RTSemEventSignal(pData->hEventSemSend);1810 AssertRC(rc);1811 return VINF_SUCCESS;1812 }1813 if (RTThreadSelf() != pData->hSendThread)1814 STAM_COUNTER_INC(&pData->StatSyncSend);1815 #endif /* PCNET_ASYNC_SEND */1816 1817 1812 STAM_PROFILE_START(&pData->StatXmitQueue, a); 1818 1813 STAM_COUNTER_INC(&pData->aStatFlushCounts[pData->iFrame]); … … 1832 1827 if (pcnetIsLinkUp(pData)) 1833 1828 { 1829 #ifdef PCNET_ASYNC_SEND 1830 1831 /** @note we make a copy here as we don't wish to have to enter the critical section in the async send thread during the lengthy send process. */ 1832 uint8_t *pPacket = RTMemTmpAlloc(pData->aFrames[i].cb); 1833 memcpy(pPacket, pv, pData->aFrames[i].cb); 1834 rc = RTReqCallEx(pData->pSendQueue, NULL, 0, RTREQFLAGS_NO_WAIT, pcnetSendAsyncPacket, pData, pPacket, (unsigned)pData->aFrames[i].cb); 1835 AssertRC(rc); 1836 #else 1834 1837 pData->pDrv->pfnSend(pData->pDrv, pv, pData->aFrames[i].cb); 1838 #endif /* PCNET_ASYNC_SEND */ 1835 1839 LOG_PACKET("xmit", pv, pData->aFrames[i].cb); 1836 1840 } … … 1868 1872 { 1869 1873 PCNetState *pData = (PCNetState *)pvUser; 1870 RTSEMEVENT hEventSemSend = pData->hEventSemSend;1871 1874 1872 1875 while(1) 1873 1876 { 1874 int rc = RT SemEventWait(pData->hEventSemSend, RT_INDEFINITE_WAIT);1877 int rc = RTReqProcess(pQueue); 1875 1878 if (VBOX_FAILURE(rc)) 1876 1879 break; 1877 1878 pcnetXmitQueueConsumer(PCNETSTATE_2_DEVINS(pData), NULL);1879 1880 } 1880 1881 return VINF_SUCCESS; … … 3944 3945 { 3945 3946 PCNetState *pData = PDMINS2DATA(pDevIns, PCNetState *); 3947 #ifdef PCNET_ASYNC_SEND 3948 if (pData->pSendQueue) 3949 RTReqDestroyQueue(pData->pSendQueue); 3950 #endif 3946 3951 PDMR3CritSectDelete(&pData->CritSect); 3947 3952 return VINF_SUCCESS; … … 4203 4208 4204 4209 #ifdef PCNET_ASYNC_SEND 4205 /* Create event semaphore for the async send thread. */4206 rc = RT SemEventCreate(&pData->hEventSemSend);4210 /* Create send queue for the async send thread. */ 4211 rc = RTReqCreateQueue(&pData->pSendQueue); 4207 4212 AssertRC(rc); 4208 4213 … … 4211 4216 AssertRC(rc); 4212 4217 4213 Assert(pData->hSendThread != NIL_RTTHREAD && pData->hEventSemSend != NIL_RTSEMEVENT); 4214 4215 PDMDevHlpSTAMRegisterF(pDevIns, &pData->StatAsyncSend, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of async send operations", "/Devices/PCNet%d/Send/Async", iInstance); 4216 PDMDevHlpSTAMRegisterF(pDevIns, &pData->StatSyncSend, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of sync send operations", "/Devices/PCNet%d/Send/Sync", iInstance); 4218 Assert(pData->hSendThread != NIL_RTTHREAD && pData->pSendQueue); 4217 4219 #endif 4218 4220
Note:
See TracChangeset
for help on using the changeset viewer.