Lines Matching defs:rdev

32 #include "rdev-ops.h"
59 struct cfg80211_registered_device *result = NULL, *rdev;
63 list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
64 if (rdev->wiphy_idx == wiphy_idx) {
65 result = rdev;
75 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
77 return rdev->wiphy_idx;
82 struct cfg80211_registered_device *rdev;
86 rdev = cfg80211_rdev_by_wiphy_idx(wiphy_idx);
87 if (!rdev)
89 return &rdev->wiphy;
92 static int cfg80211_dev_check_name(struct cfg80211_registered_device *rdev,
105 if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) {
126 int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
132 lockdep_assert_wiphy(&rdev->wiphy);
135 if (strcmp(newname, wiphy_name(&rdev->wiphy)) == 0)
138 result = cfg80211_dev_check_name(rdev, newname);
142 result = device_rename(&rdev->wiphy.dev, newname);
146 if (!IS_ERR_OR_NULL(rdev->wiphy.debugfsdir))
147 debugfs_rename(rdev->wiphy.debugfsdir->d_parent,
148 rdev->wiphy.debugfsdir,
149 rdev->wiphy.debugfsdir->d_parent, newname);
151 nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
156 int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,
162 if (!(rdev->wiphy.flags & WIPHY_FLAG_NETNS_OK))
165 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
177 net = wiphy_net(&rdev->wiphy);
180 &rdev->wiphy.wdev_list,
194 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
197 nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE);
200 wiphy_lock(&rdev->wiphy);
201 nl80211_notify_wiphy(rdev, NL80211_CMD_DEL_WIPHY);
203 wiphy_net_set(&rdev->wiphy, net);
205 err = device_rename(&rdev->wiphy.dev, dev_name(&rdev->wiphy.dev));
208 nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
209 wiphy_unlock(&rdev->wiphy);
211 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
214 nl80211_notify_iface(rdev, wdev, NL80211_CMD_NEW_INTERFACE);
222 struct cfg80211_registered_device *rdev = data;
224 wiphy_lock(&rdev->wiphy);
225 rdev_rfkill_poll(rdev);
226 wiphy_unlock(&rdev->wiphy);
229 void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
232 lockdep_assert_held(&rdev->wiphy.mtx);
240 rdev_stop_p2p_device(rdev, wdev);
243 rdev->opencount--;
245 if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
246 if (WARN_ON(!rdev->scan_req->notified &&
247 (!rdev->int_scan_req ||
248 !rdev->int_scan_req->notified)))
249 rdev->scan_req->info.aborted = true;
250 ___cfg80211_scan_done(rdev, false);
254 void cfg80211_stop_nan(struct cfg80211_registered_device *rdev,
257 lockdep_assert_held(&rdev->wiphy.mtx);
265 rdev_stop_nan(rdev, wdev);
268 rdev->opencount--;
273 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
278 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
290 cfg80211_stop_p2p_device(rdev, wdev);
293 cfg80211_stop_nan(rdev, wdev);
306 struct cfg80211_registered_device *rdev = data;
312 cfg80211_shutdown_all_interfaces(&rdev->wiphy);
320 struct cfg80211_registered_device *rdev;
322 rdev = container_of(work, struct cfg80211_registered_device,
324 cfg80211_rfkill_set_block(rdev, true);
329 struct cfg80211_registered_device *rdev;
331 rdev = container_of(work, struct cfg80211_registered_device,
334 wiphy_lock(&rdev->wiphy);
335 cfg80211_process_rdev_events(rdev);
336 wiphy_unlock(&rdev->wiphy);
339 void cfg80211_destroy_ifaces(struct cfg80211_registered_device *rdev)
345 list_for_each_entry_safe(wdev, tmp, &rdev->wiphy.wdev_list, list) {
350 wiphy_lock(&rdev->wiphy);
351 cfg80211_leave(rdev, wdev);
352 cfg80211_remove_virtual_intf(rdev, wdev);
353 wiphy_unlock(&rdev->wiphy);
360 struct cfg80211_registered_device *rdev;
362 rdev = container_of(work, struct cfg80211_registered_device,
366 cfg80211_destroy_ifaces(rdev);
373 struct cfg80211_registered_device *rdev;
376 rdev = container_of(work, struct cfg80211_registered_device,
379 list_for_each_entry_safe(req, tmp, &rdev->sched_scan_req_list, list) {
381 cfg80211_stop_sched_scan_req(rdev, req, false);
387 struct cfg80211_registered_device *rdev;
389 rdev = container_of(work, struct cfg80211_registered_device,
394 regulatory_propagate_dfs_state(&rdev->wiphy, &rdev->radar_chandef,
403 struct cfg80211_registered_device *rdev;
405 rdev = container_of(work, struct cfg80211_registered_device,
410 regulatory_propagate_dfs_state(&rdev->wiphy, &rdev->cac_done_chandef,
419 struct cfg80211_registered_device *rdev;
422 rdev = container_of(work, struct cfg80211_registered_device, wiphy_work);
424 wiphy_lock(&rdev->wiphy);
425 if (rdev->suspended)
428 spin_lock_irq(&rdev->wiphy_work_lock);
429 wk = list_first_entry_or_null(&rdev->wiphy_work_list,
433 if (!list_empty(&rdev->wiphy_work_list))
435 spin_unlock_irq(&rdev->wiphy_work_lock);
437 wk->func(&rdev->wiphy, wk);
439 spin_unlock_irq(&rdev->wiphy_work_lock);
442 wiphy_unlock(&rdev->wiphy);
452 struct cfg80211_registered_device *rdev;
472 alloc_size = sizeof(*rdev) + sizeof_priv;
474 rdev = kzalloc(alloc_size, GFP_KERNEL);
475 if (!rdev)
478 rdev->ops = ops;
480 rdev->wiphy_idx = atomic_inc_return(&wiphy_counter);
482 if (unlikely(rdev->wiphy_idx < 0)) {
485 kfree(rdev);
490 rdev->wiphy_idx--;
497 rv = cfg80211_dev_check_name(rdev, requested_name);
504 rv = dev_set_name(&rdev->wiphy.dev, "%s", requested_name);
518 rv = dev_set_name(&rdev->wiphy.dev, PHY_NAME "%d", rdev->wiphy_idx);
520 kfree(rdev);
525 mutex_init(&rdev->wiphy.mtx);
526 INIT_LIST_HEAD(&rdev->wiphy.wdev_list);
527 INIT_LIST_HEAD(&rdev->beacon_registrations);
528 spin_lock_init(&rdev->beacon_registrations_lock);
529 spin_lock_init(&rdev->bss_lock);
530 INIT_LIST_HEAD(&rdev->bss_list);
531 INIT_LIST_HEAD(&rdev->sched_scan_req_list);
532 wiphy_work_init(&rdev->scan_done_wk, __cfg80211_scan_done);
533 INIT_DELAYED_WORK(&rdev->dfs_update_channels_wk,
536 rdev->wiphy.wext = &cfg80211_wext_handler;
539 device_initialize(&rdev->wiphy.dev);
540 rdev->wiphy.dev.class = &ieee80211_class;
541 rdev->wiphy.dev.platform_data = rdev;
542 device_enable_async_suspend(&rdev->wiphy.dev);
544 INIT_WORK(&rdev->destroy_work, cfg80211_destroy_iface_wk);
545 wiphy_work_init(&rdev->sched_scan_stop_wk, cfg80211_sched_scan_stop_wk);
546 INIT_WORK(&rdev->sched_scan_res_wk, cfg80211_sched_scan_results_wk);
547 INIT_WORK(&rdev->propagate_radar_detect_wk,
549 INIT_WORK(&rdev->propagate_cac_done_wk, cfg80211_propagate_cac_done_wk);
550 INIT_WORK(&rdev->mgmt_registrations_update_wk,
552 spin_lock_init(&rdev->mgmt_registrations_lock);
555 rdev->wiphy.flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
558 wiphy_net_set(&rdev->wiphy, &init_net);
560 rdev->rfkill_ops.set_block = cfg80211_rfkill_set_block;
561 rdev->wiphy.rfkill = rfkill_alloc(dev_name(&rdev->wiphy.dev),
562 &rdev->wiphy.dev, RFKILL_TYPE_WLAN,
563 &rdev->rfkill_ops, rdev);
565 if (!rdev->wiphy.rfkill) {
566 wiphy_free(&rdev->wiphy);
570 INIT_WORK(&rdev->wiphy_work, cfg80211_wiphy_work);
571 INIT_LIST_HEAD(&rdev->wiphy_work_list);
572 spin_lock_init(&rdev->wiphy_work_lock);
573 INIT_WORK(&rdev->rfkill_block, cfg80211_rfkill_block_work);
574 INIT_WORK(&rdev->conn_work, cfg80211_conn_work);
575 INIT_WORK(&rdev->event_work, cfg80211_event_work);
576 INIT_WORK(&rdev->background_cac_abort_wk,
578 INIT_DELAYED_WORK(&rdev->background_cac_done_wk,
581 init_waitqueue_head(&rdev->dev_wait);
588 rdev->wiphy.retry_short = 7;
589 rdev->wiphy.retry_long = 4;
590 rdev->wiphy.frag_threshold = (u32) -1;
591 rdev->wiphy.rts_threshold = (u32) -1;
592 rdev->wiphy.coverage_class = 0;
594 rdev->wiphy.max_num_csa_counters = 1;
596 rdev->wiphy.max_sched_scan_plans = 1;
597 rdev->wiphy.max_sched_scan_plan_interval = U32_MAX;
599 return &rdev->wiphy;
695 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
714 (!rdev->ops->tdls_channel_switch ||
715 !rdev->ops->tdls_cancel_channel_switch)))
719 (!rdev->ops->start_nan || !rdev->ops->stop_nan ||
720 !rdev->ops->add_nan_func || !rdev->ops->del_nan_func ||
792 !rdev->ops->set_mac_acl)))
802 if (WARN_ON(wiphy_ext_feature_isset(&rdev->wiphy,
804 (!rdev->ops->set_pmk || !rdev->ops->del_pmk)))
807 if (WARN_ON(!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_FW_ROAM) &&
808 rdev->ops->update_connect_params))
932 for (i = 0; i < rdev->wiphy.n_vendor_commands; i++) {
938 if (WARN_ON(!rdev->wiphy.vendor_commands[i].policy))
940 if (WARN_ON(!rdev->wiphy.vendor_commands[i].doit &&
941 !rdev->wiphy.vendor_commands[i].dumpit))
946 if (WARN_ON(rdev->wiphy.wowlan && rdev->wiphy.wowlan->n_patterns &&
947 (!rdev->wiphy.wowlan->pattern_min_len ||
948 rdev->wiphy.wowlan->pattern_min_len >
949 rdev->wiphy.wowlan->pattern_max_len)))
962 rdev->wiphy.features |= NL80211_FEATURE_SCAN_FLUSH;
965 wiphy_lock(&rdev->wiphy);
966 res = device_add(&rdev->wiphy.dev);
968 wiphy_unlock(&rdev->wiphy);
973 list_add_rcu(&rdev->list, &cfg80211_rdev_list);
977 rdev->wiphy.debugfsdir = debugfs_create_dir(wiphy_name(&rdev->wiphy),
980 cfg80211_debugfs_rdev_add(rdev);
981 nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
982 wiphy_unlock(&rdev->wiphy);
1028 rdev->wiphy.registered = true;
1031 res = rfkill_register(rdev->wiphy.rfkill);
1033 rfkill_destroy(rdev->wiphy.rfkill);
1034 rdev->wiphy.rfkill = NULL;
1035 wiphy_unregister(&rdev->wiphy);
1045 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1047 if (!rdev->ops->rfkill_poll)
1049 rdev->rfkill_ops.poll = cfg80211_rfkill_poll;
1054 void cfg80211_process_wiphy_works(struct cfg80211_registered_device *rdev,
1060 lockdep_assert_held(&rdev->wiphy.mtx);
1062 spin_lock_irqsave(&rdev->wiphy_work_lock, flags);
1063 while (!list_empty(&rdev->wiphy_work_list)) {
1066 wk = list_first_entry(&rdev->wiphy_work_list,
1069 spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags);
1071 wk->func(&rdev->wiphy, wk);
1073 spin_lock_irqsave(&rdev->wiphy_work_lock, flags);
1079 INIT_LIST_HEAD(&rdev->wiphy_work_list);
1081 spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags);
1086 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1088 wait_event(rdev->dev_wait, ({
1090 wiphy_lock(&rdev->wiphy);
1091 __count = rdev->opencount;
1092 wiphy_unlock(&rdev->wiphy);
1095 if (rdev->wiphy.rfkill)
1096 rfkill_unregister(rdev->wiphy.rfkill);
1099 wiphy_lock(&rdev->wiphy);
1100 nl80211_notify_wiphy(rdev, NL80211_CMD_DEL_WIPHY);
1101 rdev->wiphy.registered = false;
1103 WARN_ON(!list_empty(&rdev->wiphy.wdev_list));
1109 debugfs_remove_recursive(rdev->wiphy.debugfsdir);
1110 list_del_rcu(&rdev->list);
1120 device_del(&rdev->wiphy.dev);
1123 if (rdev->wiphy.wowlan_config && rdev->ops->set_wakeup)
1124 rdev_set_wakeup(rdev, false);
1128 cfg80211_process_wiphy_works(rdev, NULL);
1129 wiphy_unlock(&rdev->wiphy);
1133 cancel_work_sync(&rdev->wiphy_work);
1135 cancel_work_sync(&rdev->conn_work);
1136 flush_work(&rdev->event_work);
1137 cancel_delayed_work_sync(&rdev->dfs_update_channels_wk);
1138 cancel_delayed_work_sync(&rdev->background_cac_done_wk);
1139 flush_work(&rdev->destroy_work);
1140 flush_work(&rdev->propagate_radar_detect_wk);
1141 flush_work(&rdev->propagate_cac_done_wk);
1142 flush_work(&rdev->mgmt_registrations_update_wk);
1143 flush_work(&rdev->background_cac_abort_wk);
1145 cfg80211_rdev_free_wowlan(rdev);
1146 cfg80211_rdev_free_coalesce(rdev);
1150 void cfg80211_dev_free(struct cfg80211_registered_device *rdev)
1154 rfkill_destroy(rdev->wiphy.rfkill);
1155 list_for_each_entry_safe(reg, treg, &rdev->beacon_registrations, list) {
1159 list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list)
1160 cfg80211_put_bss(&rdev->wiphy, &scan->pub);
1161 mutex_destroy(&rdev->wiphy.mtx);
1170 kfree(rcu_dereference_raw(rdev->wiphy.regd));
1172 kfree(rdev);
1184 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1187 schedule_work(&rdev->rfkill_block);
1194 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1199 lockdep_assert_held(&rdev->wiphy.mtx);
1201 nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE);
1213 rdev->devlist_generation++;
1219 cfg80211_stop_p2p_device(rdev, wdev);
1222 cfg80211_stop_nan(rdev, wdev);
1271 void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
1274 lockdep_assert_held(&rdev->wiphy.mtx);
1276 rdev->num_running_ifaces += num;
1278 rdev->num_running_monitor_ifaces += num;
1281 void __cfg80211_leave(struct cfg80211_registered_device *rdev,
1287 lockdep_assert_held(&rdev->wiphy.mtx);
1296 __cfg80211_leave_ibss(rdev, dev, true);
1300 list_for_each_entry_safe(pos, tmp, &rdev->sched_scan_req_list,
1303 cfg80211_stop_sched_scan_req(rdev, pos, false);
1312 cfg80211_disconnect(rdev, dev,
1316 __cfg80211_leave_mesh(rdev, dev);
1320 __cfg80211_stop_ap(rdev, dev, -1, true);
1323 __cfg80211_leave_ocb(rdev, dev);
1341 void cfg80211_leave(struct cfg80211_registered_device *rdev,
1345 __cfg80211_leave(rdev, wdev);
1352 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1367 queue_work(cfg80211_wq, &rdev->event_work);
1404 void cfg80211_register_wdev(struct cfg80211_registered_device *rdev,
1408 lockdep_assert_held(&rdev->wiphy.mtx);
1418 wdev->identifier = ++rdev->wdev_id;
1419 list_add_rcu(&wdev->list, &rdev->wiphy.wdev_list);
1420 rdev->devlist_generation++;
1424 sysfs_create_link(&wdev->netdev->dev.kobj, &rdev->wiphy.dev.kobj,
1428 nl80211_notify_iface(rdev, wdev, NL80211_CMD_NEW_INTERFACE);
1434 struct cfg80211_registered_device *rdev;
1442 rdev = wiphy_to_rdev(wdev->wiphy);
1444 lockdep_assert_held(&rdev->wiphy.mtx);
1453 cfg80211_register_wdev(rdev, wdev);
1468 struct cfg80211_registered_device *rdev;
1474 rdev = wiphy_to_rdev(wdev->wiphy);
1489 wiphy_lock(&rdev->wiphy);
1490 cfg80211_register_wdev(rdev, wdev);
1491 wiphy_unlock(&rdev->wiphy);
1500 wiphy_lock(&rdev->wiphy);
1502 wiphy_unlock(&rdev->wiphy);
1506 wiphy_lock(&rdev->wiphy);
1507 cfg80211_leave(rdev, wdev);
1509 wiphy_unlock(&rdev->wiphy);
1515 wiphy_lock(&rdev->wiphy);
1516 cfg80211_update_iface_num(rdev, wdev->iftype, -1);
1517 if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
1518 if (WARN_ON(!rdev->scan_req->notified &&
1519 (!rdev->int_scan_req ||
1520 !rdev->int_scan_req->notified)))
1521 rdev->scan_req->info.aborted = true;
1522 ___cfg80211_scan_done(rdev, false);
1526 &rdev->sched_scan_req_list, list) {
1528 cfg80211_stop_sched_scan_req(rdev, pos, false);
1531 rdev->opencount--;
1532 wiphy_unlock(&rdev->wiphy);
1533 wake_up(&rdev->dev_wait);
1536 wiphy_lock(&rdev->wiphy);
1537 cfg80211_update_iface_num(rdev, wdev->iftype, 1);
1542 cfg80211_ibss_wext_join(rdev, wdev);
1545 cfg80211_mgd_wext_connect(rdev, wdev);
1559 __cfg80211_join_mesh(rdev, dev,
1569 rdev->opencount++;
1577 rdev->ops->set_power_mgmt &&
1578 rdev_set_power_mgmt(rdev, dev, wdev->ps,
1583 wiphy_unlock(&rdev->wiphy);
1590 if (rfkill_blocked(rdev->wiphy.rfkill))
1608 struct cfg80211_registered_device *rdev;
1611 list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
1612 if (net_eq(wiphy_net(&rdev->wiphy), net))
1613 WARN_ON(cfg80211_switch_netns(rdev, &init_net));
1624 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1627 spin_lock_irqsave(&rdev->wiphy_work_lock, flags);
1629 list_add_tail(&work->entry, &rdev->wiphy_work_list);
1630 spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags);
1632 queue_work(system_unbound_wq, &rdev->wiphy_work);
1638 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1643 spin_lock_irqsave(&rdev->wiphy_work_lock, flags);
1646 spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags);
1652 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1656 spin_lock_irqsave(&rdev->wiphy_work_lock, flags);
1658 spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags);
1661 cfg80211_process_wiphy_works(rdev, work);