54#include <sys/sysctl.h>
56#include <sys/malloc.h>
59#include <sys/kernel.h>
60#include <sys/socket.h>
61#include <sys/sockio.h>
63#include <sys/callout.h>
65#include <sys/endian.h>
66#include <sys/kthread.h>
67#include <sys/taskqueue.h>
69#include <sys/module.h>
73#include <machine/bus.h>
76#include <net/if_var.h>
78#include <net/if_media.h>
79#include <net/if_types.h>
80#include <net/if_arp.h>
81#include <net/ethernet.h>
82#include <net/if_llc.h>
84#include <net80211/ieee80211_var.h>
85#include <net80211/ieee80211_regdomain.h>
86#ifdef IEEE80211_SUPPORT_SUPERG
87#include <net80211/ieee80211_superg.h>
89#ifdef IEEE80211_SUPPORT_TDMA
90#include <net80211/ieee80211_tdma.h>
96#include <netinet/in.h>
97#include <netinet/if_ether.h>
131ath_load_cb(
void *arg, bus_dma_segment_t *segs,
int nsegs,
int error)
133 bus_addr_t *paddr = (bus_addr_t*) arg;
134 KASSERT(error == 0, (
"error %u on bus_dma callback", error));
135 *paddr = segs->ds_addr;
147 const char *name,
int ds_size,
int ndesc)
149#define DS2PHYS(_dd, _ds) \
150 ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
151#define ATH_DESC_4KB_BOUND_CHECK(_daddr, _len) \
152 ((((u_int32_t)(_daddr) & 0xFFF) > (0x1000 - (_len))) ? 1 : 0)
158 "%s: %s DMA: %u desc, %d bytes per descriptor\n",
180 error = bus_dma_tag_create(bus_get_dma_tag(sc->
sc_dev),
182 BUS_SPACE_MAXADDR_32BIT,
194 "cannot allocate %s DMA tag\n", dd->
dd_name);
200 BUS_DMA_NOWAIT | BUS_DMA_COHERENT,
204 "unable to alloc memory for %u %s descriptors, error %u\n",
215 "unable to map %s descriptors, error %u\n",
220 DPRINTF(sc, ATH_DEBUG_RESET,
"%s: %s DMA map: %p (%lu) -> %p (%lu)\n",
230 bus_dma_tag_destroy(dd->
dd_dmat);
231 memset(dd, 0,
sizeof(*dd));
234#undef ATH_DESC_4KB_BOUND_CHECK
240 const char *name,
int ds_size,
int nbuf,
int ndesc)
242#define DS2PHYS(_dd, _ds) \
243 ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
244#define ATH_DESC_4KB_BOUND_CHECK(_daddr, _len) \
245 ((((u_int32_t)(_daddr) & 0xFFF) > (0x1000 - (_len))) ? 1 : 0)
262 bsize =
sizeof(
struct ath_buf) * nbuf;
263 bf = malloc(bsize, M_ATHDEV, M_NOWAIT | M_ZERO);
266 "malloc of %s buffers failed, size %u\n",
273 for (i = 0; i < nbuf; i++, bf++, ds += (ndesc * dd->
dd_descsize)) {
285 ds += 0x1000 - (bf->
bf_daddr & 0xFFF);
290 error = bus_dmamap_create(sc->
sc_dmat, BUS_DMA_NOWAIT,
293 device_printf(sc->
sc_dev,
"unable to create dmamap "
294 "for %s buffer %u, error %u\n",
300 TAILQ_INSERT_TAIL(head, bf, bf_list);
313 bus_dma_tag_destroy(dd->
dd_dmat);
314 memset(dd, 0,
sizeof(*dd));
317#undef ATH_DESC_4KB_BOUND_CHECK
329 const char *name,
int nbuf,
int rx_status_len)
334 DPRINTF(sc, ATH_DEBUG_RESET,
"%s: %s DMA: %u buffers\n",
335 __func__, name, nbuf);
350 bsize =
sizeof(
struct ath_buf) * nbuf;
351 bf = malloc(bsize, M_ATHDEV, M_NOWAIT | M_ZERO);
354 "malloc of %s buffers failed, size %u\n",
362 for (i = 0; i < nbuf; i++, bf++) {
367 error = bus_dmamap_create(sc->
sc_dmat, BUS_DMA_NOWAIT,
370 device_printf(sc->
sc_dev,
"unable to create dmamap "
371 "for %s buffer %u, error %u\n",
376 TAILQ_INSERT_TAIL(head, bf, bf_list);
380 memset(dd, 0,
sizeof(*dd));
389 struct ieee80211_node *ni;
395 bus_dma_tag_destroy(dd->
dd_dmat);
399 TAILQ_FOREACH(bf, head, bf_list) {
407 if (do_warning == 0) {
410 "%s: %s: mbuf should've been"
411 " unmapped/freed!\n",
416 BUS_DMASYNC_POSTREAD);
431 ieee80211_free_node(ni);
441 memset(dd, 0,
sizeof(*dd));
#define DPRINTF(sc, m, fmt,...)
int ath_descdma_alloc_desc(struct ath_softc *sc, struct ath_descdma *dd, ath_bufhead *head, const char *name, int ds_size, int ndesc)
#define DS2PHYS(_dd, _ds)
void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd, ath_bufhead *head)
int ath_descdma_setup_rx_edma(struct ath_softc *sc, struct ath_descdma *dd, ath_bufhead *head, const char *name, int nbuf, int rx_status_len)
static void ath_load_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, ath_bufhead *head, const char *name, int ds_size, int nbuf, int ndesc)
#define ATH_DESC_4KB_BOUND_CHECK(_daddr, _len)
#define ath_hal_split4ktrans(_ah)
struct ath_desc * bf_lastds
struct ath_desc * bf_desc
struct ieee80211_node * bf_node
struct ath_desc * dd_desc
struct ath_buf * dd_bufptr