Lines Matching +full:local +full:- +full:cap +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright 2002-2005, Instant802 Networks, Inc.
6 * Copyright 2005-2006, Devicescape Software, Inc.
9 * Copyright 2013-2014 Intel Mobile Communications GmbH
11 * Copyright (C) 2018-2020 Intel Corporation
25 #include "driver-ops.h"
33 * three-fold:
39 * can traverse the list in RCU-safe blocks.
53 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in __ieee80211_recalc_txpower()
59 power = ieee80211_chandef_max_power(&chanctx_conf->def); in __ieee80211_recalc_txpower()
62 if (sdata->user_power_level != IEEE80211_UNSET_POWER_LEVEL) in __ieee80211_recalc_txpower()
63 power = min(power, sdata->user_power_level); in __ieee80211_recalc_txpower()
65 if (sdata->ap_power_level != IEEE80211_UNSET_POWER_LEVEL) in __ieee80211_recalc_txpower()
66 power = min(power, sdata->ap_power_level); in __ieee80211_recalc_txpower()
68 if (power != sdata->vif.bss_conf.txpower) { in __ieee80211_recalc_txpower()
69 sdata->vif.bss_conf.txpower = power; in __ieee80211_recalc_txpower()
70 ieee80211_hw_config(sdata->local, 0); in __ieee80211_recalc_txpower()
85 static u32 __ieee80211_idle_off(struct ieee80211_local *local) in __ieee80211_idle_off() argument
87 if (!(local->hw.conf.flags & IEEE80211_CONF_IDLE)) in __ieee80211_idle_off()
90 local->hw.conf.flags &= ~IEEE80211_CONF_IDLE; in __ieee80211_idle_off()
94 static u32 __ieee80211_idle_on(struct ieee80211_local *local) in __ieee80211_idle_on() argument
96 if (local->hw.conf.flags & IEEE80211_CONF_IDLE) in __ieee80211_idle_on()
99 ieee80211_flush_queues(local, NULL, false); in __ieee80211_idle_on()
101 local->hw.conf.flags |= IEEE80211_CONF_IDLE; in __ieee80211_idle_on()
105 static u32 __ieee80211_recalc_idle(struct ieee80211_local *local, in __ieee80211_recalc_idle() argument
111 lockdep_assert_held(&local->mtx); in __ieee80211_recalc_idle()
114 !list_empty(&local->chanctx_list) || in __ieee80211_recalc_idle()
115 local->monitors; in __ieee80211_recalc_idle()
117 working = !local->ops->remain_on_channel && in __ieee80211_recalc_idle()
118 !list_empty(&local->roc_list); in __ieee80211_recalc_idle()
120 scanning = test_bit(SCAN_SW_SCANNING, &local->scanning) || in __ieee80211_recalc_idle()
121 test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning); in __ieee80211_recalc_idle()
133 ieee80211_mod_tpt_led_trig(local, led_trig_start, led_trig_stop); in __ieee80211_recalc_idle()
136 return __ieee80211_idle_off(local); in __ieee80211_recalc_idle()
137 return __ieee80211_idle_on(local); in __ieee80211_recalc_idle()
140 u32 ieee80211_idle_off(struct ieee80211_local *local) in ieee80211_idle_off() argument
142 return __ieee80211_recalc_idle(local, true); in ieee80211_idle_off()
145 void ieee80211_recalc_idle(struct ieee80211_local *local) in ieee80211_recalc_idle() argument
147 u32 change = __ieee80211_recalc_idle(local, false); in ieee80211_recalc_idle()
149 ieee80211_hw_config(local, change); in ieee80211_recalc_idle()
155 struct ieee80211_local *local = sdata->local; in ieee80211_verify_mac() local
161 if (is_zero_ether_addr(local->hw.wiphy->addr_mask)) in ieee80211_verify_mac()
169 m = local->hw.wiphy->addr_mask; in ieee80211_verify_mac()
177 mutex_lock(&local->iflist_mtx); in ieee80211_verify_mac()
178 list_for_each_entry(iter, &local->interfaces, list) { in ieee80211_verify_mac()
182 if (iter->vif.type == NL80211_IFTYPE_MONITOR && in ieee80211_verify_mac()
183 !(iter->u.mntr.flags & MONITOR_FLAG_ACTIVE)) in ieee80211_verify_mac()
186 m = iter->vif.addr; in ieee80211_verify_mac()
192 ret = -EINVAL; in ieee80211_verify_mac()
196 mutex_unlock(&local->iflist_mtx); in ieee80211_verify_mac()
209 return -EBUSY; in ieee80211_change_mac()
211 if (sdata->vif.type == NL80211_IFTYPE_MONITOR && in ieee80211_change_mac()
212 !(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE)) in ieee80211_change_mac()
215 ret = ieee80211_verify_mac(sdata, sa->sa_data, check_dup); in ieee80211_change_mac()
222 memcpy(sdata->vif.addr, sa->sa_data, ETH_ALEN); in ieee80211_change_mac()
246 struct ieee80211_local *local = sdata->local; in ieee80211_check_concurrent_iface() local
253 list_for_each_entry(nsdata, &local->interfaces, list) { in ieee80211_check_concurrent_iface()
258 if ((sdata->vif.type == NL80211_IFTYPE_OCB && in ieee80211_check_concurrent_iface()
259 nsdata->vif.type != NL80211_IFTYPE_MONITOR) || in ieee80211_check_concurrent_iface()
260 (sdata->vif.type != NL80211_IFTYPE_MONITOR && in ieee80211_check_concurrent_iface()
261 nsdata->vif.type == NL80211_IFTYPE_OCB)) in ieee80211_check_concurrent_iface()
262 return -EBUSY; in ieee80211_check_concurrent_iface()
275 nsdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_check_concurrent_iface()
276 return -EBUSY; in ieee80211_check_concurrent_iface()
281 if (nsdata->vif.csa_active) in ieee80211_check_concurrent_iface()
282 return -EBUSY; in ieee80211_check_concurrent_iface()
288 if (!ether_addr_equal(sdata->vif.addr, in ieee80211_check_concurrent_iface()
289 nsdata->vif.addr)) in ieee80211_check_concurrent_iface()
296 nsdata->vif.type)) in ieee80211_check_concurrent_iface()
297 return -ENOTUNIQ; in ieee80211_check_concurrent_iface()
303 nsdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_check_concurrent_iface()
304 sdata->bss = &nsdata->u.ap; in ieee80211_check_concurrent_iface()
308 mutex_lock(&local->chanctx_mtx); in ieee80211_check_concurrent_iface()
310 mutex_unlock(&local->chanctx_mtx); in ieee80211_check_concurrent_iface()
317 int n_queues = sdata->local->hw.queues; in ieee80211_check_queues()
325 if (WARN_ON_ONCE(sdata->vif.hw_queue[i] == in ieee80211_check_queues()
327 return -EINVAL; in ieee80211_check_queues()
328 if (WARN_ON_ONCE(sdata->vif.hw_queue[i] >= in ieee80211_check_queues()
330 return -EINVAL; in ieee80211_check_queues()
337 !ieee80211_hw_check(&sdata->local->hw, QUEUE_CONTROL)) { in ieee80211_check_queues()
338 sdata->vif.cab_queue = IEEE80211_INVAL_HW_QUEUE; in ieee80211_check_queues()
342 if (WARN_ON_ONCE(sdata->vif.cab_queue == IEEE80211_INVAL_HW_QUEUE)) in ieee80211_check_queues()
343 return -EINVAL; in ieee80211_check_queues()
345 if (WARN_ON_ONCE(sdata->vif.cab_queue >= n_queues)) in ieee80211_check_queues()
346 return -EINVAL; in ieee80211_check_queues()
357 if (!is_valid_ether_addr(dev->dev_addr)) in ieee80211_open()
358 return -EADDRNOTAVAIL; in ieee80211_open()
360 err = ieee80211_check_concurrent_iface(sdata, sdata->vif.type); in ieee80211_open()
364 return ieee80211_do_open(&sdata->wdev, true); in ieee80211_open()
370 struct ieee80211_local *local = sdata->local; in ieee80211_do_stop() local
380 clear_bit(SDATA_STATE_RUNNING, &sdata->state); in ieee80211_do_stop()
382 cancel_scan = rcu_access_pointer(local->scan_sdata) == sdata; in ieee80211_do_stop()
384 ieee80211_scan_cancel(local); in ieee80211_do_stop()
389 if (sdata->dev) in ieee80211_do_stop()
390 netif_tx_stop_all_queues(sdata->dev); in ieee80211_do_stop()
392 ieee80211_roc_purge(local, sdata); in ieee80211_do_stop()
394 switch (sdata->vif.type) { in ieee80211_do_stop()
402 if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) in ieee80211_do_stop()
404 list_del_rcu(&sdata->u.mntr.list); in ieee80211_do_stop()
413 * This must be done before calling ops->remove_interface() in ieee80211_do_stop()
414 * because otherwise we can later invoke ops->sta_notify() in ieee80211_do_stop()
417 * (because if we remove a STA after ops->remove_interface() in ieee80211_do_stop()
426 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_do_stop()
427 ((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) || in ieee80211_do_stop()
428 (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1))); in ieee80211_do_stop()
431 if (sdata->flags & IEEE80211_SDATA_ALLMULTI) in ieee80211_do_stop()
432 atomic_dec(&local->iff_allmultis); in ieee80211_do_stop()
434 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_do_stop()
435 local->fif_pspoll--; in ieee80211_do_stop()
436 local->fif_probe_req--; in ieee80211_do_stop()
437 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in ieee80211_do_stop()
438 local->fif_probe_req--; in ieee80211_do_stop()
441 if (sdata->dev) { in ieee80211_do_stop()
442 netif_addr_lock_bh(sdata->dev); in ieee80211_do_stop()
443 spin_lock_bh(&local->filter_lock); in ieee80211_do_stop()
444 __hw_addr_unsync(&local->mc_list, &sdata->dev->mc, in ieee80211_do_stop()
445 sdata->dev->addr_len); in ieee80211_do_stop()
446 spin_unlock_bh(&local->filter_lock); in ieee80211_do_stop()
447 netif_addr_unlock_bh(sdata->dev); in ieee80211_do_stop()
450 del_timer_sync(&local->dynamic_ps_timer); in ieee80211_do_stop()
451 cancel_work_sync(&local->dynamic_ps_enable_work); in ieee80211_do_stop()
453 cancel_work_sync(&sdata->recalc_smps); in ieee80211_do_stop()
455 mutex_lock(&local->mtx); in ieee80211_do_stop()
456 sdata->vif.csa_active = false; in ieee80211_do_stop()
457 if (sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_do_stop()
458 sdata->u.mgd.csa_waiting_bcn = false; in ieee80211_do_stop()
459 if (sdata->csa_block_tx) { in ieee80211_do_stop()
460 ieee80211_wake_vif_queues(local, sdata, in ieee80211_do_stop()
462 sdata->csa_block_tx = false; in ieee80211_do_stop()
464 mutex_unlock(&local->mtx); in ieee80211_do_stop()
467 cancel_work_sync(&sdata->csa_finalize_work); in ieee80211_do_stop()
469 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work); in ieee80211_do_stop()
471 if (sdata->wdev.cac_started) { in ieee80211_do_stop()
472 chandef = sdata->vif.bss_conf.chandef; in ieee80211_do_stop()
473 WARN_ON(local->suspended); in ieee80211_do_stop()
474 mutex_lock(&local->mtx); in ieee80211_do_stop()
476 mutex_unlock(&local->mtx); in ieee80211_do_stop()
477 cfg80211_cac_event(sdata->dev, &chandef, in ieee80211_do_stop()
483 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_do_stop()
487 list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans, in ieee80211_do_stop()
489 dev_close(vlan->dev); in ieee80211_do_stop()
490 WARN_ON(!list_empty(&sdata->u.ap.vlans)); in ieee80211_do_stop()
491 } else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_do_stop()
493 ps = &sdata->bss->ps; in ieee80211_do_stop()
495 spin_lock_irqsave(&ps->bc_buf.lock, flags); in ieee80211_do_stop()
496 skb_queue_walk_safe(&ps->bc_buf, skb, tmp) { in ieee80211_do_stop()
497 if (skb->dev == sdata->dev) { in ieee80211_do_stop()
498 __skb_unlink(skb, &ps->bc_buf); in ieee80211_do_stop()
499 local->total_ps_buffered--; in ieee80211_do_stop()
500 ieee80211_free_txskb(&local->hw, skb); in ieee80211_do_stop()
503 spin_unlock_irqrestore(&ps->bc_buf.lock, flags); in ieee80211_do_stop()
507 local->open_count--; in ieee80211_do_stop()
509 switch (sdata->vif.type) { in ieee80211_do_stop()
511 mutex_lock(&local->mtx); in ieee80211_do_stop()
512 list_del(&sdata->u.vlan.list); in ieee80211_do_stop()
513 mutex_unlock(&local->mtx); in ieee80211_do_stop()
514 RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL); in ieee80211_do_stop()
520 if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) { in ieee80211_do_stop()
521 local->cooked_mntrs--; in ieee80211_do_stop()
525 local->monitors--; in ieee80211_do_stop()
526 if (local->monitors == 0) { in ieee80211_do_stop()
527 local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR; in ieee80211_do_stop()
531 ieee80211_adjust_monitor_flags(sdata, -1); in ieee80211_do_stop()
535 spin_lock_bh(&sdata->u.nan.func_lock); in ieee80211_do_stop()
537 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, i) { in ieee80211_do_stop()
538 idr_remove(&sdata->u.nan.function_inst_ids, i); in ieee80211_do_stop()
541 idr_destroy(&sdata->u.nan.function_inst_ids); in ieee80211_do_stop()
543 spin_unlock_bh(&sdata->u.nan.func_lock); in ieee80211_do_stop()
547 RCU_INIT_POINTER(local->p2p_sdata, NULL); in ieee80211_do_stop()
550 cancel_work_sync(&sdata->work); in ieee80211_do_stop()
564 skb_queue_purge(&sdata->skb_queue); in ieee80211_do_stop()
567 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_do_stop()
569 skb_queue_walk_safe(&local->pending[i], skb, tmp) { in ieee80211_do_stop()
571 if (info->control.vif == &sdata->vif) { in ieee80211_do_stop()
572 __skb_unlink(skb, &local->pending[i]); in ieee80211_do_stop()
573 ieee80211_free_txskb(&local->hw, skb); in ieee80211_do_stop()
577 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_do_stop()
579 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_do_stop()
580 ieee80211_txq_remove_vlan(local, sdata); in ieee80211_do_stop()
582 sdata->bss = NULL; in ieee80211_do_stop()
584 if (local->open_count == 0) in ieee80211_do_stop()
585 ieee80211_clear_tx_pending(local); in ieee80211_do_stop()
587 sdata->vif.bss_conf.beacon_int = 0; in ieee80211_do_stop()
598 if (local->suspended) { in ieee80211_do_stop()
599 WARN_ON(local->wowlan); in ieee80211_do_stop()
600 WARN_ON(rtnl_dereference(local->monitor_sdata)); in ieee80211_do_stop()
604 switch (sdata->vif.type) { in ieee80211_do_stop()
608 if (local->monitors == 0) in ieee80211_do_stop()
609 ieee80211_del_virtual_monitor(local); in ieee80211_do_stop()
611 mutex_lock(&local->mtx); in ieee80211_do_stop()
612 ieee80211_recalc_idle(local); in ieee80211_do_stop()
613 mutex_unlock(&local->mtx); in ieee80211_do_stop()
615 if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE)) in ieee80211_do_stop()
621 drv_remove_interface(local, sdata); in ieee80211_do_stop()
624 ieee80211_recalc_ps(local); in ieee80211_do_stop()
627 flush_delayed_work(&local->scan_work); in ieee80211_do_stop()
629 if (local->open_count == 0) { in ieee80211_do_stop()
630 ieee80211_stop_device(local); in ieee80211_do_stop()
637 ieee80211_configure_filter(local); in ieee80211_do_stop()
638 ieee80211_hw_config(local, hw_reconf_flags); in ieee80211_do_stop()
640 if (local->monitors == local->open_count) in ieee80211_do_stop()
641 ieee80211_add_virtual_monitor(local); in ieee80211_do_stop()
656 struct ieee80211_local *local = sdata->local; in ieee80211_set_multicast_list() local
659 allmulti = !!(dev->flags & IFF_ALLMULTI); in ieee80211_set_multicast_list()
660 sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI); in ieee80211_set_multicast_list()
663 if (dev->flags & IFF_ALLMULTI) in ieee80211_set_multicast_list()
664 atomic_inc(&local->iff_allmultis); in ieee80211_set_multicast_list()
666 atomic_dec(&local->iff_allmultis); in ieee80211_set_multicast_list()
667 sdata->flags ^= IEEE80211_SDATA_ALLMULTI; in ieee80211_set_multicast_list()
670 spin_lock_bh(&local->filter_lock); in ieee80211_set_multicast_list()
671 __hw_addr_sync(&local->mc_list, &dev->mc, dev->addr_len); in ieee80211_set_multicast_list()
672 spin_unlock_bh(&local->filter_lock); in ieee80211_set_multicast_list()
673 ieee80211_queue_work(&local->hw, &local->reconfig_filter); in ieee80211_set_multicast_list()
690 __skb_queue_purge(&sdata->fragments[i].skb_list); in ieee80211_teardown_sdata()
691 sdata->fragment_next = 0; in ieee80211_teardown_sdata()
693 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_teardown_sdata()
712 dev_fetch_sw_netstats(stats, dev->tstats); in ieee80211_get_stats64()
731 struct ieee80211_local *local = sdata->local; in ieee80211_monitor_select_queue() local
736 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_monitor_select_queue()
745 len_rthdr = ieee80211_get_radiotap_len(skb->data); in ieee80211_monitor_select_queue()
746 hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); in ieee80211_monitor_select_queue()
747 if (skb->len < len_rthdr + 2 || in ieee80211_monitor_select_queue()
748 skb->len < len_rthdr + ieee80211_hdrlen(hdr->frame_control)) in ieee80211_monitor_select_queue()
790 struct ieee80211_local *local = sdata->local; in ieee80211_set_sdata_offload_flags() local
793 flags = sdata->vif.offload_flags; in ieee80211_set_sdata_offload_flags()
795 if (ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) && in ieee80211_set_sdata_offload_flags()
796 ieee80211_iftype_supports_encap_offload(sdata->vif.type)) { in ieee80211_set_sdata_offload_flags()
799 if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG) && in ieee80211_set_sdata_offload_flags()
800 local->hw.wiphy->frag_threshold != (u32)-1) in ieee80211_set_sdata_offload_flags()
803 if (local->monitors) in ieee80211_set_sdata_offload_flags()
809 if (sdata->vif.offload_flags == flags) in ieee80211_set_sdata_offload_flags()
812 sdata->vif.offload_flags = flags; in ieee80211_set_sdata_offload_flags()
818 struct ieee80211_local *local = sdata->local; in ieee80211_set_vif_encap_ops() local
822 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_set_vif_encap_ops()
823 if (!sdata->bss) in ieee80211_set_vif_encap_ops()
826 bss = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_set_vif_encap_ops()
829 if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) || in ieee80211_set_vif_encap_ops()
830 !ieee80211_iftype_supports_encap_offload(bss->vif.type)) in ieee80211_set_vif_encap_ops()
833 enabled = bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED; in ieee80211_set_vif_encap_ops()
834 if (sdata->wdev.use_4addr && in ieee80211_set_vif_encap_ops()
835 !(bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_4ADDR)) in ieee80211_set_vif_encap_ops()
838 sdata->dev->netdev_ops = enabled ? &ieee80211_dataif_8023_ops : in ieee80211_set_vif_encap_ops()
844 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_sdata_offload() local
848 drv_update_vif_offload(local, sdata); in ieee80211_recalc_sdata_offload()
852 list_for_each_entry(vsdata, &local->interfaces, list) { in ieee80211_recalc_sdata_offload()
853 if (vsdata->vif.type != NL80211_IFTYPE_AP_VLAN || in ieee80211_recalc_sdata_offload()
854 vsdata->bss != &sdata->u.ap) in ieee80211_recalc_sdata_offload()
861 void ieee80211_recalc_offload(struct ieee80211_local *local) in ieee80211_recalc_offload() argument
865 if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD)) in ieee80211_recalc_offload()
868 mutex_lock(&local->iflist_mtx); in ieee80211_recalc_offload()
870 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_recalc_offload()
877 mutex_unlock(&local->iflist_mtx); in ieee80211_recalc_offload()
883 struct ieee80211_local *local = sdata->local; in ieee80211_adjust_monitor_flags() local
884 u32 flags = sdata->u.mntr.flags; in ieee80211_adjust_monitor_flags()
888 local->fif_##_s += offset; \ in ieee80211_adjust_monitor_flags()
902 struct ieee80211_local *local = sdata->local; in ieee80211_set_default_queues() local
906 if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in ieee80211_set_default_queues()
907 sdata->vif.hw_queue[i] = IEEE80211_INVAL_HW_QUEUE; in ieee80211_set_default_queues()
908 else if (local->hw.queues >= IEEE80211_NUM_ACS) in ieee80211_set_default_queues()
909 sdata->vif.hw_queue[i] = i; in ieee80211_set_default_queues()
911 sdata->vif.hw_queue[i] = 0; in ieee80211_set_default_queues()
913 sdata->vif.cab_queue = IEEE80211_INVAL_HW_QUEUE; in ieee80211_set_default_queues()
916 int ieee80211_add_virtual_monitor(struct ieee80211_local *local) in ieee80211_add_virtual_monitor() argument
921 if (!ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) in ieee80211_add_virtual_monitor()
926 if (local->monitor_sdata) in ieee80211_add_virtual_monitor()
929 sdata = kzalloc(sizeof(*sdata) + local->hw.vif_data_size, GFP_KERNEL); in ieee80211_add_virtual_monitor()
931 return -ENOMEM; in ieee80211_add_virtual_monitor()
934 sdata->local = local; in ieee80211_add_virtual_monitor()
935 sdata->vif.type = NL80211_IFTYPE_MONITOR; in ieee80211_add_virtual_monitor()
936 snprintf(sdata->name, IFNAMSIZ, "%s-monitor", in ieee80211_add_virtual_monitor()
937 wiphy_name(local->hw.wiphy)); in ieee80211_add_virtual_monitor()
938 sdata->wdev.iftype = NL80211_IFTYPE_MONITOR; in ieee80211_add_virtual_monitor()
940 sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; in ieee80211_add_virtual_monitor()
944 ret = drv_add_interface(local, sdata); in ieee80211_add_virtual_monitor()
951 set_bit(SDATA_STATE_RUNNING, &sdata->state); in ieee80211_add_virtual_monitor()
959 mutex_lock(&local->iflist_mtx); in ieee80211_add_virtual_monitor()
960 rcu_assign_pointer(local->monitor_sdata, sdata); in ieee80211_add_virtual_monitor()
961 mutex_unlock(&local->iflist_mtx); in ieee80211_add_virtual_monitor()
963 mutex_lock(&local->mtx); in ieee80211_add_virtual_monitor()
964 ret = ieee80211_vif_use_channel(sdata, &local->monitor_chandef, in ieee80211_add_virtual_monitor()
966 mutex_unlock(&local->mtx); in ieee80211_add_virtual_monitor()
968 mutex_lock(&local->iflist_mtx); in ieee80211_add_virtual_monitor()
969 RCU_INIT_POINTER(local->monitor_sdata, NULL); in ieee80211_add_virtual_monitor()
970 mutex_unlock(&local->iflist_mtx); in ieee80211_add_virtual_monitor()
972 drv_remove_interface(local, sdata); in ieee80211_add_virtual_monitor()
977 skb_queue_head_init(&sdata->skb_queue); in ieee80211_add_virtual_monitor()
978 INIT_WORK(&sdata->work, ieee80211_iface_work); in ieee80211_add_virtual_monitor()
983 void ieee80211_del_virtual_monitor(struct ieee80211_local *local) in ieee80211_del_virtual_monitor() argument
987 if (!ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) in ieee80211_del_virtual_monitor()
992 mutex_lock(&local->iflist_mtx); in ieee80211_del_virtual_monitor()
994 sdata = rcu_dereference_protected(local->monitor_sdata, in ieee80211_del_virtual_monitor()
995 lockdep_is_held(&local->iflist_mtx)); in ieee80211_del_virtual_monitor()
997 mutex_unlock(&local->iflist_mtx); in ieee80211_del_virtual_monitor()
1001 RCU_INIT_POINTER(local->monitor_sdata, NULL); in ieee80211_del_virtual_monitor()
1002 mutex_unlock(&local->iflist_mtx); in ieee80211_del_virtual_monitor()
1006 mutex_lock(&local->mtx); in ieee80211_del_virtual_monitor()
1008 mutex_unlock(&local->mtx); in ieee80211_del_virtual_monitor()
1010 drv_remove_interface(local, sdata); in ieee80211_del_virtual_monitor()
1017 * an error on interface type changes that have been pre-checked, so most
1023 struct net_device *dev = wdev->netdev; in ieee80211_do_open()
1024 struct ieee80211_local *local = sdata->local; in ieee80211_do_open() local
1030 switch (sdata->vif.type) { in ieee80211_do_open()
1032 if (!is_valid_ether_addr(sdata->u.wds.remote_addr)) in ieee80211_do_open()
1033 return -ENOLINK; in ieee80211_do_open()
1038 if (!sdata->bss) in ieee80211_do_open()
1039 return -ENOLINK; in ieee80211_do_open()
1041 mutex_lock(&local->mtx); in ieee80211_do_open()
1042 list_add(&sdata->u.vlan.list, &sdata->bss->vlans); in ieee80211_do_open()
1043 mutex_unlock(&local->mtx); in ieee80211_do_open()
1045 master = container_of(sdata->bss, in ieee80211_do_open()
1047 sdata->control_port_protocol = in ieee80211_do_open()
1048 master->control_port_protocol; in ieee80211_do_open()
1049 sdata->control_port_no_encrypt = in ieee80211_do_open()
1050 master->control_port_no_encrypt; in ieee80211_do_open()
1051 sdata->control_port_over_nl80211 = in ieee80211_do_open()
1052 master->control_port_over_nl80211; in ieee80211_do_open()
1053 sdata->control_port_no_preauth = in ieee80211_do_open()
1054 master->control_port_no_preauth; in ieee80211_do_open()
1055 sdata->vif.cab_queue = master->vif.cab_queue; in ieee80211_do_open()
1056 memcpy(sdata->vif.hw_queue, master->vif.hw_queue, in ieee80211_do_open()
1057 sizeof(sdata->vif.hw_queue)); in ieee80211_do_open()
1058 sdata->vif.bss_conf.chandef = master->vif.bss_conf.chandef; in ieee80211_do_open()
1060 mutex_lock(&local->key_mtx); in ieee80211_do_open()
1061 sdata->crypto_tx_tailroom_needed_cnt += in ieee80211_do_open()
1062 master->crypto_tx_tailroom_needed_cnt; in ieee80211_do_open()
1063 mutex_unlock(&local->key_mtx); in ieee80211_do_open()
1068 sdata->bss = &sdata->u.ap; in ieee80211_do_open()
1088 if (local->open_count == 0) { in ieee80211_do_open()
1089 res = drv_start(local); in ieee80211_do_open()
1094 ieee80211_led_radio(local, true); in ieee80211_do_open()
1095 ieee80211_mod_tpt_led_trig(local, in ieee80211_do_open()
1100 * Copy the hopefully now-present MAC address to in ieee80211_do_open()
1103 if (dev && is_zero_ether_addr(dev->dev_addr)) { in ieee80211_do_open()
1104 memcpy(dev->dev_addr, in ieee80211_do_open()
1105 local->hw.wiphy->perm_addr, in ieee80211_do_open()
1107 memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN); in ieee80211_do_open()
1109 if (!is_valid_ether_addr(dev->dev_addr)) { in ieee80211_do_open()
1110 res = -EADDRNOTAVAIL; in ieee80211_do_open()
1115 switch (sdata->vif.type) { in ieee80211_do_open()
1118 if (rtnl_dereference(sdata->bss->beacon)) { in ieee80211_do_open()
1127 if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) { in ieee80211_do_open()
1128 local->cooked_mntrs++; in ieee80211_do_open()
1132 if (sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in ieee80211_do_open()
1133 res = drv_add_interface(local, sdata); in ieee80211_do_open()
1136 } else if (local->monitors == 0 && local->open_count == 0) { in ieee80211_do_open()
1137 res = ieee80211_add_virtual_monitor(local); in ieee80211_do_open()
1143 local->monitors++; in ieee80211_do_open()
1144 if (local->monitors == 1) { in ieee80211_do_open()
1145 local->hw.conf.flags |= IEEE80211_CONF_MONITOR; in ieee80211_do_open()
1150 ieee80211_configure_filter(local); in ieee80211_do_open()
1151 ieee80211_recalc_offload(local); in ieee80211_do_open()
1152 mutex_lock(&local->mtx); in ieee80211_do_open()
1153 ieee80211_recalc_idle(local); in ieee80211_do_open()
1154 mutex_unlock(&local->mtx); in ieee80211_do_open()
1160 ieee80211_del_virtual_monitor(local); in ieee80211_do_open()
1163 res = drv_add_interface(local, sdata); in ieee80211_do_open()
1169 ieee80211_vif_type_p2p(&sdata->vif)); in ieee80211_do_open()
1174 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_do_open()
1175 local->fif_pspoll++; in ieee80211_do_open()
1176 local->fif_probe_req++; in ieee80211_do_open()
1178 ieee80211_configure_filter(local); in ieee80211_do_open()
1179 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in ieee80211_do_open()
1180 local->fif_probe_req++; in ieee80211_do_open()
1183 if (sdata->vif.probe_req_reg) in ieee80211_do_open()
1184 drv_config_iface_filter(local, sdata, in ieee80211_do_open()
1188 if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE && in ieee80211_do_open()
1189 sdata->vif.type != NL80211_IFTYPE_NAN) in ieee80211_do_open()
1193 switch (sdata->vif.type) { in ieee80211_do_open()
1217 sdata->vif.type != NL80211_IFTYPE_STATION); in ieee80211_do_open()
1220 set_bit(SDATA_STATE_RUNNING, &sdata->state); in ieee80211_do_open()
1222 switch (sdata->vif.type) { in ieee80211_do_open()
1225 sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr, in ieee80211_do_open()
1228 res = -ENOMEM; in ieee80211_do_open()
1246 rcu_assign_pointer(local->p2p_sdata, sdata); in ieee80211_do_open()
1249 if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) in ieee80211_do_open()
1251 list_add_tail_rcu(&sdata->u.mntr.list, &local->mon_list); in ieee80211_do_open()
1262 if (sdata->flags & IEEE80211_SDATA_ALLMULTI) in ieee80211_do_open()
1263 atomic_inc(&local->iff_allmultis); in ieee80211_do_open()
1266 local->open_count++; in ieee80211_do_open()
1269 ieee80211_hw_config(local, hw_reconf_flags); in ieee80211_do_open()
1271 ieee80211_recalc_ps(local); in ieee80211_do_open()
1273 if (sdata->vif.type == NL80211_IFTYPE_MONITOR || in ieee80211_do_open()
1274 sdata->vif.type == NL80211_IFTYPE_AP_VLAN || in ieee80211_do_open()
1275 local->ops->wake_tx_queue) { in ieee80211_do_open()
1284 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_do_open()
1287 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_do_open()
1288 if (sdata->vif.cab_queue == IEEE80211_INVAL_HW_QUEUE || in ieee80211_do_open()
1289 (local->queue_stop_reasons[sdata->vif.cab_queue] == 0 && in ieee80211_do_open()
1290 skb_queue_empty(&local->pending[sdata->vif.cab_queue]))) { in ieee80211_do_open()
1292 int ac_queue = sdata->vif.hw_queue[ac]; in ieee80211_do_open()
1294 if (local->queue_stop_reasons[ac_queue] == 0 && in ieee80211_do_open()
1295 skb_queue_empty(&local->pending[ac_queue])) in ieee80211_do_open()
1299 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_do_open()
1304 drv_remove_interface(local, sdata); in ieee80211_do_open()
1306 if (!local->open_count) in ieee80211_do_open()
1307 drv_stop(local); in ieee80211_do_open()
1309 sdata->bss = NULL; in ieee80211_do_open()
1310 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_do_open()
1311 mutex_lock(&local->mtx); in ieee80211_do_open()
1312 list_del(&sdata->u.vlan.list); in ieee80211_do_open()
1313 mutex_unlock(&local->mtx); in ieee80211_do_open()
1316 clear_bit(SDATA_STATE_RUNNING, &sdata->state); in ieee80211_do_open()
1322 free_percpu(dev->tstats); in ieee80211_if_free()
1328 dev->priv_flags &= ~IFF_TX_SKB_SHARING; in ieee80211_if_setup()
1329 dev->netdev_ops = &ieee80211_dataif_ops; in ieee80211_if_setup()
1330 dev->needs_free_netdev = true; in ieee80211_if_setup()
1331 dev->priv_destructor = ieee80211_if_free; in ieee80211_if_setup()
1337 dev->priv_flags |= IFF_NO_QUEUE; in ieee80211_if_setup_no_queue()
1344 struct ieee80211_local *local = sdata->local; in ieee80211_iface_work() local
1351 if (test_bit(SCAN_SW_SCANNING, &local->scanning)) in ieee80211_iface_work()
1354 if (!ieee80211_can_run_worker(local)) in ieee80211_iface_work()
1358 while ((skb = skb_dequeue(&sdata->skb_queue))) { in ieee80211_iface_work()
1359 struct ieee80211_mgmt *mgmt = (void *)skb->data; in ieee80211_iface_work()
1361 if (ieee80211_is_action(mgmt->frame_control) && in ieee80211_iface_work()
1362 mgmt->u.action.category == WLAN_CATEGORY_BACK) { in ieee80211_iface_work()
1363 int len = skb->len; in ieee80211_iface_work()
1365 mutex_lock(&local->sta_mtx); in ieee80211_iface_work()
1366 sta = sta_info_get_bss(sdata, mgmt->sa); in ieee80211_iface_work()
1368 switch (mgmt->u.action.u.addba_req.action_code) { in ieee80211_iface_work()
1371 local, sta, mgmt, len); in ieee80211_iface_work()
1374 ieee80211_process_addba_resp(local, sta, in ieee80211_iface_work()
1386 mutex_unlock(&local->sta_mtx); in ieee80211_iface_work()
1387 } else if (ieee80211_is_action(mgmt->frame_control) && in ieee80211_iface_work()
1388 mgmt->u.action.category == WLAN_CATEGORY_VHT) { in ieee80211_iface_work()
1389 switch (mgmt->u.action.u.vht_group_notif.action_code) { in ieee80211_iface_work()
1396 band = status->band; in ieee80211_iface_work()
1397 opmode = mgmt->u.action.u.vht_opmode_notif.operating_mode; in ieee80211_iface_work()
1399 mutex_lock(&local->sta_mtx); in ieee80211_iface_work()
1400 sta = sta_info_get_bss(sdata, mgmt->sa); in ieee80211_iface_work()
1407 mutex_unlock(&local->sta_mtx); in ieee80211_iface_work()
1417 } else if (ieee80211_is_ext(mgmt->frame_control)) { in ieee80211_iface_work()
1418 if (sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_iface_work()
1422 } else if (ieee80211_is_data_qos(mgmt->frame_control)) { in ieee80211_iface_work()
1432 WARN_ON(hdr->frame_control & in ieee80211_iface_work()
1434 WARN_ON(!(hdr->seq_ctrl & in ieee80211_iface_work()
1438 * a block-ack session was active. That cannot be in ieee80211_iface_work()
1441 mutex_lock(&local->sta_mtx); in ieee80211_iface_work()
1442 sta = sta_info_get_bss(sdata, mgmt->sa); in ieee80211_iface_work()
1451 mutex_unlock(&local->sta_mtx); in ieee80211_iface_work()
1452 } else switch (sdata->vif.type) { in ieee80211_iface_work()
1460 if (!ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_iface_work()
1472 /* then other type-dependent work */ in ieee80211_iface_work()
1473 switch (sdata->vif.type) { in ieee80211_iface_work()
1481 if (!ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_iface_work()
1510 /* clear type-dependent union */ in ieee80211_setup_sdata()
1511 memset(&sdata->u, 0, sizeof(sdata->u)); in ieee80211_setup_sdata()
1513 /* and set some type-dependent values */ in ieee80211_setup_sdata()
1514 sdata->vif.type = type; in ieee80211_setup_sdata()
1515 sdata->vif.p2p = false; in ieee80211_setup_sdata()
1516 sdata->wdev.iftype = type; in ieee80211_setup_sdata()
1518 sdata->control_port_protocol = cpu_to_be16(ETH_P_PAE); in ieee80211_setup_sdata()
1519 sdata->control_port_no_encrypt = false; in ieee80211_setup_sdata()
1520 sdata->control_port_over_nl80211 = false; in ieee80211_setup_sdata()
1521 sdata->control_port_no_preauth = false; in ieee80211_setup_sdata()
1522 sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; in ieee80211_setup_sdata()
1523 sdata->vif.bss_conf.idle = true; in ieee80211_setup_sdata()
1524 sdata->vif.bss_conf.txpower = INT_MIN; /* unset */ in ieee80211_setup_sdata()
1526 sdata->noack_map = 0; in ieee80211_setup_sdata()
1528 /* only monitor/p2p-device differ */ in ieee80211_setup_sdata()
1529 if (sdata->dev) { in ieee80211_setup_sdata()
1530 sdata->dev->netdev_ops = &ieee80211_dataif_ops; in ieee80211_setup_sdata()
1531 sdata->dev->type = ARPHRD_ETHER; in ieee80211_setup_sdata()
1534 skb_queue_head_init(&sdata->skb_queue); in ieee80211_setup_sdata()
1535 INIT_WORK(&sdata->work, ieee80211_iface_work); in ieee80211_setup_sdata()
1536 INIT_WORK(&sdata->recalc_smps, ieee80211_recalc_smps_work); in ieee80211_setup_sdata()
1537 INIT_WORK(&sdata->csa_finalize_work, ieee80211_csa_finalize_work); in ieee80211_setup_sdata()
1538 INIT_LIST_HEAD(&sdata->assigned_chanctx_list); in ieee80211_setup_sdata()
1539 INIT_LIST_HEAD(&sdata->reserved_chanctx_list); in ieee80211_setup_sdata()
1544 sdata->vif.type = type; in ieee80211_setup_sdata()
1545 sdata->vif.p2p = true; in ieee80211_setup_sdata()
1548 skb_queue_head_init(&sdata->u.ap.ps.bc_buf); in ieee80211_setup_sdata()
1549 INIT_LIST_HEAD(&sdata->u.ap.vlans); in ieee80211_setup_sdata()
1550 sdata->vif.bss_conf.bssid = sdata->vif.addr; in ieee80211_setup_sdata()
1554 sdata->vif.type = type; in ieee80211_setup_sdata()
1555 sdata->vif.p2p = true; in ieee80211_setup_sdata()
1558 sdata->vif.bss_conf.bssid = sdata->u.mgd.bssid; in ieee80211_setup_sdata()
1562 sdata->vif.bss_conf.bssid = bssid_wildcard; in ieee80211_setup_sdata()
1566 sdata->vif.bss_conf.bssid = sdata->u.ibss.bssid; in ieee80211_setup_sdata()
1570 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_setup_sdata()
1574 sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP; in ieee80211_setup_sdata()
1575 sdata->dev->netdev_ops = &ieee80211_monitorif_ops; in ieee80211_setup_sdata()
1576 sdata->u.mntr.flags = MONITOR_FLAG_CONTROL | in ieee80211_setup_sdata()
1580 sdata->vif.bss_conf.bssid = NULL; in ieee80211_setup_sdata()
1583 idr_init(&sdata->u.nan.function_inst_ids); in ieee80211_setup_sdata()
1584 spin_lock_init(&sdata->u.nan.func_lock); in ieee80211_setup_sdata()
1585 sdata->vif.bss_conf.bssid = sdata->vif.addr; in ieee80211_setup_sdata()
1589 sdata->vif.bss_conf.bssid = sdata->vif.addr; in ieee80211_setup_sdata()
1603 struct ieee80211_local *local = sdata->local; in ieee80211_runtime_change_iftype() local
1610 if (!local->ops->change_interface) in ieee80211_runtime_change_iftype()
1611 return -EBUSY; in ieee80211_runtime_change_iftype()
1613 switch (sdata->vif.type) { in ieee80211_runtime_change_iftype()
1626 return -EBUSY; in ieee80211_runtime_change_iftype()
1650 return -EBUSY; in ieee80211_runtime_change_iftype()
1662 ret = drv_change_interface(local, sdata, internal_type, p2p); in ieee80211_runtime_change_iftype()
1664 type = ieee80211_vif_type_p2p(&sdata->vif); in ieee80211_runtime_change_iftype()
1669 * The warnings will hopefully make driver authors fix it :-) in ieee80211_runtime_change_iftype()
1676 err = ieee80211_do_open(&sdata->wdev, false); in ieee80211_runtime_change_iftype()
1689 if (type == ieee80211_vif_type_p2p(&sdata->vif)) in ieee80211_if_change_type()
1697 /* Purge and reset type-dependent state. */ in ieee80211_if_change_type()
1704 sdata->u.mgd.use_4addr = false; in ieee80211_if_change_type()
1709 static void ieee80211_assign_perm_addr(struct ieee80211_local *local, in ieee80211_assign_perm_addr() argument
1719 memcpy(perm_addr, local->hw.wiphy->perm_addr, ETH_ALEN); in ieee80211_assign_perm_addr()
1721 if (is_zero_ether_addr(local->hw.wiphy->addr_mask) && in ieee80211_assign_perm_addr()
1722 local->hw.wiphy->n_addresses <= 1) in ieee80211_assign_perm_addr()
1725 mutex_lock(&local->iflist_mtx); in ieee80211_assign_perm_addr()
1734 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_assign_perm_addr()
1735 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_assign_perm_addr()
1737 memcpy(perm_addr, sdata->vif.addr, ETH_ALEN); in ieee80211_assign_perm_addr()
1744 if (ieee80211_hw_check(&local->hw, P2P_DEV_ADDR_FOR_INTF)) { in ieee80211_assign_perm_addr()
1745 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_assign_perm_addr()
1746 if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE) in ieee80211_assign_perm_addr()
1750 memcpy(perm_addr, sdata->vif.addr, ETH_ALEN); in ieee80211_assign_perm_addr()
1756 /* assign a new address if possible -- try n_addresses first */ in ieee80211_assign_perm_addr()
1757 for (i = 0; i < local->hw.wiphy->n_addresses; i++) { in ieee80211_assign_perm_addr()
1760 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_assign_perm_addr()
1761 if (ether_addr_equal(local->hw.wiphy->addresses[i].addr, in ieee80211_assign_perm_addr()
1762 sdata->vif.addr)) { in ieee80211_assign_perm_addr()
1770 local->hw.wiphy->addresses[i].addr, in ieee80211_assign_perm_addr()
1777 if (is_zero_ether_addr(local->hw.wiphy->addr_mask)) in ieee80211_assign_perm_addr()
1780 m = local->hw.wiphy->addr_mask; in ieee80211_assign_perm_addr()
1795 m = local->hw.wiphy->perm_addr; in ieee80211_assign_perm_addr()
1796 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_assign_perm_addr()
1797 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) in ieee80211_assign_perm_addr()
1799 m = sdata->vif.addr; in ieee80211_assign_perm_addr()
1821 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_assign_perm_addr()
1822 if (ether_addr_equal(tmp_addr, sdata->vif.addr)) { in ieee80211_assign_perm_addr()
1839 mutex_unlock(&local->iflist_mtx); in ieee80211_assign_perm_addr()
1842 int ieee80211_if_add(struct ieee80211_local *local, const char *name, in ieee80211_if_add() argument
1859 sdata = kzalloc(sizeof(*sdata) + local->hw.vif_data_size, in ieee80211_if_add()
1862 return -ENOMEM; in ieee80211_if_add()
1863 wdev = &sdata->wdev; in ieee80211_if_add()
1865 sdata->dev = NULL; in ieee80211_if_add()
1866 strlcpy(sdata->name, name, IFNAMSIZ); in ieee80211_if_add()
1867 ieee80211_assign_perm_addr(local, wdev->address, type); in ieee80211_if_add()
1868 memcpy(sdata->vif.addr, wdev->address, ETH_ALEN); in ieee80211_if_add()
1870 int size = ALIGN(sizeof(*sdata) + local->hw.vif_data_size, in ieee80211_if_add() local
1874 if (local->ops->wake_tx_queue && in ieee80211_if_add()
1877 (params->flags & MONITOR_FLAG_ACTIVE))) in ieee80211_if_add()
1879 local->hw.txq_data_size; in ieee80211_if_add()
1881 if (local->ops->wake_tx_queue) { in ieee80211_if_add()
1885 if (local->hw.queues >= IEEE80211_NUM_ACS) in ieee80211_if_add()
1889 ndev = alloc_netdev_mqs(size + txq_size, in ieee80211_if_add()
1893 return -ENOMEM; in ieee80211_if_add()
1895 if (!local->ops->wake_tx_queue && local->hw.wiphy->tx_queue_len) in ieee80211_if_add()
1896 ndev->tx_queue_len = local->hw.wiphy->tx_queue_len; in ieee80211_if_add()
1898 dev_net_set(ndev, wiphy_net(local->hw.wiphy)); in ieee80211_if_add()
1900 ndev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); in ieee80211_if_add()
1901 if (!ndev->tstats) { in ieee80211_if_add()
1903 return -ENOMEM; in ieee80211_if_add()
1906 ndev->needed_headroom = local->tx_headroom + in ieee80211_if_add()
1911 - ETH_HLEN /* ethernet hard_header_len */ in ieee80211_if_add()
1913 ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM; in ieee80211_if_add()
1915 ret = dev_alloc_name(ndev, ndev->name); in ieee80211_if_add()
1922 ieee80211_assign_perm_addr(local, ndev->perm_addr, type); in ieee80211_if_add()
1923 if (is_valid_ether_addr(params->macaddr)) in ieee80211_if_add()
1924 memcpy(ndev->dev_addr, params->macaddr, ETH_ALEN); in ieee80211_if_add()
1926 memcpy(ndev->dev_addr, ndev->perm_addr, ETH_ALEN); in ieee80211_if_add()
1927 SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy)); in ieee80211_if_add()
1929 /* don't use IEEE80211_DEV_TO_SUB_IF -- it checks too much */ in ieee80211_if_add()
1931 ndev->ieee80211_ptr = &sdata->wdev; in ieee80211_if_add()
1932 memcpy(sdata->vif.addr, ndev->dev_addr, ETH_ALEN); in ieee80211_if_add()
1933 memcpy(sdata->name, ndev->name, IFNAMSIZ); in ieee80211_if_add()
1936 txqi = netdev_priv(ndev) + size; in ieee80211_if_add()
1940 sdata->dev = ndev; in ieee80211_if_add()
1943 /* initialise type-independent data */ in ieee80211_if_add()
1944 sdata->wdev.wiphy = local->hw.wiphy; in ieee80211_if_add()
1945 sdata->local = local; in ieee80211_if_add()
1948 skb_queue_head_init(&sdata->fragments[i].skb_list); in ieee80211_if_add()
1950 INIT_LIST_HEAD(&sdata->key_list); in ieee80211_if_add()
1952 INIT_DELAYED_WORK(&sdata->dfs_cac_timer_work, in ieee80211_if_add()
1954 INIT_DELAYED_WORK(&sdata->dec_tailroom_needed_wk, in ieee80211_if_add()
1959 sband = local->hw.wiphy->bands[i]; in ieee80211_if_add()
1960 sdata->rc_rateidx_mask[i] = in ieee80211_if_add()
1961 sband ? (1 << sband->n_bitrates) - 1 : 0; in ieee80211_if_add()
1963 __le16 cap; in ieee80211_if_add() local
1966 memcpy(sdata->rc_rateidx_mcs_mask[i], in ieee80211_if_add()
1967 sband->ht_cap.mcs.rx_mask, in ieee80211_if_add()
1968 sizeof(sdata->rc_rateidx_mcs_mask[i])); in ieee80211_if_add()
1970 cap = sband->vht_cap.vht_mcs.rx_mcs_map; in ieee80211_if_add()
1971 vht_rate_mask = sdata->rc_rateidx_vht_mcs_mask[i]; in ieee80211_if_add()
1972 ieee80211_get_vht_mask_from_cap(cap, vht_rate_mask); in ieee80211_if_add()
1974 memset(sdata->rc_rateidx_mcs_mask[i], 0, in ieee80211_if_add()
1975 sizeof(sdata->rc_rateidx_mcs_mask[i])); in ieee80211_if_add()
1976 memset(sdata->rc_rateidx_vht_mcs_mask[i], 0, in ieee80211_if_add()
1977 sizeof(sdata->rc_rateidx_vht_mcs_mask[i])); in ieee80211_if_add()
1983 sdata->ap_power_level = IEEE80211_UNSET_POWER_LEVEL; in ieee80211_if_add()
1984 sdata->user_power_level = local->user_power_level; in ieee80211_if_add()
1986 sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; in ieee80211_if_add()
1988 /* setup type-dependent data */ in ieee80211_if_add()
1992 ndev->ieee80211_ptr->use_4addr = params->use_4addr; in ieee80211_if_add()
1994 sdata->u.mgd.use_4addr = params->use_4addr; in ieee80211_if_add()
1996 ndev->features |= local->hw.netdev_features; in ieee80211_if_add()
1997 ndev->hw_features |= ndev->features & in ieee80211_if_add()
2002 /* MTU range: 256 - 2304 */ in ieee80211_if_add()
2003 ndev->min_mtu = 256; in ieee80211_if_add()
2004 ndev->max_mtu = local->hw.max_mtu; in ieee80211_if_add()
2013 mutex_lock(&local->iflist_mtx); in ieee80211_if_add()
2014 list_add_tail_rcu(&sdata->list, &local->interfaces); in ieee80211_if_add()
2015 mutex_unlock(&local->iflist_mtx); in ieee80211_if_add()
2018 *new_wdev = &sdata->wdev; in ieee80211_if_add()
2027 mutex_lock(&sdata->local->iflist_mtx); in ieee80211_if_remove()
2028 list_del_rcu(&sdata->list); in ieee80211_if_remove()
2029 mutex_unlock(&sdata->local->iflist_mtx); in ieee80211_if_remove()
2031 if (sdata->vif.txq) in ieee80211_if_remove()
2032 ieee80211_txq_purge(sdata->local, to_txq_info(sdata->vif.txq)); in ieee80211_if_remove()
2036 if (sdata->dev) { in ieee80211_if_remove()
2037 unregister_netdevice(sdata->dev); in ieee80211_if_remove()
2039 cfg80211_unregister_wdev(&sdata->wdev); in ieee80211_if_remove()
2047 if (WARN_ON_ONCE(!test_bit(SDATA_STATE_RUNNING, &sdata->state))) in ieee80211_sdata_stop()
2052 void ieee80211_remove_interfaces(struct ieee80211_local *local) in ieee80211_remove_interfaces() argument
2068 * have stopped all of its activities, so that we can do RCU-unaware in ieee80211_remove_interfaces()
2071 cfg80211_shutdown_all_interfaces(local->hw.wiphy); in ieee80211_remove_interfaces()
2073 WARN(local->open_count, "%s: open count remains %d\n", in ieee80211_remove_interfaces()
2074 wiphy_name(local->hw.wiphy), local->open_count); in ieee80211_remove_interfaces()
2076 ieee80211_txq_teardown_flows(local); in ieee80211_remove_interfaces()
2078 mutex_lock(&local->iflist_mtx); in ieee80211_remove_interfaces()
2079 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) { in ieee80211_remove_interfaces()
2080 list_del(&sdata->list); in ieee80211_remove_interfaces()
2082 if (sdata->dev) in ieee80211_remove_interfaces()
2083 unregister_netdevice_queue(sdata->dev, &unreg_list); in ieee80211_remove_interfaces()
2085 list_add(&sdata->list, &wdev_list); in ieee80211_remove_interfaces()
2087 mutex_unlock(&local->iflist_mtx); in ieee80211_remove_interfaces()
2091 list_del(&sdata->list); in ieee80211_remove_interfaces()
2092 cfg80211_unregister_wdev(&sdata->wdev); in ieee80211_remove_interfaces()
2106 if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy) in netdev_notify()
2109 if (dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid) in netdev_notify()
2113 memcpy(sdata->name, dev->name, IFNAMSIZ); in netdev_notify()
2135 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_vif_inc_num_mcast()
2136 atomic_inc(&sdata->u.ap.num_mcast_sta); in ieee80211_vif_inc_num_mcast()
2137 else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_vif_inc_num_mcast()
2138 atomic_inc(&sdata->u.vlan.num_mcast_sta); in ieee80211_vif_inc_num_mcast()
2143 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_vif_dec_num_mcast()
2144 atomic_dec(&sdata->u.ap.num_mcast_sta); in ieee80211_vif_dec_num_mcast()
2145 else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_vif_dec_num_mcast()
2146 atomic_dec(&sdata->u.vlan.num_mcast_sta); in ieee80211_vif_dec_num_mcast()