blob: 747ad3279b3dc184be9cddeefaade36c9667234c [file] [log] [blame]
developer82d34062024-02-29 09:50:59 +08001From d9f388ece4275ee2ff5102825110dc9c7557b1a1 Mon Sep 17 00:00:00 2001
developer5ec82702024-01-25 14:40:04 +08002From: MeiChia Chiu <MeiChia.Chiu@mediatek.com>
3Date: Wed, 24 Jan 2024 14:39:14 +0800
developer82d34062024-02-29 09:50:59 +08004Subject: [PATCH 1048/1049] wifi: mt76: mt7915: add no_beacon vendor command
developer5ec82702024-01-25 14:40:04 +08005 for cert
6
7Add the vendor command to disable/enable beacon
8
9[Usage]
10hostapd_cli -i <interface> no_beacon <value>
11<value>
120: enable beacon
131: disable beacon
14
15Signed-off-by: MeiChia Chiu <meichia.chiu@mediatek.com>
16---
17 mt7915/mcu.c | 11 +++++++++++
18 mt7915/mt7915.h | 1 +
19 mt7915/vendor.c | 42 +++++++++++++++++++++++++++++++++++++++++-
20 mt7915/vendor.h | 12 ++++++++++++
21 4 files changed, 65 insertions(+), 1 deletion(-)
22
23diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer82d34062024-02-29 09:50:59 +080024index ba47d0d0..3b214a23 100644
developer5ec82702024-01-25 14:40:04 +080025--- a/mt7915/mcu.c
26+++ b/mt7915/mcu.c
developera72bbd82024-02-04 18:27:28 +080027@@ -5107,6 +5107,17 @@ int mt7915_mcu_set_rfeature_trig_type(struct mt7915_phy *phy, u8 enable, u8 trig
developer5ec82702024-01-25 14:40:04 +080028 return 0;
29 }
30 }
31+
32+void mt7915_set_beacon_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
33+{
34+ struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
35+ struct ieee80211_hw *hw = mvif->phy->mt76->hw;
36+ u8 val = *((u8 *)data);
37+
38+ vif->bss_conf.enable_beacon = val;
39+
40+ mt7915_mcu_add_beacon(hw, vif, val);
41+}
42 #endif
43
44 #ifdef MTK_DEBUG
45diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer82d34062024-02-29 09:50:59 +080046index 23ee118f..3a596dad 100644
developer5ec82702024-01-25 14:40:04 +080047--- a/mt7915/mt7915.h
48+++ b/mt7915/mt7915.h
developera72bbd82024-02-04 18:27:28 +080049@@ -794,6 +794,7 @@ void mt7915_vendor_amnt_fill_rx(struct mt7915_phy *phy, struct sk_buff *skb);
developer5ec82702024-01-25 14:40:04 +080050 int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy,
51 struct ieee80211_sta *sta);
52 int mt7915_mcu_set_lpi(struct mt7915_phy *phy, bool en);
53+void mt7915_set_beacon_vif(void *data, u8 *mac, struct ieee80211_vif *vif);
54 #endif
55 int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value, s8 compensation);
56 int mt7915_mcu_get_edcca(struct mt7915_phy *phy, u8 mode, s8 *value);
57diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developer82d34062024-02-29 09:50:59 +080058index 566fec01..6154d1a0 100644
developer5ec82702024-01-25 14:40:04 +080059--- a/mt7915/vendor.c
60+++ b/mt7915/vendor.c
61@@ -113,6 +113,11 @@ txpower_ctrl_policy[NUM_MTK_VENDOR_ATTRS_TXPOWER_CTRL] = {
62 [MTK_VENDOR_ATTR_TXPOWER_CTRL_BCN_DUP] = { .type = NLA_U8 },
63 };
64
65+static const struct nla_policy
66+beacon_ctrl_policy[NUM_MTK_VENDOR_ATTRS_BEACON_CTRL] = {
67+ [MTK_VENDOR_ATTR_BEACON_CTRL_MODE] = { .type = NLA_U8 },
68+};
69+
70 struct csi_null_tone {
71 u8 start;
72 u8 end;
73@@ -1399,6 +1404,30 @@ static int mt7915_vendor_txpower_ctrl(struct wiphy *wiphy,
74 return 0;
75 }
76
77+static int mt7915_vendor_beacon_ctrl(struct wiphy *wiphy,
78+ struct wireless_dev *wdev,
79+ const void *data,
80+ int data_len)
81+{
82+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
83+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_BEACON_CTRL];
84+ int err;
85+ u8 val8;
86+
87+ err = nla_parse(tb, MTK_VENDOR_ATTR_BEACON_CTRL_MAX, data, data_len,
88+ beacon_ctrl_policy, NULL);
89+ if (err)
90+ return err;
91+
92+ if (tb[MTK_VENDOR_ATTR_BEACON_CTRL_MODE]) {
93+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_BEACON_CTRL_MODE]);
94+ ieee80211_iterate_active_interfaces_atomic(hw, IEEE80211_IFACE_ITER_RESUME_ALL,
95+ mt7915_set_beacon_vif, &val8);
96+ }
97+
98+ return 0;
99+}
100+
101 static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
102 {
103 .info = {
104@@ -1526,7 +1555,18 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
105 .doit = mt7915_vendor_txpower_ctrl,
106 .policy = txpower_ctrl_policy,
107 .maxattr = MTK_VENDOR_ATTR_TXPOWER_CTRL_MAX,
108- }
109+ },
110+ {
111+ .info = {
112+ .vendor_id = MTK_NL80211_VENDOR_ID,
113+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_BEACON_CTRL,
114+ },
115+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
116+ WIPHY_VENDOR_CMD_NEED_RUNNING,
117+ .doit = mt7915_vendor_beacon_ctrl,
118+ .policy = beacon_ctrl_policy,
119+ .maxattr = MTK_VENDOR_ATTR_BEACON_CTRL_MAX,
120+ },
121 };
122
123 void mt7915_vendor_register(struct mt7915_phy *phy)
124diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developer82d34062024-02-29 09:50:59 +0800125index 5b8a1fb3..661d636f 100644
developer5ec82702024-01-25 14:40:04 +0800126--- a/mt7915/vendor.h
127+++ b/mt7915/vendor.h
128@@ -16,6 +16,7 @@ enum mtk_nl80211_vendor_subcmds {
129 MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8,
130 MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9,
131 MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL = 0xca,
132+ MTK_NL80211_VENDOR_SUBCMD_BEACON_CTRL = 0xcd,
133 MTK_NL80211_VENDOR_SUBCMD_TXPOWER_CTRL = 0xce,
134 };
135
136@@ -289,4 +290,15 @@ enum mtk_vendor_attr_txpower_ctrl {
137 NUM_MTK_VENDOR_ATTRS_TXPOWER_CTRL - 1
138 };
139
140+enum mtk_vendor_attr_beacon_ctrl {
141+ MTK_VENDOR_ATTR_BEACON_CTRL_UNSPEC,
142+
143+ MTK_VENDOR_ATTR_BEACON_CTRL_MODE,
144+
145+ /* keep last */
146+ NUM_MTK_VENDOR_ATTRS_BEACON_CTRL,
147+ MTK_VENDOR_ATTR_BEACON_CTRL_MAX =
148+ NUM_MTK_VENDOR_ATTRS_BEACON_CTRL - 1
149+};
150+
151 #endif
152--
1532.18.0
154