blob: 2d626156e518ea8e9bc4ef9a923d32b926f659f4 [file] [log] [blame]
developerbbd45e12023-05-19 08:22:06 +08001From ceaf2875e70fba9ac5c4a65f6cfa13c447a2cf0d 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
developerbbd45e12023-05-19 08:22:06 +08004Subject: [PATCH 1023/1033] wifi: mt76: mt7915: add vendor subcmd three wire
developerc9233442023-04-04 06:06:17 +08005 (PTA) ctrl
developer6727afb2022-09-01 20:56:09 +08006
developer887da632022-10-28 09:35:38 +08007Change-Id: Ic1044698f294455594a0c6254f55326fdab90580
developer6727afb2022-09-01 20:56:09 +08008Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
9---
10 mt76_connac_mcu.h | 2 +-
developer81ca9d62022-10-14 11:23:22 +080011 mt7915/mcu.c | 50 ++++++++++++++++++++++-------------------------
developer6727afb2022-09-01 20:56:09 +080012 mt7915/mcu.h | 29 +++++++++++++++++++++++++++
13 mt7915/mt7915.h | 1 +
developer335cbee2022-11-17 14:55:34 +080014 mt7915/vendor.c | 44 ++++++++++++++++++++++++++++++++++++++++-
15 mt7915/vendor.h | 14 +++++++++++++
16 6 files changed, 111 insertions(+), 29 deletions(-)
developer6727afb2022-09-01 20:56:09 +080017
18diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developerbbd45e12023-05-19 08:22:06 +080019index 35fb252..661d790 100644
developer6727afb2022-09-01 20:56:09 +080020--- a/mt76_connac_mcu.h
21+++ b/mt76_connac_mcu.h
developer4f0d84b2023-03-03 14:21:44 +080022@@ -1201,7 +1201,7 @@ enum {
developer6727afb2022-09-01 20:56:09 +080023 /* for vendor csi and air monitor */
24 MCU_EXT_CMD_SMESH_CTRL = 0xae,
25 MCU_EXT_CMD_RX_STAT_USER_CTRL = 0xb3,
26- MCU_EXT_CMD_CERT_CFG = 0xb7,
27+ MCU_EXT_CMD_SET_CFG = 0xb7,
28 MCU_EXT_CMD_EDCCA = 0xba,
29 MCU_EXT_CMD_CSI_CTRL = 0xc2,
developer887da632022-10-28 09:35:38 +080030 MCU_EXT_CMD_IPI_HIST_SCAN = 0xc5,
developer6727afb2022-09-01 20:56:09 +080031diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developerbbd45e12023-05-19 08:22:06 +080032index 9cde484..7603bd8 100644
developer6727afb2022-09-01 20:56:09 +080033--- a/mt7915/mcu.c
34+++ b/mt7915/mcu.c
developerbbd45e12023-05-19 08:22:06 +080035@@ -4419,37 +4419,33 @@ void mt7915_mcu_set_dynalgo(struct mt7915_phy *phy, u8 enable)
developer6727afb2022-09-01 20:56:09 +080036 &req, sizeof(req), false);
37 }
38
39-void mt7915_mcu_set_cert(struct mt7915_phy *phy, u8 type)
40+int mt7915_mcu_set_cfg(struct mt7915_phy *phy, u8 cfg_info, u8 type)
41 {
42-#define CFGINFO_CERT_CFG 4
43 struct mt7915_dev *dev = phy->dev;
44- struct {
45- struct basic_info{
46- u8 dbdc_idx;
47- u8 rsv[3];
48- __le32 tlv_num;
49- u8 tlv_buf[0];
50- } hdr;
51- struct cert_cfg{
52- __le16 tag;
53- __le16 length;
54- u8 cert_program;
55- u8 rsv[3];
56- } tlv;
57- } req = {
58- .hdr = {
59- .dbdc_idx = phy != &dev->phy,
60- .tlv_num = cpu_to_le32(1),
61- },
62- .tlv = {
63- .tag = cpu_to_le16(CFGINFO_CERT_CFG),
64- .length = cpu_to_le16(sizeof(struct cert_cfg)),
65- .cert_program = type, /* 1: CAPI Enable */
66- }
67+ struct cfg_basic_info req = {
68+ .dbdc_idx = phy != &dev->phy,
69+ .tlv_num = cpu_to_le32(1),
70 };
developer6727afb2022-09-01 20:56:09 +080071+ int tlv_len;
72+
73+ switch (cfg_info) {
74+ case CFGINFO_CERT_CFG:
75+ tlv_len = sizeof(struct cert_cfg);
76+ req.cert.tag = cpu_to_le16(cfg_info);
77+ req.cert.length = cpu_to_le16(tlv_len);
78+ req.cert.cert_program = type;
79+ break;
80+ case CFGINFO_3WIRE_EN_CFG:
81+ tlv_len = sizeof(struct three_wire_cfg);
82+ req.three_wire.tag = cpu_to_le16(cfg_info);
83+ req.three_wire.length = cpu_to_le16(tlv_len);
84+ req.three_wire.three_wire_en = type;
85+ break;
86+ default:
87+ return -EOPNOTSUPP;
88+ }
89
90- mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(CERT_CFG),
91- &req, sizeof(req), false);
92+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_CFG), &req, sizeof(req), false);
93 }
94
95 void mt7915_mcu_set_bypass_smthint(struct mt7915_phy *phy, u8 val)
96diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developerbbd45e12023-05-19 08:22:06 +080097index 97ae882..3da650c 100644
developer6727afb2022-09-01 20:56:09 +080098--- a/mt7915/mcu.h
99+++ b/mt7915/mcu.h
developerbbd45e12023-05-19 08:22:06 +0800100@@ -904,6 +904,35 @@ struct mt7915_mcu_rdd_ipi_scan {
developer887da632022-10-28 09:35:38 +0800101 u8 tx_assert_time; /* unit: us */
102 } __packed;
developer6727afb2022-09-01 20:56:09 +0800103
104+struct cert_cfg {
105+ __le16 tag;
106+ __le16 length;
107+ u8 cert_program;
108+ u8 rsv[3];
109+} __packed;
110+
111+struct three_wire_cfg {
112+ __le16 tag;
113+ __le16 length;
114+ u8 three_wire_en;
115+ u8 rsv[3];
116+} __packed;
117+
118+struct cfg_basic_info {
119+ u8 dbdc_idx;
120+ u8 rsv[3];
121+ __le32 tlv_num;
122+ union {
123+ struct cert_cfg cert;
124+ struct three_wire_cfg three_wire;
125+ };
126+} __packed;
127+
128+enum {
129+ CFGINFO_CERT_CFG = 4,
130+ CFGINFO_3WIRE_EN_CFG = 10,
131+};
132+
133 /* MURU */
134 #define OFDMA_DL BIT(0)
135 #define OFDMA_UL BIT(1)
136diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developerbbd45e12023-05-19 08:22:06 +0800137index 25f92e1..b3a0f2a 100644
developer6727afb2022-09-01 20:56:09 +0800138--- a/mt7915/mt7915.h
139+++ b/mt7915/mt7915.h
developerbbd45e12023-05-19 08:22:06 +0800140@@ -756,6 +756,7 @@ void mt7915_mcu_set_mimo(struct mt7915_phy *phy, u8 direction);
developer6727afb2022-09-01 20:56:09 +0800141 void mt7915_mcu_set_dynalgo(struct mt7915_phy *phy, u8 enable);
142 int mt7915_mcu_set_mu_edca(struct mt7915_phy *phy, u8 val);
143 void mt7915_mcu_set_cert(struct mt7915_phy *phy, u8 type);
144+int mt7915_mcu_set_cfg(struct mt7915_phy *phy, u8 cfg_info, u8 type);
145 void mt7915_mcu_set_bypass_smthint(struct mt7915_phy *phy, u8 val);
146 void mt7915_vendor_register(struct mt7915_phy *phy);
147 int mt7915_mcu_set_csi(struct mt7915_phy *phy, u8 mode,
148diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developerbbd45e12023-05-19 08:22:06 +0800149index 0c0b47e..b651cea 100644
developer6727afb2022-09-01 20:56:09 +0800150--- a/mt7915/vendor.c
151+++ b/mt7915/vendor.c
developer57de9b72023-02-20 11:15:54 +0800152@@ -40,6 +40,11 @@ mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = {
153 [MTK_VENDOR_ATTR_MU_CTRL_DUMP] = {.type = NLA_U8 },
developer6727afb2022-09-01 20:56:09 +0800154 };
155
156+static const struct nla_policy
157+three_wire_ctrl_policy[NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL] = {
158+ [MTK_VENDOR_ATTR_3WIRE_CTRL_MODE] = {.type = NLA_U8 },
159+};
160+
161 static const struct nla_policy
162 rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = {
163 [MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI] = {.type = NLA_U8 },
developerbbd45e12023-05-19 08:22:06 +0800164@@ -973,7 +978,7 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy,
developer6727afb2022-09-01 20:56:09 +0800165 mt7915_set_wireless_vif, &val32);
166 } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT]) {
167 val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT]);
168- mt7915_mcu_set_cert(phy, val8); /* Cert Enable for OMI */
169+ mt7915_mcu_set_cfg(phy, CFGINFO_CERT_CFG, val8); /* Cert Enable for OMI */
170 mt7915_mcu_set_bypass_smthint(phy, val8); /* Cert bypass smooth interpolation */
171 }
172
developerbbd45e12023-05-19 08:22:06 +0800173@@ -1117,6 +1122,7 @@ static int mt7915_vendor_edcca_ctrl(struct wiphy *wiphy,
developer6727afb2022-09-01 20:56:09 +0800174 return 0;
175 }
176
developer335cbee2022-11-17 14:55:34 +0800177+
178 static int
179 mt7915_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
180 struct sk_buff *skb, const void *data, int data_len,
developerbbd45e12023-05-19 08:22:06 +0800181@@ -1160,6 +1166,31 @@ mt7915_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
developer335cbee2022-11-17 14:55:34 +0800182 return len;
183 }
184
developer6727afb2022-09-01 20:56:09 +0800185+static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy,
186+ struct wireless_dev *wdev,
187+ const void *data,
188+ int data_len)
189+{
190+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
191+ struct mt7915_phy *phy = mt7915_hw_phy(hw);
192+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL];
193+ int err;
194+ u8 three_wire_mode;
195+
196+ err = nla_parse(tb, MTK_VENDOR_ATTR_3WIRE_CTRL_MAX, data, data_len,
197+ three_wire_ctrl_policy, NULL);
198+ if (err)
199+ return err;
200+
201+ if (!tb[MTK_VENDOR_ATTR_3WIRE_CTRL_MODE])
202+ return -EINVAL;
203+
204+ three_wire_mode = nla_get_u8(tb[MTK_VENDOR_ATTR_3WIRE_CTRL_MODE]);
205+
206+ return mt7915_mcu_set_cfg(phy, CFGINFO_3WIRE_EN_CFG, three_wire_mode);
207+}
208+
developer335cbee2022-11-17 14:55:34 +0800209+
developer6727afb2022-09-01 20:56:09 +0800210 static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
211 {
developer335cbee2022-11-17 14:55:34 +0800212 .info = {
developerbbd45e12023-05-19 08:22:06 +0800213@@ -1241,6 +1272,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developer335cbee2022-11-17 14:55:34 +0800214 .dumpit = mt7915_vendor_edcca_ctrl_dump,
developer6727afb2022-09-01 20:56:09 +0800215 .policy = edcca_ctrl_policy,
216 .maxattr = MTK_VENDOR_ATTR_EDCCA_CTRL_MAX,
217+ },
218+ {
219+ .info = {
220+ .vendor_id = MTK_NL80211_VENDOR_ID,
221+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL,
222+ },
223+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
224+ WIPHY_VENDOR_CMD_NEED_RUNNING,
225+ .doit = mt7915_vendor_3wire_ctrl,
226+ .policy = three_wire_ctrl_policy,
227+ .maxattr = MTK_VENDOR_ATTR_3WIRE_CTRL_MAX,
228 }
229 };
230
231diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developer1d9da7d2023-04-15 12:45:34 +0800232index d8e23d3..de3cbe2 100644
developer6727afb2022-09-01 20:56:09 +0800233--- a/mt7915/vendor.h
234+++ b/mt7915/vendor.h
developer335cbee2022-11-17 14:55:34 +0800235@@ -12,6 +12,7 @@ enum mtk_nl80211_vendor_subcmds {
developer57de9b72023-02-20 11:15:54 +0800236 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developer6727afb2022-09-01 20:56:09 +0800237 MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6,
238 MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7,
239+ MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8
240 };
241
242
developer335cbee2022-11-17 14:55:34 +0800243@@ -31,6 +32,7 @@ enum mtk_vendor_attr_edcca_ctrl {
developer6727afb2022-09-01 20:56:09 +0800244 NUM_MTK_VENDOR_ATTRS_EDCCA_CTRL - 1
245 };
246
developer335cbee2022-11-17 14:55:34 +0800247+
248 enum mtk_vendor_attr_edcca_dump {
249 MTK_VENDOR_ATTR_EDCCA_DUMP_UNSPEC = 0,
250
251@@ -45,6 +47,18 @@ enum mtk_vendor_attr_edcca_dump {
252 NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP - 1
253 };
254
developer6727afb2022-09-01 20:56:09 +0800255+enum mtk_vendor_attr_3wire_ctrl {
256+ MTK_VENDOR_ATTR_3WIRE_CTRL_UNSPEC,
257+
258+ MTK_VENDOR_ATTR_3WIRE_CTRL_MODE,
259+
260+ /* keep last */
261+ NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL,
262+ MTK_VENDOR_ATTR_3WIRE_CTRL_MAX =
263+ NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL - 1
264+};
265+
developer335cbee2022-11-17 14:55:34 +0800266+
developer6727afb2022-09-01 20:56:09 +0800267 enum mtk_capi_control_changed {
268 CAPI_RFEATURE_CHANGED = BIT(16),
developer335cbee2022-11-17 14:55:34 +0800269 CAPI_WIRELESS_CHANGED = BIT(17),
developer6727afb2022-09-01 20:56:09 +0800270--
developer2324aa22023-04-12 11:30:15 +08002712.18.0
developer6727afb2022-09-01 20:56:09 +0800272