VirtualBox

Changeset 97299 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Oct 25, 2022 2:21:34 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154290
Message:

tstIntNetR0: Unborked the bi-dir test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/testcase/tstIntNetR0.cpp

    r97294 r97299  
    221221    uint64_t        u64Start;
    222222    uint64_t        u64End;
     223    uint32_t        cbSent;
     224    uint32_t        cFramesSent;
    223225} MYARGS, *PMYARGS;
    224226
     
    254256    uint32_t        iFrame  = 0;
    255257    uint32_t        cbSent  = 0;
     258    uint32_t        cErrors = 0;
    256259
    257260    pHdr->SrcMac            = pArgs->Mac;
     
    272275        if (RT_SUCCESS(rc))
    273276            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
    274283        cbSent += cb;
    275284    }
     285    pArgs->cbSent      = cbSent;
     286    pArgs->cFramesSent = iFrame;
    276287
    277288    /*
     
    401412
    402413/**
     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 */
     418static 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/**
    403427 * Test state.
    404428 */
     
    471495static void tstBidirectionalTransfer(PTSTSTATE pThis, uint32_t cbFrame)
    472496{
     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     */
    473526    MYARGS Args0;
    474527    RT_ZERO(Args0);
     
    479532    Args0.Mac.au16[2] = 0;
    480533    Args0.cbFrame     = cbFrame;
     534    tstDrainInterfaceBuffer(&Args0);
     535    //RTTESTI_CHECK_RC_OK(IntNetR0IfSetMacAddress(pThis->hIf0, g_pSession, &Args0.Mac));
    481536
    482537    MYARGS Args1;
     
    488543    Args1.Mac.au16[2] = 1;
    489544    Args1.cbFrame     = cbFrame;
     545    tstDrainInterfaceBuffer(&Args1);
     546    //RTTESTI_CHECK_RC_OK(IntNetR0IfSetMacAddress(pThis->hIf1, g_pSession, &Args1.Mac));
    490547
    491548    RTTHREAD ThreadRecv0 = NIL_RTTHREAD;
     
    500557    int rc2 = VINF_SUCCESS;
    501558    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));
    503560    if (RT_SUCCESS(rc))
    504561    {
    505562        RTTESTI_CHECK_RC_OK(rc2);
    506563        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));
    508565        if (RT_SUCCESS(rc))
    509566        {
     
    523580            RTThreadYield();
    524581
    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 
    531582        /*
    532583         * Wait for the threads to finish up...
    533584         */
    534         RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadRecv0, 5000, &rc2));
     585        RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadRecv0, RT_MS_5SEC, &rc2));
    535586        if (RT_SUCCESS(rc))
    536587        {
     
    539590        }
    540591
    541         RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadRecv1, 5000, &rc2));
     592        RTTESTI_CHECK_RC_OK(rc = RTThreadWait(ThreadRecv1, RT_MS_5MIN, &rc2));
    542593        if (RT_SUCCESS(rc))
    543594        {
     
    545596            ThreadRecv1 = NIL_RTTHREAD;
    546597        }
     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
    547616    }
    548617
     
    550619     * Give them a chance to complete...
    551620     */
    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);
    556625
    557626
     
    726795        tstBidirectionalTransfer(pThis, 256);
    727796
    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)
    729801        {
    730             RTTestISubF("bi-dir benchmark, xbuf=%u rbuf=%u xmit=%u frame=%u",
     802            RTTestISubF("bi-dir benchmark, xbuf=%u rbuf=%u xmit=%u frm=%u",
    731803                        pThis->pBuf0->cbSend, pThis->pBuf0->cbRecv, g_cbTransfer, cbFrame);
    732804            tstBidirectionalTransfer(pThis, cbFrame);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette