summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>2000-04-18 18:44:32 +0000
committerJason Wright <jason@cvs.openbsd.org>2000-04-18 18:44:32 +0000
commit0ba7f186e7fdec54ca89d32522f2ef62868743d1 (patch)
treef48b4104b428a87b4bce8cbd3f386a5d0ccf28a2 /sys
parent0a95ed57a67e9a221d089c449a7d2453f2403c0d (diff)
split fxp into bus independent and dependent (pci) parts (cardbus to come)
Diffstat (limited to 'sys')
-rw-r--r--sys/conf/files7
-rw-r--r--sys/dev/ic/fxp.c (renamed from sys/dev/pci/if_fxp.c)225
-rw-r--r--sys/dev/ic/fxpreg.h (renamed from sys/dev/pci/if_fxpreg.h)2
-rw-r--r--sys/dev/ic/fxpvar.h (renamed from sys/dev/pci/if_fxpvar.h)5
-rw-r--r--sys/dev/pci/files.pci11
-rw-r--r--sys/dev/pci/if_fxp_pci.c178
6 files changed, 265 insertions, 163 deletions
diff --git a/sys/conf/files b/sys/conf/files
index 6715a328cd8..3ad86bd51db 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.157 2000/04/08 05:50:50 aaron Exp $
+# $OpenBSD: files,v 1.158 2000/04/18 18:44:22 jason Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -116,9 +116,14 @@ file dev/ic/rlnsubr.c rln
device le: ether, ifnet, ifmedia
file dev/ic/am7990.c le
+# 3Com 3c9xx
device xl: ether, ifnet, ifmedia, mii
file dev/ic/xl.c xl
+# Intel EtherExpress PRO 10/100B
+device fxp: ether, ifnet, ifmedia, mii
+file dev/ic/fxp.c fxp
+
# SMC 91Cxx Ethernet Controller
device sm: ether, ifnet, ifmedia
file dev/ic/smc91cxx.c sm
diff --git a/sys/dev/pci/if_fxp.c b/sys/dev/ic/fxp.c
index 2fa3bce3236..a5adc1da376 100644
--- a/sys/dev/pci/if_fxp.c
+++ b/sys/dev/ic/fxp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_fxp.c,v 1.26 2000/04/18 03:40:55 jason Exp $ */
+/* $OpenBSD: fxp.c,v 1.1 2000/04/18 18:44:26 jason Exp $ */
/* $NetBSD: if_fxp.c,v 1.2 1997/06/05 02:01:55 thorpej Exp $ */
/*
@@ -88,8 +88,8 @@
#include <dev/mii/miivar.h>
-#include <dev/pci/if_fxpreg.h>
-#include <dev/pci/if_fxpvar.h>
+#include <dev/ic/fxpreg.h>
+#include <dev/ic/fxpvar.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
@@ -173,7 +173,6 @@ struct fxp_supported_media {
int fxp_mediachange __P((struct ifnet *));
void fxp_mediastatus __P((struct ifnet *, struct ifmediareq *));
static inline void fxp_scb_wait __P((struct fxp_softc *));
-int fxp_intr __P((void *));
void fxp_start __P((struct ifnet *));
int fxp_ioctl __P((struct ifnet *, u_long, caddr_t));
void fxp_init __P((void *));
@@ -186,8 +185,6 @@ void fxp_autosize_eeprom __P((struct fxp_softc *));
void fxp_statchg __P((struct device *));
void fxp_read_eeprom __P((struct fxp_softc *, u_int16_t *,
int, int));
-int fxp_attach_common __P((struct fxp_softc *, u_int8_t *));
-
void fxp_stats_update __P((void *));
void fxp_mc_setup __P((struct fxp_softc *));
@@ -250,7 +247,6 @@ fxp_scb_wait(sc)
* Operating system-specific autoconfiguration glue
*************************************************************/
-int fxp_match __P((struct device *, void *, void *));
void fxp_attach __P((struct device *, struct device *, void *));
void fxp_shutdown __P((void *));
@@ -260,157 +256,11 @@ void fxp_power __P((int, void *));
int fxp_ether_ioctl __P((struct ifnet *, u_long, caddr_t));
#define ether_ioctl fxp_ether_ioctl
-struct cfattach fxp_ca = {
- sizeof(struct fxp_softc), fxp_match, fxp_attach
-};
-
struct cfdriver fxp_cd = {
NULL, "fxp", DV_IFNET
};
/*
- * Check if a device is an 82557.
- */
-int
-fxp_match(parent, match, aux)
- struct device *parent;
- void *match;
- void *aux;
-{
- struct pci_attach_args *pa = aux;
-
- if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL)
- return (0);
-
- switch (PCI_PRODUCT(pa->pa_id)) {
- case PCI_PRODUCT_INTEL_82557:
- case PCI_PRODUCT_INTEL_82559:
- return (1);
- }
-
- return (0);
-}
-
-void
-fxp_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct fxp_softc *sc = (struct fxp_softc *)self;
- struct pci_attach_args *pa = aux;
- pci_chipset_tag_t pc = pa->pa_pc;
- pci_intr_handle_t ih;
- const char *intrstr = NULL;
- u_int8_t enaddr[6];
- struct ifnet *ifp;
- bus_space_tag_t iot = pa->pa_iot;
- bus_addr_t iobase;
- bus_size_t iosize;
-
- if (pci_io_find(pc, pa->pa_tag, FXP_PCI_IOBA, &iobase, &iosize)) {
- printf(": can't find i/o space\n");
- return;
- }
-
- if (bus_space_map(iot, iobase, iosize, 0, &sc->sc_sh)) {
- printf(": can't map i/o space\n");
- return;
- }
- sc->sc_st = iot;
-
- /*
- * Allocate our interrupt.
- */
- if (pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
- pa->pa_intrline, &ih)) {
- printf(": couldn't map interrupt\n");
- return;
- }
-
- intrstr = pci_intr_string(pc, ih);
- sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, fxp_intr, sc,
- self->dv_xname);
- if (sc->sc_ih == NULL) {
- printf(": couldn't establish interrupt");
- if (intrstr != NULL)
- printf(" at %s", intrstr);
- printf("\n");
- return;
- }
-
- /* Do generic parts of attach. */
- if (fxp_attach_common(sc, enaddr)) {
- /* Failed! */
- return;
- }
-
-
- ifp = &sc->arpcom.ac_if;
- bcopy(enaddr, sc->arpcom.ac_enaddr, sizeof(enaddr));
- bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
- ifp->if_softc = sc;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = fxp_ioctl;
- ifp->if_start = fxp_start;
- ifp->if_watchdog = fxp_watchdog;
-
- printf(": %s, address %s\n", intrstr,
- ether_sprintf(sc->arpcom.ac_enaddr));
-
- /*
- * Initialize our media structures and probe the MII.
- */
- sc->sc_mii.mii_ifp = ifp;
- sc->sc_mii.mii_readreg = fxp_mdi_read;
- sc->sc_mii.mii_writereg = fxp_mdi_write;
- sc->sc_mii.mii_statchg = fxp_statchg;
- ifmedia_init(&sc->sc_mii.mii_media, 0, fxp_mediachange,
- fxp_mediastatus);
- mii_phy_probe(self, &sc->sc_mii, 0xffffffff);
- /* If no phy found, just use auto mode */
- if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
- ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_MANUAL,
- 0, NULL);
- printf("%s: no phy found, using manual mode\n",
- sc->sc_dev.dv_xname);
- }
-
- if (ifmedia_match(&sc->sc_mii.mii_media, IFM_ETHER|IFM_MANUAL, 0))
- ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_MANUAL);
- else if (ifmedia_match(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO, 0))
- ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
- else
- ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T);
-
- /*
- * Attach the interface.
- */
- if_attach(ifp);
- /*
- * Let the system queue as many packets as we have available
- * TX descriptors.
- */
- ifp->if_snd.ifq_maxlen = FXP_NTXCB - 1;
- ether_ifattach(ifp);
-#if NBPFILTER > 0
- bpfattach(&sc->arpcom.ac_if.if_bpf, ifp, DLT_EN10MB,
- sizeof(struct ether_header));
-#endif
-
- /*
- * Add shutdown hook so that DMA is disabled prior to reboot. Not
- * doing do could allow DMA to corrupt kernel memory during the
- * reboot before the driver initializes.
- */
- shutdownhook_establish(fxp_shutdown, sc);
-
- /*
- * Add suspend hook, for similiar reasons..
- */
- powerhook_establish(fxp_power, sc);
-}
-
-/*
* Device shutdown routine. Called at system shutdown after sync. The
* main purpose of this routine is to shut off receiver DMA so that
* kernel memory doesn't get clobbered during warmboot.
@@ -505,10 +355,12 @@ fxp_ether_ioctl(ifp, cmd, data)
* Do generic parts of attach.
*/
int
-fxp_attach_common(sc, enaddr)
+fxp_attach_common(sc, enaddr, intrstr)
struct fxp_softc *sc;
u_int8_t *enaddr;
+ const char *intrstr;
{
+ struct ifnet *ifp;
u_int16_t data;
int i;
@@ -558,6 +410,71 @@ fxp_attach_common(sc, enaddr)
* Read MAC address.
*/
fxp_read_eeprom(sc, (u_int16_t *)enaddr, 0, 3);
+
+ ifp = &sc->arpcom.ac_if;
+ bcopy(enaddr, sc->arpcom.ac_enaddr, sizeof(enaddr));
+ bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
+ ifp->if_softc = sc;
+ ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+ ifp->if_ioctl = fxp_ioctl;
+ ifp->if_start = fxp_start;
+ ifp->if_watchdog = fxp_watchdog;
+
+ printf(": %s, address %s\n", intrstr,
+ ether_sprintf(sc->arpcom.ac_enaddr));
+
+ /*
+ * Initialize our media structures and probe the MII.
+ */
+ sc->sc_mii.mii_ifp = ifp;
+ sc->sc_mii.mii_readreg = fxp_mdi_read;
+ sc->sc_mii.mii_writereg = fxp_mdi_write;
+ sc->sc_mii.mii_statchg = fxp_statchg;
+ ifmedia_init(&sc->sc_mii.mii_media, 0, fxp_mediachange,
+ fxp_mediastatus);
+ mii_phy_probe(&sc->sc_dev, &sc->sc_mii, 0xffffffff);
+ /* If no phy found, just use auto mode */
+ if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+ ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_MANUAL,
+ 0, NULL);
+ printf("%s: no phy found, using manual mode\n",
+ sc->sc_dev.dv_xname);
+ }
+
+ if (ifmedia_match(&sc->sc_mii.mii_media, IFM_ETHER|IFM_MANUAL, 0))
+ ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_MANUAL);
+ else if (ifmedia_match(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO, 0))
+ ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
+ else
+ ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T);
+
+ /*
+ * Attach the interface.
+ */
+ if_attach(ifp);
+ /*
+ * Let the system queue as many packets as we have available
+ * TX descriptors.
+ */
+ ifp->if_snd.ifq_maxlen = FXP_NTXCB - 1;
+ ether_ifattach(ifp);
+#if NBPFILTER > 0
+ bpfattach(&sc->arpcom.ac_if.if_bpf, ifp, DLT_EN10MB,
+ sizeof(struct ether_header));
+#endif
+
+ /*
+ * Add shutdown hook so that DMA is disabled prior to reboot. Not
+ * doing do could allow DMA to corrupt kernel memory during the
+ * reboot before the driver initializes.
+ */
+ shutdownhook_establish(fxp_shutdown, sc);
+
+ /*
+ * Add suspend hook, for similiar reasons..
+ */
+ powerhook_establish(fxp_power, sc);
+
return (0);
fail:
diff --git a/sys/dev/pci/if_fxpreg.h b/sys/dev/ic/fxpreg.h
index 38a2ac5fe2e..68cbd61b047 100644
--- a/sys/dev/pci/if_fxpreg.h
+++ b/sys/dev/ic/fxpreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_fxpreg.h,v 1.5 1998/07/02 21:15:46 downsj Exp $ */
+/* $OpenBSD: fxpreg.h,v 1.1 2000/04/18 18:44:27 jason Exp $ */
/*
* Copyright (c) 1995, David Greenman
diff --git a/sys/dev/pci/if_fxpvar.h b/sys/dev/ic/fxpvar.h
index 783a0912aee..4918342a218 100644
--- a/sys/dev/pci/if_fxpvar.h
+++ b/sys/dev/ic/fxpvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_fxpvar.h,v 1.8 2000/04/18 03:40:55 jason Exp $ */
+/* $OpenBSD: fxpvar.h,v 1.1 2000/04/18 18:44:27 jason Exp $ */
/* $NetBSD: if_fxpvar.h,v 1.1 1997/06/05 02:01:58 thorpej Exp $ */
/*
@@ -78,3 +78,6 @@ struct fxp_softc {
bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val))
#define CSR_WRITE_4(sc, reg, val) \
bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
+
+extern int fxp_intr __P((void *));
+extern int fxp_attach_common __P((struct fxp_softc *, u_int8_t *, const char *));
diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci
index 16aed13dada..bda71e4342c 100644
--- a/sys/dev/pci/files.pci
+++ b/sys/dev/pci/files.pci
@@ -1,4 +1,4 @@
-# $OpenBSD: files.pci,v 1.70 2000/04/13 00:10:52 csapuntz Exp $
+# $OpenBSD: files.pci,v 1.71 2000/04/18 18:44:31 jason Exp $
# $NetBSD: files.pci,v 1.20 1996/09/24 17:47:15 christos Exp $
#
# Config file and device description for machine-independent PCI code.
@@ -130,11 +130,6 @@ file dev/pci/if_lmc_common.c lmc
file dev/pci/if_lmc_media.c lmc
file dev/pci/if_lmc_obsd.c lmc
-# Intel EtherExpress PRO 10/100B
-device fxp: ether, ifnet, mii, ifmedia
-attach fxp at pci
-file dev/pci/if_fxp.c fxp
-
# RealTek 8129/8139
device rl: ether, ifnet, mii, ifmedia
attach rl at pci
@@ -169,6 +164,10 @@ file dev/pci/brooktree848.c bktr needs-count
attach xl at pci with xl_pci
file dev/pci/if_xl_pci.c xl_pci
+# Intel EtherExpress PRO 10/100B
+attach fxp at pci with fxp_pci
+file dev/pci/if_fxp_pci.c fxp_pci
+
# SMC EPIC, 83c170
device tx: ether, ifnet, ifmedia
attach tx at pci
diff --git a/sys/dev/pci/if_fxp_pci.c b/sys/dev/pci/if_fxp_pci.c
new file mode 100644
index 00000000000..61b4aa1d0fc
--- /dev/null
+++ b/sys/dev/pci/if_fxp_pci.c
@@ -0,0 +1,178 @@
+/* $OpenBSD: if_fxp_pci.c,v 1.1 2000/04/18 18:44:31 jason Exp $ */
+
+/*
+ * Copyright (c) 1995, David Greenman
+ * All rights reserved.
+ *
+ * Modifications to support NetBSD:
+ * Copyright (c) 1997 Jason R. Thorpe. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Id: if_fxp.c,v 1.55 1998/08/04 08:53:12 dg Exp
+ */
+
+/*
+ * Intel EtherExpress Pro/100B PCI Fast Ethernet driver
+ */
+
+#include "bpfilter.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/syslog.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_types.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#endif
+
+#ifdef IPX
+#include <netipx/ipx.h>
+#include <netipx/ipx_if.h>
+#endif
+
+#ifdef NS
+#include <netns/ns.h>
+#include <netns/ns_if.h>
+#endif
+
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#include <net/bpfdesc.h>
+#endif
+
+#include <sys/ioctl.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+
+#include <netinet/if_ether.h>
+
+#include <vm/vm.h>
+
+#include <machine/cpu.h>
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/mii/miivar.h>
+
+#include <dev/ic/fxpreg.h>
+#include <dev/ic/fxpvar.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcidevs.h>
+
+int fxp_pci_match __P((struct device *, void *, void *));
+void fxp_pci_attach __P((struct device *, struct device *, void *));
+
+struct cfattach fxp_pci_ca = {
+ sizeof(struct fxp_softc), fxp_pci_match, fxp_pci_attach
+};
+
+/*
+ * Check if a device is an 82557.
+ */
+int
+fxp_pci_match(parent, match, aux)
+ struct device *parent;
+ void *match;
+ void *aux;
+{
+ struct pci_attach_args *pa = aux;
+
+ if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL)
+ return (0);
+
+ switch (PCI_PRODUCT(pa->pa_id)) {
+ case PCI_PRODUCT_INTEL_82557:
+ case PCI_PRODUCT_INTEL_82559:
+ return (1);
+ }
+
+ return (0);
+}
+
+void
+fxp_pci_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct fxp_softc *sc = (struct fxp_softc *)self;
+ struct pci_attach_args *pa = aux;
+ pci_chipset_tag_t pc = pa->pa_pc;
+ pci_intr_handle_t ih;
+ const char *intrstr = NULL;
+ u_int8_t enaddr[6];
+ bus_space_tag_t iot = pa->pa_iot;
+ bus_addr_t iobase;
+ bus_size_t iosize;
+
+ if (pci_io_find(pc, pa->pa_tag, FXP_PCI_IOBA, &iobase, &iosize)) {
+ printf(": can't find i/o space\n");
+ return;
+ }
+
+ if (bus_space_map(iot, iobase, iosize, 0, &sc->sc_sh)) {
+ printf(": can't map i/o space\n");
+ return;
+ }
+ sc->sc_st = iot;
+
+ /*
+ * Allocate our interrupt.
+ */
+ if (pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
+ pa->pa_intrline, &ih)) {
+ printf(": couldn't map interrupt\n");
+ return;
+ }
+
+ intrstr = pci_intr_string(pc, ih);
+ sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, fxp_intr, sc,
+ self->dv_xname);
+ if (sc->sc_ih == NULL) {
+ printf(": couldn't establish interrupt");
+ if (intrstr != NULL)
+ printf(" at %s", intrstr);
+ printf("\n");
+ return;
+ }
+
+ /* Do generic parts of attach. */
+ if (fxp_attach_common(sc, enaddr, intrstr)) {
+ /* Failed! */
+ return;
+ }
+}