developer | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 1 | From b4551b622d6a57b6613200bee2f83729e64ba64e Mon Sep 17 00:00:00 2001 |
| 2 | From: MeiChia Chiu <meichia.chiu@mediatek.com> |
| 3 | Date: Wed, 19 Oct 2022 13:45:42 +0800 |
| 4 | Subject: [PATCH 906/914] mac80211: add support for runtime set inband |
| 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 | 32 +++++++++++++++++++++++++++++++- |
| 13 | net/wireless/nl80211.c | 31 +++++++++++++++++++++++++++---- |
| 14 | 5 files changed, 61 insertions(+), 5 deletions(-) |
| 15 | |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 16 | diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h |
developer | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 17 | index ab83553..f594914 100644 |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 18 | --- a/include/net/cfg80211.h |
| 19 | +++ b/include/net/cfg80211.h |
| 20 | @@ -1158,6 +1158,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 | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 29 | index edcad3b..bde3495 100644 |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 30 | --- a/include/net/mac80211.h |
| 31 | +++ b/include/net/mac80211.h |
| 32 | @@ -505,6 +505,7 @@ struct ieee80211_ftm_responder_params { |
| 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 | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 41 | index 019f065..e674aa7 100644 |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 42 | --- a/include/uapi/linux/nl80211.h |
| 43 | +++ b/include/uapi/linux/nl80211.h |
developer | 55bf715 | 2022-07-18 12:08:07 +0800 | [diff] [blame] | 44 | @@ -7242,6 +7242,7 @@ enum nl80211_fils_discovery_attributes { |
developer | 7d2399a | 2022-05-13 17:59:07 +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 | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 53 | index b582730..1328827 100644 |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 54 | --- a/net/mac80211/cfg.c |
| 55 | +++ b/net/mac80211/cfg.c |
developer | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 56 | @@ -906,6 +906,7 @@ static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata, |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 57 | fd = &sdata->vif.bss_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(sdata->u.ap.fils_discovery, sdata); |
| 63 | new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL); |
developer | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 64 | @@ -1316,6 +1317,9 @@ static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 65 | { |
| 66 | struct ieee80211_sub_if_data *sdata; |
| 67 | struct beacon_data *old; |
| 68 | + struct cfg80211_ap_settings *ap_params; |
developer | 55bf715 | 2022-07-18 12:08:07 +0800 | [diff] [blame] | 69 | + struct ieee80211_supported_band *sband; |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 70 | + u32 changed; |
| 71 | int err; |
| 72 | |
| 73 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
developer | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 74 | @@ -1334,7 +1338,33 @@ static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 75 | err = ieee80211_assign_beacon(sdata, params, NULL, NULL); |
| 76 | if (err < 0) |
| 77 | return err; |
| 78 | - ieee80211_bss_info_change_notify(sdata, err); |
| 79 | + |
| 80 | + changed = err; |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 81 | + |
developer | 55bf715 | 2022-07-18 12:08:07 +0800 | [diff] [blame] | 82 | + sband = ieee80211_get_sband(sdata); |
| 83 | + if (!sband) |
| 84 | + return -EINVAL; |
| 85 | + |
| 86 | + if (sband->band == NL80211_BAND_6GHZ) { |
| 87 | + ap_params = container_of(params, struct cfg80211_ap_settings, beacon); |
| 88 | + |
| 89 | + if(ap_params->unsol_bcast_probe_resp.interval) { |
| 90 | + err = ieee80211_set_unsol_bcast_probe_resp(sdata, |
| 91 | + &ap_params->unsol_bcast_probe_resp); |
| 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); |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 98 | + |
developer | 55bf715 | 2022-07-18 12:08:07 +0800 | [diff] [blame] | 99 | + if (err < 0) |
| 100 | + return err; |
| 101 | + changed |= BSS_CHANGED_FILS_DISCOVERY; |
| 102 | + } |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 103 | + } |
| 104 | + |
| 105 | + ieee80211_bss_info_change_notify(sdata, changed); |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c |
developer | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 110 | index 1292634..a20aba5 100644 |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 111 | --- a/net/wireless/nl80211.c |
| 112 | +++ b/net/wireless/nl80211.c |
developer | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 113 | @@ -421,6 +421,7 @@ nl80211_fils_discovery_policy[NL80211_FILS_DISCOVERY_ATTR_MAX + 1] = { |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 114 | [NL80211_FILS_DISCOVERY_ATTR_TMPL] = { .type = NLA_BINARY, |
| 115 | .len = IEEE80211_MAX_DATA_LEN }, |
| 116 | #endif |
| 117 | + [NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE] = NLA_POLICY_MAX(NLA_U32, 20), |
| 118 | }; |
| 119 | |
| 120 | static const struct nla_policy |
developer | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 121 | @@ -5364,6 +5365,8 @@ static int nl80211_parse_fils_discovery(struct cfg80211_registered_device *rdev, |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 122 | fd->tmpl = nla_data(tb[NL80211_FILS_DISCOVERY_ATTR_TMPL]); |
| 123 | fd->min_interval = nla_get_u32(tb[NL80211_FILS_DISCOVERY_ATTR_INT_MIN]); |
| 124 | fd->max_interval = nla_get_u32(tb[NL80211_FILS_DISCOVERY_ATTR_INT_MAX]); |
| 125 | + fd->disable = !(fd->max_interval || |
| 126 | + nla_get_u32(tb[NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE])); |
| 127 | |
| 128 | return 0; |
| 129 | } |
developer | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 130 | @@ -5769,7 +5772,8 @@ static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info) |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 131 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
| 132 | struct net_device *dev = info->user_ptr[1]; |
| 133 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 134 | - struct cfg80211_beacon_data params; |
| 135 | + struct cfg80211_ap_settings ap_params; |
| 136 | + struct cfg80211_beacon_data *params; |
| 137 | int err; |
| 138 | |
| 139 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && |
developer | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 140 | @@ -5782,16 +5786,35 @@ static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info) |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 141 | if (!wdev->beacon_interval) |
| 142 | return -EINVAL; |
| 143 | |
| 144 | - err = nl80211_parse_beacon(rdev, info->attrs, ¶ms); |
| 145 | + memset(&ap_params, 0, sizeof(ap_params)); |
| 146 | + params = &ap_params.beacon; |
| 147 | + |
| 148 | + err = nl80211_parse_beacon(rdev, info->attrs, params); |
| 149 | if (err) |
| 150 | goto out; |
| 151 | |
| 152 | + if (info->attrs[NL80211_ATTR_FILS_DISCOVERY]) { |
| 153 | + err = nl80211_parse_fils_discovery(rdev, |
| 154 | + info->attrs[NL80211_ATTR_FILS_DISCOVERY], |
| 155 | + &ap_params); |
| 156 | + if (err) |
| 157 | + goto out; |
| 158 | + } |
| 159 | + |
| 160 | + if (info->attrs[NL80211_ATTR_UNSOL_BCAST_PROBE_RESP]) { |
| 161 | + err = nl80211_parse_unsol_bcast_probe_resp(rdev, |
| 162 | + info->attrs[NL80211_ATTR_UNSOL_BCAST_PROBE_RESP], |
| 163 | + &ap_params); |
| 164 | + if (err) |
| 165 | + goto out; |
| 166 | + } |
| 167 | + |
| 168 | wdev_lock(wdev); |
| 169 | - err = rdev_change_beacon(rdev, dev, ¶ms); |
| 170 | + err = rdev_change_beacon(rdev, dev, params); |
| 171 | wdev_unlock(wdev); |
| 172 | |
| 173 | out: |
| 174 | - kfree(params.mbssid_ies); |
| 175 | + kfree(params->mbssid_ies); |
| 176 | return err; |
| 177 | } |
| 178 | |
developer | 3e4199d | 2022-10-19 14:18:06 +0800 | [diff] [blame] | 179 | -- |
| 180 | 2.18.0 |
| 181 | |