1 /* $NetBSD: if_tlvar.h,v 1.12 2005/12/11 12:22:50 christos Exp $ */ 2 3 /* 4 * Copyright (c) 1997 Manuel Bouyer. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by Manuel Bouyer. 17 * 4. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * Texas Instruments ThunderLAN ethernet controller 34 * ThunderLAN Programmer's Guide (TI Literature Number SPWU013A) 35 * available from www.ti.com 36 */ 37 38 #include "rnd.h" 39 40 #if NRND > 0 41 #include <sys/rnd.h> 42 #endif 43 44 #include <dev/i2c/i2cvar.h> 45 46 struct tl_product_desc { 47 u_int32_t tp_product; 48 int tp_tlphymedia; 49 const char *tp_desc; 50 }; 51 52 struct tl_softc { 53 struct device sc_dev; /* base device */ 54 bus_space_tag_t tl_bustag; 55 bus_space_handle_t tl_bushandle; /* CSR region handle */ 56 bus_dma_tag_t tl_dmatag; 57 const struct tl_product_desc *tl_product; 58 void* tl_ih; 59 struct ethercom tl_ec; 60 struct callout tl_tick_ch; /* tick callout */ 61 struct callout tl_restart_ch; /* restart callout */ 62 u_int8_t tl_enaddr[ETHER_ADDR_LEN]; /* hardware address */ 63 struct i2c_controller sc_i2c; /* i2c controller info, for eeprom */ 64 mii_data_t tl_mii; /* mii bus */ 65 bus_dma_segment_t ctrl_segs; /* bus-dma memory for control blocks */ 66 int ctrl_nsegs; 67 char *ctrl; /* vaddr for ctrl_segs */ 68 struct Rx_list *Rx_list; /* Receive and transmit lists */ 69 struct tl_Rx_list *hw_Rx_list; /* and assocoated hw descriptor */ 70 bus_dmamap_t Rx_dmamap; /* and associated DMA maps */ 71 struct Tx_list *Tx_list; 72 struct tl_Tx_list *hw_Tx_list; 73 bus_dmamap_t Tx_dmamap; 74 struct Rx_list *active_Rx, *last_Rx; 75 struct Tx_list *active_Tx, *last_Tx; 76 struct Tx_list *Free_Tx; 77 bus_dmamap_t null_dmamap; /* for small packets padding */ 78 #ifdef TL_PRIV_STATS 79 int ierr_overr; 80 int ierr_code; 81 int ierr_crc; 82 int ierr_nomem; 83 int oerr_underr; 84 int oerr_deferred; 85 int oerr_coll; 86 int oerr_multicoll; 87 int oerr_latecoll; 88 int oerr_exesscoll; 89 int oerr_carrloss; 90 int oerr_mcopy; 91 #endif 92 #if NRND > 0 93 rndsource_element_t rnd_source; 94 #endif 95 }; 96 #define tl_if tl_ec.ec_if 97 #define tl_bpf tl_if.if_bpf 98 99 typedef struct tl_softc tl_softc_t; 100 typedef u_long ioctl_cmd_t; 101 102 #define TL_HR_READ(sc, reg) \ 103 bus_space_read_4(sc->tl_bustag, sc->tl_bushandle, (reg)) 104 #define TL_HR_READ_BYTE(sc, reg) \ 105 bus_space_read_1(sc->tl_bustag, sc->tl_bushandle, (reg)) 106 #define TL_HR_WRITE(sc, reg, data) \ 107 bus_space_write_4(sc->tl_bustag, sc->tl_bushandle, (reg), (data)) 108 #define TL_HR_WRITE_BYTE(sc, reg, data) \ 109 bus_space_write_1(sc->tl_bustag, sc->tl_bushandle, (reg), (data)) 110 #define ETHER_MIN_TX (ETHERMIN + sizeof(struct ether_header)) 111