Changeset 97338 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Oct 31, 2022 8:15:38 AM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 154336
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvIntNet.cpp
r97089 r97338 249 249 xpc_dictionary_set_data(hObj, "req", pvArg, cbArg); 250 250 xpc_object_t hObjReply = xpc_connection_send_message_with_reply_sync(pThis->hXpcCon, hObj); 251 int rc = (int)xpc_dictionary_get_int64(hObjReply, "rc"); 252 253 size_t cbReply = 0; 254 const void *pvData = xpc_dictionary_get_data(hObjReply, "reply", &cbReply); 255 AssertRelease(cbReply == cbArg); 256 memcpy(pvArg, pvData, cbArg); 251 uint64_t u64Rc = xpc_dictionary_get_uint64(hObjReply, "rc"); 252 if (INTNET_R3_SVC_IS_VALID_RC(u64Rc)) 253 { 254 size_t cbReply = 0; 255 const void *pvData = xpc_dictionary_get_data(hObjReply, "reply", &cbReply); 256 AssertRelease(cbReply == cbArg); 257 memcpy(pvArg, pvData, cbArg); 258 xpc_release(hObjReply); 259 260 return INTNET_R3_SVC_GET_RC(u64Rc); 261 } 262 257 263 xpc_release(hObjReply); 258 259 return rc; 264 return VERR_INVALID_STATE; 260 265 } 261 266 else … … 316 321 xpc_dictionary_set_data(hObj, "req", &GetBufferPtrsReq, sizeof(GetBufferPtrsReq)); 317 322 xpc_object_t hObjReply = xpc_connection_send_message_with_reply_sync(pThis->hXpcCon, hObj); 318 rc = (int)xpc_dictionary_get_int64(hObjReply, "rc"); 323 uint64_t u64Rc = xpc_dictionary_get_uint64(hObjReply, "rc"); 324 if (INTNET_R3_SVC_IS_VALID_RC(u64Rc)) 325 rc = INTNET_R3_SVC_GET_RC(u64Rc); 326 else 327 rc = VERR_INVALID_STATE; 328 319 329 if (RT_SUCCESS(rc)) 320 330 { … … 327 337 pThis->cbBuf = cbMem; 328 338 } 339 329 340 xpc_release(hObjReply); 330 341 } -
trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
r96407 r97338 245 245 /** Pointer to ring-3 mapping of the default exchange buffer. */ 246 246 R3PTRTYPE(PINTNETBUF) pIntBufDefaultR3; 247 #if !defined(VBOX_WITH_INTNET_SERVICE_IN_R3) || !defined(IN_RING3) 247 248 /** Event semaphore which a receiver/consumer thread will sleep on while 248 249 * waiting for data to arrive. */ … … 250 251 /** Number of threads sleeping on the event semaphore. */ 251 252 uint32_t volatile cSleepers; 253 #else 254 /** The callback to call when there is something to receive/consume. */ 255 PFNINTNETIFRECVAVAIL pfnRecvAvail; 256 /** Opaque user data to pass to the receive avail callback (pfnRecvAvail). */ 257 void *pvUserRecvAvail; 258 #endif 252 259 /** The interface handle. 253 260 * When this is INTNET_HANDLE_INVALID a sleeper which is waking up … … 2833 2840 2834 2841 2842 /** 2843 * Notifies consumers of incoming data from @a pIf that data is available. 2844 */ 2845 DECL_FORCE_INLINE(void) intnetR0IfNotifyRecv(PINTNETIF pIf) 2846 { 2847 #if !defined(VBOX_WITH_INTNET_SERVICE_IN_R3) || !defined(IN_RING3) 2848 RTSemEventSignal(pIf->hRecvEvent); 2849 #else 2850 pIf->pfnRecvAvail(pIf->hIf, pIf->pvUserRecvAvail); 2851 #endif 2852 } 2853 2854 2835 2855 /** 2836 2856 * Sends a frame to a specific interface. … … 2852 2872 { 2853 2873 pIf->cYields = 0; 2854 RTSemEventSignal(pIf->hRecvEvent);2874 intnetR0IfNotifyRecv(pIf); 2855 2875 return; 2856 2876 } … … 2870 2890 while (--cYields > 0) 2871 2891 { 2872 RTSemEventSignal(pIf->hRecvEvent);2892 intnetR0IfNotifyRecv(pIf); 2873 2893 RTThreadYield(); 2874 2894 … … 2879 2899 { 2880 2900 STAM_REL_COUNTER_INC(&pIf->pIntBuf->cStatYieldsOk); 2881 RTSemEventSignal(pIf->hRecvEvent);2901 intnetR0IfNotifyRecv(pIf); 2882 2902 return; 2883 2903 } … … 2889 2909 /* ok, the frame is lost. */ 2890 2910 STAM_REL_COUNTER_INC(&pIf->pIntBuf->cStatLost); 2891 RTSemEventSignal(pIf->hRecvEvent);2911 intnetR0IfNotifyRecv(pIf); 2892 2912 } 2893 2913 … … 4667 4687 } 4668 4688 4669 const RTSEMEVENT hRecvEvent = pIf->hRecvEvent; 4689 #if defined(VBOX_WITH_INTNET_SERVICE_IN_R3) && defined(IN_RING3) 4690 AssertReleaseFailed(); /* Should never be called. */ 4691 return VERR_NOT_SUPPORTED; 4692 #else 4693 const RTSEMEVENT hRecvEvent = pIf->hRecvEvent; 4670 4694 const bool fNoMoreWaits = ASMAtomicUoReadBool(&pIf->fNoMoreWaits); 4671 4695 RTNATIVETHREAD hDtorThrd; … … 4721 4745 Log4(("IntNetR0IfWait: returns %Rrc\n", rc)); 4722 4746 return rc; 4747 #endif 4723 4748 } 4724 4749 … … 4765 4790 } 4766 4791 4792 #if defined(VBOX_WITH_INTNET_SERVICE_IN_R3) && defined(IN_RING3) 4793 AssertReleaseFailed(); 4794 return VERR_NOT_SUPPORTED; 4795 #else 4767 4796 const RTSEMEVENT hRecvEvent = pIf->hRecvEvent; 4768 4797 RTNATIVETHREAD hDtorThrd; … … 4807 4836 Log4(("IntNetR0IfWait: returns %Rrc\n", VINF_SUCCESS)); 4808 4837 return VINF_SUCCESS; 4838 #endif 4809 4839 } 4810 4840 … … 4851 4881 ASMAtomicWriteU32(&pIf->hIf, INTNET_HANDLE_INVALID); 4852 4882 4883 #if !defined(VBOX_WITH_INTNET_SERVICE_IN_R3) || !defined(IN_RING3) 4853 4884 /* 4854 4885 * Signal the event semaphore to wake up any threads in IntNetR0IfWait … … 4862 4893 } 4863 4894 RTSemEventSignal(pIf->hRecvEvent); 4895 #endif 4864 4896 4865 4897 /* … … 5000 5032 RTSemMutexRelease(pIntNet->hMtxCreateOpenDestroy); 5001 5033 5034 #if !defined(VBOX_WITH_INTNET_SERVICE_IN_R3) || !defined(IN_RING3) 5002 5035 /* 5003 5036 * Wakeup anyone waiting on this interface. (Kind of unlikely, but perhaps … … 5031 5064 pIf->hRecvEvent = NIL_RTSEMEVENT; 5032 5065 } 5066 #endif 5033 5067 5034 5068 /* … … 5080 5114 * 5081 5115 * @returns VBox status code. 5082 * @param pNetwork The network, referenced. The reference is consumed on 5083 * success. 5084 * @param pSession The session handle. 5085 * @param cbSend The size of the send buffer. 5086 * @param cbRecv The size of the receive buffer. 5087 * @param fFlags The open network flags. 5088 * @param phIf Where to store the interface handle. 5089 */ 5090 static int intnetR0NetworkCreateIf(PINTNETNETWORK pNetwork, PSUPDRVSESSION pSession, 5091 unsigned cbSend, unsigned cbRecv, uint32_t fFlags, 5092 PINTNETIFHANDLE phIf) 5116 * @param pNetwork The network, referenced. The reference is consumed 5117 * on success. 5118 * @param pSession The session handle. 5119 * @param cbSend The size of the send buffer. 5120 * @param cbRecv The size of the receive buffer. 5121 * @param fFlags The open network flags. 5122 * @param pfnRecvAvail The receive available callback to call instead of 5123 * signalling the semaphore (R3 service only). 5124 * @param pvUser The opaque user data to pass to the callback. 5125 * @param phIf Where to store the interface handle. 5126 */ 5127 static int intnetR0NetworkCreateIf(PINTNETNETWORK pNetwork, PSUPDRVSESSION pSession, unsigned cbSend, unsigned cbRecv, 5128 uint32_t fFlags, PFNINTNETIFRECVAVAIL pfnRecvAvail, void *pvUser, PINTNETIFHANDLE phIf) 5093 5129 { 5094 5130 LogFlow(("intnetR0NetworkCreateIf: pNetwork=%p pSession=%p cbSend=%u cbRecv=%u fFlags=%#x phIf=%p\n", … … 5100 5136 AssertPtr(pNetwork); 5101 5137 AssertPtr(phIf); 5138 #if !defined(VBOX_WITH_INTNET_SERVICE_IN_R3) || !defined(IN_RING3) 5139 Assert(pfnRecvAvail == NULL); 5140 Assert(pvUser == NULL); 5141 RT_NOREF(pfnRecvAvail, pvUser); 5142 #endif 5102 5143 5103 5144 /* … … 5136 5177 //pIf->pIntBufDefault = 0; 5137 5178 //pIf->pIntBufDefaultR3 = NIL_RTR3PTR; 5179 #if !defined(VBOX_WITH_INTNET_SERVICE_IN_R3) || !defined(IN_RING3) 5138 5180 pIf->hRecvEvent = NIL_RTSEMEVENT; 5181 #else 5182 pIf->pfnRecvAvail = pfnRecvAvail; 5183 pIf->pvUserRecvAvail = pvUser; 5184 #endif 5139 5185 //pIf->cSleepers = 0; 5140 5186 pIf->hIf = INTNET_HANDLE_INVALID; … … 5154 5200 if (RT_SUCCESS(rc)) 5155 5201 rc = intnetR0AllocDstTab(pNetwork->MacTab.cEntriesAllocated, (PINTNETDSTTAB *)&pIf->pDstTab); 5202 #if !defined(VBOX_WITH_INTNET_SERVICE_IN_R3) || !defined(IN_RING3) 5156 5203 if (RT_SUCCESS(rc)) 5157 5204 rc = RTSemEventCreate((PRTSEMEVENT)&pIf->hRecvEvent); 5205 #endif 5158 5206 if (RT_SUCCESS(rc)) 5159 5207 rc = RTSpinlockCreate(&pIf->hRecvInSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "hRecvInSpinlock"); … … 5248 5296 RTSpinlockDestroy(pIf->hRecvInSpinlock); 5249 5297 pIf->hRecvInSpinlock = NIL_RTSPINLOCK; 5298 #if !defined(VBOX_WITH_INTNET_SERVICE_IN_R3) || !defined(IN_RING3) 5250 5299 RTSemEventDestroy(pIf->hRecvEvent); 5251 5300 pIf->hRecvEvent = NIL_RTSEMEVENT; 5301 #else 5302 pIf->pfnRecvAvail = NULL; 5303 pIf->pvUserRecvAvail = NULL; 5304 #endif 5252 5305 RTMemFree(pIf->pDstTab); 5253 5306 for (int i = kIntNetAddrType_Invalid + 1; i < kIntNetAddrType_End; i++) … … 6594 6647 * @param pszTrunk The trunk name. Its meaning is specific to the type. 6595 6648 * @param fFlags Flags, see INTNET_OPEN_FLAGS_*. 6596 * @param fRestrictAccess Whether new participants should be subjected to access check or not. 6649 * @param fRestrictAccess Whether new participants should be subjected to 6650 * access check or not. 6597 6651 * @param cbSend The send buffer size. 6598 6652 * @param cbRecv The receive buffer size. 6653 * @param pfnRecvAvail The receive available callback to call instead of 6654 * signalling the semaphore (R3 service only). 6655 * @param pvUser The opaque user data to pass to the callback. 6599 6656 * @param phIf Where to store the handle to the network interface. 6600 6657 */ 6601 6658 INTNETR0DECL(int) IntNetR0Open(PSUPDRVSESSION pSession, const char *pszNetwork, 6602 6659 INTNETTRUNKTYPE enmTrunkType, const char *pszTrunk, uint32_t fFlags, 6603 uint32_t cbSend, uint32_t cbRecv, PINTNETIFHANDLE phIf) 6660 uint32_t cbSend, uint32_t cbRecv, PFNINTNETIFRECVAVAIL pfnRecvAvail, void *pvUser, 6661 PINTNETIFHANDLE phIf) 6604 6662 { 6605 6663 LogFlow(("IntNetR0Open: pSession=%p pszNetwork=%p:{%s} enmTrunkType=%d pszTrunk=%p:{%s} fFlags=%#x cbSend=%u cbRecv=%u phIf=%p\n", … … 6675 6733 if (RT_SUCCESS(rc)) 6676 6734 { 6677 rc = intnetR0NetworkCreateIf(pNetwork, pSession, cbSend, cbRecv, fFlags, p hIf);6735 rc = intnetR0NetworkCreateIf(pNetwork, pSession, cbSend, cbRecv, fFlags, pfnRecvAvail, pvUser, phIf); 6678 6736 if (RT_SUCCESS(rc)) 6679 6737 { … … 6689 6747 if (RT_SUCCESS(rc)) 6690 6748 { 6691 rc = intnetR0NetworkCreateIf(pNetwork, pSession, cbSend, cbRecv, fFlags, p hIf);6749 rc = intnetR0NetworkCreateIf(pNetwork, pSession, cbSend, cbRecv, fFlags, pfnRecvAvail, pvUser, phIf); 6692 6750 if (RT_FAILURE(rc)) 6693 6751 SUPR0ObjRelease(pNetwork->pvObj, pSession); … … 6713 6771 return VERR_INVALID_PARAMETER; 6714 6772 return IntNetR0Open(pSession, &pReq->szNetwork[0], pReq->enmTrunkType, pReq->szTrunk, 6715 pReq->fFlags, pReq->cbSend, pReq->cbRecv, &pReq->hIf); 6716 } 6773 pReq->fFlags, pReq->cbSend, pReq->cbRecv, NULL /*pfnRecvAvail*/, NULL /*pvUser*/, &pReq->hIf); 6774 } 6775 6776 6777 #if defined(VBOX_WITH_INTNET_SERVICE_IN_R3) && defined(IN_RING3) 6778 INTNETR3DECL(int) IntNetR3Open(PSUPDRVSESSION pSession, const char *pszNetwork, 6779 INTNETTRUNKTYPE enmTrunkType, const char *pszTrunk, uint32_t fFlags, 6780 uint32_t cbSend, uint32_t cbRecv, PFNINTNETIFRECVAVAIL pfnRecvAvail, void *pvUser, 6781 PINTNETIFHANDLE phIf) 6782 { 6783 return IntNetR0Open(pSession, pszNetwork, enmTrunkType, pszTrunk, fFlags, cbSend, cbRecv, pfnRecvAvail, pvUser, phIf); 6784 } 6785 #endif 6717 6786 6718 6787 -
trunk/src/VBox/Devices/Network/testcase/tstIntNetR0.cpp
r97300 r97338 447 447 { 448 448 pThis->hIf0 = INTNET_HANDLE_INVALID; 449 RTTESTI_CHECK_RC_OK_RET(IntNetR0Open(g_pSession, pszNetwork, kIntNetTrunkType_None, "", 450 0/*fFlags*/, cbSend, cbRecv, &pThis->hIf0), rcCheck);449 RTTESTI_CHECK_RC_OK_RET(IntNetR0Open(g_pSession, pszNetwork, kIntNetTrunkType_None, "", 0/*fFlags*/, cbSend, cbRecv, 450 NULL /*pfnRecvAvail*/, NULL /*pvUser*/, &pThis->hIf0), rcCheck); 451 451 RTTESTI_CHECK_RET(pThis->hIf0 != INTNET_HANDLE_INVALID, VERR_INTERNAL_ERROR); 452 452 RTTESTI_CHECK_RC_RET(IntNetR0IfGetBufferPtrs(pThis->hIf0, g_pSession, &pThis->pBuf0, NULL), VINF_SUCCESS, rcCheck); … … 455 455 456 456 pThis->hIf1 = INTNET_HANDLE_INVALID; 457 RTTESTI_CHECK_RC_OK_RET(IntNetR0Open(g_pSession, pszNetwork, kIntNetTrunkType_None, "", 458 0/*fFlags*/, cbSend, cbRecv, &pThis->hIf1), rcCheck);457 RTTESTI_CHECK_RC_OK_RET(IntNetR0Open(g_pSession, pszNetwork, kIntNetTrunkType_None, "", 0/*fFlags*/, cbSend, cbRecv, 458 NULL /*pfnRecvAvail*/, NULL /*pvUser*/, &pThis->hIf1), rcCheck); 459 459 RTTESTI_CHECK_RET(pThis->hIf1 != INTNET_HANDLE_INVALID, VERR_INTERNAL_ERROR); 460 460 RTTESTI_CHECK_RC_RET(IntNetR0IfGetBufferPtrs(pThis->hIf1, g_pSession, &pThis->pBuf1, NULL), VINF_SUCCESS, rcCheck);
Note:
See TracChangeset
for help on using the changeset viewer.