2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 typedef const struct hnddma_pub hnddma_t
;
23 #endif /* _hnddma_pub_ */
25 /* range param for dma_getnexttxp() and dma_txreclaim */
26 typedef enum txd_range
{
28 HNDDMA_RANGE_TRANSMITTED
,
29 HNDDMA_RANGE_TRANSFERED
32 /* dma function type */
33 typedef void (*di_detach_t
) (hnddma_t
*dmah
);
34 typedef bool(*di_txreset_t
) (hnddma_t
*dmah
);
35 typedef bool(*di_rxreset_t
) (hnddma_t
*dmah
);
36 typedef bool(*di_rxidle_t
) (hnddma_t
*dmah
);
37 typedef void (*di_txinit_t
) (hnddma_t
*dmah
);
38 typedef bool(*di_txenabled_t
) (hnddma_t
*dmah
);
39 typedef void (*di_rxinit_t
) (hnddma_t
*dmah
);
40 typedef void (*di_txsuspend_t
) (hnddma_t
*dmah
);
41 typedef void (*di_txresume_t
) (hnddma_t
*dmah
);
42 typedef bool(*di_txsuspended_t
) (hnddma_t
*dmah
);
43 typedef bool(*di_txsuspendedidle_t
) (hnddma_t
*dmah
);
44 typedef int (*di_txfast_t
) (hnddma_t
*dmah
, struct sk_buff
*p
, bool commit
);
45 typedef int (*di_txunframed_t
) (hnddma_t
*dmah
, void *p
, uint len
,
47 typedef void *(*di_getpos_t
) (hnddma_t
*di
, bool direction
);
48 typedef void (*di_fifoloopbackenable_t
) (hnddma_t
*dmah
);
49 typedef bool(*di_txstopped_t
) (hnddma_t
*dmah
);
50 typedef bool(*di_rxstopped_t
) (hnddma_t
*dmah
);
51 typedef bool(*di_rxenable_t
) (hnddma_t
*dmah
);
52 typedef bool(*di_rxenabled_t
) (hnddma_t
*dmah
);
53 typedef void *(*di_rx_t
) (hnddma_t
*dmah
);
54 typedef bool(*di_rxfill_t
) (hnddma_t
*dmah
);
55 typedef void (*di_txreclaim_t
) (hnddma_t
*dmah
, txd_range_t range
);
56 typedef void (*di_rxreclaim_t
) (hnddma_t
*dmah
);
57 typedef unsigned long (*di_getvar_t
) (hnddma_t
*dmah
, const char *name
);
58 typedef void *(*di_getnexttxp_t
) (hnddma_t
*dmah
, txd_range_t range
);
59 typedef void *(*di_getnextrxp_t
) (hnddma_t
*dmah
, bool forceall
);
60 typedef void *(*di_peeknexttxp_t
) (hnddma_t
*dmah
);
61 typedef void *(*di_peeknextrxp_t
) (hnddma_t
*dmah
);
62 typedef void (*di_rxparam_get_t
) (hnddma_t
*dmah
, u16
*rxoffset
,
64 typedef void (*di_txblock_t
) (hnddma_t
*dmah
);
65 typedef void (*di_txunblock_t
) (hnddma_t
*dmah
);
66 typedef uint(*di_txactive_t
) (hnddma_t
*dmah
);
67 typedef void (*di_txrotate_t
) (hnddma_t
*dmah
);
68 typedef void (*di_counterreset_t
) (hnddma_t
*dmah
);
69 typedef uint(*di_ctrlflags_t
) (hnddma_t
*dmah
, uint mask
, uint flags
);
70 typedef char *(*di_dump_t
) (hnddma_t
*dmah
, struct bcmstrbuf
*b
,
72 typedef char *(*di_dumptx_t
) (hnddma_t
*dmah
, struct bcmstrbuf
*b
,
74 typedef char *(*di_dumprx_t
) (hnddma_t
*dmah
, struct bcmstrbuf
*b
,
76 typedef uint(*di_rxactive_t
) (hnddma_t
*dmah
);
77 typedef uint(*di_txpending_t
) (hnddma_t
*dmah
);
78 typedef uint(*di_txcommitted_t
) (hnddma_t
*dmah
);
81 typedef struct di_fcn_s
{
85 di_txenabled_t txenabled
;
86 di_txsuspend_t txsuspend
;
87 di_txresume_t txresume
;
88 di_txsuspended_t txsuspended
;
89 di_txsuspendedidle_t txsuspendedidle
;
91 di_txunframed_t txunframed
;
93 di_txstopped_t txstopped
;
94 di_txreclaim_t txreclaim
;
95 di_getnexttxp_t getnexttxp
;
96 di_peeknexttxp_t peeknexttxp
;
98 di_txunblock_t txunblock
;
99 di_txactive_t txactive
;
100 di_txrotate_t txrotate
;
103 di_rxreset_t rxreset
;
105 di_rxstopped_t rxstopped
;
106 di_rxenable_t rxenable
;
107 di_rxenabled_t rxenabled
;
110 di_rxreclaim_t rxreclaim
;
111 di_getnextrxp_t getnextrxp
;
112 di_peeknextrxp_t peeknextrxp
;
113 di_rxparam_get_t rxparam_get
;
115 di_fifoloopbackenable_t fifoloopbackenable
;
116 di_getvar_t d_getvar
;
117 di_counterreset_t counterreset
;
118 di_ctrlflags_t ctrlflags
;
122 di_rxactive_t rxactive
;
123 di_txpending_t txpending
;
124 di_txcommitted_t txcommitted
;
129 * Exported data structure (read-only)
131 /* export structure */
133 const di_fcn_t
*di_fn
; /* DMA function pointers */
134 uint txavail
; /* # free tx descriptors */
135 uint dmactrlflags
; /* dma control flags */
137 /* rx error counters */
138 uint rxgiants
; /* rx giant frames */
139 uint rxnobuf
; /* rx out of dma descriptors */
140 /* tx error counters */
141 uint txnobuf
; /* tx out of dma descriptors */
144 extern hnddma_t
*dma_attach(struct osl_info
*osh
, char *name
, si_t
*sih
,
145 void *dmaregstx
, void *dmaregsrx
, uint ntxd
,
146 uint nrxd
, uint rxbufsize
, int rxextheadroom
,
147 uint nrxpost
, uint rxoffset
, uint
*msg_level
);
150 #define dma_detach(di) ((di)->di_fn->detach(di))
151 #define dma_txreset(di) ((di)->di_fn->txreset(di))
152 #define dma_rxreset(di) ((di)->di_fn->rxreset(di))
153 #define dma_rxidle(di) ((di)->di_fn->rxidle(di))
154 #define dma_txinit(di) ((di)->di_fn->txinit(di))
155 #define dma_txenabled(di) ((di)->di_fn->txenabled(di))
156 #define dma_rxinit(di) ((di)->di_fn->rxinit(di))
157 #define dma_txsuspend(di) ((di)->di_fn->txsuspend(di))
158 #define dma_txresume(di) ((di)->di_fn->txresume(di))
159 #define dma_txsuspended(di) ((di)->di_fn->txsuspended(di))
160 #define dma_txsuspendedidle(di) ((di)->di_fn->txsuspendedidle(di))
161 #define dma_txfast(di, p, commit) ((di)->di_fn->txfast(di, p, commit))
162 #define dma_fifoloopbackenable(di) ((di)->di_fn->fifoloopbackenable(di))
163 #define dma_txstopped(di) ((di)->di_fn->txstopped(di))
164 #define dma_rxstopped(di) ((di)->di_fn->rxstopped(di))
165 #define dma_rxenable(di) ((di)->di_fn->rxenable(di))
166 #define dma_rxenabled(di) ((di)->di_fn->rxenabled(di))
167 #define dma_rx(di) ((di)->di_fn->rx(di))
168 #define dma_rxfill(di) ((di)->di_fn->rxfill(di))
169 #define dma_txreclaim(di, range) ((di)->di_fn->txreclaim(di, range))
170 #define dma_rxreclaim(di) ((di)->di_fn->rxreclaim(di))
171 #define dma_getvar(di, name) ((di)->di_fn->d_getvar(di, name))
172 #define dma_getnexttxp(di, range) ((di)->di_fn->getnexttxp(di, range))
173 #define dma_getnextrxp(di, forceall) ((di)->di_fn->getnextrxp(di, forceall))
174 #define dma_peeknexttxp(di) ((di)->di_fn->peeknexttxp(di))
175 #define dma_peeknextrxp(di) ((di)->di_fn->peeknextrxp(di))
176 #define dma_rxparam_get(di, off, bufs) ((di)->di_fn->rxparam_get(di, off, bufs))
178 #define dma_txblock(di) ((di)->di_fn->txblock(di))
179 #define dma_txunblock(di) ((di)->di_fn->txunblock(di))
180 #define dma_txactive(di) ((di)->di_fn->txactive(di))
181 #define dma_rxactive(di) ((di)->di_fn->rxactive(di))
182 #define dma_txrotate(di) ((di)->di_fn->txrotate(di))
183 #define dma_counterreset(di) ((di)->di_fn->counterreset(di))
184 #define dma_ctrlflags(di, mask, flags) ((di)->di_fn->ctrlflags((di), (mask), (flags)))
185 #define dma_txpending(di) ((di)->di_fn->txpending(di))
186 #define dma_txcommitted(di) ((di)->di_fn->txcommitted(di))
189 extern const di_fcn_t dma64proc
;
191 #define dma_detach(di) (dma64proc.detach(di))
192 #define dma_txreset(di) (dma64proc.txreset(di))
193 #define dma_rxreset(di) (dma64proc.rxreset(di))
194 #define dma_rxidle(di) (dma64proc.rxidle(di))
195 #define dma_txinit(di) (dma64proc.txinit(di))
196 #define dma_txenabled(di) (dma64proc.txenabled(di))
197 #define dma_rxinit(di) (dma64proc.rxinit(di))
198 #define dma_txsuspend(di) (dma64proc.txsuspend(di))
199 #define dma_txresume(di) (dma64proc.txresume(di))
200 #define dma_txsuspended(di) (dma64proc.txsuspended(di))
201 #define dma_txsuspendedidle(di) (dma64proc.txsuspendedidle(di))
202 #define dma_txfast(di, p, commit) (dma64proc.txfast(di, p, commit))
203 #define dma_txunframed(di, p, l, commit)(dma64proc.txunframed(di, p, l, commit))
204 #define dma_getpos(di, dir) (dma64proc.getpos(di, dir))
205 #define dma_fifoloopbackenable(di) (dma64proc.fifoloopbackenable(di))
206 #define dma_txstopped(di) (dma64proc.txstopped(di))
207 #define dma_rxstopped(di) (dma64proc.rxstopped(di))
208 #define dma_rxenable(di) (dma64proc.rxenable(di))
209 #define dma_rxenabled(di) (dma64proc.rxenabled(di))
210 #define dma_rx(di) (dma64proc.rx(di))
211 #define dma_rxfill(di) (dma64proc.rxfill(di))
212 #define dma_txreclaim(di, range) (dma64proc.txreclaim(di, range))
213 #define dma_rxreclaim(di) (dma64proc.rxreclaim(di))
214 #define dma_getvar(di, name) (dma64proc.d_getvar(di, name))
215 #define dma_getnexttxp(di, range) (dma64proc.getnexttxp(di, range))
216 #define dma_getnextrxp(di, forceall) (dma64proc.getnextrxp(di, forceall))
217 #define dma_peeknexttxp(di) (dma64proc.peeknexttxp(di))
218 #define dma_peeknextrxp(di) (dma64proc.peeknextrxp(di))
219 #define dma_rxparam_get(di, off, bufs) (dma64proc.rxparam_get(di, off, bufs))
221 #define dma_txblock(di) (dma64proc.txblock(di))
222 #define dma_txunblock(di) (dma64proc.txunblock(di))
223 #define dma_txactive(di) (dma64proc.txactive(di))
224 #define dma_rxactive(di) (dma64proc.rxactive(di))
225 #define dma_txrotate(di) (dma64proc.txrotate(di))
226 #define dma_counterreset(di) (dma64proc.counterreset(di))
227 #define dma_ctrlflags(di, mask, flags) (dma64proc.ctrlflags((di), (mask), (flags)))
228 #define dma_txpending(di) (dma64proc.txpending(di))
229 #define dma_txcommitted(di) (dma64proc.txcommitted(di))
231 #endif /* BCMDMA32 */
233 /* return addresswidth allowed
234 * This needs to be done after SB attach but before dma attach.
235 * SB attach provides ability to probe backplane and dma core capabilities
236 * This info is needed by DMA_ALLOC_CONSISTENT in dma attach
238 extern uint
dma_addrwidth(si_t
*sih
, void *dmaregs
);
241 extern void dma_txpioloopback(struct osl_info
*osh
, dma32regs_t
*);
243 #endif /* _hnddma_h_ */