diff options
Diffstat (limited to 'sys/dev/pci/if_de.c')
-rw-r--r-- | sys/dev/pci/if_de.c | 95 |
1 files changed, 54 insertions, 41 deletions
diff --git a/sys/dev/pci/if_de.c b/sys/dev/pci/if_de.c index aefcf00fc41..6c85de4952b 100644 --- a/sys/dev/pci/if_de.c +++ b/sys/dev/pci/if_de.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_de.c,v 1.8 1996/05/07 07:38:29 deraadt Exp $ */ -/* $NetBSD: if_de.c,v 1.18 1996/05/03 17:32:20 christos Exp $ */ +/* $OpenBSD: if_de.c,v 1.9 1996/05/10 12:41:24 deraadt Exp $ */ +/* $NetBSD: if_de.c,v 1.19 1996/05/07 02:17:18 thorpej Exp $ */ /*- * Copyright (c) 1994, 1995 Matt Thomas (matt@lkg.dec.com) @@ -317,6 +317,7 @@ struct _tulip_softc_t { bus_io_handle_t tulip_memh; /* memory region handle */ #endif #endif + char tulip_xname[IFNAMSIZ]; /* name + unit number */ struct arpcom tulip_ac; tulip_regfile_t tulip_csrs; unsigned tulip_flags; @@ -366,6 +367,7 @@ typedef void ifnet_ret_t; typedef int ioctl_cmd_t; tulip_softc_t *tulips[NDE]; #define TULIP_UNIT_TO_SOFTC(unit) (tulips[unit]) +#define TULIP_IFP_TO_SOFTC(ifp) (TULIP_UNIT_TO_SOFTC((ifp)->if_unit)) #define TULIP_BURSTSIZE(unit) pci_max_burst_len #endif #if defined(__bsdi__) @@ -373,6 +375,7 @@ typedef int ifnet_ret_t; typedef int ioctl_cmd_t; extern struct cfdriver decd; #define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) decd.cd_devs[unit]) +#define TULIP_IFP_TO_SOFTC(ifp) (TULIP_UNIT_TO_SOFTC((ifp)->if_unit)) #define TULIP_BURSTSIZE(unit) log2_burst_size #endif #if defined(__NetBSD__) @@ -381,6 +384,7 @@ typedef u_long ioctl_cmd_t; extern struct cfattach de_ca; extern struct cfdriver de_cd; #define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) de_cd.cd_devs[unit]) +#define TULIP_IFP_TO_SOFTC(ifp) ((tulip_softc_t *)((ifp)->if_softc)) #endif #ifndef TULIP_BURSTSIZE @@ -388,8 +392,13 @@ extern struct cfdriver de_cd; #endif #define tulip_if tulip_ac.ac_if +#ifdef __NetBSD__ +#define tulip_unit tulip_dev.dv_unit +#define tulip_name tulip_dev.dv_cfdata->cf_driver->cd_name +#else #define tulip_unit tulip_ac.ac_if.if_unit #define tulip_name tulip_ac.ac_if.if_name +#endif #define tulip_bpf tulip_ac.ac_if.if_bpf #define tulip_hwaddr tulip_ac.ac_enaddr @@ -440,14 +449,12 @@ tulip_dc21040_media_select( TULIP_WRITE_CSR(sc, csr_sia_connectivity, TULIP_SIACONN_RESET); if (sc->tulip_if.if_flags & IFF_ALTPHYS) { if ((sc->tulip_flags & TULIP_ALTPHYS) == 0) - printf("%s%d: enabling Thinwire/AUI port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); + printf("%s: enabling Thinwire/AUI port\n", sc->tulip_xname); TULIP_WRITE_CSR(sc, csr_sia_connectivity, TULIP_SIACONN_AUI); sc->tulip_flags |= TULIP_ALTPHYS; } else { if (sc->tulip_flags & TULIP_ALTPHYS) - printf("%s%d: enabling 10baseT/UTP port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); + printf("%s: enabling 10baseT/UTP port\n", sc->tulip_xname); TULIP_WRITE_CSR(sc, csr_sia_connectivity, TULIP_SIACONN_10BASET); sc->tulip_flags &= ~TULIP_ALTPHYS; sc->tulip_media = TULIP_MEDIA_10BASET; @@ -478,8 +485,7 @@ tulip_zx314_media_select( |TULIP_CMD_BACKOFFCTR; TULIP_WRITE_CSR(sc, csr_sia_connectivity, TULIP_SIACONN_RESET); if (sc->tulip_flags & TULIP_ALTPHYS) - printf("%s%d: enabling 10baseT/UTP port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); + printf("%s: enabling 10baseT/UTP port\n", sc->tulip_xname); TULIP_WRITE_CSR(sc, csr_sia_connectivity, TULIP_SIACONN_10BASET); sc->tulip_flags &= ~TULIP_ALTPHYS; sc->tulip_media = TULIP_MEDIA_10BASET; @@ -525,8 +531,7 @@ tulip_dc21140_evalboard_media_select( TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_EB_INIT); if (sc->tulip_if.if_flags & IFF_ALTPHYS) { if ((sc->tulip_flags & TULIP_ALTPHYS) == 0) - printf("%s%d: enabling 100baseTX UTP port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); + printf("%s: enabling 100baseTX UTP port\n", sc->tulip_xname); sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT |TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER; sc->tulip_cmdmode &= ~TULIP_CMD_TXTHRSHLDCTL; @@ -534,8 +539,7 @@ tulip_dc21140_evalboard_media_select( sc->tulip_media = TULIP_MEDIA_100BASET; } else { if (sc->tulip_flags & TULIP_ALTPHYS) - printf("%s%d: enabling 10baseT UTP port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); + printf("%s: enabling 10baseT UTP port\n", sc->tulip_xname); sc->tulip_cmdmode &= ~(TULIP_CMD_PORTSELECT |TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER); sc->tulip_cmdmode |= TULIP_CMD_TXTHRSHLDCTL; @@ -579,8 +583,7 @@ tulip_dc21140_cogent_em100_media_select( TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_EM100_PINS); TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_EM100_INIT); if ((sc->tulip_flags & TULIP_ALTPHYS) == 0) - printf("%s%d: enabling 100baseTX UTP port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); + printf("%s: enabling 100baseTX UTP port\n", sc->tulip_xname); sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT |TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER; sc->tulip_cmdmode &= ~TULIP_CMD_TXTHRSHLDCTL; @@ -627,8 +630,7 @@ tulip_dc21140_znyx_zx34x_media_select( TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_ZX34X_INIT); if (sc->tulip_if.if_flags & IFF_ALTPHYS) { if ((sc->tulip_flags & TULIP_ALTPHYS) == 0) - printf("%s%d: enabling 100baseTX UTP port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); + printf("%s: enabling 100baseTX UTP port\n", sc->tulip_xname); sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT |TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER; sc->tulip_cmdmode &= ~TULIP_CMD_TXTHRSHLDCTL; @@ -636,8 +638,7 @@ tulip_dc21140_znyx_zx34x_media_select( sc->tulip_media = TULIP_MEDIA_100BASET; } else { if (sc->tulip_flags & TULIP_ALTPHYS) - printf("%s%d: enabling 10baseT UTP port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); + printf("%s: enabling 10baseT UTP port\n", sc->tulip_xname); sc->tulip_cmdmode &= ~(TULIP_CMD_PORTSELECT |TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER); sc->tulip_cmdmode |= TULIP_CMD_TXTHRSHLDCTL; @@ -689,8 +690,7 @@ tulip_dc21140_de500_media_select( TULIP_WRITE_CSR(sc, csr_gp, TULIP_GP_DE500_PINS); if (sc->tulip_if.if_flags & IFF_ALTPHYS) { if ((sc->tulip_flags & TULIP_ALTPHYS) == 0) - printf("%s%d: enabling 100baseTX UTP port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); + printf("%s: enabling 100baseTX UTP port\n", sc->tulip_xname); sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT |TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER; sc->tulip_cmdmode &= ~TULIP_CMD_TXTHRSHLDCTL; @@ -700,8 +700,7 @@ tulip_dc21140_de500_media_select( TULIP_GP_DE500_HALFDUPLEX|TULIP_GP_DE500_FORCE_100); } else { if (sc->tulip_flags & TULIP_ALTPHYS) - printf("%s%d: enabling 10baseT UTP port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); + printf("%s: enabling 10baseT UTP port\n", sc->tulip_xname); sc->tulip_cmdmode &= ~(TULIP_CMD_PORTSELECT |TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER); sc->tulip_cmdmode |= TULIP_CMD_TXTHRSHLDCTL; @@ -827,8 +826,7 @@ tulip_dc21041_media_select( && sc->tulip_media != TULIP_MEDIA_AUI) || (sc->tulip_probe_state == TULIP_PROBE_BNC && sc->tulip_media != TULIP_MEDIA_AUI)) { - printf("%s%d: enabling %s port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit, + printf("%s: enabling %s port\n", sc->tulip_xname, sc->tulip_probe_state == TULIP_PROBE_BNC ? "Thinwire/BNC" : "AUI"); if (sc->tulip_probe_state == TULIP_PROBE_AUI) @@ -888,8 +886,8 @@ tulip_dc21041_media_select( sc->tulip_flags &= ~TULIP_WANTRXACT; sc->tulip_gpticks = 4; } else { - printf("%s%d: autosense failed: cable problem?\n", - sc->tulip_name, sc->tulip_unit); + printf("%s: autosense failed: cable problem?\n", + sc->tulip_xname); } } /* @@ -920,8 +918,7 @@ tulip_dc21041_media_select( * proper media to use. */ if (sc->tulip_media != TULIP_MEDIA_10BASET) - printf("%s%d: enabling 10baseT/UTP port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); + printf("%s: enabling 10baseT/UTP port\n", sc->tulip_xname); if (sc->tulip_media != TULIP_MEDIA_10BASET || (sc->tulip_flags & TULIP_INRESET)) { sc->tulip_media = TULIP_MEDIA_10BASET; @@ -1282,7 +1279,7 @@ static ifnet_ret_t tulip_start( struct ifnet * const ifp) { - tulip_softc_t * const sc = TULIP_UNIT_TO_SOFTC(ifp->if_unit); + tulip_softc_t * const sc = TULIP_IFP_TO_SOFTC(ifp); struct ifqueue * const ifq = &ifp->if_snd; tulip_ringinfo_t * const ri = &sc->tulip_txinfo; struct mbuf *m, *m0, *next_m0; @@ -1514,8 +1511,8 @@ tulip_intr( } } if (csr & TULIP_STS_ABNRMLINTR) { - printf("%s%d: abnormal interrupt: 0x%05x [0x%05x]\n", - sc->tulip_name, sc->tulip_unit, csr, csr & sc->tulip_intrmask); + printf("%s: abnormal interrupt: 0x%05x [0x%05x]\n", + sc->tulip_xname, csr, csr & sc->tulip_intrmask); TULIP_WRITE_CSR(sc, csr_command, sc->tulip_cmdmode); } if (csr & TULIP_STS_RXINTR) @@ -1930,7 +1927,7 @@ tulip_ioctl( ioctl_cmd_t cmd, caddr_t data) { - tulip_softc_t * const sc = TULIP_UNIT_TO_SOFTC(ifp->if_unit); + tulip_softc_t * const sc = TULIP_IFP_TO_SOFTC(ifp); struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; @@ -2048,15 +2045,22 @@ tulip_attach( ifp->if_start = tulip_start; #if defined(__FreeBSD__) - printf("%s%d", sc->tulip_name, sc->tulip_unit); + printf("%s", sc->tulip_xname); #elif defined(__bsdi__) - printf("\n%s%d", sc->tulip_name, sc->tulip_unit); + printf("\n%s", sc->tulip_xname); #endif +#if defined(__NetBSD__) + printf(": %s%s pass %d.%d\n%s: Ethernet address %s\n", +#else printf(": %s%s pass %d.%d Ethernet address %s\n", +#endif sc->tulip_boardsw->bd_description, tulip_chipdescs[sc->tulip_chipid], (sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F, +#if defined(__NetBSD__) + sc->tulip_dev.dv_xname, +#endif ether_sprintf(sc->tulip_hwaddr)); if ((*sc->tulip_boardsw->bd_media_probe)(sc)) { @@ -2515,9 +2519,19 @@ tulip_pci_attach( } sc->tulip_chipid = chipid; +#if defined(__NetBSD__) + bcopy(self->dv_xname, sc->tulip_if.if_xname, IFNAMSIZ); + sc->tulip_if.if_softc = sc; +#else sc->tulip_unit = unit; sc->tulip_name = "de"; +#endif sc->tulip_revinfo = revinfo; + + /* Set up human-readable name. */ + bzero(sc->tulip_xname, sizeof(sc->tulip_xname)); + sprintf(sc->tulip_xname, "%s%d", sc->tulip_name, sc->tulip_unit); + #if defined(__FreeBSD__) #if defined(TULIP_IOMAPPED) retval = pci_map_port(config_id, PCI_CBIO, &csr_base); @@ -2567,14 +2581,14 @@ tulip_pci_attach( tulip_initring(sc, &sc->tulip_txinfo, txdescs, TULIP_TXDESCS); if ((retval = tulip_read_macaddr(sc)) < 0) { #ifdef __FreeBSD__ - printf("%s%d", sc->tulip_name, sc->tulip_unit); + printf("%s", sc->tulip_xname); #endif printf(": can't read ENET ROM (why=%d) (", retval); for (idx = 0; idx < 32; idx++) printf("%02x", sc->tulip_rombuf[idx]); printf("\n"); - printf("%s%d: %s%s pass %d.%d Ethernet address %s\n", - sc->tulip_name, sc->tulip_unit, + printf("%s: %s%s pass %d.%d Ethernet address %s\n", + sc->tulip_xname, (sc->tulip_boardsw != NULL ? sc->tulip_boardsw->bd_description : ""), tulip_chipdescs[sc->tulip_chipid], (sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F, @@ -2609,14 +2623,13 @@ tulip_pci_attach( } sc->tulip_ats = shutdownhook_establish(tulip_pci_shutdown, sc); if (sc->tulip_ats == NULL) - printf("\n%s%d: warning: couldn't establish shutdown hook", - sc->tulip_name, sc->tulip_unit); + printf("\n%s: warning: couldn't establish shutdown hook", + sc->tulip_xname); #endif #if defined(__FreeBSD__) if (sc->tulip_boardsw->bd_type != TULIP_DC21040_ZX314_SLAVE) { if (!pci_map_int (config_id, tulip_intr, (void*) sc, &net_imask)) { - printf("%s%d: couldn't map interrupt\n", - sc->tulip_name, sc->tulip_unit); + printf("%s: couldn't map interrupt\n", sc->tulip_xname); return; } } |