Changeset 46904 in vbox for trunk/include/VBox
- Timestamp:
- Jul 2, 2013 12:59:56 PM (11 years ago)
- Location:
- trunk/include/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/intnet.h
r39034 r46904 214 214 typedef struct INTNETHDR 215 215 { 216 /** The size of the frame. */ 217 uint32_t cbFrame : 24; 216 218 /** Header type. This is currently serving as a magic, it 217 219 * can be extended later to encode special command frames and stuff. */ 218 uint16_t u16Type; 219 /** The size of the frame. */ 220 uint16_t cbFrame; 220 uint32_t u8Type : 8; 221 221 /** The offset from the start of this header to where the actual frame starts. 222 222 * This is used to keep the frame it self contiguous in virtual memory and … … 236 236 AssertCompile(INTNETHDR_ALIGNMENT <= INTNETRINGBUF_ALIGNMENT); 237 237 238 /** @name Frame types (INTNETHDR::u 16Type).238 /** @name Frame types (INTNETHDR::u8Type). 239 239 * @{ */ 240 240 /** Normal frames. */ 241 #define INTNETHDR_TYPE_FRAME 0x 2442241 #define INTNETHDR_TYPE_FRAME 0x42 242 242 /** Padding frames. */ 243 #define INTNETHDR_TYPE_PADDING 0x 3553243 #define INTNETHDR_TYPE_PADDING 0x53 244 244 /** Generic segment offload frames. 245 245 * The frame starts with a PDMNETWORKGSO structure which is followed by the 246 246 * header template and data. */ 247 #define INTNETHDR_TYPE_GSO 0x 4664247 #define INTNETHDR_TYPE_GSO 0x64 248 248 AssertCompileSize(PDMNETWORKGSO, 8); 249 249 /** @} */ … … 258 258 AssertPtr(pHdr); \ 259 259 Assert(RT_ALIGN_PT(pHdr, INTNETHDR_ALIGNMENT, INTNETHDR *) == pHdr); \ 260 Assert( (pHdr)->u 16Type == INTNETHDR_TYPE_FRAME \261 || (pHdr)->u 16Type == INTNETHDR_TYPE_GSO \262 || (pHdr)->u 16Type == INTNETHDR_TYPE_PADDING); \260 Assert( (pHdr)->u8Type == INTNETHDR_TYPE_FRAME \ 261 || (pHdr)->u8Type == INTNETHDR_TYPE_GSO \ 262 || (pHdr)->u8Type == INTNETHDR_TYPE_PADDING); \ 263 263 { \ 264 264 uintptr_t const offHdr = (uintptr_t)pHdr - (uintptr_t)pRingBuf; \ -
trunk/include/VBox/intnetinline.h
r44528 r46904 44 44 * 45 45 * @returns true / false. 46 * @param u16Type The frame type to check.47 */ 48 DECLINLINE(bool) IntNetIsValidFrameType(uint 16_t u16Type)49 { 50 if (RT_LIKELY( u 16Type == INTNETHDR_TYPE_FRAME51 || u 16Type == INTNETHDR_TYPE_GSO52 || u 16Type == INTNETHDR_TYPE_PADDING))46 * @param u8Type The frame type to check. 47 */ 48 DECLINLINE(bool) IntNetIsValidFrameType(uint8_t u8Type) 49 { 50 if (RT_LIKELY( u8Type == INTNETHDR_TYPE_FRAME 51 || u8Type == INTNETHDR_TYPE_GSO 52 || u8Type == INTNETHDR_TYPE_PADDING)) 53 53 return true; 54 54 return false; … … 328 328 #ifdef VBOX_STRICT 329 329 const uintptr_t off = (uintptr_t)pu8 - (uintptr_t)pBuf; 330 Assert(IntNetIsValidFrameType(pHdr->u 16Type));330 Assert(IntNetIsValidFrameType(pHdr->u8Type)); 331 331 Assert(off < pBuf->cbBuf); 332 332 Assert(off + pHdr->cbFrame <= pBuf->cbBuf); … … 354 354 #ifdef VBOX_STRICT 355 355 const uintptr_t off = (uintptr_t)pGso - (uintptr_t)pBuf; 356 Assert(pHdr->u 16Type == INTNETHDR_TYPE_GSO);356 Assert(pHdr->u8Type == INTNETHDR_TYPE_GSO); 357 357 Assert(off < pBuf->cbBuf); 358 358 Assert(off + pHdr->cbFrame <= pBuf->cbBuf); … … 375 375 Assert(offReadOld < pRingBuf->offEnd); 376 376 Assert(RT_ALIGN_PT(pHdr, INTNETHDR_ALIGNMENT, INTNETHDR *) == pHdr); 377 Assert(IntNetIsValidFrameType(pHdr->u 16Type));377 Assert(IntNetIsValidFrameType(pHdr->u8Type)); 378 378 379 379 /* skip the frame */ … … 402 402 * @param ppvFrame Where to return the frame pointer. 403 403 */ 404 DECLINLINE(int) intnetRingAllocateFrameInternal(PINTNETRINGBUF pRingBuf, uint32_t cbFrame, uint 16_t u16Type,404 DECLINLINE(int) intnetRingAllocateFrameInternal(PINTNETRINGBUF pRingBuf, uint32_t cbFrame, uint8_t u8Type, 405 405 PINTNETHDR *ppHdr, void **ppvFrame) 406 406 { … … 426 426 if (RT_UNLIKELY(!ASMAtomicCmpXchgU32(&pRingBuf->offWriteInt, offNew, offWriteInt))) 427 427 return VERR_WRONG_ORDER; /* race */ 428 Log2(("intnetRingAllocateFrameInternal: offWriteInt: %#x -> %#x (1) (R=%#x T=%#x S=%#x)\n", offWriteInt, offNew, offRead, u 16Type, cbFrame));428 Log2(("intnetRingAllocateFrameInternal: offWriteInt: %#x -> %#x (1) (R=%#x T=%#x S=%#x)\n", offWriteInt, offNew, offRead, u8Type, cbFrame)); 429 429 430 430 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt); 431 pHdr->u 16Type = u16Type;432 pHdr->cbFrame = (uint16_t)cbFrame; Assert(pHdr->cbFrame == cbFrame);431 pHdr->u8Type = u8Type; 432 pHdr->cbFrame = cbFrame; Assert(pHdr->cbFrame == cbFrame); 433 433 pHdr->offFrame = sizeof(INTNETHDR); 434 434 … … 447 447 if (RT_UNLIKELY(!ASMAtomicCmpXchgU32(&pRingBuf->offWriteInt, offNew, offWriteInt))) 448 448 return VERR_WRONG_ORDER; /* race */ 449 Log2(("intnetRingAllocateFrameInternal: offWriteInt: %#x -> %#x (2) (R=%#x T=%#x S=%#x)\n", offWriteInt, offNew, offRead, u 16Type, cbFrame));449 Log2(("intnetRingAllocateFrameInternal: offWriteInt: %#x -> %#x (2) (R=%#x T=%#x S=%#x)\n", offWriteInt, offNew, offRead, u8Type, cbFrame)); 450 450 451 451 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt); 452 pHdr->u 16Type = u16Type;453 pHdr->cbFrame = (uint16_t)cbFrame; Assert(pHdr->cbFrame == cbFrame);452 pHdr->u8Type = u8Type; 453 pHdr->cbFrame = cbFrame; Assert(pHdr->cbFrame == cbFrame); 454 454 pHdr->offFrame = pRingBuf->offStart - offWriteInt; 455 455 … … 467 467 if (RT_UNLIKELY(!ASMAtomicCmpXchgU32(&pRingBuf->offWriteInt, offNew, offWriteInt))) 468 468 return VERR_WRONG_ORDER; /* race */ 469 Log2(("intnetRingAllocateFrameInternal: offWriteInt: %#x -> %#x (3) (R=%#x T=%#x S=%#x)\n", offWriteInt, offNew, offRead, u 16Type, cbFrame));469 Log2(("intnetRingAllocateFrameInternal: offWriteInt: %#x -> %#x (3) (R=%#x T=%#x S=%#x)\n", offWriteInt, offNew, offRead, u8Type, cbFrame)); 470 470 471 471 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt); 472 pHdr->u 16Type = u16Type;473 pHdr->cbFrame = (uint16_t)cbFrame; Assert(pHdr->cbFrame == cbFrame);472 pHdr->u8Type = u8Type; 473 pHdr->cbFrame = cbFrame; Assert(pHdr->cbFrame == cbFrame); 474 474 pHdr->offFrame = sizeof(INTNETHDR); 475 475 … … 561 561 offWriteCom = pRingBuf->offStart; 562 562 } 563 Log2(("IntNetRingCommitFrame: offWriteCom: %#x -> %#x (R=%#x T=%#x S=%#x)\n", pRingBuf->offWriteCom, offWriteCom, pRingBuf->offReadX, pHdr->u 16Type, cbFrame));563 Log2(("IntNetRingCommitFrame: offWriteCom: %#x -> %#x (R=%#x T=%#x S=%#x)\n", pRingBuf->offWriteCom, offWriteCom, pRingBuf->offReadX, pHdr->u8Type, cbFrame)); 564 564 ASMAtomicWriteU32(&pRingBuf->offWriteCom, offWriteCom); 565 565 STAM_REL_COUNTER_ADD(&pRingBuf->cbStatWritten, cbFrame); … … 589 589 Assert(pRingBuf->offWriteCom == ((uintptr_t)pHdr - (uintptr_t)pRingBuf)); 590 590 591 if (pHdr->u 16Type == INTNETHDR_TYPE_GSO)591 if (pHdr->u8Type == INTNETHDR_TYPE_GSO) 592 592 cbUsed += sizeof(PDMNETWORKGSO); 593 593 … … 613 613 /** @todo Later: Try unallocate the extra memory. */ 614 614 PINTNETHDR pHdrPadding = (PINTNETHDR)((uint8_t *)pHdr + pHdr->offFrame + cbAlignedUsed); 615 pHdrPadding->u16Type = INTNETHDR_TYPE_PADDING; 616 pHdrPadding->cbFrame = (uint16_t)(cbAlignedFrame - cbAlignedUsed - sizeof(INTNETHDR)); 615 pHdrPadding->u8Type = INTNETHDR_TYPE_PADDING; 616 pHdrPadding->cbFrame = cbAlignedFrame - cbAlignedUsed - sizeof(INTNETHDR); 617 Assert(pHdrPadding->cbFrame == cbAlignedFrame - cbAlignedUsed - sizeof(INTNETHDR)); 617 618 pHdrPadding->offFrame = sizeof(INTNETHDR); 618 pHdr->cbFrame = (uint16_t)cbUsed;619 } 620 621 Log2(("IntNetRingCommitFrameEx: offWriteCom: %#x -> %#x (R=%#x T=%#x S=%#x P=%#x)\n", pRingBuf->offWriteCom, offWriteCom, pRingBuf->offReadX, pHdr->u 16Type, pHdr->cbFrame, cbAlignedFrame - cbAlignedUsed));619 pHdr->cbFrame = cbUsed; Assert(pHdr->cbFrame == cbUsed); 620 } 621 622 Log2(("IntNetRingCommitFrameEx: offWriteCom: %#x -> %#x (R=%#x T=%#x S=%#x P=%#x)\n", pRingBuf->offWriteCom, offWriteCom, pRingBuf->offReadX, pHdr->u8Type, pHdr->cbFrame, cbAlignedFrame - cbAlignedUsed)); 622 623 ASMAtomicWriteU32(&pRingBuf->offWriteCom, offWriteCom); 623 624 STAM_REL_COUNTER_ADD(&pRingBuf->cbStatWritten, cbUsed); … … 665 666 666 667 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt); 667 pHdr->u 16Type= INTNETHDR_TYPE_FRAME;668 pHdr->cbFrame = (uint16_t)cbFrame; Assert(pHdr->cbFrame == cbFrame);668 pHdr->u8Type = INTNETHDR_TYPE_FRAME; 669 pHdr->cbFrame = cbFrame; Assert(pHdr->cbFrame == cbFrame); 669 670 pHdr->offFrame = sizeof(INTNETHDR); 670 671 … … 690 691 691 692 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt); 692 pHdr->u 16Type= INTNETHDR_TYPE_FRAME;693 pHdr->cbFrame = (uint16_t)cbFrame; Assert(pHdr->cbFrame == cbFrame);693 pHdr->u8Type = INTNETHDR_TYPE_FRAME; 694 pHdr->cbFrame = cbFrame; Assert(pHdr->cbFrame == cbFrame); 694 695 pHdr->offFrame = pRingBuf->offStart - offWriteInt; 695 696 … … 714 715 715 716 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt); 716 pHdr->u 16Type= INTNETHDR_TYPE_FRAME;717 pHdr->cbFrame = (uint16_t)cbFrame; Assert(pHdr->cbFrame == cbFrame);717 pHdr->u8Type = INTNETHDR_TYPE_FRAME; 718 pHdr->cbFrame = cbFrame; Assert(pHdr->cbFrame == cbFrame); 718 719 pHdr->offFrame = sizeof(INTNETHDR); 719 720
Note:
See TracChangeset
for help on using the changeset viewer.