VirtualBox

Changeset 83664 in vbox


Ignore:
Timestamp:
Apr 10, 2020 7:58:57 AM (5 years ago)
Author:
vboxsync
Message:

Network/DevVirtioNet_1_0.cpp: Now have round trip networking working. Can ssh login into and out of VM guest. This is contingent on a 'kick' hack in Virtio_1_0.cpp that needs investigation. See BugRef 8651, Comment #65

Location:
trunk/src/VBox/Devices
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevVirtioNet_1_0.cpp

    r83603 r83664  
    201201/** @name VirtIO 1.0 NET Host Device device specific control types
    202202 * @{  */
    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     */
    209209/** @} */
    210210
     
    216216    uint16_t uHdrLen;                                          /**< hdr_len                                         */
    217217    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                                   */
    220220    uint16_t uNumBuffers;                                      /**< num_buffers                                     */
    221221};
     
    417417    uint8_t                 aVlanFilter[VIRTIONET_MAX_VLAN_ID / sizeof(uint8_t)];
    418418
    419     bool                    fLog;
    420     bool                    fBp;
    421419    /* Receive-blocking-related fields ***************************************/
    422420
     
    575573    PVIRTIONET pThis = PDMDEVINS_2_DATA(pDevIns, PVIRTIONET);
    576574    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    }
    591592    virtioNetR3PacketDump(pThis, (const uint8_t *)pvBuf, cb, "<-- Incoming");
    592593    LogFunc((". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n"));
     
    13101311        return false;
    13111312    }
    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 }
    13201313
    13211314    if (virtioNetR3IsBroadcast(pvBuf))
     
    14451438
    14461439        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);
    14481441
    14491442        /** @todo  Find a better way to deal with this */
     
    15171510                  rc);
    15181511
    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 
    15271512    virtioCoreQueueSync(pDevIns, &pThis->Virtio, RXQIDX_QPAIR(idxQueue));
    15281513
    1529 
    1530 if (pThis->fLog) {
    1531 //    RTThreadSleep(500);
    1532 //   RT_BREAKPOINT();
    1533     pThis->fBp = false;
    1534 }
    15351514    RTMemFree(paVirtSegsToGuest);
    15361515    RTMemFree(pVirtSegBufToGuest);
     
    15421521        return VERR_TOO_MUCH_DATA;
    15431522    }
    1544 pThis->fLog = false;
    15451523    return VINF_SUCCESS;
    15461524}
     
    17831761                LogFunc(("         %RTmac\n", &pThis->aMacMulticastFilter[i]));
    17841762#endif
    1785 
    17861763        }
    17871764    }
     
    19191896    LogFunc(("%s Finished processing CTRL command with status %s\n",
    19201897             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
     1900static int virtioNetR3ReadHeader(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, PVIRTIONET_PKT_HDR_T pPktHdr, uint32_t cbFrame)
    19251901{
    19261902    int rc = PDMDevHlpPCIPhysRead(pDevIns, GCPhys, pPktHdr, sizeof(*pPktHdr));
     
    19281904        return rc;
    19291905
    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",
    19311907          pPktHdr->uFlags, pPktHdr->uGsoType, pPktHdr->uHdrLen,
    1932           pPktHdr->uGsoSize, pPktHdr->uChksumStart, pPktHdr->uChksumOffset, cbMax));
     1908          pPktHdr->uGsoSize, pPktHdr->uChksumStart, pPktHdr->uChksumOffset, cbFrame));
    19331909
    19341910    if (pPktHdr->uGsoType)
     
    19371913
    19381914        /* 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                           && RT_UNLIKELY(pPktHdr->uGsoType & VIRTIONET_HDR_GSO_ECN),
    1941                           ("Unsupported ECN request in pkt header\n"), VERR_NOT_SUPPORTED);
     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);
    19421918
    19431919        switch (pPktHdr->uGsoType)
     
    19551931        }
    19561932        /* Header + MSS must not exceed the packet size. */
    1957         AssertMsgReturn(RT_LIKELY(uMinHdrSize + pPktHdr->uChksumStart + pPktHdr->uGsoSize <= cbMax),
     1933        AssertMsgReturn(RT_LIKELY(uMinHdrSize + pPktHdr->uChksumStart + pPktHdr->uGsoSize <= cbFrame),
    19581934                    ("Header plus message exceeds packet size"), VERR_BUFFER_OVERFLOW);
    19591935    }
    19601936
    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);
    19641942
    19651943    return VINF_SUCCESS;
     
    21142092            {
    21152093                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;
    21172097                virtioCoreSgBufAdvance(pSgPhysSend, sizeof(PktHdr));
    21182098
     
    24992479    if (fVirtioReady)
    25002480    {
    2501 pThis->fBp = true;
    25022481        LogFunc(("%s VirtIO ready\n-----------------------------------------------------------------------------------------\n",
    25032482                 INSTANCE(pThis)));
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r83603 r83664  
    11151115            return;
    11161116        }
     1117/** TEMPORARY DEBUGGING HACK, EVALUATE AND REMOVE */
     1118virtioKick(pDevIns, pVirtio, VIRTIO_ISR_VIRTQ_INTERRUPT, pVirtio->uQueueMsixVector[idxQueue], fForce);
    11171119
    11181120        Log6Func(("...skipping interrupt. Guest flagged VIRTQ_AVAIL_F_NO_INTERRUPT for queue\n"));
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette