blob: 29f951041b4f3d4694d8d989d058feafe866d5e0 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 6b95665d9e183c522e051a18177afe8b91ea817c Mon Sep 17 00:00:00 2001
2From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Wed, 26 Jun 2024 19:09:46 +0800
4Subject: [PATCH 167/199] mtk: mt76: mt7996: rework the setting flow of starec
5 RA and MLD tags
6
71. STA_REC_RA and STA_REC_MLD tags need to be set when newly is true,
8 so that FW can correctly set non-setup link(s) to powersave mode when
9 the peer is a MLSR MLD STA. (reported by Peter)
10
112. This patch also tries to fix random EAPOL timeout issue.
12
13Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
14---
15 mt7996/main.c | 4 --
16 mt7996/mcu.c | 187 +++++++++++++++++++++---------------------------
17 mt7996/mcu.h | 3 +
18 mt7996/mt7996.h | 2 -
19 4 files changed, 83 insertions(+), 113 deletions(-)
20
21diff --git a/mt7996/main.c b/mt7996/main.c
22index 35a77609..b5d45d19 100644
23--- a/mt7996/main.c
24+++ b/mt7996/main.c
25@@ -1318,10 +1318,6 @@ mt7996_mac_sta_add_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
26 mtxq->wcid = mlink->wcid.idx;
27 }
28
29- ret = mt7996_mcu_add_mld_sta(dev, vif, sta, add);
30- if (ret)
31- goto error;
32-
33 return 0;
34 error:
35 mt7996_mac_sta_remove_links(dev, vif, sta, add);
36diff --git a/mt7996/mcu.c b/mt7996/mcu.c
37index 54295414..9b3c6e3d 100644
38--- a/mt7996/mcu.c
39+++ b/mt7996/mcu.c
40@@ -2911,6 +2911,77 @@ int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev,
41 return mt7996_mcu_add_rate_ctrl_fixed(dev, conf, mconf, link_sta, mlink);
42 }
43
44+static void
45+mt7996_mcu_sta_mld_setup_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
46+ struct ieee80211_sta *sta, unsigned long valid_links)
47+{
48+ struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
49+ struct sta_rec_mld_setup *mld_setup;
50+ struct mld_setup_link *mld_setup_link;
51+ struct mt7996_link_sta *mlink;
52+ struct mt7996_bss_conf *mconf;
53+ struct tlv *tlv;
54+ unsigned int link_id;
55+ struct ieee80211_vif *vif = container_of((void *)msta->vif, struct ieee80211_vif,
56+ drv_priv);
57+
58+ mlink = mlink_dereference_protected(msta, msta->pri_link);
59+ if (!mlink)
60+ return;
61+
62+ tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_MLD,
63+ sizeof(*mld_setup) +
64+ sizeof(struct mld_setup_link) *
65+ hweight16(valid_links));
66+
67+ mld_setup = (struct sta_rec_mld_setup *)tlv;
68+ memcpy(mld_setup->mld_addr, sta->addr, ETH_ALEN);
69+ mld_setup->setup_wcid = cpu_to_le16(mlink->wcid.idx);
70+ mld_setup->primary_id = cpu_to_le16(mlink->wcid.idx);
71+ if (msta->sec_link != msta->pri_link) {
72+ mlink = mlink_dereference_protected(msta, msta->sec_link);
73+ if (!mlink)
74+ return;
75+ }
76+ mld_setup->seconed_id = cpu_to_le16(mlink->wcid.idx);
77+ mld_setup->link_num = hweight16(valid_links);
78+
79+ mld_setup_link = (struct mld_setup_link *)mld_setup->link_info;
80+ mt76_trace(vif, "STA %pM pri_link=%u, pri_wcid=%u, sec_link=%u, sec_wcid=%u\n",
81+ sta->addr, msta->pri_link, le16_to_cpu(mld_setup->primary_id),
82+ msta->sec_link, le16_to_cpu(mld_setup->seconed_id));
83+ for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) {
84+ mlink = mlink_dereference_protected(msta, link_id);
85+ mconf = mconf_dereference_protected(msta->vif, link_id);
86+
87+ mld_setup_link->wcid = cpu_to_le16(mlink->wcid.idx);
88+ mld_setup_link->bss_idx = mconf->mt76.idx;
89+ mt76_trace(vif, "link_id(%d) wcid(%d) bss_idx(%d)\n",
90+ link_id, mld_setup_link->wcid, mld_setup_link->bss_idx);
91+ mld_setup_link++;
92+ }
93+}
94+
95+static void
96+mt7996_mcu_sta_eht_mld_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
97+ struct ieee80211_sta *sta)
98+{
99+ struct sta_rec_eht_mld *eht_mld;
100+ struct tlv *tlv;
101+ int i;
102+
103+ tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_EHT_MLD, sizeof(*eht_mld));
104+ eht_mld = (struct sta_rec_eht_mld *)tlv;
105+
106+ for (i = 0; i < ARRAY_SIZE(eht_mld->str_cap); i++)
107+ eht_mld->str_cap[i] = 0x7;
108+
109+ eht_mld->eml_cap = cpu_to_le16(sta->eml_capa);
110+ /* TODO:
111+ eht_mld->nsep = ;
112+ */
113+}
114+
115 #if 0
116 static int
117 mt7996_mcu_sta_init_vow(struct mt7996_bss_conf *mconf,
118@@ -2978,6 +3049,8 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
119
120 /* tag order is in accordance with firmware dependency. */
121 if (link_sta) {
122+ struct ieee80211_sta *sta = link_sta->sta;
123+
124 /* starec hdrt mode */
125 mt7996_mcu_sta_hdrt_tlv(dev, skb);
126 /* starec bfer */
127@@ -2987,7 +3060,7 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
128 /* starec vht */
129 mt7996_mcu_sta_vht_tlv(skb, link_sta);
130 /* starec uapsd */
131- mt76_connac_mcu_sta_uapsd(skb, vif, link_sta->sta);
132+ mt76_connac_mcu_sta_uapsd(skb, vif, sta);
133 /* starec amsdu */
134 mt7996_mcu_sta_amsdu_tlv(dev, skb, vif, link_sta, mlink);
135 /* starec he */
136@@ -3000,6 +3073,12 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
137 mt7996_mcu_sta_muru_tlv(dev, skb, conf, mconf, link_sta);
138 /* starec bfee */
139 mt7996_mcu_sta_bfee_tlv(dev, skb, conf, mconf, link_sta);
140+
141+ if (sta->mlo) {
142+ /* starec mld setup */
143+ mt7996_mcu_sta_mld_setup_tlv(dev, skb, sta, sta->valid_links);
144+ mt7996_mcu_sta_eht_mld_tlv(dev, skb, sta);
145+ }
146 }
147
148 #if 0
149@@ -3014,112 +3093,6 @@ out:
150 MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
151 }
152
153-static void
154-mt7996_mcu_sta_mld_setup_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
155- struct ieee80211_sta *sta)
156-{
157- struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
158- struct sta_rec_mld_setup *mld_setup;
159- struct mld_setup_link *mld_setup_link;
160- struct mt7996_link_sta *mlink;
161- struct mt7996_bss_conf *mconf;
162- struct tlv *tlv;
163- unsigned long valid_links = sta->valid_links;
164- unsigned int link_id;
165- struct ieee80211_vif *vif = container_of((void *)msta->vif, struct ieee80211_vif,
166- drv_priv);
167-
168- mlink = mlink_dereference_protected(msta, msta->pri_link);
169- if (!mlink)
170- return;
171-
172- tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_MLD,
173- sizeof(*mld_setup) +
174- sizeof(struct mld_setup_link) *
175- hweight16(sta->valid_links));
176-
177- mld_setup = (struct sta_rec_mld_setup *)tlv;
178- memcpy(mld_setup->mld_addr, sta->addr, ETH_ALEN);
179- mld_setup->setup_wcid = cpu_to_le16(mlink->wcid.idx);
180- mld_setup->primary_id = cpu_to_le16(mlink->wcid.idx);
181- if (msta->sec_link != msta->pri_link) {
182- mlink = mlink_dereference_protected(msta, msta->sec_link);
183- if (!mlink)
184- return;
185- }
186- mld_setup->seconed_id = cpu_to_le16(mlink->wcid.idx);
187- mld_setup->link_num = hweight16(sta->valid_links);
188-
189- mld_setup_link = (struct mld_setup_link *)mld_setup->link_info;
190- mt76_trace(vif, "STA %pM pri_link=%u, pri_wcid=%u, sec_link=%u, sec_wcid=%u\n",
191- sta->addr, msta->pri_link, le16_to_cpu(mld_setup->primary_id),
192- msta->sec_link, le16_to_cpu(mld_setup->seconed_id));
193- for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) {
194- mlink = mlink_dereference_protected(msta, link_id);
195- mconf = mconf_dereference_protected(msta->vif, link_id);
196-
197- mld_setup_link->wcid = cpu_to_le16(mlink->wcid.idx);
198- mld_setup_link->bss_idx = mconf->mt76.idx;
199- mt76_trace(vif, "link_id(%d) wcid(%d) bss_idx(%d)\n",
200- link_id, mld_setup_link->wcid, mld_setup_link->bss_idx);
201- mld_setup_link++;
202- }
203-}
204-
205-static void
206-mt7996_mcu_sta_eht_mld_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
207- struct ieee80211_sta *sta)
208-{
209- struct sta_rec_eht_mld *eht_mld;
210- struct tlv *tlv;
211- int i;
212-
213- tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_EHT_MLD, sizeof(*eht_mld));
214- eht_mld = (struct sta_rec_eht_mld *)tlv;
215-
216- for (i = 0; i < ARRAY_SIZE(eht_mld->str_cap); i++)
217- eht_mld->str_cap[i] = 0x7;
218-
219- eht_mld->eml_cap = cpu_to_le16(sta->eml_capa);
220- /* TODO:
221- eht_mld->nsep = ;
222- */
223-}
224-
225-int mt7996_mcu_add_mld_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
226- struct ieee80211_sta *sta, unsigned long add)
227-{
228- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
229- struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
230- unsigned int link_id;
231-
232- if (!sta->mlo)
233- return 0;
234-
235- for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {
236- struct mt7996_bss_conf *mconf =
237- mconf_dereference_protected(mvif, link_id);
238- struct mt7996_link_sta *mlink =
239- mlink_dereference_protected(msta, link_id);
240- struct sk_buff *skb;
241- int ret;
242-
243- skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76,
244- &mlink->wcid,
245- MT7996_STA_UPDATE_MAX_SIZE);
246- if (IS_ERR(skb))
247- return PTR_ERR(skb);
248- /* starec mld setup */
249- mt7996_mcu_sta_mld_setup_tlv(dev, skb, sta);
250- /* starec eht mld */
251- mt7996_mcu_sta_eht_mld_tlv(dev, skb, sta);
252- ret = mt76_mcu_skb_send_msg(&dev->mt76, skb,
253- MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
254- if (ret)
255- return ret;
256- }
257- return 0;
258-}
259 int mt7996_mcu_teardown_mld_sta(struct mt7996_dev *dev,
260 struct mt7996_bss_conf *mconf,
261 struct mt7996_link_sta *mlink)
262diff --git a/mt7996/mcu.h b/mt7996/mcu.h
263index 20eaf20d..05b29c90 100644
264--- a/mt7996/mcu.h
265+++ b/mt7996/mcu.h
266@@ -983,6 +983,9 @@ enum {
267 sizeof(struct sta_rec_hdrt) + \
268 sizeof(struct sta_rec_hdr_trans) + \
269 sizeof(struct sta_rec_tx_cap) + \
270+ sizeof(struct sta_rec_mld_setup) + \
271+ sizeof(struct mld_setup_link) * 3 + \
272+ sizeof(struct sta_rec_eht_mld) + \
273 sizeof(struct tlv))
274
275 #define MT7996_MAX_BEACON_SIZE 1338
276diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
277index 3ee8156c..1e507b1c 100644
278--- a/mt7996/mt7996.h
279+++ b/mt7996/mt7996.h
280@@ -1083,8 +1083,6 @@ int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev,
281 struct mt7996_bss_conf *mconf,
282 struct ieee80211_link_sta *link_sta,
283 struct mt7996_link_sta *mlink, bool changed);
284-int mt7996_mcu_add_mld_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
285- struct ieee80211_sta *sta, unsigned long add);
286 int mt7996_set_channel(struct mt7996_phy *phy, struct cfg80211_chan_def *chandef);
287 int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag, bool sta);
288 int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct mt7996_bss_conf *mconf);
289--
2902.18.0
291