Skip to content

Commit 96d4f39

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 03a0e1f commit 96d4f39

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
@@ -235,19 +235,6 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
235235
rcu_read_unlock();
236236
}
237237

238-
void mt7915_mac_enable_rtscts(struct mt7915_dev *dev,
239-
struct ieee80211_vif *vif, bool enable)
240-
{
241-
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
242-
u32 addr;
243-
244-
addr = mt7915_mac_wtbl_lmac_addr(dev, mvif->sta.wcid.idx, 5);
245-
if (enable)
246-
mt76_set(dev, addr, BIT(5));
247-
else
248-
mt76_clear(dev, addr, BIT(5));
249-
}
250-
251238
static void
252239
mt7915_wed_check_ppe(struct mt7915_dev *dev, struct mt76_queue *q,
253240
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;
@@ -630,8 +630,9 @@ static void mt7915_bss_info_changed(struct ieee80211_hw *hw,
630630
if (set_sta == 1)
631631
mt7915_mcu_add_sta(dev, vif, NULL, CONN_STATE_PORT_SECURE, false);
632632

633-
if (changed & BSS_CHANGED_ERP_CTS_PROT)
634-
mt7915_mac_enable_rtscts(dev, vif, info->use_cts_prot);
633+
if (changed & BSS_CHANGED_HT || changed & BSS_CHANGED_ERP_CTS_PROT)
634+
mt7915_mcu_set_protection(phy, vif, info->ht_operation_mode,
635+
info->use_cts_prot);
635636

636637
if (changed & BSS_CHANGED_ERP_SLOT) {
637638
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
@@ -3799,6 +3799,68 @@ int mt7915_mcu_get_rx_rate(struct mt7915_phy *phy, struct ieee80211_vif *vif,
37993799
return ret;
38003800
}
38013801

3802+
int mt7915_mcu_set_protection(struct mt7915_phy *phy, struct ieee80211_vif *vif,
3803+
u8 ht_mode, bool use_cts_prot)
3804+
{
3805+
struct mt7915_dev *dev = phy->dev;
3806+
int len = sizeof(struct sta_req_hdr) + sizeof(struct bss_info_prot);
3807+
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
3808+
struct bss_info_prot *prot;
3809+
struct sk_buff *skb;
3810+
struct tlv *tlv;
3811+
enum {
3812+
PROT_NONMEMBER = BIT(1),
3813+
PROT_20MHZ = BIT(2),
3814+
PROT_NONHT_MIXED = BIT(3),
3815+
PROT_LEGACY_ERP = BIT(5),
3816+
PROT_NONGF_STA = BIT(7),
3817+
};
3818+
u32 rts_threshold;
3819+
3820+
skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
3821+
NULL, len);
3822+
if (IS_ERR(skb))
3823+
return PTR_ERR(skb);
3824+
3825+
tlv = mt76_connac_mcu_add_tlv(skb, BSS_INFO_PROTECT_INFO,
3826+
sizeof(*prot));
3827+
prot = (struct bss_info_prot *)tlv;
3828+
3829+
switch (ht_mode & IEEE80211_HT_OP_MODE_PROTECTION) {
3830+
case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
3831+
prot->prot_mode = cpu_to_le32(PROT_NONMEMBER);
3832+
break;
3833+
case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
3834+
prot->prot_mode = cpu_to_le32(PROT_20MHZ);
3835+
break;
3836+
case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
3837+
prot->prot_mode = cpu_to_le32(PROT_NONHT_MIXED);
3838+
break;
3839+
}
3840+
3841+
if (ht_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)
3842+
prot->prot_mode |= cpu_to_le32(PROT_NONGF_STA);
3843+
3844+
if (use_cts_prot)
3845+
prot->prot_mode |= cpu_to_le32(PROT_LEGACY_ERP);
3846+
3847+
/* reuse current RTS setting */
3848+
rts_threshold = phy->mt76->hw->wiphy->rts_threshold;
3849+
if (rts_threshold == (u32)-1)
3850+
prot->rts_len_thres = cpu_to_le32(MT7915_RTS_LEN_THRES);
3851+
else
3852+
prot->rts_len_thres = cpu_to_le32(rts_threshold);
3853+
3854+
prot->rts_pkt_thres = 0x2;
3855+
3856+
prot->he_rts_thres = cpu_to_le16(vif->bss_conf.frame_time_rts_th);
3857+
if (!prot->he_rts_thres)
3858+
prot->he_rts_thres = cpu_to_le16(DEFAULT_HE_DURATION_RTS_THRES);
3859+
3860+
return mt76_mcu_skb_send_msg(&dev->mt76, skb,
3861+
MCU_EXT_CMD(BSS_INFO_UPDATE), true);
3862+
}
3863+
38023864
int mt7915_mcu_update_bss_color(struct mt7915_dev *dev, struct ieee80211_vif *vif,
38033865
struct cfg80211_he_bss_color *he_bss_color)
38043866
{

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;
@@ -458,6 +460,8 @@ int mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *v
458460
u32 changed);
459461
int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
460462
int enable, u32 changed);
463+
int mt7915_mcu_set_protection(struct mt7915_phy *phy, struct ieee80211_vif *vif,
464+
u8 ht_mode, bool use_cts_prot);
461465
int mt7915_mcu_add_obss_spr(struct mt7915_phy *phy, struct ieee80211_vif *vif,
462466
struct ieee80211_he_obss_pd *he_obss_pd);
463467
int mt7915_mcu_add_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif,

0 commit comments

Comments
 (0)