developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 1 | From bd12a6bbc6783a69d6ab5630b7b7ffda53da88d5 Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Mon, 1 Apr 2024 17:00:21 +0800 |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 104/223] mtk: mt76: mt7996: enable ampdu limit to avoid BA |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 5 | bound issue |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 6 | |
| 7 | [Description] |
| 8 | When the station is MTK device and the peak is higher than 15G, the PPS |
| 9 | would exceed HW-RRO's bandwidth and lead to Rx fifo full and PER. When |
| 10 | a link occurs PER, it may occupy SSN and the other two bands are not |
| 11 | able to transmit. |
| 12 | |
| 13 | Limit AMPDU to 512 when satisify all of the following conditions |
| 14 | 1. BA winsize is 1024. |
| 15 | 2. At least one link use BW320 and its spatial stream is larger |
| 16 | than 3. |
| 17 | 3. At least one link use BW160 and its spatial stream is larger |
| 18 | than 3. |
| 19 | |
| 20 | By limiting AMPDU to 512, it can solve this issue. |
| 21 | 1. Reduce PPS so we can avoid Rx fifo full due to HW-RRO. |
| 22 | 2. If a bind occupy SSN, the other two bands can use the SSN |
| 23 | between 512 to 1024. |
| 24 | |
| 25 | [Release-log] |
| 26 | N/A |
| 27 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 28 | Change-Id: I64ea1d5df012c1eb9462391e5e9c20658ed7f4fe |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 29 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 30 | --- |
| 31 | mt76_connac_mcu.h | 1 + |
| 32 | mt7996/mcu.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++ |
| 33 | mt7996/mcu.h | 8 +++++ |
| 34 | 3 files changed, 95 insertions(+) |
| 35 | |
| 36 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 37 | index 1dcd1696..f6b472ef 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 38 | --- a/mt76_connac_mcu.h |
| 39 | +++ b/mt76_connac_mcu.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 40 | @@ -834,6 +834,7 @@ enum { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 41 | STA_REC_KEY_V3 = 0x27, |
| 42 | STA_REC_HDRT = 0x28, |
| 43 | STA_REC_HDR_TRANS = 0x2B, |
| 44 | + STA_REC_TX_CAP = 0x2f, |
| 45 | STA_REC_MAX_NUM |
| 46 | }; |
| 47 | |
| 48 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 49 | index 54b0272c..8034c8ab 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 50 | --- a/mt7996/mcu.c |
| 51 | +++ b/mt7996/mcu.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 52 | @@ -1349,6 +1349,85 @@ mt7996_mcu_sta_ba(struct mt7996_dev *dev, struct mt76_vif *mvif, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 53 | MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true); |
| 54 | } |
| 55 | |
| 56 | +static int |
| 57 | +mt7996_mcu_sta_tx_cap(struct mt7996_dev *dev, struct mt76_vif *mvif, |
| 58 | + struct mt76_wcid *wcid) |
| 59 | +{ |
| 60 | + struct sta_rec_tx_cap *tx_cap; |
| 61 | + struct sk_buff *skb; |
| 62 | + struct tlv *tlv; |
| 63 | + |
| 64 | + skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, mvif, wcid, |
| 65 | + MT7996_STA_UPDATE_MAX_SIZE); |
| 66 | + if (IS_ERR(skb)) |
| 67 | + return PTR_ERR(skb); |
| 68 | + |
| 69 | + tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_TX_CAP, sizeof(*tx_cap)); |
| 70 | + |
| 71 | + tx_cap = (struct sta_rec_tx_cap *)tlv; |
| 72 | + tx_cap->ampdu_limit_en = true; |
| 73 | + |
| 74 | + dev_info(dev->mt76.dev, "%s: limit wcid %d ampdu to 512\n", __func__, wcid->idx); |
| 75 | + |
| 76 | + return mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| 77 | + MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true); |
| 78 | +} |
| 79 | + |
| 80 | +static bool mt7996_check_limit_ampdu_en(struct ieee80211_ampdu_params *params) { |
| 81 | + struct ieee80211_sta *sta = params->sta; |
| 82 | + struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 83 | + unsigned long valid_links = sta->valid_links ?: BIT(0); |
| 84 | + unsigned int link_id; |
| 85 | + bool BW320 = false, BW160 = false; |
| 86 | + |
| 87 | + if (params->buf_size < 1024) |
| 88 | + return false; |
| 89 | + |
| 90 | + for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 91 | + struct ieee80211_link_sta __rcu *link = |
| 92 | + link_sta_dereference_protected(sta, link_id); |
| 93 | + struct mt7996_bss_conf *mconf = |
| 94 | + mconf_dereference_protected(msta->vif, link_id); |
| 95 | + struct mt76_phy *phy = mconf->phy->mt76; |
| 96 | + struct ieee80211_eht_mcs_nss_supp_bw *ss = NULL; |
| 97 | + u8 sta_bw, ap_nss, sta_nss; |
| 98 | + |
| 99 | + switch (phy->chandef.width) { |
| 100 | + case NL80211_CHAN_WIDTH_160: |
| 101 | + if (link->bandwidth >= IEEE80211_STA_RX_BW_160) { |
| 102 | + ss = &link->eht_cap.eht_mcs_nss_supp.bw._160; |
| 103 | + sta_bw = NL80211_CHAN_WIDTH_160; |
| 104 | + } |
| 105 | + break; |
| 106 | + case NL80211_CHAN_WIDTH_320: |
| 107 | + if (link->bandwidth == IEEE80211_STA_RX_BW_320) { |
| 108 | + ss = &link->eht_cap.eht_mcs_nss_supp.bw._320; |
| 109 | + sta_bw = NL80211_CHAN_WIDTH_320; |
| 110 | + } |
| 111 | + break; |
| 112 | + default: |
| 113 | + break; |
| 114 | + } |
| 115 | + |
| 116 | + if (!ss) |
| 117 | + continue; |
| 118 | + |
| 119 | + ap_nss = hweight8(phy->antenna_mask); |
| 120 | + sta_nss = max(u8_get_bits(ss->rx_tx_mcs11_max_nss, IEEE80211_EHT_MCS_NSS_RX), |
| 121 | + u8_get_bits(ss->rx_tx_mcs13_max_nss, IEEE80211_EHT_MCS_NSS_RX)); |
| 122 | + |
| 123 | + if (min(ap_nss, sta_nss) <= 2) |
| 124 | + continue; |
| 125 | + |
| 126 | + if (sta_bw == NL80211_CHAN_WIDTH_160) |
| 127 | + BW160 = true; |
| 128 | + else if (sta_bw == NL80211_CHAN_WIDTH_320) |
| 129 | + BW320 = true; |
| 130 | + } |
| 131 | + |
| 132 | + return BW320 && BW160; |
| 133 | +} |
| 134 | + |
| 135 | /** starec & wtbl **/ |
| 136 | int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev, |
| 137 | struct ieee80211_ampdu_params *params, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 138 | @@ -1358,6 +1437,7 @@ int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 139 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 140 | unsigned long valid_links = sta->valid_links ?: BIT(0); |
| 141 | unsigned int link_id; |
| 142 | + bool limit_ampdu_en = mt7996_check_limit_ampdu_en(params); |
| 143 | |
| 144 | for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 145 | struct mt7996_link_sta *mlink = |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 146 | @@ -1373,6 +1453,12 @@ int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 147 | &mlink->wcid, enable, true); |
| 148 | if (ret) |
| 149 | return ret; |
| 150 | + |
| 151 | + if (limit_ampdu_en) { |
| 152 | + ret = mt7996_mcu_sta_tx_cap(dev, &mconf->mt76, &mlink->wcid); |
| 153 | + if (ret) |
| 154 | + return ret; |
| 155 | + } |
| 156 | } |
| 157 | |
| 158 | return 0; |
| 159 | diff --git a/mt7996/mcu.h b/mt7996/mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 160 | index 9903d88e..f9f04680 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 161 | --- a/mt7996/mcu.h |
| 162 | +++ b/mt7996/mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 163 | @@ -573,6 +573,13 @@ struct sta_rec_ba_uni { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 164 | u8 __rsv[3]; |
| 165 | } __packed; |
| 166 | |
| 167 | +struct sta_rec_tx_cap { |
| 168 | + __le16 tag; |
| 169 | + __le16 len; |
| 170 | + u8 ampdu_limit_en; |
| 171 | + u8 rsv[3]; |
| 172 | +} __packed; |
| 173 | + |
| 174 | struct sta_rec_eht { |
| 175 | __le16 tag; |
| 176 | __le16 len; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 177 | @@ -939,6 +946,7 @@ enum { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 178 | sizeof(struct sta_rec_eht) + \ |
| 179 | sizeof(struct sta_rec_hdrt) + \ |
| 180 | sizeof(struct sta_rec_hdr_trans) + \ |
| 181 | + sizeof(struct sta_rec_tx_cap) + \ |
| 182 | sizeof(struct tlv)) |
| 183 | |
| 184 | #define MT7996_MAX_BEACON_SIZE 1338 |
| 185 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 186 | 2.45.2 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 187 | |