blob: b5be350dac59d997fd5e93b4e884ee5bd1b1f01a [file] [log] [blame]
developer9bc8ec12022-11-18 16:01:14 +08001From 6de06b0f652673f2db19060161dcc94d47ff4ce3 Mon Sep 17 00:00:00 2001
developer20126ad2022-09-12 14:42:56 +08002From: mtk27835 <shurong.wen@mediatek.com>
3Date: Wed, 7 Sep 2022 14:01:29 -0700
developer9bc8ec12022-11-18 16:01:14 +08004Subject: [PATCH] mt76: add ibf control vendor cmd
developer20126ad2022-09-12 14:42:56 +08005
6Signed-off-by: mtk27835 <shurong.wen@mediatek.com>
7---
developer9bc8ec12022-11-18 16:01:14 +08008 mt7915/vendor.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++
9 mt7915/vendor.h | 25 ++++++++++++++++-
10 2 files changed, 95 insertions(+), 1 deletion(-)
developer20126ad2022-09-12 14:42:56 +080011
12diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developer9bc8ec12022-11-18 16:01:14 +080013index 84e088c9..648d2dfb 100644
developer20126ad2022-09-12 14:42:56 +080014--- a/mt7915/vendor.c
15+++ b/mt7915/vendor.c
developer9bc8ec12022-11-18 16:01:14 +080016@@ -86,6 +86,17 @@ edcca_dump_policy[NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP] = {
17 [MTK_VENDOR_ATTR_EDCCA_DUMP_SEC80_VAL] = { .type = NLA_U8 },
developer20126ad2022-09-12 14:42:56 +080018 };
19
20+static const struct nla_policy
21+ibf_ctrl_policy[NUM_MTK_VENDOR_ATTRS_IBF_CTRL] = {
22+ [MTK_VENDOR_ATTR_IBF_CTRL_ENABLE] = { .type = NLA_U8 },
23+};
24+
25+static struct nla_policy
26+ibf_dump_policy[NUM_MTK_VENDOR_ATTRS_IBF_DUMP] = {
27+ [MTK_VENDOR_ATTR_IBF_DUMP_ENABLE] = { .type = NLA_U8 },
28+};
29+
developer9bc8ec12022-11-18 16:01:14 +080030+
developer20126ad2022-09-12 14:42:56 +080031 struct csi_null_tone {
32 u8 start;
developer9bc8ec12022-11-18 16:01:14 +080033 u8 end;
34@@ -1194,6 +1205,54 @@ static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy,
developer20126ad2022-09-12 14:42:56 +080035 return mt7915_mcu_set_cfg(phy, CFGINFO_3WIRE_EN_CFG, three_wire_mode);
36 }
37
38+static int mt7915_vendor_ibf_ctrl(struct wiphy *wiphy,
39+ struct wireless_dev *wdev,
40+ const void *data,
41+ int data_len)
42+{
43+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
44+ struct mt7915_phy *phy = mt7915_hw_phy(hw);
45+ struct mt7915_dev *dev = phy->dev;
46+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_IBF_CTRL];
47+ int err;
48+ u8 val;
49+
50+ err = nla_parse(tb, MTK_VENDOR_ATTR_IBF_CTRL_MAX, data, data_len,
51+ ibf_ctrl_policy, NULL);
52+ if (err)
53+ return err;
54+
55+ if (tb[MTK_VENDOR_ATTR_IBF_CTRL_ENABLE]) {
56+ val = nla_get_u8(tb[MTK_VENDOR_ATTR_IBF_CTRL_ENABLE]);
57+
58+ dev->ibf = !!val;
59+
60+ err = mt7915_mcu_set_txbf(dev, MT_BF_TYPE_UPDATE);
61+ if (err)
62+ return err;
63+ }
64+ return 0;
65+}
66+
67+static int
68+mt7915_vendor_ibf_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
69+ struct sk_buff *skb, const void *data, int data_len,
70+ unsigned long *storage)
71+{
72+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
73+ struct mt7915_phy *phy = mt7915_hw_phy(hw);
74+ struct mt7915_dev *dev = phy->dev;
75+
76+ if (*storage == 1)
77+ return -ENOENT;
78+ *storage = 1;
79+
80+ if (nla_put_u8(skb, MTK_VENDOR_ATTR_IBF_DUMP_ENABLE, dev->ibf))
81+ return -ENOMEM;
82+
83+ return 1;
84+}
85+
86
87 static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
88 {
developer9bc8ec12022-11-18 16:01:14 +080089@@ -1287,6 +1346,18 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developer20126ad2022-09-12 14:42:56 +080090 .doit = mt7915_vendor_3wire_ctrl,
91 .policy = three_wire_ctrl_policy,
92 .maxattr = MTK_VENDOR_ATTR_3WIRE_CTRL_MAX,
93+ },
94+ {
95+ .info = {
96+ .vendor_id = MTK_NL80211_VENDOR_ID,
97+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL,
98+ },
99+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
100+ WIPHY_VENDOR_CMD_NEED_RUNNING,
101+ .doit = mt7915_vendor_ibf_ctrl,
102+ .dumpit = mt7915_vendor_ibf_ctrl_dump,
103+ .policy = ibf_ctrl_policy,
104+ .maxattr = MTK_VENDOR_ATTR_IBF_CTRL_MAX,
105 }
106 };
107
108diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developer9bc8ec12022-11-18 16:01:14 +0800109index d96e5c23..949c8853 100644
developer20126ad2022-09-12 14:42:56 +0800110--- a/mt7915/vendor.h
111+++ b/mt7915/vendor.h
developer9bc8ec12022-11-18 16:01:14 +0800112@@ -12,7 +12,8 @@ enum mtk_nl80211_vendor_subcmds {
developer20126ad2022-09-12 14:42:56 +0800113 MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL = 0xc5,
114 MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6,
115 MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7,
116- MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8
117+ MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8,
118+ MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9,
119 };
120
121
developer9bc8ec12022-11-18 16:01:14 +0800122@@ -222,4 +223,26 @@ enum mtk_vendor_attr_phy_capa_dump {
developer20126ad2022-09-12 14:42:56 +0800123 NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP - 1
124 };
125
126+enum mtk_vendor_attr_ibf_ctrl {
127+ MTK_VENDOR_ATTR_IBF_CTRL_UNSPEC,
128+
129+ MTK_VENDOR_ATTR_IBF_CTRL_ENABLE,
130+
131+ /* keep last */
132+ NUM_MTK_VENDOR_ATTRS_IBF_CTRL,
133+ MTK_VENDOR_ATTR_IBF_CTRL_MAX =
134+ NUM_MTK_VENDOR_ATTRS_IBF_CTRL - 1
135+};
136+
137+enum mtk_vendor_attr_ibf_dump {
138+ MTK_VENDOR_ATTR_IBF_DUMP_UNSPEC,
139+
140+ MTK_VENDOR_ATTR_IBF_DUMP_ENABLE,
141+
142+ /* keep last */
143+ NUM_MTK_VENDOR_ATTRS_IBF_DUMP,
144+ MTK_VENDOR_ATTR_IBF_DUMP_MAX =
145+ NUM_MTK_VENDOR_ATTRS_IBF_DUMP - 1
146+};
147+
148 #endif
149--
developerb81e95d2022-11-08 10:16:29 +08001502.18.0
developer20126ad2022-09-12 14:42:56 +0800151