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