Changeset 83587 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Apr 6, 2020 12:31:32 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevVirtioNet_1_0.cpp
r83499 r83587 1427 1427 uint16_t cSegsAllocated = VIRTIONET_PREALLOCATE_RX_SEG_COUNT; 1428 1428 1429 PRTSGBUF pVirtSegBufToGuest = (PRTSGBUF)RTMemAllocZ(sizeof(RTSGBUF)); 1429 /** @todo r=bird: error codepaths below are almost all leaky! Maybe keep 1430 * allocations and cleanup here and put the code doing the complicated 1431 * work into a helper that can AssertReturn at will without needing to 1432 * care about cleaning stuff up. */ 1433 PRTSGBUF pVirtSegBufToGuest = (PRTSGBUF)RTMemAllocZ(sizeof(RTSGBUF)); /** @todo r=bird: Missing check. */ 1430 1434 PRTSGSEG paVirtSegsToGuest = (PRTSGSEG)RTMemAllocZ(sizeof(RTSGSEG) * cSegsAllocated); 1431 1435 AssertReturn(paVirtSegsToGuest, VERR_NO_MEMORY); … … 1438 1442 for (cDescs = uOffset = 0; uOffset < cb; ) 1439 1443 { 1440 PVIRTIO_DESC_CHAIN_T pDescChain ;1444 PVIRTIO_DESC_CHAIN_T pDescChain = NULL; 1441 1445 1442 1446 int rc = virtioCoreR3QueueGet(pDevIns, &pThis->Virtio, RXQIDX_QPAIR(idxQueue), &pDescChain, true); 1443 Assert RC(rc == VINF_SUCCESS || rc == VERR_NOT_AVAILABLE);1447 Assert(rc == VINF_SUCCESS || rc == VERR_NOT_AVAILABLE, ("%Rrc\n", rc)); 1444 1448 1445 1449 /** @todo Find a better way to deal with this */ 1446 AssertMsgReturn(rc == VINF_SUCCESS && pDescChain->cbPhysReturn, 1447 ("Not enough Rx buffers in queue to accomodate ethernet packet\n"), 1448 VERR_INTERNAL_ERROR); 1450 AssertMsgReturnStmt(rc == VINF_SUCCESS && pDescChain->cbPhysReturn, 1451 ("Not enough Rx buffers in queue to accomodate ethernet packet\n"), 1452 virtioCoreR3DescChainRelease(pDescChain), 1453 VERR_INTERNAL_ERROR); 1449 1454 1450 1455 /* Unlikely that len of 1st seg of guest Rx (IN) buf is less than sizeof(virtio_net_pkt_hdr) == 12. 1451 1456 * Assert it to reduce complexity. Robust solution would entail finding seg idx and offset of 1452 1457 * virtio_net_header.num_buffers (to update field *after* hdr & pkts copied to gcPhys) */ 1453 AssertMsgReturn(pDescChain->pSgPhysReturn->paSegs[0].cbSeg >= sizeof(VIRTIONET_PKT_HDR_T), 1454 ("Desc chain's first seg has insufficient space for pkt header!\n"), 1455 VERR_INTERNAL_ERROR); 1458 AssertMsgReturnStmt(pDescChain->pSgPhysReturn->paSegs[0].cbSeg >= sizeof(VIRTIONET_PKT_HDR_T), 1459 ("Desc chain's first seg has insufficient space for pkt header!\n"), 1460 virtioCoreR3DescChainRelease(pDescChain), 1461 VERR_INTERNAL_ERROR); 1456 1462 1457 1463 uint32_t cbDescChainLeft = pDescChain->cbPhysReturn; … … 1500 1506 break; 1501 1507 } 1508 1509 virtioCoreR3DescChainRelease(pDescChain); 1502 1510 } 1503 1511 … … 2063 2071 2064 2072 int rc; 2065 PVIRTIO_DESC_CHAIN_T pDescChain ;2073 PVIRTIO_DESC_CHAIN_T pDescChain = NULL; 2066 2074 while ((rc = virtioCoreR3QueuePeek(pVirtio->pDevIns, pVirtio, idxQueue, &pDescChain)) == VINF_SUCCESS) 2067 2075 { 2068 if (RT_SUCCESS(rc)) 2076 if (RT_SUCCESS(rc)) /** @todo r=bird: pointless, see loop condition. */ 2069 2077 Log10Func(("%s fetched descriptor chain from %s\n", INSTANCE(pThis), VIRTQNAME(idxQueue))); 2070 2078 else 2071 2079 { 2072 2080 LogFunc(("%s failed to find expected data on %s, rc = %Rrc\n", INSTANCE(pThis), VIRTQNAME(idxQueue), rc)); 2081 virtioCoreR3DescChainRelease(pDescChain); 2073 2082 break; 2074 2083 } … … 2096 2105 if (pThisCC->pDrv) 2097 2106 { 2098 PDMNETWORKGSO Gso, *pGso = virtioNetR3SetupGsoCtx(&Gso, &PktHdr); 2107 PDMNETWORKGSO Gso; 2108 PPDMNETWORKGSO pGso = virtioNetR3SetupGsoCtx(&Gso, &PktHdr); 2099 2109 2100 2110 /** @todo Optimize away the extra copying! (lazy bird) */ … … 2141 2151 Log4Func(("Failed to allocate S/G buffer: size=%u rc=%Rrc\n", uSize, rc)); 2142 2152 /* Stop trying to fetch TX descriptors until we get more bandwidth. */ 2153 virtioCoreR3DescChainRelease(pDescChain); 2143 2154 break; 2144 2155 } … … 2152 2163 virtioCoreQueueSync(pVirtio->pDevIns, pVirtio, idxQueue); 2153 2164 } 2165 2166 virtioCoreR3DescChainRelease(pDescChain); 2167 pDescChain = NULL; 2154 2168 } 2155 2169 virtioNetR3SetWriteLed(pThisCC, false); … … 2266 2280 { 2267 2281 Log10Func(("%s fetching next descriptor chain from %s\n", INSTANCE(pThis), VIRTQNAME(idxQueue))); 2268 PVIRTIO_DESC_CHAIN_T pDescChain ;2282 PVIRTIO_DESC_CHAIN_T pDescChain = NULL; 2269 2283 int rc = virtioCoreR3QueueGet(pDevIns, &pThis->Virtio, idxQueue, &pDescChain, true); 2270 2284 if (rc == VERR_NOT_AVAILABLE) … … 2274 2288 } 2275 2289 virtioNetR3Ctrl(pDevIns, pThis, pThisCC, pDescChain); 2290 virtioCoreR3DescChainRelease(pDescChain); 2276 2291 } 2277 2292 else if (IS_TX_QUEUE(idxQueue))
Note:
See TracChangeset
for help on using the changeset viewer.