1 /* $NetBSD: midwayvar.h,v 1.10 1997/03/20 21:34:46 chuck Exp $ */
4 * Copyright (c) 1996 Charles D. Cranor and Washington University.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Charles D. Cranor and
18 * Washington University.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 * m i d w a y v a r . h
39 * we define the en_softc here so that bus specific modules can allocate
40 * it as the first item in their softc.
42 * author: Chuck Cranor <chuck@ccrc.wustl.edu>
46 * params needed to determine softc size
49 #define EN_NTX 8 /* number of tx bufs to use */
52 #define EN_TXSZ 32 /* trasmit buf size in KB */
55 #define EN_RXSZ 32 /* recv buf size in KB */
58 /* largest possible NRX (depends on RAM size) */
59 #define EN_MAXNRX ((2048 - (EN_NTX * EN_TXSZ)) / EN_RXSZ)
62 #define EN_MAX_DMASEG 32
65 /* number of bytes to use in the first receive buffer. This must not be larger
66 * than MHLEN, should be a multiple of 64 and must be a multiple of 4. */
70 * Structure to hold DMA maps. These are handle via a typestable uma zone.
73 uintptr_t flags; /* map flags */
74 struct en_map *rsvd2; /* see uma_zalloc(9) */
75 struct en_softc *sc; /* back pointer */
76 bus_dmamap_t map; /* the map */
78 #define ENMAP_LOADED 0x02
79 #define ENMAP_ALLOC 0x01
81 #define EN_MAX_MAPS 400
87 uint32_t vtrash; /* sw copy of counter */
88 uint32_t otrash; /* sw copy of counter */
89 uint32_t ttrash; /* # of RBD's with T bit set */
90 uint32_t mfixaddr; /* # of times we had to mfix an address */
91 uint32_t mfixlen; /* # of times we had to mfix a lenght*/
92 uint32_t mfixfail; /* # of times mfix failed */
93 uint32_t txmbovr; /* # of times we dropped due to mbsize */
94 uint32_t dmaovr; /* tx dma overflow count */
95 uint32_t txoutspace; /* out of space in xmit buffer */
96 uint32_t txdtqout; /* out of DTQs */
97 uint32_t launch; /* total # of launches */
98 uint32_t hwpull; /* # of pulls off hardware service list */
99 uint32_t swadd; /* # of pushes on sw service list */
100 uint32_t rxqnotus; /* # of times we pull from rx q, but fail */
101 uint32_t rxqus; /* # of good pulls from rx q */
102 uint32_t rxdrqout; /* # of times out of DRQs */
103 uint32_t rxmbufout; /* # of time out of mbufs */
104 uint32_t txnomap; /* out of DMA maps in TX */
108 * Each of these structures describes one of the eight transmit channels
111 uint32_t mbsize; /* # mbuf bytes in use (max=TXHIWAT) */
112 uint32_t bfree; /* # free bytes in buffer */
113 uint32_t start; /* start of buffer area (byte offset) */
114 uint32_t stop; /* ends of buffer area (byte offset) */
115 uint32_t cur; /* next free area (byte offset) */
116 uint32_t nref; /* # of VCs using this channel */
117 struct ifqueue q; /* mbufs waiting for DMA now */
118 struct ifqueue indma; /* mbufs waiting for DMA now */
122 * Each of these structures is used for each of the receive buffers on the
126 uint32_t mode; /* saved copy of mode info */
127 uint32_t start; /* begin of my buffer area */
128 uint32_t stop; /* end of my buffer area */
129 uint32_t cur; /* where I am at in the buffer */
130 struct en_vcc *vcc; /* backpointer to VCI */
131 struct ifqueue q; /* mbufs waiting for dma now */
132 struct ifqueue indma; /* mbufs being dma'd now */
136 struct atmio_vcc vcc; /* required by common code */
145 struct en_txslot *txslot; /* transmit slot */
146 struct en_rxslot *rxslot; /* receive slot */
148 #define VCC_DRAIN 0x0001 /* closed, but draining rx */
149 #define VCC_SWSL 0x0002 /* on rx software service list */
150 #define VCC_CLOSE_RX 0x0004 /* currently closing */
160 bus_space_tag_t en_memt; /* for EN_READ/EN_WRITE */
161 bus_space_handle_t en_base; /* base of en card */
162 bus_size_t en_obmemsz; /* size of en card (bytes) */
163 void (*en_busreset)(void *); /* bus specific reset function */
164 bus_dma_tag_t txtag; /* TX DMA tag */
167 uint32_t hwslistp; /* hw pointer to service list (byte offset) */
168 uint16_t swslist[MID_SL_N]; /* software svc list (see en_service()) */
169 uint16_t swsl_head; /* ends of swslist (index into swslist) */
171 uint32_t swsl_size; /* # of items in swsl */
174 uint32_t dtq[MID_DTQ_N];/* sw copy of dma q (see EN_DQ_MK macros) */
175 uint32_t dtq_free; /* # of dtq's free */
176 uint32_t dtq_us; /* software copy of our pointer (byte offset) */
177 uint32_t dtq_chip; /* chip's pointer (byte offset) */
178 uint32_t need_dtqs; /* true if we ran out of DTQs */
181 uint32_t drq[MID_DRQ_N];/* sw copy of dma q (see ENIDQ macros) */
182 uint32_t drq_free; /* # of drq's free */
183 uint32_t drq_us; /* software copy of our pointer (byte offset) */
184 uint32_t drq_chip; /* chip's pointer (byte offset) */
185 uint32_t need_drqs; /* true if we ran out of DRQs */
187 /* xmit buf ctrl. (per channel) */
188 struct en_txslot txslot[MID_NTX_CH];
190 /* recv buf ctrl. (per recv slot) */
191 struct en_rxslot rxslot[EN_MAXNRX];
192 int en_nrx; /* # of active rx slots */
195 struct en_vcc **vccs;
197 struct cv cv_close; /* close CV */
200 struct en_stats stats;
203 uint32_t ipl; /* sbus interrupt lvl (1 on pci?) */
204 uint8_t bestburstcode; /* code of best burst we can use */
205 uint8_t bestburstlen; /* length of best burst (bytes) */
206 uint8_t bestburstshift; /* (x >> shift) == (x / bestburstlen) */
207 uint8_t bestburstmask; /* bits to check if not multiple of burst */
208 uint8_t alburst; /* align dma bursts? */
209 uint8_t noalbursts; /* don't use unaligned > 4 byte bursts */
210 uint8_t is_adaptec; /* adaptec version of midway? */
211 struct mbuf *padbuf; /* buffer of zeros for TX padding */
213 /* mutex to protect this structure and the associated hardware */
217 struct sysctl_ctx_list sysctl_ctx;
218 struct sysctl_oid *sysctl_tree;
224 struct ifmedia media;
225 struct utopia utopia;
236 int en_attach(struct en_softc *);
237 void en_destroy(struct en_softc *);
238 void en_intr(void *);
239 void en_reset(struct en_softc *);
240 int en_modevent(module_t, int, void *arg);