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.
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) (struct hnddma_pub *dmah);
34 typedef bool(*di_txreset_t) (struct hnddma_pub *dmah);
35 typedef bool(*di_rxreset_t) (struct hnddma_pub *dmah);
36 typedef bool(*di_rxidle_t) (struct hnddma_pub *dmah);
37 typedef void (*di_txinit_t) (struct hnddma_pub *dmah);
38 typedef bool(*di_txenabled_t) (struct hnddma_pub *dmah);
39 typedef void (*di_rxinit_t) (struct hnddma_pub *dmah);
40 typedef void (*di_txsuspend_t) (struct hnddma_pub *dmah);
41 typedef void (*di_txresume_t) (struct hnddma_pub *dmah);
42 typedef bool(*di_txsuspended_t) (struct hnddma_pub *dmah);
43 typedef bool(*di_txsuspendedidle_t) (struct hnddma_pub *dmah);
44 typedef int (*di_txfast_t) (struct hnddma_pub *dmah, struct sk_buff *p,
46 typedef int (*di_txunframed_t) (struct hnddma_pub *dmah, void *p, uint len,
48 typedef void *(*di_getpos_t) (struct hnddma_pub *di, bool direction);
49 typedef void (*di_fifoloopbackenable_t) (struct hnddma_pub *dmah);
50 typedef bool(*di_txstopped_t) (struct hnddma_pub *dmah);
51 typedef bool(*di_rxstopped_t) (struct hnddma_pub *dmah);
52 typedef bool(*di_rxenable_t) (struct hnddma_pub *dmah);
53 typedef bool(*di_rxenabled_t) (struct hnddma_pub *dmah);
54 typedef void *(*di_rx_t) (struct hnddma_pub *dmah);
55 typedef bool(*di_rxfill_t) (struct hnddma_pub *dmah);
56 typedef void (*di_txreclaim_t) (struct hnddma_pub *dmah, txd_range_t range);
57 typedef void (*di_rxreclaim_t) (struct hnddma_pub *dmah);
58 typedef unsigned long (*di_getvar_t) (struct hnddma_pub *dmah,
60 typedef void *(*di_getnexttxp_t) (struct hnddma_pub *dmah, txd_range_t range);
61 typedef void *(*di_getnextrxp_t) (struct hnddma_pub *dmah, bool forceall);
62 typedef void *(*di_peeknexttxp_t) (struct hnddma_pub *dmah);
63 typedef void *(*di_peeknextrxp_t) (struct hnddma_pub *dmah);
64 typedef void (*di_rxparam_get_t) (struct hnddma_pub *dmah, u16 *rxoffset,
66 typedef void (*di_txblock_t) (struct hnddma_pub *dmah);
67 typedef void (*di_txunblock_t) (struct hnddma_pub *dmah);
68 typedef uint(*di_txactive_t) (struct hnddma_pub *dmah);
69 typedef void (*di_txrotate_t) (struct hnddma_pub *dmah);
70 typedef void (*di_counterreset_t) (struct hnddma_pub *dmah);
71 typedef uint(*di_ctrlflags_t) (struct hnddma_pub *dmah, uint mask, uint flags);
72 typedef char *(*di_dump_t) (struct hnddma_pub *dmah, struct bcmstrbuf *b,
74 typedef char *(*di_dumptx_t) (struct hnddma_pub *dmah, struct bcmstrbuf *b,
76 typedef char *(*di_dumprx_t) (struct hnddma_pub *dmah, struct bcmstrbuf *b,
78 typedef uint(*di_rxactive_t) (struct hnddma_pub *dmah);
79 typedef uint(*di_txpending_t) (struct hnddma_pub *dmah);
80 typedef uint(*di_txcommitted_t) (struct hnddma_pub *dmah);
83 typedef struct di_fcn_s {
87 di_txenabled_t txenabled;
88 di_txsuspend_t txsuspend;
89 di_txresume_t txresume;
90 di_txsuspended_t txsuspended;
91 di_txsuspendedidle_t txsuspendedidle;
93 di_txunframed_t txunframed;
95 di_txstopped_t txstopped;
96 di_txreclaim_t txreclaim;
97 di_getnexttxp_t getnexttxp;
98 di_peeknexttxp_t peeknexttxp;
100 di_txunblock_t txunblock;
101 di_txactive_t txactive;
102 di_txrotate_t txrotate;
105 di_rxreset_t rxreset;
107 di_rxstopped_t rxstopped;
108 di_rxenable_t rxenable;
109 di_rxenabled_t rxenabled;
112 di_rxreclaim_t rxreclaim;
113 di_getnextrxp_t getnextrxp;
114 di_peeknextrxp_t peeknextrxp;
115 di_rxparam_get_t rxparam_get;
117 di_fifoloopbackenable_t fifoloopbackenable;
118 di_getvar_t d_getvar;
119 di_counterreset_t counterreset;
120 di_ctrlflags_t ctrlflags;
124 di_rxactive_t rxactive;
125 di_txpending_t txpending;
126 di_txcommitted_t txcommitted;
131 * Exported data structure (read-only)
133 /* export structure */
135 const di_fcn_t *di_fn; /* DMA function pointers */
136 uint txavail; /* # free tx descriptors */
137 uint dmactrlflags; /* dma control flags */
139 /* rx error counters */
140 uint rxgiants; /* rx giant frames */
141 uint rxnobuf; /* rx out of dma descriptors */
142 /* tx error counters */
143 uint txnobuf; /* tx out of dma descriptors */
146 extern struct hnddma_pub *dma_attach(struct osl_info *osh, char *name,
148 void *dmaregstx, void *dmaregsrx, uint ntxd,
149 uint nrxd, uint rxbufsize, int rxextheadroom,
150 uint nrxpost, uint rxoffset, uint *msg_level);
153 #define dma_detach(di) ((di)->di_fn->detach(di))
154 #define dma_txreset(di) ((di)->di_fn->txreset(di))
155 #define dma_rxreset(di) ((di)->di_fn->rxreset(di))
156 #define dma_rxidle(di) ((di)->di_fn->rxidle(di))
157 #define dma_txinit(di) ((di)->di_fn->txinit(di))
158 #define dma_txenabled(di) ((di)->di_fn->txenabled(di))
159 #define dma_rxinit(di) ((di)->di_fn->rxinit(di))
160 #define dma_txsuspend(di) ((di)->di_fn->txsuspend(di))
161 #define dma_txresume(di) ((di)->di_fn->txresume(di))
162 #define dma_txsuspended(di) ((di)->di_fn->txsuspended(di))
163 #define dma_txsuspendedidle(di) ((di)->di_fn->txsuspendedidle(di))
164 #define dma_txfast(di, p, commit) ((di)->di_fn->txfast(di, p, commit))
165 #define dma_fifoloopbackenable(di) ((di)->di_fn->fifoloopbackenable(di))
166 #define dma_txstopped(di) ((di)->di_fn->txstopped(di))
167 #define dma_rxstopped(di) ((di)->di_fn->rxstopped(di))
168 #define dma_rxenable(di) ((di)->di_fn->rxenable(di))
169 #define dma_rxenabled(di) ((di)->di_fn->rxenabled(di))
170 #define dma_rx(di) ((di)->di_fn->rx(di))
171 #define dma_rxfill(di) ((di)->di_fn->rxfill(di))
172 #define dma_txreclaim(di, range) ((di)->di_fn->txreclaim(di, range))
173 #define dma_rxreclaim(di) ((di)->di_fn->rxreclaim(di))
174 #define dma_getvar(di, name) ((di)->di_fn->d_getvar(di, name))
175 #define dma_getnexttxp(di, range) ((di)->di_fn->getnexttxp(di, range))
176 #define dma_getnextrxp(di, forceall) ((di)->di_fn->getnextrxp(di, forceall))
177 #define dma_peeknexttxp(di) ((di)->di_fn->peeknexttxp(di))
178 #define dma_peeknextrxp(di) ((di)->di_fn->peeknextrxp(di))
179 #define dma_rxparam_get(di, off, bufs) ((di)->di_fn->rxparam_get(di, off, bufs))
181 #define dma_txblock(di) ((di)->di_fn->txblock(di))
182 #define dma_txunblock(di) ((di)->di_fn->txunblock(di))
183 #define dma_txactive(di) ((di)->di_fn->txactive(di))
184 #define dma_rxactive(di) ((di)->di_fn->rxactive(di))
185 #define dma_txrotate(di) ((di)->di_fn->txrotate(di))
186 #define dma_counterreset(di) ((di)->di_fn->counterreset(di))
187 #define dma_ctrlflags(di, mask, flags) ((di)->di_fn->ctrlflags((di), (mask), (flags)))
188 #define dma_txpending(di) ((di)->di_fn->txpending(di))
189 #define dma_txcommitted(di) ((di)->di_fn->txcommitted(di))
192 extern const di_fcn_t dma64proc;
194 #define dma_detach(di) (dma64proc.detach(di))
195 #define dma_txreset(di) (dma64proc.txreset(di))
196 #define dma_rxreset(di) (dma64proc.rxreset(di))
197 #define dma_rxidle(di) (dma64proc.rxidle(di))
198 #define dma_txinit(di) (dma64proc.txinit(di))
199 #define dma_txenabled(di) (dma64proc.txenabled(di))
200 #define dma_rxinit(di) (dma64proc.rxinit(di))
201 #define dma_txsuspend(di) (dma64proc.txsuspend(di))
202 #define dma_txresume(di) (dma64proc.txresume(di))
203 #define dma_txsuspended(di) (dma64proc.txsuspended(di))
204 #define dma_txsuspendedidle(di) (dma64proc.txsuspendedidle(di))
205 #define dma_txfast(di, p, commit) (dma64proc.txfast(di, p, commit))
206 #define dma_txunframed(di, p, l, commit)(dma64proc.txunframed(di, p, l, commit))
207 #define dma_getpos(di, dir) (dma64proc.getpos(di, dir))
208 #define dma_fifoloopbackenable(di) (dma64proc.fifoloopbackenable(di))
209 #define dma_txstopped(di) (dma64proc.txstopped(di))
210 #define dma_rxstopped(di) (dma64proc.rxstopped(di))
211 #define dma_rxenable(di) (dma64proc.rxenable(di))
212 #define dma_rxenabled(di) (dma64proc.rxenabled(di))
213 #define dma_rx(di) (dma64proc.rx(di))
214 #define dma_rxfill(di) (dma64proc.rxfill(di))
215 #define dma_txreclaim(di, range) (dma64proc.txreclaim(di, range))
216 #define dma_rxreclaim(di) (dma64proc.rxreclaim(di))
217 #define dma_getvar(di, name) (dma64proc.d_getvar(di, name))
218 #define dma_getnexttxp(di, range) (dma64proc.getnexttxp(di, range))
219 #define dma_getnextrxp(di, forceall) (dma64proc.getnextrxp(di, forceall))
220 #define dma_peeknexttxp(di) (dma64proc.peeknexttxp(di))
221 #define dma_peeknextrxp(di) (dma64proc.peeknextrxp(di))
222 #define dma_rxparam_get(di, off, bufs) (dma64proc.rxparam_get(di, off, bufs))
224 #define dma_txblock(di) (dma64proc.txblock(di))
225 #define dma_txunblock(di) (dma64proc.txunblock(di))
226 #define dma_txactive(di) (dma64proc.txactive(di))
227 #define dma_rxactive(di) (dma64proc.rxactive(di))
228 #define dma_txrotate(di) (dma64proc.txrotate(di))
229 #define dma_counterreset(di) (dma64proc.counterreset(di))
230 #define dma_ctrlflags(di, mask, flags) (dma64proc.ctrlflags((di), (mask), (flags)))
231 #define dma_txpending(di) (dma64proc.txpending(di))
232 #define dma_txcommitted(di) (dma64proc.txcommitted(di))
234 #endif /* BCMDMA32 */
236 /* return addresswidth allowed
237 * This needs to be done after SB attach but before dma attach.
238 * SB attach provides ability to probe backplane and dma core capabilities
239 * This info is needed by DMA_ALLOC_CONSISTENT in dma attach
241 extern uint dma_addrwidth(si_t *sih, void *dmaregs);
244 extern void dma_txpioloopback(struct osl_info *osh, dma32regs_t *);
246 #endif /* _hnddma_h_ */