From 9fans-admin@cse.psu.edu Thu Mar 07 18:00:15 2002
Return-Path: <9fans-admin@cse.psu.edu>
Delivered-To: dpx@acl.lanl.gov
Received: (qmail 307693 invoked from network); 7 Mar 2002 11:00:14 -0700
Received: from mailrelay1.lanl.gov (128.165.4.101)
  by acl.lanl.gov with SMTP; 7 Mar 2002 11:00:14 -0700
Received: from mailproxy1.lanl.gov (localhost.localdomain [127.0.0.1])
	by mailrelay1.lanl.gov (8.11.6/8.11.6/(ccn-5)) with ESMTP id g27I0EQ14510;
	Thu, 7 Mar 2002 11:00:14 -0700
Received: from mail.cse.psu.edu (psuvax1.cse.psu.edu [130.203.4.6])
	by mailproxy1.lanl.gov (8.11.6/8.11.6/(ccn-5)) with ESMTP id g27I2n202166;
	Thu, 7 Mar 2002 11:02:50 -0700
Received: from psuvax1.cse.psu.edu (psuvax1.cse.psu.edu [130.203.18.6])
	by mail.cse.psu.edu (CSE Mail Server) with ESMTP
	id 03D4819992; Thu, 7 Mar 2002 13:00:08 -0500 (EST)
Delivered-To: 9fans@cse.psu.edu
Received: from plan9.cs.bell-labs.com (ampl.com [204.178.31.2])
	by mail.cse.psu.edu (CSE Mail Server) with SMTP id E54B219981
	for <9fans@cse.psu.edu>; Thu, 7 Mar 2002 12:59:30 -0500 (EST)
Message-ID: <d8d618efa2331a72ab5d975fcb42789d@plan9.bell-labs.com>
Subject: Re: [9fans] ether8139.c fix
From: jmk@plan9.bell-labs.com
To: 9fans@cse.psu.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
Sender: 9fans-admin@cse.psu.edu
Errors-To: 9fans-admin@cse.psu.edu
X-BeenThere: 9fans@cse.psu.edu
X-Mailman-Version: 2.0.8
Precedence: bulk
Reply-To: 9fans@cse.psu.edu
List-Help: <mailto:9fans-request@cse.psu.edu?subject=help>
List-Id: Fans of the OS Plan 9 from Bell Labs <9fans.cse.psu.edu>
List-Archive: <https://lists.cse.psu.edu/archives/9fans/>
Date: Thu, 7 Mar 2002 12:59:28 -0500
Status: RO
X-Status:

OK. I think we all got confused about this. Turns out I thought
the fix posted by geoff@collyer.net was referring to the 2nd memmove in
the receive code, where the real problem lay and which I had already
fixed some time before. My apologies for not taking time to verify
the fix was what I thought it was.

Anyway, in conjunction with Presotto I've tested the following which
completely replaces the code in rtl8139receive() for handling an OK packet:


		/*
		 * Receive Completed OK.
		 * Very simplistic; there are ways this could be done
		 * without copying, but the juice probably isn't worth
		 * the squeeze.
		 * The packet length includes a 4 byte CRC on the end.
		 */
		capr = (capr+4) % ctlr->rblen;
		p = ctlr->rbstart+capr;
		capr = (capr+length) % ctlr->rblen;

		if((bp = iallocb(length)) != nil){
			if(p+length >= ctlr->rbstart+ctlr->rblen){
				l = ctlr->rbstart+ctlr->rblen - p;
				memmove(bp->wp, p, l);
				bp->wp += l;
				length -= l;
				p = ctlr->rbstart;
			}
			if(length > 0){
				memmove(bp->wp, p, length);
				bp->wp += length;
			}
			bp->wp -= 4;
			etheriq(edev, bp, 1);
		}

		capr = ROUNDUP(capr, 4);
		csr16w(ctlr, Capr, capr-16);