2 * Generic Broadcom Home Networking Division (HND) DMA engine SW interface
3 * This supports the following chips: BCM42xx, 44xx, 47xx .
5 * Copyright (C) 2010, Broadcom Corporation. All Rights Reserved.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
14 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
16 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 * $Id: hnddma.h,v 13.82.12.4 2011-01-27 19:03:20 Exp $
27 typedef const struct hnddma_pub hnddma_t
;
28 #endif /* _hnddma_pub_ */
30 /* range param for dma_getnexttxp() and dma_txreclaim */
31 typedef enum txd_range
{
33 HNDDMA_RANGE_TRANSMITTED
,
34 HNDDMA_RANGE_TRANSFERED
37 /* dma function type */
38 typedef void (*di_detach_t
)(hnddma_t
*dmah
);
39 typedef bool (*di_txreset_t
)(hnddma_t
*dmah
);
40 typedef bool (*di_rxreset_t
)(hnddma_t
*dmah
);
41 typedef bool (*di_rxidle_t
)(hnddma_t
*dmah
);
42 typedef void (*di_txinit_t
)(hnddma_t
*dmah
);
43 typedef bool (*di_txenabled_t
)(hnddma_t
*dmah
);
44 typedef void (*di_rxinit_t
)(hnddma_t
*dmah
);
45 typedef void (*di_txsuspend_t
)(hnddma_t
*dmah
);
46 typedef void (*di_txresume_t
)(hnddma_t
*dmah
);
47 typedef bool (*di_txsuspended_t
)(hnddma_t
*dmah
);
48 typedef bool (*di_txsuspendedidle_t
)(hnddma_t
*dmah
);
50 typedef void (*di_txflush_t
)(hnddma_t
*dmah
);
51 typedef void (*di_txflush_clear_t
)(hnddma_t
*dmah
);
52 #endif /* WL_MULTIQUEUE */
53 typedef int (*di_txfast_t
)(hnddma_t
*dmah
, void *p
, bool commit
);
55 typedef int (*di_txunframed_t
)(hnddma_t
*dmah
, void *p
, uint len
, bool commit
);
56 typedef void* (*di_getpos_t
)(hnddma_t
*di
, bool direction
);
58 typedef void (*di_fifoloopbackenable_t
)(hnddma_t
*dmah
);
59 typedef bool (*di_txstopped_t
)(hnddma_t
*dmah
);
60 typedef bool (*di_rxstopped_t
)(hnddma_t
*dmah
);
61 typedef bool (*di_rxenable_t
)(hnddma_t
*dmah
);
62 typedef bool (*di_rxenabled_t
)(hnddma_t
*dmah
);
63 typedef void* (*di_rx_t
)(hnddma_t
*dmah
);
64 typedef bool (*di_rxfill_t
)(hnddma_t
*dmah
);
65 typedef void (*di_txreclaim_t
)(hnddma_t
*dmah
, txd_range_t range
);
66 typedef void (*di_rxreclaim_t
)(hnddma_t
*dmah
);
67 typedef uintptr (*di_getvar_t
)(hnddma_t
*dmah
, const char *name
);
68 typedef void* (*di_getnexttxp_t
)(hnddma_t
*dmah
, txd_range_t range
);
69 typedef void* (*di_getnextrxp_t
)(hnddma_t
*dmah
, bool forceall
);
70 typedef void* (*di_peeknexttxp_t
)(hnddma_t
*dmah
);
71 typedef void* (*di_peeknextrxp_t
)(hnddma_t
*dmah
);
72 typedef void (*di_rxparam_get_t
)(hnddma_t
*dmah
, uint16
*rxoffset
, uint16
*rxbufsize
);
73 typedef void (*di_txblock_t
)(hnddma_t
*dmah
);
74 typedef void (*di_txunblock_t
)(hnddma_t
*dmah
);
75 typedef uint (*di_txactive_t
)(hnddma_t
*dmah
);
76 typedef void (*di_txrotate_t
)(hnddma_t
*dmah
);
77 typedef void (*di_counterreset_t
)(hnddma_t
*dmah
);
78 typedef uint (*di_ctrlflags_t
)(hnddma_t
*dmah
, uint mask
, uint flags
);
79 typedef char* (*di_dump_t
)(hnddma_t
*dmah
, struct bcmstrbuf
*b
, bool dumpring
);
80 typedef char* (*di_dumptx_t
)(hnddma_t
*dmah
, struct bcmstrbuf
*b
, bool dumpring
);
81 typedef char* (*di_dumprx_t
)(hnddma_t
*dmah
, struct bcmstrbuf
*b
, bool dumpring
);
82 typedef uint (*di_rxactive_t
)(hnddma_t
*dmah
);
83 typedef uint (*di_txpending_t
)(hnddma_t
*dmah
);
84 typedef uint (*di_txcommitted_t
)(hnddma_t
*dmah
);
85 typedef uint (*di_avoidancecnt_t
)(hnddma_t
*dmah
);
88 typedef struct di_fcn_s
{
92 di_txenabled_t txenabled
;
93 di_txsuspend_t txsuspend
;
94 di_txresume_t txresume
;
95 di_txsuspended_t txsuspended
;
96 di_txsuspendedidle_t txsuspendedidle
;
99 di_txflush_clear_t txflush_clear
;
100 #endif /* WL_MULTIQUEUE */
103 di_txunframed_t txunframed
;
106 di_txstopped_t txstopped
;
107 di_txreclaim_t txreclaim
;
108 di_getnexttxp_t getnexttxp
;
109 di_peeknexttxp_t peeknexttxp
;
110 di_txblock_t txblock
;
111 di_txunblock_t txunblock
;
112 di_txactive_t txactive
;
113 di_txrotate_t txrotate
;
116 di_rxreset_t rxreset
;
118 di_rxstopped_t rxstopped
;
119 di_rxenable_t rxenable
;
120 di_rxenabled_t rxenabled
;
123 di_rxreclaim_t rxreclaim
;
124 di_getnextrxp_t getnextrxp
;
125 di_peeknextrxp_t peeknextrxp
;
126 di_rxparam_get_t rxparam_get
;
128 di_fifoloopbackenable_t fifoloopbackenable
;
129 di_getvar_t d_getvar
;
130 di_counterreset_t counterreset
;
131 di_ctrlflags_t ctrlflags
;
135 di_rxactive_t rxactive
;
136 di_txpending_t txpending
;
137 di_txcommitted_t txcommitted
;
138 di_avoidancecnt_t avoidancecnt
;
143 * Exported data structure (read-only)
145 /* export structure */
147 const di_fcn_t
*di_fn
; /* DMA function pointers */
148 uint txavail
; /* # free tx descriptors */
149 uint dmactrlflags
; /* dma control flags */
151 /* rx error counters */
152 uint rxgiants
; /* rx giant frames */
153 uint rxnobuf
; /* rx out of dma descriptors */
154 /* tx error counters */
155 uint txnobuf
; /* tx out of dma descriptors */
156 uint txnodesc
; /* tx out of dma descriptors running count */
160 extern hnddma_t
* dma_attach(osl_t
*osh
, char *name
, si_t
*sih
, void *dmaregstx
, void *dmaregsrx
,
161 uint ntxd
, uint nrxd
, uint rxbufsize
, int rxextheadroom
, uint nrxpost
,
162 uint rxoffset
, uint
*msg_level
);
165 #define dma_detach(di) ((di)->di_fn->detach(di))
166 #define dma_txreset(di) ((di)->di_fn->txreset(di))
167 #define dma_rxreset(di) ((di)->di_fn->rxreset(di))
168 #define dma_rxidle(di) ((di)->di_fn->rxidle(di))
169 #define dma_txinit(di) ((di)->di_fn->txinit(di))
170 #define dma_txenabled(di) ((di)->di_fn->txenabled(di))
171 #define dma_rxinit(di) ((di)->di_fn->rxinit(di))
172 #define dma_txsuspend(di) ((di)->di_fn->txsuspend(di))
173 #define dma_txresume(di) ((di)->di_fn->txresume(di))
174 #define dma_txsuspended(di) ((di)->di_fn->txsuspended(di))
175 #define dma_txsuspendedidle(di) ((di)->di_fn->txsuspendedidle(di))
177 #define dma_txflush(di) ((di)->di_fn->txflush(di))
178 #define dma_txflush_clear(di) ((di)->di_fn->txflush_clear(di))
179 #endif /* WL_MULTIQUEUE */
180 #define dma_txfast(di, p, commit) ((di)->di_fn->txfast(di, p, commit))
181 #define dma_fifoloopbackenable(di) ((di)->di_fn->fifoloopbackenable(di))
182 #define dma_txstopped(di) ((di)->di_fn->txstopped(di))
183 #define dma_rxstopped(di) ((di)->di_fn->rxstopped(di))
184 #define dma_rxenable(di) ((di)->di_fn->rxenable(di))
185 #define dma_rxenabled(di) ((di)->di_fn->rxenabled(di))
186 #define dma_rx(di) ((di)->di_fn->rx(di))
187 #define dma_rxfill(di) ((di)->di_fn->rxfill(di))
188 #define dma_txreclaim(di, range) ((di)->di_fn->txreclaim(di, range))
189 #define dma_rxreclaim(di) ((di)->di_fn->rxreclaim(di))
190 #define dma_getvar(di, name) ((di)->di_fn->d_getvar(di, name))
191 #define dma_getnexttxp(di, range) ((di)->di_fn->getnexttxp(di, range))
192 #define dma_getnextrxp(di, forceall) ((di)->di_fn->getnextrxp(di, forceall))
193 #define dma_peeknexttxp(di) ((di)->di_fn->peeknexttxp(di))
194 #define dma_peeknextrxp(di) ((di)->di_fn->peeknextrxp(di))
195 #define dma_rxparam_get(di, off, bufs) ((di)->di_fn->rxparam_get(di, off, bufs))
197 #define dma_txblock(di) ((di)->di_fn->txblock(di))
198 #define dma_txunblock(di) ((di)->di_fn->txunblock(di))
199 #define dma_txactive(di) ((di)->di_fn->txactive(di))
200 #define dma_rxactive(di) ((di)->di_fn->rxactive(di))
201 #define dma_txrotate(di) ((di)->di_fn->txrotate(di))
202 #define dma_counterreset(di) ((di)->di_fn->counterreset(di))
203 #define dma_ctrlflags(di, mask, flags) ((di)->di_fn->ctrlflags((di), (mask), (flags)))
204 #define dma_txpending(di) ((di)->di_fn->txpending(di))
205 #define dma_txcommitted(di) ((di)->di_fn->txcommitted(di))
206 #if defined(BCMDBG) || defined(BCMDBG_DUMP)
207 #define dma_dump(di, buf, dumpring) ((di)->di_fn->dump(di, buf, dumpring))
208 #define dma_dumptx(di, buf, dumpring) ((di)->di_fn->dumptx(di, buf, dumpring))
209 #define dma_dumprx(di, buf, dumpring) ((di)->di_fn->dumprx(di, buf, dumpring))
210 #endif /* defined(BCMDBG) || defined(BCMDBG_DUMP) */
211 #define dma_avoidance_cnt(di) ((di)->di_fn->avoidancecnt(di))
214 extern const di_fcn_t dma64proc
;
216 #define dma_detach(di) (dma64proc.detach(di))
217 #define dma_txreset(di) (dma64proc.txreset(di))
218 #define dma_rxreset(di) (dma64proc.rxreset(di))
219 #define dma_rxidle(di) (dma64proc.rxidle(di))
220 #define dma_txinit(di) (dma64proc.txinit(di))
221 #define dma_txenabled(di) (dma64proc.txenabled(di))
222 #define dma_rxinit(di) (dma64proc.rxinit(di))
223 #define dma_txsuspend(di) (dma64proc.txsuspend(di))
224 #define dma_txresume(di) (dma64proc.txresume(di))
225 #define dma_txsuspended(di) (dma64proc.txsuspended(di))
226 #define dma_txsuspendedidle(di) (dma64proc.txsuspendedidle(di))
228 #define dma_txflush(di) (dma64proc.txflush(di))
229 #define dma_txflush_clear(di) (dma64proc.txflush_clear(di))
230 #endif /* WL_MULTIQUEUE */
231 #define dma_txfast(di, p, commit) (dma64proc.txfast(di, p, commit))
233 #define dma_txunframed(di, p, l, commit)(dma64proc.txunframed(di, p, l, commit))
234 #define dma_getpos(di, dir) (dma64proc.getpos(di, dir))
236 #define dma_fifoloopbackenable(di) (dma64proc.fifoloopbackenable(di))
237 #define dma_txstopped(di) (dma64proc.txstopped(di))
238 #define dma_rxstopped(di) (dma64proc.rxstopped(di))
239 #define dma_rxenable(di) (dma64proc.rxenable(di))
240 #define dma_rxenabled(di) (dma64proc.rxenabled(di))
241 #define dma_rx(di) (dma64proc.rx(di))
242 #define dma_rxfill(di) (dma64proc.rxfill(di))
243 #define dma_txreclaim(di, range) (dma64proc.txreclaim(di, range))
244 #define dma_rxreclaim(di) (dma64proc.rxreclaim(di))
245 #define dma_getvar(di, name) (dma64proc.d_getvar(di, name))
246 #define dma_getnexttxp(di, range) (dma64proc.getnexttxp(di, range))
247 #define dma_getnextrxp(di, forceall) (dma64proc.getnextrxp(di, forceall))
248 #define dma_peeknexttxp(di) (dma64proc.peeknexttxp(di))
249 #define dma_peeknextrxp(di) (dma64proc.peeknextrxp(di))
250 #define dma_rxparam_get(di, off, bufs) (dma64proc.rxparam_get(di, off, bufs))
252 #define dma_txblock(di) (dma64proc.txblock(di))
253 #define dma_txunblock(di) (dma64proc.txunblock(di))
254 #define dma_txactive(di) (dma64proc.txactive(di))
255 #define dma_rxactive(di) (dma64proc.rxactive(di))
256 #define dma_txrotate(di) (dma64proc.txrotate(di))
257 #define dma_counterreset(di) (dma64proc.counterreset(di))
258 #define dma_ctrlflags(di, mask, flags) (dma64proc.ctrlflags((di), (mask), (flags)))
259 #define dma_txpending(di) (dma64proc.txpending(di))
260 #define dma_txcommitted(di) (dma64proc.txcommitted(di))
261 #if defined(BCMDBG) || defined(BCMDBG_DUMP)
262 #define dma_dump(di, buf, dumpring) (dma64proc.dump(di, buf, dumpring))
263 #define dma_dumptx(di, buf, dumpring) (dma64proc.dumptx(di, buf, dumpring))
264 #define dma_dumprx(di, buf, dumpring) (dma64proc.dumprx(di, buf, dumpring))
266 #define dma_avoidance_cnt(di) (dma64proc.avoidancecnt(di))
268 #endif /* BCMDMA32 */
270 /* return addresswidth allowed
271 * This needs to be done after SB attach but before dma attach.
272 * SB attach provides ability to probe backplane and dma core capabilities
273 * This info is needed by DMA_ALLOC_CONSISTENT in dma attach
275 extern uint
dma_addrwidth(si_t
*sih
, void *dmaregs
);
278 extern void dma_txpioloopback(osl_t
*osh
, dma32regs_t
*);
280 #endif /* _hnddma_h_ */