Lines Matching refs:pRingBuf

260  * @param   pRingBuf        The ring buffer.
262 DECLINLINE(uint32_t) IntNetRingGetWritable(PINTNETRINGBUF pRingBuf)
264 uint32_t const offRead = ASMAtomicUoReadU32(&pRingBuf->offReadX);
265 uint32_t const offWriteInt = ASMAtomicUoReadU32(&pRingBuf->offWriteInt);
267 ? pRingBuf->offEnd - offWriteInt + offRead - pRingBuf->offStart - 1
276 * @param pRingBuf The ring buffer.
278 DECLINLINE(bool) IntNetRingHasMoreToRead(PINTNETRINGBUF pRingBuf)
280 uint32_t const offRead = ASMAtomicUoReadU32(&pRingBuf->offReadX);
281 uint32_t const offWriteCom = ASMAtomicUoReadU32(&pRingBuf->offWriteCom);
290 * @param pRingBuf The ring buffer.
292 DECLINLINE(PINTNETHDR) IntNetRingGetNextFrameToRead(PINTNETRINGBUF pRingBuf)
294 uint32_t const offRead = ASMAtomicUoReadU32(&pRingBuf->offReadX);
295 uint32_t const offWriteCom = ASMAtomicUoReadU32(&pRingBuf->offWriteCom);
298 return (PINTNETHDR)((uint8_t *)pRingBuf + offRead);
306 * @param pRingBuf The ring buffer.
308 DECLINLINE(uint32_t) IntNetRingGetReadable(PINTNETRINGBUF pRingBuf)
310 uint32_t const offRead = ASMAtomicUoReadU32(&pRingBuf->offReadX);
311 uint32_t const offWriteCom = ASMAtomicUoReadU32(&pRingBuf->offWriteCom);
314 : pRingBuf->offEnd - offRead + offWriteCom - pRingBuf->offStart;
368 * @param pRingBuf The ring buffer in question.
370 DECLINLINE(void) IntNetRingSkipFrame(PINTNETRINGBUF pRingBuf)
372 uint32_t const offReadOld = ASMAtomicUoReadU32(&pRingBuf->offReadX);
373 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offReadOld);
374 Assert(offReadOld >= pRingBuf->offStart);
375 Assert(offReadOld < pRingBuf->offEnd);
382 Assert(offReadNew <= pRingBuf->offEnd && offReadNew >= pRingBuf->offStart);
383 if (offReadNew >= pRingBuf->offEnd)
384 offReadNew = pRingBuf->offStart;
390 ASMAtomicWriteU32(&pRingBuf->offReadX, offReadNew);
398 * @param pRingBuf The ring buffer.
404 DECLINLINE(int) intnetRingAllocateFrameInternal(PINTNETRINGBUF pRingBuf, uint32_t cbFrame, uint8_t u8Type,
410 INTNETRINGBUF_ASSERT_SANITY(pRingBuf);
414 uint32_t offWriteInt = ASMAtomicUoReadU32(&pRingBuf->offWriteInt);
415 uint32_t offRead = ASMAtomicUoReadU32(&pRingBuf->offReadX);
421 if (pRingBuf->offEnd - offWriteInt >= cb + sizeof(INTNETHDR))
424 if (offNew >= pRingBuf->offEnd)
425 offNew = pRingBuf->offStart;
426 if (RT_UNLIKELY(!ASMAtomicCmpXchgU32(&pRingBuf->offWriteInt, offNew, offWriteInt)))
430 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt);
443 AssertMsg(pRingBuf->offEnd - offWriteInt >= sizeof(INTNETHDR), ("offEnd=%x offWriteInt=%x\n", pRingBuf->offEnd, offWriteInt));
444 if (offRead - pRingBuf->offStart > cb) /* not >= ! */
446 uint32_t offNew = pRingBuf->offStart + cb;
447 if (RT_UNLIKELY(!ASMAtomicCmpXchgU32(&pRingBuf->offWriteInt, offNew, offWriteInt)))
451 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt);
454 pHdr->offFrame = pRingBuf->offStart - offWriteInt;
457 *ppvFrame = (uint8_t *)pRingBuf + pRingBuf->offStart;
467 if (RT_UNLIKELY(!ASMAtomicCmpXchgU32(&pRingBuf->offWriteInt, offNew, offWriteInt)))
471 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt);
484 STAM_REL_COUNTER_INC(&pRingBuf->cOverflows);
493 * @param pRingBuf The ring buffer.
499 DECLINLINE(int) IntNetRingAllocateFrame(PINTNETRINGBUF pRingBuf, uint32_t cbFrame, PINTNETHDR *ppHdr, void **ppvFrame)
501 return intnetRingAllocateFrameInternal(pRingBuf, cbFrame, INTNETHDR_TYPE_FRAME, ppHdr, ppvFrame);
509 * @param pRingBuf The ring buffer.
516 DECLINLINE(int) IntNetRingAllocateGsoFrame(PINTNETRINGBUF pRingBuf, uint32_t cbFrame, PCPDMNETWORKGSO pGso,
520 int rc = intnetRingAllocateFrameInternal(pRingBuf, cbFrame + sizeof(*pGso), INTNETHDR_TYPE_GSO, ppHdr, &pvFrame);
537 * @param pRingBuf The ring buffer.
541 DECLINLINE(void) IntNetRingCommitFrame(PINTNETRINGBUF pRingBuf, PINTNETHDR pHdr)
546 INTNETRINGBUF_ASSERT_SANITY(pRingBuf);
547 INTNETHDR_ASSERT_SANITY(pHdr, pRingBuf);
548 Assert(pRingBuf->offWriteCom == ((uintptr_t)pHdr - (uintptr_t)pRingBuf));
555 uint32_t offWriteCom = (uint32_t)((uintptr_t)pHdr - (uintptr_t)pRingBuf)
558 if (offWriteCom >= pRingBuf->offEnd)
560 Assert(offWriteCom == pRingBuf->offEnd);
561 offWriteCom = pRingBuf->offStart;
563 Log2(("IntNetRingCommitFrame: offWriteCom: %#x -> %#x (R=%#x T=%#x S=%#x)\n", pRingBuf->offWriteCom, offWriteCom, pRingBuf->offReadX, pHdr->u8Type, cbFrame));
564 ASMAtomicWriteU32(&pRingBuf->offWriteCom, offWriteCom);
565 STAM_REL_COUNTER_ADD(&pRingBuf->cbStatWritten, cbFrame);
566 STAM_REL_COUNTER_INC(&pRingBuf->cStatFrames);
576 * @param pRingBuf The ring buffer.
582 DECLINLINE(void) IntNetRingCommitFrameEx(PINTNETRINGBUF pRingBuf, PINTNETHDR pHdr, size_t cbUsed)
587 INTNETRINGBUF_ASSERT_SANITY(pRingBuf);
588 INTNETHDR_ASSERT_SANITY(pHdr, pRingBuf);
589 Assert(pRingBuf->offWriteCom == ((uintptr_t)pHdr - (uintptr_t)pRingBuf));
599 uint32_t offWriteCom = (uint32_t)((uintptr_t)pHdr - (uintptr_t)pRingBuf)
602 if (offWriteCom >= pRingBuf->offEnd)
604 Assert(offWriteCom == pRingBuf->offEnd);
605 offWriteCom = pRingBuf->offStart;
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));
623 ASMAtomicWriteU32(&pRingBuf->offWriteCom, offWriteCom);
624 STAM_REL_COUNTER_ADD(&pRingBuf->cbStatWritten, cbUsed);
625 STAM_REL_COUNTER_INC(&pRingBuf->cStatFrames);
635 * @param pRingBuf The ring buffer.
639 DECLINLINE(int) IntNetRingWriteFrame(PINTNETRINGBUF pRingBuf, const void *pvFrame, size_t cbFrame)
644 INTNETRINGBUF_ASSERT_SANITY(pRingBuf);
651 uint32_t offWriteInt = ASMAtomicUoReadU32(&pRingBuf->offWriteInt);
652 uint32_t offRead = ASMAtomicUoReadU32(&pRingBuf->offReadX);
658 if (pRingBuf->offEnd - offWriteInt >= cb + sizeof(INTNETHDR))
661 if (offNew >= pRingBuf->offEnd)
662 offNew = pRingBuf->offStart;
663 if (RT_UNLIKELY(!ASMAtomicCmpXchgU32(&pRingBuf->offWriteInt, offNew, offWriteInt)))
667 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt);
674 Log2(("IntNetRingWriteFrame: offWriteCom: %#x -> %#x (1)\n", pRingBuf->offWriteCom, offNew));
675 ASMAtomicWriteU32(&pRingBuf->offWriteCom, offNew);
676 STAM_REL_COUNTER_ADD(&pRingBuf->cbStatWritten, cbFrame);
677 STAM_REL_COUNTER_INC(&pRingBuf->cStatFrames);
684 AssertMsg(pRingBuf->offEnd - offWriteInt >= sizeof(INTNETHDR), ("offEnd=%x offWriteInt=%x\n", pRingBuf->offEnd, offWriteInt));
685 if (offRead - pRingBuf->offStart > cb) /* not >= ! */
687 uint32_t offNew = pRingBuf->offStart + cb;
688 if (RT_UNLIKELY(!ASMAtomicCmpXchgU32(&pRingBuf->offWriteInt, offNew, offWriteInt)))
692 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt);
695 pHdr->offFrame = pRingBuf->offStart - offWriteInt;
697 memcpy((uint8_t *)pRingBuf + pRingBuf->offStart, pvFrame, cbFrame);
699 Log2(("IntNetRingWriteFrame: offWriteCom: %#x -> %#x (2)\n", pRingBuf->offWriteCom, offNew));
700 ASMAtomicWriteU32(&pRingBuf->offWriteCom, offNew);
701 STAM_REL_COUNTER_ADD(&pRingBuf->cbStatWritten, cbFrame);
702 STAM_REL_COUNTER_INC(&pRingBuf->cStatFrames);
712 if (RT_UNLIKELY(!ASMAtomicCmpXchgU32(&pRingBuf->offWriteInt, offNew, offWriteInt)))
716 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offWriteInt);
723 Log2(("IntNetRingWriteFrame: offWriteCom: %#x -> %#x (3)\n", pRingBuf->offWriteCom, offNew));
724 ASMAtomicWriteU32(&pRingBuf->offWriteCom, offNew);
725 STAM_REL_COUNTER_ADD(&pRingBuf->cbStatWritten, cbFrame);
726 STAM_REL_COUNTER_INC(&pRingBuf->cStatFrames);
731 STAM_REL_COUNTER_INC(&pRingBuf->cOverflows);
746 DECLINLINE(uint32_t) IntNetRingReadAndSkipFrame(PINTNETRINGBUF pRingBuf, void *pvFrameDst)
748 INTNETRINGBUF_ASSERT_SANITY(pRingBuf);
750 uint32_t offRead = ASMAtomicUoReadU32(&pRingBuf->offReadX);
751 uint32_t const offWriteCom = ASMAtomicUoReadU32(&pRingBuf->offWriteCom);
755 PINTNETHDR pHdr = (PINTNETHDR)((uint8_t *)pRingBuf + offRead);
756 INTNETHDR_ASSERT_SANITY(pHdr, pRingBuf);
770 Assert(offRead <= pRingBuf->offEnd && offRead >= pRingBuf->offStart);
771 if (offRead >= pRingBuf->offEnd)
772 offRead = pRingBuf->offStart;
773 ASMAtomicWriteU32(&pRingBuf->offReadX, offRead);