midwayvar.h revision 92739
1/* $NetBSD: midwayvar.h,v 1.10 1997/03/20 21:34:46 chuck Exp $ */ 2 3/* 4 * 5 * Copyright (c) 1996 Charles D. Cranor and Washington University. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Charles D. Cranor and 19 * Washington University. 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * $FreeBSD: head/sys/dev/en/midwayvar.h 92739 2002-03-20 02:08:01Z alfred $ 35 */ 36 37/* 38 * m i d w a y v a r . h 39 * 40 * we define the en_softc here so that bus specific modules can allocate 41 * it as the first item in their softc. note that BSD-required 42 * "struct device" is in the mid_softc! 43 * 44 * author: Chuck Cranor <chuck@ccrc.wustl.edu> 45 */ 46 47/* 48 * params needed to determine softc size 49 */ 50 51#ifndef EN_NTX 52#define EN_NTX 8 /* number of tx bufs to use */ 53#endif 54#ifndef EN_TXSZ 55#define EN_TXSZ 32 /* trasmit buf size in KB */ 56#endif 57#ifndef EN_RXSZ 58#define EN_RXSZ 32 /* recv buf size in KB */ 59#endif 60#define EN_MAXNRX ((2048-(EN_NTX*EN_TXSZ))/EN_RXSZ) 61 /* largest possible NRX (depends on RAM size) */ 62 63 64#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) 65#define EN_INTR_TYPE int 66#define EN_INTR_RET(X) return(X) 67#if defined(__NetBSD__) || defined(__OpenBSD__) 68#define EN_IOCTL_CMDT u_long 69#elif defined(__bsdi__) 70#define EN_IOCTL_CMDT int 71#endif 72 73#elif defined(__FreeBSD__) 74 75#define EN_INTR_TYPE void 76#define EN_INTR_RET(X) return 77#define EN_IOCTL_CMDT u_long 78 79struct device { 80 char dv_xname[IFNAMSIZ]; 81}; 82 83#define DV_IFNET 1 84 85#endif 86 87/* 88 * softc 89 */ 90 91struct en_softc { 92 /* bsd glue */ 93 struct device sc_dev; /* system device */ 94 struct ifnet enif; /* network ifnet handle */ 95 96 /* bus glue */ 97 bus_space_tag_t en_memt; /* for EN_READ/EN_WRITE */ 98 bus_space_handle_t en_base; /* base of en card */ 99 bus_size_t en_obmemsz; /* size of en card (bytes) */ 100 void (*en_busreset)(void *); 101 /* bus specific reset function */ 102 103 /* serv list */ 104 u_int32_t hwslistp; /* hw pointer to service list (byte offset) */ 105 u_int16_t swslist[MID_SL_N]; /* software service list (see en_service()) */ 106 u_int16_t swsl_head, /* ends of swslist (index into swslist) */ 107 swsl_tail; 108 u_int32_t swsl_size; /* # of items in swsl */ 109 110 111 /* xmit dma */ 112 u_int32_t dtq[MID_DTQ_N]; /* sw copy of dma q (see ENIDQ macros) */ 113 u_int32_t dtq_free; /* # of dtq's free */ 114 u_int32_t dtq_us; /* software copy of our pointer (byte offset) */ 115 u_int32_t dtq_chip; /* chip's pointer (byte offset) */ 116 u_int32_t need_dtqs; /* true if we ran out of DTQs */ 117 118 /* recv dma */ 119 u_int32_t drq[MID_DRQ_N]; /* sw copy of dma q (see ENIDQ macros) */ 120 u_int32_t drq_free; /* # of drq's free */ 121 u_int32_t drq_us; /* software copy of our pointer (byte offset) */ 122 u_int32_t drq_chip; /* chip's pointer (byte offset) */ 123 u_int32_t need_drqs; /* true if we ran out of DRQs */ 124 125 /* xmit buf ctrl. (per channel) */ 126 struct { 127 u_int32_t mbsize; /* # mbuf bytes we are using (max=TXHIWAT) */ 128 u_int32_t bfree; /* # free bytes in buffer (not dma or xmit) */ 129 u_int32_t start, stop; /* ends of buffer area (byte offset) */ 130 u_int32_t cur; /* next free area (byte offset) */ 131 u_int32_t nref; /* # of VCs using this channel */ 132 struct ifqueue indma; /* mbufs being dma'd now */ 133 struct ifqueue q; /* mbufs waiting for dma now */ 134 } txslot[MID_NTX_CH]; 135 136 /* xmit vc ctrl. (per vc) */ 137 u_int8_t txspeed[MID_N_VC]; /* speed of tx on a VC */ 138 u_int8_t txvc2slot[MID_N_VC]; /* map VC to slot */ 139 140 /* recv vc ctrl. (per vc). maps VC number to recv slot */ 141 u_int16_t rxvc2slot[MID_N_VC]; 142 int en_nrx; /* # of active rx slots */ 143 144 /* recv buf ctrl. (per recv slot) */ 145 struct { 146 void *rxhand; /* recv. handle if doing direct delivery */ 147 u_int32_t mode; /* saved copy of mode info */ 148 u_int32_t start, stop; /* ends of my buffer area */ 149 u_int32_t cur; /* where I am at */ 150 u_int16_t atm_vci; /* backpointer to VCI */ 151 u_int8_t atm_flags; /* copy of atm_flags from atm_ph */ 152 u_int8_t oth_flags; /* other flags */ 153 u_int32_t raw_threshold; /* for raw mode */ 154 struct ifqueue indma; /* mbufs being dma'd now */ 155 struct ifqueue q; /* mbufs waiting for dma now */ 156 } rxslot[EN_MAXNRX]; /* recv info */ 157 158 u_int8_t macaddr[6]; /* card unique mac address */ 159 160 /* stats */ 161 u_int32_t vtrash; /* sw copy of counter */ 162 u_int32_t otrash; /* sw copy of counter */ 163 u_int32_t ttrash; /* # of RBD's with T bit set */ 164 u_int32_t mfix; /* # of times we had to call mfix */ 165 u_int32_t mfixfail; /* # of times mfix failed */ 166 u_int32_t headbyte; /* # of times we used BYTE DMA at front */ 167 u_int32_t tailbyte; /* # of times we used BYTE DMA at end */ 168 u_int32_t tailflush; /* # of times we had to FLUSH out DMA bytes */ 169 u_int32_t txmbovr; /* # of times we dropped due to mbsize */ 170 u_int32_t dmaovr; /* tx dma overflow count */ 171 u_int32_t txoutspace; /* out of space in xmit buffer */ 172 u_int32_t txdtqout; /* out of DTQs */ 173 u_int32_t launch; /* total # of launches */ 174 u_int32_t lheader; /* # of launches without OB header */ 175 u_int32_t ltail; /* # of launches without OB tail */ 176 u_int32_t hwpull; /* # of pulls off hardware service list */ 177 u_int32_t swadd; /* # of pushes on sw service list */ 178 u_int32_t rxqnotus; /* # of times we pull from rx q, but fail */ 179 u_int32_t rxqus; /* # of good pulls from rx q */ 180 u_int32_t rxoutboth; /* # of times out of mbufs and DRQs */ 181 u_int32_t rxdrqout; /* # of times out of DRQs */ 182 u_int32_t rxmbufout; /* # of time out of mbufs */ 183 184 /* random stuff */ 185 u_int32_t ipl; /* sbus interrupt lvl (1 on pci?) */ 186 u_int8_t bestburstcode; /* code of best burst we can use */ 187 u_int8_t bestburstlen; /* length of best burst (bytes) */ 188 u_int8_t bestburstshift; /* (x >> shift) == (x / bestburstlen) */ 189 u_int8_t bestburstmask; /* bits to check if not multiple of burst */ 190 u_int8_t alburst; /* align dma bursts? */ 191 u_int8_t is_adaptec; /* adaptec version of midway? */ 192}; 193 194/* 195 * exported functions 196 */ 197 198void en_attach(struct en_softc *); 199EN_INTR_TYPE en_intr(void *); 200void en_reset(struct en_softc *); 201