VirtualBox

Changeset 2867 in vbox


Ignore:
Timestamp:
May 25, 2007 11:51:53 AM (17 years ago)
Author:
vboxsync
Message:

Fixed DevPCNet receive code so that it can properly receive into arbitrary
number of buffers, not just one or two.

File:
1 edited

Legend:

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

    r2777 r2867  
    16291629    PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pData);
    16301630    int is_padr = 0, is_bcast = 0, is_ladr = 0;
     1631    unsigned i;
     1632    int pkt_size;
    16311633
    16321634    if (RT_UNLIKELY(CSR_DRX(pData) || CSR_STOP(pData) || CSR_SPND(pData) || !size))
     
    16561658            const unsigned  cb = 1 << pData->iLog2DescSize;
    16571659            RTGCPHYS        GCPhys = pData->GCRDRA;
    1658             unsigned        i = CSR_RCVRL(pData);
     1660            i = CSR_RCVRL(pData);
    16591661            while (i-- > 0)
    16601662            {
     
    16881690            }
    16891691            size += 4;
     1692            pkt_size = size;
    16901693
    16911694#ifdef PCNET_DEBUG_MATCH
     
    17021705            src  += count;
    17031706            size -= count;
    1704             rmd.rmd2.mcnt = count;
    17051707            pktcount++;
    1706             if (size > 0)
     1708
     1709            /* Read current receive descriptor index */
     1710            i = CSR_RCVRC(pData);
     1711
     1712            while (size > 0)
    17071713            {
    1708                 if (HOST_IS_OWNER(CSR_NRST(pData)))
    1709                 {
    1710                     /* From the manual: ``Regardless of ownership of the second receive
    1711                      * descriptor, the Am79C972 controller will continue to perform receive
    1712                      * data DMA transfers to the first buffer. If the frame length exceeds
    1713                      * the length of the first buffer, and the Am79C972 controller does not
    1714                      * own the second buffer, ownership of the current descriptor will be
    1715                      * passed back to the system by writing a 0 to the OWN bit of RMD1.
    1716                      * Status will be written indicating buffer (BUFF = 1) and possibly
    1717                      * overflow (OFLO = 1) errors.
    1718                      * If the frame length exceeds the length of the first (current) buffer,
    1719                      * and the Am79C972 controller does own the second (next) buffer,
    1720                      * ownership will be passed back to the system by writing a 0 to the OWN
    1721                      * bit of RMD1 when the first buffer is full. The OWN bit is the only bit
    1722                      * modified in the descriptor. Receive data transfers to the second buffer
    1723                      * may occur before the Am79C972 controller proceeds to look ahead to the
    1724                      * ownership of the third buffer. Such action will depend upon the state
    1725                      * of the FIFO when the OWN bit has been updated in the first descriptor.
    1726                      * In any case, lookahead will be performed to the third buffer and the
    1727                      * information gathered will be stored in the chip, regardless of the state
    1728                      * of the ownership bit.'' */
    1729                     pcnetRdtePoll(pData, true);
    1730                 }
    1731                 if (CARD_IS_OWNER(CSR_NRST(pData)))
    1732                 {
    1733                     /* write back, clear the own bit */
    1734                     pcnetRmdStorePassHost(pData, &rmd, PHYSADDR(pData, crda));
    1735                     crda  = CSR_NRDA(pData);
    1736                     pcnetRmdLoad(pData, &rmd, PHYSADDR(pData, crda));
    1737                     count = RT_MIN(4096 - (int)rmd.rmd1.bcnt, size);
    1738                     rbadr = PHYSADDR(pData, rmd.rmd0.rbadr);
    1739                     PDMDevHlpPhysWrite(pDevIns, rbadr, src, count);
    1740                     src  += count;
    1741                     size -= count;
    1742                     rmd.rmd2.mcnt = count;
    1743                     pktcount++;
    1744                 }
     1714                /* write back, clear the own bit */
     1715                pcnetRmdStorePassHost(pData, &rmd, PHYSADDR(pData, crda));
     1716
     1717                /* Read the entire next descriptor as we're likely to need it. */
     1718                if (--i < 1)
     1719                    i = CSR_RCVRL(pData);
     1720                crda = pcnetRdraAddr(pData, i);
     1721                pcnetRmdLoad(pData, &rmd, PHYSADDR(pData, crda));
     1722
     1723                if (!rmd.rmd1.own)
     1724                    break;      /* Error - not enough buffer space available. */
     1725               
     1726                count = RT_MIN(4096 - (int)rmd.rmd1.bcnt, size);
     1727                rbadr = PHYSADDR(pData, rmd.rmd0.rbadr);
     1728                PDMDevHlpPhysWrite(pDevIns, rbadr, src, count);
     1729                src  += count;
     1730                size -= count;
     1731                pktcount++;
    17451732            }
    17461733
     
    17511738                rmd.rmd1.lafm = !CSR_PROM(pData) && is_ladr;
    17521739                rmd.rmd1.bam  = !CSR_PROM(pData) && is_bcast;
     1740                rmd.rmd2.mcnt = pkt_size;
    17531741            }
    17541742            else
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