Subject: Adding support for SN-5000TX network card
To: None <current-users@netbsd.org>
From: Martin Husemann <martin@rumolt.teuto.de>
List: current-users
Date: 01/31/1999 10:40:12
Short background: I've been give a new PC at work which uses a "Simple Net
SN-5000TX" fast ethernet card. Due to other problems deployment was delayed
and I took it home over the weekend to see if I can keep this card or have
to swap it against one supported by NetBSD (probably an Intel ether express).

I searched the web for SN-5000TX and the PCI manufacturer, MACRONIX, but
didn't find anything usefull. The only relevant hit was an article in a linux
newsgroup reporting their tulip driver has problems with this card too.

That gave me a start and I hacked our if_de.c to support this card (patch 
below). Now it almost works. I can netboot the new system:

[..]
de0 at pci0 dev 11 function 0
de0: interrupting at irq 12
de0: 21140 [10-100Mb/s] pass 1.1
de0: address 00:40:05:50:ee:9b
de0: enabling 100baseTX port
[..]
boot device: <unknown>
nfs_boot: trying DHCP/BOOTP
nfs_boot: DHCP server: 0xd408cb51
nfs_boot: my_domain=teuto.de
nfs_boot: my_addr=0xd408cb55
nfs_boot: my_mask=0xfffffff8
nfs_boot: gateway=0xd408cb51
root on rumolt.teuto.de:/a/alzey

What's wrong here is the medium - it currently runs 10baseT, but it works 
anyway. Receiving seems to be fine, but under heavy transmit load it prints

de0: abnormal interrupt: transmit underflow (raising TX threshold to 96|256)
de0: abnormal interrupt: transmit underflow (raising TX threshold to 128|512)

and then it hangs rock-solid (can't even break into the debugger).

Since I don't know anything about Tulip chips, and this board doesn't even
use an original one (only big part on the board is labeled "MX98713FC") I'm
probably the wrong person to find a solution here. So I'll swap the card,
but I'll have access to it on another PC at work, just to test drivers.

If someone likes to jump in and finish this or give me some pointers to
docs on this chip...



Martin


*** /usr/src/sys/dev/pci/if_de.c	Fri Jan 29 20:26:46 1999
--- /usr/src/sys-i4b/dev/pci/if_de.c	Sun Jan 31 10:06:18 1999
***************
*** 140,149 ****
--- 140,150 ----
  #endif
  #include <machine/bus.h>
  #include <machine/intr.h>
  #include <dev/pci/pcireg.h>
  #include <dev/pci/pcivar.h>
+ #include <dev/pci/pcidevs.h>
  #include <dev/ic/dc21040reg.h>
  #define	DEVAR_INCLUDE	"dev/pci/if_devar.h"
  #endif /* __NetBSD__ */
  
  /*
***************
*** 2842,2851 ****
--- 2843,2867 ----
  	}
      }
  
  
      if (bcmp(&sc->tulip_rombuf[0], &sc->tulip_rombuf[16], 8) != 0) {
+     	/*
+     	 * The MACRONIX board has a ROM with all zeros and the
+     	 * MAC address at offset 20
+     	 */
+     	for (idx = 0; idx < 20; idx++)
+     	    if (sc->tulip_rombuf[idx] != 0)
+     	        break;
+     	if (idx == 20) {
+     	    if (sc->tulip_rombuf[idx] == 0 && sc->tulip_rombuf[idx+1] == 0
+     	        && sc->tulip_rombuf[idx+2] == 0)
+     	            return -4;
+     	    bcopy(sc->tulip_rombuf+idx, sc->tulip_enaddr, 6);
+     	    sc->tulip_features |= TULIP_HAVE_OKROM;
+     	    return 0;
+     	}
  	/*
  	 * Some folks don't use the standard ethernet rom format
  	 * but instead just put the address in the first 6 bytes
  	 * of the rom and let the rest be all 0xffs.  (Can we say
  	 * ZNYX???) (well sometimes they put in a checksum so we'll
***************
*** 5429,5438 ****
--- 5445,5460 ----
      struct cfdata *match,
      void *aux)
  {
      struct pci_attach_args *pa = (struct pci_attach_args *) aux;
  
+     if (PCI_VENDORID(pa->pa_id) == PCI_VENDOR_MACRONIX) {
+     	if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_MACRONIX_MX98713) {
+     	   /* XXX - not yet working, experimental support */
+     	   return 1;
+     	}
+     }
      if (PCI_VENDORID(pa->pa_id) != DEC_VENDORID)
  	return 0;
      if (PCI_CHIPID(pa->pa_id) == CHIPID_21040
  	    || PCI_CHIPID(pa->pa_id) == CHIPID_21041
  	    || PCI_CHIPID(pa->pa_id) == CHIPID_21140
***************
*** 5533,5543 ****
      revinfo  = PCI_CONF_READ(PCI_CFRV) & 0xFF;
      id       = PCI_CONF_READ(PCI_CFID);
      cfdainfo = PCI_CONF_READ(PCI_CFDA);
  #endif /* __bsdi__ */
  
!     if (PCI_VENDORID(id) == DEC_VENDORID) {
  	if (PCI_CHIPID(id) == CHIPID_21040)
  		chipid = TULIP_21040;
  	else if (PCI_CHIPID(id) == CHIPID_21041)
  		chipid = TULIP_21041;
  	else if (PCI_CHIPID(id) == CHIPID_21140)
--- 5555,5568 ----
      revinfo  = PCI_CONF_READ(PCI_CFRV) & 0xFF;
      id       = PCI_CONF_READ(PCI_CFID);
      cfdainfo = PCI_CONF_READ(PCI_CFDA);
  #endif /* __bsdi__ */
  
!     if (PCI_VENDORID(id) == PCI_VENDOR_MACRONIX && PCI_PRODUCT(id) == PCI_PRODUCT_MACRONIX_MX98713) {
!         chipid = TULIP_21140;
!         revinfo = 0x11;
!     } else if (PCI_VENDORID(id) == DEC_VENDORID) {
  	if (PCI_CHIPID(id) == CHIPID_21040)
  		chipid = TULIP_21040;
  	else if (PCI_CHIPID(id) == CHIPID_21041)
  		chipid = TULIP_21041;
  	else if (PCI_CHIPID(id) == CHIPID_21140)