2 * Copyright (c) 2010 Atheros Communications Inc.
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
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.
23 static const int subtype_txq_to_hwq[] = {
24 [WME_AC_BE] = ATH_TXQ_AC_BE,
25 [WME_AC_BK] = ATH_TXQ_AC_BK,
26 [WME_AC_VI] = ATH_TXQ_AC_VI,
27 [WME_AC_VO] = ATH_TXQ_AC_VO,
30 #define ATH9K_HTC_INIT_TXQ(subtype) do { \
31 qi.tqi_subtype = subtype_txq_to_hwq[subtype]; \
32 qi.tqi_aifs = ATH9K_TXQ_USEDEFAULT; \
33 qi.tqi_cwmin = ATH9K_TXQ_USEDEFAULT; \
34 qi.tqi_cwmax = ATH9K_TXQ_USEDEFAULT; \
35 qi.tqi_physCompBuf = 0; \
36 qi.tqi_qflags = TXQ_FLAG_TXEOLINT_ENABLE | \
37 TXQ_FLAG_TXDESCINT_ENABLE; \
40 int get_hw_qnum(u16 queue, int *hwq_map)
44 return hwq_map[WME_AC_VO];
46 return hwq_map[WME_AC_VI];
48 return hwq_map[WME_AC_BE];
50 return hwq_map[WME_AC_BK];
52 return hwq_map[WME_AC_BE];
56 int ath_htc_txq_update(struct ath9k_htc_priv *priv, int qnum,
57 struct ath9k_tx_queue_info *qinfo)
59 struct ath_hw *ah = priv->ah;
61 struct ath9k_tx_queue_info qi;
63 ath9k_hw_get_txq_props(ah, qnum, &qi);
65 qi.tqi_aifs = qinfo->tqi_aifs;
66 qi.tqi_cwmin = qinfo->tqi_cwmin / 2; /* XXX */
67 qi.tqi_cwmax = qinfo->tqi_cwmax;
68 qi.tqi_burstTime = qinfo->tqi_burstTime;
69 qi.tqi_readyTime = qinfo->tqi_readyTime;
71 if (!ath9k_hw_set_txq_props(ah, qnum, &qi)) {
72 ath_err(ath9k_hw_common(ah),
73 "Unable to update hardware queue %u!\n", qnum);
76 ath9k_hw_resettxqueue(ah, qnum);
82 int ath9k_htc_tx_start(struct ath9k_htc_priv *priv, struct sk_buff *skb)
84 struct ieee80211_hdr *hdr;
85 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
86 struct ieee80211_sta *sta = tx_info->control.sta;
87 struct ieee80211_vif *vif = tx_info->control.vif;
88 struct ath9k_htc_sta *ista;
89 struct ath9k_htc_vif *avp;
90 struct ath9k_htc_tx_ctl tx_ctl;
91 enum htc_endpoint_id epid;
97 hdr = (struct ieee80211_hdr *) skb->data;
98 fc = hdr->frame_control;
101 * Find out on which interface this packet has to be
105 avp = (struct ath9k_htc_vif *) vif->drv_priv;
106 vif_idx = avp->index;
108 if (!priv->ah->is_monitoring) {
109 ath_dbg(ath9k_hw_common(priv->ah), ATH_DBG_XMIT,
110 "VIF is null, but no monitor interface !\n");
114 vif_idx = priv->mon_vif_idx;
118 * Find out which station this packet is destined for.
121 ista = (struct ath9k_htc_sta *) sta->drv_priv;
122 sta_idx = ista->index;
124 sta_idx = priv->vif_sta_pos[vif_idx];
127 memset(&tx_ctl, 0, sizeof(struct ath9k_htc_tx_ctl));
129 if (ieee80211_is_data(fc)) {
130 struct tx_frame_hdr tx_hdr;
134 memset(&tx_hdr, 0, sizeof(struct tx_frame_hdr));
136 tx_hdr.node_idx = sta_idx;
137 tx_hdr.vif_idx = vif_idx;
139 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
140 tx_ctl.type = ATH9K_HTC_AMPDU;
141 tx_hdr.data_type = ATH9K_HTC_AMPDU;
143 tx_ctl.type = ATH9K_HTC_NORMAL;
144 tx_hdr.data_type = ATH9K_HTC_NORMAL;
147 if (ieee80211_is_data_qos(fc)) {
148 qc = ieee80211_get_qos_ctl(hdr);
149 tx_hdr.tidno = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
152 /* Check for RTS protection */
153 if (priv->hw->wiphy->rts_threshold != (u32) -1)
154 if (skb->len > priv->hw->wiphy->rts_threshold)
155 flags |= ATH9K_HTC_TX_RTSCTS;
158 if (!(flags & ATH9K_HTC_TX_RTSCTS) &&
159 (vif && vif->bss_conf.use_cts_prot))
160 flags |= ATH9K_HTC_TX_CTSONLY;
162 tx_hdr.flags = cpu_to_be32(flags);
163 tx_hdr.key_type = ath9k_cmn_get_hw_crypto_keytype(skb);
164 if (tx_hdr.key_type == ATH9K_KEY_TYPE_CLEAR)
165 tx_hdr.keyix = (u8) ATH9K_TXKEYIX_INVALID;
167 tx_hdr.keyix = tx_info->control.hw_key->hw_key_idx;
169 tx_fhdr = skb_push(skb, sizeof(tx_hdr));
170 memcpy(tx_fhdr, (u8 *) &tx_hdr, sizeof(tx_hdr));
172 qnum = skb_get_queue_mapping(skb);
176 TX_QSTAT_INC(WME_AC_VO);
177 epid = priv->data_vo_ep;
180 TX_QSTAT_INC(WME_AC_VI);
181 epid = priv->data_vi_ep;
184 TX_QSTAT_INC(WME_AC_BE);
185 epid = priv->data_be_ep;
189 TX_QSTAT_INC(WME_AC_BK);
190 epid = priv->data_bk_ep;
194 struct tx_mgmt_hdr mgmt_hdr;
196 memset(&mgmt_hdr, 0, sizeof(struct tx_mgmt_hdr));
198 tx_ctl.type = ATH9K_HTC_NORMAL;
200 mgmt_hdr.node_idx = sta_idx;
201 mgmt_hdr.vif_idx = vif_idx;
205 mgmt_hdr.key_type = ath9k_cmn_get_hw_crypto_keytype(skb);
206 if (mgmt_hdr.key_type == ATH9K_KEY_TYPE_CLEAR)
207 mgmt_hdr.keyix = (u8) ATH9K_TXKEYIX_INVALID;
209 mgmt_hdr.keyix = tx_info->control.hw_key->hw_key_idx;
211 tx_fhdr = skb_push(skb, sizeof(mgmt_hdr));
212 memcpy(tx_fhdr, (u8 *) &mgmt_hdr, sizeof(mgmt_hdr));
213 epid = priv->mgmt_ep;
216 return htc_send(priv->htc, skb, epid, &tx_ctl);
219 static bool ath9k_htc_check_tx_aggr(struct ath9k_htc_priv *priv,
220 struct ath9k_htc_sta *ista, u8 tid)
224 spin_lock_bh(&priv->tx_lock);
225 if ((tid < ATH9K_HTC_MAX_TID) && (ista->tid_state[tid] == AGGR_STOP))
227 spin_unlock_bh(&priv->tx_lock);
232 void ath9k_tx_tasklet(unsigned long data)
234 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *)data;
235 struct ieee80211_vif *vif;
236 struct ieee80211_sta *sta;
237 struct ieee80211_hdr *hdr;
238 struct ieee80211_tx_info *tx_info;
239 struct sk_buff *skb = NULL;
242 while ((skb = skb_dequeue(&priv->tx_queue)) != NULL) {
244 hdr = (struct ieee80211_hdr *) skb->data;
245 fc = hdr->frame_control;
246 tx_info = IEEE80211_SKB_CB(skb);
247 vif = tx_info->control.vif;
249 memset(&tx_info->status, 0, sizeof(tx_info->status));
256 sta = ieee80211_find_sta(vif, hdr->addr1);
259 ieee80211_tx_status(priv->hw, skb);
263 /* Check if we need to start aggregation */
265 if (sta && conf_is_ht(&priv->hw->conf) &&
266 !(skb->protocol == cpu_to_be16(ETH_P_PAE))) {
267 if (ieee80211_is_data_qos(fc)) {
269 struct ath9k_htc_sta *ista;
271 qc = ieee80211_get_qos_ctl(hdr);
273 ista = (struct ath9k_htc_sta *)sta->drv_priv;
275 if (ath9k_htc_check_tx_aggr(priv, ista, tid)) {
276 ieee80211_start_tx_ba_session(sta, tid, 0);
277 spin_lock_bh(&priv->tx_lock);
278 ista->tid_state[tid] = AGGR_PROGRESS;
279 spin_unlock_bh(&priv->tx_lock);
287 /* Send status to mac80211 */
288 ieee80211_tx_status(priv->hw, skb);
291 /* Wake TX queues if needed */
292 spin_lock_bh(&priv->tx_lock);
293 if (priv->tx_queues_stop) {
294 priv->tx_queues_stop = false;
295 spin_unlock_bh(&priv->tx_lock);
296 ath_dbg(ath9k_hw_common(priv->ah), ATH_DBG_XMIT,
297 "Waking up TX queues\n");
298 ieee80211_wake_queues(priv->hw);
301 spin_unlock_bh(&priv->tx_lock);
304 void ath9k_htc_txep(void *drv_priv, struct sk_buff *skb,
305 enum htc_endpoint_id ep_id, bool txok)
307 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) drv_priv;
308 struct ath_common *common = ath9k_hw_common(priv->ah);
309 struct ieee80211_tx_info *tx_info;
314 if (ep_id == priv->mgmt_ep) {
315 skb_pull(skb, sizeof(struct tx_mgmt_hdr));
316 } else if ((ep_id == priv->data_bk_ep) ||
317 (ep_id == priv->data_be_ep) ||
318 (ep_id == priv->data_vi_ep) ||
319 (ep_id == priv->data_vo_ep)) {
320 skb_pull(skb, sizeof(struct tx_frame_hdr));
322 ath_err(common, "Unsupported TX EPID: %d\n", ep_id);
323 dev_kfree_skb_any(skb);
327 tx_info = IEEE80211_SKB_CB(skb);
330 tx_info->flags |= IEEE80211_TX_STAT_ACK;
332 skb_queue_tail(&priv->tx_queue, skb);
333 tasklet_schedule(&priv->tx_tasklet);
336 int ath9k_tx_init(struct ath9k_htc_priv *priv)
338 skb_queue_head_init(&priv->tx_queue);
342 void ath9k_tx_cleanup(struct ath9k_htc_priv *priv)
347 bool ath9k_htc_txq_setup(struct ath9k_htc_priv *priv, int subtype)
349 struct ath_hw *ah = priv->ah;
350 struct ath_common *common = ath9k_hw_common(ah);
351 struct ath9k_tx_queue_info qi;
354 memset(&qi, 0, sizeof(qi));
355 ATH9K_HTC_INIT_TXQ(subtype);
357 qnum = ath9k_hw_setuptxqueue(priv->ah, ATH9K_TX_QUEUE_DATA, &qi);
361 if (qnum >= ARRAY_SIZE(priv->hwq_map)) {
362 ath_err(common, "qnum %u out of range, max %zu!\n",
363 qnum, ARRAY_SIZE(priv->hwq_map));
364 ath9k_hw_releasetxqueue(ah, qnum);
368 priv->hwq_map[subtype] = qnum;
372 int ath9k_htc_cabq_setup(struct ath9k_htc_priv *priv)
374 struct ath9k_tx_queue_info qi;
376 memset(&qi, 0, sizeof(qi));
377 ATH9K_HTC_INIT_TXQ(0);
379 return ath9k_hw_setuptxqueue(priv->ah, ATH9K_TX_QUEUE_CAB, &qi);
387 * Calculate the RX filter to be set in the HW.
389 u32 ath9k_htc_calcrxfilter(struct ath9k_htc_priv *priv)
391 #define RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)
393 struct ath_hw *ah = priv->ah;
396 rfilt = (ath9k_hw_getrxfilter(ah) & RX_FILTER_PRESERVE)
397 | ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST
398 | ATH9K_RX_FILTER_MCAST;
400 if (priv->rxfilter & FIF_PROBE_REQ)
401 rfilt |= ATH9K_RX_FILTER_PROBEREQ;
404 * Set promiscuous mode when FIF_PROMISC_IN_BSS is enabled for station
405 * mode interface or when in monitor mode. AP mode does not need this
406 * since it receives all in-BSS frames anyway.
408 if (((ah->opmode != NL80211_IFTYPE_AP) &&
409 (priv->rxfilter & FIF_PROMISC_IN_BSS)) ||
410 (ah->opmode == NL80211_IFTYPE_MONITOR))
411 rfilt |= ATH9K_RX_FILTER_PROM;
413 if (priv->rxfilter & FIF_CONTROL)
414 rfilt |= ATH9K_RX_FILTER_CONTROL;
416 if ((ah->opmode == NL80211_IFTYPE_STATION) &&
417 !(priv->rxfilter & FIF_BCN_PRBRESP_PROMISC))
418 rfilt |= ATH9K_RX_FILTER_MYBEACON;
420 rfilt |= ATH9K_RX_FILTER_BEACON;
422 if (conf_is_ht(&priv->hw->conf))
423 rfilt |= ATH9K_RX_FILTER_COMP_BAR;
427 #undef RX_FILTER_PRESERVE
431 * Recv initialization for opmode change.
433 static void ath9k_htc_opmode_init(struct ath9k_htc_priv *priv)
435 struct ath_hw *ah = priv->ah;
438 /* configure rx filter */
439 rfilt = ath9k_htc_calcrxfilter(priv);
440 ath9k_hw_setrxfilter(ah, rfilt);
442 /* calculate and install multicast filter */
443 mfilt[0] = mfilt[1] = ~0;
444 ath9k_hw_setmcastfilter(ah, mfilt[0], mfilt[1]);
447 void ath9k_host_rx_init(struct ath9k_htc_priv *priv)
449 ath9k_hw_rxena(priv->ah);
450 ath9k_htc_opmode_init(priv);
451 ath9k_hw_startpcureceive(priv->ah, (priv->op_flags & OP_SCANNING));
452 priv->rx.last_rssi = ATH_RSSI_DUMMY_MARKER;
455 static void ath9k_process_rate(struct ieee80211_hw *hw,
456 struct ieee80211_rx_status *rxs,
457 u8 rx_rate, u8 rs_flags)
459 struct ieee80211_supported_band *sband;
460 enum ieee80211_band band;
463 if (rx_rate & 0x80) {
465 rxs->flag |= RX_FLAG_HT;
466 if (rs_flags & ATH9K_RX_2040)
467 rxs->flag |= RX_FLAG_40MHZ;
468 if (rs_flags & ATH9K_RX_GI)
469 rxs->flag |= RX_FLAG_SHORT_GI;
470 rxs->rate_idx = rx_rate & 0x7f;
474 band = hw->conf.channel->band;
475 sband = hw->wiphy->bands[band];
477 for (i = 0; i < sband->n_bitrates; i++) {
478 if (sband->bitrates[i].hw_value == rx_rate) {
482 if (sband->bitrates[i].hw_value_short == rx_rate) {
484 rxs->flag |= RX_FLAG_SHORTPRE;
491 static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
492 struct ath9k_htc_rxbuf *rxbuf,
493 struct ieee80211_rx_status *rx_status)
496 struct ieee80211_hdr *hdr;
497 struct ieee80211_hw *hw = priv->hw;
498 struct sk_buff *skb = rxbuf->skb;
499 struct ath_common *common = ath9k_hw_common(priv->ah);
500 struct ath_htc_rx_status *rxstatus;
501 int hdrlen, padpos, padsize;
502 int last_rssi = ATH_RSSI_DUMMY_MARKER;
505 if (skb->len <= HTC_RX_FRAME_HEADER_SIZE) {
506 ath_err(common, "Corrupted RX frame, dropping\n");
510 rxstatus = (struct ath_htc_rx_status *)skb->data;
512 if (be16_to_cpu(rxstatus->rs_datalen) -
513 (skb->len - HTC_RX_FRAME_HEADER_SIZE) != 0) {
515 "Corrupted RX data len, dropping (dlen: %d, skblen: %d)\n",
516 rxstatus->rs_datalen, skb->len);
520 /* Get the RX status information */
521 memcpy(&rxbuf->rxstatus, rxstatus, HTC_RX_FRAME_HEADER_SIZE);
522 skb_pull(skb, HTC_RX_FRAME_HEADER_SIZE);
524 hdr = (struct ieee80211_hdr *)skb->data;
525 fc = hdr->frame_control;
526 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
528 padpos = ath9k_cmn_padpos(fc);
530 padsize = padpos & 3;
531 if (padsize && skb->len >= padpos+padsize+FCS_LEN) {
532 memmove(skb->data + padsize, skb->data, padpos);
533 skb_pull(skb, padsize);
536 memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
538 if (rxbuf->rxstatus.rs_status != 0) {
539 if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_CRC)
540 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
541 if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_PHY)
544 if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_DECRYPT) {
546 } else if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_MIC) {
547 if (ieee80211_is_ctl(fc))
549 * Sometimes, we get invalid
550 * MIC failures on valid control frames.
551 * Remove these mic errors.
553 rxbuf->rxstatus.rs_status &= ~ATH9K_RXERR_MIC;
555 rx_status->flag |= RX_FLAG_MMIC_ERROR;
559 * Reject error frames with the exception of
560 * decryption and MIC failures. For monitor mode,
561 * we also ignore the CRC error.
563 if (priv->ah->opmode == NL80211_IFTYPE_MONITOR) {
564 if (rxbuf->rxstatus.rs_status &
565 ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
569 if (rxbuf->rxstatus.rs_status &
570 ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC)) {
576 if (!(rxbuf->rxstatus.rs_status & ATH9K_RXERR_DECRYPT)) {
578 keyix = rxbuf->rxstatus.rs_keyix;
579 if (keyix != ATH9K_RXKEYIX_INVALID) {
580 rx_status->flag |= RX_FLAG_DECRYPTED;
581 } else if (ieee80211_has_protected(fc) &&
582 skb->len >= hdrlen + 4) {
583 keyix = skb->data[hdrlen + 3] >> 6;
584 if (test_bit(keyix, common->keymap))
585 rx_status->flag |= RX_FLAG_DECRYPTED;
589 ath9k_process_rate(hw, rx_status, rxbuf->rxstatus.rs_rate,
590 rxbuf->rxstatus.rs_flags);
592 if (rxbuf->rxstatus.rs_rssi != ATH9K_RSSI_BAD &&
593 !rxbuf->rxstatus.rs_moreaggr)
594 ATH_RSSI_LPF(priv->rx.last_rssi,
595 rxbuf->rxstatus.rs_rssi);
597 last_rssi = priv->rx.last_rssi;
599 if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
600 rxbuf->rxstatus.rs_rssi = ATH_EP_RND(last_rssi,
601 ATH_RSSI_EP_MULTIPLIER);
603 if (rxbuf->rxstatus.rs_rssi < 0)
604 rxbuf->rxstatus.rs_rssi = 0;
606 if (ieee80211_is_beacon(fc))
607 priv->ah->stats.avgbrssi = rxbuf->rxstatus.rs_rssi;
609 rx_status->mactime = be64_to_cpu(rxbuf->rxstatus.rs_tstamp);
610 rx_status->band = hw->conf.channel->band;
611 rx_status->freq = hw->conf.channel->center_freq;
612 rx_status->signal = rxbuf->rxstatus.rs_rssi + ATH_DEFAULT_NOISE_FLOOR;
613 rx_status->antenna = rxbuf->rxstatus.rs_antenna;
614 rx_status->flag |= RX_FLAG_TSFT;
623 * FIXME: Handle FLUSH later on.
625 void ath9k_rx_tasklet(unsigned long data)
627 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *)data;
628 struct ath9k_htc_rxbuf *rxbuf = NULL, *tmp_buf = NULL;
629 struct ieee80211_rx_status rx_status;
632 struct ieee80211_hdr *hdr;
635 spin_lock_irqsave(&priv->rx.rxbuflock, flags);
636 list_for_each_entry(tmp_buf, &priv->rx.rxbuf, list) {
637 if (tmp_buf->in_process) {
644 spin_unlock_irqrestore(&priv->rx.rxbuflock, flags);
651 if (!ath9k_rx_prepare(priv, rxbuf, &rx_status)) {
652 dev_kfree_skb_any(rxbuf->skb);
656 memcpy(IEEE80211_SKB_RXCB(rxbuf->skb), &rx_status,
657 sizeof(struct ieee80211_rx_status));
659 hdr = (struct ieee80211_hdr *) skb->data;
661 if (ieee80211_is_beacon(hdr->frame_control) && priv->ps_enabled)
662 ieee80211_queue_work(priv->hw, &priv->ps_work);
664 spin_unlock_irqrestore(&priv->rx.rxbuflock, flags);
666 ieee80211_rx(priv->hw, skb);
668 spin_lock_irqsave(&priv->rx.rxbuflock, flags);
670 rxbuf->in_process = false;
672 list_move_tail(&rxbuf->list, &priv->rx.rxbuf);
674 spin_unlock_irqrestore(&priv->rx.rxbuflock, flags);
679 void ath9k_htc_rxep(void *drv_priv, struct sk_buff *skb,
680 enum htc_endpoint_id ep_id)
682 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *)drv_priv;
683 struct ath_hw *ah = priv->ah;
684 struct ath_common *common = ath9k_hw_common(ah);
685 struct ath9k_htc_rxbuf *rxbuf = NULL, *tmp_buf = NULL;
687 spin_lock(&priv->rx.rxbuflock);
688 list_for_each_entry(tmp_buf, &priv->rx.rxbuf, list) {
689 if (!tmp_buf->in_process) {
694 spin_unlock(&priv->rx.rxbuflock);
697 ath_dbg(common, ATH_DBG_ANY,
698 "No free RX buffer\n");
702 spin_lock(&priv->rx.rxbuflock);
704 rxbuf->in_process = true;
705 spin_unlock(&priv->rx.rxbuflock);
707 tasklet_schedule(&priv->rx_tasklet);
710 dev_kfree_skb_any(skb);
713 /* FIXME: Locking for cleanup/init */
715 void ath9k_rx_cleanup(struct ath9k_htc_priv *priv)
717 struct ath9k_htc_rxbuf *rxbuf, *tbuf;
719 list_for_each_entry_safe(rxbuf, tbuf, &priv->rx.rxbuf, list) {
720 list_del(&rxbuf->list);
722 dev_kfree_skb_any(rxbuf->skb);
727 int ath9k_rx_init(struct ath9k_htc_priv *priv)
729 struct ath_hw *ah = priv->ah;
730 struct ath_common *common = ath9k_hw_common(ah);
731 struct ath9k_htc_rxbuf *rxbuf;
734 INIT_LIST_HEAD(&priv->rx.rxbuf);
735 spin_lock_init(&priv->rx.rxbuflock);
737 for (i = 0; i < ATH9K_HTC_RXBUF; i++) {
738 rxbuf = kzalloc(sizeof(struct ath9k_htc_rxbuf), GFP_KERNEL);
740 ath_err(common, "Unable to allocate RX buffers\n");
743 list_add_tail(&rxbuf->list, &priv->rx.rxbuf);
749 ath9k_rx_cleanup(priv);