blob: 8a29fda9d77b672ccca174bb0028563733e5a6c9 [file] [log] [blame]
developer9237f442024-06-14 17:13:04 +08001From f8092ef14eb9b03588ea29ac1b5a3a023f34c705 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: Allen Ye <allen.ye@mediatek.com>
3Date: Thu, 18 Apr 2024 11:16:24 +0800
developer9237f442024-06-14 17:13:04 +08004Subject: [PATCH 008/116] mtk: wifi: mt76: mt7996: add preamble puncture
developer66e89bc2024-04-23 14:50:01 +08005 support for mt7996
6
7Add support configure preamble puncture feature through mcu commands.
8
9Co-developed-by: Howard Hsu <howard-yh.hsu@mediatek.com>
10Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
11Signed-off-by: Allen Ye <allen.ye@mediatek.com>
12---
13 mt76_connac_mcu.h | 1 +
14 mt7996/init.c | 1 +
15 mt7996/main.c | 5 +++++
16 mt7996/mcu.c | 40 ++++++++++++++++++++++++++++++++++++++++
17 mt7996/mcu.h | 10 ++++++++++
18 mt7996/mt7996.h | 4 ++++
19 6 files changed, 61 insertions(+)
20
21diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developer9237f442024-06-14 17:13:04 +080022index 915eb3a..1e187a8 100644
developer66e89bc2024-04-23 14:50:01 +080023--- a/mt76_connac_mcu.h
24+++ b/mt76_connac_mcu.h
developer9237f442024-06-14 17:13:04 +080025@@ -1273,6 +1273,7 @@ enum {
developer66e89bc2024-04-23 14:50:01 +080026 MCU_UNI_CMD_CHANNEL_SWITCH = 0x34,
27 MCU_UNI_CMD_THERMAL = 0x35,
28 MCU_UNI_CMD_VOW = 0x37,
29+ MCU_UNI_CMD_PP = 0x38,
30 MCU_UNI_CMD_FIXED_RATE_TABLE = 0x40,
31 MCU_UNI_CMD_RRO = 0x57,
32 MCU_UNI_CMD_OFFCH_SCAN_CTRL = 0x58,
33diff --git a/mt7996/init.c b/mt7996/init.c
developer9237f442024-06-14 17:13:04 +080034index ab9445c..afe8a0a 100644
developer66e89bc2024-04-23 14:50:01 +080035--- a/mt7996/init.c
36+++ b/mt7996/init.c
37@@ -387,6 +387,7 @@ mt7996_init_wiphy(struct ieee80211_hw *hw, struct mtk_wed_device *wed)
38 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_ACK_SIGNAL_SUPPORT);
39 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_CAN_REPLACE_PTK0);
40 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER);
41+ wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_PUNCT);
42
43 if (!mdev->dev->of_node ||
44 !of_property_read_bool(mdev->dev->of_node,
45diff --git a/mt7996/main.c b/mt7996/main.c
developer9237f442024-06-14 17:13:04 +080046index 40ccfdc..1791335 100644
developer66e89bc2024-04-23 14:50:01 +080047--- a/mt7996/main.c
48+++ b/mt7996/main.c
49@@ -411,6 +411,11 @@ static int mt7996_config(struct ieee80211_hw *hw, u32 changed)
50 int ret;
51
52 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
53+ ret = mt7996_mcu_set_pp_en(phy, PP_USR_MODE,
54+ phy->mt76->chandef.punctured);
55+ if (ret)
56+ return ret;
57+
58 ieee80211_stop_queues(hw);
59 ret = mt7996_set_channel(phy);
60 if (ret)
61diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developer9237f442024-06-14 17:13:04 +080062index 0e5ddf6..1f99b2d 100644
developer66e89bc2024-04-23 14:50:01 +080063--- a/mt7996/mcu.c
64+++ b/mt7996/mcu.c
65@@ -4550,3 +4550,43 @@ int mt7996_mcu_cp_support(struct mt7996_dev *dev, u8 mode)
66 return mt76_mcu_send_msg(&dev->mt76, MCU_WA_EXT_CMD(CP_SUPPORT),
67 &cp_mode, sizeof(cp_mode), true);
68 }
69+
70+int mt7996_mcu_set_pp_en(struct mt7996_phy *phy, u8 mode, u16 bitmap)
71+{
72+ struct mt7996_dev *dev = phy->dev;
73+ bool pp_auto = (mode == PP_FW_MODE);
74+ struct {
75+ u8 _rsv1[4];
76+
77+ __le16 tag;
78+ __le16 len;
79+ u8 mgmt_mode;
80+ u8 band_idx;
81+ u8 force_bitmap_ctrl;
82+ u8 auto_mode;
83+ __le16 bitmap;
84+ u8 _rsv2[2];
85+ } __packed req = {
86+ .tag = cpu_to_le16(UNI_CMD_PP_EN_CTRL),
87+ .len = cpu_to_le16(sizeof(req) - 4),
88+
89+ .mgmt_mode = !pp_auto,
90+ .band_idx = phy->mt76->band_idx,
91+ .force_bitmap_ctrl = (mode == PP_USR_MODE) ? 2 : 0,
92+ .auto_mode = pp_auto,
93+ .bitmap = cpu_to_le16(bitmap),
94+ };
95+
96+ if (phy->mt76->chandef.chan->band == NL80211_BAND_2GHZ ||
97+ mode > PP_USR_MODE)
98+ return 0;
99+
100+ if (bitmap && phy->punct_bitmap == bitmap)
101+ return 0;
102+
103+ phy->punct_bitmap = bitmap;
104+ phy->pp_mode = mode;
105+
106+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(PP),
107+ &req, sizeof(req), false);
108+}
109diff --git a/mt7996/mcu.h b/mt7996/mcu.h
developer9237f442024-06-14 17:13:04 +0800110index a9ba63d..2052555 100644
developer66e89bc2024-04-23 14:50:01 +0800111--- a/mt7996/mcu.h
112+++ b/mt7996/mcu.h
113@@ -923,6 +923,16 @@ enum {
114 MT7996_SEC_MODE_MAX,
115 };
116
117+enum {
118+ UNI_CMD_PP_EN_CTRL,
119+};
120+
121+enum pp_mode {
122+ PP_DISABLE = 0,
123+ PP_FW_MODE,
124+ PP_USR_MODE,
125+};
126+
127 #define MT7996_PATCH_SEC GENMASK(31, 24)
128 #define MT7996_PATCH_SCRAMBLE_KEY GENMASK(15, 8)
129 #define MT7996_PATCH_AES_KEY GENMASK(7, 0)
130diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developer9237f442024-06-14 17:13:04 +0800131index 177cfff..58fa6b4 100644
developer66e89bc2024-04-23 14:50:01 +0800132--- a/mt7996/mt7996.h
133+++ b/mt7996/mt7996.h
134@@ -237,6 +237,9 @@ struct mt7996_phy {
135 struct mt76_channel_state state_ts;
136
137 bool has_aux_rx;
138+
139+ u8 pp_mode;
140+ u16 punct_bitmap;
141 };
142
143 struct mt7996_dev {
144@@ -614,6 +617,7 @@ int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev,
145 struct ieee80211_vif *vif,
146 struct ieee80211_sta *sta);
147 int mt7996_mcu_cp_support(struct mt7996_dev *dev, u8 mode);
148+int mt7996_mcu_set_pp_en(struct mt7996_phy *phy, u8 mode, u16 bitmap);
149 #ifdef CONFIG_MAC80211_DEBUGFS
150 void mt7996_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
151 struct ieee80211_sta *sta, struct dentry *dir);
152--
developer9237f442024-06-14 17:13:04 +08001532.18.0
developer66e89bc2024-04-23 14:50:01 +0800154