From rajit@csl.cornell.edu Tue Aug 10 18:12:21 1999
Return-Path: <rajit@csl.cornell.edu>
Received: from doubleday.csl.cornell.edu (DOUBLEDAY.CSL.CORNELL.EDU [132.236.71.12])
	by hub.freebsd.org (Postfix) with ESMTP id AF4CD14D2F
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 10 Aug 1999 18:11:56 -0700 (PDT)
	(envelope-from rajit@csl.cornell.edu)
Received: (from rajit@localhost)
	by doubleday.csl.cornell.edu (8.9.3/8.9.2) id VAA01577;
	Tue, 10 Aug 1999 21:09:05 -0400 (EDT)
	(envelope-from rajit)
Message-Id: <199908110109.VAA01577@doubleday.csl.cornell.edu>
Date: Tue, 10 Aug 1999 21:09:05 -0400 (EDT)
From: Rajit Manohar <rajit@csl.cornell.edu>
Reply-To: rajit@csl.cornell.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: lnc ethernet xmit underflow problem
X-Send-Pr-Version: 3.2

>Number:         13062
>Category:       kern
>Synopsis:       lnc ethernet xmit underflow problem
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 10 18:20:00 PDT 1999
>Closed-Date:    Tue Mar 26 04:59:22 PST 2002
>Last-Modified:  Tue Mar 26 04:59:22 PST 2002
>Originator:     Rajit Manohar
>Release:        FreeBSD 3.2-RELEASE i386
>Organization:
Cornell Computer Systems Laboratory
>Environment:

Running a cluster of Dell (xl0 driver, 3c905B PCI nic) and HP Kayak XU
(lnc1 driver PCnet-FAST+ PCI, Am79C972 nic) connected by a 100Mbps
switched ethernet.  The Dells run FreeBSD 3.1-RELEASE, and the Kayaks
run 3.2-RELEASE.

>Description:

The PCI lnc driver on the Kayak reports transmit underflow errors. The
following message appears on console repeatedly:

Aug  6 12:00:00 <host> /kernel: lnc1: Transmit underflow error -- Resetting

The system also exhibits poor throughput; an ftp between two Kayaks
results in transmit rates of between 300KB/sec and 700KB/sec, well
below the 100Mbps transfer rate.

>How-To-Repeat:

ftp a file (like /kernel) from one machine to another. Any sustained
network activity results in the above problem.

>Fix:
	
It appears that under certain cases, the data being transferred from
memory to the nic does not arrive in time for the transmitter,
resulting in the underflow. The Am79C972 nic has a bus control bit
that can be set to prevent any message transmits until the entire
message is DMAed to the network card SRAM. Setting this bit solves
both the transmit underflow problem as well as the throughput problem,
since the card is no longer periodically reset. I've included a patch
for i386/isa/if_lnc.c for 3.2-RELEASE.

I check that the nic # is > PCnet_FAST (i.e. == PCnet_FASTplus) before 
changing the bus control register. This might work on the Am79C97x,
but I only have Am79C972 nics.

After the modifications, I no longer get any transmit underflow
errors, and I can ftp files at 10MB/sec between the Kayaks. :)

-Rajit Manohar <rajit@csl.cornell.edu>


*** if_lnc.c.orig	Mon Aug  9 16:23:27 1999
--- if_lnc.c	Tue Aug 10 12:10:07 1999
***************
*** 1504,1516 ****
  
  	write_csr(sc, CSR3, 0);
  
  	/* Let's see if it starts */
  
  	write_csr(sc, CSR0, INIT);
  	for (i = 0; i < 1000; i++)
  		if (read_csr(sc, CSR0) & IDON)
  			break;
- 
  	/*
  	 * Now that the initialisation is complete there's no reason to
  	 * access anything except CSR0, so we leave RAP pointing there
--- 1504,1528 ----
  
  	write_csr(sc, CSR3, 0);
  
+ 	/* 
+ 	 * If we have a Am79C972 card, we set the NOUFLO bit
+ 	 * (bit 11) in BCR18 to avoid underflow errors.
+ 	 * The #define's really should go into ic/
+ 	 */
+ #define BCR18 18
+ #define NOUFLO 0x0800
+ 	if (sc->nic.ic > PCnet_FAST) {
+ 	  u_short oval;
+ 	  oval = read_bcr (sc, BCR18);
+ 	  write_bcr (sc, BCR18, oval|NOUFLO);
+ 	}
+ 
  	/* Let's see if it starts */
  
  	write_csr(sc, CSR0, INIT);
  	for (i = 0; i < 1000; i++)
  		if (read_csr(sc, CSR0) & IDON)
  			break;
  	/*
  	 * Now that the initialisation is complete there's no reason to
  	 * access anything except CSR0, so we leave RAP pointing there



>Release-Note:
>Audit-Trail:

From: Ken Lui <klui@cup.hp.com>
To: freebsd-gnats-submit@freebsd.org, rajit@csl.cornell.edu
Cc:  
Subject: Re: kern/13062: lnc ethernet xmit underflow problem
Date: Sat, 09 Oct 1999 12:33:00 -0700

 I have experienced the same thing on my Kayak XU. While it doesn't have
 an Am79C972, it has instead a Symbios/NCR ultra-wide SCSI/PCnet-FAST
 ethernet combination card. The 971's data sheet says it has the same
 NOUFLO control bit. Making your patch work with 971 and above chipssets
 requires changing:
 
      if (sc->nic.ic > PCnet_FAST)
 
 to
 
      if (sc->nic.ic==PCnet_FAST || sc->nic.ic==PCnet_FASTplus)
 
 
 Ken
 p.s. This bit is only applicable to the 971, 972, 973/975
 (PCnetFastIII)--not the 970A (and assuming 970, since there's no
 datasheet for it currently at AMD's website).
 
 Relevant kernel messages:
 
      Probing for devices on PCI bus 2:
      ncr0: <ncr 53c875 fast20 wide scsi> rev 0x26 int a irq 11 on
 pci2.4.0
      lnc1: <PCNet/PCI Ethernet adapter> rev 0x25 int a irq 11 on
 pci2.5.0
      lnc1: PCnet-FAST address [. . .]
 
State-Changed-From-To: open->feedback 
State-Changed-By: iedowse 
State-Changed-When: Sun Dec 2 11:23:42 PST 2001 
State-Changed-Why:  

Does this problem still occur in more recent releases? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=13062 
State-Changed-From-To: feedback->closed 
State-Changed-By: cjc 
State-Changed-When: Tue Mar 26 04:59:02 PST 2002 
State-Changed-Why:  
Feedback timeout. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=13062 
>Unformatted:
