Changeset 14196 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Nov 14, 2008 7:30:48 AM (16 years ago)
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r14195 r14196 179 179 { 180 180 PDRVNAT pThis = PDMINETWORKCONNECTOR_2_DRVNAT(pInterface); 181 int rc; 181 182 182 183 LogFlow(("drvNATNotifyLinkChanged: enmLinkState=%d\n", enmLinkState)); … … 184 185 LogRel(("drvNATNotifyLinkChanged\n")); 185 186 #ifndef VBOX_WITH_SIMPLEFIED_SLIRP_SYNC 186 intrc = RTCritSectEnter(&pThis->CritSect);187 rc = RTCritSectEnter(&pThis->CritSect); 187 188 AssertReleaseRC(rc); 188 189 #endif … … 196 197 #ifdef VBOX_WITH_SIMPLEFIED_SLIRP_SYNC 197 198 # ifndef RT_OS_WINDOWS 198 intrc = RTFileWrite(pThis->PipeWrite, "2", 2, NULL);199 rc = RTFileWrite(pThis->PipeWrite, "2", 2, NULL); 199 200 AssertRC(rc); 200 201 # else … … 210 211 #ifdef VBOX_WITH_SIMPLEFIED_SLIRP_SYNC 211 212 # ifndef RT_OS_WINDOWS 212 intrc = RTFileWrite(pThis->PipeWrite, "2", 2, NULL);213 rc = RTFileWrite(pThis->PipeWrite, "2", 2, NULL); 213 214 AssertRC(rc); 214 215 # else … … 267 268 HANDLE *phEvents; 268 269 # endif 269 const struct timeval TimeWait = { 0, 2000 }; /* 2ms for the fast timer */270 const struct timeval TimeNoWait = { 0, 0 }; /* return immediately */271 270 272 271 LogFlow(("drvNATAsyncIoThread: pThis=%p\n", pThis)); … … 284 283 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 285 284 { 286 bool fWait = true;287 285 288 286 FD_ZERO(&ReadFDs); … … 296 294 slirp_select_fill(pThis->pNATState, &nFDs, &ReadFDs, &WriteFDs, &XcptFDs); 297 295 # ifndef RT_OS_WINDOWS 298 struct timeval tv = fWait ? TimeWait : TimeNoWait;299 FD_SET(pThis->PipeRead, &ReadFDs); /* Linux only */296 struct timeval tv = { 0, 2000 }; /* 2ms */ 297 FD_SET(pThis->PipeRead, &ReadFDs); 300 298 nFDs = ((int)pThis->PipeRead < nFDs ? nFDs : pThis->PipeRead); 301 299 int cChangedFDs = select(nFDs + 1, &ReadFDs, &WriteFDs, &XcptFDs, &tv); … … 315 313 slirp_input(pThis->pNATState, (uint8_t *)pThis->cBuffer, pThis->sBufferSize); 316 314 RTSemEventSignal(pThis->semSndMutex); 317 fWait = 1;318 315 break; 319 316 case '2': … … 697 694 if (RT_SUCCESS(rc)) 698 695 { 696 slirp_register_timers(pThis->pNATState, pDrvIns); 699 697 int rc2 = drvNATConstructRedir(pDrvIns->iInstance, pThis, pCfgHandle, Network); 700 698 if (RT_SUCCESS(rc2)) -
trunk/src/VBox/Devices/Network/slirp/libslirp.h
r14194 r14196 28 28 29 29 int slirp_init(PNATState *, const char *, uint32_t, bool, const char *, const char *, void *); 30 void slirp_register_timers(PNATState pData, PPDMDRVINS pDrvIns); 30 31 void slirp_term(PNATState); 31 32 void slirp_link_up(PNATState); -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r14194 r14196 4 4 #endif 5 5 6 /* disable these counters for the final release */ 7 /* #define VBOX_WITHOUT_RELEASE_STATISTICS */ 8 6 9 #include <VBox/err.h> 10 #include <VBox/stam.h> 11 #include <VBox/pdmdrv.h> 7 12 #include <iprt/assert.h> 8 13 … … 250 255 251 256 /** 257 * Statistics counters. 258 */ 259 void slirp_register_timers(PNATState pData, PPDMDRVINS pDrvIns) 260 { 261 #ifndef VBOX_WITHOUT_RELEASE_STATISTICS 262 PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatFill, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, 263 STAMUNIT_TICKS_PER_CALL, "Profiling slirp fills", "/Drivers/NAT%d/Fill", pDrvIns->iInstance); 264 PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatPoll, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, 265 STAMUNIT_TICKS_PER_CALL, "Profiling slirp polls", "/Drivers/NAT%d/Poll", pDrvIns->iInstance); 266 PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatFastTimer, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, 267 STAMUNIT_TICKS_PER_CALL, "Profiling slirp fast timer", "/Drivers/NAT%d/TimerFast", pDrvIns->iInstance); 268 PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatSlowTimer, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, 269 STAMUNIT_TICKS_PER_CALL, "Profiling slirp slow timer", "/Drivers/NAT%d/TimerSlow", pDrvIns->iInstance); 270 PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatTCP, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, 271 STAMUNIT_COUNT, "TCP sockets", "/Drivers/NAT%d/SockTCP", pDrvIns->iInstance); 272 PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatTCPHot, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, 273 STAMUNIT_COUNT, "TCP sockets active", "/Drivers/NAT%d/SockTCPHot", pDrvIns->iInstance); 274 PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatUDP, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, 275 STAMUNIT_COUNT, "UDP sockets", "/Drivers/NAT%d/SockUDP", pDrvIns->iInstance); 276 PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatTCPHot, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, 277 STAMUNIT_COUNT, "UDP sockets active", "/Drivers/NAT%d/SockUDPHot", pDrvIns->iInstance); 278 #endif /* VBOX_WITHOUT_RELEASE_STATISTICS */ 279 } 280 281 /** 252 282 * Marks the link as up, making it possible to establish new connections. 253 283 */ … … 358 388 #endif 359 389 390 STAM_REL_PROFILE_START(&pData->StatFill, a); 391 360 392 nfds = *pnfds; 361 393 /* … … 371 403 ((struct ipasfrag *)&ipq != u32_to_ptr(pData, ipq.next, struct ipasfrag *))); 372 404 405 STAM_REL_COUNTER_RESET(&pData->StatTCP); 406 STAM_REL_COUNTER_RESET(&pData->StatTCPHot); 407 373 408 for (so = tcb.so_next; so != &tcb; so = so_next) { 374 409 so_next = so->so_next; 410 411 STAM_REL_COUNTER_INC(&pData->StatTCP); 375 412 376 413 /* … … 391 428 */ 392 429 if (so->so_state & SS_FACCEPTCONN) { 430 STAM_REL_COUNTER_INC(&pData->StatTCPHot); 393 431 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 394 432 FD_SET(so->s, readfds); … … 410 448 */ 411 449 if (so->so_state & SS_ISFCONNECTING) { 450 STAM_REL_COUNTER_INC(&pData->StatTCPHot); 412 451 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 413 452 FD_SET(so->s, writefds); … … 426 465 */ 427 466 if (CONN_CANFSEND(so) && so->so_rcv.sb_cc) { 467 STAM_REL_COUNTER_INC(&pData->StatTCPHot); 428 468 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 429 469 FD_SET(so->s, writefds); … … 442 482 */ 443 483 if (CONN_CANFRCV(so) && (so->so_snd.sb_cc < (so->so_snd.sb_datalen/2))) { 484 STAM_REL_COUNTER_INC(&pData->StatTCPHot); 444 485 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 445 486 FD_SET(so->s, readfds); … … 463 504 * UDP sockets 464 505 */ 506 STAM_REL_COUNTER_RESET(&pData->StatUDP); 507 STAM_REL_COUNTER_RESET(&pData->StatUDPHot); 508 465 509 for (so = udb.so_next; so != &udb; so = so_next) { 466 510 so_next = so->so_next; 511 512 STAM_REL_COUNTER_INC(&pData->StatUDP); 467 513 468 514 /* … … 488 534 */ 489 535 if ((so->so_state & SS_ISFCONNECTED) && so->so_queued <= 4) { 536 STAM_REL_COUNTER_INC(&pData->StatUDPHot); 490 537 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 491 538 FD_SET(so->s, readfds); … … 497 544 continue; 498 545 #endif 546 STAM_REL_COUNTER_INC(&pData->StatUDPHot); 499 547 } 500 548 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) … … 547 595 *pnfds = VBOX_EVENT_COUNT; 548 596 #endif 597 598 STAM_REL_PROFILE_STOP(&pData->StatFill, a); 549 599 } 550 600 … … 559 609 int timer_update = (readfds == NULL && writefds == NULL && xfds == NULL); 560 610 #endif 611 STAM_REL_PROFILE_START(&pData->StatPoll, a); 561 612 562 613 /* Update time */ … … 568 619 if (link_up) { 569 620 if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) { 621 STAM_REL_PROFILE_START(&pData->StatFastTimer, a); 570 622 tcp_fasttimo(pData); 571 623 time_fasttimo = 0; 624 STAM_REL_PROFILE_STOP(&pData->StatFastTimer, a); 572 625 } 573 626 if (do_slowtimo && ((curtime - last_slowtimo) >= 499)) { 627 STAM_REL_PROFILE_START(&pData->StatSlowTimer, a); 574 628 ip_slowtimo(pData); 575 629 tcp_slowtimo(pData); 576 630 last_slowtimo = curtime; 631 STAM_REL_PROFILE_STOP(&pData->StatSlowTimer, a); 577 632 } 578 633 } … … 598 653 continue; 599 654 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 600 rc = WSAEnumNetworkEvents(so->s, VBOX_SOCKET_EVENT, &NetworkEvents);655 rc = WSAEnumNetworkEvents(so->s, so->hNetworkEvent, &NetworkEvents); 601 656 if (rc == SOCKET_ERROR) 602 657 { … … 615 670 if (FD_ISSET(so->s, xfds)) 616 671 #else 672 /* out-of-band data */ 617 673 if ((NetworkEvents.lNetworkEvents & FD_OOB) && NetworkEvents.iErrorCode[FD_OOB_BIT] == 0) 618 674 #endif … … 761 817 if (if_queued && link_up) 762 818 if_start(pData); 819 820 STAM_REL_PROFILE_STOP(&pData->StatPoll, a); 763 821 } 764 822 -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r14194 r14196 21 21 #ifndef _slirp_state_h_ 22 22 #define _slirp_state_h_ 23 24 #include <VBox/stam.h> 23 25 24 26 /** Number of DHCP clients supported by NAT. */ … … 121 123 HANDLE phEvents[VBOX_EVENT_COUNT]; 122 124 #endif 125 STAMPROFILE StatFill; 126 STAMPROFILE StatPoll; 127 STAMPROFILE StatFastTimer; 128 STAMPROFILE StatSlowTimer; 129 STAMCOUNTER StatTCP; 130 STAMCOUNTER StatUDP; 131 STAMCOUNTER StatTCPHot; 132 STAMCOUNTER StatUDPHot; 123 133 } NATState; 124 134
Note:
See TracChangeset
for help on using the changeset viewer.