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.
17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19 #include <linux/slab.h>
20 #include <linux/delay.h>
21 #include <linux/pci.h>
23 #include <brcmu_utils.h>
30 * dma register field offset calculation
32 #define DMA64REGOFFS(field) offsetof(struct dma64regs, field)
33 #define DMA64TXREGOFFS(di, field) (di->d64txregbase + DMA64REGOFFS(field))
34 #define DMA64RXREGOFFS(di, field) (di->d64rxregbase + DMA64REGOFFS(field))
37 * DMA hardware requires each descriptor ring to be 8kB aligned, and fit within
38 * a contiguous 8kB physical address.
40 #define D64RINGALIGN_BITS 13
41 #define D64MAXRINGSZ (1 << D64RINGALIGN_BITS)
42 #define D64RINGALIGN (1 << D64RINGALIGN_BITS)
44 #define D64MAXDD (D64MAXRINGSZ / sizeof(struct dma64desc))
46 /* transmit channel control */
47 #define D64_XC_XE 0x00000001 /* transmit enable */
48 #define D64_XC_SE 0x00000002 /* transmit suspend request */
49 #define D64_XC_LE 0x00000004 /* loopback enable */
50 #define D64_XC_FL 0x00000010 /* flush request */
51 #define D64_XC_PD 0x00000800 /* parity check disable */
52 #define D64_XC_AE 0x00030000 /* address extension bits */
53 #define D64_XC_AE_SHIFT 16
55 /* transmit descriptor table pointer */
56 #define D64_XP_LD_MASK 0x00000fff /* last valid descriptor */
58 /* transmit channel status */
59 #define D64_XS0_CD_MASK 0x00001fff /* current descriptor pointer */
60 #define D64_XS0_XS_MASK 0xf0000000 /* transmit state */
61 #define D64_XS0_XS_SHIFT 28
62 #define D64_XS0_XS_DISABLED 0x00000000 /* disabled */
63 #define D64_XS0_XS_ACTIVE 0x10000000 /* active */
64 #define D64_XS0_XS_IDLE 0x20000000 /* idle wait */
65 #define D64_XS0_XS_STOPPED 0x30000000 /* stopped */
66 #define D64_XS0_XS_SUSP 0x40000000 /* suspend pending */
68 #define D64_XS1_AD_MASK 0x00001fff /* active descriptor */
69 #define D64_XS1_XE_MASK 0xf0000000 /* transmit errors */
70 #define D64_XS1_XE_SHIFT 28
71 #define D64_XS1_XE_NOERR 0x00000000 /* no error */
72 #define D64_XS1_XE_DPE 0x10000000 /* descriptor protocol error */
73 #define D64_XS1_XE_DFU 0x20000000 /* data fifo underrun */
74 #define D64_XS1_XE_DTE 0x30000000 /* data transfer error */
75 #define D64_XS1_XE_DESRE 0x40000000 /* descriptor read error */
76 #define D64_XS1_XE_COREE 0x50000000 /* core error */
78 /* receive channel control */
80 #define D64_RC_RE 0x00000001
81 /* receive frame offset */
82 #define D64_RC_RO_MASK 0x000000fe
83 #define D64_RC_RO_SHIFT 1
84 /* direct fifo receive (pio) mode */
85 #define D64_RC_FM 0x00000100
86 /* separate rx header descriptor enable */
87 #define D64_RC_SH 0x00000200
88 /* overflow continue */
89 #define D64_RC_OC 0x00000400
90 /* parity check disable */
91 #define D64_RC_PD 0x00000800
92 /* address extension bits */
93 #define D64_RC_AE 0x00030000
94 #define D64_RC_AE_SHIFT 16
96 /* flags for dma controller */
98 #define DMA_CTRL_PEN (1 << 0)
99 /* rx overflow continue */
100 #define DMA_CTRL_ROC (1 << 1)
101 /* allow rx scatter to multiple descriptors */
102 #define DMA_CTRL_RXMULTI (1 << 2)
103 /* Unframed Rx/Tx data */
104 #define DMA_CTRL_UNFRAMED (1 << 3)
106 /* receive descriptor table pointer */
107 #define D64_RP_LD_MASK 0x00000fff /* last valid descriptor */
109 /* receive channel status */
110 #define D64_RS0_CD_MASK 0x00001fff /* current descriptor pointer */
111 #define D64_RS0_RS_MASK 0xf0000000 /* receive state */
112 #define D64_RS0_RS_SHIFT 28
113 #define D64_RS0_RS_DISABLED 0x00000000 /* disabled */
114 #define D64_RS0_RS_ACTIVE 0x10000000 /* active */
115 #define D64_RS0_RS_IDLE 0x20000000 /* idle wait */
116 #define D64_RS0_RS_STOPPED 0x30000000 /* stopped */
117 #define D64_RS0_RS_SUSP 0x40000000 /* suspend pending */
119 #define D64_RS1_AD_MASK 0x0001ffff /* active descriptor */
120 #define D64_RS1_RE_MASK 0xf0000000 /* receive errors */
121 #define D64_RS1_RE_SHIFT 28
122 #define D64_RS1_RE_NOERR 0x00000000 /* no error */
123 #define D64_RS1_RE_DPO 0x10000000 /* descriptor protocol error */
124 #define D64_RS1_RE_DFU 0x20000000 /* data fifo overflow */
125 #define D64_RS1_RE_DTE 0x30000000 /* data transfer error */
126 #define D64_RS1_RE_DESRE 0x40000000 /* descriptor read error */
127 #define D64_RS1_RE_COREE 0x50000000 /* core error */
130 #define D64_FA_OFF_MASK 0xffff /* offset */
131 #define D64_FA_SEL_MASK 0xf0000 /* select */
132 #define D64_FA_SEL_SHIFT 16
133 #define D64_FA_SEL_XDD 0x00000 /* transmit dma data */
134 #define D64_FA_SEL_XDP 0x10000 /* transmit dma pointers */
135 #define D64_FA_SEL_RDD 0x40000 /* receive dma data */
136 #define D64_FA_SEL_RDP 0x50000 /* receive dma pointers */
137 #define D64_FA_SEL_XFD 0x80000 /* transmit fifo data */
138 #define D64_FA_SEL_XFP 0x90000 /* transmit fifo pointers */
139 #define D64_FA_SEL_RFD 0xc0000 /* receive fifo data */
140 #define D64_FA_SEL_RFP 0xd0000 /* receive fifo pointers */
141 #define D64_FA_SEL_RSD 0xe0000 /* receive frame status data */
142 #define D64_FA_SEL_RSP 0xf0000 /* receive frame status pointers */
144 /* descriptor control flags 1 */
145 #define D64_CTRL_COREFLAGS 0x0ff00000 /* core specific flags */
146 #define D64_CTRL1_EOT ((u32)1 << 28) /* end of descriptor table */
147 #define D64_CTRL1_IOC ((u32)1 << 29) /* interrupt on completion */
148 #define D64_CTRL1_EOF ((u32)1 << 30) /* end of frame */
149 #define D64_CTRL1_SOF ((u32)1 << 31) /* start of frame */
151 /* descriptor control flags 2 */
152 /* buffer byte count. real data len must <= 16KB */
153 #define D64_CTRL2_BC_MASK 0x00007fff
154 /* address extension bits */
155 #define D64_CTRL2_AE 0x00030000
156 #define D64_CTRL2_AE_SHIFT 16
158 #define D64_CTRL2_PARITY 0x00040000
160 /* control flags in the range [27:20] are core-specific and not defined here */
161 #define D64_CTRL_CORE_MASK 0x0ff00000
163 #define D64_RX_FRM_STS_LEN 0x0000ffff /* frame length mask */
164 #define D64_RX_FRM_STS_OVFL 0x00800000 /* RxOverFlow */
165 #define D64_RX_FRM_STS_DSCRCNT 0x0f000000 /* no. of descriptors used - 1 */
166 #define D64_RX_FRM_STS_DATATYPE 0xf0000000 /* core-dependent data type */
169 * packet headroom necessary to accommodate the largest header
170 * in the system, (i.e TXOFF). By doing, we avoid the need to
171 * allocate an extra buffer for the header when bridging to WL.
172 * There is a compile time check in wlc.c which ensure that this
173 * value is at least as big as TXOFF. This value is used in
177 #define BCMEXTRAHDROOM 172
181 #define DMA_ERROR(fmt, ...) \
183 if (*di->msg_level & 1) \
184 pr_debug("%s: " fmt, __func__, ##__VA_ARGS__); \
186 #define DMA_TRACE(fmt, ...) \
188 if (*di->msg_level & 2) \
189 pr_debug("%s: " fmt, __func__, ##__VA_ARGS__); \
192 #define DMA_ERROR(fmt, ...) \
193 no_printk(fmt, ##__VA_ARGS__)
194 #define DMA_TRACE(fmt, ...) \
195 no_printk(fmt, ##__VA_ARGS__)
198 #define DMA_NONE(fmt, ...) \
199 no_printk(fmt, ##__VA_ARGS__)
201 #define MAXNAMEL 8 /* 8 char names */
203 /* macros to convert between byte offsets and indexes */
204 #define B2I(bytes, type) ((bytes) / sizeof(type))
205 #define I2B(index, type) ((index) * sizeof(type))
207 #define PCI32ADDR_HIGH 0xc0000000 /* address[31:30] */
208 #define PCI32ADDR_HIGH_SHIFT 30 /* address[31:30] */
210 #define PCI64ADDR_HIGH 0x80000000 /* address[63] */
211 #define PCI64ADDR_HIGH_SHIFT 31 /* address[63] */
215 * Descriptors are only read by the hardware, never written back.
218 __le32 ctrl1
; /* misc control bits & bufcount */
219 __le32 ctrl2
; /* buffer count and address extension */
220 __le32 addrlow
; /* memory address of the date buffer, bits 31:0 */
221 __le32 addrhigh
; /* memory address of the date buffer, bits 63:32 */
224 /* dma engine software state */
226 struct dma_pub dma
; /* exported structure */
227 uint
*msg_level
; /* message level pointer */
228 char name
[MAXNAMEL
]; /* callers name for diag msgs */
230 struct bcma_device
*core
;
231 struct device
*dmadev
;
233 bool dma64
; /* this dma engine is operating in 64-bit mode */
234 bool addrext
; /* this dma engine supports DmaExtendedAddrChanges */
236 /* 64-bit dma tx engine registers */
238 /* 64-bit dma rx engine registers */
240 /* pointer to dma64 tx descriptor ring */
241 struct dma64desc
*txd64
;
242 /* pointer to dma64 rx descriptor ring */
243 struct dma64desc
*rxd64
;
245 u16 dmadesc_align
; /* alignment requirement for dma descriptors */
247 u16 ntxd
; /* # tx descriptors tunable */
248 u16 txin
; /* index of next descriptor to reclaim */
249 u16 txout
; /* index of next descriptor to post */
250 /* pointer to parallel array of pointers to packets */
251 struct sk_buff
**txp
;
252 /* Aligned physical address of descriptor ring */
254 /* Original physical address of descriptor ring */
255 dma_addr_t txdpaorig
;
256 u16 txdalign
; /* #bytes added to alloc'd mem to align txd */
257 u32 txdalloc
; /* #bytes allocated for the ring */
258 u32 xmtptrbase
; /* When using unaligned descriptors, the ptr register
259 * is not just an index, it needs all 13 bits to be
260 * an offset from the addr register.
263 u16 nrxd
; /* # rx descriptors tunable */
264 u16 rxin
; /* index of next descriptor to reclaim */
265 u16 rxout
; /* index of next descriptor to post */
266 /* pointer to parallel array of pointers to packets */
267 struct sk_buff
**rxp
;
268 /* Aligned physical address of descriptor ring */
270 /* Original physical address of descriptor ring */
271 dma_addr_t rxdpaorig
;
272 u16 rxdalign
; /* #bytes added to alloc'd mem to align rxd */
273 u32 rxdalloc
; /* #bytes allocated for the ring */
274 u32 rcvptrbase
; /* Base for ptr reg when using unaligned descriptors */
277 unsigned int rxbufsize
; /* rx buffer size in bytes, not including
280 uint rxextrahdrroom
; /* extra rx headroom, reverseved to assist upper
281 * stack, e.g. some rx pkt buffers will be
282 * bridged to tx side without byte copying.
283 * The extra headroom needs to be large enough
284 * to fit txheader needs. Some dongle driver may
287 uint nrxpost
; /* # rx buffers to keep posted */
288 unsigned int rxoffset
; /* rxcontrol offset */
289 /* add to get dma address of descriptor ring, low 32 bits */
293 /* add to get dma address of data buffer, low 32 bits */
297 /* descriptor base need to be aligned or not */
302 * default dma message level (if input msg_level
303 * pointer is null in dma_attach())
305 static uint dma_msg_level
;
307 /* Check for odd number of 1's */
308 static u32
parity32(__le32 data
)
310 /* no swap needed for counting 1's */
311 u32 par_data
= *(u32
*)&data
;
313 par_data
^= par_data
>> 16;
314 par_data
^= par_data
>> 8;
315 par_data
^= par_data
>> 4;
316 par_data
^= par_data
>> 2;
317 par_data
^= par_data
>> 1;
322 static bool dma64_dd_parity(struct dma64desc
*dd
)
324 return parity32(dd
->addrlow
^ dd
->addrhigh
^ dd
->ctrl1
^ dd
->ctrl2
);
327 /* descriptor bumping functions */
329 static uint
xxd(uint x
, uint n
)
331 return x
& (n
- 1); /* faster than %, but n must be power of 2 */
334 static uint
txd(struct dma_info
*di
, uint x
)
336 return xxd(x
, di
->ntxd
);
339 static uint
rxd(struct dma_info
*di
, uint x
)
341 return xxd(x
, di
->nrxd
);
344 static uint
nexttxd(struct dma_info
*di
, uint i
)
346 return txd(di
, i
+ 1);
349 static uint
prevtxd(struct dma_info
*di
, uint i
)
351 return txd(di
, i
- 1);
354 static uint
nextrxd(struct dma_info
*di
, uint i
)
356 return txd(di
, i
+ 1);
359 static uint
ntxdactive(struct dma_info
*di
, uint h
, uint t
)
364 static uint
nrxdactive(struct dma_info
*di
, uint h
, uint t
)
369 static uint
_dma_ctrlflags(struct dma_info
*di
, uint mask
, uint flags
)
374 DMA_ERROR("NULL dma handle\n");
378 dmactrlflags
= di
->dma
.dmactrlflags
;
379 dmactrlflags
&= ~mask
;
380 dmactrlflags
|= flags
;
382 /* If trying to enable parity, check if parity is actually supported */
383 if (dmactrlflags
& DMA_CTRL_PEN
) {
386 control
= bcma_read32(di
->core
, DMA64TXREGOFFS(di
, control
));
387 bcma_write32(di
->core
, DMA64TXREGOFFS(di
, control
),
388 control
| D64_XC_PD
);
389 if (bcma_read32(di
->core
, DMA64TXREGOFFS(di
, control
)) &
391 /* We *can* disable it so it is supported,
392 * restore control register
394 bcma_write32(di
->core
, DMA64TXREGOFFS(di
, control
),
397 /* Not supported, don't allow it to be enabled */
398 dmactrlflags
&= ~DMA_CTRL_PEN
;
401 di
->dma
.dmactrlflags
= dmactrlflags
;
406 static bool _dma64_addrext(struct dma_info
*di
, uint ctrl_offset
)
409 bcma_set32(di
->core
, ctrl_offset
, D64_XC_AE
);
410 w
= bcma_read32(di
->core
, ctrl_offset
);
411 bcma_mask32(di
->core
, ctrl_offset
, ~D64_XC_AE
);
412 return (w
& D64_XC_AE
) == D64_XC_AE
;
416 * return true if this dma engine supports DmaExtendedAddrChanges,
419 static bool _dma_isaddrext(struct dma_info
*di
)
421 /* DMA64 supports full 32- or 64-bit operation. AE is always valid */
423 /* not all tx or rx channel are available */
424 if (di
->d64txregbase
!= 0) {
425 if (!_dma64_addrext(di
, DMA64TXREGOFFS(di
, control
)))
426 DMA_ERROR("%s: DMA64 tx doesn't have AE set\n",
429 } else if (di
->d64rxregbase
!= 0) {
430 if (!_dma64_addrext(di
, DMA64RXREGOFFS(di
, control
)))
431 DMA_ERROR("%s: DMA64 rx doesn't have AE set\n",
439 static bool _dma_descriptor_align(struct dma_info
*di
)
443 /* Check to see if the descriptors need to be aligned on 4K/8K or not */
444 if (di
->d64txregbase
!= 0) {
445 bcma_write32(di
->core
, DMA64TXREGOFFS(di
, addrlow
), 0xff0);
446 addrl
= bcma_read32(di
->core
, DMA64TXREGOFFS(di
, addrlow
));
449 } else if (di
->d64rxregbase
!= 0) {
450 bcma_write32(di
->core
, DMA64RXREGOFFS(di
, addrlow
), 0xff0);
451 addrl
= bcma_read32(di
->core
, DMA64RXREGOFFS(di
, addrlow
));
459 * Descriptor table must start at the DMA hardware dictated alignment, so
460 * allocated memory must be large enough to support this requirement.
462 static void *dma_alloc_consistent(struct dma_info
*di
, uint size
,
463 u16 align_bits
, uint
*alloced
,
467 u16 align
= (1 << align_bits
);
468 if (!IS_ALIGNED(PAGE_SIZE
, align
))
472 return dma_alloc_coherent(di
->dmadev
, size
, pap
, GFP_ATOMIC
);
476 u8
dma_align_sizetobits(uint size
)
484 /* This function ensures that the DMA descriptor ring will not get allocated
485 * across Page boundary. If the allocation is done across the page boundary
486 * at the first time, then it is freed and the allocation is done at
487 * descriptor ring size aligned location. This will ensure that the ring will
488 * not cross page boundary
490 static void *dma_ringalloc(struct dma_info
*di
, u32 boundary
, uint size
,
491 u16
*alignbits
, uint
*alloced
,
496 u32 alignbytes
= 1 << *alignbits
;
498 va
= dma_alloc_consistent(di
, size
, *alignbits
, alloced
, descpa
);
503 desc_strtaddr
= (u32
) roundup((unsigned long)va
, alignbytes
);
504 if (((desc_strtaddr
+ size
- 1) & boundary
) != (desc_strtaddr
506 *alignbits
= dma_align_sizetobits(size
);
507 dma_free_coherent(di
->dmadev
, size
, va
, *descpa
);
508 va
= dma_alloc_consistent(di
, size
, *alignbits
,
514 static bool dma64_alloc(struct dma_info
*di
, uint direction
)
523 ddlen
= sizeof(struct dma64desc
);
525 size
= (direction
== DMA_TX
) ? (di
->ntxd
* ddlen
) : (di
->nrxd
* ddlen
);
526 align_bits
= di
->dmadesc_align
;
527 align
= (1 << align_bits
);
529 if (direction
== DMA_TX
) {
530 va
= dma_ringalloc(di
, D64RINGALIGN
, size
, &align_bits
,
531 &alloced
, &di
->txdpaorig
);
533 DMA_ERROR("%s: DMA_ALLOC_CONSISTENT(ntxd) failed\n",
537 align
= (1 << align_bits
);
538 di
->txd64
= (struct dma64desc
*)
539 roundup((unsigned long)va
, align
);
540 di
->txdalign
= (uint
) ((s8
*)di
->txd64
- (s8
*) va
);
541 di
->txdpa
= di
->txdpaorig
+ di
->txdalign
;
542 di
->txdalloc
= alloced
;
544 va
= dma_ringalloc(di
, D64RINGALIGN
, size
, &align_bits
,
545 &alloced
, &di
->rxdpaorig
);
547 DMA_ERROR("%s: DMA_ALLOC_CONSISTENT(nrxd) failed\n",
551 align
= (1 << align_bits
);
552 di
->rxd64
= (struct dma64desc
*)
553 roundup((unsigned long)va
, align
);
554 di
->rxdalign
= (uint
) ((s8
*)di
->rxd64
- (s8
*) va
);
555 di
->rxdpa
= di
->rxdpaorig
+ di
->rxdalign
;
556 di
->rxdalloc
= alloced
;
562 static bool _dma_alloc(struct dma_info
*di
, uint direction
)
564 return dma64_alloc(di
, direction
);
567 struct dma_pub
*dma_attach(char *name
, struct si_pub
*sih
,
568 struct bcma_device
*core
,
569 uint txregbase
, uint rxregbase
, uint ntxd
, uint nrxd
,
570 uint rxbufsize
, int rxextheadroom
,
571 uint nrxpost
, uint rxoffset
, uint
*msg_level
)
574 u8 rev
= core
->id
.rev
;
576 struct si_info
*sii
= container_of(sih
, struct si_info
, pub
);
578 /* allocate private info structure */
579 di
= kzalloc(sizeof(struct dma_info
), GFP_ATOMIC
);
583 di
->msg_level
= msg_level
? msg_level
: &dma_msg_level
;
587 ((bcma_aread32(core
, BCMA_IOST
) & SISF_DMA64
) == SISF_DMA64
);
589 /* init dma reg info */
591 di
->d64txregbase
= txregbase
;
592 di
->d64rxregbase
= rxregbase
;
595 * Default flags (which can be changed by the driver calling
596 * dma_ctrlflags before enable): For backwards compatibility
597 * both Rx Overflow Continue and Parity are DISABLED.
599 _dma_ctrlflags(di
, DMA_CTRL_ROC
| DMA_CTRL_PEN
, 0);
601 DMA_TRACE("%s: %s flags 0x%x ntxd %d nrxd %d "
602 "rxbufsize %d rxextheadroom %d nrxpost %d rxoffset %d "
603 "txregbase %u rxregbase %u\n", name
, "DMA64",
604 di
->dma
.dmactrlflags
, ntxd
, nrxd
, rxbufsize
,
605 rxextheadroom
, nrxpost
, rxoffset
, txregbase
, rxregbase
);
607 /* make a private copy of our callers name */
608 strncpy(di
->name
, name
, MAXNAMEL
);
609 di
->name
[MAXNAMEL
- 1] = '\0';
611 di
->dmadev
= core
->dma_dev
;
614 di
->ntxd
= (u16
) ntxd
;
615 di
->nrxd
= (u16
) nrxd
;
617 /* the actual dma size doesn't include the extra headroom */
619 (rxextheadroom
== -1) ? BCMEXTRAHDROOM
: rxextheadroom
;
620 if (rxbufsize
> BCMEXTRAHDROOM
)
621 di
->rxbufsize
= (u16
) (rxbufsize
- di
->rxextrahdrroom
);
623 di
->rxbufsize
= (u16
) rxbufsize
;
625 di
->nrxpost
= (u16
) nrxpost
;
626 di
->rxoffset
= (u8
) rxoffset
;
629 * figure out the DMA physical address offset for dd and data
630 * PCI/PCIE: they map silicon backplace address to zero
631 * based memory, need offset
632 * Other bus: use zero SI_BUS BIGENDIAN kludge: use sdram
633 * swapped region for data buffer, not descriptor
636 di
->dataoffsetlow
= 0;
637 /* for pci bus, add offset */
638 if (sii
->icbus
->hosttype
== BCMA_HOSTTYPE_PCI
) {
639 /* add offset for pcie with DMA64 bus */
641 di
->ddoffsethigh
= SI_PCIE_DMA_H32
;
643 di
->dataoffsetlow
= di
->ddoffsetlow
;
644 di
->dataoffsethigh
= di
->ddoffsethigh
;
646 /* WAR64450 : DMACtl.Addr ext fields are not supported in SDIOD core. */
647 if ((core
->id
.id
== BCMA_CORE_SDIO_DEV
)
648 && ((rev
> 0) && (rev
<= 2)))
650 else if ((core
->id
.id
== BCMA_CORE_I2S
) &&
651 ((rev
== 0) || (rev
== 1)))
654 di
->addrext
= _dma_isaddrext(di
);
656 /* does the descriptor need to be aligned and if yes, on 4K/8K or not */
657 di
->aligndesc_4k
= _dma_descriptor_align(di
);
658 if (di
->aligndesc_4k
) {
659 di
->dmadesc_align
= D64RINGALIGN_BITS
;
660 if ((ntxd
< D64MAXDD
/ 2) && (nrxd
< D64MAXDD
/ 2))
661 /* for smaller dd table, HW relax alignment reqmnt */
662 di
->dmadesc_align
= D64RINGALIGN_BITS
- 1;
664 di
->dmadesc_align
= 4; /* 16 byte alignment */
667 DMA_NONE("DMA descriptor align_needed %d, align %d\n",
668 di
->aligndesc_4k
, di
->dmadesc_align
);
670 /* allocate tx packet pointer vector */
672 size
= ntxd
* sizeof(void *);
673 di
->txp
= kzalloc(size
, GFP_ATOMIC
);
678 /* allocate rx packet pointer vector */
680 size
= nrxd
* sizeof(void *);
681 di
->rxp
= kzalloc(size
, GFP_ATOMIC
);
687 * allocate transmit descriptor ring, only need ntxd descriptors
688 * but it must be aligned
691 if (!_dma_alloc(di
, DMA_TX
))
696 * allocate receive descriptor ring, only need nrxd descriptors
697 * but it must be aligned
700 if (!_dma_alloc(di
, DMA_RX
))
704 if ((di
->ddoffsetlow
!= 0) && !di
->addrext
) {
705 if (di
->txdpa
> SI_PCI_DMA_SZ
) {
706 DMA_ERROR("%s: txdpa 0x%x: addrext not supported\n",
707 di
->name
, (u32
)di
->txdpa
);
710 if (di
->rxdpa
> SI_PCI_DMA_SZ
) {
711 DMA_ERROR("%s: rxdpa 0x%x: addrext not supported\n",
712 di
->name
, (u32
)di
->rxdpa
);
717 DMA_TRACE("ddoffsetlow 0x%x ddoffsethigh 0x%x dataoffsetlow 0x%x dataoffsethigh 0x%x addrext %d\n",
718 di
->ddoffsetlow
, di
->ddoffsethigh
,
719 di
->dataoffsetlow
, di
->dataoffsethigh
,
722 return (struct dma_pub
*) di
;
725 dma_detach((struct dma_pub
*)di
);
730 dma64_dd_upd(struct dma_info
*di
, struct dma64desc
*ddring
,
731 dma_addr_t pa
, uint outidx
, u32
*flags
, u32 bufcount
)
733 u32 ctrl2
= bufcount
& D64_CTRL2_BC_MASK
;
735 /* PCI bus with big(>1G) physical address, use address extension */
736 if ((di
->dataoffsetlow
== 0) || !(pa
& PCI32ADDR_HIGH
)) {
737 ddring
[outidx
].addrlow
= cpu_to_le32(pa
+ di
->dataoffsetlow
);
738 ddring
[outidx
].addrhigh
= cpu_to_le32(di
->dataoffsethigh
);
739 ddring
[outidx
].ctrl1
= cpu_to_le32(*flags
);
740 ddring
[outidx
].ctrl2
= cpu_to_le32(ctrl2
);
742 /* address extension for 32-bit PCI */
745 ae
= (pa
& PCI32ADDR_HIGH
) >> PCI32ADDR_HIGH_SHIFT
;
746 pa
&= ~PCI32ADDR_HIGH
;
748 ctrl2
|= (ae
<< D64_CTRL2_AE_SHIFT
) & D64_CTRL2_AE
;
749 ddring
[outidx
].addrlow
= cpu_to_le32(pa
+ di
->dataoffsetlow
);
750 ddring
[outidx
].addrhigh
= cpu_to_le32(di
->dataoffsethigh
);
751 ddring
[outidx
].ctrl1
= cpu_to_le32(*flags
);
752 ddring
[outidx
].ctrl2
= cpu_to_le32(ctrl2
);
754 if (di
->dma
.dmactrlflags
& DMA_CTRL_PEN
) {
755 if (dma64_dd_parity(&ddring
[outidx
]))
756 ddring
[outidx
].ctrl2
=
757 cpu_to_le32(ctrl2
| D64_CTRL2_PARITY
);
761 /* !! may be called with core in reset */
762 void dma_detach(struct dma_pub
*pub
)
764 struct dma_info
*di
= (struct dma_info
*)pub
;
766 DMA_TRACE("%s:\n", di
->name
);
768 /* free dma descriptor rings */
770 dma_free_coherent(di
->dmadev
, di
->txdalloc
,
771 ((s8
*)di
->txd64
- di
->txdalign
),
774 dma_free_coherent(di
->dmadev
, di
->rxdalloc
,
775 ((s8
*)di
->rxd64
- di
->rxdalign
),
778 /* free packet pointer vectors */
782 /* free our private info structure */
787 /* initialize descriptor table base address */
789 _dma_ddtable_init(struct dma_info
*di
, uint direction
, dma_addr_t pa
)
791 if (!di
->aligndesc_4k
) {
792 if (direction
== DMA_TX
)
798 if ((di
->ddoffsetlow
== 0)
799 || !(pa
& PCI32ADDR_HIGH
)) {
800 if (direction
== DMA_TX
) {
801 bcma_write32(di
->core
, DMA64TXREGOFFS(di
, addrlow
),
802 pa
+ di
->ddoffsetlow
);
803 bcma_write32(di
->core
, DMA64TXREGOFFS(di
, addrhigh
),
806 bcma_write32(di
->core
, DMA64RXREGOFFS(di
, addrlow
),
807 pa
+ di
->ddoffsetlow
);
808 bcma_write32(di
->core
, DMA64RXREGOFFS(di
, addrhigh
),
812 /* DMA64 32bits address extension */
815 /* shift the high bit(s) from pa to ae */
816 ae
= (pa
& PCI32ADDR_HIGH
) >> PCI32ADDR_HIGH_SHIFT
;
817 pa
&= ~PCI32ADDR_HIGH
;
819 if (direction
== DMA_TX
) {
820 bcma_write32(di
->core
, DMA64TXREGOFFS(di
, addrlow
),
821 pa
+ di
->ddoffsetlow
);
822 bcma_write32(di
->core
, DMA64TXREGOFFS(di
, addrhigh
),
824 bcma_maskset32(di
->core
, DMA64TXREGOFFS(di
, control
),
825 D64_XC_AE
, (ae
<< D64_XC_AE_SHIFT
));
827 bcma_write32(di
->core
, DMA64RXREGOFFS(di
, addrlow
),
828 pa
+ di
->ddoffsetlow
);
829 bcma_write32(di
->core
, DMA64RXREGOFFS(di
, addrhigh
),
831 bcma_maskset32(di
->core
, DMA64RXREGOFFS(di
, control
),
832 D64_RC_AE
, (ae
<< D64_RC_AE_SHIFT
));
837 static void _dma_rxenable(struct dma_info
*di
)
839 uint dmactrlflags
= di
->dma
.dmactrlflags
;
842 DMA_TRACE("%s:\n", di
->name
);
844 control
= D64_RC_RE
| (bcma_read32(di
->core
,
845 DMA64RXREGOFFS(di
, control
)) &
848 if ((dmactrlflags
& DMA_CTRL_PEN
) == 0)
849 control
|= D64_RC_PD
;
851 if (dmactrlflags
& DMA_CTRL_ROC
)
852 control
|= D64_RC_OC
;
854 bcma_write32(di
->core
, DMA64RXREGOFFS(di
, control
),
855 ((di
->rxoffset
<< D64_RC_RO_SHIFT
) | control
));
858 void dma_rxinit(struct dma_pub
*pub
)
860 struct dma_info
*di
= (struct dma_info
*)pub
;
862 DMA_TRACE("%s:\n", di
->name
);
867 di
->rxin
= di
->rxout
= 0;
869 /* clear rx descriptor ring */
870 memset(di
->rxd64
, '\0', di
->nrxd
* sizeof(struct dma64desc
));
872 /* DMA engine with out alignment requirement requires table to be inited
873 * before enabling the engine
875 if (!di
->aligndesc_4k
)
876 _dma_ddtable_init(di
, DMA_RX
, di
->rxdpa
);
880 if (di
->aligndesc_4k
)
881 _dma_ddtable_init(di
, DMA_RX
, di
->rxdpa
);
884 static struct sk_buff
*dma64_getnextrxp(struct dma_info
*di
, bool forceall
)
892 /* return if no packets posted */
897 B2I(((bcma_read32(di
->core
,
898 DMA64RXREGOFFS(di
, status0
)) & D64_RS0_CD_MASK
) -
899 di
->rcvptrbase
) & D64_RS0_CD_MASK
, struct dma64desc
);
901 /* ignore curr if forceall */
902 if (!forceall
&& (i
== curr
))
905 /* get the packet pointer that corresponds to the rx descriptor */
909 pa
= le32_to_cpu(di
->rxd64
[i
].addrlow
) - di
->dataoffsetlow
;
911 /* clear this packet from the descriptor ring */
912 dma_unmap_single(di
->dmadev
, pa
, di
->rxbufsize
, DMA_FROM_DEVICE
);
914 di
->rxd64
[i
].addrlow
= cpu_to_le32(0xdeadbeef);
915 di
->rxd64
[i
].addrhigh
= cpu_to_le32(0xdeadbeef);
917 di
->rxin
= nextrxd(di
, i
);
922 static struct sk_buff
*_dma_getnextrxp(struct dma_info
*di
, bool forceall
)
927 return dma64_getnextrxp(di
, forceall
);
931 * !! rx entry routine
932 * returns the number packages in the next frame, or 0 if there are no more
933 * if DMA_CTRL_RXMULTI is defined, DMA scattering(multiple buffers) is
934 * supported with pkts chain
935 * otherwise, it's treated as giant pkt and will be tossed.
936 * The DMA scattering starts with normal DMA header, followed by first
937 * buffer data. After it reaches the max size of buffer, the data continues
938 * in next DMA descriptor buffer WITHOUT DMA header
940 int dma_rx(struct dma_pub
*pub
, struct sk_buff_head
*skb_list
)
942 struct dma_info
*di
= (struct dma_info
*)pub
;
943 struct sk_buff_head dma_frames
;
944 struct sk_buff
*p
, *next
;
950 skb_queue_head_init(&dma_frames
);
952 p
= _dma_getnextrxp(di
, false);
956 len
= le16_to_cpu(*(__le16
*) (p
->data
));
957 DMA_TRACE("%s: dma_rx len %d\n", di
->name
, len
);
958 dma_spin_for_len(len
, p
);
960 /* set actual length */
961 pkt_len
= min((di
->rxoffset
+ len
), di
->rxbufsize
);
962 __skb_trim(p
, pkt_len
);
963 skb_queue_tail(&dma_frames
, p
);
964 resid
= len
- (di
->rxbufsize
- di
->rxoffset
);
966 /* check for single or multi-buffer rx */
968 while ((resid
> 0) && (p
= _dma_getnextrxp(di
, false))) {
969 pkt_len
= min_t(uint
, resid
, di
->rxbufsize
);
970 __skb_trim(p
, pkt_len
);
971 skb_queue_tail(&dma_frames
, p
);
972 resid
-= di
->rxbufsize
;
980 B2I(((bcma_read32(di
->core
,
981 DMA64RXREGOFFS(di
, status0
)) &
982 D64_RS0_CD_MASK
) - di
->rcvptrbase
) &
983 D64_RS0_CD_MASK
, struct dma64desc
);
984 DMA_ERROR("rxin %d rxout %d, hw_curr %d\n",
985 di
->rxin
, di
->rxout
, cur
);
989 if ((di
->dma
.dmactrlflags
& DMA_CTRL_RXMULTI
) == 0) {
990 DMA_ERROR("%s: bad frame length (%d)\n",
992 skb_queue_walk_safe(&dma_frames
, p
, next
) {
993 skb_unlink(p
, &dma_frames
);
994 brcmu_pkt_buf_free_skb(p
);
1002 skb_queue_splice_tail(&dma_frames
, skb_list
);
1006 static bool dma64_rxidle(struct dma_info
*di
)
1008 DMA_TRACE("%s:\n", di
->name
);
1013 return ((bcma_read32(di
->core
,
1014 DMA64RXREGOFFS(di
, status0
)) & D64_RS0_CD_MASK
) ==
1015 (bcma_read32(di
->core
, DMA64RXREGOFFS(di
, ptr
)) &
1020 * post receive buffers
1021 * return false is refill failed completely and ring is empty this will stall
1022 * the rx dma and user might want to call rxfill again asap. This unlikely
1023 * happens on memory-rich NIC, but often on memory-constrained dongle
1025 bool dma_rxfill(struct dma_pub
*pub
)
1027 struct dma_info
*di
= (struct dma_info
*)pub
;
1034 uint extra_offset
= 0;
1040 * Determine how many receive buffers we're lacking
1041 * from the full complement, allocate, initialize,
1042 * and post them, then update the chip rx lastdscr.
1048 n
= di
->nrxpost
- nrxdactive(di
, rxin
, rxout
);
1050 DMA_TRACE("%s: post %d\n", di
->name
, n
);
1052 if (di
->rxbufsize
> BCMEXTRAHDROOM
)
1053 extra_offset
= di
->rxextrahdrroom
;
1055 for (i
= 0; i
< n
; i
++) {
1057 * the di->rxbufsize doesn't include the extra headroom,
1058 * we need to add it to the size to be allocated
1060 p
= brcmu_pkt_buf_get_skb(di
->rxbufsize
+ extra_offset
);
1063 DMA_ERROR("%s: out of rxbufs\n", di
->name
);
1064 if (i
== 0 && dma64_rxidle(di
)) {
1065 DMA_ERROR("%s: ring is empty !\n", di
->name
);
1071 /* reserve an extra headroom, if applicable */
1073 skb_pull(p
, extra_offset
);
1075 /* Do a cached write instead of uncached write since DMA_MAP
1076 * will flush the cache.
1078 *(u32
*) (p
->data
) = 0;
1080 pa
= dma_map_single(di
->dmadev
, p
->data
, di
->rxbufsize
,
1083 /* save the free packet pointer */
1086 /* reset flags for each descriptor */
1088 if (rxout
== (di
->nrxd
- 1))
1089 flags
= D64_CTRL1_EOT
;
1091 dma64_dd_upd(di
, di
->rxd64
, pa
, rxout
, &flags
,
1093 rxout
= nextrxd(di
, rxout
);
1098 /* update the chip lastdscr pointer */
1099 bcma_write32(di
->core
, DMA64RXREGOFFS(di
, ptr
),
1100 di
->rcvptrbase
+ I2B(rxout
, struct dma64desc
));
1105 void dma_rxreclaim(struct dma_pub
*pub
)
1107 struct dma_info
*di
= (struct dma_info
*)pub
;
1110 DMA_TRACE("%s:\n", di
->name
);
1112 while ((p
= _dma_getnextrxp(di
, true)))
1113 brcmu_pkt_buf_free_skb(p
);
1116 void dma_counterreset(struct dma_pub
*pub
)
1118 /* reset all software counters */
1124 /* get the address of the var in order to change later */
1125 unsigned long dma_getvar(struct dma_pub
*pub
, const char *name
)
1127 struct dma_info
*di
= (struct dma_info
*)pub
;
1129 if (!strcmp(name
, "&txavail"))
1130 return (unsigned long)&(di
->dma
.txavail
);
1134 /* 64-bit DMA functions */
1136 void dma_txinit(struct dma_pub
*pub
)
1138 struct dma_info
*di
= (struct dma_info
*)pub
;
1139 u32 control
= D64_XC_XE
;
1141 DMA_TRACE("%s:\n", di
->name
);
1146 di
->txin
= di
->txout
= 0;
1147 di
->dma
.txavail
= di
->ntxd
- 1;
1149 /* clear tx descriptor ring */
1150 memset(di
->txd64
, '\0', (di
->ntxd
* sizeof(struct dma64desc
)));
1152 /* DMA engine with out alignment requirement requires table to be inited
1153 * before enabling the engine
1155 if (!di
->aligndesc_4k
)
1156 _dma_ddtable_init(di
, DMA_TX
, di
->txdpa
);
1158 if ((di
->dma
.dmactrlflags
& DMA_CTRL_PEN
) == 0)
1159 control
|= D64_XC_PD
;
1160 bcma_set32(di
->core
, DMA64TXREGOFFS(di
, control
), control
);
1162 /* DMA engine with alignment requirement requires table to be inited
1163 * before enabling the engine
1165 if (di
->aligndesc_4k
)
1166 _dma_ddtable_init(di
, DMA_TX
, di
->txdpa
);
1169 void dma_txsuspend(struct dma_pub
*pub
)
1171 struct dma_info
*di
= (struct dma_info
*)pub
;
1173 DMA_TRACE("%s:\n", di
->name
);
1178 bcma_set32(di
->core
, DMA64TXREGOFFS(di
, control
), D64_XC_SE
);
1181 void dma_txresume(struct dma_pub
*pub
)
1183 struct dma_info
*di
= (struct dma_info
*)pub
;
1185 DMA_TRACE("%s:\n", di
->name
);
1190 bcma_mask32(di
->core
, DMA64TXREGOFFS(di
, control
), ~D64_XC_SE
);
1193 bool dma_txsuspended(struct dma_pub
*pub
)
1195 struct dma_info
*di
= (struct dma_info
*)pub
;
1197 return (di
->ntxd
== 0) ||
1198 ((bcma_read32(di
->core
,
1199 DMA64TXREGOFFS(di
, control
)) & D64_XC_SE
) ==
1203 void dma_txreclaim(struct dma_pub
*pub
, enum txd_range range
)
1205 struct dma_info
*di
= (struct dma_info
*)pub
;
1208 DMA_TRACE("%s: %s\n",
1210 range
== DMA_RANGE_ALL
? "all" :
1211 range
== DMA_RANGE_TRANSMITTED
? "transmitted" :
1214 if (di
->txin
== di
->txout
)
1217 while ((p
= dma_getnexttxp(pub
, range
))) {
1218 /* For unframed data, we don't have any packets to free */
1219 if (!(di
->dma
.dmactrlflags
& DMA_CTRL_UNFRAMED
))
1220 brcmu_pkt_buf_free_skb(p
);
1224 bool dma_txreset(struct dma_pub
*pub
)
1226 struct dma_info
*di
= (struct dma_info
*)pub
;
1232 /* suspend tx DMA first */
1233 bcma_write32(di
->core
, DMA64TXREGOFFS(di
, control
), D64_XC_SE
);
1235 (bcma_read32(di
->core
, DMA64TXREGOFFS(di
, status0
)) &
1236 D64_XS0_XS_MASK
)) != D64_XS0_XS_DISABLED
) &&
1237 (status
!= D64_XS0_XS_IDLE
) && (status
!= D64_XS0_XS_STOPPED
),
1240 bcma_write32(di
->core
, DMA64TXREGOFFS(di
, control
), 0);
1242 (bcma_read32(di
->core
, DMA64TXREGOFFS(di
, status0
)) &
1243 D64_XS0_XS_MASK
)) != D64_XS0_XS_DISABLED
), 10000);
1245 /* wait for the last transaction to complete */
1248 return status
== D64_XS0_XS_DISABLED
;
1251 bool dma_rxreset(struct dma_pub
*pub
)
1253 struct dma_info
*di
= (struct dma_info
*)pub
;
1259 bcma_write32(di
->core
, DMA64RXREGOFFS(di
, control
), 0);
1261 (bcma_read32(di
->core
, DMA64RXREGOFFS(di
, status0
)) &
1262 D64_RS0_RS_MASK
)) != D64_RS0_RS_DISABLED
), 10000);
1264 return status
== D64_RS0_RS_DISABLED
;
1268 * !! tx entry routine
1269 * WARNING: call must check the return value for error.
1270 * the error(toss frames) could be fatal and cause many subsequent hard
1273 int dma_txfast(struct dma_pub
*pub
, struct sk_buff
*p
, bool commit
)
1275 struct dma_info
*di
= (struct dma_info
*)pub
;
1276 unsigned char *data
;
1282 DMA_TRACE("%s:\n", di
->name
);
1287 * obtain and initialize transmit descriptor entry.
1292 /* no use to transmit a zero length packet */
1296 /* return nonzero if out of tx descriptors */
1297 if (nexttxd(di
, txout
) == di
->txin
)
1300 /* get physical address of buffer start */
1301 pa
= dma_map_single(di
->dmadev
, data
, len
, DMA_TO_DEVICE
);
1303 /* With a DMA segment list, Descriptor table is filled
1304 * using the segment list instead of looping over
1305 * buffers in multi-chain DMA. Therefore, EOF for SGLIST
1306 * is when end of segment list is reached.
1308 flags
= D64_CTRL1_SOF
| D64_CTRL1_IOC
| D64_CTRL1_EOF
;
1309 if (txout
== (di
->ntxd
- 1))
1310 flags
|= D64_CTRL1_EOT
;
1312 dma64_dd_upd(di
, di
->txd64
, pa
, txout
, &flags
, len
);
1314 txout
= nexttxd(di
, txout
);
1316 /* save the packet */
1317 di
->txp
[prevtxd(di
, txout
)] = p
;
1319 /* bump the tx descriptor index */
1324 bcma_write32(di
->core
, DMA64TXREGOFFS(di
, ptr
),
1325 di
->xmtptrbase
+ I2B(txout
, struct dma64desc
));
1327 /* tx flow control */
1328 di
->dma
.txavail
= di
->ntxd
- ntxdactive(di
, di
->txin
, di
->txout
) - 1;
1333 DMA_ERROR("%s: out of txds !!!\n", di
->name
);
1334 brcmu_pkt_buf_free_skb(p
);
1335 di
->dma
.txavail
= 0;
1341 * Reclaim next completed txd (txds if using chained buffers) in the range
1342 * specified and return associated packet.
1343 * If range is DMA_RANGE_TRANSMITTED, reclaim descriptors that have be
1344 * transmitted as noted by the hardware "CurrDescr" pointer.
1345 * If range is DMA_RANGE_TRANSFERED, reclaim descriptors that have be
1346 * transferred by the DMA as noted by the hardware "ActiveDescr" pointer.
1347 * If range is DMA_RANGE_ALL, reclaim all txd(s) posted to the ring and
1348 * return associated packet regardless of the value of hardware pointers.
1350 struct sk_buff
*dma_getnexttxp(struct dma_pub
*pub
, enum txd_range range
)
1352 struct dma_info
*di
= (struct dma_info
*)pub
;
1355 struct sk_buff
*txp
;
1357 DMA_TRACE("%s: %s\n",
1359 range
== DMA_RANGE_ALL
? "all" :
1360 range
== DMA_RANGE_TRANSMITTED
? "transmitted" :
1369 if (range
== DMA_RANGE_ALL
)
1372 end
= (u16
) (B2I(((bcma_read32(di
->core
,
1373 DMA64TXREGOFFS(di
, status0
)) &
1374 D64_XS0_CD_MASK
) - di
->xmtptrbase
) &
1375 D64_XS0_CD_MASK
, struct dma64desc
));
1377 if (range
== DMA_RANGE_TRANSFERED
) {
1379 (u16
)(bcma_read32(di
->core
,
1380 DMA64TXREGOFFS(di
, status1
)) &
1383 (active_desc
- di
->xmtptrbase
) & D64_XS0_CD_MASK
;
1384 active_desc
= B2I(active_desc
, struct dma64desc
);
1385 if (end
!= active_desc
)
1386 end
= prevtxd(di
, active_desc
);
1390 if ((start
== 0) && (end
> di
->txout
))
1393 for (i
= start
; i
!= end
&& !txp
; i
= nexttxd(di
, i
)) {
1397 pa
= le32_to_cpu(di
->txd64
[i
].addrlow
) - di
->dataoffsetlow
;
1400 (le32_to_cpu(di
->txd64
[i
].ctrl2
) &
1403 di
->txd64
[i
].addrlow
= cpu_to_le32(0xdeadbeef);
1404 di
->txd64
[i
].addrhigh
= cpu_to_le32(0xdeadbeef);
1409 dma_unmap_single(di
->dmadev
, pa
, size
, DMA_TO_DEVICE
);
1414 /* tx flow control */
1415 di
->dma
.txavail
= di
->ntxd
- ntxdactive(di
, di
->txin
, di
->txout
) - 1;
1420 DMA_NONE("bogus curr: start %d end %d txout %d\n",
1421 start
, end
, di
->txout
);
1426 * Mac80211 initiated actions sometimes require packets in the DMA queue to be
1427 * modified. The modified portion of the packet is not under control of the DMA
1428 * engine. This function calls a caller-supplied function for each packet in
1429 * the caller specified dma chain.
1431 void dma_walk_packets(struct dma_pub
*dmah
, void (*callback_fnc
)
1432 (void *pkt
, void *arg_a
), void *arg_a
)
1434 struct dma_info
*di
= (struct dma_info
*) dmah
;
1436 uint end
= di
->txout
;
1437 struct sk_buff
*skb
;
1438 struct ieee80211_tx_info
*tx_info
;
1443 tx_info
= (struct ieee80211_tx_info
*)skb
->cb
;
1444 (callback_fnc
)(tx_info
, arg_a
);