Skip to content

Commit 295b02c

Browse files
Aloka Dixitjmberg-intel
authored andcommitted
mac80211: Add FILS discovery support
This patch adds mac80211 support to configure FILS discovery transmission. Changes include functions to store and retrieve FILS discovery template, minimum and maximum packet intervals. Signed-off-by: Aloka Dixit <[email protected]> Link: https://lore.kernel.org/r/[email protected] [remove SUPPORTS_FILS_DISCOVERY, driver can just set wiphy info] Link: https://lore.kernel.org/r/010101747a7b3cbb-6edaa89c-436d-4391-8765-61456d7f5f4e-000000@us-west-2.amazonses.com Signed-off-by: Johannes Berg <[email protected]>
1 parent 291c49d commit 295b02c

File tree

4 files changed

+110
-6
lines changed

4 files changed

+110
-6
lines changed

include/net/mac80211.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ struct ieee80211_vif_chanctx_switch {
317317
* @BSS_CHANGED_TWT: TWT status changed
318318
* @BSS_CHANGED_HE_OBSS_PD: OBSS Packet Detection status changed.
319319
* @BSS_CHANGED_HE_BSS_COLOR: BSS Color has changed
320+
* @BSS_CHANGED_FILS_DISCOVERY: FILS discovery status changed.
320321
*
321322
*/
322323
enum ieee80211_bss_change {
@@ -350,6 +351,7 @@ enum ieee80211_bss_change {
350351
BSS_CHANGED_TWT = 1<<27,
351352
BSS_CHANGED_HE_OBSS_PD = 1<<28,
352353
BSS_CHANGED_HE_BSS_COLOR = 1<<29,
354+
BSS_CHANGED_FILS_DISCOVERY = 1<<30,
353355

354356
/* when adding here, make sure to change ieee80211_reconfig */
355357
};
@@ -490,6 +492,18 @@ struct ieee80211_ftm_responder_params {
490492
size_t civicloc_len;
491493
};
492494

495+
/**
496+
* struct ieee80211_fils_discovery - FILS discovery parameters from
497+
* IEEE Std 802.11ai-2016, Annex C.3 MIB detail.
498+
*
499+
* @min_interval: Minimum packet interval in TUs (0 - 10000)
500+
* @max_interval: Maximum packet interval in TUs (0 - 10000)
501+
*/
502+
struct ieee80211_fils_discovery {
503+
u32 min_interval;
504+
u32 max_interval;
505+
};
506+
493507
/**
494508
* struct ieee80211_bss_conf - holds the BSS's changing parameters
495509
*
@@ -607,6 +621,7 @@ struct ieee80211_ftm_responder_params {
607621
* @he_oper: HE operation information of the AP we are connected to
608622
* @he_obss_pd: OBSS Packet Detection parameters.
609623
* @he_bss_color: BSS coloring settings, if BSS supports HE
624+
* @fils_discovery: FILS discovery configuration
610625
*/
611626
struct ieee80211_bss_conf {
612627
const u8 *bssid;
@@ -674,6 +689,7 @@ struct ieee80211_bss_conf {
674689
} he_oper;
675690
struct ieee80211_he_obss_pd he_obss_pd;
676691
struct cfg80211_he_bss_color he_bss_color;
692+
struct ieee80211_fils_discovery fils_discovery;
677693
};
678694

679695
/**
@@ -6629,4 +6645,15 @@ u32 ieee80211_calc_tx_airtime(struct ieee80211_hw *hw,
66296645
*/
66306646
bool ieee80211_set_hw_80211_encap(struct ieee80211_vif *vif, bool enable);
66316647

6648+
/**
6649+
* ieee80211_get_fils_discovery_tmpl - Get FILS discovery template.
6650+
* @hw: pointer obtained from ieee80211_alloc_hw().
6651+
* @vif: &struct ieee80211_vif pointer from the add_interface callback.
6652+
*
6653+
* The driver is responsible for freeing the returned skb.
6654+
*
6655+
* Return: FILS discovery template. %NULL on error.
6656+
*/
6657+
struct sk_buff *ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw *hw,
6658+
struct ieee80211_vif *vif);
66326659
#endif /* MAC80211_H */

net/mac80211/cfg.c

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,33 @@ static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
837837
return 0;
838838
}
839839

840+
static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata,
841+
struct cfg80211_fils_discovery *params)
842+
{
843+
struct fils_discovery_data *new, *old = NULL;
844+
struct ieee80211_fils_discovery *fd;
845+
846+
if (!params->tmpl || !params->tmpl_len)
847+
return -EINVAL;
848+
849+
fd = &sdata->vif.bss_conf.fils_discovery;
850+
fd->min_interval = params->min_interval;
851+
fd->max_interval = params->max_interval;
852+
853+
old = sdata_dereference(sdata->u.ap.fils_discovery, sdata);
854+
new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
855+
if (!new)
856+
return -ENOMEM;
857+
new->len = params->tmpl_len;
858+
memcpy(new->data, params->tmpl, params->tmpl_len);
859+
rcu_assign_pointer(sdata->u.ap.fils_discovery, new);
860+
861+
if (old)
862+
kfree_rcu(old, rcu_head);
863+
864+
return 0;
865+
}
866+
840867
static int ieee80211_set_ftm_responder_params(
841868
struct ieee80211_sub_if_data *sdata,
842869
const u8 *lci, size_t lci_len,
@@ -1099,21 +1126,26 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
10991126
}
11001127

11011128
err = ieee80211_assign_beacon(sdata, &params->beacon, NULL);
1102-
if (err < 0) {
1103-
ieee80211_vif_release_channel(sdata);
1104-
return err;
1105-
}
1129+
if (err < 0)
1130+
goto error;
11061131
changed |= err;
11071132

1133+
if (params->fils_discovery.max_interval) {
1134+
err = ieee80211_set_fils_discovery(sdata,
1135+
&params->fils_discovery);
1136+
if (err < 0)
1137+
goto error;
1138+
changed |= BSS_CHANGED_FILS_DISCOVERY;
1139+
}
1140+
11081141
err = drv_start_ap(sdata->local, sdata);
11091142
if (err) {
11101143
old = sdata_dereference(sdata->u.ap.beacon, sdata);
11111144

11121145
if (old)
11131146
kfree_rcu(old, rcu_head);
11141147
RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1115-
ieee80211_vif_release_channel(sdata);
1116-
return err;
1148+
goto error;
11171149
}
11181150

11191151
ieee80211_recalc_dtim(local, sdata);
@@ -1124,6 +1156,10 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
11241156
netif_carrier_on(vlan->dev);
11251157

11261158
return 0;
1159+
1160+
error:
1161+
ieee80211_vif_release_channel(sdata);
1162+
return err;
11271163
}
11281164

11291165
static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
@@ -1160,6 +1196,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
11601196
struct ieee80211_local *local = sdata->local;
11611197
struct beacon_data *old_beacon;
11621198
struct probe_resp *old_probe_resp;
1199+
struct fils_discovery_data *old_fils_discovery;
11631200
struct cfg80211_chan_def chandef;
11641201

11651202
sdata_assert_lock(sdata);
@@ -1168,6 +1205,8 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
11681205
if (!old_beacon)
11691206
return -ENOENT;
11701207
old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata);
1208+
old_fils_discovery = sdata_dereference(sdata->u.ap.fils_discovery,
1209+
sdata);
11711210

11721211
/* abort any running channel switch */
11731212
mutex_lock(&local->mtx);
@@ -1191,9 +1230,12 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
11911230
/* remove beacon and probe response */
11921231
RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
11931232
RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL);
1233+
RCU_INIT_POINTER(sdata->u.ap.fils_discovery, NULL);
11941234
kfree_rcu(old_beacon, rcu_head);
11951235
if (old_probe_resp)
11961236
kfree_rcu(old_probe_resp, rcu_head);
1237+
if (old_fils_discovery)
1238+
kfree_rcu(old_fils_discovery, rcu_head);
11971239

11981240
kfree(sdata->vif.bss_conf.ftmr_params);
11991241
sdata->vif.bss_conf.ftmr_params = NULL;

net/mac80211/ieee80211_i.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ struct probe_resp {
271271
u8 data[];
272272
};
273273

274+
struct fils_discovery_data {
275+
struct rcu_head rcu_head;
276+
int len;
277+
u8 data[];
278+
};
279+
274280
struct ps_data {
275281
/* yes, this looks ugly, but guarantees that we can later use
276282
* bitmap_empty :)
@@ -286,6 +292,7 @@ struct ps_data {
286292
struct ieee80211_if_ap {
287293
struct beacon_data __rcu *beacon;
288294
struct probe_resp __rcu *probe_resp;
295+
struct fils_discovery_data __rcu *fils_discovery;
289296

290297
/* to be used after channel switch. */
291298
struct cfg80211_beacon_data *next_beacon;

net/mac80211/tx.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4999,6 +4999,34 @@ struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw,
49994999
}
50005000
EXPORT_SYMBOL(ieee80211_proberesp_get);
50015001

5002+
struct sk_buff *ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw *hw,
5003+
struct ieee80211_vif *vif)
5004+
{
5005+
struct sk_buff *skb = NULL;
5006+
struct fils_discovery_data *tmpl = NULL;
5007+
struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
5008+
5009+
if (sdata->vif.type != NL80211_IFTYPE_AP)
5010+
return NULL;
5011+
5012+
rcu_read_lock();
5013+
tmpl = rcu_dereference(sdata->u.ap.fils_discovery);
5014+
if (!tmpl) {
5015+
rcu_read_unlock();
5016+
return NULL;
5017+
}
5018+
5019+
skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len);
5020+
if (skb) {
5021+
skb_reserve(skb, sdata->local->hw.extra_tx_headroom);
5022+
skb_put_data(skb, tmpl->data, tmpl->len);
5023+
}
5024+
5025+
rcu_read_unlock();
5026+
return skb;
5027+
}
5028+
EXPORT_SYMBOL(ieee80211_get_fils_discovery_tmpl);
5029+
50025030
struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw,
50035031
struct ieee80211_vif *vif)
50045032
{

0 commit comments

Comments
 (0)