2 * cfg80211 MLME SAP interface
4 * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
7 #include <linux/kernel.h>
8 #include <linux/module.h>
9 #include <linux/etherdevice.h>
10 #include <linux/netdevice.h>
11 #include <linux/nl80211.h>
12 #include <linux/slab.h>
13 #include <linux/wireless.h>
14 #include <net/cfg80211.h>
15 #include <net/iw_handler.h>
21 void cfg80211_rx_assoc_resp(struct net_device
*dev
, struct cfg80211_bss
*bss
,
22 const u8
*buf
, size_t len
, int uapsd_queues
)
24 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
25 struct wiphy
*wiphy
= wdev
->wiphy
;
26 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wiphy
);
27 struct ieee80211_mgmt
*mgmt
= (struct ieee80211_mgmt
*)buf
;
28 u8
*ie
= mgmt
->u
.assoc_resp
.variable
;
29 int ieoffs
= offsetof(struct ieee80211_mgmt
, u
.assoc_resp
.variable
);
30 u16 status_code
= le16_to_cpu(mgmt
->u
.assoc_resp
.status_code
);
32 trace_cfg80211_send_rx_assoc(dev
, bss
);
35 * This is a bit of a hack, we don't notify userspace of
36 * a (re-)association reply if we tried to send a reassoc
37 * and got a reject -- we only try again with an assoc
38 * frame instead of reassoc.
40 if (cfg80211_sme_rx_assoc_resp(wdev
, status_code
)) {
41 cfg80211_unhold_bss(bss_from_pub(bss
));
42 cfg80211_put_bss(wiphy
, bss
);
46 nl80211_send_rx_assoc(rdev
, dev
, buf
, len
, GFP_KERNEL
, uapsd_queues
);
47 /* update current_bss etc., consumes the bss reference */
48 __cfg80211_connect_result(dev
, mgmt
->bssid
, NULL
, 0, ie
, len
- ieoffs
,
50 status_code
== WLAN_STATUS_SUCCESS
, bss
);
52 EXPORT_SYMBOL(cfg80211_rx_assoc_resp
);
54 static void cfg80211_process_auth(struct wireless_dev
*wdev
,
55 const u8
*buf
, size_t len
)
57 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
59 nl80211_send_rx_auth(rdev
, wdev
->netdev
, buf
, len
, GFP_KERNEL
);
60 cfg80211_sme_rx_auth(wdev
, buf
, len
);
63 static void cfg80211_process_deauth(struct wireless_dev
*wdev
,
64 const u8
*buf
, size_t len
)
66 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
67 struct ieee80211_mgmt
*mgmt
= (struct ieee80211_mgmt
*)buf
;
68 const u8
*bssid
= mgmt
->bssid
;
69 u16 reason_code
= le16_to_cpu(mgmt
->u
.deauth
.reason_code
);
70 bool from_ap
= !ether_addr_equal(mgmt
->sa
, wdev
->netdev
->dev_addr
);
72 nl80211_send_deauth(rdev
, wdev
->netdev
, buf
, len
, GFP_KERNEL
);
74 if (!wdev
->current_bss
||
75 !ether_addr_equal(wdev
->current_bss
->pub
.bssid
, bssid
))
78 __cfg80211_disconnected(wdev
->netdev
, NULL
, 0, reason_code
, from_ap
);
79 cfg80211_sme_deauth(wdev
);
82 static void cfg80211_process_disassoc(struct wireless_dev
*wdev
,
83 const u8
*buf
, size_t len
)
85 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
86 struct ieee80211_mgmt
*mgmt
= (struct ieee80211_mgmt
*)buf
;
87 const u8
*bssid
= mgmt
->bssid
;
88 u16 reason_code
= le16_to_cpu(mgmt
->u
.disassoc
.reason_code
);
89 bool from_ap
= !ether_addr_equal(mgmt
->sa
, wdev
->netdev
->dev_addr
);
91 nl80211_send_disassoc(rdev
, wdev
->netdev
, buf
, len
, GFP_KERNEL
);
93 if (WARN_ON(!wdev
->current_bss
||
94 !ether_addr_equal(wdev
->current_bss
->pub
.bssid
, bssid
)))
97 __cfg80211_disconnected(wdev
->netdev
, NULL
, 0, reason_code
, from_ap
);
98 cfg80211_sme_disassoc(wdev
);
101 void cfg80211_rx_mlme_mgmt(struct net_device
*dev
, const u8
*buf
, size_t len
)
103 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
104 struct ieee80211_mgmt
*mgmt
= (void *)buf
;
106 ASSERT_WDEV_LOCK(wdev
);
108 trace_cfg80211_rx_mlme_mgmt(dev
, buf
, len
);
110 if (WARN_ON(len
< 2))
113 if (ieee80211_is_auth(mgmt
->frame_control
))
114 cfg80211_process_auth(wdev
, buf
, len
);
115 else if (ieee80211_is_deauth(mgmt
->frame_control
))
116 cfg80211_process_deauth(wdev
, buf
, len
);
117 else if (ieee80211_is_disassoc(mgmt
->frame_control
))
118 cfg80211_process_disassoc(wdev
, buf
, len
);
120 EXPORT_SYMBOL(cfg80211_rx_mlme_mgmt
);
122 void cfg80211_auth_timeout(struct net_device
*dev
, const u8
*addr
)
124 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
125 struct wiphy
*wiphy
= wdev
->wiphy
;
126 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wiphy
);
128 trace_cfg80211_send_auth_timeout(dev
, addr
);
130 nl80211_send_auth_timeout(rdev
, dev
, addr
, GFP_KERNEL
);
131 cfg80211_sme_auth_timeout(wdev
);
133 EXPORT_SYMBOL(cfg80211_auth_timeout
);
135 void cfg80211_assoc_timeout(struct net_device
*dev
, struct cfg80211_bss
*bss
)
137 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
138 struct wiphy
*wiphy
= wdev
->wiphy
;
139 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wiphy
);
141 trace_cfg80211_send_assoc_timeout(dev
, bss
->bssid
);
143 nl80211_send_assoc_timeout(rdev
, dev
, bss
->bssid
, GFP_KERNEL
);
144 cfg80211_sme_assoc_timeout(wdev
);
146 cfg80211_unhold_bss(bss_from_pub(bss
));
147 cfg80211_put_bss(wiphy
, bss
);
149 EXPORT_SYMBOL(cfg80211_assoc_timeout
);
151 void cfg80211_tx_mlme_mgmt(struct net_device
*dev
, const u8
*buf
, size_t len
)
153 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
154 struct ieee80211_mgmt
*mgmt
= (void *)buf
;
156 ASSERT_WDEV_LOCK(wdev
);
158 trace_cfg80211_tx_mlme_mgmt(dev
, buf
, len
);
160 if (WARN_ON(len
< 2))
163 if (ieee80211_is_deauth(mgmt
->frame_control
))
164 cfg80211_process_deauth(wdev
, buf
, len
);
166 cfg80211_process_disassoc(wdev
, buf
, len
);
168 EXPORT_SYMBOL(cfg80211_tx_mlme_mgmt
);
170 void cfg80211_michael_mic_failure(struct net_device
*dev
, const u8
*addr
,
171 enum nl80211_key_type key_type
, int key_id
,
172 const u8
*tsc
, gfp_t gfp
)
174 struct wiphy
*wiphy
= dev
->ieee80211_ptr
->wiphy
;
175 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wiphy
);
176 #ifdef CONFIG_CFG80211_WEXT
177 union iwreq_data wrqu
;
178 char *buf
= kmalloc(128, gfp
);
181 sprintf(buf
, "MLME-MICHAELMICFAILURE.indication("
182 "keyid=%d %scast addr=%pM)", key_id
,
183 key_type
== NL80211_KEYTYPE_GROUP
? "broad" : "uni",
185 memset(&wrqu
, 0, sizeof(wrqu
));
186 wrqu
.data
.length
= strlen(buf
);
187 wireless_send_event(dev
, IWEVCUSTOM
, &wrqu
, buf
);
192 trace_cfg80211_michael_mic_failure(dev
, addr
, key_type
, key_id
, tsc
);
193 nl80211_michael_mic_failure(rdev
, dev
, addr
, key_type
, key_id
, tsc
, gfp
);
195 EXPORT_SYMBOL(cfg80211_michael_mic_failure
);
197 /* some MLME handling for userspace SME */
198 int cfg80211_mlme_auth(struct cfg80211_registered_device
*rdev
,
199 struct net_device
*dev
,
200 struct ieee80211_channel
*chan
,
201 enum nl80211_auth_type auth_type
,
203 const u8
*ssid
, int ssid_len
,
204 const u8
*ie
, int ie_len
,
205 const u8
*key
, int key_len
, int key_idx
,
206 const u8
*sae_data
, int sae_data_len
)
208 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
209 struct cfg80211_auth_request req
= {
212 .sae_data
= sae_data
,
213 .sae_data_len
= sae_data_len
,
214 .auth_type
= auth_type
,
221 ASSERT_WDEV_LOCK(wdev
);
223 if (auth_type
== NL80211_AUTHTYPE_SHARED_KEY
)
224 if (!key
|| !key_len
|| key_idx
< 0 || key_idx
> 4)
227 if (wdev
->current_bss
&&
228 ether_addr_equal(bssid
, wdev
->current_bss
->pub
.bssid
))
231 req
.bss
= cfg80211_get_bss(&rdev
->wiphy
, chan
, bssid
, ssid
, ssid_len
,
232 IEEE80211_BSS_TYPE_ESS
,
233 IEEE80211_PRIVACY_ANY
);
237 err
= rdev_auth(rdev
, dev
, &req
);
239 cfg80211_put_bss(&rdev
->wiphy
, req
.bss
);
243 /* Do a logical ht_capa &= ht_capa_mask. */
244 void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap
*ht_capa
,
245 const struct ieee80211_ht_cap
*ht_capa_mask
)
250 memset(ht_capa
, 0, sizeof(*ht_capa
));
255 p2
= (u8
*)(ht_capa_mask
);
256 for (i
= 0; i
<sizeof(*ht_capa
); i
++)
260 /* Do a logical ht_capa &= ht_capa_mask. */
261 void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap
*vht_capa
,
262 const struct ieee80211_vht_cap
*vht_capa_mask
)
266 if (!vht_capa_mask
) {
267 memset(vht_capa
, 0, sizeof(*vht_capa
));
271 p1
= (u8
*)(vht_capa
);
272 p2
= (u8
*)(vht_capa_mask
);
273 for (i
= 0; i
< sizeof(*vht_capa
); i
++)
277 int cfg80211_mlme_assoc(struct cfg80211_registered_device
*rdev
,
278 struct net_device
*dev
,
279 struct ieee80211_channel
*chan
,
281 const u8
*ssid
, int ssid_len
,
282 struct cfg80211_assoc_request
*req
)
284 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
287 ASSERT_WDEV_LOCK(wdev
);
289 if (wdev
->current_bss
&&
290 (!req
->prev_bssid
|| !ether_addr_equal(wdev
->current_bss
->pub
.bssid
,
294 cfg80211_oper_and_ht_capa(&req
->ht_capa_mask
,
295 rdev
->wiphy
.ht_capa_mod_mask
);
296 cfg80211_oper_and_vht_capa(&req
->vht_capa_mask
,
297 rdev
->wiphy
.vht_capa_mod_mask
);
299 req
->bss
= cfg80211_get_bss(&rdev
->wiphy
, chan
, bssid
, ssid
, ssid_len
,
300 IEEE80211_BSS_TYPE_ESS
,
301 IEEE80211_PRIVACY_ANY
);
305 err
= rdev_assoc(rdev
, dev
, req
);
307 cfg80211_hold_bss(bss_from_pub(req
->bss
));
309 cfg80211_put_bss(&rdev
->wiphy
, req
->bss
);
314 int cfg80211_mlme_deauth(struct cfg80211_registered_device
*rdev
,
315 struct net_device
*dev
, const u8
*bssid
,
316 const u8
*ie
, int ie_len
, u16 reason
,
317 bool local_state_change
)
319 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
320 struct cfg80211_deauth_request req
= {
322 .reason_code
= reason
,
325 .local_state_change
= local_state_change
,
328 ASSERT_WDEV_LOCK(wdev
);
330 if (local_state_change
&&
331 (!wdev
->current_bss
||
332 !ether_addr_equal(wdev
->current_bss
->pub
.bssid
, bssid
)))
335 return rdev_deauth(rdev
, dev
, &req
);
338 int cfg80211_mlme_disassoc(struct cfg80211_registered_device
*rdev
,
339 struct net_device
*dev
, const u8
*bssid
,
340 const u8
*ie
, int ie_len
, u16 reason
,
341 bool local_state_change
)
343 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
344 struct cfg80211_disassoc_request req
= {
345 .reason_code
= reason
,
346 .local_state_change
= local_state_change
,
352 ASSERT_WDEV_LOCK(wdev
);
354 if (!wdev
->current_bss
)
357 if (ether_addr_equal(wdev
->current_bss
->pub
.bssid
, bssid
))
358 req
.bss
= &wdev
->current_bss
->pub
;
362 err
= rdev_disassoc(rdev
, dev
, &req
);
366 /* driver should have reported the disassoc */
367 WARN_ON(wdev
->current_bss
);
371 void cfg80211_mlme_down(struct cfg80211_registered_device
*rdev
,
372 struct net_device
*dev
)
374 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
377 ASSERT_WDEV_LOCK(wdev
);
379 if (!rdev
->ops
->deauth
)
382 if (!wdev
->current_bss
)
385 memcpy(bssid
, wdev
->current_bss
->pub
.bssid
, ETH_ALEN
);
386 cfg80211_mlme_deauth(rdev
, dev
, bssid
, NULL
, 0,
387 WLAN_REASON_DEAUTH_LEAVING
, false);
390 struct cfg80211_mgmt_registration
{
391 struct list_head list
;
402 int cfg80211_mlme_register_mgmt(struct wireless_dev
*wdev
, u32 snd_portid
,
403 u16 frame_type
, const u8
*match_data
,
406 struct wiphy
*wiphy
= wdev
->wiphy
;
407 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wiphy
);
408 struct cfg80211_mgmt_registration
*reg
, *nreg
;
412 if (!wdev
->wiphy
->mgmt_stypes
)
415 if ((frame_type
& IEEE80211_FCTL_FTYPE
) != IEEE80211_FTYPE_MGMT
)
418 if (frame_type
& ~(IEEE80211_FCTL_FTYPE
| IEEE80211_FCTL_STYPE
))
421 mgmt_type
= (frame_type
& IEEE80211_FCTL_STYPE
) >> 4;
422 if (!(wdev
->wiphy
->mgmt_stypes
[wdev
->iftype
].rx
& BIT(mgmt_type
)))
425 nreg
= kzalloc(sizeof(*reg
) + match_len
, GFP_KERNEL
);
429 spin_lock_bh(&wdev
->mgmt_registrations_lock
);
431 list_for_each_entry(reg
, &wdev
->mgmt_registrations
, list
) {
432 int mlen
= min(match_len
, reg
->match_len
);
434 if (frame_type
!= le16_to_cpu(reg
->frame_type
))
437 if (memcmp(reg
->match
, match_data
, mlen
) == 0) {
448 memcpy(nreg
->match
, match_data
, match_len
);
449 nreg
->match_len
= match_len
;
450 nreg
->nlportid
= snd_portid
;
451 nreg
->frame_type
= cpu_to_le16(frame_type
);
452 list_add(&nreg
->list
, &wdev
->mgmt_registrations
);
454 if (rdev
->ops
->mgmt_frame_register
)
455 rdev_mgmt_frame_register(rdev
, wdev
, frame_type
, true);
458 spin_unlock_bh(&wdev
->mgmt_registrations_lock
);
463 void cfg80211_mlme_unregister_socket(struct wireless_dev
*wdev
, u32 nlportid
)
465 struct wiphy
*wiphy
= wdev
->wiphy
;
466 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wiphy
);
467 struct cfg80211_mgmt_registration
*reg
, *tmp
;
469 spin_lock_bh(&wdev
->mgmt_registrations_lock
);
471 list_for_each_entry_safe(reg
, tmp
, &wdev
->mgmt_registrations
, list
) {
472 if (reg
->nlportid
!= nlportid
)
475 if (rdev
->ops
->mgmt_frame_register
) {
476 u16 frame_type
= le16_to_cpu(reg
->frame_type
);
478 rdev_mgmt_frame_register(rdev
, wdev
,
482 list_del(®
->list
);
486 spin_unlock_bh(&wdev
->mgmt_registrations_lock
);
488 if (nlportid
&& rdev
->crit_proto_nlportid
== nlportid
) {
489 rdev
->crit_proto_nlportid
= 0;
490 rdev_crit_proto_stop(rdev
, wdev
);
493 if (nlportid
== wdev
->ap_unexpected_nlportid
)
494 wdev
->ap_unexpected_nlportid
= 0;
497 void cfg80211_mlme_purge_registrations(struct wireless_dev
*wdev
)
499 struct cfg80211_mgmt_registration
*reg
, *tmp
;
501 spin_lock_bh(&wdev
->mgmt_registrations_lock
);
503 list_for_each_entry_safe(reg
, tmp
, &wdev
->mgmt_registrations
, list
) {
504 list_del(®
->list
);
508 spin_unlock_bh(&wdev
->mgmt_registrations_lock
);
511 int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device
*rdev
,
512 struct wireless_dev
*wdev
,
513 struct cfg80211_mgmt_tx_params
*params
, u64
*cookie
)
515 const struct ieee80211_mgmt
*mgmt
;
518 if (!wdev
->wiphy
->mgmt_stypes
)
521 if (!rdev
->ops
->mgmt_tx
)
524 if (params
->len
< 24 + 1)
527 mgmt
= (const struct ieee80211_mgmt
*)params
->buf
;
529 if (!ieee80211_is_mgmt(mgmt
->frame_control
))
532 stype
= le16_to_cpu(mgmt
->frame_control
) & IEEE80211_FCTL_STYPE
;
533 if (!(wdev
->wiphy
->mgmt_stypes
[wdev
->iftype
].tx
& BIT(stype
>> 4)))
536 if (ieee80211_is_action(mgmt
->frame_control
) &&
537 mgmt
->u
.action
.category
!= WLAN_CATEGORY_PUBLIC
) {
542 switch (wdev
->iftype
) {
543 case NL80211_IFTYPE_ADHOC
:
544 case NL80211_IFTYPE_STATION
:
545 case NL80211_IFTYPE_P2P_CLIENT
:
546 if (!wdev
->current_bss
) {
551 if (!ether_addr_equal(wdev
->current_bss
->pub
.bssid
,
558 * check for IBSS DA must be done by driver as
559 * cfg80211 doesn't track the stations
561 if (wdev
->iftype
== NL80211_IFTYPE_ADHOC
)
564 /* for station, check that DA is the AP */
565 if (!ether_addr_equal(wdev
->current_bss
->pub
.bssid
,
571 case NL80211_IFTYPE_AP
:
572 case NL80211_IFTYPE_P2P_GO
:
573 case NL80211_IFTYPE_AP_VLAN
:
574 if (!ether_addr_equal(mgmt
->bssid
, wdev_address(wdev
)))
577 case NL80211_IFTYPE_MESH_POINT
:
578 if (!ether_addr_equal(mgmt
->sa
, mgmt
->bssid
)) {
583 * check for mesh DA must be done by driver as
584 * cfg80211 doesn't track the stations
587 case NL80211_IFTYPE_P2P_DEVICE
:
589 * fall through, P2P device only supports
590 * public action frames
602 if (!ether_addr_equal(mgmt
->sa
, wdev_address(wdev
)))
605 /* Transmit the Action frame as requested by user space */
606 return rdev_mgmt_tx(rdev
, wdev
, params
, cookie
);
609 bool cfg80211_rx_mgmt(struct wireless_dev
*wdev
, int freq
, int sig_mbm
,
610 const u8
*buf
, size_t len
, u32 flags
)
612 struct wiphy
*wiphy
= wdev
->wiphy
;
613 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wiphy
);
614 struct cfg80211_mgmt_registration
*reg
;
615 const struct ieee80211_txrx_stypes
*stypes
=
616 &wiphy
->mgmt_stypes
[wdev
->iftype
];
617 struct ieee80211_mgmt
*mgmt
= (void *)buf
;
621 __le16 ftype
= mgmt
->frame_control
&
622 cpu_to_le16(IEEE80211_FCTL_FTYPE
| IEEE80211_FCTL_STYPE
);
625 trace_cfg80211_rx_mgmt(wdev
, freq
, sig_mbm
);
626 stype
= (le16_to_cpu(mgmt
->frame_control
) & IEEE80211_FCTL_STYPE
) >> 4;
628 if (!(stypes
->rx
& BIT(stype
))) {
629 trace_cfg80211_return_bool(false);
633 data
= buf
+ ieee80211_hdrlen(mgmt
->frame_control
);
634 data_len
= len
- ieee80211_hdrlen(mgmt
->frame_control
);
636 spin_lock_bh(&wdev
->mgmt_registrations_lock
);
638 list_for_each_entry(reg
, &wdev
->mgmt_registrations
, list
) {
639 if (reg
->frame_type
!= ftype
)
642 if (reg
->match_len
> data_len
)
645 if (memcmp(reg
->match
, data
, reg
->match_len
))
650 /* Indicate the received Action frame to user space */
651 if (nl80211_send_mgmt(rdev
, wdev
, reg
->nlportid
,
653 buf
, len
, flags
, GFP_ATOMIC
))
660 spin_unlock_bh(&wdev
->mgmt_registrations_lock
);
662 trace_cfg80211_return_bool(result
);
665 EXPORT_SYMBOL(cfg80211_rx_mgmt
);
667 void cfg80211_dfs_channels_update_work(struct work_struct
*work
)
669 struct delayed_work
*delayed_work
;
670 struct cfg80211_registered_device
*rdev
;
671 struct cfg80211_chan_def chandef
;
672 struct ieee80211_supported_band
*sband
;
673 struct ieee80211_channel
*c
;
675 bool check_again
= false;
676 unsigned long timeout
, next_time
= 0;
679 delayed_work
= container_of(work
, struct delayed_work
, work
);
680 rdev
= container_of(delayed_work
, struct cfg80211_registered_device
,
681 dfs_update_channels_wk
);
682 wiphy
= &rdev
->wiphy
;
685 for (bandid
= 0; bandid
< IEEE80211_NUM_BANDS
; bandid
++) {
686 sband
= wiphy
->bands
[bandid
];
690 for (i
= 0; i
< sband
->n_channels
; i
++) {
691 c
= &sband
->channels
[i
];
693 if (c
->dfs_state
!= NL80211_DFS_UNAVAILABLE
)
696 timeout
= c
->dfs_state_entered
+ msecs_to_jiffies(
697 IEEE80211_DFS_MIN_NOP_TIME_MS
);
699 if (time_after_eq(jiffies
, timeout
)) {
700 c
->dfs_state
= NL80211_DFS_USABLE
;
701 c
->dfs_state_entered
= jiffies
;
703 cfg80211_chandef_create(&chandef
, c
,
706 nl80211_radar_notify(rdev
, &chandef
,
707 NL80211_RADAR_NOP_FINISHED
,
713 next_time
= timeout
- jiffies
;
715 next_time
= min(next_time
, timeout
- jiffies
);
721 /* reschedule if there are other channels waiting to be cleared again */
723 queue_delayed_work(cfg80211_wq
, &rdev
->dfs_update_channels_wk
,
728 void cfg80211_radar_event(struct wiphy
*wiphy
,
729 struct cfg80211_chan_def
*chandef
,
732 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wiphy
);
733 unsigned long timeout
;
735 trace_cfg80211_radar_event(wiphy
, chandef
);
737 /* only set the chandef supplied channel to unavailable, in
738 * case the radar is detected on only one of multiple channels
739 * spanned by the chandef.
741 cfg80211_set_dfs_state(wiphy
, chandef
, NL80211_DFS_UNAVAILABLE
);
743 timeout
= msecs_to_jiffies(IEEE80211_DFS_MIN_NOP_TIME_MS
);
744 queue_delayed_work(cfg80211_wq
, &rdev
->dfs_update_channels_wk
,
747 nl80211_radar_notify(rdev
, chandef
, NL80211_RADAR_DETECTED
, NULL
, gfp
);
749 EXPORT_SYMBOL(cfg80211_radar_event
);
751 void cfg80211_cac_event(struct net_device
*netdev
,
752 const struct cfg80211_chan_def
*chandef
,
753 enum nl80211_radar_event event
, gfp_t gfp
)
755 struct wireless_dev
*wdev
= netdev
->ieee80211_ptr
;
756 struct wiphy
*wiphy
= wdev
->wiphy
;
757 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wiphy
);
758 unsigned long timeout
;
760 trace_cfg80211_cac_event(netdev
, event
);
762 if (WARN_ON(!wdev
->cac_started
))
765 if (WARN_ON(!wdev
->chandef
.chan
))
769 case NL80211_RADAR_CAC_FINISHED
:
770 timeout
= wdev
->cac_start_time
+
771 msecs_to_jiffies(wdev
->cac_time_ms
);
772 WARN_ON(!time_after_eq(jiffies
, timeout
));
773 cfg80211_set_dfs_state(wiphy
, chandef
, NL80211_DFS_AVAILABLE
);
775 case NL80211_RADAR_CAC_ABORTED
:
781 wdev
->cac_started
= false;
783 nl80211_radar_notify(rdev
, chandef
, event
, netdev
, gfp
);
785 EXPORT_SYMBOL(cfg80211_cac_event
);