Skip to content

Commit 729b4ad

Browse files
ryderlee1110gregkh
authored andcommitted
wifi: mt76: mt7615: fix use_cts_prot support
[ Upstream commit 1974a67 ] Driver should not directly write WTBL to prevent overwritten issues. 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: e34235c ("wifi: mt76: mt7615: enable use_cts_prot support") Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Link: https://patch.msgid.link/edb87088b0111b32fafc6c4179f54a5286dd37d8.1768879119.git.ryder.lee@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9aa3b49 commit 729b4ad

5 files changed

Lines changed: 53 additions & 23 deletions

File tree

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,21 +1167,6 @@ void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
11671167
}
11681168
EXPORT_SYMBOL_GPL(mt7615_mac_set_rates);
11691169

1170-
void mt7615_mac_enable_rtscts(struct mt7615_dev *dev,
1171-
struct ieee80211_vif *vif, bool enable)
1172-
{
1173-
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
1174-
u32 addr;
1175-
1176-
addr = mt7615_mac_wtbl_addr(dev, mvif->sta.wcid.idx) + 3 * 4;
1177-
1178-
if (enable)
1179-
mt76_set(dev, addr, MT_WTBL_W3_RTS);
1180-
else
1181-
mt76_clear(dev, addr, MT_WTBL_W3_RTS);
1182-
}
1183-
EXPORT_SYMBOL_GPL(mt7615_mac_enable_rtscts);
1184-
11851170
static int
11861171
mt7615_mac_wtbl_update_key(struct mt7615_dev *dev, struct mt76_wcid *wcid,
11871172
struct ieee80211_key_conf *key,

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,6 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
583583
}
584584
}
585585

586-
if (changed & BSS_CHANGED_ERP_CTS_PROT)
587-
mt7615_mac_enable_rtscts(dev, vif, info->use_cts_prot);
588-
589586
if (changed & BSS_CHANGED_BEACON_ENABLED && info->enable_beacon) {
590587
mt7615_mcu_add_bss_info(phy, vif, NULL, true);
591588
mt7615_mcu_sta_add(phy, vif, NULL, true);
@@ -598,6 +595,10 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
598595
BSS_CHANGED_BEACON_ENABLED))
599596
mt7615_mcu_add_beacon(dev, hw, vif, info->enable_beacon);
600597

598+
if (changed & BSS_CHANGED_HT || changed & BSS_CHANGED_ERP_CTS_PROT)
599+
mt7615_mcu_set_protection(phy, vif, info->ht_operation_mode,
600+
info->use_cts_prot);
601+
601602
if (changed & BSS_CHANGED_PS)
602603
mt76_connac_mcu_set_vif_ps(&dev->mt76, vif);
603604

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,3 +2564,50 @@ int mt7615_mcu_set_roc(struct mt7615_phy *phy, struct ieee80211_vif *vif,
25642564
return mt76_mcu_send_msg(&dev->mt76, MCU_CE_CMD(SET_ROC),
25652565
&req, sizeof(req), false);
25662566
}
2567+
2568+
int mt7615_mcu_set_protection(struct mt7615_phy *phy, struct ieee80211_vif *vif,
2569+
u8 ht_mode, bool use_cts_prot)
2570+
{
2571+
struct mt7615_dev *dev = phy->dev;
2572+
struct {
2573+
u8 prot_idx;
2574+
u8 band;
2575+
u8 rsv[2];
2576+
2577+
bool long_nav;
2578+
bool prot_mm;
2579+
bool prot_gf;
2580+
bool prot_bw40;
2581+
bool prot_rifs;
2582+
bool prot_bw80;
2583+
bool prot_bw160;
2584+
u8 prot_erp_mask;
2585+
} __packed req = {
2586+
.prot_idx = 0x2,
2587+
.band = phy != &dev->phy,
2588+
};
2589+
2590+
switch (ht_mode & IEEE80211_HT_OP_MODE_PROTECTION) {
2591+
case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
2592+
case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
2593+
req.prot_mm = true;
2594+
req.prot_gf = true;
2595+
fallthrough;
2596+
case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
2597+
req.prot_bw40 = true;
2598+
break;
2599+
}
2600+
2601+
if (ht_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)
2602+
req.prot_gf = true;
2603+
2604+
if (use_cts_prot) {
2605+
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
2606+
u8 i = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 : mvif->mt76.omac_idx;
2607+
2608+
req.prot_erp_mask = BIT(i);
2609+
}
2610+
2611+
return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(PROTECT_CTRL), &req,
2612+
sizeof(req), true);
2613+
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,6 @@ void mt7615_mac_reset_counters(struct mt7615_phy *phy);
466466
void mt7615_mac_cca_stats_reset(struct mt7615_phy *phy);
467467
void mt7615_mac_set_scs(struct mt7615_phy *phy, bool enable);
468468
void mt7615_mac_enable_nf(struct mt7615_dev *dev, bool ext_phy);
469-
void mt7615_mac_enable_rtscts(struct mt7615_dev *dev,
470-
struct ieee80211_vif *vif, bool enable);
471469
void mt7615_mac_sta_poll(struct mt7615_dev *dev);
472470
int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
473471
struct sk_buff *skb, struct mt76_wcid *wcid,
@@ -522,7 +520,8 @@ int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable);
522520
int mt7615_mcu_apply_rx_dcoc(struct mt7615_phy *phy);
523521
int mt7615_mcu_apply_tx_dpd(struct mt7615_phy *phy);
524522
int mt7615_dfs_init_radar_detector(struct mt7615_phy *phy);
525-
523+
int mt7615_mcu_set_protection(struct mt7615_phy *phy, struct ieee80211_vif *vif,
524+
u8 ht_mode, bool use_cts_prot);
526525
int mt7615_mcu_set_roc(struct mt7615_phy *phy, struct ieee80211_vif *vif,
527526
struct ieee80211_channel *chan, int duration);
528527

drivers/net/wireless/mediatek/mt76/mt7615/regs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,6 @@ enum mt7615_reg_base {
455455
#define MT_WTBL_RIUCR3_RATE6 GENMASK(19, 8)
456456
#define MT_WTBL_RIUCR3_RATE7 GENMASK(31, 20)
457457

458-
#define MT_WTBL_W3_RTS BIT(22)
459-
460458
#define MT_WTBL_W5_CHANGE_BW_RATE GENMASK(7, 5)
461459
#define MT_WTBL_W5_SHORT_GI_20 BIT(8)
462460
#define MT_WTBL_W5_SHORT_GI_40 BIT(9)

0 commit comments

Comments
 (0)