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,
83 struct sk_buff *skb, bool is_cab)
85 struct ieee80211_hdr *hdr;
86 struct ieee80211_mgmt *mgmt;
87 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
88 struct ieee80211_sta *sta = tx_info->control.sta;
89 struct ieee80211_vif *vif = tx_info->control.vif;
90 struct ath9k_htc_sta *ista;
91 struct ath9k_htc_vif *avp = NULL;
92 struct ath9k_htc_tx_ctl *tx_ctl;
93 enum htc_endpoint_id epid;
99 tx_ctl = HTC_SKB_CB(skb);
100 memset(tx_ctl, 0, sizeof(*tx_ctl));
102 hdr = (struct ieee80211_hdr *) skb->data;
103 fc = hdr->frame_control;
106 * Find out on which interface this packet has to be
110 avp = (struct ath9k_htc_vif *) vif->drv_priv;
111 vif_idx = avp->index;
113 if (!priv->ah->is_monitoring) {
114 ath_dbg(ath9k_hw_common(priv->ah), ATH_DBG_XMIT,
115 "VIF is null, but no monitor interface !\n");
119 vif_idx = priv->mon_vif_idx;
123 * Find out which station this packet is destined for.
126 ista = (struct ath9k_htc_sta *) sta->drv_priv;
127 sta_idx = ista->index;
129 sta_idx = priv->vif_sta_pos[vif_idx];
132 if (ieee80211_is_data(fc)) {
133 struct tx_frame_hdr tx_hdr;
137 memset(&tx_hdr, 0, sizeof(struct tx_frame_hdr));
139 tx_hdr.node_idx = sta_idx;
140 tx_hdr.vif_idx = vif_idx;
142 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
143 tx_ctl->type = ATH9K_HTC_AMPDU;
144 tx_hdr.data_type = ATH9K_HTC_AMPDU;
146 tx_ctl->type = ATH9K_HTC_NORMAL;
147 tx_hdr.data_type = ATH9K_HTC_NORMAL;
150 if (ieee80211_is_data_qos(fc)) {
151 qc = ieee80211_get_qos_ctl(hdr);
152 tx_hdr.tidno = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
155 /* Check for RTS protection */
156 if (priv->hw->wiphy->rts_threshold != (u32) -1)
157 if (skb->len > priv->hw->wiphy->rts_threshold)
158 flags |= ATH9K_HTC_TX_RTSCTS;
161 if (!(flags & ATH9K_HTC_TX_RTSCTS) &&
162 (vif && vif->bss_conf.use_cts_prot))
163 flags |= ATH9K_HTC_TX_CTSONLY;
165 tx_hdr.flags = cpu_to_be32(flags);
166 tx_hdr.key_type = ath9k_cmn_get_hw_crypto_keytype(skb);
167 if (tx_hdr.key_type == ATH9K_KEY_TYPE_CLEAR)
168 tx_hdr.keyix = (u8) ATH9K_TXKEYIX_INVALID;
170 tx_hdr.keyix = tx_info->control.hw_key->hw_key_idx;
172 tx_fhdr = skb_push(skb, sizeof(tx_hdr));
173 memcpy(tx_fhdr, (u8 *) &tx_hdr, sizeof(tx_hdr));
181 qnum = skb_get_queue_mapping(skb);
185 TX_QSTAT_INC(WME_AC_VO);
186 epid = priv->data_vo_ep;
189 TX_QSTAT_INC(WME_AC_VI);
190 epid = priv->data_vi_ep;
193 TX_QSTAT_INC(WME_AC_BE);
194 epid = priv->data_be_ep;
198 TX_QSTAT_INC(WME_AC_BK);
199 epid = priv->data_bk_ep;
203 struct tx_mgmt_hdr mgmt_hdr;
205 memset(&mgmt_hdr, 0, sizeof(struct tx_mgmt_hdr));
208 * Set the TSF adjust value for probe response
211 if (avp && unlikely(ieee80211_is_probe_resp(fc))) {
212 mgmt = (struct ieee80211_mgmt *)skb->data;
213 mgmt->u.probe_resp.timestamp = avp->tsfadjust;
216 tx_ctl->type = ATH9K_HTC_MGMT;
218 mgmt_hdr.node_idx = sta_idx;
219 mgmt_hdr.vif_idx = vif_idx;
223 mgmt_hdr.key_type = ath9k_cmn_get_hw_crypto_keytype(skb);
224 if (mgmt_hdr.key_type == ATH9K_KEY_TYPE_CLEAR)
225 mgmt_hdr.keyix = (u8) ATH9K_TXKEYIX_INVALID;
227 mgmt_hdr.keyix = tx_info->control.hw_key->hw_key_idx;
229 tx_fhdr = skb_push(skb, sizeof(mgmt_hdr));
230 memcpy(tx_fhdr, (u8 *) &mgmt_hdr, sizeof(mgmt_hdr));
231 epid = priv->mgmt_ep;
234 return htc_send(priv->htc, skb, epid);
237 static bool ath9k_htc_check_tx_aggr(struct ath9k_htc_priv *priv,
238 struct ath9k_htc_sta *ista, u8 tid)
242 spin_lock_bh(&priv->tx_lock);
243 if ((tid < ATH9K_HTC_MAX_TID) && (ista->tid_state[tid] == AGGR_STOP))
245 spin_unlock_bh(&priv->tx_lock);
250 void ath9k_tx_tasklet(unsigned long data)
252 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *)data;
253 struct ieee80211_vif *vif;
254 struct ieee80211_sta *sta;
255 struct ieee80211_hdr *hdr;
256 struct ieee80211_tx_info *tx_info;
257 struct sk_buff *skb = NULL;
260 while ((skb = skb_dequeue(&priv->tx_queue)) != NULL) {
262 hdr = (struct ieee80211_hdr *) skb->data;
263 fc = hdr->frame_control;
264 tx_info = IEEE80211_SKB_CB(skb);
265 vif = tx_info->control.vif;
267 memset(&tx_info->status, 0, sizeof(tx_info->status));
274 sta = ieee80211_find_sta(vif, hdr->addr1);
277 ieee80211_tx_status(priv->hw, skb);
281 /* Check if we need to start aggregation */
283 if (sta && conf_is_ht(&priv->hw->conf) &&
284 !(skb->protocol == cpu_to_be16(ETH_P_PAE))) {
285 if (ieee80211_is_data_qos(fc)) {
287 struct ath9k_htc_sta *ista;
289 qc = ieee80211_get_qos_ctl(hdr);
291 ista = (struct ath9k_htc_sta *)sta->drv_priv;
293 if (ath9k_htc_check_tx_aggr(priv, ista, tid)) {
294 ieee80211_start_tx_ba_session(sta, tid, 0);
295 spin_lock_bh(&priv->tx_lock);
296 ista->tid_state[tid] = AGGR_PROGRESS;
297 spin_unlock_bh(&priv->tx_lock);
305 /* Send status to mac80211 */
306 ieee80211_tx_status(priv->hw, skb);
309 /* Wake TX queues if needed */
310 spin_lock_bh(&priv->tx_lock);
311 if (priv->tx_queues_stop) {
312 priv->tx_queues_stop = false;
313 spin_unlock_bh(&priv->tx_lock);
314 ath_dbg(ath9k_hw_common(priv->ah), ATH_DBG_XMIT,
315 "Waking up TX queues\n");
316 ieee80211_wake_queues(priv->hw);
319 spin_unlock_bh(&priv->tx_lock);
322 void ath9k_htc_txep(void *drv_priv, struct sk_buff *skb,
323 enum htc_endpoint_id ep_id, bool txok)
325 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) drv_priv;
326 struct ath_common *common = ath9k_hw_common(priv->ah);
327 struct ieee80211_tx_info *tx_info;
332 if (ep_id == priv->mgmt_ep) {
333 skb_pull(skb, sizeof(struct tx_mgmt_hdr));
334 } else if ((ep_id == priv->data_bk_ep) ||
335 (ep_id == priv->data_be_ep) ||
336 (ep_id == priv->data_vi_ep) ||
337 (ep_id == priv->data_vo_ep) ||
338 (ep_id == priv->cab_ep)) {
339 skb_pull(skb, sizeof(struct tx_frame_hdr));
341 ath_err(common, "Unsupported TX EPID: %d\n", ep_id);
342 dev_kfree_skb_any(skb);
346 tx_info = IEEE80211_SKB_CB(skb);
349 tx_info->flags |= IEEE80211_TX_STAT_ACK;
351 skb_queue_tail(&priv->tx_queue, skb);
352 tasklet_schedule(&priv->tx_tasklet);
355 int ath9k_tx_init(struct ath9k_htc_priv *priv)
357 skb_queue_head_init(&priv->tx_queue);
361 void ath9k_tx_cleanup(struct ath9k_htc_priv *priv)
366 bool ath9k_htc_txq_setup(struct ath9k_htc_priv *priv, int subtype)
368 struct ath_hw *ah = priv->ah;
369 struct ath_common *common = ath9k_hw_common(ah);
370 struct ath9k_tx_queue_info qi;
373 memset(&qi, 0, sizeof(qi));
374 ATH9K_HTC_INIT_TXQ(subtype);
376 qnum = ath9k_hw_setuptxqueue(priv->ah, ATH9K_TX_QUEUE_DATA, &qi);
380 if (qnum >= ARRAY_SIZE(priv->hwq_map)) {
381 ath_err(common, "qnum %u out of range, max %zu!\n",
382 qnum, ARRAY_SIZE(priv->hwq_map));
383 ath9k_hw_releasetxqueue(ah, qnum);
387 priv->hwq_map[subtype] = qnum;
391 int ath9k_htc_cabq_setup(struct ath9k_htc_priv *priv)
393 struct ath9k_tx_queue_info qi;
395 memset(&qi, 0, sizeof(qi));
396 ATH9K_HTC_INIT_TXQ(0);
398 return ath9k_hw_setuptxqueue(priv->ah, ATH9K_TX_QUEUE_CAB, &qi);
406 * Calculate the RX filter to be set in the HW.
408 u32 ath9k_htc_calcrxfilter(struct ath9k_htc_priv *priv)
410 #define RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)
412 struct ath_hw *ah = priv->ah;
415 rfilt = (ath9k_hw_getrxfilter(ah) & RX_FILTER_PRESERVE)
416 | ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST
417 | ATH9K_RX_FILTER_MCAST;
419 if (priv->rxfilter & FIF_PROBE_REQ)
420 rfilt |= ATH9K_RX_FILTER_PROBEREQ;
423 * Set promiscuous mode when FIF_PROMISC_IN_BSS is enabled for station
424 * mode interface or when in monitor mode. AP mode does not need this
425 * since it receives all in-BSS frames anyway.
427 if (((ah->opmode != NL80211_IFTYPE_AP) &&
428 (priv->rxfilter & FIF_PROMISC_IN_BSS)) ||
430 rfilt |= ATH9K_RX_FILTER_PROM;
432 if (priv->rxfilter & FIF_CONTROL)
433 rfilt |= ATH9K_RX_FILTER_CONTROL;
435 if ((ah->opmode == NL80211_IFTYPE_STATION) &&
436 !(priv->rxfilter & FIF_BCN_PRBRESP_PROMISC))
437 rfilt |= ATH9K_RX_FILTER_MYBEACON;
439 rfilt |= ATH9K_RX_FILTER_BEACON;
441 if (conf_is_ht(&priv->hw->conf)) {
442 rfilt |= ATH9K_RX_FILTER_COMP_BAR;
443 rfilt |= ATH9K_RX_FILTER_UNCOMP_BA_BAR;
446 if (priv->rxfilter & FIF_PSPOLL)
447 rfilt |= ATH9K_RX_FILTER_PSPOLL;
451 #undef RX_FILTER_PRESERVE
455 * Recv initialization for opmode change.
457 static void ath9k_htc_opmode_init(struct ath9k_htc_priv *priv)
459 struct ath_hw *ah = priv->ah;
462 /* configure rx filter */
463 rfilt = ath9k_htc_calcrxfilter(priv);
464 ath9k_hw_setrxfilter(ah, rfilt);
466 /* calculate and install multicast filter */
467 mfilt[0] = mfilt[1] = ~0;
468 ath9k_hw_setmcastfilter(ah, mfilt[0], mfilt[1]);
471 void ath9k_host_rx_init(struct ath9k_htc_priv *priv)
473 ath9k_hw_rxena(priv->ah);
474 ath9k_htc_opmode_init(priv);
475 ath9k_hw_startpcureceive(priv->ah, (priv->op_flags & OP_SCANNING));
476 priv->rx.last_rssi = ATH_RSSI_DUMMY_MARKER;
479 static void ath9k_process_rate(struct ieee80211_hw *hw,
480 struct ieee80211_rx_status *rxs,
481 u8 rx_rate, u8 rs_flags)
483 struct ieee80211_supported_band *sband;
484 enum ieee80211_band band;
487 if (rx_rate & 0x80) {
489 rxs->flag |= RX_FLAG_HT;
490 if (rs_flags & ATH9K_RX_2040)
491 rxs->flag |= RX_FLAG_40MHZ;
492 if (rs_flags & ATH9K_RX_GI)
493 rxs->flag |= RX_FLAG_SHORT_GI;
494 rxs->rate_idx = rx_rate & 0x7f;
498 band = hw->conf.channel->band;
499 sband = hw->wiphy->bands[band];
501 for (i = 0; i < sband->n_bitrates; i++) {
502 if (sband->bitrates[i].hw_value == rx_rate) {
506 if (sband->bitrates[i].hw_value_short == rx_rate) {
508 rxs->flag |= RX_FLAG_SHORTPRE;
515 static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
516 struct ath9k_htc_rxbuf *rxbuf,
517 struct ieee80211_rx_status *rx_status)
520 struct ieee80211_hdr *hdr;
521 struct ieee80211_hw *hw = priv->hw;
522 struct sk_buff *skb = rxbuf->skb;
523 struct ath_common *common = ath9k_hw_common(priv->ah);
524 struct ath_htc_rx_status *rxstatus;
525 int hdrlen, padpos, padsize;
526 int last_rssi = ATH_RSSI_DUMMY_MARKER;
529 if (skb->len < HTC_RX_FRAME_HEADER_SIZE) {
530 ath_err(common, "Corrupted RX frame, dropping (len: %d)\n",
535 rxstatus = (struct ath_htc_rx_status *)skb->data;
537 if (be16_to_cpu(rxstatus->rs_datalen) -
538 (skb->len - HTC_RX_FRAME_HEADER_SIZE) != 0) {
540 "Corrupted RX data len, dropping (dlen: %d, skblen: %d)\n",
541 rxstatus->rs_datalen, skb->len);
545 ath9k_htc_err_stat_rx(priv, rxstatus);
547 /* Get the RX status information */
548 memcpy(&rxbuf->rxstatus, rxstatus, HTC_RX_FRAME_HEADER_SIZE);
549 skb_pull(skb, HTC_RX_FRAME_HEADER_SIZE);
551 hdr = (struct ieee80211_hdr *)skb->data;
552 fc = hdr->frame_control;
553 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
555 padpos = ath9k_cmn_padpos(fc);
557 padsize = padpos & 3;
558 if (padsize && skb->len >= padpos+padsize+FCS_LEN) {
559 memmove(skb->data + padsize, skb->data, padpos);
560 skb_pull(skb, padsize);
563 memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
565 if (rxbuf->rxstatus.rs_status != 0) {
566 if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_CRC)
567 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
568 if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_PHY)
571 if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_DECRYPT) {
573 } else if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_MIC) {
574 if (ieee80211_is_ctl(fc))
576 * Sometimes, we get invalid
577 * MIC failures on valid control frames.
578 * Remove these mic errors.
580 rxbuf->rxstatus.rs_status &= ~ATH9K_RXERR_MIC;
582 rx_status->flag |= RX_FLAG_MMIC_ERROR;
586 * Reject error frames with the exception of
587 * decryption and MIC failures. For monitor mode,
588 * we also ignore the CRC error.
590 if (priv->ah->opmode == NL80211_IFTYPE_MONITOR) {
591 if (rxbuf->rxstatus.rs_status &
592 ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
596 if (rxbuf->rxstatus.rs_status &
597 ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC)) {
603 if (!(rxbuf->rxstatus.rs_status & ATH9K_RXERR_DECRYPT)) {
605 keyix = rxbuf->rxstatus.rs_keyix;
606 if (keyix != ATH9K_RXKEYIX_INVALID) {
607 rx_status->flag |= RX_FLAG_DECRYPTED;
608 } else if (ieee80211_has_protected(fc) &&
609 skb->len >= hdrlen + 4) {
610 keyix = skb->data[hdrlen + 3] >> 6;
611 if (test_bit(keyix, common->keymap))
612 rx_status->flag |= RX_FLAG_DECRYPTED;
616 ath9k_process_rate(hw, rx_status, rxbuf->rxstatus.rs_rate,
617 rxbuf->rxstatus.rs_flags);
619 if (rxbuf->rxstatus.rs_rssi != ATH9K_RSSI_BAD &&
620 !rxbuf->rxstatus.rs_moreaggr)
621 ATH_RSSI_LPF(priv->rx.last_rssi,
622 rxbuf->rxstatus.rs_rssi);
624 last_rssi = priv->rx.last_rssi;
626 if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
627 rxbuf->rxstatus.rs_rssi = ATH_EP_RND(last_rssi,
628 ATH_RSSI_EP_MULTIPLIER);
630 if (rxbuf->rxstatus.rs_rssi < 0)
631 rxbuf->rxstatus.rs_rssi = 0;
633 if (ieee80211_is_beacon(fc))
634 priv->ah->stats.avgbrssi = rxbuf->rxstatus.rs_rssi;
636 rx_status->mactime = be64_to_cpu(rxbuf->rxstatus.rs_tstamp);
637 rx_status->band = hw->conf.channel->band;
638 rx_status->freq = hw->conf.channel->center_freq;
639 rx_status->signal = rxbuf->rxstatus.rs_rssi + ATH_DEFAULT_NOISE_FLOOR;
640 rx_status->antenna = rxbuf->rxstatus.rs_antenna;
641 rx_status->flag |= RX_FLAG_MACTIME_MPDU;
650 * FIXME: Handle FLUSH later on.
652 void ath9k_rx_tasklet(unsigned long data)
654 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *)data;
655 struct ath9k_htc_rxbuf *rxbuf = NULL, *tmp_buf = NULL;
656 struct ieee80211_rx_status rx_status;
659 struct ieee80211_hdr *hdr;
662 spin_lock_irqsave(&priv->rx.rxbuflock, flags);
663 list_for_each_entry(tmp_buf, &priv->rx.rxbuf, list) {
664 if (tmp_buf->in_process) {
671 spin_unlock_irqrestore(&priv->rx.rxbuflock, flags);
678 if (!ath9k_rx_prepare(priv, rxbuf, &rx_status)) {
679 dev_kfree_skb_any(rxbuf->skb);
683 memcpy(IEEE80211_SKB_RXCB(rxbuf->skb), &rx_status,
684 sizeof(struct ieee80211_rx_status));
686 hdr = (struct ieee80211_hdr *) skb->data;
688 if (ieee80211_is_beacon(hdr->frame_control) && priv->ps_enabled)
689 ieee80211_queue_work(priv->hw, &priv->ps_work);
691 spin_unlock_irqrestore(&priv->rx.rxbuflock, flags);
693 ieee80211_rx(priv->hw, skb);
695 spin_lock_irqsave(&priv->rx.rxbuflock, flags);
697 rxbuf->in_process = false;
699 list_move_tail(&rxbuf->list, &priv->rx.rxbuf);
701 spin_unlock_irqrestore(&priv->rx.rxbuflock, flags);
706 void ath9k_htc_rxep(void *drv_priv, struct sk_buff *skb,
707 enum htc_endpoint_id ep_id)
709 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *)drv_priv;
710 struct ath_hw *ah = priv->ah;
711 struct ath_common *common = ath9k_hw_common(ah);
712 struct ath9k_htc_rxbuf *rxbuf = NULL, *tmp_buf = NULL;
714 spin_lock(&priv->rx.rxbuflock);
715 list_for_each_entry(tmp_buf, &priv->rx.rxbuf, list) {
716 if (!tmp_buf->in_process) {
721 spin_unlock(&priv->rx.rxbuflock);
724 ath_dbg(common, ATH_DBG_ANY,
725 "No free RX buffer\n");
729 spin_lock(&priv->rx.rxbuflock);
731 rxbuf->in_process = true;
732 spin_unlock(&priv->rx.rxbuflock);
734 tasklet_schedule(&priv->rx_tasklet);
737 dev_kfree_skb_any(skb);
740 /* FIXME: Locking for cleanup/init */
742 void ath9k_rx_cleanup(struct ath9k_htc_priv *priv)
744 struct ath9k_htc_rxbuf *rxbuf, *tbuf;
746 list_for_each_entry_safe(rxbuf, tbuf, &priv->rx.rxbuf, list) {
747 list_del(&rxbuf->list);
749 dev_kfree_skb_any(rxbuf->skb);
754 int ath9k_rx_init(struct ath9k_htc_priv *priv)
756 struct ath_hw *ah = priv->ah;
757 struct ath_common *common = ath9k_hw_common(ah);
758 struct ath9k_htc_rxbuf *rxbuf;
761 INIT_LIST_HEAD(&priv->rx.rxbuf);
762 spin_lock_init(&priv->rx.rxbuflock);
764 for (i = 0; i < ATH9K_HTC_RXBUF; i++) {
765 rxbuf = kzalloc(sizeof(struct ath9k_htc_rxbuf), GFP_KERNEL);
767 ath_err(common, "Unable to allocate RX buffers\n");
770 list_add_tail(&rxbuf->list, &priv->rx.rxbuf);
776 ath9k_rx_cleanup(priv);