blob: 2bb3866b263bffcccea0d8472eee0a154162c2b7 [file] [log] [blame]
developera72bbd82024-02-04 18:27:28 +08001From 8b25fabf3bbe6c6337b7e8a4ff192562fcc8bbf3 Mon Sep 17 00:00:00 2001
developer6727afb2022-09-01 20:56:09 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
developer887da632022-10-28 09:35:38 +08003Date: Fri, 28 Oct 2022 10:15:56 +0800
developera72bbd82024-02-04 18:27:28 +08004Subject: [PATCH 1021/1048] wifi: mt76: mt7915: add vendor subcmd three wire
5 (PTA) ctrl
developer6727afb2022-09-01 20:56:09 +08006
developer6727afb2022-09-01 20:56:09 +08007Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
8---
9 mt76_connac_mcu.h | 2 +-
developer81ca9d62022-10-14 11:23:22 +080010 mt7915/mcu.c | 50 ++++++++++++++++++++++-------------------------
developer6727afb2022-09-01 20:56:09 +080011 mt7915/mcu.h | 29 +++++++++++++++++++++++++++
12 mt7915/mt7915.h | 1 +
developer335cbee2022-11-17 14:55:34 +080013 mt7915/vendor.c | 44 ++++++++++++++++++++++++++++++++++++++++-
14 mt7915/vendor.h | 14 +++++++++++++
15 6 files changed, 111 insertions(+), 29 deletions(-)
developer6727afb2022-09-01 20:56:09 +080016
17diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developera72bbd82024-02-04 18:27:28 +080018index 8dba184..6f6a889 100644
developer6727afb2022-09-01 20:56:09 +080019--- a/mt76_connac_mcu.h
20+++ b/mt76_connac_mcu.h
developera72bbd82024-02-04 18:27:28 +080021@@ -1242,7 +1242,7 @@ enum {
developer6727afb2022-09-01 20:56:09 +080022 /* for vendor csi and air monitor */
23 MCU_EXT_CMD_SMESH_CTRL = 0xae,
24 MCU_EXT_CMD_RX_STAT_USER_CTRL = 0xb3,
25- 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,
developer887da632022-10-28 09:35:38 +080029 MCU_EXT_CMD_IPI_HIST_SCAN = 0xc5,
developer6727afb2022-09-01 20:56:09 +080030diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developera72bbd82024-02-04 18:27:28 +080031index 697e964..f793a95 100644
developer6727afb2022-09-01 20:56:09 +080032--- a/mt7915/mcu.c
33+++ b/mt7915/mcu.c
developera72bbd82024-02-04 18:27:28 +080034@@ -4725,37 +4725,33 @@ void mt7915_mcu_set_dynalgo(struct mt7915_phy *phy, u8 enable)
developer6727afb2022-09-01 20:56:09 +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 };
developer6727afb2022-09-01 20:56:09 +080070+ 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
developera72bbd82024-02-04 18:27:28 +080096index 1682c11..1b0bd06 100644
developer6727afb2022-09-01 20:56:09 +080097--- a/mt7915/mcu.h
98+++ b/mt7915/mcu.h
developera72bbd82024-02-04 18:27:28 +080099@@ -916,6 +916,35 @@ struct mt7915_mcu_rdd_ipi_scan {
developer887da632022-10-28 09:35:38 +0800100 u8 tx_assert_time; /* unit: us */
101 } __packed;
developer6727afb2022-09-01 20:56:09 +0800102
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
developera72bbd82024-02-04 18:27:28 +0800136index f3e38bc..e01afea 100644
developer6727afb2022-09-01 20:56:09 +0800137--- a/mt7915/mt7915.h
138+++ b/mt7915/mt7915.h
developera72bbd82024-02-04 18:27:28 +0800139@@ -750,6 +750,7 @@ void mt7915_mcu_set_mimo(struct mt7915_phy *phy, u8 direction);
developer6727afb2022-09-01 20:56:09 +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
developera72bbd82024-02-04 18:27:28 +0800148index ac6f637..eeac18d 100644
developer6727afb2022-09-01 20:56:09 +0800149--- a/mt7915/vendor.c
150+++ b/mt7915/vendor.c
developera72bbd82024-02-04 18:27:28 +0800151@@ -41,6 +41,11 @@ mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = {
developer57de9b72023-02-20 11:15:54 +0800152 [MTK_VENDOR_ATTR_MU_CTRL_DUMP] = {.type = NLA_U8 },
developer6727afb2022-09-01 20:56:09 +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 },
developera72bbd82024-02-04 18:27:28 +0800163@@ -992,7 +997,7 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy,
developer6727afb2022-09-01 20:56:09 +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
developera72bbd82024-02-04 18:27:28 +0800172@@ -1136,6 +1141,7 @@ static int mt7915_vendor_edcca_ctrl(struct wiphy *wiphy,
developer6727afb2022-09-01 20:56:09 +0800173 return 0;
174 }
175
developer335cbee2022-11-17 14:55:34 +0800176+
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,
developera72bbd82024-02-04 18:27:28 +0800180@@ -1179,6 +1185,31 @@ mt7915_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
developer335cbee2022-11-17 14:55:34 +0800181 return len;
182 }
183
developer6727afb2022-09-01 20:56:09 +0800184+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+
developer335cbee2022-11-17 14:55:34 +0800208+
developer6727afb2022-09-01 20:56:09 +0800209 static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
210 {
developer335cbee2022-11-17 14:55:34 +0800211 .info = {
developera72bbd82024-02-04 18:27:28 +0800212@@ -1260,6 +1291,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developer335cbee2022-11-17 14:55:34 +0800213 .dumpit = mt7915_vendor_edcca_ctrl_dump,
developer6727afb2022-09-01 20:56:09 +0800214 .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
developera72bbd82024-02-04 18:27:28 +0800231index 8c2a996..e61a6aa 100644
developer6727afb2022-09-01 20:56:09 +0800232--- a/mt7915/vendor.h
233+++ b/mt7915/vendor.h
developera72bbd82024-02-04 18:27:28 +0800234@@ -13,6 +13,7 @@ enum mtk_nl80211_vendor_subcmds {
developer57de9b72023-02-20 11:15:54 +0800235 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developer6727afb2022-09-01 20:56:09 +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
developera72bbd82024-02-04 18:27:28 +0800242@@ -32,6 +33,7 @@ enum mtk_vendor_attr_edcca_ctrl {
developer6727afb2022-09-01 20:56:09 +0800243 NUM_MTK_VENDOR_ATTRS_EDCCA_CTRL - 1
244 };
245
developer335cbee2022-11-17 14:55:34 +0800246+
247 enum mtk_vendor_attr_edcca_dump {
248 MTK_VENDOR_ATTR_EDCCA_DUMP_UNSPEC = 0,
249
developera72bbd82024-02-04 18:27:28 +0800250@@ -46,6 +48,18 @@ enum mtk_vendor_attr_edcca_dump {
developer335cbee2022-11-17 14:55:34 +0800251 NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP - 1
252 };
253
developer6727afb2022-09-01 20:56:09 +0800254+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+
developer335cbee2022-11-17 14:55:34 +0800265+
developer6727afb2022-09-01 20:56:09 +0800266 enum mtk_capi_control_changed {
267 CAPI_RFEATURE_CHANGED = BIT(16),
developer335cbee2022-11-17 14:55:34 +0800268 CAPI_WIRELESS_CHANGED = BIT(17),
developer6727afb2022-09-01 20:56:09 +0800269--
developer0443cd32023-09-19 14:11:49 +08002702.18.0
developer6727afb2022-09-01 20:56:09 +0800271