Changeset 40706 in vbox
- Timestamp:
- Mar 29, 2012 12:16:40 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 77165
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNetShaper.cpp
r40652 r40706 403 403 rc = VINF_SUCCESS; 404 404 405 pThis->Filter.pIDrvNet = &pThis->INetworkDown; 405 406 rc = PDMDrvHlpNetShaperAttach(pDrvIns, pThis->pszBwGroup, &pThis->Filter); 406 407 if (RT_FAILURE(rc)) -
trunk/src/VBox/Main/Makefile.kmk
r40066 r40706 710 710 endif 711 711 712 ifdef VBOX_WITH_NETSHAPER 713 VBoxC_DEFS += VBOX_WITH_NETSHAPER 714 endif 715 712 716 ifeq ($(KBUILD_TARGET),darwin) 713 717 VBoxC_ORDERDEPS += $(VBoxC_0_OUTDIR)/VBoxC.def -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r40652 r40706 3708 3708 ComObjPtr<IBandwidthGroup> pBwGroup; 3709 3709 Bstr strBwGroup; 3710 PNETSHAPER pShaper = NULL;3711 PNETSHAPERFILTER pFilter = NULL;3712 3710 hrc = aNetworkAdapter->COMGETTER(BandwidthGroup)(pBwGroup.asOutParam()); H(); 3713 3711 -
trunk/src/VBox/VMM/VMMR3/PDMNetShaper.cpp
r40652 r40706 87 87 /** Critical section protecting all members below. */ 88 88 RTCRITSECT cs; 89 /** Pending TX thread. */ 90 PPDMTHREAD hTxThread; 89 91 /** Pointer to the first bandwidth group. */ 90 92 PPDMNSBWGROUP pBwGroupsHead; … … 221 223 } 222 224 225 static void pdmNsBwGroupXmitPending(PPDMNSBWGROUP pBwGroup) 226 { 227 int rc = RTCritSectEnter(&pBwGroup->cs); AssertRC(rc); 228 229 PPDMNSFILTER pFilter = pBwGroup->pFiltersHead; 230 while (pFilter) 231 { 232 bool fChoked = ASMAtomicXchgBool(&pFilter->fChoked, false); 233 LogFlowFunc(("pFilter=%#p fChoked=%RTbool\n", pFilter, fChoked)); 234 if (fChoked && pFilter->pIDrvNet) 235 { 236 LogFlowFunc(("Calling pfnXmitPending for pFilter=%#p\n", pFilter)); 237 pFilter->pIDrvNet->pfnXmitPending(pFilter->pIDrvNet); 238 } 239 240 pFilter = pFilter->pNext; 241 } 242 243 rc = RTCritSectLeave(&pBwGroup->cs); AssertRC(rc); 244 } 245 223 246 static void pdmNsFilterLink(PPDMNSFILTER pFilter) 224 247 { … … 316 339 bool PDMR3NsAllocateBandwidth(PPDMNSFILTER pFilter, uint32_t cbTransfer) 317 340 { 341 AssertPtrReturn(pFilter, VERR_INVALID_POINTER); 318 342 if (!VALID_PTR(pFilter->pBwGroupR3)) 319 343 return true; … … 328 352 329 353 if (cbTransfer > uTokens) 354 { 330 355 fAllowed = false; 356 ASMAtomicWriteBool(&pFilter->fChoked, true); 357 } 331 358 else 332 359 { … … 338 365 LogFlowFunc(("BwGroup=%#p{%s} cbTransfer=%u uTokens=%u uTokensAdded=%u fAllowed=%RTbool\n", 339 366 pBwGroup, pBwGroup->pszName, cbTransfer, uTokens, uTokensAdded, fAllowed)); 340 return true; // @todo: i need to implement TX thread first! return fAllowed; 341 } 342 367 return fAllowed; 368 } 369 370 /** 371 * I/O thread for pending TX. 372 * 373 * @returns VINF_SUCCESS (ignored). 374 * @param pVM The VM handle. 375 * @param pThread The PDM thread data. 376 */ 377 static DECLCALLBACK(int) pdmR3NsTxThread(PVM pVM, PPDMTHREAD pThread) 378 { 379 PPDMNETSHAPER pShaper = (PPDMNETSHAPER)pThread->pvUser; 380 LogFlow(("pdmR3NsTxThread: pShaper=%p\n", pShaper)); 381 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 382 { 383 RTThreadSleep(PDM_NETSHAPER_MAX_LATENCY); 384 /* Go over all bandwidth groups/filters calling pfnXmitPending */ 385 int rc = RTCritSectEnter(&pShaper->cs); AssertRC(rc); 386 PPDMNSBWGROUP pBwGroup = pShaper->pBwGroupsHead; 387 while (pBwGroup) 388 { 389 pdmNsBwGroupXmitPending(pBwGroup); 390 pBwGroup = pBwGroup->pNext; 391 } 392 rc = RTCritSectLeave(&pShaper->cs); AssertRC(rc); 393 } 394 return VINF_SUCCESS; 395 } 396 397 /** 398 * @copydoc FNPDMTHREADWAKEUPINT 399 */ 400 static DECLCALLBACK(int) pdmR3NsTxWakeUp(PVM pVM, PPDMTHREAD pThread) 401 { 402 PPDMNETSHAPER pShaper = (PPDMNETSHAPER)pThread->pvUser; 403 LogFlow(("pdmR3NsTxWakeUp: pShaper=%p\n", pShaper)); 404 /* Nothing to do */ 405 return VINF_SUCCESS; 406 } 343 407 344 408 /** … … 433 497 ("Network shaper was already initialized\n")); 434 498 435 pUVM->pdm.s.pNetShaper = pNetShaper; 436 return VINF_SUCCESS; 499 char szDesc[256]; 500 static unsigned iThread; 501 502 RTStrPrintf(szDesc, sizeof(szDesc), "PDMNSTXThread-%d", ++iThread); 503 rc = PDMR3ThreadCreate(pVM, &pNetShaper->hTxThread, pNetShaper, 504 pdmR3NsTxThread, pdmR3NsTxWakeUp, 0, 505 RTTHREADTYPE_IO, szDesc); 506 if (RT_SUCCESS(rc)) 507 { 508 pUVM->pdm.s.pNetShaper = pNetShaper; 509 return VINF_SUCCESS; 510 } 437 511 } 438 512
Note:
See TracChangeset
for help on using the changeset viewer.