dp83932var.h revision 1.3.4.3 1 1.3.4.3 thorpej /* $NetBSD: dp83932var.h,v 1.3.4.3 2003/01/17 16:31:23 thorpej Exp $ */
2 1.3.4.2 nathanw
3 1.3.4.2 nathanw /*-
4 1.3.4.2 nathanw * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 1.3.4.2 nathanw * All rights reserved.
6 1.3.4.2 nathanw *
7 1.3.4.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.3.4.2 nathanw * by Jason R. Thorpe.
9 1.3.4.2 nathanw *
10 1.3.4.2 nathanw * Redistribution and use in source and binary forms, with or without
11 1.3.4.2 nathanw * modification, are permitted provided that the following conditions
12 1.3.4.2 nathanw * are met:
13 1.3.4.2 nathanw * 1. Redistributions of source code must retain the above copyright
14 1.3.4.2 nathanw * notice, this list of conditions and the following disclaimer.
15 1.3.4.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
16 1.3.4.2 nathanw * notice, this list of conditions and the following disclaimer in the
17 1.3.4.2 nathanw * documentation and/or other materials provided with the distribution.
18 1.3.4.2 nathanw * 3. All advertising materials mentioning features or use of this software
19 1.3.4.2 nathanw * must display the following acknowledgement:
20 1.3.4.2 nathanw * This product includes software developed by the NetBSD
21 1.3.4.2 nathanw * Foundation, Inc. and its contributors.
22 1.3.4.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.3.4.2 nathanw * contributors may be used to endorse or promote products derived
24 1.3.4.2 nathanw * from this software without specific prior written permission.
25 1.3.4.2 nathanw *
26 1.3.4.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.3.4.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.3.4.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.3.4.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.3.4.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.3.4.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.3.4.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.3.4.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.3.4.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.3.4.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.3.4.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
37 1.3.4.2 nathanw */
38 1.3.4.2 nathanw
39 1.3.4.2 nathanw #ifndef _DEV_IC_DP83932VAR_H_
40 1.3.4.2 nathanw #define _DEV_IC_DP83932VAR_H_
41 1.3.4.2 nathanw
42 1.3.4.2 nathanw /*
43 1.3.4.2 nathanw * Data structure definitions for the National Semiconductor DP83932
44 1.3.4.2 nathanw * Systems-Oriented Network Interface Controller (SONIC).
45 1.3.4.2 nathanw */
46 1.3.4.2 nathanw
47 1.3.4.2 nathanw /*
48 1.3.4.2 nathanw * NOTE: The control data for the SONIC must not cross a 64k boundary,
49 1.3.4.2 nathanw * so we have to be careful about how we size things.
50 1.3.4.2 nathanw *
51 1.3.4.2 nathanw * Also, since the SONIC is only a 10Mb/s chip, and systems on which
52 1.3.4.2 nathanw * it is present tend to be low on memory, we try to keep the data
53 1.3.4.2 nathanw * structure sizes small.
54 1.3.4.2 nathanw */
55 1.3.4.2 nathanw
56 1.3.4.2 nathanw /*
57 1.3.4.2 nathanw * Transmit descriptor list size.
58 1.3.4.2 nathanw */
59 1.3.4.2 nathanw #define SONIC_NTXDESC 32
60 1.3.4.2 nathanw #define SONIC_NTXDESC_MASK (SONIC_NTXDESC - 1)
61 1.3.4.2 nathanw #define SONIC_NEXTTX(x) (((x) + 1) & SONIC_NTXDESC_MASK)
62 1.3.4.2 nathanw
63 1.3.4.2 nathanw /*
64 1.3.4.2 nathanw * Receive descriptor list size.
65 1.3.4.2 nathanw */
66 1.3.4.2 nathanw #define SONIC_NRXDESC 32
67 1.3.4.2 nathanw #define SONIC_NRXDESC_MASK (SONIC_NRXDESC - 1)
68 1.3.4.2 nathanw #define SONIC_NEXTRX(x) (((x) + 1) & SONIC_NRXDESC_MASK)
69 1.3.4.2 nathanw #define SONIC_PREVRX(x) (((x) - 1) & SONIC_NRXDESC_MASK)
70 1.3.4.2 nathanw #define SONIC_RXSEQ_TO_DESC(x) ((x) & SONIC_NRXDESC_MASK)
71 1.3.4.2 nathanw
72 1.3.4.2 nathanw /*
73 1.3.4.2 nathanw * Control structures are DMA'd to the SONIC chip. We allocate them in
74 1.3.4.2 nathanw * a single clump that maps to a single DMA segment to make several things
75 1.3.4.2 nathanw * easier.
76 1.3.4.2 nathanw */
77 1.3.4.2 nathanw struct sonic_control_data16 {
78 1.3.4.2 nathanw /*
79 1.3.4.2 nathanw * The transmit descriptors.
80 1.3.4.2 nathanw */
81 1.3.4.2 nathanw struct sonic_tda16 scd_txdescs[SONIC_NTXDESC];
82 1.3.4.2 nathanw
83 1.3.4.2 nathanw /*
84 1.3.4.2 nathanw * The receive descriptors.
85 1.3.4.2 nathanw */
86 1.3.4.2 nathanw struct sonic_rda16 scd_rxdescs[SONIC_NRXDESC];
87 1.3.4.2 nathanw
88 1.3.4.2 nathanw /*
89 1.3.4.2 nathanw * The receive resource descriptors.
90 1.3.4.2 nathanw */
91 1.3.4.2 nathanw struct sonic_rra16 scd_rxbufs[SONIC_NRXDESC];
92 1.3.4.2 nathanw
93 1.3.4.2 nathanw /*
94 1.3.4.2 nathanw * The CAM descriptors.
95 1.3.4.2 nathanw */
96 1.3.4.2 nathanw struct sonic_cda16 scd_cam[16];
97 1.3.4.2 nathanw };
98 1.3.4.2 nathanw
99 1.3.4.2 nathanw #define SONIC_CDOFF16(x) offsetof(struct sonic_control_data16, x)
100 1.3.4.2 nathanw #define SONIC_CDTXOFF16(x) SONIC_CDOFF16(scd_txdescs[(x)])
101 1.3.4.2 nathanw #define SONIC_CDRXOFF16(x) SONIC_CDOFF16(scd_rxdescs[(x)])
102 1.3.4.2 nathanw #define SONIC_CDRROFF16(x) SONIC_CDOFF16(scd_rxbufs[(x)])
103 1.3.4.2 nathanw #define SONIC_CDCAMOFF16 SONIC_CDOFF16(scd_cam)
104 1.3.4.2 nathanw
105 1.3.4.2 nathanw struct sonic_control_data32 {
106 1.3.4.2 nathanw /*
107 1.3.4.2 nathanw * The transmit descriptors.
108 1.3.4.2 nathanw */
109 1.3.4.2 nathanw struct sonic_tda32 scd_txdescs[SONIC_NTXDESC];
110 1.3.4.2 nathanw
111 1.3.4.2 nathanw /*
112 1.3.4.2 nathanw * The receive descriptors.
113 1.3.4.2 nathanw */
114 1.3.4.2 nathanw struct sonic_rda32 scd_rxdescs[SONIC_NRXDESC];
115 1.3.4.2 nathanw
116 1.3.4.2 nathanw /*
117 1.3.4.2 nathanw * The receive resource descriptors.
118 1.3.4.2 nathanw */
119 1.3.4.2 nathanw struct sonic_rra32 scd_rxbufs[SONIC_NRXDESC];
120 1.3.4.2 nathanw
121 1.3.4.2 nathanw /*
122 1.3.4.2 nathanw * The CAM descriptors.
123 1.3.4.2 nathanw */
124 1.3.4.2 nathanw struct sonic_cda32 scd_cam[16];
125 1.3.4.2 nathanw };
126 1.3.4.2 nathanw
127 1.3.4.2 nathanw #define SONIC_CDOFF32(x) offsetof(struct sonic_control_data32, x)
128 1.3.4.2 nathanw #define SONIC_CDTXOFF32(x) SONIC_CDOFF32(scd_txdescs[(x)])
129 1.3.4.2 nathanw #define SONIC_CDRXOFF32(x) SONIC_CDOFF32(scd_rxdescs[(x)])
130 1.3.4.2 nathanw #define SONIC_CDRROFF32(x) SONIC_CDOFF32(scd_rxbufs[(x)])
131 1.3.4.2 nathanw #define SONIC_CDCAMOFF32 SONIC_CDOFF32(scd_cam)
132 1.3.4.2 nathanw
133 1.3.4.2 nathanw /*
134 1.3.4.2 nathanw * Software state for transmit and receive descriptors.
135 1.3.4.2 nathanw */
136 1.3.4.2 nathanw struct sonic_descsoft {
137 1.3.4.2 nathanw struct mbuf *ds_mbuf; /* head of mbuf chain */
138 1.3.4.2 nathanw bus_dmamap_t ds_dmamap; /* our DMA map */
139 1.3.4.2 nathanw };
140 1.3.4.2 nathanw
141 1.3.4.2 nathanw /*
142 1.3.4.2 nathanw * Software state per device.
143 1.3.4.2 nathanw */
144 1.3.4.2 nathanw struct sonic_softc {
145 1.3.4.2 nathanw struct device sc_dev; /* generic device information */
146 1.3.4.2 nathanw bus_space_tag_t sc_st; /* bus space tag */
147 1.3.4.2 nathanw bus_space_handle_t sc_sh; /* bus space handle */
148 1.3.4.2 nathanw bus_dma_tag_t sc_dmat; /* bus DMA tag */
149 1.3.4.2 nathanw struct ethercom sc_ethercom; /* ethernet common data */
150 1.3.4.2 nathanw void *sc_sdhook; /* shutdown hook */
151 1.3.4.2 nathanw
152 1.3.4.2 nathanw int sc_32bit; /* use 32-bit mode */
153 1.3.4.2 nathanw int sc_bigendian; /* BMODE -> Vcc */
154 1.3.4.2 nathanw
155 1.3.4.2 nathanw /* Our register map. */
156 1.3.4.2 nathanw bus_addr_t sc_regmap[SONIC_NREGS];
157 1.3.4.2 nathanw
158 1.3.4.2 nathanw bus_dmamap_t sc_cddmamap; /* control data DMA map */
159 1.3.4.2 nathanw #define sc_cddma sc_cddmamap->dm_segs[0].ds_addr
160 1.3.4.3 thorpej bus_dmamap_t sc_nulldmamap; /* DMA map for the pad buffer */
161 1.3.4.3 thorpej #define sc_nulldma sc_nulldmamap->dm_segs[0].ds_addr
162 1.3.4.2 nathanw
163 1.3.4.2 nathanw /*
164 1.3.4.2 nathanw * Software state for transmit and receive descriptors.
165 1.3.4.2 nathanw */
166 1.3.4.2 nathanw struct sonic_descsoft sc_txsoft[SONIC_NTXDESC];
167 1.3.4.2 nathanw struct sonic_descsoft sc_rxsoft[SONIC_NRXDESC];
168 1.3.4.2 nathanw
169 1.3.4.2 nathanw /*
170 1.3.4.2 nathanw * Control data structures.
171 1.3.4.2 nathanw */
172 1.3.4.2 nathanw union {
173 1.3.4.2 nathanw struct sonic_control_data16 *cdun_16;
174 1.3.4.2 nathanw struct sonic_control_data32 *cdun_32;
175 1.3.4.2 nathanw } sc_cdun;
176 1.3.4.2 nathanw #define sc_cdata16 sc_cdun.cdun_16
177 1.3.4.2 nathanw #define sc_cdata32 sc_cdun.cdun_32
178 1.3.4.2 nathanw
179 1.3.4.2 nathanw #define sc_tda16 sc_cdun.cdun_16->scd_txdescs
180 1.3.4.2 nathanw #define sc_rda16 sc_cdun.cdun_16->scd_rxdescs
181 1.3.4.2 nathanw #define sc_rra16 sc_cdun.cdun_16->scd_rxbufs
182 1.3.4.2 nathanw #define sc_cda16 sc_cdun.cdun_16->scd_cam
183 1.3.4.2 nathanw
184 1.3.4.2 nathanw #define sc_tda32 sc_cdun.cdun_32->scd_txdescs
185 1.3.4.2 nathanw #define sc_rda32 sc_cdun.cdun_32->scd_rxdescs
186 1.3.4.2 nathanw #define sc_rra32 sc_cdun.cdun_32->scd_rxbufs
187 1.3.4.2 nathanw #define sc_cda32 sc_cdun.cdun_32->scd_cam
188 1.3.4.2 nathanw
189 1.3.4.2 nathanw int sc_txpending; /* number of Tx requests pending */
190 1.3.4.2 nathanw int sc_txdirty; /* first dirty Tx descriptor */
191 1.3.4.2 nathanw int sc_txlast; /* last used Tx descriptor */
192 1.3.4.2 nathanw
193 1.3.4.2 nathanw int sc_rxptr; /* next ready Rx descriptor */
194 1.3.4.2 nathanw
195 1.3.4.2 nathanw uint16_t sc_imr; /* prototype IMR */
196 1.3.4.2 nathanw uint16_t sc_dcr; /* prototype DCR */
197 1.3.4.2 nathanw uint16_t sc_dcr2; /* prototype DCR2 */
198 1.3.4.2 nathanw };
199 1.3.4.2 nathanw
200 1.3.4.2 nathanw #define CSR_READ(sc, reg) \
201 1.3.4.2 nathanw bus_space_read_2((sc)->sc_st, (sc)->sc_sh, \
202 1.3.4.2 nathanw (sc)->sc_regmap[(reg)])
203 1.3.4.2 nathanw
204 1.3.4.2 nathanw #define CSR_WRITE(sc, reg, val) \
205 1.3.4.2 nathanw bus_space_write_2((sc)->sc_st, (sc)->sc_sh, \
206 1.3.4.2 nathanw (sc)->sc_regmap[(reg)], (val))
207 1.3.4.2 nathanw
208 1.3.4.2 nathanw #define SONIC_CDTXADDR16(sc, x) \
209 1.3.4.2 nathanw ((sc)->sc_cddma + SONIC_CDTXOFF16((x)))
210 1.3.4.2 nathanw
211 1.3.4.2 nathanw #define SONIC_CDTXADDR32(sc, x) \
212 1.3.4.2 nathanw ((sc)->sc_cddma + SONIC_CDTXOFF32((x)))
213 1.3.4.2 nathanw
214 1.3.4.2 nathanw #define SONIC_CDTXADDR(sc, x) \
215 1.3.4.2 nathanw ((sc)->sc_32bit ? SONIC_CDTXADDR32((sc), (x)) : \
216 1.3.4.2 nathanw SONIC_CDTXADDR16((sc), (x)))
217 1.3.4.2 nathanw
218 1.3.4.2 nathanw #define SONIC_CDRXADDR16(sc, x) \
219 1.3.4.2 nathanw ((sc)->sc_cddma + SONIC_CDRXOFF16((x)))
220 1.3.4.2 nathanw
221 1.3.4.2 nathanw #define SONIC_CDRXADDR32(sc, x) \
222 1.3.4.2 nathanw ((sc)->sc_cddma + SONIC_CDRXOFF32((x)))
223 1.3.4.2 nathanw
224 1.3.4.2 nathanw #define SONIC_CDRXADDR(sc, x) \
225 1.3.4.2 nathanw ((sc)->sc_32bit ? SONIC_CDRXADDR32((sc), (x)) : \
226 1.3.4.2 nathanw SONIC_CDRXADDR16((sc), (x)))
227 1.3.4.2 nathanw
228 1.3.4.2 nathanw #define SONIC_CDRRADDR(sc, x) \
229 1.3.4.2 nathanw ((sc)->sc_cddma + \
230 1.3.4.2 nathanw ((sc)->sc_32bit ? SONIC_CDRROFF32((x)) : SONIC_CDRROFF16((x))))
231 1.3.4.2 nathanw
232 1.3.4.2 nathanw #define SONIC_CDCAMADDR(sc) \
233 1.3.4.2 nathanw ((sc)->sc_cddma + \
234 1.3.4.2 nathanw ((sc)->sc_32bit ? SONIC_CDCAMOFF32 : SONIC_CDCAMOFF32))
235 1.3.4.2 nathanw
236 1.3.4.2 nathanw #define SONIC_CDTXSYNC16(sc, x, ops) \
237 1.3.4.2 nathanw bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \
238 1.3.4.2 nathanw SONIC_CDTXOFF16((x)), sizeof(struct sonic_tda16), (ops))
239 1.3.4.2 nathanw
240 1.3.4.2 nathanw #define SONIC_CDTXSYNC32(sc, x, ops) \
241 1.3.4.2 nathanw bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \
242 1.3.4.2 nathanw SONIC_CDTXOFF32((x)), sizeof(struct sonic_tda32), (ops))
243 1.3.4.2 nathanw
244 1.3.4.2 nathanw #define SONIC_CDRXSYNC16(sc, x, ops) \
245 1.3.4.2 nathanw bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \
246 1.3.4.2 nathanw SONIC_CDRXOFF16((x)), sizeof(struct sonic_rda16), (ops))
247 1.3.4.2 nathanw
248 1.3.4.2 nathanw #define SONIC_CDRXSYNC32(sc, x, ops) \
249 1.3.4.2 nathanw bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \
250 1.3.4.2 nathanw SONIC_CDRXOFF32((x)), sizeof(struct sonic_rda32), (ops))
251 1.3.4.2 nathanw
252 1.3.4.2 nathanw #define SONIC_CDRRSYNC16(sc, x, ops) \
253 1.3.4.2 nathanw bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \
254 1.3.4.2 nathanw SONIC_CDRROFF16((x)), sizeof(struct sonic_rra16), (ops))
255 1.3.4.2 nathanw
256 1.3.4.2 nathanw #define SONIC_CDRRSYNC32(sc, x, ops) \
257 1.3.4.2 nathanw bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \
258 1.3.4.2 nathanw SONIC_CDRROFF32((x)), sizeof(struct sonic_rra32), (ops))
259 1.3.4.2 nathanw
260 1.3.4.2 nathanw #define SONIC_CDCAMSYNC(sc, ops) \
261 1.3.4.2 nathanw do { \
262 1.3.4.2 nathanw if ((sc)->sc_32bit) \
263 1.3.4.2 nathanw bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \
264 1.3.4.2 nathanw SONIC_CDCAMOFF32, sizeof(struct sonic_cda32) * 16, \
265 1.3.4.2 nathanw (ops)); \
266 1.3.4.2 nathanw else \
267 1.3.4.2 nathanw bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \
268 1.3.4.2 nathanw SONIC_CDCAMOFF16, sizeof(struct sonic_cda16) * 16, \
269 1.3.4.2 nathanw (ops)); \
270 1.3.4.2 nathanw } while (/*CONSTCOND*/0)
271 1.3.4.2 nathanw
272 1.3.4.2 nathanw #define SONIC_INIT_RXDESC(sc, x) \
273 1.3.4.2 nathanw do { \
274 1.3.4.2 nathanw struct sonic_descsoft *__ds = &(sc)->sc_rxsoft[(x)]; \
275 1.3.4.2 nathanw struct mbuf *__m = __ds->ds_mbuf; \
276 1.3.4.2 nathanw \
277 1.3.4.2 nathanw if ((sc)->sc_32bit) { \
278 1.3.4.2 nathanw /* \
279 1.3.4.2 nathanw * Unfortuantely, in 32-bit mode, the Rx buffer must \
280 1.3.4.2 nathanw * be 32-bit aligned. \
281 1.3.4.2 nathanw */ \
282 1.3.4.2 nathanw struct sonic_rda32 *__rda = &(sc)->sc_rda32[(x)]; \
283 1.3.4.2 nathanw struct sonic_rda32 *__prda = \
284 1.3.4.2 nathanw &(sc)->sc_rda32[SONIC_PREVRX((x))]; \
285 1.3.4.2 nathanw struct sonic_rra32 *__rra = &(sc)->sc_rra32[(x)]; \
286 1.3.4.2 nathanw \
287 1.3.4.2 nathanw __m->m_data = __m->m_ext.ext_buf; \
288 1.3.4.2 nathanw \
289 1.3.4.2 nathanw __rra->rra_ptr1 = \
290 1.3.4.2 nathanw __ds->ds_dmamap->dm_segs[0].ds_addr >> 16; \
291 1.3.4.2 nathanw __rra->rra_ptr0 = \
292 1.3.4.2 nathanw __ds->ds_dmamap->dm_segs[0].ds_addr & 0xffff; \
293 1.3.4.2 nathanw __rra->rra_wc1 = 0; \
294 1.3.4.2 nathanw __rra->rra_wc0 = (ETHER_MAX_LEN + 6) / 2; \
295 1.3.4.2 nathanw \
296 1.3.4.2 nathanw __rda->rda_link = \
297 1.3.4.2 nathanw (SONIC_CDRXADDR32((sc), SONIC_NEXTRX((x))) & 0xffff) |\
298 1.3.4.2 nathanw RDA_LINK_EOL; \
299 1.3.4.2 nathanw __rda->rda_inuse = 1; \
300 1.3.4.2 nathanw \
301 1.3.4.2 nathanw __prda->rda_link = SONIC_CDRXADDR32((sc), (x)); \
302 1.3.4.2 nathanw \
303 1.3.4.2 nathanw SONIC_CDRRSYNC32((sc), (x), BUS_DMASYNC_PREWRITE); \
304 1.3.4.2 nathanw SONIC_CDRXSYNC32((sc), (x), \
305 1.3.4.2 nathanw BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); \
306 1.3.4.2 nathanw SONIC_CDRXSYNC32((sc), SONIC_PREVRX(x), \
307 1.3.4.2 nathanw BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); \
308 1.3.4.2 nathanw } else { \
309 1.3.4.2 nathanw /* \
310 1.3.4.2 nathanw * In 16-bit mode, we scoot the packet forward 2 bytes \
311 1.3.4.2 nathanw * so that the payload after the Ethernet header is \
312 1.3.4.2 nathanw * suitably aligned. \
313 1.3.4.2 nathanw */ \
314 1.3.4.2 nathanw struct sonic_rda16 *__rda = &(sc)->sc_rda16[(x)]; \
315 1.3.4.2 nathanw struct sonic_rda16 *__prda = \
316 1.3.4.2 nathanw &(sc)->sc_rda16[SONIC_PREVRX((x))]; \
317 1.3.4.2 nathanw struct sonic_rra16 *__rra = &(sc)->sc_rra16[(x)]; \
318 1.3.4.2 nathanw \
319 1.3.4.2 nathanw __m->m_data = __m->m_ext.ext_buf + 2; \
320 1.3.4.2 nathanw \
321 1.3.4.2 nathanw __rra->rra_ptr1 = \
322 1.3.4.2 nathanw __ds->ds_dmamap->dm_segs[0].ds_addr >> 16; \
323 1.3.4.2 nathanw __rra->rra_ptr0 = \
324 1.3.4.2 nathanw (__ds->ds_dmamap->dm_segs[0].ds_addr + 2) & 0xffff; \
325 1.3.4.2 nathanw __rra->rra_wc1 = 0; \
326 1.3.4.2 nathanw __rra->rra_wc0 = (ETHER_MAX_LEN + 2) / 2; \
327 1.3.4.2 nathanw \
328 1.3.4.2 nathanw __rda->rda_link = \
329 1.3.4.2 nathanw (SONIC_CDRXADDR16((sc), SONIC_NEXTRX((x))) & 0xffff) |\
330 1.3.4.2 nathanw RDA_LINK_EOL; \
331 1.3.4.2 nathanw __rda->rda_inuse = 1; \
332 1.3.4.2 nathanw \
333 1.3.4.2 nathanw __prda->rda_link = SONIC_CDRXADDR16((sc), (x)); \
334 1.3.4.2 nathanw \
335 1.3.4.2 nathanw SONIC_CDRRSYNC16((sc), (x), BUS_DMASYNC_PREWRITE); \
336 1.3.4.2 nathanw SONIC_CDRXSYNC16((sc), (x), \
337 1.3.4.2 nathanw BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); \
338 1.3.4.2 nathanw SONIC_CDRXSYNC16((sc), SONIC_PREVRX(x), \
339 1.3.4.2 nathanw BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); \
340 1.3.4.2 nathanw } \
341 1.3.4.2 nathanw } while (/*CONSTCOND*/0)
342 1.3.4.2 nathanw
343 1.3.4.2 nathanw static __inline uint16_t __attribute__((__unused__))
344 1.3.4.2 nathanw htosonic16(struct sonic_softc *sc, uint16_t val)
345 1.3.4.2 nathanw {
346 1.3.4.2 nathanw
347 1.3.4.2 nathanw if (sc->sc_bigendian)
348 1.3.4.2 nathanw return (htobe16(val));
349 1.3.4.2 nathanw return (htole16(val));
350 1.3.4.2 nathanw }
351 1.3.4.2 nathanw
352 1.3.4.2 nathanw static __inline uint16_t __attribute__((__unused__))
353 1.3.4.2 nathanw sonic16toh(struct sonic_softc *sc, uint16_t val)
354 1.3.4.2 nathanw {
355 1.3.4.2 nathanw
356 1.3.4.2 nathanw if (sc->sc_bigendian)
357 1.3.4.2 nathanw return (be16toh(val));
358 1.3.4.2 nathanw return (le16toh(val));
359 1.3.4.2 nathanw }
360 1.3.4.2 nathanw
361 1.3.4.2 nathanw static __inline uint32_t __attribute__((__unused__))
362 1.3.4.2 nathanw htosonic32(struct sonic_softc *sc, uint32_t val)
363 1.3.4.2 nathanw {
364 1.3.4.2 nathanw
365 1.3.4.2 nathanw if (sc->sc_bigendian)
366 1.3.4.2 nathanw return (htobe32(val));
367 1.3.4.2 nathanw return (htole32(val));
368 1.3.4.2 nathanw }
369 1.3.4.2 nathanw
370 1.3.4.2 nathanw static __inline uint32_t __attribute__((__unused__))
371 1.3.4.2 nathanw sonic32toh(struct sonic_softc *sc, uint32_t val)
372 1.3.4.2 nathanw {
373 1.3.4.2 nathanw
374 1.3.4.2 nathanw if (sc->sc_bigendian)
375 1.3.4.2 nathanw return (be32toh(val));
376 1.3.4.2 nathanw return (le32toh(val));
377 1.3.4.2 nathanw }
378 1.3.4.2 nathanw
379 1.3.4.2 nathanw #ifdef _KERNEL
380 1.3.4.2 nathanw void sonic_attach(struct sonic_softc *, const uint8_t *);
381 1.3.4.2 nathanw int sonic_intr(void *);
382 1.3.4.2 nathanw #endif /* _KERNEL */
383 1.3.4.2 nathanw
384 1.3.4.2 nathanw #endif /* _DEV_IC_DP83932VAR_H_ */
385