developer | 14ab311 | 2024-03-21 07:21:44 +0800 | [diff] [blame^] | 1 | From ba07e0c01317f0d39fb56aceef557c04c0f770c2 Mon Sep 17 00:00:00 2001 |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 2 | From: MeiChia Chiu <meichia.chiu@mediatek.com> |
| 3 | Date: Wed, 22 Nov 2023 22:42:09 +0800 |
developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1040/1044] mtk: wifi: mt76: mt7996: add no_beacon vendor |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 5 | command for cert |
| 6 | |
| 7 | Add the vendor command to disable/enable beacon |
| 8 | |
| 9 | [Usage] |
| 10 | hostapd_cli -i <interface> no_beacon <value> |
| 11 | <value> |
| 12 | 0: enable beacon |
| 13 | 1: disable beacon |
| 14 | |
| 15 | Signed-off-by: MeiChia Chiu <meichia.chiu@mediatek.com> |
| 16 | --- |
| 17 | mt7996/mcu.c | 11 +++++++++++ |
| 18 | mt7996/mt7996.h | 1 + |
| 19 | mt7996/vendor.c | 41 +++++++++++++++++++++++++++++++++++++++++ |
| 20 | mt7996/vendor.h | 12 ++++++++++++ |
| 21 | 4 files changed, 65 insertions(+) |
| 22 | |
| 23 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | c992b60 | 2024-02-28 08:42:27 +0800 | [diff] [blame] | 24 | index a39b8bab..c97a3204 100644 |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 25 | --- a/mt7996/mcu.c |
| 26 | +++ b/mt7996/mcu.c |
developer | c992b60 | 2024-02-28 08:42:27 +0800 | [diff] [blame] | 27 | @@ -5058,4 +5058,15 @@ void mt7996_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif) |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 28 | break; |
| 29 | } |
| 30 | } |
| 31 | + |
| 32 | +void mt7996_set_beacon_vif(void *data, u8 *mac, struct ieee80211_vif *vif) |
| 33 | +{ |
| 34 | + struct mt7996_vif *mvif = (struct mt7996_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 | + mt7996_mcu_add_beacon(hw, vif, val); |
| 41 | +} |
| 42 | #endif |
| 43 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 44 | index 881328be..bb2cee92 100644 |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 45 | --- a/mt7996/mt7996.h |
| 46 | +++ b/mt7996/mt7996.h |
developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 47 | @@ -829,6 +829,7 @@ void mt7996_set_wireless_amsdu(struct ieee80211_hw *hw, u8 en); |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 48 | void mt7996_mcu_set_mimo(struct mt7996_phy *phy); |
| 49 | int mt7996_set_muru_cfg(struct mt7996_phy *phy, u8 action, u8 val); |
| 50 | int mt7996_mcu_set_muru_cfg(struct mt7996_phy *phy, void *data); |
| 51 | +void mt7996_set_beacon_vif(void *data, u8 *mac, struct ieee80211_vif *vif); |
| 52 | #endif |
| 53 | |
| 54 | int mt7996_mcu_edcca_enable(struct mt7996_phy *phy, bool enable); |
| 55 | diff --git a/mt7996/vendor.c b/mt7996/vendor.c |
| 56 | index 9732ed28..c87cc5c1 100644 |
| 57 | --- a/mt7996/vendor.c |
| 58 | +++ b/mt7996/vendor.c |
| 59 | @@ -112,6 +112,11 @@ pp_ctrl_policy[NUM_MTK_VENDOR_ATTRS_PP_CTRL] = { |
| 60 | [MTK_VENDOR_ATTR_PP_MODE] = { .type = NLA_U8 }, |
| 61 | }; |
| 62 | |
| 63 | +static const struct nla_policy |
| 64 | +beacon_ctrl_policy[NUM_MTK_VENDOR_ATTRS_BEACON_CTRL] = { |
| 65 | + [MTK_VENDOR_ATTR_BEACON_CTRL_MODE] = { .type = NLA_U8 }, |
| 66 | +}; |
| 67 | + |
| 68 | struct mt7996_amnt_data { |
| 69 | u8 idx; |
| 70 | u8 addr[ETH_ALEN]; |
| 71 | @@ -904,6 +909,31 @@ static int mt7996_vendor_pp_ctrl(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 72 | return err; |
| 73 | } |
| 74 | |
| 75 | +static int mt7996_vendor_beacon_ctrl(struct wiphy *wiphy, |
| 76 | + struct wireless_dev *wdev, |
| 77 | + const void *data, |
| 78 | + int data_len) |
| 79 | +{ |
| 80 | + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
| 81 | + struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_BEACON_CTRL]; |
| 82 | + int err; |
| 83 | + u8 val8; |
| 84 | + |
| 85 | + err = nla_parse(tb, MTK_VENDOR_ATTR_BEACON_CTRL_MAX, data, data_len, |
| 86 | + beacon_ctrl_policy, NULL); |
| 87 | + if (err) |
| 88 | + return err; |
| 89 | + |
| 90 | + if (tb[MTK_VENDOR_ATTR_BEACON_CTRL_MODE]) { |
| 91 | + val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_BEACON_CTRL_MODE]); |
| 92 | + ieee80211_iterate_active_interfaces_atomic(hw, IEEE80211_IFACE_ITER_RESUME_ALL, |
| 93 | + mt7996_set_beacon_vif, &val8); |
| 94 | + } |
| 95 | + |
| 96 | + return 0; |
| 97 | +} |
| 98 | + |
| 99 | + |
| 100 | static const struct wiphy_vendor_command mt7996_vendor_commands[] = { |
| 101 | { |
| 102 | .info = { |
| 103 | @@ -1020,6 +1050,17 @@ static const struct wiphy_vendor_command mt7996_vendor_commands[] = { |
| 104 | .policy = pp_ctrl_policy, |
| 105 | .maxattr = MTK_VENDOR_ATTR_PP_CTRL_MAX, |
| 106 | }, |
| 107 | + { |
| 108 | + .info = { |
| 109 | + .vendor_id = MTK_NL80211_VENDOR_ID, |
| 110 | + .subcmd = MTK_NL80211_VENDOR_SUBCMD_BEACON_CTRL, |
| 111 | + }, |
| 112 | + .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 113 | + WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 114 | + .doit = mt7996_vendor_beacon_ctrl, |
| 115 | + .policy = beacon_ctrl_policy, |
| 116 | + .maxattr = MTK_VENDOR_ATTR_BEACON_CTRL_MAX, |
| 117 | + }, |
| 118 | }; |
| 119 | |
| 120 | void mt7996_vendor_register(struct mt7996_phy *phy) |
| 121 | diff --git a/mt7996/vendor.h b/mt7996/vendor.h |
| 122 | index 98128965..e7d88828 100644 |
| 123 | --- a/mt7996/vendor.h |
| 124 | +++ b/mt7996/vendor.h |
| 125 | @@ -16,6 +16,7 @@ enum mtk_nl80211_vendor_subcmds { |
| 126 | MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL = 0xca, |
| 127 | MTK_NL80211_VENDOR_SUBCMD_BACKGROUND_RADAR_CTRL = 0xcb, |
| 128 | MTK_NL80211_VENDOR_SUBCMD_PP_CTRL = 0xcc, |
| 129 | + MTK_NL80211_VENDOR_SUBCMD_BEACON_CTRL = 0xcd, |
| 130 | }; |
| 131 | |
| 132 | enum mtk_vendor_attr_edcca_ctrl { |
| 133 | @@ -226,6 +227,17 @@ enum mtk_vendor_attr_pp_ctrl { |
| 134 | NUM_MTK_VENDOR_ATTRS_PP_CTRL - 1 |
| 135 | }; |
| 136 | |
| 137 | +enum mtk_vendor_attr_beacon_ctrl { |
| 138 | + MTK_VENDOR_ATTR_BEACON_CTRL_UNSPEC, |
| 139 | + |
| 140 | + MTK_VENDOR_ATTR_BEACON_CTRL_MODE, |
| 141 | + |
| 142 | + /* keep last */ |
| 143 | + NUM_MTK_VENDOR_ATTRS_BEACON_CTRL, |
| 144 | + MTK_VENDOR_ATTR_BEACON_CTRL_MAX = |
| 145 | + NUM_MTK_VENDOR_ATTRS_BEACON_CTRL - 1 |
| 146 | +}; |
| 147 | + |
| 148 | #endif |
| 149 | |
| 150 | #endif |
| 151 | -- |
| 152 | 2.18.0 |
| 153 | |