1 /* $NetBSD: elinkxlvar.h,v 1.23 2011/11/19 22:51:22 tls 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 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include "rnd.h" 33 34 #if NRND > 0 35 #include <sys/rnd.h> 36 #endif 37 38 /* 39 * Ethernet software status per interface. 40 */ 41 struct ex_softc { 42 device_t sc_dev; 43 device_suspensor_t sc_suspensor; 44 pmf_qual_t sc_qual; 45 void *sc_ih; 46 47 struct ethercom sc_ethercom; /* Ethernet common part */ 48 bus_space_tag_t sc_iot; /* bus cookie */ 49 bus_space_handle_t sc_ioh; /* bus i/o handle */ 50 bus_dma_tag_t sc_dmat; /* bus dma tag */ 51 bus_dmamap_t sc_dpd_dmamap; 52 bus_dmamap_t sc_upd_dmamap; 53 #define sc_upddma sc_upd_dmamap->dm_segs[0].ds_addr 54 #define sc_dpddma sc_dpd_dmamap->dm_segs[0].ds_addr 55 struct ex_upd *sc_upd; 56 struct ex_dpd *sc_dpd; 57 bus_dmamap_t sc_tx_dmamaps[EX_NDPD]; /* DMA maps for DPDs */ 58 bus_dmamap_t sc_rx_dmamaps[EX_NUPD]; /* DMA maps for UPDs */ 59 struct ex_rxdesc sc_rxdescs[EX_NUPD]; 60 struct ex_txdesc sc_txdescs[EX_NDPD]; 61 62 struct ex_rxdesc *rx_head; 63 struct ex_rxdesc *rx_tail; 64 65 struct ex_txdesc *tx_head; 66 struct ex_txdesc *tx_tail; 67 struct ex_txdesc *tx_free; 68 struct ex_txdesc *tx_ftail; 69 70 int tx_start_thresh; /* Current TX_start_thresh. */ 71 int tx_succ_ok; /* # packets sent in sequence */ 72 73 u_int ex_connectors; /* Connectors on this card. */ 74 mii_data_t ex_mii; /* mii bus data */ 75 struct callout ex_mii_callout; /* mii callout */ 76 u_int ex_conf; /* config flags */ 77 78 #define EX_CONF_MII 0x0001 /* has MII bus */ 79 #define EX_CONF_INTPHY 0x0002 /* has internal PHY */ 80 #define EX_CONF_90XB 0x0004 /* is 90xB */ 81 #define EX_CONF_INV_LED_POLARITY 0x0010 /* CardBus & MiniPCI: LED polarity */ 82 #define EX_CONF_PHY_POWER 0x0020 /* CardBus & MiniPCI: PHY power */ 83 #define EX_CONF_EEPROM_OFF 0x0040 /* EEPROM is offset by 0x30 */ 84 #define EX_CONF_EEPROM_8BIT 0x0080 /* 8 bit EEPROM */ 85 #define EX_CONF_PCI_FUNCREG 0x0100 /* Has PCI function registers */ 86 #define EX_CONF_RESETHACK 0x0200 /* Hack to make reset work on 556B */ 87 #define EX_CONF_NO_XCVR_PWR 0x0400 /* Hack to enable later 556B xcvr */ 88 89 #define EX_XCVR_PWR_MAGICBITS 0x0900 /* NO_XCVR_PWR magic value */ 90 91 92 /* 93 * XXX code duplication from elink3var.h 94 */ 95 u_int ex_flags; /* capabilities flag (from EEPROM) */ 96 #define EX_FLAGS_PNP 0x0001 97 #define EX_FLAGS_FULLDUPLEX 0x0002 98 #define EX_FLAGS_LARGEPKT 0x0004 /* 4k packet support */ 99 #define EX_FLAGS_SLAVEDMA 0x0008 100 #define EX_FLAGS_SECONDDMA 0x0010 101 #define EX_FLAGS_FULLDMA 0x0020 102 #define EX_FLAGS_FRAGMENTDMA 0x0040 103 #define EX_FLAGS_CRC_PASSTHRU 0x0080 104 #define EX_FLAGS_TXDONE 0x0100 105 #define EX_FLAGS_NO_TXLENGTH 0x0200 106 #define EX_FLAGS_RXREPEAT 0x0400 107 #define EX_FLAGS_SNOOPING 0x0800 108 #define EX_FLAGS_100MBIT 0x1000 109 #define EX_FLAGS_POWERMGMT 0x2000 110 #define EX_FLAGS_ATTACHED 0x4000 /* attach has succeeded */ 111 112 #if NRND > 0 113 krndsource_t rnd_source; 114 #endif 115 116 /* power management hooks */ 117 int (*enable)(struct ex_softc *); 118 void (*disable)(struct ex_softc *); 119 int enabled; 120 121 /* interrupt acknowledge hook */ 122 void (*intr_ack)(struct ex_softc *); 123 124 bus_dma_segment_t sc_useg, sc_dseg; 125 int sc_urseg, sc_drseg; 126 127 short sc_if_flags; 128 }; 129 130 #define ex_waitcmd(sc) \ 131 do { \ 132 int stat; \ 133 do { \ 134 stat = bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, \ 135 ELINK_STATUS); \ 136 } while ((stat & COMMAND_IN_PROGRESS) && (stat != 0xffff)); \ 137 } while (0)\ 138 139 u_int16_t exreadeeprom(bus_space_tag_t, bus_space_handle_t, int); 140 void ex_config(struct ex_softc *); 141 142 int ex_intr(void *); 143 void ex_stop(struct ifnet *, int); 144 void ex_watchdog(struct ifnet *); 145 int ex_ioctl(struct ifnet *ifp, u_long, void *); 146 int ex_activate(device_t, enum devact); 147 int ex_detach(struct ex_softc *); 148 149 int ex_enable(struct ex_softc *); 150 void ex_disable(struct ex_softc *); 151