blob: 20ddb7acdb9493c881ced6e2c0e1fb659fc7f003 [file] [log] [blame]
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001/*
2 * Copyright (c) 2008 Atheros Communications Inc.
3 *
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.
7 *
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
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/*
18 * Implementation of receive path.
19 */
20
21#include "core.h"
22
23/*
24 * Setup and link descriptors.
25 *
26 * 11N: we can no longer afford to self link the last descriptor.
27 * MAC acknowledges BA status as long as it copies frames to host
28 * buffer (or rx fifo). This can incorrectly acknowledge packets
29 * to a sender if last desc is self-linked.
30 *
31 * NOTE: Caller should hold the rxbuf lock.
32 */
33
34static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf)
35{
36 struct ath_hal *ah = sc->sc_ah;
37 struct ath_desc *ds;
38 struct sk_buff *skb;
39
40 ATH_RXBUF_RESET(bf);
41
42 ds = bf->bf_desc;
43 ds->ds_link = 0; /* link to null */
44 ds->ds_data = bf->bf_buf_addr;
45
46 /* XXX For RADAR?
47 * virtual addr of the beginning of the buffer. */
48 skb = bf->bf_mpdu;
49 ASSERT(skb != NULL);
50 ds->ds_vdata = skb->data;
51
52 /* setup rx descriptors */
53 ath9k_hw_setuprxdesc(ah,
54 ds,
55 skb_tailroom(skb), /* buffer size */
56 0);
57
58 if (sc->sc_rxlink == NULL)
59 ath9k_hw_putrxbuf(ah, bf->bf_daddr);
60 else
61 *sc->sc_rxlink = bf->bf_daddr;
62
63 sc->sc_rxlink = &ds->ds_link;
64 ath9k_hw_rxena(ah);
65}
66
67/* Process received BAR frame */
68
69static int ath_bar_rx(struct ath_softc *sc,
70 struct ath_node *an,
71 struct sk_buff *skb)
72{
73 struct ieee80211_bar *bar;
74 struct ath_arx_tid *rxtid;
75 struct sk_buff *tskb;
76 struct ath_recv_status *rx_status;
77 int tidno, index, cindex;
78 u16 seqno;
79
80 /* look at BAR contents */
81
82 bar = (struct ieee80211_bar *)skb->data;
83 tidno = (le16_to_cpu(bar->control) & IEEE80211_BAR_CTL_TID_M)
84 >> IEEE80211_BAR_CTL_TID_S;
85 seqno = le16_to_cpu(bar->start_seq_num) >> IEEE80211_SEQ_SEQ_SHIFT;
86
87 /* process BAR - indicate all pending RX frames till the BAR seqno */
88
89 rxtid = &an->an_aggr.rx.tid[tidno];
90
91 spin_lock_bh(&rxtid->tidlock);
92
93 /* get relative index */
94
95 index = ATH_BA_INDEX(rxtid->seq_next, seqno);
96
97 /* drop BAR if old sequence (index is too large) */
98
99 if ((index > rxtid->baw_size) &&
100 (index > (IEEE80211_SEQ_MAX - (rxtid->baw_size << 2))))
101 /* discard frame, ieee layer may not treat frame as a dup */
102 goto unlock_and_free;
103
104 /* complete receive processing for all pending frames upto BAR seqno */
105
106 cindex = (rxtid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
107 while ((rxtid->baw_head != rxtid->baw_tail) &&
108 (rxtid->baw_head != cindex)) {
109 tskb = rxtid->rxbuf[rxtid->baw_head].rx_wbuf;
110 rx_status = &rxtid->rxbuf[rxtid->baw_head].rx_status;
111 rxtid->rxbuf[rxtid->baw_head].rx_wbuf = NULL;
112
113 if (tskb != NULL)
114 ath_rx_subframe(an, tskb, rx_status);
115
116 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
117 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
118 }
119
120 /* ... and indicate rest of the frames in-order */
121
122 while (rxtid->baw_head != rxtid->baw_tail &&
123 rxtid->rxbuf[rxtid->baw_head].rx_wbuf != NULL) {
124 tskb = rxtid->rxbuf[rxtid->baw_head].rx_wbuf;
125 rx_status = &rxtid->rxbuf[rxtid->baw_head].rx_status;
126 rxtid->rxbuf[rxtid->baw_head].rx_wbuf = NULL;
127
128 ath_rx_subframe(an, tskb, rx_status);
129
130 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
131 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
132 }
133
134unlock_and_free:
135 spin_unlock_bh(&rxtid->tidlock);
136 /* free bar itself */
137 dev_kfree_skb(skb);
138 return IEEE80211_FTYPE_CTL;
139}
140
141/* Function to handle a subframe of aggregation when HT is enabled */
142
143static int ath_ampdu_input(struct ath_softc *sc,
144 struct ath_node *an,
145 struct sk_buff *skb,
146 struct ath_recv_status *rx_status)
147{
148 struct ieee80211_hdr *hdr;
149 struct ath_arx_tid *rxtid;
150 struct ath_rxbuf *rxbuf;
151 u8 type, subtype;
152 u16 rxseq;
153 int tid = 0, index, cindex, rxdiff;
154 __le16 fc;
155 u8 *qc;
156
157 hdr = (struct ieee80211_hdr *)skb->data;
158 fc = hdr->frame_control;
159
160 /* collect stats of frames with non-zero version */
161
162 if ((le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_VERS) != 0) {
163 dev_kfree_skb(skb);
164 return -1;
165 }
166
167 type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE;
168 subtype = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE;
169
170 if (ieee80211_is_back_req(fc))
171 return ath_bar_rx(sc, an, skb);
172
173 /* special aggregate processing only for qos unicast data frames */
174
175 if (!ieee80211_is_data(fc) ||
176 !ieee80211_is_data_qos(fc) ||
177 is_multicast_ether_addr(hdr->addr1))
178 return ath_rx_subframe(an, skb, rx_status);
179
180 /* lookup rx tid state */
181
182 if (ieee80211_is_data_qos(fc)) {
183 qc = ieee80211_get_qos_ctl(hdr);
184 tid = qc[0] & 0xf;
185 }
186
187 if (sc->sc_opmode == ATH9K_M_STA) {
188 /* Drop the frame not belonging to me. */
189 if (memcmp(hdr->addr1, sc->sc_myaddr, ETH_ALEN)) {
190 dev_kfree_skb(skb);
191 return -1;
192 }
193 }
194
195 rxtid = &an->an_aggr.rx.tid[tid];
196
197 spin_lock(&rxtid->tidlock);
198
199 rxdiff = (rxtid->baw_tail - rxtid->baw_head) &
200 (ATH_TID_MAX_BUFS - 1);
201
202 /*
203 * If the ADDBA exchange has not been completed by the source,
204 * process via legacy path (i.e. no reordering buffer is needed)
205 */
206 if (!rxtid->addba_exchangecomplete) {
207 spin_unlock(&rxtid->tidlock);
208 return ath_rx_subframe(an, skb, rx_status);
209 }
210
211 /* extract sequence number from recvd frame */
212
213 rxseq = le16_to_cpu(hdr->seq_ctrl) >> IEEE80211_SEQ_SEQ_SHIFT;
214
215 if (rxtid->seq_reset) {
216 rxtid->seq_reset = 0;
217 rxtid->seq_next = rxseq;
218 }
219
220 index = ATH_BA_INDEX(rxtid->seq_next, rxseq);
221
222 /* drop frame if old sequence (index is too large) */
223
224 if (index > (IEEE80211_SEQ_MAX - (rxtid->baw_size << 2))) {
225 /* discard frame, ieee layer may not treat frame as a dup */
226 spin_unlock(&rxtid->tidlock);
227 dev_kfree_skb(skb);
228 return IEEE80211_FTYPE_DATA;
229 }
230
231 /* sequence number is beyond block-ack window */
232
233 if (index >= rxtid->baw_size) {
234
235 /* complete receive processing for all pending frames */
236
237 while (index >= rxtid->baw_size) {
238
239 rxbuf = rxtid->rxbuf + rxtid->baw_head;
240
241 if (rxbuf->rx_wbuf != NULL) {
242 ath_rx_subframe(an, rxbuf->rx_wbuf,
243 &rxbuf->rx_status);
244 rxbuf->rx_wbuf = NULL;
245 }
246
247 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
248 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
249
250 index--;
251 }
252 }
253
254 /* add buffer to the recv ba window */
255
256 cindex = (rxtid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
257 rxbuf = rxtid->rxbuf + cindex;
258
259 if (rxbuf->rx_wbuf != NULL) {
260 spin_unlock(&rxtid->tidlock);
261 /* duplicate frame */
262 dev_kfree_skb(skb);
263 return IEEE80211_FTYPE_DATA;
264 }
265
266 rxbuf->rx_wbuf = skb;
267 rxbuf->rx_time = get_timestamp();
268 rxbuf->rx_status = *rx_status;
269
270 /* advance tail if sequence received is newer
271 * than any received so far */
272
273 if (index >= rxdiff) {
274 rxtid->baw_tail = cindex;
275 INCR(rxtid->baw_tail, ATH_TID_MAX_BUFS);
276 }
277
278 /* indicate all in-order received frames */
279
280 while (rxtid->baw_head != rxtid->baw_tail) {
281 rxbuf = rxtid->rxbuf + rxtid->baw_head;
282 if (!rxbuf->rx_wbuf)
283 break;
284
285 ath_rx_subframe(an, rxbuf->rx_wbuf, &rxbuf->rx_status);
286 rxbuf->rx_wbuf = NULL;
287
288 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
289 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
290 }
291
292 /*
293 * start a timer to flush all received frames if there are pending
294 * receive frames
295 */
296 if (rxtid->baw_head != rxtid->baw_tail)
297 mod_timer(&rxtid->timer, ATH_RX_TIMEOUT);
298 else
299 del_timer_sync(&rxtid->timer);
300
301 spin_unlock(&rxtid->tidlock);
302 return IEEE80211_FTYPE_DATA;
303}
304
305/* Timer to flush all received sub-frames */
306
307static void ath_rx_timer(unsigned long data)
308{
309 struct ath_arx_tid *rxtid = (struct ath_arx_tid *)data;
310 struct ath_node *an = rxtid->an;
311 struct ath_rxbuf *rxbuf;
312 int nosched;
313
314 spin_lock_bh(&rxtid->tidlock);
315 while (rxtid->baw_head != rxtid->baw_tail) {
316 rxbuf = rxtid->rxbuf + rxtid->baw_head;
317 if (!rxbuf->rx_wbuf) {
318 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
319 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
320 continue;
321 }
322
323 /*
324 * Stop if the next one is a very recent frame.
325 *
326 * Call get_timestamp in every iteration to protect against the
327 * case in which a new frame is received while we are executing
328 * this function. Using a timestamp obtained before entering
329 * the loop could lead to a very large time interval
330 * (a negative value typecast to unsigned), breaking the
331 * function's logic.
332 */
333 if ((get_timestamp() - rxbuf->rx_time) <
334 (ATH_RX_TIMEOUT * HZ / 1000))
335 break;
336
337 ath_rx_subframe(an, rxbuf->rx_wbuf,
338 &rxbuf->rx_status);
339 rxbuf->rx_wbuf = NULL;
340
341 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
342 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
343 }
344
345 /*
346 * start a timer to flush all received frames if there are pending
347 * receive frames
348 */
349 if (rxtid->baw_head != rxtid->baw_tail)
350 nosched = 0;
351 else
352 nosched = 1; /* no need to re-arm the timer again */
353
354 spin_unlock_bh(&rxtid->tidlock);
355}
356
357/* Free all pending sub-frames in the re-ordering buffer */
358
359static void ath_rx_flush_tid(struct ath_softc *sc,
360 struct ath_arx_tid *rxtid, int drop)
361{
362 struct ath_rxbuf *rxbuf;
Senthil Balasubramanian773b4e02008-09-01 19:58:20 +0530363 unsigned long flag;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700364
Senthil Balasubramanian773b4e02008-09-01 19:58:20 +0530365 spin_lock_irqsave(&rxtid->tidlock, flag);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700366 while (rxtid->baw_head != rxtid->baw_tail) {
367 rxbuf = rxtid->rxbuf + rxtid->baw_head;
368 if (!rxbuf->rx_wbuf) {
369 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
370 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
371 continue;
372 }
373
374 if (drop)
375 dev_kfree_skb(rxbuf->rx_wbuf);
376 else
377 ath_rx_subframe(rxtid->an,
378 rxbuf->rx_wbuf,
379 &rxbuf->rx_status);
380
381 rxbuf->rx_wbuf = NULL;
382
383 INCR(rxtid->baw_head, ATH_TID_MAX_BUFS);
384 INCR(rxtid->seq_next, IEEE80211_SEQ_MAX);
385 }
Senthil Balasubramanian773b4e02008-09-01 19:58:20 +0530386 spin_unlock_irqrestore(&rxtid->tidlock, flag);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700387}
388
389static struct sk_buff *ath_rxbuf_alloc(struct ath_softc *sc,
390 u32 len)
391{
392 struct sk_buff *skb;
393 u32 off;
394
395 /*
396 * Cache-line-align. This is important (for the
397 * 5210 at least) as not doing so causes bogus data
398 * in rx'd frames.
399 */
400
401 skb = dev_alloc_skb(len + sc->sc_cachelsz - 1);
402 if (skb != NULL) {
403 off = ((unsigned long) skb->data) % sc->sc_cachelsz;
404 if (off != 0)
405 skb_reserve(skb, sc->sc_cachelsz - off);
406 } else {
407 DPRINTF(sc, ATH_DBG_FATAL,
408 "%s: skbuff alloc of size %u failed\n",
409 __func__, len);
410 return NULL;
411 }
412
413 return skb;
414}
415
416static void ath_rx_requeue(struct ath_softc *sc, struct sk_buff *skb)
417{
418 struct ath_buf *bf = ATH_RX_CONTEXT(skb)->ctx_rxbuf;
419
420 ASSERT(bf != NULL);
421
422 spin_lock_bh(&sc->sc_rxbuflock);
423 if (bf->bf_status & ATH_BUFSTATUS_STALE) {
424 /*
425 * This buffer is still held for hw acess.
426 * Mark it as free to be re-queued it later.
427 */
428 bf->bf_status |= ATH_BUFSTATUS_FREE;
429 } else {
430 /* XXX: we probably never enter here, remove after
431 * verification */
432 list_add_tail(&bf->list, &sc->sc_rxbuf);
433 ath_rx_buf_link(sc, bf);
434 }
435 spin_unlock_bh(&sc->sc_rxbuflock);
436}
437
438/*
439 * The skb indicated to upper stack won't be returned to us.
440 * So we have to allocate a new one and queue it by ourselves.
441 */
442static int ath_rx_indicate(struct ath_softc *sc,
443 struct sk_buff *skb,
444 struct ath_recv_status *status,
445 u16 keyix)
446{
447 struct ath_buf *bf = ATH_RX_CONTEXT(skb)->ctx_rxbuf;
448 struct sk_buff *nskb;
449 int type;
450
451 /* indicate frame to the stack, which will free the old skb. */
452 type = ath__rx_indicate(sc, skb, status, keyix);
453
454 /* allocate a new skb and queue it to for H/W processing */
455 nskb = ath_rxbuf_alloc(sc, sc->sc_rxbufsize);
456 if (nskb != NULL) {
457 bf->bf_mpdu = nskb;
458 bf->bf_buf_addr = ath_skb_map_single(sc,
459 nskb,
460 PCI_DMA_FROMDEVICE,
461 /* XXX: Remove get_dma_mem_context() */
462 get_dma_mem_context(bf, bf_dmacontext));
463 ATH_RX_CONTEXT(nskb)->ctx_rxbuf = bf;
464
465 /* queue the new wbuf to H/W */
466 ath_rx_requeue(sc, nskb);
467 }
468
469 return type;
470}
471
472static void ath_opmode_init(struct ath_softc *sc)
473{
474 struct ath_hal *ah = sc->sc_ah;
475 u32 rfilt, mfilt[2];
476
477 /* configure rx filter */
478 rfilt = ath_calcrxfilter(sc);
479 ath9k_hw_setrxfilter(ah, rfilt);
480
481 /* configure bssid mask */
Sujith60b67f52008-08-07 10:52:38 +0530482 if (ah->ah_caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK)
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700483 ath9k_hw_setbssidmask(ah, sc->sc_bssidmask);
484
485 /* configure operational mode */
486 ath9k_hw_setopmode(ah);
487
488 /* Handle any link-level address change. */
489 ath9k_hw_setmac(ah, sc->sc_myaddr);
490
491 /* calculate and install multicast filter */
492 mfilt[0] = mfilt[1] = ~0;
493
494 ath9k_hw_setmcastfilter(ah, mfilt[0], mfilt[1]);
495 DPRINTF(sc, ATH_DBG_CONFIG ,
496 "%s: RX filter 0x%x, MC filter %08x:%08x\n",
497 __func__, rfilt, mfilt[0], mfilt[1]);
498}
499
500int ath_rx_init(struct ath_softc *sc, int nbufs)
501{
502 struct sk_buff *skb;
503 struct ath_buf *bf;
504 int error = 0;
505
506 do {
507 spin_lock_init(&sc->sc_rxflushlock);
508 sc->sc_rxflush = 0;
509 spin_lock_init(&sc->sc_rxbuflock);
510
511 /*
512 * Cisco's VPN software requires that drivers be able to
513 * receive encapsulated frames that are larger than the MTU.
514 * Since we can't be sure how large a frame we'll get, setup
515 * to handle the larges on possible.
516 */
517 sc->sc_rxbufsize = roundup(IEEE80211_MAX_MPDU_LEN,
518 min(sc->sc_cachelsz,
519 (u16)64));
520
521 DPRINTF(sc, ATH_DBG_CONFIG, "%s: cachelsz %u rxbufsize %u\n",
522 __func__, sc->sc_cachelsz, sc->sc_rxbufsize);
523
524 /* Initialize rx descriptors */
525
526 error = ath_descdma_setup(sc, &sc->sc_rxdma, &sc->sc_rxbuf,
527 "rx", nbufs, 1);
528 if (error != 0) {
529 DPRINTF(sc, ATH_DBG_FATAL,
530 "%s: failed to allocate rx descriptors: %d\n",
531 __func__, error);
532 break;
533 }
534
535 /* Pre-allocate a wbuf for each rx buffer */
536
537 list_for_each_entry(bf, &sc->sc_rxbuf, list) {
538 skb = ath_rxbuf_alloc(sc, sc->sc_rxbufsize);
539 if (skb == NULL) {
540 error = -ENOMEM;
541 break;
542 }
543
544 bf->bf_mpdu = skb;
545 bf->bf_buf_addr =
546 ath_skb_map_single(sc, skb, PCI_DMA_FROMDEVICE,
547 get_dma_mem_context(bf, bf_dmacontext));
548 ATH_RX_CONTEXT(skb)->ctx_rxbuf = bf;
549 }
550 sc->sc_rxlink = NULL;
551
552 } while (0);
553
554 if (error)
555 ath_rx_cleanup(sc);
556
557 return error;
558}
559
560/* Reclaim all rx queue resources */
561
562void ath_rx_cleanup(struct ath_softc *sc)
563{
564 struct sk_buff *skb;
565 struct ath_buf *bf;
566
567 list_for_each_entry(bf, &sc->sc_rxbuf, list) {
568 skb = bf->bf_mpdu;
569 if (skb)
570 dev_kfree_skb(skb);
571 }
572
573 /* cleanup rx descriptors */
574
575 if (sc->sc_rxdma.dd_desc_len != 0)
576 ath_descdma_cleanup(sc, &sc->sc_rxdma, &sc->sc_rxbuf);
577}
578
579/*
580 * Calculate the receive filter according to the
581 * operating mode and state:
582 *
583 * o always accept unicast, broadcast, and multicast traffic
584 * o maintain current state of phy error reception (the hal
585 * may enable phy error frames for noise immunity work)
586 * o probe request frames are accepted only when operating in
587 * hostap, adhoc, or monitor modes
588 * o enable promiscuous mode according to the interface state
589 * o accept beacons:
590 * - when operating in adhoc mode so the 802.11 layer creates
591 * node table entries for peers,
592 * - when operating in station mode for collecting rssi data when
593 * the station is otherwise quiet, or
594 * - when operating as a repeater so we see repeater-sta beacons
595 * - when scanning
596 */
597
598u32 ath_calcrxfilter(struct ath_softc *sc)
599{
600#define RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)
601 u32 rfilt;
602
603 rfilt = (ath9k_hw_getrxfilter(sc->sc_ah) & RX_FILTER_PRESERVE)
604 | ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST
605 | ATH9K_RX_FILTER_MCAST;
606
607 /* If not a STA, enable processing of Probe Requests */
608 if (sc->sc_opmode != ATH9K_M_STA)
609 rfilt |= ATH9K_RX_FILTER_PROBEREQ;
610
611 /* Can't set HOSTAP into promiscous mode */
612 if (sc->sc_opmode == ATH9K_M_MONITOR) {
613 rfilt |= ATH9K_RX_FILTER_PROM;
614 /* ??? To prevent from sending ACK */
615 rfilt &= ~ATH9K_RX_FILTER_UCAST;
616 }
617
618 if (sc->sc_opmode == ATH9K_M_STA || sc->sc_opmode == ATH9K_M_IBSS ||
619 sc->sc_scanning)
620 rfilt |= ATH9K_RX_FILTER_BEACON;
621
622 /* If in HOSTAP mode, want to enable reception of PSPOLL frames
623 & beacon frames */
624 if (sc->sc_opmode == ATH9K_M_HOSTAP)
625 rfilt |= (ATH9K_RX_FILTER_BEACON | ATH9K_RX_FILTER_PSPOLL);
626 return rfilt;
627#undef RX_FILTER_PRESERVE
628}
629
630/* Enable the receive h/w following a reset. */
631
632int ath_startrecv(struct ath_softc *sc)
633{
634 struct ath_hal *ah = sc->sc_ah;
635 struct ath_buf *bf, *tbf;
636
637 spin_lock_bh(&sc->sc_rxbuflock);
638 if (list_empty(&sc->sc_rxbuf))
639 goto start_recv;
640
641 sc->sc_rxlink = NULL;
642 list_for_each_entry_safe(bf, tbf, &sc->sc_rxbuf, list) {
643 if (bf->bf_status & ATH_BUFSTATUS_STALE) {
644 /* restarting h/w, no need for holding descriptors */
645 bf->bf_status &= ~ATH_BUFSTATUS_STALE;
646 /*
647 * Upper layer may not be done with the frame yet so
648 * we can't just re-queue it to hardware. Remove it
649 * from h/w queue. It'll be re-queued when upper layer
650 * returns the frame and ath_rx_requeue_mpdu is called.
651 */
652 if (!(bf->bf_status & ATH_BUFSTATUS_FREE)) {
653 list_del(&bf->list);
654 continue;
655 }
656 }
657 /* chain descriptors */
658 ath_rx_buf_link(sc, bf);
659 }
660
661 /* We could have deleted elements so the list may be empty now */
662 if (list_empty(&sc->sc_rxbuf))
663 goto start_recv;
664
665 bf = list_first_entry(&sc->sc_rxbuf, struct ath_buf, list);
666 ath9k_hw_putrxbuf(ah, bf->bf_daddr);
667 ath9k_hw_rxena(ah); /* enable recv descriptors */
668
669start_recv:
670 spin_unlock_bh(&sc->sc_rxbuflock);
671 ath_opmode_init(sc); /* set filters, etc. */
672 ath9k_hw_startpcureceive(ah); /* re-enable PCU/DMA engine */
673 return 0;
674}
675
676/* Disable the receive h/w in preparation for a reset. */
677
678bool ath_stoprecv(struct ath_softc *sc)
679{
680 struct ath_hal *ah = sc->sc_ah;
681 u64 tsf;
682 bool stopped;
683
684 ath9k_hw_stoppcurecv(ah); /* disable PCU */
685 ath9k_hw_setrxfilter(ah, 0); /* clear recv filter */
686 stopped = ath9k_hw_stopdmarecv(ah); /* disable DMA engine */
687 mdelay(3); /* 3ms is long enough for 1 frame */
688 tsf = ath9k_hw_gettsf64(ah);
689 sc->sc_rxlink = NULL; /* just in case */
690 return stopped;
691}
692
693/* Flush receive queue */
694
695void ath_flushrecv(struct ath_softc *sc)
696{
697 /*
698 * ath_rx_tasklet may be used to handle rx interrupt and flush receive
699 * queue at the same time. Use a lock to serialize the access of rx
700 * queue.
701 * ath_rx_tasklet cannot hold the spinlock while indicating packets.
702 * Instead, do not claim the spinlock but check for a flush in
703 * progress (see references to sc_rxflush)
704 */
705 spin_lock_bh(&sc->sc_rxflushlock);
706 sc->sc_rxflush = 1;
707
708 ath_rx_tasklet(sc, 1);
709
710 sc->sc_rxflush = 0;
711 spin_unlock_bh(&sc->sc_rxflushlock);
712}
713
714/* Process an individual frame */
715
716int ath_rx_input(struct ath_softc *sc,
717 struct ath_node *an,
718 int is_ampdu,
719 struct sk_buff *skb,
720 struct ath_recv_status *rx_status,
721 enum ATH_RX_TYPE *status)
722{
723 if (is_ampdu && sc->sc_rxaggr) {
724 *status = ATH_RX_CONSUMED;
725 return ath_ampdu_input(sc, an, skb, rx_status);
726 } else {
727 *status = ATH_RX_NON_CONSUMED;
728 return -1;
729 }
730}
731
732/* Process receive queue, as well as LED, etc. */
733
734int ath_rx_tasklet(struct ath_softc *sc, int flush)
735{
736#define PA2DESC(_sc, _pa) \
737 ((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \
738 ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr)))
739
740 struct ath_buf *bf, *bf_held = NULL;
741 struct ath_desc *ds;
742 struct ieee80211_hdr *hdr;
743 struct sk_buff *skb = NULL;
744 struct ath_recv_status rx_status;
745 struct ath_hal *ah = sc->sc_ah;
746 int type, rx_processed = 0;
747 u32 phyerr;
748 u8 chainreset = 0;
749 int retval;
750 __le16 fc;
751
752 do {
753 /* If handling rx interrupt and flush is in progress => exit */
754 if (sc->sc_rxflush && (flush == 0))
755 break;
756
757 spin_lock_bh(&sc->sc_rxbuflock);
758 if (list_empty(&sc->sc_rxbuf)) {
759 sc->sc_rxlink = NULL;
760 spin_unlock_bh(&sc->sc_rxbuflock);
761 break;
762 }
763
764 bf = list_first_entry(&sc->sc_rxbuf, struct ath_buf, list);
765
766 /*
767 * There is a race condition that BH gets scheduled after sw
768 * writes RxE and before hw re-load the last descriptor to get
769 * the newly chained one. Software must keep the last DONE
770 * descriptor as a holding descriptor - software does so by
771 * marking it with the STALE flag.
772 */
773 if (bf->bf_status & ATH_BUFSTATUS_STALE) {
774 bf_held = bf;
775 if (list_is_last(&bf_held->list, &sc->sc_rxbuf)) {
776 /*
777 * The holding descriptor is the last
778 * descriptor in queue. It's safe to
779 * remove the last holding descriptor
780 * in BH context.
781 */
782 list_del(&bf_held->list);
783 bf_held->bf_status &= ~ATH_BUFSTATUS_STALE;
784 sc->sc_rxlink = NULL;
785
786 if (bf_held->bf_status & ATH_BUFSTATUS_FREE) {
787 list_add_tail(&bf_held->list,
788 &sc->sc_rxbuf);
789 ath_rx_buf_link(sc, bf_held);
790 }
791 spin_unlock_bh(&sc->sc_rxbuflock);
792 break;
793 }
794 bf = list_entry(bf->list.next, struct ath_buf, list);
795 }
796
797 ds = bf->bf_desc;
798 ++rx_processed;
799
800 /*
801 * Must provide the virtual address of the current
802 * descriptor, the physical address, and the virtual
803 * address of the next descriptor in the h/w chain.
804 * This allows the HAL to look ahead to see if the
805 * hardware is done with a descriptor by checking the
806 * done bit in the following descriptor and the address
807 * of the current descriptor the DMA engine is working
808 * on. All this is necessary because of our use of
809 * a self-linked list to avoid rx overruns.
810 */
811 retval = ath9k_hw_rxprocdesc(ah,
812 ds,
813 bf->bf_daddr,
814 PA2DESC(sc, ds->ds_link),
815 0);
816 if (retval == -EINPROGRESS) {
817 struct ath_buf *tbf;
818 struct ath_desc *tds;
819
820 if (list_is_last(&bf->list, &sc->sc_rxbuf)) {
821 spin_unlock_bh(&sc->sc_rxbuflock);
822 break;
823 }
824
825 tbf = list_entry(bf->list.next, struct ath_buf, list);
826
827 /*
828 * On some hardware the descriptor status words could
829 * get corrupted, including the done bit. Because of
830 * this, check if the next descriptor's done bit is
831 * set or not.
832 *
833 * If the next descriptor's done bit is set, the current
834 * descriptor has been corrupted. Force s/w to discard
835 * this descriptor and continue...
836 */
837
838 tds = tbf->bf_desc;
839 retval = ath9k_hw_rxprocdesc(ah,
840 tds, tbf->bf_daddr,
841 PA2DESC(sc, tds->ds_link), 0);
842 if (retval == -EINPROGRESS) {
843 spin_unlock_bh(&sc->sc_rxbuflock);
844 break;
845 }
846 }
847
848 /* XXX: we do not support frames spanning
849 * multiple descriptors */
850 bf->bf_status |= ATH_BUFSTATUS_DONE;
851
852 skb = bf->bf_mpdu;
853 if (skb == NULL) { /* XXX ??? can this happen */
854 spin_unlock_bh(&sc->sc_rxbuflock);
855 continue;
856 }
857 /*
858 * Now we know it's a completed frame, we can indicate the
859 * frame. Remove the previous holding descriptor and leave
860 * this one in the queue as the new holding descriptor.
861 */
862 if (bf_held) {
863 list_del(&bf_held->list);
864 bf_held->bf_status &= ~ATH_BUFSTATUS_STALE;
865 if (bf_held->bf_status & ATH_BUFSTATUS_FREE) {
866 list_add_tail(&bf_held->list, &sc->sc_rxbuf);
867 /* try to requeue this descriptor */
868 ath_rx_buf_link(sc, bf_held);
869 }
870 }
871
872 bf->bf_status |= ATH_BUFSTATUS_STALE;
873 bf_held = bf;
874 /*
875 * Release the lock here in case ieee80211_input() return
876 * the frame immediately by calling ath_rx_mpdu_requeue().
877 */
878 spin_unlock_bh(&sc->sc_rxbuflock);
879
880 if (flush) {
881 /*
882 * If we're asked to flush receive queue, directly
883 * chain it back at the queue without processing it.
884 */
885 goto rx_next;
886 }
887
888 hdr = (struct ieee80211_hdr *)skb->data;
889 fc = hdr->frame_control;
890 memzero(&rx_status, sizeof(struct ath_recv_status));
891
892 if (ds->ds_rxstat.rs_more) {
893 /*
894 * Frame spans multiple descriptors; this
895 * cannot happen yet as we don't support
896 * jumbograms. If not in monitor mode,
897 * discard the frame.
898 */
899#ifndef ERROR_FRAMES
900 /*
901 * Enable this if you want to see
902 * error frames in Monitor mode.
903 */
904 if (sc->sc_opmode != ATH9K_M_MONITOR)
905 goto rx_next;
906#endif
907 /* fall thru for monitor mode handling... */
908 } else if (ds->ds_rxstat.rs_status != 0) {
909 if (ds->ds_rxstat.rs_status & ATH9K_RXERR_CRC)
910 rx_status.flags |= ATH_RX_FCS_ERROR;
911 if (ds->ds_rxstat.rs_status & ATH9K_RXERR_PHY) {
912 phyerr = ds->ds_rxstat.rs_phyerr & 0x1f;
913 goto rx_next;
914 }
915
916 if (ds->ds_rxstat.rs_status & ATH9K_RXERR_DECRYPT) {
917 /*
918 * Decrypt error. We only mark packet status
919 * here and always push up the frame up to let
920 * mac80211 handle the actual error case, be
921 * it no decryption key or real decryption
922 * error. This let us keep statistics there.
923 */
924 rx_status.flags |= ATH_RX_DECRYPT_ERROR;
925 } else if (ds->ds_rxstat.rs_status & ATH9K_RXERR_MIC) {
926 /*
927 * Demic error. We only mark frame status here
928 * and always push up the frame up to let
929 * mac80211 handle the actual error case. This
930 * let us keep statistics there. Hardware may
931 * post a false-positive MIC error.
932 */
933 if (ieee80211_is_ctl(fc))
934 /*
935 * Sometimes, we get invalid
936 * MIC failures on valid control frames.
937 * Remove these mic errors.
938 */
939 ds->ds_rxstat.rs_status &=
940 ~ATH9K_RXERR_MIC;
941 else
942 rx_status.flags |= ATH_RX_MIC_ERROR;
943 }
944 /*
945 * Reject error frames with the exception of
946 * decryption and MIC failures. For monitor mode,
947 * we also ignore the CRC error.
948 */
949 if (sc->sc_opmode == ATH9K_M_MONITOR) {
950 if (ds->ds_rxstat.rs_status &
951 ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
952 ATH9K_RXERR_CRC))
953 goto rx_next;
954 } else {
955 if (ds->ds_rxstat.rs_status &
956 ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC)) {
957 goto rx_next;
958 }
959 }
960 }
961 /*
962 * The status portion of the descriptor could get corrupted.
963 */
964 if (sc->sc_rxbufsize < ds->ds_rxstat.rs_datalen)
965 goto rx_next;
966 /*
967 * Sync and unmap the frame. At this point we're
968 * committed to passing the sk_buff somewhere so
969 * clear buf_skb; this means a new sk_buff must be
970 * allocated when the rx descriptor is setup again
971 * to receive another frame.
972 */
973 skb_put(skb, ds->ds_rxstat.rs_datalen);
974 skb->protocol = cpu_to_be16(ETH_P_CONTROL);
975 rx_status.tsf = ath_extend_tsf(sc, ds->ds_rxstat.rs_tstamp);
976 rx_status.rateieee =
977 sc->sc_hwmap[ds->ds_rxstat.rs_rate].ieeerate;
978 rx_status.rateKbps =
979 sc->sc_hwmap[ds->ds_rxstat.rs_rate].rateKbps;
980 rx_status.ratecode = ds->ds_rxstat.rs_rate;
981
982 /* HT rate */
983 if (rx_status.ratecode & 0x80) {
984 /* TODO - add table to avoid division */
985 if (ds->ds_rxstat.rs_flags & ATH9K_RX_2040) {
986 rx_status.flags |= ATH_RX_40MHZ;
987 rx_status.rateKbps =
988 (rx_status.rateKbps * 27) / 13;
989 }
990 if (ds->ds_rxstat.rs_flags & ATH9K_RX_GI)
991 rx_status.rateKbps =
992 (rx_status.rateKbps * 10) / 9;
993 else
994 rx_status.flags |= ATH_RX_SHORT_GI;
995 }
996
997 /* sc->sc_noise_floor is only available when the station
998 attaches to an AP, so we use a default value
999 if we are not yet attached. */
1000
1001 /* XXX we should use either sc->sc_noise_floor or
1002 * ath_hal_getChanNoise(ah, &sc->sc_curchan)
1003 * to calculate the noise floor.
1004 * However, the value returned by ath_hal_getChanNoise
1005 * seems to be incorrect (-31dBm on the last test),
1006 * so we will use a hard-coded value until we
1007 * figure out what is going on.
1008 */
1009 rx_status.abs_rssi =
1010 ds->ds_rxstat.rs_rssi + ATH_DEFAULT_NOISE_FLOOR;
1011
1012 pci_dma_sync_single_for_cpu(sc->pdev,
1013 bf->bf_buf_addr,
1014 skb_tailroom(skb),
1015 PCI_DMA_FROMDEVICE);
1016 pci_unmap_single(sc->pdev,
1017 bf->bf_buf_addr,
1018 sc->sc_rxbufsize,
1019 PCI_DMA_FROMDEVICE);
1020
1021 /* XXX: Ah! make me more readable, use a helper */
Sujith60b67f52008-08-07 10:52:38 +05301022 if (ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) {
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001023 if (ds->ds_rxstat.rs_moreaggr == 0) {
1024 rx_status.rssictl[0] =
1025 ds->ds_rxstat.rs_rssi_ctl0;
1026 rx_status.rssictl[1] =
1027 ds->ds_rxstat.rs_rssi_ctl1;
1028 rx_status.rssictl[2] =
1029 ds->ds_rxstat.rs_rssi_ctl2;
1030 rx_status.rssi = ds->ds_rxstat.rs_rssi;
1031 if (ds->ds_rxstat.rs_flags & ATH9K_RX_2040) {
1032 rx_status.rssiextn[0] =
1033 ds->ds_rxstat.rs_rssi_ext0;
1034 rx_status.rssiextn[1] =
1035 ds->ds_rxstat.rs_rssi_ext1;
1036 rx_status.rssiextn[2] =
1037 ds->ds_rxstat.rs_rssi_ext2;
1038 rx_status.flags |=
1039 ATH_RX_RSSI_EXTN_VALID;
1040 }
1041 rx_status.flags |= ATH_RX_RSSI_VALID |
1042 ATH_RX_CHAIN_RSSI_VALID;
1043 }
1044 } else {
1045 /*
1046 * Need to insert the "combined" rssi into the
1047 * status structure for upper layer processing
1048 */
1049 rx_status.rssi = ds->ds_rxstat.rs_rssi;
1050 rx_status.flags |= ATH_RX_RSSI_VALID;
1051 }
1052
1053 /* Pass frames up to the stack. */
1054
1055 type = ath_rx_indicate(sc, skb,
1056 &rx_status, ds->ds_rxstat.rs_keyix);
1057
1058 /*
1059 * change the default rx antenna if rx diversity chooses the
1060 * other antenna 3 times in a row.
1061 */
1062 if (sc->sc_defant != ds->ds_rxstat.rs_antenna) {
1063 if (++sc->sc_rxotherant >= 3)
1064 ath_setdefantenna(sc,
1065 ds->ds_rxstat.rs_antenna);
1066 } else {
1067 sc->sc_rxotherant = 0;
1068 }
1069
1070#ifdef CONFIG_SLOW_ANT_DIV
1071 if ((rx_status.flags & ATH_RX_RSSI_VALID) &&
1072 ieee80211_is_beacon(fc)) {
1073 ath_slow_ant_div(&sc->sc_antdiv, hdr, &ds->ds_rxstat);
1074 }
1075#endif
1076 /*
1077 * For frames successfully indicated, the buffer will be
1078 * returned to us by upper layers by calling
1079 * ath_rx_mpdu_requeue, either synchronusly or asynchronously.
1080 * So we don't want to do it here in this loop.
1081 */
1082 continue;
1083
1084rx_next:
1085 bf->bf_status |= ATH_BUFSTATUS_FREE;
1086 } while (TRUE);
1087
1088 if (chainreset) {
1089 DPRINTF(sc, ATH_DBG_CONFIG,
1090 "%s: Reset rx chain mask. "
1091 "Do internal reset\n", __func__);
1092 ASSERT(flush == 0);
1093 ath_internal_reset(sc);
1094 }
1095
1096 return 0;
1097#undef PA2DESC
1098}
1099
1100/* Process ADDBA request in per-TID data structure */
1101
1102int ath_rx_aggr_start(struct ath_softc *sc,
1103 const u8 *addr,
1104 u16 tid,
1105 u16 *ssn)
1106{
1107 struct ath_arx_tid *rxtid;
1108 struct ath_node *an;
1109 struct ieee80211_hw *hw = sc->hw;
1110 struct ieee80211_supported_band *sband;
1111 u16 buffersize = 0;
1112
1113 spin_lock_bh(&sc->node_lock);
1114 an = ath_node_find(sc, (u8 *) addr);
1115 spin_unlock_bh(&sc->node_lock);
1116
1117 if (!an) {
1118 DPRINTF(sc, ATH_DBG_AGGR,
1119 "%s: Node not found to initialize RX aggregation\n",
1120 __func__);
1121 return -1;
1122 }
1123
1124 sband = hw->wiphy->bands[hw->conf.channel->band];
1125 buffersize = IEEE80211_MIN_AMPDU_BUF <<
1126 sband->ht_info.ampdu_factor; /* FIXME */
1127
1128 rxtid = &an->an_aggr.rx.tid[tid];
1129
1130 spin_lock_bh(&rxtid->tidlock);
1131 if (sc->sc_rxaggr) {
1132 /* Allow aggregation reception
1133 * Adjust rx BA window size. Peer might indicate a
1134 * zero buffer size for a _dont_care_ condition.
1135 */
1136 if (buffersize)
1137 rxtid->baw_size = min(buffersize, rxtid->baw_size);
1138
1139 /* set rx sequence number */
1140 rxtid->seq_next = *ssn;
1141
1142 /* Allocate the receive buffers for this TID */
1143 DPRINTF(sc, ATH_DBG_AGGR,
1144 "%s: Allcating rxbuffer for TID %d\n", __func__, tid);
1145
1146 if (rxtid->rxbuf == NULL) {
1147 /*
1148 * If the rxbuff is not NULL at this point, we *probably*
1149 * already allocated the buffer on a previous ADDBA,
1150 * and this is a subsequent ADDBA that got through.
1151 * Don't allocate, but use the value in the pointer,
1152 * we zero it out when we de-allocate.
1153 */
1154 rxtid->rxbuf = kmalloc(ATH_TID_MAX_BUFS *
1155 sizeof(struct ath_rxbuf), GFP_ATOMIC);
1156 }
1157 if (rxtid->rxbuf == NULL) {
1158 DPRINTF(sc, ATH_DBG_AGGR,
1159 "%s: Unable to allocate RX buffer, "
1160 "refusing ADDBA\n", __func__);
1161 } else {
1162 /* Ensure the memory is zeroed out (all internal
1163 * pointers are null) */
1164 memzero(rxtid->rxbuf, ATH_TID_MAX_BUFS *
1165 sizeof(struct ath_rxbuf));
1166 DPRINTF(sc, ATH_DBG_AGGR,
1167 "%s: Allocated @%p\n", __func__, rxtid->rxbuf);
1168
1169 /* Allow aggregation reception */
1170 rxtid->addba_exchangecomplete = 1;
1171 }
1172 }
1173 spin_unlock_bh(&rxtid->tidlock);
1174
1175 return 0;
1176}
1177
1178/* Process DELBA */
1179
1180int ath_rx_aggr_stop(struct ath_softc *sc,
1181 const u8 *addr,
1182 u16 tid)
1183{
1184 struct ath_node *an;
1185
1186 spin_lock_bh(&sc->node_lock);
1187 an = ath_node_find(sc, (u8 *) addr);
1188 spin_unlock_bh(&sc->node_lock);
1189
1190 if (!an) {
1191 DPRINTF(sc, ATH_DBG_AGGR,
1192 "%s: RX aggr stop for non-existent node\n", __func__);
1193 return -1;
1194 }
1195
1196 ath_rx_aggr_teardown(sc, an, tid);
1197 return 0;
1198}
1199
1200/* Rx aggregation tear down */
1201
1202void ath_rx_aggr_teardown(struct ath_softc *sc,
1203 struct ath_node *an, u8 tid)
1204{
1205 struct ath_arx_tid *rxtid = &an->an_aggr.rx.tid[tid];
1206
1207 if (!rxtid->addba_exchangecomplete)
1208 return;
1209
1210 del_timer_sync(&rxtid->timer);
1211 ath_rx_flush_tid(sc, rxtid, 0);
1212 rxtid->addba_exchangecomplete = 0;
1213
1214 /* De-allocate the receive buffer array allocated when addba started */
1215
1216 if (rxtid->rxbuf) {
1217 DPRINTF(sc, ATH_DBG_AGGR,
1218 "%s: Deallocating TID %d rxbuff @%p\n",
1219 __func__, tid, rxtid->rxbuf);
1220 kfree(rxtid->rxbuf);
1221
1222 /* Set pointer to null to avoid reuse*/
1223 rxtid->rxbuf = NULL;
1224 }
1225}
1226
1227/* Initialize per-node receive state */
1228
1229void ath_rx_node_init(struct ath_softc *sc, struct ath_node *an)
1230{
1231 if (sc->sc_rxaggr) {
1232 struct ath_arx_tid *rxtid;
1233 int tidno;
1234
1235 /* Init per tid rx state */
1236 for (tidno = 0, rxtid = &an->an_aggr.rx.tid[tidno];
1237 tidno < WME_NUM_TID;
1238 tidno++, rxtid++) {
1239 rxtid->an = an;
1240 rxtid->seq_reset = 1;
1241 rxtid->seq_next = 0;
1242 rxtid->baw_size = WME_MAX_BA;
1243 rxtid->baw_head = rxtid->baw_tail = 0;
1244
1245 /*
1246 * Ensure the buffer pointer is null at this point
1247 * (needs to be allocated when addba is received)
1248 */
1249
1250 rxtid->rxbuf = NULL;
1251 setup_timer(&rxtid->timer, ath_rx_timer,
1252 (unsigned long)rxtid);
1253 spin_lock_init(&rxtid->tidlock);
1254
1255 /* ADDBA state */
1256 rxtid->addba_exchangecomplete = 0;
1257 }
1258 }
1259}
1260
1261void ath_rx_node_cleanup(struct ath_softc *sc, struct ath_node *an)
1262{
1263 if (sc->sc_rxaggr) {
1264 struct ath_arx_tid *rxtid;
1265 int tidno, i;
1266
1267 /* Init per tid rx state */
1268 for (tidno = 0, rxtid = &an->an_aggr.rx.tid[tidno];
1269 tidno < WME_NUM_TID;
1270 tidno++, rxtid++) {
1271
1272 if (!rxtid->addba_exchangecomplete)
1273 continue;
1274
1275 /* must cancel timer first */
1276 del_timer_sync(&rxtid->timer);
1277
1278 /* drop any pending sub-frames */
1279 ath_rx_flush_tid(sc, rxtid, 1);
1280
1281 for (i = 0; i < ATH_TID_MAX_BUFS; i++)
1282 ASSERT(rxtid->rxbuf[i].rx_wbuf == NULL);
1283
1284 rxtid->addba_exchangecomplete = 0;
1285 }
1286 }
1287
1288}
1289
1290/* Cleanup per-node receive state */
1291
1292void ath_rx_node_free(struct ath_softc *sc, struct ath_node *an)
1293{
1294 ath_rx_node_cleanup(sc, an);
1295}
1296
1297dma_addr_t ath_skb_map_single(struct ath_softc *sc,
1298 struct sk_buff *skb,
1299 int direction,
1300 dma_addr_t *pa)
1301{
1302 /*
1303 * NB: do NOT use skb->len, which is 0 on initialization.
1304 * Use skb's entire data area instead.
1305 */
1306 *pa = pci_map_single(sc->pdev, skb->data,
1307 skb_end_pointer(skb) - skb->head, direction);
1308 return *pa;
1309}
1310
1311void ath_skb_unmap_single(struct ath_softc *sc,
1312 struct sk_buff *skb,
1313 int direction,
1314 dma_addr_t *pa)
1315{
1316 /* Unmap skb's entire data area */
1317 pci_unmap_single(sc->pdev, *pa,
1318 skb_end_pointer(skb) - skb->head, direction);
1319}