Changeset 83664 in vbox
- Timestamp:
- Apr 10, 2020 7:58:57 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevVirtioNet_1_0.cpp
r83603 r83664 201 201 /** @name VirtIO 1.0 NET Host Device device specific control types 202 202 * @{ */ 203 #define VIRTIONET_HDR_F_NEEDS_CSUM 1 /**< Packet needs checksum*/204 #define VIRTIONET_HDR_GSO_NONE 0 /**< No Global Segmentation Offset*/205 #define VIRTIONET_HDR_GSO_TCPV4 1 /**< Global Segment Offset for TCPV4*/206 #define VIRTIONET_HDR_GSO_UDP 3 /**< Global Segment Offset for UDP*/207 #define VIRTIONET_HDR_GSO_TCPV6 4 /**< Global Segment Offset for TCPV6*/208 #define VIRTIONET_HDR_GSO_ECN 0x80 /**< Explicit Congestion Notification*/203 #define VIRTIONET_HDR_F_NEEDS_CSUM 1 /**< flags: Packet needs checksum */ 204 #define VIRTIONET_HDR_GSO_NONE 0 /**< gso_type: No Global Segmentation Offset */ 205 #define VIRTIONET_HDR_GSO_TCPV4 1 /**< gso_type: Global Segment Offset for TCPV4 */ 206 #define VIRTIONET_HDR_GSO_UDP 3 /**< gso_type: Global Segment Offset for UDP */ 207 #define VIRTIONET_HDR_GSO_TCPV6 4 /**< gso_type: Global Segment Offset for TCPV6 */ 208 #define VIRTIONET_HDR_GSO_ECN 0x80 /**< gso_type: Explicit Congestion Notification */ 209 209 /** @} */ 210 210 … … 216 216 uint16_t uHdrLen; /**< hdr_len */ 217 217 uint16_t uGsoSize; /**< gso_size */ 218 uint16_t uChksumStart; /**< Chksum_start 219 uint16_t uChksumOffset; /**< Chksum_offset 218 uint16_t uChksumStart; /**< Chksum_start */ 219 uint16_t uChksumOffset; /**< Chksum_offset */ 220 220 uint16_t uNumBuffers; /**< num_buffers */ 221 221 }; … … 417 417 uint8_t aVlanFilter[VIRTIONET_MAX_VLAN_ID / sizeof(uint8_t)]; 418 418 419 bool fLog;420 bool fBp;421 419 /* Receive-blocking-related fields ***************************************/ 422 420 … … 575 573 PVIRTIONET pThis = PDMDEVINS_2_DATA(pDevIns, PVIRTIONET); 576 574 pRxPktHdr->uNumBuffers = cDescs; 577 LogFunc(("-------------------------------------------------------------------\n")); 578 LogFunc(("rxPktHdr\n" 579 " uFlags ......... %2.2x\n" 580 " uGsoType ....... %2.2x\n" 581 " uHdrLen ........ %4.4x\n" 582 " uGsoSize ....... %4.4x\n" 583 " uChksumStart ... %4.4x\n" 584 " uChksumOffset .. %4.4x\n" 585 " uNumBuffers .... %4.4x\n", 586 pRxPktHdr->uFlags, 587 pRxPktHdr->uGsoType, pRxPktHdr->uHdrLen, pRxPktHdr->uGsoSize, 588 pRxPktHdr->uChksumStart, pRxPktHdr->uChksumOffset, pRxPktHdr->uNumBuffers)); 589 590 virtioCoreHexDump((uint8_t *)pRxPktHdr, sizeof(VIRTIONET_PKT_HDR_T), 0, "Dump of virtual rPktHdr"); 575 if (pRxPktHdr) 576 { 577 LogFunc(("-------------------------------------------------------------------\n")); 578 LogFunc(("rxPktHdr\n" 579 " uFlags ......... %2.2x\n" 580 " uGsoType ....... %2.2x\n" 581 " uHdrLen ........ %4.4x\n" 582 " uGsoSize ....... %4.4x\n" 583 " uChksumStart ... %4.4x\n" 584 " uChksumOffset .. %4.4x\n" 585 " uNumBuffers .... %4.4x\n", 586 pRxPktHdr->uFlags, 587 pRxPktHdr->uGsoType, pRxPktHdr->uHdrLen, pRxPktHdr->uGsoSize, 588 pRxPktHdr->uChksumStart, pRxPktHdr->uChksumOffset, pRxPktHdr->uNumBuffers)); 589 590 virtioCoreHexDump((uint8_t *)pRxPktHdr, sizeof(VIRTIONET_PKT_HDR_T), 0, "Dump of virtual rPktHdr"); 591 } 591 592 virtioNetR3PacketDump(pThis, (const uint8_t *)pvBuf, cb, "<-- Incoming"); 592 593 LogFunc((". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n")); … … 1310 1311 return false; 1311 1312 } 1312 /** @todo remove this debug hack that detects ARP from specific ping on development setup - pk */1313 uint8_t src[6] = { 0xA8, 0x20, 0x66, 0x57, 0x50, 0x3C };1314 uint8_t dst[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };1315 if (memcmp(pvBuf, dst, 6) == 0 && memcmp(((uint8_t *)pvBuf) + 6, src, 6) == 0)1316 {1317 pThis->fLog = true;1318 virtioNetR3PacketDump(pThis, (const uint8_t *)pvBuf, cb, "<-- Incoming");1319 }1320 1313 1321 1314 if (virtioNetR3IsBroadcast(pvBuf)) … … 1445 1438 1446 1439 int rc = virtioCoreR3QueueGet(pDevIns, &pThis->Virtio, RXQIDX_QPAIR(idxQueue), &pDescChain, true); 1447 Assert (rc == VINF_SUCCESS || rc == VERR_NOT_AVAILABLE, ("%Rrc\n", rc));1440 AssertMsgReturn(rc == VINF_SUCCESS || rc == VERR_NOT_AVAILABLE, ("%Rrc\n", rc), rc); 1448 1441 1449 1442 /** @todo Find a better way to deal with this */ … … 1517 1510 rc); 1518 1511 1519 /* Dump Rx Pkt after it's been written to guest physical memory via the virtio core API */1520 // if (pThis->fLog)1521 // {1522 virtioNetDumpGcPhysRxBuf(pDevIns, &rxPktHdr, cDescs, (uint8_t *)pvBuf, cb,1523 gcPhysPktHdrNumBuffers - RT_UOFFSETOF(VIRTIONET_PKT_HDR_T, uNumBuffers),1524 cb + sizeof(VIRTIONET_PKT_HDR_T));1525 // }1526 1527 1512 virtioCoreQueueSync(pDevIns, &pThis->Virtio, RXQIDX_QPAIR(idxQueue)); 1528 1513 1529 1530 if (pThis->fLog) {1531 // RTThreadSleep(500);1532 // RT_BREAKPOINT();1533 pThis->fBp = false;1534 }1535 1514 RTMemFree(paVirtSegsToGuest); 1536 1515 RTMemFree(pVirtSegBufToGuest); … … 1542 1521 return VERR_TOO_MUCH_DATA; 1543 1522 } 1544 pThis->fLog = false;1545 1523 return VINF_SUCCESS; 1546 1524 } … … 1783 1761 LogFunc((" %RTmac\n", &pThis->aMacMulticastFilter[i])); 1784 1762 #endif 1785 1786 1763 } 1787 1764 } … … 1919 1896 LogFunc(("%s Finished processing CTRL command with status %s\n", 1920 1897 INSTANCE(pThis), uAck == VIRTIONET_OK ? "VIRTIONET_OK" : "VIRTIONET_ERROR")); 1921 1922 } 1923 1924 static int virtioNetR3ReadHeader(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, PVIRTIONET_PKT_HDR_T pPktHdr, uint32_t cbMax) 1898 } 1899 1900 static int virtioNetR3ReadHeader(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, PVIRTIONET_PKT_HDR_T pPktHdr, uint32_t cbFrame) 1925 1901 { 1926 1902 int rc = PDMDevHlpPCIPhysRead(pDevIns, GCPhys, pPktHdr, sizeof(*pPktHdr)); … … 1928 1904 return rc; 1929 1905 1930 Log(("virtio-net: header flags=%x gso-type=%x len=%x gso-size=%x Chksum-start=%x Chksum-offset=%x cb=%x\n",1906 Log(("virtio-net: header (flags=%x gso-type=%x len=%x gso-size=%x Chksum-start=%x Chksum-offset=%x) cbFrame=%d\n", 1931 1907 pPktHdr->uFlags, pPktHdr->uGsoType, pPktHdr->uHdrLen, 1932 pPktHdr->uGsoSize, pPktHdr->uChksumStart, pPktHdr->uChksumOffset, cb Max));1908 pPktHdr->uGsoSize, pPktHdr->uChksumStart, pPktHdr->uChksumOffset, cbFrame)); 1933 1909 1934 1910 if (pPktHdr->uGsoType) … … 1937 1913 1938 1914 /* Segmentation offloading cannot be done without checksumming, and we do not support ECN */ 1939 AssertMsgReturn( RT_LIKELY(pPktHdr->uFlags & VIRTIONET_HDR_F_NEEDS_CSUM)1940 1941 1915 AssertMsgReturn( RT_LIKELY(pPktHdr->uFlags & VIRTIONET_HDR_F_NEEDS_CSUM) 1916 && RT_UNLIKELY(pPktHdr->uGsoType & VIRTIONET_HDR_GSO_ECN), 1917 ("Unsupported ECN request in pkt header\n"), VERR_NOT_SUPPORTED); 1942 1918 1943 1919 switch (pPktHdr->uGsoType) … … 1955 1931 } 1956 1932 /* Header + MSS must not exceed the packet size. */ 1957 AssertMsgReturn(RT_LIKELY(uMinHdrSize + pPktHdr->uChksumStart + pPktHdr->uGsoSize <= cb Max),1933 AssertMsgReturn(RT_LIKELY(uMinHdrSize + pPktHdr->uChksumStart + pPktHdr->uGsoSize <= cbFrame), 1958 1934 ("Header plus message exceeds packet size"), VERR_BUFFER_OVERFLOW); 1959 1935 } 1960 1936 1961 AssertMsgReturn( !pPktHdr->uFlags & VIRTIONET_HDR_F_NEEDS_CSUM 1962 || sizeof(uint16_t) + pPktHdr->uChksumStart + pPktHdr->uChksumOffset <= cbMax, 1963 ("Checksum doesn't fit into pkt header\n"), VERR_BUFFER_OVERFLOW); 1937 AssertMsgReturn( !pPktHdr->uFlags & VIRTIONET_HDR_F_NEEDS_CSUM 1938 || sizeof(uint16_t) + pPktHdr->uChksumStart + pPktHdr->uChksumOffset <= cbFrame, 1939 ("Checksum (%d bytes) doesn't fit into pkt header (%d bytes)\n", 1940 sizeof(uint16_t) + pPktHdr->uChksumStart + pPktHdr->uChksumOffset, cbFrame), 1941 VERR_BUFFER_OVERFLOW); 1964 1942 1965 1943 return VINF_SUCCESS; … … 2114 2092 { 2115 2093 uSize -= sizeof(PktHdr); 2116 rc = virtioNetR3ReadHeader(pDevIns, paSegsFromGuest[0].gcPhys, &PktHdr, sizeof(PktHdr)); 2094 rc = virtioNetR3ReadHeader(pDevIns, paSegsFromGuest[0].gcPhys, &PktHdr, uSize); 2095 if (RT_FAILURE(rc)) 2096 return; 2117 2097 virtioCoreSgBufAdvance(pSgPhysSend, sizeof(PktHdr)); 2118 2098 … … 2499 2479 if (fVirtioReady) 2500 2480 { 2501 pThis->fBp = true;2502 2481 LogFunc(("%s VirtIO ready\n-----------------------------------------------------------------------------------------\n", 2503 2482 INSTANCE(pThis))); -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp
r83603 r83664 1115 1115 return; 1116 1116 } 1117 /** TEMPORARY DEBUGGING HACK, EVALUATE AND REMOVE */ 1118 virtioKick(pDevIns, pVirtio, VIRTIO_ISR_VIRTQ_INTERRUPT, pVirtio->uQueueMsixVector[idxQueue], fForce); 1117 1119 1118 1120 Log6Func(("...skipping interrupt. Guest flagged VIRTQ_AVAIL_F_NO_INTERRUPT for queue\n"));
Note:
See TracChangeset
for help on using the changeset viewer.