Lines Matching +full:edma +full:- +full:err
2 * Copyright (c) 2008-2011 Atheros Communications Inc.
17 #include <linux/dma-mapping.h>
33 #define TIME_SYMBOLS_HALFGI(t) (((t) * 5 - 4) / 18)
35 #define NUM_SYMBOLS_PER_USEC_HALFGI(_usec) (((_usec*5)-4)/18)
49 { 104, 216 }, /* 3: 16-QAM 1/2 */
50 { 156, 324 }, /* 4: 16-QAM 3/4 */
51 { 208, 432 }, /* 5: 64-QAM 2/3 */
52 { 234, 486 }, /* 6: 64-QAM 3/4 */
53 { 260, 540 }, /* 7: 64-QAM 5/6 */
92 struct ieee80211_sta *sta = info->status.status_driver_data[0]; in ath_tx_status()
94 if (info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS | in ath_tx_status()
107 __releases(&txq->axq_lock) in ath_txq_unlock_complete()
109 struct ieee80211_hw *hw = sc->hw; in ath_txq_unlock_complete()
114 skb_queue_splice_init(&txq->complete_q, &q); in ath_txq_unlock_complete()
115 spin_unlock_bh(&txq->axq_lock); in ath_txq_unlock_complete()
126 ieee80211_schedule_txq(sc->hw, queue); in ath_tx_queue_tid()
131 struct ath_softc *sc = hw->priv; in ath9k_wake_tx_queue()
132 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_wake_tx_queue()
133 struct ath_atx_tid *tid = (struct ath_atx_tid *) queue->drv_priv; in ath9k_wake_tx_queue()
134 struct ath_txq *txq = tid->txq; in ath9k_wake_tx_queue()
137 queue->sta ? queue->sta->addr : queue->vif->addr, in ath9k_wake_tx_queue()
138 tid->tidno); in ath9k_wake_tx_queue()
149 sizeof(tx_info->status.status_driver_data)); in get_frame_info()
150 return (struct ath_frame_info *) &tx_info->status.status_driver_data[0]; in get_frame_info()
155 if (!tid->an->sta) in ath_send_bar()
158 ieee80211_send_bar(tid->an->vif, tid->an->sta->addr, tid->tidno, in ath_send_bar()
171 ratetbl = rcu_dereference(sta->rates); in ath_merge_ratetbl()
175 if (tx_info->control.rates[0].idx < 0 || in ath_merge_ratetbl()
176 tx_info->control.rates[0].count == 0) in ath_merge_ratetbl()
180 bf->rates[0] = tx_info->control.rates[0]; in ath_merge_ratetbl()
185 bf->rates[i].idx = ratetbl->rate[i].idx; in ath_merge_ratetbl()
186 bf->rates[i].flags = ratetbl->rate[i].flags; in ath_merge_ratetbl()
187 if (tx_info->control.use_rts) in ath_merge_ratetbl()
188 bf->rates[i].count = ratetbl->rate[i].count_rts; in ath_merge_ratetbl()
189 else if (tx_info->control.use_cts_prot) in ath_merge_ratetbl()
190 bf->rates[i].count = ratetbl->rate[i].count_cts; in ath_merge_ratetbl()
192 bf->rates[i].count = ratetbl->rate[i].count; in ath_merge_ratetbl()
203 tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); in ath_set_rates()
206 ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates, in ath_set_rates()
207 ARRAY_SIZE(bf->rates)); in ath_set_rates()
214 int q = fi->txq; in ath_txq_skb_done()
219 txq = sc->tx.txq_map[q]; in ath_txq_skb_done()
220 if (WARN_ON(--txq->pending_frames < 0)) in ath_txq_skb_done()
221 txq->pending_frames = 0; in ath_txq_skb_done()
228 u8 tidno = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ath_get_skb_tid()
236 struct ath_softc *sc = tid->an->sc; in ath_tid_pull()
237 struct ieee80211_hw *hw = sc->hw; in ath_tid_pull()
239 .txq = tid->txq, in ath_tid_pull()
240 .sta = tid->an->sta, in ath_tid_pull()
248 return -ENOENT; in ath_tid_pull()
257 if (tid->txq == sc->tx.txq_map[q]) { in ath_tid_pull()
259 fi->txq = q; in ath_tid_pull()
260 ++tid->txq->pending_frames; in ath_tid_pull()
271 *skb = __skb_dequeue(&tid->retry_q); in ath_tid_dequeue()
280 struct ath_txq *txq = tid->txq; in ath_tx_flush_tid()
292 while ((skb = __skb_dequeue(&tid->retry_q))) { in ath_tx_flush_tid()
294 bf = fi->bf; in ath_tx_flush_tid()
297 ieee80211_free_txskb(sc->hw, skb); in ath_tx_flush_tid()
301 if (fi->baw_tracked) { in ath_tx_flush_tid()
306 list_add_tail(&bf->list, &bf_head); in ath_tx_flush_tid()
312 ath_send_bar(tid, tid->seq_start); in ath_tx_flush_tid()
319 struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu); in ath_tx_update_baw()
320 u16 seqno = bf->bf_state.seqno; in ath_tx_update_baw()
323 if (!fi->baw_tracked) in ath_tx_update_baw()
326 index = ATH_BA_INDEX(tid->seq_start, seqno); in ath_tx_update_baw()
327 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1); in ath_tx_update_baw()
329 __clear_bit(cindex, tid->tx_buf); in ath_tx_update_baw()
331 while (tid->baw_head != tid->baw_tail && !test_bit(tid->baw_head, tid->tx_buf)) { in ath_tx_update_baw()
332 INCR(tid->seq_start, IEEE80211_SEQ_MAX); in ath_tx_update_baw()
333 INCR(tid->baw_head, ATH_TID_MAX_BUFS); in ath_tx_update_baw()
334 if (tid->bar_index >= 0) in ath_tx_update_baw()
335 tid->bar_index--; in ath_tx_update_baw()
341 struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu); in ath_tx_addto_baw()
342 u16 seqno = bf->bf_state.seqno; in ath_tx_addto_baw()
345 if (fi->baw_tracked) in ath_tx_addto_baw()
348 index = ATH_BA_INDEX(tid->seq_start, seqno); in ath_tx_addto_baw()
349 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1); in ath_tx_addto_baw()
350 __set_bit(cindex, tid->tx_buf); in ath_tx_addto_baw()
351 fi->baw_tracked = 1; in ath_tx_addto_baw()
353 if (index >= ((tid->baw_tail - tid->baw_head) & in ath_tx_addto_baw()
354 (ATH_TID_MAX_BUFS - 1))) { in ath_tx_addto_baw()
355 tid->baw_tail = cindex; in ath_tx_addto_baw()
356 INCR(tid->baw_tail, ATH_TID_MAX_BUFS); in ath_tx_addto_baw()
375 bf = fi->bf; in ath_tid_drain()
382 list_add_tail(&bf->list, &bf_head); in ath_tid_drain()
391 struct ath_buf *bf = fi->bf; in ath_tx_set_retry()
393 int prev = fi->retries; in ath_tx_set_retry()
395 TX_STAT_INC(sc, txq->axq_qnum, a_retries); in ath_tx_set_retry()
396 fi->retries += count; in ath_tx_set_retry()
401 hdr = (struct ieee80211_hdr *)skb->data; in ath_tx_set_retry()
402 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_RETRY); in ath_tx_set_retry()
403 dma_sync_single_for_device(sc->dev, bf->bf_buf_addr, in ath_tx_set_retry()
411 spin_lock_bh(&sc->tx.txbuflock); in ath_tx_get_buffer()
413 if (unlikely(list_empty(&sc->tx.txbuf))) { in ath_tx_get_buffer()
414 spin_unlock_bh(&sc->tx.txbuflock); in ath_tx_get_buffer()
418 bf = list_first_entry(&sc->tx.txbuf, struct ath_buf, list); in ath_tx_get_buffer()
419 list_del(&bf->list); in ath_tx_get_buffer()
421 spin_unlock_bh(&sc->tx.txbuflock); in ath_tx_get_buffer()
428 spin_lock_bh(&sc->tx.txbuflock); in ath_tx_return_buffer()
429 list_add_tail(&bf->list, &sc->tx.txbuf); in ath_tx_return_buffer()
430 spin_unlock_bh(&sc->tx.txbuflock); in ath_tx_return_buffer()
443 tbf->bf_mpdu = bf->bf_mpdu; in ath_clone_txbuf()
444 tbf->bf_buf_addr = bf->bf_buf_addr; in ath_clone_txbuf()
445 memcpy(tbf->bf_desc, bf->bf_desc, sc->sc_ah->caps.tx_desc_len); in ath_clone_txbuf()
446 tbf->bf_state = bf->bf_state; in ath_clone_txbuf()
447 tbf->bf_state.stale = false; in ath_clone_txbuf()
467 seq_st = ts->ts_seqnum; in ath_tx_count_frames()
468 memcpy(ba, &ts->ba, WME_BA_BMP_SIZE >> 3); in ath_tx_count_frames()
472 ba_index = ATH_BA_INDEX(seq_st, bf->bf_state.seqno); in ath_tx_count_frames()
478 bf = bf->bf_next; in ath_tx_count_frames()
492 struct ath_buf *bf_next, *bf_last = bf->bf_lastbf; in ath_tx_complete_aggr()
502 bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH); in ath_tx_complete_aggr()
504 int bar_index = -1; in ath_tx_complete_aggr()
506 skb = bf->bf_mpdu; in ath_tx_complete_aggr()
509 memcpy(rates, bf->rates, sizeof(rates)); in ath_tx_complete_aggr()
511 retries = ts->ts_longretry + 1; in ath_tx_complete_aggr()
512 for (i = 0; i < ts->ts_rateindex; i++) in ath_tx_complete_aggr()
518 bf_next = bf->bf_next; in ath_tx_complete_aggr()
520 if (!bf->bf_state.stale || bf_next != NULL) in ath_tx_complete_aggr()
521 list_move_tail(&bf->list, &bf_head); in ath_tx_complete_aggr()
530 an = (struct ath_node *)sta->drv_priv; in ath_tx_complete_aggr()
531 seq_first = tid->seq_start; in ath_tx_complete_aggr()
532 isba = ts->ts_flags & ATH9K_TX_BA; in ath_tx_complete_aggr()
542 if (isba && tid->tidno != ts->tid) in ath_tx_complete_aggr()
549 if (ts->ts_flags & ATH9K_TX_BA) { in ath_tx_complete_aggr()
550 seq_st = ts->ts_seqnum; in ath_tx_complete_aggr()
551 memcpy(ba, &ts->ba, WME_BA_BMP_SIZE >> 3); in ath_tx_complete_aggr()
560 if (sc->sc_ah->opmode == NL80211_IFTYPE_STATION) in ath_tx_complete_aggr()
569 u16 seqno = bf->bf_state.seqno; in ath_tx_complete_aggr()
572 bf_next = bf->bf_next; in ath_tx_complete_aggr()
574 skb = bf->bf_mpdu; in ath_tx_complete_aggr()
578 if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno) || in ath_tx_complete_aggr()
579 !tid->active) { in ath_tx_complete_aggr()
594 } else if (fi->retries < ATH_MAX_SW_RETRIES) { in ath_tx_complete_aggr()
595 if (txok || !an->sleeping) in ath_tx_complete_aggr()
596 ath_tx_set_retry(sc, txq, bf->bf_mpdu, in ath_tx_complete_aggr()
612 if (bf_next != NULL || !bf_last->bf_state.stale) in ath_tx_complete_aggr()
613 list_move_tail(&bf->list, &bf_head); in ath_tx_complete_aggr()
617 * complete the acked-ones/xretried ones; update in ath_tx_complete_aggr()
618 * block-ack window in ath_tx_complete_aggr()
623 memcpy(tx_info->control.rates, rates, sizeof(rates)); in ath_tx_complete_aggr()
626 if (bf == bf->bf_lastbf) in ath_tx_complete_aggr()
627 ath_dynack_sample_tx_ts(sc->sc_ah, in ath_tx_complete_aggr()
628 bf->bf_mpdu, in ath_tx_complete_aggr()
635 if (tx_info->flags & IEEE80211_TX_STATUS_EOSP) { in ath_tx_complete_aggr()
636 tx_info->flags &= ~IEEE80211_TX_STATUS_EOSP; in ath_tx_complete_aggr()
639 /* retry the un-acked ones */ in ath_tx_complete_aggr()
640 if (bf->bf_next == NULL && bf_last->bf_state.stale) { in ath_tx_complete_aggr()
660 fi->bf = tbf; in ath_tx_complete_aggr()
673 /* prepend un-acked frames to the beginning of the pending frame queue */ in ath_tx_complete_aggr()
675 if (an->sleeping) in ath_tx_complete_aggr()
676 ieee80211_sta_set_buffered(sta, tid->tidno, true); in ath_tx_complete_aggr()
678 skb_queue_splice_tail(&bf_pending, &tid->retry_q); in ath_tx_complete_aggr()
679 if (!an->sleeping) { in ath_tx_complete_aggr()
681 if (ts->ts_status & (ATH9K_TXERR_FILT | ATH9K_TXERR_XRETRY)) in ath_tx_complete_aggr()
682 tid->clear_ps_filter = true; in ath_tx_complete_aggr()
689 if (BAW_WITHIN(tid->seq_start, tid->baw_size, bar_seq)) in ath_tx_complete_aggr()
690 tid->bar_index = ATH_BA_INDEX(tid->seq_start, bar_seq); in ath_tx_complete_aggr()
703 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(bf->bf_mpdu); in bf_is_ampdu_not_probing()
704 return bf_isampdu(bf) && !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE); in bf_is_ampdu_not_probing()
716 airtime += ts->duration * (ts->ts_longretry + 1); in ath_tx_count_airtime()
717 for(i = 0; i < ts->ts_rateindex; i++) { in ath_tx_count_airtime()
718 int rate_dur = ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc, i); in ath_tx_count_airtime()
719 airtime += rate_dur * bf->rates[i].count; in ath_tx_count_airtime()
729 struct ieee80211_hw *hw = sc->hw; in ath_tx_process_buffer()
736 txok = !(ts->ts_status & ATH9K_TXERR_MASK); in ath_tx_process_buffer()
737 flush = !!(ts->ts_status & ATH9K_TX_FLUSH); in ath_tx_process_buffer()
738 txq->axq_tx_inprogress = false; in ath_tx_process_buffer()
740 txq->axq_depth--; in ath_tx_process_buffer()
742 txq->axq_ampdu_depth--; in ath_tx_process_buffer()
744 ts->duration = ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc, in ath_tx_process_buffer()
745 ts->ts_rateindex); in ath_tx_process_buffer()
747 hdr = (struct ieee80211_hdr *) bf->bf_mpdu->data; in ath_tx_process_buffer()
748 sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr1, hdr->addr2); in ath_tx_process_buffer()
750 struct ath_node *an = (struct ath_node *)sta->drv_priv; in ath_tx_process_buffer()
751 tid = ath_get_skb_tid(an, bf->bf_mpdu); in ath_tx_process_buffer()
752 ath_tx_count_airtime(sc, sta, bf, ts, tid->tidno); in ath_tx_process_buffer()
753 if (ts->ts_status & (ATH9K_TXERR_FILT | ATH9K_TXERR_XRETRY)) in ath_tx_process_buffer()
754 tid->clear_ps_filter = true; in ath_tx_process_buffer()
759 info = IEEE80211_SKB_CB(bf->bf_mpdu); in ath_tx_process_buffer()
760 memcpy(info->control.rates, bf->rates, in ath_tx_process_buffer()
761 sizeof(info->control.rates)); in ath_tx_process_buffer()
763 ath_dynack_sample_tx_ts(sc->sc_ah, bf->bf_mpdu, ts, in ath_tx_process_buffer()
781 skb = bf->bf_mpdu; in ath_lookup_legacy()
783 rates = tx_info->control.rates; in ath_lookup_legacy()
804 int q = tid->txq->mac80211_qnum; in ath_lookup_rate()
807 skb = bf->bf_mpdu; in ath_lookup_rate()
809 rates = bf->rates; in ath_lookup_rate()
836 frmlen = sc->tx.max_aggr_framelen[q][modeidx][rates[i].idx]; in ath_lookup_rate()
845 if (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE || legacy) in ath_lookup_rate()
857 if (tid->an->maxampdu) in ath_lookup_rate()
858 aggr_limit = min(aggr_limit, tid->an->maxampdu); in ath_lookup_rate()
876 struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu); in ath_compute_num_delims()
884 * TODO - this could be improved to be dependent on the rate. in ath_compute_num_delims()
887 if ((fi->keyix != ATH9K_TXKEYIX_INVALID) && in ath_compute_num_delims()
888 !(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)) in ath_compute_num_delims()
895 if (first_subfrm && !AR_SREV_9580_10_OR_LATER(sc->sc_ah) && in ath_compute_num_delims()
896 (sc->sc_ah->ent_mode & AR_ENT_OTP_MIN_PKT_SIZE_DISABLE)) in ath_compute_num_delims()
909 if (tid->an->mpdudensity == 0) in ath_compute_num_delims()
912 rix = bf->rates[0].idx; in ath_compute_num_delims()
913 flags = bf->rates[0].flags; in ath_compute_num_delims()
918 nsymbols = NUM_SYMBOLS_PER_USEC_HALFGI(tid->an->mpdudensity); in ath_compute_num_delims()
920 nsymbols = NUM_SYMBOLS_PER_USEC(tid->an->mpdudensity); in ath_compute_num_delims()
930 mindelim = (minlen - frmlen) / ATH_AGGR_DELIM_SZ; in ath_compute_num_delims()
954 bf = fi->bf; in ath_tx_get_tid_subframe()
955 if (!fi->bf) in ath_tx_get_tid_subframe()
958 bf->bf_state.stale = false; in ath_tx_get_tid_subframe()
962 ieee80211_free_txskb(sc->hw, skb); in ath_tx_get_tid_subframe()
966 bf->bf_next = NULL; in ath_tx_get_tid_subframe()
967 bf->bf_lastbf = bf; in ath_tx_get_tid_subframe()
970 tx_info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT | in ath_tx_get_tid_subframe()
978 if (!tid->active) in ath_tx_get_tid_subframe()
979 tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU; in ath_tx_get_tid_subframe()
981 if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) { in ath_tx_get_tid_subframe()
982 bf->bf_state.bf_type = 0; in ath_tx_get_tid_subframe()
986 bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR; in ath_tx_get_tid_subframe()
987 seqno = bf->bf_state.seqno; in ath_tx_get_tid_subframe()
989 /* do not step over block-ack window */ in ath_tx_get_tid_subframe()
990 if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) { in ath_tx_get_tid_subframe()
991 __skb_queue_tail(&tid->retry_q, skb); in ath_tx_get_tid_subframe()
996 if (!skb_queue_is_first(&tid->retry_q, skb) && in ath_tx_get_tid_subframe()
1002 return -EINPROGRESS; in ath_tx_get_tid_subframe()
1005 if (tid->bar_index > ATH_BA_INDEX(tid->seq_start, seqno)) { in ath_tx_get_tid_subframe()
1010 list_add(&bf->list, &bf_head); in ath_tx_get_tid_subframe()
1031 #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4) in ath_tx_form_aggr()
1035 al_delta, h_baw = tid->baw_size / 2; in ath_tx_form_aggr()
1046 skb = bf->bf_mpdu; in ath_tx_form_aggr()
1050 al_delta = ATH_AGGR_DELIM_SZ + fi->framelen; in ath_tx_form_aggr()
1056 tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); in ath_tx_form_aggr()
1057 if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) || in ath_tx_form_aggr()
1058 !(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) in ath_tx_form_aggr()
1069 ndelim = ath_compute_num_delims(sc, tid, bf_first, fi->framelen, in ath_tx_form_aggr()
1074 bf->bf_next = NULL; in ath_tx_form_aggr()
1077 bf->bf_state.ndelim = ndelim; in ath_tx_form_aggr()
1079 list_add_tail(&bf->list, bf_q); in ath_tx_form_aggr()
1081 bf_prev->bf_next = bf; in ath_tx_form_aggr()
1091 __skb_queue_tail(&tid->retry_q, bf->bf_mpdu); in ath_tx_form_aggr()
1094 bf->bf_lastbf = bf_prev; in ath_tx_form_aggr()
1097 al = get_frame_info(bf->bf_mpdu)->framelen; in ath_tx_form_aggr()
1098 bf->bf_state.bf_type = BUF_AMPDU; in ath_tx_form_aggr()
1100 TX_STAT_INC(sc, txq->axq_qnum, a_aggr); in ath_tx_form_aggr()
1108 * rix - rate index
1109 * pktlen - total bytes (delims + data + fcs + pads + pad delims)
1110 * width - 0 for 20 MHz, 1 for 40 MHz
1111 * half_gi - to use 4us v/s 3.6 us for symbol time
1123 nsymbols = (nbits + nsymbits - 1) / nsymbits; in ath_pkt_duration()
1142 usec -= L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams); in ath_max_framelen()
1145 bits -= OFDM_PLCP_BITS; in ath_max_framelen()
1162 cur_ht20 = sc->tx.max_aggr_framelen[queue][MCS_HT20]; in ath_update_max_aggr_framelen()
1163 cur_ht20_sgi = sc->tx.max_aggr_framelen[queue][MCS_HT20_SGI]; in ath_update_max_aggr_framelen()
1164 cur_ht40 = sc->tx.max_aggr_framelen[queue][MCS_HT40]; in ath_update_max_aggr_framelen()
1165 cur_ht40_sgi = sc->tx.max_aggr_framelen[queue][MCS_HT40_SGI]; in ath_update_max_aggr_framelen()
1181 struct ath_hw *ah = sc->sc_ah; in ath_get_rate_txpower()
1184 if (sc->tx99_state || !ah->tpc_enabled) in ath_get_rate_txpower()
1187 skb = bf->bf_mpdu; in ath_get_rate_txpower()
1191 is_2ghz = info->band == NL80211_BAND_2GHZ; in ath_get_rate_txpower()
1192 is_5ghz = info->band == NL80211_BAND_5GHZ; in ath_get_rate_txpower()
1193 use_stbc = is_mcs && rateidx < 8 && (info->flags & in ath_get_rate_txpower()
1205 int txpower = fi->tx_power; in ath_get_rate_txpower()
1209 struct ar5416_eeprom_def *eep = &ah->eeprom.def; in ath_get_rate_txpower()
1210 u16 eeprom_rev = ah->eep_ops->get_eeprom_rev(ah); in ath_get_rate_txpower()
1215 pmodal = &eep->modalHeader[is_2ghz]; in ath_get_rate_txpower()
1216 power_ht40delta = pmodal->ht40PowerIncForPdadc; in ath_get_rate_txpower()
1225 txpower -= 2 * AR9287_PWR_TABLE_OFFSET_DB; in ath_get_rate_txpower()
1229 power_offset = ah->eep_ops->get_eeprom(ah, in ath_get_rate_txpower()
1231 txpower -= 2 * power_offset; in ath_get_rate_txpower()
1235 txpower -= 2; in ath_get_rate_txpower()
1238 max_power = min_t(u8, ah->tx_power[rateidx], txpower); in ath_get_rate_txpower()
1246 } else if (!bf->bf_state.bfs_paprd) { in ath_get_rate_txpower()
1248 max_power = min_t(u8, ah->tx_power_stbc[rateidx], in ath_get_rate_txpower()
1249 fi->tx_power); in ath_get_rate_txpower()
1251 max_power = min_t(u8, ah->tx_power[rateidx], in ath_get_rate_txpower()
1252 fi->tx_power); in ath_get_rate_txpower()
1254 max_power = ah->paprd_training_power; in ath_get_rate_txpower()
1263 struct ath_hw *ah = sc->sc_ah; in ath_buf_set_rate()
1270 struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu); in ath_buf_set_rate()
1271 u32 rts_thresh = sc->hw->wiphy->rts_threshold; in ath_buf_set_rate()
1275 skb = bf->bf_mpdu; in ath_buf_set_rate()
1277 rates = bf->rates; in ath_buf_set_rate()
1278 hdr = (struct ieee80211_hdr *)skb->data; in ath_buf_set_rate()
1280 /* set dur_update_en for l-sig computation except for PS-Poll frames */ in ath_buf_set_rate()
1281 info->dur_update = !ieee80211_is_pspoll(hdr->frame_control); in ath_buf_set_rate()
1282 info->rtscts_rate = fi->rtscts_rate; in ath_buf_set_rate()
1284 for (i = 0; i < ARRAY_SIZE(bf->rates); i++) { in ath_buf_set_rate()
1292 info->rates[i].Tries = rates[i].count; in ath_buf_set_rate()
1299 unlikely(rts_thresh != (u32) -1)) { in ath_buf_set_rate()
1305 info->rates[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS; in ath_buf_set_rate()
1306 info->flags |= ATH9K_TXDESC_RTSENA; in ath_buf_set_rate()
1308 info->rates[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS; in ath_buf_set_rate()
1309 info->flags |= ATH9K_TXDESC_CTSENA; in ath_buf_set_rate()
1313 info->rates[i].RateFlags |= ATH9K_RATESERIES_2040; in ath_buf_set_rate()
1315 info->rates[i].RateFlags |= ATH9K_RATESERIES_HALFGI; in ath_buf_set_rate()
1323 info->rates[i].Rate = rix | 0x80; in ath_buf_set_rate()
1324 info->rates[i].ChSel = ath_txchainmask_reduction(sc, in ath_buf_set_rate()
1325 ah->txchainmask, info->rates[i].Rate); in ath_buf_set_rate()
1326 info->rates[i].PktDuration = ath_pkt_duration(rix, len, in ath_buf_set_rate()
1328 if (rix < 8 && (tx_info->flags & IEEE80211_TX_CTL_STBC)) in ath_buf_set_rate()
1329 info->rates[i].RateFlags |= ATH9K_RATESERIES_STBC; in ath_buf_set_rate()
1330 if (rix >= 8 && fi->dyn_smps) { in ath_buf_set_rate()
1331 info->rates[i].RateFlags |= in ath_buf_set_rate()
1333 info->flags |= ATH9K_TXDESC_CTSENA; in ath_buf_set_rate()
1336 info->txpower[i] = ath_get_rate_txpower(sc, bf, rix, in ath_buf_set_rate()
1342 rate = &common->sbands[tx_info->band].bitrates[rates[i].idx]; in ath_buf_set_rate()
1343 if ((tx_info->band == NL80211_BAND_2GHZ) && in ath_buf_set_rate()
1344 !(rate->flags & IEEE80211_RATE_ERP_G)) in ath_buf_set_rate()
1349 info->rates[i].Rate = rate->hw_value; in ath_buf_set_rate()
1350 if (rate->hw_value_short) { in ath_buf_set_rate()
1352 info->rates[i].Rate |= rate->hw_value_short; in ath_buf_set_rate()
1357 if (bf->bf_state.bfs_paprd) in ath_buf_set_rate()
1358 info->rates[i].ChSel = ah->txchainmask; in ath_buf_set_rate()
1360 info->rates[i].ChSel = ath_txchainmask_reduction(sc, in ath_buf_set_rate()
1361 ah->txchainmask, info->rates[i].Rate); in ath_buf_set_rate()
1363 info->rates[i].PktDuration = ath9k_hw_computetxtime(sc->sc_ah, in ath_buf_set_rate()
1364 phy, rate->bitrate * 100, len, rix, is_sp); in ath_buf_set_rate()
1366 is_cck = IS_CCK_RATE(info->rates[i].Rate); in ath_buf_set_rate()
1367 info->txpower[i] = ath_get_rate_txpower(sc, bf, rix, false, in ath_buf_set_rate()
1371 /* For AR5416 - RTS cannot be followed by a frame larger than 8K */ in ath_buf_set_rate()
1372 if (bf_isaggr(bf) && (len > sc->sc_ah->caps.rts_aggr_limit)) in ath_buf_set_rate()
1373 info->flags &= ~ATH9K_TXDESC_RTSENA; in ath_buf_set_rate()
1376 if (info->flags & ATH9K_TXDESC_RTSENA) in ath_buf_set_rate()
1377 info->flags &= ~ATH9K_TXDESC_CTSENA; in ath_buf_set_rate()
1386 hdr = (struct ieee80211_hdr *)skb->data; in get_hw_packet_type()
1387 fc = hdr->frame_control; in get_hw_packet_type()
1406 struct ath_hw *ah = sc->sc_ah; in ath_tx_fill_desc()
1409 u32 rts_thresh = sc->hw->wiphy->rts_threshold; in ath_tx_fill_desc()
1415 info.qcu = txq->axq_qnum; in ath_tx_fill_desc()
1418 struct sk_buff *skb = bf->bf_mpdu; in ath_tx_fill_desc()
1421 bool aggr = !!(bf->bf_state.bf_type & BUF_AGGR); in ath_tx_fill_desc()
1424 if (bf->bf_next) in ath_tx_fill_desc()
1425 info.link = bf->bf_next->bf_daddr; in ath_tx_fill_desc()
1427 info.link = (sc->tx99_state) ? bf->bf_daddr : 0; in ath_tx_fill_desc()
1432 if (!sc->tx99_state) in ath_tx_fill_desc()
1434 if ((tx_info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT) || in ath_tx_fill_desc()
1435 txq == sc->tx.uapsdq) in ath_tx_fill_desc()
1438 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) in ath_tx_fill_desc()
1440 if (tx_info->flags & IEEE80211_TX_CTL_LDPC) in ath_tx_fill_desc()
1443 if (bf->bf_state.bfs_paprd) in ath_tx_fill_desc()
1444 info.flags |= (u32) bf->bf_state.bfs_paprd << in ath_tx_fill_desc()
1455 unlikely(rts_thresh != (u32) -1)) { in ath_tx_fill_desc()
1464 len = fi->framelen; in ath_tx_fill_desc()
1469 info.buf_addr[0] = bf->bf_buf_addr; in ath_tx_fill_desc()
1470 info.buf_len[0] = skb->len; in ath_tx_fill_desc()
1471 info.pkt_len = fi->framelen; in ath_tx_fill_desc()
1472 info.keyix = fi->keyix; in ath_tx_fill_desc()
1473 info.keytype = fi->keytype; in ath_tx_fill_desc()
1478 else if (bf == bf_first->bf_lastbf) in ath_tx_fill_desc()
1483 info.ndelim = bf->bf_state.ndelim; in ath_tx_fill_desc()
1487 if (bf == bf_first->bf_lastbf) in ath_tx_fill_desc()
1490 ath9k_hw_set_txdesc(ah, bf->bf_desc, &info); in ath_tx_fill_desc()
1491 bf = bf->bf_next; in ath_tx_fill_desc()
1507 list_add_tail(&bf->list, bf_q); in ath_tx_form_burst()
1509 bf_prev->bf_next = bf; in ath_tx_form_burst()
1519 tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); in ath_tx_form_burst()
1520 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { in ath_tx_form_burst()
1521 __skb_queue_tail(&tid->retry_q, bf->bf_mpdu); in ath_tx_form_burst()
1525 ath_set_rates(tid->an->vif, tid->an->sta, bf); in ath_tx_form_burst()
1544 tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); in ath_tx_sched_aggr()
1545 aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU); in ath_tx_sched_aggr()
1546 if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) || in ath_tx_sched_aggr()
1547 (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) { in ath_tx_sched_aggr()
1548 __skb_queue_tail(&tid->retry_q, bf->bf_mpdu); in ath_tx_sched_aggr()
1549 return -EBUSY; in ath_tx_sched_aggr()
1552 ath_set_rates(tid->an->vif, tid->an->sta, bf); in ath_tx_sched_aggr()
1559 return -EAGAIN; in ath_tx_sched_aggr()
1561 if (tid->clear_ps_filter || tid->an->no_ps_filter) { in ath_tx_sched_aggr()
1562 tid->clear_ps_filter = false; in ath_tx_sched_aggr()
1563 tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ath_tx_sched_aggr()
1574 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_tx_aggr_start()
1582 an = (struct ath_node *)sta->drv_priv; in ath_tx_aggr_start()
1584 txq = txtid->txq; in ath_tx_aggr_start()
1589 * in HT IBSS when a beacon with HT-info is received after the station in ath_tx_aggr_start()
1592 if (sta->deflink.ht_cap.ht_supported) { in ath_tx_aggr_start()
1593 an->maxampdu = (1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + in ath_tx_aggr_start()
1594 sta->deflink.ht_cap.ampdu_factor)) - 1; in ath_tx_aggr_start()
1595 density = ath9k_parse_mpdudensity(sta->deflink.ht_cap.ampdu_density); in ath_tx_aggr_start()
1596 an->mpdudensity = density; in ath_tx_aggr_start()
1599 txtid->active = true; in ath_tx_aggr_start()
1600 *ssn = txtid->seq_start = txtid->seq_next; in ath_tx_aggr_start()
1601 txtid->bar_index = -1; in ath_tx_aggr_start()
1603 memset(txtid->tx_buf, 0, sizeof(txtid->tx_buf)); in ath_tx_aggr_start()
1604 txtid->baw_head = txtid->baw_tail = 0; in ath_tx_aggr_start()
1613 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_tx_aggr_stop()
1614 struct ath_node *an = (struct ath_node *)sta->drv_priv; in ath_tx_aggr_stop()
1616 struct ath_txq *txq = txtid->txq; in ath_tx_aggr_stop()
1621 txtid->active = false; in ath_tx_aggr_stop()
1629 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_tx_aggr_sleep()
1638 if (!skb_queue_empty(&tid->retry_q)) in ath_tx_aggr_sleep()
1639 ieee80211_sta_set_buffered(sta, tid->tidno, true); in ath_tx_aggr_sleep()
1646 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_tx_aggr_wakeup()
1655 txq = tid->txq; in ath_tx_aggr_wakeup()
1658 tid->clear_ps_filter = true; in ath_tx_aggr_wakeup()
1659 if (!skb_queue_empty(&tid->retry_q)) { in ath_tx_aggr_wakeup()
1682 hdr = (struct ieee80211_hdr *) bf->bf_mpdu->data; in ath9k_set_moredata()
1683 if ((hdr->frame_control & mask) != mask_val) { in ath9k_set_moredata()
1684 hdr->frame_control = (hdr->frame_control & ~mask) | mask_val; in ath9k_set_moredata()
1685 dma_sync_single_for_device(sc->dev, bf->bf_buf_addr, in ath9k_set_moredata()
1696 struct ath_softc *sc = hw->priv; in ath9k_release_buffered_frames()
1697 struct ath_node *an = (struct ath_node *)sta->drv_priv; in ath9k_release_buffered_frames()
1698 struct ath_txq *txq = sc->tx.uapsdq; in ath9k_release_buffered_frames()
1713 ath_txq_lock(sc, tid->txq); in ath9k_release_buffered_frames()
1715 ret = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, in ath9k_release_buffered_frames()
1721 list_add_tail(&bf->list, &bf_q); in ath9k_release_buffered_frames()
1722 ath_set_rates(tid->an->vif, tid->an->sta, bf); in ath9k_release_buffered_frames()
1724 bf->bf_state.bf_type &= ~BUF_AGGR; in ath9k_release_buffered_frames()
1726 bf_tail->bf_next = bf; in ath9k_release_buffered_frames()
1729 nframes--; in ath9k_release_buffered_frames()
1730 TX_STAT_INC(sc, txq->axq_qnum, a_queued_hw); in ath9k_release_buffered_frames()
1732 if (an->sta && skb_queue_empty(&tid->retry_q)) in ath9k_release_buffered_frames()
1733 ieee80211_sta_set_buffered(an->sta, i, false); in ath9k_release_buffered_frames()
1735 ath_txq_unlock_complete(sc, tid->txq); in ath9k_release_buffered_frames()
1744 info = IEEE80211_SKB_CB(bf_tail->bf_mpdu); in ath9k_release_buffered_frames()
1745 info->flags |= IEEE80211_TX_STATUS_EOSP; in ath9k_release_buffered_frames()
1760 struct ath_hw *ah = sc->sc_ah; in ath_txq_setup()
1789 * The UAPSD queue is an exception, since we take a desc- in ath_txq_setup()
1792 if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { in ath_txq_setup()
1802 if (axq_qnum == -1) { in ath_txq_setup()
1810 struct ath_txq *txq = &sc->tx.txq[axq_qnum]; in ath_txq_setup()
1812 txq->axq_qnum = axq_qnum; in ath_txq_setup()
1813 txq->mac80211_qnum = -1; in ath_txq_setup()
1814 txq->axq_link = NULL; in ath_txq_setup()
1815 __skb_queue_head_init(&txq->complete_q); in ath_txq_setup()
1816 INIT_LIST_HEAD(&txq->axq_q); in ath_txq_setup()
1817 spin_lock_init(&txq->axq_lock); in ath_txq_setup()
1818 txq->axq_depth = 0; in ath_txq_setup()
1819 txq->axq_ampdu_depth = 0; in ath_txq_setup()
1820 txq->axq_tx_inprogress = false; in ath_txq_setup()
1821 sc->tx.txqsetup |= 1<<axq_qnum; in ath_txq_setup()
1823 txq->txq_headidx = txq->txq_tailidx = 0; in ath_txq_setup()
1825 INIT_LIST_HEAD(&txq->txq_fifo[i]); in ath_txq_setup()
1827 return &sc->tx.txq[axq_qnum]; in ath_txq_setup()
1833 struct ath_hw *ah = sc->sc_ah; in ath_txq_update()
1837 BUG_ON(sc->tx.txq[qnum].axq_qnum != qnum); in ath_txq_update()
1840 qi.tqi_aifs = qinfo->tqi_aifs; in ath_txq_update()
1841 qi.tqi_cwmin = qinfo->tqi_cwmin; in ath_txq_update()
1842 qi.tqi_cwmax = qinfo->tqi_cwmax; in ath_txq_update()
1843 qi.tqi_burstTime = qinfo->tqi_burstTime; in ath_txq_update()
1844 qi.tqi_readyTime = qinfo->tqi_readyTime; in ath_txq_update()
1847 ath_err(ath9k_hw_common(sc->sc_ah), in ath_txq_update()
1849 error = -EIO; in ath_txq_update()
1860 struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon; in ath_cabq_update()
1861 int qnum = sc->beacon.cabq->axq_qnum; in ath_cabq_update()
1863 ath9k_hw_get_txq_props(sc->sc_ah, qnum, &qi); in ath_cabq_update()
1865 qi.tqi_readyTime = (TU_TO_USEC(cur_conf->beacon_interval) * in ath_cabq_update()
1886 if (bf->bf_state.stale) { in ath_drain_txq_list()
1887 list_del(&bf->list); in ath_drain_txq_list()
1893 lastbf = bf->bf_lastbf; in ath_drain_txq_list()
1894 list_cut_position(&bf_head, list, &lastbf->list); in ath_drain_txq_list()
1910 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { in ath_draintxq()
1911 int idx = txq->txq_tailidx; in ath_draintxq()
1913 while (!list_empty(&txq->txq_fifo[idx])) { in ath_draintxq()
1914 ath_drain_txq_list(sc, txq, &txq->txq_fifo[idx]); in ath_draintxq()
1918 txq->txq_tailidx = idx; in ath_draintxq()
1921 txq->axq_link = NULL; in ath_draintxq()
1922 txq->axq_tx_inprogress = false; in ath_draintxq()
1923 ath_drain_txq_list(sc, txq, &txq->axq_q); in ath_draintxq()
1931 struct ath_hw *ah = sc->sc_ah; in ath_drain_all_txq()
1932 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_drain_all_txq()
1937 if (test_bit(ATH_OP_INVALID, &common->op_flags)) in ath_drain_all_txq()
1947 if (!sc->tx.txq[i].axq_depth) in ath_drain_all_txq()
1950 if (ath9k_hw_numtxpending(ah, sc->tx.txq[i].axq_qnum)) in ath_drain_all_txq()
1964 txq = &sc->tx.txq[i]; in ath_drain_all_txq()
1973 ath9k_hw_releasetxqueue(sc->sc_ah, txq->axq_qnum); in ath_tx_cleanupq()
1974 sc->tx.txqsetup &= ~(1<<txq->axq_qnum); in ath_tx_cleanupq()
1982 struct ieee80211_hw *hw = sc->hw; in ath_txq_schedule()
1983 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_txq_schedule()
1988 if (txq->mac80211_qnum < 0) in ath_txq_schedule()
1991 if (test_bit(ATH_OP_HW_RESET, &common->op_flags)) in ath_txq_schedule()
1994 ieee80211_txq_schedule_start(hw, txq->mac80211_qnum); in ath_txq_schedule()
1995 spin_lock_bh(&sc->chan_lock); in ath_txq_schedule()
1998 if (sc->cur_chan->stopped) in ath_txq_schedule()
2001 while ((queue = ieee80211_next_txq(hw, txq->mac80211_qnum))) { in ath_txq_schedule()
2004 tid = (struct ath_atx_tid *)queue->drv_priv; in ath_txq_schedule()
2009 force = !skb_queue_empty(&tid->retry_q); in ath_txq_schedule()
2015 spin_unlock_bh(&sc->chan_lock); in ath_txq_schedule()
2016 ieee80211_txq_schedule_end(hw, txq->mac80211_qnum); in ath_txq_schedule()
2025 txq = sc->tx.txq_map[i]; in ath_txq_schedule_all()
2027 spin_lock_bh(&txq->axq_lock); in ath_txq_schedule_all()
2029 spin_unlock_bh(&txq->axq_lock); in ath_txq_schedule_all()
2044 struct ath_hw *ah = sc->sc_ah; in ath_tx_txqaddbuf()
2048 bool edma; in ath_tx_txqaddbuf() local
2058 edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA); in ath_tx_txqaddbuf()
2060 bf_last = list_entry(head->prev, struct ath_buf, list); in ath_tx_txqaddbuf()
2063 txq->axq_qnum, txq->axq_depth); in ath_tx_txqaddbuf()
2065 if (edma && list_empty(&txq->txq_fifo[txq->txq_headidx])) { in ath_tx_txqaddbuf()
2066 list_splice_tail_init(head, &txq->txq_fifo[txq->txq_headidx]); in ath_tx_txqaddbuf()
2067 INCR(txq->txq_headidx, ATH_TXFIFO_DEPTH); in ath_tx_txqaddbuf()
2070 list_splice_tail_init(head, &txq->axq_q); in ath_tx_txqaddbuf()
2072 if (txq->axq_link) { in ath_tx_txqaddbuf()
2073 ath9k_hw_set_desc_link(ah, txq->axq_link, bf->bf_daddr); in ath_tx_txqaddbuf()
2075 txq->axq_qnum, txq->axq_link, in ath_tx_txqaddbuf()
2076 ito64(bf->bf_daddr), bf->bf_desc); in ath_tx_txqaddbuf()
2077 } else if (!edma) in ath_tx_txqaddbuf()
2080 txq->axq_link = bf_last->bf_desc; in ath_tx_txqaddbuf()
2084 TX_STAT_INC(sc, txq->axq_qnum, puttxbuf); in ath_tx_txqaddbuf()
2085 ath9k_hw_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr); in ath_tx_txqaddbuf()
2087 txq->axq_qnum, ito64(bf->bf_daddr), bf->bf_desc); in ath_tx_txqaddbuf()
2090 if (!edma || sc->tx99_state) { in ath_tx_txqaddbuf()
2091 TX_STAT_INC(sc, txq->axq_qnum, txstart); in ath_tx_txqaddbuf()
2092 ath9k_hw_txstart(ah, txq->axq_qnum); in ath_tx_txqaddbuf()
2097 txq->axq_depth++; in ath_tx_txqaddbuf()
2099 txq->axq_ampdu_depth++; in ath_tx_txqaddbuf()
2101 bf_last = bf->bf_lastbf; in ath_tx_txqaddbuf()
2102 bf = bf_last->bf_next; in ath_tx_txqaddbuf()
2103 bf_last->bf_next = NULL; in ath_tx_txqaddbuf()
2114 struct ath_buf *bf = fi->bf; in ath_tx_send_normal()
2117 list_add_tail(&bf->list, &bf_head); in ath_tx_send_normal()
2118 bf->bf_state.bf_type = 0; in ath_tx_send_normal()
2119 if (tid && (tx_info->flags & IEEE80211_TX_CTL_AMPDU)) { in ath_tx_send_normal()
2120 bf->bf_state.bf_type = BUF_AMPDU; in ath_tx_send_normal()
2124 bf->bf_next = NULL; in ath_tx_send_normal()
2125 bf->bf_lastbf = bf; in ath_tx_send_normal()
2126 ath_tx_fill_desc(sc, bf, txq, fi->framelen); in ath_tx_send_normal()
2128 TX_STAT_INC(sc, txq->axq_qnum, queued); in ath_tx_send_normal()
2137 struct ieee80211_key_conf *hw_key = tx_info->control.hw_key; in setup_frame_info()
2138 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in setup_frame_info()
2151 if (tx_info->control.vif && in setup_frame_info()
2152 tx_info->control.vif->bss_conf.use_short_preamble) in setup_frame_info()
2159 an = (struct ath_node *) sta->drv_priv; in setup_frame_info()
2161 if (tx_info->control.vif) { in setup_frame_info()
2162 struct ieee80211_vif *vif = tx_info->control.vif; in setup_frame_info()
2163 if (vif->bss_conf.txpower == INT_MIN) in setup_frame_info()
2165 txpower = 2 * vif->bss_conf.txpower; in setup_frame_info()
2169 sc = hw->priv; in setup_frame_info()
2171 txpower = sc->cur_chan->cur_txpower; in setup_frame_info()
2175 fi->txq = -1; in setup_frame_info()
2177 fi->keyix = hw_key->hw_key_idx; in setup_frame_info()
2178 else if (an && ieee80211_is_data(hdr->frame_control) && an->ps_key > 0) in setup_frame_info()
2179 fi->keyix = an->ps_key; in setup_frame_info()
2181 fi->keyix = ATH9K_TXKEYIX_INVALID; in setup_frame_info()
2182 fi->dyn_smps = sta && sta->deflink.smps_mode == IEEE80211_SMPS_DYNAMIC; in setup_frame_info()
2183 fi->keytype = keytype; in setup_frame_info()
2184 fi->framelen = framelen; in setup_frame_info()
2185 fi->tx_power = txpower; in setup_frame_info()
2189 fi->rtscts_rate = rate->hw_value; in setup_frame_info()
2191 fi->rtscts_rate |= rate->hw_value_short; in setup_frame_info()
2196 struct ath_hw *ah = sc->sc_ah; in ath_txchainmask_reduction()
2197 struct ath9k_channel *curchan = ah->curchan; in ath_txchainmask_reduction()
2199 if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) && IS_CHAN_5GHZ(curchan) && in ath_txchainmask_reduction()
2218 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_tx_setup_buffer()
2220 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ath_tx_setup_buffer()
2233 if (tid && ieee80211_is_data_present(hdr->frame_control)) { in ath_tx_setup_buffer()
2234 fragno = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG; in ath_tx_setup_buffer()
2235 seqno = tid->seq_next; in ath_tx_setup_buffer()
2236 hdr->seq_ctrl = cpu_to_le16(tid->seq_next << IEEE80211_SEQ_SEQ_SHIFT); in ath_tx_setup_buffer()
2239 hdr->seq_ctrl |= cpu_to_le16(fragno); in ath_tx_setup_buffer()
2241 if (!ieee80211_has_morefrags(hdr->frame_control)) in ath_tx_setup_buffer()
2242 INCR(tid->seq_next, IEEE80211_SEQ_MAX); in ath_tx_setup_buffer()
2244 bf->bf_state.seqno = seqno; in ath_tx_setup_buffer()
2247 bf->bf_mpdu = skb; in ath_tx_setup_buffer()
2249 bf->bf_buf_addr = dma_map_single(sc->dev, skb->data, in ath_tx_setup_buffer()
2250 skb->len, DMA_TO_DEVICE); in ath_tx_setup_buffer()
2251 if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) { in ath_tx_setup_buffer()
2252 bf->bf_mpdu = NULL; in ath_tx_setup_buffer()
2253 bf->bf_buf_addr = 0; in ath_tx_setup_buffer()
2254 ath_err(ath9k_hw_common(sc->sc_ah), in ath_tx_setup_buffer()
2260 fi->bf = bf; in ath_tx_setup_buffer()
2267 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ath_assign_seq()
2269 struct ieee80211_vif *vif = info->control.vif; in ath_assign_seq()
2272 if (!(info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)) in ath_assign_seq()
2278 avp = (struct ath_vif *)vif->drv_priv; in ath_assign_seq()
2280 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) in ath_assign_seq()
2281 avp->seq_no += 0x10; in ath_assign_seq()
2283 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); in ath_assign_seq()
2284 hdr->seq_ctrl |= cpu_to_le16(avp->seq_no); in ath_assign_seq()
2290 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ath_tx_prepare()
2292 struct ieee80211_sta *sta = txctl->sta; in ath_tx_prepare()
2293 struct ieee80211_vif *vif = info->control.vif; in ath_tx_prepare()
2294 struct ath_softc *sc = hw->priv; in ath_tx_prepare()
2295 int frmlen = skb->len + FCS_LEN; in ath_tx_prepare()
2298 if (info->control.hw_key) in ath_tx_prepare()
2299 frmlen += info->control.hw_key->icv_len; in ath_tx_prepare()
2301 ath_assign_seq(ath9k_hw_common(sc->sc_ah), skb); in ath_tx_prepare()
2303 if ((vif && vif->type != NL80211_IFTYPE_AP && in ath_tx_prepare()
2304 vif->type != NL80211_IFTYPE_AP_VLAN) || in ath_tx_prepare()
2305 !ieee80211_is_data(hdr->frame_control)) in ath_tx_prepare()
2306 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ath_tx_prepare()
2309 padpos = ieee80211_hdrlen(hdr->frame_control); in ath_tx_prepare()
2311 if (padsize && skb->len > padpos) { in ath_tx_prepare()
2313 return -ENOMEM; in ath_tx_prepare()
2316 memmove(skb->data, skb->data + padsize, padpos); in ath_tx_prepare()
2329 struct ieee80211_sta *sta = txctl->sta; in ath_tx_start()
2330 struct ieee80211_vif *vif = info->control.vif; in ath_tx_start()
2332 struct ath_softc *sc = hw->priv; in ath_tx_start()
2333 struct ath_txq *txq = txctl->txq; in ath_tx_start()
2340 ps_resp = !!(info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE); in ath_tx_start()
2354 txq = sc->tx.uapsdq; in ath_tx_start()
2356 if (txctl->sta) { in ath_tx_start()
2357 an = (struct ath_node *) sta->drv_priv; in ath_tx_start()
2362 if (txq == sc->tx.txq_map[q]) { in ath_tx_start()
2363 fi->txq = q; in ath_tx_start()
2364 ++txq->pending_frames; in ath_tx_start()
2370 if (txctl->paprd) in ath_tx_start()
2373 ieee80211_free_txskb(sc->hw, skb); in ath_tx_start()
2377 bf->bf_state.bfs_paprd = txctl->paprd; in ath_tx_start()
2379 if (txctl->paprd) in ath_tx_start()
2380 bf->bf_state.bfs_paprd_timestamp = jiffies; in ath_tx_start()
2394 struct ath_softc *sc = hw->priv; in ath_tx_cabq()
2396 .txq = sc->beacon.cabq in ath_tx_cabq()
2406 sc->cur_chan->beacon.beacon_interval * 1000 * in ath_tx_cabq()
2407 sc->cur_chan->beacon.dtim_period / ATH_BCBUF; in ath_tx_cabq()
2419 bf->bf_lastbf = bf; in ath_tx_cabq()
2421 ath_buf_set_rate(sc, bf, &info, fi->framelen, false); in ath_tx_cabq()
2424 bf_tail->bf_next = bf; in ath_tx_cabq()
2426 list_add_tail(&bf->list, &bf_q); in ath_tx_cabq()
2449 TX_STAT_INC(sc, txctl.txq->axq_qnum, queued); in ath_tx_cabq()
2462 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_tx_complete()
2463 struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data; in ath_tx_complete()
2469 if (sc->sc_ah->caldata) in ath_tx_complete()
2470 set_bit(PAPRD_PACKET_SENT, &sc->sc_ah->caldata->cal_flags); in ath_tx_complete()
2473 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) in ath_tx_complete()
2474 tx_info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED; in ath_tx_complete()
2476 tx_info->flags |= IEEE80211_TX_STAT_ACK; in ath_tx_complete()
2479 if (tx_info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) { in ath_tx_complete()
2480 padpos = ieee80211_hdrlen(hdr->frame_control); in ath_tx_complete()
2482 if (padsize && skb->len>padpos+padsize) { in ath_tx_complete()
2487 memmove(skb->data + padsize, skb->data, padpos); in ath_tx_complete()
2492 spin_lock_irqsave(&sc->sc_pm_lock, flags); in ath_tx_complete()
2493 if ((sc->ps_flags & PS_WAIT_FOR_TX_ACK) && !txq->axq_depth) { in ath_tx_complete()
2494 sc->ps_flags &= ~PS_WAIT_FOR_TX_ACK; in ath_tx_complete()
2497 sc->ps_flags & (PS_WAIT_FOR_BEACON | in ath_tx_complete()
2502 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); in ath_tx_complete()
2505 tx_info->status.status_driver_data[0] = sta; in ath_tx_complete()
2506 __skb_queue_tail(&txq->complete_q, skb); in ath_tx_complete()
2514 struct sk_buff *skb = bf->bf_mpdu; in ath_tx_complete_buf()
2522 if (ts->ts_status & ATH9K_TXERR_FILT) in ath_tx_complete_buf()
2523 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED; in ath_tx_complete_buf()
2525 dma_unmap_single(sc->dev, bf->bf_buf_addr, skb->len, DMA_TO_DEVICE); in ath_tx_complete_buf()
2526 bf->bf_buf_addr = 0; in ath_tx_complete_buf()
2527 if (sc->tx99_state) in ath_tx_complete_buf()
2530 if (bf->bf_state.bfs_paprd) { in ath_tx_complete_buf()
2532 bf->bf_state.bfs_paprd_timestamp + in ath_tx_complete_buf()
2536 complete(&sc->paprd_complete); in ath_tx_complete_buf()
2542 /* At this point, skb (bf->bf_mpdu) is consumed...make sure we don't in ath_tx_complete_buf()
2545 bf->bf_mpdu = NULL; in ath_tx_complete_buf()
2550 spin_lock_irqsave(&sc->tx.txbuflock, flags); in ath_tx_complete_buf()
2551 list_splice_tail_init(bf_q, &sc->tx.txbuf); in ath_tx_complete_buf()
2552 spin_unlock_irqrestore(&sc->tx.txbuflock, flags); in ath_tx_complete_buf()
2557 void *ptr = &tx_info->status; in ath_clear_tx_status()
2559 memset(ptr + sizeof(tx_info->status.rates), 0, in ath_clear_tx_status()
2560 sizeof(tx_info->status) - in ath_clear_tx_status()
2561 sizeof(tx_info->status.rates) - in ath_clear_tx_status()
2562 sizeof(tx_info->status.status_driver_data)); in ath_clear_tx_status()
2569 struct sk_buff *skb = bf->bf_mpdu; in ath_tx_rc_status()
2570 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ath_tx_rc_status()
2572 struct ieee80211_hw *hw = sc->hw; in ath_tx_rc_status()
2573 struct ath_hw *ah = sc->sc_ah; in ath_tx_rc_status()
2579 tx_info->status.ack_signal = ts->ts_rssi; in ath_tx_rc_status()
2581 tx_rateindex = ts->ts_rateindex; in ath_tx_rc_status()
2582 WARN_ON(tx_rateindex >= hw->max_rates); in ath_tx_rc_status()
2584 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { in ath_tx_rc_status()
2585 tx_info->flags |= IEEE80211_TX_STAT_AMPDU; in ath_tx_rc_status()
2589 tx_info->status.ampdu_len = nframes; in ath_tx_rc_status()
2590 tx_info->status.ampdu_ack_len = nframes - nbad; in ath_tx_rc_status()
2592 tx_info->status.rates[tx_rateindex].count = ts->ts_longretry + 1; in ath_tx_rc_status()
2594 for (i = tx_rateindex + 1; i < hw->max_rates; i++) { in ath_tx_rc_status()
2595 tx_info->status.rates[i].count = 0; in ath_tx_rc_status()
2596 tx_info->status.rates[i].idx = -1; in ath_tx_rc_status()
2599 if ((ts->ts_status & ATH9K_TXERR_FILT) == 0 && in ath_tx_rc_status()
2600 (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) == 0) { in ath_tx_rc_status()
2606 * hw->max_rate_tries times to affect how rate control updates in ath_tx_rc_status()
2613 if (unlikely(ts->ts_flags & (ATH9K_TX_DATA_UNDERRUN | in ath_tx_rc_status()
2615 ieee80211_is_data(hdr->frame_control) && in ath_tx_rc_status()
2616 ah->tx_trig_level >= sc->sc_ah->config.max_txtrig_level) in ath_tx_rc_status()
2617 tx_info->status.rates[tx_rateindex].count = in ath_tx_rc_status()
2618 hw->max_rate_tries; in ath_tx_rc_status()
2624 struct ath_hw *ah = sc->sc_ah; in ath_tx_processq()
2633 txq->axq_qnum, ath9k_hw_gettxbuf(sc->sc_ah, txq->axq_qnum), in ath_tx_processq()
2634 txq->axq_link); in ath_tx_processq()
2638 if (test_bit(ATH_OP_HW_RESET, &common->op_flags)) in ath_tx_processq()
2641 if (list_empty(&txq->axq_q)) { in ath_tx_processq()
2642 txq->axq_link = NULL; in ath_tx_processq()
2646 bf = list_first_entry(&txq->axq_q, struct ath_buf, list); in ath_tx_processq()
2650 * after sw writes TxE and before hw re-load the last in ath_tx_processq()
2653 * holding descriptor - software does so by marking in ath_tx_processq()
2657 if (bf->bf_state.stale) { in ath_tx_processq()
2659 if (list_is_last(&bf_held->list, &txq->axq_q)) in ath_tx_processq()
2662 bf = list_entry(bf_held->list.next, struct ath_buf, in ath_tx_processq()
2666 lastbf = bf->bf_lastbf; in ath_tx_processq()
2667 ds = lastbf->bf_desc; in ath_tx_processq()
2671 if (status == -EINPROGRESS) in ath_tx_processq()
2674 TX_STAT_INC(sc, txq->axq_qnum, txprocdesc); in ath_tx_processq()
2681 lastbf->bf_state.stale = true; in ath_tx_processq()
2683 if (!list_is_singular(&lastbf->list)) in ath_tx_processq()
2685 &txq->axq_q, lastbf->list.prev); in ath_tx_processq()
2688 list_del(&bf_held->list); in ath_tx_processq()
2699 struct ath_hw *ah = sc->sc_ah; in ath_tx_tasklet()
2700 u32 qcumask = ((1 << ATH9K_NUM_TX_QUEUES) - 1) & ah->intr_txqs; in ath_tx_tasklet()
2706 ath_tx_processq(sc, &sc->tx.txq[i]); in ath_tx_tasklet()
2714 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_tx_edma_tasklet()
2715 struct ath_hw *ah = sc->sc_ah; in ath_tx_edma_tasklet()
2724 if (test_bit(ATH_OP_HW_RESET, &common->op_flags)) in ath_tx_edma_tasklet()
2728 if (status == -EINPROGRESS) in ath_tx_edma_tasklet()
2730 if (status == -EIO) { in ath_tx_edma_tasklet()
2736 if (ts.qid == sc->beacon.beaconq) { in ath_tx_edma_tasklet()
2737 sc->beacon.tx_processed = true; in ath_tx_edma_tasklet()
2738 sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK); in ath_tx_edma_tasklet()
2749 txq = &sc->tx.txq[ts.qid]; in ath_tx_edma_tasklet()
2753 TX_STAT_INC(sc, txq->axq_qnum, txprocdesc); in ath_tx_edma_tasklet()
2755 fifo_list = &txq->txq_fifo[txq->txq_tailidx]; in ath_tx_edma_tasklet()
2762 if (bf->bf_state.stale) { in ath_tx_edma_tasklet()
2763 list_del(&bf->list); in ath_tx_edma_tasklet()
2768 lastbf = bf->bf_lastbf; in ath_tx_edma_tasklet()
2771 if (list_is_last(&lastbf->list, fifo_list)) { in ath_tx_edma_tasklet()
2773 INCR(txq->txq_tailidx, ATH_TXFIFO_DEPTH); in ath_tx_edma_tasklet()
2775 if (!list_empty(&txq->axq_q)) { in ath_tx_edma_tasklet()
2779 txq->axq_link = NULL; in ath_tx_edma_tasklet()
2780 list_splice_tail_init(&txq->axq_q, &bf_q); in ath_tx_edma_tasklet()
2784 lastbf->bf_state.stale = true; in ath_tx_edma_tasklet()
2787 lastbf->list.prev); in ath_tx_edma_tasklet()
2802 struct ath_descdma *dd = &sc->txsdma; in ath_txstatus_setup()
2803 u8 txs_len = sc->sc_ah->caps.txs_len; in ath_txstatus_setup()
2805 dd->dd_desc_len = size * txs_len; in ath_txstatus_setup()
2806 dd->dd_desc = dmam_alloc_coherent(sc->dev, dd->dd_desc_len, in ath_txstatus_setup()
2807 &dd->dd_desc_paddr, GFP_KERNEL); in ath_txstatus_setup()
2808 if (!dd->dd_desc) in ath_txstatus_setup()
2809 return -ENOMEM; in ath_txstatus_setup()
2816 int err; in ath_tx_edma_init() local
2818 err = ath_txstatus_setup(sc, ATH_TXSTATUS_RING_SIZE); in ath_tx_edma_init()
2819 if (!err) in ath_tx_edma_init()
2820 ath9k_hw_setup_statusring(sc->sc_ah, sc->txsdma.dd_desc, in ath_tx_edma_init()
2821 sc->txsdma.dd_desc_paddr, in ath_tx_edma_init()
2824 return err; in ath_tx_edma_init()
2829 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_tx_init()
2832 spin_lock_init(&sc->tx.txbuflock); in ath_tx_init()
2834 error = ath_descdma_setup(sc, &sc->tx.txdma, &sc->tx.txbuf, in ath_tx_init()
2842 error = ath_descdma_setup(sc, &sc->beacon.bdma, &sc->beacon.bbuf, in ath_tx_init()
2850 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) in ath_tx_init()
2863 tid->an = an; in ath_tx_node_init()
2864 tid->tidno = tidno; in ath_tx_node_init()
2865 tid->seq_start = tid->seq_next = 0; in ath_tx_node_init()
2866 tid->baw_size = WME_MAX_BA; in ath_tx_node_init()
2867 tid->baw_head = tid->baw_tail = 0; in ath_tx_node_init()
2868 tid->active = false; in ath_tx_node_init()
2869 tid->clear_ps_filter = true; in ath_tx_node_init()
2870 __skb_queue_head_init(&tid->retry_q); in ath_tx_node_init()
2871 INIT_LIST_HEAD(&tid->list); in ath_tx_node_init()
2873 tid->txq = sc->tx.txq_map[acno]; in ath_tx_node_init()
2875 if (!an->sta) in ath_tx_node_init()
2890 txq = tid->txq; in ath_tx_node_cleanup()
2894 if (!list_empty(&tid->list)) in ath_tx_node_cleanup()
2895 list_del_init(&tid->list); in ath_tx_node_cleanup()
2898 tid->active = false; in ath_tx_node_cleanup()
2902 if (!an->sta) in ath_tx_node_cleanup()
2914 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ath9k_tx99_send()
2916 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_tx99_send()
2920 padpos = ieee80211_hdrlen(hdr->frame_control); in ath9k_tx99_send()
2923 if (padsize && skb->len > padpos) { in ath9k_tx99_send()
2927 return -EINVAL; in ath9k_tx99_send()
2931 memmove(skb->data, skb->data + padsize, padpos); in ath9k_tx99_send()
2934 fi->keyix = ATH9K_TXKEYIX_INVALID; in ath9k_tx99_send()
2935 fi->framelen = skb->len + FCS_LEN; in ath9k_tx99_send()
2936 fi->keytype = ATH9K_KEY_TYPE_CLEAR; in ath9k_tx99_send()
2938 bf = ath_tx_setup_buffer(sc, txctl->txq, NULL, skb); in ath9k_tx99_send()
2941 return -EINVAL; in ath9k_tx99_send()
2944 ath_set_rates(sc->tx99_vif, NULL, bf); in ath9k_tx99_send()
2946 ath9k_hw_set_desc_link(sc->sc_ah, bf->bf_desc, bf->bf_daddr); in ath9k_tx99_send()
2947 ath9k_hw_tx99_start(sc->sc_ah, txctl->txq->axq_qnum); in ath9k_tx99_send()
2949 ath_tx_send_normal(sc, txctl->txq, NULL, skb); in ath9k_tx99_send()