2 * Generic Broadcom Home Networking Division (HND) DMA engine SW interface
3 * This supports the following chips: BCM42xx, 44xx, 47xx .
5 * Copyright 2007, Broadcom Corporation
8 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
11 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
18 typedef const struct hnddma_pub hnddma_t
;
20 /* dma function type */
21 typedef void (*di_detach_t
)(hnddma_t
*dmah
);
22 typedef bool (*di_txreset_t
)(hnddma_t
*dmah
);
23 typedef bool (*di_rxreset_t
)(hnddma_t
*dmah
);
24 typedef bool (*di_rxidle_t
)(hnddma_t
*dmah
);
25 typedef void (*di_txinit_t
)(hnddma_t
*dmah
);
26 typedef bool (*di_txenabled_t
)(hnddma_t
*dmah
);
27 typedef void (*di_rxinit_t
)(hnddma_t
*dmah
);
28 typedef void (*di_txsuspend_t
)(hnddma_t
*dmah
);
29 typedef void (*di_txresume_t
)(hnddma_t
*dmah
);
30 typedef bool (*di_txsuspended_t
)(hnddma_t
*dmah
);
31 typedef bool (*di_txsuspendedidle_t
)(hnddma_t
*dmah
);
32 typedef int (*di_txfast_t
)(hnddma_t
*dmah
, void *p
, bool commit
);
33 typedef void (*di_fifoloopbackenable_t
)(hnddma_t
*dmah
);
34 typedef bool (*di_txstopped_t
)(hnddma_t
*dmah
);
35 typedef bool (*di_rxstopped_t
)(hnddma_t
*dmah
);
36 typedef bool (*di_rxenable_t
)(hnddma_t
*dmah
);
37 typedef bool (*di_rxenabled_t
)(hnddma_t
*dmah
);
38 typedef void* (*di_rx_t
)(hnddma_t
*dmah
);
39 typedef void (*di_rxfill_t
)(hnddma_t
*dmah
);
40 typedef void (*di_txreclaim_t
)(hnddma_t
*dmah
, bool forceall
);
41 typedef void (*di_rxreclaim_t
)(hnddma_t
*dmah
);
42 typedef uintptr (*di_getvar_t
)(hnddma_t
*dmah
, const char *name
);
43 typedef void* (*di_getnexttxp_t
)(hnddma_t
*dmah
, bool forceall
);
44 typedef void* (*di_getnextrxp_t
)(hnddma_t
*dmah
, bool forceall
);
45 typedef void* (*di_peeknexttxp_t
)(hnddma_t
*dmah
);
46 typedef void (*di_txblock_t
)(hnddma_t
*dmah
);
47 typedef void (*di_txunblock_t
)(hnddma_t
*dmah
);
48 typedef uint (*di_txactive_t
)(hnddma_t
*dmah
);
49 typedef void (*di_txrotate_t
)(hnddma_t
*dmah
);
50 typedef void (*di_counterreset_t
)(hnddma_t
*dmah
);
51 typedef char* (*di_dump_t
)(hnddma_t
*dmah
, struct bcmstrbuf
*b
, bool dumpring
);
52 typedef char* (*di_dumptx_t
)(hnddma_t
*dmah
, struct bcmstrbuf
*b
, bool dumpring
);
53 typedef char* (*di_dumprx_t
)(hnddma_t
*dmah
, struct bcmstrbuf
*b
, bool dumpring
);
56 typedef struct di_fcn_s
{
60 di_txenabled_t txenabled
;
61 di_txsuspend_t txsuspend
;
62 di_txresume_t txresume
;
63 di_txsuspended_t txsuspended
;
64 di_txsuspendedidle_t txsuspendedidle
;
66 di_txstopped_t txstopped
;
67 di_txreclaim_t txreclaim
;
68 di_getnexttxp_t getnexttxp
;
69 di_peeknexttxp_t peeknexttxp
;
71 di_txunblock_t txunblock
;
72 di_txactive_t txactive
;
73 di_txrotate_t txrotate
;
78 di_rxstopped_t rxstopped
;
79 di_rxenable_t rxenable
;
80 di_rxenabled_t rxenabled
;
83 di_rxreclaim_t rxreclaim
;
84 di_getnextrxp_t getnextrxp
;
86 di_fifoloopbackenable_t fifoloopbackenable
;
88 di_counterreset_t counterreset
;
96 * Exported data structure (read-only)
98 /* export structure */
100 di_fcn_t di_fn
; /* DMA function pointers */
101 uint txavail
; /* # free tx descriptors */
103 /* rx error counters */
104 uint rxgiants
; /* rx giant frames */
105 uint rxnobuf
; /* rx out of dma descriptors */
106 /* tx error counters */
107 uint txnobuf
; /* tx out of dma descriptors */
111 extern hnddma_t
* dma_attach(osl_t
*osh
, char *name
, sb_t
*sbh
, void *dmaregstx
, void *dmaregsrx
,
112 uint ntxd
, uint nrxd
, uint rxbufsize
, uint nrxpost
, uint rxoffset
,
114 #define dma_detach(di) ((di)->di_fn.detach(di))
115 #define dma_txreset(di) ((di)->di_fn.txreset(di))
116 #define dma_rxreset(di) ((di)->di_fn.rxreset(di))
117 #define dma_rxidle(di) ((di)->di_fn.rxidle(di))
118 #define dma_txinit(di) ((di)->di_fn.txinit(di))
119 #define dma_txenabled(di) ((di)->di_fn.txenabled(di))
120 #define dma_rxinit(di) ((di)->di_fn.rxinit(di))
121 #define dma_txsuspend(di) ((di)->di_fn.txsuspend(di))
122 #define dma_txresume(di) ((di)->di_fn.txresume(di))
123 #define dma_txsuspended(di) ((di)->di_fn.txsuspended(di))
124 #define dma_txsuspendedidle(di) ((di)->di_fn.txsuspendedidle(di))
125 #define dma_txfast(di, p, commit) ((di)->di_fn.txfast(di, p, commit))
126 #define dma_fifoloopbackenable(di) ((di)->di_fn.fifoloopbackenable(di))
127 #define dma_txstopped(di) ((di)->di_fn.txstopped(di))
128 #define dma_rxstopped(di) ((di)->di_fn.rxstopped(di))
129 #define dma_rxenable(di) ((di)->di_fn.rxenable(di))
130 #define dma_rxenabled(di) ((di)->di_fn.rxenabled(di))
131 #define dma_rx(di) ((di)->di_fn.rx(di))
132 #define dma_rxfill(di) ((di)->di_fn.rxfill(di))
133 #define dma_txreclaim(di, forceall) ((di)->di_fn.txreclaim(di, forceall))
134 #define dma_rxreclaim(di) ((di)->di_fn.rxreclaim(di))
135 #define dma_getvar(di, name) ((di)->di_fn.d_getvar(di, name))
136 #define dma_getnexttxp(di, forceall) ((di)->di_fn.getnexttxp(di, forceall))
137 #define dma_getnextrxp(di, forceall) ((di)->di_fn.getnextrxp(di, forceall))
138 #define dma_peeknexttxp(di) ((di)->di_fn.peeknexttxp(di))
139 #define dma_txblock(di) ((di)->di_fn.txblock(di))
140 #define dma_txunblock(di) ((di)->di_fn.txunblock(di))
141 #define dma_txactive(di) ((di)->di_fn.txactive(di))
142 #define dma_txrotate(di) ((di)->di_fn.txrotate(di))
143 #define dma_counterreset(di) ((di)->di_fn.counterreset(di))
145 #define dma_dump(di, buf, dumpring) ((di)->di_fn.dump(di, buf, dumpring))
146 #define dma_dumptx(di, buf, dumpring) ((di)->di_fn.dumptx(di, buf, dumpring))
147 #define dma_dumprx(di, buf, dumpring) ((di)->di_fn.dumprx(di, buf, dumpring))
150 /* return addresswidth allowed
151 * This needs to be done after SB attach but before dma attach.
152 * SB attach provides ability to probe backplane and dma core capabilities
153 * This info is needed by DMA_ALLOC_CONSISTENT in dma attach
155 extern uint
dma_addrwidth(sb_t
*sbh
, void *dmaregs
);
158 void dma_txpioloopback(osl_t
*osh
, dma32regs_t
*);
160 #endif /* _hnddma_h_ */