Skip to content

Commit 4dd75a7

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 382cbdf commit 4dd75a7

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
@@ -228,19 +228,6 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
228228
rcu_read_unlock();
229229
}
230230

231-
void mt7915_mac_enable_rtscts(struct mt7915_dev *dev,
232-
struct ieee80211_vif *vif, bool enable)
233-
{
234-
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
235-
u32 addr;
236-
237-
addr = mt7915_mac_wtbl_lmac_addr(dev, mvif->sta.wcid.idx, 5);
238-
if (enable)
239-
mt76_set(dev, addr, BIT(5));
240-
else
241-
mt76_clear(dev, addr, BIT(5));
242-
}
243-
244231
static void
245232
mt7915_wed_check_ppe(struct mt7915_dev *dev, struct mt76_queue *q,
246233
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;
@@ -623,8 +623,9 @@ static void mt7915_bss_info_changed(struct ieee80211_hw *hw,
623623
if (set_sta == 1)
624624
mt7915_mcu_add_sta(dev, vif, NULL, true);
625625

626-
if (changed & BSS_CHANGED_ERP_CTS_PROT)
627-
mt7915_mac_enable_rtscts(dev, vif, info->use_cts_prot);
626+
if (changed & BSS_CHANGED_HT || changed & BSS_CHANGED_ERP_CTS_PROT)
627+
mt7915_mcu_set_protection(phy, vif, info->ht_operation_mode,
628+
info->use_cts_prot);
628629

629630
if (changed & BSS_CHANGED_ERP_SLOT) {
630631
int slottime = info->use_short_slot ? 9 : 20;

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

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

3733+
int mt7915_mcu_set_protection(struct mt7915_phy *phy, struct ieee80211_vif *vif,
3734+
u8 ht_mode, bool use_cts_prot)
3735+
{
3736+
struct mt7915_dev *dev = phy->dev;
3737+
int len = sizeof(struct sta_req_hdr) + sizeof(struct bss_info_prot);
3738+
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
3739+
struct bss_info_prot *prot;
3740+
struct sk_buff *skb;
3741+
struct tlv *tlv;
3742+
enum {
3743+
PROT_NONMEMBER = BIT(1),
3744+
PROT_20MHZ = BIT(2),
3745+
PROT_NONHT_MIXED = BIT(3),
3746+
PROT_LEGACY_ERP = BIT(5),
3747+
PROT_NONGF_STA = BIT(7),
3748+
};
3749+
u32 rts_threshold;
3750+
3751+
skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
3752+
NULL, len);
3753+
if (IS_ERR(skb))
3754+
return PTR_ERR(skb);
3755+
3756+
tlv = mt76_connac_mcu_add_tlv(skb, BSS_INFO_PROTECT_INFO,
3757+
sizeof(*prot));
3758+
prot = (struct bss_info_prot *)tlv;
3759+
3760+
switch (ht_mode & IEEE80211_HT_OP_MODE_PROTECTION) {
3761+
case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
3762+
prot->prot_mode = cpu_to_le32(PROT_NONMEMBER);
3763+
break;
3764+
case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
3765+
prot->prot_mode = cpu_to_le32(PROT_20MHZ);
3766+
break;
3767+
case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
3768+
prot->prot_mode = cpu_to_le32(PROT_NONHT_MIXED);
3769+
break;
3770+
}
3771+
3772+
if (ht_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)
3773+
prot->prot_mode |= cpu_to_le32(PROT_NONGF_STA);
3774+
3775+
if (use_cts_prot)
3776+
prot->prot_mode |= cpu_to_le32(PROT_LEGACY_ERP);
3777+
3778+
/* reuse current RTS setting */
3779+
rts_threshold = phy->mt76->hw->wiphy->rts_threshold;
3780+
if (rts_threshold == (u32)-1)
3781+
prot->rts_len_thres = cpu_to_le32(MT7915_RTS_LEN_THRES);
3782+
else
3783+
prot->rts_len_thres = cpu_to_le32(rts_threshold);
3784+
3785+
prot->rts_pkt_thres = 0x2;
3786+
3787+
prot->he_rts_thres = cpu_to_le16(vif->bss_conf.frame_time_rts_th);
3788+
if (!prot->he_rts_thres)
3789+
prot->he_rts_thres = cpu_to_le16(DEFAULT_HE_DURATION_RTS_THRES);
3790+
3791+
return mt76_mcu_skb_send_msg(&dev->mt76, skb,
3792+
MCU_EXT_CMD(BSS_INFO_UPDATE), true);
3793+
}
3794+
37333795
int mt7915_mcu_update_bss_color(struct mt7915_dev *dev, struct ieee80211_vif *vif,
37343796
struct cfg80211_he_bss_color *he_bss_color)
37353797
{

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;
@@ -453,6 +455,8 @@ int mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *v
453455
u32 changed);
454456
int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
455457
int enable, u32 changed);
458+
int mt7915_mcu_set_protection(struct mt7915_phy *phy, struct ieee80211_vif *vif,
459+
u8 ht_mode, bool use_cts_prot);
456460
int mt7915_mcu_add_obss_spr(struct mt7915_phy *phy, struct ieee80211_vif *vif,
457461
struct ieee80211_he_obss_pd *he_obss_pd);
458462
int mt7915_mcu_add_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif,

0 commit comments

Comments
 (0)