2 * mac80211 configuration hooks for cfg80211
4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
6 * This file is GPLv2 as found in COPYING.
9 #include <linux/ieee80211.h>
10 #include <linux/nl80211.h>
11 #include <linux/rtnetlink.h>
12 #include <linux/slab.h>
13 #include <net/net_namespace.h>
14 #include <linux/rcupdate.h>
15 #include <linux/if_ether.h>
16 #include <net/cfg80211.h>
17 #include "ieee80211_i.h"
18 #include "driver-ops.h"
23 static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, char *name,
24 enum nl80211_iftype type,
26 struct vif_params *params)
28 struct ieee80211_local *local = wiphy_priv(wiphy);
29 struct wireless_dev *wdev;
30 struct ieee80211_sub_if_data *sdata;
33 err = ieee80211_if_add(local, name, &wdev, type, params);
37 if (type == NL80211_IFTYPE_MONITOR && flags) {
38 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
39 sdata->u.mntr_flags = *flags;
45 static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
47 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
52 static int ieee80211_change_iface(struct wiphy *wiphy,
53 struct net_device *dev,
54 enum nl80211_iftype type, u32 *flags,
55 struct vif_params *params)
57 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
60 ret = ieee80211_if_change_type(sdata, type);
64 if (type == NL80211_IFTYPE_AP_VLAN &&
65 params && params->use_4addr == 0)
66 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
67 else if (type == NL80211_IFTYPE_STATION &&
68 params && params->use_4addr >= 0)
69 sdata->u.mgd.use_4addr = params->use_4addr;
71 if (sdata->vif.type == NL80211_IFTYPE_MONITOR && flags) {
72 struct ieee80211_local *local = sdata->local;
74 if (ieee80211_sdata_running(sdata)) {
76 * Prohibit MONITOR_FLAG_COOK_FRAMES to be
77 * changed while the interface is up.
78 * Else we would need to add a lot of cruft
79 * to update everything:
80 * cooked_mntrs, monitor and all fif_* counters
81 * reconfigure hardware
83 if ((*flags & MONITOR_FLAG_COOK_FRAMES) !=
84 (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES))
87 ieee80211_adjust_monitor_flags(sdata, -1);
88 sdata->u.mntr_flags = *flags;
89 ieee80211_adjust_monitor_flags(sdata, 1);
91 ieee80211_configure_filter(local);
94 * Because the interface is down, ieee80211_do_stop
95 * and ieee80211_do_open take care of "everything"
96 * mentioned in the comment above.
98 sdata->u.mntr_flags = *flags;
105 static int ieee80211_start_p2p_device(struct wiphy *wiphy,
106 struct wireless_dev *wdev)
108 return ieee80211_do_open(wdev, true);
111 static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
112 struct wireless_dev *wdev)
114 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
117 static int ieee80211_set_noack_map(struct wiphy *wiphy,
118 struct net_device *dev,
121 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
123 sdata->noack_map = noack_map;
127 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
128 u8 key_idx, bool pairwise, const u8 *mac_addr,
129 struct key_params *params)
131 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
132 struct sta_info *sta = NULL;
133 struct ieee80211_key *key;
136 if (!ieee80211_sdata_running(sdata))
139 /* reject WEP and TKIP keys if WEP failed to initialize */
140 switch (params->cipher) {
141 case WLAN_CIPHER_SUITE_WEP40:
142 case WLAN_CIPHER_SUITE_TKIP:
143 case WLAN_CIPHER_SUITE_WEP104:
144 if (IS_ERR(sdata->local->wep_tx_tfm))
151 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
152 params->key, params->seq_len, params->seq);
157 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
159 mutex_lock(&sdata->local->sta_mtx);
162 if (ieee80211_vif_is_mesh(&sdata->vif))
163 sta = sta_info_get(sdata, mac_addr);
165 sta = sta_info_get_bss(sdata, mac_addr);
167 ieee80211_key_free(sdata->local, key);
173 err = ieee80211_key_link(key, sdata, sta);
175 ieee80211_key_free(sdata->local, key);
178 mutex_unlock(&sdata->local->sta_mtx);
183 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
184 u8 key_idx, bool pairwise, const u8 *mac_addr)
186 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
187 struct ieee80211_local *local = sdata->local;
188 struct sta_info *sta;
189 struct ieee80211_key *key = NULL;
192 mutex_lock(&local->sta_mtx);
193 mutex_lock(&local->key_mtx);
198 sta = sta_info_get_bss(sdata, mac_addr);
203 key = key_mtx_dereference(local, sta->ptk);
205 key = key_mtx_dereference(local, sta->gtk[key_idx]);
207 key = key_mtx_dereference(local, sdata->keys[key_idx]);
214 __ieee80211_key_free(key);
218 mutex_unlock(&local->key_mtx);
219 mutex_unlock(&local->sta_mtx);
224 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
225 u8 key_idx, bool pairwise, const u8 *mac_addr,
227 void (*callback)(void *cookie,
228 struct key_params *params))
230 struct ieee80211_sub_if_data *sdata;
231 struct sta_info *sta = NULL;
233 struct key_params params;
234 struct ieee80211_key *key = NULL;
240 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
245 sta = sta_info_get_bss(sdata, mac_addr);
250 key = rcu_dereference(sta->ptk);
251 else if (key_idx < NUM_DEFAULT_KEYS)
252 key = rcu_dereference(sta->gtk[key_idx]);
254 key = rcu_dereference(sdata->keys[key_idx]);
259 memset(¶ms, 0, sizeof(params));
261 params.cipher = key->conf.cipher;
263 switch (key->conf.cipher) {
264 case WLAN_CIPHER_SUITE_TKIP:
265 iv32 = key->u.tkip.tx.iv32;
266 iv16 = key->u.tkip.tx.iv16;
268 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
269 drv_get_tkip_seq(sdata->local,
270 key->conf.hw_key_idx,
273 seq[0] = iv16 & 0xff;
274 seq[1] = (iv16 >> 8) & 0xff;
275 seq[2] = iv32 & 0xff;
276 seq[3] = (iv32 >> 8) & 0xff;
277 seq[4] = (iv32 >> 16) & 0xff;
278 seq[5] = (iv32 >> 24) & 0xff;
282 case WLAN_CIPHER_SUITE_CCMP:
283 pn64 = atomic64_read(&key->u.ccmp.tx_pn);
293 case WLAN_CIPHER_SUITE_AES_CMAC:
294 pn64 = atomic64_read(&key->u.aes_cmac.tx_pn);
306 params.key = key->conf.key;
307 params.key_len = key->conf.keylen;
309 callback(cookie, ¶ms);
317 static int ieee80211_config_default_key(struct wiphy *wiphy,
318 struct net_device *dev,
319 u8 key_idx, bool uni,
322 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
324 ieee80211_set_default_key(sdata, key_idx, uni, multi);
329 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
330 struct net_device *dev,
333 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
335 ieee80211_set_default_mgmt_key(sdata, key_idx);
340 static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx)
342 if (!(rate->flags & RATE_INFO_FLAGS_MCS)) {
343 struct ieee80211_supported_band *sband;
344 sband = sta->local->hw.wiphy->bands[
345 sta->local->oper_channel->band];
346 rate->legacy = sband->bitrates[idx].bitrate;
351 void sta_set_rate_info_tx(struct sta_info *sta,
352 const struct ieee80211_tx_rate *rate,
353 struct rate_info *rinfo)
356 if (rate->flags & IEEE80211_TX_RC_MCS)
357 rinfo->flags |= RATE_INFO_FLAGS_MCS;
358 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
359 rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
360 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
361 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
362 rate_idx_to_bitrate(rinfo, sta, rate->idx);
365 static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
367 struct ieee80211_sub_if_data *sdata = sta->sdata;
368 struct ieee80211_local *local = sdata->local;
369 struct timespec uptime;
371 sinfo->generation = sdata->local->sta_generation;
373 sinfo->filled = STATION_INFO_INACTIVE_TIME |
374 STATION_INFO_RX_BYTES |
375 STATION_INFO_TX_BYTES |
376 STATION_INFO_RX_PACKETS |
377 STATION_INFO_TX_PACKETS |
378 STATION_INFO_TX_RETRIES |
379 STATION_INFO_TX_FAILED |
380 STATION_INFO_TX_BITRATE |
381 STATION_INFO_RX_BITRATE |
382 STATION_INFO_RX_DROP_MISC |
383 STATION_INFO_BSS_PARAM |
384 STATION_INFO_CONNECTED_TIME |
385 STATION_INFO_STA_FLAGS |
386 STATION_INFO_BEACON_LOSS_COUNT;
388 do_posix_clock_monotonic_gettime(&uptime);
389 sinfo->connected_time = uptime.tv_sec - sta->last_connected;
391 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
392 sinfo->rx_bytes = sta->rx_bytes;
393 sinfo->tx_bytes = sta->tx_bytes;
394 sinfo->rx_packets = sta->rx_packets;
395 sinfo->tx_packets = sta->tx_packets;
396 sinfo->tx_retries = sta->tx_retry_count;
397 sinfo->tx_failed = sta->tx_retry_failed;
398 sinfo->rx_dropped_misc = sta->rx_dropped;
399 sinfo->beacon_loss_count = sta->beacon_loss_count;
401 if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
402 (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
403 sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG;
404 if (!local->ops->get_rssi ||
405 drv_get_rssi(local, sdata, &sta->sta, &sinfo->signal))
406 sinfo->signal = (s8)sta->last_signal;
407 sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
410 sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
412 sinfo->rxrate.flags = 0;
413 if (sta->last_rx_rate_flag & RX_FLAG_HT)
414 sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS;
415 if (sta->last_rx_rate_flag & RX_FLAG_40MHZ)
416 sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
417 if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI)
418 sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
419 rate_idx_to_bitrate(&sinfo->rxrate, sta, sta->last_rx_rate_idx);
421 if (ieee80211_vif_is_mesh(&sdata->vif)) {
422 #ifdef CONFIG_MAC80211_MESH
423 sinfo->filled |= STATION_INFO_LLID |
425 STATION_INFO_PLINK_STATE;
427 sinfo->llid = le16_to_cpu(sta->llid);
428 sinfo->plid = le16_to_cpu(sta->plid);
429 sinfo->plink_state = sta->plink_state;
430 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
431 sinfo->filled |= STATION_INFO_T_OFFSET;
432 sinfo->t_offset = sta->t_offset;
437 sinfo->bss_param.flags = 0;
438 if (sdata->vif.bss_conf.use_cts_prot)
439 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;
440 if (sdata->vif.bss_conf.use_short_preamble)
441 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
442 if (sdata->vif.bss_conf.use_short_slot)
443 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
444 sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period;
445 sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int;
447 sinfo->sta_flags.set = 0;
448 sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
449 BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
450 BIT(NL80211_STA_FLAG_WME) |
451 BIT(NL80211_STA_FLAG_MFP) |
452 BIT(NL80211_STA_FLAG_AUTHENTICATED) |
453 BIT(NL80211_STA_FLAG_TDLS_PEER);
454 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
455 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED);
456 if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE))
457 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE);
458 if (test_sta_flag(sta, WLAN_STA_WME))
459 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME);
460 if (test_sta_flag(sta, WLAN_STA_MFP))
461 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP);
462 if (test_sta_flag(sta, WLAN_STA_AUTH))
463 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED);
464 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER))
465 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER);
468 static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
469 "rx_packets", "rx_bytes", "wep_weak_iv_count",
470 "rx_duplicates", "rx_fragments", "rx_dropped",
471 "tx_packets", "tx_bytes", "tx_fragments",
472 "tx_filtered", "tx_retry_failed", "tx_retries",
473 "beacon_loss", "sta_state", "txrate", "rxrate", "signal",
474 "channel", "noise", "ch_time", "ch_time_busy",
475 "ch_time_ext_busy", "ch_time_rx", "ch_time_tx"
477 #define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats)
479 static int ieee80211_get_et_sset_count(struct wiphy *wiphy,
480 struct net_device *dev,
483 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
486 if (sset == ETH_SS_STATS)
489 rv += drv_get_et_sset_count(sdata, sset);
496 static void ieee80211_get_et_stats(struct wiphy *wiphy,
497 struct net_device *dev,
498 struct ethtool_stats *stats,
501 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
502 struct sta_info *sta;
503 struct ieee80211_local *local = sdata->local;
504 struct station_info sinfo;
505 struct survey_info survey;
507 #define STA_STATS_SURVEY_LEN 7
509 memset(data, 0, sizeof(u64) * STA_STATS_LEN);
511 #define ADD_STA_STATS(sta) \
513 data[i++] += sta->rx_packets; \
514 data[i++] += sta->rx_bytes; \
515 data[i++] += sta->wep_weak_iv_count; \
516 data[i++] += sta->num_duplicates; \
517 data[i++] += sta->rx_fragments; \
518 data[i++] += sta->rx_dropped; \
520 data[i++] += sta->tx_packets; \
521 data[i++] += sta->tx_bytes; \
522 data[i++] += sta->tx_fragments; \
523 data[i++] += sta->tx_filtered_count; \
524 data[i++] += sta->tx_retry_failed; \
525 data[i++] += sta->tx_retry_count; \
526 data[i++] += sta->beacon_loss_count; \
529 /* For Managed stations, find the single station based on BSSID
530 * and use that. For interface types, iterate through all available
531 * stations and add stats for any station that is assigned to this
535 mutex_lock(&local->sta_mtx);
537 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
538 sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid);
540 if (!(sta && !WARN_ON(sta->sdata->dev != dev)))
546 data[i++] = sta->sta_state;
549 sta_set_sinfo(sta, &sinfo);
551 if (sinfo.filled & STATION_INFO_TX_BITRATE)
553 cfg80211_calculate_bitrate(&sinfo.txrate);
555 if (sinfo.filled & STATION_INFO_RX_BITRATE)
557 cfg80211_calculate_bitrate(&sinfo.rxrate);
560 if (sinfo.filled & STATION_INFO_SIGNAL_AVG)
561 data[i] = (u8)sinfo.signal_avg;
564 list_for_each_entry(sta, &local->sta_list, list) {
565 /* Make sure this station belongs to the proper dev */
566 if (sta->sdata->dev != dev)
575 i = STA_STATS_LEN - STA_STATS_SURVEY_LEN;
576 /* Get survey stats for current channel */
580 if (drv_get_survey(local, q, &survey) != 0) {
585 if (survey.channel &&
586 (local->oper_channel->center_freq ==
587 survey.channel->center_freq))
593 data[i++] = survey.channel->center_freq;
596 if (survey.filled & SURVEY_INFO_NOISE_DBM)
597 data[i++] = (u8)survey.noise;
600 if (survey.filled & SURVEY_INFO_CHANNEL_TIME)
601 data[i++] = survey.channel_time;
604 if (survey.filled & SURVEY_INFO_CHANNEL_TIME_BUSY)
605 data[i++] = survey.channel_time_busy;
608 if (survey.filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY)
609 data[i++] = survey.channel_time_ext_busy;
612 if (survey.filled & SURVEY_INFO_CHANNEL_TIME_RX)
613 data[i++] = survey.channel_time_rx;
616 if (survey.filled & SURVEY_INFO_CHANNEL_TIME_TX)
617 data[i++] = survey.channel_time_tx;
621 mutex_unlock(&local->sta_mtx);
623 if (WARN_ON(i != STA_STATS_LEN))
626 drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN]));
629 static void ieee80211_get_et_strings(struct wiphy *wiphy,
630 struct net_device *dev,
633 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
634 int sz_sta_stats = 0;
636 if (sset == ETH_SS_STATS) {
637 sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
638 memcpy(data, *ieee80211_gstrings_sta_stats, sz_sta_stats);
640 drv_get_et_strings(sdata, sset, &(data[sz_sta_stats]));
643 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
644 int idx, u8 *mac, struct station_info *sinfo)
646 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
647 struct ieee80211_local *local = sdata->local;
648 struct sta_info *sta;
651 mutex_lock(&local->sta_mtx);
653 sta = sta_info_get_by_idx(sdata, idx);
656 memcpy(mac, sta->sta.addr, ETH_ALEN);
657 sta_set_sinfo(sta, sinfo);
660 mutex_unlock(&local->sta_mtx);
665 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
666 int idx, struct survey_info *survey)
668 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
670 return drv_get_survey(local, idx, survey);
673 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
674 u8 *mac, struct station_info *sinfo)
676 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
677 struct ieee80211_local *local = sdata->local;
678 struct sta_info *sta;
681 mutex_lock(&local->sta_mtx);
683 sta = sta_info_get_bss(sdata, mac);
686 sta_set_sinfo(sta, sinfo);
689 mutex_unlock(&local->sta_mtx);
694 static int ieee80211_set_channel(struct wiphy *wiphy,
695 struct net_device *netdev,
696 struct ieee80211_channel *chan,
697 enum nl80211_channel_type channel_type)
699 struct ieee80211_local *local = wiphy_priv(wiphy);
700 struct ieee80211_sub_if_data *sdata = NULL;
703 sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
705 switch (ieee80211_get_channel_mode(local, NULL)) {
706 case CHAN_MODE_HOPPING:
708 case CHAN_MODE_FIXED:
709 if (local->oper_channel != chan ||
710 (!sdata && local->_oper_channel_type != channel_type))
712 if (!sdata && local->_oper_channel_type == channel_type)
715 case CHAN_MODE_UNDEFINED:
719 if (!ieee80211_set_channel_type(local, sdata, channel_type))
722 local->oper_channel = chan;
724 /* auto-detects changes */
725 ieee80211_hw_config(local, 0);
730 static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
731 struct ieee80211_channel *chan,
732 enum nl80211_channel_type channel_type)
734 return ieee80211_set_channel(wiphy, NULL, chan, channel_type);
737 static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
738 const u8 *resp, size_t resp_len)
740 struct probe_resp *new, *old;
742 if (!resp || !resp_len)
745 old = rtnl_dereference(sdata->u.ap.probe_resp);
747 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
752 memcpy(new->data, resp, resp_len);
754 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
756 kfree_rcu(old, rcu_head);
761 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
762 struct cfg80211_beacon_data *params)
764 struct beacon_data *new, *old;
765 int new_head_len, new_tail_len;
767 u32 changed = BSS_CHANGED_BEACON;
769 old = rtnl_dereference(sdata->u.ap.beacon);
771 /* Need to have a beacon head if we don't have one yet */
772 if (!params->head && !old)
775 /* new or old head? */
777 new_head_len = params->head_len;
779 new_head_len = old->head_len;
781 /* new or old tail? */
782 if (params->tail || !old)
783 /* params->tail_len will be zero for !params->tail */
784 new_tail_len = params->tail_len;
786 new_tail_len = old->tail_len;
788 size = sizeof(*new) + new_head_len + new_tail_len;
790 new = kzalloc(size, GFP_KERNEL);
794 /* start filling the new info now */
797 * pointers go into the block we allocated,
798 * memory is | beacon_data | head | tail |
800 new->head = ((u8 *) new) + sizeof(*new);
801 new->tail = new->head + new_head_len;
802 new->head_len = new_head_len;
803 new->tail_len = new_tail_len;
807 memcpy(new->head, params->head, new_head_len);
809 memcpy(new->head, old->head, new_head_len);
811 /* copy in optional tail */
813 memcpy(new->tail, params->tail, new_tail_len);
816 memcpy(new->tail, old->tail, new_tail_len);
818 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
819 params->probe_resp_len);
823 changed |= BSS_CHANGED_AP_PROBE_RESP;
825 rcu_assign_pointer(sdata->u.ap.beacon, new);
828 kfree_rcu(old, rcu_head);
833 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
834 struct cfg80211_ap_settings *params)
836 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
837 struct beacon_data *old;
838 struct ieee80211_sub_if_data *vlan;
839 u32 changed = BSS_CHANGED_BEACON_INT |
840 BSS_CHANGED_BEACON_ENABLED |
845 old = rtnl_dereference(sdata->u.ap.beacon);
849 err = ieee80211_set_channel(wiphy, dev, params->channel,
850 params->channel_type);
855 * Apply control port protocol, this allows us to
856 * not encrypt dynamic WEP control frames.
858 sdata->control_port_protocol = params->crypto.control_port_ethertype;
859 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
860 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
861 vlan->control_port_protocol =
862 params->crypto.control_port_ethertype;
863 vlan->control_port_no_encrypt =
864 params->crypto.control_port_no_encrypt;
867 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
868 sdata->vif.bss_conf.dtim_period = params->dtim_period;
870 sdata->vif.bss_conf.ssid_len = params->ssid_len;
871 if (params->ssid_len)
872 memcpy(sdata->vif.bss_conf.ssid, params->ssid,
874 sdata->vif.bss_conf.hidden_ssid =
875 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
877 err = ieee80211_assign_beacon(sdata, ¶ms->beacon);
882 ieee80211_bss_info_change_notify(sdata, changed);
884 netif_carrier_on(dev);
885 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
886 netif_carrier_on(vlan->dev);
891 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
892 struct cfg80211_beacon_data *params)
894 struct ieee80211_sub_if_data *sdata;
895 struct beacon_data *old;
898 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
900 old = rtnl_dereference(sdata->u.ap.beacon);
904 err = ieee80211_assign_beacon(sdata, params);
907 ieee80211_bss_info_change_notify(sdata, err);
911 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
913 struct ieee80211_sub_if_data *sdata, *vlan;
914 struct beacon_data *old;
916 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
918 old = rtnl_dereference(sdata->u.ap.beacon);
922 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
923 netif_carrier_off(vlan->dev);
924 netif_carrier_off(dev);
926 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
928 kfree_rcu(old, rcu_head);
930 sta_info_flush(sdata->local, sdata);
931 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
936 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
937 struct iapp_layer2_update {
938 u8 da[ETH_ALEN]; /* broadcast */
939 u8 sa[ETH_ALEN]; /* STA addr */
947 static void ieee80211_send_layer2_update(struct sta_info *sta)
949 struct iapp_layer2_update *msg;
952 /* Send Level 2 Update Frame to update forwarding tables in layer 2
955 skb = dev_alloc_skb(sizeof(*msg));
958 msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
960 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
961 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
963 eth_broadcast_addr(msg->da);
964 memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
967 msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
968 msg->control = 0xaf; /* XID response lsb.1111F101.
969 * F=0 (no poll command; unsolicited frame) */
970 msg->xid_info[0] = 0x81; /* XID format identifier */
971 msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
972 msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
974 skb->dev = sta->sdata->dev;
975 skb->protocol = eth_type_trans(skb, sta->sdata->dev);
976 memset(skb->cb, 0, sizeof(skb->cb));
980 static int sta_apply_parameters(struct ieee80211_local *local,
981 struct sta_info *sta,
982 struct station_parameters *params)
987 struct ieee80211_supported_band *sband;
988 struct ieee80211_sub_if_data *sdata = sta->sdata;
991 sband = local->hw.wiphy->bands[local->oper_channel->band];
993 mask = params->sta_flags_mask;
994 set = params->sta_flags_set;
997 * In mesh mode, we can clear AUTHENTICATED flag but must
998 * also make ASSOCIATED follow appropriately for the driver
999 * API. See also below, after AUTHORIZED changes.
1001 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
1002 /* cfg80211 should not allow this in non-mesh modes */
1003 if (WARN_ON(!ieee80211_vif_is_mesh(&sdata->vif)))
1006 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1007 !test_sta_flag(sta, WLAN_STA_AUTH)) {
1008 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1011 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1017 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1018 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
1019 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1020 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1021 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1026 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
1027 /* cfg80211 should not allow this in non-mesh modes */
1028 if (WARN_ON(!ieee80211_vif_is_mesh(&sdata->vif)))
1031 if (!(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
1032 test_sta_flag(sta, WLAN_STA_AUTH)) {
1033 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1036 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
1043 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
1044 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
1045 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1047 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1050 if (mask & BIT(NL80211_STA_FLAG_WME)) {
1051 if (set & BIT(NL80211_STA_FLAG_WME)) {
1052 set_sta_flag(sta, WLAN_STA_WME);
1053 sta->sta.wme = true;
1055 clear_sta_flag(sta, WLAN_STA_WME);
1056 sta->sta.wme = false;
1060 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
1061 if (set & BIT(NL80211_STA_FLAG_MFP))
1062 set_sta_flag(sta, WLAN_STA_MFP);
1064 clear_sta_flag(sta, WLAN_STA_MFP);
1067 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
1068 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1069 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1071 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
1074 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1075 sta->sta.uapsd_queues = params->uapsd_queues;
1076 sta->sta.max_sp = params->max_sp;
1080 * cfg80211 validates this (1-2007) and allows setting the AID
1081 * only when creating a new station entry
1084 sta->sta.aid = params->aid;
1087 * FIXME: updating the following information is racy when this
1088 * function is called from ieee80211_change_station().
1089 * However, all this information should be static so
1090 * maybe we should just reject attemps to change it.
1093 if (params->listen_interval >= 0)
1094 sta->listen_interval = params->listen_interval;
1096 if (params->supported_rates) {
1099 for (i = 0; i < params->supported_rates_len; i++) {
1100 int rate = (params->supported_rates[i] & 0x7f) * 5;
1101 for (j = 0; j < sband->n_bitrates; j++) {
1102 if (sband->bitrates[j].bitrate == rate)
1106 sta->sta.supp_rates[local->oper_channel->band] = rates;
1109 if (params->ht_capa)
1110 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1114 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1115 #ifdef CONFIG_MAC80211_MESH
1116 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED)
1117 switch (params->plink_state) {
1118 case NL80211_PLINK_LISTEN:
1119 case NL80211_PLINK_ESTAB:
1120 case NL80211_PLINK_BLOCKED:
1121 sta->plink_state = params->plink_state;
1128 switch (params->plink_action) {
1129 case PLINK_ACTION_OPEN:
1130 mesh_plink_open(sta);
1132 case PLINK_ACTION_BLOCK:
1133 mesh_plink_block(sta);
1142 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1143 u8 *mac, struct station_parameters *params)
1145 struct ieee80211_local *local = wiphy_priv(wiphy);
1146 struct sta_info *sta;
1147 struct ieee80211_sub_if_data *sdata;
1152 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1154 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1155 sdata->vif.type != NL80211_IFTYPE_AP)
1158 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1160 if (ether_addr_equal(mac, sdata->vif.addr))
1163 if (is_multicast_ether_addr(mac))
1166 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
1170 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1171 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1173 err = sta_apply_parameters(local, sta, params);
1175 sta_info_free(local, sta);
1180 * for TDLS, rate control should be initialized only when supported
1183 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER))
1184 rate_control_rate_init(sta);
1186 layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
1187 sdata->vif.type == NL80211_IFTYPE_AP;
1189 err = sta_info_insert_rcu(sta);
1196 ieee80211_send_layer2_update(sta);
1203 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1206 struct ieee80211_local *local = wiphy_priv(wiphy);
1207 struct ieee80211_sub_if_data *sdata;
1209 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1212 return sta_info_destroy_addr_bss(sdata, mac);
1214 sta_info_flush(local, sdata);
1218 static int ieee80211_change_station(struct wiphy *wiphy,
1219 struct net_device *dev,
1221 struct station_parameters *params)
1223 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1224 struct ieee80211_local *local = wiphy_priv(wiphy);
1225 struct sta_info *sta;
1226 struct ieee80211_sub_if_data *vlansdata;
1229 mutex_lock(&local->sta_mtx);
1231 sta = sta_info_get_bss(sdata, mac);
1233 mutex_unlock(&local->sta_mtx);
1237 /* in station mode, supported rates are only valid with TDLS */
1238 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1239 params->supported_rates &&
1240 !test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1241 mutex_unlock(&local->sta_mtx);
1245 if (params->vlan && params->vlan != sta->sdata->dev) {
1246 bool prev_4addr = false;
1247 bool new_4addr = false;
1249 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1251 if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1252 vlansdata->vif.type != NL80211_IFTYPE_AP) {
1253 mutex_unlock(&local->sta_mtx);
1257 if (params->vlan->ieee80211_ptr->use_4addr) {
1258 if (vlansdata->u.vlan.sta) {
1259 mutex_unlock(&local->sta_mtx);
1263 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
1267 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
1268 sta->sdata->u.vlan.sta) {
1269 rcu_assign_pointer(sta->sdata->u.vlan.sta, NULL);
1273 sta->sdata = vlansdata;
1275 if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
1276 prev_4addr != new_4addr) {
1278 atomic_dec(&sta->sdata->bss->num_mcast_sta);
1280 atomic_inc(&sta->sdata->bss->num_mcast_sta);
1283 ieee80211_send_layer2_update(sta);
1286 err = sta_apply_parameters(local, sta, params);
1288 mutex_unlock(&local->sta_mtx);
1292 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates)
1293 rate_control_rate_init(sta);
1295 mutex_unlock(&local->sta_mtx);
1297 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1298 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1299 ieee80211_recalc_ps(local, -1);
1300 ieee80211_recalc_ps_vif(sdata);
1305 #ifdef CONFIG_MAC80211_MESH
1306 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
1307 u8 *dst, u8 *next_hop)
1309 struct ieee80211_sub_if_data *sdata;
1310 struct mesh_path *mpath;
1311 struct sta_info *sta;
1314 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1317 sta = sta_info_get(sdata, next_hop);
1323 err = mesh_path_add(dst, sdata);
1329 mpath = mesh_path_lookup(dst, sdata);
1334 mesh_path_fix_nexthop(mpath, sta);
1340 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
1343 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1346 return mesh_path_del(dst, sdata);
1348 mesh_path_flush_by_iface(sdata);
1352 static int ieee80211_change_mpath(struct wiphy *wiphy,
1353 struct net_device *dev,
1354 u8 *dst, u8 *next_hop)
1356 struct ieee80211_sub_if_data *sdata;
1357 struct mesh_path *mpath;
1358 struct sta_info *sta;
1360 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1364 sta = sta_info_get(sdata, next_hop);
1370 mpath = mesh_path_lookup(dst, sdata);
1376 mesh_path_fix_nexthop(mpath, sta);
1382 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
1383 struct mpath_info *pinfo)
1385 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
1388 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
1390 memset(next_hop, 0, ETH_ALEN);
1392 memset(pinfo, 0, sizeof(*pinfo));
1394 pinfo->generation = mesh_paths_generation;
1396 pinfo->filled = MPATH_INFO_FRAME_QLEN |
1399 MPATH_INFO_EXPTIME |
1400 MPATH_INFO_DISCOVERY_TIMEOUT |
1401 MPATH_INFO_DISCOVERY_RETRIES |
1404 pinfo->frame_qlen = mpath->frame_queue.qlen;
1405 pinfo->sn = mpath->sn;
1406 pinfo->metric = mpath->metric;
1407 if (time_before(jiffies, mpath->exp_time))
1408 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
1409 pinfo->discovery_timeout =
1410 jiffies_to_msecs(mpath->discovery_timeout);
1411 pinfo->discovery_retries = mpath->discovery_retries;
1412 if (mpath->flags & MESH_PATH_ACTIVE)
1413 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
1414 if (mpath->flags & MESH_PATH_RESOLVING)
1415 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
1416 if (mpath->flags & MESH_PATH_SN_VALID)
1417 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
1418 if (mpath->flags & MESH_PATH_FIXED)
1419 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
1420 if (mpath->flags & MESH_PATH_RESOLVED)
1421 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
1424 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
1425 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
1428 struct ieee80211_sub_if_data *sdata;
1429 struct mesh_path *mpath;
1431 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1434 mpath = mesh_path_lookup(dst, sdata);
1439 memcpy(dst, mpath->dst, ETH_ALEN);
1440 mpath_set_pinfo(mpath, next_hop, pinfo);
1445 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1446 int idx, u8 *dst, u8 *next_hop,
1447 struct mpath_info *pinfo)
1449 struct ieee80211_sub_if_data *sdata;
1450 struct mesh_path *mpath;
1452 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1455 mpath = mesh_path_lookup_by_idx(idx, sdata);
1460 memcpy(dst, mpath->dst, ETH_ALEN);
1461 mpath_set_pinfo(mpath, next_hop, pinfo);
1466 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
1467 struct net_device *dev,
1468 struct mesh_config *conf)
1470 struct ieee80211_sub_if_data *sdata;
1471 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1473 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1477 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
1479 return (mask >> (parm-1)) & 0x1;
1482 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
1483 const struct mesh_setup *setup)
1487 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
1488 struct ieee80211_sub_if_data, u.mesh);
1490 /* allocate information elements */
1494 if (setup->ie_len) {
1495 new_ie = kmemdup(setup->ie, setup->ie_len,
1500 ifmsh->ie_len = setup->ie_len;
1504 /* now copy the rest of the setup parameters */
1505 ifmsh->mesh_id_len = setup->mesh_id_len;
1506 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
1507 ifmsh->mesh_sp_id = setup->sync_method;
1508 ifmsh->mesh_pp_id = setup->path_sel_proto;
1509 ifmsh->mesh_pm_id = setup->path_metric;
1510 ifmsh->security = IEEE80211_MESH_SEC_NONE;
1511 if (setup->is_authenticated)
1512 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
1513 if (setup->is_secure)
1514 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
1516 /* mcast rate setting in Mesh Node */
1517 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
1518 sizeof(setup->mcast_rate));
1523 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
1524 struct net_device *dev, u32 mask,
1525 const struct mesh_config *nconf)
1527 struct mesh_config *conf;
1528 struct ieee80211_sub_if_data *sdata;
1529 struct ieee80211_if_mesh *ifmsh;
1531 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1532 ifmsh = &sdata->u.mesh;
1534 /* Set the config options which we are interested in setting */
1535 conf = &(sdata->u.mesh.mshcfg);
1536 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
1537 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
1538 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
1539 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
1540 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
1541 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
1542 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
1543 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
1544 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
1545 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
1546 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
1547 conf->dot11MeshTTL = nconf->dot11MeshTTL;
1548 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
1549 conf->element_ttl = nconf->element_ttl;
1550 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
1551 conf->auto_open_plinks = nconf->auto_open_plinks;
1552 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
1553 conf->dot11MeshNbrOffsetMaxNeighbor =
1554 nconf->dot11MeshNbrOffsetMaxNeighbor;
1555 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1556 conf->dot11MeshHWMPmaxPREQretries =
1557 nconf->dot11MeshHWMPmaxPREQretries;
1558 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1559 conf->path_refresh_time = nconf->path_refresh_time;
1560 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1561 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1562 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1563 conf->dot11MeshHWMPactivePathTimeout =
1564 nconf->dot11MeshHWMPactivePathTimeout;
1565 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1566 conf->dot11MeshHWMPpreqMinInterval =
1567 nconf->dot11MeshHWMPpreqMinInterval;
1568 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
1569 conf->dot11MeshHWMPperrMinInterval =
1570 nconf->dot11MeshHWMPperrMinInterval;
1571 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1573 conf->dot11MeshHWMPnetDiameterTraversalTime =
1574 nconf->dot11MeshHWMPnetDiameterTraversalTime;
1575 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
1576 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
1577 ieee80211_mesh_root_setup(ifmsh);
1579 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
1580 /* our current gate announcement implementation rides on root
1581 * announcements, so require this ifmsh to also be a root node
1583 if (nconf->dot11MeshGateAnnouncementProtocol &&
1584 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
1585 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
1586 ieee80211_mesh_root_setup(ifmsh);
1588 conf->dot11MeshGateAnnouncementProtocol =
1589 nconf->dot11MeshGateAnnouncementProtocol;
1591 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
1592 conf->dot11MeshHWMPRannInterval =
1593 nconf->dot11MeshHWMPRannInterval;
1594 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
1595 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
1596 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
1597 /* our RSSI threshold implementation is supported only for
1598 * devices that report signal in dBm.
1600 if (!(sdata->local->hw.flags & IEEE80211_HW_SIGNAL_DBM))
1602 conf->rssi_threshold = nconf->rssi_threshold;
1604 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
1605 conf->ht_opmode = nconf->ht_opmode;
1606 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
1607 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
1609 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
1610 conf->dot11MeshHWMPactivePathToRootTimeout =
1611 nconf->dot11MeshHWMPactivePathToRootTimeout;
1612 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
1613 conf->dot11MeshHWMProotInterval =
1614 nconf->dot11MeshHWMProotInterval;
1615 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
1616 conf->dot11MeshHWMPconfirmationInterval =
1617 nconf->dot11MeshHWMPconfirmationInterval;
1621 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1622 const struct mesh_config *conf,
1623 const struct mesh_setup *setup)
1625 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1626 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
1629 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
1630 err = copy_mesh_setup(ifmsh, setup);
1634 err = ieee80211_set_channel(wiphy, dev, setup->channel,
1635 setup->channel_type);
1639 ieee80211_start_mesh(sdata);
1644 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
1646 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1648 ieee80211_stop_mesh(sdata);
1654 static int ieee80211_change_bss(struct wiphy *wiphy,
1655 struct net_device *dev,
1656 struct bss_parameters *params)
1658 struct ieee80211_sub_if_data *sdata;
1661 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1663 if (params->use_cts_prot >= 0) {
1664 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
1665 changed |= BSS_CHANGED_ERP_CTS_PROT;
1667 if (params->use_short_preamble >= 0) {
1668 sdata->vif.bss_conf.use_short_preamble =
1669 params->use_short_preamble;
1670 changed |= BSS_CHANGED_ERP_PREAMBLE;
1673 if (!sdata->vif.bss_conf.use_short_slot &&
1674 sdata->local->oper_channel->band == IEEE80211_BAND_5GHZ) {
1675 sdata->vif.bss_conf.use_short_slot = true;
1676 changed |= BSS_CHANGED_ERP_SLOT;
1679 if (params->use_short_slot_time >= 0) {
1680 sdata->vif.bss_conf.use_short_slot =
1681 params->use_short_slot_time;
1682 changed |= BSS_CHANGED_ERP_SLOT;
1685 if (params->basic_rates) {
1688 struct ieee80211_local *local = wiphy_priv(wiphy);
1689 struct ieee80211_supported_band *sband =
1690 wiphy->bands[local->oper_channel->band];
1692 for (i = 0; i < params->basic_rates_len; i++) {
1693 int rate = (params->basic_rates[i] & 0x7f) * 5;
1694 for (j = 0; j < sband->n_bitrates; j++) {
1695 if (sband->bitrates[j].bitrate == rate)
1699 sdata->vif.bss_conf.basic_rates = rates;
1700 changed |= BSS_CHANGED_BASIC_RATES;
1703 if (params->ap_isolate >= 0) {
1704 if (params->ap_isolate)
1705 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1707 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1710 if (params->ht_opmode >= 0) {
1711 sdata->vif.bss_conf.ht_operation_mode =
1712 (u16) params->ht_opmode;
1713 changed |= BSS_CHANGED_HT;
1716 ieee80211_bss_info_change_notify(sdata, changed);
1721 static int ieee80211_set_txq_params(struct wiphy *wiphy,
1722 struct net_device *dev,
1723 struct ieee80211_txq_params *params)
1725 struct ieee80211_local *local = wiphy_priv(wiphy);
1726 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1727 struct ieee80211_tx_queue_params p;
1729 if (!local->ops->conf_tx)
1732 if (local->hw.queues < IEEE80211_NUM_ACS)
1735 memset(&p, 0, sizeof(p));
1736 p.aifs = params->aifs;
1737 p.cw_max = params->cwmax;
1738 p.cw_min = params->cwmin;
1739 p.txop = params->txop;
1742 * Setting tx queue params disables u-apsd because it's only
1743 * called in master mode.
1747 sdata->tx_conf[params->ac] = p;
1748 if (drv_conf_tx(local, sdata, params->ac, &p)) {
1749 wiphy_debug(local->hw.wiphy,
1750 "failed to set TX queue parameters for AC %d\n",
1755 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
1761 static int ieee80211_suspend(struct wiphy *wiphy,
1762 struct cfg80211_wowlan *wowlan)
1764 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
1767 static int ieee80211_resume(struct wiphy *wiphy)
1769 return __ieee80211_resume(wiphy_priv(wiphy));
1772 #define ieee80211_suspend NULL
1773 #define ieee80211_resume NULL
1776 static int ieee80211_scan(struct wiphy *wiphy,
1777 struct cfg80211_scan_request *req)
1779 struct ieee80211_sub_if_data *sdata;
1781 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
1783 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
1784 case NL80211_IFTYPE_STATION:
1785 case NL80211_IFTYPE_ADHOC:
1786 case NL80211_IFTYPE_MESH_POINT:
1787 case NL80211_IFTYPE_P2P_CLIENT:
1788 case NL80211_IFTYPE_P2P_DEVICE:
1790 case NL80211_IFTYPE_P2P_GO:
1791 if (sdata->local->ops->hw_scan)
1794 * FIXME: implement NoA while scanning in software,
1795 * for now fall through to allow scanning only when
1796 * beaconing hasn't been configured yet
1798 case NL80211_IFTYPE_AP:
1799 if (sdata->u.ap.beacon)
1806 return ieee80211_request_scan(sdata, req);
1810 ieee80211_sched_scan_start(struct wiphy *wiphy,
1811 struct net_device *dev,
1812 struct cfg80211_sched_scan_request *req)
1814 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1816 if (!sdata->local->ops->sched_scan_start)
1819 return ieee80211_request_sched_scan_start(sdata, req);
1823 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
1825 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1827 if (!sdata->local->ops->sched_scan_stop)
1830 return ieee80211_request_sched_scan_stop(sdata);
1833 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1834 struct cfg80211_auth_request *req)
1836 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
1839 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1840 struct cfg80211_assoc_request *req)
1842 struct ieee80211_local *local = wiphy_priv(wiphy);
1843 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1845 switch (ieee80211_get_channel_mode(local, sdata)) {
1846 case CHAN_MODE_HOPPING:
1848 case CHAN_MODE_FIXED:
1849 if (local->oper_channel == req->bss->channel)
1852 case CHAN_MODE_UNDEFINED:
1856 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
1859 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
1860 struct cfg80211_deauth_request *req)
1862 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
1865 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
1866 struct cfg80211_disassoc_request *req)
1868 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
1871 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
1872 struct cfg80211_ibss_params *params)
1874 struct ieee80211_local *local = wiphy_priv(wiphy);
1875 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1877 switch (ieee80211_get_channel_mode(local, sdata)) {
1878 case CHAN_MODE_HOPPING:
1880 case CHAN_MODE_FIXED:
1881 if (!params->channel_fixed)
1883 if (local->oper_channel == params->channel)
1886 case CHAN_MODE_UNDEFINED:
1890 return ieee80211_ibss_join(sdata, params);
1893 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
1895 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1897 return ieee80211_ibss_leave(sdata);
1900 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1902 struct ieee80211_local *local = wiphy_priv(wiphy);
1905 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1906 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
1912 if (changed & WIPHY_PARAM_COVERAGE_CLASS) {
1913 err = drv_set_coverage_class(local, wiphy->coverage_class);
1919 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1920 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
1926 if (changed & WIPHY_PARAM_RETRY_SHORT)
1927 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
1928 if (changed & WIPHY_PARAM_RETRY_LONG)
1929 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
1931 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
1932 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
1937 static int ieee80211_set_tx_power(struct wiphy *wiphy,
1938 enum nl80211_tx_power_setting type, int mbm)
1940 struct ieee80211_local *local = wiphy_priv(wiphy);
1941 struct ieee80211_channel *chan = local->oper_channel;
1945 case NL80211_TX_POWER_AUTOMATIC:
1946 local->user_power_level = -1;
1948 case NL80211_TX_POWER_LIMITED:
1949 if (mbm < 0 || (mbm % 100))
1951 local->user_power_level = MBM_TO_DBM(mbm);
1953 case NL80211_TX_POWER_FIXED:
1954 if (mbm < 0 || (mbm % 100))
1956 /* TODO: move to cfg80211 when it knows the channel */
1957 if (MBM_TO_DBM(mbm) > chan->max_power)
1959 local->user_power_level = MBM_TO_DBM(mbm);
1963 ieee80211_hw_config(local, changes);
1968 static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm)
1970 struct ieee80211_local *local = wiphy_priv(wiphy);
1972 *dbm = local->hw.conf.power_level;
1977 static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
1980 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1982 memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
1987 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
1989 struct ieee80211_local *local = wiphy_priv(wiphy);
1991 drv_rfkill_poll(local);
1994 #ifdef CONFIG_NL80211_TESTMODE
1995 static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len)
1997 struct ieee80211_local *local = wiphy_priv(wiphy);
1999 if (!local->ops->testmode_cmd)
2002 return local->ops->testmode_cmd(&local->hw, data, len);
2005 static int ieee80211_testmode_dump(struct wiphy *wiphy,
2006 struct sk_buff *skb,
2007 struct netlink_callback *cb,
2008 void *data, int len)
2010 struct ieee80211_local *local = wiphy_priv(wiphy);
2012 if (!local->ops->testmode_dump)
2015 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
2019 int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
2020 enum ieee80211_smps_mode smps_mode)
2023 enum ieee80211_smps_mode old_req;
2026 lockdep_assert_held(&sdata->u.mgd.mtx);
2028 old_req = sdata->u.mgd.req_smps;
2029 sdata->u.mgd.req_smps = smps_mode;
2031 if (old_req == smps_mode &&
2032 smps_mode != IEEE80211_SMPS_AUTOMATIC)
2036 * If not associated, or current association is not an HT
2037 * association, there's no need to send an action frame.
2039 if (!sdata->u.mgd.associated ||
2040 sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) {
2041 mutex_lock(&sdata->local->iflist_mtx);
2042 ieee80211_recalc_smps(sdata->local);
2043 mutex_unlock(&sdata->local->iflist_mtx);
2047 ap = sdata->u.mgd.associated->bssid;
2049 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
2050 if (sdata->u.mgd.powersave)
2051 smps_mode = IEEE80211_SMPS_DYNAMIC;
2053 smps_mode = IEEE80211_SMPS_OFF;
2056 /* send SM PS frame to AP */
2057 err = ieee80211_send_smps_action(sdata, smps_mode,
2060 sdata->u.mgd.req_smps = old_req;
2065 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2066 bool enabled, int timeout)
2068 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2069 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2071 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2074 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
2077 if (enabled == sdata->u.mgd.powersave &&
2078 timeout == local->dynamic_ps_forced_timeout)
2081 sdata->u.mgd.powersave = enabled;
2082 local->dynamic_ps_forced_timeout = timeout;
2084 /* no change, but if automatic follow powersave */
2085 mutex_lock(&sdata->u.mgd.mtx);
2086 __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps);
2087 mutex_unlock(&sdata->u.mgd.mtx);
2089 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
2090 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
2092 ieee80211_recalc_ps(local, -1);
2093 ieee80211_recalc_ps_vif(sdata);
2098 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
2099 struct net_device *dev,
2100 s32 rssi_thold, u32 rssi_hyst)
2102 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2103 struct ieee80211_vif *vif = &sdata->vif;
2104 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
2106 if (rssi_thold == bss_conf->cqm_rssi_thold &&
2107 rssi_hyst == bss_conf->cqm_rssi_hyst)
2110 bss_conf->cqm_rssi_thold = rssi_thold;
2111 bss_conf->cqm_rssi_hyst = rssi_hyst;
2113 /* tell the driver upon association, unless already associated */
2114 if (sdata->u.mgd.associated &&
2115 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
2116 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
2121 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
2122 struct net_device *dev,
2124 const struct cfg80211_bitrate_mask *mask)
2126 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2127 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2130 if (!ieee80211_sdata_running(sdata))
2133 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
2134 ret = drv_set_bitrate_mask(local, sdata, mask);
2139 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
2140 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
2141 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
2142 sizeof(mask->control[i].mcs));
2148 static int ieee80211_start_roc_work(struct ieee80211_local *local,
2149 struct ieee80211_sub_if_data *sdata,
2150 struct ieee80211_channel *channel,
2151 enum nl80211_channel_type channel_type,
2152 unsigned int duration, u64 *cookie,
2153 struct sk_buff *txskb)
2155 struct ieee80211_roc_work *roc, *tmp;
2156 bool queued = false;
2159 lockdep_assert_held(&local->mtx);
2161 roc = kzalloc(sizeof(*roc), GFP_KERNEL);
2165 roc->chan = channel;
2166 roc->chan_type = channel_type;
2167 roc->duration = duration;
2168 roc->req_duration = duration;
2170 roc->mgmt_tx_cookie = (unsigned long)txskb;
2172 INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work);
2173 INIT_LIST_HEAD(&roc->dependents);
2175 /* if there's one pending or we're scanning, queue this one */
2176 if (!list_empty(&local->roc_list) || local->scanning)
2177 goto out_check_combine;
2179 /* if not HW assist, just queue & schedule work */
2180 if (!local->ops->remain_on_channel) {
2181 ieee80211_queue_delayed_work(&local->hw, &roc->work, 0);
2185 /* otherwise actually kick it off here (for error handling) */
2188 * If the duration is zero, then the driver
2189 * wouldn't actually do anything. Set it to
2192 * TODO: cancel the off-channel operation
2193 * when we get the SKB's TX status and
2194 * the wait time was zero before.
2199 ret = drv_remain_on_channel(local, channel, channel_type, duration);
2205 roc->started = true;
2209 list_for_each_entry(tmp, &local->roc_list, list) {
2210 if (tmp->chan != channel || tmp->chan_type != channel_type)
2214 * Extend this ROC if possible:
2216 * If it hasn't started yet, just increase the duration
2217 * and add the new one to the list of dependents.
2219 if (!tmp->started) {
2220 list_add_tail(&roc->list, &tmp->dependents);
2221 tmp->duration = max(tmp->duration, roc->duration);
2226 /* If it has already started, it's more difficult ... */
2227 if (local->ops->remain_on_channel) {
2228 unsigned long j = jiffies;
2231 * In the offloaded ROC case, if it hasn't begun, add
2232 * this new one to the dependent list to be handled
2233 * when the the master one begins. If it has begun,
2234 * check that there's still a minimum time left and
2235 * if so, start this one, transmitting the frame, but
2236 * add it to the list directly after this one with a
2237 * a reduced time so we'll ask the driver to execute
2238 * it right after finishing the previous one, in the
2239 * hope that it'll also be executed right afterwards,
2240 * effectively extending the old one.
2241 * If there's no minimum time left, just add it to the
2244 if (!tmp->hw_begun) {
2245 list_add_tail(&roc->list, &tmp->dependents);
2250 if (time_before(j + IEEE80211_ROC_MIN_LEFT,
2251 tmp->hw_start_time +
2252 msecs_to_jiffies(tmp->duration))) {
2255 ieee80211_handle_roc_started(roc);
2257 new_dur = roc->duration -
2258 jiffies_to_msecs(tmp->hw_start_time +
2264 /* add right after tmp */
2265 list_add(&roc->list, &tmp->list);
2267 list_add_tail(&roc->list,
2272 } else if (del_timer_sync(&tmp->work.timer)) {
2273 unsigned long new_end;
2276 * In the software ROC case, cancel the timer, if
2277 * that fails then the finish work is already
2278 * queued/pending and thus we queue the new ROC
2279 * normally, if that succeeds then we can extend
2280 * the timer duration and TX the frame (if any.)
2283 list_add_tail(&roc->list, &tmp->dependents);
2286 new_end = jiffies + msecs_to_jiffies(roc->duration);
2288 /* ok, it was started & we canceled timer */
2289 if (time_after(new_end, tmp->work.timer.expires))
2290 mod_timer(&tmp->work.timer, new_end);
2292 add_timer(&tmp->work.timer);
2294 ieee80211_handle_roc_started(roc);
2301 list_add_tail(&roc->list, &local->roc_list);
2304 * cookie is either the roc (for normal roc)
2305 * or the SKB (for mgmt TX)
2308 *cookie = (unsigned long)txskb;
2310 *cookie = (unsigned long)roc;
2315 static int ieee80211_remain_on_channel(struct wiphy *wiphy,
2316 struct wireless_dev *wdev,
2317 struct ieee80211_channel *chan,
2318 enum nl80211_channel_type channel_type,
2319 unsigned int duration,
2322 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2323 struct ieee80211_local *local = sdata->local;
2326 mutex_lock(&local->mtx);
2327 ret = ieee80211_start_roc_work(local, sdata, chan, channel_type,
2328 duration, cookie, NULL);
2329 mutex_unlock(&local->mtx);
2334 static int ieee80211_cancel_roc(struct ieee80211_local *local,
2335 u64 cookie, bool mgmt_tx)
2337 struct ieee80211_roc_work *roc, *tmp, *found = NULL;
2340 mutex_lock(&local->mtx);
2341 list_for_each_entry_safe(roc, tmp, &local->roc_list, list) {
2342 struct ieee80211_roc_work *dep, *tmp2;
2344 list_for_each_entry_safe(dep, tmp2, &roc->dependents, list) {
2345 if (!mgmt_tx && (unsigned long)dep != cookie)
2347 else if (mgmt_tx && dep->mgmt_tx_cookie != cookie)
2349 /* found dependent item -- just remove it */
2350 list_del(&dep->list);
2351 mutex_unlock(&local->mtx);
2353 ieee80211_roc_notify_destroy(dep);
2357 if (!mgmt_tx && (unsigned long)roc != cookie)
2359 else if (mgmt_tx && roc->mgmt_tx_cookie != cookie)
2367 mutex_unlock(&local->mtx);
2372 * We found the item to cancel, so do that. Note that it
2373 * may have dependents, which we also cancel (and send
2374 * the expired signal for.) Not doing so would be quite
2375 * tricky here, but we may need to fix it later.
2378 if (local->ops->remain_on_channel) {
2379 if (found->started) {
2380 ret = drv_cancel_remain_on_channel(local);
2381 if (WARN_ON_ONCE(ret)) {
2382 mutex_unlock(&local->mtx);
2387 list_del(&found->list);
2390 ieee80211_start_next_roc(local);
2391 mutex_unlock(&local->mtx);
2393 ieee80211_roc_notify_destroy(found);
2395 /* work may be pending so use it all the time */
2396 found->abort = true;
2397 ieee80211_queue_delayed_work(&local->hw, &found->work, 0);
2399 mutex_unlock(&local->mtx);
2401 /* work will clean up etc */
2402 flush_delayed_work(&found->work);
2408 static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
2409 struct wireless_dev *wdev,
2412 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2413 struct ieee80211_local *local = sdata->local;
2415 return ieee80211_cancel_roc(local, cookie, false);
2418 static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
2419 struct ieee80211_channel *chan, bool offchan,
2420 enum nl80211_channel_type channel_type,
2421 bool channel_type_valid, unsigned int wait,
2422 const u8 *buf, size_t len, bool no_cck,
2423 bool dont_wait_for_ack, u64 *cookie)
2425 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2426 struct ieee80211_local *local = sdata->local;
2427 struct sk_buff *skb;
2428 struct sta_info *sta;
2429 const struct ieee80211_mgmt *mgmt = (void *)buf;
2430 bool need_offchan = false;
2434 if (dont_wait_for_ack)
2435 flags = IEEE80211_TX_CTL_NO_ACK;
2437 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
2438 IEEE80211_TX_CTL_REQ_TX_STATUS;
2441 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
2443 switch (sdata->vif.type) {
2444 case NL80211_IFTYPE_ADHOC:
2445 if (!sdata->vif.bss_conf.ibss_joined)
2446 need_offchan = true;
2448 #ifdef CONFIG_MAC80211_MESH
2449 case NL80211_IFTYPE_MESH_POINT:
2450 if (ieee80211_vif_is_mesh(&sdata->vif) &&
2451 !sdata->u.mesh.mesh_id_len)
2452 need_offchan = true;
2455 case NL80211_IFTYPE_AP:
2456 case NL80211_IFTYPE_AP_VLAN:
2457 case NL80211_IFTYPE_P2P_GO:
2458 if (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
2459 !ieee80211_vif_is_mesh(&sdata->vif) &&
2460 !rcu_access_pointer(sdata->bss->beacon))
2461 need_offchan = true;
2462 if (!ieee80211_is_action(mgmt->frame_control) ||
2463 mgmt->u.action.category == WLAN_CATEGORY_PUBLIC)
2466 sta = sta_info_get(sdata, mgmt->da);
2471 case NL80211_IFTYPE_STATION:
2472 case NL80211_IFTYPE_P2P_CLIENT:
2473 if (!sdata->u.mgd.associated)
2474 need_offchan = true;
2476 case NL80211_IFTYPE_P2P_DEVICE:
2477 need_offchan = true;
2483 mutex_lock(&local->mtx);
2485 /* Check if the operating channel is the requested channel */
2486 if (!need_offchan) {
2487 need_offchan = chan != local->oper_channel;
2488 if (channel_type_valid &&
2489 channel_type != local->_oper_channel_type)
2490 need_offchan = true;
2493 if (need_offchan && !offchan) {
2498 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len);
2503 skb_reserve(skb, local->hw.extra_tx_headroom);
2505 memcpy(skb_put(skb, len), buf, len);
2507 IEEE80211_SKB_CB(skb)->flags = flags;
2509 skb->dev = sdata->dev;
2511 if (!need_offchan) {
2512 *cookie = (unsigned long) skb;
2513 ieee80211_tx_skb(sdata, skb);
2518 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
2519 if (local->hw.flags & IEEE80211_HW_QUEUE_CONTROL)
2520 IEEE80211_SKB_CB(skb)->hw_queue =
2521 local->hw.offchannel_tx_hw_queue;
2523 /* This will handle all kinds of coalescing and immediate TX */
2524 ret = ieee80211_start_roc_work(local, sdata, chan, channel_type,
2529 mutex_unlock(&local->mtx);
2533 static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
2534 struct wireless_dev *wdev,
2537 struct ieee80211_local *local = wiphy_priv(wiphy);
2539 return ieee80211_cancel_roc(local, cookie, true);
2542 static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
2543 struct wireless_dev *wdev,
2544 u16 frame_type, bool reg)
2546 struct ieee80211_local *local = wiphy_priv(wiphy);
2547 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2549 switch (frame_type) {
2550 case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH:
2551 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
2552 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
2555 ifibss->auth_frame_registrations++;
2557 ifibss->auth_frame_registrations--;
2560 case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ:
2562 local->probe_req_reg++;
2564 local->probe_req_reg--;
2566 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
2573 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
2575 struct ieee80211_local *local = wiphy_priv(wiphy);
2580 return drv_set_antenna(local, tx_ant, rx_ant);
2583 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
2585 struct ieee80211_local *local = wiphy_priv(wiphy);
2587 return drv_get_antenna(local, tx_ant, rx_ant);
2590 static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx)
2592 struct ieee80211_local *local = wiphy_priv(wiphy);
2594 return drv_set_ringparam(local, tx, rx);
2597 static void ieee80211_get_ringparam(struct wiphy *wiphy,
2598 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
2600 struct ieee80211_local *local = wiphy_priv(wiphy);
2602 drv_get_ringparam(local, tx, tx_max, rx, rx_max);
2605 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
2606 struct net_device *dev,
2607 struct cfg80211_gtk_rekey_data *data)
2609 struct ieee80211_local *local = wiphy_priv(wiphy);
2610 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2612 if (!local->ops->set_rekey_data)
2615 drv_set_rekey_data(local, sdata, data);
2620 static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb)
2622 u8 *pos = (void *)skb_put(skb, 7);
2624 *pos++ = WLAN_EID_EXT_CAPABILITY;
2625 *pos++ = 5; /* len */
2630 *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED;
2633 static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata)
2635 struct ieee80211_local *local = sdata->local;
2639 if (local->oper_channel->band != IEEE80211_BAND_2GHZ)
2642 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
2643 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
2644 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
2645 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
2650 static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr,
2651 u8 *peer, u8 *bssid)
2653 struct ieee80211_tdls_lnkie *lnkid;
2655 lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie));
2657 lnkid->ie_type = WLAN_EID_LINK_ID;
2658 lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2;
2660 memcpy(lnkid->bssid, bssid, ETH_ALEN);
2661 memcpy(lnkid->init_sta, src_addr, ETH_ALEN);
2662 memcpy(lnkid->resp_sta, peer, ETH_ALEN);
2666 ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2667 u8 *peer, u8 action_code, u8 dialog_token,
2668 u16 status_code, struct sk_buff *skb)
2670 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2671 struct ieee80211_local *local = sdata->local;
2672 struct ieee80211_tdls_data *tf;
2674 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
2676 memcpy(tf->da, peer, ETH_ALEN);
2677 memcpy(tf->sa, sdata->vif.addr, ETH_ALEN);
2678 tf->ether_type = cpu_to_be16(ETH_P_TDLS);
2679 tf->payload_type = WLAN_TDLS_SNAP_RFTYPE;
2681 switch (action_code) {
2682 case WLAN_TDLS_SETUP_REQUEST:
2683 tf->category = WLAN_CATEGORY_TDLS;
2684 tf->action_code = WLAN_TDLS_SETUP_REQUEST;
2686 skb_put(skb, sizeof(tf->u.setup_req));
2687 tf->u.setup_req.dialog_token = dialog_token;
2688 tf->u.setup_req.capability =
2689 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2691 ieee80211_add_srates_ie(sdata, skb, false,
2692 local->oper_channel->band);
2693 ieee80211_add_ext_srates_ie(sdata, skb, false,
2694 local->oper_channel->band);
2695 ieee80211_tdls_add_ext_capab(skb);
2697 case WLAN_TDLS_SETUP_RESPONSE:
2698 tf->category = WLAN_CATEGORY_TDLS;
2699 tf->action_code = WLAN_TDLS_SETUP_RESPONSE;
2701 skb_put(skb, sizeof(tf->u.setup_resp));
2702 tf->u.setup_resp.status_code = cpu_to_le16(status_code);
2703 tf->u.setup_resp.dialog_token = dialog_token;
2704 tf->u.setup_resp.capability =
2705 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2707 ieee80211_add_srates_ie(sdata, skb, false,
2708 local->oper_channel->band);
2709 ieee80211_add_ext_srates_ie(sdata, skb, false,
2710 local->oper_channel->band);
2711 ieee80211_tdls_add_ext_capab(skb);
2713 case WLAN_TDLS_SETUP_CONFIRM:
2714 tf->category = WLAN_CATEGORY_TDLS;
2715 tf->action_code = WLAN_TDLS_SETUP_CONFIRM;
2717 skb_put(skb, sizeof(tf->u.setup_cfm));
2718 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
2719 tf->u.setup_cfm.dialog_token = dialog_token;
2721 case WLAN_TDLS_TEARDOWN:
2722 tf->category = WLAN_CATEGORY_TDLS;
2723 tf->action_code = WLAN_TDLS_TEARDOWN;
2725 skb_put(skb, sizeof(tf->u.teardown));
2726 tf->u.teardown.reason_code = cpu_to_le16(status_code);
2728 case WLAN_TDLS_DISCOVERY_REQUEST:
2729 tf->category = WLAN_CATEGORY_TDLS;
2730 tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST;
2732 skb_put(skb, sizeof(tf->u.discover_req));
2733 tf->u.discover_req.dialog_token = dialog_token;
2743 ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
2744 u8 *peer, u8 action_code, u8 dialog_token,
2745 u16 status_code, struct sk_buff *skb)
2747 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2748 struct ieee80211_local *local = sdata->local;
2749 struct ieee80211_mgmt *mgmt;
2751 mgmt = (void *)skb_put(skb, 24);
2752 memset(mgmt, 0, 24);
2753 memcpy(mgmt->da, peer, ETH_ALEN);
2754 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
2755 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
2757 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2758 IEEE80211_STYPE_ACTION);
2760 switch (action_code) {
2761 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2762 skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp));
2763 mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
2764 mgmt->u.action.u.tdls_discover_resp.action_code =
2765 WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
2766 mgmt->u.action.u.tdls_discover_resp.dialog_token =
2768 mgmt->u.action.u.tdls_discover_resp.capability =
2769 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2771 ieee80211_add_srates_ie(sdata, skb, false,
2772 local->oper_channel->band);
2773 ieee80211_add_ext_srates_ie(sdata, skb, false,
2774 local->oper_channel->band);
2775 ieee80211_tdls_add_ext_capab(skb);
2784 static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2785 u8 *peer, u8 action_code, u8 dialog_token,
2786 u16 status_code, const u8 *extra_ies,
2787 size_t extra_ies_len)
2789 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2790 struct ieee80211_local *local = sdata->local;
2791 struct ieee80211_tx_info *info;
2792 struct sk_buff *skb = NULL;
2796 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2799 /* make sure we are in managed mode, and associated */
2800 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
2801 !sdata->u.mgd.associated)
2804 tdls_dbg(sdata, "TDLS mgmt action %d peer %pM\n",
2807 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
2808 max(sizeof(struct ieee80211_mgmt),
2809 sizeof(struct ieee80211_tdls_data)) +
2810 50 + /* supported rates */
2813 sizeof(struct ieee80211_tdls_lnkie));
2817 info = IEEE80211_SKB_CB(skb);
2818 skb_reserve(skb, local->hw.extra_tx_headroom);
2820 switch (action_code) {
2821 case WLAN_TDLS_SETUP_REQUEST:
2822 case WLAN_TDLS_SETUP_RESPONSE:
2823 case WLAN_TDLS_SETUP_CONFIRM:
2824 case WLAN_TDLS_TEARDOWN:
2825 case WLAN_TDLS_DISCOVERY_REQUEST:
2826 ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer,
2827 action_code, dialog_token,
2829 send_direct = false;
2831 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2832 ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code,
2833 dialog_token, status_code,
2846 memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len);
2848 /* the TDLS link IE is always added last */
2849 switch (action_code) {
2850 case WLAN_TDLS_SETUP_REQUEST:
2851 case WLAN_TDLS_SETUP_CONFIRM:
2852 case WLAN_TDLS_TEARDOWN:
2853 case WLAN_TDLS_DISCOVERY_REQUEST:
2854 /* we are the initiator */
2855 ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer,
2856 sdata->u.mgd.bssid);
2858 case WLAN_TDLS_SETUP_RESPONSE:
2859 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2860 /* we are the responder */
2861 ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr,
2862 sdata->u.mgd.bssid);
2870 ieee80211_tx_skb(sdata, skb);
2875 * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise
2876 * we should default to AC_VI.
2878 switch (action_code) {
2879 case WLAN_TDLS_SETUP_REQUEST:
2880 case WLAN_TDLS_SETUP_RESPONSE:
2881 skb_set_queue_mapping(skb, IEEE80211_AC_BK);
2885 skb_set_queue_mapping(skb, IEEE80211_AC_VI);
2890 /* disable bottom halves when entering the Tx path */
2892 ret = ieee80211_subif_start_xmit(skb, dev);
2902 static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
2903 u8 *peer, enum nl80211_tdls_operation oper)
2905 struct sta_info *sta;
2906 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2908 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2911 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2914 tdls_dbg(sdata, "TDLS oper %d peer %pM\n", oper, peer);
2917 case NL80211_TDLS_ENABLE_LINK:
2919 sta = sta_info_get(sdata, peer);
2925 set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH);
2928 case NL80211_TDLS_DISABLE_LINK:
2929 return sta_info_destroy_addr(sdata, peer);
2930 case NL80211_TDLS_TEARDOWN:
2931 case NL80211_TDLS_SETUP:
2932 case NL80211_TDLS_DISCOVERY_REQ:
2933 /* We don't support in-driver setup/teardown/discovery */
2942 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
2943 const u8 *peer, u64 *cookie)
2945 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2946 struct ieee80211_local *local = sdata->local;
2947 struct ieee80211_qos_hdr *nullfunc;
2948 struct sk_buff *skb;
2949 int size = sizeof(*nullfunc);
2952 struct ieee80211_tx_info *info;
2953 struct sta_info *sta;
2956 sta = sta_info_get(sdata, peer);
2958 qos = test_sta_flag(sta, WLAN_STA_WME);
2966 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
2967 IEEE80211_STYPE_QOS_NULLFUNC |
2968 IEEE80211_FCTL_FROMDS);
2971 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
2972 IEEE80211_STYPE_NULLFUNC |
2973 IEEE80211_FCTL_FROMDS);
2976 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
2982 skb_reserve(skb, local->hw.extra_tx_headroom);
2984 nullfunc = (void *) skb_put(skb, size);
2985 nullfunc->frame_control = fc;
2986 nullfunc->duration_id = 0;
2987 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
2988 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
2989 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
2990 nullfunc->seq_ctrl = 0;
2992 info = IEEE80211_SKB_CB(skb);
2994 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
2995 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
2997 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
3000 nullfunc->qos_ctrl = cpu_to_le16(7);
3003 ieee80211_xmit(sdata, skb);
3006 *cookie = (unsigned long) skb;
3010 static struct ieee80211_channel *
3011 ieee80211_cfg_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
3012 enum nl80211_channel_type *type)
3014 struct ieee80211_local *local = wiphy_priv(wiphy);
3016 *type = local->_oper_channel_type;
3017 return local->oper_channel;
3021 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
3023 drv_set_wakeup(wiphy_priv(wiphy), enabled);
3027 struct cfg80211_ops mac80211_config_ops = {
3028 .add_virtual_intf = ieee80211_add_iface,
3029 .del_virtual_intf = ieee80211_del_iface,
3030 .change_virtual_intf = ieee80211_change_iface,
3031 .start_p2p_device = ieee80211_start_p2p_device,
3032 .stop_p2p_device = ieee80211_stop_p2p_device,
3033 .add_key = ieee80211_add_key,
3034 .del_key = ieee80211_del_key,
3035 .get_key = ieee80211_get_key,
3036 .set_default_key = ieee80211_config_default_key,
3037 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
3038 .start_ap = ieee80211_start_ap,
3039 .change_beacon = ieee80211_change_beacon,
3040 .stop_ap = ieee80211_stop_ap,
3041 .add_station = ieee80211_add_station,
3042 .del_station = ieee80211_del_station,
3043 .change_station = ieee80211_change_station,
3044 .get_station = ieee80211_get_station,
3045 .dump_station = ieee80211_dump_station,
3046 .dump_survey = ieee80211_dump_survey,
3047 #ifdef CONFIG_MAC80211_MESH
3048 .add_mpath = ieee80211_add_mpath,
3049 .del_mpath = ieee80211_del_mpath,
3050 .change_mpath = ieee80211_change_mpath,
3051 .get_mpath = ieee80211_get_mpath,
3052 .dump_mpath = ieee80211_dump_mpath,
3053 .update_mesh_config = ieee80211_update_mesh_config,
3054 .get_mesh_config = ieee80211_get_mesh_config,
3055 .join_mesh = ieee80211_join_mesh,
3056 .leave_mesh = ieee80211_leave_mesh,
3058 .change_bss = ieee80211_change_bss,
3059 .set_txq_params = ieee80211_set_txq_params,
3060 .set_monitor_channel = ieee80211_set_monitor_channel,
3061 .suspend = ieee80211_suspend,
3062 .resume = ieee80211_resume,
3063 .scan = ieee80211_scan,
3064 .sched_scan_start = ieee80211_sched_scan_start,
3065 .sched_scan_stop = ieee80211_sched_scan_stop,
3066 .auth = ieee80211_auth,
3067 .assoc = ieee80211_assoc,
3068 .deauth = ieee80211_deauth,
3069 .disassoc = ieee80211_disassoc,
3070 .join_ibss = ieee80211_join_ibss,
3071 .leave_ibss = ieee80211_leave_ibss,
3072 .set_wiphy_params = ieee80211_set_wiphy_params,
3073 .set_tx_power = ieee80211_set_tx_power,
3074 .get_tx_power = ieee80211_get_tx_power,
3075 .set_wds_peer = ieee80211_set_wds_peer,
3076 .rfkill_poll = ieee80211_rfkill_poll,
3077 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
3078 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
3079 .set_power_mgmt = ieee80211_set_power_mgmt,
3080 .set_bitrate_mask = ieee80211_set_bitrate_mask,
3081 .remain_on_channel = ieee80211_remain_on_channel,
3082 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
3083 .mgmt_tx = ieee80211_mgmt_tx,
3084 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
3085 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
3086 .mgmt_frame_register = ieee80211_mgmt_frame_register,
3087 .set_antenna = ieee80211_set_antenna,
3088 .get_antenna = ieee80211_get_antenna,
3089 .set_ringparam = ieee80211_set_ringparam,
3090 .get_ringparam = ieee80211_get_ringparam,
3091 .set_rekey_data = ieee80211_set_rekey_data,
3092 .tdls_oper = ieee80211_tdls_oper,
3093 .tdls_mgmt = ieee80211_tdls_mgmt,
3094 .probe_client = ieee80211_probe_client,
3095 .set_noack_map = ieee80211_set_noack_map,
3097 .set_wakeup = ieee80211_set_wakeup,
3099 .get_et_sset_count = ieee80211_get_et_sset_count,
3100 .get_et_stats = ieee80211_get_et_stats,
3101 .get_et_strings = ieee80211_get_et_strings,
3102 .get_channel = ieee80211_cfg_get_channel,