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
,
25 enum nl80211_iftype type
,
27 struct vif_params
*params
)
29 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
30 struct wireless_dev
*wdev
;
31 struct ieee80211_sub_if_data
*sdata
;
34 err
= ieee80211_if_add(local
, name
, &wdev
, type
, params
);
38 if (type
== NL80211_IFTYPE_MONITOR
&& flags
) {
39 sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
40 sdata
->u
.mntr_flags
= *flags
;
46 static int ieee80211_del_iface(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
48 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev
));
53 static int ieee80211_change_iface(struct wiphy
*wiphy
,
54 struct net_device
*dev
,
55 enum nl80211_iftype type
, u32
*flags
,
56 struct vif_params
*params
)
58 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
61 ret
= ieee80211_if_change_type(sdata
, type
);
65 if (type
== NL80211_IFTYPE_AP_VLAN
&&
66 params
&& params
->use_4addr
== 0)
67 RCU_INIT_POINTER(sdata
->u
.vlan
.sta
, NULL
);
68 else if (type
== NL80211_IFTYPE_STATION
&&
69 params
&& params
->use_4addr
>= 0)
70 sdata
->u
.mgd
.use_4addr
= params
->use_4addr
;
72 if (sdata
->vif
.type
== NL80211_IFTYPE_MONITOR
&& flags
) {
73 struct ieee80211_local
*local
= sdata
->local
;
75 if (ieee80211_sdata_running(sdata
)) {
76 u32 mask
= MONITOR_FLAG_COOK_FRAMES
|
80 * Prohibit MONITOR_FLAG_COOK_FRAMES and
81 * MONITOR_FLAG_ACTIVE to be changed while the
83 * Else we would need to add a lot of cruft
84 * to update everything:
85 * cooked_mntrs, monitor and all fif_* counters
86 * reconfigure hardware
88 if ((*flags
& mask
) != (sdata
->u
.mntr_flags
& mask
))
91 ieee80211_adjust_monitor_flags(sdata
, -1);
92 sdata
->u
.mntr_flags
= *flags
;
93 ieee80211_adjust_monitor_flags(sdata
, 1);
95 ieee80211_configure_filter(local
);
98 * Because the interface is down, ieee80211_do_stop
99 * and ieee80211_do_open take care of "everything"
100 * mentioned in the comment above.
102 sdata
->u
.mntr_flags
= *flags
;
109 static int ieee80211_start_p2p_device(struct wiphy
*wiphy
,
110 struct wireless_dev
*wdev
)
112 return ieee80211_do_open(wdev
, true);
115 static void ieee80211_stop_p2p_device(struct wiphy
*wiphy
,
116 struct wireless_dev
*wdev
)
118 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev
));
121 static int ieee80211_set_noack_map(struct wiphy
*wiphy
,
122 struct net_device
*dev
,
125 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
127 sdata
->noack_map
= noack_map
;
131 static int ieee80211_add_key(struct wiphy
*wiphy
, struct net_device
*dev
,
132 u8 key_idx
, bool pairwise
, const u8
*mac_addr
,
133 struct key_params
*params
)
135 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
136 struct sta_info
*sta
= NULL
;
137 struct ieee80211_key
*key
;
140 if (!ieee80211_sdata_running(sdata
))
143 /* reject WEP and TKIP keys if WEP failed to initialize */
144 switch (params
->cipher
) {
145 case WLAN_CIPHER_SUITE_WEP40
:
146 case WLAN_CIPHER_SUITE_TKIP
:
147 case WLAN_CIPHER_SUITE_WEP104
:
148 if (IS_ERR(sdata
->local
->wep_tx_tfm
))
155 key
= ieee80211_key_alloc(params
->cipher
, key_idx
, params
->key_len
,
156 params
->key
, params
->seq_len
, params
->seq
);
161 key
->conf
.flags
|= IEEE80211_KEY_FLAG_PAIRWISE
;
163 mutex_lock(&sdata
->local
->sta_mtx
);
166 if (ieee80211_vif_is_mesh(&sdata
->vif
))
167 sta
= sta_info_get(sdata
, mac_addr
);
169 sta
= sta_info_get_bss(sdata
, mac_addr
);
171 * The ASSOC test makes sure the driver is ready to
172 * receive the key. When wpa_supplicant has roamed
173 * using FT, it attempts to set the key before
174 * association has completed, this rejects that attempt
175 * so it will set the key again after assocation.
177 * TODO: accept the key if we have a station entry and
178 * add it to the device after the station.
180 if (!sta
|| !test_sta_flag(sta
, WLAN_STA_ASSOC
)) {
181 ieee80211_key_free_unused(key
);
187 switch (sdata
->vif
.type
) {
188 case NL80211_IFTYPE_STATION
:
189 if (sdata
->u
.mgd
.mfp
!= IEEE80211_MFP_DISABLED
)
190 key
->conf
.flags
|= IEEE80211_KEY_FLAG_RX_MGMT
;
192 case NL80211_IFTYPE_AP
:
193 case NL80211_IFTYPE_AP_VLAN
:
194 /* Keys without a station are used for TX only */
195 if (key
->sta
&& test_sta_flag(key
->sta
, WLAN_STA_MFP
))
196 key
->conf
.flags
|= IEEE80211_KEY_FLAG_RX_MGMT
;
198 case NL80211_IFTYPE_ADHOC
:
201 case NL80211_IFTYPE_MESH_POINT
:
202 #ifdef CONFIG_MAC80211_MESH
203 if (sdata
->u
.mesh
.security
!= IEEE80211_MESH_SEC_NONE
)
204 key
->conf
.flags
|= IEEE80211_KEY_FLAG_RX_MGMT
;
207 case NL80211_IFTYPE_WDS
:
208 case NL80211_IFTYPE_MONITOR
:
209 case NL80211_IFTYPE_P2P_DEVICE
:
210 case NL80211_IFTYPE_UNSPECIFIED
:
211 case NUM_NL80211_IFTYPES
:
212 case NL80211_IFTYPE_P2P_CLIENT
:
213 case NL80211_IFTYPE_P2P_GO
:
214 /* shouldn't happen */
219 err
= ieee80211_key_link(key
, sdata
, sta
);
222 mutex_unlock(&sdata
->local
->sta_mtx
);
227 static int ieee80211_del_key(struct wiphy
*wiphy
, struct net_device
*dev
,
228 u8 key_idx
, bool pairwise
, const u8
*mac_addr
)
230 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
231 struct ieee80211_local
*local
= sdata
->local
;
232 struct sta_info
*sta
;
233 struct ieee80211_key
*key
= NULL
;
236 mutex_lock(&local
->sta_mtx
);
237 mutex_lock(&local
->key_mtx
);
242 sta
= sta_info_get_bss(sdata
, mac_addr
);
247 key
= key_mtx_dereference(local
, sta
->ptk
);
249 key
= key_mtx_dereference(local
, sta
->gtk
[key_idx
]);
251 key
= key_mtx_dereference(local
, sdata
->keys
[key_idx
]);
258 ieee80211_key_free(key
, true);
262 mutex_unlock(&local
->key_mtx
);
263 mutex_unlock(&local
->sta_mtx
);
268 static int ieee80211_get_key(struct wiphy
*wiphy
, struct net_device
*dev
,
269 u8 key_idx
, bool pairwise
, const u8
*mac_addr
,
271 void (*callback
)(void *cookie
,
272 struct key_params
*params
))
274 struct ieee80211_sub_if_data
*sdata
;
275 struct sta_info
*sta
= NULL
;
277 struct key_params params
;
278 struct ieee80211_key
*key
= NULL
;
284 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
289 sta
= sta_info_get_bss(sdata
, mac_addr
);
294 key
= rcu_dereference(sta
->ptk
);
295 else if (key_idx
< NUM_DEFAULT_KEYS
)
296 key
= rcu_dereference(sta
->gtk
[key_idx
]);
298 key
= rcu_dereference(sdata
->keys
[key_idx
]);
303 memset(¶ms
, 0, sizeof(params
));
305 params
.cipher
= key
->conf
.cipher
;
307 switch (key
->conf
.cipher
) {
308 case WLAN_CIPHER_SUITE_TKIP
:
309 iv32
= key
->u
.tkip
.tx
.iv32
;
310 iv16
= key
->u
.tkip
.tx
.iv16
;
312 if (key
->flags
& KEY_FLAG_UPLOADED_TO_HARDWARE
)
313 drv_get_tkip_seq(sdata
->local
,
314 key
->conf
.hw_key_idx
,
317 seq
[0] = iv16
& 0xff;
318 seq
[1] = (iv16
>> 8) & 0xff;
319 seq
[2] = iv32
& 0xff;
320 seq
[3] = (iv32
>> 8) & 0xff;
321 seq
[4] = (iv32
>> 16) & 0xff;
322 seq
[5] = (iv32
>> 24) & 0xff;
326 case WLAN_CIPHER_SUITE_CCMP
:
327 pn64
= atomic64_read(&key
->u
.ccmp
.tx_pn
);
337 case WLAN_CIPHER_SUITE_AES_CMAC
:
338 pn64
= atomic64_read(&key
->u
.aes_cmac
.tx_pn
);
350 params
.key
= key
->conf
.key
;
351 params
.key_len
= key
->conf
.keylen
;
353 callback(cookie
, ¶ms
);
361 static int ieee80211_config_default_key(struct wiphy
*wiphy
,
362 struct net_device
*dev
,
363 u8 key_idx
, bool uni
,
366 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
368 ieee80211_set_default_key(sdata
, key_idx
, uni
, multi
);
373 static int ieee80211_config_default_mgmt_key(struct wiphy
*wiphy
,
374 struct net_device
*dev
,
377 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
379 ieee80211_set_default_mgmt_key(sdata
, key_idx
);
384 void sta_set_rate_info_tx(struct sta_info
*sta
,
385 const struct ieee80211_tx_rate
*rate
,
386 struct rate_info
*rinfo
)
389 if (rate
->flags
& IEEE80211_TX_RC_MCS
) {
390 rinfo
->flags
|= RATE_INFO_FLAGS_MCS
;
391 rinfo
->mcs
= rate
->idx
;
392 } else if (rate
->flags
& IEEE80211_TX_RC_VHT_MCS
) {
393 rinfo
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
394 rinfo
->mcs
= ieee80211_rate_get_vht_mcs(rate
);
395 rinfo
->nss
= ieee80211_rate_get_vht_nss(rate
);
397 struct ieee80211_supported_band
*sband
;
398 sband
= sta
->local
->hw
.wiphy
->bands
[
399 ieee80211_get_sdata_band(sta
->sdata
)];
400 rinfo
->legacy
= sband
->bitrates
[rate
->idx
].bitrate
;
402 if (rate
->flags
& IEEE80211_TX_RC_40_MHZ_WIDTH
)
403 rinfo
->flags
|= RATE_INFO_FLAGS_40_MHZ_WIDTH
;
404 if (rate
->flags
& IEEE80211_TX_RC_80_MHZ_WIDTH
)
405 rinfo
->flags
|= RATE_INFO_FLAGS_80_MHZ_WIDTH
;
406 if (rate
->flags
& IEEE80211_TX_RC_160_MHZ_WIDTH
)
407 rinfo
->flags
|= RATE_INFO_FLAGS_160_MHZ_WIDTH
;
408 if (rate
->flags
& IEEE80211_TX_RC_SHORT_GI
)
409 rinfo
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
412 void sta_set_rate_info_rx(struct sta_info
*sta
, struct rate_info
*rinfo
)
416 if (sta
->last_rx_rate_flag
& RX_FLAG_HT
) {
417 rinfo
->flags
|= RATE_INFO_FLAGS_MCS
;
418 rinfo
->mcs
= sta
->last_rx_rate_idx
;
419 } else if (sta
->last_rx_rate_flag
& RX_FLAG_VHT
) {
420 rinfo
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
421 rinfo
->nss
= sta
->last_rx_rate_vht_nss
;
422 rinfo
->mcs
= sta
->last_rx_rate_idx
;
424 struct ieee80211_supported_band
*sband
;
426 sband
= sta
->local
->hw
.wiphy
->bands
[
427 ieee80211_get_sdata_band(sta
->sdata
)];
429 sband
->bitrates
[sta
->last_rx_rate_idx
].bitrate
;
432 if (sta
->last_rx_rate_flag
& RX_FLAG_40MHZ
)
433 rinfo
->flags
|= RATE_INFO_FLAGS_40_MHZ_WIDTH
;
434 if (sta
->last_rx_rate_flag
& RX_FLAG_SHORT_GI
)
435 rinfo
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
436 if (sta
->last_rx_rate_flag
& RX_FLAG_80MHZ
)
437 rinfo
->flags
|= RATE_INFO_FLAGS_80_MHZ_WIDTH
;
438 if (sta
->last_rx_rate_flag
& RX_FLAG_80P80MHZ
)
439 rinfo
->flags
|= RATE_INFO_FLAGS_80P80_MHZ_WIDTH
;
440 if (sta
->last_rx_rate_flag
& RX_FLAG_160MHZ
)
441 rinfo
->flags
|= RATE_INFO_FLAGS_160_MHZ_WIDTH
;
444 static void sta_set_sinfo(struct sta_info
*sta
, struct station_info
*sinfo
)
446 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
447 struct ieee80211_local
*local
= sdata
->local
;
448 struct timespec uptime
;
452 sinfo
->generation
= sdata
->local
->sta_generation
;
454 sinfo
->filled
= STATION_INFO_INACTIVE_TIME
|
455 STATION_INFO_RX_BYTES64
|
456 STATION_INFO_TX_BYTES64
|
457 STATION_INFO_RX_PACKETS
|
458 STATION_INFO_TX_PACKETS
|
459 STATION_INFO_TX_RETRIES
|
460 STATION_INFO_TX_FAILED
|
461 STATION_INFO_TX_BITRATE
|
462 STATION_INFO_RX_BITRATE
|
463 STATION_INFO_RX_DROP_MISC
|
464 STATION_INFO_BSS_PARAM
|
465 STATION_INFO_CONNECTED_TIME
|
466 STATION_INFO_STA_FLAGS
|
467 STATION_INFO_BEACON_LOSS_COUNT
;
469 do_posix_clock_monotonic_gettime(&uptime
);
470 sinfo
->connected_time
= uptime
.tv_sec
- sta
->last_connected
;
472 sinfo
->inactive_time
= jiffies_to_msecs(jiffies
- sta
->last_rx
);
474 for (ac
= 0; ac
< IEEE80211_NUM_ACS
; ac
++) {
475 sinfo
->tx_bytes
+= sta
->tx_bytes
[ac
];
476 packets
+= sta
->tx_packets
[ac
];
478 sinfo
->tx_packets
= packets
;
479 sinfo
->rx_bytes
= sta
->rx_bytes
;
480 sinfo
->rx_packets
= sta
->rx_packets
;
481 sinfo
->tx_retries
= sta
->tx_retry_count
;
482 sinfo
->tx_failed
= sta
->tx_retry_failed
;
483 sinfo
->rx_dropped_misc
= sta
->rx_dropped
;
484 sinfo
->beacon_loss_count
= sta
->beacon_loss_count
;
486 if ((sta
->local
->hw
.flags
& IEEE80211_HW_SIGNAL_DBM
) ||
487 (sta
->local
->hw
.flags
& IEEE80211_HW_SIGNAL_UNSPEC
)) {
488 sinfo
->filled
|= STATION_INFO_SIGNAL
| STATION_INFO_SIGNAL_AVG
;
489 if (!local
->ops
->get_rssi
||
490 drv_get_rssi(local
, sdata
, &sta
->sta
, &sinfo
->signal
))
491 sinfo
->signal
= (s8
)sta
->last_signal
;
492 sinfo
->signal_avg
= (s8
) -ewma_read(&sta
->avg_signal
);
495 sinfo
->filled
|= STATION_INFO_CHAIN_SIGNAL
|
496 STATION_INFO_CHAIN_SIGNAL_AVG
;
498 sinfo
->chains
= sta
->chains
;
499 for (i
= 0; i
< ARRAY_SIZE(sinfo
->chain_signal
); i
++) {
500 sinfo
->chain_signal
[i
] = sta
->chain_signal_last
[i
];
501 sinfo
->chain_signal_avg
[i
] =
502 (s8
) -ewma_read(&sta
->chain_signal_avg
[i
]);
506 sta_set_rate_info_tx(sta
, &sta
->last_tx_rate
, &sinfo
->txrate
);
507 sta_set_rate_info_rx(sta
, &sinfo
->rxrate
);
509 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
510 #ifdef CONFIG_MAC80211_MESH
511 sinfo
->filled
|= STATION_INFO_LLID
|
513 STATION_INFO_PLINK_STATE
|
514 STATION_INFO_LOCAL_PM
|
515 STATION_INFO_PEER_PM
|
516 STATION_INFO_NONPEER_PM
;
518 sinfo
->llid
= le16_to_cpu(sta
->llid
);
519 sinfo
->plid
= le16_to_cpu(sta
->plid
);
520 sinfo
->plink_state
= sta
->plink_state
;
521 if (test_sta_flag(sta
, WLAN_STA_TOFFSET_KNOWN
)) {
522 sinfo
->filled
|= STATION_INFO_T_OFFSET
;
523 sinfo
->t_offset
= sta
->t_offset
;
525 sinfo
->local_pm
= sta
->local_pm
;
526 sinfo
->peer_pm
= sta
->peer_pm
;
527 sinfo
->nonpeer_pm
= sta
->nonpeer_pm
;
531 sinfo
->bss_param
.flags
= 0;
532 if (sdata
->vif
.bss_conf
.use_cts_prot
)
533 sinfo
->bss_param
.flags
|= BSS_PARAM_FLAGS_CTS_PROT
;
534 if (sdata
->vif
.bss_conf
.use_short_preamble
)
535 sinfo
->bss_param
.flags
|= BSS_PARAM_FLAGS_SHORT_PREAMBLE
;
536 if (sdata
->vif
.bss_conf
.use_short_slot
)
537 sinfo
->bss_param
.flags
|= BSS_PARAM_FLAGS_SHORT_SLOT_TIME
;
538 sinfo
->bss_param
.dtim_period
= sdata
->local
->hw
.conf
.ps_dtim_period
;
539 sinfo
->bss_param
.beacon_interval
= sdata
->vif
.bss_conf
.beacon_int
;
541 sinfo
->sta_flags
.set
= 0;
542 sinfo
->sta_flags
.mask
= BIT(NL80211_STA_FLAG_AUTHORIZED
) |
543 BIT(NL80211_STA_FLAG_SHORT_PREAMBLE
) |
544 BIT(NL80211_STA_FLAG_WME
) |
545 BIT(NL80211_STA_FLAG_MFP
) |
546 BIT(NL80211_STA_FLAG_AUTHENTICATED
) |
547 BIT(NL80211_STA_FLAG_ASSOCIATED
) |
548 BIT(NL80211_STA_FLAG_TDLS_PEER
);
549 if (test_sta_flag(sta
, WLAN_STA_AUTHORIZED
))
550 sinfo
->sta_flags
.set
|= BIT(NL80211_STA_FLAG_AUTHORIZED
);
551 if (test_sta_flag(sta
, WLAN_STA_SHORT_PREAMBLE
))
552 sinfo
->sta_flags
.set
|= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE
);
553 if (test_sta_flag(sta
, WLAN_STA_WME
))
554 sinfo
->sta_flags
.set
|= BIT(NL80211_STA_FLAG_WME
);
555 if (test_sta_flag(sta
, WLAN_STA_MFP
))
556 sinfo
->sta_flags
.set
|= BIT(NL80211_STA_FLAG_MFP
);
557 if (test_sta_flag(sta
, WLAN_STA_AUTH
))
558 sinfo
->sta_flags
.set
|= BIT(NL80211_STA_FLAG_AUTHENTICATED
);
559 if (test_sta_flag(sta
, WLAN_STA_ASSOC
))
560 sinfo
->sta_flags
.set
|= BIT(NL80211_STA_FLAG_ASSOCIATED
);
561 if (test_sta_flag(sta
, WLAN_STA_TDLS_PEER
))
562 sinfo
->sta_flags
.set
|= BIT(NL80211_STA_FLAG_TDLS_PEER
);
565 static const char ieee80211_gstrings_sta_stats
[][ETH_GSTRING_LEN
] = {
566 "rx_packets", "rx_bytes", "wep_weak_iv_count",
567 "rx_duplicates", "rx_fragments", "rx_dropped",
568 "tx_packets", "tx_bytes", "tx_fragments",
569 "tx_filtered", "tx_retry_failed", "tx_retries",
570 "beacon_loss", "sta_state", "txrate", "rxrate", "signal",
571 "channel", "noise", "ch_time", "ch_time_busy",
572 "ch_time_ext_busy", "ch_time_rx", "ch_time_tx"
574 #define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats)
576 static int ieee80211_get_et_sset_count(struct wiphy
*wiphy
,
577 struct net_device
*dev
,
580 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
583 if (sset
== ETH_SS_STATS
)
586 rv
+= drv_get_et_sset_count(sdata
, sset
);
593 static void ieee80211_get_et_stats(struct wiphy
*wiphy
,
594 struct net_device
*dev
,
595 struct ethtool_stats
*stats
,
598 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
599 struct ieee80211_chanctx_conf
*chanctx_conf
;
600 struct ieee80211_channel
*channel
;
601 struct sta_info
*sta
;
602 struct ieee80211_local
*local
= sdata
->local
;
603 struct station_info sinfo
;
604 struct survey_info survey
;
606 #define STA_STATS_SURVEY_LEN 7
608 memset(data
, 0, sizeof(u64
) * STA_STATS_LEN
);
610 #define ADD_STA_STATS(sta) \
612 data[i++] += sta->rx_packets; \
613 data[i++] += sta->rx_bytes; \
614 data[i++] += sta->wep_weak_iv_count; \
615 data[i++] += sta->num_duplicates; \
616 data[i++] += sta->rx_fragments; \
617 data[i++] += sta->rx_dropped; \
619 data[i++] += sinfo.tx_packets; \
620 data[i++] += sinfo.tx_bytes; \
621 data[i++] += sta->tx_fragments; \
622 data[i++] += sta->tx_filtered_count; \
623 data[i++] += sta->tx_retry_failed; \
624 data[i++] += sta->tx_retry_count; \
625 data[i++] += sta->beacon_loss_count; \
628 /* For Managed stations, find the single station based on BSSID
629 * and use that. For interface types, iterate through all available
630 * stations and add stats for any station that is assigned to this
634 mutex_lock(&local
->sta_mtx
);
636 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
) {
637 sta
= sta_info_get_bss(sdata
, sdata
->u
.mgd
.bssid
);
639 if (!(sta
&& !WARN_ON(sta
->sdata
->dev
!= dev
)))
643 sta_set_sinfo(sta
, &sinfo
);
648 data
[i
++] = sta
->sta_state
;
651 if (sinfo
.filled
& STATION_INFO_TX_BITRATE
)
653 cfg80211_calculate_bitrate(&sinfo
.txrate
);
655 if (sinfo
.filled
& STATION_INFO_RX_BITRATE
)
657 cfg80211_calculate_bitrate(&sinfo
.rxrate
);
660 if (sinfo
.filled
& STATION_INFO_SIGNAL_AVG
)
661 data
[i
] = (u8
)sinfo
.signal_avg
;
664 list_for_each_entry(sta
, &local
->sta_list
, list
) {
665 /* Make sure this station belongs to the proper dev */
666 if (sta
->sdata
->dev
!= dev
)
670 sta_set_sinfo(sta
, &sinfo
);
677 i
= STA_STATS_LEN
- STA_STATS_SURVEY_LEN
;
678 /* Get survey stats for current channel */
682 chanctx_conf
= rcu_dereference(sdata
->vif
.chanctx_conf
);
684 channel
= chanctx_conf
->def
.chan
;
693 if (drv_get_survey(local
, q
, &survey
) != 0) {
698 } while (channel
!= survey
.channel
);
702 data
[i
++] = survey
.channel
->center_freq
;
705 if (survey
.filled
& SURVEY_INFO_NOISE_DBM
)
706 data
[i
++] = (u8
)survey
.noise
;
709 if (survey
.filled
& SURVEY_INFO_CHANNEL_TIME
)
710 data
[i
++] = survey
.channel_time
;
713 if (survey
.filled
& SURVEY_INFO_CHANNEL_TIME_BUSY
)
714 data
[i
++] = survey
.channel_time_busy
;
717 if (survey
.filled
& SURVEY_INFO_CHANNEL_TIME_EXT_BUSY
)
718 data
[i
++] = survey
.channel_time_ext_busy
;
721 if (survey
.filled
& SURVEY_INFO_CHANNEL_TIME_RX
)
722 data
[i
++] = survey
.channel_time_rx
;
725 if (survey
.filled
& SURVEY_INFO_CHANNEL_TIME_TX
)
726 data
[i
++] = survey
.channel_time_tx
;
730 mutex_unlock(&local
->sta_mtx
);
732 if (WARN_ON(i
!= STA_STATS_LEN
))
735 drv_get_et_stats(sdata
, stats
, &(data
[STA_STATS_LEN
]));
738 static void ieee80211_get_et_strings(struct wiphy
*wiphy
,
739 struct net_device
*dev
,
742 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
743 int sz_sta_stats
= 0;
745 if (sset
== ETH_SS_STATS
) {
746 sz_sta_stats
= sizeof(ieee80211_gstrings_sta_stats
);
747 memcpy(data
, ieee80211_gstrings_sta_stats
, sz_sta_stats
);
749 drv_get_et_strings(sdata
, sset
, &(data
[sz_sta_stats
]));
752 static int ieee80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
753 int idx
, u8
*mac
, struct station_info
*sinfo
)
755 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
756 struct ieee80211_local
*local
= sdata
->local
;
757 struct sta_info
*sta
;
760 mutex_lock(&local
->sta_mtx
);
762 sta
= sta_info_get_by_idx(sdata
, idx
);
765 memcpy(mac
, sta
->sta
.addr
, ETH_ALEN
);
766 sta_set_sinfo(sta
, sinfo
);
769 mutex_unlock(&local
->sta_mtx
);
774 static int ieee80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
775 int idx
, struct survey_info
*survey
)
777 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
779 return drv_get_survey(local
, idx
, survey
);
782 static int ieee80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
783 u8
*mac
, struct station_info
*sinfo
)
785 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
786 struct ieee80211_local
*local
= sdata
->local
;
787 struct sta_info
*sta
;
790 mutex_lock(&local
->sta_mtx
);
792 sta
= sta_info_get_bss(sdata
, mac
);
795 sta_set_sinfo(sta
, sinfo
);
798 mutex_unlock(&local
->sta_mtx
);
803 static int ieee80211_set_monitor_channel(struct wiphy
*wiphy
,
804 struct cfg80211_chan_def
*chandef
)
806 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
807 struct ieee80211_sub_if_data
*sdata
;
810 if (cfg80211_chandef_identical(&local
->monitor_chandef
, chandef
))
813 mutex_lock(&local
->iflist_mtx
);
814 if (local
->use_chanctx
) {
815 sdata
= rcu_dereference_protected(
816 local
->monitor_sdata
,
817 lockdep_is_held(&local
->iflist_mtx
));
819 ieee80211_vif_release_channel(sdata
);
820 ret
= ieee80211_vif_use_channel(sdata
, chandef
,
821 IEEE80211_CHANCTX_EXCLUSIVE
);
823 } else if (local
->open_count
== local
->monitors
) {
824 local
->_oper_chandef
= *chandef
;
825 ieee80211_hw_config(local
, 0);
829 local
->monitor_chandef
= *chandef
;
830 mutex_unlock(&local
->iflist_mtx
);
835 static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data
*sdata
,
836 const u8
*resp
, size_t resp_len
)
838 struct probe_resp
*new, *old
;
840 if (!resp
|| !resp_len
)
843 old
= rtnl_dereference(sdata
->u
.ap
.probe_resp
);
845 new = kzalloc(sizeof(struct probe_resp
) + resp_len
, GFP_KERNEL
);
850 memcpy(new->data
, resp
, resp_len
);
852 rcu_assign_pointer(sdata
->u
.ap
.probe_resp
, new);
854 kfree_rcu(old
, rcu_head
);
859 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data
*sdata
,
860 struct cfg80211_beacon_data
*params
)
862 struct beacon_data
*new, *old
;
863 int new_head_len
, new_tail_len
;
865 u32 changed
= BSS_CHANGED_BEACON
;
867 old
= rtnl_dereference(sdata
->u
.ap
.beacon
);
869 /* Need to have a beacon head if we don't have one yet */
870 if (!params
->head
&& !old
)
873 /* new or old head? */
875 new_head_len
= params
->head_len
;
877 new_head_len
= old
->head_len
;
879 /* new or old tail? */
880 if (params
->tail
|| !old
)
881 /* params->tail_len will be zero for !params->tail */
882 new_tail_len
= params
->tail_len
;
884 new_tail_len
= old
->tail_len
;
886 size
= sizeof(*new) + new_head_len
+ new_tail_len
;
888 new = kzalloc(size
, GFP_KERNEL
);
892 /* start filling the new info now */
895 * pointers go into the block we allocated,
896 * memory is | beacon_data | head | tail |
898 new->head
= ((u8
*) new) + sizeof(*new);
899 new->tail
= new->head
+ new_head_len
;
900 new->head_len
= new_head_len
;
901 new->tail_len
= new_tail_len
;
905 memcpy(new->head
, params
->head
, new_head_len
);
907 memcpy(new->head
, old
->head
, new_head_len
);
909 /* copy in optional tail */
911 memcpy(new->tail
, params
->tail
, new_tail_len
);
914 memcpy(new->tail
, old
->tail
, new_tail_len
);
916 err
= ieee80211_set_probe_resp(sdata
, params
->probe_resp
,
917 params
->probe_resp_len
);
921 changed
|= BSS_CHANGED_AP_PROBE_RESP
;
923 rcu_assign_pointer(sdata
->u
.ap
.beacon
, new);
926 kfree_rcu(old
, rcu_head
);
931 static int ieee80211_start_ap(struct wiphy
*wiphy
, struct net_device
*dev
,
932 struct cfg80211_ap_settings
*params
)
934 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
935 struct beacon_data
*old
;
936 struct ieee80211_sub_if_data
*vlan
;
937 u32 changed
= BSS_CHANGED_BEACON_INT
|
938 BSS_CHANGED_BEACON_ENABLED
|
944 old
= rtnl_dereference(sdata
->u
.ap
.beacon
);
948 /* TODO: make hostapd tell us what it wants */
949 sdata
->smps_mode
= IEEE80211_SMPS_OFF
;
950 sdata
->needed_rx_chains
= sdata
->local
->rx_chains
;
951 sdata
->radar_required
= params
->radar_required
;
953 err
= ieee80211_vif_use_channel(sdata
, ¶ms
->chandef
,
954 IEEE80211_CHANCTX_SHARED
);
957 ieee80211_vif_copy_chanctx_to_vlans(sdata
, false);
960 * Apply control port protocol, this allows us to
961 * not encrypt dynamic WEP control frames.
963 sdata
->control_port_protocol
= params
->crypto
.control_port_ethertype
;
964 sdata
->control_port_no_encrypt
= params
->crypto
.control_port_no_encrypt
;
965 list_for_each_entry(vlan
, &sdata
->u
.ap
.vlans
, u
.vlan
.list
) {
966 vlan
->control_port_protocol
=
967 params
->crypto
.control_port_ethertype
;
968 vlan
->control_port_no_encrypt
=
969 params
->crypto
.control_port_no_encrypt
;
972 sdata
->vif
.bss_conf
.beacon_int
= params
->beacon_interval
;
973 sdata
->vif
.bss_conf
.dtim_period
= params
->dtim_period
;
974 sdata
->vif
.bss_conf
.enable_beacon
= true;
976 sdata
->vif
.bss_conf
.ssid_len
= params
->ssid_len
;
977 if (params
->ssid_len
)
978 memcpy(sdata
->vif
.bss_conf
.ssid
, params
->ssid
,
980 sdata
->vif
.bss_conf
.hidden_ssid
=
981 (params
->hidden_ssid
!= NL80211_HIDDEN_SSID_NOT_IN_USE
);
983 memset(&sdata
->vif
.bss_conf
.p2p_noa_attr
, 0,
984 sizeof(sdata
->vif
.bss_conf
.p2p_noa_attr
));
985 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
=
986 params
->p2p_ctwindow
& IEEE80211_P2P_OPPPS_CTWINDOW_MASK
;
987 if (params
->p2p_opp_ps
)
988 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
|=
989 IEEE80211_P2P_OPPPS_ENABLE_BIT
;
991 err
= ieee80211_assign_beacon(sdata
, ¶ms
->beacon
);
996 err
= drv_start_ap(sdata
->local
, sdata
);
998 old
= rtnl_dereference(sdata
->u
.ap
.beacon
);
1000 kfree_rcu(old
, rcu_head
);
1001 RCU_INIT_POINTER(sdata
->u
.ap
.beacon
, NULL
);
1005 ieee80211_bss_info_change_notify(sdata
, changed
);
1007 netif_carrier_on(dev
);
1008 list_for_each_entry(vlan
, &sdata
->u
.ap
.vlans
, u
.vlan
.list
)
1009 netif_carrier_on(vlan
->dev
);
1014 static int ieee80211_change_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
1015 struct cfg80211_beacon_data
*params
)
1017 struct ieee80211_sub_if_data
*sdata
;
1018 struct beacon_data
*old
;
1021 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1023 old
= rtnl_dereference(sdata
->u
.ap
.beacon
);
1027 err
= ieee80211_assign_beacon(sdata
, params
);
1030 ieee80211_bss_info_change_notify(sdata
, err
);
1034 static int ieee80211_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
1036 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1037 struct ieee80211_sub_if_data
*vlan
;
1038 struct ieee80211_local
*local
= sdata
->local
;
1039 struct beacon_data
*old_beacon
;
1040 struct probe_resp
*old_probe_resp
;
1042 old_beacon
= rtnl_dereference(sdata
->u
.ap
.beacon
);
1045 old_probe_resp
= rtnl_dereference(sdata
->u
.ap
.probe_resp
);
1047 /* turn off carrier for this interface and dependent VLANs */
1048 list_for_each_entry(vlan
, &sdata
->u
.ap
.vlans
, u
.vlan
.list
)
1049 netif_carrier_off(vlan
->dev
);
1050 netif_carrier_off(dev
);
1052 /* remove beacon and probe response */
1053 RCU_INIT_POINTER(sdata
->u
.ap
.beacon
, NULL
);
1054 RCU_INIT_POINTER(sdata
->u
.ap
.probe_resp
, NULL
);
1055 kfree_rcu(old_beacon
, rcu_head
);
1057 kfree_rcu(old_probe_resp
, rcu_head
);
1059 list_for_each_entry(vlan
, &sdata
->u
.ap
.vlans
, u
.vlan
.list
)
1060 sta_info_flush_defer(vlan
);
1061 sta_info_flush_defer(sdata
);
1064 list_for_each_entry(vlan
, &sdata
->u
.ap
.vlans
, u
.vlan
.list
) {
1065 sta_info_flush_cleanup(vlan
);
1066 ieee80211_free_keys(vlan
);
1068 sta_info_flush_cleanup(sdata
);
1069 ieee80211_free_keys(sdata
);
1071 sdata
->vif
.bss_conf
.enable_beacon
= false;
1072 sdata
->vif
.bss_conf
.ssid_len
= 0;
1073 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED
, &sdata
->state
);
1074 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BEACON_ENABLED
);
1076 if (sdata
->wdev
.cac_started
) {
1077 cancel_delayed_work_sync(&sdata
->dfs_cac_timer_work
);
1078 cfg80211_cac_event(sdata
->dev
, NL80211_RADAR_CAC_ABORTED
,
1082 drv_stop_ap(sdata
->local
, sdata
);
1084 /* free all potentially still buffered bcast frames */
1085 local
->total_ps_buffered
-= skb_queue_len(&sdata
->u
.ap
.ps
.bc_buf
);
1086 skb_queue_purge(&sdata
->u
.ap
.ps
.bc_buf
);
1088 ieee80211_vif_copy_chanctx_to_vlans(sdata
, true);
1089 ieee80211_vif_release_channel(sdata
);
1094 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
1095 struct iapp_layer2_update
{
1096 u8 da
[ETH_ALEN
]; /* broadcast */
1097 u8 sa
[ETH_ALEN
]; /* STA addr */
1105 static void ieee80211_send_layer2_update(struct sta_info
*sta
)
1107 struct iapp_layer2_update
*msg
;
1108 struct sk_buff
*skb
;
1110 /* Send Level 2 Update Frame to update forwarding tables in layer 2
1113 skb
= dev_alloc_skb(sizeof(*msg
));
1116 msg
= (struct iapp_layer2_update
*)skb_put(skb
, sizeof(*msg
));
1118 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
1119 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
1121 eth_broadcast_addr(msg
->da
);
1122 memcpy(msg
->sa
, sta
->sta
.addr
, ETH_ALEN
);
1123 msg
->len
= htons(6);
1125 msg
->ssap
= 0x01; /* NULL LSAP, CR Bit: Response */
1126 msg
->control
= 0xaf; /* XID response lsb.1111F101.
1127 * F=0 (no poll command; unsolicited frame) */
1128 msg
->xid_info
[0] = 0x81; /* XID format identifier */
1129 msg
->xid_info
[1] = 1; /* LLC types/classes: Type 1 LLC */
1130 msg
->xid_info
[2] = 0; /* XID sender's receive window size (RW) */
1132 skb
->dev
= sta
->sdata
->dev
;
1133 skb
->protocol
= eth_type_trans(skb
, sta
->sdata
->dev
);
1134 memset(skb
->cb
, 0, sizeof(skb
->cb
));
1138 static int sta_apply_auth_flags(struct ieee80211_local
*local
,
1139 struct sta_info
*sta
,
1144 if (mask
& BIT(NL80211_STA_FLAG_AUTHENTICATED
) &&
1145 set
& BIT(NL80211_STA_FLAG_AUTHENTICATED
) &&
1146 !test_sta_flag(sta
, WLAN_STA_AUTH
)) {
1147 ret
= sta_info_move_state(sta
, IEEE80211_STA_AUTH
);
1152 if (mask
& BIT(NL80211_STA_FLAG_ASSOCIATED
) &&
1153 set
& BIT(NL80211_STA_FLAG_ASSOCIATED
) &&
1154 !test_sta_flag(sta
, WLAN_STA_ASSOC
)) {
1155 ret
= sta_info_move_state(sta
, IEEE80211_STA_ASSOC
);
1160 if (mask
& BIT(NL80211_STA_FLAG_AUTHORIZED
)) {
1161 if (set
& BIT(NL80211_STA_FLAG_AUTHORIZED
))
1162 ret
= sta_info_move_state(sta
, IEEE80211_STA_AUTHORIZED
);
1163 else if (test_sta_flag(sta
, WLAN_STA_AUTHORIZED
))
1164 ret
= sta_info_move_state(sta
, IEEE80211_STA_ASSOC
);
1171 if (mask
& BIT(NL80211_STA_FLAG_ASSOCIATED
) &&
1172 !(set
& BIT(NL80211_STA_FLAG_ASSOCIATED
)) &&
1173 test_sta_flag(sta
, WLAN_STA_ASSOC
)) {
1174 ret
= sta_info_move_state(sta
, IEEE80211_STA_AUTH
);
1179 if (mask
& BIT(NL80211_STA_FLAG_AUTHENTICATED
) &&
1180 !(set
& BIT(NL80211_STA_FLAG_AUTHENTICATED
)) &&
1181 test_sta_flag(sta
, WLAN_STA_AUTH
)) {
1182 ret
= sta_info_move_state(sta
, IEEE80211_STA_NONE
);
1190 static int sta_apply_parameters(struct ieee80211_local
*local
,
1191 struct sta_info
*sta
,
1192 struct station_parameters
*params
)
1197 struct ieee80211_supported_band
*sband
;
1198 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
1199 enum ieee80211_band band
= ieee80211_get_sdata_band(sdata
);
1202 sband
= local
->hw
.wiphy
->bands
[band
];
1204 mask
= params
->sta_flags_mask
;
1205 set
= params
->sta_flags_set
;
1207 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
1209 * In mesh mode, ASSOCIATED isn't part of the nl80211
1210 * API but must follow AUTHENTICATED for driver state.
1212 if (mask
& BIT(NL80211_STA_FLAG_AUTHENTICATED
))
1213 mask
|= BIT(NL80211_STA_FLAG_ASSOCIATED
);
1214 if (set
& BIT(NL80211_STA_FLAG_AUTHENTICATED
))
1215 set
|= BIT(NL80211_STA_FLAG_ASSOCIATED
);
1216 } else if (test_sta_flag(sta
, WLAN_STA_TDLS_PEER
)) {
1218 * TDLS -- everything follows authorized, but
1219 * only becoming authorized is possible, not
1222 if (set
& BIT(NL80211_STA_FLAG_AUTHORIZED
)) {
1223 set
|= BIT(NL80211_STA_FLAG_AUTHENTICATED
) |
1224 BIT(NL80211_STA_FLAG_ASSOCIATED
);
1225 mask
|= BIT(NL80211_STA_FLAG_AUTHENTICATED
) |
1226 BIT(NL80211_STA_FLAG_ASSOCIATED
);
1230 ret
= sta_apply_auth_flags(local
, sta
, mask
, set
);
1234 if (mask
& BIT(NL80211_STA_FLAG_SHORT_PREAMBLE
)) {
1235 if (set
& BIT(NL80211_STA_FLAG_SHORT_PREAMBLE
))
1236 set_sta_flag(sta
, WLAN_STA_SHORT_PREAMBLE
);
1238 clear_sta_flag(sta
, WLAN_STA_SHORT_PREAMBLE
);
1241 if (mask
& BIT(NL80211_STA_FLAG_WME
)) {
1242 if (set
& BIT(NL80211_STA_FLAG_WME
)) {
1243 set_sta_flag(sta
, WLAN_STA_WME
);
1244 sta
->sta
.wme
= true;
1246 clear_sta_flag(sta
, WLAN_STA_WME
);
1247 sta
->sta
.wme
= false;
1251 if (mask
& BIT(NL80211_STA_FLAG_MFP
)) {
1252 if (set
& BIT(NL80211_STA_FLAG_MFP
))
1253 set_sta_flag(sta
, WLAN_STA_MFP
);
1255 clear_sta_flag(sta
, WLAN_STA_MFP
);
1258 if (mask
& BIT(NL80211_STA_FLAG_TDLS_PEER
)) {
1259 if (set
& BIT(NL80211_STA_FLAG_TDLS_PEER
))
1260 set_sta_flag(sta
, WLAN_STA_TDLS_PEER
);
1262 clear_sta_flag(sta
, WLAN_STA_TDLS_PEER
);
1265 if (params
->sta_modify_mask
& STATION_PARAM_APPLY_UAPSD
) {
1266 sta
->sta
.uapsd_queues
= params
->uapsd_queues
;
1267 sta
->sta
.max_sp
= params
->max_sp
;
1271 * cfg80211 validates this (1-2007) and allows setting the AID
1272 * only when creating a new station entry
1275 sta
->sta
.aid
= params
->aid
;
1278 * Some of the following updates would be racy if called on an
1279 * existing station, via ieee80211_change_station(). However,
1280 * all such changes are rejected by cfg80211 except for updates
1281 * changing the supported rates on an existing but not yet used
1285 if (params
->listen_interval
>= 0)
1286 sta
->listen_interval
= params
->listen_interval
;
1288 if (params
->supported_rates
) {
1291 for (i
= 0; i
< params
->supported_rates_len
; i
++) {
1292 int rate
= (params
->supported_rates
[i
] & 0x7f) * 5;
1293 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
1294 if (sband
->bitrates
[j
].bitrate
== rate
)
1298 sta
->sta
.supp_rates
[band
] = rates
;
1301 if (params
->ht_capa
)
1302 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata
, sband
,
1303 params
->ht_capa
, sta
);
1305 if (params
->vht_capa
)
1306 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata
, sband
,
1307 params
->vht_capa
, sta
);
1309 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
1310 #ifdef CONFIG_MAC80211_MESH
1313 if (params
->sta_modify_mask
& STATION_PARAM_APPLY_PLINK_STATE
) {
1314 switch (params
->plink_state
) {
1315 case NL80211_PLINK_ESTAB
:
1316 if (sta
->plink_state
!= NL80211_PLINK_ESTAB
)
1317 changed
= mesh_plink_inc_estab_count(
1319 sta
->plink_state
= params
->plink_state
;
1321 ieee80211_mps_sta_status_update(sta
);
1322 changed
|= ieee80211_mps_set_sta_local_pm(sta
,
1323 sdata
->u
.mesh
.mshcfg
.power_mode
);
1325 case NL80211_PLINK_LISTEN
:
1326 case NL80211_PLINK_BLOCKED
:
1327 case NL80211_PLINK_OPN_SNT
:
1328 case NL80211_PLINK_OPN_RCVD
:
1329 case NL80211_PLINK_CNF_RCVD
:
1330 case NL80211_PLINK_HOLDING
:
1331 if (sta
->plink_state
== NL80211_PLINK_ESTAB
)
1332 changed
= mesh_plink_dec_estab_count(
1334 sta
->plink_state
= params
->plink_state
;
1336 ieee80211_mps_sta_status_update(sta
);
1338 ieee80211_mps_local_status_update(sdata
);
1346 switch (params
->plink_action
) {
1347 case NL80211_PLINK_ACTION_NO_ACTION
:
1350 case NL80211_PLINK_ACTION_OPEN
:
1351 changed
|= mesh_plink_open(sta
);
1353 case NL80211_PLINK_ACTION_BLOCK
:
1354 changed
|= mesh_plink_block(sta
);
1358 if (params
->local_pm
)
1360 ieee80211_mps_set_sta_local_pm(sta
,
1362 ieee80211_bss_info_change_notify(sdata
, changed
);
1369 static int ieee80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1370 u8
*mac
, struct station_parameters
*params
)
1372 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1373 struct sta_info
*sta
;
1374 struct ieee80211_sub_if_data
*sdata
;
1379 sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
1381 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
1382 sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
1385 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1387 if (ether_addr_equal(mac
, sdata
->vif
.addr
))
1390 if (is_multicast_ether_addr(mac
))
1393 sta
= sta_info_alloc(sdata
, mac
, GFP_KERNEL
);
1398 * defaults -- if userspace wants something else we'll
1399 * change it accordingly in sta_apply_parameters()
1401 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
))) {
1402 sta_info_pre_move_state(sta
, IEEE80211_STA_AUTH
);
1403 sta_info_pre_move_state(sta
, IEEE80211_STA_ASSOC
);
1406 err
= sta_apply_parameters(local
, sta
, params
);
1408 sta_info_free(local
, sta
);
1413 * for TDLS, rate control should be initialized only when
1414 * rates are known and station is marked authorized
1416 if (!test_sta_flag(sta
, WLAN_STA_TDLS_PEER
))
1417 rate_control_rate_init(sta
);
1419 layer2_update
= sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
||
1420 sdata
->vif
.type
== NL80211_IFTYPE_AP
;
1422 err
= sta_info_insert_rcu(sta
);
1429 ieee80211_send_layer2_update(sta
);
1436 static int ieee80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1439 struct ieee80211_sub_if_data
*sdata
;
1441 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1444 return sta_info_destroy_addr_bss(sdata
, mac
);
1446 sta_info_flush(sdata
);
1450 static int ieee80211_change_station(struct wiphy
*wiphy
,
1451 struct net_device
*dev
, u8
*mac
,
1452 struct station_parameters
*params
)
1454 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1455 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1456 struct sta_info
*sta
;
1457 struct ieee80211_sub_if_data
*vlansdata
;
1458 enum cfg80211_station_type statype
;
1461 mutex_lock(&local
->sta_mtx
);
1463 sta
= sta_info_get_bss(sdata
, mac
);
1469 switch (sdata
->vif
.type
) {
1470 case NL80211_IFTYPE_MESH_POINT
:
1471 if (sdata
->u
.mesh
.user_mpm
)
1472 statype
= CFG80211_STA_MESH_PEER_USER
;
1474 statype
= CFG80211_STA_MESH_PEER_KERNEL
;
1476 case NL80211_IFTYPE_ADHOC
:
1477 statype
= CFG80211_STA_IBSS
;
1479 case NL80211_IFTYPE_STATION
:
1480 if (!test_sta_flag(sta
, WLAN_STA_TDLS_PEER
)) {
1481 statype
= CFG80211_STA_AP_STA
;
1484 if (test_sta_flag(sta
, WLAN_STA_AUTHORIZED
))
1485 statype
= CFG80211_STA_TDLS_PEER_ACTIVE
;
1487 statype
= CFG80211_STA_TDLS_PEER_SETUP
;
1489 case NL80211_IFTYPE_AP
:
1490 case NL80211_IFTYPE_AP_VLAN
:
1491 statype
= CFG80211_STA_AP_CLIENT
;
1498 err
= cfg80211_check_station_change(wiphy
, params
, statype
);
1502 if (params
->vlan
&& params
->vlan
!= sta
->sdata
->dev
) {
1503 bool prev_4addr
= false;
1504 bool new_4addr
= false;
1506 vlansdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
1508 if (params
->vlan
->ieee80211_ptr
->use_4addr
) {
1509 if (vlansdata
->u
.vlan
.sta
) {
1514 rcu_assign_pointer(vlansdata
->u
.vlan
.sta
, sta
);
1518 if (sta
->sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
&&
1519 sta
->sdata
->u
.vlan
.sta
) {
1520 rcu_assign_pointer(sta
->sdata
->u
.vlan
.sta
, NULL
);
1524 sta
->sdata
= vlansdata
;
1526 if (sta
->sta_state
== IEEE80211_STA_AUTHORIZED
&&
1527 prev_4addr
!= new_4addr
) {
1529 atomic_dec(&sta
->sdata
->bss
->num_mcast_sta
);
1531 atomic_inc(&sta
->sdata
->bss
->num_mcast_sta
);
1534 ieee80211_send_layer2_update(sta
);
1537 err
= sta_apply_parameters(local
, sta
, params
);
1541 /* When peer becomes authorized, init rate control as well */
1542 if (test_sta_flag(sta
, WLAN_STA_TDLS_PEER
) &&
1543 test_sta_flag(sta
, WLAN_STA_AUTHORIZED
))
1544 rate_control_rate_init(sta
);
1546 mutex_unlock(&local
->sta_mtx
);
1548 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
&&
1549 params
->sta_flags_mask
& BIT(NL80211_STA_FLAG_AUTHORIZED
)) {
1550 ieee80211_recalc_ps(local
, -1);
1551 ieee80211_recalc_ps_vif(sdata
);
1556 mutex_unlock(&local
->sta_mtx
);
1560 #ifdef CONFIG_MAC80211_MESH
1561 static int ieee80211_add_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
1562 u8
*dst
, u8
*next_hop
)
1564 struct ieee80211_sub_if_data
*sdata
;
1565 struct mesh_path
*mpath
;
1566 struct sta_info
*sta
;
1568 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1571 sta
= sta_info_get(sdata
, next_hop
);
1577 mpath
= mesh_path_add(sdata
, dst
);
1578 if (IS_ERR(mpath
)) {
1580 return PTR_ERR(mpath
);
1583 mesh_path_fix_nexthop(mpath
, sta
);
1589 static int ieee80211_del_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
1592 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1595 return mesh_path_del(sdata
, dst
);
1597 mesh_path_flush_by_iface(sdata
);
1601 static int ieee80211_change_mpath(struct wiphy
*wiphy
,
1602 struct net_device
*dev
,
1603 u8
*dst
, u8
*next_hop
)
1605 struct ieee80211_sub_if_data
*sdata
;
1606 struct mesh_path
*mpath
;
1607 struct sta_info
*sta
;
1609 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1613 sta
= sta_info_get(sdata
, next_hop
);
1619 mpath
= mesh_path_lookup(sdata
, dst
);
1625 mesh_path_fix_nexthop(mpath
, sta
);
1631 static void mpath_set_pinfo(struct mesh_path
*mpath
, u8
*next_hop
,
1632 struct mpath_info
*pinfo
)
1634 struct sta_info
*next_hop_sta
= rcu_dereference(mpath
->next_hop
);
1637 memcpy(next_hop
, next_hop_sta
->sta
.addr
, ETH_ALEN
);
1639 memset(next_hop
, 0, ETH_ALEN
);
1641 memset(pinfo
, 0, sizeof(*pinfo
));
1643 pinfo
->generation
= mesh_paths_generation
;
1645 pinfo
->filled
= MPATH_INFO_FRAME_QLEN
|
1648 MPATH_INFO_EXPTIME
|
1649 MPATH_INFO_DISCOVERY_TIMEOUT
|
1650 MPATH_INFO_DISCOVERY_RETRIES
|
1653 pinfo
->frame_qlen
= mpath
->frame_queue
.qlen
;
1654 pinfo
->sn
= mpath
->sn
;
1655 pinfo
->metric
= mpath
->metric
;
1656 if (time_before(jiffies
, mpath
->exp_time
))
1657 pinfo
->exptime
= jiffies_to_msecs(mpath
->exp_time
- jiffies
);
1658 pinfo
->discovery_timeout
=
1659 jiffies_to_msecs(mpath
->discovery_timeout
);
1660 pinfo
->discovery_retries
= mpath
->discovery_retries
;
1661 if (mpath
->flags
& MESH_PATH_ACTIVE
)
1662 pinfo
->flags
|= NL80211_MPATH_FLAG_ACTIVE
;
1663 if (mpath
->flags
& MESH_PATH_RESOLVING
)
1664 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
1665 if (mpath
->flags
& MESH_PATH_SN_VALID
)
1666 pinfo
->flags
|= NL80211_MPATH_FLAG_SN_VALID
;
1667 if (mpath
->flags
& MESH_PATH_FIXED
)
1668 pinfo
->flags
|= NL80211_MPATH_FLAG_FIXED
;
1669 if (mpath
->flags
& MESH_PATH_RESOLVED
)
1670 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVED
;
1673 static int ieee80211_get_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
1674 u8
*dst
, u8
*next_hop
, struct mpath_info
*pinfo
)
1677 struct ieee80211_sub_if_data
*sdata
;
1678 struct mesh_path
*mpath
;
1680 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1683 mpath
= mesh_path_lookup(sdata
, dst
);
1688 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
1689 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
1694 static int ieee80211_dump_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
1695 int idx
, u8
*dst
, u8
*next_hop
,
1696 struct mpath_info
*pinfo
)
1698 struct ieee80211_sub_if_data
*sdata
;
1699 struct mesh_path
*mpath
;
1701 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1704 mpath
= mesh_path_lookup_by_idx(sdata
, idx
);
1709 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
1710 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
1715 static int ieee80211_get_mesh_config(struct wiphy
*wiphy
,
1716 struct net_device
*dev
,
1717 struct mesh_config
*conf
)
1719 struct ieee80211_sub_if_data
*sdata
;
1720 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1722 memcpy(conf
, &(sdata
->u
.mesh
.mshcfg
), sizeof(struct mesh_config
));
1726 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm
, u32 mask
)
1728 return (mask
>> (parm
-1)) & 0x1;
1731 static int copy_mesh_setup(struct ieee80211_if_mesh
*ifmsh
,
1732 const struct mesh_setup
*setup
)
1736 struct ieee80211_sub_if_data
*sdata
= container_of(ifmsh
,
1737 struct ieee80211_sub_if_data
, u
.mesh
);
1739 /* allocate information elements */
1743 if (setup
->ie_len
) {
1744 new_ie
= kmemdup(setup
->ie
, setup
->ie_len
,
1749 ifmsh
->ie_len
= setup
->ie_len
;
1753 /* now copy the rest of the setup parameters */
1754 ifmsh
->mesh_id_len
= setup
->mesh_id_len
;
1755 memcpy(ifmsh
->mesh_id
, setup
->mesh_id
, ifmsh
->mesh_id_len
);
1756 ifmsh
->mesh_sp_id
= setup
->sync_method
;
1757 ifmsh
->mesh_pp_id
= setup
->path_sel_proto
;
1758 ifmsh
->mesh_pm_id
= setup
->path_metric
;
1759 ifmsh
->user_mpm
= setup
->user_mpm
;
1760 ifmsh
->mesh_auth_id
= setup
->auth_id
;
1761 ifmsh
->security
= IEEE80211_MESH_SEC_NONE
;
1762 if (setup
->is_authenticated
)
1763 ifmsh
->security
|= IEEE80211_MESH_SEC_AUTHED
;
1764 if (setup
->is_secure
)
1765 ifmsh
->security
|= IEEE80211_MESH_SEC_SECURED
;
1767 /* mcast rate setting in Mesh Node */
1768 memcpy(sdata
->vif
.bss_conf
.mcast_rate
, setup
->mcast_rate
,
1769 sizeof(setup
->mcast_rate
));
1770 sdata
->vif
.bss_conf
.basic_rates
= setup
->basic_rates
;
1772 sdata
->vif
.bss_conf
.beacon_int
= setup
->beacon_interval
;
1773 sdata
->vif
.bss_conf
.dtim_period
= setup
->dtim_period
;
1778 static int ieee80211_update_mesh_config(struct wiphy
*wiphy
,
1779 struct net_device
*dev
, u32 mask
,
1780 const struct mesh_config
*nconf
)
1782 struct mesh_config
*conf
;
1783 struct ieee80211_sub_if_data
*sdata
;
1784 struct ieee80211_if_mesh
*ifmsh
;
1786 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1787 ifmsh
= &sdata
->u
.mesh
;
1789 /* Set the config options which we are interested in setting */
1790 conf
= &(sdata
->u
.mesh
.mshcfg
);
1791 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT
, mask
))
1792 conf
->dot11MeshRetryTimeout
= nconf
->dot11MeshRetryTimeout
;
1793 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT
, mask
))
1794 conf
->dot11MeshConfirmTimeout
= nconf
->dot11MeshConfirmTimeout
;
1795 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT
, mask
))
1796 conf
->dot11MeshHoldingTimeout
= nconf
->dot11MeshHoldingTimeout
;
1797 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS
, mask
))
1798 conf
->dot11MeshMaxPeerLinks
= nconf
->dot11MeshMaxPeerLinks
;
1799 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES
, mask
))
1800 conf
->dot11MeshMaxRetries
= nconf
->dot11MeshMaxRetries
;
1801 if (_chg_mesh_attr(NL80211_MESHCONF_TTL
, mask
))
1802 conf
->dot11MeshTTL
= nconf
->dot11MeshTTL
;
1803 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL
, mask
))
1804 conf
->element_ttl
= nconf
->element_ttl
;
1805 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS
, mask
)) {
1806 if (ifmsh
->user_mpm
)
1808 conf
->auto_open_plinks
= nconf
->auto_open_plinks
;
1810 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR
, mask
))
1811 conf
->dot11MeshNbrOffsetMaxNeighbor
=
1812 nconf
->dot11MeshNbrOffsetMaxNeighbor
;
1813 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES
, mask
))
1814 conf
->dot11MeshHWMPmaxPREQretries
=
1815 nconf
->dot11MeshHWMPmaxPREQretries
;
1816 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME
, mask
))
1817 conf
->path_refresh_time
= nconf
->path_refresh_time
;
1818 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT
, mask
))
1819 conf
->min_discovery_timeout
= nconf
->min_discovery_timeout
;
1820 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT
, mask
))
1821 conf
->dot11MeshHWMPactivePathTimeout
=
1822 nconf
->dot11MeshHWMPactivePathTimeout
;
1823 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL
, mask
))
1824 conf
->dot11MeshHWMPpreqMinInterval
=
1825 nconf
->dot11MeshHWMPpreqMinInterval
;
1826 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL
, mask
))
1827 conf
->dot11MeshHWMPperrMinInterval
=
1828 nconf
->dot11MeshHWMPperrMinInterval
;
1829 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME
,
1831 conf
->dot11MeshHWMPnetDiameterTraversalTime
=
1832 nconf
->dot11MeshHWMPnetDiameterTraversalTime
;
1833 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE
, mask
)) {
1834 conf
->dot11MeshHWMPRootMode
= nconf
->dot11MeshHWMPRootMode
;
1835 ieee80211_mesh_root_setup(ifmsh
);
1837 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS
, mask
)) {
1838 /* our current gate announcement implementation rides on root
1839 * announcements, so require this ifmsh to also be a root node
1841 if (nconf
->dot11MeshGateAnnouncementProtocol
&&
1842 !(conf
->dot11MeshHWMPRootMode
> IEEE80211_ROOTMODE_ROOT
)) {
1843 conf
->dot11MeshHWMPRootMode
= IEEE80211_PROACTIVE_RANN
;
1844 ieee80211_mesh_root_setup(ifmsh
);
1846 conf
->dot11MeshGateAnnouncementProtocol
=
1847 nconf
->dot11MeshGateAnnouncementProtocol
;
1849 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL
, mask
))
1850 conf
->dot11MeshHWMPRannInterval
=
1851 nconf
->dot11MeshHWMPRannInterval
;
1852 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING
, mask
))
1853 conf
->dot11MeshForwarding
= nconf
->dot11MeshForwarding
;
1854 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD
, mask
)) {
1855 /* our RSSI threshold implementation is supported only for
1856 * devices that report signal in dBm.
1858 if (!(sdata
->local
->hw
.flags
& IEEE80211_HW_SIGNAL_DBM
))
1860 conf
->rssi_threshold
= nconf
->rssi_threshold
;
1862 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE
, mask
)) {
1863 conf
->ht_opmode
= nconf
->ht_opmode
;
1864 sdata
->vif
.bss_conf
.ht_operation_mode
= nconf
->ht_opmode
;
1865 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_HT
);
1867 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT
, mask
))
1868 conf
->dot11MeshHWMPactivePathToRootTimeout
=
1869 nconf
->dot11MeshHWMPactivePathToRootTimeout
;
1870 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL
, mask
))
1871 conf
->dot11MeshHWMProotInterval
=
1872 nconf
->dot11MeshHWMProotInterval
;
1873 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL
, mask
))
1874 conf
->dot11MeshHWMPconfirmationInterval
=
1875 nconf
->dot11MeshHWMPconfirmationInterval
;
1876 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE
, mask
)) {
1877 conf
->power_mode
= nconf
->power_mode
;
1878 ieee80211_mps_local_status_update(sdata
);
1880 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW
, mask
))
1881 conf
->dot11MeshAwakeWindowDuration
=
1882 nconf
->dot11MeshAwakeWindowDuration
;
1883 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT
, mask
))
1884 conf
->plink_timeout
= nconf
->plink_timeout
;
1885 ieee80211_mbss_info_change_notify(sdata
, BSS_CHANGED_BEACON
);
1889 static int ieee80211_join_mesh(struct wiphy
*wiphy
, struct net_device
*dev
,
1890 const struct mesh_config
*conf
,
1891 const struct mesh_setup
*setup
)
1893 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1894 struct ieee80211_if_mesh
*ifmsh
= &sdata
->u
.mesh
;
1897 memcpy(&ifmsh
->mshcfg
, conf
, sizeof(struct mesh_config
));
1898 err
= copy_mesh_setup(ifmsh
, setup
);
1902 /* can mesh use other SMPS modes? */
1903 sdata
->smps_mode
= IEEE80211_SMPS_OFF
;
1904 sdata
->needed_rx_chains
= sdata
->local
->rx_chains
;
1906 err
= ieee80211_vif_use_channel(sdata
, &setup
->chandef
,
1907 IEEE80211_CHANCTX_SHARED
);
1911 return ieee80211_start_mesh(sdata
);
1914 static int ieee80211_leave_mesh(struct wiphy
*wiphy
, struct net_device
*dev
)
1916 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1918 ieee80211_stop_mesh(sdata
);
1919 ieee80211_vif_release_channel(sdata
);
1925 static int ieee80211_change_bss(struct wiphy
*wiphy
,
1926 struct net_device
*dev
,
1927 struct bss_parameters
*params
)
1929 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1930 enum ieee80211_band band
;
1933 if (!rtnl_dereference(sdata
->u
.ap
.beacon
))
1936 band
= ieee80211_get_sdata_band(sdata
);
1938 if (params
->use_cts_prot
>= 0) {
1939 sdata
->vif
.bss_conf
.use_cts_prot
= params
->use_cts_prot
;
1940 changed
|= BSS_CHANGED_ERP_CTS_PROT
;
1942 if (params
->use_short_preamble
>= 0) {
1943 sdata
->vif
.bss_conf
.use_short_preamble
=
1944 params
->use_short_preamble
;
1945 changed
|= BSS_CHANGED_ERP_PREAMBLE
;
1948 if (!sdata
->vif
.bss_conf
.use_short_slot
&&
1949 band
== IEEE80211_BAND_5GHZ
) {
1950 sdata
->vif
.bss_conf
.use_short_slot
= true;
1951 changed
|= BSS_CHANGED_ERP_SLOT
;
1954 if (params
->use_short_slot_time
>= 0) {
1955 sdata
->vif
.bss_conf
.use_short_slot
=
1956 params
->use_short_slot_time
;
1957 changed
|= BSS_CHANGED_ERP_SLOT
;
1960 if (params
->basic_rates
) {
1963 struct ieee80211_supported_band
*sband
= wiphy
->bands
[band
];
1965 for (i
= 0; i
< params
->basic_rates_len
; i
++) {
1966 int rate
= (params
->basic_rates
[i
] & 0x7f) * 5;
1967 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
1968 if (sband
->bitrates
[j
].bitrate
== rate
)
1972 sdata
->vif
.bss_conf
.basic_rates
= rates
;
1973 changed
|= BSS_CHANGED_BASIC_RATES
;
1976 if (params
->ap_isolate
>= 0) {
1977 if (params
->ap_isolate
)
1978 sdata
->flags
|= IEEE80211_SDATA_DONT_BRIDGE_PACKETS
;
1980 sdata
->flags
&= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS
;
1983 if (params
->ht_opmode
>= 0) {
1984 sdata
->vif
.bss_conf
.ht_operation_mode
=
1985 (u16
) params
->ht_opmode
;
1986 changed
|= BSS_CHANGED_HT
;
1989 if (params
->p2p_ctwindow
>= 0) {
1990 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
&=
1991 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK
;
1992 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
|=
1993 params
->p2p_ctwindow
& IEEE80211_P2P_OPPPS_CTWINDOW_MASK
;
1994 changed
|= BSS_CHANGED_P2P_PS
;
1997 if (params
->p2p_opp_ps
> 0) {
1998 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
|=
1999 IEEE80211_P2P_OPPPS_ENABLE_BIT
;
2000 changed
|= BSS_CHANGED_P2P_PS
;
2001 } else if (params
->p2p_opp_ps
== 0) {
2002 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
&=
2003 ~IEEE80211_P2P_OPPPS_ENABLE_BIT
;
2004 changed
|= BSS_CHANGED_P2P_PS
;
2007 ieee80211_bss_info_change_notify(sdata
, changed
);
2012 static int ieee80211_set_txq_params(struct wiphy
*wiphy
,
2013 struct net_device
*dev
,
2014 struct ieee80211_txq_params
*params
)
2016 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2017 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2018 struct ieee80211_tx_queue_params p
;
2020 if (!local
->ops
->conf_tx
)
2023 if (local
->hw
.queues
< IEEE80211_NUM_ACS
)
2026 memset(&p
, 0, sizeof(p
));
2027 p
.aifs
= params
->aifs
;
2028 p
.cw_max
= params
->cwmax
;
2029 p
.cw_min
= params
->cwmin
;
2030 p
.txop
= params
->txop
;
2033 * Setting tx queue params disables u-apsd because it's only
2034 * called in master mode.
2038 sdata
->tx_conf
[params
->ac
] = p
;
2039 if (drv_conf_tx(local
, sdata
, params
->ac
, &p
)) {
2040 wiphy_debug(local
->hw
.wiphy
,
2041 "failed to set TX queue parameters for AC %d\n",
2046 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_QOS
);
2052 static int ieee80211_suspend(struct wiphy
*wiphy
,
2053 struct cfg80211_wowlan
*wowlan
)
2055 return __ieee80211_suspend(wiphy_priv(wiphy
), wowlan
);
2058 static int ieee80211_resume(struct wiphy
*wiphy
)
2060 return __ieee80211_resume(wiphy_priv(wiphy
));
2063 #define ieee80211_suspend NULL
2064 #define ieee80211_resume NULL
2067 static int ieee80211_scan(struct wiphy
*wiphy
,
2068 struct cfg80211_scan_request
*req
)
2070 struct ieee80211_sub_if_data
*sdata
;
2072 sdata
= IEEE80211_WDEV_TO_SUB_IF(req
->wdev
);
2074 switch (ieee80211_vif_type_p2p(&sdata
->vif
)) {
2075 case NL80211_IFTYPE_STATION
:
2076 case NL80211_IFTYPE_ADHOC
:
2077 case NL80211_IFTYPE_MESH_POINT
:
2078 case NL80211_IFTYPE_P2P_CLIENT
:
2079 case NL80211_IFTYPE_P2P_DEVICE
:
2081 case NL80211_IFTYPE_P2P_GO
:
2082 if (sdata
->local
->ops
->hw_scan
)
2085 * FIXME: implement NoA while scanning in software,
2086 * for now fall through to allow scanning only when
2087 * beaconing hasn't been configured yet
2089 case NL80211_IFTYPE_AP
:
2091 * If the scan has been forced (and the driver supports
2092 * forcing), don't care about being beaconing already.
2093 * This will create problems to the attached stations (e.g. all
2094 * the frames sent while scanning on other channel will be
2097 if (sdata
->u
.ap
.beacon
&&
2098 (!(wiphy
->features
& NL80211_FEATURE_AP_SCAN
) ||
2099 !(req
->flags
& NL80211_SCAN_FLAG_AP
)))
2106 return ieee80211_request_scan(sdata
, req
);
2110 ieee80211_sched_scan_start(struct wiphy
*wiphy
,
2111 struct net_device
*dev
,
2112 struct cfg80211_sched_scan_request
*req
)
2114 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2116 if (!sdata
->local
->ops
->sched_scan_start
)
2119 return ieee80211_request_sched_scan_start(sdata
, req
);
2123 ieee80211_sched_scan_stop(struct wiphy
*wiphy
, struct net_device
*dev
)
2125 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2127 if (!sdata
->local
->ops
->sched_scan_stop
)
2130 return ieee80211_request_sched_scan_stop(sdata
);
2133 static int ieee80211_auth(struct wiphy
*wiphy
, struct net_device
*dev
,
2134 struct cfg80211_auth_request
*req
)
2136 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev
), req
);
2139 static int ieee80211_assoc(struct wiphy
*wiphy
, struct net_device
*dev
,
2140 struct cfg80211_assoc_request
*req
)
2142 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev
), req
);
2145 static int ieee80211_deauth(struct wiphy
*wiphy
, struct net_device
*dev
,
2146 struct cfg80211_deauth_request
*req
)
2148 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev
), req
);
2151 static int ieee80211_disassoc(struct wiphy
*wiphy
, struct net_device
*dev
,
2152 struct cfg80211_disassoc_request
*req
)
2154 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev
), req
);
2157 static int ieee80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
2158 struct cfg80211_ibss_params
*params
)
2160 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev
), params
);
2163 static int ieee80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
2165 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev
));
2168 static int ieee80211_set_mcast_rate(struct wiphy
*wiphy
, struct net_device
*dev
,
2169 int rate
[IEEE80211_NUM_BANDS
])
2171 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2173 memcpy(sdata
->vif
.bss_conf
.mcast_rate
, rate
,
2174 sizeof(int) * IEEE80211_NUM_BANDS
);
2179 static int ieee80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
2181 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2184 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
2185 err
= drv_set_frag_threshold(local
, wiphy
->frag_threshold
);
2191 if (changed
& WIPHY_PARAM_COVERAGE_CLASS
) {
2192 err
= drv_set_coverage_class(local
, wiphy
->coverage_class
);
2198 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
2199 err
= drv_set_rts_threshold(local
, wiphy
->rts_threshold
);
2205 if (changed
& WIPHY_PARAM_RETRY_SHORT
) {
2206 if (wiphy
->retry_short
> IEEE80211_MAX_TX_RETRY
)
2208 local
->hw
.conf
.short_frame_max_tx_count
= wiphy
->retry_short
;
2210 if (changed
& WIPHY_PARAM_RETRY_LONG
) {
2211 if (wiphy
->retry_long
> IEEE80211_MAX_TX_RETRY
)
2213 local
->hw
.conf
.long_frame_max_tx_count
= wiphy
->retry_long
;
2216 (WIPHY_PARAM_RETRY_SHORT
| WIPHY_PARAM_RETRY_LONG
))
2217 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_RETRY_LIMITS
);
2222 static int ieee80211_set_tx_power(struct wiphy
*wiphy
,
2223 struct wireless_dev
*wdev
,
2224 enum nl80211_tx_power_setting type
, int mbm
)
2226 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2227 struct ieee80211_sub_if_data
*sdata
;
2230 sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
2233 case NL80211_TX_POWER_AUTOMATIC
:
2234 sdata
->user_power_level
= IEEE80211_UNSET_POWER_LEVEL
;
2236 case NL80211_TX_POWER_LIMITED
:
2237 case NL80211_TX_POWER_FIXED
:
2238 if (mbm
< 0 || (mbm
% 100))
2240 sdata
->user_power_level
= MBM_TO_DBM(mbm
);
2244 ieee80211_recalc_txpower(sdata
);
2250 case NL80211_TX_POWER_AUTOMATIC
:
2251 local
->user_power_level
= IEEE80211_UNSET_POWER_LEVEL
;
2253 case NL80211_TX_POWER_LIMITED
:
2254 case NL80211_TX_POWER_FIXED
:
2255 if (mbm
< 0 || (mbm
% 100))
2257 local
->user_power_level
= MBM_TO_DBM(mbm
);
2261 mutex_lock(&local
->iflist_mtx
);
2262 list_for_each_entry(sdata
, &local
->interfaces
, list
)
2263 sdata
->user_power_level
= local
->user_power_level
;
2264 list_for_each_entry(sdata
, &local
->interfaces
, list
)
2265 ieee80211_recalc_txpower(sdata
);
2266 mutex_unlock(&local
->iflist_mtx
);
2271 static int ieee80211_get_tx_power(struct wiphy
*wiphy
,
2272 struct wireless_dev
*wdev
,
2275 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2276 struct ieee80211_sub_if_data
*sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
2278 if (!local
->use_chanctx
)
2279 *dbm
= local
->hw
.conf
.power_level
;
2281 *dbm
= sdata
->vif
.bss_conf
.txpower
;
2286 static int ieee80211_set_wds_peer(struct wiphy
*wiphy
, struct net_device
*dev
,
2289 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2291 memcpy(&sdata
->u
.wds
.remote_addr
, addr
, ETH_ALEN
);
2296 static void ieee80211_rfkill_poll(struct wiphy
*wiphy
)
2298 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2300 drv_rfkill_poll(local
);
2303 #ifdef CONFIG_NL80211_TESTMODE
2304 static int ieee80211_testmode_cmd(struct wiphy
*wiphy
, void *data
, int len
)
2306 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2308 if (!local
->ops
->testmode_cmd
)
2311 return local
->ops
->testmode_cmd(&local
->hw
, data
, len
);
2314 static int ieee80211_testmode_dump(struct wiphy
*wiphy
,
2315 struct sk_buff
*skb
,
2316 struct netlink_callback
*cb
,
2317 void *data
, int len
)
2319 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2321 if (!local
->ops
->testmode_dump
)
2324 return local
->ops
->testmode_dump(&local
->hw
, skb
, cb
, data
, len
);
2328 int __ieee80211_request_smps(struct ieee80211_sub_if_data
*sdata
,
2329 enum ieee80211_smps_mode smps_mode
)
2332 enum ieee80211_smps_mode old_req
;
2335 lockdep_assert_held(&sdata
->wdev
.mtx
);
2337 old_req
= sdata
->u
.mgd
.req_smps
;
2338 sdata
->u
.mgd
.req_smps
= smps_mode
;
2340 if (old_req
== smps_mode
&&
2341 smps_mode
!= IEEE80211_SMPS_AUTOMATIC
)
2345 * If not associated, or current association is not an HT
2346 * association, there's no need to do anything, just store
2347 * the new value until we associate.
2349 if (!sdata
->u
.mgd
.associated
||
2350 sdata
->vif
.bss_conf
.chandef
.width
== NL80211_CHAN_WIDTH_20_NOHT
)
2353 ap
= sdata
->u
.mgd
.associated
->bssid
;
2355 if (smps_mode
== IEEE80211_SMPS_AUTOMATIC
) {
2356 if (sdata
->u
.mgd
.powersave
)
2357 smps_mode
= IEEE80211_SMPS_DYNAMIC
;
2359 smps_mode
= IEEE80211_SMPS_OFF
;
2362 /* send SM PS frame to AP */
2363 err
= ieee80211_send_smps_action(sdata
, smps_mode
,
2366 sdata
->u
.mgd
.req_smps
= old_req
;
2371 static int ieee80211_set_power_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
2372 bool enabled
, int timeout
)
2374 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2375 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
2377 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
&&
2378 sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
)
2381 if (!(local
->hw
.flags
& IEEE80211_HW_SUPPORTS_PS
))
2384 if (enabled
== sdata
->u
.mgd
.powersave
&&
2385 timeout
== local
->dynamic_ps_forced_timeout
)
2388 sdata
->u
.mgd
.powersave
= enabled
;
2389 local
->dynamic_ps_forced_timeout
= timeout
;
2391 /* no change, but if automatic follow powersave */
2393 __ieee80211_request_smps(sdata
, sdata
->u
.mgd
.req_smps
);
2394 sdata_unlock(sdata
);
2396 if (local
->hw
.flags
& IEEE80211_HW_SUPPORTS_DYNAMIC_PS
)
2397 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_PS
);
2399 ieee80211_recalc_ps(local
, -1);
2400 ieee80211_recalc_ps_vif(sdata
);
2405 static int ieee80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
2406 struct net_device
*dev
,
2407 s32 rssi_thold
, u32 rssi_hyst
)
2409 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2410 struct ieee80211_vif
*vif
= &sdata
->vif
;
2411 struct ieee80211_bss_conf
*bss_conf
= &vif
->bss_conf
;
2413 if (rssi_thold
== bss_conf
->cqm_rssi_thold
&&
2414 rssi_hyst
== bss_conf
->cqm_rssi_hyst
)
2417 bss_conf
->cqm_rssi_thold
= rssi_thold
;
2418 bss_conf
->cqm_rssi_hyst
= rssi_hyst
;
2420 /* tell the driver upon association, unless already associated */
2421 if (sdata
->u
.mgd
.associated
&&
2422 sdata
->vif
.driver_flags
& IEEE80211_VIF_SUPPORTS_CQM_RSSI
)
2423 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_CQM
);
2428 static int ieee80211_set_bitrate_mask(struct wiphy
*wiphy
,
2429 struct net_device
*dev
,
2431 const struct cfg80211_bitrate_mask
*mask
)
2433 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2434 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
2437 if (!ieee80211_sdata_running(sdata
))
2440 if (local
->hw
.flags
& IEEE80211_HW_HAS_RATE_CONTROL
) {
2441 ret
= drv_set_bitrate_mask(local
, sdata
, mask
);
2446 for (i
= 0; i
< IEEE80211_NUM_BANDS
; i
++) {
2447 struct ieee80211_supported_band
*sband
= wiphy
->bands
[i
];
2450 sdata
->rc_rateidx_mask
[i
] = mask
->control
[i
].legacy
;
2451 memcpy(sdata
->rc_rateidx_mcs_mask
[i
], mask
->control
[i
].mcs
,
2452 sizeof(mask
->control
[i
].mcs
));
2454 sdata
->rc_has_mcs_mask
[i
] = false;
2458 for (j
= 0; j
< IEEE80211_HT_MCS_MASK_LEN
; j
++)
2459 if (~sdata
->rc_rateidx_mcs_mask
[i
][j
]) {
2460 sdata
->rc_has_mcs_mask
[i
] = true;
2468 static int ieee80211_start_roc_work(struct ieee80211_local
*local
,
2469 struct ieee80211_sub_if_data
*sdata
,
2470 struct ieee80211_channel
*channel
,
2471 unsigned int duration
, u64
*cookie
,
2472 struct sk_buff
*txskb
,
2473 enum ieee80211_roc_type type
)
2475 struct ieee80211_roc_work
*roc
, *tmp
;
2476 bool queued
= false;
2479 lockdep_assert_held(&local
->mtx
);
2481 if (local
->use_chanctx
&& !local
->ops
->remain_on_channel
)
2484 roc
= kzalloc(sizeof(*roc
), GFP_KERNEL
);
2488 roc
->chan
= channel
;
2489 roc
->duration
= duration
;
2490 roc
->req_duration
= duration
;
2493 roc
->mgmt_tx_cookie
= (unsigned long)txskb
;
2495 INIT_DELAYED_WORK(&roc
->work
, ieee80211_sw_roc_work
);
2496 INIT_LIST_HEAD(&roc
->dependents
);
2498 /* if there's one pending or we're scanning, queue this one */
2499 if (!list_empty(&local
->roc_list
) ||
2500 local
->scanning
|| local
->radar_detect_enabled
)
2501 goto out_check_combine
;
2503 /* if not HW assist, just queue & schedule work */
2504 if (!local
->ops
->remain_on_channel
) {
2505 ieee80211_queue_delayed_work(&local
->hw
, &roc
->work
, 0);
2509 /* otherwise actually kick it off here (for error handling) */
2512 * If the duration is zero, then the driver
2513 * wouldn't actually do anything. Set it to
2516 * TODO: cancel the off-channel operation
2517 * when we get the SKB's TX status and
2518 * the wait time was zero before.
2523 ret
= drv_remain_on_channel(local
, sdata
, channel
, duration
, type
);
2529 roc
->started
= true;
2533 list_for_each_entry(tmp
, &local
->roc_list
, list
) {
2534 if (tmp
->chan
!= channel
|| tmp
->sdata
!= sdata
)
2538 * Extend this ROC if possible:
2540 * If it hasn't started yet, just increase the duration
2541 * and add the new one to the list of dependents.
2542 * If the type of the new ROC has higher priority, modify the
2543 * type of the previous one to match that of the new one.
2545 if (!tmp
->started
) {
2546 list_add_tail(&roc
->list
, &tmp
->dependents
);
2547 tmp
->duration
= max(tmp
->duration
, roc
->duration
);
2548 tmp
->type
= max(tmp
->type
, roc
->type
);
2553 /* If it has already started, it's more difficult ... */
2554 if (local
->ops
->remain_on_channel
) {
2555 unsigned long j
= jiffies
;
2558 * In the offloaded ROC case, if it hasn't begun, add
2559 * this new one to the dependent list to be handled
2560 * when the master one begins. If it has begun,
2561 * check that there's still a minimum time left and
2562 * if so, start this one, transmitting the frame, but
2563 * add it to the list directly after this one with
2564 * a reduced time so we'll ask the driver to execute
2565 * it right after finishing the previous one, in the
2566 * hope that it'll also be executed right afterwards,
2567 * effectively extending the old one.
2568 * If there's no minimum time left, just add it to the
2570 * TODO: the ROC type is ignored here, assuming that it
2571 * is better to immediately use the current ROC.
2573 if (!tmp
->hw_begun
) {
2574 list_add_tail(&roc
->list
, &tmp
->dependents
);
2579 if (time_before(j
+ IEEE80211_ROC_MIN_LEFT
,
2580 tmp
->hw_start_time
+
2581 msecs_to_jiffies(tmp
->duration
))) {
2584 ieee80211_handle_roc_started(roc
);
2586 new_dur
= roc
->duration
-
2587 jiffies_to_msecs(tmp
->hw_start_time
+
2593 /* add right after tmp */
2594 list_add(&roc
->list
, &tmp
->list
);
2596 list_add_tail(&roc
->list
,
2601 } else if (del_timer_sync(&tmp
->work
.timer
)) {
2602 unsigned long new_end
;
2605 * In the software ROC case, cancel the timer, if
2606 * that fails then the finish work is already
2607 * queued/pending and thus we queue the new ROC
2608 * normally, if that succeeds then we can extend
2609 * the timer duration and TX the frame (if any.)
2612 list_add_tail(&roc
->list
, &tmp
->dependents
);
2615 new_end
= jiffies
+ msecs_to_jiffies(roc
->duration
);
2617 /* ok, it was started & we canceled timer */
2618 if (time_after(new_end
, tmp
->work
.timer
.expires
))
2619 mod_timer(&tmp
->work
.timer
, new_end
);
2621 add_timer(&tmp
->work
.timer
);
2623 ieee80211_handle_roc_started(roc
);
2630 list_add_tail(&roc
->list
, &local
->roc_list
);
2633 * cookie is either the roc cookie (for normal roc)
2634 * or the SKB (for mgmt TX)
2637 /* local->mtx protects this */
2638 local
->roc_cookie_counter
++;
2639 roc
->cookie
= local
->roc_cookie_counter
;
2640 /* wow, you wrapped 64 bits ... more likely a bug */
2641 if (WARN_ON(roc
->cookie
== 0)) {
2643 local
->roc_cookie_counter
++;
2645 *cookie
= roc
->cookie
;
2647 *cookie
= (unsigned long)txskb
;
2653 static int ieee80211_remain_on_channel(struct wiphy
*wiphy
,
2654 struct wireless_dev
*wdev
,
2655 struct ieee80211_channel
*chan
,
2656 unsigned int duration
,
2659 struct ieee80211_sub_if_data
*sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
2660 struct ieee80211_local
*local
= sdata
->local
;
2663 mutex_lock(&local
->mtx
);
2664 ret
= ieee80211_start_roc_work(local
, sdata
, chan
,
2665 duration
, cookie
, NULL
,
2666 IEEE80211_ROC_TYPE_NORMAL
);
2667 mutex_unlock(&local
->mtx
);
2672 static int ieee80211_cancel_roc(struct ieee80211_local
*local
,
2673 u64 cookie
, bool mgmt_tx
)
2675 struct ieee80211_roc_work
*roc
, *tmp
, *found
= NULL
;
2678 mutex_lock(&local
->mtx
);
2679 list_for_each_entry_safe(roc
, tmp
, &local
->roc_list
, list
) {
2680 struct ieee80211_roc_work
*dep
, *tmp2
;
2682 list_for_each_entry_safe(dep
, tmp2
, &roc
->dependents
, list
) {
2683 if (!mgmt_tx
&& dep
->cookie
!= cookie
)
2685 else if (mgmt_tx
&& dep
->mgmt_tx_cookie
!= cookie
)
2687 /* found dependent item -- just remove it */
2688 list_del(&dep
->list
);
2689 mutex_unlock(&local
->mtx
);
2691 ieee80211_roc_notify_destroy(dep
, true);
2695 if (!mgmt_tx
&& roc
->cookie
!= cookie
)
2697 else if (mgmt_tx
&& roc
->mgmt_tx_cookie
!= cookie
)
2705 mutex_unlock(&local
->mtx
);
2710 * We found the item to cancel, so do that. Note that it
2711 * may have dependents, which we also cancel (and send
2712 * the expired signal for.) Not doing so would be quite
2713 * tricky here, but we may need to fix it later.
2716 if (local
->ops
->remain_on_channel
) {
2717 if (found
->started
) {
2718 ret
= drv_cancel_remain_on_channel(local
);
2719 if (WARN_ON_ONCE(ret
)) {
2720 mutex_unlock(&local
->mtx
);
2725 list_del(&found
->list
);
2728 ieee80211_start_next_roc(local
);
2729 mutex_unlock(&local
->mtx
);
2731 ieee80211_roc_notify_destroy(found
, true);
2733 /* work may be pending so use it all the time */
2734 found
->abort
= true;
2735 ieee80211_queue_delayed_work(&local
->hw
, &found
->work
, 0);
2737 mutex_unlock(&local
->mtx
);
2739 /* work will clean up etc */
2740 flush_delayed_work(&found
->work
);
2741 WARN_ON(!found
->to_be_freed
);
2748 static int ieee80211_cancel_remain_on_channel(struct wiphy
*wiphy
,
2749 struct wireless_dev
*wdev
,
2752 struct ieee80211_sub_if_data
*sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
2753 struct ieee80211_local
*local
= sdata
->local
;
2755 return ieee80211_cancel_roc(local
, cookie
, false);
2758 static int ieee80211_start_radar_detection(struct wiphy
*wiphy
,
2759 struct net_device
*dev
,
2760 struct cfg80211_chan_def
*chandef
)
2762 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2763 struct ieee80211_local
*local
= sdata
->local
;
2764 unsigned long timeout
;
2767 if (!list_empty(&local
->roc_list
) || local
->scanning
)
2770 /* whatever, but channel contexts should not complain about that one */
2771 sdata
->smps_mode
= IEEE80211_SMPS_OFF
;
2772 sdata
->needed_rx_chains
= local
->rx_chains
;
2773 sdata
->radar_required
= true;
2775 mutex_lock(&local
->iflist_mtx
);
2776 err
= ieee80211_vif_use_channel(sdata
, chandef
,
2777 IEEE80211_CHANCTX_SHARED
);
2778 mutex_unlock(&local
->iflist_mtx
);
2782 timeout
= msecs_to_jiffies(IEEE80211_DFS_MIN_CAC_TIME_MS
);
2783 ieee80211_queue_delayed_work(&sdata
->local
->hw
,
2784 &sdata
->dfs_cac_timer_work
, timeout
);
2789 static int ieee80211_mgmt_tx(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
2790 struct ieee80211_channel
*chan
, bool offchan
,
2791 unsigned int wait
, const u8
*buf
, size_t len
,
2792 bool no_cck
, bool dont_wait_for_ack
, u64
*cookie
)
2794 struct ieee80211_sub_if_data
*sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
2795 struct ieee80211_local
*local
= sdata
->local
;
2796 struct sk_buff
*skb
;
2797 struct sta_info
*sta
;
2798 const struct ieee80211_mgmt
*mgmt
= (void *)buf
;
2799 bool need_offchan
= false;
2803 if (dont_wait_for_ack
)
2804 flags
= IEEE80211_TX_CTL_NO_ACK
;
2806 flags
= IEEE80211_TX_INTFL_NL80211_FRAME_TX
|
2807 IEEE80211_TX_CTL_REQ_TX_STATUS
;
2810 flags
|= IEEE80211_TX_CTL_NO_CCK_RATE
;
2812 switch (sdata
->vif
.type
) {
2813 case NL80211_IFTYPE_ADHOC
:
2814 if (!sdata
->vif
.bss_conf
.ibss_joined
)
2815 need_offchan
= true;
2817 #ifdef CONFIG_MAC80211_MESH
2818 case NL80211_IFTYPE_MESH_POINT
:
2819 if (ieee80211_vif_is_mesh(&sdata
->vif
) &&
2820 !sdata
->u
.mesh
.mesh_id_len
)
2821 need_offchan
= true;
2824 case NL80211_IFTYPE_AP
:
2825 case NL80211_IFTYPE_AP_VLAN
:
2826 case NL80211_IFTYPE_P2P_GO
:
2827 if (sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
&&
2828 !ieee80211_vif_is_mesh(&sdata
->vif
) &&
2829 !rcu_access_pointer(sdata
->bss
->beacon
))
2830 need_offchan
= true;
2831 if (!ieee80211_is_action(mgmt
->frame_control
) ||
2832 mgmt
->u
.action
.category
== WLAN_CATEGORY_PUBLIC
||
2833 mgmt
->u
.action
.category
== WLAN_CATEGORY_SELF_PROTECTED
)
2836 sta
= sta_info_get(sdata
, mgmt
->da
);
2841 case NL80211_IFTYPE_STATION
:
2842 case NL80211_IFTYPE_P2P_CLIENT
:
2843 if (!sdata
->u
.mgd
.associated
)
2844 need_offchan
= true;
2846 case NL80211_IFTYPE_P2P_DEVICE
:
2847 need_offchan
= true;
2853 /* configurations requiring offchan cannot work if no channel has been
2856 if (need_offchan
&& !chan
)
2859 mutex_lock(&local
->mtx
);
2861 /* Check if the operating channel is the requested channel */
2862 if (!need_offchan
) {
2863 struct ieee80211_chanctx_conf
*chanctx_conf
;
2866 chanctx_conf
= rcu_dereference(sdata
->vif
.chanctx_conf
);
2869 need_offchan
= chan
&& (chan
!= chanctx_conf
->def
.chan
);
2875 need_offchan
= true;
2880 if (need_offchan
&& !offchan
) {
2885 skb
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+ len
);
2890 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
2892 memcpy(skb_put(skb
, len
), buf
, len
);
2894 IEEE80211_SKB_CB(skb
)->flags
= flags
;
2896 skb
->dev
= sdata
->dev
;
2898 if (!need_offchan
) {
2899 *cookie
= (unsigned long) skb
;
2900 ieee80211_tx_skb(sdata
, skb
);
2905 IEEE80211_SKB_CB(skb
)->flags
|= IEEE80211_TX_CTL_TX_OFFCHAN
|
2906 IEEE80211_TX_INTFL_OFFCHAN_TX_OK
;
2907 if (local
->hw
.flags
& IEEE80211_HW_QUEUE_CONTROL
)
2908 IEEE80211_SKB_CB(skb
)->hw_queue
=
2909 local
->hw
.offchannel_tx_hw_queue
;
2911 /* This will handle all kinds of coalescing and immediate TX */
2912 ret
= ieee80211_start_roc_work(local
, sdata
, chan
,
2914 IEEE80211_ROC_TYPE_MGMT_TX
);
2918 mutex_unlock(&local
->mtx
);
2922 static int ieee80211_mgmt_tx_cancel_wait(struct wiphy
*wiphy
,
2923 struct wireless_dev
*wdev
,
2926 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2928 return ieee80211_cancel_roc(local
, cookie
, true);
2931 static void ieee80211_mgmt_frame_register(struct wiphy
*wiphy
,
2932 struct wireless_dev
*wdev
,
2933 u16 frame_type
, bool reg
)
2935 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2937 switch (frame_type
) {
2938 case IEEE80211_FTYPE_MGMT
| IEEE80211_STYPE_PROBE_REQ
:
2940 local
->probe_req_reg
++;
2942 local
->probe_req_reg
--;
2944 if (!local
->open_count
)
2947 ieee80211_queue_work(&local
->hw
, &local
->reconfig_filter
);
2954 static int ieee80211_set_antenna(struct wiphy
*wiphy
, u32 tx_ant
, u32 rx_ant
)
2956 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2961 return drv_set_antenna(local
, tx_ant
, rx_ant
);
2964 static int ieee80211_get_antenna(struct wiphy
*wiphy
, u32
*tx_ant
, u32
*rx_ant
)
2966 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2968 return drv_get_antenna(local
, tx_ant
, rx_ant
);
2971 static int ieee80211_set_ringparam(struct wiphy
*wiphy
, u32 tx
, u32 rx
)
2973 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2975 return drv_set_ringparam(local
, tx
, rx
);
2978 static void ieee80211_get_ringparam(struct wiphy
*wiphy
,
2979 u32
*tx
, u32
*tx_max
, u32
*rx
, u32
*rx_max
)
2981 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2983 drv_get_ringparam(local
, tx
, tx_max
, rx
, rx_max
);
2986 static int ieee80211_set_rekey_data(struct wiphy
*wiphy
,
2987 struct net_device
*dev
,
2988 struct cfg80211_gtk_rekey_data
*data
)
2990 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2991 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2993 if (!local
->ops
->set_rekey_data
)
2996 drv_set_rekey_data(local
, sdata
, data
);
3001 static void ieee80211_tdls_add_ext_capab(struct sk_buff
*skb
)
3003 u8
*pos
= (void *)skb_put(skb
, 7);
3005 *pos
++ = WLAN_EID_EXT_CAPABILITY
;
3006 *pos
++ = 5; /* len */
3011 *pos
++ = WLAN_EXT_CAPA5_TDLS_ENABLED
;
3014 static u16
ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data
*sdata
)
3016 struct ieee80211_local
*local
= sdata
->local
;
3020 if (ieee80211_get_sdata_band(sdata
) != IEEE80211_BAND_2GHZ
)
3023 if (!(local
->hw
.flags
& IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE
))
3024 capab
|= WLAN_CAPABILITY_SHORT_SLOT_TIME
;
3025 if (!(local
->hw
.flags
& IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE
))
3026 capab
|= WLAN_CAPABILITY_SHORT_PREAMBLE
;
3031 static void ieee80211_tdls_add_link_ie(struct sk_buff
*skb
, u8
*src_addr
,
3032 u8
*peer
, u8
*bssid
)
3034 struct ieee80211_tdls_lnkie
*lnkid
;
3036 lnkid
= (void *)skb_put(skb
, sizeof(struct ieee80211_tdls_lnkie
));
3038 lnkid
->ie_type
= WLAN_EID_LINK_ID
;
3039 lnkid
->ie_len
= sizeof(struct ieee80211_tdls_lnkie
) - 2;
3041 memcpy(lnkid
->bssid
, bssid
, ETH_ALEN
);
3042 memcpy(lnkid
->init_sta
, src_addr
, ETH_ALEN
);
3043 memcpy(lnkid
->resp_sta
, peer
, ETH_ALEN
);
3047 ieee80211_prep_tdls_encap_data(struct wiphy
*wiphy
, struct net_device
*dev
,
3048 u8
*peer
, u8 action_code
, u8 dialog_token
,
3049 u16 status_code
, struct sk_buff
*skb
)
3051 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
3052 enum ieee80211_band band
= ieee80211_get_sdata_band(sdata
);
3053 struct ieee80211_tdls_data
*tf
;
3055 tf
= (void *)skb_put(skb
, offsetof(struct ieee80211_tdls_data
, u
));
3057 memcpy(tf
->da
, peer
, ETH_ALEN
);
3058 memcpy(tf
->sa
, sdata
->vif
.addr
, ETH_ALEN
);
3059 tf
->ether_type
= cpu_to_be16(ETH_P_TDLS
);
3060 tf
->payload_type
= WLAN_TDLS_SNAP_RFTYPE
;
3062 switch (action_code
) {
3063 case WLAN_TDLS_SETUP_REQUEST
:
3064 tf
->category
= WLAN_CATEGORY_TDLS
;
3065 tf
->action_code
= WLAN_TDLS_SETUP_REQUEST
;
3067 skb_put(skb
, sizeof(tf
->u
.setup_req
));
3068 tf
->u
.setup_req
.dialog_token
= dialog_token
;
3069 tf
->u
.setup_req
.capability
=
3070 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata
));
3072 ieee80211_add_srates_ie(sdata
, skb
, false, band
);
3073 ieee80211_add_ext_srates_ie(sdata
, skb
, false, band
);
3074 ieee80211_tdls_add_ext_capab(skb
);
3076 case WLAN_TDLS_SETUP_RESPONSE
:
3077 tf
->category
= WLAN_CATEGORY_TDLS
;
3078 tf
->action_code
= WLAN_TDLS_SETUP_RESPONSE
;
3080 skb_put(skb
, sizeof(tf
->u
.setup_resp
));
3081 tf
->u
.setup_resp
.status_code
= cpu_to_le16(status_code
);
3082 tf
->u
.setup_resp
.dialog_token
= dialog_token
;
3083 tf
->u
.setup_resp
.capability
=
3084 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata
));
3086 ieee80211_add_srates_ie(sdata
, skb
, false, band
);
3087 ieee80211_add_ext_srates_ie(sdata
, skb
, false, band
);
3088 ieee80211_tdls_add_ext_capab(skb
);
3090 case WLAN_TDLS_SETUP_CONFIRM
:
3091 tf
->category
= WLAN_CATEGORY_TDLS
;
3092 tf
->action_code
= WLAN_TDLS_SETUP_CONFIRM
;
3094 skb_put(skb
, sizeof(tf
->u
.setup_cfm
));
3095 tf
->u
.setup_cfm
.status_code
= cpu_to_le16(status_code
);
3096 tf
->u
.setup_cfm
.dialog_token
= dialog_token
;
3098 case WLAN_TDLS_TEARDOWN
:
3099 tf
->category
= WLAN_CATEGORY_TDLS
;
3100 tf
->action_code
= WLAN_TDLS_TEARDOWN
;
3102 skb_put(skb
, sizeof(tf
->u
.teardown
));
3103 tf
->u
.teardown
.reason_code
= cpu_to_le16(status_code
);
3105 case WLAN_TDLS_DISCOVERY_REQUEST
:
3106 tf
->category
= WLAN_CATEGORY_TDLS
;
3107 tf
->action_code
= WLAN_TDLS_DISCOVERY_REQUEST
;
3109 skb_put(skb
, sizeof(tf
->u
.discover_req
));
3110 tf
->u
.discover_req
.dialog_token
= dialog_token
;
3120 ieee80211_prep_tdls_direct(struct wiphy
*wiphy
, struct net_device
*dev
,
3121 u8
*peer
, u8 action_code
, u8 dialog_token
,
3122 u16 status_code
, struct sk_buff
*skb
)
3124 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
3125 enum ieee80211_band band
= ieee80211_get_sdata_band(sdata
);
3126 struct ieee80211_mgmt
*mgmt
;
3128 mgmt
= (void *)skb_put(skb
, 24);
3129 memset(mgmt
, 0, 24);
3130 memcpy(mgmt
->da
, peer
, ETH_ALEN
);
3131 memcpy(mgmt
->sa
, sdata
->vif
.addr
, ETH_ALEN
);
3132 memcpy(mgmt
->bssid
, sdata
->u
.mgd
.bssid
, ETH_ALEN
);
3134 mgmt
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
3135 IEEE80211_STYPE_ACTION
);
3137 switch (action_code
) {
3138 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3139 skb_put(skb
, 1 + sizeof(mgmt
->u
.action
.u
.tdls_discover_resp
));
3140 mgmt
->u
.action
.category
= WLAN_CATEGORY_PUBLIC
;
3141 mgmt
->u
.action
.u
.tdls_discover_resp
.action_code
=
3142 WLAN_PUB_ACTION_TDLS_DISCOVER_RES
;
3143 mgmt
->u
.action
.u
.tdls_discover_resp
.dialog_token
=
3145 mgmt
->u
.action
.u
.tdls_discover_resp
.capability
=
3146 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata
));
3148 ieee80211_add_srates_ie(sdata
, skb
, false, band
);
3149 ieee80211_add_ext_srates_ie(sdata
, skb
, false, band
);
3150 ieee80211_tdls_add_ext_capab(skb
);
3159 static int ieee80211_tdls_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
3160 u8
*peer
, u8 action_code
, u8 dialog_token
,
3161 u16 status_code
, const u8
*extra_ies
,
3162 size_t extra_ies_len
)
3164 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
3165 struct ieee80211_local
*local
= sdata
->local
;
3166 struct sk_buff
*skb
= NULL
;
3170 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
))
3173 /* make sure we are in managed mode, and associated */
3174 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
||
3175 !sdata
->u
.mgd
.associated
)
3178 tdls_dbg(sdata
, "TDLS mgmt action %d peer %pM\n",
3181 skb
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+
3182 max(sizeof(struct ieee80211_mgmt
),
3183 sizeof(struct ieee80211_tdls_data
)) +
3184 50 + /* supported rates */
3187 sizeof(struct ieee80211_tdls_lnkie
));
3191 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
3193 switch (action_code
) {
3194 case WLAN_TDLS_SETUP_REQUEST
:
3195 case WLAN_TDLS_SETUP_RESPONSE
:
3196 case WLAN_TDLS_SETUP_CONFIRM
:
3197 case WLAN_TDLS_TEARDOWN
:
3198 case WLAN_TDLS_DISCOVERY_REQUEST
:
3199 ret
= ieee80211_prep_tdls_encap_data(wiphy
, dev
, peer
,
3200 action_code
, dialog_token
,
3202 send_direct
= false;
3204 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3205 ret
= ieee80211_prep_tdls_direct(wiphy
, dev
, peer
, action_code
,
3206 dialog_token
, status_code
,
3219 memcpy(skb_put(skb
, extra_ies_len
), extra_ies
, extra_ies_len
);
3221 /* the TDLS link IE is always added last */
3222 switch (action_code
) {
3223 case WLAN_TDLS_SETUP_REQUEST
:
3224 case WLAN_TDLS_SETUP_CONFIRM
:
3225 case WLAN_TDLS_TEARDOWN
:
3226 case WLAN_TDLS_DISCOVERY_REQUEST
:
3227 /* we are the initiator */
3228 ieee80211_tdls_add_link_ie(skb
, sdata
->vif
.addr
, peer
,
3229 sdata
->u
.mgd
.bssid
);
3231 case WLAN_TDLS_SETUP_RESPONSE
:
3232 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3233 /* we are the responder */
3234 ieee80211_tdls_add_link_ie(skb
, peer
, sdata
->vif
.addr
,
3235 sdata
->u
.mgd
.bssid
);
3243 ieee80211_tx_skb(sdata
, skb
);
3248 * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise
3249 * we should default to AC_VI.
3251 switch (action_code
) {
3252 case WLAN_TDLS_SETUP_REQUEST
:
3253 case WLAN_TDLS_SETUP_RESPONSE
:
3254 skb_set_queue_mapping(skb
, IEEE80211_AC_BK
);
3258 skb_set_queue_mapping(skb
, IEEE80211_AC_VI
);
3263 /* disable bottom halves when entering the Tx path */
3265 ret
= ieee80211_subif_start_xmit(skb
, dev
);
3275 static int ieee80211_tdls_oper(struct wiphy
*wiphy
, struct net_device
*dev
,
3276 u8
*peer
, enum nl80211_tdls_operation oper
)
3278 struct sta_info
*sta
;
3279 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
3281 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
))
3284 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
3287 tdls_dbg(sdata
, "TDLS oper %d peer %pM\n", oper
, peer
);
3290 case NL80211_TDLS_ENABLE_LINK
:
3292 sta
= sta_info_get(sdata
, peer
);
3298 set_sta_flag(sta
, WLAN_STA_TDLS_PEER_AUTH
);
3301 case NL80211_TDLS_DISABLE_LINK
:
3302 return sta_info_destroy_addr(sdata
, peer
);
3303 case NL80211_TDLS_TEARDOWN
:
3304 case NL80211_TDLS_SETUP
:
3305 case NL80211_TDLS_DISCOVERY_REQ
:
3306 /* We don't support in-driver setup/teardown/discovery */
3315 static int ieee80211_probe_client(struct wiphy
*wiphy
, struct net_device
*dev
,
3316 const u8
*peer
, u64
*cookie
)
3318 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
3319 struct ieee80211_local
*local
= sdata
->local
;
3320 struct ieee80211_qos_hdr
*nullfunc
;
3321 struct sk_buff
*skb
;
3322 int size
= sizeof(*nullfunc
);
3325 struct ieee80211_tx_info
*info
;
3326 struct sta_info
*sta
;
3327 struct ieee80211_chanctx_conf
*chanctx_conf
;
3328 enum ieee80211_band band
;
3331 chanctx_conf
= rcu_dereference(sdata
->vif
.chanctx_conf
);
3332 if (WARN_ON(!chanctx_conf
)) {
3336 band
= chanctx_conf
->def
.chan
->band
;
3337 sta
= sta_info_get(sdata
, peer
);
3339 qos
= test_sta_flag(sta
, WLAN_STA_WME
);
3346 fc
= cpu_to_le16(IEEE80211_FTYPE_DATA
|
3347 IEEE80211_STYPE_QOS_NULLFUNC
|
3348 IEEE80211_FCTL_FROMDS
);
3351 fc
= cpu_to_le16(IEEE80211_FTYPE_DATA
|
3352 IEEE80211_STYPE_NULLFUNC
|
3353 IEEE80211_FCTL_FROMDS
);
3356 skb
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+ size
);
3364 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
3366 nullfunc
= (void *) skb_put(skb
, size
);
3367 nullfunc
->frame_control
= fc
;
3368 nullfunc
->duration_id
= 0;
3369 memcpy(nullfunc
->addr1
, sta
->sta
.addr
, ETH_ALEN
);
3370 memcpy(nullfunc
->addr2
, sdata
->vif
.addr
, ETH_ALEN
);
3371 memcpy(nullfunc
->addr3
, sdata
->vif
.addr
, ETH_ALEN
);
3372 nullfunc
->seq_ctrl
= 0;
3374 info
= IEEE80211_SKB_CB(skb
);
3376 info
->flags
|= IEEE80211_TX_CTL_REQ_TX_STATUS
|
3377 IEEE80211_TX_INTFL_NL80211_FRAME_TX
;
3379 skb_set_queue_mapping(skb
, IEEE80211_AC_VO
);
3382 nullfunc
->qos_ctrl
= cpu_to_le16(7);
3385 ieee80211_xmit(sdata
, skb
, band
);
3389 *cookie
= (unsigned long) skb
;
3393 static int ieee80211_cfg_get_channel(struct wiphy
*wiphy
,
3394 struct wireless_dev
*wdev
,
3395 struct cfg80211_chan_def
*chandef
)
3397 struct ieee80211_sub_if_data
*sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
3398 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
3399 struct ieee80211_chanctx_conf
*chanctx_conf
;
3403 chanctx_conf
= rcu_dereference(sdata
->vif
.chanctx_conf
);
3405 *chandef
= chanctx_conf
->def
;
3407 } else if (local
->open_count
> 0 &&
3408 local
->open_count
== local
->monitors
&&
3409 sdata
->vif
.type
== NL80211_IFTYPE_MONITOR
) {
3410 if (local
->use_chanctx
)
3411 *chandef
= local
->monitor_chandef
;
3413 *chandef
= local
->_oper_chandef
;
3422 static void ieee80211_set_wakeup(struct wiphy
*wiphy
, bool enabled
)
3424 drv_set_wakeup(wiphy_priv(wiphy
), enabled
);
3428 struct cfg80211_ops mac80211_config_ops
= {
3429 .add_virtual_intf
= ieee80211_add_iface
,
3430 .del_virtual_intf
= ieee80211_del_iface
,
3431 .change_virtual_intf
= ieee80211_change_iface
,
3432 .start_p2p_device
= ieee80211_start_p2p_device
,
3433 .stop_p2p_device
= ieee80211_stop_p2p_device
,
3434 .add_key
= ieee80211_add_key
,
3435 .del_key
= ieee80211_del_key
,
3436 .get_key
= ieee80211_get_key
,
3437 .set_default_key
= ieee80211_config_default_key
,
3438 .set_default_mgmt_key
= ieee80211_config_default_mgmt_key
,
3439 .start_ap
= ieee80211_start_ap
,
3440 .change_beacon
= ieee80211_change_beacon
,
3441 .stop_ap
= ieee80211_stop_ap
,
3442 .add_station
= ieee80211_add_station
,
3443 .del_station
= ieee80211_del_station
,
3444 .change_station
= ieee80211_change_station
,
3445 .get_station
= ieee80211_get_station
,
3446 .dump_station
= ieee80211_dump_station
,
3447 .dump_survey
= ieee80211_dump_survey
,
3448 #ifdef CONFIG_MAC80211_MESH
3449 .add_mpath
= ieee80211_add_mpath
,
3450 .del_mpath
= ieee80211_del_mpath
,
3451 .change_mpath
= ieee80211_change_mpath
,
3452 .get_mpath
= ieee80211_get_mpath
,
3453 .dump_mpath
= ieee80211_dump_mpath
,
3454 .update_mesh_config
= ieee80211_update_mesh_config
,
3455 .get_mesh_config
= ieee80211_get_mesh_config
,
3456 .join_mesh
= ieee80211_join_mesh
,
3457 .leave_mesh
= ieee80211_leave_mesh
,
3459 .change_bss
= ieee80211_change_bss
,
3460 .set_txq_params
= ieee80211_set_txq_params
,
3461 .set_monitor_channel
= ieee80211_set_monitor_channel
,
3462 .suspend
= ieee80211_suspend
,
3463 .resume
= ieee80211_resume
,
3464 .scan
= ieee80211_scan
,
3465 .sched_scan_start
= ieee80211_sched_scan_start
,
3466 .sched_scan_stop
= ieee80211_sched_scan_stop
,
3467 .auth
= ieee80211_auth
,
3468 .assoc
= ieee80211_assoc
,
3469 .deauth
= ieee80211_deauth
,
3470 .disassoc
= ieee80211_disassoc
,
3471 .join_ibss
= ieee80211_join_ibss
,
3472 .leave_ibss
= ieee80211_leave_ibss
,
3473 .set_mcast_rate
= ieee80211_set_mcast_rate
,
3474 .set_wiphy_params
= ieee80211_set_wiphy_params
,
3475 .set_tx_power
= ieee80211_set_tx_power
,
3476 .get_tx_power
= ieee80211_get_tx_power
,
3477 .set_wds_peer
= ieee80211_set_wds_peer
,
3478 .rfkill_poll
= ieee80211_rfkill_poll
,
3479 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd
)
3480 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump
)
3481 .set_power_mgmt
= ieee80211_set_power_mgmt
,
3482 .set_bitrate_mask
= ieee80211_set_bitrate_mask
,
3483 .remain_on_channel
= ieee80211_remain_on_channel
,
3484 .cancel_remain_on_channel
= ieee80211_cancel_remain_on_channel
,
3485 .mgmt_tx
= ieee80211_mgmt_tx
,
3486 .mgmt_tx_cancel_wait
= ieee80211_mgmt_tx_cancel_wait
,
3487 .set_cqm_rssi_config
= ieee80211_set_cqm_rssi_config
,
3488 .mgmt_frame_register
= ieee80211_mgmt_frame_register
,
3489 .set_antenna
= ieee80211_set_antenna
,
3490 .get_antenna
= ieee80211_get_antenna
,
3491 .set_ringparam
= ieee80211_set_ringparam
,
3492 .get_ringparam
= ieee80211_get_ringparam
,
3493 .set_rekey_data
= ieee80211_set_rekey_data
,
3494 .tdls_oper
= ieee80211_tdls_oper
,
3495 .tdls_mgmt
= ieee80211_tdls_mgmt
,
3496 .probe_client
= ieee80211_probe_client
,
3497 .set_noack_map
= ieee80211_set_noack_map
,
3499 .set_wakeup
= ieee80211_set_wakeup
,
3501 .get_et_sset_count
= ieee80211_get_et_sset_count
,
3502 .get_et_stats
= ieee80211_get_et_stats
,
3503 .get_et_strings
= ieee80211_get_et_strings
,
3504 .get_channel
= ieee80211_cfg_get_channel
,
3505 .start_radar_detection
= ieee80211_start_radar_detection
,