Skip to content

Commit 9f8f4a5

Browse files
Ming Yen Hsiehnbd168
authored andcommitted
wifi: mt76: mt7925: fix incorrect scan probe IE handling for hw_scan
The IEs should be processed and filled into the command tlv separately according to each band. Cc: [email protected] Fixes: c948b5d ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Signed-off-by: Ming Yen Hsieh <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Felix Fietkau <[email protected]>
1 parent c701574 commit 9f8f4a5

File tree

3 files changed

+63
-19
lines changed

3 files changed

+63
-19
lines changed

drivers/net/wireless/mediatek/mt76/mt7925/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ mt7925_start_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
14811481

14821482
mt792x_mutex_acquire(dev);
14831483

1484-
err = mt7925_mcu_sched_scan_req(mphy, vif, req);
1484+
err = mt7925_mcu_sched_scan_req(mphy, vif, req, ies);
14851485
if (err < 0)
14861486
goto out;
14871487

drivers/net/wireless/mediatek/mt76/mt7925/mcu.c

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ mt7925_connac_mcu_set_wow_ctrl(struct mt76_phy *phy, struct ieee80211_vif *vif,
164164
bool suspend, struct cfg80211_wowlan *wowlan)
165165
{
166166
struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv;
167+
struct ieee80211_scan_ies ies = {};
167168
struct mt76_dev *dev = phy->dev;
168169
struct {
169170
struct {
@@ -194,7 +195,7 @@ mt7925_connac_mcu_set_wow_ctrl(struct mt76_phy *phy, struct ieee80211_vif *vif,
194195
req.wow_ctrl_tlv.trigger |= (UNI_WOW_DETECT_TYPE_DISCONNECT |
195196
UNI_WOW_DETECT_TYPE_BCN_LOST);
196197
if (wowlan->nd_config) {
197-
mt7925_mcu_sched_scan_req(phy, vif, wowlan->nd_config);
198+
mt7925_mcu_sched_scan_req(phy, vif, wowlan->nd_config, &ies);
198199
req.wow_ctrl_tlv.trigger |= UNI_WOW_DETECT_TYPE_SCH_SCAN_HIT;
199200
mt7925_mcu_sched_scan_enable(phy, vif, suspend);
200201
}
@@ -2818,6 +2819,54 @@ int mt7925_mcu_set_dbdc(struct mt76_phy *phy, bool enable)
28182819
return err;
28192820
}
28202821

2822+
static void
2823+
mt7925_mcu_build_scan_ie_tlv(struct mt76_dev *mdev,
2824+
struct sk_buff *skb,
2825+
struct ieee80211_scan_ies *scan_ies)
2826+
{
2827+
u32 max_len = sizeof(struct scan_ie_tlv) + MT76_CONNAC_SCAN_IE_LEN;
2828+
struct scan_ie_tlv *ie;
2829+
enum nl80211_band i;
2830+
struct tlv *tlv;
2831+
const u8 *ies;
2832+
u16 ies_len;
2833+
2834+
for (i = 0; i <= NL80211_BAND_6GHZ; i++) {
2835+
if (i == NL80211_BAND_60GHZ)
2836+
continue;
2837+
2838+
ies = scan_ies->ies[i];
2839+
ies_len = scan_ies->len[i];
2840+
2841+
if (!ies || !ies_len)
2842+
continue;
2843+
2844+
if (ies_len > max_len)
2845+
return;
2846+
2847+
tlv = mt76_connac_mcu_add_tlv(skb, UNI_SCAN_IE,
2848+
sizeof(*ie) + ies_len);
2849+
ie = (struct scan_ie_tlv *)tlv;
2850+
2851+
memcpy(ie->ies, ies, ies_len);
2852+
ie->ies_len = cpu_to_le16(ies_len);
2853+
2854+
switch (i) {
2855+
case NL80211_BAND_2GHZ:
2856+
ie->band = 1;
2857+
break;
2858+
case NL80211_BAND_6GHZ:
2859+
ie->band = 3;
2860+
break;
2861+
default:
2862+
ie->band = 2;
2863+
break;
2864+
}
2865+
2866+
max_len -= (sizeof(*ie) + ies_len);
2867+
}
2868+
}
2869+
28212870
int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
28222871
struct ieee80211_scan_request *scan_req)
28232872
{
@@ -2843,7 +2892,8 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
28432892

28442893
max_len = sizeof(*hdr) + sizeof(*req) + sizeof(*ssid) +
28452894
sizeof(*bssid) * MT7925_RNR_SCAN_MAX_BSSIDS +
2846-
sizeof(*chan_info) + sizeof(*misc) + sizeof(*ie);
2895+
sizeof(*chan_info) + sizeof(*misc) + sizeof(*ie) +
2896+
MT76_CONNAC_SCAN_IE_LEN;
28472897

28482898
skb = mt76_mcu_msg_alloc(mdev, NULL, max_len);
28492899
if (!skb)
@@ -2925,13 +2975,6 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
29252975
}
29262976
chan_info->channel_type = sreq->n_channels ? 4 : 0;
29272977

2928-
tlv = mt76_connac_mcu_add_tlv(skb, UNI_SCAN_IE, sizeof(*ie));
2929-
ie = (struct scan_ie_tlv *)tlv;
2930-
if (sreq->ie_len > 0) {
2931-
memcpy(ie->ies, sreq->ie, sreq->ie_len);
2932-
ie->ies_len = cpu_to_le16(sreq->ie_len);
2933-
}
2934-
29352978
req->scan_func |= SCAN_FUNC_SPLIT_SCAN;
29362979

29372980
tlv = mt76_connac_mcu_add_tlv(skb, UNI_SCAN_MISC, sizeof(*misc));
@@ -2942,6 +2985,9 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
29422985
req->scan_func |= SCAN_FUNC_RANDOM_MAC;
29432986
}
29442987

2988+
/* Append scan probe IEs as the last tlv */
2989+
mt7925_mcu_build_scan_ie_tlv(mdev, skb, &scan_req->ies);
2990+
29452991
err = mt76_mcu_skb_send_msg(mdev, skb, MCU_UNI_CMD(SCAN_REQ),
29462992
true);
29472993
if (err < 0)
@@ -2953,7 +2999,8 @@ EXPORT_SYMBOL_GPL(mt7925_mcu_hw_scan);
29532999

29543000
int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,
29553001
struct ieee80211_vif *vif,
2956-
struct cfg80211_sched_scan_request *sreq)
3002+
struct cfg80211_sched_scan_request *sreq,
3003+
struct ieee80211_scan_ies *ies)
29573004
{
29583005
struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv;
29593006
struct ieee80211_channel **scan_list = sreq->channels;
@@ -3041,12 +3088,8 @@ int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,
30413088
}
30423089
chan_info->channel_type = sreq->n_channels ? 4 : 0;
30433090

3044-
tlv = mt76_connac_mcu_add_tlv(skb, UNI_SCAN_IE, sizeof(*ie));
3045-
ie = (struct scan_ie_tlv *)tlv;
3046-
if (sreq->ie_len > 0) {
3047-
memcpy(ie->ies, sreq->ie, sreq->ie_len);
3048-
ie->ies_len = cpu_to_le16(sreq->ie_len);
3049-
}
3091+
/* Append scan probe IEs as the last tlv */
3092+
mt7925_mcu_build_scan_ie_tlv(mdev, skb, ies);
30503093

30513094
return mt76_mcu_skb_send_msg(mdev, skb, MCU_UNI_CMD(SCAN_REQ),
30523095
true);

drivers/net/wireless/mediatek/mt76/mt7925/mcu.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ struct scan_ie_tlv {
269269
__le16 ies_len;
270270
u8 band;
271271
u8 pad;
272-
u8 ies[MT76_CONNAC_SCAN_IE_LEN];
272+
u8 ies[];
273273
};
274274

275275
struct scan_misc_tlv {
@@ -673,7 +673,8 @@ int mt7925_mcu_cancel_hw_scan(struct mt76_phy *phy,
673673
struct ieee80211_vif *vif);
674674
int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,
675675
struct ieee80211_vif *vif,
676-
struct cfg80211_sched_scan_request *sreq);
676+
struct cfg80211_sched_scan_request *sreq,
677+
struct ieee80211_scan_ies *ies);
677678
int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy,
678679
struct ieee80211_vif *vif,
679680
bool enable);

0 commit comments

Comments
 (0)