From dudin@np.nk.nornik.ru  Wed May 17 22:22:49 2000
Return-Path: <dudin@np.nk.nornik.ru>
Received: from ns.nk.nornik.ru (ns.nk.nornik.ru [195.133.78.67])
	by hub.freebsd.org (Postfix) with ESMTP id 3E68637BAAC
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 17 May 2000 22:22:41 -0700 (PDT)
	(envelope-from dudin@np.nk.nornik.ru)
Received: from np.nk.nornik.ru (IDENT:dudin@mail.np.nk.nornik.ru [172.31.71.3])
          by ns.nk.nornik.ru (8.9.1/8.9.1) with ESMTP id NAA25962
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 18 May 2000 13:20:03 +0800 (KRSS)
Received: (from dudin@localhost)
	by np.nk.nornik.ru (8.9.3/8.9.3) id NAA25798
	for FreeBSD-gnats-submit@freebsd.org; Thu, 18 May 2000 13:22:36 +0800
Message-Id: <200005180522.NAA25798@np.nk.nornik.ru>
Date: Thu, 18 May 2000 13:22:36 +0800
From: dudin@np.nk.nornik.ru
Reply-To: dudin@np.nk.nornik.ru
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCH] le driver doesn't work with DEPCA
X-Send-Pr-Version: 3.2

>Number:         18639
>Category:       kern
>Synopsis:       [PATCH] le driver doesn't work with DEPCA
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 17 22:30:00 PDT 2000
>Closed-Date:    Thu May 20 18:51:30 PDT 2004
>Last-Modified:  Thu May 20 18:51:30 PDT 2004
>Originator:     Eugene A. Doudine
>Release:        FreeBSD 3.2-RELEASE i386
>Organization:
Institute "Norilskproject"
>Environment:

FreeBSD mom.np.nk.nornik.ru 3.2-RELEASE FreeBSD 3.2-RELEASE #25: Wed May 17 00:31:35 KRAST 2000     root@mom.np.nk.nornik.ru:/usr/src/sys/compile/MOM  i386

Digital DEPCA rev.E  NIC

>Description:

	DEPCA is not detected by driver.
	(it can be sometimes detected, if other drivers probe DEPCA's
	 base address earlier in the boot process but doesn't work anyway)
	The author of driver states, that driver has been tested only with
	DE200 and later cards (/usr/src/sys/i386/isa/README.le), so this
	behaviour is somewhat expected. 

	Unlike DE200 and later cards DEPCA has 8 bit NICSR, not 16 bit
	as driver assumes, so OUTW/INW do not work with DEPCA. The higher
	byte of NICSR is not used by driver, so I changed OUTW/INW to
	OUTB/INB.  This solved problem with detecting the board on boot.

	The other problem was that board could transmit only several
	packets and then transmission stopped. 

	DEPCA is based on AM7990 LANCE chip, which, unlike AM79C96, 
	restricts the sizes of descriptor rings to powers of 2. 
	So I added the check for this for DEPCA. I'm not sure which chip
	DE100 and DE101 use, probably they need this fix as well.
	
	Now driver works with DEPCA, but I have no chance to check
	if it still works with other cards. 

>How-To-Repeat:

	100% reproducible ( if DEPCA fits into your computer case,
		that is :-) )

>Fix:
	
--- i386/isa/if_le.c.orig	Sun May 14 01:12:52 2000
+++ i386/isa/if_le.c	Wed May 17 00:29:56 2000
@@ -1377,8 +1377,8 @@
 #define	DEPCA_NICSR_SHE		0x0080		/* Shared RAM Enabled (ie hide ROM) */
 #define	DEPCA_NICSR_BOOTTMO	0x0100		/* Remote Boot Timeout (ignored) */
 
-#define	DEPCA_RDNICSR(sc)	(LE_INW(sc, DEPCA_REG_NICSR))
-#define	DEPCA_WRNICSR(sc, val)	(LE_OUTW(sc, DEPCA_REG_NICSR, val))
+#define	DEPCA_RDNICSR(sc)	(LE_INB(sc, DEPCA_REG_NICSR))
+#define	DEPCA_WRNICSR(sc, val)	(LE_OUTB(sc, DEPCA_REG_NICSR, val))
 
 #define	DEPCA_IDSTR_OFFSET	0xC006		/* ID String Offset */
 
@@ -1546,10 +1546,17 @@
 	sc->lance_rxbufsize *= rxdescs / LN_DESC_MAX;
 	rxdescs = LN_DESC_MAX;
     }
-    txdescs = sc->lance_ramsize / LN_TXDESC_RATIO;
-    if (txdescs > LN_DESC_MAX)
-	txdescs = LN_DESC_MAX;
-
+    if (!strcmp(sc->le_prodname,"DEPCA")) {
+	txdescs = 1;
+	while (txdescs <= sc->lance_ramsize / LN_TXDESC_RATIO && 
+		txdescs <= LN_DESC_MAX)
+	    txdescs *= 2;
+	txdescs /= 2;
+    } else {
+    	txdescs = sc->lance_ramsize / LN_TXDESC_RATIO;
+    	if (txdescs > LN_DESC_MAX)
+	    txdescs = LN_DESC_MAX;
+    }
     /*
      * Now calculate where everything goes in memory
      */


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: mike 
State-Changed-When: Sat Jul 21 19:31:05 PDT 2001 
State-Changed-Why:  

Does this problem still occur in newer versions of FreeBSD, 
such as 4.3-RELEASE? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18639 

From: Mike Barcroft <mike@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/18639: [PATCH] le driver doesn't work with DEPCA
Date: Wed, 1 Aug 2001 23:41:36 -0400

 Adding to Audit-Trail.
 
 ----- Forwarded message from "Eugene A. Doudine" <dudin@np.nk.nornik.ru> -----
 
 X-UIDL: 214bb02178cc435747c0ad4c42fdff23
 Delivered-To: mike@freebsd.org
 Date: Fri, 27 Jul 2001 00:29:36 +0800 (KRAST)
 From: "Eugene A. Doudine" <dudin@np.nk.nornik.ru>
 To: mike@FreeBSD.org
 Cc: freebsd-bugs@FreeBSD.org
 Subject: Re: kern/18639: [PATCH] le driver doesn't work with DEPCA
 In-Reply-To: <200107220231.f6M2VKK79582@freefall.freebsd.org>
 
 
 Hello, Mike
 
 I didn't try 4.3-RELEASE.
 I tried 4.2-RELEASE, has the same problems and some others.
 It cannot detect the card without my patch. 
 With my patch applied it's able to detect the card. Kernel on boot 
 gives this warning:
 le0 XXX: driver didn't set ifq_maxlen
 
 And then the kernel panics during configuration of the interface,
 exactly as described in PR kern/19219.
 
 
 Regards,
 Eugene
 
 On Sat, 21 Jul 2001 mike@FreeBSD.org wrote:
 
 > Synopsis: [PATCH] le driver doesn't work with DEPCA
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: mike
 > State-Changed-When: Sat Jul 21 19:31:05 PDT 2001
 > State-Changed-Why: 
 > 
 > Does this problem still occur in newer versions of FreeBSD,
 > such as 4.3-RELEASE?
 > 
 > http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18639
 > 
 > 
 
 
 
 
 ----- End forwarded message -----
State-Changed-From-To: feedback->suspended 
State-Changed-By: mike 
State-Changed-When: Wed Aug 1 20:56:34 PDT 2001 
State-Changed-Why:  

This is still a problem in 4.3-RELEASE.  Awaiting a committer 
with the necessary hardware to review and commit this or another 
patch which solves this problem. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18639 
State-Changed-From-To: suspended->closed 
State-Changed-By: arved 
State-Changed-When: Thu May 20 18:50:31 PDT 2004 
State-Changed-Why:  
The le driver has been removed from CURRENT, so this will probably not be 
fixed. 

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