Subject: kern/5256: if_ne_pci: VIA Technologies VT86C926 doesn't match/attach
To: None <gnats-bugs@gnats.netbsd.org>
From: None <sakamoto@cec.co.jp>
List: netbsd-bugs
Date: 04/06/1998 13:54:29
>Number:         5256
>Category:       kern
>Synopsis:       if_ne_pci: VIA Technologies VT86C926 doesn't match/attach
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Apr  5 22:05:00 1998
>Last-Modified:
>Originator:     Kazuki Sakamoto
>Organization:
CEC
>Release:        Current(Apr 4 1998)
>Environment:
	
System: NetBSD saturn100 1.3E NetBSD 1.3E (SATURN) #1: Mon Apr 6 11:43:30 JST 1998 sakamoto@saturn100:/usr/src/sys/arch/i386/compile/SATURN i386


>Description:
	if_ne_pci driver doesn't match/attach "VIA Technologies VT86C926
	NE2000 compatible PCI ethernet card".

>How-To-Repeat:
	See if_ne_pci.c.
>Fix:

*** if_ne_pci.c.orig	Tue Jan 13 23:27:57 1998
--- if_ne_pci.c	Mon Apr  6 12:37:01 1998
***************
*** 86,91 ****
--- 86,122 ----
  	sizeof(struct ne_pci_softc), ne_pci_match, ne_pci_attach
  };
  
+ struct ne_pci_compatdev {
+ 	pci_vendor_id_t vendor;
+ 	pci_product_id_t product;
+ 	char *name;
+ };
+ 
+ struct ne_pci_compatdev ne_pci_compatdevs[] = {
+ 	{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8029, "Realtek 8029" },
+ 	{ PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W89C940F, "Winbond 89C940F" },
+ 	{ PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT86C926,
+ 		"VIA Technologies VT86C926" },
+ 	{ 0, 0, NULL },
+ };
+ 
+ char *ne_pci_lookup __P((pcireg_t));
+ 
+ char *
+ ne_pci_lookup(id)
+ 	pcireg_t id;
+ {
+ 	struct ne_pci_compatdev *nc;
+ 
+ 	for (nc = ne_pci_compatdevs; nc->vendor != 0; nc++) {
+ 		if (PCI_VENDOR(id) == nc->vendor &&
+ 		    PCI_PRODUCT(id) == nc->product)
+ 			return (nc->name);
+ 	}
+ 
+ 	return (NULL);
+ }
+ 
  /*
   * PCI constants.
   * XXX These should be in a common file!
***************
*** 104,122 ****
  {
  	struct pci_attach_args *pa = aux;
  
! 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_REALTEK) {
! 		switch (PCI_PRODUCT(pa->pa_id)) {
! 		case PCI_PRODUCT_REALTEK_RT8029:
! 			return (1);
! 		}
! 	}
! 
! 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_WINBOND) {
! 		switch (PCI_PRODUCT(pa->pa_id)) {
! 		case PCI_PRODUCT_WINBOND_W89C940F:
! 			return (1);
! 		}
! 	}
  
  	return (0);
  }
--- 135,142 ----
  {
  	struct pci_attach_args *pa = aux;
  
! 	if (ne_pci_lookup(pa->pa_id) != NULL)
! 		return (1);
  
  	return (0);
  }
***************
*** 139,160 ****
  	pci_intr_handle_t ih;
  	pcireg_t csr;
  
! 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_REALTEK) {
! 		switch (PCI_PRODUCT(pa->pa_id)) {
! 		case PCI_PRODUCT_REALTEK_RT8029:
! 			typestr = "Realtek 8029";
! 			break;
! 		}
! 	}
! 
! 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_WINBOND) {
! 		switch (PCI_PRODUCT(pa->pa_id)) {
! 		case PCI_PRODUCT_WINBOND_W89C940F:
! 			typestr = "Winbond 89C940F";
! 			break;
! 		}
! 	}
! 
  	if (typestr == NULL) {
  		printf(": unknown model?!\n");
  		return;
--- 159,165 ----
  	pci_intr_handle_t ih;
  	pcireg_t csr;
  
! 	typestr = ne_pci_lookup(pa->pa_id);
  	if (typestr == NULL) {
  		printf(": unknown model?!\n");
  		return;
>Audit-Trail:
>Unformatted: