Home | History | Annotate | Line # | Download | only in ic
elinkxlvar.h revision 1.4
      1 /*	$NetBSD: elinkxlvar.h,v 1.4 2000/02/05 18:11:56 augustss Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Frank van der Linden.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the NetBSD
     21  *	Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #include "rnd.h"
     40 
     41 #if NRND > 0
     42 #include <sys/rnd.h>
     43 #endif
     44 
     45 /*
     46  * Ethernet software status per interface.
     47  */
     48 struct ex_softc {
     49 	struct device sc_dev;
     50 	void *sc_ih;
     51 
     52 	struct ethercom sc_ethercom;	/* Ethernet common part		*/
     53 	bus_space_tag_t sc_iot;		/* bus cookie			*/
     54 	bus_space_handle_t sc_ioh;	/* bus i/o handle		*/
     55 	bus_dma_tag_t sc_dmat;		/* bus dma tag */
     56 	bus_dmamap_t sc_dpd_dmamap;
     57 	bus_dmamap_t sc_upd_dmamap;
     58 #define sc_upddma	sc_upd_dmamap->dm_segs[0].ds_addr
     59 #define sc_dpddma	sc_dpd_dmamap->dm_segs[0].ds_addr
     60 	struct ex_upd *sc_upd;
     61 	struct ex_dpd *sc_dpd;
     62 	bus_dmamap_t sc_tx_dmamaps[EX_NDPD];	/* DMA maps for DPDs	*/
     63 	bus_dmamap_t sc_rx_dmamaps[EX_NUPD];	/* DMA maps for UPDs	*/
     64 	struct ex_rxdesc sc_rxdescs[EX_NUPD];
     65 	struct ex_txdesc sc_txdescs[EX_NDPD];
     66 
     67 	struct ex_rxdesc *rx_head;
     68 	struct ex_rxdesc *rx_tail;
     69 
     70 	struct ex_txdesc *tx_head;
     71 	struct ex_txdesc *tx_tail;
     72 	struct ex_txdesc *tx_free;
     73 	struct ex_txdesc *tx_ftail;
     74 
     75 	int tx_start_thresh;		/* Current TX_start_thresh.     */
     76 	int tx_succ_ok;			/* # packets sent in sequence   */
     77 
     78 	u_int ex_connectors;		/* Connectors on this card.	*/
     79 	mii_data_t ex_mii;		/* mii bus data 		*/
     80 	u_int ex_conf;			/* config flags */
     81 
     82 #define EX_CONF_MII		0x0001	/* has MII bus */
     83 #define EX_CONF_INTPHY		0x0002	/* has internal PHY */
     84 #define EX_CONF_90XB		0x0004	/* is 90xB */
     85 
     86 
     87 	/*
     88 	 * XXX code duplication from elink3var.h
     89 	 */
     90 	u_int	ex_flags;		/* capabilities flag (from EEPROM) */
     91 #define EX_FLAGS_PNP			0x0001
     92 #define EX_FLAGS_FULLDUPLEX		0x0002
     93 #define EX_FLAGS_LARGEPKT		0x0004	/* 4k packet support */
     94 #define EX_FLAGS_SLAVEDMA		0x0008
     95 #define EX_FLAGS_SECONDDMA		0x0010
     96 #define EX_FLAGS_FULLDMA		0x0020
     97 #define EX_FLAGS_FRAGMENTDMA		0x0040
     98 #define EX_FLAGS_CRC_PASSTHRU		0x0080
     99 #define EX_FLAGS_TXDONE			0x0100
    100 #define EX_FLAGS_NO_TXLENGTH		0x0200
    101 #define EX_FLAGS_RXREPEAT		0x0400
    102 #define EX_FLAGS_SNOOPING		0x0800
    103 #define EX_FLAGS_100MBIT		0x1000
    104 #define EX_FLAGS_POWERMGMT		0x2000
    105 
    106 	u_char	ex_bustype;		/* parent bus type (currently unused) */
    107 
    108 #define EX_BUS_PCI	0
    109 #define EX_BUS_CARDBUS	1
    110 
    111 #if NRND > 0
    112 	rndsource_element_t rnd_source;
    113 #endif
    114 
    115 	/* power management hooks */
    116 	int (*enable) __P((struct ex_softc *));
    117 	void (*disable) __P((struct ex_softc *));
    118 	int enabled;
    119 	/* interrupt acknowledge hook */
    120 	void (*intr_ack) __P((struct ex_softc *));
    121 
    122 	void *sc_sdhook;
    123 
    124 	bus_dma_segment_t sc_useg, sc_dseg;
    125 	int sc_urseg, sc_drseg;
    126 };
    127 
    128 #define ex_waitcmd(sc) \
    129 	while (bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, ELINK_STATUS) \
    130 		& S_COMMAND_IN_PROGRESS);
    131 
    132 u_int16_t exreadeeprom __P((bus_space_tag_t, bus_space_handle_t, int));
    133 void	ex_config __P((struct ex_softc *));
    134 
    135 int	ex_intr __P((void *));
    136 void	ex_stop __P((struct ex_softc *));
    137 void	ex_watchdog __P((struct ifnet *));
    138 int	ex_ioctl __P((struct ifnet *ifp, u_long, caddr_t));
    139 int	ex_activate __P((struct device *, enum devact));
    140 int	ex_detach __P((struct ex_softc *));
    141