Changeset 19113 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Apr 22, 2009 3:04:04 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r19112 r19113 1825 1825 * Write data into guest receive buffers. 1826 1826 */ 1827 static void pcnetReceiveNoSync(PCNetState *pThis, const uint8_t *buf, size_t size)1827 static void pcnetReceiveNoSync(PCNetState *pThis, const uint8_t *buf, size_t cbToRecv) 1828 1828 { 1829 1829 PPDMDEVINS pDevIns = PCNETSTATE_2_DEVINS(pThis); 1830 1830 int is_padr = 0, is_bcast = 0, is_ladr = 0; 1831 1831 unsigned iRxDesc; 1832 int pkt_size;1833 1834 if (RT_UNLIKELY(CSR_DRX(pThis) || CSR_STOP(pThis) || CSR_SPND(pThis) || ! size))1832 int cbPacket; 1833 1834 if (RT_UNLIKELY(CSR_DRX(pThis) || CSR_STOP(pThis) || CSR_SPND(pThis) || !cbToRecv)) 1835 1835 return; 1836 1836 … … 1841 1841 return; 1842 1842 1843 Log(("#%d pcnetReceiveNoSync: size=%d\n", PCNET_INST_NR, size));1843 Log(("#%d pcnetReceiveNoSync: size=%d\n", PCNET_INST_NR, cbToRecv)); 1844 1844 1845 1845 /* … … 1847 1847 */ 1848 1848 if ( CSR_PROM(pThis) 1849 || (is_padr = padr_match(pThis, buf, size))1850 || (is_bcast = padr_bcast(pThis, buf, size))1851 || (is_ladr = ladr_match(pThis, buf, size)))1849 || (is_padr = padr_match(pThis, buf, cbToRecv)) 1850 || (is_bcast = padr_bcast(pThis, buf, cbToRecv)) 1851 || (is_ladr = ladr_match(pThis, buf, cbToRecv))) 1852 1852 { 1853 1853 if (HOST_IS_OWNER(CSR_CRST(pThis))) … … 1878 1878 RTGCPHYS32 crda = CSR_CRDA(pThis); 1879 1879 RTGCPHYS32 next_crda; 1880 RMD rmd, next_rmd;1881 1882 memcpy(src, buf, size);1880 RMD rmd, next_rmd; 1881 1882 memcpy(src, buf, cbToRecv); 1883 1883 if (!CSR_ASTRP_RCV(pThis)) 1884 1884 { … … 1886 1886 uint8_t *p = src; 1887 1887 1888 while ( size< 60)1889 src[ size++] = 0;1890 while (p != &src[ size])1888 while (cbToRecv < 60) 1889 src[cbToRecv++] = 0; 1890 while (p != &src[cbToRecv]) 1891 1891 CRC(fcs, *p++); 1892 ((uint32_t *)&src[ size])[0] = htonl(fcs);1892 ((uint32_t *)&src[cbToRecv])[0] = htonl(fcs); 1893 1893 /* FCS at end of packet */ 1894 1894 } 1895 size+= 4;1896 pkt_size = (int)size; Assert((size_t)pkt_size == size);1895 cbToRecv += 4; 1896 cbPacket = (int)cbToRecv; Assert((size_t)cbPacket == cbToRecv); 1897 1897 1898 1898 #ifdef PCNET_DEBUG_MATCH … … 1904 1904 rmd.rmd1.stp = 1; 1905 1905 1906 size_t c ount = RT_MIN(4096 - (size_t)rmd.rmd1.bcnt, size);1906 size_t cbBuf = RT_MIN(4096 - (size_t)rmd.rmd1.bcnt, cbToRecv); 1907 1907 RTGCPHYS32 rbadr = PHYSADDR(pThis, rmd.rmd0.rbadr); 1908 1909 /* save the old value to check if it was changed as long as we didn't 1910 * hold the critical section */ 1911 iRxDesc = CSR_RCVRC(pThis); 1908 1912 1909 1913 /* We have to leave the critical section here or we risk deadlocking … … 1917 1921 */ 1918 1922 PDMCritSectLeave(&pThis->CritSect); 1919 PDMDevHlpPhysWrite(pDevIns, rbadr, src, c ount);1923 PDMDevHlpPhysWrite(pDevIns, rbadr, src, cbBuf); 1920 1924 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); 1921 1925 AssertReleaseRC(rc); 1922 1926 1923 src += count; 1924 size -= count; 1925 1926 /* adapt the current RX descriptor counter */ 1927 iRxDesc = CSR_RCVRC(pThis); 1928 if (iRxDesc-- < 2) 1929 iRxDesc = CSR_RCVRL(pThis); 1930 CSR_RCVRC(pThis) = iRxDesc; 1931 1932 while (size > 0) 1927 /* RX disabled in the meantime? If so, abort RX. */ 1928 if (RT_UNLIKELY(CSR_DRX(pThis) || CSR_STOP(pThis) || CSR_SPND(pThis))) 1929 return; 1930 1931 /* Was the register modified in the meantime? If so, don't touch the 1932 * register but still update the RX descriptor. */ 1933 if (RT_LIKELY(iRxDesc == CSR_RCVRC(pThis))) 1934 { 1935 if (iRxDesc-- < 2) 1936 iRxDesc = CSR_RCVRL(pThis); 1937 CSR_RCVRC(pThis) = iRxDesc; 1938 } 1939 else 1940 iRxDesc = CSR_RCVRC(pThis); 1941 1942 src += cbBuf; 1943 cbToRecv -= cbBuf; 1944 1945 while (cbToRecv > 0) 1933 1946 { 1934 1947 /* Read the entire next descriptor as we're likely to need it. */ … … 1948 1961 rmd = next_rmd; 1949 1962 1950 c ount = RT_MIN(4096 - (size_t)rmd.rmd1.bcnt, size);1963 cbBuf = RT_MIN(4096 - (size_t)rmd.rmd1.bcnt, cbToRecv); 1951 1964 RTGCPHYS32 rbadr = PHYSADDR(pThis, rmd.rmd0.rbadr); 1952 1965 … … 1955 1968 * handler associated with it. See above for additional comments. */ 1956 1969 PDMCritSectLeave(&pThis->CritSect); 1957 PDMDevHlpPhysWrite(pDevIns, rbadr, src, c ount);1958 intrc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);1970 PDMDevHlpPhysWrite(pDevIns, rbadr, src, cbBuf); 1971 rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); 1959 1972 AssertReleaseRC(rc); 1960 1973 1961 src += count; 1962 size -= count; 1963 1964 /* adapt the current RX descriptor counter */ 1965 iRxDesc = CSR_RCVRC(pThis); 1966 if (iRxDesc-- < 1) 1967 iRxDesc = CSR_RCVRL(pThis); 1968 CSR_RCVRC(pThis) = iRxDesc; 1974 /* RX disabled in the meantime? If so, abort RX. */ 1975 if (RT_UNLIKELY(CSR_DRX(pThis) || CSR_STOP(pThis) || CSR_SPND(pThis))) 1976 return; 1977 1978 /* Was the register modified in the meantime? If so, don't touch the 1979 * register but still update the RX descriptor. */ 1980 if (RT_LIKELY(iRxDesc == CSR_RCVRC(pThis))) 1981 { 1982 if (iRxDesc-- < 2) 1983 iRxDesc = CSR_RCVRL(pThis); 1984 CSR_RCVRC(pThis) = iRxDesc; 1985 } 1986 else 1987 iRxDesc = CSR_RCVRC(pThis); 1988 1989 src += cbBuf; 1990 cbToRecv -= cbBuf; 1969 1991 } 1970 1992 1971 if (RT_LIKELY( size== 0))1993 if (RT_LIKELY(cbToRecv == 0)) 1972 1994 { 1973 1995 rmd.rmd1.enp = 1; … … 1975 1997 rmd.rmd1.lafm = !CSR_PROM(pThis) && is_ladr; 1976 1998 rmd.rmd1.bam = !CSR_PROM(pThis) && is_bcast; 1977 rmd.rmd2.mcnt = pkt_size;1978 1979 STAM_REL_COUNTER_ADD(&pThis->StatReceiveBytes, pkt_size);1999 rmd.rmd2.mcnt = cbPacket; 2000 2001 STAM_REL_COUNTER_ADD(&pThis->StatReceiveBytes, cbPacket); 1980 2002 } 1981 2003 else 1982 2004 { 1983 Log(("#%d: Overflow by %ubytes\n", PCNET_INST_NR, size));2005 Log(("#%d: Overflow by %ubytes\n", PCNET_INST_NR, cbToRecv)); 1984 2006 rmd.rmd1.oflo = 1; 1985 2007 rmd.rmd1.buff = 1;
Note:
See TracChangeset
for help on using the changeset viewer.