Home | History | Annotate | Line # | Download | only in ic
tulipvar.h revision 1.10
      1  1.10  thorpej /*	$NetBSD: tulipvar.h,v 1.10 1999/09/14 23:33:05 thorpej Exp $	*/
      2   1.1  thorpej 
      3   1.1  thorpej /*-
      4   1.1  thorpej  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
      5   1.1  thorpej  * All rights reserved.
      6   1.1  thorpej  *
      7   1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1  thorpej  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9   1.1  thorpej  * NASA Ames Research Center.
     10   1.1  thorpej  *
     11   1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     12   1.1  thorpej  * modification, are permitted provided that the following conditions
     13   1.1  thorpej  * are met:
     14   1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     15   1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     16   1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     17   1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     18   1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     19   1.1  thorpej  * 3. All advertising materials mentioning features or use of this software
     20   1.1  thorpej  *    must display the following acknowledgement:
     21   1.1  thorpej  *	This product includes software developed by the NetBSD
     22   1.1  thorpej  *	Foundation, Inc. and its contributors.
     23   1.1  thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24   1.1  thorpej  *    contributors may be used to endorse or promote products derived
     25   1.1  thorpej  *    from this software without specific prior written permission.
     26   1.1  thorpej  *
     27   1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28   1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29   1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30   1.1  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31   1.1  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32   1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33   1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34   1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35   1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36   1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37   1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     38   1.1  thorpej  */
     39   1.1  thorpej 
     40   1.1  thorpej #ifndef _DEV_IC_TULIPVAR_H_
     41   1.1  thorpej #define _DEV_IC_TULIPVAR_H_
     42   1.1  thorpej 
     43   1.1  thorpej #include <sys/queue.h>
     44   1.1  thorpej 
     45   1.1  thorpej /*
     46   1.1  thorpej  * Misc. definitions for the Digital Semiconductor ``Tulip'' (21x4x)
     47   1.1  thorpej  * Ethernet controller family driver.
     48   1.1  thorpej  */
     49   1.1  thorpej 
     50   1.1  thorpej /*
     51   1.1  thorpej  * Transmit descriptor list size.  This is arbitrary, but allocate
     52   1.1  thorpej  * enough descriptors for 64 pending transmissions and 16 segments
     53   1.1  thorpej  * per packet.  Since a descriptor holds 2 buffer addresses, that's
     54   1.1  thorpej  * 8 descriptors per packet.  This MUST work out to a power of 2.
     55   1.1  thorpej  */
     56   1.1  thorpej #define	TULIP_NTXSEGS		16
     57   1.1  thorpej 
     58   1.1  thorpej #define	TULIP_TXQUEUELEN	64
     59   1.1  thorpej #define	TULIP_NTXDESC		(TULIP_TXQUEUELEN * TULIP_NTXSEGS)
     60   1.1  thorpej #define	TULIP_NTXDESC_MASK	(TULIP_NTXDESC - 1)
     61   1.1  thorpej #define	TULIP_NEXTTX(x)		((x + 1) & TULIP_NTXDESC_MASK)
     62   1.1  thorpej 
     63   1.1  thorpej /*
     64   1.1  thorpej  * Receive descriptor list size.  We have one Rx buffer per incoming
     65   1.1  thorpej  * packet, so this logic is a little simpler.
     66   1.1  thorpej  */
     67   1.1  thorpej #define	TULIP_NRXDESC		64
     68   1.1  thorpej #define	TULIP_NRXDESC_MASK	(TULIP_NRXDESC - 1)
     69   1.1  thorpej #define	TULIP_NEXTRX(x)		((x + 1) & TULIP_NRXDESC_MASK)
     70   1.1  thorpej 
     71   1.1  thorpej /*
     72   1.1  thorpej  * Control structures are DMA'd to the TULIP chip.  We allocate them in
     73   1.1  thorpej  * a single clump that maps to a single DMA segment to make several things
     74   1.1  thorpej  * easier.
     75   1.1  thorpej  */
     76   1.1  thorpej struct tulip_control_data {
     77   1.1  thorpej 	/*
     78   1.1  thorpej 	 * The transmit descriptors.
     79   1.1  thorpej 	 */
     80   1.1  thorpej 	struct tulip_desc tcd_txdescs[TULIP_NTXDESC];
     81   1.1  thorpej 
     82   1.1  thorpej 	/*
     83   1.1  thorpej 	 * The receive descriptors.
     84   1.1  thorpej 	 */
     85   1.1  thorpej 	struct tulip_desc tcd_rxdescs[TULIP_NRXDESC];
     86   1.1  thorpej 
     87   1.1  thorpej 	/*
     88   1.1  thorpej 	 * The setup descriptor.
     89   1.1  thorpej 	 */
     90   1.1  thorpej 	struct tulip_desc tcd_setup_desc;
     91   1.1  thorpej 
     92   1.1  thorpej 	/*
     93   1.1  thorpej 	 * The setup packet.
     94   1.1  thorpej 	 */
     95   1.1  thorpej 	u_int32_t tcd_setup_packet[TULIP_SETUP_PACKET_LEN / sizeof(u_int32_t)];
     96   1.1  thorpej };
     97   1.1  thorpej 
     98   1.1  thorpej #define	TULIP_CDOFF(x)		offsetof(struct tulip_control_data, x)
     99   1.1  thorpej #define	TULIP_CDTXOFF(x)	TULIP_CDOFF(tcd_txdescs[(x)])
    100   1.1  thorpej #define	TULIP_CDRXOFF(x)	TULIP_CDOFF(tcd_rxdescs[(x)])
    101   1.1  thorpej #define	TULIP_CDSDOFF		TULIP_CDOFF(tcd_setup_desc)
    102   1.1  thorpej #define	TULIP_CDSPOFF		TULIP_CDOFF(tcd_setup_packet)
    103   1.1  thorpej 
    104   1.1  thorpej /*
    105   1.1  thorpej  * Software state for transmit jobs.
    106   1.1  thorpej  */
    107   1.1  thorpej struct tulip_txsoft {
    108   1.1  thorpej 	struct mbuf *txs_mbuf;		/* head of our mbuf chain */
    109   1.1  thorpej 	bus_dmamap_t txs_dmamap;	/* our DMA map */
    110   1.1  thorpej 	int txs_firstdesc;		/* first descriptor in packet */
    111   1.1  thorpej 	int txs_lastdesc;		/* last descriptor in packet */
    112   1.1  thorpej 	SIMPLEQ_ENTRY(tulip_txsoft) txs_q;
    113   1.1  thorpej };
    114   1.1  thorpej 
    115   1.1  thorpej SIMPLEQ_HEAD(tulip_txsq, tulip_txsoft);
    116   1.1  thorpej 
    117   1.1  thorpej /*
    118   1.1  thorpej  * Software state for receive jobs.
    119   1.1  thorpej  */
    120   1.1  thorpej struct tulip_rxsoft {
    121   1.1  thorpej 	struct mbuf *rxs_mbuf;		/* head of our mbuf chain */
    122   1.1  thorpej 	bus_dmamap_t rxs_dmamap;	/* our DMA map */
    123   1.1  thorpej };
    124   1.1  thorpej 
    125   1.1  thorpej /*
    126   1.1  thorpej  * Type of Tulip chip we're dealing with.
    127   1.1  thorpej  */
    128   1.1  thorpej typedef enum {
    129   1.1  thorpej 	TULIP_CHIP_INVALID   = 0,	/* invalid chip type */
    130   1.1  thorpej 	TULIP_CHIP_DE425     = 1,	/* DE-425 EISA */
    131   1.1  thorpej 	TULIP_CHIP_21040     = 2,	/* DECchip 21040 */
    132   1.1  thorpej 	TULIP_CHIP_21041     = 3,	/* DECchip 21041 */
    133   1.1  thorpej 	TULIP_CHIP_21140     = 4,	/* DECchip 21140 */
    134   1.1  thorpej 	TULIP_CHIP_21140A    = 5,	/* DECchip 21140A */
    135   1.1  thorpej 	TULIP_CHIP_21142     = 6,	/* DECchip 21142 */
    136   1.1  thorpej 	TULIP_CHIP_21143     = 7,	/* DECchip 21143 */
    137   1.1  thorpej 	TULIP_CHIP_82C168    = 8,	/* Lite-On 82C168 PNIC */
    138   1.1  thorpej 	TULIP_CHIP_82C169    = 9,	/* Lite-On 82C169 PNIC */
    139   1.5  thorpej 	TULIP_CHIP_82C115    = 10,	/* Lite-On 82C115 PNIC II */
    140   1.5  thorpej 	TULIP_CHIP_MX98713   = 11,	/* Macronix 98713 PMAC */
    141   1.5  thorpej 	TULIP_CHIP_MX98713A  = 12,	/* Macronix 98713A PMAC */
    142   1.5  thorpej 	TULIP_CHIP_MX98715   = 13,	/* Macronix 98715, 98715A PMAC */
    143   1.5  thorpej 	TULIP_CHIP_MX98725   = 14,	/* Macronix 98725 PMAC */
    144   1.5  thorpej 	TULIP_CHIP_WB89C840F = 15,	/* Winbond 89C840F */
    145   1.5  thorpej 	TULIP_CHIP_DM9102    = 16,	/* Davicom DM9102 */
    146   1.5  thorpej 	TULIP_CHIP_AL981     = 17,	/* ADMtek AL981 */
    147   1.5  thorpej 	TULIP_CHIP_AX88140   = 18,	/* ASIX AX88140 */
    148   1.5  thorpej 	TULIP_CHIP_AX88141   = 19,	/* ASIX AX88141 */
    149   1.1  thorpej } tulip_chip_t;
    150   1.1  thorpej 
    151   1.1  thorpej #define	TULIP_CHIP_NAMES						\
    152   1.1  thorpej {									\
    153   1.1  thorpej 	NULL,								\
    154   1.1  thorpej 	"DE-425",							\
    155   1.1  thorpej 	"DECchip 21040",						\
    156   1.1  thorpej 	"DECchip 21041",						\
    157   1.1  thorpej 	"DECchip 21140",						\
    158   1.1  thorpej 	"DECchip 21140A",						\
    159   1.1  thorpej 	"DECchip 21142",						\
    160   1.1  thorpej 	"DECchip 21143",						\
    161   1.1  thorpej 	"Lite-On 82C168",						\
    162   1.1  thorpej 	"Lite-On 82C169",						\
    163   1.5  thorpej 	"Lite-On 82C115",						\
    164   1.1  thorpej 	"Macronix MX98713",						\
    165   1.1  thorpej 	"Macronix MX98713A",						\
    166   1.1  thorpej 	"Macronix MX98715",						\
    167   1.1  thorpej 	"Macronix MX98725",						\
    168   1.1  thorpej 	"Winbond 89C840F",						\
    169   1.5  thorpej 	"Davicom DM9102",						\
    170   1.5  thorpej 	"ADMtek AL981",							\
    171   1.5  thorpej 	"ASIX AX88140",							\
    172   1.5  thorpej 	"ASIX AX88141",							\
    173   1.1  thorpej }
    174   1.1  thorpej 
    175   1.1  thorpej struct tulip_softc;
    176   1.1  thorpej 
    177   1.1  thorpej /*
    178   1.1  thorpej  * Media init, change, status function pointers.
    179   1.1  thorpej  */
    180   1.1  thorpej struct tulip_mediasw {
    181   1.1  thorpej 	void	(*tmsw_init) __P((struct tulip_softc *));
    182   1.1  thorpej 	void	(*tmsw_get) __P((struct tulip_softc *, struct ifmediareq *));
    183   1.1  thorpej 	int	(*tmsw_set) __P((struct tulip_softc *));
    184   1.1  thorpej };
    185   1.1  thorpej 
    186   1.1  thorpej /*
    187   1.1  thorpej  * Table which describes the transmit threshold mode.
    188   1.1  thorpej  */
    189   1.1  thorpej struct tulip_txthresh_tab {
    190   1.1  thorpej 	u_int32_t txth_opmode;		/* OPMODE bits */
    191   1.1  thorpej 	const char *txth_name;		/* name of mode */
    192   1.1  thorpej };
    193   1.1  thorpej 
    194   1.1  thorpej /*
    195   1.7  thorpej  * Description of 21040/21041 SIA media.
    196   1.7  thorpej  */
    197   1.7  thorpej struct tulip_21040_21041_sia_media {
    198   1.7  thorpej 	u_int32_t	tsm_siaconn;	/* CSR13 value */
    199   1.7  thorpej 	u_int32_t	tsm_siatxrx;	/* CSR14 value */
    200   1.7  thorpej 	u_int32_t	tsm_siagen;	/* CSR15 value */
    201   1.7  thorpej };
    202   1.7  thorpej 
    203   1.7  thorpej /*
    204   1.1  thorpej  * Software state per device.
    205   1.1  thorpej  */
    206   1.1  thorpej struct tulip_softc {
    207   1.1  thorpej 	struct device sc_dev;		/* generic device information */
    208   1.1  thorpej 	bus_space_tag_t sc_st;		/* bus space tag */
    209   1.1  thorpej 	bus_space_handle_t sc_sh;	/* bus space handle */
    210   1.1  thorpej 	bus_dma_tag_t sc_dmat;		/* bus DMA tag */
    211   1.1  thorpej 	struct ethercom sc_ethercom;	/* ethernet common data */
    212   1.1  thorpej 	void *sc_sdhook;		/* shutdown hook */
    213   1.1  thorpej 
    214   1.1  thorpej 	/*
    215   1.7  thorpej 	 * Contents of the SROM.
    216   1.7  thorpej 	 */
    217   1.7  thorpej 	u_int8_t sc_srom[TULIP_MAX_ROM_SIZE];
    218   1.7  thorpej 
    219   1.7  thorpej 	/*
    220   1.1  thorpej 	 * Media access functions for this chip.
    221   1.1  thorpej 	 */
    222   1.1  thorpej 	const struct tulip_mediasw *sc_mediasw;
    223   1.1  thorpej 
    224   1.6  thorpej 	/*
    225   1.6  thorpej 	 * For chips with built-in NWay blocks, these are state
    226   1.6  thorpej 	 * variables required for autonegotiation.
    227   1.6  thorpej 	 */
    228   1.6  thorpej 	int		sc_nway_ticks;	/* tick counter */
    229   1.6  thorpej 	int		sc_nway_active;	/* last active media */
    230   1.6  thorpej 
    231   1.1  thorpej 	tulip_chip_t	sc_chip;	/* chip type */
    232   1.1  thorpej 	int		sc_rev;		/* chip revision */
    233   1.1  thorpej 	int		sc_flags;	/* misc flags. */
    234   1.9  thorpej 	char		sc_name[16];	/* board name */
    235   1.1  thorpej 	u_int32_t	sc_cacheline;	/* cache line size */
    236  1.10  thorpej 	int		sc_devno;	/* PCI device # */
    237   1.1  thorpej 
    238   1.1  thorpej 	struct mii_data sc_mii;		/* MII/media information */
    239   1.1  thorpej 
    240   1.1  thorpej 	const struct tulip_txthresh_tab *sc_txth;
    241   1.1  thorpej 	int		sc_txthresh;	/* current transmit threshold */
    242   1.1  thorpej 
    243   1.1  thorpej 	/* Filter setup function. */
    244   1.1  thorpej 	void		(*sc_filter_setup) __P((struct tulip_softc *));
    245   1.1  thorpej 
    246   1.6  thorpej 	/* Media status update function. */
    247   1.4  thorpej 	void		(*sc_statchg) __P((struct device *));
    248   1.4  thorpej 
    249   1.6  thorpej 	/* Media tick function. */
    250   1.6  thorpej 	void		(*sc_tick) __P((void *));
    251   1.6  thorpej 
    252   1.1  thorpej 	/*
    253   1.1  thorpej 	 * The Winbond 89C840F places registers 4 bytes apart, instead
    254   1.1  thorpej 	 * of 8.
    255   1.1  thorpej 	 */
    256   1.1  thorpej 	int		sc_regshift;
    257   1.1  thorpej 
    258   1.1  thorpej 	u_int32_t	sc_busmode;	/* copy of CSR_BUSMODE */
    259   1.1  thorpej 	u_int32_t	sc_opmode;	/* copy of CSR_OPMODE */
    260   1.1  thorpej 	u_int32_t	sc_inten;	/* copy of CSR_INTEN */
    261   1.4  thorpej 
    262   1.4  thorpej 	u_int32_t	sc_rxint_mask;	/* mask of Rx interrupts we want */
    263   1.4  thorpej 	u_int32_t	sc_txint_mask;	/* mask of Tx interrupts we want */
    264   1.1  thorpej 
    265   1.1  thorpej 	u_int32_t	sc_filtmode;	/* filter mode we're using */
    266   1.1  thorpej 
    267   1.1  thorpej 	bus_dmamap_t sc_cddmamap;	/* control data DMA map */
    268   1.1  thorpej #define	sc_cddma	sc_cddmamap->dm_segs[0].ds_addr
    269   1.1  thorpej 
    270   1.1  thorpej 	/*
    271   1.1  thorpej 	 * Software state for transmit and receive descriptors.
    272   1.1  thorpej 	 */
    273   1.1  thorpej 	struct tulip_txsoft sc_txsoft[TULIP_TXQUEUELEN];
    274   1.1  thorpej 	struct tulip_rxsoft sc_rxsoft[TULIP_NRXDESC];
    275   1.1  thorpej 
    276   1.1  thorpej 	/*
    277   1.1  thorpej 	 * Control data structures.
    278   1.1  thorpej 	 */
    279   1.1  thorpej 	struct tulip_control_data *sc_control_data;
    280   1.1  thorpej #define	sc_txdescs	sc_control_data->tcd_txdescs
    281   1.1  thorpej #define	sc_rxdescs	sc_control_data->tcd_rxdescs
    282   1.1  thorpej #define	sc_setup_desc	sc_control_data->tcd_setup_desc
    283   1.1  thorpej 
    284   1.1  thorpej 	int	sc_txfree;		/* number of free Tx descriptors */
    285   1.1  thorpej 	int	sc_txnext;		/* next ready Tx descriptor */
    286   1.1  thorpej 
    287   1.1  thorpej 	struct tulip_txsq sc_txfreeq;	/* free Tx descsofts */
    288   1.1  thorpej 	struct tulip_txsq sc_txdirtyq;	/* dirty Tx descsofts */
    289   1.1  thorpej 
    290   1.1  thorpej 	int	sc_rxptr;		/* next ready RX descriptor/descsoft */
    291   1.1  thorpej };
    292   1.1  thorpej 
    293   1.1  thorpej /* sc_flags */
    294   1.1  thorpej #define	TULIPF_WANT_SETUP	0x00000001	/* want filter setup */
    295   1.3  thorpej #define	TULIPF_DOING_SETUP	0x00000002	/* doing multicast setup */
    296   1.3  thorpej #define	TULIPF_HAS_MII		0x00000004	/* has media on MII */
    297   1.3  thorpej #define	TULIPF_IC_FS		0x00000008	/* IC bit on first tx seg */
    298   1.6  thorpej #define	TULIPF_LINK_UP		0x00000010	/* link is up (non-MII) */
    299   1.6  thorpej #define	TULIPF_DOINGAUTO	0x00000020	/* doing autoneg (non-MII) */
    300   1.1  thorpej 
    301   1.1  thorpej #define	TULIP_CDTXADDR(sc, x)	((sc)->sc_cddma + TULIP_CDTXOFF((x)))
    302   1.1  thorpej #define	TULIP_CDRXADDR(sc, x)	((sc)->sc_cddma + TULIP_CDRXOFF((x)))
    303   1.1  thorpej 
    304   1.1  thorpej #define	TULIP_CDSDADDR(sc)	((sc)->sc_cddma + TULIP_CDSDOFF)
    305   1.1  thorpej #define	TULIP_CDSPADDR(sc)	((sc)->sc_cddma + TULIP_CDSPOFF)
    306   1.1  thorpej 
    307   1.1  thorpej #define	TULIP_CDSP(sc)		((sc)->sc_control_data->tcd_setup_packet)
    308   1.1  thorpej 
    309   1.1  thorpej #define	TULIP_CDTXSYNC(sc, x, n, ops)					\
    310   1.1  thorpej do {									\
    311   1.1  thorpej 	int __x, __n;							\
    312   1.1  thorpej 									\
    313   1.1  thorpej 	__x = (x);							\
    314   1.1  thorpej 	__n = (n);							\
    315   1.1  thorpej 									\
    316   1.1  thorpej 	/* If it will wrap around, sync to the end of the ring. */	\
    317   1.1  thorpej 	if ((__x + __n) > TULIP_NTXDESC) {				\
    318   1.1  thorpej 		bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,	\
    319   1.1  thorpej 		    TULIP_CDTXOFF(__x), sizeof(struct tulip_desc) *	\
    320   1.1  thorpej 		    (TULIP_NTXDESC - __x), (ops));			\
    321   1.1  thorpej 		__n -= (TULIP_NTXDESC - __x);				\
    322   1.1  thorpej 		__x = 0;						\
    323   1.1  thorpej 	}								\
    324   1.1  thorpej 									\
    325   1.1  thorpej 	/* Now sync whatever is left. */				\
    326   1.1  thorpej 	bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,		\
    327   1.1  thorpej 	    TULIP_CDTXOFF(__x), sizeof(struct tulip_desc) * __n, (ops)); \
    328   1.1  thorpej } while (0)
    329   1.1  thorpej 
    330   1.1  thorpej #define	TULIP_CDRXSYNC(sc, x, ops)					\
    331   1.1  thorpej 	bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,		\
    332   1.1  thorpej 	    TULIP_CDRXOFF((x)), sizeof(struct tulip_desc), (ops))
    333   1.1  thorpej 
    334   1.1  thorpej #define	TULIP_CDSDSYNC(sc, ops)						\
    335   1.1  thorpej 	bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,		\
    336   1.1  thorpej 	    TULIP_CDSDOFF, sizeof(struct tulip_desc), (ops))
    337   1.1  thorpej 
    338   1.1  thorpej #define	TULIP_CDSPSYNC(sc, ops)						\
    339   1.1  thorpej 	bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,		\
    340   1.1  thorpej 	    TULIP_CDSPOFF, TULIP_SETUP_PACKET_LEN, (ops))
    341   1.1  thorpej 
    342   1.1  thorpej /*
    343   1.1  thorpej  * Note we rely on MCLBYTES being a power of two.  Because the `length'
    344   1.1  thorpej  * field is only 11 bits, we must subtract 1 from the length to avoid
    345   1.1  thorpej  * having it truncated to 0!
    346   1.1  thorpej  */
    347   1.1  thorpej #define	TULIP_INIT_RXDESC(sc, x)					\
    348   1.1  thorpej do {									\
    349   1.1  thorpej 	struct tulip_rxsoft *__rxs = &sc->sc_rxsoft[(x)];		\
    350   1.1  thorpej 	struct tulip_desc *__rxd = &sc->sc_rxdescs[(x)];		\
    351   1.1  thorpej 	struct mbuf *__m = __rxs->rxs_mbuf;				\
    352   1.1  thorpej 									\
    353   1.1  thorpej 	__m->m_data = __m->m_ext.ext_buf;				\
    354   1.1  thorpej 	__rxd->td_bufaddr1 = __rxs->rxs_dmamap->dm_segs[0].ds_addr;	\
    355   1.1  thorpej 	__rxd->td_bufaddr2 = TULIP_CDRXADDR((sc), TULIP_NEXTRX((x)));	\
    356   1.1  thorpej 	__rxd->td_ctl =							\
    357   1.1  thorpej 	    ((__m->m_ext.ext_size - 1) << TDCTL_SIZE1_SHIFT) | TDCTL_CH; \
    358   1.1  thorpej 	__rxd->td_status = TDSTAT_OWN|TDSTAT_Rx_FS|TDSTAT_Rx_LS;	\
    359   1.1  thorpej 	TULIP_CDRXSYNC((sc), (x), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); \
    360   1.1  thorpej } while (0)
    361   1.1  thorpej 
    362   1.1  thorpej /* CSR access */
    363   1.8  thorpej #define	TULIP_CSR_OFFSET(sc, csr)					\
    364   1.8  thorpej 	(TULIP_CSR_INDEX(csr) << (sc)->sc_regshift)
    365   1.8  thorpej 
    366   1.1  thorpej #define	TULIP_READ(sc, reg)						\
    367   1.1  thorpej 	bus_space_read_4((sc)->sc_st, (sc)->sc_sh,			\
    368   1.8  thorpej 	    TULIP_CSR_OFFSET((sc), (reg)))
    369   1.1  thorpej 
    370   1.1  thorpej #define	TULIP_WRITE(sc, reg, val)					\
    371   1.1  thorpej 	bus_space_write_4((sc)->sc_st, (sc)->sc_sh,			\
    372   1.8  thorpej 	    TULIP_CSR_OFFSET((sc), (reg)), (val))
    373   1.1  thorpej 
    374   1.1  thorpej #define	TULIP_SET(sc, reg, mask)					\
    375   1.1  thorpej 	TULIP_WRITE((sc), (reg), TULIP_READ((sc), (reg)) | (mask))
    376   1.1  thorpej 
    377   1.1  thorpej #define	TULIP_CLR(sc, reg, mask)					\
    378   1.1  thorpej 	TULIP_WRITE((sc), (reg), TULIP_READ((sc), (reg)) & ~(mask))
    379   1.1  thorpej 
    380   1.1  thorpej #define	TULIP_ISSET(sc, reg, mask)					\
    381   1.1  thorpej 	(TULIP_READ((sc), (reg)) & (mask))
    382   1.1  thorpej 
    383   1.1  thorpej #ifdef _KERNEL
    384   1.7  thorpej extern const struct tulip_mediasw tlp_21040_mediasw;
    385   1.7  thorpej extern const struct tulip_mediasw tlp_21040_tp_mediasw;
    386   1.7  thorpej extern const struct tulip_mediasw tlp_21040_auibnc_mediasw;
    387   1.1  thorpej extern const struct tulip_mediasw tlp_sio_mii_mediasw;
    388   1.1  thorpej extern const struct tulip_mediasw tlp_pnic_mediasw;
    389   1.1  thorpej 
    390   1.9  thorpej void	tlp_attach __P((struct tulip_softc *, const u_int8_t *));
    391   1.1  thorpej int	tlp_intr __P((void *));
    392   1.1  thorpej void	tlp_read_srom __P((struct tulip_softc *, int, int, u_int16_t *));
    393   1.1  thorpej int	tlp_srom_crcok __P((u_int8_t *));
    394   1.7  thorpej int	tlp_parse_old_srom __P((struct tulip_softc *, u_int8_t *));
    395   1.1  thorpej 
    396   1.1  thorpej int	tlp_mediachange __P((struct ifnet *));
    397   1.1  thorpej void	tlp_mediastatus __P((struct ifnet *, struct ifmediareq *));
    398   1.1  thorpej #endif /* _KERNEL */
    399   1.1  thorpej 
    400   1.1  thorpej #endif /* _DEV_IC_TULIPVAR_H_ */
    401