diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/mvm/tx.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/tx.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/tx.c b/drivers/net/wireless/iwlwifi/mvm/tx.c index 90378c217bc7..76ee486039d7 100644 --- a/drivers/net/wireless/iwlwifi/mvm/tx.c +++ b/drivers/net/wireless/iwlwifi/mvm/tx.c | |||
@@ -659,8 +659,14 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm, | |||
659 | rcu_read_lock(); | 659 | rcu_read_lock(); |
660 | 660 | ||
661 | sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); | 661 | sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); |
662 | /* | ||
663 | * sta can't be NULL otherwise it'd mean that the sta has been freed in | ||
664 | * the firmware while we still have packets for it in the Tx queues. | ||
665 | */ | ||
666 | if (WARN_ON_ONCE(!sta)) | ||
667 | goto out; | ||
662 | 668 | ||
663 | if (!IS_ERR_OR_NULL(sta)) { | 669 | if (!IS_ERR(sta)) { |
664 | mvmsta = iwl_mvm_sta_from_mac80211(sta); | 670 | mvmsta = iwl_mvm_sta_from_mac80211(sta); |
665 | 671 | ||
666 | if (tid != IWL_TID_NON_QOS) { | 672 | if (tid != IWL_TID_NON_QOS) { |
@@ -675,7 +681,6 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm, | |||
675 | spin_unlock_bh(&mvmsta->lock); | 681 | spin_unlock_bh(&mvmsta->lock); |
676 | } | 682 | } |
677 | } else { | 683 | } else { |
678 | sta = NULL; | ||
679 | mvmsta = NULL; | 684 | mvmsta = NULL; |
680 | } | 685 | } |
681 | 686 | ||
@@ -683,42 +688,38 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm, | |||
683 | * If the txq is not an AMPDU queue, there is no chance we freed | 688 | * If the txq is not an AMPDU queue, there is no chance we freed |
684 | * several skbs. Check that out... | 689 | * several skbs. Check that out... |
685 | */ | 690 | */ |
686 | if (txq_id < mvm->first_agg_queue && !WARN_ON(skb_freed > 1) && | 691 | if (txq_id >= mvm->first_agg_queue) |
687 | atomic_sub_and_test(skb_freed, &mvm->pending_frames[sta_id])) { | 692 | goto out; |
688 | if (mvmsta) { | 693 | |
689 | /* | 694 | /* We can't free more than one frame at once on a shared queue */ |
690 | * If there are no pending frames for this STA, notify | 695 | WARN_ON(skb_freed > 1); |
691 | * mac80211 that this station can go to sleep in its | 696 | |
692 | * STA table. | 697 | /* If we have still frames from this STA nothing to do here */ |
693 | */ | 698 | if (!atomic_sub_and_test(skb_freed, &mvm->pending_frames[sta_id])) |
694 | if (mvmsta->vif->type == NL80211_IFTYPE_AP) | 699 | goto out; |
695 | ieee80211_sta_block_awake(mvm->hw, sta, false); | 700 | |
696 | /* | 701 | if (mvmsta && mvmsta->vif->type == NL80211_IFTYPE_AP) { |
697 | * We might very well have taken mvmsta pointer while | 702 | /* |
698 | * the station was being removed. The remove flow might | 703 | * If there are no pending frames for this STA, notify |
699 | * have seen a pending_frame (because we didn't take | 704 | * mac80211 that this station can go to sleep in its |
700 | * the lock) even if now the queues are drained. So make | 705 | * STA table. |
701 | * really sure now that this the station is not being | 706 | * If mvmsta is not NULL, sta is valid. |
702 | * removed. If it is, run the drain worker to remove it. | 707 | */ |
703 | */ | 708 | ieee80211_sta_block_awake(mvm->hw, sta, false); |
704 | spin_lock_bh(&mvmsta->lock); | ||
705 | sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); | ||
706 | if (!sta || PTR_ERR(sta) == -EBUSY) { | ||
707 | /* | ||
708 | * Station disappeared in the meantime: | ||
709 | * so we are draining. | ||
710 | */ | ||
711 | set_bit(sta_id, mvm->sta_drained); | ||
712 | schedule_work(&mvm->sta_drained_wk); | ||
713 | } | ||
714 | spin_unlock_bh(&mvmsta->lock); | ||
715 | } else if (!mvmsta && PTR_ERR(sta) == -EBUSY) { | ||
716 | /* Tx response without STA, so we are draining */ | ||
717 | set_bit(sta_id, mvm->sta_drained); | ||
718 | schedule_work(&mvm->sta_drained_wk); | ||
719 | } | ||
720 | } | 709 | } |
721 | 710 | ||
711 | if (PTR_ERR(sta) == -EBUSY || PTR_ERR(sta) == -ENOENT) { | ||
712 | /* | ||
713 | * We are draining and this was the last packet - pre_rcu_remove | ||
714 | * has been called already. We might be after the | ||
715 | * synchronize_net already. | ||
716 | * Don't rely on iwl_mvm_rm_sta to see the empty Tx queues. | ||
717 | */ | ||
718 | set_bit(sta_id, mvm->sta_drained); | ||
719 | schedule_work(&mvm->sta_drained_wk); | ||
720 | } | ||
721 | |||
722 | out: | ||
722 | rcu_read_unlock(); | 723 | rcu_read_unlock(); |
723 | } | 724 | } |
724 | 725 | ||
@@ -821,16 +822,12 @@ int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb, | |||
821 | struct iwl_mvm_ba_notif *ba_notif = (void *)pkt->data; | 822 | struct iwl_mvm_ba_notif *ba_notif = (void *)pkt->data; |
822 | struct sk_buff_head reclaimed_skbs; | 823 | struct sk_buff_head reclaimed_skbs; |
823 | struct iwl_mvm_tid_data *tid_data; | 824 | struct iwl_mvm_tid_data *tid_data; |
824 | struct ieee80211_tx_info *info; | ||
825 | struct ieee80211_sta *sta; | 825 | struct ieee80211_sta *sta; |
826 | struct iwl_mvm_sta *mvmsta; | 826 | struct iwl_mvm_sta *mvmsta; |
827 | struct ieee80211_hdr *hdr; | ||
828 | struct sk_buff *skb; | 827 | struct sk_buff *skb; |
829 | int sta_id, tid, freed; | 828 | int sta_id, tid, freed; |
830 | |||
831 | /* "flow" corresponds to Tx queue */ | 829 | /* "flow" corresponds to Tx queue */ |
832 | u16 scd_flow = le16_to_cpu(ba_notif->scd_flow); | 830 | u16 scd_flow = le16_to_cpu(ba_notif->scd_flow); |
833 | |||
834 | /* "ssn" is start of block-ack Tx window, corresponds to index | 831 | /* "ssn" is start of block-ack Tx window, corresponds to index |
835 | * (in Tx queue's circular buffer) of first TFD/frame in window */ | 832 | * (in Tx queue's circular buffer) of first TFD/frame in window */ |
836 | u16 ba_resp_scd_ssn = le16_to_cpu(ba_notif->scd_ssn); | 833 | u16 ba_resp_scd_ssn = le16_to_cpu(ba_notif->scd_ssn); |
@@ -887,22 +884,26 @@ int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb, | |||
887 | freed = 0; | 884 | freed = 0; |
888 | 885 | ||
889 | skb_queue_walk(&reclaimed_skbs, skb) { | 886 | skb_queue_walk(&reclaimed_skbs, skb) { |
890 | hdr = (struct ieee80211_hdr *)skb->data; | 887 | struct ieee80211_hdr *hdr = (void *)skb->data; |
888 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
891 | 889 | ||
892 | if (ieee80211_is_data_qos(hdr->frame_control)) | 890 | if (ieee80211_is_data_qos(hdr->frame_control)) |
893 | freed++; | 891 | freed++; |
894 | else | 892 | else |
895 | WARN_ON_ONCE(1); | 893 | WARN_ON_ONCE(1); |
896 | 894 | ||
897 | info = IEEE80211_SKB_CB(skb); | ||
898 | iwl_trans_free_tx_cmd(mvm->trans, info->driver_data[1]); | 895 | iwl_trans_free_tx_cmd(mvm->trans, info->driver_data[1]); |
899 | 896 | ||
897 | memset(&info->status, 0, sizeof(info->status)); | ||
898 | /* Packet was transmitted successfully, failures come as single | ||
899 | * frames because before failing a frame the firmware transmits | ||
900 | * it without aggregation at least once. | ||
901 | */ | ||
902 | info->flags |= IEEE80211_TX_STAT_ACK; | ||
903 | |||
900 | if (freed == 1) { | 904 | if (freed == 1) { |
901 | /* this is the first skb we deliver in this batch */ | 905 | /* this is the first skb we deliver in this batch */ |
902 | /* put the rate scaling data there */ | 906 | /* put the rate scaling data there */ |
903 | info = IEEE80211_SKB_CB(skb); | ||
904 | memset(&info->status, 0, sizeof(info->status)); | ||
905 | info->flags |= IEEE80211_TX_STAT_ACK; | ||
906 | info->flags |= IEEE80211_TX_STAT_AMPDU; | 907 | info->flags |= IEEE80211_TX_STAT_AMPDU; |
907 | info->status.ampdu_ack_len = ba_notif->txed_2_done; | 908 | info->status.ampdu_ack_len = ba_notif->txed_2_done; |
908 | info->status.ampdu_len = ba_notif->txed; | 909 | info->status.ampdu_len = ba_notif->txed; |