blob: 8fd0e42f56a8bb324227ca7e14a18fd65c633ee6 [file] [log] [blame]
developerd243af02023-12-21 14:49:33 +08001From 05f2c9d7b83e9528809d5ee9773a8f3653fe3334 Mon Sep 17 00:00:00 2001
developer6a1998b2022-12-08 18:09:45 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Fri, 28 Oct 2022 10:15:56 +0800
developerd243af02023-12-21 14:49:33 +08004Subject: [PATCH 33/76] wifi: mt76: mt7915: add vendor subcmd three wire (PTA)
5 ctrl
developer6a1998b2022-12-08 18:09:45 +08006
7Change-Id: Ic1044698f294455594a0c6254f55326fdab90580
8Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
9---
10 mt76_connac_mcu.h | 2 +-
11 mt7915/mcu.c | 50 ++++++++++++++++++++++-------------------------
12 mt7915/mcu.h | 29 +++++++++++++++++++++++++++
13 mt7915/mt7915.h | 1 +
14 mt7915/vendor.c | 44 ++++++++++++++++++++++++++++++++++++++++-
15 mt7915/vendor.h | 14 +++++++++++++
16 6 files changed, 111 insertions(+), 29 deletions(-)
17
18diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developerd243af02023-12-21 14:49:33 +080019index 9e40749..b4392bc 100644
developer6a1998b2022-12-08 18:09:45 +080020--- a/mt76_connac_mcu.h
21+++ b/mt76_connac_mcu.h
developerd243af02023-12-21 14:49:33 +080022@@ -1236,7 +1236,7 @@ enum {
developer6a1998b2022-12-08 18:09:45 +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,
30 MCU_EXT_CMD_IPI_HIST_SCAN = 0xc5,
31diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developerd243af02023-12-21 14:49:33 +080032index 884b394..42f699f 100644
developer6a1998b2022-12-08 18:09:45 +080033--- a/mt7915/mcu.c
34+++ b/mt7915/mcu.c
developere35b8e42023-10-16 11:04:00 +080035@@ -4526,37 +4526,33 @@ void mt7915_mcu_set_dynalgo(struct mt7915_phy *phy, u8 enable)
developer6a1998b2022-12-08 18:09:45 +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 };
71+ 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
developere35b8e42023-10-16 11:04:00 +080097index d271e2b..5fc4e2e 100644
developer6a1998b2022-12-08 18:09:45 +080098--- a/mt7915/mcu.h
99+++ b/mt7915/mcu.h
developerad9333b2023-05-22 15:16:16 +0800100@@ -904,6 +904,35 @@ struct mt7915_mcu_rdd_ipi_scan {
developer6a1998b2022-12-08 18:09:45 +0800101 u8 tx_assert_time; /* unit: us */
102 } __packed;
103
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
developerd243af02023-12-21 14:49:33 +0800137index 992323d..8730655 100644
developer6a1998b2022-12-08 18:09:45 +0800138--- a/mt7915/mt7915.h
139+++ b/mt7915/mt7915.h
developerd243af02023-12-21 14:49:33 +0800140@@ -708,6 +708,7 @@ void mt7915_mcu_set_mimo(struct mt7915_phy *phy, u8 direction);
developer6a1998b2022-12-08 18:09:45 +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
developerd243af02023-12-21 14:49:33 +0800149index 25509d6..0db493d 100644
developer6a1998b2022-12-08 18:09:45 +0800150--- a/mt7915/vendor.c
151+++ b/mt7915/vendor.c
developere0a1e0e2023-02-24 11:26:12 +0800152@@ -40,6 +40,11 @@ mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = {
153 [MTK_VENDOR_ATTR_MU_CTRL_DUMP] = {.type = NLA_U8 },
developer6a1998b2022-12-08 18:09:45 +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 },
developerd243af02023-12-21 14:49:33 +0800164@@ -974,7 +979,7 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy,
developer6a1998b2022-12-08 18:09:45 +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
developerd243af02023-12-21 14:49:33 +0800173@@ -1118,6 +1123,7 @@ static int mt7915_vendor_edcca_ctrl(struct wiphy *wiphy,
developer6a1998b2022-12-08 18:09:45 +0800174 return 0;
175 }
176
177+
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,
developerd243af02023-12-21 14:49:33 +0800181@@ -1161,6 +1167,31 @@ mt7915_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
developer6a1998b2022-12-08 18:09:45 +0800182 return len;
183 }
184
185+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+
209+
210 static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
211 {
212 .info = {
developerd243af02023-12-21 14:49:33 +0800213@@ -1242,6 +1273,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developer6a1998b2022-12-08 18:09:45 +0800214 .dumpit = mt7915_vendor_edcca_ctrl_dump,
215 .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
developere35b8e42023-10-16 11:04:00 +0800232index d8e23d3..de3cbe2 100644
developer6a1998b2022-12-08 18:09:45 +0800233--- a/mt7915/vendor.h
234+++ b/mt7915/vendor.h
235@@ -12,6 +12,7 @@ enum mtk_nl80211_vendor_subcmds {
developere0a1e0e2023-02-24 11:26:12 +0800236 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developer6a1998b2022-12-08 18:09:45 +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
243@@ -31,6 +32,7 @@ enum mtk_vendor_attr_edcca_ctrl {
244 NUM_MTK_VENDOR_ATTRS_EDCCA_CTRL - 1
245 };
246
247+
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
255+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+
266+
267 enum mtk_capi_control_changed {
268 CAPI_RFEATURE_CHANGED = BIT(16),
269 CAPI_WIRELESS_CHANGED = BIT(17),
270--
developere35b8e42023-10-16 11:04:00 +08002712.18.0
developer6a1998b2022-12-08 18:09:45 +0800272