Module Name: src Committed By: tsutsui Date: Sat May 16 07:34:05 UTC 2009
Modified Files: src/sys/dev/pci: if_vge.c Log Message: Split device_t/softc split, tested on VT6212L. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/dev/pci/if_vge.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_vge.c diff -u src/sys/dev/pci/if_vge.c:1.47 src/sys/dev/pci/if_vge.c:1.48 --- src/sys/dev/pci/if_vge.c:1.47 Tue May 12 08:23:01 2009 +++ src/sys/dev/pci/if_vge.c Sat May 16 07:34:05 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vge.c,v 1.47 2009/05/12 08:23:01 cegger Exp $ */ +/* $NetBSD: if_vge.c,v 1.48 2009/05/16 07:34:05 tsutsui Exp $ */ /*- * Copyright (c) 2004 @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.47 2009/05/12 08:23:01 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.48 2009/05/16 07:34:05 tsutsui Exp $"); /* * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver. @@ -190,7 +190,7 @@ struct vge_softc { - struct device sc_dev; + device_t sc_dev; bus_space_tag_t sc_bst; /* bus space tag */ bus_space_handle_t sc_bsh; /* bus space handle */ @@ -333,7 +333,7 @@ static void vge_setmulti(struct vge_softc *); static void vge_reset(struct vge_softc *); -CFATTACH_DECL(vge, sizeof(struct vge_softc), +CFATTACH_DECL_NEW(vge, sizeof(struct vge_softc), vge_match, vge_attach, NULL, NULL); static inline void @@ -446,7 +446,7 @@ } if (i == VGE_TIMEOUT) { - aprint_error_dev(&sc->sc_dev, "EEPROM read timed out\n"); + printf("%s: EEPROM read timed out\n", device_xname(sc->sc_dev)); return 0; } @@ -474,7 +474,8 @@ } if (i == VGE_TIMEOUT) { - aprint_error_dev(&sc->sc_dev, "failed to idle MII autopoll\n"); + printf("%s: failed to idle MII autopoll\n", + device_xname(sc->sc_dev)); } } @@ -495,7 +496,8 @@ } if (i == VGE_TIMEOUT) { - aprint_error_dev(&sc->sc_dev, "failed to idle MII autopoll\n"); + printf("%s: failed to idle MII autopoll\n", + device_xname(sc->sc_dev)); return; } @@ -512,7 +514,8 @@ } if (i == VGE_TIMEOUT) { - aprint_error_dev(&sc->sc_dev, "failed to start MII autopoll\n"); + printf("%s: failed to start MII autopoll\n", + device_xname(sc->sc_dev)); } } @@ -545,7 +548,7 @@ } if (i == VGE_TIMEOUT) - aprint_error_dev(&sc->sc_dev, "MII read timed out\n"); + printf("%s: MII read timed out\n", device_xname(sc->sc_dev)); else rval = CSR_READ_2(sc, VGE_MIIDATA); @@ -585,7 +588,7 @@ } if (i == VGE_TIMEOUT) { - aprint_error_dev(&sc->sc_dev, "MII write timed out\n"); + printf("%s: MII write timed out\n", device_xname(sc->sc_dev)); } vge_miipoll_start(sc); @@ -654,7 +657,8 @@ } if (i == VGE_TIMEOUT) { - aprint_error_dev(&sc->sc_dev, "setting CAM filter failed\n"); + printf("%s: setting CAM filter failed\n", + device_xname(sc->sc_dev)); error = EIO; goto fail; } @@ -769,7 +773,7 @@ } if (i == VGE_TIMEOUT) { - aprint_error_dev(&sc->sc_dev, "soft reset timed out"); + printf("%s: soft reset timed out", device_xname(sc->sc_dev)); CSR_WRITE_1(sc, VGE_CRS3, VGE_CR3_STOP_FORCE); DELAY(2000); } @@ -785,7 +789,8 @@ } if (i == VGE_TIMEOUT) { - aprint_error_dev(&sc->sc_dev, "EEPROM reload timed out\n"); + printf("%s: EEPROM reload timed out\n", + device_xname(sc->sc_dev)); return; } @@ -829,7 +834,8 @@ error = bus_dmamem_alloc(sc->sc_dmat, sizeof(struct vge_control_data), VGE_RING_ALIGN, 0, &seg, 1, &nseg, BUS_DMA_NOWAIT); if (error) { - aprint_error_dev(&sc->sc_dev, "could not allocate control data dma memory\n"); + aprint_error_dev(sc->sc_dev, + "could not allocate control data dma memory\n"); goto fail_1; } @@ -839,7 +845,8 @@ sizeof(struct vge_control_data), (void **)&sc->sc_control_data, BUS_DMA_NOWAIT); if (error) { - aprint_error_dev(&sc->sc_dev, "could not map control data dma memory\n"); + aprint_error_dev(sc->sc_dev, + "could not map control data dma memory\n"); goto fail_2; } memset(sc->sc_control_data, 0, sizeof(struct vge_control_data)); @@ -852,7 +859,8 @@ sizeof(struct vge_control_data), 0, BUS_DMA_NOWAIT, &sc->sc_cddmamap); if (error) { - aprint_error_dev(&sc->sc_dev, "could not create control data dmamap\n"); + aprint_error_dev(sc->sc_dev, + "could not create control data dmamap\n"); goto fail_3; } @@ -861,7 +869,8 @@ sc->sc_control_data, sizeof(struct vge_control_data), NULL, BUS_DMA_NOWAIT); if (error) { - aprint_error_dev(&sc->sc_dev, "could not load control data dma memory\n"); + aprint_error_dev(sc->sc_dev, + "could not load control data dma memory\n"); goto fail_4; } @@ -872,7 +881,8 @@ VGE_TX_FRAGS, VGE_TX_MAXLEN, 0, BUS_DMA_NOWAIT, &sc->sc_txsoft[i].txs_dmamap); if (error) { - aprint_error_dev(&sc->sc_dev, "can't create DMA map for TX descs\n"); + aprint_error_dev(sc->sc_dev, + "can't create DMA map for TX descs\n"); goto fail_5; } } @@ -884,7 +894,8 @@ 1, MCLBYTES, 0, BUS_DMA_NOWAIT, &sc->sc_rxsoft[i].rxs_dmamap); if (error) { - aprint_error_dev(&sc->sc_dev, "can't create DMA map for RX descs\n"); + aprint_error_dev(sc->sc_dev, + "can't create DMA map for RX descs\n"); goto fail_6; } sc->sc_rxsoft[i].rxs_mbuf = NULL; @@ -932,6 +943,8 @@ pci_intr_handle_t ih; uint16_t val; + sc->sc_dev = self; + aprint_normal(": VIA VT612X Gigabit Ethernet (rev. %#x)\n", PCI_REVISION(pa->pa_class)); @@ -945,7 +958,7 @@ */ if (pci_mapreg_map(pa, VGE_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, &sc->sc_bst, &sc->sc_bsh, NULL, NULL) != 0) { - aprint_error_dev(&sc->sc_dev, "couldn't map memory\n"); + aprint_error_dev(self, "couldn't map memory\n"); return; } @@ -953,19 +966,19 @@ * Map and establish our interrupt. */ if (pci_intr_map(pa, &ih)) { - aprint_error_dev(&sc->sc_dev, "unable to map interrupt\n"); + aprint_error_dev(self, "unable to map interrupt\n"); return; } intrstr = pci_intr_string(pc, ih); sc->sc_intrhand = pci_intr_establish(pc, ih, IPL_NET, vge_intr, sc); if (sc->sc_intrhand == NULL) { - aprint_error_dev(&sc->sc_dev, "unable to establish interrupt"); + aprint_error_dev(self, "unable to establish interrupt"); if (intrstr != NULL) aprint_error(" at %s", intrstr); aprint_error("\n"); return; } - aprint_normal_dev(&sc->sc_dev, "interrupting at %s\n", intrstr); + aprint_normal_dev(self, "interrupting at %s\n", intrstr); /* Reset the adapter. */ vge_reset(sc); @@ -984,7 +997,7 @@ eaddr[4] = val & 0xff; eaddr[5] = val >> 8; - aprint_normal_dev(&sc->sc_dev, "Ethernet address: %s\n", + aprint_normal_dev(self, "Ethernet address: %s\n", ether_sprintf(eaddr)); /* @@ -998,7 +1011,7 @@ ifp = &sc->sc_ethercom.ec_if; ifp->if_softc = sc; - strlcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ); + strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); ifp->if_mtu = ETHERMTU; ifp->if_baudrate = IF_Gbps(1); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; @@ -1043,7 +1056,7 @@ sc->sc_ethercom.ec_mii = &sc->sc_mii; ifmedia_init(&sc->sc_mii.mii_media, 0, ether_mediachange, ether_mediastatus); - mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, + mii_attach(self, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, MIIF_DOPAUSE); if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) { ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL); @@ -1065,7 +1078,8 @@ * Make sure the interface is shutdown during reboot. */ if (shutdownhook_establish(vge_shutdown, sc) == NULL) { - aprint_error_dev(&sc->sc_dev, "WARNING: unable to establish shutdown hook\n"); + aprint_error_dev(self, + "WARNING: unable to establish shutdown hook\n"); } } @@ -1127,7 +1141,7 @@ VGE_RXDESCSYNC(sc, idx, BUS_DMASYNC_PREREAD); if (rd_sts & VGE_RDSTS_OWN) { panic("%s: tried to map busy RX descriptor", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); } #endif @@ -1428,14 +1442,14 @@ } static void -vge_tick(void *xsc) +vge_tick(void *arg) { struct vge_softc *sc; struct ifnet *ifp; struct mii_data *mii; int s; - sc = xsc; + sc = arg; ifp = &sc->sc_ethercom.ec_if; mii = &sc->sc_mii; @@ -1694,8 +1708,9 @@ if ((error = vge_encap(sc, m_head, idx))) { if (error == EFBIG) { - aprint_error_dev(&sc->sc_dev, "Tx packet consumes too many " - "DMA segments, dropping...\n"); + printf("%s: Tx packet consumes too many " + "DMA segments, dropping...\n", + device_xname(sc->sc_dev)); IFQ_DEQUEUE(&ifp->if_snd, m_head); m_freem(m_head); continue; @@ -1783,8 +1798,8 @@ sc->sc_rx_consumed = 0; for (i = 0; i < VGE_NRXDESC; i++) { if (vge_newbuf(sc, i, NULL) == ENOBUFS) { - aprint_error_dev(&sc->sc_dev, "unable to allocate or map " - "rx buffer\n"); + printf("%s: unable to allocate or map rx buffer\n", + device_xname(sc->sc_dev)); return 1; /* XXX */ } } @@ -1959,7 +1974,7 @@ struct mii_data *mii; struct ifmedia_entry *ife; - sc = (void *)self; + sc = device_private(self); mii = &sc->sc_mii; ife = mii->mii_media.ifm_cur; /* @@ -1992,7 +2007,8 @@ } break; default: - aprint_error_dev(&sc->sc_dev, "unknown media type: %x\n", + printf("%s: unknown media type: %x\n", + device_xname(sc->sc_dev), IFM_SUBTYPE(ife->ifm_media)); break; } @@ -2057,7 +2073,7 @@ sc = ifp->if_softc; s = splnet(); - aprint_error_dev(&sc->sc_dev, "watchdog timeout\n"); + printf("%s: watchdog timeout\n", device_xname(sc->sc_dev)); ifp->if_oerrors++; vge_txeof(sc);