blob: e70b1563112ae22bc8f04b1803b95e0f8960ac49 [file] [log] [blame]
developer753619c2024-02-22 13:42:45 +08001From 3826a1e88d7c7a979550040d1bcacd4358491ad2 Mon Sep 17 00:00:00 2001
developerbd9fa1e2023-10-16 11:04:00 +08002From: "Allen.Ye" <allen.ye@mediatek.com>
3Date: Fri, 22 Sep 2023 09:54:49 +0800
developereb155692024-01-11 14:08:37 +08004Subject: [PATCH 1025/1044] mtk: wifi: mt76: mt7996: add ibf control vendor cmd
developerbd9fa1e2023-10-16 11:04:00 +08005
6Signed-off-by: Allen.Ye <allen.ye@mediatek.com>
7---
8 mt7996/vendor.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
9 mt7996/vendor.h | 23 +++++++++++++++++
10 2 files changed, 88 insertions(+)
11
12diff --git a/mt7996/vendor.c b/mt7996/vendor.c
developer1a173672023-12-21 14:49:33 +080013index 9f333d0e..dae3260a 100644
developerbd9fa1e2023-10-16 11:04:00 +080014--- a/mt7996/vendor.c
15+++ b/mt7996/vendor.c
16@@ -60,6 +60,11 @@ edcca_dump_policy[NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP] = {
17 [MTK_VENDOR_ATTR_EDCCA_DUMP_SEC160_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 struct mt7996_amnt_data {
26 u8 idx;
27 u8 addr[ETH_ALEN];
28@@ -556,6 +561,54 @@ mt7996_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
29 return EDCCA_MAX_BW_NUM;
30 }
31
32+static int mt7996_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 mt7996_phy *phy = mt7996_hw_phy(hw);
39+ struct mt7996_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 = mt7996_mcu_set_txbf(dev, BF_HW_EN_UPDATE);
55+ if (err)
56+ return err;
57+ }
58+ return 0;
59+}
60+
61+static int
62+mt7996_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 mt7996_phy *phy = mt7996_hw_phy(hw);
68+ struct mt7996_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 static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
81 {
82 .info = {
83@@ -604,6 +657,18 @@ static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
84 .policy = edcca_ctrl_policy,
85 .maxattr = MTK_VENDOR_ATTR_EDCCA_CTRL_MAX,
86 },
87+ {
88+ .info = {
89+ .vendor_id = MTK_NL80211_VENDOR_ID,
90+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL,
91+ },
92+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
93+ WIPHY_VENDOR_CMD_NEED_RUNNING,
94+ .doit = mt7996_vendor_ibf_ctrl,
95+ .dumpit = mt7996_vendor_ibf_ctrl_dump,
96+ .policy = ibf_ctrl_policy,
97+ .maxattr = MTK_VENDOR_ATTR_IBF_CTRL_MAX,
98+ },
99 };
100
101 void mt7996_vendor_register(struct mt7996_phy *phy)
102diff --git a/mt7996/vendor.h b/mt7996/vendor.h
developer1a173672023-12-21 14:49:33 +0800103index 4465bc9d..49f46f25 100644
developerbd9fa1e2023-10-16 11:04:00 +0800104--- a/mt7996/vendor.h
105+++ b/mt7996/vendor.h
106@@ -7,6 +7,7 @@ enum mtk_nl80211_vendor_subcmds {
107 MTK_NL80211_VENDOR_SUBCMD_AMNT_CTRL = 0xae,
108 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
109 MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7,
110+ MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9,
111 MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL = 0xca,
112 };
113
114@@ -102,4 +103,26 @@ enum mtk_vendor_attr_bss_color_ctrl {
115 NUM_MTK_VENDOR_ATTRS_BSS_COLOR_CTRL - 1
116 };
117
118+enum mtk_vendor_attr_ibf_ctrl {
119+ MTK_VENDOR_ATTR_IBF_CTRL_UNSPEC,
120+
121+ MTK_VENDOR_ATTR_IBF_CTRL_ENABLE,
122+
123+ /* keep last */
124+ NUM_MTK_VENDOR_ATTRS_IBF_CTRL,
125+ MTK_VENDOR_ATTR_IBF_CTRL_MAX =
126+ NUM_MTK_VENDOR_ATTRS_IBF_CTRL - 1
127+};
128+
129+enum mtk_vendor_attr_ibf_dump {
130+ MTK_VENDOR_ATTR_IBF_DUMP_UNSPEC,
131+
132+ MTK_VENDOR_ATTR_IBF_DUMP_ENABLE,
133+
134+ /* keep last */
135+ NUM_MTK_VENDOR_ATTRS_IBF_DUMP,
136+ MTK_VENDOR_ATTR_IBF_DUMP_MAX =
137+ NUM_MTK_VENDOR_ATTRS_IBF_DUMP - 1
138+};
139+
140 #endif
141--
1422.18.0
143