wifi: rtlwifi: rtl8192cu: Fix TX aggregation
authorBitterblue Smith <rtl8821cerfe2@gmail.com>
Thu, 15 Feb 2024 18:57:59 +0000 (20:57 +0200)
committerKalle Valo <kvalo@kernel.org>
Wed, 21 Feb 2024 18:54:57 +0000 (20:54 +0200)
rtl8192cu is checking rtl_mac.tids when deciding if it should enable
aggregation. This is wrong because rtl_mac.tids is not initialised
anywhere. Check rtl_sta_info.tids instead, which is initialised.

Also, when enabling aggregation also enable RTS. The vendor driver does
this, my router does this. It seems like the thing to do.

Also also, it seems right to set the AMPDU density only when enabling
aggregation.

Also also also, delete the unused member rtl_mac.tids and the unused
macros RTL_AGG_ON and RTL_AGG_OFF.

Naturally, with working AMPDU the download/upload speeds are better.
Before: 59/32 Mbps.
After:  68/46 Mbps.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/4e936334-5f81-403f-a495-0628ebfb6903@gmail.com
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h
drivers/net/wireless/realtek/rtlwifi/wifi.h

index 4856ed40005b0408f51dc42ef390dbc701ca3896..aa702ba7c9f5402b9cef50fabc46be22f3d018df 100644 (file)
@@ -482,8 +482,9 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
        struct rtl_priv *rtlpriv = rtl_priv(hw);
        struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
        struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
-       u8 *qc = ieee80211_get_qos_ctl(hdr);
-       u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
+       struct rtl_sta_info *sta_entry;
+       u8 agg_state = RTL_AGG_STOP;
+       u8 ampdu_density = 0;
        u16 seq_number;
        __le16 fc = hdr->frame_control;
        u8 rate_flag = info->control.rates[0].flags;
@@ -492,6 +493,7 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
                                                skb_get_queue_mapping(skb));
        u8 *txdesc8;
        __le32 *txdesc;
+       u8 tid;
 
        seq_number = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
        rtl_get_tcb_desc(hw, info, sta, skb, tcb_desc);
@@ -505,10 +507,21 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
        set_tx_desc_tx_rate(txdesc, tcb_desc->hw_rate);
        if (tcb_desc->use_shortgi || tcb_desc->use_shortpreamble)
                set_tx_desc_data_shortgi(txdesc, 1);
-       if (mac->tids[tid].agg.agg_state == RTL_AGG_ON &&
-                   info->flags & IEEE80211_TX_CTL_AMPDU) {
+
+       if (sta) {
+               sta_entry = (struct rtl_sta_info *)sta->drv_priv;
+               tid = ieee80211_get_tid(hdr);
+               agg_state = sta_entry->tids[tid].agg.agg_state;
+               ampdu_density = sta->deflink.ht_cap.ampdu_density;
+       }
+
+       if (agg_state == RTL_AGG_OPERATIONAL &&
+           info->flags & IEEE80211_TX_CTL_AMPDU) {
                set_tx_desc_agg_enable(txdesc, 1);
                set_tx_desc_max_agg_num(txdesc, 0x14);
+               set_tx_desc_ampdu_density(txdesc, ampdu_density);
+               tcb_desc->rts_enable = 1;
+               tcb_desc->rts_rate = DESC_RATE24M;
        } else {
                set_tx_desc_agg_break(txdesc, 1);
        }
@@ -543,14 +556,6 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
                set_tx_desc_data_bw(txdesc, 0);
                set_tx_desc_data_sc(txdesc, 0);
        }
-       rcu_read_lock();
-       sta = ieee80211_find_sta(mac->vif, mac->bssid);
-       if (sta) {
-               u8 ampdu_density = sta->deflink.ht_cap.ampdu_density;
-
-               set_tx_desc_ampdu_density(txdesc, ampdu_density);
-       }
-       rcu_read_unlock();
        if (info->control.hw_key) {
                struct ieee80211_key_conf *keyconf = info->control.hw_key;
 
index 8678fa0043f436ded51f1774f4be514e9035c58a..09e61dc0f3171b5812f7b99e0476e6c87c36fb57 100644 (file)
@@ -10,8 +10,6 @@
 #define RTL92C_SIZE_MAX_RX_BUFFER              15360   /* 8192 */
 #define RX_DRV_INFO_SIZE_UNIT                  8
 
-#define RTL_AGG_ON                             1
-
 enum usb_rx_agg_mode {
        USB_RX_AGG_DISABLE,
        USB_RX_AGG_DMA,
index 01df00a43cdb7e871877735fa587d6ea0dfebec8..f388d13e2ba8b854ef32874591b879e4be74875d 100644 (file)
@@ -1397,8 +1397,6 @@ struct rtl_phy {
 #define RTL_AGG_PROGRESS                       1
 #define RTL_AGG_START                          2
 #define RTL_AGG_OPERATIONAL                    3
-#define RTL_AGG_OFF                            0
-#define RTL_AGG_ON                             1
 #define RTL_RX_AGG_START                       1
 #define RTL_RX_AGG_STOP                                0
 #define RTL_AGG_EMPTYING_HW_QUEUE_ADDBA                2
@@ -1473,7 +1471,6 @@ struct rtl_mac {
        enum nl80211_iftype opmode;
 
        /*Probe Beacon management */
-       struct rtl_tid_data tids[MAX_TID_COUNT];
        enum rtl_link_state link_state;
 
        int n_channels;