Lines Matching +full:txpower +full:-
25 * Copyright (c) 2007-2008 Atheros Communications, Inc.
72 return (DIV_ROUND_UP(IEEE80211_MAX_FRAME_LEN, ar->fw.mem_block_size) > in is_mem_full()
73 atomic_read(&ar->mem_free_blocks)); in is_mem_full()
81 atomic_inc(&ar->tx_total_queued); in carl9170_tx_accounting()
84 spin_lock_bh(&ar->tx_stats_lock); in carl9170_tx_accounting()
92 ar->tx_stats[queue].len++; in carl9170_tx_accounting()
93 ar->tx_stats[queue].count++; in carl9170_tx_accounting()
96 for (i = 0; i < ar->hw->queues; i++) { in carl9170_tx_accounting()
97 if (mem_full || ar->tx_stats[i].len >= ar->tx_stats[i].limit) { in carl9170_tx_accounting()
98 ieee80211_stop_queue(ar->hw, i); in carl9170_tx_accounting()
99 ar->queue_stop_timeout[i] = jiffies; in carl9170_tx_accounting()
103 spin_unlock_bh(&ar->tx_stats_lock); in carl9170_tx_accounting()
110 struct _carl9170_tx_superframe *super = (void *) skb->data; in __carl9170_get_tx_sta()
111 struct ieee80211_hdr *hdr = (void *) super->frame_data; in __carl9170_get_tx_sta()
115 vif_id = (super->s.misc & CARL9170_TX_SUPER_MISC_VIF_ID) >> in __carl9170_get_tx_sta()
121 vif = rcu_dereference(ar->vif_priv[vif_id].vif); in __carl9170_get_tx_sta()
135 return ieee80211_find_sta(vif, hdr->addr1); in __carl9170_get_tx_sta()
148 sta_info = (struct carl9170_sta_info *) sta->drv_priv; in carl9170_tx_ps_unblock()
149 if (atomic_dec_return(&sta_info->pending_frames) == 0) in carl9170_tx_ps_unblock()
150 ieee80211_sta_block_awake(ar->hw, sta, false); in carl9170_tx_ps_unblock()
162 spin_lock_bh(&ar->tx_stats_lock); in carl9170_tx_accounting_free()
164 ar->tx_stats[queue].len--; in carl9170_tx_accounting_free()
168 for (i = 0; i < ar->hw->queues; i++) { in carl9170_tx_accounting_free()
169 if (ar->tx_stats[i].len >= CARL9170_NUM_TX_LIMIT_SOFT) in carl9170_tx_accounting_free()
172 if (ieee80211_queue_stopped(ar->hw, i)) { in carl9170_tx_accounting_free()
175 tmp = jiffies - ar->queue_stop_timeout[i]; in carl9170_tx_accounting_free()
176 if (tmp > ar->max_queue_stop_timeout[i]) in carl9170_tx_accounting_free()
177 ar->max_queue_stop_timeout[i] = tmp; in carl9170_tx_accounting_free()
180 ieee80211_wake_queue(ar->hw, i); in carl9170_tx_accounting_free()
184 spin_unlock_bh(&ar->tx_stats_lock); in carl9170_tx_accounting_free()
186 if (atomic_dec_and_test(&ar->tx_total_queued)) in carl9170_tx_accounting_free()
187 complete(&ar->tx_flush); in carl9170_tx_accounting_free()
192 struct _carl9170_tx_superframe *super = (void *) skb->data; in carl9170_alloc_dev_space()
194 int cookie = -1; in carl9170_alloc_dev_space()
196 atomic_inc(&ar->mem_allocs); in carl9170_alloc_dev_space()
198 chunks = DIV_ROUND_UP(skb->len, ar->fw.mem_block_size); in carl9170_alloc_dev_space()
199 if (unlikely(atomic_sub_return(chunks, &ar->mem_free_blocks) < 0)) { in carl9170_alloc_dev_space()
200 atomic_add(chunks, &ar->mem_free_blocks); in carl9170_alloc_dev_space()
201 return -ENOSPC; in carl9170_alloc_dev_space()
204 spin_lock_bh(&ar->mem_lock); in carl9170_alloc_dev_space()
205 cookie = bitmap_find_free_region(ar->mem_bitmap, ar->fw.mem_blocks, 0); in carl9170_alloc_dev_space()
206 spin_unlock_bh(&ar->mem_lock); in carl9170_alloc_dev_space()
209 atomic_add(chunks, &ar->mem_free_blocks); in carl9170_alloc_dev_space()
210 return -ENOSPC; in carl9170_alloc_dev_space()
213 super = (void *) skb->data; in carl9170_alloc_dev_space()
220 * 2. Prevent double-free bugs. in carl9170_alloc_dev_space()
222 super->s.cookie = (u8) cookie + 1; in carl9170_alloc_dev_space()
228 struct _carl9170_tx_superframe *super = (void *) skb->data; in carl9170_release_dev_space()
232 cookie = super->s.cookie; in carl9170_release_dev_space()
234 super->s.cookie = 0; in carl9170_release_dev_space()
237 * Do a out-of-bounds check on the cookie: in carl9170_release_dev_space()
240 * out-going frame. Internally however, it is used to in carl9170_release_dev_space()
241 * mark no longer/un-accounted frames and serves as a in carl9170_release_dev_space()
250 WARN_ON_ONCE(cookie > ar->fw.mem_blocks)) in carl9170_release_dev_space()
253 atomic_add(DIV_ROUND_UP(skb->len, ar->fw.mem_block_size), in carl9170_release_dev_space()
254 &ar->mem_free_blocks); in carl9170_release_dev_space()
256 spin_lock_bh(&ar->mem_lock); in carl9170_release_dev_space()
257 bitmap_release_region(ar->mem_bitmap, cookie - 1, 0); in carl9170_release_dev_space()
258 spin_unlock_bh(&ar->mem_lock); in carl9170_release_dev_space()
274 ar = arinfo->ar; in carl9170_tx_release()
283 memset_after(&txinfo->status, 0, rates); in carl9170_tx_release()
285 if (atomic_read(&ar->tx_total_queued)) in carl9170_tx_release()
286 ar->tx_schedule = true; in carl9170_tx_release()
288 if (txinfo->flags & IEEE80211_TX_CTL_AMPDU) { in carl9170_tx_release()
289 if (!atomic_read(&ar->tx_ampdu_upload)) in carl9170_tx_release()
290 ar->tx_ampdu_schedule = true; in carl9170_tx_release()
292 if (txinfo->flags & IEEE80211_TX_STAT_AMPDU) { in carl9170_tx_release()
295 super = (void *)skb->data; in carl9170_tx_release()
296 txinfo->status.ampdu_len = super->s.rix; in carl9170_tx_release()
297 txinfo->status.ampdu_ack_len = super->s.cnt; in carl9170_tx_release()
298 } else if ((txinfo->flags & IEEE80211_TX_STAT_ACK) && in carl9170_tx_release()
299 !(txinfo->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) { in carl9170_tx_release()
316 ieee80211_free_txskb(ar->hw, skb); in carl9170_tx_release()
327 ieee80211_tx_status_irqsafe(ar->hw, skb); in carl9170_tx_release()
333 (IEEE80211_SKB_CB(skb))->rate_driver_data; in carl9170_tx_get_skb()
334 kref_get(&arinfo->ref); in carl9170_tx_get_skb()
340 (IEEE80211_SKB_CB(skb))->rate_driver_data; in carl9170_tx_put_skb()
342 return kref_put(&arinfo->ref, carl9170_tx_release); in carl9170_tx_put_skb()
345 /* Caller must hold the tid_info->lock & rcu_read_lock */
351 off = SEQ_DIFF(seq, tid_info->bsn); in carl9170_tx_shift_bm()
362 WARN_ON_ONCE(!test_and_clear_bit(off, tid_info->bitmap)); in carl9170_tx_shift_bm()
364 off = SEQ_DIFF(tid_info->snx, tid_info->bsn); in carl9170_tx_shift_bm()
368 if (!bitmap_empty(tid_info->bitmap, off)) in carl9170_tx_shift_bm()
369 off = find_first_bit(tid_info->bitmap, off); in carl9170_tx_shift_bm()
371 tid_info->bsn += off; in carl9170_tx_shift_bm()
372 tid_info->bsn &= 0x0fff; in carl9170_tx_shift_bm()
374 bitmap_shift_right(tid_info->bitmap, tid_info->bitmap, in carl9170_tx_shift_bm()
381 struct _carl9170_tx_superframe *super = (void *) skb->data; in carl9170_tx_status_process_ampdu()
382 struct ieee80211_hdr *hdr = (void *) super->frame_data; in carl9170_tx_status_process_ampdu()
388 if (!(txinfo->flags & IEEE80211_TX_CTL_AMPDU) || in carl9170_tx_status_process_ampdu()
389 txinfo->flags & IEEE80211_TX_CTL_INJECTED) in carl9170_tx_status_process_ampdu()
399 sta_info = (void *) sta->drv_priv; in carl9170_tx_status_process_ampdu()
400 tid_info = rcu_dereference(sta_info->agg[tid]); in carl9170_tx_status_process_ampdu()
404 spin_lock_bh(&tid_info->lock); in carl9170_tx_status_process_ampdu()
405 if (likely(tid_info->state >= CARL9170_TID_STATE_IDLE)) in carl9170_tx_status_process_ampdu()
408 if (sta_info->stats[tid].clear) { in carl9170_tx_status_process_ampdu()
409 sta_info->stats[tid].clear = false; in carl9170_tx_status_process_ampdu()
410 sta_info->stats[tid].req = false; in carl9170_tx_status_process_ampdu()
411 sta_info->stats[tid].ampdu_len = 0; in carl9170_tx_status_process_ampdu()
412 sta_info->stats[tid].ampdu_ack_len = 0; in carl9170_tx_status_process_ampdu()
415 sta_info->stats[tid].ampdu_len++; in carl9170_tx_status_process_ampdu()
416 if (txinfo->status.rates[0].count == 1) in carl9170_tx_status_process_ampdu()
417 sta_info->stats[tid].ampdu_ack_len++; in carl9170_tx_status_process_ampdu()
419 if (!(txinfo->flags & IEEE80211_TX_STAT_ACK)) in carl9170_tx_status_process_ampdu()
420 sta_info->stats[tid].req = true; in carl9170_tx_status_process_ampdu()
422 if (super->f.mac_control & cpu_to_le16(AR9170_TX_MAC_IMM_BA)) { in carl9170_tx_status_process_ampdu()
423 super->s.rix = sta_info->stats[tid].ampdu_len; in carl9170_tx_status_process_ampdu()
424 super->s.cnt = sta_info->stats[tid].ampdu_ack_len; in carl9170_tx_status_process_ampdu()
425 txinfo->flags |= IEEE80211_TX_STAT_AMPDU; in carl9170_tx_status_process_ampdu()
426 if (sta_info->stats[tid].req) in carl9170_tx_status_process_ampdu()
427 txinfo->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; in carl9170_tx_status_process_ampdu()
429 sta_info->stats[tid].clear = true; in carl9170_tx_status_process_ampdu()
431 spin_unlock_bh(&tid_info->lock); in carl9170_tx_status_process_ampdu()
440 struct _carl9170_tx_superframe *super = (void *) skb->data; in carl9170_tx_bar_status()
441 struct ieee80211_bar *bar = (void *) super->frame_data; in carl9170_tx_bar_status()
447 * Instead the RX-path will scan for incoming BAs and set the in carl9170_tx_bar_status()
452 if (unlikely(ieee80211_is_back_req(bar->frame_control)) && in carl9170_tx_bar_status()
453 !(tx_info->flags & IEEE80211_TX_STAT_ACK)) { in carl9170_tx_bar_status()
458 list_for_each_entry_rcu(entry, &ar->bar_list[queue], list) { in carl9170_tx_bar_status()
459 if (entry->skb == skb) { in carl9170_tx_bar_status()
460 spin_lock_bh(&ar->bar_list_lock[queue]); in carl9170_tx_bar_status()
461 list_del_rcu(&entry->list); in carl9170_tx_bar_status()
462 spin_unlock_bh(&ar->bar_list_lock[queue]); in carl9170_tx_bar_status()
468 WARN(1, "bar not found in %d - ra:%pM ta:%pM c:%x ssn:%x\n", in carl9170_tx_bar_status()
469 queue, bar->ra, bar->ta, bar->control, in carl9170_tx_bar_status()
470 bar->start_seq_num); in carl9170_tx_bar_status()
488 txinfo->flags |= IEEE80211_TX_STAT_ACK; in carl9170_tx_status()
490 ar->tx_ack_failures++; in carl9170_tx_status()
492 if (txinfo->flags & IEEE80211_TX_CTL_AMPDU) in carl9170_tx_status()
504 atomic_dec(&ar->tx_total_pending); in carl9170_tx_callback()
506 if (txinfo->flags & IEEE80211_TX_CTL_AMPDU) in carl9170_tx_callback()
507 atomic_dec(&ar->tx_ampdu_upload); in carl9170_tx_callback()
510 tasklet_hi_schedule(&ar->usb_tasklet); in carl9170_tx_callback()
518 spin_lock_bh(&queue->lock); in carl9170_get_queued_skb()
520 struct _carl9170_tx_superframe *txc = (void *) skb->data; in carl9170_get_queued_skb()
522 if (txc->s.cookie != cookie) in carl9170_get_queued_skb()
526 spin_unlock_bh(&queue->lock); in carl9170_get_queued_skb()
531 spin_unlock_bh(&queue->lock); in carl9170_get_queued_skb()
542 if (txinfo->status.rates[i].idx < 0) in carl9170_tx_fill_rateinfo()
546 txinfo->status.rates[i].count = tries; in carl9170_tx_fill_rateinfo()
553 txinfo->status.rates[i].idx = -1; in carl9170_tx_fill_rateinfo()
554 txinfo->status.rates[i].count = 0; in carl9170_tx_fill_rateinfo()
566 for (i = 0; i < ar->hw->queues; i++) { in carl9170_check_queue_stop_timeout()
567 spin_lock_bh(&ar->tx_status[i].lock); in carl9170_check_queue_stop_timeout()
569 skb = skb_peek(&ar->tx_status[i]); in carl9170_check_queue_stop_timeout()
575 arinfo = (void *) txinfo->rate_driver_data; in carl9170_check_queue_stop_timeout()
577 if (time_is_before_jiffies(arinfo->timeout + in carl9170_check_queue_stop_timeout()
582 spin_unlock_bh(&ar->tx_status[i].lock); in carl9170_check_queue_stop_timeout()
592 * - frames got lost/corrupted (bad connection to the device) in carl9170_check_queue_stop_timeout()
593 * - stalled rx processing/usb controller hiccups in carl9170_check_queue_stop_timeout()
594 * - firmware errors/bugs in carl9170_check_queue_stop_timeout()
595 * - every bug you can think of. in carl9170_check_queue_stop_timeout()
596 * - all bugs you can't... in carl9170_check_queue_stop_timeout()
597 * - ... in carl9170_check_queue_stop_timeout()
612 list_for_each_entry_rcu(iter, &ar->tx_ampdu_list, list) { in carl9170_tx_ampdu_timeout()
613 if (iter->state < CARL9170_TID_STATE_IDLE) in carl9170_tx_ampdu_timeout()
616 spin_lock_bh(&iter->lock); in carl9170_tx_ampdu_timeout()
617 skb = skb_peek(&iter->queue); in carl9170_tx_ampdu_timeout()
622 arinfo = (void *)txinfo->rate_driver_data; in carl9170_tx_ampdu_timeout()
623 if (time_is_after_jiffies(arinfo->timeout + in carl9170_tx_ampdu_timeout()
627 sta = iter->sta; in carl9170_tx_ampdu_timeout()
631 ieee80211_stop_tx_ba_session(sta, iter->tid); in carl9170_tx_ampdu_timeout()
633 spin_unlock_bh(&iter->lock); in carl9170_tx_ampdu_timeout()
646 ar->tx_janitor_last_run = jiffies; in carl9170_tx_janitor()
651 if (!atomic_read(&ar->tx_total_queued)) in carl9170_tx_janitor()
654 ieee80211_queue_delayed_work(ar->hw, &ar->tx_janitor, in carl9170_tx_janitor()
668 skb = carl9170_get_queued_skb(ar, cookie, &ar->tx_status[q]); in __carl9170_tx_process_status()
694 for (i = 0; i < cmd->hdr.ext; i++) { in carl9170_tx_process_status()
695 if (WARN_ON(i > ((cmd->hdr.len / 2) + 1))) { in carl9170_tx_process_status()
697 (void *) cmd, cmd->hdr.len + 4); in carl9170_tx_process_status()
701 __carl9170_tx_process_status(ar, cmd->_tx_status[i].cookie, in carl9170_tx_process_status()
702 cmd->_tx_status[i].info); in carl9170_tx_process_status()
711 u8 *txpower; in carl9170_tx_rate_tpc_chains() local
714 idx = txrate->idx; in carl9170_tx_rate_tpc_chains()
718 if (txrate->flags & IEEE80211_TX_RC_MCS) { in carl9170_tx_rate_tpc_chains()
719 if (txrate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) { in carl9170_tx_rate_tpc_chains()
723 if (info->band == NL80211_BAND_2GHZ) in carl9170_tx_rate_tpc_chains()
724 txpower = ar->power_2G_ht40; in carl9170_tx_rate_tpc_chains()
726 txpower = ar->power_5G_ht40; in carl9170_tx_rate_tpc_chains()
728 if (info->band == NL80211_BAND_2GHZ) in carl9170_tx_rate_tpc_chains()
729 txpower = ar->power_2G_ht20; in carl9170_tx_rate_tpc_chains()
731 txpower = ar->power_5G_ht20; in carl9170_tx_rate_tpc_chains()
734 *phyrate = txrate->idx; in carl9170_tx_rate_tpc_chains()
735 *tpc += txpower[idx & 7]; in carl9170_tx_rate_tpc_chains()
737 if (info->band == NL80211_BAND_2GHZ) { in carl9170_tx_rate_tpc_chains()
739 txpower = ar->power_2G_cck; in carl9170_tx_rate_tpc_chains()
741 txpower = ar->power_2G_ofdm; in carl9170_tx_rate_tpc_chains()
743 txpower = ar->power_5G_leg; in carl9170_tx_rate_tpc_chains()
748 *tpc += txpower[(rate->hw_value & 0x30) >> 4]; in carl9170_tx_rate_tpc_chains()
749 *phyrate = rate->hw_value & 0xf; in carl9170_tx_rate_tpc_chains()
752 if (ar->eeprom.tx_mask == 1) { in carl9170_tx_rate_tpc_chains()
755 if (!(txrate->flags & IEEE80211_TX_RC_MCS) && in carl9170_tx_rate_tpc_chains()
756 rate && rate->bitrate >= 360) in carl9170_tx_rate_tpc_chains()
762 *tpc = min_t(unsigned int, *tpc, ar->hw->conf.power_level * 2); in carl9170_tx_rate_tpc_chains()
773 if (txrate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in carl9170_tx_physet()
777 if (txrate->flags & IEEE80211_TX_RC_DUP_DATA) in carl9170_tx_physet()
781 if (txrate->flags & IEEE80211_TX_RC_SHORT_GI) in carl9170_tx_physet()
784 if (txrate->flags & IEEE80211_TX_RC_MCS) { in carl9170_tx_physet()
785 SET_VAL(AR9170_TX_PHY_MCS, phyrate, txrate->idx); in carl9170_tx_physet()
788 tmp |= cpu_to_le32((txrate->idx & 0x7) << in carl9170_tx_physet()
796 * if (txrate->flags & IEEE80211_TX_RC_GREEN_FIELD) in carl9170_tx_physet()
800 if (info->band == NL80211_BAND_2GHZ) { in carl9170_tx_physet()
801 if (txrate->idx <= AR9170_TX_PHY_RATE_CCK_11M) in carl9170_tx_physet()
812 * if (txrate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) in carl9170_tx_physet()
829 switch (ar->erp_mode) { in carl9170_tx_rts_check()
836 if (!(rate->flags & IEEE80211_TX_RC_USE_RTS_CTS)) in carl9170_tx_rts_check()
855 switch (ar->erp_mode) { in carl9170_tx_cts_check()
858 if (!(rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT)) in carl9170_tx_cts_check()
885 info->control.rates, in carl9170_tx_get_rates()
895 struct _carl9170_tx_superframe *txc = (void *) skb->data; in carl9170_tx_apply_rateset()
901 ampdu = !!(info->flags & IEEE80211_TX_CTL_AMPDU); in carl9170_tx_apply_rateset()
902 no_ack = !!(info->flags & IEEE80211_TX_CTL_NO_ACK); in carl9170_tx_apply_rateset()
904 /* Set the rate control probe flag for all (sub-) frames. in carl9170_tx_apply_rateset()
908 info->flags |= (sinfo->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE); in carl9170_tx_apply_rateset()
917 txrate = &sinfo->control.rates[i]; in carl9170_tx_apply_rateset()
918 if (txrate->idx < 0) in carl9170_tx_apply_rateset()
925 /* first rate - part of the hw's frame header */ in carl9170_tx_apply_rateset()
926 txc->f.phy_control = phy_set; in carl9170_tx_apply_rateset()
928 if (ampdu && txrate->flags & IEEE80211_TX_RC_MCS) in carl9170_tx_apply_rateset()
936 txc->f.mac_control |= mac_tmp; in carl9170_tx_apply_rateset()
941 txc->s.rr[i - 1] = phy_set; in carl9170_tx_apply_rateset()
944 SET_VAL(CARL9170_TX_SUPER_RI_TRIES, txc->s.ri[i], in carl9170_tx_apply_rateset()
945 txrate->count); in carl9170_tx_apply_rateset()
948 txc->s.ri[i] |= (AR9170_TX_MAC_PROT_RTS << in carl9170_tx_apply_rateset()
951 txc->s.ri[i] |= (AR9170_TX_MAC_PROT_CTS << in carl9170_tx_apply_rateset()
954 if (ampdu && (txrate->flags & IEEE80211_TX_RC_MCS)) in carl9170_tx_apply_rateset()
955 txc->s.ri[i] |= CARL9170_TX_SUPER_RI_AMPDU; in carl9170_tx_apply_rateset()
972 BUILD_BUG_ON(sizeof(*arinfo) > sizeof(info->rate_driver_data)); in carl9170_tx_prepare()
985 hdr = (void *)skb->data; in carl9170_tx_prepare()
987 len = skb->len; in carl9170_tx_prepare()
993 if (likely(info->control.vif)) in carl9170_tx_prepare()
994 cvif = (void *) info->control.vif->drv_priv; in carl9170_tx_prepare()
1001 SET_VAL(CARL9170_TX_SUPER_MISC_QUEUE, txc->s.misc, hw_queue); in carl9170_tx_prepare()
1004 SET_VAL(CARL9170_TX_SUPER_MISC_VIF_ID, txc->s.misc, cvif->id); in carl9170_tx_prepare()
1006 if (unlikely(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM)) in carl9170_tx_prepare()
1007 txc->s.misc |= CARL9170_TX_SUPER_MISC_CAB; in carl9170_tx_prepare()
1009 if (unlikely(info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)) in carl9170_tx_prepare()
1010 txc->s.misc |= CARL9170_TX_SUPER_MISC_ASSIGN_SEQ; in carl9170_tx_prepare()
1012 if (unlikely(ieee80211_is_probe_resp(hdr->frame_control))) in carl9170_tx_prepare()
1013 txc->s.misc |= CARL9170_TX_SUPER_MISC_FILL_IN_TSF; in carl9170_tx_prepare()
1020 if (unlikely(info->flags & IEEE80211_TX_CTL_NO_ACK)) in carl9170_tx_prepare()
1023 if (info->control.hw_key) { in carl9170_tx_prepare()
1024 len += info->control.hw_key->icv_len; in carl9170_tx_prepare()
1026 switch (info->control.hw_key->cipher) { in carl9170_tx_prepare()
1041 if (info->flags & IEEE80211_TX_CTL_AMPDU) { in carl9170_tx_prepare()
1048 sta->deflink.ht_cap.ampdu_factor); in carl9170_tx_prepare()
1049 density = sta->deflink.ht_cap.ampdu_density; in carl9170_tx_prepare()
1063 txc->s.ampdu_settings, density); in carl9170_tx_prepare()
1066 txc->s.ampdu_settings, factor); in carl9170_tx_prepare()
1069 txc->s.len = cpu_to_le16(skb->len); in carl9170_tx_prepare()
1070 txc->f.length = cpu_to_le16(len + FCS_LEN); in carl9170_tx_prepare()
1071 txc->f.mac_control = mac_tmp; in carl9170_tx_prepare()
1073 arinfo = (void *)info->rate_driver_data; in carl9170_tx_prepare()
1074 arinfo->timeout = jiffies; in carl9170_tx_prepare()
1075 arinfo->ar = ar; in carl9170_tx_prepare()
1076 kref_init(&arinfo->ref); in carl9170_tx_prepare()
1081 return -EINVAL; in carl9170_tx_prepare()
1088 super = (void *) skb->data; in carl9170_set_immba()
1089 super->f.mac_control |= cpu_to_le16(AR9170_TX_MAC_IMM_BA); in carl9170_set_immba()
1097 super = (void *) skb->data; in carl9170_set_ampdu_params()
1099 tmp = (super->s.ampdu_settings & CARL9170_TX_SUPER_AMPDU_DENSITY) << in carl9170_set_ampdu_params()
1113 if (tmp != ar->current_density) { in carl9170_set_ampdu_params()
1114 ar->current_density = tmp; in carl9170_set_ampdu_params()
1115 super->s.ampdu_settings |= in carl9170_set_ampdu_params()
1119 tmp = (super->s.ampdu_settings & CARL9170_TX_SUPER_AMPDU_FACTOR) << in carl9170_set_ampdu_params()
1122 if (tmp != ar->current_factor) { in carl9170_set_ampdu_params()
1123 ar->current_factor = tmp; in carl9170_set_ampdu_params()
1124 super->s.ampdu_settings |= in carl9170_set_ampdu_params()
1138 atomic_inc(&ar->tx_ampdu_scheduler); in carl9170_tx_ampdu()
1139 ar->tx_ampdu_schedule = false; in carl9170_tx_ampdu()
1141 if (atomic_read(&ar->tx_ampdu_upload)) in carl9170_tx_ampdu()
1144 if (!ar->tx_ampdu_list_len) in carl9170_tx_ampdu()
1150 tid_info = rcu_dereference(ar->tx_ampdu_iter); in carl9170_tx_ampdu()
1157 list_for_each_entry_continue_rcu(tid_info, &ar->tx_ampdu_list, list) { in carl9170_tx_ampdu()
1160 if (tid_info->state < CARL9170_TID_STATE_PROGRESS) in carl9170_tx_ampdu()
1163 queue = TID_TO_WME_AC(tid_info->tid); in carl9170_tx_ampdu()
1165 spin_lock_bh(&tid_info->lock); in carl9170_tx_ampdu()
1166 if (tid_info->state != CARL9170_TID_STATE_XMIT) in carl9170_tx_ampdu()
1169 tid_info->counter++; in carl9170_tx_ampdu()
1170 first = skb_peek(&tid_info->queue); in carl9170_tx_ampdu()
1172 seq = tid_info->snx; in carl9170_tx_ampdu()
1175 tid_info->state = CARL9170_TID_STATE_IDLE; in carl9170_tx_ampdu()
1181 while ((skb = skb_peek(&tid_info->queue))) { in carl9170_tx_ampdu()
1182 /* strict 0, 1, ..., n - 1, n frame sequence order */ in carl9170_tx_ampdu()
1187 if (unlikely(SEQ_DIFF(tid_info->snx, tid_info->bsn) >= in carl9170_tx_ampdu()
1188 (tid_info->max - 1))) in carl9170_tx_ampdu()
1192 carl9170_tx_get_rates(ar, tid_info->vif, in carl9170_tx_ampdu()
1193 tid_info->sta, first); in carl9170_tx_ampdu()
1199 atomic_inc(&ar->tx_ampdu_upload); in carl9170_tx_ampdu()
1200 tid_info->snx = seq = SEQ_NEXT(seq); in carl9170_tx_ampdu()
1201 __skb_unlink(skb, &tid_info->queue); in carl9170_tx_ampdu()
1209 if (skb_queue_empty(&tid_info->queue) || in carl9170_tx_ampdu()
1210 carl9170_get_seq(skb_peek(&tid_info->queue)) != in carl9170_tx_ampdu()
1211 tid_info->snx) { in carl9170_tx_ampdu()
1212 /* stop TID, if A-MPDU frames are still missing, in carl9170_tx_ampdu()
1216 tid_info->state = CARL9170_TID_STATE_IDLE; in carl9170_tx_ampdu()
1221 spin_unlock_bh(&tid_info->lock); in carl9170_tx_ampdu()
1232 spin_lock_bh(&ar->tx_pending[queue].lock); in carl9170_tx_ampdu()
1233 skb_queue_splice_tail_init(&agg, &ar->tx_pending[queue]); in carl9170_tx_ampdu()
1234 spin_unlock_bh(&ar->tx_pending[queue].lock); in carl9170_tx_ampdu()
1235 ar->tx_schedule = true; in carl9170_tx_ampdu()
1240 rcu_assign_pointer(ar->tx_ampdu_iter, tid_info); in carl9170_tx_ampdu()
1251 BUILD_BUG_ON(sizeof(*arinfo) > sizeof(info->rate_driver_data)); in carl9170_tx_pick_skb()
1253 spin_lock_bh(&queue->lock); in carl9170_tx_pick_skb()
1262 spin_unlock_bh(&queue->lock); in carl9170_tx_pick_skb()
1265 arinfo = (void *) info->rate_driver_data; in carl9170_tx_pick_skb()
1267 arinfo->timeout = jiffies; in carl9170_tx_pick_skb()
1271 spin_unlock_bh(&queue->lock); in carl9170_tx_pick_skb()
1280 ar->tx_dropped++; in carl9170_tx_drop()
1282 super = (void *)skb->data; in carl9170_tx_drop()
1285 __carl9170_tx_process_status(ar, super->s.cookie, q); in carl9170_tx_drop()
1299 sta_info = (void *) sta->drv_priv; in carl9170_tx_ps_drop()
1302 if (unlikely(sta_info->sleeping) && in carl9170_tx_ps_drop()
1303 !(tx_info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER | in carl9170_tx_ps_drop()
1307 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) in carl9170_tx_ps_drop()
1308 atomic_dec(&ar->tx_ampdu_upload); in carl9170_tx_ps_drop()
1310 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED; in carl9170_tx_ps_drop()
1323 struct _carl9170_tx_superframe *super = (void *) skb->data; in carl9170_bar_check()
1324 struct ieee80211_bar *bar = (void *) super->frame_data; in carl9170_bar_check()
1326 if (unlikely(ieee80211_is_back_req(bar->frame_control)) && in carl9170_bar_check()
1327 skb->len >= sizeof(struct ieee80211_bar)) { in carl9170_bar_check()
1333 entry->skb = skb; in carl9170_bar_check()
1334 spin_lock_bh(&ar->bar_list_lock[queue]); in carl9170_bar_check()
1335 list_add_tail_rcu(&entry->list, &ar->bar_list[queue]); in carl9170_bar_check()
1336 spin_unlock_bh(&ar->bar_list_lock[queue]); in carl9170_bar_check()
1347 ar->tx_schedule = false; in carl9170_tx()
1354 for (i = 0; i < ar->hw->queues; i++) { in carl9170_tx()
1355 while (!skb_queue_empty(&ar->tx_pending[i])) { in carl9170_tx()
1356 skb = carl9170_tx_pick_skb(ar, &ar->tx_pending[i]); in carl9170_tx()
1365 atomic_inc(&ar->tx_total_pending); in carl9170_tx()
1372 skb_queue_tail(&ar->tx_status[q], skb); in carl9170_tx()
1392 ieee80211_queue_delayed_work(ar->hw, &ar->tx_janitor, in carl9170_tx()
1408 sta_info = (void *) sta->drv_priv; in carl9170_tx_ampdu_queue()
1411 agg = rcu_dereference(sta_info->agg[tid]); in carl9170_tx_ampdu_queue()
1416 spin_lock_bh(&agg->lock); in carl9170_tx_ampdu_queue()
1417 if (unlikely(agg->state < CARL9170_TID_STATE_IDLE)) in carl9170_tx_ampdu_queue()
1421 if (unlikely(!BAW_WITHIN(agg->bsn, CARL9170_BAW_BITS, seq))) in carl9170_tx_ampdu_queue()
1424 if (WARN_ON_ONCE(!BAW_WITHIN(agg->snx, CARL9170_BAW_BITS, seq))) in carl9170_tx_ampdu_queue()
1427 off = SEQ_DIFF(seq, agg->bsn); in carl9170_tx_ampdu_queue()
1428 if (WARN_ON_ONCE(test_and_set_bit(off, agg->bitmap))) in carl9170_tx_ampdu_queue()
1431 if (likely(BAW_WITHIN(agg->hsn, CARL9170_BAW_BITS, seq))) { in carl9170_tx_ampdu_queue()
1432 __skb_queue_tail(&agg->queue, skb); in carl9170_tx_ampdu_queue()
1433 agg->hsn = seq; in carl9170_tx_ampdu_queue()
1437 skb_queue_reverse_walk(&agg->queue, iter) { in carl9170_tx_ampdu_queue()
1441 __skb_queue_after(&agg->queue, iter, skb); in carl9170_tx_ampdu_queue()
1446 __skb_queue_head(&agg->queue, skb); in carl9170_tx_ampdu_queue()
1449 if (unlikely(agg->state != CARL9170_TID_STATE_XMIT)) { in carl9170_tx_ampdu_queue()
1450 if (agg->snx == carl9170_get_seq(skb_peek(&agg->queue))) { in carl9170_tx_ampdu_queue()
1451 agg->state = CARL9170_TID_STATE_XMIT; in carl9170_tx_ampdu_queue()
1456 spin_unlock_bh(&agg->lock); in carl9170_tx_ampdu_queue()
1462 spin_unlock_bh(&agg->lock); in carl9170_tx_ampdu_queue()
1466 txinfo->flags &= ~IEEE80211_TX_CTL_AMPDU; in carl9170_tx_ampdu_queue()
1468 ar->tx_dropped++; in carl9170_tx_ampdu_queue()
1476 struct ar9170 *ar = hw->priv; in carl9170_op_tx()
1478 struct ieee80211_sta *sta = control->sta; in carl9170_op_tx()
1486 vif = info->control.vif; in carl9170_op_tx()
1498 struct carl9170_sta_info *stai = (void *) sta->drv_priv; in carl9170_op_tx()
1499 atomic_inc(&stai->pending_frames); in carl9170_op_tx()
1502 if (info->flags & IEEE80211_TX_CTL_AMPDU) { in carl9170_op_tx()
1519 skb_queue_tail(&ar->tx_pending[queue], skb); in carl9170_op_tx()
1526 ar->tx_dropped++; in carl9170_op_tx()
1527 ieee80211_free_txskb(ar->hw, skb); in carl9170_op_tx()
1533 if (ar->tx_ampdu_schedule) in carl9170_tx_scheduler()
1536 if (ar->tx_schedule) in carl9170_tx_scheduler()
1553 cvif = rcu_dereference(ar->beacon_iter); in carl9170_pick_beaconing_vif()
1554 if (ar->vifs > 0 && cvif) { in carl9170_pick_beaconing_vif()
1556 list_for_each_entry_continue_rcu(cvif, &ar->vif_list, in carl9170_pick_beaconing_vif()
1558 if (cvif->active && cvif->enable_beacon) in carl9170_pick_beaconing_vif()
1561 } while (ar->beacon_enabled && i--); in carl9170_pick_beaconing_vif()
1568 RCU_INIT_POINTER(ar->beacon_iter, cvif); in carl9170_pick_beaconing_vif()
1581 rate = &txinfo->control.rates[0]; in carl9170_tx_beacon_physet()
1582 ht_rate = !!(txinfo->control.rates[0].flags & IEEE80211_TX_RC_MCS); in carl9170_tx_beacon_physet()
1594 if (rate->flags & IEEE80211_TX_RC_SHORT_GI) in carl9170_tx_beacon_physet()
1597 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) { in carl9170_tx_beacon_physet()
1600 } else if (rate->flags & IEEE80211_TX_RC_DUP_DATA) { in carl9170_tx_beacon_physet()
1605 SET_VAL(AR9170_MAC_BCN_HT2_LEN, *plcp, skb->len + FCS_LEN); in carl9170_tx_beacon_physet()
1608 *plcp |= ((skb->len + FCS_LEN) << (3 + 16)) + 0x0400; in carl9170_tx_beacon_physet()
1610 *plcp |= ((skb->len + FCS_LEN) << 16) + 0x0010; in carl9170_tx_beacon_physet()
1630 skb = ieee80211_beacon_get_tim(ar->hw, carl9170_get_vif(cvif), in carl9170_update_beacon()
1634 err = -ENOMEM; in carl9170_update_beacon()
1638 spin_lock_bh(&ar->beacon_lock); in carl9170_update_beacon()
1639 data = (__le32 *)skb->data; in carl9170_update_beacon()
1640 if (cvif->beacon) in carl9170_update_beacon()
1641 old = (__le32 *)cvif->beacon->data; in carl9170_update_beacon()
1643 off = cvif->id * AR9170_MAC_BCN_LENGTH_MAX; in carl9170_update_beacon()
1644 addr = ar->fw.beacon_addr + off; in carl9170_update_beacon()
1645 len = roundup(skb->len + FCS_LEN, 4); in carl9170_update_beacon()
1647 if ((off + len) > ar->fw.beacon_max_len) { in carl9170_update_beacon()
1649 wiphy_err(ar->hw->wiphy, "beacon does not " in carl9170_update_beacon()
1652 err = -EINVAL; in carl9170_update_beacon()
1658 wiphy_err(ar->hw->wiphy, "no support for beacons " in carl9170_update_beacon()
1663 err = -EMSGSIZE; in carl9170_update_beacon()
1676 for (i = 0; i < DIV_ROUND_UP(skb->len, 4); i++) { in carl9170_update_beacon()
1690 dev_kfree_skb_any(cvif->beacon); in carl9170_update_beacon()
1691 cvif->beacon = NULL; in carl9170_update_beacon()
1695 cvif->beacon = skb; in carl9170_update_beacon()
1696 spin_unlock_bh(&ar->beacon_lock); in carl9170_update_beacon()
1701 err = carl9170_bcn_ctrl(ar, cvif->id, in carl9170_update_beacon()
1703 addr, skb->len + FCS_LEN); in carl9170_update_beacon()
1713 spin_unlock_bh(&ar->beacon_lock); in carl9170_update_beacon()