2 * Interface handling (except master interface)
4 * Copyright 2002-2005, Instant802 Networks, Inc.
5 * Copyright 2005-2006, Devicescape Software, Inc.
6 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
7 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/if_arp.h>
15 #include <linux/netdevice.h>
16 #include <linux/rtnetlink.h>
17 #include <net/mac80211.h>
18 #include "ieee80211_i.h"
20 #include "debugfs_netdev.h"
24 static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
27 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
29 meshhdrlen = (sdata->vif.type == NL80211_IFTYPE_MESH_POINT) ? 5 : 0;
31 /* FIX: what would be proper limits for MTU?
32 * This interface uses 802.3 frames. */
34 new_mtu > IEEE80211_MAX_DATA_LEN - 24 - 6 - meshhdrlen) {
38 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
39 printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu);
40 #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
45 static inline int identical_mac_addr_allowed(int type1, int type2)
47 return type1 == NL80211_IFTYPE_MONITOR ||
48 type2 == NL80211_IFTYPE_MONITOR ||
49 (type1 == NL80211_IFTYPE_AP && type2 == NL80211_IFTYPE_WDS) ||
50 (type1 == NL80211_IFTYPE_WDS &&
51 (type2 == NL80211_IFTYPE_WDS ||
52 type2 == NL80211_IFTYPE_AP)) ||
53 (type1 == NL80211_IFTYPE_AP && type2 == NL80211_IFTYPE_AP_VLAN) ||
54 (type1 == NL80211_IFTYPE_AP_VLAN &&
55 (type2 == NL80211_IFTYPE_AP ||
56 type2 == NL80211_IFTYPE_AP_VLAN));
59 static int ieee80211_open(struct net_device *dev)
61 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
62 struct ieee80211_sub_if_data *nsdata;
63 struct ieee80211_local *local = sdata->local;
65 struct ieee80211_if_init_conf conf;
68 u32 hw_reconf_flags = 0;
69 u8 null_addr[ETH_ALEN] = {0};
71 /* fail early if user set an invalid address */
72 if (compare_ether_addr(dev->dev_addr, null_addr) &&
73 !is_valid_ether_addr(dev->dev_addr))
74 return -EADDRNOTAVAIL;
76 /* we hold the RTNL here so can safely walk the list */
77 list_for_each_entry(nsdata, &local->interfaces, list) {
78 struct net_device *ndev = nsdata->dev;
80 if (ndev != dev && netif_running(ndev)) {
82 * Allow only a single IBSS interface to be up at any
83 * time. This is restricted because beacon distribution
84 * cannot work properly if both are in the same IBSS.
86 * To remove this restriction we'd have to disallow them
87 * from setting the same SSID on different IBSS interfaces
88 * belonging to the same hardware. Then, however, we're
89 * faced with having to adopt two different TSF timers...
91 if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
92 nsdata->vif.type == NL80211_IFTYPE_ADHOC)
96 * The remaining checks are only performed for interfaces
97 * with the same MAC address.
99 if (compare_ether_addr(dev->dev_addr, ndev->dev_addr))
103 * check whether it may have the same address
105 if (!identical_mac_addr_allowed(sdata->vif.type,
110 * can only add VLANs to enabled APs
112 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
113 nsdata->vif.type == NL80211_IFTYPE_AP)
114 sdata->bss = &nsdata->u.ap;
118 switch (sdata->vif.type) {
119 case NL80211_IFTYPE_WDS:
120 if (!is_valid_ether_addr(sdata->u.wds.remote_addr))
123 case NL80211_IFTYPE_AP_VLAN:
126 list_add(&sdata->u.vlan.list, &sdata->bss->vlans);
128 case NL80211_IFTYPE_AP:
129 sdata->bss = &sdata->u.ap;
131 case NL80211_IFTYPE_MESH_POINT:
132 if (!ieee80211_vif_is_mesh(&sdata->vif))
134 /* mesh ifaces must set allmulti to forward mcast traffic */
135 atomic_inc(&local->iff_allmultis);
137 case NL80211_IFTYPE_STATION:
138 case NL80211_IFTYPE_MONITOR:
139 case NL80211_IFTYPE_ADHOC:
140 /* no special treatment */
142 case NL80211_IFTYPE_UNSPECIFIED:
143 case __NL80211_IFTYPE_AFTER_LAST:
149 if (local->open_count == 0) {
151 if (local->ops->start)
152 res = local->ops->start(local_to_hw(local));
155 /* we're brought up, everything changes */
156 hw_reconf_flags = ~0;
157 ieee80211_led_radio(local, local->hw.conf.radio_enabled);
161 * Check all interfaces and copy the hopefully now-present
162 * MAC address to those that have the special null one.
164 list_for_each_entry(nsdata, &local->interfaces, list) {
165 struct net_device *ndev = nsdata->dev;
168 * No need to check netif_running since we do not allow
169 * it to start up with this invalid address.
171 if (compare_ether_addr(null_addr, ndev->dev_addr) == 0)
172 memcpy(ndev->dev_addr,
173 local->hw.wiphy->perm_addr,
177 if (compare_ether_addr(null_addr, local->mdev->dev_addr) == 0)
178 memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr,
182 * Validate the MAC address for this device.
184 if (!is_valid_ether_addr(dev->dev_addr)) {
185 if (!local->open_count && local->ops->stop)
186 local->ops->stop(local_to_hw(local));
187 return -EADDRNOTAVAIL;
190 switch (sdata->vif.type) {
191 case NL80211_IFTYPE_AP_VLAN:
192 /* no need to tell driver */
194 case NL80211_IFTYPE_MONITOR:
195 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
196 local->cooked_mntrs++;
200 /* must be before the call to ieee80211_configure_filter */
202 if (local->monitors == 1) {
203 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
204 hw_reconf_flags |= IEEE80211_CONF_CHANGE_RADIOTAP;
207 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
208 local->fif_fcsfail++;
209 if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL)
210 local->fif_plcpfail++;
211 if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL)
212 local->fif_control++;
213 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS)
214 local->fif_other_bss++;
216 netif_addr_lock_bh(local->mdev);
217 ieee80211_configure_filter(local);
218 netif_addr_unlock_bh(local->mdev);
220 case NL80211_IFTYPE_STATION:
221 case NL80211_IFTYPE_ADHOC:
222 sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET;
225 conf.vif = &sdata->vif;
226 conf.type = sdata->vif.type;
227 conf.mac_addr = dev->dev_addr;
228 res = local->ops->add_interface(local_to_hw(local), &conf);
232 if (ieee80211_vif_is_mesh(&sdata->vif)) {
233 local->fif_other_bss++;
234 netif_addr_lock_bh(local->mdev);
235 ieee80211_configure_filter(local);
236 netif_addr_unlock_bh(local->mdev);
238 ieee80211_start_mesh(sdata);
240 changed |= ieee80211_reset_erp_info(sdata);
241 ieee80211_bss_info_change_notify(sdata, changed);
242 ieee80211_enable_keys(sdata);
244 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
245 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
246 netif_carrier_off(dev);
248 netif_carrier_on(dev);
251 if (sdata->vif.type == NL80211_IFTYPE_WDS) {
252 /* Create STA entry for the WDS peer */
253 sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
257 goto err_del_interface;
260 /* no locking required since STA is not live yet */
261 sta->flags |= WLAN_STA_AUTHORIZED;
263 res = sta_info_insert(sta);
265 /* STA has been freed */
266 goto err_del_interface;
270 if (local->open_count == 0) {
271 res = dev_open(local->mdev);
274 goto err_del_interface;
275 tasklet_enable(&local->tx_pending_tasklet);
276 tasklet_enable(&local->tasklet);
280 * set_multicast_list will be invoked by the networking core
281 * which will check whether any increments here were done in
282 * error and sync them down to the hardware as filter flags.
284 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
285 atomic_inc(&local->iff_allmultis);
287 if (sdata->flags & IEEE80211_SDATA_PROMISC)
288 atomic_inc(&local->iff_promiscs);
291 if (hw_reconf_flags) {
292 ieee80211_hw_config(local, hw_reconf_flags);
294 * set default queue parameters so drivers don't
295 * need to initialise the hardware if the hardware
296 * doesn't start up with sane defaults
298 ieee80211_set_wmm_default(sdata);
302 * ieee80211_sta_work is disabled while network interface
303 * is down. Therefore, some configuration changes may not
304 * yet be effective. Trigger execution of ieee80211_sta_work
307 if (sdata->vif.type == NL80211_IFTYPE_STATION ||
308 sdata->vif.type == NL80211_IFTYPE_ADHOC) {
309 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
310 queue_work(local->hw.workqueue, &ifsta->work);
313 netif_tx_start_all_queues(dev);
317 local->ops->remove_interface(local_to_hw(local), &conf);
319 if (!local->open_count && local->ops->stop)
320 local->ops->stop(local_to_hw(local));
323 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
324 list_del(&sdata->u.vlan.list);
328 static int ieee80211_stop(struct net_device *dev)
330 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
331 struct ieee80211_local *local = sdata->local;
332 struct ieee80211_if_init_conf conf;
333 struct sta_info *sta;
334 u32 hw_reconf_flags = 0;
337 * Stop TX on this interface first.
339 netif_tx_stop_all_queues(dev);
342 * Now delete all active aggregation sessions.
346 list_for_each_entry_rcu(sta, &local->sta_list, list) {
347 if (sta->sdata == sdata)
348 ieee80211_sta_tear_down_BA_sessions(sdata,
355 * Remove all stations associated with this interface.
357 * This must be done before calling ops->remove_interface()
358 * because otherwise we can later invoke ops->sta_notify()
359 * whenever the STAs are removed, and that invalidates driver
360 * assumptions about always getting a vif pointer that is valid
361 * (because if we remove a STA after ops->remove_interface()
362 * the driver will have removed the vif info already!)
364 * We could relax this and only unlink the stations from the
365 * hash table and list but keep them on a per-sdata list that
366 * will be inserted back again when the interface is brought
367 * up again, but I don't currently see a use case for that,
368 * except with WDS which gets a STA entry created when it is
371 sta_info_flush(local, sdata);
374 * Don't count this interface for promisc/allmulti while it
375 * is down. dev_mc_unsync() will invoke set_multicast_list
376 * on the master interface which will sync these down to the
377 * hardware as filter flags.
379 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
380 atomic_dec(&local->iff_allmultis);
382 if (sdata->flags & IEEE80211_SDATA_PROMISC)
383 atomic_dec(&local->iff_promiscs);
385 dev_mc_unsync(local->mdev, dev);
387 /* APs need special treatment */
388 if (sdata->vif.type == NL80211_IFTYPE_AP) {
389 struct ieee80211_sub_if_data *vlan, *tmp;
390 struct beacon_data *old_beacon = sdata->u.ap.beacon;
393 rcu_assign_pointer(sdata->u.ap.beacon, NULL);
397 /* down all dependent devices, that is VLANs */
398 list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans,
400 dev_close(vlan->dev);
401 WARN_ON(!list_empty(&sdata->u.ap.vlans));
406 switch (sdata->vif.type) {
407 case NL80211_IFTYPE_AP_VLAN:
408 list_del(&sdata->u.vlan.list);
409 /* no need to tell driver */
411 case NL80211_IFTYPE_MONITOR:
412 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
413 local->cooked_mntrs--;
418 if (local->monitors == 0) {
419 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
420 hw_reconf_flags |= IEEE80211_CONF_CHANGE_RADIOTAP;
423 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
424 local->fif_fcsfail--;
425 if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL)
426 local->fif_plcpfail--;
427 if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL)
428 local->fif_control--;
429 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS)
430 local->fif_other_bss--;
432 netif_addr_lock_bh(local->mdev);
433 ieee80211_configure_filter(local);
434 netif_addr_unlock_bh(local->mdev);
436 case NL80211_IFTYPE_STATION:
437 case NL80211_IFTYPE_ADHOC:
438 /* Announce that we are leaving the network. */
439 if (sdata->u.sta.state != IEEE80211_STA_MLME_DISABLED)
440 ieee80211_sta_deauthenticate(sdata,
441 WLAN_REASON_DEAUTH_LEAVING);
443 memset(sdata->u.sta.bssid, 0, ETH_ALEN);
444 del_timer_sync(&sdata->u.sta.timer);
446 * If the timer fired while we waited for it, it will have
447 * requeued the work. Now the work will be running again
448 * but will not rearm the timer again because it checks
449 * whether the interface is running, which, at this point,
452 cancel_work_sync(&sdata->u.sta.work);
454 * When we get here, the interface is marked down.
455 * Call synchronize_rcu() to wait for the RX path
456 * should it be using the interface and enqueuing
457 * frames at this very time on another CPU.
460 skb_queue_purge(&sdata->u.sta.skb_queue);
462 sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED;
463 kfree(sdata->u.sta.extra_ie);
464 sdata->u.sta.extra_ie = NULL;
465 sdata->u.sta.extra_ie_len = 0;
467 case NL80211_IFTYPE_MESH_POINT:
468 if (ieee80211_vif_is_mesh(&sdata->vif)) {
469 /* other_bss and allmulti are always set on mesh
471 local->fif_other_bss--;
472 atomic_dec(&local->iff_allmultis);
474 netif_addr_lock_bh(local->mdev);
475 ieee80211_configure_filter(local);
476 netif_addr_unlock_bh(local->mdev);
478 ieee80211_stop_mesh(sdata);
482 if (local->scan_sdata == sdata) {
483 if (!local->ops->hw_scan)
484 cancel_delayed_work_sync(&local->scan_work);
486 * The software scan can no longer run now, so we can
487 * clear out the scan_sdata reference. However, the
488 * hardware scan may still be running. The complete
489 * function must be prepared to handle a NULL value.
491 local->scan_sdata = NULL;
493 * The memory barrier guarantees that another CPU
494 * that is hardware-scanning will now see the fact
495 * that this interface is gone.
499 * If software scanning, complete the scan but since
500 * the scan_sdata is NULL already don't send out a
501 * scan event to userspace -- the scan is incomplete.
503 if (local->sw_scanning)
504 ieee80211_scan_completed(&local->hw);
507 conf.vif = &sdata->vif;
508 conf.type = sdata->vif.type;
509 conf.mac_addr = dev->dev_addr;
510 /* disable all keys for as long as this netdev is down */
511 ieee80211_disable_keys(sdata);
512 local->ops->remove_interface(local_to_hw(local), &conf);
517 if (local->open_count == 0) {
518 if (netif_running(local->mdev))
519 dev_close(local->mdev);
521 if (local->ops->stop)
522 local->ops->stop(local_to_hw(local));
524 ieee80211_led_radio(local, 0);
526 flush_workqueue(local->hw.workqueue);
528 tasklet_disable(&local->tx_pending_tasklet);
529 tasklet_disable(&local->tasklet);
531 /* no reconfiguring after stop! */
535 /* do after stop to avoid reconfiguring when we stop anyway */
537 ieee80211_hw_config(local, hw_reconf_flags);
542 static void ieee80211_set_multicast_list(struct net_device *dev)
544 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
545 struct ieee80211_local *local = sdata->local;
546 int allmulti, promisc, sdata_allmulti, sdata_promisc;
548 allmulti = !!(dev->flags & IFF_ALLMULTI);
549 promisc = !!(dev->flags & IFF_PROMISC);
550 sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI);
551 sdata_promisc = !!(sdata->flags & IEEE80211_SDATA_PROMISC);
553 if (allmulti != sdata_allmulti) {
554 if (dev->flags & IFF_ALLMULTI)
555 atomic_inc(&local->iff_allmultis);
557 atomic_dec(&local->iff_allmultis);
558 sdata->flags ^= IEEE80211_SDATA_ALLMULTI;
561 if (promisc != sdata_promisc) {
562 if (dev->flags & IFF_PROMISC)
563 atomic_inc(&local->iff_promiscs);
565 atomic_dec(&local->iff_promiscs);
566 sdata->flags ^= IEEE80211_SDATA_PROMISC;
569 dev_mc_sync(local->mdev, dev);
572 static void ieee80211_if_setup(struct net_device *dev)
575 dev->hard_start_xmit = ieee80211_subif_start_xmit;
576 dev->wireless_handlers = &ieee80211_iw_handler_def;
577 dev->set_multicast_list = ieee80211_set_multicast_list;
578 dev->change_mtu = ieee80211_change_mtu;
579 dev->open = ieee80211_open;
580 dev->stop = ieee80211_stop;
581 dev->destructor = free_netdev;
582 /* we will validate the address ourselves in ->open */
583 dev->validate_addr = NULL;
586 * Called when the netdev is removed or, by the code below, before
587 * the interface type changes.
589 static void ieee80211_teardown_sdata(struct net_device *dev)
591 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
592 struct ieee80211_local *local = sdata->local;
593 struct beacon_data *beacon;
598 /* free extra data */
599 ieee80211_free_keys(sdata);
601 ieee80211_debugfs_remove_netdev(sdata);
603 for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
604 __skb_queue_purge(&sdata->fragments[i].skb_list);
605 sdata->fragment_next = 0;
607 switch (sdata->vif.type) {
608 case NL80211_IFTYPE_AP:
609 beacon = sdata->u.ap.beacon;
610 rcu_assign_pointer(sdata->u.ap.beacon, NULL);
614 while ((skb = skb_dequeue(&sdata->u.ap.ps_bc_buf))) {
615 local->total_ps_buffered--;
620 case NL80211_IFTYPE_MESH_POINT:
621 if (ieee80211_vif_is_mesh(&sdata->vif))
622 mesh_rmc_free(sdata);
624 case NL80211_IFTYPE_STATION:
625 case NL80211_IFTYPE_ADHOC:
626 kfree(sdata->u.sta.extra_ie);
627 kfree(sdata->u.sta.assocreq_ies);
628 kfree(sdata->u.sta.assocresp_ies);
629 kfree_skb(sdata->u.sta.probe_resp);
631 case NL80211_IFTYPE_WDS:
632 case NL80211_IFTYPE_AP_VLAN:
633 case NL80211_IFTYPE_MONITOR:
635 case NL80211_IFTYPE_UNSPECIFIED:
636 case __NL80211_IFTYPE_AFTER_LAST:
641 flushed = sta_info_flush(local, sdata);
646 * Helper function to initialise an interface to a specific type.
648 static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
649 enum nl80211_iftype type)
651 /* clear type-dependent union */
652 memset(&sdata->u, 0, sizeof(sdata->u));
654 /* and set some type-dependent values */
655 sdata->vif.type = type;
656 sdata->dev->hard_start_xmit = ieee80211_subif_start_xmit;
657 sdata->wdev.iftype = type;
659 /* only monitor differs */
660 sdata->dev->type = ARPHRD_ETHER;
663 case NL80211_IFTYPE_AP:
664 skb_queue_head_init(&sdata->u.ap.ps_bc_buf);
665 INIT_LIST_HEAD(&sdata->u.ap.vlans);
667 case NL80211_IFTYPE_STATION:
668 case NL80211_IFTYPE_ADHOC:
669 ieee80211_sta_setup_sdata(sdata);
671 case NL80211_IFTYPE_MESH_POINT:
672 if (ieee80211_vif_is_mesh(&sdata->vif))
673 ieee80211_mesh_init_sdata(sdata);
675 case NL80211_IFTYPE_MONITOR:
676 sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
677 sdata->dev->hard_start_xmit = ieee80211_monitor_start_xmit;
678 sdata->u.mntr_flags = MONITOR_FLAG_CONTROL |
679 MONITOR_FLAG_OTHER_BSS;
681 case NL80211_IFTYPE_WDS:
682 case NL80211_IFTYPE_AP_VLAN:
684 case NL80211_IFTYPE_UNSPECIFIED:
685 case __NL80211_IFTYPE_AFTER_LAST:
690 ieee80211_debugfs_add_netdev(sdata);
693 int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
694 enum nl80211_iftype type)
698 if (type == sdata->vif.type)
701 /* Setting ad-hoc mode on non-IBSS channel is not supported. */
702 if (sdata->local->oper_channel->flags & IEEE80211_CHAN_NO_IBSS)
706 * We could, here, on changes between IBSS/STA/MESH modes,
707 * invoke an MLME function instead that disassociates etc.
708 * and goes into the requested mode.
711 if (netif_running(sdata->dev))
714 /* Purge and reset type-dependent state. */
715 ieee80211_teardown_sdata(sdata->dev);
716 ieee80211_setup_sdata(sdata, type);
718 /* reset some values that shouldn't be kept across type changes */
719 sdata->vif.bss_conf.basic_rates =
720 ieee80211_mandatory_rates(sdata->local,
721 sdata->local->hw.conf.channel->band);
722 sdata->drop_unencrypted = 0;
727 int ieee80211_if_add(struct ieee80211_local *local, const char *name,
728 struct net_device **new_dev, enum nl80211_iftype type,
729 struct vif_params *params)
731 struct net_device *ndev;
732 struct ieee80211_sub_if_data *sdata = NULL;
737 ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size,
738 name, ieee80211_if_setup);
742 ndev->needed_headroom = local->tx_headroom +
743 4*6 /* four MAC addresses */
744 + 2 + 2 + 2 + 2 /* ctl, dur, seq, qos */
746 + 8 /* rfc1042/bridge tunnel */
747 - ETH_HLEN /* ethernet hard_header_len */
748 + IEEE80211_ENCRYPT_HEADROOM;
749 ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM;
751 ret = dev_alloc_name(ndev, ndev->name);
755 memcpy(ndev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
756 SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy));
758 /* don't use IEEE80211_DEV_TO_SUB_IF because it checks too much */
759 sdata = netdev_priv(ndev);
760 ndev->ieee80211_ptr = &sdata->wdev;
762 /* initialise type-independent data */
763 sdata->wdev.wiphy = local->hw.wiphy;
764 sdata->local = local;
767 for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
768 skb_queue_head_init(&sdata->fragments[i].skb_list);
770 INIT_LIST_HEAD(&sdata->key_list);
772 sdata->force_unicast_rateidx = -1;
773 sdata->max_ratectrl_rateidx = -1;
775 /* setup type-dependent data */
776 ieee80211_setup_sdata(sdata, type);
778 ret = register_netdevice(ndev);
782 ndev->uninit = ieee80211_teardown_sdata;
784 if (ieee80211_vif_is_mesh(&sdata->vif) &&
785 params && params->mesh_id_len)
786 ieee80211_sdata_set_mesh_id(sdata,
790 list_add_tail_rcu(&sdata->list, &local->interfaces);
802 void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata)
806 list_del_rcu(&sdata->list);
808 unregister_netdevice(sdata->dev);
812 * Remove all interfaces, may only be called at hardware unregistration
813 * time because it doesn't do RCU-safe list removals.
815 void ieee80211_remove_interfaces(struct ieee80211_local *local)
817 struct ieee80211_sub_if_data *sdata, *tmp;
821 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
822 list_del(&sdata->list);
823 unregister_netdevice(sdata->dev);