diff options
| author | thorpej <thorpej@NetBSD.org> | 1996-05-07 02:17:18 +0000 |
|---|---|---|
| committer | thorpej <thorpej@NetBSD.org> | 1996-05-07 02:17:18 +0000 |
| commit | edbe37b13e124e811f36bc46f912ecaa530633c9 (patch) | |
| tree | 477ef3daf14bfe91f45c66ef1ffe67058b4444a5 /sys/dev | |
| parent | c1e45dd1f7ea776cd753b0761cf0523bd22c4a0e (diff) | |
Changed struct ifnet to have a pointer to the softc of the underlying
device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_reset)()
to take a struct ifnet *, rather than a unit number.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/pci/if_de.c | 93 | ||||
| -rw-r--r-- | sys/dev/pci/if_fpa.c | 40 |
2 files changed, 82 insertions, 51 deletions
diff --git a/sys/dev/pci/if_de.c b/sys/dev/pci/if_de.c index 66f7ba3a161..d16ccd21e6f 100644 --- a/sys/dev/pci/if_de.c +++ b/sys/dev/pci/if_de.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_de.c,v 1.18 1996/05/03 17:32:20 christos 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) @@ -321,6 +321,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; @@ -370,6 +371,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__) @@ -377,6 +379,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__) @@ -385,6 +388,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 @@ -392,8 +396,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 @@ -444,14 +453,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; @@ -482,8 +489,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; @@ -529,8 +535,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; @@ -538,8 +543,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; @@ -583,8 +587,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; @@ -631,8 +634,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; @@ -640,8 +642,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; @@ -693,8 +694,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; @@ -704,8 +704,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; @@ -831,8 +830,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) @@ -892,8 +890,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); } } /* @@ -924,8 +922,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; @@ -1286,7 +1283,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; @@ -1518,8 +1515,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) @@ -1934,7 +1931,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; @@ -2068,15 +2065,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)) { @@ -2535,9 +2539,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); @@ -2587,14 +2601,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, @@ -2629,14 +2643,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; } } diff --git a/sys/dev/pci/if_fpa.c b/sys/dev/pci/if_fpa.c index 3e05b708b52..f444579496d 100644 --- a/sys/dev/pci/if_fpa.c +++ b/sys/dev/pci/if_fpa.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_fpa.c,v 1.7 1996/03/17 00:55:30 thorpej Exp $ */ +/* $NetBSD: if_fpa.c,v 1.8 1996/05/07 02:17:23 thorpej Exp $ */ /*- * Copyright (c) 1995 Matt Thomas (thomas@lkg.dec.com) @@ -190,9 +190,24 @@ extern struct cfdriver fpa_cd; #define PDQ_PCI_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)fpa_cd.cd_devs[unit]) #endif +#if defined(__NetBSD__) static ifnet_ret_t pdq_pci_ifinit( - int unit) + struct ifnet *ifp) +{ + pdq_ifinit((pdq_softc_t *)(ifp->if_softc)); +} + +static ifnet_ret_t +pdq_pci_ifwatchdog( + struct ifnet *ifp) +{ + pdq_ifwatchdog((pdq_softc_t *)(ifp->if_softc)); +} +#else +static ifnet_ret_t +pdq_pci_ifinit( + int unit) { pdq_ifinit(PDQ_PCI_UNIT_TO_SOFTC(unit)); } @@ -203,6 +218,7 @@ pdq_pci_ifwatchdog( { pdq_ifwatchdog(PDQ_PCI_UNIT_TO_SOFTC(unit)); } +#endif static int pdq_pci_ifintr( @@ -427,22 +443,24 @@ pdq_pci_attach( pdq_uint32_t data; pdq_softc_t * const sc = (pdq_softc_t *) self; struct pci_attach_args * const pa = (struct pci_attach_args *) aux; + pci_chipset_tag_t pc = pa->pa_pc; - data = pci_conf_read(pa->pa_tag, PCI_CFLT); + data = pci_conf_read(pc, pa->pa_tag, PCI_CFLT); if ((data & 0xFF00) == 0) { data &= ~0xFF00; data |= DEFPA_LATENCY << 8; - pci_conf_write(pa->pa_tag, PCI_CFLT, data); + pci_conf_write(pc, pa->pa_tag, PCI_CFLT, data); } if (pci_map_mem(pa->pa_tag, PCI_CBMA, &va_csrs, &pa_csrs)) return; - sc->sc_if.if_name = "fpa"; - sc->sc_if.if_unit = sc->sc_dev.dv_unit; + bcopy(sc->sc_dev.dv_xname, sc->sc_if.if_xname, IFNAMSIZ); + sc->sc_if.if_softc = sc; sc->sc_if.if_flags = 0; - sc->sc_pdq = pdq_initialize((void *) va_csrs, sc->sc_if.if_name, - sc->sc_if.if_unit, (void *) sc, PDQ_DEFPA); + sc->sc_pdq = pdq_initialize((void *) va_csrs, + sc->sc_dev.dv_cfdata->cf_driver->cd_name, sc->sc_dev.dv_unit, + (void *) sc, PDQ_DEFPA); if (sc->sc_pdq == NULL) return; bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); @@ -450,14 +468,14 @@ pdq_pci_attach( sc->sc_ih = pci_map_int(pa->pa_tag, IPL_NET, pdq_pci_ifintr, sc); if (sc->sc_ih == NULL) { - printf("fpa%d: error: couldn't map interrupt\n", sc->sc_if.if_unit); + printf("%s: error: couldn't map interrupt\n", sc->sc_dev.dv_xname); return; } #if 0 sc->sc_ats = shutdownhook_establish(pdq_hwreset, sc); if (sc->sc_ats == NULL) - printf("fpa%d: warning: couldn't establish shutdown hook\n", - sc->sc_if.if_unit); + printf("%s: warning: couldn't establish shutdown hook\n", + sc->sc_dev.dv_xname); #endif } |
