Subject: kern/20063: PCI wireless network driver source development limitation
To: None <gnats-bugs@gnats.netbsd.org>
From: None <gremlin@glasseye.bag.plethora.net>
List: netbsd-bugs
Date: 01/26/2003 03:13:19
>Number: 20063
>Category: kern
>Synopsis: PCI wireless network driver does not support adding chipsets.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Jan 26 01:14:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: T. M. Pederson
>Release: NetBSD-current (2003-01-25), NetBSD 1.6_STABLE
>Organization:
Plethora . Net
>Environment:
System: NetBSD ariel.plethora.net 1.6_STABLE NetBSD 1.6_STABLE (ARIEL) #0: Wed Oct 23 18:33:58 CDT 2002 gremlin@ariel.plethora.net:/usr/src/sys/arch/i386/compile/ARIEL i386
Architecture: i386
Machine: i386
>Description:
The current structure of the source in sys/dev/pci/if_wi_pci.c
uses boolean tests to distinguish between chipsets, which limits
the ease of adding support for additional chipsets.
>How-To-Repeat:
Attempt to add support for a wireless pci chipset.
>Fix:
Change to a switch/case structure.
Patch for -current (2003-01-25) included.
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# patch-wi_pci
#
echo x - patch-wi_pci
sed 's/^X//' >patch-wi_pci << 'END-of-patch-wi_pci'
X+++ sys/dev/pci/if_wi_pci.c Sat Jan 25 21:45:30 2003
X@@ -1,4 +1,4 @@
X+/* $NetBSD: if_wi_pci.c,v 1.16a 2003/01/26 07:46:49 gremlin Exp $ */
X
X /*-
X * Copyright (c) 2001 The NetBSD Foundation, Inc.
X@@ -78,6 +78,8 @@
X #define WI_PLX_COR_OFFSET 0x3E0
X #define WI_PLX_COR_VALUE 0x41
X
X+enum { WPP_ISA, WPP_PLX };
X+
X struct wi_pci_softc {
X struct wi_softc psc_wi; /* real "wi" softc */
X
X@@ -105,20 +107,20 @@
X pci_vendor_id_t wpp_vendor; /* vendor ID */
X pci_product_id_t wpp_product; /* product ID */
X const char *wpp_name; /* product name */
X- int wpp_plx; /* uses PLX chip */
X+ int wpp_chip; /* chipset used */
X } wi_pci_products[] = {
X { PCI_VENDOR_GLOBALSUN, PCI_PRODUCT_GLOBALSUN_GL24110P,
X- NULL, 1 },
X+ NULL, WPP_PLX },
X { PCI_VENDOR_GLOBALSUN, PCI_PRODUCT_GLOBALSUN_GL24110P02,
X- NULL, 1 },
X+ NULL, WPP_PLX },
X { PCI_VENDOR_EUMITCOM, PCI_PRODUCT_EUMITCOM_WL11000P,
X- NULL, 1 },
X+ NULL, WPP_PLX },
X { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CRWE777A,
X- NULL, 1 },
X+ NULL, WPP_PLX },
X { PCI_VENDOR_NETGEAR, PCI_PRODUCT_NETGEAR_MA301,
X- NULL, 1 },
X+ NULL, WPP_PLX },
X { PCI_VENDOR_INTERSIL, PCI_PRODUCT_INTERSIL_MINI_PCI_WLAN,
X- "Intersil Prism2.5", 0 },
X+ "Intersil Prism2.5", WPP_ISA },
X { 0, 0,
X NULL, 0},
X };
X@@ -239,7 +241,8 @@
X }
X #endif
X
X- if (wpp->wpp_plx) {
X+ switch (wpp->wpp_chip) {
X+ case WPP_PLX:
X /* Map memory and I/O registers. */
X if (pci_mapreg_map(pa, WI_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0,
X &memt, &memh, NULL, NULL) != 0) {
X@@ -251,7 +254,9 @@
X printf(": can't map I/O space\n");
X return;
X }
X- } else {
X+ break;
X+
X+ case WPP_ISA:
X if (pci_mapreg_map(pa, WI_PCI_CBMA,
X PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
X 0, &iot, &ioh, NULL, NULL) != 0) {
X@@ -262,6 +267,11 @@
X memt = iot;
X memh = ioh;
X sc->sc_pci = 1;
X+ break;
X+
X+ default:
X+ printf(": unknown model!\n");
X+ return;
X }
X
X if (wpp->wpp_name != NULL) {
X@@ -304,16 +314,26 @@
X
X printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
X
X- if (wpp->wpp_plx) {
X+ switch (wpp->wpp_chip) {
X+ case WPP_PLX:
X /*
X * Setup the PLX chip for level interrupts and config index 1
X * XXX - should really reset the PLX chip too.
X */
X bus_space_write_1(memt, memh,
X WI_PLX_COR_OFFSET, WI_PLX_COR_VALUE);
X- } else {
X+ break;
X+
X+ case WPP_ISA:
X /* reset HFA3842 MAC core */
X wi_pci_reset(sc);
X+ break;
X+
X+ default:
X+ /* This should be a 'can't happen' condition. */
X+ printf(": unknown chipset!\n");
X+ pci_intr_disestablish(pa->pa_pc, sc->sc_ih);
X+ return;
X }
X
X printf("%s:", sc->sc_dev.dv_xname);
END-of-patch-wi_pci
exit
>Release-Note:
>Audit-Trail:
>Unformatted: