developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 1 | From 5deaaa36bfeb7a68bbcce8770011ef49be6a6991 Mon Sep 17 00:00:00 2001 |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 2 | From: MeiChia Chiu <meichia.chiu@mediatek.com> |
| 3 | Date: Wed, 19 Oct 2022 13:45:42 +0800 |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 4 | Subject: [PATCH 05/14] mac80211: mtk: add support for runtime set inband |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 5 | discovery |
| 6 | |
| 7 | Signed-off-by: MeiChia Chiu <meichia.chiu@mediatek.com> |
| 8 | --- |
| 9 | include/net/cfg80211.h | 1 + |
| 10 | include/net/mac80211.h | 1 + |
| 11 | include/uapi/linux/nl80211.h | 1 + |
| 12 | net/mac80211/cfg.c | 33 ++++++++++++++++++++++++++++++++- |
| 13 | net/wireless/nl80211.c | 31 +++++++++++++++++++++++++++---- |
| 14 | 5 files changed, 62 insertions(+), 5 deletions(-) |
| 15 | |
| 16 | diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 17 | index 8d72357..450de58 100644 |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 18 | --- a/include/net/cfg80211.h |
| 19 | +++ b/include/net/cfg80211.h |
| 20 | @@ -1268,6 +1268,7 @@ struct cfg80211_fils_discovery { |
| 21 | u32 max_interval; |
| 22 | size_t tmpl_len; |
| 23 | const u8 *tmpl; |
| 24 | + u8 disable; |
| 25 | }; |
| 26 | |
| 27 | /** |
| 28 | diff --git a/include/net/mac80211.h b/include/net/mac80211.h |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 29 | index 24d2a66..09fad2b 100644 |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 30 | --- a/include/net/mac80211.h |
| 31 | +++ b/include/net/mac80211.h |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 32 | @@ -526,6 +526,7 @@ struct ieee80211_ftm_responder_params { |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 33 | struct ieee80211_fils_discovery { |
| 34 | u32 min_interval; |
| 35 | u32 max_interval; |
| 36 | + u8 disable; |
| 37 | }; |
| 38 | |
| 39 | /** |
| 40 | diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 41 | index 173aef8..bd26a06 100644 |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 42 | --- a/include/uapi/linux/nl80211.h |
| 43 | +++ b/include/uapi/linux/nl80211.h |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 44 | @@ -7513,6 +7513,7 @@ enum nl80211_fils_discovery_attributes { |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 45 | NL80211_FILS_DISCOVERY_ATTR_INT_MIN, |
| 46 | NL80211_FILS_DISCOVERY_ATTR_INT_MAX, |
| 47 | NL80211_FILS_DISCOVERY_ATTR_TMPL, |
| 48 | + NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE, |
| 49 | |
| 50 | /* keep last */ |
| 51 | __NL80211_FILS_DISCOVERY_ATTR_LAST, |
| 52 | diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 53 | index 49760bf..97f7905 100644 |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 54 | --- a/net/mac80211/cfg.c |
| 55 | +++ b/net/mac80211/cfg.c |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 56 | @@ -984,6 +984,7 @@ static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata, |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 57 | fd = &link_conf->fils_discovery; |
| 58 | fd->min_interval = params->min_interval; |
| 59 | fd->max_interval = params->max_interval; |
| 60 | + fd->disable = params->disable; |
| 61 | |
| 62 | old = sdata_dereference(link->u.ap.fils_discovery, sdata); |
| 63 | new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL); |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 64 | @@ -1466,6 +1467,9 @@ static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 65 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 66 | struct ieee80211_link_data *link; |
| 67 | struct beacon_data *old; |
| 68 | + struct cfg80211_ap_settings *ap_params; |
| 69 | + struct ieee80211_supported_band *sband; |
| 70 | + u32 changed; |
| 71 | int err; |
| 72 | struct ieee80211_bss_conf *link_conf; |
| 73 | |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 74 | @@ -1497,7 +1501,34 @@ static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 75 | err |= BSS_CHANGED_HE_BSS_COLOR; |
| 76 | } |
| 77 | |
| 78 | - ieee80211_link_info_change_notify(sdata, link, err); |
| 79 | + changed = err; |
| 80 | + |
| 81 | + sband = ieee80211_get_sband(sdata); |
| 82 | + if (!sband) |
| 83 | + return -EINVAL; |
| 84 | + |
| 85 | + if (sband->band == NL80211_BAND_6GHZ) { |
| 86 | + ap_params = container_of(params, struct cfg80211_ap_settings, beacon); |
| 87 | + |
| 88 | + if(ap_params->unsol_bcast_probe_resp.interval) { |
| 89 | + err = ieee80211_set_unsol_bcast_probe_resp(sdata, |
| 90 | + &ap_params->unsol_bcast_probe_resp, |
| 91 | + link, link_conf); |
| 92 | + if (err < 0) |
| 93 | + return err; |
| 94 | + changed |= BSS_CHANGED_UNSOL_BCAST_PROBE_RESP; |
| 95 | + } else { |
| 96 | + err = ieee80211_set_fils_discovery(sdata, |
| 97 | + &ap_params->fils_discovery, |
| 98 | + link, link_conf); |
| 99 | + |
| 100 | + if (err < 0) |
| 101 | + return err; |
| 102 | + changed |= BSS_CHANGED_FILS_DISCOVERY; |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + ieee80211_bss_info_change_notify(sdata, changed); |
| 107 | return 0; |
| 108 | } |
| 109 | |
| 110 | diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 111 | index c5620f3..95676d9 100644 |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 112 | --- a/net/wireless/nl80211.c |
| 113 | +++ b/net/wireless/nl80211.c |
| 114 | @@ -423,6 +423,7 @@ nl80211_fils_discovery_policy[NL80211_FILS_DISCOVERY_ATTR_MAX + 1] = { |
| 115 | [NL80211_FILS_DISCOVERY_ATTR_INT_MAX] = NLA_POLICY_MAX(NLA_U32, 10000), |
| 116 | [NL80211_FILS_DISCOVERY_ATTR_TMPL] = |
| 117 | NLA_POLICY_BINARY_RANGE(NL80211_FILS_DISCOVERY_TMPL_MIN_LEN, IEEE80211_MAX_DATA_LEN), |
| 118 | + [NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE] = NLA_POLICY_MAX(NLA_U32, 20), |
| 119 | }; |
| 120 | |
| 121 | static const struct nla_policy |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 122 | @@ -5605,6 +5606,8 @@ static int nl80211_parse_fils_discovery(struct cfg80211_registered_device *rdev, |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 123 | fd->tmpl = nla_data(tb[NL80211_FILS_DISCOVERY_ATTR_TMPL]); |
| 124 | fd->min_interval = nla_get_u32(tb[NL80211_FILS_DISCOVERY_ATTR_INT_MIN]); |
| 125 | fd->max_interval = nla_get_u32(tb[NL80211_FILS_DISCOVERY_ATTR_INT_MAX]); |
| 126 | + fd->disable = !(fd->max_interval || |
| 127 | + nla_get_u32(tb[NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE])); |
| 128 | |
| 129 | return 0; |
| 130 | } |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 131 | @@ -6092,7 +6095,8 @@ static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info) |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 132 | unsigned int link_id = nl80211_link_id(info->attrs); |
| 133 | struct net_device *dev = info->user_ptr[1]; |
| 134 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 135 | - struct cfg80211_beacon_data params; |
| 136 | + struct cfg80211_ap_settings ap_params; |
| 137 | + struct cfg80211_beacon_data *params; |
| 138 | int err; |
| 139 | |
| 140 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 141 | @@ -6105,16 +6109,35 @@ static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info) |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 142 | if (!wdev->links[link_id].ap.beacon_interval) |
| 143 | return -EINVAL; |
| 144 | |
| 145 | - err = nl80211_parse_beacon(rdev, info->attrs, ¶ms); |
| 146 | + memset(&ap_params, 0, sizeof(ap_params)); |
| 147 | + params = &ap_params.beacon; |
| 148 | + |
| 149 | + err = nl80211_parse_beacon(rdev, info->attrs, params); |
| 150 | if (err) |
| 151 | goto out; |
| 152 | |
| 153 | + if (info->attrs[NL80211_ATTR_FILS_DISCOVERY]) { |
| 154 | + err = nl80211_parse_fils_discovery(rdev, |
| 155 | + info->attrs[NL80211_ATTR_FILS_DISCOVERY], |
| 156 | + &ap_params); |
| 157 | + if (err) |
| 158 | + goto out; |
| 159 | + } |
| 160 | + |
| 161 | + if (info->attrs[NL80211_ATTR_UNSOL_BCAST_PROBE_RESP]) { |
| 162 | + err = nl80211_parse_unsol_bcast_probe_resp(rdev, |
| 163 | + info->attrs[NL80211_ATTR_UNSOL_BCAST_PROBE_RESP], |
| 164 | + &ap_params); |
| 165 | + if (err) |
| 166 | + goto out; |
| 167 | + } |
| 168 | + |
| 169 | wdev_lock(wdev); |
| 170 | - err = rdev_change_beacon(rdev, dev, ¶ms); |
| 171 | + err = rdev_change_beacon(rdev, dev, params); |
| 172 | wdev_unlock(wdev); |
| 173 | |
| 174 | out: |
| 175 | - kfree(params.mbssid_ies); |
| 176 | + kfree(params->mbssid_ies); |
| 177 | return err; |
| 178 | } |
| 179 | |
| 180 | -- |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 181 | 2.39.2 |
developer | 4a339e8 | 2022-12-12 19:00:30 +0800 | [diff] [blame] | 182 | |