18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * cfg80211 MLME SAP interface 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2009, Jouni Malinen <j@w1.fi> 68c2ecf20Sopenharmony_ci * Copyright (c) 2015 Intel Deutschland GmbH 78c2ecf20Sopenharmony_ci * Copyright (C) 2019 Intel Corporation 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/kernel.h> 118c2ecf20Sopenharmony_ci#include <linux/module.h> 128c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 138c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 148c2ecf20Sopenharmony_ci#include <linux/nl80211.h> 158c2ecf20Sopenharmony_ci#include <linux/slab.h> 168c2ecf20Sopenharmony_ci#include <linux/wireless.h> 178c2ecf20Sopenharmony_ci#include <net/cfg80211.h> 188c2ecf20Sopenharmony_ci#include <net/iw_handler.h> 198c2ecf20Sopenharmony_ci#include "core.h" 208c2ecf20Sopenharmony_ci#include "nl80211.h" 218c2ecf20Sopenharmony_ci#include "rdev-ops.h" 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_civoid cfg80211_rx_assoc_resp(struct net_device *dev, struct cfg80211_bss *bss, 258c2ecf20Sopenharmony_ci const u8 *buf, size_t len, int uapsd_queues, 268c2ecf20Sopenharmony_ci const u8 *req_ies, size_t req_ies_len) 278c2ecf20Sopenharmony_ci{ 288c2ecf20Sopenharmony_ci struct wireless_dev *wdev = dev->ieee80211_ptr; 298c2ecf20Sopenharmony_ci struct wiphy *wiphy = wdev->wiphy; 308c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 318c2ecf20Sopenharmony_ci struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; 328c2ecf20Sopenharmony_ci struct cfg80211_connect_resp_params cr; 338c2ecf20Sopenharmony_ci const u8 *resp_ie = mgmt->u.assoc_resp.variable; 348c2ecf20Sopenharmony_ci size_t resp_ie_len = len - offsetof(struct ieee80211_mgmt, 358c2ecf20Sopenharmony_ci u.assoc_resp.variable); 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci if (bss->channel->band == NL80211_BAND_S1GHZ) { 388c2ecf20Sopenharmony_ci resp_ie = (u8 *)&mgmt->u.s1g_assoc_resp.variable; 398c2ecf20Sopenharmony_ci resp_ie_len = len - offsetof(struct ieee80211_mgmt, 408c2ecf20Sopenharmony_ci u.s1g_assoc_resp.variable); 418c2ecf20Sopenharmony_ci } 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci memset(&cr, 0, sizeof(cr)); 448c2ecf20Sopenharmony_ci cr.status = (int)le16_to_cpu(mgmt->u.assoc_resp.status_code); 458c2ecf20Sopenharmony_ci cr.bssid = mgmt->bssid; 468c2ecf20Sopenharmony_ci cr.bss = bss; 478c2ecf20Sopenharmony_ci cr.req_ie = req_ies; 488c2ecf20Sopenharmony_ci cr.req_ie_len = req_ies_len; 498c2ecf20Sopenharmony_ci cr.resp_ie = resp_ie; 508c2ecf20Sopenharmony_ci cr.resp_ie_len = resp_ie_len; 518c2ecf20Sopenharmony_ci cr.timeout_reason = NL80211_TIMEOUT_UNSPECIFIED; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci trace_cfg80211_send_rx_assoc(dev, bss); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci /* 568c2ecf20Sopenharmony_ci * This is a bit of a hack, we don't notify userspace of 578c2ecf20Sopenharmony_ci * a (re-)association reply if we tried to send a reassoc 588c2ecf20Sopenharmony_ci * and got a reject -- we only try again with an assoc 598c2ecf20Sopenharmony_ci * frame instead of reassoc. 608c2ecf20Sopenharmony_ci */ 618c2ecf20Sopenharmony_ci if (cfg80211_sme_rx_assoc_resp(wdev, cr.status)) { 628c2ecf20Sopenharmony_ci cfg80211_unhold_bss(bss_from_pub(bss)); 638c2ecf20Sopenharmony_ci cfg80211_put_bss(wiphy, bss); 648c2ecf20Sopenharmony_ci return; 658c2ecf20Sopenharmony_ci } 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci nl80211_send_rx_assoc(rdev, dev, buf, len, GFP_KERNEL, uapsd_queues, 688c2ecf20Sopenharmony_ci req_ies, req_ies_len); 698c2ecf20Sopenharmony_ci /* update current_bss etc., consumes the bss reference */ 708c2ecf20Sopenharmony_ci __cfg80211_connect_result(dev, &cr, cr.status == WLAN_STATUS_SUCCESS); 718c2ecf20Sopenharmony_ci} 728c2ecf20Sopenharmony_ciEXPORT_SYMBOL(cfg80211_rx_assoc_resp); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cistatic void cfg80211_process_auth(struct wireless_dev *wdev, 758c2ecf20Sopenharmony_ci const u8 *buf, size_t len) 768c2ecf20Sopenharmony_ci{ 778c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci nl80211_send_rx_auth(rdev, wdev->netdev, buf, len, GFP_KERNEL); 808c2ecf20Sopenharmony_ci cfg80211_sme_rx_auth(wdev, buf, len); 818c2ecf20Sopenharmony_ci} 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cistatic void cfg80211_process_deauth(struct wireless_dev *wdev, 848c2ecf20Sopenharmony_ci const u8 *buf, size_t len) 858c2ecf20Sopenharmony_ci{ 868c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 878c2ecf20Sopenharmony_ci struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; 888c2ecf20Sopenharmony_ci const u8 *bssid = mgmt->bssid; 898c2ecf20Sopenharmony_ci u16 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); 908c2ecf20Sopenharmony_ci bool from_ap = !ether_addr_equal(mgmt->sa, wdev->netdev->dev_addr); 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci nl80211_send_deauth(rdev, wdev->netdev, buf, len, GFP_KERNEL); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci if (!wdev->current_bss || 958c2ecf20Sopenharmony_ci !ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) 968c2ecf20Sopenharmony_ci return; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci __cfg80211_disconnected(wdev->netdev, NULL, 0, reason_code, from_ap); 998c2ecf20Sopenharmony_ci cfg80211_sme_deauth(wdev); 1008c2ecf20Sopenharmony_ci} 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistatic void cfg80211_process_disassoc(struct wireless_dev *wdev, 1038c2ecf20Sopenharmony_ci const u8 *buf, size_t len) 1048c2ecf20Sopenharmony_ci{ 1058c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 1068c2ecf20Sopenharmony_ci struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; 1078c2ecf20Sopenharmony_ci const u8 *bssid = mgmt->bssid; 1088c2ecf20Sopenharmony_ci u16 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); 1098c2ecf20Sopenharmony_ci bool from_ap = !ether_addr_equal(mgmt->sa, wdev->netdev->dev_addr); 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci nl80211_send_disassoc(rdev, wdev->netdev, buf, len, GFP_KERNEL); 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci if (WARN_ON(!wdev->current_bss || 1148c2ecf20Sopenharmony_ci !ether_addr_equal(wdev->current_bss->pub.bssid, bssid))) 1158c2ecf20Sopenharmony_ci return; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci __cfg80211_disconnected(wdev->netdev, NULL, 0, reason_code, from_ap); 1188c2ecf20Sopenharmony_ci cfg80211_sme_disassoc(wdev); 1198c2ecf20Sopenharmony_ci} 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_civoid cfg80211_rx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len) 1228c2ecf20Sopenharmony_ci{ 1238c2ecf20Sopenharmony_ci struct wireless_dev *wdev = dev->ieee80211_ptr; 1248c2ecf20Sopenharmony_ci struct ieee80211_mgmt *mgmt = (void *)buf; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci ASSERT_WDEV_LOCK(wdev); 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci trace_cfg80211_rx_mlme_mgmt(dev, buf, len); 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci if (WARN_ON(len < 2)) 1318c2ecf20Sopenharmony_ci return; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci if (ieee80211_is_auth(mgmt->frame_control)) 1348c2ecf20Sopenharmony_ci cfg80211_process_auth(wdev, buf, len); 1358c2ecf20Sopenharmony_ci else if (ieee80211_is_deauth(mgmt->frame_control)) 1368c2ecf20Sopenharmony_ci cfg80211_process_deauth(wdev, buf, len); 1378c2ecf20Sopenharmony_ci else if (ieee80211_is_disassoc(mgmt->frame_control)) 1388c2ecf20Sopenharmony_ci cfg80211_process_disassoc(wdev, buf, len); 1398c2ecf20Sopenharmony_ci} 1408c2ecf20Sopenharmony_ciEXPORT_SYMBOL(cfg80211_rx_mlme_mgmt); 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_civoid cfg80211_auth_timeout(struct net_device *dev, const u8 *addr) 1438c2ecf20Sopenharmony_ci{ 1448c2ecf20Sopenharmony_ci struct wireless_dev *wdev = dev->ieee80211_ptr; 1458c2ecf20Sopenharmony_ci struct wiphy *wiphy = wdev->wiphy; 1468c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci trace_cfg80211_send_auth_timeout(dev, addr); 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL); 1518c2ecf20Sopenharmony_ci cfg80211_sme_auth_timeout(wdev); 1528c2ecf20Sopenharmony_ci} 1538c2ecf20Sopenharmony_ciEXPORT_SYMBOL(cfg80211_auth_timeout); 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_civoid cfg80211_assoc_timeout(struct net_device *dev, struct cfg80211_bss *bss) 1568c2ecf20Sopenharmony_ci{ 1578c2ecf20Sopenharmony_ci struct wireless_dev *wdev = dev->ieee80211_ptr; 1588c2ecf20Sopenharmony_ci struct wiphy *wiphy = wdev->wiphy; 1598c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci trace_cfg80211_send_assoc_timeout(dev, bss->bssid); 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci nl80211_send_assoc_timeout(rdev, dev, bss->bssid, GFP_KERNEL); 1648c2ecf20Sopenharmony_ci cfg80211_sme_assoc_timeout(wdev); 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci cfg80211_unhold_bss(bss_from_pub(bss)); 1678c2ecf20Sopenharmony_ci cfg80211_put_bss(wiphy, bss); 1688c2ecf20Sopenharmony_ci} 1698c2ecf20Sopenharmony_ciEXPORT_SYMBOL(cfg80211_assoc_timeout); 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_civoid cfg80211_abandon_assoc(struct net_device *dev, struct cfg80211_bss *bss) 1728c2ecf20Sopenharmony_ci{ 1738c2ecf20Sopenharmony_ci struct wireless_dev *wdev = dev->ieee80211_ptr; 1748c2ecf20Sopenharmony_ci struct wiphy *wiphy = wdev->wiphy; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci cfg80211_sme_abandon_assoc(wdev); 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci cfg80211_unhold_bss(bss_from_pub(bss)); 1798c2ecf20Sopenharmony_ci cfg80211_put_bss(wiphy, bss); 1808c2ecf20Sopenharmony_ci} 1818c2ecf20Sopenharmony_ciEXPORT_SYMBOL(cfg80211_abandon_assoc); 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_civoid cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len) 1848c2ecf20Sopenharmony_ci{ 1858c2ecf20Sopenharmony_ci struct wireless_dev *wdev = dev->ieee80211_ptr; 1868c2ecf20Sopenharmony_ci struct ieee80211_mgmt *mgmt = (void *)buf; 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci ASSERT_WDEV_LOCK(wdev); 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci trace_cfg80211_tx_mlme_mgmt(dev, buf, len); 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci if (WARN_ON(len < 2)) 1938c2ecf20Sopenharmony_ci return; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci if (ieee80211_is_deauth(mgmt->frame_control)) 1968c2ecf20Sopenharmony_ci cfg80211_process_deauth(wdev, buf, len); 1978c2ecf20Sopenharmony_ci else 1988c2ecf20Sopenharmony_ci cfg80211_process_disassoc(wdev, buf, len); 1998c2ecf20Sopenharmony_ci} 2008c2ecf20Sopenharmony_ciEXPORT_SYMBOL(cfg80211_tx_mlme_mgmt); 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_civoid cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr, 2038c2ecf20Sopenharmony_ci enum nl80211_key_type key_type, int key_id, 2048c2ecf20Sopenharmony_ci const u8 *tsc, gfp_t gfp) 2058c2ecf20Sopenharmony_ci{ 2068c2ecf20Sopenharmony_ci struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 2078c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 2088c2ecf20Sopenharmony_ci#ifdef CONFIG_CFG80211_WEXT 2098c2ecf20Sopenharmony_ci union iwreq_data wrqu; 2108c2ecf20Sopenharmony_ci char *buf = kmalloc(128, gfp); 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci if (buf) { 2138c2ecf20Sopenharmony_ci sprintf(buf, "MLME-MICHAELMICFAILURE.indication(" 2148c2ecf20Sopenharmony_ci "keyid=%d %scast addr=%pM)", key_id, 2158c2ecf20Sopenharmony_ci key_type == NL80211_KEYTYPE_GROUP ? "broad" : "uni", 2168c2ecf20Sopenharmony_ci addr); 2178c2ecf20Sopenharmony_ci memset(&wrqu, 0, sizeof(wrqu)); 2188c2ecf20Sopenharmony_ci wrqu.data.length = strlen(buf); 2198c2ecf20Sopenharmony_ci wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); 2208c2ecf20Sopenharmony_ci kfree(buf); 2218c2ecf20Sopenharmony_ci } 2228c2ecf20Sopenharmony_ci#endif 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci trace_cfg80211_michael_mic_failure(dev, addr, key_type, key_id, tsc); 2258c2ecf20Sopenharmony_ci nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp); 2268c2ecf20Sopenharmony_ci} 2278c2ecf20Sopenharmony_ciEXPORT_SYMBOL(cfg80211_michael_mic_failure); 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci/* some MLME handling for userspace SME */ 2308c2ecf20Sopenharmony_ciint cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, 2318c2ecf20Sopenharmony_ci struct net_device *dev, 2328c2ecf20Sopenharmony_ci struct ieee80211_channel *chan, 2338c2ecf20Sopenharmony_ci enum nl80211_auth_type auth_type, 2348c2ecf20Sopenharmony_ci const u8 *bssid, 2358c2ecf20Sopenharmony_ci const u8 *ssid, int ssid_len, 2368c2ecf20Sopenharmony_ci const u8 *ie, int ie_len, 2378c2ecf20Sopenharmony_ci const u8 *key, int key_len, int key_idx, 2388c2ecf20Sopenharmony_ci const u8 *auth_data, int auth_data_len) 2398c2ecf20Sopenharmony_ci{ 2408c2ecf20Sopenharmony_ci struct wireless_dev *wdev = dev->ieee80211_ptr; 2418c2ecf20Sopenharmony_ci struct cfg80211_auth_request req = { 2428c2ecf20Sopenharmony_ci .ie = ie, 2438c2ecf20Sopenharmony_ci .ie_len = ie_len, 2448c2ecf20Sopenharmony_ci .auth_data = auth_data, 2458c2ecf20Sopenharmony_ci .auth_data_len = auth_data_len, 2468c2ecf20Sopenharmony_ci .auth_type = auth_type, 2478c2ecf20Sopenharmony_ci .key = key, 2488c2ecf20Sopenharmony_ci .key_len = key_len, 2498c2ecf20Sopenharmony_ci .key_idx = key_idx, 2508c2ecf20Sopenharmony_ci }; 2518c2ecf20Sopenharmony_ci int err; 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci ASSERT_WDEV_LOCK(wdev); 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci if (auth_type == NL80211_AUTHTYPE_SHARED_KEY) 2568c2ecf20Sopenharmony_ci if (!key || !key_len || key_idx < 0 || key_idx > 3) 2578c2ecf20Sopenharmony_ci return -EINVAL; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci if (wdev->current_bss && 2608c2ecf20Sopenharmony_ci ether_addr_equal(bssid, wdev->current_bss->pub.bssid)) 2618c2ecf20Sopenharmony_ci return -EALREADY; 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, 2648c2ecf20Sopenharmony_ci IEEE80211_BSS_TYPE_ESS, 2658c2ecf20Sopenharmony_ci IEEE80211_PRIVACY_ANY); 2668c2ecf20Sopenharmony_ci if (!req.bss) 2678c2ecf20Sopenharmony_ci return -ENOENT; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci err = rdev_auth(rdev, dev, &req); 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci cfg80211_put_bss(&rdev->wiphy, req.bss); 2728c2ecf20Sopenharmony_ci return err; 2738c2ecf20Sopenharmony_ci} 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci/* Do a logical ht_capa &= ht_capa_mask. */ 2768c2ecf20Sopenharmony_civoid cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa, 2778c2ecf20Sopenharmony_ci const struct ieee80211_ht_cap *ht_capa_mask) 2788c2ecf20Sopenharmony_ci{ 2798c2ecf20Sopenharmony_ci int i; 2808c2ecf20Sopenharmony_ci u8 *p1, *p2; 2818c2ecf20Sopenharmony_ci if (!ht_capa_mask) { 2828c2ecf20Sopenharmony_ci memset(ht_capa, 0, sizeof(*ht_capa)); 2838c2ecf20Sopenharmony_ci return; 2848c2ecf20Sopenharmony_ci } 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci p1 = (u8*)(ht_capa); 2878c2ecf20Sopenharmony_ci p2 = (u8*)(ht_capa_mask); 2888c2ecf20Sopenharmony_ci for (i = 0; i < sizeof(*ht_capa); i++) 2898c2ecf20Sopenharmony_ci p1[i] &= p2[i]; 2908c2ecf20Sopenharmony_ci} 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci/* Do a logical vht_capa &= vht_capa_mask. */ 2938c2ecf20Sopenharmony_civoid cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa, 2948c2ecf20Sopenharmony_ci const struct ieee80211_vht_cap *vht_capa_mask) 2958c2ecf20Sopenharmony_ci{ 2968c2ecf20Sopenharmony_ci int i; 2978c2ecf20Sopenharmony_ci u8 *p1, *p2; 2988c2ecf20Sopenharmony_ci if (!vht_capa_mask) { 2998c2ecf20Sopenharmony_ci memset(vht_capa, 0, sizeof(*vht_capa)); 3008c2ecf20Sopenharmony_ci return; 3018c2ecf20Sopenharmony_ci } 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci p1 = (u8*)(vht_capa); 3048c2ecf20Sopenharmony_ci p2 = (u8*)(vht_capa_mask); 3058c2ecf20Sopenharmony_ci for (i = 0; i < sizeof(*vht_capa); i++) 3068c2ecf20Sopenharmony_ci p1[i] &= p2[i]; 3078c2ecf20Sopenharmony_ci} 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ciint cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, 3108c2ecf20Sopenharmony_ci struct net_device *dev, 3118c2ecf20Sopenharmony_ci struct ieee80211_channel *chan, 3128c2ecf20Sopenharmony_ci const u8 *bssid, 3138c2ecf20Sopenharmony_ci const u8 *ssid, int ssid_len, 3148c2ecf20Sopenharmony_ci struct cfg80211_assoc_request *req) 3158c2ecf20Sopenharmony_ci{ 3168c2ecf20Sopenharmony_ci struct wireless_dev *wdev = dev->ieee80211_ptr; 3178c2ecf20Sopenharmony_ci int err; 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci ASSERT_WDEV_LOCK(wdev); 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci if (wdev->current_bss && 3228c2ecf20Sopenharmony_ci (!req->prev_bssid || !ether_addr_equal(wdev->current_bss->pub.bssid, 3238c2ecf20Sopenharmony_ci req->prev_bssid))) 3248c2ecf20Sopenharmony_ci return -EALREADY; 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci cfg80211_oper_and_ht_capa(&req->ht_capa_mask, 3278c2ecf20Sopenharmony_ci rdev->wiphy.ht_capa_mod_mask); 3288c2ecf20Sopenharmony_ci cfg80211_oper_and_vht_capa(&req->vht_capa_mask, 3298c2ecf20Sopenharmony_ci rdev->wiphy.vht_capa_mod_mask); 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci req->bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, 3328c2ecf20Sopenharmony_ci IEEE80211_BSS_TYPE_ESS, 3338c2ecf20Sopenharmony_ci IEEE80211_PRIVACY_ANY); 3348c2ecf20Sopenharmony_ci if (!req->bss) 3358c2ecf20Sopenharmony_ci return -ENOENT; 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci err = rdev_assoc(rdev, dev, req); 3388c2ecf20Sopenharmony_ci if (!err) 3398c2ecf20Sopenharmony_ci cfg80211_hold_bss(bss_from_pub(req->bss)); 3408c2ecf20Sopenharmony_ci else 3418c2ecf20Sopenharmony_ci cfg80211_put_bss(&rdev->wiphy, req->bss); 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci return err; 3448c2ecf20Sopenharmony_ci} 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ciint cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, 3478c2ecf20Sopenharmony_ci struct net_device *dev, const u8 *bssid, 3488c2ecf20Sopenharmony_ci const u8 *ie, int ie_len, u16 reason, 3498c2ecf20Sopenharmony_ci bool local_state_change) 3508c2ecf20Sopenharmony_ci{ 3518c2ecf20Sopenharmony_ci struct wireless_dev *wdev = dev->ieee80211_ptr; 3528c2ecf20Sopenharmony_ci struct cfg80211_deauth_request req = { 3538c2ecf20Sopenharmony_ci .bssid = bssid, 3548c2ecf20Sopenharmony_ci .reason_code = reason, 3558c2ecf20Sopenharmony_ci .ie = ie, 3568c2ecf20Sopenharmony_ci .ie_len = ie_len, 3578c2ecf20Sopenharmony_ci .local_state_change = local_state_change, 3588c2ecf20Sopenharmony_ci }; 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci ASSERT_WDEV_LOCK(wdev); 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_ci if (local_state_change && 3638c2ecf20Sopenharmony_ci (!wdev->current_bss || 3648c2ecf20Sopenharmony_ci !ether_addr_equal(wdev->current_bss->pub.bssid, bssid))) 3658c2ecf20Sopenharmony_ci return 0; 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci if (ether_addr_equal(wdev->disconnect_bssid, bssid) || 3688c2ecf20Sopenharmony_ci (wdev->current_bss && 3698c2ecf20Sopenharmony_ci ether_addr_equal(wdev->current_bss->pub.bssid, bssid))) 3708c2ecf20Sopenharmony_ci wdev->conn_owner_nlportid = 0; 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci return rdev_deauth(rdev, dev, &req); 3738c2ecf20Sopenharmony_ci} 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ciint cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, 3768c2ecf20Sopenharmony_ci struct net_device *dev, const u8 *bssid, 3778c2ecf20Sopenharmony_ci const u8 *ie, int ie_len, u16 reason, 3788c2ecf20Sopenharmony_ci bool local_state_change) 3798c2ecf20Sopenharmony_ci{ 3808c2ecf20Sopenharmony_ci struct wireless_dev *wdev = dev->ieee80211_ptr; 3818c2ecf20Sopenharmony_ci struct cfg80211_disassoc_request req = { 3828c2ecf20Sopenharmony_ci .reason_code = reason, 3838c2ecf20Sopenharmony_ci .local_state_change = local_state_change, 3848c2ecf20Sopenharmony_ci .ie = ie, 3858c2ecf20Sopenharmony_ci .ie_len = ie_len, 3868c2ecf20Sopenharmony_ci }; 3878c2ecf20Sopenharmony_ci int err; 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci ASSERT_WDEV_LOCK(wdev); 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci if (!wdev->current_bss) 3928c2ecf20Sopenharmony_ci return -ENOTCONN; 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci if (ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) 3958c2ecf20Sopenharmony_ci req.bss = &wdev->current_bss->pub; 3968c2ecf20Sopenharmony_ci else 3978c2ecf20Sopenharmony_ci return -ENOTCONN; 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci err = rdev_disassoc(rdev, dev, &req); 4008c2ecf20Sopenharmony_ci if (err) 4018c2ecf20Sopenharmony_ci return err; 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_ci /* driver should have reported the disassoc */ 4048c2ecf20Sopenharmony_ci WARN_ON(wdev->current_bss); 4058c2ecf20Sopenharmony_ci return 0; 4068c2ecf20Sopenharmony_ci} 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_civoid cfg80211_mlme_down(struct cfg80211_registered_device *rdev, 4098c2ecf20Sopenharmony_ci struct net_device *dev) 4108c2ecf20Sopenharmony_ci{ 4118c2ecf20Sopenharmony_ci struct wireless_dev *wdev = dev->ieee80211_ptr; 4128c2ecf20Sopenharmony_ci u8 bssid[ETH_ALEN]; 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci ASSERT_WDEV_LOCK(wdev); 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_ci if (!rdev->ops->deauth) 4178c2ecf20Sopenharmony_ci return; 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_ci if (!wdev->current_bss) 4208c2ecf20Sopenharmony_ci return; 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); 4238c2ecf20Sopenharmony_ci cfg80211_mlme_deauth(rdev, dev, bssid, NULL, 0, 4248c2ecf20Sopenharmony_ci WLAN_REASON_DEAUTH_LEAVING, false); 4258c2ecf20Sopenharmony_ci} 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_cistruct cfg80211_mgmt_registration { 4288c2ecf20Sopenharmony_ci struct list_head list; 4298c2ecf20Sopenharmony_ci struct wireless_dev *wdev; 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ci u32 nlportid; 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_ci int match_len; 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_ci __le16 frame_type; 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci bool multicast_rx; 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci u8 match[]; 4408c2ecf20Sopenharmony_ci}; 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_cistatic void cfg80211_mgmt_registrations_update(struct wireless_dev *wdev) 4438c2ecf20Sopenharmony_ci{ 4448c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 4458c2ecf20Sopenharmony_ci struct wireless_dev *tmp; 4468c2ecf20Sopenharmony_ci struct cfg80211_mgmt_registration *reg; 4478c2ecf20Sopenharmony_ci struct mgmt_frame_regs upd = {}; 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci ASSERT_RTNL(); 4508c2ecf20Sopenharmony_ci 4518c2ecf20Sopenharmony_ci spin_lock_bh(&rdev->mgmt_registrations_lock); 4528c2ecf20Sopenharmony_ci if (!wdev->mgmt_registrations_need_update) { 4538c2ecf20Sopenharmony_ci spin_unlock_bh(&rdev->mgmt_registrations_lock); 4548c2ecf20Sopenharmony_ci return; 4558c2ecf20Sopenharmony_ci } 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci rcu_read_lock(); 4588c2ecf20Sopenharmony_ci list_for_each_entry_rcu(tmp, &rdev->wiphy.wdev_list, list) { 4598c2ecf20Sopenharmony_ci list_for_each_entry(reg, &tmp->mgmt_registrations, list) { 4608c2ecf20Sopenharmony_ci u32 mask = BIT(le16_to_cpu(reg->frame_type) >> 4); 4618c2ecf20Sopenharmony_ci u32 mcast_mask = 0; 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci if (reg->multicast_rx) 4648c2ecf20Sopenharmony_ci mcast_mask = mask; 4658c2ecf20Sopenharmony_ci 4668c2ecf20Sopenharmony_ci upd.global_stypes |= mask; 4678c2ecf20Sopenharmony_ci upd.global_mcast_stypes |= mcast_mask; 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_ci if (tmp == wdev) { 4708c2ecf20Sopenharmony_ci upd.interface_stypes |= mask; 4718c2ecf20Sopenharmony_ci upd.interface_mcast_stypes |= mcast_mask; 4728c2ecf20Sopenharmony_ci } 4738c2ecf20Sopenharmony_ci } 4748c2ecf20Sopenharmony_ci } 4758c2ecf20Sopenharmony_ci rcu_read_unlock(); 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci wdev->mgmt_registrations_need_update = 0; 4788c2ecf20Sopenharmony_ci spin_unlock_bh(&rdev->mgmt_registrations_lock); 4798c2ecf20Sopenharmony_ci 4808c2ecf20Sopenharmony_ci rdev_update_mgmt_frame_registrations(rdev, wdev, &upd); 4818c2ecf20Sopenharmony_ci} 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_civoid cfg80211_mgmt_registrations_update_wk(struct work_struct *wk) 4848c2ecf20Sopenharmony_ci{ 4858c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev; 4868c2ecf20Sopenharmony_ci struct wireless_dev *wdev; 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_ci rdev = container_of(wk, struct cfg80211_registered_device, 4898c2ecf20Sopenharmony_ci mgmt_registrations_update_wk); 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci rtnl_lock(); 4928c2ecf20Sopenharmony_ci list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) 4938c2ecf20Sopenharmony_ci cfg80211_mgmt_registrations_update(wdev); 4948c2ecf20Sopenharmony_ci rtnl_unlock(); 4958c2ecf20Sopenharmony_ci} 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ciint cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid, 4988c2ecf20Sopenharmony_ci u16 frame_type, const u8 *match_data, 4998c2ecf20Sopenharmony_ci int match_len, bool multicast_rx, 5008c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack) 5018c2ecf20Sopenharmony_ci{ 5028c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 5038c2ecf20Sopenharmony_ci struct cfg80211_mgmt_registration *reg, *nreg; 5048c2ecf20Sopenharmony_ci int err = 0; 5058c2ecf20Sopenharmony_ci u16 mgmt_type; 5068c2ecf20Sopenharmony_ci bool update_multicast = false; 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_ci if (!wdev->wiphy->mgmt_stypes) 5098c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci if ((frame_type & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT) { 5128c2ecf20Sopenharmony_ci NL_SET_ERR_MSG(extack, "frame type not management"); 5138c2ecf20Sopenharmony_ci return -EINVAL; 5148c2ecf20Sopenharmony_ci } 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci if (frame_type & ~(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) { 5178c2ecf20Sopenharmony_ci NL_SET_ERR_MSG(extack, "Invalid frame type"); 5188c2ecf20Sopenharmony_ci return -EINVAL; 5198c2ecf20Sopenharmony_ci } 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ci mgmt_type = (frame_type & IEEE80211_FCTL_STYPE) >> 4; 5228c2ecf20Sopenharmony_ci if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].rx & BIT(mgmt_type))) { 5238c2ecf20Sopenharmony_ci NL_SET_ERR_MSG(extack, 5248c2ecf20Sopenharmony_ci "Registration to specific type not supported"); 5258c2ecf20Sopenharmony_ci return -EINVAL; 5268c2ecf20Sopenharmony_ci } 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_ci /* 5298c2ecf20Sopenharmony_ci * To support Pre Association Security Negotiation (PASN), registration 5308c2ecf20Sopenharmony_ci * for authentication frames should be supported. However, as some 5318c2ecf20Sopenharmony_ci * versions of the user space daemons wrongly register to all types of 5328c2ecf20Sopenharmony_ci * authentication frames (which might result in unexpected behavior) 5338c2ecf20Sopenharmony_ci * allow such registration if the request is for a specific 5348c2ecf20Sopenharmony_ci * authentication algorithm number. 5358c2ecf20Sopenharmony_ci */ 5368c2ecf20Sopenharmony_ci if (wdev->iftype == NL80211_IFTYPE_STATION && 5378c2ecf20Sopenharmony_ci (frame_type & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_AUTH && 5388c2ecf20Sopenharmony_ci !(match_data && match_len >= 2)) { 5398c2ecf20Sopenharmony_ci NL_SET_ERR_MSG(extack, 5408c2ecf20Sopenharmony_ci "Authentication algorithm number required"); 5418c2ecf20Sopenharmony_ci return -EINVAL; 5428c2ecf20Sopenharmony_ci } 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci nreg = kzalloc(sizeof(*reg) + match_len, GFP_KERNEL); 5458c2ecf20Sopenharmony_ci if (!nreg) 5468c2ecf20Sopenharmony_ci return -ENOMEM; 5478c2ecf20Sopenharmony_ci 5488c2ecf20Sopenharmony_ci spin_lock_bh(&rdev->mgmt_registrations_lock); 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ci list_for_each_entry(reg, &wdev->mgmt_registrations, list) { 5518c2ecf20Sopenharmony_ci int mlen = min(match_len, reg->match_len); 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_ci if (frame_type != le16_to_cpu(reg->frame_type)) 5548c2ecf20Sopenharmony_ci continue; 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_ci if (memcmp(reg->match, match_data, mlen) == 0) { 5578c2ecf20Sopenharmony_ci if (reg->multicast_rx != multicast_rx) { 5588c2ecf20Sopenharmony_ci update_multicast = true; 5598c2ecf20Sopenharmony_ci reg->multicast_rx = multicast_rx; 5608c2ecf20Sopenharmony_ci break; 5618c2ecf20Sopenharmony_ci } 5628c2ecf20Sopenharmony_ci NL_SET_ERR_MSG(extack, "Match already configured"); 5638c2ecf20Sopenharmony_ci err = -EALREADY; 5648c2ecf20Sopenharmony_ci break; 5658c2ecf20Sopenharmony_ci } 5668c2ecf20Sopenharmony_ci } 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci if (err) 5698c2ecf20Sopenharmony_ci goto out; 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_ci if (update_multicast) { 5728c2ecf20Sopenharmony_ci kfree(nreg); 5738c2ecf20Sopenharmony_ci } else { 5748c2ecf20Sopenharmony_ci memcpy(nreg->match, match_data, match_len); 5758c2ecf20Sopenharmony_ci nreg->match_len = match_len; 5768c2ecf20Sopenharmony_ci nreg->nlportid = snd_portid; 5778c2ecf20Sopenharmony_ci nreg->frame_type = cpu_to_le16(frame_type); 5788c2ecf20Sopenharmony_ci nreg->wdev = wdev; 5798c2ecf20Sopenharmony_ci nreg->multicast_rx = multicast_rx; 5808c2ecf20Sopenharmony_ci list_add(&nreg->list, &wdev->mgmt_registrations); 5818c2ecf20Sopenharmony_ci } 5828c2ecf20Sopenharmony_ci wdev->mgmt_registrations_need_update = 1; 5838c2ecf20Sopenharmony_ci spin_unlock_bh(&rdev->mgmt_registrations_lock); 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_ci cfg80211_mgmt_registrations_update(wdev); 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_ci return 0; 5888c2ecf20Sopenharmony_ci 5898c2ecf20Sopenharmony_ci out: 5908c2ecf20Sopenharmony_ci kfree(nreg); 5918c2ecf20Sopenharmony_ci spin_unlock_bh(&rdev->mgmt_registrations_lock); 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci return err; 5948c2ecf20Sopenharmony_ci} 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_civoid cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid) 5978c2ecf20Sopenharmony_ci{ 5988c2ecf20Sopenharmony_ci struct wiphy *wiphy = wdev->wiphy; 5998c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 6008c2ecf20Sopenharmony_ci struct cfg80211_mgmt_registration *reg, *tmp; 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_ci spin_lock_bh(&rdev->mgmt_registrations_lock); 6038c2ecf20Sopenharmony_ci 6048c2ecf20Sopenharmony_ci list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) { 6058c2ecf20Sopenharmony_ci if (reg->nlportid != nlportid) 6068c2ecf20Sopenharmony_ci continue; 6078c2ecf20Sopenharmony_ci 6088c2ecf20Sopenharmony_ci list_del(®->list); 6098c2ecf20Sopenharmony_ci kfree(reg); 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci wdev->mgmt_registrations_need_update = 1; 6128c2ecf20Sopenharmony_ci schedule_work(&rdev->mgmt_registrations_update_wk); 6138c2ecf20Sopenharmony_ci } 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci spin_unlock_bh(&rdev->mgmt_registrations_lock); 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci if (nlportid && rdev->crit_proto_nlportid == nlportid) { 6188c2ecf20Sopenharmony_ci rdev->crit_proto_nlportid = 0; 6198c2ecf20Sopenharmony_ci rdev_crit_proto_stop(rdev, wdev); 6208c2ecf20Sopenharmony_ci } 6218c2ecf20Sopenharmony_ci 6228c2ecf20Sopenharmony_ci if (nlportid == wdev->ap_unexpected_nlportid) 6238c2ecf20Sopenharmony_ci wdev->ap_unexpected_nlportid = 0; 6248c2ecf20Sopenharmony_ci} 6258c2ecf20Sopenharmony_ci 6268c2ecf20Sopenharmony_civoid cfg80211_mlme_purge_registrations(struct wireless_dev *wdev) 6278c2ecf20Sopenharmony_ci{ 6288c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 6298c2ecf20Sopenharmony_ci struct cfg80211_mgmt_registration *reg, *tmp; 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_ci spin_lock_bh(&rdev->mgmt_registrations_lock); 6328c2ecf20Sopenharmony_ci list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) { 6338c2ecf20Sopenharmony_ci list_del(®->list); 6348c2ecf20Sopenharmony_ci kfree(reg); 6358c2ecf20Sopenharmony_ci } 6368c2ecf20Sopenharmony_ci wdev->mgmt_registrations_need_update = 1; 6378c2ecf20Sopenharmony_ci spin_unlock_bh(&rdev->mgmt_registrations_lock); 6388c2ecf20Sopenharmony_ci 6398c2ecf20Sopenharmony_ci cfg80211_mgmt_registrations_update(wdev); 6408c2ecf20Sopenharmony_ci} 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_ciint cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, 6438c2ecf20Sopenharmony_ci struct wireless_dev *wdev, 6448c2ecf20Sopenharmony_ci struct cfg80211_mgmt_tx_params *params, u64 *cookie) 6458c2ecf20Sopenharmony_ci{ 6468c2ecf20Sopenharmony_ci const struct ieee80211_mgmt *mgmt; 6478c2ecf20Sopenharmony_ci u16 stype; 6488c2ecf20Sopenharmony_ci 6498c2ecf20Sopenharmony_ci if (!wdev->wiphy->mgmt_stypes) 6508c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 6518c2ecf20Sopenharmony_ci 6528c2ecf20Sopenharmony_ci if (!rdev->ops->mgmt_tx) 6538c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 6548c2ecf20Sopenharmony_ci 6558c2ecf20Sopenharmony_ci if (params->len < 24 + 1) 6568c2ecf20Sopenharmony_ci return -EINVAL; 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_ci mgmt = (const struct ieee80211_mgmt *)params->buf; 6598c2ecf20Sopenharmony_ci 6608c2ecf20Sopenharmony_ci if (!ieee80211_is_mgmt(mgmt->frame_control)) 6618c2ecf20Sopenharmony_ci return -EINVAL; 6628c2ecf20Sopenharmony_ci 6638c2ecf20Sopenharmony_ci stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE; 6648c2ecf20Sopenharmony_ci if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].tx & BIT(stype >> 4))) 6658c2ecf20Sopenharmony_ci return -EINVAL; 6668c2ecf20Sopenharmony_ci 6678c2ecf20Sopenharmony_ci if (ieee80211_is_action(mgmt->frame_control) && 6688c2ecf20Sopenharmony_ci mgmt->u.action.category != WLAN_CATEGORY_PUBLIC) { 6698c2ecf20Sopenharmony_ci int err = 0; 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_ci wdev_lock(wdev); 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_ci switch (wdev->iftype) { 6748c2ecf20Sopenharmony_ci case NL80211_IFTYPE_ADHOC: 6758c2ecf20Sopenharmony_ci case NL80211_IFTYPE_STATION: 6768c2ecf20Sopenharmony_ci case NL80211_IFTYPE_P2P_CLIENT: 6778c2ecf20Sopenharmony_ci if (!wdev->current_bss) { 6788c2ecf20Sopenharmony_ci err = -ENOTCONN; 6798c2ecf20Sopenharmony_ci break; 6808c2ecf20Sopenharmony_ci } 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci if (!ether_addr_equal(wdev->current_bss->pub.bssid, 6838c2ecf20Sopenharmony_ci mgmt->bssid)) { 6848c2ecf20Sopenharmony_ci err = -ENOTCONN; 6858c2ecf20Sopenharmony_ci break; 6868c2ecf20Sopenharmony_ci } 6878c2ecf20Sopenharmony_ci 6888c2ecf20Sopenharmony_ci /* 6898c2ecf20Sopenharmony_ci * check for IBSS DA must be done by driver as 6908c2ecf20Sopenharmony_ci * cfg80211 doesn't track the stations 6918c2ecf20Sopenharmony_ci */ 6928c2ecf20Sopenharmony_ci if (wdev->iftype == NL80211_IFTYPE_ADHOC) 6938c2ecf20Sopenharmony_ci break; 6948c2ecf20Sopenharmony_ci 6958c2ecf20Sopenharmony_ci /* for station, check that DA is the AP */ 6968c2ecf20Sopenharmony_ci if (!ether_addr_equal(wdev->current_bss->pub.bssid, 6978c2ecf20Sopenharmony_ci mgmt->da)) { 6988c2ecf20Sopenharmony_ci err = -ENOTCONN; 6998c2ecf20Sopenharmony_ci break; 7008c2ecf20Sopenharmony_ci } 7018c2ecf20Sopenharmony_ci break; 7028c2ecf20Sopenharmony_ci case NL80211_IFTYPE_AP: 7038c2ecf20Sopenharmony_ci case NL80211_IFTYPE_P2P_GO: 7048c2ecf20Sopenharmony_ci case NL80211_IFTYPE_AP_VLAN: 7058c2ecf20Sopenharmony_ci if (!ether_addr_equal(mgmt->bssid, wdev_address(wdev))) 7068c2ecf20Sopenharmony_ci err = -EINVAL; 7078c2ecf20Sopenharmony_ci break; 7088c2ecf20Sopenharmony_ci case NL80211_IFTYPE_MESH_POINT: 7098c2ecf20Sopenharmony_ci if (!ether_addr_equal(mgmt->sa, mgmt->bssid)) { 7108c2ecf20Sopenharmony_ci err = -EINVAL; 7118c2ecf20Sopenharmony_ci break; 7128c2ecf20Sopenharmony_ci } 7138c2ecf20Sopenharmony_ci /* 7148c2ecf20Sopenharmony_ci * check for mesh DA must be done by driver as 7158c2ecf20Sopenharmony_ci * cfg80211 doesn't track the stations 7168c2ecf20Sopenharmony_ci */ 7178c2ecf20Sopenharmony_ci break; 7188c2ecf20Sopenharmony_ci case NL80211_IFTYPE_P2P_DEVICE: 7198c2ecf20Sopenharmony_ci /* 7208c2ecf20Sopenharmony_ci * fall through, P2P device only supports 7218c2ecf20Sopenharmony_ci * public action frames 7228c2ecf20Sopenharmony_ci */ 7238c2ecf20Sopenharmony_ci case NL80211_IFTYPE_NAN: 7248c2ecf20Sopenharmony_ci default: 7258c2ecf20Sopenharmony_ci err = -EOPNOTSUPP; 7268c2ecf20Sopenharmony_ci break; 7278c2ecf20Sopenharmony_ci } 7288c2ecf20Sopenharmony_ci wdev_unlock(wdev); 7298c2ecf20Sopenharmony_ci 7308c2ecf20Sopenharmony_ci if (err) 7318c2ecf20Sopenharmony_ci return err; 7328c2ecf20Sopenharmony_ci } 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_ci if (!ether_addr_equal(mgmt->sa, wdev_address(wdev))) { 7358c2ecf20Sopenharmony_ci /* Allow random TA to be used with Public Action frames if the 7368c2ecf20Sopenharmony_ci * driver has indicated support for this. Otherwise, only allow 7378c2ecf20Sopenharmony_ci * the local address to be used. 7388c2ecf20Sopenharmony_ci */ 7398c2ecf20Sopenharmony_ci if (!ieee80211_is_action(mgmt->frame_control) || 7408c2ecf20Sopenharmony_ci mgmt->u.action.category != WLAN_CATEGORY_PUBLIC) 7418c2ecf20Sopenharmony_ci return -EINVAL; 7428c2ecf20Sopenharmony_ci if (!wdev->current_bss && 7438c2ecf20Sopenharmony_ci !wiphy_ext_feature_isset( 7448c2ecf20Sopenharmony_ci &rdev->wiphy, 7458c2ecf20Sopenharmony_ci NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA)) 7468c2ecf20Sopenharmony_ci return -EINVAL; 7478c2ecf20Sopenharmony_ci if (wdev->current_bss && 7488c2ecf20Sopenharmony_ci !wiphy_ext_feature_isset( 7498c2ecf20Sopenharmony_ci &rdev->wiphy, 7508c2ecf20Sopenharmony_ci NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED)) 7518c2ecf20Sopenharmony_ci return -EINVAL; 7528c2ecf20Sopenharmony_ci } 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci /* Transmit the Action frame as requested by user space */ 7558c2ecf20Sopenharmony_ci return rdev_mgmt_tx(rdev, wdev, params, cookie); 7568c2ecf20Sopenharmony_ci} 7578c2ecf20Sopenharmony_ci 7588c2ecf20Sopenharmony_cibool cfg80211_rx_mgmt_khz(struct wireless_dev *wdev, int freq, int sig_dbm, 7598c2ecf20Sopenharmony_ci const u8 *buf, size_t len, u32 flags) 7608c2ecf20Sopenharmony_ci{ 7618c2ecf20Sopenharmony_ci struct wiphy *wiphy = wdev->wiphy; 7628c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 7638c2ecf20Sopenharmony_ci struct cfg80211_mgmt_registration *reg; 7648c2ecf20Sopenharmony_ci const struct ieee80211_txrx_stypes *stypes = 7658c2ecf20Sopenharmony_ci &wiphy->mgmt_stypes[wdev->iftype]; 7668c2ecf20Sopenharmony_ci struct ieee80211_mgmt *mgmt = (void *)buf; 7678c2ecf20Sopenharmony_ci const u8 *data; 7688c2ecf20Sopenharmony_ci int data_len; 7698c2ecf20Sopenharmony_ci bool result = false; 7708c2ecf20Sopenharmony_ci __le16 ftype = mgmt->frame_control & 7718c2ecf20Sopenharmony_ci cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE); 7728c2ecf20Sopenharmony_ci u16 stype; 7738c2ecf20Sopenharmony_ci 7748c2ecf20Sopenharmony_ci trace_cfg80211_rx_mgmt(wdev, freq, sig_dbm); 7758c2ecf20Sopenharmony_ci stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4; 7768c2ecf20Sopenharmony_ci 7778c2ecf20Sopenharmony_ci if (!(stypes->rx & BIT(stype))) { 7788c2ecf20Sopenharmony_ci trace_cfg80211_return_bool(false); 7798c2ecf20Sopenharmony_ci return false; 7808c2ecf20Sopenharmony_ci } 7818c2ecf20Sopenharmony_ci 7828c2ecf20Sopenharmony_ci data = buf + ieee80211_hdrlen(mgmt->frame_control); 7838c2ecf20Sopenharmony_ci data_len = len - ieee80211_hdrlen(mgmt->frame_control); 7848c2ecf20Sopenharmony_ci 7858c2ecf20Sopenharmony_ci spin_lock_bh(&rdev->mgmt_registrations_lock); 7868c2ecf20Sopenharmony_ci 7878c2ecf20Sopenharmony_ci list_for_each_entry(reg, &wdev->mgmt_registrations, list) { 7888c2ecf20Sopenharmony_ci if (reg->frame_type != ftype) 7898c2ecf20Sopenharmony_ci continue; 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci if (reg->match_len > data_len) 7928c2ecf20Sopenharmony_ci continue; 7938c2ecf20Sopenharmony_ci 7948c2ecf20Sopenharmony_ci if (memcmp(reg->match, data, reg->match_len)) 7958c2ecf20Sopenharmony_ci continue; 7968c2ecf20Sopenharmony_ci 7978c2ecf20Sopenharmony_ci /* found match! */ 7988c2ecf20Sopenharmony_ci 7998c2ecf20Sopenharmony_ci /* Indicate the received Action frame to user space */ 8008c2ecf20Sopenharmony_ci if (nl80211_send_mgmt(rdev, wdev, reg->nlportid, 8018c2ecf20Sopenharmony_ci freq, sig_dbm, 8028c2ecf20Sopenharmony_ci buf, len, flags, GFP_ATOMIC)) 8038c2ecf20Sopenharmony_ci continue; 8048c2ecf20Sopenharmony_ci 8058c2ecf20Sopenharmony_ci result = true; 8068c2ecf20Sopenharmony_ci break; 8078c2ecf20Sopenharmony_ci } 8088c2ecf20Sopenharmony_ci 8098c2ecf20Sopenharmony_ci spin_unlock_bh(&rdev->mgmt_registrations_lock); 8108c2ecf20Sopenharmony_ci 8118c2ecf20Sopenharmony_ci trace_cfg80211_return_bool(result); 8128c2ecf20Sopenharmony_ci return result; 8138c2ecf20Sopenharmony_ci} 8148c2ecf20Sopenharmony_ciEXPORT_SYMBOL(cfg80211_rx_mgmt_khz); 8158c2ecf20Sopenharmony_ci 8168c2ecf20Sopenharmony_civoid cfg80211_sched_dfs_chan_update(struct cfg80211_registered_device *rdev) 8178c2ecf20Sopenharmony_ci{ 8188c2ecf20Sopenharmony_ci cancel_delayed_work(&rdev->dfs_update_channels_wk); 8198c2ecf20Sopenharmony_ci queue_delayed_work(cfg80211_wq, &rdev->dfs_update_channels_wk, 0); 8208c2ecf20Sopenharmony_ci} 8218c2ecf20Sopenharmony_ci 8228c2ecf20Sopenharmony_civoid cfg80211_dfs_channels_update_work(struct work_struct *work) 8238c2ecf20Sopenharmony_ci{ 8248c2ecf20Sopenharmony_ci struct delayed_work *delayed_work = to_delayed_work(work); 8258c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev; 8268c2ecf20Sopenharmony_ci struct cfg80211_chan_def chandef; 8278c2ecf20Sopenharmony_ci struct ieee80211_supported_band *sband; 8288c2ecf20Sopenharmony_ci struct ieee80211_channel *c; 8298c2ecf20Sopenharmony_ci struct wiphy *wiphy; 8308c2ecf20Sopenharmony_ci bool check_again = false; 8318c2ecf20Sopenharmony_ci unsigned long timeout, next_time = 0; 8328c2ecf20Sopenharmony_ci unsigned long time_dfs_update; 8338c2ecf20Sopenharmony_ci enum nl80211_radar_event radar_event; 8348c2ecf20Sopenharmony_ci int bandid, i; 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_ci rdev = container_of(delayed_work, struct cfg80211_registered_device, 8378c2ecf20Sopenharmony_ci dfs_update_channels_wk); 8388c2ecf20Sopenharmony_ci wiphy = &rdev->wiphy; 8398c2ecf20Sopenharmony_ci 8408c2ecf20Sopenharmony_ci rtnl_lock(); 8418c2ecf20Sopenharmony_ci for (bandid = 0; bandid < NUM_NL80211_BANDS; bandid++) { 8428c2ecf20Sopenharmony_ci sband = wiphy->bands[bandid]; 8438c2ecf20Sopenharmony_ci if (!sband) 8448c2ecf20Sopenharmony_ci continue; 8458c2ecf20Sopenharmony_ci 8468c2ecf20Sopenharmony_ci for (i = 0; i < sband->n_channels; i++) { 8478c2ecf20Sopenharmony_ci c = &sband->channels[i]; 8488c2ecf20Sopenharmony_ci 8498c2ecf20Sopenharmony_ci if (!(c->flags & IEEE80211_CHAN_RADAR)) 8508c2ecf20Sopenharmony_ci continue; 8518c2ecf20Sopenharmony_ci 8528c2ecf20Sopenharmony_ci if (c->dfs_state != NL80211_DFS_UNAVAILABLE && 8538c2ecf20Sopenharmony_ci c->dfs_state != NL80211_DFS_AVAILABLE) 8548c2ecf20Sopenharmony_ci continue; 8558c2ecf20Sopenharmony_ci 8568c2ecf20Sopenharmony_ci if (c->dfs_state == NL80211_DFS_UNAVAILABLE) { 8578c2ecf20Sopenharmony_ci time_dfs_update = IEEE80211_DFS_MIN_NOP_TIME_MS; 8588c2ecf20Sopenharmony_ci radar_event = NL80211_RADAR_NOP_FINISHED; 8598c2ecf20Sopenharmony_ci } else { 8608c2ecf20Sopenharmony_ci if (regulatory_pre_cac_allowed(wiphy) || 8618c2ecf20Sopenharmony_ci cfg80211_any_wiphy_oper_chan(wiphy, c)) 8628c2ecf20Sopenharmony_ci continue; 8638c2ecf20Sopenharmony_ci 8648c2ecf20Sopenharmony_ci time_dfs_update = REG_PRE_CAC_EXPIRY_GRACE_MS; 8658c2ecf20Sopenharmony_ci radar_event = NL80211_RADAR_PRE_CAC_EXPIRED; 8668c2ecf20Sopenharmony_ci } 8678c2ecf20Sopenharmony_ci 8688c2ecf20Sopenharmony_ci timeout = c->dfs_state_entered + 8698c2ecf20Sopenharmony_ci msecs_to_jiffies(time_dfs_update); 8708c2ecf20Sopenharmony_ci 8718c2ecf20Sopenharmony_ci if (time_after_eq(jiffies, timeout)) { 8728c2ecf20Sopenharmony_ci c->dfs_state = NL80211_DFS_USABLE; 8738c2ecf20Sopenharmony_ci c->dfs_state_entered = jiffies; 8748c2ecf20Sopenharmony_ci 8758c2ecf20Sopenharmony_ci cfg80211_chandef_create(&chandef, c, 8768c2ecf20Sopenharmony_ci NL80211_CHAN_NO_HT); 8778c2ecf20Sopenharmony_ci 8788c2ecf20Sopenharmony_ci nl80211_radar_notify(rdev, &chandef, 8798c2ecf20Sopenharmony_ci radar_event, NULL, 8808c2ecf20Sopenharmony_ci GFP_ATOMIC); 8818c2ecf20Sopenharmony_ci 8828c2ecf20Sopenharmony_ci regulatory_propagate_dfs_state(wiphy, &chandef, 8838c2ecf20Sopenharmony_ci c->dfs_state, 8848c2ecf20Sopenharmony_ci radar_event); 8858c2ecf20Sopenharmony_ci continue; 8868c2ecf20Sopenharmony_ci } 8878c2ecf20Sopenharmony_ci 8888c2ecf20Sopenharmony_ci if (!check_again) 8898c2ecf20Sopenharmony_ci next_time = timeout - jiffies; 8908c2ecf20Sopenharmony_ci else 8918c2ecf20Sopenharmony_ci next_time = min(next_time, timeout - jiffies); 8928c2ecf20Sopenharmony_ci check_again = true; 8938c2ecf20Sopenharmony_ci } 8948c2ecf20Sopenharmony_ci } 8958c2ecf20Sopenharmony_ci rtnl_unlock(); 8968c2ecf20Sopenharmony_ci 8978c2ecf20Sopenharmony_ci /* reschedule if there are other channels waiting to be cleared again */ 8988c2ecf20Sopenharmony_ci if (check_again) 8998c2ecf20Sopenharmony_ci queue_delayed_work(cfg80211_wq, &rdev->dfs_update_channels_wk, 9008c2ecf20Sopenharmony_ci next_time); 9018c2ecf20Sopenharmony_ci} 9028c2ecf20Sopenharmony_ci 9038c2ecf20Sopenharmony_ci 9048c2ecf20Sopenharmony_civoid cfg80211_radar_event(struct wiphy *wiphy, 9058c2ecf20Sopenharmony_ci struct cfg80211_chan_def *chandef, 9068c2ecf20Sopenharmony_ci gfp_t gfp) 9078c2ecf20Sopenharmony_ci{ 9088c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 9098c2ecf20Sopenharmony_ci 9108c2ecf20Sopenharmony_ci trace_cfg80211_radar_event(wiphy, chandef); 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci /* only set the chandef supplied channel to unavailable, in 9138c2ecf20Sopenharmony_ci * case the radar is detected on only one of multiple channels 9148c2ecf20Sopenharmony_ci * spanned by the chandef. 9158c2ecf20Sopenharmony_ci */ 9168c2ecf20Sopenharmony_ci cfg80211_set_dfs_state(wiphy, chandef, NL80211_DFS_UNAVAILABLE); 9178c2ecf20Sopenharmony_ci 9188c2ecf20Sopenharmony_ci cfg80211_sched_dfs_chan_update(rdev); 9198c2ecf20Sopenharmony_ci 9208c2ecf20Sopenharmony_ci nl80211_radar_notify(rdev, chandef, NL80211_RADAR_DETECTED, NULL, gfp); 9218c2ecf20Sopenharmony_ci 9228c2ecf20Sopenharmony_ci memcpy(&rdev->radar_chandef, chandef, sizeof(struct cfg80211_chan_def)); 9238c2ecf20Sopenharmony_ci queue_work(cfg80211_wq, &rdev->propagate_radar_detect_wk); 9248c2ecf20Sopenharmony_ci} 9258c2ecf20Sopenharmony_ciEXPORT_SYMBOL(cfg80211_radar_event); 9268c2ecf20Sopenharmony_ci 9278c2ecf20Sopenharmony_civoid cfg80211_cac_event(struct net_device *netdev, 9288c2ecf20Sopenharmony_ci const struct cfg80211_chan_def *chandef, 9298c2ecf20Sopenharmony_ci enum nl80211_radar_event event, gfp_t gfp) 9308c2ecf20Sopenharmony_ci{ 9318c2ecf20Sopenharmony_ci struct wireless_dev *wdev = netdev->ieee80211_ptr; 9328c2ecf20Sopenharmony_ci struct wiphy *wiphy = wdev->wiphy; 9338c2ecf20Sopenharmony_ci struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 9348c2ecf20Sopenharmony_ci unsigned long timeout; 9358c2ecf20Sopenharmony_ci 9368c2ecf20Sopenharmony_ci trace_cfg80211_cac_event(netdev, event); 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci if (WARN_ON(!wdev->cac_started && event != NL80211_RADAR_CAC_STARTED)) 9398c2ecf20Sopenharmony_ci return; 9408c2ecf20Sopenharmony_ci 9418c2ecf20Sopenharmony_ci if (WARN_ON(!wdev->chandef.chan)) 9428c2ecf20Sopenharmony_ci return; 9438c2ecf20Sopenharmony_ci 9448c2ecf20Sopenharmony_ci switch (event) { 9458c2ecf20Sopenharmony_ci case NL80211_RADAR_CAC_FINISHED: 9468c2ecf20Sopenharmony_ci timeout = wdev->cac_start_time + 9478c2ecf20Sopenharmony_ci msecs_to_jiffies(wdev->cac_time_ms); 9488c2ecf20Sopenharmony_ci WARN_ON(!time_after_eq(jiffies, timeout)); 9498c2ecf20Sopenharmony_ci cfg80211_set_dfs_state(wiphy, chandef, NL80211_DFS_AVAILABLE); 9508c2ecf20Sopenharmony_ci memcpy(&rdev->cac_done_chandef, chandef, 9518c2ecf20Sopenharmony_ci sizeof(struct cfg80211_chan_def)); 9528c2ecf20Sopenharmony_ci queue_work(cfg80211_wq, &rdev->propagate_cac_done_wk); 9538c2ecf20Sopenharmony_ci cfg80211_sched_dfs_chan_update(rdev); 9548c2ecf20Sopenharmony_ci fallthrough; 9558c2ecf20Sopenharmony_ci case NL80211_RADAR_CAC_ABORTED: 9568c2ecf20Sopenharmony_ci wdev->cac_started = false; 9578c2ecf20Sopenharmony_ci break; 9588c2ecf20Sopenharmony_ci case NL80211_RADAR_CAC_STARTED: 9598c2ecf20Sopenharmony_ci wdev->cac_started = true; 9608c2ecf20Sopenharmony_ci break; 9618c2ecf20Sopenharmony_ci default: 9628c2ecf20Sopenharmony_ci WARN_ON(1); 9638c2ecf20Sopenharmony_ci return; 9648c2ecf20Sopenharmony_ci } 9658c2ecf20Sopenharmony_ci 9668c2ecf20Sopenharmony_ci nl80211_radar_notify(rdev, chandef, event, netdev, gfp); 9678c2ecf20Sopenharmony_ci} 9688c2ecf20Sopenharmony_ciEXPORT_SYMBOL(cfg80211_cac_event); 969