Subject: kern/6852: patch for COMDEX 4-port TULIP boards
To: None <gnats-bugs@gnats.netbsd.org>
From: Chris Jones <cjones@hideo.nervana.montana.edu>
List: netbsd-bugs
Date: 01/19/1999 14:01:26
>Number:         6852
>Category:       kern
>Synopsis:       patch for COMDEX 4-port TULIP boards
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 19 13:35:00 1999
>Last-Modified:
>Originator:     Chris Jones
>Organization:
Center for Computational Biology, Montana State University
>Release:        Jan. 18, 1999
>Environment:
	
System: NetBSD hideo 1.3I NetBSD 1.3I (HIDEO) #1: Tue Dec 1 14:02:08 MST 1998 root@hideo:/usr/src/sys/arch/i386/compile/HIDEO i386


>Description:
As discussed on current-users and port-i386, I have two 4-port TULIP
boards made by COMDEX, and they don't work correctly.  Each board
responds only on the first channel; the others lock up the machine
when ifconfig'ed.

>How-To-Repeat:
See above.

>Fix:
Matt was right; it's an interrupt sharing problem.  This patch fixes
the problem, but it has one buglet:  There's no newline printed after
"de* at pci? dev ? function ?".  I'm sure that somebody more familiar
with the kernel than I am can fix that.

*** if_de.c.old	Tue Jan 19 11:10:24 1999
--- if_de.c	Tue Jan 19 13:55:42 1999
***************
*** 1,4 ****
- /*	$NetBSD: if_de.c,v 1.81 1998/11/09 23:41:14 matt Exp $	*/
  
  /*-
   * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
--- 1,3 ----
***************
*** 2372,2377 ****
--- 2371,2415 ----
      }
  }
  
+ static void
+ tulip_identify_compex_nic(
+     tulip_softc_t * const sc)
+ {
+     strcpy(sc->tulip_boardid, "COMPEX ");
+     if (sc->tulip_chipid == TULIP_21140A) {
+ 	int root_unit;
+ 	tulip_softc_t *root_sc = NULL;
+ 
+ 	strcat(sc->tulip_boardid, "400TX/PCI ");
+ 	/*
+ 	 * All 4 chips on these boards share an interrupt.  This code
+ 	 * copied from tulip_read_macaddr.
+ 	 */
+ 	sc->tulip_features |= TULIP_HAVE_SHAREDINTR;
+ 	for (root_unit = sc->tulip_unit - 1; root_unit >= 0; root_unit--) {
+ 	    root_sc = TULIP_UNIT_TO_SOFTC(root_unit);
+ 	    if (root_sc == NULL
+ 		|| !(root_sc->tulip_features & TULIP_HAVE_SLAVEDINTR))
+ 		break;
+ 	    root_sc = NULL;
+ 	}
+ 	if (root_sc != NULL
+ 	    && root_sc->tulip_chipid == sc->tulip_chipid
+ 	    && root_sc->tulip_pci_busno == sc->tulip_pci_busno) {
+ 	    sc->tulip_features |= TULIP_HAVE_SLAVEDINTR;
+ 	    sc->tulip_slaves = root_sc->tulip_slaves;
+ 	    root_sc->tulip_slaves = sc;
+ 	} else if(sc->tulip_features & TULIP_HAVE_SLAVEDINTR) {
+ 	    printf("\nCannot find master device for de%d interrupts",
+ 		   sc->tulip_unit);
+ 	}
+     } else {
+ 	strcat(sc->tulip_boardid, "unknown ");
+     }
+     /*      sc->tulip_boardsw = &tulip_21140_eb_boardsw; */
+     return;
+ }
+ 
  static int
  tulip_srom_decode(
      tulip_softc_t * const sc)
***************
*** 2746,2751 ****
--- 2784,2790 ----
      { tulip_identify_cogent_nic,	{ 0x00, 0x00, 0x92 } },
      { tulip_identify_asante_nic,	{ 0x00, 0x00, 0x94 } },
      { tulip_identify_accton_nic,	{ 0x00, 0x00, 0xE8 } },
+     { tulip_identify_compex_nic,        { 0x00, 0x80, 0x48 } },
      { NULL }
  };
  
***************
*** 2800,2806 ****
  	     * it's the best we can do until every one switches to
  	     * the new SROM format.
  	     */
! 	     
  	    sc->tulip_boardsw = &tulip_21140_eb_boardsw;
  	}
  	tulip_srom_read(sc);
--- 2839,2845 ----
  	     * it's the best we can do until every one switches to
  	     * the new SROM format.
  	     */
! 
  	    sc->tulip_boardsw = &tulip_21140_eb_boardsw;
  	}
  	tulip_srom_read(sc);
>Audit-Trail:
>Unformatted: