blob: 47606a02211dfa0b293b201426f5e73cee2bcb06 [file] [log] [blame]
developer6a1998b2022-12-08 18:09:45 +08001From c327c081324034c44660ded9a50848da27c81879 Mon Sep 17 00:00:00 2001
2From: mtk27835 <shurong.wen@mediatek.com>
3Date: Wed, 7 Sep 2022 14:01:29 -0700
4Subject: [PATCH 1126/1128] mt76: mt7915: add ibf control vendor cmd
5
6Signed-off-by: mtk27835 <shurong.wen@mediatek.com>
7---
8 mt7915/vendor.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++
9 mt7915/vendor.h | 25 ++++++++++++++++-
10 2 files changed, 95 insertions(+), 1 deletion(-)
11
12diff --git a/mt7915/vendor.c b/mt7915/vendor.c
13index 6b86b77a..e4915623 100644
14--- a/mt7915/vendor.c
15+++ b/mt7915/vendor.c
16@@ -86,6 +86,17 @@ edcca_dump_policy[NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP] = {
17 [MTK_VENDOR_ATTR_EDCCA_DUMP_SEC80_VAL] = { .type = NLA_U8 },
18 };
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+
30+
31 struct csi_null_tone {
32 u8 start;
33 u8 end;
34@@ -1192,6 +1203,54 @@ static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy,
35 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 {
89@@ -1285,6 +1344,18 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
90 .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
109index d96e5c23..949c8853 100644
110--- a/mt7915/vendor.h
111+++ b/mt7915/vendor.h
112@@ -12,7 +12,8 @@ enum mtk_nl80211_vendor_subcmds {
113 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
122@@ -222,4 +223,26 @@ enum mtk_vendor_attr_phy_capa_dump {
123 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--
1502.36.1
151