blob: 60b7d81fba842c7955de6219e0df685f8573c54f [file] [log] [blame]
developera20cdc22024-05-31 18:57:31 +08001From b523d127286292b2915eda127d35001ee67ab461 Mon Sep 17 00:00:00 2001
developere2cfb522022-12-08 18:09:45 +08002From: mtk27835 <shurong.wen@mediatek.com>
3Date: Wed, 7 Sep 2022 14:01:29 -0700
developera20cdc22024-05-31 18:57:31 +08004Subject: [PATCH 1019/1051] wifi: mt76: mt7915: add ibf control vendor cmd
developere2cfb522022-12-08 18:09:45 +08005
6Signed-off-by: mtk27835 <shurong.wen@mediatek.com>
7---
developeraa5b1b22022-12-13 17:05:25 +08008 mt7915/vendor.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
9 mt7915/vendor.h | 25 ++++++++++++++++++-
10 2 files changed, 89 insertions(+), 1 deletion(-)
developere2cfb522022-12-08 18:09:45 +080011
12diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developerdc9eeae2024-04-08 14:36:46 +080013index eeac18d..a21cbce 100644
developere2cfb522022-12-08 18:09:45 +080014--- a/mt7915/vendor.c
15+++ b/mt7915/vendor.c
developer753619c2024-02-22 13:42:45 +080016@@ -87,6 +87,11 @@ edcca_dump_policy[NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP] = {
developere2cfb522022-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+
developere2cfb522022-12-08 18:09:45 +080025 struct csi_null_tone {
26 u8 start;
27 u8 end;
developer753619c2024-02-22 13:42:45 +080028@@ -1209,6 +1214,54 @@ static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy,
developere2cfb522022-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 {
developer753619c2024-02-22 13:42:45 +080083@@ -1302,6 +1355,18 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developere2cfb522022-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
developerdc9eeae2024-04-08 14:36:46 +0800103index e61a6aa..876edf3 100644
developere2cfb522022-12-08 18:09:45 +0800104--- a/mt7915/vendor.h
105+++ b/mt7915/vendor.h
developer753619c2024-02-22 13:42:45 +0800106@@ -13,7 +13,8 @@ enum mtk_nl80211_vendor_subcmds {
developer2c78ce72023-02-24 11:26:12 +0800107 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developere2cfb522022-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
developer753619c2024-02-22 13:42:45 +0800116@@ -225,4 +226,26 @@ enum mtk_vendor_attr_phy_capa_dump {
developere2cfb522022-12-08 18:09:45 +0800117 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--
developerbd9fa1e2023-10-16 11:04:00 +08001442.18.0
developere2cfb522022-12-08 18:09:45 +0800145