blob: 04614d940ca2357800bddc3ea5ed3b2accb565e3 [file] [log] [blame]
developerbf24a8a2022-11-30 14:52:20 +08001From 31e449f812b7ca3f4bdea98c63f2d98bc740a112 Mon Sep 17 00:00:00 2001
developer3e4199d2022-10-19 14:18:06 +08002From: MeiChia Chiu <meichia.chiu@mediatek.com>
3Date: Wed, 19 Oct 2022 13:45:42 +0800
developerbf24a8a2022-11-30 14:52:20 +08004Subject: [PATCH 905/911] mac80211: mtk: add support for runtime set inband
developer3e4199d2022-10-19 14:18:06 +08005 discovery
6
7Signed-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
developer7d2399a2022-05-13 17:59:07 +080016diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
developera09ec1d2022-11-26 11:00:33 +080017index 8e05f55..ae2af09 100644
developer7d2399a2022-05-13 17:59:07 +080018--- 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 /**
28diff --git a/include/net/mac80211.h b/include/net/mac80211.h
developera09ec1d2022-11-26 11:00:33 +080029index 4d3cfb1..66fedf6 100644
developer7d2399a2022-05-13 17:59:07 +080030--- 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 /**
40diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
developer3e4199d2022-10-19 14:18:06 +080041index 019f065..e674aa7 100644
developer7d2399a2022-05-13 17:59:07 +080042--- a/include/uapi/linux/nl80211.h
43+++ b/include/uapi/linux/nl80211.h
developer55bf7152022-07-18 12:08:07 +080044@@ -7242,6 +7242,7 @@ enum nl80211_fils_discovery_attributes {
developer7d2399a2022-05-13 17:59:07 +080045 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,
52diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
developera09ec1d2022-11-26 11:00:33 +080053index abe7318..bf71594 100644
developer7d2399a2022-05-13 17:59:07 +080054--- a/net/mac80211/cfg.c
55+++ b/net/mac80211/cfg.c
developer3e4199d2022-10-19 14:18:06 +080056@@ -906,6 +906,7 @@ static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata,
developer7d2399a2022-05-13 17:59:07 +080057 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);
developer3e4199d2022-10-19 14:18:06 +080064@@ -1316,6 +1317,9 @@ static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
developer7d2399a2022-05-13 17:59:07 +080065 {
66 struct ieee80211_sub_if_data *sdata;
67 struct beacon_data *old;
68+ struct cfg80211_ap_settings *ap_params;
developer55bf7152022-07-18 12:08:07 +080069+ struct ieee80211_supported_band *sband;
developer7d2399a2022-05-13 17:59:07 +080070+ u32 changed;
71 int err;
72
73 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
developer3e4199d2022-10-19 14:18:06 +080074@@ -1334,7 +1338,33 @@ static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
developer7d2399a2022-05-13 17:59:07 +080075 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;
developer7d2399a2022-05-13 17:59:07 +080081+
developer55bf7152022-07-18 12:08:07 +080082+ 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);
developer7d2399a2022-05-13 17:59:07 +080098+
developer55bf7152022-07-18 12:08:07 +080099+ if (err < 0)
100+ return err;
101+ changed |= BSS_CHANGED_FILS_DISCOVERY;
102+ }
developer7d2399a2022-05-13 17:59:07 +0800103+ }
104+
105+ ieee80211_bss_info_change_notify(sdata, changed);
106 return 0;
107 }
108
109diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
developer3e4199d2022-10-19 14:18:06 +0800110index 1292634..a20aba5 100644
developer7d2399a2022-05-13 17:59:07 +0800111--- a/net/wireless/nl80211.c
112+++ b/net/wireless/nl80211.c
developer3e4199d2022-10-19 14:18:06 +0800113@@ -421,6 +421,7 @@ nl80211_fils_discovery_policy[NL80211_FILS_DISCOVERY_ATTR_MAX + 1] = {
developer7d2399a2022-05-13 17:59:07 +0800114 [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
developer3e4199d2022-10-19 14:18:06 +0800121@@ -5364,6 +5365,8 @@ static int nl80211_parse_fils_discovery(struct cfg80211_registered_device *rdev,
developer7d2399a2022-05-13 17:59:07 +0800122 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 }
developer3e4199d2022-10-19 14:18:06 +0800130@@ -5769,7 +5772,8 @@ static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info)
developer7d2399a2022-05-13 17:59:07 +0800131 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 &&
developer3e4199d2022-10-19 14:18:06 +0800140@@ -5782,16 +5786,35 @@ static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info)
developer7d2399a2022-05-13 17:59:07 +0800141 if (!wdev->beacon_interval)
142 return -EINVAL;
143
144- err = nl80211_parse_beacon(rdev, info->attrs, &params);
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, &params);
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
developer3e4199d2022-10-19 14:18:06 +0800179--
developera09ec1d2022-11-26 11:00:33 +08001802.36.1
developer3e4199d2022-10-19 14:18:06 +0800181