Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Fix a bug in ring-buffer wrap calculation. On th...



details:   https://anonhg.NetBSD.org/src/rev/1086f0c14f0e
branches:  trunk
changeset: 503130:1086f0c14f0e
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Feb 01 04:45:17 2001 +0000

description:
Fix a bug in ring-buffer wrap calculation.  On the Dreamcast,
it causes assertions to fail in the PCI bounce buffer code.  On
other platforms, it causes the address of the next packet to
be mis-calculated, leading to packet loss.

diffstat:

 sys/dev/ic/rtl81x9.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (27 lines):

diff -r 7f1c5efeb5e8 -r 1086f0c14f0e sys/dev/ic/rtl81x9.c
--- a/sys/dev/ic/rtl81x9.c      Thu Feb 01 01:27:59 2001 +0000
+++ b/sys/dev/ic/rtl81x9.c      Thu Feb 01 04:45:17 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtl81x9.c,v 1.28 2001/01/29 01:24:42 enami Exp $       */
+/*     $NetBSD: rtl81x9.c,v 1.29 2001/02/01 04:45:17 thorpej Exp $     */
 
 /*
  * Copyright (c) 1997, 1998
@@ -1051,14 +1051,14 @@
                 * Skip the status word, wrapping around to the beginning
                 * of the Rx area, if necessary.
                 */
-               cur_rx += RTK_RXSTAT_LEN;
-               rxbufpos = sc->rtk_cdata.rtk_rx_buf + (cur_rx % RTK_RXBUFLEN);
+               cur_rx = (cur_rx + RTK_RXSTAT_LEN) % RTK_RXBUFLEN;
+               rxbufpos = sc->rtk_cdata.rtk_rx_buf + cur_rx;
 
                /*
                 * Compute the number of bytes at which the packet
                 * will wrap to the beginning of the ring buffer.
                 */
-               wrap = RTK_RXBUFLEN - (cur_rx % RTK_RXBUFLEN);
+               wrap = RTK_RXBUFLEN - cur_rx;
 
                /*
                 * Compute where the next pending packet is.



Home | Main Index | Thread Index | Old Index