blob: e2b2206ba7b7e3f7963a8f3964cb6c3fa67140d0 [file] [log] [blame]
developer78848c62023-04-06 13:44:00 +08001From 20a1dbdfe4d19e29748048c864a5946d0c9108b3 Mon Sep 17 00:00:00 2001
developer6a1998b2022-12-08 18:09:45 +08002From: mtk27835 <shurong.wen@mediatek.com>
3Date: Wed, 7 Sep 2022 14:01:29 -0700
developer78848c62023-04-06 13:44:00 +08004Subject: [PATCH 1024/1031] wifi: mt76: mt7915: add ibf control vendor cmd
developer6a1998b2022-12-08 18:09:45 +08005
6Signed-off-by: mtk27835 <shurong.wen@mediatek.com>
7---
developer79e690d2022-12-13 17:05:25 +08008 mt7915/vendor.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
9 mt7915/vendor.h | 25 ++++++++++++++++++-
10 2 files changed, 89 insertions(+), 1 deletion(-)
developer6a1998b2022-12-08 18:09:45 +080011
12diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developerf8871e82023-03-08 17:22:32 +080013index b26b1cc6..3e5c479e 100644
developer6a1998b2022-12-08 18:09:45 +080014--- a/mt7915/vendor.c
15+++ b/mt7915/vendor.c
developer79e690d2022-12-13 17:05:25 +080016@@ -86,6 +86,11 @@ edcca_dump_policy[NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP] = {
developer6a1998b2022-12-08 18:09:45 +080017 [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+
developer6a1998b2022-12-08 18:09:45 +080025 struct csi_null_tone {
26 u8 start;
27 u8 end;
developerb8853042023-02-17 11:50:45 +080028@@ -1188,6 +1193,54 @@ static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy,
developer6a1998b2022-12-08 18:09:45 +080029 return mt7915_mcu_set_cfg(phy, CFGINFO_3WIRE_EN_CFG, three_wire_mode);
30 }
31
32+static int mt7915_vendor_ibf_ctrl(struct wiphy *wiphy,
33+ struct wireless_dev *wdev,
34+ const void *data,
35+ int data_len)
36+{
37+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
38+ struct mt7915_phy *phy = mt7915_hw_phy(hw);
39+ struct mt7915_dev *dev = phy->dev;
40+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_IBF_CTRL];
41+ int err;
42+ u8 val;
43+
44+ err = nla_parse(tb, MTK_VENDOR_ATTR_IBF_CTRL_MAX, data, data_len,
45+ ibf_ctrl_policy, NULL);
46+ if (err)
47+ return err;
48+
49+ if (tb[MTK_VENDOR_ATTR_IBF_CTRL_ENABLE]) {
50+ val = nla_get_u8(tb[MTK_VENDOR_ATTR_IBF_CTRL_ENABLE]);
51+
52+ dev->ibf = !!val;
53+
54+ err = mt7915_mcu_set_txbf(dev, MT_BF_TYPE_UPDATE);
55+ if (err)
56+ return err;
57+ }
58+ return 0;
59+}
60+
61+static int
62+mt7915_vendor_ibf_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
63+ struct sk_buff *skb, const void *data, int data_len,
64+ unsigned long *storage)
65+{
66+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
67+ struct mt7915_phy *phy = mt7915_hw_phy(hw);
68+ struct mt7915_dev *dev = phy->dev;
69+
70+ if (*storage == 1)
71+ return -ENOENT;
72+ *storage = 1;
73+
74+ if (nla_put_u8(skb, MTK_VENDOR_ATTR_IBF_DUMP_ENABLE, dev->ibf))
75+ return -ENOMEM;
76+
77+ return 1;
78+}
79+
80
81 static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
82 {
developerb8853042023-02-17 11:50:45 +080083@@ -1281,6 +1334,18 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developer6a1998b2022-12-08 18:09:45 +080084 .doit = mt7915_vendor_3wire_ctrl,
85 .policy = three_wire_ctrl_policy,
86 .maxattr = MTK_VENDOR_ATTR_3WIRE_CTRL_MAX,
87+ },
88+ {
89+ .info = {
90+ .vendor_id = MTK_NL80211_VENDOR_ID,
91+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL,
92+ },
93+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
94+ WIPHY_VENDOR_CMD_NEED_RUNNING,
95+ .doit = mt7915_vendor_ibf_ctrl,
96+ .dumpit = mt7915_vendor_ibf_ctrl_dump,
97+ .policy = ibf_ctrl_policy,
98+ .maxattr = MTK_VENDOR_ATTR_IBF_CTRL_MAX,
99 }
100 };
101
102diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developerf8871e82023-03-08 17:22:32 +0800103index de3cbe2c..a6309a32 100644
developer6a1998b2022-12-08 18:09:45 +0800104--- a/mt7915/vendor.h
105+++ b/mt7915/vendor.h
106@@ -12,7 +12,8 @@ enum mtk_nl80211_vendor_subcmds {
developere0a1e0e2023-02-24 11:26:12 +0800107 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developer6a1998b2022-12-08 18:09:45 +0800108 MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6,
109 MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7,
110- MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8
111+ MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8,
112+ MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9,
113 };
114
115
116@@ -222,4 +223,26 @@ enum mtk_vendor_attr_phy_capa_dump {
117 NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP - 1
118 };
119
120+enum mtk_vendor_attr_ibf_ctrl {
121+ MTK_VENDOR_ATTR_IBF_CTRL_UNSPEC,
122+
123+ MTK_VENDOR_ATTR_IBF_CTRL_ENABLE,
124+
125+ /* keep last */
126+ NUM_MTK_VENDOR_ATTRS_IBF_CTRL,
127+ MTK_VENDOR_ATTR_IBF_CTRL_MAX =
128+ NUM_MTK_VENDOR_ATTRS_IBF_CTRL - 1
129+};
130+
131+enum mtk_vendor_attr_ibf_dump {
132+ MTK_VENDOR_ATTR_IBF_DUMP_UNSPEC,
133+
134+ MTK_VENDOR_ATTR_IBF_DUMP_ENABLE,
135+
136+ /* keep last */
137+ NUM_MTK_VENDOR_ATTRS_IBF_DUMP,
138+ MTK_VENDOR_ATTR_IBF_DUMP_MAX =
139+ NUM_MTK_VENDOR_ATTRS_IBF_DUMP - 1
140+};
141+
142 #endif
143--
developer78848c62023-04-06 13:44:00 +08001442.39.0
developer6a1998b2022-12-08 18:09:45 +0800145