blob: 354e5530867206c8c50ca91b79391b67d61e0282 [file] [log] [blame]
developere35b8e42023-10-16 11:04:00 +08001From b5d139f32d6f4f6476b82d59af7a96a1f57858a9 Mon Sep 17 00:00:00 2001
2From: "Allen.Ye" <allen.ye@mediatek.com>
3Date: Fri, 22 Sep 2023 09:54:49 +0800
4Subject: [PATCH 59/98] wifi: mt76: mt7996: add ibf control vendor cmd
5
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
13index 9f333d0..dae3260 100644
14--- 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
103index 4465bc9..49f46f2 100644
104--- 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