Changeset 23141 in vbox
- Timestamp:
- Sep 18, 2009 3:31:10 PM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r23137 r23141 59 59 * Defined Constants And Macros * 60 60 *******************************************************************************/ 61 #define SLIRP_SPLIT_CAN_OUTPUT 162 63 61 #define GET_EXTRADATA(pthis, node, name, rc, type, type_name, var) \ 64 62 do { \ … … 114 112 x.s_addr = def; \ 115 113 } while (0) 116 117 /** Queue depth (!SLIRP_SPLIT_CAN_OUTPUT). */118 #define QUEUE_SIZE 50119 120 114 121 115 /******************************************************************************* … … 149 143 /** Queue for NAT-thread-external events. */ 150 144 PRTREQQUEUE pSlirpReqQueue; 151 #ifndef SLIRP_SPLIT_CAN_OUTPUT152 /* Receive PDM queue (deliver packets to the guest) */153 PPDMQUEUE pRecvQueue;154 #endif155 145 156 146 #ifdef VBOX_WITH_SLIRP_MT … … 174 164 #define DRV_COUNTING_COUNTER(name, dsc) STAMCOUNTER Stat ## name 175 165 #include "counters.h" 176 #ifdef SLIRP_SPLIT_CAN_OUTPUT177 166 /** thread delivering packets for receiving by the guest */ 178 167 PPDMTHREAD pRecvThread; … … 181 170 /** Receive Req queue (deliver packets to the guest) */ 182 171 PRTREQQUEUE pRecvReqQueue; 183 #endif184 172 } DRVNAT; 185 173 AssertCompileMemberAlignment(DRVNAT, StatNATRecvWakeups, 8); … … 211 199 212 200 213 #ifdef SLIRP_SPLIT_CAN_OUTPUT214 201 215 202 static DECLCALLBACK(int) drvNATRecv(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) … … 256 243 STAM_PROFILE_STOP(&pThis->StatNATRecv, a); 257 244 } 258 259 #endif /* SLIRP_SPLIT_CAN_OUTPUT */260 245 261 246 /** … … 622 607 Log2(("slirp_output: pu8Buf=%p cb=%#x (pThis=%p)\n%.*Rhxd\n", pu8Buf, cb, pThis, cb, pu8Buf)); 623 608 624 #ifndef SLIRP_SPLIT_CAN_OUTPUT625 PDRVNATQUEUITEM pItem = (PDRVNATQUEUITEM)PDMQueueAlloc(pThis->pRecvQueue);626 if (pItem)627 {628 pItem->pu8Buf = pu8Buf;629 pItem->cb = cb;630 pItem->mbuf = pvArg;631 Log2(("pItem:%p %.Rhxd\n", pItem, pItem->pu8Buf));632 PDMQueueInsert(pThis->pRecvQueue, &pItem->Core);633 STAM_COUNTER_INC(&pThis->StatQueuePktSent);634 return;635 }636 static unsigned s_cDroppedPackets;637 if (s_cDroppedPackets < 64)638 s_cDroppedPackets++;639 else640 {641 LogRel(("NAT: %d messages suppressed about dropping packet (couldn't allocate queue item)\n", s_cDroppedPackets));642 s_cDroppedPackets = 0;643 }644 STAM_COUNTER_INC(&pThis->StatQueuePktDropped);645 RTMemFree((void *)pu8Buf);646 #else647 609 PRTREQ pReq = NULL; 648 610 … … 663 625 drvNATRecvWakeup(pThis->pDrvIns, pThis->pRecvThread); 664 626 STAM_COUNTER_INC(&pThis->StatQueuePktSent); 665 #endif 666 } 667 668 669 #ifndef SLIRP_SPLIT_CAN_OUTPUT 670 /** 671 * Queue callback for processing a queued item. 672 * 673 * @returns Success indicator. 674 * If false the item will not be removed and the flushing will stop. 675 * @param pDrvIns The driver instance. 676 * @param pItemCore Pointer to the queue item to process. 677 */ 678 static DECLCALLBACK(bool) drvNATQueueConsumer(PPDMDRVINS pDrvIns, PPDMQUEUEITEMCORE pItemCore) 679 { 680 int rc; 681 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 682 PDRVNATQUEUITEM pItem = (PDRVNATQUEUITEM)pItemCore; 683 PRTREQ pReq = NULL; 684 Log(("drvNATQueueConsumer(pItem:%p, pu8Buf:%p, cb:%d)\n", pItem, pItem->pu8Buf, pItem->cb)); 685 Log2(("drvNATQueueConsumer: pu8Buf:\n%.Rhxd\n", pItem->pu8Buf)); 686 if (RT_FAILURE(pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0))) 687 { 688 STAM_COUNTER_INC(&pThis->StatConsumerFalse); 689 return false; 690 } 691 rc = pThis->pPort->pfnReceive(pThis->pPort, pItem->pu8Buf, pItem->cb); 692 RTMemFree((void *)pItem->pu8Buf); 693 return true; 694 695 AssertRelease(pItem->mbuf == NULL); 696 return RT_SUCCESS(rc); 697 } 698 #endif 627 } 699 628 700 629 … … 1004 933 1005 934 1006 #ifndef SLIRP_SPLIT_CAN_OUTPUT1007 rc = PDMDrvHlpPDMQueueCreate(pDrvIns, sizeof(DRVNATQUEUITEM), QUEUE_SIZE, 0,1008 drvNATQueueConsumer, "NAT", &pThis->pRecvQueue);1009 if (RT_FAILURE(rc))1010 {1011 LogRel(("NAT: Can't create send queue\n"));1012 return rc;1013 }1014 #else1015 935 rc = RTReqCreateQueue(&pThis->pRecvReqQueue); 1016 936 if (RT_FAILURE(rc)) … … 1023 943 AssertReleaseRC(rc); 1024 944 rc = RTSemEventCreate(&pThis->EventRecv); 1025 #endif1026 945 1027 946 #ifndef RT_OS_WINDOWS -
trunk/src/VBox/Devices/Network/slirp/counters.h
r22458 r23141 117 117 # else 118 118 /*DrvNAT.cpp*/ 119 # ifdef SLIRP_SPLIT_CAN_OUTPUT120 119 DRV_COUNTING_COUNTER(NATRecvWakeups, "counting wakeups of NAT RX thread"); 121 120 DRV_PROFILE_COUNTER(NATRecv,"Time spent in NATRecv worker"); 122 121 DRV_PROFILE_COUNTER(NATRecvWait,"Time spent in NATRecv worker in waiting of free RX buffers"); 123 # endif124 122 DRV_COUNTING_COUNTER(QueuePktSent, "counting packet sent via PDM Queue"); 125 123 DRV_COUNTING_COUNTER(QueuePktDropped, "counting packet drops by PDM Queue");
Note:
See TracChangeset
for help on using the changeset viewer.