blob: 90266c6dffc1b4c9bd928dc8274f72f7fa6977b1 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From a2610e02282fb1825cdc2d76ebff9e979a6a977c Mon Sep 17 00:00:00 2001
developere2cfb522022-12-08 18:09:45 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Fri, 28 Oct 2022 10:15:56 +0800
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 1018/1052] wifi: mt76: mt7915: add vendor subcmd three wire
developera20cdc22024-05-31 18:57:31 +08005 (PTA) ctrl
developere2cfb522022-12-08 18:09:45 +08006
developere2cfb522022-12-08 18:09:45 +08007Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
8---
9 mt76_connac_mcu.h | 2 +-
10 mt7915/mcu.c | 50 ++++++++++++++++++++++-------------------------
11 mt7915/mcu.h | 29 +++++++++++++++++++++++++++
12 mt7915/mt7915.h | 1 +
13 mt7915/vendor.c | 44 ++++++++++++++++++++++++++++++++++++++++-
14 mt7915/vendor.h | 14 +++++++++++++
15 6 files changed, 111 insertions(+), 29 deletions(-)
16
17diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developer05f3b2b2024-08-19 19:17:34 +080018index a85179b8..e7eb6a93 100644
developere2cfb522022-12-08 18:09:45 +080019--- a/mt76_connac_mcu.h
20+++ b/mt76_connac_mcu.h
developer05f3b2b2024-08-19 19:17:34 +080021@@ -1253,7 +1253,7 @@ enum {
developere2cfb522022-12-08 18:09:45 +080022 MCU_EXT_CMD_SMESH_CTRL = 0xae,
23 MCU_EXT_CMD_RX_STAT_USER_CTRL = 0xb3,
developerdad89a32024-04-29 14:17:17 +080024 MCU_EXT_CMD_SET_QOS_MAP = 0xb4,
developere2cfb522022-12-08 18:09:45 +080025- MCU_EXT_CMD_CERT_CFG = 0xb7,
26+ MCU_EXT_CMD_SET_CFG = 0xb7,
27 MCU_EXT_CMD_EDCCA = 0xba,
28 MCU_EXT_CMD_CSI_CTRL = 0xc2,
29 MCU_EXT_CMD_IPI_HIST_SCAN = 0xc5,
30diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer05f3b2b2024-08-19 19:17:34 +080031index f83d969c..3e4239f6 100644
developere2cfb522022-12-08 18:09:45 +080032--- a/mt7915/mcu.c
33+++ b/mt7915/mcu.c
developera46f6132024-03-26 14:09:54 +080034@@ -4736,37 +4736,33 @@ void mt7915_mcu_set_dynalgo(struct mt7915_phy *phy, u8 enable)
developere2cfb522022-12-08 18:09:45 +080035 &req, sizeof(req), false);
36 }
37
38-void mt7915_mcu_set_cert(struct mt7915_phy *phy, u8 type)
39+int mt7915_mcu_set_cfg(struct mt7915_phy *phy, u8 cfg_info, u8 type)
40 {
41-#define CFGINFO_CERT_CFG 4
42 struct mt7915_dev *dev = phy->dev;
43- struct {
44- struct basic_info{
45- u8 dbdc_idx;
46- u8 rsv[3];
47- __le32 tlv_num;
48- u8 tlv_buf[0];
49- } hdr;
50- struct cert_cfg{
51- __le16 tag;
52- __le16 length;
53- u8 cert_program;
54- u8 rsv[3];
55- } tlv;
56- } req = {
57- .hdr = {
58- .dbdc_idx = phy != &dev->phy,
59- .tlv_num = cpu_to_le32(1),
60- },
61- .tlv = {
62- .tag = cpu_to_le16(CFGINFO_CERT_CFG),
63- .length = cpu_to_le16(sizeof(struct cert_cfg)),
64- .cert_program = type, /* 1: CAPI Enable */
65- }
66+ struct cfg_basic_info req = {
67+ .dbdc_idx = phy != &dev->phy,
68+ .tlv_num = cpu_to_le32(1),
69 };
70+ int tlv_len;
71+
72+ switch (cfg_info) {
73+ case CFGINFO_CERT_CFG:
74+ tlv_len = sizeof(struct cert_cfg);
75+ req.cert.tag = cpu_to_le16(cfg_info);
76+ req.cert.length = cpu_to_le16(tlv_len);
77+ req.cert.cert_program = type;
78+ break;
79+ case CFGINFO_3WIRE_EN_CFG:
80+ tlv_len = sizeof(struct three_wire_cfg);
81+ req.three_wire.tag = cpu_to_le16(cfg_info);
82+ req.three_wire.length = cpu_to_le16(tlv_len);
83+ req.three_wire.three_wire_en = type;
84+ break;
85+ default:
86+ return -EOPNOTSUPP;
87+ }
88
89- mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(CERT_CFG),
90- &req, sizeof(req), false);
91+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_CFG), &req, sizeof(req), false);
92 }
93
94 void mt7915_mcu_set_bypass_smthint(struct mt7915_phy *phy, u8 val)
95diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developer05f3b2b2024-08-19 19:17:34 +080096index 1682c117..1b0bd06b 100644
developere2cfb522022-12-08 18:09:45 +080097--- a/mt7915/mcu.h
98+++ b/mt7915/mcu.h
developer753619c2024-02-22 13:42:45 +080099@@ -916,6 +916,35 @@ struct mt7915_mcu_rdd_ipi_scan {
developere2cfb522022-12-08 18:09:45 +0800100 u8 tx_assert_time; /* unit: us */
101 } __packed;
102
103+struct cert_cfg {
104+ __le16 tag;
105+ __le16 length;
106+ u8 cert_program;
107+ u8 rsv[3];
108+} __packed;
109+
110+struct three_wire_cfg {
111+ __le16 tag;
112+ __le16 length;
113+ u8 three_wire_en;
114+ u8 rsv[3];
115+} __packed;
116+
117+struct cfg_basic_info {
118+ u8 dbdc_idx;
119+ u8 rsv[3];
120+ __le32 tlv_num;
121+ union {
122+ struct cert_cfg cert;
123+ struct three_wire_cfg three_wire;
124+ };
125+} __packed;
126+
127+enum {
128+ CFGINFO_CERT_CFG = 4,
129+ CFGINFO_3WIRE_EN_CFG = 10,
130+};
131+
132 /* MURU */
133 #define OFDMA_DL BIT(0)
134 #define OFDMA_UL BIT(1)
135diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer05f3b2b2024-08-19 19:17:34 +0800136index 2fb8e2fb..6027e7f7 100644
developere2cfb522022-12-08 18:09:45 +0800137--- a/mt7915/mt7915.h
138+++ b/mt7915/mt7915.h
developer05f3b2b2024-08-19 19:17:34 +0800139@@ -781,6 +781,7 @@ void mt7915_mcu_set_mimo(struct mt7915_phy *phy, u8 direction);
developere2cfb522022-12-08 18:09:45 +0800140 void mt7915_mcu_set_dynalgo(struct mt7915_phy *phy, u8 enable);
141 int mt7915_mcu_set_mu_edca(struct mt7915_phy *phy, u8 val);
142 void mt7915_mcu_set_cert(struct mt7915_phy *phy, u8 type);
143+int mt7915_mcu_set_cfg(struct mt7915_phy *phy, u8 cfg_info, u8 type);
144 void mt7915_mcu_set_bypass_smthint(struct mt7915_phy *phy, u8 val);
145 void mt7915_vendor_register(struct mt7915_phy *phy);
146 int mt7915_mcu_set_csi(struct mt7915_phy *phy, u8 mode,
147diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developer05f3b2b2024-08-19 19:17:34 +0800148index eb0b380d..54b89030 100644
developere2cfb522022-12-08 18:09:45 +0800149--- a/mt7915/vendor.c
150+++ b/mt7915/vendor.c
developer05f3b2b2024-08-19 19:17:34 +0800151@@ -42,6 +42,11 @@ mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = {
developer2c78ce72023-02-24 11:26:12 +0800152 [MTK_VENDOR_ATTR_MU_CTRL_DUMP] = {.type = NLA_U8 },
developere2cfb522022-12-08 18:09:45 +0800153 };
154
155+static const struct nla_policy
156+three_wire_ctrl_policy[NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL] = {
157+ [MTK_VENDOR_ATTR_3WIRE_CTRL_MODE] = {.type = NLA_U8 },
158+};
159+
160 static const struct nla_policy
161 rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = {
162 [MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI] = {.type = NLA_U8 },
developer05f3b2b2024-08-19 19:17:34 +0800163@@ -1128,7 +1133,7 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy,
developere2cfb522022-12-08 18:09:45 +0800164 mt7915_set_wireless_vif, &val32);
165 } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT]) {
166 val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT]);
167- mt7915_mcu_set_cert(phy, val8); /* Cert Enable for OMI */
168+ mt7915_mcu_set_cfg(phy, CFGINFO_CERT_CFG, val8); /* Cert Enable for OMI */
169 mt7915_mcu_set_bypass_smthint(phy, val8); /* Cert bypass smooth interpolation */
170 }
171
developer05f3b2b2024-08-19 19:17:34 +0800172@@ -1272,6 +1277,7 @@ static int mt7915_vendor_edcca_ctrl(struct wiphy *wiphy,
developere2cfb522022-12-08 18:09:45 +0800173 return 0;
174 }
175
176+
177 static int
178 mt7915_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
179 struct sk_buff *skb, const void *data, int data_len,
developer05f3b2b2024-08-19 19:17:34 +0800180@@ -1315,6 +1321,31 @@ mt7915_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
developere2cfb522022-12-08 18:09:45 +0800181 return len;
182 }
183
184+static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy,
185+ struct wireless_dev *wdev,
186+ const void *data,
187+ int data_len)
188+{
189+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
190+ struct mt7915_phy *phy = mt7915_hw_phy(hw);
191+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL];
192+ int err;
193+ u8 three_wire_mode;
194+
195+ err = nla_parse(tb, MTK_VENDOR_ATTR_3WIRE_CTRL_MAX, data, data_len,
196+ three_wire_ctrl_policy, NULL);
197+ if (err)
198+ return err;
199+
200+ if (!tb[MTK_VENDOR_ATTR_3WIRE_CTRL_MODE])
201+ return -EINVAL;
202+
203+ three_wire_mode = nla_get_u8(tb[MTK_VENDOR_ATTR_3WIRE_CTRL_MODE]);
204+
205+ return mt7915_mcu_set_cfg(phy, CFGINFO_3WIRE_EN_CFG, three_wire_mode);
206+}
207+
208+
209 static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
210 {
211 .info = {
developer05f3b2b2024-08-19 19:17:34 +0800212@@ -1396,6 +1427,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developere2cfb522022-12-08 18:09:45 +0800213 .dumpit = mt7915_vendor_edcca_ctrl_dump,
214 .policy = edcca_ctrl_policy,
215 .maxattr = MTK_VENDOR_ATTR_EDCCA_CTRL_MAX,
216+ },
217+ {
218+ .info = {
219+ .vendor_id = MTK_NL80211_VENDOR_ID,
220+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL,
221+ },
222+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
223+ WIPHY_VENDOR_CMD_NEED_RUNNING,
224+ .doit = mt7915_vendor_3wire_ctrl,
225+ .policy = three_wire_ctrl_policy,
226+ .maxattr = MTK_VENDOR_ATTR_3WIRE_CTRL_MAX,
227 }
228 };
229
230diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developer05f3b2b2024-08-19 19:17:34 +0800231index c61ba260..ddde0cc0 100644
developere2cfb522022-12-08 18:09:45 +0800232--- a/mt7915/vendor.h
233+++ b/mt7915/vendor.h
developer753619c2024-02-22 13:42:45 +0800234@@ -13,6 +13,7 @@ enum mtk_nl80211_vendor_subcmds {
developer2c78ce72023-02-24 11:26:12 +0800235 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developere2cfb522022-12-08 18:09:45 +0800236 MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6,
237 MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7,
238+ MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8
239 };
240
241
developer753619c2024-02-22 13:42:45 +0800242@@ -32,6 +33,7 @@ enum mtk_vendor_attr_edcca_ctrl {
developere2cfb522022-12-08 18:09:45 +0800243 NUM_MTK_VENDOR_ATTRS_EDCCA_CTRL - 1
244 };
245
246+
247 enum mtk_vendor_attr_edcca_dump {
248 MTK_VENDOR_ATTR_EDCCA_DUMP_UNSPEC = 0,
249
developer753619c2024-02-22 13:42:45 +0800250@@ -46,6 +48,18 @@ enum mtk_vendor_attr_edcca_dump {
developere2cfb522022-12-08 18:09:45 +0800251 NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP - 1
252 };
253
254+enum mtk_vendor_attr_3wire_ctrl {
255+ MTK_VENDOR_ATTR_3WIRE_CTRL_UNSPEC,
256+
257+ MTK_VENDOR_ATTR_3WIRE_CTRL_MODE,
258+
259+ /* keep last */
260+ NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL,
261+ MTK_VENDOR_ATTR_3WIRE_CTRL_MAX =
262+ NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL - 1
263+};
264+
265+
266 enum mtk_capi_control_changed {
267 CAPI_RFEATURE_CHANGED = BIT(16),
268 CAPI_WIRELESS_CHANGED = BIT(17),
269--
developerbd9fa1e2023-10-16 11:04:00 +08002702.18.0
developere2cfb522022-12-08 18:09:45 +0800271