Changeset 97299 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Oct 25, 2022 2:21:34 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 154290
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/testcase/tstIntNetR0.cpp
r97294 r97299 221 221 uint64_t u64Start; 222 222 uint64_t u64End; 223 uint32_t cbSent; 224 uint32_t cFramesSent; 223 225 } MYARGS, *PMYARGS; 224 226 … … 254 256 uint32_t iFrame = 0; 255 257 uint32_t cbSent = 0; 258 uint32_t cErrors = 0; 256 259 257 260 pHdr->SrcMac = pArgs->Mac; … … 272 275 if (RT_SUCCESS(rc)) 273 276 RTTEST_CHECK_RC_OK(g_hTest, rc = IntNetR0IfSend(pArgs->hIf, g_pSession)); 277 if (RT_FAILURE(rc) && ++cErrors > 64) 278 { 279 RTTestFailed(g_hTest, "Aborting xmit after >64 errors"); 280 break; 281 } 282 274 283 cbSent += cb; 275 284 } 285 pArgs->cbSent = cbSent; 286 pArgs->cFramesSent = iFrame; 276 287 277 288 /* … … 401 412 402 413 /** 414 * Drains the interface buffer before starting a new bi-directional run. 415 * 416 * We may have termination frames from previous runs pending in the buffer. 417 */ 418 static void tstDrainInterfaceBuffer(PMYARGS pArgs) 419 { 420 uint8_t abBuf[16384 + 1024]; 421 while (IntNetRingHasMoreToRead(&pArgs->pBuf->Recv)) 422 IntNetRingReadAndSkipFrame(&pArgs->pBuf->Recv, abBuf); 423 } 424 425 426 /** 403 427 * Test state. 404 428 */ … … 471 495 static void tstBidirectionalTransfer(PTSTSTATE pThis, uint32_t cbFrame) 472 496 { 497 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "-------------------------------------------------------------\n"); 498 499 /* 500 * Reset statistics. 501 */ 502 pThis->pBuf0->cStatYieldsOk.c = 0; 503 pThis->pBuf0->cStatYieldsNok.c = 0; 504 pThis->pBuf0->cStatLost.c = 0; 505 pThis->pBuf0->cStatBadFrames.c = 0; 506 pThis->pBuf0->Recv.cStatFrames.c = 0; 507 pThis->pBuf0->Recv.cbStatWritten.c = 0; 508 pThis->pBuf0->Recv.cOverflows.c = 0; 509 pThis->pBuf0->Send.cStatFrames.c = 0; 510 pThis->pBuf0->Send.cbStatWritten.c = 0; 511 pThis->pBuf0->Send.cOverflows.c = 0; 512 pThis->pBuf1->cStatYieldsOk.c = 0; 513 pThis->pBuf1->cStatYieldsNok.c = 0; 514 pThis->pBuf1->cStatLost.c = 0; 515 pThis->pBuf1->cStatBadFrames.c = 0; 516 pThis->pBuf1->Recv.cStatFrames.c = 0; 517 pThis->pBuf1->Recv.cbStatWritten.c = 0; 518 pThis->pBuf1->Recv.cOverflows.c = 0; 519 pThis->pBuf1->Send.cStatFrames.c = 0; 520 pThis->pBuf1->Send.cbStatWritten.c = 0; 521 pThis->pBuf1->Send.cOverflows.c = 0; 522 523 /* 524 * Do the benchmarking. 525 */ 473 526 MYARGS Args0; 474 527 RT_ZERO(Args0); … … 479 532 Args0.Mac.au16[2] = 0; 480 533 Args0.cbFrame = cbFrame; 534 tstDrainInterfaceBuffer(&Args0); 535 //RTTESTI_CHECK_RC_OK(IntNetR0IfSetMacAddress(pThis->hIf0, g_pSession, &Args0.Mac)); 481 536 482 537 MYARGS Args1; … … 488 543 Args1.Mac.au16[2] = 1; 489 544 Args1.cbFrame = cbFrame; 545 tstDrainInterfaceBuffer(&Args1); 546 //RTTESTI_CHECK_RC_OK(IntNetR0IfSetMacAddress(pThis->hIf1, g_pSession, &Args1.Mac)); 490 547 491 548 RTTHREAD ThreadRecv0 = NIL_RTTHREAD; … … 500 557 int rc2 = VINF_SUCCESS; 501 558 int rc; 502 RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadSend0, 5*60*1000, &rc2));559 RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadSend0, RT_MS_5MIN, &rc2)); 503 560 if (RT_SUCCESS(rc)) 504 561 { 505 562 RTTESTI_CHECK_RC_OK(rc2); 506 563 ThreadSend0 = NIL_RTTHREAD; 507 RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadSend1, 5*60*1000, RT_SUCCESS(rc2) ? &rc2 : NULL));564 RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadSend1, RT_MS_5MIN, RT_SUCCESS(rc2) ? &rc2 : NULL)); 508 565 if (RT_SUCCESS(rc)) 509 566 { … … 523 580 RTThreadYield(); 524 581 525 uint64_t u64Elapsed = RT_MAX(Args0.u64End, Args1.u64End) - RT_MIN(Args0.u64Start, Args1.u64Start);526 uint64_t u64Speed = (uint64_t)((double)(2 * g_cbTransfer / 1024) / ((double)u64Elapsed / 1000000000.0));527 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,528 "transferred %u bytes in %'RU64 ns (%'RU64 KB/s)\n",529 2 * g_cbTransfer, u64Elapsed, u64Speed);530 531 582 /* 532 583 * Wait for the threads to finish up... 533 584 */ 534 RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadRecv0, 5000, &rc2));585 RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadRecv0, RT_MS_5SEC, &rc2)); 535 586 if (RT_SUCCESS(rc)) 536 587 { … … 539 590 } 540 591 541 RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadRecv1, 5000, &rc2));592 RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadRecv1, RT_MS_5MIN, &rc2)); 542 593 if (RT_SUCCESS(rc)) 543 594 { … … 545 596 ThreadRecv1 = NIL_RTTHREAD; 546 597 } 598 599 /* 600 * Report the results. 601 */ 602 uint64_t cNsElapsed = RT_MAX(Args0.u64End, Args1.u64End) - RT_MIN(Args0.u64Start, Args1.u64Start); 603 uint64_t cbSent = (uint64_t)Args0.cbSent + Args1.cbSent; 604 uint64_t cKbps = (uint64_t)((double)(cbSent / 1024) / ((double)cNsElapsed / 1000000000.0)); 605 uint64_t cFrames = (uint64_t)Args0.cFramesSent + Args1.cFramesSent; 606 uint64_t cFps = (uint64_t)(cFrames / ((double)cNsElapsed / 1000000000.0)); 607 RTTestValue(g_hTest, "frame size", cbFrame, RTTESTUNIT_BYTES); 608 RTTestValue(g_hTest, "xmit time", cNsElapsed, RTTESTUNIT_NS); 609 RTTestValue(g_hTest, "bytes sent", cbSent, RTTESTUNIT_BYTES); 610 RTTestValue(g_hTest, "speed", cKbps, RTTESTUNIT_KILOBYTES_PER_SEC); 611 RTTestValue(g_hTest, "frames sent", cFrames, RTTESTUNIT_FRAMES); 612 RTTestValue(g_hTest, "fps", cFps, RTTESTUNIT_FRAMES_PER_SEC); 613 RTTestValue(g_hTest, "overflows", 614 pThis->pBuf0->Send.cOverflows.c + pThis->pBuf1->Send.cOverflows.c, RTTESTUNIT_OCCURRENCES); 615 547 616 } 548 617 … … 550 619 * Give them a chance to complete... 551 620 */ 552 RTThreadWait(ThreadRecv0, 5000, NULL);553 RTThreadWait(ThreadRecv1, 5000, NULL);554 RTThreadWait(ThreadSend0, 5000, NULL);555 RTThreadWait(ThreadSend1, 5000, NULL);621 RTThreadWait(ThreadRecv0, RT_MS_5MIN, NULL); 622 RTThreadWait(ThreadRecv1, RT_MS_5MIN, NULL); 623 RTThreadWait(ThreadSend0, RT_MS_5MIN, NULL); 624 RTThreadWait(ThreadSend1, RT_MS_5MIN, NULL); 556 625 557 626 … … 726 795 tstBidirectionalTransfer(pThis, 256); 727 796 728 for (uint32_t cbFrame = 64; cbFrame < cbSend - 64; cbFrame += 8) 797 /* Only doing up to half the xmit buffer size as it is easy to get into a 798 bad frame position from a previous run and run into overflow issues. */ 799 /** @todo fix the code so it skips to a more optimal buffer position? */ 800 for (uint32_t cbFrame = 64; cbFrame < cbSend / 2 - 64; cbFrame += 16) 729 801 { 730 RTTestISubF("bi-dir benchmark, xbuf=%u rbuf=%u xmit=%u fr ame=%u",802 RTTestISubF("bi-dir benchmark, xbuf=%u rbuf=%u xmit=%u frm=%u", 731 803 pThis->pBuf0->cbSend, pThis->pBuf0->cbRecv, g_cbTransfer, cbFrame); 732 804 tstBidirectionalTransfer(pThis, cbFrame);
Note:
See TracChangeset
for help on using the changeset viewer.