VirtualBox

Changeset 81731 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 6, 2019 9:35:07 PM (5 years ago)
Author:
vboxsync
Message:

DevRirtioNet,Virtio: nits. bugref:9218

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

Legend:

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

    r81727 r81731  
    938938        }
    939939
    940         if (elem.nIn < 1)
     940        if (elem.cIn < 1)
    941941        {
    942942            Log(("%s vnetR3HandleRxPacket: No writable descriptors in receive queue!\n", INSTANCE(pThis)));
     
    963963            uElemSize += cbHdr;
    964964        }
    965         while (nSeg < elem.nIn && uOffset < cb)
     965        while (nSeg < elem.cIn && uOffset < cb)
    966966        {
    967967            unsigned int uSize = (unsigned int)RT_MIN(elem.aSegsIn[nSeg].cb - (nSeg?0:cbReserved),
     
    13731373    {
    13741374        unsigned int uOffset = 0;
    1375         if (elem.nOut < 2 || elem.aSegsOut[0].cb != cbHdr)
     1375        if (elem.cOut < 2 || elem.aSegsOut[0].cb != cbHdr)
    13761376        {
    13771377            Log(("%s vnetR3QueueTransmit: The first segment is not the header! (%u < 2 || %u != %u).\n",
    1378                  INSTANCE(pThis), elem.nOut, elem.aSegsOut[0].cb, cbHdr));
     1378                 INSTANCE(pThis), elem.cOut, elem.aSegsOut[0].cb, cbHdr));
    13791379            break; /* For now we simply ignore the header, but it must be there anyway! */
    13801380        }
     
    13861386
    13871387        /* Compute total frame size. */
    1388         for (unsigned int i = 1; i < elem.nOut && uSize < VNET_MAX_FRAME_SIZE; i++)
     1388        for (unsigned int i = 1; i < elem.cOut && uSize < VNET_MAX_FRAME_SIZE; i++)
    13891389            uSize += elem.aSegsOut[i].cb;
    13901390        Log5(("%s vnetR3TransmitPendingPackets: complete frame is %u bytes.\n", INSTANCE(pThis), uSize));
     
    14121412
    14131413                /* Assemble a complete frame. */
    1414                 for (unsigned int i = 1; i < elem.nOut && uSize > 0; i++)
     1414                for (unsigned int i = 1; i < elem.cOut && uSize > 0; i++)
    14151415                {
    14161416                    unsigned int cbSegment = RT_MIN(uSize, elem.aSegsOut[i].cb);
     
    16621662
    16631663    if (   pCtlHdr->u8Command != VNET_CTRL_CMD_MAC_TABLE_SET
    1664         || pElem->nOut != 3
     1664        || pElem->cOut != 3
    16651665        || pElem->aSegsOut[1].cb < sizeof(nMacs)
    16661666        || pElem->aSegsOut[2].cb < sizeof(nMacs))
    16671667    {
    16681668        Log(("%s vnetR3ControlMac: Segment layout is wrong (u8Command=%u nOut=%u cb1=%u cb2=%u)\n",
    1669              INSTANCE(pThis), pCtlHdr->u8Command, pElem->nOut, pElem->aSegsOut[1].cb, pElem->aSegsOut[2].cb));
     1669             INSTANCE(pThis), pCtlHdr->u8Command, pElem->cOut, pElem->aSegsOut[1].cb, pElem->aSegsOut[2].cb));
    16701670        return VNET_ERROR;
    16711671    }
     
    17371737    uint16_t u16Vid;
    17381738
    1739     if (pElem->nOut != 2 || pElem->aSegsOut[1].cb != sizeof(u16Vid))
     1739    if (pElem->cOut != 2 || pElem->aSegsOut[1].cb != sizeof(u16Vid))
    17401740    {
    17411741        Log(("%s vnetR3ControlVlan: Segment layout is wrong (u8Command=%u nOut=%u cb=%u)\n",
    1742              INSTANCE(pThis), pCtlHdr->u8Command, pElem->nOut, pElem->aSegsOut[1].cb));
     1742             INSTANCE(pThis), pCtlHdr->u8Command, pElem->cOut, pElem->aSegsOut[1].cb));
    17431743        return VNET_ERROR;
    17441744    }
     
    17811781    while (vqueueGet(pDevIns, &pThis->VPCI, pQueue, &elem))
    17821782    {
    1783         if (elem.nOut < 1 || elem.aSegsOut[0].cb < sizeof(VNETCTLHDR))
     1783        if (elem.cOut < 1 || elem.aSegsOut[0].cb < sizeof(VNETCTLHDR))
    17841784        {
    17851785            Log(("%s vnetR3QueueControl: The first 'out' segment is not the header! (%u < 1 || %u < %u).\n",
    1786                  INSTANCE(pThis), elem.nOut, elem.aSegsOut[0].cb,sizeof(VNETCTLHDR)));
     1786                 INSTANCE(pThis), elem.cOut, elem.aSegsOut[0].cb,sizeof(VNETCTLHDR)));
    17871787            break; /* Skip the element and hope the next one is good. */
    17881788        }
    1789         if (   elem.nIn < 1
    1790             || elem.aSegsIn[elem.nIn - 1].cb < sizeof(VNETCTLACK))
     1789        if (   elem.cIn < 1
     1790            || elem.aSegsIn[elem.cIn - 1].cb < sizeof(VNETCTLACK))
    17911791        {
    17921792            Log(("%s vnetR3QueueControl: The last 'in' segment is too small to hold the acknowledge! (%u < 1 || %u < %u).\n",
    1793                  INSTANCE(pThis), elem.nIn, elem.aSegsIn[elem.nIn - 1].cb, sizeof(VNETCTLACK)));
     1793                 INSTANCE(pThis), elem.cIn, elem.aSegsIn[elem.cIn - 1].cb, sizeof(VNETCTLACK)));
    17941794            break; /* Skip the element and hope the next one is good. */
    17951795        }
     
    18131813        }
    18141814        Log(("%s Processed control message %u, ack=%u.\n", INSTANCE(pThis), CtlHdr.u8Class, bAck));
    1815         PDMDevHlpPCIPhysWrite(pDevIns, elem.aSegsIn[elem.nIn - 1].addr, &bAck, sizeof(bAck));
     1815        PDMDevHlpPCIPhysWrite(pDevIns, elem.aSegsIn[elem.cIn - 1].addr, &bAck, sizeof(bAck));
    18161816
    18171817        vqueuePut(pDevIns, &pThis->VPCI, pQueue, &elem, sizeof(bAck));
     
    18291829    PVNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVNETSTATE);
    18301830    RT_NOREF(cArgs, papszArgs);
    1831     vpcR3iDumpStateWorker(&pThis->VPCI, pHlp);
     1831    vpciR3DumpStateWorker(&pThis->VPCI, pHlp);
    18321832}
    18331833
  • trunk/src/VBox/Devices/VirtIO/Virtio.cpp

    r81722 r81731  
    113113        return false;
    114114
    115     pElem->nIn = pElem->nOut = 0;
     115    pElem->cIn = pElem->cOut = 0;
    116116
    117117    Log2(("%s vqueueGet: %s avail_idx=%u\n", INSTANCE(pThis), pQueue->szName, pQueue->uNextAvailIndex));
     
    132132         * total number of descriptors in the ring (see @bugref{8620}).
    133133         */
    134         if (pElem->nIn + pElem->nOut >= VRING_MAX_SIZE)
     134        if (pElem->cIn + pElem->cOut >= VRING_MAX_SIZE)
    135135        {
    136136            static volatile uint32_t s_cMessages  = 0;
     
    153153        {
    154154            Log2(("%s vqueueGet: %s IN  seg=%u desc_idx=%u addr=%p cb=%u\n", INSTANCE(pThis),
    155                   pQueue->szName, pElem->nIn, idx, desc.u64Addr, desc.uLen));
    156             pSeg = &pElem->aSegsIn[pElem->nIn++];
     155                  pQueue->szName, pElem->cIn, idx, desc.u64Addr, desc.uLen));
     156            pSeg = &pElem->aSegsIn[pElem->cIn++];
    157157        }
    158158        else
    159159        {
    160160            Log2(("%s vqueueGet: %s OUT seg=%u desc_idx=%u addr=%p cb=%u\n", INSTANCE(pThis),
    161                   pQueue->szName, pElem->nOut, idx, desc.u64Addr, desc.uLen));
    162             pSeg = &pElem->aSegsOut[pElem->nOut++];
     161                  pQueue->szName, pElem->cOut, idx, desc.u64Addr, desc.uLen));
     162            pSeg = &pElem->aSegsOut[pElem->cOut++];
    163163        }
    164164
     
    171171
    172172    Log2(("%s vqueueGet: %s head_desc_idx=%u nIn=%u nOut=%u\n", INSTANCE(pThis),
    173           pQueue->szName, pElem->uIndex, pElem->nIn, pElem->nOut));
     173          pQueue->szName, pElem->uIndex, pElem->cIn, pElem->cOut));
    174174    return true;
    175175}
     
    212212    uint32_t cbSkip = uReserved;
    213213
    214     for (unsigned i = 0; i < pElem->nIn && cbLen > 0; ++i)
     214    for (unsigned i = 0; i < pElem->cIn && cbLen > 0; ++i)
    215215    {
    216216        if (cbSkip >= pElem->aSegsIn[i].cb) /* segment completely skipped? */
     
    659659 * Dumps the state (useful for both logging and info items).
    660660 */
    661 void vpcR3iDumpStateWorker(PVPCISTATE pThis, PCDBGFINFOHLP pHlp)
     661void vpciR3DumpStateWorker(PVPCISTATE pThis, PCDBGFINFOHLP pHlp)
    662662{
    663663
     
    698698    {
    699699        Log2(("vpciR3DumpState: (called from %s)\n", pcszCaller));
    700         vpcR3iDumpStateWorker(pThis, DBGFR3InfoLogHlp());
     700        vpciR3DumpStateWorker(pThis, DBGFR3InfoLogHlp());
    701701    }
    702702}
  • trunk/src/VBox/Devices/VirtIO/Virtio.h

    r81722 r81731  
    5353#define DEVICE_PCI_BASE_ID                  0x1000
    5454#define DEVICE_PCI_SUBSYSTEM_VENDOR_ID      0x1AF4
    55 #define DEVICE_PCI_SUBSYSTEM_BASE_ID       1
     55#define DEVICE_PCI_SUBSYSTEM_BASE_ID        1
    5656
    5757#define VIRTIO_MAX_NQUEUES                  3
     
    7575#define VPCI_STATUS_FAILED                  0x80
    7676
    77 #define VPCI_F_NOTIFY_ON_EMPTY              0x01000000
    78 #define VPCI_F_ANY_LAYOUT                   0x08000000
    79 #define VPCI_F_RING_INDIRECT_DESC           0x10000000
    80 #define VPCI_F_RING_EVENT_IDX               0x20000000
    81 #define VPCI_F_BAD_FEATURE                  0x40000000
     77#define VPCI_F_NOTIFY_ON_EMPTY              UINT32_C(0x01000000)
     78#define VPCI_F_ANY_LAYOUT                   UINT32_C(0x08000000)
     79#define VPCI_F_RING_INDIRECT_DESC           UINT32_C(0x10000000)
     80#define VPCI_F_RING_EVENT_IDX               UINT32_C(0x20000000)
     81#define VPCI_F_BAD_FEATURE                  UINT32_C(0x40000000)
    8282
    8383#define VRINGDESC_MAX_SIZE                  (2 * 1024 * 1024)
     
    8686#define VRINGDESC_F_INDIRECT                0x04
    8787
    88 typedef struct VRingDesc
     88typedef struct VRINGDESC
    8989{
    9090    uint64_t u64Addr;
     
    9595typedef VRINGDESC *PVRINGDESC;
    9696
    97 #define VRINGAVAIL_F_NO_INTERRUPT 0x01
    98 
    99 typedef struct VRingAvail
     97#define VRINGAVAIL_F_NO_INTERRUPT           0x01
     98
     99typedef struct VRINGAVAIL
    100100{
    101101    uint16_t uFlags;
     
    104104} VRINGAVAIL;
    105105
    106 typedef struct VRingUsedElem
     106typedef struct VRINGUSEDELEM
    107107{
    108108    uint32_t uId;
     
    120120typedef VRINGUSED *PVRINGUSED;
    121121
    122 #define VRING_MAX_SIZE 1024
    123 
    124 typedef struct VRing
     122#define VRING_MAX_SIZE                      1024
     123
     124typedef struct VRING
    125125{
    126126    uint16_t   uSize;
     
    158158typedef VQUEUER3 *PVQUEUER3;
    159159
    160 typedef struct VQueueElemSeg
     160typedef struct VQUEUESEG
    161161{
    162162    RTGCPHYS addr;
     
    165165} VQUEUESEG;
    166166
    167 typedef struct VQueueElem
     167typedef struct VQUEUEELEM
    168168{
    169169    uint32_t  uIndex;
    170     uint32_t  nIn;
    171     uint32_t  nOut;
     170    uint32_t  cIn;
     171    uint32_t  cOut;
    172172    VQUEUESEG aSegsIn[VRING_MAX_SIZE];
    173173    VQUEUESEG aSegsOut[VRING_MAX_SIZE];
     
    282282int   vpciRZInit(PPDMDEVINS pDevIns, PVPCISTATE pThis, PVPCISTATECC pThisCC);
    283283int   vpciR3Term(PPDMDEVINS pDevIns, PVPCISTATE pThis);
    284 
     284PVQUEUE vpciR3AddQueue(PVPCISTATE pThis, PVPCISTATECC pThisCC, unsigned uSize, PFNVPCIQUEUECALLBACK pfnCallback, const char *pcszName);
     285void *vpciR3QueryInterface(PVPCISTATECC pThisCC, const char *pszIID);
     286void  vpciR3SetWriteLed(PVPCISTATE pThis, bool fOn);
     287void  vpciR3SetReadLed(PVPCISTATE pThis, bool fOn);
     288int   vpciR3SaveExec(PCPDMDEVHLPR3 pHlp, PVPCISTATE pThis, PSSMHANDLE pSSM);
     289int   vpciR3LoadExec(PCPDMDEVHLPR3 pHlp, PVPCISTATE pThis, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass, uint32_t cQueues);
     290void  vpciR3DumpStateWorker(PVPCISTATE pThis, PCDBGFINFOHLP pHlp);
     291
     292void  vpciReset(PPDMDEVINS pDevIns, PVPCISTATE pThis);
    285293int   vpciRaiseInterrupt(PPDMDEVINS pDevIns, PVPCISTATE pThis, int rcBusy, uint8_t u8IntCause);
    286294int   vpciIOPortIn(PPDMDEVINS pDevIns, PVPCISTATE pThis, RTIOPORT offPort,
     
    288296int   vpciIOPortOut(PPDMDEVINS pDevIns, PVPCISTATE pThis, PVPCISTATECC pThisCC, RTIOPORT offPort,
    289297                    uint32_t u32, unsigned cb, PCVPCIIOCALLBACKS pCallbacks);
    290 
    291 void  vpciR3SetWriteLed(PVPCISTATE pThis, bool fOn);
    292 void  vpciR3SetReadLed(PVPCISTATE pThis, bool fOn);
    293 int   vpciR3SaveExec(PCPDMDEVHLPR3 pHlp, PVPCISTATE pThis, PSSMHANDLE pSSM);
    294 int   vpciR3LoadExec(PCPDMDEVHLPR3 pHlp, PVPCISTATE pThis, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass, uint32_t cQueues);
    295 void  vpciReset(PPDMDEVINS pDevIns, PVPCISTATE pThis);
    296 void *vpciR3QueryInterface(PVPCISTATECC pThisCC, const char *pszIID);
    297 PVQUEUE vpciR3AddQueue(PVPCISTATE pThis, PVPCISTATECC pThisCC, unsigned uSize, PFNVPCIQUEUECALLBACK pfnCallback, const char *pcszName);
    298298
    299299#define VPCI_CS
     
    347347}
    348348
    349 void vpcR3iDumpStateWorker(PVPCISTATE pThis, PCDBGFINFOHLP pHlp);
    350 
    351349#endif /* !VBOX_INCLUDED_SRC_VirtIO_Virtio_h */
     350
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