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