From nobody@FreeBSD.ORG Wed May  5 01:35:08 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 304E215301; Wed,  5 May 1999 01:35:08 -0700 (PDT)
Message-Id: <19990505083508.304E215301@hub.freebsd.org>
Date: Wed,  5 May 1999 01:35:08 -0700 (PDT)
From: max@cca.usart.ru
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: CS89XX (i386/isa/if_cs.c) fails to properly initialize CS8920-based PnP NIC
X-Send-Pr-Version: www-1.0

>Number:         11507
>Category:       kern
>Synopsis:       CS89XX (i386/isa/if_cs.c) fails to properly initialize CS8920-based PnP NIC
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    imp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May  5 01:40:01 PDT 1999
>Closed-Date:    Mon Nov 03 18:54:41 MST 2003
>Last-Modified:  Mon Nov 03 18:54:41 MST 2003
>Originator:     Max Gotlib
>Release:        GreeBSD-CURRENT (05.02.99) (affected starting with 04.16.99)
>Organization:
The Urals State Academy of Railway Transport
>Environment:
FreeBSD unxsrv.ks.usart.ru 4.0-CURRENT FreeBSD 4.0-CURRENT #2: Tue Mar 4 10:22:25 ES 1999     root@unxsrv.ks.usart.ru:/usr/src/sys/compile/UNXSRV  i386

>Description:
See PR kern/11462 for the primary problem description.
The proposed (former) patch was built against CURRENT (04.16.99(
source tree state, but then there were a number of changes, conserning
PnP stuff, so another "bug" was introdused. The simthoms are the following:
while booting kernel it correctly locates PnP CS9820-based NIC,
but in case of EEPROM driver configuration block checksum mismatch (I've
got ten IBM 300GLs with such a "feature"), driver fails to assing
media for the NIC and panics. More, since the driver "forgets" to initialize
the "id_alive" if "isa_device" structure, PnP code simply throws the
driver away during attachment procedure. More, because of the changes in
the PnP code, "old" sceme (when it was supposed that "id_unit" could be
equil to "id_id") used in PnP interrupt handler became broken and
driver gets no IRQs (constant OACTIVE interface state).
>How-To-Repeat:
Just try to boot :) I've performed tests in IBM 300GL with
embedded CS8920M-based NIC
>Fix:
The solution is the following: simply ignore the EEPROM checksum
mismatch (controlled by the oppropriate #define) and introduce oppropriate
fixes in the driver's code (for "id_alive" and "id_id" typos).

Here the patch (includes proposed in kern/11462 one)
for /sys/i386/isa/if_cs.c:
=========================
--- if_cs.c.ORIG        Mon Apr 19 20:19:57 1999
+++ if_cs.c     Wed May  5 13:13:30 1999
@@ -34,6 +34,8 @@
  */
 
 /* #define      CS_DEBUG */
+#define  IGNORE_CHKSUM_MISMATCH
+
 #include "cs.h"
 #include "bpfilter.h"
 
@@ -165,7 +167,7 @@
 
 #ifdef CS_DEBUG
                printf("%02x %02x ",(unsigned char)buffer[i],
-                                       (unsigned char)buffer[i+1]);
+                                       (unsigned char)(buffer[i] >> 8));
 #endif
        }
 
@@ -186,7 +188,12 @@
        cksum &= 0xffff;
        if (cksum==0)
                return 0;
+#ifdef IGNORE_CHKSUM_MISMATCH
+       printf ("cs: checksum mismatched, ignoring\n");
+       return (0);
+#else
        return -1;
+#endif
 }
 
 static int
@@ -599,6 +606,18 @@
 
                 if (sc->adapter_cnf & A_CNF_MEDIA)
                         ifmedia_add(&sc->media, IFM_ETHER|IFM_AUTO, 0, NULL);
+               else {
+                       printf (CS_NAME"%d: adapter reports no media"
+                               ", assuming 10baseT\n", unit);
+                       sc->adapter_cnf |= A_CNF_10B_T;
+                       ifmedia_add(&sc->media, IFM_ETHER|IFM_10_T, 0, NULL);
+                       if (sc->chip_type != CS8900) {
+                               ifmedia_add(&sc->media,
+                                       IFM_ETHER|IFM_10_T|IFM_FDX, 0, NULL);
+                               ifmedia_add(&sc->media,
+                                       IFM_ETHER|IFM_10_T|IFM_HDX, 0, NULL);
+                       }
+               }
 
                 /* Set default media from EEPROM */
                 switch (sc->adapter_cnf & A_CNF_MEDIA_TYPE) {
@@ -1307,11 +1326,11 @@
 {
     struct csintr_list *intr;
 
-    for (intr=csintr_head; intr; intr=intr->next) {
-           if (intr->unit == unit)
+    for (intr=csintr_head; intr; intr=intr->next)
+           if (intr->unit == unit) {
                csintr_sc(intr->sc, unit);
                break;
-       }
+           }
 }
 
 static char *
@@ -1378,7 +1397,8 @@
     if (!sc) return;
 
     bzero(sc, sizeof *sc);
-    if (cs_cs89x0_probe(sc, &irq, &drq, iobase, unit, flags) == 0
+    if ((dev->id_alive = 
+        cs_cs89x0_probe(sc, &irq, &drq, iobase, unit, flags)) == 0
        || cs_attach(sc, unit, flags) == 0) {
            free(sc, M_DEVBUF);
     } else {
@@ -1391,6 +1411,6 @@
                printf("failed to pnp card parametars\n");
        }
     }
-    csintr_pnp_add(sc, dev->id_unit);
+    csintr_pnp_add(sc, dev->id_id);
 }
 #endif /* NPNP */

=========================

And just the same in uue:
=========================
begin 644 if_cs.c.diff
M+2TM(&EF7V-S+F,N3U))1PE-;VX@07!R(#$Y(#(P.C$Y.C4W(#$Y.3D**RLK
M(&EF7V-S+F,)5V5D($UA>2`@-2`Q,SHQ,SHS,"`Q.3DY"D!`("TS-"PV("LS
M-"PX($!`"B`@*B\*(`H@+RH@(V1E9FEN90D@0U-?1$5"54<@*B\**R-D969I
M;F4@($E'3D]215]#2$M354U?34E334%40T@**PH@(VEN8VQU9&4@(F-S+F@B
M"B`C:6YC;'5D92`B8G!F:6QT97(N:"(*(`I`0"`M,38U+#<@*S$V-RPW($!`
M"B`*("-I9F1E9B!#4U]$14)51PH@"0EP<FEN=&8H(B4P,G@@)3`R>"`B+"AU
M;G-I9VYE9"!C:&%R*6)U9F9E<EMI72P*+0D)"0D)*'5N<VEG;F5D(&-H87(I
M8G5F9F5R6VDK,5TI.PHK"0D)"0DH=6YS:6=N960@8VAA<BDH8G5F9F5R6VE=
M(#X^(#@I*3L*("-E;F1I9@H@"7T*(`I`0"`M,3@V+#<@*S$X."PQ,B!`0`H@
M"6-K<W5M("8](#!X9F9F9CL*(`EI9B`H8VMS=6T]/3`I"B`)"7)E='5R;B`P
M.PHK(VEF9&5F($E'3D]215]#2$M354U?34E334%40T@**PEP<FEN=&8@*")C
M<SH@8VAE8VMS=6T@;6ES;6%T8VAE9"P@:6=N;W)I;F=<;B(I.PHK"7)E='5R
M;B`H,"D["BLC96QS90H@"7)E='5R;B`M,3L**R-E;F1I9@H@?0H@"B!S=&%T
M:6,@:6YT"D!`("TU.3DL-B`K-C`V+#$X($!`"B`*("`@("`@("`@("`@("`@
M("!I9B`H<V,M/F%D87!T97)?8VYF("8@05]#3D9?345$24$I"B`@("`@("`@
M("`@("`@("`@("`@("`@("!I9FUE9&EA7V%D9"@F<V,M/FUE9&EA+"!)1DU?
M151(15)\249-7T%55$\L(#`L($Y53$PI.PHK"0EE;'-E('L**PD)"7!R:6YT
M9B`H0U-?3D%-12(E9#H@861A<'1E<B!R97!O<G1S(&YO(&UE9&EA(@HK"0D)
M"2(L(&%S<W5M:6YG(#$P8F%S951<;B(L('5N:70I.PHK"0D)<V,M/F%D87!T
M97)?8VYF('P]($%?0TY&7S$P0E]4.PHK"0D):69M961I85]A9&0H)G-C+3YM
M961I82P@249-7T542$52?$E&35\Q,%]4+"`P+"!.54Q,*3L**PD)"6EF("AS
M8RT^8VAI<%]T>7!E("$]($-3.#DP,"D@>PHK"0D)"6EF;65D:6%?861D*"9S
M8RT^;65D:6$L"BL)"0D)"4E&35]%5$A%4GQ)1DU?,3!?5'Q)1DU?1D18+"`P
M+"!.54Q,*3L**PD)"0EI9FUE9&EA7V%D9"@F<V,M/FUE9&EA+`HK"0D)"0E)
M1DU?151(15)\249-7S$P7U1\249-7TA$6"P@,"P@3E5,3"D["BL)"0E]"BL)
M"7T*(`H@("`@("`@("`@("`@("`@("\J(%-E="!D969A=6QT(&UE9&EA(&9R
M;VT@14504D]-("HO"B`@("`@("`@("`@("`@("`@<W=I=&-H("AS8RT^861A
M<'1E<E]C;F8@)B!!7T-.1E]-141)05]465!%*2!["D!`("TQ,S`W+#$Q("LQ
M,S(V+#$Q($!`"B!["B`@("`@<W1R=6-T(&-S:6YT<E]L:7-T("II;G1R.PH@
M"BT@("`@9F]R("AI;G1R/6-S:6YT<E]H96%D.R!I;G1R.R!I;G1R/6EN='(M
M/FYE>'0I('L*+0D@("`@:68@*&EN='(M/G5N:70@/3T@=6YI="D**R`@("!F
M;W(@*&EN='(]8W-I;G1R7VAE860[(&EN='([(&EN='(]:6YT<BT^;F5X="D*
M*PD@("`@:68@*&EN='(M/G5N:70@/3T@=6YI="D@>PH@"0EC<VEN=')?<V,H
M:6YT<BT^<V,L('5N:70I.PH@"0EB<F5A:SL*+0E]"BL)("`@('T*('T*(`H@
M<W1A=&EC(&-H87(@*@I`0"`M,3,W."PW("LQ,SDW+#@@0$`*("`@("!I9B`H
M(7-C*2!R971U<FX["B`*("`@("!B>F5R;RAS8RP@<VEZ96]F("IS8RD["BT@
M("`@:68@*&-S7V-S.#EX,%]P<F]B92AS8RP@)FER<2P@)F1R<2P@:6]B87-E
M+"!U;FET+"!F;&%G<RD@/3T@,`HK("`@(&EF("@H9&5V+3YI9%]A;&EV92`]
M(`HK"2!C<U]C<S@Y>#!?<')O8F4H<V,L("9I<G$L("9D<G$L(&EO8F%S92P@
M=6YI="P@9FQA9W,I*2`]/2`P"B`)?'P@8W-?871T86-H*'-C+"!U;FET+"!F
M;&%G<RD@/3T@,"D@>PH@"2`@("!F<F5E*'-C+"!-7T1%5D)51BD["B`@("`@
M?2!E;'-E('L*0$`@+3$S.3$L-B`K,30Q,2PV($!`"B`)"7!R:6YT9B@B9F%I
M;&5D('1O('!N<"!C87)D('!A<F%M971A<G-<;B(I.PH@"7T*("`@("!]"BT@
M("`@8W-I;G1R7W!N<%]A9&0H<V,L(&1E=BT^:61?=6YI="D["BL@("`@8W-I
M;G1R7W!N<%]A9&0H<V,L(&1E=BT^:61?:60I.PH@?0H@(V5N9&EF("\J($Y0
&3E`@*B\*
`
end


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->msmith 
Responsible-Changed-By: msmith 
Responsible-Changed-When: Wed Jun 23 17:54:47 PDT 1999 
Responsible-Changed-Why:  
Remind myself to work on this as 'cs' owner. 

From: Phani Gopal A V <aphani@in.ibm.com>
To: freebsd-gnats-submit@freebsd.org, max@cca.usart.ru
Cc:  
Subject: Re: kern/11507: CS89XX (i386/isa/if_cs.c) fails to properly initialize CS8920-based PnP NIC
Date: Thu, 01 Jul 1999 09:27:29 +0530

 I am using an IBM 300 GL with the onboard Crystal Lan adapter. The above
 mentioned works for me wonderfully. Why is this fix not on any stable
 release. I am currently on 3.2-RELEASE
 Thanks
 Phani
 
 

From: David La Croix <dlacroix@streams.com>
To: <freebsd-gnats-submit@FreeBSD.org>, <max@cca.usart.ru>
Cc:  
Subject: Re: kern/11507: CS89XX (i386/isa/if_cs.c) fails to properly initialize CS8920-based PnP NIC
Date: Wed, 15 Nov 2000 13:27:58 -0600

 I want to note that this bug is STILL present in FreeBSD 4.1.1-RELEASE.
 
 Can someone who knows what they're doing please review the patches submitted
 and commit the fix to 4.x-STABLE?
 
 I have a 486-33 and a couple of real IBM Etherjet ISA cards (one with an
 IBM stamped chip, and one with a Crystal Semiconductors chip) with
 10Base[25T] interfaces that is subject to this problem.
 
 Given that this card is listed as supported in the README, maybe this
 problem should be fixed for the 4.2-RELEASE?
 
 

From: David La Croix <dlacroix@streams.com>
To: <freebsd-gnats-submit@FreeBSD.org>
Cc:  
Subject: Re: kern/11507: CS89XX (i386/isa/if_cs.c) fails to properly initialize CS8920-based PnP NIC
Date: Tue, 2 Jan 2001 14:12:45 -0600

 Ok, After futzing with the patches a bit, I've determined that this driver
 doesn't work with my card for reasons other than the Checksum mismatch
 listed in the PR.  Perhaps there is a problem with the PNP code, and how it
 relates to 4.x.
 
 I personally am not familiar with the PNP code, and I'm willing to donate
 one of the problem cards to a developer who is willing to fix the problem
 for 4.x and possibly maintain the driver into the world of 5-CURRENT (and
 beyond).
 
 (The cards are worthless to me without a working driver anyway)
 
 
Responsible-Changed-From-To: msmith->imp 
Responsible-Changed-By: imp 
Responsible-Changed-When: Fri Jun 1 12:48:48 MDT 2001 
Responsible-Changed-Why:  
Mike told me a while ago he didn't have hardware to test, while I do. 

Warner 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=11507 
State-Changed-From-To: open->closed 
State-Changed-By: imp 
State-Changed-When: Mon Nov 3 18:52:53 MST 2003 
State-Changed-Why:  
This appears to be a duplicate at 11462 


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