Lines Matching +full:super +full:- +full:set

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() local
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; in carl9170_alloc_dev_space() local
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() local
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(&txinfo->pad, 0, sizeof(txinfo->pad)); in carl9170_tx_release()
284 memset(&txinfo->rate_driver_data, 0, sizeof(txinfo->rate_driver_data)); in carl9170_tx_release()
286 if (atomic_read(&ar->tx_total_queued)) in carl9170_tx_release()
287 ar->tx_schedule = true; in carl9170_tx_release()
289 if (txinfo->flags & IEEE80211_TX_CTL_AMPDU) { in carl9170_tx_release()
290 if (!atomic_read(&ar->tx_ampdu_upload)) in carl9170_tx_release()
291 ar->tx_ampdu_schedule = true; in carl9170_tx_release()
293 if (txinfo->flags & IEEE80211_TX_STAT_AMPDU) { in carl9170_tx_release()
294 struct _carl9170_tx_superframe *super; in carl9170_tx_release() local
296 super = (void *)skb->data; in carl9170_tx_release()
297 txinfo->status.ampdu_len = super->s.rix; in carl9170_tx_release()
298 txinfo->status.ampdu_ack_len = super->s.cnt; in carl9170_tx_release()
299 } else if ((txinfo->flags & IEEE80211_TX_STAT_ACK) && in carl9170_tx_release()
300 !(txinfo->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) { in carl9170_tx_release()
314 * feedback either [CTL_REQ_TX_STATUS not set] in carl9170_tx_release()
317 ieee80211_free_txskb(ar->hw, skb); in carl9170_tx_release()
328 ieee80211_tx_status_irqsafe(ar->hw, skb); in carl9170_tx_release()
334 (IEEE80211_SKB_CB(skb))->rate_driver_data; in carl9170_tx_get_skb()
335 kref_get(&arinfo->ref); in carl9170_tx_get_skb()
341 (IEEE80211_SKB_CB(skb))->rate_driver_data; in carl9170_tx_put_skb()
343 return kref_put(&arinfo->ref, carl9170_tx_release); in carl9170_tx_put_skb()
346 /* Caller must hold the tid_info->lock & rcu_read_lock */
352 off = SEQ_DIFF(seq, tid_info->bsn); in carl9170_tx_shift_bm()
358 * Sanity check. For each MPDU we set the bit in bitmap and in carl9170_tx_shift_bm()
363 WARN_ON_ONCE(!test_and_clear_bit(off, tid_info->bitmap)); in carl9170_tx_shift_bm()
365 off = SEQ_DIFF(tid_info->snx, tid_info->bsn); in carl9170_tx_shift_bm()
369 if (!bitmap_empty(tid_info->bitmap, off)) in carl9170_tx_shift_bm()
370 off = find_first_bit(tid_info->bitmap, off); in carl9170_tx_shift_bm()
372 tid_info->bsn += off; in carl9170_tx_shift_bm()
373 tid_info->bsn &= 0x0fff; in carl9170_tx_shift_bm()
375 bitmap_shift_right(tid_info->bitmap, tid_info->bitmap, in carl9170_tx_shift_bm()
382 struct _carl9170_tx_superframe *super = (void *) skb->data; in carl9170_tx_status_process_ampdu() local
383 struct ieee80211_hdr *hdr = (void *) super->frame_data; in carl9170_tx_status_process_ampdu()
389 if (!(txinfo->flags & IEEE80211_TX_CTL_AMPDU) || in carl9170_tx_status_process_ampdu()
390 txinfo->flags & IEEE80211_TX_CTL_INJECTED) in carl9170_tx_status_process_ampdu()
400 sta_info = (void *) sta->drv_priv; in carl9170_tx_status_process_ampdu()
401 tid_info = rcu_dereference(sta_info->agg[tid]); in carl9170_tx_status_process_ampdu()
405 spin_lock_bh(&tid_info->lock); in carl9170_tx_status_process_ampdu()
406 if (likely(tid_info->state >= CARL9170_TID_STATE_IDLE)) in carl9170_tx_status_process_ampdu()
409 if (sta_info->stats[tid].clear) { in carl9170_tx_status_process_ampdu()
410 sta_info->stats[tid].clear = false; in carl9170_tx_status_process_ampdu()
411 sta_info->stats[tid].req = false; in carl9170_tx_status_process_ampdu()
412 sta_info->stats[tid].ampdu_len = 0; in carl9170_tx_status_process_ampdu()
413 sta_info->stats[tid].ampdu_ack_len = 0; in carl9170_tx_status_process_ampdu()
416 sta_info->stats[tid].ampdu_len++; in carl9170_tx_status_process_ampdu()
417 if (txinfo->status.rates[0].count == 1) in carl9170_tx_status_process_ampdu()
418 sta_info->stats[tid].ampdu_ack_len++; in carl9170_tx_status_process_ampdu()
420 if (!(txinfo->flags & IEEE80211_TX_STAT_ACK)) in carl9170_tx_status_process_ampdu()
421 sta_info->stats[tid].req = true; in carl9170_tx_status_process_ampdu()
423 if (super->f.mac_control & cpu_to_le16(AR9170_TX_MAC_IMM_BA)) { in carl9170_tx_status_process_ampdu()
424 super->s.rix = sta_info->stats[tid].ampdu_len; in carl9170_tx_status_process_ampdu()
425 super->s.cnt = sta_info->stats[tid].ampdu_ack_len; in carl9170_tx_status_process_ampdu()
426 txinfo->flags |= IEEE80211_TX_STAT_AMPDU; in carl9170_tx_status_process_ampdu()
427 if (sta_info->stats[tid].req) in carl9170_tx_status_process_ampdu()
428 txinfo->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; in carl9170_tx_status_process_ampdu()
430 sta_info->stats[tid].clear = true; in carl9170_tx_status_process_ampdu()
432 spin_unlock_bh(&tid_info->lock); in carl9170_tx_status_process_ampdu()
441 struct _carl9170_tx_superframe *super = (void *) skb->data; in carl9170_tx_bar_status() local
442 struct ieee80211_bar *bar = (void *) super->frame_data; in carl9170_tx_bar_status()
448 * Instead the RX-path will scan for incoming BAs and set the in carl9170_tx_bar_status()
453 if (unlikely(ieee80211_is_back_req(bar->frame_control)) && in carl9170_tx_bar_status()
454 !(tx_info->flags & IEEE80211_TX_STAT_ACK)) { in carl9170_tx_bar_status()
459 list_for_each_entry_rcu(entry, &ar->bar_list[queue], list) { in carl9170_tx_bar_status()
460 if (entry->skb == skb) { in carl9170_tx_bar_status()
461 spin_lock_bh(&ar->bar_list_lock[queue]); in carl9170_tx_bar_status()
462 list_del_rcu(&entry->list); in carl9170_tx_bar_status()
463 spin_unlock_bh(&ar->bar_list_lock[queue]); in carl9170_tx_bar_status()
469 WARN(1, "bar not found in %d - ra:%pM ta:%pM c:%x ssn:%x\n", in carl9170_tx_bar_status()
470 queue, bar->ra, bar->ta, bar->control, in carl9170_tx_bar_status()
471 bar->start_seq_num); in carl9170_tx_bar_status()
489 txinfo->flags |= IEEE80211_TX_STAT_ACK; in carl9170_tx_status()
491 ar->tx_ack_failures++; in carl9170_tx_status()
493 if (txinfo->flags & IEEE80211_TX_CTL_AMPDU) in carl9170_tx_status()
505 atomic_dec(&ar->tx_total_pending); in carl9170_tx_callback()
507 if (txinfo->flags & IEEE80211_TX_CTL_AMPDU) in carl9170_tx_callback()
508 atomic_dec(&ar->tx_ampdu_upload); in carl9170_tx_callback()
511 tasklet_hi_schedule(&ar->usb_tasklet); in carl9170_tx_callback()
519 spin_lock_bh(&queue->lock); in carl9170_get_queued_skb()
521 struct _carl9170_tx_superframe *txc = (void *) skb->data; in carl9170_get_queued_skb()
523 if (txc->s.cookie != cookie) in carl9170_get_queued_skb()
527 spin_unlock_bh(&queue->lock); in carl9170_get_queued_skb()
532 spin_unlock_bh(&queue->lock); in carl9170_get_queued_skb()
543 if (txinfo->status.rates[i].idx < 0) in carl9170_tx_fill_rateinfo()
547 txinfo->status.rates[i].count = tries; in carl9170_tx_fill_rateinfo()
554 txinfo->status.rates[i].idx = -1; in carl9170_tx_fill_rateinfo()
555 txinfo->status.rates[i].count = 0; in carl9170_tx_fill_rateinfo()
567 for (i = 0; i < ar->hw->queues; i++) { in carl9170_check_queue_stop_timeout()
568 spin_lock_bh(&ar->tx_status[i].lock); in carl9170_check_queue_stop_timeout()
570 skb = skb_peek(&ar->tx_status[i]); in carl9170_check_queue_stop_timeout()
576 arinfo = (void *) txinfo->rate_driver_data; in carl9170_check_queue_stop_timeout()
578 if (time_is_before_jiffies(arinfo->timeout + in carl9170_check_queue_stop_timeout()
583 spin_unlock_bh(&ar->tx_status[i].lock); in carl9170_check_queue_stop_timeout()
593 * - frames got lost/corrupted (bad connection to the device) in carl9170_check_queue_stop_timeout()
594 * - stalled rx processing/usb controller hiccups in carl9170_check_queue_stop_timeout()
595 * - firmware errors/bugs in carl9170_check_queue_stop_timeout()
596 * - every bug you can think of. in carl9170_check_queue_stop_timeout()
597 * - all bugs you can't... in carl9170_check_queue_stop_timeout()
598 * - ... in carl9170_check_queue_stop_timeout()
613 list_for_each_entry_rcu(iter, &ar->tx_ampdu_list, list) { in carl9170_tx_ampdu_timeout()
614 if (iter->state < CARL9170_TID_STATE_IDLE) in carl9170_tx_ampdu_timeout()
617 spin_lock_bh(&iter->lock); in carl9170_tx_ampdu_timeout()
618 skb = skb_peek(&iter->queue); in carl9170_tx_ampdu_timeout()
623 arinfo = (void *)txinfo->rate_driver_data; in carl9170_tx_ampdu_timeout()
624 if (time_is_after_jiffies(arinfo->timeout + in carl9170_tx_ampdu_timeout()
628 sta = iter->sta; in carl9170_tx_ampdu_timeout()
632 ieee80211_stop_tx_ba_session(sta, iter->tid); in carl9170_tx_ampdu_timeout()
634 spin_unlock_bh(&iter->lock); in carl9170_tx_ampdu_timeout()
647 ar->tx_janitor_last_run = jiffies; in carl9170_tx_janitor()
652 if (!atomic_read(&ar->tx_total_queued)) in carl9170_tx_janitor()
655 ieee80211_queue_delayed_work(ar->hw, &ar->tx_janitor, in carl9170_tx_janitor()
669 skb = carl9170_get_queued_skb(ar, cookie, &ar->tx_status[q]); in __carl9170_tx_process_status()
695 for (i = 0; i < cmd->hdr.ext; i++) { in carl9170_tx_process_status()
696 if (WARN_ON(i > ((cmd->hdr.len / 2) + 1))) { in carl9170_tx_process_status()
698 (void *) cmd, cmd->hdr.len + 4); in carl9170_tx_process_status()
702 __carl9170_tx_process_status(ar, cmd->_tx_status[i].cookie, in carl9170_tx_process_status()
703 cmd->_tx_status[i].info); in carl9170_tx_process_status()
715 idx = txrate->idx; in carl9170_tx_rate_tpc_chains()
719 if (txrate->flags & IEEE80211_TX_RC_MCS) { in carl9170_tx_rate_tpc_chains()
720 if (txrate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) { in carl9170_tx_rate_tpc_chains()
724 if (info->band == NL80211_BAND_2GHZ) in carl9170_tx_rate_tpc_chains()
725 txpower = ar->power_2G_ht40; in carl9170_tx_rate_tpc_chains()
727 txpower = ar->power_5G_ht40; in carl9170_tx_rate_tpc_chains()
729 if (info->band == NL80211_BAND_2GHZ) in carl9170_tx_rate_tpc_chains()
730 txpower = ar->power_2G_ht20; in carl9170_tx_rate_tpc_chains()
732 txpower = ar->power_5G_ht20; in carl9170_tx_rate_tpc_chains()
735 *phyrate = txrate->idx; in carl9170_tx_rate_tpc_chains()
738 if (info->band == NL80211_BAND_2GHZ) { in carl9170_tx_rate_tpc_chains()
740 txpower = ar->power_2G_cck; in carl9170_tx_rate_tpc_chains()
742 txpower = ar->power_2G_ofdm; in carl9170_tx_rate_tpc_chains()
744 txpower = ar->power_5G_leg; in carl9170_tx_rate_tpc_chains()
749 *tpc += txpower[(rate->hw_value & 0x30) >> 4]; in carl9170_tx_rate_tpc_chains()
750 *phyrate = rate->hw_value & 0xf; in carl9170_tx_rate_tpc_chains()
753 if (ar->eeprom.tx_mask == 1) { in carl9170_tx_rate_tpc_chains()
756 if (!(txrate->flags & IEEE80211_TX_RC_MCS) && in carl9170_tx_rate_tpc_chains()
757 rate && rate->bitrate >= 360) in carl9170_tx_rate_tpc_chains()
763 *tpc = min_t(unsigned int, *tpc, ar->hw->conf.power_level * 2); in carl9170_tx_rate_tpc_chains()
774 if (txrate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in carl9170_tx_physet()
778 if (txrate->flags & IEEE80211_TX_RC_DUP_DATA) in carl9170_tx_physet()
782 if (txrate->flags & IEEE80211_TX_RC_SHORT_GI) in carl9170_tx_physet()
785 if (txrate->flags & IEEE80211_TX_RC_MCS) { in carl9170_tx_physet()
786 SET_VAL(AR9170_TX_PHY_MCS, phyrate, txrate->idx); in carl9170_tx_physet()
789 tmp |= cpu_to_le32((txrate->idx & 0x7) << in carl9170_tx_physet()
797 * if (txrate->flags & IEEE80211_TX_RC_GREEN_FIELD) in carl9170_tx_physet()
801 if (info->band == NL80211_BAND_2GHZ) { in carl9170_tx_physet()
802 if (txrate->idx <= AR9170_TX_PHY_RATE_CCK_11M) in carl9170_tx_physet()
813 * if (txrate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) in carl9170_tx_physet()
830 switch (ar->erp_mode) { in carl9170_tx_rts_check()
837 if (!(rate->flags & IEEE80211_TX_RC_USE_RTS_CTS)) in carl9170_tx_rts_check()
856 switch (ar->erp_mode) { in carl9170_tx_cts_check()
859 if (!(rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT)) in carl9170_tx_cts_check()
886 info->control.rates, in carl9170_tx_get_rates()
896 struct _carl9170_tx_superframe *txc = (void *) skb->data; in carl9170_tx_apply_rateset()
902 ampdu = !!(info->flags & IEEE80211_TX_CTL_AMPDU); in carl9170_tx_apply_rateset()
903 no_ack = !!(info->flags & IEEE80211_TX_CTL_NO_ACK); in carl9170_tx_apply_rateset()
905 /* Set the rate control probe flag for all (sub-) frames. in carl9170_tx_apply_rateset()
906 * This is because the TX_STATS_AMPDU flag is only set on in carl9170_tx_apply_rateset()
909 info->flags |= (sinfo->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE); in carl9170_tx_apply_rateset()
918 txrate = &sinfo->control.rates[i]; in carl9170_tx_apply_rateset()
919 if (txrate->idx < 0) in carl9170_tx_apply_rateset()
926 /* first rate - part of the hw's frame header */ in carl9170_tx_apply_rateset()
927 txc->f.phy_control = phy_set; in carl9170_tx_apply_rateset()
929 if (ampdu && txrate->flags & IEEE80211_TX_RC_MCS) in carl9170_tx_apply_rateset()
937 txc->f.mac_control |= mac_tmp; in carl9170_tx_apply_rateset()
940 * retry rate set array. in carl9170_tx_apply_rateset()
942 txc->s.rr[i - 1] = phy_set; in carl9170_tx_apply_rateset()
945 SET_VAL(CARL9170_TX_SUPER_RI_TRIES, txc->s.ri[i], in carl9170_tx_apply_rateset()
946 txrate->count); in carl9170_tx_apply_rateset()
949 txc->s.ri[i] |= (AR9170_TX_MAC_PROT_RTS << in carl9170_tx_apply_rateset()
952 txc->s.ri[i] |= (AR9170_TX_MAC_PROT_CTS << in carl9170_tx_apply_rateset()
955 if (ampdu && (txrate->flags & IEEE80211_TX_RC_MCS)) in carl9170_tx_apply_rateset()
956 txc->s.ri[i] |= CARL9170_TX_SUPER_RI_AMPDU; in carl9170_tx_apply_rateset()
973 BUILD_BUG_ON(sizeof(*arinfo) > sizeof(info->rate_driver_data)); in carl9170_tx_prepare()
986 hdr = (void *)skb->data; in carl9170_tx_prepare()
988 len = skb->len; in carl9170_tx_prepare()
994 if (likely(info->control.vif)) in carl9170_tx_prepare()
995 cvif = (void *) info->control.vif->drv_priv; in carl9170_tx_prepare()
1002 SET_VAL(CARL9170_TX_SUPER_MISC_QUEUE, txc->s.misc, hw_queue); in carl9170_tx_prepare()
1005 SET_VAL(CARL9170_TX_SUPER_MISC_VIF_ID, txc->s.misc, cvif->id); in carl9170_tx_prepare()
1007 if (unlikely(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM)) in carl9170_tx_prepare()
1008 txc->s.misc |= CARL9170_TX_SUPER_MISC_CAB; in carl9170_tx_prepare()
1010 if (unlikely(info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)) in carl9170_tx_prepare()
1011 txc->s.misc |= CARL9170_TX_SUPER_MISC_ASSIGN_SEQ; in carl9170_tx_prepare()
1013 if (unlikely(ieee80211_is_probe_resp(hdr->frame_control))) in carl9170_tx_prepare()
1014 txc->s.misc |= CARL9170_TX_SUPER_MISC_FILL_IN_TSF; in carl9170_tx_prepare()
1021 if (unlikely(info->flags & IEEE80211_TX_CTL_NO_ACK)) in carl9170_tx_prepare()
1024 if (info->control.hw_key) { in carl9170_tx_prepare()
1025 len += info->control.hw_key->icv_len; in carl9170_tx_prepare()
1027 switch (info->control.hw_key->cipher) { in carl9170_tx_prepare()
1042 if (info->flags & IEEE80211_TX_CTL_AMPDU) { in carl9170_tx_prepare()
1049 sta->deflink.ht_cap.ampdu_factor); in carl9170_tx_prepare()
1050 density = sta->deflink.ht_cap.ampdu_density; in carl9170_tx_prepare()
1064 txc->s.ampdu_settings, density); in carl9170_tx_prepare()
1067 txc->s.ampdu_settings, factor); in carl9170_tx_prepare()
1070 txc->s.len = cpu_to_le16(skb->len); in carl9170_tx_prepare()
1071 txc->f.length = cpu_to_le16(len + FCS_LEN); in carl9170_tx_prepare()
1072 txc->f.mac_control = mac_tmp; in carl9170_tx_prepare()
1074 arinfo = (void *)info->rate_driver_data; in carl9170_tx_prepare()
1075 arinfo->timeout = jiffies; in carl9170_tx_prepare()
1076 arinfo->ar = ar; in carl9170_tx_prepare()
1077 kref_init(&arinfo->ref); in carl9170_tx_prepare()
1082 return -EINVAL; in carl9170_tx_prepare()
1087 struct _carl9170_tx_superframe *super; in carl9170_set_immba() local
1089 super = (void *) skb->data; in carl9170_set_immba()
1090 super->f.mac_control |= cpu_to_le16(AR9170_TX_MAC_IMM_BA); in carl9170_set_immba()
1095 struct _carl9170_tx_superframe *super; in carl9170_set_ampdu_params() local
1098 super = (void *) skb->data; in carl9170_set_ampdu_params()
1100 tmp = (super->s.ampdu_settings & CARL9170_TX_SUPER_AMPDU_DENSITY) << in carl9170_set_ampdu_params()
1114 if (tmp != ar->current_density) { in carl9170_set_ampdu_params()
1115 ar->current_density = tmp; in carl9170_set_ampdu_params()
1116 super->s.ampdu_settings |= in carl9170_set_ampdu_params()
1120 tmp = (super->s.ampdu_settings & CARL9170_TX_SUPER_AMPDU_FACTOR) << in carl9170_set_ampdu_params()
1123 if (tmp != ar->current_factor) { in carl9170_set_ampdu_params()
1124 ar->current_factor = tmp; in carl9170_set_ampdu_params()
1125 super->s.ampdu_settings |= in carl9170_set_ampdu_params()
1139 atomic_inc(&ar->tx_ampdu_scheduler); in carl9170_tx_ampdu()
1140 ar->tx_ampdu_schedule = false; in carl9170_tx_ampdu()
1142 if (atomic_read(&ar->tx_ampdu_upload)) in carl9170_tx_ampdu()
1145 if (!ar->tx_ampdu_list_len) in carl9170_tx_ampdu()
1151 tid_info = rcu_dereference(ar->tx_ampdu_iter); in carl9170_tx_ampdu()
1158 list_for_each_entry_continue_rcu(tid_info, &ar->tx_ampdu_list, list) { in carl9170_tx_ampdu()
1161 if (tid_info->state < CARL9170_TID_STATE_PROGRESS) in carl9170_tx_ampdu()
1164 queue = TID_TO_WME_AC(tid_info->tid); in carl9170_tx_ampdu()
1166 spin_lock_bh(&tid_info->lock); in carl9170_tx_ampdu()
1167 if (tid_info->state != CARL9170_TID_STATE_XMIT) in carl9170_tx_ampdu()
1170 tid_info->counter++; in carl9170_tx_ampdu()
1171 first = skb_peek(&tid_info->queue); in carl9170_tx_ampdu()
1173 seq = tid_info->snx; in carl9170_tx_ampdu()
1176 tid_info->state = CARL9170_TID_STATE_IDLE; in carl9170_tx_ampdu()
1182 while ((skb = skb_peek(&tid_info->queue))) { in carl9170_tx_ampdu()
1183 /* strict 0, 1, ..., n - 1, n frame sequence order */ in carl9170_tx_ampdu()
1188 if (unlikely(SEQ_DIFF(tid_info->snx, tid_info->bsn) >= in carl9170_tx_ampdu()
1189 (tid_info->max - 1))) in carl9170_tx_ampdu()
1193 carl9170_tx_get_rates(ar, tid_info->vif, in carl9170_tx_ampdu()
1194 tid_info->sta, first); in carl9170_tx_ampdu()
1200 atomic_inc(&ar->tx_ampdu_upload); in carl9170_tx_ampdu()
1201 tid_info->snx = seq = SEQ_NEXT(seq); in carl9170_tx_ampdu()
1202 __skb_unlink(skb, &tid_info->queue); in carl9170_tx_ampdu()
1210 if (skb_queue_empty(&tid_info->queue) || in carl9170_tx_ampdu()
1211 carl9170_get_seq(skb_peek(&tid_info->queue)) != in carl9170_tx_ampdu()
1212 tid_info->snx) { in carl9170_tx_ampdu()
1213 /* stop TID, if A-MPDU frames are still missing, in carl9170_tx_ampdu()
1217 tid_info->state = CARL9170_TID_STATE_IDLE; in carl9170_tx_ampdu()
1222 spin_unlock_bh(&tid_info->lock); in carl9170_tx_ampdu()
1230 /* set aggregation push bit */ in carl9170_tx_ampdu()
1233 spin_lock_bh(&ar->tx_pending[queue].lock); in carl9170_tx_ampdu()
1234 skb_queue_splice_tail_init(&agg, &ar->tx_pending[queue]); in carl9170_tx_ampdu()
1235 spin_unlock_bh(&ar->tx_pending[queue].lock); in carl9170_tx_ampdu()
1236 ar->tx_schedule = true; in carl9170_tx_ampdu()
1241 rcu_assign_pointer(ar->tx_ampdu_iter, tid_info); in carl9170_tx_ampdu()
1252 BUILD_BUG_ON(sizeof(*arinfo) > sizeof(info->rate_driver_data)); in carl9170_tx_pick_skb()
1254 spin_lock_bh(&queue->lock); in carl9170_tx_pick_skb()
1263 spin_unlock_bh(&queue->lock); in carl9170_tx_pick_skb()
1266 arinfo = (void *) info->rate_driver_data; in carl9170_tx_pick_skb()
1268 arinfo->timeout = jiffies; in carl9170_tx_pick_skb()
1272 spin_unlock_bh(&queue->lock); in carl9170_tx_pick_skb()
1278 struct _carl9170_tx_superframe *super; in carl9170_tx_drop() local
1281 ar->tx_dropped++; in carl9170_tx_drop()
1283 super = (void *)skb->data; in carl9170_tx_drop()
1286 __carl9170_tx_process_status(ar, super->s.cookie, q); in carl9170_tx_drop()
1300 sta_info = (void *) sta->drv_priv; in carl9170_tx_ps_drop()
1303 if (unlikely(sta_info->sleeping) && in carl9170_tx_ps_drop()
1304 !(tx_info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER | in carl9170_tx_ps_drop()
1308 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) in carl9170_tx_ps_drop()
1309 atomic_dec(&ar->tx_ampdu_upload); in carl9170_tx_ps_drop()
1311 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED; in carl9170_tx_ps_drop()
1324 struct _carl9170_tx_superframe *super = (void *) skb->data; in carl9170_bar_check() local
1325 struct ieee80211_bar *bar = (void *) super->frame_data; in carl9170_bar_check()
1327 if (unlikely(ieee80211_is_back_req(bar->frame_control)) && in carl9170_bar_check()
1328 skb->len >= sizeof(struct ieee80211_bar)) { in carl9170_bar_check()
1334 entry->skb = skb; in carl9170_bar_check()
1335 spin_lock_bh(&ar->bar_list_lock[queue]); in carl9170_bar_check()
1336 list_add_tail_rcu(&entry->list, &ar->bar_list[queue]); in carl9170_bar_check()
1337 spin_unlock_bh(&ar->bar_list_lock[queue]); in carl9170_bar_check()
1348 ar->tx_schedule = false; in carl9170_tx()
1355 for (i = 0; i < ar->hw->queues; i++) { in carl9170_tx()
1356 while (!skb_queue_empty(&ar->tx_pending[i])) { in carl9170_tx()
1357 skb = carl9170_tx_pick_skb(ar, &ar->tx_pending[i]); in carl9170_tx()
1366 atomic_inc(&ar->tx_total_pending); in carl9170_tx()
1373 skb_queue_tail(&ar->tx_status[q], skb); in carl9170_tx()
1393 ieee80211_queue_delayed_work(ar->hw, &ar->tx_janitor, in carl9170_tx()
1409 sta_info = (void *) sta->drv_priv; in carl9170_tx_ampdu_queue()
1412 agg = rcu_dereference(sta_info->agg[tid]); in carl9170_tx_ampdu_queue()
1417 spin_lock_bh(&agg->lock); in carl9170_tx_ampdu_queue()
1418 if (unlikely(agg->state < CARL9170_TID_STATE_IDLE)) in carl9170_tx_ampdu_queue()
1422 if (unlikely(!BAW_WITHIN(agg->bsn, CARL9170_BAW_BITS, seq))) in carl9170_tx_ampdu_queue()
1425 if (WARN_ON_ONCE(!BAW_WITHIN(agg->snx, CARL9170_BAW_BITS, seq))) in carl9170_tx_ampdu_queue()
1428 off = SEQ_DIFF(seq, agg->bsn); in carl9170_tx_ampdu_queue()
1429 if (WARN_ON_ONCE(test_and_set_bit(off, agg->bitmap))) in carl9170_tx_ampdu_queue()
1432 if (likely(BAW_WITHIN(agg->hsn, CARL9170_BAW_BITS, seq))) { in carl9170_tx_ampdu_queue()
1433 __skb_queue_tail(&agg->queue, skb); in carl9170_tx_ampdu_queue()
1434 agg->hsn = seq; in carl9170_tx_ampdu_queue()
1438 skb_queue_reverse_walk(&agg->queue, iter) { in carl9170_tx_ampdu_queue()
1442 __skb_queue_after(&agg->queue, iter, skb); in carl9170_tx_ampdu_queue()
1447 __skb_queue_head(&agg->queue, skb); in carl9170_tx_ampdu_queue()
1450 if (unlikely(agg->state != CARL9170_TID_STATE_XMIT)) { in carl9170_tx_ampdu_queue()
1451 if (agg->snx == carl9170_get_seq(skb_peek(&agg->queue))) { in carl9170_tx_ampdu_queue()
1452 agg->state = CARL9170_TID_STATE_XMIT; in carl9170_tx_ampdu_queue()
1457 spin_unlock_bh(&agg->lock); in carl9170_tx_ampdu_queue()
1463 spin_unlock_bh(&agg->lock); in carl9170_tx_ampdu_queue()
1467 txinfo->flags &= ~IEEE80211_TX_CTL_AMPDU; in carl9170_tx_ampdu_queue()
1469 ar->tx_dropped++; in carl9170_tx_ampdu_queue()
1477 struct ar9170 *ar = hw->priv; in carl9170_op_tx()
1479 struct ieee80211_sta *sta = control->sta; in carl9170_op_tx()
1487 vif = info->control.vif; in carl9170_op_tx()
1499 struct carl9170_sta_info *stai = (void *) sta->drv_priv; in carl9170_op_tx()
1500 atomic_inc(&stai->pending_frames); in carl9170_op_tx()
1503 if (info->flags & IEEE80211_TX_CTL_AMPDU) { in carl9170_op_tx()
1520 skb_queue_tail(&ar->tx_pending[queue], skb); in carl9170_op_tx()
1527 ar->tx_dropped++; in carl9170_op_tx()
1528 ieee80211_free_txskb(ar->hw, skb); in carl9170_op_tx()
1534 if (ar->tx_ampdu_schedule) in carl9170_tx_scheduler()
1537 if (ar->tx_schedule) in carl9170_tx_scheduler()
1554 cvif = rcu_dereference(ar->beacon_iter); in carl9170_pick_beaconing_vif()
1555 if (ar->vifs > 0 && cvif) { in carl9170_pick_beaconing_vif()
1557 list_for_each_entry_continue_rcu(cvif, &ar->vif_list, in carl9170_pick_beaconing_vif()
1559 if (cvif->active && cvif->enable_beacon) in carl9170_pick_beaconing_vif()
1562 } while (ar->beacon_enabled && i--); in carl9170_pick_beaconing_vif()
1569 RCU_INIT_POINTER(ar->beacon_iter, cvif); in carl9170_pick_beaconing_vif()
1582 rate = &txinfo->control.rates[0]; in carl9170_tx_beacon_physet()
1583 ht_rate = !!(txinfo->control.rates[0].flags & IEEE80211_TX_RC_MCS); in carl9170_tx_beacon_physet()
1595 if (rate->flags & IEEE80211_TX_RC_SHORT_GI) in carl9170_tx_beacon_physet()
1598 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) { in carl9170_tx_beacon_physet()
1601 } else if (rate->flags & IEEE80211_TX_RC_DUP_DATA) { in carl9170_tx_beacon_physet()
1606 SET_VAL(AR9170_MAC_BCN_HT2_LEN, *plcp, skb->len + FCS_LEN); in carl9170_tx_beacon_physet()
1609 *plcp |= ((skb->len + FCS_LEN) << (3 + 16)) + 0x0400; in carl9170_tx_beacon_physet()
1611 *plcp |= ((skb->len + FCS_LEN) << 16) + 0x0010; in carl9170_tx_beacon_physet()
1631 skb = ieee80211_beacon_get_tim(ar->hw, carl9170_get_vif(cvif), in carl9170_update_beacon()
1635 err = -ENOMEM; in carl9170_update_beacon()
1639 spin_lock_bh(&ar->beacon_lock); in carl9170_update_beacon()
1640 data = (__le32 *)skb->data; in carl9170_update_beacon()
1641 if (cvif->beacon) in carl9170_update_beacon()
1642 old = (__le32 *)cvif->beacon->data; in carl9170_update_beacon()
1644 off = cvif->id * AR9170_MAC_BCN_LENGTH_MAX; in carl9170_update_beacon()
1645 addr = ar->fw.beacon_addr + off; in carl9170_update_beacon()
1646 len = roundup(skb->len + FCS_LEN, 4); in carl9170_update_beacon()
1648 if ((off + len) > ar->fw.beacon_max_len) { in carl9170_update_beacon()
1650 wiphy_err(ar->hw->wiphy, "beacon does not " in carl9170_update_beacon()
1653 err = -EINVAL; in carl9170_update_beacon()
1659 wiphy_err(ar->hw->wiphy, "no support for beacons " in carl9170_update_beacon()
1664 err = -EMSGSIZE; in carl9170_update_beacon()
1677 for (i = 0; i < DIV_ROUND_UP(skb->len, 4); i++) { in carl9170_update_beacon()
1691 dev_kfree_skb_any(cvif->beacon); in carl9170_update_beacon()
1692 cvif->beacon = NULL; in carl9170_update_beacon()
1696 cvif->beacon = skb; in carl9170_update_beacon()
1697 spin_unlock_bh(&ar->beacon_lock); in carl9170_update_beacon()
1702 err = carl9170_bcn_ctrl(ar, cvif->id, in carl9170_update_beacon()
1704 addr, skb->len + FCS_LEN); in carl9170_update_beacon()
1714 spin_unlock_bh(&ar->beacon_lock); in carl9170_update_beacon()