mt76: move mt76_check_agg_ssn to driver tx_prepare calls
authorFelix Fietkau <nbd@nbd.name>
Tue, 28 Jul 2020 18:41:09 +0000 (20:41 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 24 Sep 2020 16:10:14 +0000 (18:10 +0200)
mt7615 and newer drivers do not need this, since they use sequence number offload
Moving this code also reduces the number of callsites to make it easier to review

Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76.h
drivers/net/wireless/mediatek/mt76/mt7603/mac.c
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
drivers/net/wireless/mediatek/mt76/tx.c

index 455ecdd..3f6b39d 100644 (file)
@@ -905,6 +905,7 @@ void mt76_txq_remove(struct mt76_dev *dev, struct ieee80211_txq *txq);
 void mt76_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
 void mt76_stop_tx_queues(struct mt76_dev *dev, struct ieee80211_sta *sta,
                         bool send_bar);
+void mt76_tx_check_agg_ssn(struct ieee80211_sta *sta, struct sk_buff *skb);
 void mt76_txq_schedule(struct mt76_phy *phy, enum mt76_txq_id qid);
 void mt76_txq_schedule_all(struct mt76_phy *phy);
 void mt76_tx_tasklet(unsigned long data);
index 8060c15..625dc6d 100644 (file)
@@ -1036,6 +1036,8 @@ int mt7603_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
                                    IEEE80211_TX_CTL_CLEAR_PS_FILT)) ||
                    (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE))
                        mt7603_wtbl_set_ps(dev, msta, false);
+
+               mt76_tx_check_agg_ssn(sta, tx_info->skb);
        }
 
        pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
index e4e03be..af2e6ff 100644 (file)
@@ -349,6 +349,8 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,
 
        memset(txwi, 0, sizeof(*txwi));
 
+       mt76_tx_check_agg_ssn(sta, skb);
+
        if (!info->control.hw_key && wcid && wcid->hw_key_idx != 0xff &&
            ieee80211_has_protected(hdr->frame_control)) {
                wcid = NULL;
index 40ec55a..d8252e2 100644 (file)
@@ -83,17 +83,27 @@ mt76_txq_get_qid(struct ieee80211_txq *txq)
        return txq->ac;
 }
 
-static void
-mt76_check_agg_ssn(struct mt76_txq *mtxq, struct sk_buff *skb)
+void
+mt76_tx_check_agg_ssn(struct ieee80211_sta *sta, struct sk_buff *skb)
 {
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+       struct ieee80211_txq *txq;
+       struct mt76_txq *mtxq;
+       u8 tid;
 
-       if (!ieee80211_is_data_qos(hdr->frame_control) ||
+       if (!sta || !ieee80211_is_data_qos(hdr->frame_control) ||
            !ieee80211_is_data_present(hdr->frame_control))
                return;
 
+       tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
+       txq = sta->txq[tid];
+       mtxq = (struct mt76_txq *)txq->drv_priv;
+       if (!mtxq->aggr)
+               return;
+
        mtxq->agg_ssn = le16_to_cpu(hdr->seq_ctrl) + 0x10;
 }
+EXPORT_SYMBOL_GPL(mt76_tx_check_agg_ssn);
 
 void
 mt76_tx_status_lock(struct mt76_dev *dev, struct sk_buff_head *list)
@@ -288,19 +298,6 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
                ieee80211_get_tx_rates(info->control.vif, sta, skb,
                                       info->control.rates, 1);
 
-       if (sta && ieee80211_is_data_qos(hdr->frame_control)) {
-               struct ieee80211_txq *txq;
-               struct mt76_txq *mtxq;
-               u8 tid;
-
-               tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
-               txq = sta->txq[tid];
-               mtxq = (struct mt76_txq *)txq->drv_priv;
-
-               if (mtxq->aggr)
-                       mt76_check_agg_ssn(mtxq, skb);
-       }
-
        if (ext_phy)
                info->hw_queue |= MT_TX_HW_QUEUE_EXT_PHY;
 
@@ -390,9 +387,6 @@ mt76_release_buffered_frames(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
                        if (!skb)
                                break;
 
-                       if (mtxq->aggr)
-                               mt76_check_agg_ssn(mtxq, skb);
-
                        nframes--;
                        if (last_skb)
                                mt76_queue_ps_skb(dev, sta, last_skb, false);
@@ -446,9 +440,6 @@ mt76_txq_send_burst(struct mt76_phy *phy, struct mt76_sw_queue *sq,
        ampdu = IEEE80211_SKB_CB(skb)->flags & IEEE80211_TX_CTL_AMPDU;
        limit = ampdu ? 16 : 3;
 
-       if (ampdu)
-               mt76_check_agg_ssn(mtxq, skb);
-
        idx = dev->queue_ops->tx_queue_skb(dev, qid, skb, wcid, txq->sta);
 
        if (idx < 0)
@@ -479,9 +470,6 @@ mt76_txq_send_burst(struct mt76_phy *phy, struct mt76_sw_queue *sq,
 
                info->control.rates[0] = tx_rate;
 
-               if (cur_ampdu)
-                       mt76_check_agg_ssn(mtxq, skb);
-
                idx = dev->queue_ops->tx_queue_skb(dev, qid, skb, wcid,
                                                   txq->sta);
                if (idx < 0)