aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/cfg.c
diff options
context:
space:
mode:
authorAyala Beker <ayala.beker@intel.com>2016-09-20 10:31:20 -0400
committerJohannes Berg <johannes.berg@intel.com>2016-09-30 07:21:52 -0400
commit167e33f4f68cc8e4e3bdaf6d43641176c51f2d79 (patch)
treece328c08fec4d0a16e54839987ed3530a9f6ccad /net/mac80211/cfg.c
parent5953ff6d6a3e92dd4f8d9d8e8a9359d7e180ae93 (diff)
mac80211: Implement add_nan_func and rm_nan_func
Implement add/rm_nan_func functions and handle NAN function termination notifications. Handle instance_id allocation for NAN functions and implement the reconfig flow. Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/cfg.c')
-rw-r--r--net/mac80211/cfg.c114
1 files changed, 114 insertions, 0 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 38fdb539cab3..72ddb4379319 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -174,6 +174,8 @@ static int ieee80211_start_nan(struct wiphy *wiphy,
174 if (ret) 174 if (ret)
175 ieee80211_sdata_stop(sdata); 175 ieee80211_sdata_stop(sdata);
176 176
177 sdata->u.nan.conf = *conf;
178
177 return ret; 179 return ret;
178} 180}
179 181
@@ -216,6 +218,84 @@ static int ieee80211_nan_change_conf(struct wiphy *wiphy,
216 return ret; 218 return ret;
217} 219}
218 220
221static int ieee80211_add_nan_func(struct wiphy *wiphy,
222 struct wireless_dev *wdev,
223 struct cfg80211_nan_func *nan_func)
224{
225 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
226 int ret;
227
228 if (sdata->vif.type != NL80211_IFTYPE_NAN)
229 return -EOPNOTSUPP;
230
231 if (!ieee80211_sdata_running(sdata))
232 return -ENETDOWN;
233
234 spin_lock_bh(&sdata->u.nan.func_lock);
235
236 ret = idr_alloc(&sdata->u.nan.function_inst_ids,
237 nan_func, 1, sdata->local->hw.max_nan_de_entries + 1,
238 GFP_ATOMIC);
239 spin_unlock_bh(&sdata->u.nan.func_lock);
240
241 if (ret < 0)
242 return ret;
243
244 nan_func->instance_id = ret;
245
246 WARN_ON(nan_func->instance_id == 0);
247
248 ret = drv_add_nan_func(sdata->local, sdata, nan_func);
249 if (ret) {
250 spin_lock_bh(&sdata->u.nan.func_lock);
251 idr_remove(&sdata->u.nan.function_inst_ids,
252 nan_func->instance_id);
253 spin_unlock_bh(&sdata->u.nan.func_lock);
254 }
255
256 return ret;
257}
258
259static struct cfg80211_nan_func *
260ieee80211_find_nan_func_by_cookie(struct ieee80211_sub_if_data *sdata,
261 u64 cookie)
262{
263 struct cfg80211_nan_func *func;
264 int id;
265
266 lockdep_assert_held(&sdata->u.nan.func_lock);
267
268 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) {
269 if (func->cookie == cookie)
270 return func;
271 }
272
273 return NULL;
274}
275
276static void ieee80211_del_nan_func(struct wiphy *wiphy,
277 struct wireless_dev *wdev, u64 cookie)
278{
279 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
280 struct cfg80211_nan_func *func;
281 u8 instance_id = 0;
282
283 if (sdata->vif.type != NL80211_IFTYPE_NAN ||
284 !ieee80211_sdata_running(sdata))
285 return;
286
287 spin_lock_bh(&sdata->u.nan.func_lock);
288
289 func = ieee80211_find_nan_func_by_cookie(sdata, cookie);
290 if (func)
291 instance_id = func->instance_id;
292
293 spin_unlock_bh(&sdata->u.nan.func_lock);
294
295 if (instance_id)
296 drv_del_nan_func(sdata->local, sdata, instance_id);
297}
298
219static int ieee80211_set_noack_map(struct wiphy *wiphy, 299static int ieee80211_set_noack_map(struct wiphy *wiphy,
220 struct net_device *dev, 300 struct net_device *dev,
221 u16 noack_map) 301 u16 noack_map)
@@ -3443,6 +3523,38 @@ static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
3443 return -ENOENT; 3523 return -ENOENT;
3444} 3524}
3445 3525
3526void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
3527 u8 inst_id,
3528 enum nl80211_nan_func_term_reason reason,
3529 gfp_t gfp)
3530{
3531 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3532 struct cfg80211_nan_func *func;
3533 u64 cookie;
3534
3535 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
3536 return;
3537
3538 spin_lock_bh(&sdata->u.nan.func_lock);
3539
3540 func = idr_find(&sdata->u.nan.function_inst_ids, inst_id);
3541 if (WARN_ON(!func)) {
3542 spin_unlock_bh(&sdata->u.nan.func_lock);
3543 return;
3544 }
3545
3546 cookie = func->cookie;
3547 idr_remove(&sdata->u.nan.function_inst_ids, inst_id);
3548
3549 spin_unlock_bh(&sdata->u.nan.func_lock);
3550
3551 cfg80211_free_nan_func(func);
3552
3553 cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id,
3554 reason, cookie, gfp);
3555}
3556EXPORT_SYMBOL(ieee80211_nan_func_terminated);
3557
3446const struct cfg80211_ops mac80211_config_ops = { 3558const struct cfg80211_ops mac80211_config_ops = {
3447 .add_virtual_intf = ieee80211_add_iface, 3559 .add_virtual_intf = ieee80211_add_iface,
3448 .del_virtual_intf = ieee80211_del_iface, 3560 .del_virtual_intf = ieee80211_del_iface,
@@ -3531,4 +3643,6 @@ const struct cfg80211_ops mac80211_config_ops = {
3531 .start_nan = ieee80211_start_nan, 3643 .start_nan = ieee80211_start_nan,
3532 .stop_nan = ieee80211_stop_nan, 3644 .stop_nan = ieee80211_stop_nan,
3533 .nan_change_conf = ieee80211_nan_change_conf, 3645 .nan_change_conf = ieee80211_nan_change_conf,
3646 .add_nan_func = ieee80211_add_nan_func,
3647 .del_nan_func = ieee80211_del_nan_func,
3534}; 3648};