Changeset 27825 in vbox
- Timestamp:
- Mar 30, 2010 1:32:40 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 59498
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r26306 r27825 78 78 /* Enable to handle frequent io reads in the guest context (recommended) */ 79 79 #define PCNET_GC_ENABLED 80 81 /* Experimental: queue TX packets */82 //#define PCNET_QUEUE_SEND_PACKETS83 80 84 81 #if defined(LOG_ENABLED) … … 278 275 bool fAm79C973; 279 276 uint32_t u32LinkSpeed; 280 281 #ifdef PCNET_QUEUE_SEND_PACKETS282 # define PCNET_MAX_XMIT_SLOTS 128283 # define PCNET_MAX_XMIT_SLOTS_MASK (PCNET_MAX_XMIT_SLOTS - 1)284 285 uint32_t iXmitRingBufProd;286 uint32_t iXmitRingBufCons;287 /** @todo XXX currently atomic operations on this variable are overkill */288 volatile int32_t cXmitRingBufPending;289 uint16_t cbXmitRingBuffer[PCNET_MAX_XMIT_SLOTS];290 R3PTRTYPE(uint8_t *) apXmitRingBuffer[PCNET_MAX_XMIT_SLOTS];291 #endif292 277 293 278 STAMCOUNTER StatReceiveBytes; … … 623 608 (R)->rmd2.zeros)) 624 609 625 #if defined(PCNET_QUEUE_SEND_PACKETS) && defined(IN_RING3)626 static int pcnetSyncTransmit(PCNetState *pThis);627 #endif628 610 static void pcnetPollTimerStart(PCNetState *pThis); 629 611 … … 2082 2064 /* Clear counter .*/ 2083 2065 ASMAtomicAndU32(&pThis->cPendingSends, 0); 2084 #ifdef PCNET_QUEUE_SEND_PACKETS2085 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);2086 AssertReleaseRC(rc);2087 pcnetSyncTransmit(pThis);2088 PDMCritSectLeave(&pThis->CritSect);2089 #else2090 2066 int rc = RTSemEventSignal(pThis->hSendEventSem); 2091 2067 AssertRC(rc); 2092 #endif2093 2068 return true; 2094 2069 } … … 2114 2089 Assert(cbFrame < sizeof(pThis->abSendBuf)); 2115 2090 2116 #ifdef PCNET_QUEUE_SEND_PACKETS2117 AssertRelease(pThis->cXmitRingBufPending < PCNET_MAX_XMIT_SLOTS-1);2118 pThis->pvSendFrame = pThis->apXmitRingBuffer[pThis->iXmitRingBufProd];2119 #else2120 2091 pThis->pvSendFrame = pThis->abSendBuf; 2121 #endif2122 2092 PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), GCPhysFrame, pThis->pvSendFrame, cbFrame); 2123 2093 pThis->cbSendFrame = cbFrame; … … 2142 2112 DECLINLINE(int) pcnetXmitCompleteFrame(PCNetState *pThis) 2143 2113 { 2144 #ifdef PCNET_QUEUE_SEND_PACKETS2145 Assert(PDMCritSectIsOwner(&pThis->CritSect));2146 AssertRelease(pThis->cXmitRingBufPending < PCNET_MAX_XMIT_SLOTS-1);2147 Assert(!pThis->cbXmitRingBuffer[pThis->iXmitRingBufProd]);2148 2149 pThis->cbXmitRingBuffer[pThis->iXmitRingBufProd] = (uint16_t)pThis->cbSendFrame;2150 pThis->iXmitRingBufProd = (pThis->iXmitRingBufProd+1) & PCNET_MAX_XMIT_SLOTS_MASK;2151 ASMAtomicIncS32(&pThis->cXmitRingBufPending);2152 2153 int rc = RTSemEventSignal(pThis->hSendEventSem);2154 AssertRC(rc);2155 2156 return VINF_SUCCESS;2157 #else2158 2114 /* Don't hold the critical section while transmitting data. */ 2159 2115 /** @note also avoids deadlocks with NAT as it can call us right back. */ … … 2170 2126 2171 2127 return PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); 2172 #endif2173 2128 } 2174 2129 … … 2280 2235 * Try to transmit frames 2281 2236 */ 2282 #ifdef PCNET_QUEUE_SEND_PACKETS2283 2237 static int pcnetAsyncTransmit(PCNetState *pThis) 2284 {2285 Assert(PDMCritSectIsOwner(&pThis->CritSect));2286 size_t cb;2287 2288 while ((pThis->cXmitRingBufPending > 0))2289 {2290 cb = pThis->cbXmitRingBuffer[pThis->iXmitRingBufCons];2291 2292 /* Don't hold the critical section while transmitting data. */2293 /** @note also avoids deadlocks with NAT as it can call us right back. */2294 PDMCritSectLeave(&pThis->CritSect);2295 2296 STAM_PROFILE_ADV_START(&pThis->StatTransmitSend, a);2297 if (cb > 70) /* unqualified guess */2298 pThis->Led.Asserted.s.fWriting = pThis->Led.Actual.s.fWriting = 1;2299 2300 pThis->pDrv->pfnSend(pThis->pDrv, pThis->apXmitRingBuffer[pThis->iXmitRingBufCons], cb);2301 STAM_REL_COUNTER_ADD(&pThis->StatTransmitBytes, cb);2302 pThis->Led.Actual.s.fWriting = 0;2303 STAM_PROFILE_ADV_STOP(&pThis->StatTransmitSend, a);2304 2305 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);2306 AssertReleaseRC(rc);2307 2308 pThis->cbXmitRingBuffer[pThis->iXmitRingBufCons] = 0;2309 pThis->iXmitRingBufCons = (pThis->iXmitRingBufCons+1) & PCNET_MAX_XMIT_SLOTS_MASK;2310 ASMAtomicDecS32(&pThis->cXmitRingBufPending);2311 }2312 return VINF_SUCCESS;2313 }2314 2315 static int pcnetSyncTransmit(PCNetState *pThis)2316 #else2317 static int pcnetAsyncTransmit(PCNetState *pThis)2318 #endif2319 2238 { 2320 2239 unsigned cFlushIrq = 0; … … 4922 4841 PDMR3CritSectDelete(&pThis->CritSect); 4923 4842 } 4924 #ifdef PCNET_QUEUE_SEND_PACKETS4925 if (pThis->apXmitRingBuffer)4926 RTMemFree(pThis->apXmitRingBuffer[0]);4927 #endif4928 4843 return VINF_SUCCESS; 4929 4844 } … … 5222 5137 rc = PDMDevHlpThreadCreate(pDevIns, &pThis->pSendThread, pThis, pcnetAsyncSendThread, pcnetAsyncSendThreadWakeUp, 0, RTTHREADTYPE_IO, "PCNET_TX"); 5223 5138 AssertRCReturn(rc, rc); 5224 5225 #ifdef PCNET_QUEUE_SEND_PACKETS5226 pThis->apXmitRingBuffer[0] = (uint8_t *)RTMemAlloc(PCNET_MAX_XMIT_SLOTS * MAX_FRAME);5227 for (unsigned i = 1; i < PCNET_MAX_XMIT_SLOTS; i++)5228 pThis->apXmitRingBuffer[i] = pThis->apXmitRingBuffer[0] + i*MAX_FRAME;5229 #endif5230 5139 5231 5140 #ifdef VBOX_WITH_STATISTICS
Note:
See TracChangeset
for help on using the changeset viewer.