Skip to content

Commit 92bc43b

Browse files
AyalaBkrjmberg-intel
authored andcommitted
mac80211: Add API to report NAN function match
Provide an API to report NAN function match. Mac80211 will lookup the corresponding cookie and report the match to cfg80211. Signed-off-by: Andrei Otcheretianski <[email protected]> Signed-off-by: Emmanuel Grumbach <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 167e33f commit 92bc43b

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

include/net/mac80211.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5777,4 +5777,20 @@ void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
57775777
u8 inst_id,
57785778
enum nl80211_nan_func_term_reason reason,
57795779
gfp_t gfp);
5780+
5781+
/**
5782+
* ieee80211_nan_func_match - notify about NAN function match event.
5783+
*
5784+
* This function is used to notify mac80211 about NAN function match. The
5785+
* cookie inside the match struct will be assigned by mac80211.
5786+
* Note that this function can't be called from hard irq.
5787+
*
5788+
* @vif: &struct ieee80211_vif pointer from the add_interface callback.
5789+
* @match: match event information
5790+
* @gfp: allocation flags
5791+
*/
5792+
void ieee80211_nan_func_match(struct ieee80211_vif *vif,
5793+
struct cfg80211_nan_match_params *match,
5794+
gfp_t gfp);
5795+
57805796
#endif /* MAC80211_H */

net/mac80211/cfg.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3555,6 +3555,31 @@ void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
35553555
}
35563556
EXPORT_SYMBOL(ieee80211_nan_func_terminated);
35573557

3558+
void ieee80211_nan_func_match(struct ieee80211_vif *vif,
3559+
struct cfg80211_nan_match_params *match,
3560+
gfp_t gfp)
3561+
{
3562+
struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3563+
struct cfg80211_nan_func *func;
3564+
3565+
if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
3566+
return;
3567+
3568+
spin_lock_bh(&sdata->u.nan.func_lock);
3569+
3570+
func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id);
3571+
if (WARN_ON(!func)) {
3572+
spin_unlock_bh(&sdata->u.nan.func_lock);
3573+
return;
3574+
}
3575+
match->cookie = func->cookie;
3576+
3577+
spin_unlock_bh(&sdata->u.nan.func_lock);
3578+
3579+
cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);
3580+
}
3581+
EXPORT_SYMBOL(ieee80211_nan_func_match);
3582+
35583583
const struct cfg80211_ops mac80211_config_ops = {
35593584
.add_virtual_intf = ieee80211_add_iface,
35603585
.del_virtual_intf = ieee80211_del_iface,

0 commit comments

Comments
 (0)