Skip to content

Commit b81a93d

Browse files
ryderlee1110gregkh
authored andcommitted
wifi: mt76: mt7915: fix use_cts_prot support
[ Upstream commit 8b2c265 ] With this fix, when driver needs to adjust its behavior for compatibility, especially concerning older 11g/n devices, by enabling or disabling CTS protection frames, often for hidden SSIDs or to manage legacy clients. Fixes: 150b914 ("wifi: mt76: mt7915: enable use_cts_prot support") Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Link: https://patch.msgid.link/eb8db4d0bf1c89b7486e89facb788ae3e510dd8b.1768879119.git.ryder.lee@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 729b4ad commit b81a93d

5 files changed

Lines changed: 81 additions & 16 deletions

File tree

drivers/net/wireless/mediatek/mt76/mt7915/mac.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,19 +232,6 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
232232
rcu_read_unlock();
233233
}
234234

235-
void mt7915_mac_enable_rtscts(struct mt7915_dev *dev,
236-
struct ieee80211_vif *vif, bool enable)
237-
{
238-
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
239-
u32 addr;
240-
241-
addr = mt7915_mac_wtbl_lmac_addr(dev, mvif->sta.wcid.idx, 5);
242-
if (enable)
243-
mt76_set(dev, addr, BIT(5));
244-
else
245-
mt76_clear(dev, addr, BIT(5));
246-
}
247-
248235
static void
249236
mt7915_wed_check_ppe(struct mt7915_dev *dev, struct mt76_queue *q,
250237
struct mt7915_sta *msta, struct sk_buff *skb,

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int mt7915_run(struct ieee80211_hw *hw)
6868
if (ret)
6969
goto out;
7070

71-
ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b,
71+
ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, MT7915_RTS_LEN_THRES,
7272
phy->mt76->band_idx);
7373
if (ret)
7474
goto out;
@@ -633,8 +633,9 @@ static void mt7915_bss_info_changed(struct ieee80211_hw *hw,
633633
if (set_sta == 1)
634634
mt7915_mcu_add_sta(dev, vif, NULL, CONN_STATE_PORT_SECURE, false);
635635

636-
if (changed & BSS_CHANGED_ERP_CTS_PROT)
637-
mt7915_mac_enable_rtscts(dev, vif, info->use_cts_prot);
636+
if (changed & BSS_CHANGED_HT || changed & BSS_CHANGED_ERP_CTS_PROT)
637+
mt7915_mcu_set_protection(phy, vif, info->ht_operation_mode,
638+
info->use_cts_prot);
638639

639640
if (changed & BSS_CHANGED_ERP_SLOT) {
640641
int slottime = 9;

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3852,6 +3852,68 @@ int mt7915_mcu_get_rx_rate(struct mt7915_phy *phy, struct ieee80211_vif *vif,
38523852
return ret;
38533853
}
38543854

3855+
int mt7915_mcu_set_protection(struct mt7915_phy *phy, struct ieee80211_vif *vif,
3856+
u8 ht_mode, bool use_cts_prot)
3857+
{
3858+
struct mt7915_dev *dev = phy->dev;
3859+
int len = sizeof(struct sta_req_hdr) + sizeof(struct bss_info_prot);
3860+
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
3861+
struct bss_info_prot *prot;
3862+
struct sk_buff *skb;
3863+
struct tlv *tlv;
3864+
enum {
3865+
PROT_NONMEMBER = BIT(1),
3866+
PROT_20MHZ = BIT(2),
3867+
PROT_NONHT_MIXED = BIT(3),
3868+
PROT_LEGACY_ERP = BIT(5),
3869+
PROT_NONGF_STA = BIT(7),
3870+
};
3871+
u32 rts_threshold;
3872+
3873+
skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
3874+
NULL, len);
3875+
if (IS_ERR(skb))
3876+
return PTR_ERR(skb);
3877+
3878+
tlv = mt76_connac_mcu_add_tlv(skb, BSS_INFO_PROTECT_INFO,
3879+
sizeof(*prot));
3880+
prot = (struct bss_info_prot *)tlv;
3881+
3882+
switch (ht_mode & IEEE80211_HT_OP_MODE_PROTECTION) {
3883+
case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
3884+
prot->prot_mode = cpu_to_le32(PROT_NONMEMBER);
3885+
break;
3886+
case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
3887+
prot->prot_mode = cpu_to_le32(PROT_20MHZ);
3888+
break;
3889+
case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
3890+
prot->prot_mode = cpu_to_le32(PROT_NONHT_MIXED);
3891+
break;
3892+
}
3893+
3894+
if (ht_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)
3895+
prot->prot_mode |= cpu_to_le32(PROT_NONGF_STA);
3896+
3897+
if (use_cts_prot)
3898+
prot->prot_mode |= cpu_to_le32(PROT_LEGACY_ERP);
3899+
3900+
/* reuse current RTS setting */
3901+
rts_threshold = phy->mt76->hw->wiphy->rts_threshold;
3902+
if (rts_threshold == (u32)-1)
3903+
prot->rts_len_thres = cpu_to_le32(MT7915_RTS_LEN_THRES);
3904+
else
3905+
prot->rts_len_thres = cpu_to_le32(rts_threshold);
3906+
3907+
prot->rts_pkt_thres = 0x2;
3908+
3909+
prot->he_rts_thres = cpu_to_le16(vif->bss_conf.frame_time_rts_th);
3910+
if (!prot->he_rts_thres)
3911+
prot->he_rts_thres = cpu_to_le16(DEFAULT_HE_DURATION_RTS_THRES);
3912+
3913+
return mt76_mcu_skb_send_msg(&dev->mt76, skb,
3914+
MCU_EXT_CMD(BSS_INFO_UPDATE), true);
3915+
}
3916+
38553917
int mt7915_mcu_update_bss_color(struct mt7915_dev *dev, struct ieee80211_vif *vif,
38563918
struct cfg80211_he_bss_color *he_bss_color)
38573919
{

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,17 @@ struct bss_info_inband_discovery {
399399
__le16 prob_rsp_len;
400400
} __packed __aligned(4);
401401

402+
struct bss_info_prot {
403+
__le16 tag;
404+
__le16 len;
405+
__le32 prot_type;
406+
__le32 prot_mode;
407+
__le32 rts_len_thres;
408+
__le16 he_rts_thres;
409+
u8 rts_pkt_thres;
410+
u8 rsv[5];
411+
} __packed;
412+
402413
enum {
403414
BSS_INFO_BCN_CSA,
404415
BSS_INFO_BCN_BCC,

drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
#define MT7915_CRIT_TEMP 110
8484
#define MT7915_MAX_TEMP 120
8585

86+
#define MT7915_RTS_LEN_THRES 0x92b
87+
8688
struct mt7915_vif;
8789
struct mt7915_sta;
8890
struct mt7915_dfs_pulse;
@@ -469,6 +471,8 @@ int mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *v
469471
u32 changed);
470472
int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
471473
int enable, u32 changed);
474+
int mt7915_mcu_set_protection(struct mt7915_phy *phy, struct ieee80211_vif *vif,
475+
u8 ht_mode, bool use_cts_prot);
472476
int mt7915_mcu_add_obss_spr(struct mt7915_phy *phy, struct ieee80211_vif *vif,
473477
struct ieee80211_he_obss_pd *he_obss_pd);
474478
int mt7915_mcu_add_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif,

0 commit comments

Comments
 (0)