blob: a68e7f7e7ff23cef16b18638e1380fc7e95ea377 [file] [log] [blame]
developer617abbd2024-04-23 14:50:01 +08001From 8531498a7a6b120e4861772b19f4f9a9a63a2484 Mon Sep 17 00:00:00 2001
2From: Howard Hsu <howard-yh.hsu@mediatek.com>
3Date: Tue, 13 Jun 2023 14:49:02 +0800
4Subject: [PATCH 044/116] mtk: wifi: mt76: mt7996: add build the following MURU
5 mcu command tlvs
6
7It includes the following tlvs:
81. MURU tlv id 0x10, 0x33, 0xC8, 0xC9, 0xCA, 0xCC, 0xCD
92. BF tlv id 0x1c
10
11Change-Id: I0ae5cbed5b4370d39a6cfca50721873845659006
12---
13 mt7996/mcu.h | 1 +
14 mt7996/mt7996.h | 3 ++
15 mt7996/mtk_debugfs.c | 12 +++++++
16 mt7996/mtk_mcu.c | 78 ++++++++++++++++++++++++++++++++++++++++++++
17 mt7996/mtk_mcu.h | 14 ++++++++
18 5 files changed, 108 insertions(+)
19
20diff --git a/mt7996/mcu.h b/mt7996/mcu.h
21index 29bd7a55b..848c85dae 100644
22--- a/mt7996/mcu.h
23+++ b/mt7996/mcu.h
24@@ -776,6 +776,7 @@ enum {
25 BF_MOD_EN_CTRL = 20,
26 BF_FBRPT_DBG_INFO_READ = 23,
27 BF_TXSND_INFO = 24,
28+ BF_CFG_PHY = 28,
29 };
30
31 enum {
32diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
33index 4602b4e7a..205a3c7b7 100644
34--- a/mt7996/mt7996.h
35+++ b/mt7996/mt7996.h
36@@ -821,6 +821,9 @@ void mt7996_mcu_rx_bf_event(struct mt7996_dev *dev, struct sk_buff *skb);
37 int mt7996_mcu_set_muru_fixed_rate_enable(struct mt7996_dev *dev, u8 action, int val);
38 int mt7996_mcu_set_muru_fixed_rate_parameter(struct mt7996_dev *dev, u8 action, void *para);
39 int mt7996_mcu_set_txbf_snd_info(struct mt7996_phy *phy, void *para);
40+int mt7996_mcu_set_muru_cmd(struct mt7996_dev *dev, u16 action, int val);
41+int mt7996_mcu_muru_set_prot_frame_thr(struct mt7996_dev *dev, u32 val);
42+int mt7996_mcu_set_bypass_smthint(struct mt7996_phy *phy, u8 val);
43 #endif
44
45 #ifdef CONFIG_NET_MEDIATEK_SOC_WED
46diff --git a/mt7996/mtk_debugfs.c b/mt7996/mtk_debugfs.c
47index 36db55479..e337ae4f7 100644
48--- a/mt7996/mtk_debugfs.c
49+++ b/mt7996/mtk_debugfs.c
50@@ -3064,6 +3064,16 @@ static const struct file_operations fops_muru_fixed_group_rate = {
51 .llseek = default_llseek,
52 };
53
54+static int mt7996_muru_prot_thr_set(void *data, u64 val)
55+{
56+ struct mt7996_phy *phy = data;
57+
58+ return mt7996_mcu_muru_set_prot_frame_thr(phy->dev, (u32)val);
59+}
60+
61+DEFINE_DEBUGFS_ATTRIBUTE(fops_muru_prot_thr, NULL,
62+ mt7996_muru_prot_thr_set, "%lld\n");
63+
64 int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir)
65 {
66 struct mt7996_dev *dev = phy->dev;
67@@ -3159,6 +3169,8 @@ int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir)
68 debugfs_create_file("bf_fbk_rpt", 0600, dir, phy, &fops_bf_fbk_rpt);
69 debugfs_create_file("pfmu_tag_read", 0600, dir, phy, &fops_bf_pfmu_tag_read);
70
71+ debugfs_create_file("muru_prot_thr", 0200, dir, phy, &fops_muru_prot_thr);
72+
73 return 0;
74 }
75
76diff --git a/mt7996/mtk_mcu.c b/mt7996/mtk_mcu.c
77index 6b2cdad6f..686506234 100644
78--- a/mt7996/mtk_mcu.c
79+++ b/mt7996/mtk_mcu.c
80@@ -904,4 +904,82 @@ error:
81 return -EINVAL;
82 }
83
84+/**
85+ * This function can be used to build the following commands
86+ * MURU_SUTX_CTRL (0x10)
87+ * SET_FORCE_MU (0x33)
88+ * SET_MUDL_ACK_POLICY (0xC8)
89+ * SET_TRIG_TYPE (0xC9)
90+ * SET_20M_DYN_ALGO (0xCA)
91+ * SET_CERT_MU_EDCA_OVERRIDE (0xCD)
92+ */
93+int mt7996_mcu_set_muru_cmd(struct mt7996_dev *dev, u16 action, int val)
94+{
95+ struct {
96+ u8 _rsv[4];
97+
98+ __le16 tag;
99+ __le16 len;
100+
101+ u8 config;
102+ u8 rsv[3];
103+ } __packed data = {
104+ .tag = cpu_to_le16(action),
105+ .len = cpu_to_le16(sizeof(data) - 4),
106+ .config = (u8) val,
107+ };
108+
109+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(MURU), &data, sizeof(data),
110+ false);
111+}
112+
113+int mt7996_mcu_muru_set_prot_frame_thr(struct mt7996_dev *dev, u32 val)
114+{
115+ struct {
116+ u8 _rsv[4];
117+
118+ __le16 tag;
119+ __le16 len;
120+
121+ __le32 prot_frame_thr;
122+ } __packed data = {
123+ .tag = cpu_to_le16(UNI_CMD_MURU_PROT_FRAME_THR),
124+ .len = cpu_to_le16(sizeof(data) - 4),
125+ .prot_frame_thr = cpu_to_le32(val),
126+ };
127+
128+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(MURU), &data, sizeof(data),
129+ false);
130+}
131+
132+int mt7996_mcu_set_bypass_smthint(struct mt7996_phy *phy, u8 val)
133+{
134+#define BF_PHY_SMTH_INT_BYPASS 0
135+#define BYPASS_VAL 1
136+ struct mt7996_dev *dev = phy->dev;
137+ struct {
138+ u8 _rsv[4];
139+
140+ u16 tag;
141+ u16 len;
142+
143+ u8 action;
144+ u8 band_idx;
145+ u8 smthintbypass;
146+ u8 __rsv2[5];
147+ } __packed data = {
148+ .tag = cpu_to_le16(BF_CFG_PHY),
149+ .len = cpu_to_le16(sizeof(data) - 4),
150+ .action = BF_PHY_SMTH_INT_BYPASS,
151+ .band_idx = phy->mt76->band_idx,
152+ .smthintbypass = val,
153+ };
154+
155+ if (val != BYPASS_VAL)
156+ return -EINVAL;
157+
158+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(BF), &data, sizeof(data),
159+ true);
160+}
161+
162 #endif
163diff --git a/mt7996/mtk_mcu.h b/mt7996/mtk_mcu.h
164index 27d6a05b8..d9686ebb5 100644
165--- a/mt7996/mtk_mcu.h
166+++ b/mt7996/mtk_mcu.h
167@@ -119,6 +119,20 @@ enum {
168 EDCCA_FCC = 1,
169 EDCCA_ETSI = 2,
170 EDCCA_JAPAN = 3
171+};
172+
173+enum {
174+ UNI_CMD_MURU_SUTX_CTRL = 0x10,
175+ UNI_CMD_MURU_FIXED_RATE_CTRL,
176+ UNI_CMD_MURU_FIXED_GROUP_RATE_CTRL,
177+ UNI_CMD_MURU_SET_FORCE_MU = 0x33,
178+ UNI_CMD_MURU_MUNUAL_CONFIG = 0x64,
179+ UNI_CMD_MURU_SET_MUDL_ACK_POLICY = 0xC9,
180+ UNI_CMD_MURU_SET_TRIG_TYPE,
181+ UNI_CMD_MURU_SET_20M_DYN_ALGO,
182+ UNI_CMD_MURU_PROT_FRAME_THR = 0xCC,
183+ UNI_CMD_MURU_SET_CERT_MU_EDCA_OVERRIDE,
184+};
185
186 struct bf_pfmu_tag {
187 __le16 tag;
188--
1892.39.2
190