Home | History | Annotate | Line # | Download | only in ic
i82557var.h revision 1.1
      1 /*	$NetBSD: i82557var.h,v 1.1 1999/06/20 16:33:29 thorpej Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the NetBSD
     22  *	Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 /*
     41  * Copyright (c) 1995, David Greenman
     42  * All rights reserved.
     43  *
     44  * Redistribution and use in source and binary forms, with or without
     45  * modification, are permitted provided that the following conditions
     46  * are met:
     47  * 1. Redistributions of source code must retain the above copyright
     48  *    notice unmodified, this list of conditions, and the following
     49  *    disclaimer.
     50  * 2. Redistributions in binary form must reproduce the above copyright
     51  *    notice, this list of conditions and the following disclaimer in the
     52  *    documentation and/or other materials provided with the distribution.
     53  *
     54  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     55  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     56  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     57  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     58  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     59  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     60  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     61  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     62  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     63  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     64  * SUCH DAMAGE.
     65  *
     66  *	Id: if_fxpvar.h,v 1.4 1997/11/29 08:11:01 davidg Exp
     67  */
     68 
     69 /*
     70  * Misc. defintions for the Intel i82557 fast Ethernet controller
     71  * driver.
     72  */
     73 
     74 /*
     75  * Number of transmit control blocks.  This determines the number
     76  * of transmit buffers that can be chained in the CB list.  This
     77  * must be a power of two.
     78  */
     79 #define	FXP_NTXCB	128
     80 
     81 /*
     82  * TxCB list index mask.  This is used to do list wrap-around.
     83  */
     84 #define	FXP_TXCB_MASK	(FXP_NTXCB - 1)
     85 
     86 /*
     87  * Number of receive frame area buffers.  These are large, so
     88  * choose wisely.
     89  */
     90 #define	FXP_NRFABUFS	64
     91 
     92 /*
     93  * Maximum number of seconds that the reciever can be idle before we
     94  * assume it's dead and attempt to reset it by reprogramming the
     95  * multicast filter.  This is part of a work-around for a bug in the
     96  * NIC.  See fxp_stats_update().
     97  */
     98 #define	FXP_MAX_RX_IDLE	15
     99 
    100 /*
    101  * Misc. DMA'd data structures are allocated in a single clump, that
    102  * maps to a single DMA segment, to make several things easier (computing
    103  * offsets, setting up DMA maps, etc.)
    104  */
    105 struct fxp_control_data {
    106 	/*
    107 	 * The transmit control blocks.  The first if these
    108 	 * is also used as the config CB.
    109 	 */
    110 	struct fxp_cb_tx fcd_txcbs[FXP_NTXCB];
    111 
    112 	/*
    113 	 * The multicast setup CB.
    114 	 */
    115 	struct fxp_cb_mcs fcd_mcscb;
    116 
    117 	/*
    118 	 * The NIC statistics.
    119 	 */
    120 	struct fxp_stats fcd_stats;
    121 };
    122 
    123 #define	FXP_CDOFF(x)	offsetof(struct fxp_control_data, x)
    124 
    125 /*
    126  * Receive buffer descriptor (software only).  This is the analog of
    127  * the software portion of the fxp_cb_tx.
    128  */
    129 struct fxp_rxdesc {
    130 	struct fxp_rxdesc *fr_next;	/* next in the chain */
    131 	struct mbuf *fr_mbhead;		/* pointer to mbuf chain */
    132 	bus_dmamap_t fr_dmamap;		/* our DMA map */
    133 };
    134 
    135 struct fxp_softc {
    136 	struct device sc_dev;		/* generic device structures */
    137 	void *sc_ih;			/* interrupt handler cookie */
    138 	void *sc_sdhook;		/* shutdown hook */
    139 	bus_space_tag_t sc_st;		/* bus space tag */
    140 	bus_space_handle_t sc_sh;	/* bus space handle */
    141 	bus_dma_tag_t sc_dmat;		/* bus dma tag */
    142 	struct ethercom sc_ethercom;	/* ethernet common part */
    143 #define	sc_if		sc_ethercom.ec_if
    144 
    145 	/*
    146 	 * We create a single DMA map that maps all data structure
    147 	 * overhead, except for RFAs, which are mapped by the
    148 	 * fxp_rxdesc DMA map on a per-mbuf basis.
    149 	 */
    150 	bus_dmamap_t sc_dmamap;
    151 #define	sc_cddma	sc_dmamap->dm_segs[0].ds_addr
    152 
    153 	/*
    154 	 * These DMA maps map transmit and recieve buffers.
    155 	 */
    156 	bus_dmamap_t sc_tx_dmamaps[FXP_NTXCB];
    157 	bus_dmamap_t sc_rx_dmamaps[FXP_NRFABUFS];
    158 
    159 	/*
    160 	 * Control data - TxCBs, stats, etc.
    161 	 */
    162 	struct fxp_control_data *control_data;
    163 
    164 					/* receive buffer descriptors */
    165 	struct fxp_rxdesc sc_rxdescs[FXP_NRFABUFS];
    166 	struct mii_data sc_mii;		/* MII media information */
    167 	struct fxp_cb_tx *cbl_first;	/* first active TxCB in list */
    168 	struct fxp_cb_tx *cbl_last;	/* last active TxCB in list */
    169 	int tx_queued;			/* # of active TxCB's */
    170 	int need_mcsetup;		/* multicast filter needs programming */
    171 	struct fxp_rxdesc *rfa_head;	/* first mbuf in receive frame area */
    172 	struct fxp_rxdesc *rfa_tail;	/* last mbuf in receive frame area */
    173 	int rx_idle_secs;		/* # of seconds RX has been idle */
    174 	int all_mcasts;			/* receive all multicasts */
    175 	int promisc_mode;		/* promiscuous mode enabled */
    176 	int phy_primary_addr;		/* address of primary PHY */
    177 	int phy_primary_device;		/* device type of primary PHY */
    178 	int phy_10Mbps_only;		/* PHY is 10Mbps-only device */
    179 #if NRND > 0
    180 	rndsource_element_t rnd_source;	/* random source */
    181 #endif
    182 };
    183 
    184 /* Macros to ease CSR access. */
    185 #define	CSR_READ_1(sc, reg)						\
    186 	bus_space_read_1((sc)->sc_st, (sc)->sc_sh, (reg))
    187 #define	CSR_READ_2(sc, reg)						\
    188 	bus_space_read_2((sc)->sc_st, (sc)->sc_sh, (reg))
    189 #define	CSR_READ_4(sc, reg)						\
    190 	bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
    191 #define	CSR_WRITE_1(sc, reg, val)					\
    192 	bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val))
    193 #define	CSR_WRITE_2(sc, reg, val)					\
    194 	bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val))
    195 #define	CSR_WRITE_4(sc, reg, val)					\
    196 	bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
    197 
    198 void	fxp_attach __P((struct fxp_softc *));
    199 int	fxp_intr __P((void *));
    200