developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From af0b14e475466b4f353c20af228c381c695ec3f9 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 | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 116/199] mtk: mt76: mt7996: enable ampdu limit to avoid BA |
| 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 | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 28 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 29 | --- |
| 30 | mt76_connac_mcu.h | 1 + |
| 31 | mt7996/mcu.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++ |
| 32 | mt7996/mcu.h | 8 +++++ |
| 33 | 3 files changed, 95 insertions(+) |
| 34 | |
| 35 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 36 | index f6a0d328..6e3324f5 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 37 | --- a/mt76_connac_mcu.h |
| 38 | +++ b/mt76_connac_mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 39 | @@ -829,6 +829,7 @@ enum { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 40 | STA_REC_KEY_V3 = 0x27, |
| 41 | STA_REC_HDRT = 0x28, |
| 42 | STA_REC_HDR_TRANS = 0x2B, |
| 43 | + STA_REC_TX_CAP = 0x2f, |
| 44 | STA_REC_MAX_NUM |
| 45 | }; |
| 46 | |
| 47 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 48 | index 340b6637..f97acfb2 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 49 | --- a/mt7996/mcu.c |
| 50 | +++ b/mt7996/mcu.c |
| 51 | @@ -1344,6 +1344,85 @@ mt7996_mcu_sta_ba(struct mt7996_dev *dev, struct mt76_vif *mvif, |
| 52 | MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true); |
| 53 | } |
| 54 | |
| 55 | +static int |
| 56 | +mt7996_mcu_sta_tx_cap(struct mt7996_dev *dev, struct mt76_vif *mvif, |
| 57 | + struct mt76_wcid *wcid) |
| 58 | +{ |
| 59 | + struct sta_rec_tx_cap *tx_cap; |
| 60 | + struct sk_buff *skb; |
| 61 | + struct tlv *tlv; |
| 62 | + |
| 63 | + skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, mvif, wcid, |
| 64 | + MT7996_STA_UPDATE_MAX_SIZE); |
| 65 | + if (IS_ERR(skb)) |
| 66 | + return PTR_ERR(skb); |
| 67 | + |
| 68 | + tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_TX_CAP, sizeof(*tx_cap)); |
| 69 | + |
| 70 | + tx_cap = (struct sta_rec_tx_cap *)tlv; |
| 71 | + tx_cap->ampdu_limit_en = true; |
| 72 | + |
| 73 | + dev_info(dev->mt76.dev, "%s: limit wcid %d ampdu to 512\n", __func__, wcid->idx); |
| 74 | + |
| 75 | + return mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| 76 | + MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true); |
| 77 | +} |
| 78 | + |
| 79 | +static bool mt7996_check_limit_ampdu_en(struct ieee80211_ampdu_params *params) { |
| 80 | + struct ieee80211_sta *sta = params->sta; |
| 81 | + struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 82 | + unsigned long valid_links = sta->valid_links ?: BIT(0); |
| 83 | + unsigned int link_id; |
| 84 | + bool BW320 = false, BW160 = false; |
| 85 | + |
| 86 | + if (params->buf_size < 1024) |
| 87 | + return false; |
| 88 | + |
| 89 | + for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 90 | + struct ieee80211_link_sta __rcu *link = |
| 91 | + link_sta_dereference_protected(sta, link_id); |
| 92 | + struct mt7996_bss_conf *mconf = |
| 93 | + mconf_dereference_protected(msta->vif, link_id); |
| 94 | + struct mt76_phy *phy = mconf->phy->mt76; |
| 95 | + struct ieee80211_eht_mcs_nss_supp_bw *ss = NULL; |
| 96 | + u8 sta_bw, ap_nss, sta_nss; |
| 97 | + |
| 98 | + switch (phy->chandef.width) { |
| 99 | + case NL80211_CHAN_WIDTH_160: |
| 100 | + if (link->bandwidth >= IEEE80211_STA_RX_BW_160) { |
| 101 | + ss = &link->eht_cap.eht_mcs_nss_supp.bw._160; |
| 102 | + sta_bw = NL80211_CHAN_WIDTH_160; |
| 103 | + } |
| 104 | + break; |
| 105 | + case NL80211_CHAN_WIDTH_320: |
| 106 | + if (link->bandwidth == IEEE80211_STA_RX_BW_320) { |
| 107 | + ss = &link->eht_cap.eht_mcs_nss_supp.bw._320; |
| 108 | + sta_bw = NL80211_CHAN_WIDTH_320; |
| 109 | + } |
| 110 | + break; |
| 111 | + default: |
| 112 | + break; |
| 113 | + } |
| 114 | + |
| 115 | + if (!ss) |
| 116 | + continue; |
| 117 | + |
| 118 | + ap_nss = hweight8(phy->antenna_mask); |
| 119 | + sta_nss = max(u8_get_bits(ss->rx_tx_mcs11_max_nss, IEEE80211_EHT_MCS_NSS_RX), |
| 120 | + u8_get_bits(ss->rx_tx_mcs13_max_nss, IEEE80211_EHT_MCS_NSS_RX)); |
| 121 | + |
| 122 | + if (min(ap_nss, sta_nss) <= 2) |
| 123 | + continue; |
| 124 | + |
| 125 | + if (sta_bw == NL80211_CHAN_WIDTH_160) |
| 126 | + BW160 = true; |
| 127 | + else if (sta_bw == NL80211_CHAN_WIDTH_320) |
| 128 | + BW320 = true; |
| 129 | + } |
| 130 | + |
| 131 | + return BW320 && BW160; |
| 132 | +} |
| 133 | + |
| 134 | /** starec & wtbl **/ |
| 135 | int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev, |
| 136 | struct ieee80211_ampdu_params *params, |
| 137 | @@ -1353,6 +1432,7 @@ int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev, |
| 138 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 139 | unsigned long valid_links = sta->valid_links ?: BIT(0); |
| 140 | unsigned int link_id; |
| 141 | + bool limit_ampdu_en = mt7996_check_limit_ampdu_en(params); |
| 142 | |
| 143 | for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 144 | struct mt7996_link_sta *mlink = |
| 145 | @@ -1368,6 +1448,12 @@ int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev, |
| 146 | &mlink->wcid, enable, true); |
| 147 | if (ret) |
| 148 | return ret; |
| 149 | + |
| 150 | + if (limit_ampdu_en) { |
| 151 | + ret = mt7996_mcu_sta_tx_cap(dev, &mconf->mt76, &mlink->wcid); |
| 152 | + if (ret) |
| 153 | + return ret; |
| 154 | + } |
| 155 | } |
| 156 | |
| 157 | return 0; |
| 158 | diff --git a/mt7996/mcu.h b/mt7996/mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 159 | index 9903d88e..f9f04680 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 160 | --- a/mt7996/mcu.h |
| 161 | +++ b/mt7996/mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 162 | @@ -573,6 +573,13 @@ struct sta_rec_ba_uni { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 163 | u8 __rsv[3]; |
| 164 | } __packed; |
| 165 | |
| 166 | +struct sta_rec_tx_cap { |
| 167 | + __le16 tag; |
| 168 | + __le16 len; |
| 169 | + u8 ampdu_limit_en; |
| 170 | + u8 rsv[3]; |
| 171 | +} __packed; |
| 172 | + |
| 173 | struct sta_rec_eht { |
| 174 | __le16 tag; |
| 175 | __le16 len; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 176 | @@ -939,6 +946,7 @@ enum { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 177 | sizeof(struct sta_rec_eht) + \ |
| 178 | sizeof(struct sta_rec_hdrt) + \ |
| 179 | sizeof(struct sta_rec_hdr_trans) + \ |
| 180 | + sizeof(struct sta_rec_tx_cap) + \ |
| 181 | sizeof(struct tlv)) |
| 182 | |
| 183 | #define MT7996_MAX_BEACON_SIZE 1338 |
| 184 | -- |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 185 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 186 | |