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 <net/cfg80211.h>
16 #include "ieee80211_i.h"
17 #include "driver-ops.h"
22 static int ieee80211_add_iface(struct wiphy
*wiphy
, char *name
,
23 enum nl80211_iftype type
, u32
*flags
,
24 struct vif_params
*params
)
26 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
27 struct net_device
*dev
;
28 struct ieee80211_sub_if_data
*sdata
;
31 err
= ieee80211_if_add(local
, name
, &dev
, type
, params
);
32 if (err
|| type
!= NL80211_IFTYPE_MONITOR
|| !flags
)
35 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
36 sdata
->u
.mntr_flags
= *flags
;
40 static int ieee80211_del_iface(struct wiphy
*wiphy
, struct net_device
*dev
)
42 ieee80211_if_remove(IEEE80211_DEV_TO_SUB_IF(dev
));
47 static int ieee80211_change_iface(struct wiphy
*wiphy
,
48 struct net_device
*dev
,
49 enum nl80211_iftype type
, u32
*flags
,
50 struct vif_params
*params
)
52 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
55 if (ieee80211_sdata_running(sdata
))
58 ret
= ieee80211_if_change_type(sdata
, type
);
62 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->mesh_id_len
)
63 ieee80211_sdata_set_mesh_id(sdata
,
67 if (type
== NL80211_IFTYPE_AP_VLAN
&&
68 params
&& params
->use_4addr
== 0)
69 rcu_assign_pointer(sdata
->u
.vlan
.sta
, NULL
);
70 else if (type
== NL80211_IFTYPE_STATION
&&
71 params
&& params
->use_4addr
>= 0)
72 sdata
->u
.mgd
.use_4addr
= params
->use_4addr
;
74 if (sdata
->vif
.type
== NL80211_IFTYPE_MONITOR
&& flags
)
75 sdata
->u
.mntr_flags
= *flags
;
80 static int ieee80211_add_key(struct wiphy
*wiphy
, struct net_device
*dev
,
81 u8 key_idx
, const u8
*mac_addr
,
82 struct key_params
*params
)
84 struct ieee80211_sub_if_data
*sdata
;
85 struct sta_info
*sta
= NULL
;
86 struct ieee80211_key
*key
;
89 if (!netif_running(dev
))
92 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
94 /* reject WEP and TKIP keys if WEP failed to initialize */
95 switch (params
->cipher
) {
96 case WLAN_CIPHER_SUITE_WEP40
:
97 case WLAN_CIPHER_SUITE_TKIP
:
98 case WLAN_CIPHER_SUITE_WEP104
:
99 if (IS_ERR(sdata
->local
->wep_tx_tfm
))
106 key
= ieee80211_key_alloc(params
->cipher
, key_idx
, params
->key_len
,
107 params
->key
, params
->seq_len
, params
->seq
);
111 mutex_lock(&sdata
->local
->sta_mtx
);
114 sta
= sta_info_get_bss(sdata
, mac_addr
);
116 ieee80211_key_free(sdata
->local
, key
);
122 err
= ieee80211_key_link(key
, sdata
, sta
);
124 ieee80211_key_free(sdata
->local
, key
);
127 mutex_unlock(&sdata
->local
->sta_mtx
);
132 static int ieee80211_del_key(struct wiphy
*wiphy
, struct net_device
*dev
,
133 u8 key_idx
, const u8
*mac_addr
)
135 struct ieee80211_sub_if_data
*sdata
;
136 struct sta_info
*sta
;
139 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
141 mutex_lock(&sdata
->local
->sta_mtx
);
146 sta
= sta_info_get_bss(sdata
, mac_addr
);
151 ieee80211_key_free(sdata
->local
, sta
->key
);
159 if (!sdata
->keys
[key_idx
]) {
164 ieee80211_key_free(sdata
->local
, sdata
->keys
[key_idx
]);
165 WARN_ON(sdata
->keys
[key_idx
]);
169 mutex_unlock(&sdata
->local
->sta_mtx
);
174 static int ieee80211_get_key(struct wiphy
*wiphy
, struct net_device
*dev
,
175 u8 key_idx
, const u8
*mac_addr
, void *cookie
,
176 void (*callback
)(void *cookie
,
177 struct key_params
*params
))
179 struct ieee80211_sub_if_data
*sdata
;
180 struct sta_info
*sta
= NULL
;
182 struct key_params params
;
183 struct ieee80211_key
*key
;
188 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
193 sta
= sta_info_get_bss(sdata
, mac_addr
);
199 key
= sdata
->keys
[key_idx
];
204 memset(¶ms
, 0, sizeof(params
));
206 params
.cipher
= key
->conf
.cipher
;
208 switch (key
->conf
.cipher
) {
209 case WLAN_CIPHER_SUITE_TKIP
:
210 iv32
= key
->u
.tkip
.tx
.iv32
;
211 iv16
= key
->u
.tkip
.tx
.iv16
;
213 if (key
->flags
& KEY_FLAG_UPLOADED_TO_HARDWARE
)
214 drv_get_tkip_seq(sdata
->local
,
215 key
->conf
.hw_key_idx
,
218 seq
[0] = iv16
& 0xff;
219 seq
[1] = (iv16
>> 8) & 0xff;
220 seq
[2] = iv32
& 0xff;
221 seq
[3] = (iv32
>> 8) & 0xff;
222 seq
[4] = (iv32
>> 16) & 0xff;
223 seq
[5] = (iv32
>> 24) & 0xff;
227 case WLAN_CIPHER_SUITE_CCMP
:
228 seq
[0] = key
->u
.ccmp
.tx_pn
[5];
229 seq
[1] = key
->u
.ccmp
.tx_pn
[4];
230 seq
[2] = key
->u
.ccmp
.tx_pn
[3];
231 seq
[3] = key
->u
.ccmp
.tx_pn
[2];
232 seq
[4] = key
->u
.ccmp
.tx_pn
[1];
233 seq
[5] = key
->u
.ccmp
.tx_pn
[0];
237 case WLAN_CIPHER_SUITE_AES_CMAC
:
238 seq
[0] = key
->u
.aes_cmac
.tx_pn
[5];
239 seq
[1] = key
->u
.aes_cmac
.tx_pn
[4];
240 seq
[2] = key
->u
.aes_cmac
.tx_pn
[3];
241 seq
[3] = key
->u
.aes_cmac
.tx_pn
[2];
242 seq
[4] = key
->u
.aes_cmac
.tx_pn
[1];
243 seq
[5] = key
->u
.aes_cmac
.tx_pn
[0];
249 params
.key
= key
->conf
.key
;
250 params
.key_len
= key
->conf
.keylen
;
252 callback(cookie
, ¶ms
);
260 static int ieee80211_config_default_key(struct wiphy
*wiphy
,
261 struct net_device
*dev
,
264 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
266 ieee80211_set_default_key(sdata
, key_idx
);
271 static int ieee80211_config_default_mgmt_key(struct wiphy
*wiphy
,
272 struct net_device
*dev
,
275 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
277 ieee80211_set_default_mgmt_key(sdata
, key_idx
);
282 static void sta_set_sinfo(struct sta_info
*sta
, struct station_info
*sinfo
)
284 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
286 sinfo
->generation
= sdata
->local
->sta_generation
;
288 sinfo
->filled
= STATION_INFO_INACTIVE_TIME
|
289 STATION_INFO_RX_BYTES
|
290 STATION_INFO_TX_BYTES
|
291 STATION_INFO_RX_PACKETS
|
292 STATION_INFO_TX_PACKETS
|
293 STATION_INFO_TX_BITRATE
;
295 sinfo
->inactive_time
= jiffies_to_msecs(jiffies
- sta
->last_rx
);
296 sinfo
->rx_bytes
= sta
->rx_bytes
;
297 sinfo
->tx_bytes
= sta
->tx_bytes
;
298 sinfo
->rx_packets
= sta
->rx_packets
;
299 sinfo
->tx_packets
= sta
->tx_packets
;
301 if ((sta
->local
->hw
.flags
& IEEE80211_HW_SIGNAL_DBM
) ||
302 (sta
->local
->hw
.flags
& IEEE80211_HW_SIGNAL_UNSPEC
)) {
303 sinfo
->filled
|= STATION_INFO_SIGNAL
;
304 sinfo
->signal
= (s8
)sta
->last_signal
;
307 sinfo
->txrate
.flags
= 0;
308 if (sta
->last_tx_rate
.flags
& IEEE80211_TX_RC_MCS
)
309 sinfo
->txrate
.flags
|= RATE_INFO_FLAGS_MCS
;
310 if (sta
->last_tx_rate
.flags
& IEEE80211_TX_RC_40_MHZ_WIDTH
)
311 sinfo
->txrate
.flags
|= RATE_INFO_FLAGS_40_MHZ_WIDTH
;
312 if (sta
->last_tx_rate
.flags
& IEEE80211_TX_RC_SHORT_GI
)
313 sinfo
->txrate
.flags
|= RATE_INFO_FLAGS_SHORT_GI
;
315 if (!(sta
->last_tx_rate
.flags
& IEEE80211_TX_RC_MCS
)) {
316 struct ieee80211_supported_band
*sband
;
317 sband
= sta
->local
->hw
.wiphy
->bands
[
318 sta
->local
->hw
.conf
.channel
->band
];
319 sinfo
->txrate
.legacy
=
320 sband
->bitrates
[sta
->last_tx_rate
.idx
].bitrate
;
322 sinfo
->txrate
.mcs
= sta
->last_tx_rate
.idx
;
324 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
325 #ifdef CONFIG_MAC80211_MESH
326 sinfo
->filled
|= STATION_INFO_LLID
|
328 STATION_INFO_PLINK_STATE
;
330 sinfo
->llid
= le16_to_cpu(sta
->llid
);
331 sinfo
->plid
= le16_to_cpu(sta
->plid
);
332 sinfo
->plink_state
= sta
->plink_state
;
338 static int ieee80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
339 int idx
, u8
*mac
, struct station_info
*sinfo
)
341 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
342 struct sta_info
*sta
;
347 sta
= sta_info_get_by_idx(sdata
, idx
);
350 memcpy(mac
, sta
->sta
.addr
, ETH_ALEN
);
351 sta_set_sinfo(sta
, sinfo
);
359 static int ieee80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
360 int idx
, struct survey_info
*survey
)
362 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
364 return drv_get_survey(local
, idx
, survey
);
367 static int ieee80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
368 u8
*mac
, struct station_info
*sinfo
)
370 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
371 struct sta_info
*sta
;
376 sta
= sta_info_get_bss(sdata
, mac
);
379 sta_set_sinfo(sta
, sinfo
);
388 * This handles both adding a beacon and setting new beacon info
390 static int ieee80211_config_beacon(struct ieee80211_sub_if_data
*sdata
,
391 struct beacon_parameters
*params
)
393 struct beacon_data
*new, *old
;
394 int new_head_len
, new_tail_len
;
398 old
= sdata
->u
.ap
.beacon
;
400 /* head must not be zero-length */
401 if (params
->head
&& !params
->head_len
)
405 * This is a kludge. beacon interval should really be part
406 * of the beacon information.
408 if (params
->interval
&&
409 (sdata
->vif
.bss_conf
.beacon_int
!= params
->interval
)) {
410 sdata
->vif
.bss_conf
.beacon_int
= params
->interval
;
411 ieee80211_bss_info_change_notify(sdata
,
412 BSS_CHANGED_BEACON_INT
);
415 /* Need to have a beacon head if we don't have one yet */
416 if (!params
->head
&& !old
)
419 /* sorry, no way to start beaconing without dtim period */
420 if (!params
->dtim_period
&& !old
)
423 /* new or old head? */
425 new_head_len
= params
->head_len
;
427 new_head_len
= old
->head_len
;
429 /* new or old tail? */
430 if (params
->tail
|| !old
)
431 /* params->tail_len will be zero for !params->tail */
432 new_tail_len
= params
->tail_len
;
434 new_tail_len
= old
->tail_len
;
436 size
= sizeof(*new) + new_head_len
+ new_tail_len
;
438 new = kzalloc(size
, GFP_KERNEL
);
442 /* start filling the new info now */
444 /* new or old dtim period? */
445 if (params
->dtim_period
)
446 new->dtim_period
= params
->dtim_period
;
448 new->dtim_period
= old
->dtim_period
;
451 * pointers go into the block we allocated,
452 * memory is | beacon_data | head | tail |
454 new->head
= ((u8
*) new) + sizeof(*new);
455 new->tail
= new->head
+ new_head_len
;
456 new->head_len
= new_head_len
;
457 new->tail_len
= new_tail_len
;
461 memcpy(new->head
, params
->head
, new_head_len
);
463 memcpy(new->head
, old
->head
, new_head_len
);
465 /* copy in optional tail */
467 memcpy(new->tail
, params
->tail
, new_tail_len
);
470 memcpy(new->tail
, old
->tail
, new_tail_len
);
472 sdata
->vif
.bss_conf
.dtim_period
= new->dtim_period
;
474 rcu_assign_pointer(sdata
->u
.ap
.beacon
, new);
480 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BEACON_ENABLED
|
485 static int ieee80211_add_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
486 struct beacon_parameters
*params
)
488 struct ieee80211_sub_if_data
*sdata
;
489 struct beacon_data
*old
;
491 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
493 old
= sdata
->u
.ap
.beacon
;
498 return ieee80211_config_beacon(sdata
, params
);
501 static int ieee80211_set_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
502 struct beacon_parameters
*params
)
504 struct ieee80211_sub_if_data
*sdata
;
505 struct beacon_data
*old
;
507 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
509 old
= sdata
->u
.ap
.beacon
;
514 return ieee80211_config_beacon(sdata
, params
);
517 static int ieee80211_del_beacon(struct wiphy
*wiphy
, struct net_device
*dev
)
519 struct ieee80211_sub_if_data
*sdata
;
520 struct beacon_data
*old
;
522 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
524 old
= sdata
->u
.ap
.beacon
;
529 rcu_assign_pointer(sdata
->u
.ap
.beacon
, NULL
);
533 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BEACON_ENABLED
);
537 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
538 struct iapp_layer2_update
{
539 u8 da
[ETH_ALEN
]; /* broadcast */
540 u8 sa
[ETH_ALEN
]; /* STA addr */
548 static void ieee80211_send_layer2_update(struct sta_info
*sta
)
550 struct iapp_layer2_update
*msg
;
553 /* Send Level 2 Update Frame to update forwarding tables in layer 2
556 skb
= dev_alloc_skb(sizeof(*msg
));
559 msg
= (struct iapp_layer2_update
*)skb_put(skb
, sizeof(*msg
));
561 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
562 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
564 memset(msg
->da
, 0xff, ETH_ALEN
);
565 memcpy(msg
->sa
, sta
->sta
.addr
, ETH_ALEN
);
568 msg
->ssap
= 0x01; /* NULL LSAP, CR Bit: Response */
569 msg
->control
= 0xaf; /* XID response lsb.1111F101.
570 * F=0 (no poll command; unsolicited frame) */
571 msg
->xid_info
[0] = 0x81; /* XID format identifier */
572 msg
->xid_info
[1] = 1; /* LLC types/classes: Type 1 LLC */
573 msg
->xid_info
[2] = 0; /* XID sender's receive window size (RW) */
575 skb
->dev
= sta
->sdata
->dev
;
576 skb
->protocol
= eth_type_trans(skb
, sta
->sdata
->dev
);
577 memset(skb
->cb
, 0, sizeof(skb
->cb
));
581 static void sta_apply_parameters(struct ieee80211_local
*local
,
582 struct sta_info
*sta
,
583 struct station_parameters
*params
)
587 struct ieee80211_supported_band
*sband
;
588 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
591 sband
= local
->hw
.wiphy
->bands
[local
->oper_channel
->band
];
593 spin_lock_bh(&sta
->lock
);
594 mask
= params
->sta_flags_mask
;
595 set
= params
->sta_flags_set
;
597 if (mask
& BIT(NL80211_STA_FLAG_AUTHORIZED
)) {
598 sta
->flags
&= ~WLAN_STA_AUTHORIZED
;
599 if (set
& BIT(NL80211_STA_FLAG_AUTHORIZED
))
600 sta
->flags
|= WLAN_STA_AUTHORIZED
;
603 if (mask
& BIT(NL80211_STA_FLAG_SHORT_PREAMBLE
)) {
604 sta
->flags
&= ~WLAN_STA_SHORT_PREAMBLE
;
605 if (set
& BIT(NL80211_STA_FLAG_SHORT_PREAMBLE
))
606 sta
->flags
|= WLAN_STA_SHORT_PREAMBLE
;
609 if (mask
& BIT(NL80211_STA_FLAG_WME
)) {
610 sta
->flags
&= ~WLAN_STA_WME
;
611 if (set
& BIT(NL80211_STA_FLAG_WME
))
612 sta
->flags
|= WLAN_STA_WME
;
615 if (mask
& BIT(NL80211_STA_FLAG_MFP
)) {
616 sta
->flags
&= ~WLAN_STA_MFP
;
617 if (set
& BIT(NL80211_STA_FLAG_MFP
))
618 sta
->flags
|= WLAN_STA_MFP
;
620 spin_unlock_bh(&sta
->lock
);
623 * cfg80211 validates this (1-2007) and allows setting the AID
624 * only when creating a new station entry
627 sta
->sta
.aid
= params
->aid
;
630 * FIXME: updating the following information is racy when this
631 * function is called from ieee80211_change_station().
632 * However, all this information should be static so
633 * maybe we should just reject attemps to change it.
636 if (params
->listen_interval
>= 0)
637 sta
->listen_interval
= params
->listen_interval
;
639 if (params
->supported_rates
) {
642 for (i
= 0; i
< params
->supported_rates_len
; i
++) {
643 int rate
= (params
->supported_rates
[i
] & 0x7f) * 5;
644 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
645 if (sband
->bitrates
[j
].bitrate
== rate
)
649 sta
->sta
.supp_rates
[local
->oper_channel
->band
] = rates
;
653 ieee80211_ht_cap_ie_to_sta_ht_cap(sband
,
657 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->plink_action
) {
658 switch (params
->plink_action
) {
659 case PLINK_ACTION_OPEN
:
660 mesh_plink_open(sta
);
662 case PLINK_ACTION_BLOCK
:
663 mesh_plink_block(sta
);
669 static int ieee80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
670 u8
*mac
, struct station_parameters
*params
)
672 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
673 struct sta_info
*sta
;
674 struct ieee80211_sub_if_data
*sdata
;
679 sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
681 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
682 sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
685 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
687 if (compare_ether_addr(mac
, sdata
->vif
.addr
) == 0)
690 if (is_multicast_ether_addr(mac
))
693 sta
= sta_info_alloc(sdata
, mac
, GFP_KERNEL
);
697 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
699 sta_apply_parameters(local
, sta
, params
);
701 rate_control_rate_init(sta
);
703 layer2_update
= sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
||
704 sdata
->vif
.type
== NL80211_IFTYPE_AP
;
706 err
= sta_info_insert_rcu(sta
);
713 ieee80211_send_layer2_update(sta
);
720 static int ieee80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
723 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
724 struct ieee80211_sub_if_data
*sdata
;
726 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
729 return sta_info_destroy_addr_bss(sdata
, mac
);
731 sta_info_flush(local
, sdata
);
735 static int ieee80211_change_station(struct wiphy
*wiphy
,
736 struct net_device
*dev
,
738 struct station_parameters
*params
)
740 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
741 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
742 struct sta_info
*sta
;
743 struct ieee80211_sub_if_data
*vlansdata
;
747 sta
= sta_info_get_bss(sdata
, mac
);
753 if (params
->vlan
&& params
->vlan
!= sta
->sdata
->dev
) {
754 vlansdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
756 if (vlansdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
757 vlansdata
->vif
.type
!= NL80211_IFTYPE_AP
) {
762 if (params
->vlan
->ieee80211_ptr
->use_4addr
) {
763 if (vlansdata
->u
.vlan
.sta
) {
768 rcu_assign_pointer(vlansdata
->u
.vlan
.sta
, sta
);
771 sta
->sdata
= vlansdata
;
772 ieee80211_send_layer2_update(sta
);
775 sta_apply_parameters(local
, sta
, params
);
782 #ifdef CONFIG_MAC80211_MESH
783 static int ieee80211_add_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
784 u8
*dst
, u8
*next_hop
)
786 struct ieee80211_sub_if_data
*sdata
;
787 struct mesh_path
*mpath
;
788 struct sta_info
*sta
;
791 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
794 sta
= sta_info_get(sdata
, next_hop
);
800 err
= mesh_path_add(dst
, sdata
);
806 mpath
= mesh_path_lookup(dst
, sdata
);
811 mesh_path_fix_nexthop(mpath
, sta
);
817 static int ieee80211_del_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
820 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
823 return mesh_path_del(dst
, sdata
);
825 mesh_path_flush(sdata
);
829 static int ieee80211_change_mpath(struct wiphy
*wiphy
,
830 struct net_device
*dev
,
831 u8
*dst
, u8
*next_hop
)
833 struct ieee80211_sub_if_data
*sdata
;
834 struct mesh_path
*mpath
;
835 struct sta_info
*sta
;
837 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
841 sta
= sta_info_get(sdata
, next_hop
);
847 mpath
= mesh_path_lookup(dst
, sdata
);
853 mesh_path_fix_nexthop(mpath
, sta
);
859 static void mpath_set_pinfo(struct mesh_path
*mpath
, u8
*next_hop
,
860 struct mpath_info
*pinfo
)
863 memcpy(next_hop
, mpath
->next_hop
->sta
.addr
, ETH_ALEN
);
865 memset(next_hop
, 0, ETH_ALEN
);
867 pinfo
->generation
= mesh_paths_generation
;
869 pinfo
->filled
= MPATH_INFO_FRAME_QLEN
|
873 MPATH_INFO_DISCOVERY_TIMEOUT
|
874 MPATH_INFO_DISCOVERY_RETRIES
|
877 pinfo
->frame_qlen
= mpath
->frame_queue
.qlen
;
878 pinfo
->sn
= mpath
->sn
;
879 pinfo
->metric
= mpath
->metric
;
880 if (time_before(jiffies
, mpath
->exp_time
))
881 pinfo
->exptime
= jiffies_to_msecs(mpath
->exp_time
- jiffies
);
882 pinfo
->discovery_timeout
=
883 jiffies_to_msecs(mpath
->discovery_timeout
);
884 pinfo
->discovery_retries
= mpath
->discovery_retries
;
886 if (mpath
->flags
& MESH_PATH_ACTIVE
)
887 pinfo
->flags
|= NL80211_MPATH_FLAG_ACTIVE
;
888 if (mpath
->flags
& MESH_PATH_RESOLVING
)
889 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
890 if (mpath
->flags
& MESH_PATH_SN_VALID
)
891 pinfo
->flags
|= NL80211_MPATH_FLAG_SN_VALID
;
892 if (mpath
->flags
& MESH_PATH_FIXED
)
893 pinfo
->flags
|= NL80211_MPATH_FLAG_FIXED
;
894 if (mpath
->flags
& MESH_PATH_RESOLVING
)
895 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
897 pinfo
->flags
= mpath
->flags
;
900 static int ieee80211_get_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
901 u8
*dst
, u8
*next_hop
, struct mpath_info
*pinfo
)
904 struct ieee80211_sub_if_data
*sdata
;
905 struct mesh_path
*mpath
;
907 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
910 mpath
= mesh_path_lookup(dst
, sdata
);
915 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
916 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
921 static int ieee80211_dump_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
922 int idx
, u8
*dst
, u8
*next_hop
,
923 struct mpath_info
*pinfo
)
925 struct ieee80211_sub_if_data
*sdata
;
926 struct mesh_path
*mpath
;
928 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
931 mpath
= mesh_path_lookup_by_idx(idx
, sdata
);
936 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
937 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
942 static int ieee80211_get_mesh_params(struct wiphy
*wiphy
,
943 struct net_device
*dev
,
944 struct mesh_config
*conf
)
946 struct ieee80211_sub_if_data
*sdata
;
947 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
949 memcpy(conf
, &(sdata
->u
.mesh
.mshcfg
), sizeof(struct mesh_config
));
953 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm
, u32 mask
)
955 return (mask
>> (parm
-1)) & 0x1;
958 static int ieee80211_set_mesh_params(struct wiphy
*wiphy
,
959 struct net_device
*dev
,
960 const struct mesh_config
*nconf
, u32 mask
)
962 struct mesh_config
*conf
;
963 struct ieee80211_sub_if_data
*sdata
;
964 struct ieee80211_if_mesh
*ifmsh
;
966 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
967 ifmsh
= &sdata
->u
.mesh
;
969 /* Set the config options which we are interested in setting */
970 conf
= &(sdata
->u
.mesh
.mshcfg
);
971 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT
, mask
))
972 conf
->dot11MeshRetryTimeout
= nconf
->dot11MeshRetryTimeout
;
973 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT
, mask
))
974 conf
->dot11MeshConfirmTimeout
= nconf
->dot11MeshConfirmTimeout
;
975 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT
, mask
))
976 conf
->dot11MeshHoldingTimeout
= nconf
->dot11MeshHoldingTimeout
;
977 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS
, mask
))
978 conf
->dot11MeshMaxPeerLinks
= nconf
->dot11MeshMaxPeerLinks
;
979 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES
, mask
))
980 conf
->dot11MeshMaxRetries
= nconf
->dot11MeshMaxRetries
;
981 if (_chg_mesh_attr(NL80211_MESHCONF_TTL
, mask
))
982 conf
->dot11MeshTTL
= nconf
->dot11MeshTTL
;
983 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS
, mask
))
984 conf
->auto_open_plinks
= nconf
->auto_open_plinks
;
985 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES
, mask
))
986 conf
->dot11MeshHWMPmaxPREQretries
=
987 nconf
->dot11MeshHWMPmaxPREQretries
;
988 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME
, mask
))
989 conf
->path_refresh_time
= nconf
->path_refresh_time
;
990 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT
, mask
))
991 conf
->min_discovery_timeout
= nconf
->min_discovery_timeout
;
992 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT
, mask
))
993 conf
->dot11MeshHWMPactivePathTimeout
=
994 nconf
->dot11MeshHWMPactivePathTimeout
;
995 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL
, mask
))
996 conf
->dot11MeshHWMPpreqMinInterval
=
997 nconf
->dot11MeshHWMPpreqMinInterval
;
998 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME
,
1000 conf
->dot11MeshHWMPnetDiameterTraversalTime
=
1001 nconf
->dot11MeshHWMPnetDiameterTraversalTime
;
1002 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE
, mask
)) {
1003 conf
->dot11MeshHWMPRootMode
= nconf
->dot11MeshHWMPRootMode
;
1004 ieee80211_mesh_root_setup(ifmsh
);
1011 static int ieee80211_change_bss(struct wiphy
*wiphy
,
1012 struct net_device
*dev
,
1013 struct bss_parameters
*params
)
1015 struct ieee80211_sub_if_data
*sdata
;
1018 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1020 if (params
->use_cts_prot
>= 0) {
1021 sdata
->vif
.bss_conf
.use_cts_prot
= params
->use_cts_prot
;
1022 changed
|= BSS_CHANGED_ERP_CTS_PROT
;
1024 if (params
->use_short_preamble
>= 0) {
1025 sdata
->vif
.bss_conf
.use_short_preamble
=
1026 params
->use_short_preamble
;
1027 changed
|= BSS_CHANGED_ERP_PREAMBLE
;
1030 if (!sdata
->vif
.bss_conf
.use_short_slot
&&
1031 sdata
->local
->hw
.conf
.channel
->band
== IEEE80211_BAND_5GHZ
) {
1032 sdata
->vif
.bss_conf
.use_short_slot
= true;
1033 changed
|= BSS_CHANGED_ERP_SLOT
;
1036 if (params
->use_short_slot_time
>= 0) {
1037 sdata
->vif
.bss_conf
.use_short_slot
=
1038 params
->use_short_slot_time
;
1039 changed
|= BSS_CHANGED_ERP_SLOT
;
1042 if (params
->basic_rates
) {
1045 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1046 struct ieee80211_supported_band
*sband
=
1047 wiphy
->bands
[local
->oper_channel
->band
];
1049 for (i
= 0; i
< params
->basic_rates_len
; i
++) {
1050 int rate
= (params
->basic_rates
[i
] & 0x7f) * 5;
1051 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
1052 if (sband
->bitrates
[j
].bitrate
== rate
)
1056 sdata
->vif
.bss_conf
.basic_rates
= rates
;
1057 changed
|= BSS_CHANGED_BASIC_RATES
;
1060 if (params
->ap_isolate
>= 0) {
1061 if (params
->ap_isolate
)
1062 sdata
->flags
|= IEEE80211_SDATA_DONT_BRIDGE_PACKETS
;
1064 sdata
->flags
&= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS
;
1067 ieee80211_bss_info_change_notify(sdata
, changed
);
1072 static int ieee80211_set_txq_params(struct wiphy
*wiphy
,
1073 struct ieee80211_txq_params
*params
)
1075 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1076 struct ieee80211_tx_queue_params p
;
1078 if (!local
->ops
->conf_tx
)
1081 memset(&p
, 0, sizeof(p
));
1082 p
.aifs
= params
->aifs
;
1083 p
.cw_max
= params
->cwmax
;
1084 p
.cw_min
= params
->cwmin
;
1085 p
.txop
= params
->txop
;
1088 * Setting tx queue params disables u-apsd because it's only
1089 * called in master mode.
1093 if (drv_conf_tx(local
, params
->queue
, &p
)) {
1094 wiphy_debug(local
->hw
.wiphy
,
1095 "failed to set TX queue parameters for queue %d\n",
1103 static int ieee80211_set_channel(struct wiphy
*wiphy
,
1104 struct net_device
*netdev
,
1105 struct ieee80211_channel
*chan
,
1106 enum nl80211_channel_type channel_type
)
1108 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1109 struct ieee80211_sub_if_data
*sdata
= NULL
;
1112 sdata
= IEEE80211_DEV_TO_SUB_IF(netdev
);
1114 switch (ieee80211_get_channel_mode(local
, NULL
)) {
1115 case CHAN_MODE_HOPPING
:
1117 case CHAN_MODE_FIXED
:
1118 if (local
->oper_channel
!= chan
)
1120 if (!sdata
&& local
->_oper_channel_type
== channel_type
)
1123 case CHAN_MODE_UNDEFINED
:
1127 local
->oper_channel
= chan
;
1129 if (!ieee80211_set_channel_type(local
, sdata
, channel_type
))
1132 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_CHANNEL
);
1133 if (sdata
&& sdata
->vif
.type
!= NL80211_IFTYPE_MONITOR
)
1134 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_HT
);
1140 static int ieee80211_suspend(struct wiphy
*wiphy
)
1142 return __ieee80211_suspend(wiphy_priv(wiphy
));
1145 static int ieee80211_resume(struct wiphy
*wiphy
)
1147 return __ieee80211_resume(wiphy_priv(wiphy
));
1150 #define ieee80211_suspend NULL
1151 #define ieee80211_resume NULL
1154 static int ieee80211_scan(struct wiphy
*wiphy
,
1155 struct net_device
*dev
,
1156 struct cfg80211_scan_request
*req
)
1158 struct ieee80211_sub_if_data
*sdata
;
1160 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1162 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
&&
1163 sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
&&
1164 sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
&&
1165 (sdata
->vif
.type
!= NL80211_IFTYPE_AP
|| sdata
->u
.ap
.beacon
))
1168 return ieee80211_request_scan(sdata
, req
);
1171 static int ieee80211_auth(struct wiphy
*wiphy
, struct net_device
*dev
,
1172 struct cfg80211_auth_request
*req
)
1174 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev
), req
);
1177 static int ieee80211_assoc(struct wiphy
*wiphy
, struct net_device
*dev
,
1178 struct cfg80211_assoc_request
*req
)
1180 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1181 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1183 switch (ieee80211_get_channel_mode(local
, sdata
)) {
1184 case CHAN_MODE_HOPPING
:
1186 case CHAN_MODE_FIXED
:
1187 if (local
->oper_channel
== req
->bss
->channel
)
1190 case CHAN_MODE_UNDEFINED
:
1194 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev
), req
);
1197 static int ieee80211_deauth(struct wiphy
*wiphy
, struct net_device
*dev
,
1198 struct cfg80211_deauth_request
*req
,
1201 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev
),
1205 static int ieee80211_disassoc(struct wiphy
*wiphy
, struct net_device
*dev
,
1206 struct cfg80211_disassoc_request
*req
,
1209 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev
),
1213 static int ieee80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
1214 struct cfg80211_ibss_params
*params
)
1216 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1217 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1219 switch (ieee80211_get_channel_mode(local
, sdata
)) {
1220 case CHAN_MODE_HOPPING
:
1222 case CHAN_MODE_FIXED
:
1223 if (!params
->channel_fixed
)
1225 if (local
->oper_channel
== params
->channel
)
1228 case CHAN_MODE_UNDEFINED
:
1232 return ieee80211_ibss_join(sdata
, params
);
1235 static int ieee80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
1237 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1239 return ieee80211_ibss_leave(sdata
);
1242 static int ieee80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
1244 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1247 if (changed
& WIPHY_PARAM_COVERAGE_CLASS
) {
1248 err
= drv_set_coverage_class(local
, wiphy
->coverage_class
);
1254 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
1255 err
= drv_set_rts_threshold(local
, wiphy
->rts_threshold
);
1261 if (changed
& WIPHY_PARAM_RETRY_SHORT
)
1262 local
->hw
.conf
.short_frame_max_tx_count
= wiphy
->retry_short
;
1263 if (changed
& WIPHY_PARAM_RETRY_LONG
)
1264 local
->hw
.conf
.long_frame_max_tx_count
= wiphy
->retry_long
;
1266 (WIPHY_PARAM_RETRY_SHORT
| WIPHY_PARAM_RETRY_LONG
))
1267 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_RETRY_LIMITS
);
1272 static int ieee80211_set_tx_power(struct wiphy
*wiphy
,
1273 enum nl80211_tx_power_setting type
, int mbm
)
1275 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1276 struct ieee80211_channel
*chan
= local
->hw
.conf
.channel
;
1280 case NL80211_TX_POWER_AUTOMATIC
:
1281 local
->user_power_level
= -1;
1283 case NL80211_TX_POWER_LIMITED
:
1284 if (mbm
< 0 || (mbm
% 100))
1286 local
->user_power_level
= MBM_TO_DBM(mbm
);
1288 case NL80211_TX_POWER_FIXED
:
1289 if (mbm
< 0 || (mbm
% 100))
1291 /* TODO: move to cfg80211 when it knows the channel */
1292 if (MBM_TO_DBM(mbm
) > chan
->max_power
)
1294 local
->user_power_level
= MBM_TO_DBM(mbm
);
1298 ieee80211_hw_config(local
, changes
);
1303 static int ieee80211_get_tx_power(struct wiphy
*wiphy
, int *dbm
)
1305 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1307 *dbm
= local
->hw
.conf
.power_level
;
1312 static int ieee80211_set_wds_peer(struct wiphy
*wiphy
, struct net_device
*dev
,
1315 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1317 memcpy(&sdata
->u
.wds
.remote_addr
, addr
, ETH_ALEN
);
1322 static void ieee80211_rfkill_poll(struct wiphy
*wiphy
)
1324 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1326 drv_rfkill_poll(local
);
1329 #ifdef CONFIG_NL80211_TESTMODE
1330 static int ieee80211_testmode_cmd(struct wiphy
*wiphy
, void *data
, int len
)
1332 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1334 if (!local
->ops
->testmode_cmd
)
1337 return local
->ops
->testmode_cmd(&local
->hw
, data
, len
);
1341 int __ieee80211_request_smps(struct ieee80211_sub_if_data
*sdata
,
1342 enum ieee80211_smps_mode smps_mode
)
1345 enum ieee80211_smps_mode old_req
;
1348 old_req
= sdata
->u
.mgd
.req_smps
;
1349 sdata
->u
.mgd
.req_smps
= smps_mode
;
1351 if (old_req
== smps_mode
&&
1352 smps_mode
!= IEEE80211_SMPS_AUTOMATIC
)
1356 * If not associated, or current association is not an HT
1357 * association, there's no need to send an action frame.
1359 if (!sdata
->u
.mgd
.associated
||
1360 sdata
->vif
.bss_conf
.channel_type
== NL80211_CHAN_NO_HT
) {
1361 mutex_lock(&sdata
->local
->iflist_mtx
);
1362 ieee80211_recalc_smps(sdata
->local
, sdata
);
1363 mutex_unlock(&sdata
->local
->iflist_mtx
);
1367 ap
= sdata
->u
.mgd
.associated
->bssid
;
1369 if (smps_mode
== IEEE80211_SMPS_AUTOMATIC
) {
1370 if (sdata
->u
.mgd
.powersave
)
1371 smps_mode
= IEEE80211_SMPS_DYNAMIC
;
1373 smps_mode
= IEEE80211_SMPS_OFF
;
1376 /* send SM PS frame to AP */
1377 err
= ieee80211_send_smps_action(sdata
, smps_mode
,
1380 sdata
->u
.mgd
.req_smps
= old_req
;
1385 static int ieee80211_set_power_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
1386 bool enabled
, int timeout
)
1388 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1389 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
1391 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
1394 if (!(local
->hw
.flags
& IEEE80211_HW_SUPPORTS_PS
))
1397 if (enabled
== sdata
->u
.mgd
.powersave
&&
1398 timeout
== local
->dynamic_ps_forced_timeout
)
1401 sdata
->u
.mgd
.powersave
= enabled
;
1402 local
->dynamic_ps_forced_timeout
= timeout
;
1404 /* no change, but if automatic follow powersave */
1405 mutex_lock(&sdata
->u
.mgd
.mtx
);
1406 __ieee80211_request_smps(sdata
, sdata
->u
.mgd
.req_smps
);
1407 mutex_unlock(&sdata
->u
.mgd
.mtx
);
1409 if (local
->hw
.flags
& IEEE80211_HW_SUPPORTS_DYNAMIC_PS
)
1410 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_PS
);
1412 ieee80211_recalc_ps(local
, -1);
1417 static int ieee80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
1418 struct net_device
*dev
,
1419 s32 rssi_thold
, u32 rssi_hyst
)
1421 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1422 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
1423 struct ieee80211_vif
*vif
= &sdata
->vif
;
1424 struct ieee80211_bss_conf
*bss_conf
= &vif
->bss_conf
;
1426 if (rssi_thold
== bss_conf
->cqm_rssi_thold
&&
1427 rssi_hyst
== bss_conf
->cqm_rssi_hyst
)
1430 bss_conf
->cqm_rssi_thold
= rssi_thold
;
1431 bss_conf
->cqm_rssi_hyst
= rssi_hyst
;
1433 if (!(local
->hw
.flags
& IEEE80211_HW_SUPPORTS_CQM_RSSI
)) {
1434 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
1439 /* tell the driver upon association, unless already associated */
1440 if (sdata
->u
.mgd
.associated
)
1441 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_CQM
);
1446 static int ieee80211_set_bitrate_mask(struct wiphy
*wiphy
,
1447 struct net_device
*dev
,
1449 const struct cfg80211_bitrate_mask
*mask
)
1451 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1452 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
1456 * This _could_ be supported by providing a hook for
1457 * drivers for this function, but at this point it
1458 * doesn't seem worth bothering.
1460 if (local
->hw
.flags
& IEEE80211_HW_HAS_RATE_CONTROL
)
1464 for (i
= 0; i
< IEEE80211_NUM_BANDS
; i
++)
1465 sdata
->rc_rateidx_mask
[i
] = mask
->control
[i
].legacy
;
1470 static int ieee80211_remain_on_channel(struct wiphy
*wiphy
,
1471 struct net_device
*dev
,
1472 struct ieee80211_channel
*chan
,
1473 enum nl80211_channel_type channel_type
,
1474 unsigned int duration
,
1477 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1479 return ieee80211_wk_remain_on_channel(sdata
, chan
, channel_type
,
1483 static int ieee80211_cancel_remain_on_channel(struct wiphy
*wiphy
,
1484 struct net_device
*dev
,
1487 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1489 return ieee80211_wk_cancel_remain_on_channel(sdata
, cookie
);
1492 static int ieee80211_mgmt_tx(struct wiphy
*wiphy
, struct net_device
*dev
,
1493 struct ieee80211_channel
*chan
,
1494 enum nl80211_channel_type channel_type
,
1495 bool channel_type_valid
,
1496 const u8
*buf
, size_t len
, u64
*cookie
)
1498 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1499 struct ieee80211_local
*local
= sdata
->local
;
1500 struct sk_buff
*skb
;
1501 struct sta_info
*sta
;
1502 const struct ieee80211_mgmt
*mgmt
= (void *)buf
;
1503 u32 flags
= IEEE80211_TX_INTFL_NL80211_FRAME_TX
|
1504 IEEE80211_TX_CTL_REQ_TX_STATUS
;
1506 /* Check that we are on the requested channel for transmission */
1507 if (chan
!= local
->tmp_channel
&&
1508 chan
!= local
->oper_channel
)
1510 if (channel_type_valid
&&
1511 (channel_type
!= local
->tmp_channel_type
&&
1512 channel_type
!= local
->_oper_channel_type
))
1515 switch (sdata
->vif
.type
) {
1516 case NL80211_IFTYPE_ADHOC
:
1517 if (mgmt
->u
.action
.category
== WLAN_CATEGORY_PUBLIC
)
1520 sta
= sta_info_get(sdata
, mgmt
->da
);
1525 case NL80211_IFTYPE_STATION
:
1531 skb
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+ len
);
1534 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
1536 memcpy(skb_put(skb
, len
), buf
, len
);
1538 IEEE80211_SKB_CB(skb
)->flags
= flags
;
1540 skb
->dev
= sdata
->dev
;
1541 ieee80211_tx_skb(sdata
, skb
);
1543 *cookie
= (unsigned long) skb
;
1547 struct cfg80211_ops mac80211_config_ops
= {
1548 .add_virtual_intf
= ieee80211_add_iface
,
1549 .del_virtual_intf
= ieee80211_del_iface
,
1550 .change_virtual_intf
= ieee80211_change_iface
,
1551 .add_key
= ieee80211_add_key
,
1552 .del_key
= ieee80211_del_key
,
1553 .get_key
= ieee80211_get_key
,
1554 .set_default_key
= ieee80211_config_default_key
,
1555 .set_default_mgmt_key
= ieee80211_config_default_mgmt_key
,
1556 .add_beacon
= ieee80211_add_beacon
,
1557 .set_beacon
= ieee80211_set_beacon
,
1558 .del_beacon
= ieee80211_del_beacon
,
1559 .add_station
= ieee80211_add_station
,
1560 .del_station
= ieee80211_del_station
,
1561 .change_station
= ieee80211_change_station
,
1562 .get_station
= ieee80211_get_station
,
1563 .dump_station
= ieee80211_dump_station
,
1564 .dump_survey
= ieee80211_dump_survey
,
1565 #ifdef CONFIG_MAC80211_MESH
1566 .add_mpath
= ieee80211_add_mpath
,
1567 .del_mpath
= ieee80211_del_mpath
,
1568 .change_mpath
= ieee80211_change_mpath
,
1569 .get_mpath
= ieee80211_get_mpath
,
1570 .dump_mpath
= ieee80211_dump_mpath
,
1571 .set_mesh_params
= ieee80211_set_mesh_params
,
1572 .get_mesh_params
= ieee80211_get_mesh_params
,
1574 .change_bss
= ieee80211_change_bss
,
1575 .set_txq_params
= ieee80211_set_txq_params
,
1576 .set_channel
= ieee80211_set_channel
,
1577 .suspend
= ieee80211_suspend
,
1578 .resume
= ieee80211_resume
,
1579 .scan
= ieee80211_scan
,
1580 .auth
= ieee80211_auth
,
1581 .assoc
= ieee80211_assoc
,
1582 .deauth
= ieee80211_deauth
,
1583 .disassoc
= ieee80211_disassoc
,
1584 .join_ibss
= ieee80211_join_ibss
,
1585 .leave_ibss
= ieee80211_leave_ibss
,
1586 .set_wiphy_params
= ieee80211_set_wiphy_params
,
1587 .set_tx_power
= ieee80211_set_tx_power
,
1588 .get_tx_power
= ieee80211_get_tx_power
,
1589 .set_wds_peer
= ieee80211_set_wds_peer
,
1590 .rfkill_poll
= ieee80211_rfkill_poll
,
1591 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd
)
1592 .set_power_mgmt
= ieee80211_set_power_mgmt
,
1593 .set_bitrate_mask
= ieee80211_set_bitrate_mask
,
1594 .remain_on_channel
= ieee80211_remain_on_channel
,
1595 .cancel_remain_on_channel
= ieee80211_cancel_remain_on_channel
,
1596 .mgmt_tx
= ieee80211_mgmt_tx
,
1597 .set_cqm_rssi_config
= ieee80211_set_cqm_rssi_config
,