Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Feb 2008 23:42:30 GMT
From:      Rafal Jaworowski <raj@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 136048 for review
Message-ID:  <200802232342.m1NNgUQq050041@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=136048

Change 136048 by raj@raj_mimi on 2008/02/23 23:42:11

	Another round of cleanups before the upcoming CVS merge.

Affected files ...

.. //depot/projects/e500/sys/dev/tsec/if_tsec.c#6 edit
.. //depot/projects/e500/sys/dev/tsec/if_tsec.h#2 edit
.. //depot/projects/e500/sys/dev/tsec/if_tsecreg.h#3 edit

Differences ...

==== //depot/projects/e500/sys/dev/tsec/if_tsec.c#6 (text+ko) ====

@@ -75,59 +75,55 @@
 #define PDEBUG(a) /* nop */
 #endif
 
-static int		tsec_probe(device_t dev);
-static int		tsec_attach(device_t dev);
-static int		tsec_setup_intr(device_t dev, struct resource **ires,
-				void **ihand, int *irid, driver_intr_t handler,
-				const char *iname);
-static void		tsec_release_intr(device_t dev, struct resource *ires,
-				void *ihand, int irid, const char *iname);
-static void		tsec_free_dma(struct tsec_softc *sc);
-static int		tsec_detach(device_t dev);
-static void		tsec_shutdown(device_t dev);
-static int		tsec_suspend(device_t dev); /* XXX */
-static int		tsec_resume(device_t dev); /* XXX */
+static int	tsec_probe(device_t dev);
+static int	tsec_attach(device_t dev);
+static int	tsec_setup_intr(device_t dev, struct resource **ires,
+    void **ihand, int *irid, driver_intr_t handler, const char *iname);
+static void	tsec_release_intr(device_t dev, struct resource *ires,
+    void *ihand, int irid, const char *iname);
+static void	tsec_free_dma(struct tsec_softc *sc);
+static int	tsec_detach(device_t dev);
+static void	tsec_shutdown(device_t dev);
+static int	tsec_suspend(device_t dev); /* XXX */
+static int	tsec_resume(device_t dev); /* XXX */
 
-static void		tsec_init(void *xsc);
-static void		tsec_init_locked(struct tsec_softc *sc);
-static void		tsec_set_mac_address(struct tsec_softc *sc);
-static void		tsec_dma_ctl(struct tsec_softc *sc, int state);
-static void		tsec_intrs_ctl(struct tsec_softc *sc, int state);
-static void		tsec_reset_mac(struct tsec_softc *sc);
+static void	tsec_init(void *xsc);
+static void	tsec_init_locked(struct tsec_softc *sc);
+static void	tsec_set_mac_address(struct tsec_softc *sc);
+static void	tsec_dma_ctl(struct tsec_softc *sc, int state);
+static void	tsec_intrs_ctl(struct tsec_softc *sc, int state);
+static void	tsec_reset_mac(struct tsec_softc *sc);
 
-static void		tsec_watchdog(struct ifnet *ifp);
-static void		tsec_start(struct ifnet *ifp);
-static void		tsec_start_locked(struct ifnet *ifp);
-static int		tsec_encap(struct tsec_softc *sc,
-				struct mbuf *m_head);
-static void		tsec_setfilter(struct tsec_softc *sc);
-static int		tsec_ioctl(struct ifnet *ifp, u_long command,
-				   caddr_t data);
-static int		tsec_ifmedia_upd(struct ifnet *ifp);
-static void		tsec_ifmedia_sts(struct ifnet *ifp,
-					struct ifmediareq *ifmr);
-static int		tsec_new_rxbuf(bus_dma_tag_t tag, bus_dmamap_t map,
-					struct mbuf **mbufp, uint32_t *paddr);
-static void		tsec_map_dma_addr(void *arg, bus_dma_segment_t *segs,
-					int nseg, int error);
-static int		tsec_alloc_dma_desc(device_t dev, bus_dma_tag_t *dtag,
-					bus_dmamap_t *dmap, bus_size_t dsize,
-					void **vaddr, void *raddr,
-					const char *dname);
-static void		tsec_free_dma_desc(bus_dma_tag_t dtag, bus_dmamap_t dmap,
-					void *vaddr);
+static void	tsec_watchdog(struct ifnet *ifp);
+static void	tsec_start(struct ifnet *ifp);
+static void	tsec_start_locked(struct ifnet *ifp);
+static int	tsec_encap(struct tsec_softc *sc,
+    struct mbuf *m_head);
+static void	tsec_setfilter(struct tsec_softc *sc);
+static int	tsec_ioctl(struct ifnet *ifp, u_long command,
+    caddr_t data);
+static int	tsec_ifmedia_upd(struct ifnet *ifp);
+static void	tsec_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr);
+static int	tsec_new_rxbuf(bus_dma_tag_t tag, bus_dmamap_t map,
+    struct mbuf **mbufp, uint32_t *paddr);
+static void	tsec_map_dma_addr(void *arg, bus_dma_segment_t *segs,
+    int nseg, int error);
+static int	tsec_alloc_dma_desc(device_t dev, bus_dma_tag_t *dtag,
+    bus_dmamap_t *dmap, bus_size_t dsize, void **vaddr, void *raddr,
+    const char *dname);
+static void	tsec_free_dma_desc(bus_dma_tag_t dtag, bus_dmamap_t dmap,
+    void *vaddr);
 
-static void		tsec_stop(struct tsec_softc *sc);
+static void	tsec_stop(struct tsec_softc *sc);
 
-static void		tsec_receive_intr(void *arg);
-static void		tsec_transmit_intr(void *arg);
-static void		tsec_error_intr(void *arg);
+static void	tsec_receive_intr(void *arg);
+static void	tsec_transmit_intr(void *arg);
+static void	tsec_error_intr(void *arg);
 
-static void		tsec_tick(void *arg);
-static int		tsec_miibus_readreg(device_t dev, int phy, int reg);
-static void		tsec_miibus_writereg(device_t dev, int phy, int reg,
-				int value);
-static void		tsec_miibus_statchg(device_t dev);
+static void	tsec_tick(void *arg);
+static int	tsec_miibus_readreg(device_t dev, int phy, int reg);
+static void	tsec_miibus_writereg(device_t dev, int phy, int reg, int value);
+static void	tsec_miibus_statchg(device_t dev);
 
 static struct tsec_softc *tsec0_sc = NULL; /* XXX ugly hack! */
 
@@ -164,7 +160,6 @@
 MODULE_DEPEND(tsec, ether, 1, 1, 1);
 MODULE_DEPEND(tsec, miibus, 1, 1, 1);
 
-
 static void
 tsec_get_hwaddr(struct tsec_softc *sc, uint8_t *addr)
 {
@@ -230,11 +225,11 @@
 
 	/* Step 2: Initialize MACCFG2 */
 	TSEC_WRITE(sc, TSEC_REG_MACCFG2,
-			TSEC_MACCFG2_FULLDUPLEX |	/* Full Duplex = 1 */
-			TSEC_MACCFG2_PADCRC |		/* PAD/CRC append */
-			TSEC_MACCFG2_GMII |		/* I/F Mode bit */
-			TSEC_MACCFG2_PRECNT		/* Preamble count = 7 */
-		);
+	    TSEC_MACCFG2_FULLDUPLEX |	/* Full Duplex = 1 */
+	    TSEC_MACCFG2_PADCRC |	/* PAD/CRC append */
+	    TSEC_MACCFG2_GMII |		/* I/F Mode bit */
+	    TSEC_MACCFG2_PRECNT		/* Preamble count = 7 */
+	);
 
 	/* Step 3: Initialize ECNTRL
 	 * While the documentation states that R100M is ignored if RPM is
@@ -270,7 +265,8 @@
 
 	/* Step 8: Read MII Mgmt indicator register and check for Busy = 0 */
 	timeout = TSEC_READ_RETRY;
-	while (--timeout && (TSEC_READ(tsec0_sc, TSEC_REG_MIIMIND) & TSEC_MIIMIND_BUSY))
+	while (--timeout && (TSEC_READ(tsec0_sc, TSEC_REG_MIIMIND) &
+	    TSEC_MIIMIND_BUSY))
 		DELAY(TSEC_READ_DELAY);
 	if (timeout == 0) {
 		if_printf(ifp, "tsec_init_locked(): Mgmt busy timeout\n");
@@ -328,16 +324,16 @@
 		tx_desc[i].flags = ((i == TSEC_TX_NUM_DESC-1) ? TSEC_TXBD_W : 0);
 	}
 	bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap, BUS_DMASYNC_PREREAD |
-			BUS_DMASYNC_PREWRITE);
+	    BUS_DMASYNC_PREWRITE);
 
 	for (i = 0; i < TSEC_RX_NUM_DESC; i++) {
 		rx_desc[i].bufptr = sc->rx_data[i].paddr;
 		rx_desc[i].length = 0;
 		rx_desc[i].flags = TSEC_RXBD_E | TSEC_RXBD_I |
-			((i == TSEC_RX_NUM_DESC-1) ? TSEC_RXBD_W : 0);
+		    ((i == TSEC_RX_NUM_DESC-1) ? TSEC_RXBD_W : 0);
 	}
 	bus_dmamap_sync(sc->tsec_rx_dtag, sc->tsec_rx_dmap, BUS_DMASYNC_PREREAD |
-			BUS_DMASYNC_PREWRITE);
+	    BUS_DMASYNC_PREWRITE);
 
 	/* Step 18: Initialize the maximum and minimum receive buffer length */
 	TSEC_WRITE(sc, TSEC_REG_MRBLR, TSEC_DEFAULT_MAX_RX_BUFFER_SIZE);
@@ -387,8 +383,8 @@
 	TSEC_GLOBAL_LOCK_ASSERT(sc);
 
 	KASSERT((ETHER_ADDR_LEN <= sizeof(macbuf)),
-			("tsec_set_mac_address: (%d <= %d",
-			ETHER_ADDR_LEN, sizeof(macbuf)));
+	    ("tsec_set_mac_address: (%d <= %d",
+	    ETHER_ADDR_LEN, sizeof(macbuf)));
 
 	macbufp = (char *)macbuf;
 	curmac = (char *)IF_LLADDR(sc->tsec_ifp);
@@ -430,14 +426,14 @@
 	case 1:
 		/* Set write with response (WWR), wait (WOP) and snoop bits */
 		dma_flags |= (TSEC_DMACTRL_TDSEN | TSEC_DMACTRL_TBDSEN |
-				DMACTRL_WWR | DMACTRL_WOP);
+		    DMACTRL_WWR | DMACTRL_WOP);
 
 		/* Clear graceful stop bits */
 		dma_flags &= ~(TSEC_DMACTRL_GRS | TSEC_DMACTRL_GTS);
 		break;
 	default:
 		device_printf(dev, "tsec_dma_ctl(): unknown state value: %d\n",
-				state);
+		    state);
 	}
 
 	TSEC_WRITE(sc, TSEC_REG_DMACTRL, dma_flags);
@@ -447,7 +443,7 @@
 		/* Wait for DMA stop */
 		timeout = TSEC_READ_RETRY;
 		while (--timeout && (!(TSEC_READ(sc, TSEC_REG_IEVENT) &
-				(TSEC_IEVENT_GRSC | TSEC_IEVENT_GTSC))))
+		    (TSEC_IEVENT_GRSC | TSEC_IEVENT_GTSC))))
 			DELAY(TSEC_READ_DELAY);
 
 		if (timeout == 0)
@@ -476,22 +472,17 @@
 		TSEC_WRITE(sc, TSEC_REG_IMASK, 0);
 		break;
 	case 1:
-		TSEC_WRITE(sc, TSEC_REG_IMASK,
-				TSEC_IMASK_BREN |
-				TSEC_IMASK_RXCEN |
-				TSEC_IMASK_BSYEN |
-				TSEC_IMASK_EBERREN |
-				TSEC_IMASK_BTEN |
-				TSEC_IMASK_TXEEN |
-				TSEC_IMASK_TXBEN |
-				TSEC_IMASK_TXFEN |
-				TSEC_IMASK_XFUNEN |
-				TSEC_IMASK_RXFEN
-			  );
+		TSEC_WRITE(sc, TSEC_REG_IMASK, TSEC_IMASK_BREN |
+		    TSEC_IMASK_RXCEN | TSEC_IMASK_BSYEN |
+		    TSEC_IMASK_EBERREN | TSEC_IMASK_BTEN |
+		    TSEC_IMASK_TXEEN | TSEC_IMASK_TXBEN |
+		    TSEC_IMASK_TXFEN | TSEC_IMASK_XFUNEN |
+		    TSEC_IMASK_RXFEN
+		  );
 		break;
 	default:
 		device_printf(dev, "tsec_intrs_ctl(): unknown state value: %d\n",
-				state);
+		    state);
 	}
 }
 
@@ -557,8 +548,8 @@
 	if (sc->tsec_link == 0)
 		return;
 
-	bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap, BUS_DMASYNC_POSTREAD |
-			BUS_DMASYNC_POSTWRITE);
+	bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap,
+	    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 
 	for (;;) {
 		/* Get packet from the queue */
@@ -578,8 +569,8 @@
 		queued++;
 		BPF_MTAP(ifp, m0);
 	}
-	bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap, BUS_DMASYNC_PREREAD |
-			BUS_DMASYNC_PREWRITE);
+	bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap,
+	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
 	if (queued) {
 		/* Enable transmitter and watchdog timer */
@@ -612,7 +603,7 @@
 
 	/* Create mapping in DMA memory */
 	error = bus_dmamap_load_mbuf_sg(sc->tsec_tx_mtag,
-	   *mapp, m0, segs, &nsegs, BUS_DMA_NOWAIT); 
+	   *mapp, m0, segs, &nsegs, BUS_DMA_NOWAIT);
 	if (error != 0 || nsegs > TSEC_FREE_TX_DESC(sc) || nsegs <= 0) {
 		bus_dmamap_unload(sc->tsec_tx_mtag, *mapp);
 		TSEC_FREE_TX_MAP(sc, mapp);
@@ -631,12 +622,12 @@
 		tx_desc->bufptr = segs[seg].ds_addr;
 
 		tx_desc->flags =
-			(tx_desc->flags & TSEC_TXBD_W) /* wrap */
-			| TSEC_TXBD_I		/* interrupt */
-			| TSEC_TXBD_R		/* ready to send */
-			| TSEC_TXBD_TC		/* transmit the CRC sequence
+		    (tx_desc->flags & TSEC_TXBD_W) | /* wrap */
+		    TSEC_TXBD_I |		/* interrupt */
+		    TSEC_TXBD_R |		/* ready to send */
+		    TSEC_TXBD_TC |		/* transmit the CRC sequence
 						 * after the last data byte */
-			| ((seg == nsegs-1) ? TSEC_TXBD_L : 0);/* last in frame */
+		    ((seg == nsegs-1) ? TSEC_TXBD_L : 0);/* last in frame */
 	}
 
 	/* Save mbuf and DMA mapping for release at later stage */
@@ -680,7 +671,7 @@
 		if (ifp->if_flags & IFF_UP) {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
 				if ((sc->tsec_if_flags ^ ifp->if_flags) &
-						IFF_PROMISC)
+				    IFF_PROMISC)
 					tsec_setfilter(sc);
 			} else
 				tsec_init_locked(sc);
@@ -694,7 +685,7 @@
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:
 		error = ifmedia_ioctl(ifp, ifr, &sc->tsec_mii->mii_media,
-				command);
+		    command);
 		break;
 	default:
 		error = ether_ioctl(ifp, command, data);
@@ -760,7 +751,7 @@
 	}
 
 	error = bus_dmamap_load_mbuf_sg(tag, map, new_mbuf, seg, &nsegs,
-			BUS_DMA_NOWAIT);
+	    BUS_DMA_NOWAIT);
 	KASSERT(nsegs == 1, ("Too many segments returned!"));
 	if (nsegs != 1 || error)
 		panic("tsec_new_rxbuf(): nsegs(%d), error(%d)", nsegs, error);
@@ -797,21 +788,20 @@
 
 static int
 tsec_alloc_dma_desc(device_t dev, bus_dma_tag_t *dtag, bus_dmamap_t *dmap,
-			bus_size_t dsize, void **vaddr, void *raddr,
-			const char *dname)
+    bus_size_t dsize, void **vaddr, void *raddr, const char *dname)
 {
 	int error;
 
 	/* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */
 	error = bus_dma_tag_create(NULL,	/* parent */
-		PAGE_SIZE, 0,			/* alignment, boundary */
-		BUS_SPACE_MAXADDR_32BIT,	/* lowaddr */
-		BUS_SPACE_MAXADDR,		/* highaddr */
-		NULL, NULL,			/* filtfunc, filtfuncarg */
-		dsize, 1,			/* maxsize, nsegments */
-		dsize, 0,			/* maxsegsz, flags */
-		NULL, NULL,			/* lockfunc, lockfuncarg */
-		dtag);				/* dmat */
+	    PAGE_SIZE, 0,			/* alignment, boundary */
+	    BUS_SPACE_MAXADDR_32BIT,		/* lowaddr */
+	    BUS_SPACE_MAXADDR,			/* highaddr */
+	    NULL, NULL,				/* filtfunc, filtfuncarg */
+	    dsize, 1,				/* maxsize, nsegments */
+	    dsize, 0,				/* maxsegsz, flags */
+	    NULL, NULL,				/* lockfunc, lockfuncarg */
+	    dtag);				/* dmat */
 
 	if (error) {
 		device_printf(dev, "failed to allocate busdma %s tag\n", dname);
@@ -820,20 +810,20 @@
 	}
 
 	error = bus_dmamem_alloc(*dtag, vaddr, BUS_DMA_NOWAIT | BUS_DMA_ZERO,
-				dmap);
+	    dmap);
 	if (error) {
 		device_printf(dev, "failed to allocate %s DMA safe memory\n",
-			dname);
+		    dname);
 		bus_dma_tag_destroy(*dtag);
 		(*vaddr) = NULL;
 		return (ENXIO);
 	}
 
 	error = bus_dmamap_load(*dtag, *dmap, *vaddr, dsize, tsec_map_dma_addr,
-			raddr, BUS_DMA_NOWAIT);
+	    raddr, BUS_DMA_NOWAIT);
 	if (error) {
 		device_printf(dev, "cannot get address of the %s descriptors\n",
-			dname);
+		    dname);
 		bus_dmamem_free(*dtag, *vaddr, *dmap);
 		bus_dma_tag_destroy(*dtag);
 		(*vaddr) = NULL;
@@ -844,8 +834,7 @@
 }
 
 static void
-tsec_free_dma_desc(bus_dma_tag_t dtag, bus_dmamap_t dmap,
-			void *vaddr)
+tsec_free_dma_desc(bus_dma_tag_t dtag, bus_dmamap_t dmap, void *vaddr)
 {
 	if (vaddr == NULL)
 		return;
@@ -920,17 +909,17 @@
 
 	callout_init(&sc->tsec_tick_ch, 1);
 	mtx_init(&sc->transmit_lock, device_get_nameunit(dev), "TSEC TX lock",
-			MTX_DEF);
+	    MTX_DEF);
 	mtx_init(&sc->receive_lock, device_get_nameunit(dev), "TSEC RX lock",
-			MTX_DEF);
+	    MTX_DEF);
 
 	/* Reset all TSEC counters */
 	TSEC_TX_RX_COUNTERS_INIT(sc);
-	
+
 	/* Allocate IO memory for TSEC registers */
 	sc->sc_rrid = 0;
 	sc->sc_rres = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->sc_rrid,
-		0ul, ~0ul, TSEC_IO_SIZE, RF_ACTIVE);
+	    0ul, ~0ul, TSEC_IO_SIZE, RF_ACTIVE);
 	if (sc->sc_rres == NULL) {
 		device_printf(dev, "could not allocate IO memory range!\n");
 		tsec_detach(dev);
@@ -950,8 +939,8 @@
 
 	/* Allocate a busdma tag and DMA safe memory for TX descriptors. */
 	error = tsec_alloc_dma_desc(dev, &sc->tsec_tx_dtag, &sc->tsec_tx_dmap,
-			sizeof(*sc->tsec_tx_vaddr) * TSEC_TX_NUM_DESC,
-			(void **)&sc->tsec_tx_vaddr, &sc->tsec_tx_raddr, "TX");
+	    sizeof(*sc->tsec_tx_vaddr) * TSEC_TX_NUM_DESC,
+	    (void **)&sc->tsec_tx_vaddr, &sc->tsec_tx_raddr, "TX");
 	if (error) {
 		tsec_detach(dev);
 		return (ENXIO);
@@ -959,8 +948,8 @@
 
 	/* Allocate a busdma tag and DMA safe memory for RX descriptors. */
 	error = tsec_alloc_dma_desc(dev, &sc->tsec_rx_dtag, &sc->tsec_rx_dmap,
-			sizeof(*sc->tsec_rx_vaddr) * TSEC_RX_NUM_DESC,
-			(void **)&sc->tsec_rx_vaddr, &sc->tsec_rx_raddr, "RX");
+	    sizeof(*sc->tsec_rx_vaddr) * TSEC_RX_NUM_DESC,
+	    (void **)&sc->tsec_rx_vaddr, &sc->tsec_rx_raddr, "RX");
 	if (error) {
 		tsec_detach(dev);
 		return (ENXIO);
@@ -968,15 +957,15 @@
 
 	/* Allocate a busdma tag for TX mbufs. */
 	error = bus_dma_tag_create(NULL,	/* parent */
-		TSEC_TXBUFFER_ALIGNMENT, 0,	/* alignment, boundary */
-		BUS_SPACE_MAXADDR_32BIT,	/* lowaddr */
-		BUS_SPACE_MAXADDR,		/* highaddr */
-		NULL, NULL,			/* filtfunc, filtfuncarg */
-		MCLBYTES * (TSEC_TX_NUM_DESC - 1),/* maxsize */
-		TSEC_TX_NUM_DESC - 1,		/* nsegments */
-		MCLBYTES, 0,			/* maxsegsz, flags */
-		NULL, NULL,			/* lockfunc, lockfuncarg */
-		&sc->tsec_tx_mtag);		/* dmat */
+	    TSEC_TXBUFFER_ALIGNMENT, 0,		/* alignment, boundary */
+	    BUS_SPACE_MAXADDR_32BIT,		/* lowaddr */
+	    BUS_SPACE_MAXADDR,			/* highaddr */
+	    NULL, NULL,				/* filtfunc, filtfuncarg */
+	    MCLBYTES * (TSEC_TX_NUM_DESC - 1),	/* maxsize */
+	    TSEC_TX_NUM_DESC - 1,		/* nsegments */
+	    MCLBYTES, 0,			/* maxsegsz, flags */
+	    NULL, NULL,				/* lockfunc, lockfuncarg */
+	    &sc->tsec_tx_mtag);			/* dmat */
 	if (error) {
 		device_printf(dev, "failed to allocate busdma tag(tx mbufs)\n");
 		tsec_detach(dev);
@@ -985,15 +974,15 @@
 
 	/* Allocate a busdma tag for RX mbufs. */
 	error = bus_dma_tag_create(NULL,	/* parent */
-		TSEC_RXBUFFER_ALIGNMENT, 0,	/* alignment, boundary */
-		BUS_SPACE_MAXADDR_32BIT,	/* lowaddr */
-		BUS_SPACE_MAXADDR,		/* highaddr */
-		NULL, NULL,			/* filtfunc, filtfuncarg */
-		MCLBYTES,			/* maxsize */
-		1,				/* nsegments */
-		MCLBYTES, 0,			/* maxsegsz, flags */
-		NULL, NULL,			/* lockfunc, lockfuncarg */
-		&sc->tsec_rx_mtag);		/* dmat */
+	    TSEC_RXBUFFER_ALIGNMENT, 0,		/* alignment, boundary */
+	    BUS_SPACE_MAXADDR_32BIT,		/* lowaddr */
+	    BUS_SPACE_MAXADDR,			/* highaddr */
+	    NULL, NULL,				/* filtfunc, filtfuncarg */
+	    MCLBYTES,				/* maxsize */
+	    1,					/* nsegments */
+	    MCLBYTES, 0,				/* maxsegsz, flags */
+	    NULL, NULL,			/* lockfunc, lockfuncarg */
+	    &sc->tsec_rx_mtag);			/* dmat */
 	if (error) {
 		device_printf(dev, "failed to allocate busdma tag(rx mbufs)\n");
 		tsec_detach(dev);
@@ -1007,7 +996,7 @@
 	for (i = 0; i < TSEC_TX_NUM_DESC; i++) {
 		map_pptr[i] = &map_ptr[i];
 		error = bus_dmamap_create(sc->tsec_tx_mtag, 0,
-				map_pptr[i]);
+		    map_pptr[i]);
 		if (error) {
 			device_printf(dev, "failed to init TX ring\n");
 			tsec_detach(dev);
@@ -1018,7 +1007,7 @@
 	/* Create RX busdma maps and zero mbuf handlers */
 	for (i = 0; i < TSEC_RX_NUM_DESC; i++) {
 		error = bus_dmamap_create(sc->tsec_rx_mtag, 0,
-				&sc->rx_data[i].map);
+		    &sc->rx_data[i].map);
 		if (error) {
 			device_printf(dev, "failed to init RX ring\n");
 			tsec_detach(dev);
@@ -1030,10 +1019,10 @@
 	/* Create mbufs for RX buffers */
 	for (i = 0; i < TSEC_RX_NUM_DESC; i++) {
 		error = tsec_new_rxbuf(sc->tsec_rx_mtag, sc->rx_data[i].map,
-				&sc->rx_data[i].mbuf, &sc->rx_data[i].paddr);
+		    &sc->rx_data[i].mbuf, &sc->rx_data[i].paddr);
 		if (error) {
 			device_printf(dev, "can't load rx DMA map %d, error = "
-					"%d\n", i, error);
+			    "%d\n", i, error);
 			tsec_detach(dev);
 			return (error);
 		}
@@ -1082,8 +1071,8 @@
 	/* Interrupts configuration (TX/RX/ERR) */
 	sc->sc_transmit_irid = OCP_TSEC_RID_TXIRQ;
 	error = tsec_setup_intr(dev, &sc->sc_transmit_ires,
-			&sc->sc_transmit_ihand, &sc->sc_transmit_irid,
-			tsec_transmit_intr, "TX");
+	    &sc->sc_transmit_ihand, &sc->sc_transmit_irid,
+	    tsec_transmit_intr, "TX");
 	if (error) {
 		tsec_detach(dev);
 		return (error);
@@ -1091,8 +1080,8 @@
 
 	sc->sc_receive_irid = OCP_TSEC_RID_RXIRQ;
 	error = tsec_setup_intr(dev, &sc->sc_receive_ires,
-			&sc->sc_receive_ihand, &sc->sc_receive_irid,
-			tsec_receive_intr, "RX");
+	    &sc->sc_receive_ihand, &sc->sc_receive_irid,
+	    tsec_receive_intr, "RX");
 	if (error) {
 		tsec_detach(dev);
 		return (error);
@@ -1100,8 +1089,8 @@
 
 	sc->sc_error_irid = OCP_TSEC_RID_ERRIRQ;
 	error = tsec_setup_intr(dev, &sc->sc_error_ires,
-			&sc->sc_error_ihand, &sc->sc_error_irid,
-			tsec_error_intr, "ERR");
+	    &sc->sc_error_ihand, &sc->sc_error_irid,
+	    tsec_error_intr, "ERR");
 	if (error) {
 		tsec_detach(dev);
 		return (error);
@@ -1112,7 +1101,7 @@
 
 static int
 tsec_setup_intr(device_t dev, struct resource **ires, void **ihand, int *irid,
-			driver_intr_t handler, const char *iname)
+    driver_intr_t handler, const char *iname)
 {
 	struct tsec_softc *sc;
 	int error;
@@ -1125,7 +1114,7 @@
 		return (ENXIO);
 	}
 	error = bus_setup_intr(dev, *ires, INTR_TYPE_NET | INTR_MPSAFE,
-			NULL, handler, sc, ihand);
+	    NULL, handler, sc, ihand);
 	if (error) {
 		device_printf(dev, "failed to set up %s IRQ\n", iname);
 		if (bus_release_resource(dev, SYS_RES_IRQ, *irid, *ires))
@@ -1138,7 +1127,7 @@
 
 static void
 tsec_release_intr(device_t dev, struct resource *ires, void *ihand, int irid,
-			const char *iname)
+    const char *iname)
 {
 	int error;
 
@@ -1148,12 +1137,12 @@
 	error = bus_teardown_intr(dev, ires, ihand);
 	if (error)
 		device_printf(dev, "bus_teardown_intr() failed for %s intr"
-				", error %d\n", iname, error);
+		    ", error %d\n", iname, error);
 
 	error = bus_release_resource(dev, SYS_RES_IRQ, irid, ires);
 	if (error)
 		device_printf(dev, "bus_release_resource() failed for %s intr"
-				", error %d\n", iname, error);
+		    ", error %d\n", iname, error);
 }
 
 static void
@@ -1165,7 +1154,7 @@
 	for (i = 0; i < TSEC_TX_NUM_DESC; i++)
 		if (sc->tx_map_data[i] != NULL)
 			bus_dmamap_destroy(sc->tsec_tx_mtag,
-				sc->tx_map_data[i]);
+			    sc->tx_map_data[i]);
 	/* Destroy tag for Tx mbufs */
 	bus_dma_tag_destroy(sc->tsec_tx_mtag);
 
@@ -1174,7 +1163,7 @@
 		if (sc->rx_data[i].mbuf) {
 			/* Unload buffer from DMA */
 			bus_dmamap_sync(sc->tsec_rx_mtag, sc->rx_data[i].map,
-					BUS_DMASYNC_POSTREAD);
+			    BUS_DMASYNC_POSTREAD);
 			bus_dmamap_unload(sc->tsec_rx_mtag, sc->rx_data[i].map);
 
 			/* Free buffer */
@@ -1183,16 +1172,16 @@
 		/* Destroy map for this buffer */
 		if (sc->rx_data[i].map != NULL)
 			bus_dmamap_destroy(sc->tsec_rx_mtag,
-				sc->rx_data[i].map);
+			    sc->rx_data[i].map);
 	}
 	/* Destroy tag for Rx mbufs */
 	bus_dma_tag_destroy(sc->tsec_rx_mtag);
 
 	/* Unload TX/RX descriptors */
 	tsec_free_dma_desc(sc->tsec_tx_dtag, sc->tsec_tx_dmap,
-			sc->tsec_tx_vaddr);
+	    sc->tsec_tx_vaddr);
 	tsec_free_dma_desc(sc->tsec_rx_dtag, sc->tsec_rx_dmap,
-			sc->tsec_rx_vaddr);
+	    sc->tsec_rx_vaddr);
 }
 
 static int
@@ -1212,11 +1201,11 @@
 
 	/* Stop and release all interrupts */
 	tsec_release_intr(dev, sc->sc_transmit_ires, sc->sc_transmit_ihand,
-			sc->sc_transmit_irid, "TX");
+	    sc->sc_transmit_irid, "TX");
 	tsec_release_intr(dev, sc->sc_receive_ires, sc->sc_receive_ihand,
-			sc->sc_receive_irid, "RX");
+	    sc->sc_receive_irid, "RX");
 	tsec_release_intr(dev, sc->sc_error_ires, sc->sc_error_ihand,
-			sc->sc_error_irid, "ERR");
+	    sc->sc_error_irid, "ERR");
 
 	/* Detach network interface */
 	if (sc->tsec_ifp) {
@@ -1231,11 +1220,10 @@
 	/* Free IO memory handler */
 	if (sc->sc_rres) {
 		error = bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_rrid,
-				sc->sc_rres);
+		    sc->sc_rres);
 		if (error)
 			device_printf(dev, "bus_release_resource() failed for"
-					" IO memory, error %d\n",
-					error);
+			    " IO memory, error %d\n", error);
 	}
 
 	/* Destroy locks */
@@ -1339,21 +1327,20 @@
 	TSEC_RECEIVE_LOCK(sc);
 
 	bus_dmamap_sync(sc->tsec_rx_dtag, sc->tsec_rx_dmap, BUS_DMASYNC_POSTREAD |
-			BUS_DMASYNC_POSTWRITE);
+	    BUS_DMASYNC_POSTWRITE);
 
 	for (count = 0; /* count < TSEC_RX_NUM_DESC */; count++) {
 		rx_desc = TSEC_GET_CUR_RX_DESC(sc);
 		flags = rx_desc->flags;
 
 		/* Check if there is anything to receive */
-		if ((flags & TSEC_RXBD_E) ||
-				(count >= TSEC_RX_NUM_DESC)) {
+		if ((flags & TSEC_RXBD_E) || (count >= TSEC_RX_NUM_DESC)) {
 			/*
 			 * Avoid generating another interrupt
 			 */
 			if (flags & TSEC_RXBD_E)
 				TSEC_WRITE(sc, TSEC_REG_IEVENT,
-					TSEC_IEVENT_RXB | TSEC_IEVENT_RXF);
+				    TSEC_IEVENT_RXB | TSEC_IEVENT_RXF);
 			/*
 			 * We didn't consume current descriptor and have to
 			 * return it to the queue
@@ -1362,13 +1349,11 @@
 			break;
 		}
 
-		if (flags & (TSEC_RXBD_LG | TSEC_RXBD_SH
-				| TSEC_RXBD_NO | TSEC_RXBD_CR
-				| TSEC_RXBD_OV | TSEC_RXBD_TR)) {
-
+		if (flags & (TSEC_RXBD_LG | TSEC_RXBD_SH | TSEC_RXBD_NO |
+		    TSEC_RXBD_CR | TSEC_RXBD_OV | TSEC_RXBD_TR)) {
 			rx_desc->length = 0;
-			rx_desc->flags = (rx_desc->flags & ~TSEC_RXBD_ZEROONINIT) |
-					  TSEC_RXBD_E | TSEC_RXBD_I;
+			rx_desc->flags = (rx_desc->flags &
+			    ~TSEC_RXBD_ZEROONINIT) | TSEC_RXBD_E | TSEC_RXBD_I;
 			continue;
 		}
 
@@ -1382,16 +1367,15 @@
 		m = rx_data[i].mbuf;
 
 		if (tsec_new_rxbuf(sc->tsec_rx_mtag, rx_data[i].map,
-				&rx_data[i].mbuf, &rx_data[i].paddr)) {
+		    &rx_data[i].mbuf, &rx_data[i].paddr)) {
 			ifp->if_ierrors++;
 			continue;
 		}
 		/* Attach new buffer to descriptor, and clear flags */
 		rx_desc->bufptr = rx_data[i].paddr;
 		rx_desc->length = 0;
-		rx_desc->flags =
-			(rx_desc->flags & ~TSEC_RXBD_ZEROONINIT) |
-			TSEC_RXBD_E | TSEC_RXBD_I;
+		rx_desc->flags = (rx_desc->flags & ~TSEC_RXBD_ZEROONINIT) |
+		    TSEC_RXBD_E | TSEC_RXBD_I;
 
 		/* Prepare buffer for upper layers */
 		m->m_pkthdr.rcvif = ifp;
@@ -1401,8 +1385,8 @@
 		rcv_mbufs[c1++] = m;
 	}
 
-	bus_dmamap_sync(sc->tsec_rx_dtag, sc->tsec_rx_dmap, BUS_DMASYNC_PREREAD |
-			BUS_DMASYNC_PREWRITE);
+	bus_dmamap_sync(sc->tsec_rx_dtag, sc->tsec_rx_dmap,
+	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
 	TSEC_RECEIVE_UNLOCK(sc);
 
@@ -1439,7 +1423,7 @@
 	TSEC_WRITE(sc, TSEC_REG_MON_TNCL, 0);
 
 	bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap, BUS_DMASYNC_POSTREAD |
-			BUS_DMASYNC_POSTWRITE);
+	    BUS_DMASYNC_POSTWRITE);
 
 	while (TSEC_CUR_DIFF_DIRTY_TX_DESC(sc)) {
 		tx_desc = TSEC_GET_DIRTY_TX_DESC(sc);
@@ -1466,15 +1450,15 @@
 		ifp->if_opackets++;
 		send = 1;
 	}
-	bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap, BUS_DMASYNC_PREREAD |
-			BUS_DMASYNC_PREWRITE);
+	bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap,
+	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
 	if (send) {
-		/* Now send anything that was pending */ 
+		/* Now send anything that was pending */
 		ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 		tsec_start_locked(ifp);
 
-		/* Stop wathdog if all sent */ 
+		/* Stop wathdog if all sent */
 		if (TSEC_EMPTYQ_TX_MBUF(sc))
 			ifp->if_timer = 0;
 	}
@@ -1497,14 +1481,13 @@
 
 	/* Clear events bits in hardware */
 	TSEC_WRITE(sc, TSEC_REG_IEVENT, TSEC_IEVENT_RXC | TSEC_IEVENT_BSY |
-					TSEC_IEVENT_EBERR | TSEC_IEVENT_MSRO |
-					TSEC_IEVENT_BABT | TSEC_IEVENT_TXC |
-					TSEC_IEVENT_TXE | TSEC_IEVENT_LC |
-					TSEC_IEVENT_CRL | TSEC_IEVENT_XFUN);
+	    TSEC_IEVENT_EBERR | TSEC_IEVENT_MSRO | TSEC_IEVENT_BABT |
+	    TSEC_IEVENT_TXC | TSEC_IEVENT_TXE | TSEC_IEVENT_LC |
+	    TSEC_IEVENT_CRL | TSEC_IEVENT_XFUN);
 
 	if (eflags & TSEC_IEVENT_EBERR)
 		if_printf(ifp, "System bus error occurred during"
-				" a DMA transaction (flags: 0x%x)\n", eflags);
+		    " a DMA transaction (flags: 0x%x)\n", eflags);
 
 	/* Check transmitter errors */
 	if (eflags & TSEC_IEVENT_TXE) {
@@ -1526,7 +1509,7 @@
 		/* Get data from RX buffers */
 		tsec_receive_intr(arg);
 
-		/* Make receiver again active */		
+		/* Make receiver again active */
 		TSEC_WRITE(sc, TSEC_REG_RSTAT, TSEC_RSTAT_QHLT);
 	}
 	if (eflags & TSEC_IEVENT_BABR)
@@ -1573,7 +1556,7 @@
 
 	timeout = TSEC_READ_RETRY;
 	while (--timeout && TSEC_READ(sc, TSEC_REG_MIIMIND) &
-			(TSEC_MIIMIND_NOTVALID | TSEC_MIIMIND_BUSY))
+	    (TSEC_MIIMIND_NOTVALID | TSEC_MIIMIND_BUSY))
 		DELAY(TSEC_READ_DELAY);
 
 	if (timeout == 0)
@@ -1583,8 +1566,7 @@
 }
 
 static void
-tsec_miibus_writereg(device_t dev, int phy, int reg,
-		     int value)
+tsec_miibus_writereg(device_t dev, int phy, int reg, int value)
 {
 	struct tsec_softc *sc;
 	uint32_t timeout;
@@ -1645,8 +1627,8 @@
 	default:
 		sc->tsec_link = 0;
 		device_printf(dev, "Unknown speed (%d), link %s!\n",
-			IFM_SUBTYPE(mii->mii_media_active),
-			((link) ? "up" : "down"));
+		    IFM_SUBTYPE(mii->mii_media_active),
+		    ((link) ? "up" : "down"));
 		return;
 	}
 	TSEC_WRITE(sc, TSEC_REG_MACCFG2, tmp);

==== //depot/projects/e500/sys/dev/tsec/if_tsec.h#2 (text+ko) ====

@@ -1,7 +1,9 @@
 /*-
- * Copyright (C) 2006, 2007 Semihalf, Piotr Kruszynski <ppk@semihalf.com>
+ * Copyright (C) 2006-2007 Semihalf
  * All rights reserved.
  *
+ * Written by: Piotr Kruszynski <ppk@semihalf.com>
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -35,7 +37,7 @@
 struct tsec_softc {
 	/* XXX MII bus requires that struct ifnet is first!!! */
 	struct ifnet	*tsec_ifp;
-	
+
 	struct mtx	transmit_lock;	/* transmitter lock */
 	struct mtx	receive_lock;	/* receiver lock */
 
@@ -99,7 +101,7 @@
 	uint32_t	tx_map_used_get_cnt;
 	uint32_t	tx_map_used_put_cnt;
 	bus_dmamap_t	*tx_map_used_data[TSEC_TX_NUM_DESC];
-	
+
 	/* mbufs in TX queue */
 	uint32_t	tx_mbuf_used_get_cnt;
 	uint32_t	tx_mbuf_used_put_cnt;

==== //depot/projects/e500/sys/dev/tsec/if_tsecreg.h#3 (text+ko) ====

@@ -1,7 +1,9 @@
 /*-
- * Copyright (C) 2006, 2007 Semihalf, Piotr Kruszynski <ppk@semihalf.com>
+ * Copyright (C) 2006-2007 Semihalf
  * All rights reserved.
  *
+ * Written by: Piotr Kruszynski <ppk@semihalf.com>
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802232342.m1NNgUQq050041>