- Timestamp:
- Nov 12, 2009 8:04:13 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevVirtioNet.cpp
r24616 r24623 225 225 PDMBOTHCBDECL(void) vnetReset(void *pState); 226 226 PDMBOTHCBDECL(void) vnetReady(void *pState); 227 #ifdef DEBUG228 static const char *vnetGetQueueName(void *pvState, PVQUEUE pQueue);229 #endif /* DEBUG */230 227 RT_C_DECLS_END 231 228 … … 982 979 pState->Queues[i].uNextUsedIndex, 983 980 pState->Queues[i].uPageNumber)); 984 985 981 } 986 982 #else 987 # define vpciDumpState(x, s)983 # define vpciDumpState(x, s) do {} while (0) 988 984 #endif 989 985 … … 1266 1262 uint16_t uStatus; 1267 1263 }; 1268 1269 1264 AssertCompileMemberOffset(struct VNetPCIConfig, uStatus, 6); 1270 1265 … … 1290 1285 uint32_t padding; 1291 1286 #endif 1292 PTMTIMERR3 pLinkUpTimer; /**< Link Up(/Restore) Timer. */ 1287 1288 /** transmit buffer */ 1289 R3PTRTYPE(uint8_t*) pTxBuf; 1290 /**< Link Up(/Restore) Timer. */ 1291 PTMTIMERR3 pLinkUpTimer; 1293 1292 1294 1293 /** PCI config area holding MAC address as well as TBD. */ 1295 struct VNetPCIConfig config;1294 struct VNetPCIConfig config; 1296 1295 /** MAC address obtained from the configuration. */ 1297 RTMAC macConfigured;1296 RTMAC macConfigured; 1298 1297 /** True if physical cable is attached in configuration. */ 1299 bool fCableConnected;1298 bool fCableConnected; 1300 1299 1301 1300 /** Number of packet being sent/received to show in debug log. */ 1302 uint32_t u32PktNo;1301 uint32_t u32PktNo; 1303 1302 1304 1303 /** Locked state -- no state alteration possible. */ 1305 bool fLocked;1304 bool fLocked; 1306 1305 1307 1306 /** N/A: */ 1308 bool volatile fMaybeOutOfSpace;1309 1310 R3PTRTYPE(PVQUEUE) pRxQueue;1311 R3PTRTYPE(PVQUEUE) pTxQueue;1312 R3PTRTYPE(PVQUEUE) pCtlQueue;1307 bool volatile fMaybeOutOfSpace; 1308 1309 R3PTRTYPE(PVQUEUE) pRxQueue; 1310 R3PTRTYPE(PVQUEUE) pTxQueue; 1311 R3PTRTYPE(PVQUEUE) pCtlQueue; 1313 1312 /* Receive-blocking-related fields ***************************************/ 1314 1313 … … 1318 1317 /* Statistic fields ******************************************************/ 1319 1318 1320 STAMCOUNTER 1321 STAMCOUNTER 1319 STAMCOUNTER StatReceiveBytes; 1320 STAMCOUNTER StatTransmitBytes; 1322 1321 #if defined(VBOX_WITH_STATISTICS) 1323 STAMPROFILEADV 1324 STAMPROFILEADV 1325 STAMPROFILEADV 1326 STAMPROFILE 1327 STAMCOUNTER 1322 STAMPROFILEADV StatReceive; 1323 STAMPROFILEADV StatTransmit; 1324 STAMPROFILEADV StatTransmitSend; 1325 STAMPROFILE StatRxOverflow; 1326 STAMCOUNTER StatRxOverflowWakeup; 1328 1327 #endif /* VBOX_WITH_STATISTICS */ 1329 1328 … … 1338 1337 struct VNetHdr 1339 1338 { 1340 uint8_t u8Flags;1341 uint8_t u8GSOType;1339 uint8_t u8Flags; 1340 uint8_t u8GSOType; 1342 1341 uint16_t u16HdrLen; 1343 1342 uint16_t u16GSOSize; … … 1347 1346 typedef struct VNetHdr VNETHDR; 1348 1347 typedef VNETHDR *PVNETHDR; 1348 AssertCompileSize(VNETHDR, 10); 1349 1349 1350 1350 AssertCompileMemberOffset(VNETSTATE, VPCI, 0); … … 1800 1800 else 1801 1801 { 1802 uint8_t *pFrame = (uint8_t *)RTMemAllocZ(VNET_MAX_FRAME_SIZE);1803 if (!pFrame)1804 {1805 Log(("%s vnetQueueTransmit: Failed to allocate %u bytes.\n",1806 INSTANCE(pState), VNET_MAX_FRAME_SIZE));1807 vqueueElemFree(&elem);1808 break; /* For now we simply ignore the header, but it must be there anyway! */1809 }1810 1811 1802 /* Assemble a complete frame. */ 1812 1803 for (unsigned int i = 1; i < elem.nOut && uOffset < VNET_MAX_FRAME_SIZE; i++) … … 1819 1810 } 1820 1811 PDMDevHlpPhysRead(pState->VPCI.CTX_SUFF(pDevIns), elem.aSegsOut[i].addr, 1821 p Frame+ uOffset, uSize);1812 pState->pTxBuf + uOffset, uSize); 1822 1813 uOffset += uSize; 1823 1814 } 1824 1815 STAM_PROFILE_ADV_START(&pState->StatTransmitSend, a); 1825 int rc = pState->pDrv->pfnSend(pState->pDrv, p Frame, uOffset);1816 int rc = pState->pDrv->pfnSend(pState->pDrv, pState->pTxBuf, uOffset); 1826 1817 STAM_PROFILE_ADV_STOP(&pState->StatTransmitSend, a); 1827 1818 STAM_REL_COUNTER_ADD(&pState->StatTransmitBytes, uOffset); 1828 RTMemFree(pFrame);1829 1819 } 1830 1820 vqueuePut(&pState->VPCI, pQueue, &elem, sizeof(VNETHDR) + uOffset); … … 1968 1958 rc = SSMR3GetMem(pSSM, &macConfigured, sizeof(macConfigured)); 1969 1959 AssertRCReturn(rc, rc); 1970 if ( 1971 && (uPass == 0 || !PDMDevHlpVMTeleportedAndNotFullyResumedYet(pDevIns)))1960 if (memcmp(&macConfigured, &pState->macConfigured, sizeof(macConfigured)) 1961 && (uPass == 0 || !PDMDevHlpVMTeleportedAndNotFullyResumedYet(pDevIns))) 1972 1962 LogRel(("%s: The mac address differs: config=%RTmac saved=%RTmac\n", INSTANCE(pState), &pState->macConfigured, &macConfigured)); 1973 1963 … … 2051 2041 pState->INetworkConfig.pfnSetLinkState = vnetSetLinkState; 2052 2042 2043 pState->pTxBuf = (uint8_t *)RTMemAllocZ(VNET_MAX_FRAME_SIZE); 2044 AssertMsgReturn(pState->pTxBuf, 2045 ("Cannot allocate TX buffer for virtio-net device\n"), VERR_NO_MEMORY); 2046 2053 2047 /* Register save/restore state handlers. */ 2054 2048 rc = PDMDevHlpSSMRegisterEx(pDevIns, VNET_SAVEDSTATE_VERSION, sizeof(VNETSTATE), NULL, … … 2057 2051 vnetLoadPrep, vnetLoadExec, NULL); 2058 2052 if (RT_FAILURE(rc)) 2059 return rc;2053 return rc; 2060 2054 2061 2055 /* Create the RX notifier signaller. */ … … 2135 2129 RTSemEventDestroy(pState->hEventMoreRxDescAvail); 2136 2130 pState->hEventMoreRxDescAvail = NIL_RTSEMEVENT; 2131 } 2132 2133 if (pState->pTxBuf) 2134 { 2135 RTMemFree(pState->pTxBuf); 2136 pState->pTxBuf = NULL; 2137 2137 } 2138 2138 … … 2348 2348 #endif /* IN_RING3 */ 2349 2349 #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */ 2350
Note:
See TracChangeset
for help on using the changeset viewer.