blob: d3485722665f03c840a0459ff8744fef4949bcb1 [file] [log] [blame]
From 139cc10423d9b2c5e5528bf45a12a54bbe265c20 Mon Sep 17 00:00:00 2001
From: MeiChia Chiu <meichia.chiu@mediatek.com>
Date: Wed, 22 Nov 2023 22:42:09 +0800
Subject: [PATCH 1040/1044] mtk: wifi: mt76: mt7996: add no_beacon vendor
command for cert
Add the vendor command to disable/enable beacon
[Usage]
hostapd_cli -i <interface> no_beacon <value>
<value>
0: enable beacon
1: disable beacon
Signed-off-by: MeiChia Chiu <meichia.chiu@mediatek.com>
---
mt7996/mcu.c | 11 +++++++++++
mt7996/mt7996.h | 1 +
mt7996/vendor.c | 41 +++++++++++++++++++++++++++++++++++++++++
mt7996/vendor.h | 12 ++++++++++++
4 files changed, 65 insertions(+)
diff --git a/mt7996/mcu.c b/mt7996/mcu.c
index dde2a505..2bcee895 100644
--- a/mt7996/mcu.c
+++ b/mt7996/mcu.c
@@ -5055,4 +5055,15 @@ void mt7996_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
break;
}
}
+
+void mt7996_set_beacon_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
+{
+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
+ struct ieee80211_hw *hw = mvif->phy->mt76->hw;
+ u8 val = *((u8 *)data);
+
+ vif->bss_conf.enable_beacon = val;
+
+ mt7996_mcu_add_beacon(hw, vif, val);
+}
#endif
diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
index 881328be..bb2cee92 100644
--- a/mt7996/mt7996.h
+++ b/mt7996/mt7996.h
@@ -829,6 +829,7 @@ void mt7996_set_wireless_amsdu(struct ieee80211_hw *hw, u8 en);
void mt7996_mcu_set_mimo(struct mt7996_phy *phy);
int mt7996_set_muru_cfg(struct mt7996_phy *phy, u8 action, u8 val);
int mt7996_mcu_set_muru_cfg(struct mt7996_phy *phy, void *data);
+void mt7996_set_beacon_vif(void *data, u8 *mac, struct ieee80211_vif *vif);
#endif
int mt7996_mcu_edcca_enable(struct mt7996_phy *phy, bool enable);
diff --git a/mt7996/vendor.c b/mt7996/vendor.c
index 9732ed28..c87cc5c1 100644
--- a/mt7996/vendor.c
+++ b/mt7996/vendor.c
@@ -112,6 +112,11 @@ pp_ctrl_policy[NUM_MTK_VENDOR_ATTRS_PP_CTRL] = {
[MTK_VENDOR_ATTR_PP_MODE] = { .type = NLA_U8 },
};
+static const struct nla_policy
+beacon_ctrl_policy[NUM_MTK_VENDOR_ATTRS_BEACON_CTRL] = {
+ [MTK_VENDOR_ATTR_BEACON_CTRL_MODE] = { .type = NLA_U8 },
+};
+
struct mt7996_amnt_data {
u8 idx;
u8 addr[ETH_ALEN];
@@ -904,6 +909,31 @@ static int mt7996_vendor_pp_ctrl(struct wiphy *wiphy, struct wireless_dev *wdev,
return err;
}
+static int mt7996_vendor_beacon_ctrl(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ const void *data,
+ int data_len)
+{
+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_BEACON_CTRL];
+ int err;
+ u8 val8;
+
+ err = nla_parse(tb, MTK_VENDOR_ATTR_BEACON_CTRL_MAX, data, data_len,
+ beacon_ctrl_policy, NULL);
+ if (err)
+ return err;
+
+ if (tb[MTK_VENDOR_ATTR_BEACON_CTRL_MODE]) {
+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_BEACON_CTRL_MODE]);
+ ieee80211_iterate_active_interfaces_atomic(hw, IEEE80211_IFACE_ITER_RESUME_ALL,
+ mt7996_set_beacon_vif, &val8);
+ }
+
+ return 0;
+}
+
+
static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
{
.info = {
@@ -1020,6 +1050,17 @@ static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
.policy = pp_ctrl_policy,
.maxattr = MTK_VENDOR_ATTR_PP_CTRL_MAX,
},
+ {
+ .info = {
+ .vendor_id = MTK_NL80211_VENDOR_ID,
+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_BEACON_CTRL,
+ },
+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
+ WIPHY_VENDOR_CMD_NEED_RUNNING,
+ .doit = mt7996_vendor_beacon_ctrl,
+ .policy = beacon_ctrl_policy,
+ .maxattr = MTK_VENDOR_ATTR_BEACON_CTRL_MAX,
+ },
};
void mt7996_vendor_register(struct mt7996_phy *phy)
diff --git a/mt7996/vendor.h b/mt7996/vendor.h
index 98128965..e7d88828 100644
--- a/mt7996/vendor.h
+++ b/mt7996/vendor.h
@@ -16,6 +16,7 @@ enum mtk_nl80211_vendor_subcmds {
MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL = 0xca,
MTK_NL80211_VENDOR_SUBCMD_BACKGROUND_RADAR_CTRL = 0xcb,
MTK_NL80211_VENDOR_SUBCMD_PP_CTRL = 0xcc,
+ MTK_NL80211_VENDOR_SUBCMD_BEACON_CTRL = 0xcd,
};
enum mtk_vendor_attr_edcca_ctrl {
@@ -226,6 +227,17 @@ enum mtk_vendor_attr_pp_ctrl {
NUM_MTK_VENDOR_ATTRS_PP_CTRL - 1
};
+enum mtk_vendor_attr_beacon_ctrl {
+ MTK_VENDOR_ATTR_BEACON_CTRL_UNSPEC,
+
+ MTK_VENDOR_ATTR_BEACON_CTRL_MODE,
+
+ /* keep last */
+ NUM_MTK_VENDOR_ATTRS_BEACON_CTRL,
+ MTK_VENDOR_ATTR_BEACON_CTRL_MAX =
+ NUM_MTK_VENDOR_ATTRS_BEACON_CTRL - 1
+};
+
#endif
#endif
--
2.18.0