VirtualBox

Changeset 7688 in vbox


Ignore:
Timestamp:
Apr 1, 2008 4:04:55 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
29214
Message:

PCnet: some cleanup, use host-provided RX buffers but don't access them directly yet

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/DevPCNet.h

    r7682 r7688  
    3434
    3535#define PCNET_GUEST_INTERFACE_VERSION         (1)
    36 #define PCNET_GUEST_SHARED_MEMORY_SIZE        _1M
     36#define PCNET_GUEST_SHARED_MEMORY_SIZE        _512K
    3737#define PCNET_GUEST_TX_DESCRIPTOR_SIZE        16
    3838#define PCNET_GUEST_RX_DESCRIPTOR_SIZE        16
     
    4949typedef struct
    5050{
    51     /** The size of the shared memory.
    52      * This is sizeof(PCNETGUESTSHAREDMEMORY) not PCNET_GUEST_SHARED_MEMORY_SIZE as one would expect.
    53      * @todo r=bird: why not rename to cbHdr or something more descriptive? */
    54     uint32_t u32Size;
     51    /** The size of the shared memory. */
     52    uint32_t cbSize;
    5553    /** Version (PCNET_GUEST_INTERFACE_VERSION). */
    5654    uint32_t u32Version;
    5755    /** Flags (See PCNET_GUEST_FLAGS_*). */
    5856    uint32_t fFlags;
     57    /** align the following members to 64 bit */
     58    uint32_t u32Alignment;
    5959
    60     /** @todo r=bird: You might consider aligning this on a 8(/16) byte boundrary to
    61      * avoid future uint64_t issues. */
    6260    union
    6361    {
     
    6866            /** The size (in bytes) of the receive descriptor array. */
    6967            uint32_t    cbRxDescriptors;
    70             /** Offset of the transmit descriptors relative to this header.
    71              * @todo r=bird: offTxDescriptors is IMO a better name. */
    72             uint32_t    u32OffTxDescriptors;
     68            /** Offset of the transmit descriptors relative to this header. */
     69            uint32_t    offTxDescriptors;
    7370            /** Offset of the receive descriptors relative to this header. */
    74             uint32_t    u32OffRxDescriptors;
     71            uint32_t    offRxDescriptors;
    7572            /** Offset of the transmit buffers relative to this header. */
    76             uint32_t    u32OffTxBuffers;
     73            uint32_t    offTxBuffers;
    7774            /** Offset of the receive buffers relative to this header. */
    78             uint32_t    u32OffRxBuffers;
     75            uint32_t    offRxBuffers;
    7976        } V1;
    8077    } V;
  • trunk/src/VBox/Devices/Network/DevPCNet.cpp

    r7683 r7688  
    610610        uint8_t *pv = (uint8_t*)pData->CTXSUFF(pSharedMMIO)
    611611                    + (addr - pData->GCTDRA)
    612                     + pData->CTXSUFF(pSharedMMIO)->V.V1.u32OffTxDescriptors;
     612                    + pData->CTXSUFF(pSharedMMIO)->V.V1.offTxDescriptors;
    613613        if (!(pv[7] & 0x80) && fRetIfNotOwn)
    614614            return false;
     
    672672        uint8_t *pv = (uint8_t*)pData->CTXSUFF(pSharedMMIO)
    673673                    + (addr - pData->GCTDRA)
    674                     + pData->CTXSUFF(pSharedMMIO)->V.V1.u32OffTxDescriptors;
     674                    + pData->CTXSUFF(pSharedMMIO)->V.V1.offTxDescriptors;
    675675        memcpy(pv, tmd, 16);
    676676        pv[7] &= ~0x80;
     
    729729        uint8_t *pb = (uint8_t*)pData->CTXSUFF(pSharedMMIO)
    730730                    + (addr - pData->GCRDRA)
    731                     + pData->CTXSUFF(pSharedMMIO)->V.V1.u32OffRxDescriptors;
     731                    + pData->CTXSUFF(pSharedMMIO)->V.V1.offRxDescriptors;
    732732        if (!(pb[7] & 0x80) && fRetIfNotOwn)
    733733            return false;
     
    789789        uint8_t *pv = (uint8_t*)pData->CTXSUFF(pSharedMMIO)
    790790                    + (addr - pData->GCRDRA)
    791                     + pData->CTXSUFF(pSharedMMIO)->V.V1.u32OffRxDescriptors;
     791                    + pData->CTXSUFF(pSharedMMIO)->V.V1.offRxDescriptors;
    792792        memcpy(pv, rmd, 16);
    793793        pv[7] &= ~0x80;
     
    873873    uint32_t u32Off = 0;
    874874    memset(pData->pSharedMMIOHC, 0, sizeof(PCNETGUESTSHAREDMEMORY));
    875     pData->pSharedMMIOHC->u32Size = sizeof(PCNETGUESTSHAREDMEMORY);
    876875    pData->pSharedMMIOHC->u32Version = PCNET_GUEST_INTERFACE_VERSION;
    877876    u32Off = 2048; /* Leave some space for more fields within the header */
    878     pData->pSharedMMIOHC->V.V1.u32OffTxDescriptors = u32Off;
     877    pData->pSharedMMIOHC->V.V1.offTxDescriptors = u32Off;
    879878    u32Off = RT_ALIGN(u32Off + PCNET_GUEST_TX_DESCRIPTOR_SIZE * PCNET_GUEST_MAX_TX_DESCRIPTORS, 32);
    880     pData->pSharedMMIOHC->V.V1.u32OffRxDescriptors = u32Off;
     879    pData->pSharedMMIOHC->V.V1.offRxDescriptors = u32Off;
    881880    u32Off = RT_ALIGN(u32Off + PCNET_GUEST_RX_DESCRIPTOR_SIZE * PCNET_GUEST_MAX_RX_DESCRIPTORS, 32);
    882881    /* Map the RX/TX descriptors into the hypervisor. Make sure we don't need too much space. */
    883882    AssertRelease(u32Off <= 8192);
    884     pData->pSharedMMIOHC->V.V1.u32OffTxBuffers = u32Off;
     883#if 0
     884    /* Don't allocate TX buffers since Windows guests cannot use it */
     885    pData->pSharedMMIOHC->V.V1.offTxBuffers = u32Off;
    885886    u32Off = RT_ALIGN(u32Off + PCNET_GUEST_NIC_BUFFER_SIZE * PCNET_GUEST_MAX_TX_DESCRIPTORS, 32);
    886     pData->pSharedMMIOHC->V.V1.u32OffRxBuffers = u32Off;
     887#endif
     888    pData->pSharedMMIOHC->V.V1.offRxBuffers = u32Off;
    887889    pData->pSharedMMIOHC->fFlags = PCNET_GUEST_FLAGS_ADMIT_HOST;
    888890    u32Off = RT_ALIGN(u32Off + PCNET_GUEST_NIC_BUFFER_SIZE * PCNET_GUEST_MAX_RX_DESCRIPTORS, 32);
    889891    AssertRelease(u32Off <= PCNET_GUEST_SHARED_MEMORY_SIZE);
     892    pData->pSharedMMIOHC->cbSize = u32Off;
    890893}
    891894
     
    18051808            int count = RT_MIN(4096 - (int)rmd.rmd1.bcnt, size);
    18061809            RTGCPHYS32 rbadr = PHYSADDR(pData, rmd.rmd0.rbadr);
    1807             PDMDevHlpPhysWrite(pDevIns, rbadr, src, count);
     1810#if 0
     1811            if (pData->fPrivIfEnabled)
     1812            {
     1813                uint8_t *pb = (uint8_t*)pData->CTXSUFF(pSharedMMIO)
     1814                            + rbadr - pData->GCRDRA + pData->CTXSUFF(pSharedMMIO)->V.V1.offRxDescriptors;
     1815                memcpy(pb, src, count);
     1816            }
     1817            else
     1818#endif
     1819                PDMDevHlpPhysWrite(pDevIns, rbadr, src, count);
    18081820            src  += count;
    18091821            size -= count;
     
    18341846
    18351847                count = RT_MIN(4096 - (int)rmd.rmd1.bcnt, size);
    1836                 rbadr = PHYSADDR(pData, rmd.rmd0.rbadr);
    1837                 PDMDevHlpPhysWrite(pDevIns, rbadr, src, count);
     1848                RTGCPHYS32 rbadr = PHYSADDR(pData, rmd.rmd0.rbadr);
     1849#if 0
     1850                if (pData->fPrivIfEnabled)
     1851                {
     1852                    uint8_t *pb = (uint8_t*)pData->CTXSUFF(pSharedMMIO)
     1853                                + rbadr - pData->GCRDRA + pData->CTXSUFF(pSharedMMIO)->V.V1.offRxDescriptors;
     1854                    memcpy(pb, src, count);
     1855                }
     1856                else
     1857#endif
     1858                    PDMDevHlpPhysWrite(pDevIns, rbadr, src, count);
    18381859                src  += count;
    18391860                size -= count;
     
    23872408static DECLCALLBACK(int) pcnetAsyncSendThread(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
    23882409{
    2389     PCNetState *pThis = PDMINS2DATA(pDevIns, PCNetState *);
     2410    PCNetState *pData = PDMINS2DATA(pDevIns, PCNetState *);
    23902411
    23912412    /*
     
    24122433         * to leave the running state.
    24132434         */
    2414         int rc = RTSemEventWait(pThis->hSendEventSem, RT_INDEFINITE_WAIT);
     2435        int rc = RTSemEventWait(pData->hSendEventSem, RT_INDEFINITE_WAIT);
    24152436        AssertRCReturn(rc, rc);
    24162437        if (RT_UNLIKELY(pThread->enmState != PDMTHREADSTATE_RUNNING))
     
    24212442         * suspended while waiting for the critical section.
    24222443         */
    2423         rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
     2444        rc = PDMCritSectEnter(&pData->CritSect, VERR_SEM_BUSY);
    24242445        AssertReleaseRCReturn(rc, rc);
    24252446
    24262447        if (pThread->enmState == PDMTHREADSTATE_RUNNING)
    24272448        {
    2428             rc = pcnetAsyncTransmit(pThis);
     2449            rc = pcnetAsyncTransmit(pData);
    24292450            AssertReleaseRC(rc);
    24302451        }
    24312452
    2432         PDMCritSectLeave(&pThis->CritSect);
     2453        PDMCritSectLeave(&pData->CritSect);
    24332454    }
    24342455
     
    24472468static DECLCALLBACK(int) pcnetAsyncSendThreadWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
    24482469{
    2449     PCNetState *pThis = PDMINS2DATA(pDevIns, PCNetState *);
    2450     return RTSemEventSignal(pThis->hSendEventSem);
     2470    PCNetState *pData = PDMINS2DATA(pDevIns, PCNetState *);
     2471    return RTSemEventSignal(pData->hSendEventSem);
    24512472}
    24522473
Note: See TracChangeset for help on using the changeset viewer.

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