Changeset 81708 in vbox
- Timestamp:
- Nov 6, 2019 2:25:11 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134470
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevVirtioNet.cpp
r81703 r81708 131 131 R3PTRTYPE(PPDMINETWORKUP) pDrv; /**< Connector of attached network driver. */ 132 132 133 R3PTRTYPE(PPDMQUEUE) pCanRxQueueR3; /**< Rx wakeup signaller - R3. */134 R0PTRTYPE(PPDMQUEUE) pCanRxQueueR0; /**< Rx wakeup signaller - R0. */135 RCPTRTYPE(PPDMQUEUE) pCanRxQueueRC; /**< Rx wakeup signaller - RC. */136 # if HC_ARCH_BITS == 64137 uint32_t padding;138 # endif139 140 133 /**< Link Up(/Restore) Timer. */ 141 134 PTMTIMERR3 pLinkUpTimer; … … 203 196 204 197 /** EMT: Gets signalled when more RX descriptors become available. */ 205 RTSEMEVENThEventMoreRxDescAvail;198 SUPSEMEVENT hEventMoreRxDescAvail; 206 199 207 200 /** @name Statistic … … 529 522 } 530 523 531 #ifdef IN_RING3532 524 533 525 /** 534 526 * Wakeup the RX thread. 535 527 */ 536 static void vnet R3WakeupReceive(PPDMDEVINS pDevIns)528 static void vnetWakeupReceive(PPDMDEVINS pDevIns) 537 529 { 538 530 PVNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVNETSTATE); 539 531 if ( pThis->fMaybeOutOfSpace 540 && pThis->hEventMoreRxDescAvail != NIL_ RTSEMEVENT)532 && pThis->hEventMoreRxDescAvail != NIL_SUPSEMEVENT) 541 533 { 542 534 STAM_COUNTER_INC(&pThis->StatRxOverflowWakeup); 543 535 Log(("%s Waking up Out-of-RX-space semaphore\n", INSTANCE(pThis))); 544 /** 545 * @todo r=bird: We can wake stuff up from ring-0 too, see vmsvga, nvme, 546 * buslogic, lsilogic, ata, ahci, xhci. Also, please address similar 547 * TODO in E1000. 548 * 549 * The API Is SUPSem*, btw. 550 */ 551 RTSemEventSignal(pThis->hEventMoreRxDescAvail); 552 } 553 } 554 536 int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEventMoreRxDescAvail); 537 AssertRC(rc); 538 } 539 } 540 541 #ifdef IN_RING3 555 542 556 543 /** … … 603 590 STATUS |= VNET_S_LINK_UP; 604 591 vnetR3RaiseInterrupt(pThis, VERR_SEM_BUSY, VPCI_ISR_CONFIG); 605 vnet R3WakeupReceive(pDevIns);592 vnetWakeupReceive(pDevIns); 606 593 vnetR3CsLeave(pThis); 607 594 Log(("%s vnetR3LinkUpTimer: Link is up\n", INSTANCE(pThis))); … … 617 604 { 618 605 RT_NOREF(pItem); 619 vnet R3WakeupReceive(pDevIns);606 vnetWakeupReceive(pDevIns); 620 607 return true; 621 608 } … … 632 619 PVNETSTATE pThis = RT_FROM_MEMBER(pVPciState, VNETSTATE, VPCI); 633 620 Log(("%s Driver became ready, waking up RX thread...\n", INSTANCE(pThis))); 634 /** 635 * @todo r=bird: We can wake stuff up from ring-0 too, see vmsvga, nvme, 636 * buslogic, lsilogic, ata, ahci, xhci. Also, please address similar 637 * TODO in E1000. 638 * 639 * The API Is SUPSem*, btw. 640 */ 641 #ifdef IN_RING3 642 vnetR3WakeupReceive(pThis->VPCI.CTX_SUFF(pDevIns)); 643 #else 644 PPDMQUEUEITEMCORE pItem = PDMQueueAlloc(pThis->CTX_SUFF(pCanRxQueue)); 645 if (pItem) 646 PDMQueueInsert(pThis->CTX_SUFF(pCanRxQueue), pItem); 647 #endif 621 vnetWakeupReceive(pThis->VPCI.CTX_SUFF(pDevIns)); 648 622 } 649 623 … … 732 706 { 733 707 PVNETSTATE pThis = RT_FROM_MEMBER(pInterface, VNETSTATE, INetworkDown); 708 PPDMDEVINS pDevIns = pThis->VPCI.pDevInsR3; 734 709 LogFlow(("%s vnetR3NetworkDown_WaitReceiveAvail(cMillies=%u)\n", INSTANCE(pThis), cMillies)); 710 735 711 int rc = vnetR3CanReceive(pThis); 736 737 712 if (RT_SUCCESS(rc)) 738 713 return VINF_SUCCESS; 739 if (RT_UNLIKELY(cMillies == 0)) 714 715 if (cMillies == 0) 740 716 return VERR_NET_NO_BUFFER_SPACE; 741 717 … … 755 731 } 756 732 Log(("%s vnetR3NetworkDown_WaitReceiveAvail: waiting cMillies=%u...\n", INSTANCE(pThis), cMillies)); 757 RTSemEventWait(pThis->hEventMoreRxDescAvail, cMillies); 733 rc2 = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->hEventMoreRxDescAvail, cMillies); 734 if (RT_FAILURE(rc2) && rc2 != VERR_TIMEOUT && rc2 != VERR_INTERRUPTED) 735 RTThreadSleep(1); 758 736 } 759 737 STAM_PROFILE_STOP(&pThis->StatRxOverflow, a); … … 1141 1119 RT_NOREF(pThis, pQueue); 1142 1120 Log(("%s Receive buffers has been added, waking up receive thread.\n", INSTANCE(pThis))); 1143 vnet R3WakeupReceive(pDevIns);1121 vnetWakeupReceive(pDevIns); 1144 1122 } 1145 1123 … … 2100 2078 { 2101 2079 /* Poke thread waiting for buffer space. */ 2102 vnet R3WakeupReceive(pDevIns);2080 vnetWakeupReceive(pDevIns); 2103 2081 } 2104 2082 … … 2110 2088 { 2111 2089 /* Poke thread waiting for buffer space. */ 2112 vnet R3WakeupReceive(pDevIns);2090 vnetWakeupReceive(pDevIns); 2113 2091 } 2114 2092 … … 2119 2097 static DECLCALLBACK(void) vnetR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 2120 2098 { 2099 vpciRelocate(pDevIns, offDelta); 2100 #ifdef VNET_TX_DELAY 2121 2101 PVNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVNETSTATE); 2122 vpciRelocate(pDevIns, offDelta); 2123 pThis->pCanRxQueueRC = PDMQueueRCPtr(pThis->pCanRxQueueR3); 2124 #ifdef VNET_TX_DELAY 2125 pThis->pTxTimerRC = TMTimerRCPtr(pThis->pTxTimerR3); 2126 #endif /* VNET_TX_DELAY */ 2127 // TBD 2102 pThis->pTxTimerRC = TMTimerRCPtr(pThis->pTxTimerR3); 2103 #endif 2128 2104 } 2129 2105 … … 2142 2118 2143 2119 Log(("%s Destroying instance\n", INSTANCE(pThis))); 2144 if (pThis->hEventMoreRxDescAvail != NIL_ RTSEMEVENT)2145 { 2146 RTSemEventSignal(pThis->hEventMoreRxDescAvail);2147 RTSemEventDestroy(pThis->hEventMoreRxDescAvail);2148 pThis->hEventMoreRxDescAvail = NIL_ RTSEMEVENT;2120 if (pThis->hEventMoreRxDescAvail != NIL_SUPSEMEVENT) 2121 { 2122 PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEventMoreRxDescAvail); 2123 PDMDevHlpSUPSemEventClose(pDevIns, pThis->hEventMoreRxDescAvail); 2124 pThis->hEventMoreRxDescAvail = NIL_SUPSEMEVENT; 2149 2125 } 2150 2126 … … 2169 2145 * Initialize the instance data suffiencently for the destructor not to blow up. 2170 2146 */ 2171 pThis->hEventMoreRxDescAvail = NIL_ RTSEMEVENT;2147 pThis->hEventMoreRxDescAvail = NIL_SUPSEMEVENT; 2172 2148 #ifndef VNET_TX_DELAY 2173 2149 pThis->hTxEvent = NIL_SUPSEMEVENT; … … 2248 2224 AssertRCReturn(rc, rc); 2249 2225 2250 /* Create the RX notifier signaller. */2251 rc = PDMDevHlpQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 1, 0,2252 vnetR3CanRxQueueConsumer, true, "VNet-Rcv", &pThis->pCanRxQueueR3);2253 AssertRCReturn(rc, rc);2254 pThis->pCanRxQueueR0 = PDMQueueR0Ptr(pThis->pCanRxQueueR3);2255 pThis->pCanRxQueueRC = PDMQueueRCPtr(pThis->pCanRxQueueR3);2256 2257 2226 /* Create Link Up Timer */ 2258 2227 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, vnetR3LinkUpTimer, pThis, TMTIMER_FLAGS_NO_CRIT_SECT, … … 2295 2264 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to attach the network LUN")); 2296 2265 2297 rc = RTSemEventCreate(&pThis->hEventMoreRxDescAvail);2266 rc = PDMDevHlpSUPSemEventCreate(pDevIns, &pThis->hEventMoreRxDescAvail); 2298 2267 AssertRCReturn(rc, rc); 2299 2268
Note:
See TracChangeset
for help on using the changeset viewer.