Changeset 44355 in vbox for trunk/src/VBox/VMM/include
- Timestamp:
- Jan 24, 2013 1:27:28 PM (12 years ago)
- Location:
- trunk/src/VBox/VMM/include
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/include/PDMInternal.h
r43657 r44355 1086 1086 R3PTRTYPE(PPDMASYNCCOMPLETIONTEMPLATE) pAsyncCompletionTemplates; 1087 1087 /** @} */ 1088 1089 /** Global block cache data. */ 1090 R3PTRTYPE(PPDMBLKCACHEGLOBAL) pBlkCacheGlobal; 1088 1091 #ifdef VBOX_WITH_NETSHAPER 1089 1092 /** Pointer to network shaper instance. */ 1090 1093 R3PTRTYPE(PPDMNETSHAPER) pNetShaper; 1091 1094 #endif /* VBOX_WITH_NETSHAPER */ 1092 1093 R3PTRTYPE(PPDMBLKCACHEGLOBAL) pBlkCacheGlobal;1094 1095 1095 1096 } PDMUSERPERVM; -
trunk/src/VBox/VMM/include/PDMNetShaperInternal.h
r44346 r44355 1 1 /* $Id$ */ 2 2 /** @file 3 * PDM Network Shaper - Internal data structures and functions common for both 4 * R0 and R3 parts. 3 * PDM Network Shaper - Internal data structures and functions common for both R0 and R3 parts. 5 4 */ 6 5 7 6 /* 8 * Copyright (C) 2011-201 2Oracle Corporation7 * Copyright (C) 2011-2013 Oracle Corporation 9 8 * 10 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 32 31 { 33 32 /** Pointer to the next group in the list. */ 34 struct PDMNSBWGROUP *pNext;33 R3PTRTYPE(struct PDMNSBWGROUP *) pNextR3; 35 34 /** Pointer to the shared UVM structure. */ 36 struct PDMNETSHAPER *pShaper;35 R3PTRTYPE(struct PDMNETSHAPER *) pShaperR3; 37 36 /** Critical section protecting all members below. */ 38 PDMCRITSECT cs;37 PDMCRITSECT Lock; 39 38 /** Pointer to the first filter attached to this group. */ 40 struct PDMNSFILTER *pFiltersHead;39 R3PTRTYPE(struct PDMNSFILTER *) pFiltersHeadR3; 41 40 /** Bandwidth group name. */ 42 char *pszName;41 R3PTRTYPE(char *) pszNameR3; 43 42 /** Maximum number of bytes filters are allowed to transfer. */ 44 volatile uint64_t cb TransferPerSecMax;43 volatile uint64_t cbPerSecMax; 45 44 /** Number of bytes we are allowed to transfer in one burst. */ 46 volatile uint32_t cbBucket Size;45 volatile uint32_t cbBucket; 47 46 /** Number of bytes we were allowed to transfer at the last update. */ 48 47 volatile uint32_t cbTokensLast; … … 55 54 typedef PDMNSBWGROUP *PPDMNSBWGROUP; 56 55 57 DECLINLINE(bool) pdmNsAllocateBandwidth(PPDMNSFILTER pFilter, size_t cbTransfer)58 {59 AssertPtrReturn(pFilter, true);60 if (!VALID_PTR(pFilter->CTX_SUFF(pBwGroup)))61 return true;62 56 63 PPDMNSBWGROUP pBwGroup = ASMAtomicReadPtrT(&pFilter->CTX_SUFF(pBwGroup), PPDMNSBWGROUP);64 int rc = PDMCritSectEnter(&pBwGroup->cs, VERR_SEM_BUSY); AssertRC(rc);65 if (RT_UNLIKELY(rc == VERR_SEM_BUSY))66 return true;67 bool fAllowed = true;68 if (pBwGroup->cbTransferPerSecMax)69 {70 /* Re-fill the bucket first */71 uint64_t tsNow = RTTimeSystemNanoTS();72 uint32_t uTokensAdded = (tsNow - pBwGroup->tsUpdatedLast)*pBwGroup->cbTransferPerSecMax/(1000*1000*1000);73 uint32_t uTokens = RT_MIN(pBwGroup->cbBucketSize, uTokensAdded + pBwGroup->cbTokensLast);74 75 if (cbTransfer > uTokens)76 {77 fAllowed = false;78 ASMAtomicWriteBool(&pFilter->fChoked, true);79 }80 else81 {82 pBwGroup->tsUpdatedLast = tsNow;83 pBwGroup->cbTokensLast = uTokens - (uint32_t)cbTransfer;84 }85 Log2((LOG_FN_FMT "BwGroup=%#p{%s} cbTransfer=%u uTokens=%u uTokensAdded=%u fAllowed=%RTbool\n",86 __PRETTY_FUNCTION__, pBwGroup, pBwGroup->pszName, cbTransfer, uTokens, uTokensAdded, fAllowed));87 }88 else89 Log2((LOG_FN_FMT "BwGroup=%#p{%s} disabled fAllowed=%RTbool\n",90 __PRETTY_FUNCTION__, pBwGroup, pBwGroup->pszName, fAllowed));91 92 rc = PDMCritSectLeave(&pBwGroup->cs); AssertRC(rc);93 return fAllowed;94 }
Note:
See TracChangeset
for help on using the changeset viewer.