Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Abhishek Singh | ef6f38c | 2018-12-20 13:51:29 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19 | /** |
| 20 | * DOC: wlan_hdd_cfg80211.c |
| 21 | * |
| 22 | * WLAN Host Device Driver cfg80211 APIs implementation |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #include <linux/version.h> |
| 27 | #include <linux/module.h> |
| 28 | #include <linux/kernel.h> |
| 29 | #include <linux/init.h> |
| 30 | #include <linux/etherdevice.h> |
| 31 | #include <linux/wireless.h> |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 32 | #include "osif_sync.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 33 | #include <wlan_hdd_includes.h> |
| 34 | #include <net/arp.h> |
| 35 | #include <net/cfg80211.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 36 | #include <wlan_hdd_wowl.h> |
| 37 | #include <ani_global.h> |
| 38 | #include "sir_params.h" |
| 39 | #include "dot11f.h" |
| 40 | #include "wlan_hdd_assoc.h" |
| 41 | #include "wlan_hdd_wext.h" |
| 42 | #include "sme_api.h" |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 43 | #include "sme_power_save_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 44 | #include "wlan_hdd_p2p.h" |
| 45 | #include "wlan_hdd_cfg80211.h" |
| 46 | #include "wlan_hdd_hostapd.h" |
| 47 | #include "wlan_hdd_softap_tx_rx.h" |
| 48 | #include "wlan_hdd_main.h" |
| 49 | #include "wlan_hdd_power.h" |
| 50 | #include "wlan_hdd_trace.h" |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 51 | #include "qdf_str.h" |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 52 | #include "qdf_trace.h" |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 53 | #include "qdf_types.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 54 | #include "cds_utils.h" |
| 55 | #include "cds_sched.h" |
| 56 | #include "wlan_hdd_scan.h" |
| 57 | #include <qc_sap_ioctl.h> |
| 58 | #include "wlan_hdd_tdls.h" |
| 59 | #include "wlan_hdd_wmm.h" |
| 60 | #include "wma_types.h" |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 61 | #include "wma.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 62 | #include "wlan_hdd_misc.h" |
| 63 | #include "wlan_hdd_nan.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 64 | #include "wlan_logging_sock_svc.h" |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 65 | #include "sap_api.h" |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 66 | #include "csr_api.h" |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 67 | #include "pld_common.h" |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 68 | #include "wmi_unified_param.h" |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 69 | |
Paul Zhang | 3a210c5 | 2016-12-08 10:18:12 +0800 | [diff] [blame] | 70 | #ifdef WLAN_UMAC_CONVERGENCE |
| 71 | #include "wlan_cfg80211.h" |
| 72 | #endif |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 73 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 74 | #include <wlan_cfg80211_scan.h> |
Ryan Hsu | c8b27a4 | 2018-01-02 13:57:56 -0800 | [diff] [blame] | 75 | #include <wlan_cfg80211_ftm.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 76 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 77 | #include "wlan_hdd_ext_scan.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 78 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 79 | #include "wlan_hdd_stats.h" |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 80 | #include "cds_api.h" |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 81 | #include "wlan_policy_mgr_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 82 | #include "qwlan_version.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 83 | |
| 84 | #include "wlan_hdd_ocb.h" |
Manikandan Mohan | 5356c2b | 2016-04-03 15:51:35 -0700 | [diff] [blame] | 85 | #include "wlan_hdd_tsf.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 86 | |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 87 | #include "wlan_hdd_subnet_detect.h" |
Abhishek Singh | 3e6172f | 2016-05-04 16:56:48 +0530 | [diff] [blame] | 88 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 89 | #include "wlan_hdd_lpass.h" |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 90 | #include "wlan_hdd_nan_datapath.h" |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 91 | #include "wlan_hdd_disa.h" |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 92 | #include "wlan_osif_request_manager.h" |
Krishna Kumaar Natarajan | f567650 | 2017-03-06 10:28:44 -0800 | [diff] [blame] | 93 | #include "wlan_hdd_he.h" |
Nachiket Kukade | 177b5b0 | 2018-05-22 20:52:17 +0530 | [diff] [blame] | 94 | #ifdef FEATURE_WLAN_APF |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 95 | #include "wlan_hdd_apf.h" |
Nachiket Kukade | 177b5b0 | 2018-05-22 20:52:17 +0530 | [diff] [blame] | 96 | #endif |
Qun Zhang | ef65562 | 2019-02-25 10:48:10 +0800 | [diff] [blame] | 97 | #include "wlan_hdd_fw_state.h" |
stonez | 2d68648 | 2019-03-12 14:54:26 +0800 | [diff] [blame] | 98 | #include "wlan_hdd_mpta_helper.h" |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 99 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 100 | #include <cdp_txrx_cmn.h> |
| 101 | #include <cdp_txrx_misc.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 102 | #include <qca_vendor.h> |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 103 | #include "wlan_pmo_ucfg_api.h" |
Naveen Rawat | 5f040ba | 2017-03-06 12:20:25 -0800 | [diff] [blame] | 104 | #include "os_if_wifi_pos.h" |
Ajit Pal Singh | 90a45a4 | 2017-04-18 18:53:46 +0530 | [diff] [blame] | 105 | #include "wlan_utility.h" |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 106 | #include "wlan_reg_ucfg_api.h" |
Naveen Rawat | d2657be | 2017-10-10 14:31:23 -0700 | [diff] [blame] | 107 | #include "wifi_pos_api.h" |
Sandeep Puligilla | 063a434 | 2018-01-10 02:50:14 -0800 | [diff] [blame] | 108 | #include "wlan_hdd_spectralscan.h" |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 109 | #include "wlan_ipa_ucfg_api.h" |
Naveen Rawat | e8b1b82 | 2018-01-30 09:46:16 -0800 | [diff] [blame] | 110 | #include <wlan_cfg80211_mc_cp_stats.h> |
Yu Wang | 157d147 | 2018-03-09 16:05:01 +0800 | [diff] [blame] | 111 | #include <wlan_cp_stats_mc_ucfg_api.h> |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 112 | #include "wlan_tdls_cfg_api.h" |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 113 | #include <wlan_hdd_bss_transition.h> |
| 114 | #include <wlan_hdd_concurrency_matrix.h> |
| 115 | #include <wlan_hdd_p2p_listen_offload.h> |
| 116 | #include <wlan_hdd_rssi_monitor.h> |
| 117 | #include <wlan_hdd_sap_cond_chan_switch.h> |
| 118 | #include <wlan_hdd_station_info.h> |
| 119 | #include <wlan_hdd_tx_power.h> |
| 120 | #include <wlan_hdd_active_tos.h> |
| 121 | #include <wlan_hdd_sar_limits.h> |
| 122 | #include <wlan_hdd_ota_test.h> |
Krunal Soni | 5e3f962 | 2018-09-26 16:35:50 -0700 | [diff] [blame] | 123 | #include "wlan_policy_mgr_ucfg.h" |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 124 | #include "wlan_mlme_ucfg_api.h" |
| 125 | #include "wlan_mlme_public_struct.h" |
Harprit Chhabada | e8155d3 | 2018-08-22 16:19:34 -0700 | [diff] [blame] | 126 | #include "wlan_extscan_ucfg_api.h" |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 127 | #include "wlan_mlme_ucfg_api.h" |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 128 | #include "wlan_pmo_cfg.h" |
| 129 | #include "cfg_ucfg_api.h" |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 130 | |
Harprit Chhabada | 6c641ba | 2018-06-28 14:45:10 -0700 | [diff] [blame] | 131 | #include "wlan_crypto_global_api.h" |
| 132 | #include "wlan_nl_to_crypto_params.h" |
| 133 | #include "wlan_crypto_global_def.h" |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 134 | #include "cdp_txrx_cfg.h" |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 135 | #include "wlan_hdd_object_manager.h" |
Nachiket Kukade | 089b983 | 2018-12-12 16:38:17 +0530 | [diff] [blame] | 136 | #include "nan_ucfg_api.h" |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 137 | #include "wlan_fwol_ucfg_api.h" |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 138 | #include "wlan_cfg80211_crypto.h" |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 139 | #include "wlan_scan_ucfg_api.h" |
Jiani Liu | a5f1722 | 2019-03-04 16:22:33 +0800 | [diff] [blame^] | 140 | #include "wlan_hdd_coex_config.h" |
Harprit Chhabada | 6c641ba | 2018-06-28 14:45:10 -0700 | [diff] [blame] | 141 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 142 | #define g_mode_rates_size (12) |
| 143 | #define a_mode_rates_size (8) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 144 | |
| 145 | /* |
| 146 | * Android CTS verifier needs atleast this much wait time (in msec) |
| 147 | */ |
| 148 | #define MAX_REMAIN_ON_CHANNEL_DURATION (5000) |
| 149 | |
| 150 | /* |
| 151 | * Refer @tCfgProtection structure for definition of the bit map. |
| 152 | * below value is obtained by setting the following bit-fields. |
| 153 | * enable obss, fromllb, overlapOBSS and overlapFromllb protection. |
| 154 | */ |
| 155 | #define IBSS_CFG_PROTECTION_ENABLE_MASK 0x8282 |
| 156 | |
| 157 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 158 | .band = HDD_NL80211_BAND_2GHZ, \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 159 | .center_freq = (freq), \ |
| 160 | .hw_value = (chan), \ |
| 161 | .flags = (flag), \ |
| 162 | .max_antenna_gain = 0, \ |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 163 | .max_power = 0, \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 167 | .band = HDD_NL80211_BAND_5GHZ, \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 168 | .center_freq = (freq), \ |
| 169 | .hw_value = (chan), \ |
| 170 | .flags = (flag), \ |
| 171 | .max_antenna_gain = 0, \ |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 172 | .max_power = 0, \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag) \ |
| 176 | { \ |
| 177 | .bitrate = rate, \ |
| 178 | .hw_value = rate_id, \ |
| 179 | .flags = flag, \ |
| 180 | } |
| 181 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 182 | #define IS_DFS_MODE_VALID(mode) ((mode >= DFS_MODE_NONE && \ |
| 183 | mode <= DFS_MODE_DEPRIORITIZE)) |
Mohit Khanna | ceb9778 | 2017-04-05 16:27:08 -0700 | [diff] [blame] | 184 | /* |
| 185 | * Number of DPTRACE records to dump when a cfg80211 disconnect with reason |
| 186 | * WLAN_REASON_DEAUTH_LEAVING DEAUTH is received from user-space. |
| 187 | */ |
| 188 | #define WLAN_DEAUTH_DPTRACE_DUMP_COUNT 100 |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 189 | #ifndef WLAN_CIPHER_SUITE_GCMP |
| 190 | #define WLAN_CIPHER_SUITE_GCMP 0x000FAC08 |
| 191 | #endif |
| 192 | #ifndef WLAN_CIPHER_SUITE_GCMP_256 |
| 193 | #define WLAN_CIPHER_SUITE_GCMP_256 0x000FAC09 |
| 194 | #endif |
Mohit Khanna | ceb9778 | 2017-04-05 16:27:08 -0700 | [diff] [blame] | 195 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 196 | static const u32 hdd_gcmp_cipher_suits[] = { |
| 197 | WLAN_CIPHER_SUITE_GCMP, |
| 198 | WLAN_CIPHER_SUITE_GCMP_256, |
| 199 | }; |
| 200 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 201 | static const u32 hdd_cipher_suites[] = { |
| 202 | WLAN_CIPHER_SUITE_WEP40, |
| 203 | WLAN_CIPHER_SUITE_WEP104, |
| 204 | WLAN_CIPHER_SUITE_TKIP, |
| 205 | #ifdef FEATURE_WLAN_ESE |
| 206 | #define WLAN_CIPHER_SUITE_BTK 0x004096fe /* use for BTK */ |
| 207 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 208 | WLAN_CIPHER_SUITE_BTK, |
| 209 | WLAN_CIPHER_SUITE_KRK, |
| 210 | WLAN_CIPHER_SUITE_CCMP, |
| 211 | #else |
| 212 | WLAN_CIPHER_SUITE_CCMP, |
| 213 | #endif |
| 214 | #ifdef FEATURE_WLAN_WAPI |
| 215 | WLAN_CIPHER_SUITE_SMS4, |
| 216 | #endif |
| 217 | #ifdef WLAN_FEATURE_11W |
| 218 | WLAN_CIPHER_SUITE_AES_CMAC, |
Padma, Santhosh Kumar | 4117d7a | 2017-12-20 17:39:33 +0530 | [diff] [blame] | 219 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) |
| 220 | WLAN_CIPHER_SUITE_BIP_GMAC_128, |
| 221 | WLAN_CIPHER_SUITE_BIP_GMAC_256, |
| 222 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 223 | #endif |
| 224 | }; |
| 225 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 226 | static const struct ieee80211_channel hdd_channels_2_4_ghz[] = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 227 | HDD2GHZCHAN(2412, 1, 0), |
| 228 | HDD2GHZCHAN(2417, 2, 0), |
| 229 | HDD2GHZCHAN(2422, 3, 0), |
| 230 | HDD2GHZCHAN(2427, 4, 0), |
| 231 | HDD2GHZCHAN(2432, 5, 0), |
| 232 | HDD2GHZCHAN(2437, 6, 0), |
| 233 | HDD2GHZCHAN(2442, 7, 0), |
| 234 | HDD2GHZCHAN(2447, 8, 0), |
| 235 | HDD2GHZCHAN(2452, 9, 0), |
| 236 | HDD2GHZCHAN(2457, 10, 0), |
| 237 | HDD2GHZCHAN(2462, 11, 0), |
| 238 | HDD2GHZCHAN(2467, 12, 0), |
| 239 | HDD2GHZCHAN(2472, 13, 0), |
| 240 | HDD2GHZCHAN(2484, 14, 0), |
| 241 | }; |
| 242 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 243 | static const struct ieee80211_channel hdd_channels_5_ghz[] = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 244 | HDD5GHZCHAN(5180, 36, 0), |
| 245 | HDD5GHZCHAN(5200, 40, 0), |
| 246 | HDD5GHZCHAN(5220, 44, 0), |
| 247 | HDD5GHZCHAN(5240, 48, 0), |
| 248 | HDD5GHZCHAN(5260, 52, 0), |
| 249 | HDD5GHZCHAN(5280, 56, 0), |
| 250 | HDD5GHZCHAN(5300, 60, 0), |
| 251 | HDD5GHZCHAN(5320, 64, 0), |
| 252 | HDD5GHZCHAN(5500, 100, 0), |
| 253 | HDD5GHZCHAN(5520, 104, 0), |
| 254 | HDD5GHZCHAN(5540, 108, 0), |
| 255 | HDD5GHZCHAN(5560, 112, 0), |
| 256 | HDD5GHZCHAN(5580, 116, 0), |
| 257 | HDD5GHZCHAN(5600, 120, 0), |
| 258 | HDD5GHZCHAN(5620, 124, 0), |
| 259 | HDD5GHZCHAN(5640, 128, 0), |
| 260 | HDD5GHZCHAN(5660, 132, 0), |
| 261 | HDD5GHZCHAN(5680, 136, 0), |
| 262 | HDD5GHZCHAN(5700, 140, 0), |
| 263 | HDD5GHZCHAN(5720, 144, 0), |
| 264 | HDD5GHZCHAN(5745, 149, 0), |
| 265 | HDD5GHZCHAN(5765, 153, 0), |
| 266 | HDD5GHZCHAN(5785, 157, 0), |
| 267 | HDD5GHZCHAN(5805, 161, 0), |
| 268 | HDD5GHZCHAN(5825, 165, 0), |
Ashish Kumar Dhanotiya | cc2e0d3 | 2017-08-24 20:13:08 +0530 | [diff] [blame] | 269 | }; |
| 270 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 271 | #ifdef WLAN_FEATURE_DSRC |
Ashish Kumar Dhanotiya | cc2e0d3 | 2017-08-24 20:13:08 +0530 | [diff] [blame] | 272 | static const struct ieee80211_channel hdd_channels_dot11p[] = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 273 | HDD5GHZCHAN(5852, 170, 0), |
| 274 | HDD5GHZCHAN(5855, 171, 0), |
| 275 | HDD5GHZCHAN(5860, 172, 0), |
| 276 | HDD5GHZCHAN(5865, 173, 0), |
| 277 | HDD5GHZCHAN(5870, 174, 0), |
| 278 | HDD5GHZCHAN(5875, 175, 0), |
| 279 | HDD5GHZCHAN(5880, 176, 0), |
| 280 | HDD5GHZCHAN(5885, 177, 0), |
| 281 | HDD5GHZCHAN(5890, 178, 0), |
| 282 | HDD5GHZCHAN(5895, 179, 0), |
| 283 | HDD5GHZCHAN(5900, 180, 0), |
| 284 | HDD5GHZCHAN(5905, 181, 0), |
| 285 | HDD5GHZCHAN(5910, 182, 0), |
| 286 | HDD5GHZCHAN(5915, 183, 0), |
| 287 | HDD5GHZCHAN(5920, 184, 0), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 288 | }; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 289 | #else |
| 290 | static const struct ieee80211_channel hdd_etsi13_srd_ch[] = { |
| 291 | HDD5GHZCHAN(5845, 169, 0), |
| 292 | HDD5GHZCHAN(5865, 173, 0), |
| 293 | }; |
| 294 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 295 | |
| 296 | static struct ieee80211_rate g_mode_rates[] = { |
| 297 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 298 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 299 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 300 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 301 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 302 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 303 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 304 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 305 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 306 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 307 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
| 308 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 309 | }; |
| 310 | |
| 311 | static struct ieee80211_rate a_mode_rates[] = { |
| 312 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 313 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 314 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 315 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 316 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 317 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 318 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
| 319 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 320 | }; |
| 321 | |
| 322 | static struct ieee80211_supported_band wlan_hdd_band_2_4_ghz = { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 323 | .channels = NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 324 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_ghz), |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 325 | .band = HDD_NL80211_BAND_2GHZ, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 326 | .bitrates = g_mode_rates, |
| 327 | .n_bitrates = g_mode_rates_size, |
| 328 | .ht_cap.ht_supported = 1, |
| 329 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 330 | | IEEE80211_HT_CAP_GRN_FLD |
| 331 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 332 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 333 | | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 334 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 335 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 336 | .ht_cap.mcs.rx_mask = {0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0,}, |
| 337 | .ht_cap.mcs.rx_highest = cpu_to_le16(72), |
| 338 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 339 | }; |
| 340 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 341 | static struct ieee80211_supported_band wlan_hdd_band_5_ghz = { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 342 | .channels = NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 343 | .n_channels = ARRAY_SIZE(hdd_channels_5_ghz), |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 344 | .band = HDD_NL80211_BAND_5GHZ, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 345 | .bitrates = a_mode_rates, |
| 346 | .n_bitrates = a_mode_rates_size, |
| 347 | .ht_cap.ht_supported = 1, |
| 348 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 349 | | IEEE80211_HT_CAP_GRN_FLD |
| 350 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 351 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 352 | | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 353 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 354 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 355 | .ht_cap.mcs.rx_mask = {0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0,}, |
| 356 | .ht_cap.mcs.rx_highest = cpu_to_le16(72), |
| 357 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 358 | .vht_cap.vht_supported = 1, |
| 359 | }; |
| 360 | |
| 361 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 362 | * TX/RX direction for each kind of interface |
| 363 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 364 | static const struct ieee80211_txrx_stypes |
| 365 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 366 | [NL80211_IFTYPE_STATION] = { |
| 367 | .tx = 0xffff, |
| 368 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
Padma, Santhosh Kumar | 1ccc133 | 2017-09-13 17:39:01 +0530 | [diff] [blame] | 369 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 370 | BIT(SIR_MAC_MGMT_AUTH), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 371 | }, |
| 372 | [NL80211_IFTYPE_AP] = { |
| 373 | .tx = 0xffff, |
| 374 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 375 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 376 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 377 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 378 | BIT(SIR_MAC_MGMT_AUTH) | |
| 379 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 380 | BIT(SIR_MAC_MGMT_ACTION), |
| 381 | }, |
| 382 | [NL80211_IFTYPE_ADHOC] = { |
| 383 | .tx = 0xffff, |
| 384 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 385 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 386 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 387 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 388 | BIT(SIR_MAC_MGMT_AUTH) | |
| 389 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 390 | BIT(SIR_MAC_MGMT_ACTION), |
| 391 | }, |
| 392 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 393 | .tx = 0xffff, |
| 394 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 395 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 396 | }, |
| 397 | [NL80211_IFTYPE_P2P_GO] = { |
| 398 | /* This is also same as for SoftAP */ |
| 399 | .tx = 0xffff, |
| 400 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 401 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 402 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 403 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 404 | BIT(SIR_MAC_MGMT_AUTH) | |
| 405 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 406 | BIT(SIR_MAC_MGMT_ACTION), |
| 407 | }, |
| 408 | }; |
| 409 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 410 | /* Interface limits and combinations registered by the driver */ |
| 411 | |
| 412 | /* STA ( + STA ) combination */ |
| 413 | static const struct ieee80211_iface_limit |
| 414 | wlan_hdd_sta_iface_limit[] = { |
| 415 | { |
| 416 | .max = 3, /* p2p0 is a STA as well */ |
| 417 | .types = BIT(NL80211_IFTYPE_STATION), |
| 418 | }, |
| 419 | }; |
| 420 | |
| 421 | /* ADHOC (IBSS) limit */ |
| 422 | static const struct ieee80211_iface_limit |
| 423 | wlan_hdd_adhoc_iface_limit[] = { |
| 424 | { |
| 425 | .max = 1, |
| 426 | .types = BIT(NL80211_IFTYPE_STATION), |
| 427 | }, |
| 428 | { |
| 429 | .max = 1, |
| 430 | .types = BIT(NL80211_IFTYPE_ADHOC), |
| 431 | }, |
| 432 | }; |
| 433 | |
| 434 | /* AP ( + AP ) combination */ |
| 435 | static const struct ieee80211_iface_limit |
| 436 | wlan_hdd_ap_iface_limit[] = { |
| 437 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 438 | .max = (QDF_MAX_NO_OF_SAP_MODE + SAP_MAX_OBSS_STA_CNT), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 439 | .types = BIT(NL80211_IFTYPE_AP), |
| 440 | }, |
| 441 | }; |
| 442 | |
| 443 | /* P2P limit */ |
| 444 | static const struct ieee80211_iface_limit |
| 445 | wlan_hdd_p2p_iface_limit[] = { |
| 446 | { |
| 447 | .max = 1, |
| 448 | .types = BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 449 | }, |
| 450 | { |
| 451 | .max = 1, |
| 452 | .types = BIT(NL80211_IFTYPE_P2P_GO), |
| 453 | }, |
| 454 | }; |
| 455 | |
| 456 | static const struct ieee80211_iface_limit |
| 457 | wlan_hdd_sta_ap_iface_limit[] = { |
| 458 | { |
| 459 | /* We need 1 extra STA interface for OBSS scan when SAP starts |
| 460 | * with HT40 in STA+SAP concurrency mode |
| 461 | */ |
| 462 | .max = (1 + SAP_MAX_OBSS_STA_CNT), |
| 463 | .types = BIT(NL80211_IFTYPE_STATION), |
| 464 | }, |
| 465 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 466 | .max = QDF_MAX_NO_OF_SAP_MODE, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 467 | .types = BIT(NL80211_IFTYPE_AP), |
| 468 | }, |
| 469 | }; |
| 470 | |
| 471 | /* STA + P2P combination */ |
| 472 | static const struct ieee80211_iface_limit |
| 473 | wlan_hdd_sta_p2p_iface_limit[] = { |
| 474 | { |
| 475 | /* One reserved for dedicated P2PDEV usage */ |
| 476 | .max = 2, |
| 477 | .types = BIT(NL80211_IFTYPE_STATION) |
| 478 | }, |
| 479 | { |
| 480 | /* Support for two identical (GO + GO or CLI + CLI) |
| 481 | * or dissimilar (GO + CLI) P2P interfaces |
| 482 | */ |
| 483 | .max = 2, |
| 484 | .types = BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 485 | }, |
| 486 | }; |
| 487 | |
| 488 | /* STA + AP + P2PGO combination */ |
| 489 | static const struct ieee80211_iface_limit |
| 490 | wlan_hdd_sta_ap_p2pgo_iface_limit[] = { |
| 491 | /* Support for AP+P2PGO interfaces */ |
| 492 | { |
| 493 | .max = 2, |
| 494 | .types = BIT(NL80211_IFTYPE_STATION) |
| 495 | }, |
| 496 | { |
| 497 | .max = 1, |
| 498 | .types = BIT(NL80211_IFTYPE_P2P_GO) |
| 499 | }, |
| 500 | { |
| 501 | .max = 1, |
| 502 | .types = BIT(NL80211_IFTYPE_AP) |
| 503 | } |
| 504 | }; |
| 505 | |
| 506 | /* SAP + P2P combination */ |
| 507 | static const struct ieee80211_iface_limit |
| 508 | wlan_hdd_sap_p2p_iface_limit[] = { |
| 509 | { |
| 510 | /* 1 dedicated for p2p0 which is a STA type */ |
| 511 | .max = 1, |
| 512 | .types = BIT(NL80211_IFTYPE_STATION) |
| 513 | }, |
| 514 | { |
| 515 | /* The p2p interface in SAP+P2P can be GO/CLI. |
| 516 | * The p2p connection can be formed on p2p0 or p2p-p2p0-x. |
| 517 | */ |
| 518 | .max = 1, |
| 519 | .types = BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 520 | }, |
| 521 | { |
| 522 | /* SAP+GO to support only one SAP interface */ |
| 523 | .max = 1, |
| 524 | .types = BIT(NL80211_IFTYPE_AP) |
| 525 | } |
| 526 | }; |
| 527 | |
| 528 | /* P2P + P2P combination */ |
| 529 | static const struct ieee80211_iface_limit |
| 530 | wlan_hdd_p2p_p2p_iface_limit[] = { |
| 531 | { |
| 532 | /* 1 dedicated for p2p0 which is a STA type */ |
| 533 | .max = 1, |
| 534 | .types = BIT(NL80211_IFTYPE_STATION) |
| 535 | }, |
| 536 | { |
| 537 | /* The p2p interface in P2P+P2P can be GO/CLI. |
| 538 | * For P2P+P2P, the new interfaces are formed on p2p-p2p0-x. |
| 539 | */ |
| 540 | .max = 2, |
| 541 | .types = BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 542 | }, |
| 543 | }; |
| 544 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 545 | static const struct ieee80211_iface_limit |
| 546 | wlan_hdd_mon_iface_limit[] = { |
| 547 | { |
| 548 | .max = 3, /* Monitor interface */ |
| 549 | .types = BIT(NL80211_IFTYPE_MONITOR), |
| 550 | }, |
| 551 | }; |
| 552 | |
| 553 | static struct ieee80211_iface_combination |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 554 | wlan_hdd_iface_combination[] = { |
| 555 | /* STA */ |
| 556 | { |
| 557 | .limits = wlan_hdd_sta_iface_limit, |
| 558 | .num_different_channels = 2, |
| 559 | .max_interfaces = 3, |
| 560 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_iface_limit), |
| 561 | }, |
| 562 | /* ADHOC */ |
| 563 | { |
| 564 | .limits = wlan_hdd_adhoc_iface_limit, |
Krunal Soni | 2c68f23 | 2015-10-26 20:52:51 -0700 | [diff] [blame] | 565 | .num_different_channels = 2, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 566 | .max_interfaces = 2, |
| 567 | .n_limits = ARRAY_SIZE(wlan_hdd_adhoc_iface_limit), |
| 568 | }, |
| 569 | /* AP */ |
| 570 | { |
| 571 | .limits = wlan_hdd_ap_iface_limit, |
| 572 | .num_different_channels = 2, |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 573 | .max_interfaces = (SAP_MAX_OBSS_STA_CNT + QDF_MAX_NO_OF_SAP_MODE), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 574 | .n_limits = ARRAY_SIZE(wlan_hdd_ap_iface_limit), |
hqu | 3c4ed3d | 2017-09-19 11:42:35 +0800 | [diff] [blame] | 575 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) || \ |
| 576 | defined(CFG80211_BEACON_INTERVAL_BACKPORT) |
| 577 | .beacon_int_min_gcd = 1, |
| 578 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 579 | }, |
| 580 | /* P2P */ |
| 581 | { |
| 582 | .limits = wlan_hdd_p2p_iface_limit, |
| 583 | .num_different_channels = 2, |
| 584 | .max_interfaces = 2, |
| 585 | .n_limits = ARRAY_SIZE(wlan_hdd_p2p_iface_limit), |
| 586 | }, |
| 587 | /* STA + AP */ |
| 588 | { |
| 589 | .limits = wlan_hdd_sta_ap_iface_limit, |
| 590 | .num_different_channels = 2, |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 591 | .max_interfaces = (1 + SAP_MAX_OBSS_STA_CNT + QDF_MAX_NO_OF_SAP_MODE), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 592 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_ap_iface_limit), |
| 593 | .beacon_int_infra_match = true, |
hqu | 3c4ed3d | 2017-09-19 11:42:35 +0800 | [diff] [blame] | 594 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) || \ |
| 595 | defined(CFG80211_BEACON_INTERVAL_BACKPORT) |
| 596 | .beacon_int_min_gcd = 1, |
| 597 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 598 | }, |
| 599 | /* STA + P2P */ |
| 600 | { |
| 601 | .limits = wlan_hdd_sta_p2p_iface_limit, |
| 602 | .num_different_channels = 2, |
| 603 | /* one interface reserved for P2PDEV dedicated usage */ |
| 604 | .max_interfaces = 4, |
| 605 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_p2p_iface_limit), |
| 606 | .beacon_int_infra_match = true, |
| 607 | }, |
| 608 | /* STA + P2P GO + SAP */ |
| 609 | { |
| 610 | .limits = wlan_hdd_sta_ap_p2pgo_iface_limit, |
| 611 | /* we can allow 3 channels for three different persona |
| 612 | * but due to firmware limitation, allow max 2 concrnt channels. |
| 613 | */ |
| 614 | .num_different_channels = 2, |
| 615 | /* one interface reserved for P2PDEV dedicated usage */ |
| 616 | .max_interfaces = 4, |
| 617 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_ap_p2pgo_iface_limit), |
| 618 | .beacon_int_infra_match = true, |
| 619 | }, |
| 620 | /* SAP + P2P */ |
| 621 | { |
| 622 | .limits = wlan_hdd_sap_p2p_iface_limit, |
| 623 | .num_different_channels = 2, |
| 624 | /* 1-p2p0 + 1-SAP + 1-P2P (on p2p0 or p2p-p2p0-x) */ |
| 625 | .max_interfaces = 3, |
| 626 | .n_limits = ARRAY_SIZE(wlan_hdd_sap_p2p_iface_limit), |
| 627 | .beacon_int_infra_match = true, |
| 628 | }, |
| 629 | /* P2P + P2P */ |
| 630 | { |
| 631 | .limits = wlan_hdd_p2p_p2p_iface_limit, |
| 632 | .num_different_channels = 2, |
| 633 | /* 1-p2p0 + 2-P2P (on p2p-p2p0-x) */ |
| 634 | .max_interfaces = 3, |
| 635 | .n_limits = ARRAY_SIZE(wlan_hdd_p2p_p2p_iface_limit), |
| 636 | .beacon_int_infra_match = true, |
| 637 | }, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 638 | /* Monitor */ |
| 639 | { |
| 640 | .limits = wlan_hdd_mon_iface_limit, |
| 641 | .max_interfaces = 3, |
| 642 | .num_different_channels = 2, |
| 643 | .n_limits = ARRAY_SIZE(wlan_hdd_mon_iface_limit), |
| 644 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 645 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 646 | |
| 647 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 648 | |
| 649 | #ifdef WLAN_NL80211_TESTMODE |
| 650 | enum wlan_hdd_tm_attr { |
| 651 | WLAN_HDD_TM_ATTR_INVALID = 0, |
| 652 | WLAN_HDD_TM_ATTR_CMD = 1, |
| 653 | WLAN_HDD_TM_ATTR_DATA = 2, |
| 654 | WLAN_HDD_TM_ATTR_STREAM_ID = 3, |
| 655 | WLAN_HDD_TM_ATTR_TYPE = 4, |
| 656 | /* keep last */ |
| 657 | WLAN_HDD_TM_ATTR_AFTER_LAST, |
| 658 | WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1, |
| 659 | }; |
| 660 | |
| 661 | enum wlan_hdd_tm_cmd { |
| 662 | WLAN_HDD_TM_CMD_WLAN_FTM = 0, |
| 663 | WLAN_HDD_TM_CMD_WLAN_HB = 1, |
| 664 | }; |
| 665 | |
| 666 | #define WLAN_HDD_TM_DATA_MAX_LEN 5000 |
| 667 | |
| 668 | static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] = { |
| 669 | [WLAN_HDD_TM_ATTR_CMD] = {.type = NLA_U32}, |
| 670 | [WLAN_HDD_TM_ATTR_DATA] = {.type = NLA_BINARY, |
| 671 | .len = WLAN_HDD_TM_DATA_MAX_LEN}, |
| 672 | }; |
| 673 | #endif /* WLAN_NL80211_TESTMODE */ |
| 674 | |
Lin Bai | a016e9a | 2017-08-29 19:10:42 +0800 | [diff] [blame] | 675 | enum wlan_hdd_vendor_ie_access_policy { |
| 676 | WLAN_HDD_VENDOR_IE_ACCESS_NONE = 0, |
| 677 | WLAN_HDD_VENDOR_IE_ACCESS_ALLOW_IF_LISTED, |
| 678 | }; |
| 679 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 680 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 681 | static const struct wiphy_wowlan_support wowlan_support_cfg80211_init = { |
| 682 | .flags = WIPHY_WOWLAN_MAGIC_PKT, |
| 683 | .n_patterns = WOWL_MAX_PTRNS_ALLOWED, |
| 684 | .pattern_min_len = 1, |
| 685 | .pattern_max_len = WOWL_PTRN_MAX_SIZE, |
| 686 | }; |
| 687 | #endif |
| 688 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 689 | /** |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 690 | * hdd_add_channel_switch_support()- Adds Channel Switch flag if supported |
| 691 | * @flags: Pointer to the flags to Add channel switch flag. |
| 692 | * |
| 693 | * This Function adds Channel Switch support flag, if channel switch is |
| 694 | * supported by kernel. |
| 695 | * Return: void. |
| 696 | */ |
| 697 | #ifdef CHANNEL_SWITCH_SUPPORTED |
| 698 | static inline void hdd_add_channel_switch_support(uint32_t *flags) |
| 699 | { |
Krishna Kumaar Natarajan | 8a8df26 | 2015-12-04 11:43:46 -0800 | [diff] [blame] | 700 | *flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 701 | } |
| 702 | #else |
| 703 | static inline void hdd_add_channel_switch_support(uint32_t *flags) |
| 704 | { |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 705 | } |
| 706 | #endif |
| 707 | |
Manikandan Mohan | 22b8372 | 2015-12-15 15:03:23 -0800 | [diff] [blame] | 708 | #ifdef FEATURE_WLAN_TDLS |
| 709 | |
| 710 | /* TDLS capabilities params */ |
| 711 | #define PARAM_MAX_TDLS_SESSION \ |
| 712 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_CAPS_MAX_CONC_SESSIONS |
| 713 | #define PARAM_TDLS_FEATURE_SUPPORT \ |
| 714 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_CAPS_FEATURES_SUPPORTED |
| 715 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 716 | /** |
Jeff Johnson | 118a4a0 | 2018-05-06 00:14:15 -0700 | [diff] [blame] | 717 | * __wlan_hdd_cfg80211_get_tdls_capabilities() - Provide TDLS Capabilities. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 718 | * @wiphy: WIPHY structure pointer |
| 719 | * @wdev: Wireless device structure pointer |
| 720 | * @data: Pointer to the data received |
| 721 | * @data_len: Length of the data received |
| 722 | * |
| 723 | * This function provides TDLS capabilities |
| 724 | * |
| 725 | * Return: 0 on success and errno on failure |
| 726 | */ |
| 727 | static int __wlan_hdd_cfg80211_get_tdls_capabilities(struct wiphy *wiphy, |
| 728 | struct wireless_dev *wdev, |
| 729 | const void *data, |
| 730 | int data_len) |
| 731 | { |
| 732 | int status; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 733 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 734 | struct sk_buff *skb; |
| 735 | uint32_t set = 0; |
Frank Liu | 5c63dc8 | 2017-09-07 14:49:05 +0800 | [diff] [blame] | 736 | uint32_t max_num_tdls_sta = 0; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 737 | bool tdls_support; |
| 738 | bool tdls_external_control; |
| 739 | bool tdls_sleep_sta_enable; |
| 740 | bool tdls_buffer_sta; |
| 741 | bool tdls_off_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 742 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 743 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 744 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 745 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 746 | hdd_err("Command not allowed in FTM mode"); |
| 747 | return -EPERM; |
| 748 | } |
| 749 | |
| 750 | status = wlan_hdd_validate_context(hdd_ctx); |
| 751 | if (status) |
| 752 | return status; |
| 753 | |
| 754 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, (2 * sizeof(u32)) + |
| 755 | NLMSG_HDRLEN); |
| 756 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 757 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | goto fail; |
| 759 | } |
| 760 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 761 | if ((cfg_tdls_get_support_enable(hdd_ctx->psoc, &tdls_support) == |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 762 | QDF_STATUS_SUCCESS) && tdls_support) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 763 | hdd_debug("TDLS feature not Enabled or Not supported in FW"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 764 | if (nla_put_u32(skb, PARAM_MAX_TDLS_SESSION, 0) || |
| 765 | nla_put_u32(skb, PARAM_TDLS_FEATURE_SUPPORT, 0)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 766 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 767 | goto fail; |
| 768 | } |
| 769 | } else { |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 770 | cfg_tdls_get_external_control(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 771 | &tdls_external_control); |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 772 | cfg_tdls_get_sleep_sta_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 773 | &tdls_sleep_sta_enable); |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 774 | cfg_tdls_get_buffer_sta_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 775 | &tdls_buffer_sta); |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 776 | cfg_tdls_get_off_channel_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 777 | &tdls_off_channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 778 | set = set | WIFI_TDLS_SUPPORT; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 779 | set = set | (tdls_external_control ? |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 780 | WIFI_TDLS_EXTERNAL_CONTROL_SUPPORT : 0); |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 781 | set = set | (tdls_off_channel ? |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 782 | WIIF_TDLS_OFFCHANNEL_SUPPORT : 0); |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 783 | if (tdls_sleep_sta_enable || tdls_buffer_sta || |
| 784 | tdls_off_channel) |
Frank Liu | 5c63dc8 | 2017-09-07 14:49:05 +0800 | [diff] [blame] | 785 | max_num_tdls_sta = HDD_MAX_NUM_TDLS_STA_P_UAPSD_OFFCHAN; |
| 786 | else |
| 787 | max_num_tdls_sta = HDD_MAX_NUM_TDLS_STA; |
| 788 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 789 | hdd_debug("TDLS Feature supported value %x", set); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 790 | if (nla_put_u32(skb, PARAM_MAX_TDLS_SESSION, |
Frank Liu | 5c63dc8 | 2017-09-07 14:49:05 +0800 | [diff] [blame] | 791 | max_num_tdls_sta) || |
| 792 | nla_put_u32(skb, PARAM_TDLS_FEATURE_SUPPORT, set)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 793 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 794 | goto fail; |
| 795 | } |
| 796 | } |
| 797 | return cfg80211_vendor_cmd_reply(skb); |
| 798 | fail: |
| 799 | if (skb) |
| 800 | kfree_skb(skb); |
| 801 | return -EINVAL; |
| 802 | } |
| 803 | |
| 804 | /** |
Jeff Johnson | 118a4a0 | 2018-05-06 00:14:15 -0700 | [diff] [blame] | 805 | * wlan_hdd_cfg80211_get_tdls_capabilities() - Provide TDLS Capabilities. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 806 | * @wiphy: WIPHY structure pointer |
| 807 | * @wdev: Wireless device structure pointer |
| 808 | * @data: Pointer to the data received |
| 809 | * @data_len: Length of the data received |
| 810 | * |
| 811 | * This function provides TDLS capabilities |
| 812 | * |
| 813 | * Return: 0 on success and errno on failure |
| 814 | */ |
| 815 | static int |
| 816 | wlan_hdd_cfg80211_get_tdls_capabilities(struct wiphy *wiphy, |
| 817 | struct wireless_dev *wdev, |
| 818 | const void *data, |
| 819 | int data_len) |
| 820 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 821 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 822 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 823 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 824 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 825 | if (errno) |
| 826 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 827 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 828 | errno = __wlan_hdd_cfg80211_get_tdls_capabilities(wiphy, wdev, |
| 829 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 830 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 831 | osif_psoc_sync_op_stop(psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 832 | |
| 833 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 834 | } |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 835 | |
| 836 | static uint8_t hdd_get_bw_offset(uint32_t ch_width) |
| 837 | { |
| 838 | uint8_t bw_offset = 0; |
| 839 | |
| 840 | if (ch_width == CH_WIDTH_40MHZ) |
| 841 | bw_offset = 1 << BW_40_OFFSET_BIT; |
| 842 | else if (ch_width == CH_WIDTH_20MHZ) |
| 843 | bw_offset = 1 << BW_20_OFFSET_BIT; |
| 844 | |
| 845 | return bw_offset; |
| 846 | } |
| 847 | |
| 848 | #else /* !FEATURE_WLAN_TDLS */ |
| 849 | |
| 850 | static inline uint8_t hdd_get_bw_offset(uint32_t ch_width) |
| 851 | { |
| 852 | return 0; |
| 853 | } |
| 854 | |
| 855 | #endif /* FEATURE_WLAN_TDLS */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 856 | |
| 857 | #ifdef QCA_HT_2040_COEX |
| 858 | static void wlan_hdd_cfg80211_start_pending_acs(struct work_struct *work); |
| 859 | #endif |
| 860 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 861 | int wlan_hdd_merge_avoid_freqs(struct ch_avoid_ind_type *destFreqList, |
| 862 | struct ch_avoid_ind_type *srcFreqList) |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 863 | { |
| 864 | int i; |
Jeff Johnson | 62f2899 | 2019-03-05 14:48:42 -0800 | [diff] [blame] | 865 | uint32_t room; |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 866 | struct ch_avoid_freq_type *avoid_range = |
| 867 | &destFreqList->avoid_freq_range[destFreqList->ch_avoid_range_cnt]; |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 868 | |
Jeff Johnson | 62f2899 | 2019-03-05 14:48:42 -0800 | [diff] [blame] | 869 | room = CH_AVOID_MAX_RANGE - destFreqList->ch_avoid_range_cnt; |
| 870 | if (srcFreqList->ch_avoid_range_cnt > room) { |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 871 | hdd_err("avoid freq overflow"); |
| 872 | return -EINVAL; |
| 873 | } |
Jeff Johnson | 62f2899 | 2019-03-05 14:48:42 -0800 | [diff] [blame] | 874 | destFreqList->ch_avoid_range_cnt += srcFreqList->ch_avoid_range_cnt; |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 875 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 876 | for (i = 0; i < srcFreqList->ch_avoid_range_cnt; i++) { |
| 877 | avoid_range->start_freq = |
| 878 | srcFreqList->avoid_freq_range[i].start_freq; |
| 879 | avoid_range->end_freq = |
| 880 | srcFreqList->avoid_freq_range[i].end_freq; |
| 881 | avoid_range++; |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 882 | } |
| 883 | return 0; |
| 884 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 885 | /* |
| 886 | * FUNCTION: wlan_hdd_send_avoid_freq_event |
| 887 | * This is called when wlan driver needs to send vendor specific |
| 888 | * avoid frequency range event to userspace |
| 889 | */ |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 890 | int wlan_hdd_send_avoid_freq_event(struct hdd_context *hdd_ctx, |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 891 | struct ch_avoid_ind_type *avoid_freq_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 892 | { |
| 893 | struct sk_buff *vendor_event; |
| 894 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 895 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 896 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 897 | if (!hdd_ctx) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 898 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 899 | return -EINVAL; |
| 900 | } |
| 901 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 902 | if (!avoid_freq_list) { |
| 903 | hdd_err("avoid_freq_list is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 904 | return -EINVAL; |
| 905 | } |
| 906 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 907 | vendor_event = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 908 | NULL, sizeof(struct ch_avoid_ind_type), |
| 909 | QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX, |
| 910 | GFP_KERNEL); |
| 911 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 912 | if (!vendor_event) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 913 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 914 | return -EINVAL; |
| 915 | } |
| 916 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 917 | memcpy(skb_put(vendor_event, sizeof(struct ch_avoid_ind_type)), |
| 918 | (void *)avoid_freq_list, sizeof(struct ch_avoid_ind_type)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 919 | |
| 920 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 921 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 922 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 923 | return 0; |
| 924 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 925 | |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 926 | /* |
| 927 | * define short names for the global vendor params |
| 928 | * used by QCA_NL80211_VENDOR_SUBCMD_HANG |
| 929 | */ |
| 930 | #define HANG_REASON_INDEX QCA_NL80211_VENDOR_SUBCMD_HANG_REASON_INDEX |
| 931 | |
| 932 | /** |
| 933 | * hdd_convert_hang_reason() - Convert cds recovery reason to vendor specific |
| 934 | * hang reason |
| 935 | * @reason: cds recovery reason |
| 936 | * |
| 937 | * Return: Vendor specific reason code |
| 938 | */ |
| 939 | static enum qca_wlan_vendor_hang_reason |
| 940 | hdd_convert_hang_reason(enum qdf_hang_reason reason) |
| 941 | { |
Mahesh Kumar Kalikot Veetil | 9111a57 | 2017-10-10 16:11:11 -0700 | [diff] [blame] | 942 | u32 ret_val; |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 943 | |
| 944 | switch (reason) { |
| 945 | case QDF_RX_HASH_NO_ENTRY_FOUND: |
| 946 | ret_val = QCA_WLAN_HANG_RX_HASH_NO_ENTRY_FOUND; |
| 947 | break; |
| 948 | case QDF_PEER_DELETION_TIMEDOUT: |
| 949 | ret_val = QCA_WLAN_HANG_PEER_DELETION_TIMEDOUT; |
| 950 | break; |
| 951 | case QDF_PEER_UNMAP_TIMEDOUT: |
| 952 | ret_val = QCA_WLAN_HANG_PEER_UNMAP_TIMEDOUT; |
| 953 | break; |
| 954 | case QDF_SCAN_REQ_EXPIRED: |
| 955 | ret_val = QCA_WLAN_HANG_SCAN_REQ_EXPIRED; |
| 956 | break; |
| 957 | case QDF_SCAN_ATTEMPT_FAILURES: |
| 958 | ret_val = QCA_WLAN_HANG_SCAN_ATTEMPT_FAILURES; |
| 959 | break; |
| 960 | case QDF_GET_MSG_BUFF_FAILURE: |
| 961 | ret_val = QCA_WLAN_HANG_GET_MSG_BUFF_FAILURE; |
| 962 | break; |
| 963 | case QDF_ACTIVE_LIST_TIMEOUT: |
| 964 | ret_val = QCA_WLAN_HANG_ACTIVE_LIST_TIMEOUT; |
| 965 | break; |
| 966 | case QDF_SUSPEND_TIMEOUT: |
| 967 | ret_val = QCA_WLAN_HANG_SUSPEND_TIMEOUT; |
| 968 | break; |
| 969 | case QDF_RESUME_TIMEOUT: |
| 970 | ret_val = QCA_WLAN_HANG_RESUME_TIMEOUT; |
| 971 | break; |
| 972 | case QDF_REASON_UNSPECIFIED: |
| 973 | default: |
| 974 | ret_val = QCA_WLAN_HANG_REASON_UNSPECIFIED; |
| 975 | } |
| 976 | return ret_val; |
| 977 | } |
| 978 | |
| 979 | /** |
| 980 | * wlan_hdd_send_hang_reason_event() - Send hang reason to the userspace |
| 981 | * @hdd_ctx: Pointer to hdd context |
| 982 | * @reason: cds recovery reason |
| 983 | * |
| 984 | * Return: 0 on success or failure reason |
| 985 | */ |
| 986 | int wlan_hdd_send_hang_reason_event(struct hdd_context *hdd_ctx, |
| 987 | enum qdf_hang_reason reason) |
| 988 | { |
| 989 | struct sk_buff *vendor_event; |
| 990 | enum qca_wlan_vendor_hang_reason hang_reason; |
| 991 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 992 | hdd_enter(); |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 993 | |
| 994 | if (!hdd_ctx) { |
| 995 | hdd_err("HDD context is null"); |
| 996 | return -EINVAL; |
| 997 | } |
| 998 | |
| 999 | vendor_event = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 1000 | NULL, |
| 1001 | sizeof(uint32_t), |
| 1002 | HANG_REASON_INDEX, |
| 1003 | GFP_KERNEL); |
| 1004 | if (!vendor_event) { |
| 1005 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 1006 | return -ENOMEM; |
| 1007 | } |
| 1008 | |
| 1009 | hang_reason = hdd_convert_hang_reason(reason); |
| 1010 | |
| 1011 | if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_HANG_REASON, |
Mahesh Kumar Kalikot Veetil | 9111a57 | 2017-10-10 16:11:11 -0700 | [diff] [blame] | 1012 | (uint32_t)hang_reason)) { |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 1013 | hdd_err("QCA_WLAN_VENDOR_ATTR_HANG_REASON put fail"); |
| 1014 | kfree_skb(vendor_event); |
| 1015 | return -EINVAL; |
| 1016 | } |
| 1017 | |
| 1018 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 1019 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 1020 | hdd_exit(); |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 1021 | return 0; |
| 1022 | } |
Mahesh Kumar Kalikot Veetil | 9111a57 | 2017-10-10 16:11:11 -0700 | [diff] [blame] | 1023 | |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 1024 | #undef HANG_REASON_INDEX |
| 1025 | |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1026 | /** |
| 1027 | * wlan_hdd_get_adjacent_chan(): Gets next/previous channel |
| 1028 | * with respect to the channel passed. |
| 1029 | * @chan: Channel |
| 1030 | * @upper: If "true" then next channel is returned or else |
| 1031 | * previous channel is returned. |
| 1032 | * |
| 1033 | * This function returns the next/previous adjacent-channel to |
| 1034 | * the channel passed. If "upper = true" then next channel is |
| 1035 | * returned else previous is returned. |
| 1036 | */ |
| 1037 | int wlan_hdd_get_adjacent_chan(uint8_t chan, bool upper) |
| 1038 | { |
Ashish Kumar Dhanotiya | aa9fdbb | 2018-12-14 15:29:14 +0530 | [diff] [blame] | 1039 | enum channel_enum ch_idx = wlan_reg_get_chan_enum(chan); |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1040 | |
| 1041 | if (ch_idx == INVALID_CHANNEL) |
| 1042 | return -EINVAL; |
| 1043 | |
| 1044 | if (upper && (ch_idx < (NUM_CHANNELS - 1))) |
| 1045 | ch_idx++; |
| 1046 | else if (!upper && (ch_idx > CHAN_ENUM_1)) |
| 1047 | ch_idx--; |
| 1048 | else |
| 1049 | return -EINVAL; |
| 1050 | |
| 1051 | return WLAN_REG_CH_NUM(ch_idx); |
| 1052 | } |
| 1053 | |
| 1054 | /** |
| 1055 | * wlan_hdd_send_avoid_freq_for_dnbs(): Sends list of frequencies to be |
| 1056 | * avoided when Do_Not_Break_Stream is active. |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1057 | * @hdd_ctx: HDD Context |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1058 | * @op_chan: AP/P2P-GO operating channel |
| 1059 | * |
| 1060 | * This function sends list of frequencies to be avoided when |
| 1061 | * Do_Not_Break_Stream is active. |
| 1062 | * To clear the avoid_frequency_list in the application, |
| 1063 | * op_chan = 0 can be passed. |
| 1064 | * |
| 1065 | * Return: 0 on success and errno on failure |
| 1066 | */ |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1067 | int wlan_hdd_send_avoid_freq_for_dnbs(struct hdd_context *hdd_ctx, uint8_t op_chan) |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1068 | { |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1069 | struct ch_avoid_ind_type p2p_avoid_freq_list; |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1070 | uint8_t min_chan, max_chan; |
| 1071 | int ret; |
| 1072 | int chan; |
| 1073 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 1074 | hdd_enter(); |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1075 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1076 | if (!hdd_ctx) { |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1077 | hdd_err("invalid param"); |
| 1078 | return -EINVAL; |
| 1079 | } |
| 1080 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1081 | qdf_mem_zero(&p2p_avoid_freq_list, sizeof(struct ch_avoid_ind_type)); |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1082 | /* |
| 1083 | * If channel passed is zero, clear the avoid_freq list in application. |
| 1084 | */ |
| 1085 | if (!op_chan) { |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1086 | #ifdef FEATURE_WLAN_CH_AVOID |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1087 | mutex_lock(&hdd_ctx->avoid_freq_lock); |
| 1088 | qdf_mem_zero(&hdd_ctx->dnbs_avoid_freq_list, |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1089 | sizeof(struct ch_avoid_ind_type)); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1090 | if (hdd_ctx->coex_avoid_freq_list.ch_avoid_range_cnt) |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1091 | memcpy(&p2p_avoid_freq_list, |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1092 | &hdd_ctx->coex_avoid_freq_list, |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1093 | sizeof(struct ch_avoid_ind_type)); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1094 | mutex_unlock(&hdd_ctx->avoid_freq_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1095 | #endif |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1096 | ret = wlan_hdd_send_avoid_freq_event(hdd_ctx, |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1097 | &p2p_avoid_freq_list); |
| 1098 | if (ret) |
| 1099 | hdd_err("wlan_hdd_send_avoid_freq_event error:%d", |
| 1100 | ret); |
| 1101 | |
| 1102 | return ret; |
| 1103 | } |
| 1104 | |
| 1105 | if (WLAN_REG_IS_24GHZ_CH(op_chan)) { |
Ashish Kumar Dhanotiya | aa9fdbb | 2018-12-14 15:29:14 +0530 | [diff] [blame] | 1106 | min_chan = WLAN_REG_MIN_24GHZ_CH_NUM; |
| 1107 | max_chan = WLAN_REG_MAX_24GHZ_CH_NUM; |
| 1108 | } else if (WLAN_REG_IS_5GHZ_CH(op_chan)) { |
| 1109 | min_chan = WLAN_REG_MIN_5GHZ_CH_NUM; |
| 1110 | max_chan = WLAN_REG_MAX_5GHZ_CH_NUM; |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1111 | } else { |
| 1112 | hdd_err("invalid channel:%d", op_chan); |
| 1113 | return -EINVAL; |
| 1114 | } |
| 1115 | |
| 1116 | if ((op_chan > min_chan) && (op_chan < max_chan)) { |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1117 | p2p_avoid_freq_list.ch_avoid_range_cnt = 2; |
| 1118 | p2p_avoid_freq_list.avoid_freq_range[0].start_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1119 | wlan_chan_to_freq(min_chan); |
| 1120 | |
| 1121 | /* Get channel before the op_chan */ |
| 1122 | chan = wlan_hdd_get_adjacent_chan(op_chan, false); |
| 1123 | if (chan < 0) |
| 1124 | return -EINVAL; |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1125 | p2p_avoid_freq_list.avoid_freq_range[0].end_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1126 | wlan_chan_to_freq(chan); |
| 1127 | |
| 1128 | /* Get channel next to the op_chan */ |
| 1129 | chan = wlan_hdd_get_adjacent_chan(op_chan, true); |
| 1130 | if (chan < 0) |
| 1131 | return -EINVAL; |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1132 | p2p_avoid_freq_list.avoid_freq_range[1].start_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1133 | wlan_chan_to_freq(chan); |
| 1134 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1135 | p2p_avoid_freq_list.avoid_freq_range[1].end_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1136 | wlan_chan_to_freq(max_chan); |
| 1137 | } else if (op_chan == min_chan) { |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1138 | p2p_avoid_freq_list.ch_avoid_range_cnt = 1; |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1139 | |
| 1140 | chan = wlan_hdd_get_adjacent_chan(op_chan, true); |
| 1141 | if (chan < 0) |
| 1142 | return -EINVAL; |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1143 | p2p_avoid_freq_list.avoid_freq_range[0].start_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1144 | wlan_chan_to_freq(chan); |
| 1145 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1146 | p2p_avoid_freq_list.avoid_freq_range[0].end_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1147 | wlan_chan_to_freq(max_chan); |
| 1148 | } else { |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1149 | p2p_avoid_freq_list.ch_avoid_range_cnt = 1; |
| 1150 | p2p_avoid_freq_list.avoid_freq_range[0].start_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1151 | wlan_chan_to_freq(min_chan); |
| 1152 | |
| 1153 | chan = wlan_hdd_get_adjacent_chan(op_chan, false); |
| 1154 | if (chan < 0) |
| 1155 | return -EINVAL; |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1156 | p2p_avoid_freq_list.avoid_freq_range[0].end_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1157 | wlan_chan_to_freq(chan); |
| 1158 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1159 | #ifdef FEATURE_WLAN_CH_AVOID |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1160 | mutex_lock(&hdd_ctx->avoid_freq_lock); |
| 1161 | hdd_ctx->dnbs_avoid_freq_list = p2p_avoid_freq_list; |
| 1162 | if (hdd_ctx->coex_avoid_freq_list.ch_avoid_range_cnt) { |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1163 | ret = wlan_hdd_merge_avoid_freqs(&p2p_avoid_freq_list, |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1164 | &hdd_ctx->coex_avoid_freq_list); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1165 | if (ret) { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1166 | mutex_unlock(&hdd_ctx->avoid_freq_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1167 | hdd_err("avoid freq merge failed"); |
| 1168 | return ret; |
| 1169 | } |
| 1170 | } |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1171 | mutex_unlock(&hdd_ctx->avoid_freq_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1172 | #endif |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1173 | ret = wlan_hdd_send_avoid_freq_event(hdd_ctx, &p2p_avoid_freq_list); |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1174 | if (ret) |
| 1175 | hdd_err("wlan_hdd_send_avoid_freq_event error:%d", ret); |
| 1176 | |
| 1177 | return ret; |
| 1178 | } |
| 1179 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1180 | /* vendor specific events */ |
| 1181 | static const struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1182 | [QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX] = { |
| 1183 | .vendor_id = |
| 1184 | QCA_NL80211_VENDOR_ID, |
| 1185 | .subcmd = |
| 1186 | QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY |
| 1187 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1188 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1189 | [QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX] = { |
| 1190 | .vendor_id = |
| 1191 | QCA_NL80211_VENDOR_ID, |
| 1192 | .subcmd = |
| 1193 | QCA_NL80211_VENDOR_SUBCMD_NAN |
| 1194 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1195 | |
| 1196 | #ifdef WLAN_FEATURE_STATS_EXT |
| 1197 | [QCA_NL80211_VENDOR_SUBCMD_STATS_EXT_INDEX] = { |
| 1198 | .vendor_id = |
| 1199 | QCA_NL80211_VENDOR_ID, |
| 1200 | .subcmd = |
| 1201 | QCA_NL80211_VENDOR_SUBCMD_STATS_EXT |
| 1202 | }, |
| 1203 | #endif /* WLAN_FEATURE_STATS_EXT */ |
| 1204 | #ifdef FEATURE_WLAN_EXTSCAN |
| 1205 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX] = { |
| 1206 | .vendor_id = |
| 1207 | QCA_NL80211_VENDOR_ID, |
| 1208 | .subcmd = |
| 1209 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START |
| 1210 | }, |
| 1211 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX] = { |
| 1212 | .vendor_id = |
| 1213 | QCA_NL80211_VENDOR_ID, |
| 1214 | .subcmd = |
| 1215 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP |
| 1216 | }, |
| 1217 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX] = { |
| 1218 | . |
| 1219 | vendor_id |
| 1220 | = |
| 1221 | QCA_NL80211_VENDOR_ID, |
| 1222 | .subcmd = |
| 1223 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES |
| 1224 | }, |
| 1225 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX] = { |
| 1226 | . |
| 1227 | vendor_id |
| 1228 | = |
| 1229 | QCA_NL80211_VENDOR_ID, |
| 1230 | . |
| 1231 | subcmd = |
| 1232 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS |
| 1233 | }, |
| 1234 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX] = { |
| 1235 | . |
| 1236 | vendor_id |
| 1237 | = |
| 1238 | QCA_NL80211_VENDOR_ID, |
| 1239 | . |
| 1240 | subcmd |
| 1241 | = |
| 1242 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE |
| 1243 | }, |
| 1244 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX] = { |
| 1245 | . |
| 1246 | vendor_id |
| 1247 | = |
| 1248 | QCA_NL80211_VENDOR_ID, |
| 1249 | .subcmd = |
| 1250 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT |
| 1251 | }, |
| 1252 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX] = { |
| 1253 | .vendor_id = |
| 1254 | QCA_NL80211_VENDOR_ID, |
| 1255 | .subcmd = |
| 1256 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT |
| 1257 | }, |
| 1258 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX] = { |
| 1259 | . |
| 1260 | vendor_id |
| 1261 | = |
| 1262 | QCA_NL80211_VENDOR_ID, |
| 1263 | .subcmd = |
| 1264 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND |
| 1265 | }, |
| 1266 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX] = { |
| 1267 | . |
| 1268 | vendor_id |
| 1269 | = |
| 1270 | QCA_NL80211_VENDOR_ID, |
| 1271 | .subcmd = |
| 1272 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST |
| 1273 | }, |
| 1274 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX] = { |
| 1275 | . |
| 1276 | vendor_id |
| 1277 | = |
| 1278 | QCA_NL80211_VENDOR_ID, |
| 1279 | . |
| 1280 | subcmd |
| 1281 | = |
| 1282 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST |
| 1283 | }, |
| 1284 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX] = { |
| 1285 | . |
| 1286 | vendor_id |
| 1287 | = |
| 1288 | QCA_NL80211_VENDOR_ID, |
| 1289 | . |
| 1290 | subcmd = |
| 1291 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE |
| 1292 | }, |
| 1293 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX] = { |
| 1294 | . |
| 1295 | vendor_id |
| 1296 | = |
| 1297 | QCA_NL80211_VENDOR_ID, |
| 1298 | . |
| 1299 | subcmd |
| 1300 | = |
| 1301 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE |
| 1302 | }, |
| 1303 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX] = { |
| 1304 | . |
| 1305 | vendor_id |
| 1306 | = |
| 1307 | QCA_NL80211_VENDOR_ID, |
| 1308 | . |
| 1309 | subcmd |
| 1310 | = |
| 1311 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE |
| 1312 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1313 | #endif /* FEATURE_WLAN_EXTSCAN */ |
| 1314 | |
| 1315 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 1316 | [QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET_INDEX] = { |
| 1317 | .vendor_id = |
| 1318 | QCA_NL80211_VENDOR_ID, |
| 1319 | .subcmd = |
| 1320 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET |
| 1321 | }, |
| 1322 | [QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET_INDEX] = { |
| 1323 | .vendor_id = |
| 1324 | QCA_NL80211_VENDOR_ID, |
| 1325 | .subcmd = |
| 1326 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET |
| 1327 | }, |
| 1328 | [QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR_INDEX] = { |
| 1329 | .vendor_id = |
| 1330 | QCA_NL80211_VENDOR_ID, |
| 1331 | .subcmd = |
| 1332 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR |
| 1333 | }, |
| 1334 | [QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX] = { |
| 1335 | .vendor_id = |
| 1336 | QCA_NL80211_VENDOR_ID, |
| 1337 | .subcmd = |
| 1338 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS |
| 1339 | }, |
| 1340 | [QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX] = { |
| 1341 | .vendor_id = |
| 1342 | QCA_NL80211_VENDOR_ID, |
| 1343 | .subcmd = |
| 1344 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS |
| 1345 | }, |
| 1346 | [QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX] = { |
| 1347 | .vendor_id = |
| 1348 | QCA_NL80211_VENDOR_ID, |
| 1349 | .subcmd = |
| 1350 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS |
| 1351 | }, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 1352 | [QCA_NL80211_VENDOR_SUBCMD_LL_STATS_EXT_INDEX] = { |
| 1353 | .vendor_id = |
| 1354 | QCA_NL80211_VENDOR_ID, |
| 1355 | .subcmd = |
| 1356 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_EXT |
| 1357 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1358 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 1359 | [QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX] = { |
| 1360 | .vendor_id = |
| 1361 | QCA_NL80211_VENDOR_ID, |
| 1362 | .subcmd = |
| 1363 | QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE |
| 1364 | }, |
| 1365 | [QCA_NL80211_VENDOR_SUBCMD_DO_ACS_INDEX] = { |
| 1366 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1367 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_DO_ACS |
| 1368 | }, |
| 1369 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1370 | [QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH_INDEX] = { |
| 1371 | .vendor_id = |
| 1372 | QCA_NL80211_VENDOR_ID, |
| 1373 | .subcmd = |
| 1374 | QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH |
| 1375 | }, |
| 1376 | #endif |
| 1377 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_STARTED_INDEX] = { |
| 1378 | .vendor_id = |
| 1379 | QCA_NL80211_VENDOR_ID, |
| 1380 | .subcmd = |
| 1381 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_STARTED |
| 1382 | }, |
| 1383 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_FINISHED_INDEX] = { |
| 1384 | .vendor_id = |
| 1385 | QCA_NL80211_VENDOR_ID, |
| 1386 | .subcmd = |
| 1387 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_FINISHED |
| 1388 | }, |
| 1389 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_ABORTED_INDEX] = { |
| 1390 | .vendor_id = |
| 1391 | QCA_NL80211_VENDOR_ID, |
| 1392 | .subcmd = |
| 1393 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_ABORTED |
| 1394 | }, |
| 1395 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_NOP_FINISHED_INDEX] = { |
| 1396 | .vendor_id = |
| 1397 | QCA_NL80211_VENDOR_ID, |
| 1398 | .subcmd = |
| 1399 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_NOP_FINISHED |
| 1400 | }, |
| 1401 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_RADAR_DETECTED_INDEX] = { |
| 1402 | .vendor_id = |
| 1403 | QCA_NL80211_VENDOR_ID, |
| 1404 | .subcmd = |
| 1405 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_RADAR_DETECTED |
| 1406 | }, |
| 1407 | #ifdef FEATURE_WLAN_EXTSCAN |
| 1408 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_NETWORK_FOUND_INDEX] = { |
| 1409 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1410 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_NETWORK_FOUND |
| 1411 | }, |
| 1412 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_PASSPOINT_NETWORK_FOUND_INDEX] = { |
| 1413 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1414 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_PASSPOINT_NETWORK_FOUND |
| 1415 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1416 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = { |
| 1417 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1418 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST |
| 1419 | }, |
| 1420 | #endif /* FEATURE_WLAN_EXTSCAN */ |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 1421 | |
| 1422 | FEATURE_RSSI_MONITOR_VENDOR_EVENTS |
| 1423 | |
Manikandan Mohan | 5356c2b | 2016-04-03 15:51:35 -0700 | [diff] [blame] | 1424 | #ifdef WLAN_FEATURE_TSF |
| 1425 | [QCA_NL80211_VENDOR_SUBCMD_TSF_INDEX] = { |
| 1426 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1427 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_TSF |
| 1428 | }, |
| 1429 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1430 | [QCA_NL80211_VENDOR_SUBCMD_SCAN_DONE_INDEX] = { |
| 1431 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1432 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_SCAN_DONE |
| 1433 | }, |
| 1434 | [QCA_NL80211_VENDOR_SUBCMD_SCAN_INDEX] = { |
| 1435 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1436 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_TRIGGER_SCAN |
| 1437 | }, |
| 1438 | /* OCB events */ |
| 1439 | [QCA_NL80211_VENDOR_SUBCMD_DCC_STATS_EVENT_INDEX] = { |
| 1440 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1441 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_STATS_EVENT |
| 1442 | }, |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 1443 | #ifdef FEATURE_LFR_SUBNET_DETECTION |
| 1444 | [QCA_NL80211_VENDOR_SUBCMD_GW_PARAM_CONFIG_INDEX] = { |
| 1445 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1446 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_GW_PARAM_CONFIG |
| 1447 | }, |
| 1448 | #endif /*FEATURE_LFR_SUBNET_DETECTION */ |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 1449 | |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 1450 | [QCA_NL80211_VENDOR_SUBCMD_NDP_INDEX] = { |
| 1451 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1452 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_NDP |
| 1453 | }, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 1454 | |
| 1455 | [QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX] = { |
| 1456 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1457 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_P2P_LISTEN_OFFLOAD_STOP |
| 1458 | }, |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 1459 | [QCA_NL80211_VENDOR_SUBCMD_SAP_CONDITIONAL_CHAN_SWITCH_INDEX] = { |
| 1460 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1461 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_SAP_CONDITIONAL_CHAN_SWITCH |
| 1462 | }, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 1463 | [QCA_NL80211_VENDOR_SUBCMD_UPDATE_EXTERNAL_ACS_CONFIG] = { |
| 1464 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1465 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTERNAL_ACS |
| 1466 | }, |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 1467 | [QCA_NL80211_VENDOR_SUBCMD_PWR_SAVE_FAIL_DETECTED_INDEX] = { |
| 1468 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1469 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_CHIP_PWRSAVE_FAILURE |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 1470 | }, |
| 1471 | [QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX] = { |
| 1472 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1473 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET, |
| 1474 | }, |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 1475 | [QCA_NL80211_VENDOR_SUBCMD_HANG_REASON_INDEX] = { |
| 1476 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1477 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_HANG, |
| 1478 | }, |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 1479 | [QCA_NL80211_VENDOR_SUBCMD_WLAN_MAC_INFO_INDEX] = { |
| 1480 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1481 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_WLAN_MAC_INFO, |
| 1482 | }, |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 1483 | [QCA_NL80211_VENDOR_SUBCMD_THROUGHPUT_CHANGE_EVENT_INDEX] = { |
| 1484 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1485 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_THROUGHPUT_CHANGE_EVENT, |
| 1486 | }, |
Nachiket Kukade | a6a70a9 | 2018-10-09 20:07:21 +0530 | [diff] [blame] | 1487 | [QCA_NL80211_VENDOR_SUBCMD_NAN_EXT_INDEX] = { |
| 1488 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1489 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN_EXT |
| 1490 | }, |
Ashish Kumar Dhanotiya | 42b0378 | 2018-01-16 10:55:16 +0530 | [diff] [blame] | 1491 | [QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES_INDEX] = { |
| 1492 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1493 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES, |
| 1494 | }, |
Paul Zhang | 3a210c5 | 2016-12-08 10:18:12 +0800 | [diff] [blame] | 1495 | #ifdef WLAN_UMAC_CONVERGENCE |
| 1496 | COMMON_VENDOR_EVENTS |
| 1497 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1498 | }; |
| 1499 | |
| 1500 | /** |
| 1501 | * __is_driver_dfs_capable() - get driver DFS capability |
| 1502 | * @wiphy: pointer to wireless wiphy structure. |
| 1503 | * @wdev: pointer to wireless_dev structure. |
| 1504 | * @data: Pointer to the data to be passed via vendor interface |
| 1505 | * @data_len:Length of the data to be passed |
| 1506 | * |
| 1507 | * This function is called by userspace to indicate whether or not |
| 1508 | * the driver supports DFS offload. |
| 1509 | * |
| 1510 | * Return: 0 on success, negative errno on failure |
| 1511 | */ |
| 1512 | static int __is_driver_dfs_capable(struct wiphy *wiphy, |
| 1513 | struct wireless_dev *wdev, |
| 1514 | const void *data, |
| 1515 | int data_len) |
| 1516 | { |
| 1517 | u32 dfs_capability = 0; |
| 1518 | struct sk_buff *temp_skbuff; |
| 1519 | int ret_val; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 1520 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1521 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 1522 | hdd_enter_dev(wdev->netdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1523 | |
| 1524 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 1525 | if (ret_val) |
| 1526 | return ret_val; |
| 1527 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1528 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1529 | hdd_err("Command not allowed in FTM mode"); |
| 1530 | return -EPERM; |
| 1531 | } |
| 1532 | |
Peng Xu | 8e8b039 | 2018-04-30 11:32:34 -0700 | [diff] [blame] | 1533 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)) || \ |
| 1534 | defined(CFG80211_DFS_OFFLOAD_BACKPORT) |
| 1535 | dfs_capability = |
| 1536 | wiphy_ext_feature_isset(wiphy, |
| 1537 | NL80211_EXT_FEATURE_DFS_OFFLOAD); |
| 1538 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1539 | dfs_capability = !!(wiphy->flags & WIPHY_FLAG_DFS_OFFLOAD); |
Peng Xu | 8e8b039 | 2018-04-30 11:32:34 -0700 | [diff] [blame] | 1540 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1541 | |
| 1542 | temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) + |
| 1543 | NLMSG_HDRLEN); |
| 1544 | |
| 1545 | if (temp_skbuff != NULL) { |
| 1546 | ret_val = nla_put_u32(temp_skbuff, QCA_WLAN_VENDOR_ATTR_DFS, |
| 1547 | dfs_capability); |
| 1548 | if (ret_val) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1549 | hdd_err("QCA_WLAN_VENDOR_ATTR_DFS put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1550 | kfree_skb(temp_skbuff); |
| 1551 | |
| 1552 | return ret_val; |
| 1553 | } |
| 1554 | |
| 1555 | return cfg80211_vendor_cmd_reply(temp_skbuff); |
| 1556 | } |
| 1557 | |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1558 | hdd_err("dfs capability: buffer alloc fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1559 | return -ENOMEM; |
| 1560 | } |
| 1561 | |
| 1562 | /** |
| 1563 | * is_driver_dfs_capable() - get driver DFS capability |
| 1564 | * @wiphy: pointer to wireless wiphy structure. |
| 1565 | * @wdev: pointer to wireless_dev structure. |
| 1566 | * @data: Pointer to the data to be passed via vendor interface |
| 1567 | * @data_len:Length of the data to be passed |
| 1568 | * |
| 1569 | * This function is called by userspace to indicate whether or not |
| 1570 | * the driver supports DFS offload. This is an SSR-protected |
| 1571 | * wrapper function. |
| 1572 | * |
| 1573 | * Return: 0 on success, negative errno on failure |
| 1574 | */ |
| 1575 | static int is_driver_dfs_capable(struct wiphy *wiphy, |
| 1576 | struct wireless_dev *wdev, |
| 1577 | const void *data, |
| 1578 | int data_len) |
| 1579 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 1580 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 1581 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 1582 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 1583 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 1584 | if (errno) |
| 1585 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1586 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 1587 | errno = __is_driver_dfs_capable(wiphy, wdev, data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1588 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 1589 | osif_psoc_sync_op_stop(psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 1590 | |
| 1591 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1592 | } |
| 1593 | |
| 1594 | /** |
| 1595 | * wlan_hdd_sap_cfg_dfs_override() - DFS MCC restriction check |
| 1596 | * |
| 1597 | * @adapter: SAP adapter pointer |
| 1598 | * |
| 1599 | * DFS in MCC is not supported for Multi bssid SAP mode due to single physical |
| 1600 | * radio. So in case of DFS MCC scenario override current SAP given config |
| 1601 | * to follow concurrent SAP DFS config |
| 1602 | * |
| 1603 | * Return: 0 - No DFS issue, 1 - Override done and negative error codes |
| 1604 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 1605 | int wlan_hdd_sap_cfg_dfs_override(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1606 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 1607 | struct hdd_adapter *con_sap_adapter; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 1608 | tsap_config_t *sap_config, *con_sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1609 | int con_ch; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 1610 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1611 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1612 | if (!hdd_ctx) { |
| 1613 | hdd_err("hdd context is NULL"); |
| 1614 | return 0; |
| 1615 | } |
| 1616 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1617 | /* |
| 1618 | * Check if AP+AP case, once primary AP chooses a DFS |
| 1619 | * channel secondary AP should always follow primary APs channel |
| 1620 | */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 1621 | if (!policy_mgr_concurrent_beaconing_sessions_running( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 1622 | hdd_ctx->psoc)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1623 | return 0; |
| 1624 | |
| 1625 | con_sap_adapter = hdd_get_con_sap_adapter(adapter, true); |
| 1626 | if (!con_sap_adapter) |
| 1627 | return 0; |
| 1628 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 1629 | sap_config = &adapter->session.ap.sap_config; |
| 1630 | con_sap_config = &con_sap_adapter->session.ap.sap_config; |
| 1631 | con_ch = con_sap_adapter->session.ap.operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1632 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1633 | if (!wlan_reg_is_dfs_ch(hdd_ctx->pdev, con_ch)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1634 | return 0; |
| 1635 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 1636 | hdd_debug("Only SCC AP-AP DFS Permitted (ch=%d, con_ch=%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1637 | sap_config->channel, con_ch); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 1638 | hdd_debug("Overriding guest AP's channel"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1639 | sap_config->channel = con_ch; |
| 1640 | |
| 1641 | if (con_sap_config->acs_cfg.acs_mode == true) { |
| 1642 | if (con_ch != con_sap_config->acs_cfg.pri_ch && |
| 1643 | con_ch != con_sap_config->acs_cfg.ht_sec_ch) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1644 | hdd_err("Primary AP channel config error"); |
| 1645 | hdd_err("Operating ch: %d ACS ch: %d %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1646 | con_ch, con_sap_config->acs_cfg.pri_ch, |
| 1647 | con_sap_config->acs_cfg.ht_sec_ch); |
| 1648 | return -EINVAL; |
| 1649 | } |
| 1650 | /* Sec AP ACS info is overwritten with Pri AP due to DFS |
| 1651 | * MCC restriction. So free ch list allocated in do_acs |
| 1652 | * func for Sec AP and realloc for Pri AP ch list size |
| 1653 | */ |
| 1654 | if (sap_config->acs_cfg.ch_list) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1655 | qdf_mem_free(sap_config->acs_cfg.ch_list); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1656 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1657 | qdf_mem_copy(&sap_config->acs_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1658 | &con_sap_config->acs_cfg, |
| 1659 | sizeof(struct sap_acs_cfg)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1660 | sap_config->acs_cfg.ch_list = qdf_mem_malloc( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1661 | sizeof(uint8_t) * |
| 1662 | con_sap_config->acs_cfg.ch_list_count); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 1663 | if (!sap_config->acs_cfg.ch_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1664 | return -ENOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1665 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1666 | qdf_mem_copy(sap_config->acs_cfg.ch_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1667 | con_sap_config->acs_cfg.ch_list, |
| 1668 | con_sap_config->acs_cfg.ch_list_count); |
| 1669 | |
| 1670 | } else { |
| 1671 | sap_config->acs_cfg.pri_ch = con_ch; |
| 1672 | if (sap_config->acs_cfg.ch_width > eHT_CHANNEL_WIDTH_20MHZ) |
| 1673 | sap_config->acs_cfg.ht_sec_ch = con_sap_config->sec_ch; |
| 1674 | } |
| 1675 | |
| 1676 | return con_ch; |
| 1677 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1678 | |
| 1679 | /** |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1680 | * wlan_hdd_set_acs_ch_range : Populate ACS hw mode and channel range values |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1681 | * @sap_cfg: pointer to SAP config struct |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1682 | * @hw_mode: hw mode retrieved from vendor command buffer |
| 1683 | * @ht_enabled: whether HT phy mode is enabled |
| 1684 | * @vht_enabled: whether VHT phy mode is enabled |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1685 | * |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1686 | * This function populates the ACS hw mode based on the configuration retrieved |
| 1687 | * from the vendor command buffer; and sets ACS start and end channel for the |
| 1688 | * given band. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1689 | * |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1690 | * Return: 0 if success; -EINVAL if ACS channel list is NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1691 | */ |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1692 | static int wlan_hdd_set_acs_ch_range( |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 1693 | tsap_config_t *sap_cfg, enum qca_wlan_vendor_acs_hw_mode hw_mode, |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1694 | bool ht_enabled, bool vht_enabled) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1695 | { |
| 1696 | int i; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 1697 | |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1698 | if (hw_mode == QCA_ACS_MODE_IEEE80211B) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1699 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11b; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1700 | sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_1); |
| 1701 | sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_14); |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1702 | } else if (hw_mode == QCA_ACS_MODE_IEEE80211G) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1703 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11g; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1704 | sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_1); |
| 1705 | sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_13); |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1706 | } else if (hw_mode == QCA_ACS_MODE_IEEE80211A) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1707 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11a; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1708 | sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_36); |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 1709 | sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_173); |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1710 | } else if (hw_mode == QCA_ACS_MODE_IEEE80211ANY) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1711 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_abg; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1712 | sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_1); |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 1713 | sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_173); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1714 | } |
| 1715 | |
| 1716 | if (ht_enabled) |
| 1717 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11n; |
| 1718 | |
| 1719 | if (vht_enabled) |
| 1720 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11ac; |
| 1721 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1722 | /* Parse ACS Chan list from hostapd */ |
| 1723 | if (!sap_cfg->acs_cfg.ch_list) |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 1724 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1725 | |
| 1726 | sap_cfg->acs_cfg.start_ch = sap_cfg->acs_cfg.ch_list[0]; |
| 1727 | sap_cfg->acs_cfg.end_ch = |
| 1728 | sap_cfg->acs_cfg.ch_list[sap_cfg->acs_cfg.ch_list_count - 1]; |
| 1729 | for (i = 0; i < sap_cfg->acs_cfg.ch_list_count; i++) { |
Manjeet Singh | 2d3b0c5 | 2016-09-02 13:31:48 +0530 | [diff] [blame] | 1730 | /* avoid channel as start channel */ |
| 1731 | if (sap_cfg->acs_cfg.start_ch > sap_cfg->acs_cfg.ch_list[i] && |
| 1732 | sap_cfg->acs_cfg.ch_list[i] != 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1733 | sap_cfg->acs_cfg.start_ch = sap_cfg->acs_cfg.ch_list[i]; |
| 1734 | if (sap_cfg->acs_cfg.end_ch < sap_cfg->acs_cfg.ch_list[i]) |
| 1735 | sap_cfg->acs_cfg.end_ch = sap_cfg->acs_cfg.ch_list[i]; |
| 1736 | } |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 1737 | |
| 1738 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1739 | } |
| 1740 | |
| 1741 | |
| 1742 | static void wlan_hdd_cfg80211_start_pending_acs(struct work_struct *work); |
| 1743 | |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1744 | |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 1745 | static void hdd_update_acs_channel_list(tsap_config_t *sap_config, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1746 | enum band_info band) |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1747 | { |
| 1748 | int i, temp_count = 0; |
| 1749 | int acs_list_count = sap_config->acs_cfg.ch_list_count; |
| 1750 | |
| 1751 | for (i = 0; i < acs_list_count; i++) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1752 | if (BAND_2G == band) { |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1753 | if (WLAN_REG_IS_24GHZ_CH( |
| 1754 | sap_config->acs_cfg.ch_list[i])) { |
| 1755 | sap_config->acs_cfg.ch_list[temp_count] = |
| 1756 | sap_config->acs_cfg.ch_list[i]; |
| 1757 | temp_count++; |
| 1758 | } |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1759 | } else if (BAND_5G == band) { |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1760 | if (WLAN_REG_IS_5GHZ_CH( |
| 1761 | sap_config->acs_cfg.ch_list[i])) { |
| 1762 | sap_config->acs_cfg.ch_list[temp_count] = |
| 1763 | sap_config->acs_cfg.ch_list[i]; |
| 1764 | temp_count++; |
| 1765 | } |
| 1766 | } |
| 1767 | } |
| 1768 | sap_config->acs_cfg.ch_list_count = temp_count; |
| 1769 | } |
| 1770 | |
| 1771 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1772 | /** |
| 1773 | * wlan_hdd_cfg80211_start_acs : Start ACS Procedure for SAP |
| 1774 | * @adapter: pointer to SAP adapter struct |
| 1775 | * |
| 1776 | * This function starts the ACS procedure if there are no |
| 1777 | * constraints like MBSSID DFS restrictions. |
| 1778 | * |
| 1779 | * Return: Status of ACS Start procedure |
| 1780 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 1781 | int wlan_hdd_cfg80211_start_acs(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1782 | { |
| 1783 | |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 1784 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 1785 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1786 | tpWLAN_SAPEventCB acs_event_callback; |
Krunal Soni | 5e3f962 | 2018-09-26 16:35:50 -0700 | [diff] [blame] | 1787 | uint8_t mcc_to_scc_switch = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1788 | int status; |
| 1789 | |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 1790 | if (!adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 1791 | hdd_err("adapter is NULL"); |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 1792 | return -EINVAL; |
| 1793 | } |
| 1794 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 1795 | status = wlan_hdd_validate_context(hdd_ctx); |
| 1796 | if (0 != status) |
| 1797 | return status; |
| 1798 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 1799 | sap_config = &adapter->session.ap.sap_config; |
Ashish Kumar Dhanotiya | b062962 | 2018-09-21 18:58:59 +0530 | [diff] [blame] | 1800 | if (!sap_config) { |
| 1801 | hdd_err("SAP config is NULL"); |
| 1802 | return -EINVAL; |
| 1803 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 1804 | if (hdd_ctx->acs_policy.acs_channel) |
| 1805 | sap_config->channel = hdd_ctx->acs_policy.acs_channel; |
| 1806 | else |
| 1807 | sap_config->channel = AUTO_CHANNEL_SELECT; |
Krunal Soni | 5e3f962 | 2018-09-26 16:35:50 -0700 | [diff] [blame] | 1808 | ucfg_policy_mgr_get_mcc_scc_switch(hdd_ctx->psoc, |
| 1809 | &mcc_to_scc_switch); |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1810 | /* |
| 1811 | * No DFS SCC is allowed in Auto use case. Hence not |
| 1812 | * calling DFS override |
| 1813 | */ |
| 1814 | if (QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION != |
Krunal Soni | 5e3f962 | 2018-09-26 16:35:50 -0700 | [diff] [blame] | 1815 | mcc_to_scc_switch) { |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1816 | status = wlan_hdd_sap_cfg_dfs_override(adapter); |
| 1817 | if (status < 0) |
| 1818 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1819 | |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1820 | if (status > 0) { |
| 1821 | /*notify hostapd about channel override */ |
| 1822 | wlan_hdd_cfg80211_acs_ch_select_evt(adapter); |
| 1823 | clear_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags); |
| 1824 | return 0; |
| 1825 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1826 | } |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1827 | /* When first 2 connections are on the same frequency band, |
| 1828 | * then PCL would include only channels from the other |
| 1829 | * frequency band on which no connections are active |
| 1830 | */ |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 1831 | if ((policy_mgr_get_connection_count(hdd_ctx->psoc) == 2) && |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1832 | (sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211ANY)) { |
| 1833 | struct policy_mgr_conc_connection_info *conc_connection_info; |
| 1834 | uint32_t i; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 1835 | |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1836 | conc_connection_info = policy_mgr_get_conn_info(&i); |
| 1837 | if (conc_connection_info[0].mac == |
| 1838 | conc_connection_info[1].mac) { |
| 1839 | if (WLAN_REG_IS_5GHZ_CH(sap_config->acs_cfg. |
| 1840 | pcl_channels[0])) { |
| 1841 | sap_config->acs_cfg.band = |
| 1842 | QCA_ACS_MODE_IEEE80211A; |
| 1843 | hdd_update_acs_channel_list(sap_config, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1844 | BAND_5G); |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1845 | } else { |
| 1846 | sap_config->acs_cfg.band = |
| 1847 | QCA_ACS_MODE_IEEE80211G; |
| 1848 | hdd_update_acs_channel_list(sap_config, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1849 | BAND_2G); |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1850 | } |
| 1851 | } |
| 1852 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1853 | status = wlan_hdd_config_acs(hdd_ctx, adapter); |
| 1854 | if (status) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1855 | hdd_err("ACS config failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1856 | return -EINVAL; |
| 1857 | } |
| 1858 | |
| 1859 | acs_event_callback = hdd_hostapd_sap_event_cb; |
| 1860 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1861 | qdf_mem_copy(sap_config->self_macaddr.bytes, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 1862 | adapter->mac_addr.bytes, sizeof(struct qdf_mac_addr)); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 1863 | hdd_info("ACS Started for %s", adapter->dev->name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1864 | status = wlansap_acs_chselect( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1865 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1866 | acs_event_callback, sap_config, adapter->dev); |
| 1867 | |
| 1868 | |
| 1869 | if (status) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1870 | hdd_err("ACS channel select failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1871 | return -EINVAL; |
| 1872 | } |
bings | 394afdd | 2017-01-09 11:22:38 +0800 | [diff] [blame] | 1873 | if (sap_is_auto_channel_select(WLAN_HDD_GET_SAP_CTX_PTR(adapter))) |
| 1874 | sap_config->acs_cfg.acs_mode = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1875 | set_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags); |
| 1876 | |
| 1877 | return 0; |
| 1878 | } |
| 1879 | |
| 1880 | /** |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 1881 | * hdd_update_vendor_pcl_list() - This API will return unsorted pcl list |
| 1882 | * @hdd_ctx: hdd context |
| 1883 | * @acs_chan_params: external acs channel params |
| 1884 | * @sap_config: SAP config |
| 1885 | * |
| 1886 | * This API provides unsorted pcl list. |
| 1887 | * this list is a subset of the valid channel list given by hostapd. |
| 1888 | * if channel is not present in pcl, weightage will be given as zero |
| 1889 | * |
| 1890 | * Return: Zero on success, non-zero on failure |
| 1891 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 1892 | static void hdd_update_vendor_pcl_list(struct hdd_context *hdd_ctx, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 1893 | struct hdd_vendor_acs_chan_params *acs_chan_params, |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 1894 | tsap_config_t *sap_config) |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 1895 | { |
| 1896 | int i, j; |
Adesh Keremane | 25ce2dc | 2017-05-29 17:55:39 +0530 | [diff] [blame] | 1897 | /* |
| 1898 | * PCL shall contain only the preferred channels from the |
| 1899 | * application. If those channels are not present in the |
| 1900 | * driver PCL, then set the weight to zero |
| 1901 | */ |
| 1902 | for (i = 0; i < sap_config->acs_cfg.ch_list_count; i++) { |
| 1903 | acs_chan_params->vendor_pcl_list[i] = |
| 1904 | sap_config->acs_cfg.ch_list[i]; |
| 1905 | acs_chan_params->vendor_weight_list[i] = 0; |
| 1906 | for (j = 0; j < sap_config->acs_cfg.pcl_ch_count; j++) { |
| 1907 | if (sap_config->acs_cfg.ch_list[i] == |
| 1908 | sap_config->acs_cfg.pcl_channels[j]) { |
| 1909 | acs_chan_params->vendor_weight_list[i] = |
| 1910 | sap_config-> |
| 1911 | acs_cfg.pcl_channels_weight_list[j]; |
| 1912 | break; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 1913 | } |
| 1914 | } |
| 1915 | } |
Adesh Keremane | 25ce2dc | 2017-05-29 17:55:39 +0530 | [diff] [blame] | 1916 | acs_chan_params->pcl_count = sap_config->acs_cfg.ch_list_count; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 1917 | } |
| 1918 | |
| 1919 | /** |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1920 | * hdd_update_reg_chan_info : This API contructs channel info |
| 1921 | * for all the given channel |
| 1922 | * @adapter: pointer to SAP adapter struct |
| 1923 | * @channel_count: channel count |
| 1924 | * @channel_list: channel list |
| 1925 | * |
| 1926 | * Return: Status of of channel information updation |
| 1927 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 1928 | static int hdd_update_reg_chan_info(struct hdd_adapter *adapter, |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1929 | uint32_t channel_count, |
| 1930 | uint8_t *channel_list) |
| 1931 | { |
| 1932 | int i; |
| 1933 | struct hdd_channel_info *icv; |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 1934 | struct ch_params ch_params = {0}; |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1935 | uint8_t bw_offset = 0, chan = 0; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 1936 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 1937 | tsap_config_t *sap_config = &adapter->session.ap.sap_config; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 1938 | mac_handle_t mac_handle; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1939 | uint8_t sub_20_chan_width = 0; |
| 1940 | QDF_STATUS status; |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1941 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 1942 | mac_handle = hdd_ctx->mac_handle; |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 1943 | sap_config->channel_info_count = channel_count; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1944 | |
| 1945 | status = ucfg_mlme_get_sub_20_chan_width(hdd_ctx->psoc, |
| 1946 | &sub_20_chan_width); |
| 1947 | if (QDF_IS_STATUS_ERROR(status)) |
| 1948 | hdd_err("Failed to get sub_20_chan_width config"); |
| 1949 | |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1950 | for (i = 0; i < channel_count; i++) { |
| 1951 | icv = &sap_config->channel_info[i]; |
| 1952 | chan = channel_list[i]; |
| 1953 | |
| 1954 | if (chan == 0) |
| 1955 | continue; |
| 1956 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1957 | icv->freq = wlan_reg_get_channel_freq(hdd_ctx->pdev, chan); |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1958 | icv->ieee_chan_number = chan; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1959 | icv->max_reg_power = wlan_reg_get_channel_reg_power( |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1960 | hdd_ctx->pdev, chan); |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1961 | |
| 1962 | /* filling demo values */ |
| 1963 | icv->max_radio_power = HDD_MAX_TX_POWER; |
| 1964 | icv->min_radio_power = HDD_MIN_TX_POWER; |
| 1965 | /* not supported in current driver */ |
| 1966 | icv->max_antenna_gain = 0; |
| 1967 | |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1968 | bw_offset = hdd_get_bw_offset(sap_config->acs_cfg.ch_width); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 1969 | icv->reg_class_id = |
| 1970 | wlan_hdd_find_opclass(mac_handle, chan, bw_offset); |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1971 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1972 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1973 | ch_params.ch_width = sap_config->acs_cfg.ch_width; |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1974 | wlan_reg_set_channel_params(hdd_ctx->pdev, chan, |
| 1975 | 0, &ch_params); |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1976 | icv->vht_center_freq_seg0 = ch_params.center_freq_seg0; |
| 1977 | icv->vht_center_freq_seg1 = ch_params.center_freq_seg1; |
| 1978 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1979 | |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1980 | icv->flags = 0; |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1981 | icv->flags = cds_get_vendor_reg_flags(hdd_ctx->pdev, chan, |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1982 | sap_config->acs_cfg.ch_width, |
| 1983 | sap_config->acs_cfg.is_ht_enabled, |
| 1984 | sap_config->acs_cfg.is_vht_enabled, |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1985 | sub_20_chan_width); |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 1986 | if (icv->flags & IEEE80211_CHAN_PASSIVE) |
| 1987 | icv->flagext |= IEEE80211_CHAN_DFS; |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1988 | |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 1989 | hdd_debug("freq %d flags %d flagext %d ieee %d maxreg %d maxpw %d minpw %d regClass %d antenna %d seg0 %d seg1 %d", |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1990 | icv->freq, icv->flags, |
| 1991 | icv->flagext, icv->ieee_chan_number, |
| 1992 | icv->max_reg_power, icv->max_radio_power, |
| 1993 | icv->min_radio_power, icv->reg_class_id, |
| 1994 | icv->max_antenna_gain, icv->vht_center_freq_seg0, |
| 1995 | icv->vht_center_freq_seg1); |
| 1996 | } |
| 1997 | return 0; |
| 1998 | } |
| 1999 | |
| 2000 | /* Short name for QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_CHAN_INFO event */ |
| 2001 | #define CHAN_INFO_ATTR_FLAGS \ |
| 2002 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_FLAGS |
| 2003 | #define CHAN_INFO_ATTR_FLAG_EXT \ |
| 2004 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_FLAG_EXT |
| 2005 | #define CHAN_INFO_ATTR_FREQ \ |
| 2006 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_FREQ |
| 2007 | #define CHAN_INFO_ATTR_MAX_REG_POWER \ |
| 2008 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_MAX_REG_POWER |
| 2009 | #define CHAN_INFO_ATTR_MAX_POWER \ |
| 2010 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_MAX_POWER |
| 2011 | #define CHAN_INFO_ATTR_MIN_POWER \ |
| 2012 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_MIN_POWER |
| 2013 | #define CHAN_INFO_ATTR_REG_CLASS_ID \ |
| 2014 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_REG_CLASS_ID |
| 2015 | #define CHAN_INFO_ATTR_ANTENNA_GAIN \ |
| 2016 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_ANTENNA_GAIN |
| 2017 | #define CHAN_INFO_ATTR_VHT_SEG_0 \ |
| 2018 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_VHT_SEG_0 |
| 2019 | #define CHAN_INFO_ATTR_VHT_SEG_1 \ |
| 2020 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_VHT_SEG_1 |
| 2021 | |
| 2022 | /** |
| 2023 | * hdd_cfg80211_update_channel_info() - add channel info attributes |
| 2024 | * @skb: pointer to sk buff |
| 2025 | * @hdd_ctx: pointer to hdd station context |
| 2026 | * @idx: attribute index |
| 2027 | * |
| 2028 | * Return: Success(0) or reason code for failure |
| 2029 | */ |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2030 | static int32_t |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2031 | hdd_cfg80211_update_channel_info(struct sk_buff *skb, |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 2032 | tsap_config_t *sap_config, int idx) |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2033 | { |
| 2034 | struct nlattr *nla_attr, *channel; |
| 2035 | struct hdd_channel_info *icv; |
| 2036 | int i; |
| 2037 | |
| 2038 | nla_attr = nla_nest_start(skb, idx); |
| 2039 | if (!nla_attr) |
| 2040 | goto fail; |
| 2041 | |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2042 | for (i = 0; i < sap_config->channel_info_count; i++) { |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2043 | channel = nla_nest_start(skb, i); |
| 2044 | if (!channel) |
| 2045 | goto fail; |
| 2046 | |
| 2047 | icv = &sap_config->channel_info[i]; |
| 2048 | if (!icv) { |
| 2049 | hdd_err("channel info not found"); |
| 2050 | goto fail; |
| 2051 | } |
| 2052 | if (nla_put_u16(skb, CHAN_INFO_ATTR_FREQ, |
| 2053 | icv->freq) || |
| 2054 | nla_put_u32(skb, CHAN_INFO_ATTR_FLAGS, |
| 2055 | icv->flags) || |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2056 | nla_put_u32(skb, CHAN_INFO_ATTR_FLAG_EXT, |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2057 | icv->flagext) || |
| 2058 | nla_put_u8(skb, CHAN_INFO_ATTR_MAX_REG_POWER, |
| 2059 | icv->max_reg_power) || |
| 2060 | nla_put_u8(skb, CHAN_INFO_ATTR_MAX_POWER, |
| 2061 | icv->max_radio_power) || |
| 2062 | nla_put_u8(skb, CHAN_INFO_ATTR_MIN_POWER, |
| 2063 | icv->min_radio_power) || |
| 2064 | nla_put_u8(skb, CHAN_INFO_ATTR_REG_CLASS_ID, |
| 2065 | icv->reg_class_id) || |
| 2066 | nla_put_u8(skb, CHAN_INFO_ATTR_ANTENNA_GAIN, |
| 2067 | icv->max_antenna_gain) || |
| 2068 | nla_put_u8(skb, CHAN_INFO_ATTR_VHT_SEG_0, |
| 2069 | icv->vht_center_freq_seg0) || |
| 2070 | nla_put_u8(skb, CHAN_INFO_ATTR_VHT_SEG_1, |
| 2071 | icv->vht_center_freq_seg1)) { |
| 2072 | hdd_err("put fail"); |
| 2073 | goto fail; |
| 2074 | } |
| 2075 | nla_nest_end(skb, channel); |
| 2076 | } |
| 2077 | nla_nest_end(skb, nla_attr); |
| 2078 | return 0; |
| 2079 | fail: |
| 2080 | hdd_err("nl channel update failed"); |
| 2081 | return -EINVAL; |
| 2082 | } |
| 2083 | #undef CHAN_INFO_ATTR_FLAGS |
| 2084 | #undef CHAN_INFO_ATTR_FLAG_EXT |
| 2085 | #undef CHAN_INFO_ATTR_FREQ |
| 2086 | #undef CHAN_INFO_ATTR_MAX_REG_POWER |
| 2087 | #undef CHAN_INFO_ATTR_MAX_POWER |
| 2088 | #undef CHAN_INFO_ATTR_MIN_POWER |
| 2089 | #undef CHAN_INFO_ATTR_REG_CLASS_ID |
| 2090 | #undef CHAN_INFO_ATTR_ANTENNA_GAIN |
| 2091 | #undef CHAN_INFO_ATTR_VHT_SEG_0 |
| 2092 | #undef CHAN_INFO_ATTR_VHT_SEG_1 |
| 2093 | |
| 2094 | /** |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2095 | * hdd_cfg80211_update_pcl() - add pcl info attributes |
| 2096 | * @skb: pointer to sk buff |
| 2097 | * @hdd_ctx: pointer to hdd station context |
| 2098 | * @idx: attribute index |
| 2099 | * @vendor_pcl_list: PCL list |
| 2100 | * @vendor_weight_list: PCL weights |
| 2101 | * |
| 2102 | * Return: Success(0) or reason code for failure |
| 2103 | */ |
| 2104 | static int32_t |
| 2105 | hdd_cfg80211_update_pcl(struct sk_buff *skb, |
| 2106 | uint8_t ch_list_count, int idx, |
| 2107 | uint8_t *vendor_pcl_list, uint8_t *vendor_weight_list) |
| 2108 | { |
| 2109 | struct nlattr *nla_attr, *channel; |
| 2110 | int i; |
| 2111 | |
| 2112 | nla_attr = nla_nest_start(skb, idx); |
| 2113 | |
| 2114 | if (!nla_attr) |
| 2115 | goto fail; |
| 2116 | |
| 2117 | for (i = 0; i < ch_list_count; i++) { |
| 2118 | channel = nla_nest_start(skb, i); |
| 2119 | if (!channel) |
| 2120 | goto fail; |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2121 | if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_PCL_CHANNEL, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2122 | vendor_pcl_list[i]) || |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2123 | nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_PCL_WEIGHT, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2124 | vendor_weight_list[i])) { |
| 2125 | hdd_err("put fail"); |
| 2126 | goto fail; |
| 2127 | } |
| 2128 | nla_nest_end(skb, channel); |
| 2129 | } |
| 2130 | nla_nest_end(skb, nla_attr); |
| 2131 | |
| 2132 | return 0; |
| 2133 | fail: |
| 2134 | hdd_err("updating pcl list failed"); |
| 2135 | return -EINVAL; |
| 2136 | } |
| 2137 | |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 2138 | static void hdd_get_scan_band(struct hdd_context *hdd_ctx, |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 2139 | tsap_config_t *sap_config, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2140 | enum band_info *band) |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2141 | { |
| 2142 | /* Get scan band */ |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2143 | if ((sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211B) || |
| 2144 | (sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211G)) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2145 | *band = BAND_2G; |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2146 | } else if (sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211A) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2147 | *band = BAND_5G; |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2148 | } else if (sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211ANY) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2149 | *band = BAND_ALL; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2150 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2151 | } |
| 2152 | |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2153 | |
| 2154 | /** |
| 2155 | * hdd_get_freq_list: API to get Frequency list based on channel list |
| 2156 | * @channel_list: channel list |
| 2157 | * @freq_list: frequency list |
| 2158 | * @channel_count: channel count |
| 2159 | * |
| 2160 | * Return: None |
| 2161 | */ |
| 2162 | static void hdd_get_freq_list(uint8_t *channel_list, uint32_t *freq_list, |
| 2163 | uint32_t channel_count) |
| 2164 | { |
| 2165 | int count; |
| 2166 | |
| 2167 | for (count = 0; count < channel_count ; count++) |
| 2168 | freq_list[count] = cds_chan_to_freq(channel_list[count]); |
| 2169 | } |
| 2170 | |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 2171 | /** |
| 2172 | * wlan_hdd_sap_get_valid_channellist() - Get SAPs valid channel list |
| 2173 | * @ap_adapter: adapter |
| 2174 | * @channel_count: valid channel count |
| 2175 | * @channel_list: valid channel list |
| 2176 | * @band: frequency band |
| 2177 | * |
| 2178 | * This API returns valid channel list for SAP after removing nol and |
| 2179 | * channel which lies outside of configuration. |
| 2180 | * |
| 2181 | * Return: Zero on success, non-zero on failure |
| 2182 | */ |
| 2183 | static int wlan_hdd_sap_get_valid_channellist(struct hdd_adapter *adapter, |
| 2184 | uint32_t *channel_count, |
| 2185 | uint8_t *channel_list, |
| 2186 | enum band_info band) |
| 2187 | { |
| 2188 | tsap_config_t *sap_config; |
| 2189 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2190 | uint8_t tmp_chan_list[QDF_MAX_NUM_CHAN] = {0}; |
| 2191 | uint32_t chan_count; |
| 2192 | uint8_t i; |
| 2193 | QDF_STATUS status; |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2194 | struct wlan_objmgr_pdev *pdev = hdd_ctx->pdev; |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 2195 | uint8_t tmp_chan; |
| 2196 | |
| 2197 | sap_config = &adapter->session.ap.sap_config; |
| 2198 | |
| 2199 | status = |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 2200 | policy_mgr_get_valid_chans(hdd_ctx->psoc, |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 2201 | tmp_chan_list, |
| 2202 | &chan_count); |
| 2203 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2204 | hdd_err("Failed to get channel list"); |
| 2205 | return -EINVAL; |
| 2206 | } |
| 2207 | |
| 2208 | for (i = 0; i < chan_count; i++) { |
| 2209 | tmp_chan = tmp_chan_list[i]; |
| 2210 | if (*channel_count < QDF_MAX_NUM_CHAN) { |
| 2211 | if ((band == BAND_2G) && |
| 2212 | (WLAN_REG_IS_24GHZ_CH(tmp_chan)) && |
| 2213 | (!wlan_reg_is_disable_ch(pdev, tmp_chan))) { |
| 2214 | channel_list[*channel_count] = tmp_chan; |
| 2215 | *channel_count += 1; |
| 2216 | } else if ((band == BAND_5G) && |
| 2217 | (WLAN_REG_IS_5GHZ_CH(tmp_chan)) && |
| 2218 | (!wlan_reg_is_disable_ch(pdev, tmp_chan))) { |
| 2219 | channel_list[*channel_count] = tmp_chan; |
| 2220 | *channel_count += 1; |
| 2221 | } |
| 2222 | } else { |
| 2223 | break; |
| 2224 | } |
| 2225 | } |
| 2226 | |
| 2227 | if (*channel_count == 0) { |
| 2228 | hdd_err("no valid channel found"); |
| 2229 | return -EINVAL; |
| 2230 | } |
| 2231 | |
| 2232 | return 0; |
| 2233 | } |
| 2234 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2235 | int hdd_cfg80211_update_acs_config(struct hdd_adapter *adapter, |
| 2236 | uint8_t reason) |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2237 | { |
| 2238 | struct sk_buff *skb; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 2239 | tsap_config_t *sap_config; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2240 | uint32_t channel_count = 0, status = -EINVAL; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2241 | uint8_t channel_list[QDF_MAX_NUM_CHAN] = {0}; |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2242 | uint32_t freq_list[QDF_MAX_NUM_CHAN] = {0}; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2243 | uint8_t vendor_pcl_list[QDF_MAX_NUM_CHAN] = {0}; |
| 2244 | uint8_t vendor_weight_list[QDF_MAX_NUM_CHAN] = {0}; |
| 2245 | struct hdd_vendor_acs_chan_params acs_chan_params; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 2246 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2247 | enum band_info band = BAND_2G; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2248 | eCsrPhyMode phy_mode; |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2249 | enum qca_wlan_vendor_attr_external_acs_policy acs_policy; |
| 2250 | uint32_t i; |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 2251 | QDF_STATUS qdf_status; |
| 2252 | bool is_external_acs_policy = cfg_default(CFG_EXTERNAL_ACS_POLICY); |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2253 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2254 | if (!hdd_ctx) { |
| 2255 | hdd_err("HDD context is NULL"); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2256 | return -EINVAL; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2257 | } |
| 2258 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 2259 | hdd_enter(); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2260 | sap_config = &adapter->session.ap.sap_config; |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 2261 | /* When first 2 connections are on the same frequency band, |
| 2262 | * then PCL would include only channels from the other |
| 2263 | * frequency band on which no connections are active |
| 2264 | */ |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 2265 | if ((policy_mgr_get_connection_count(hdd_ctx->psoc) == 2) && |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 2266 | (sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211ANY)) { |
| 2267 | struct policy_mgr_conc_connection_info *conc_connection_info; |
| 2268 | |
| 2269 | conc_connection_info = policy_mgr_get_conn_info(&i); |
| 2270 | if (conc_connection_info[0].mac == |
| 2271 | conc_connection_info[1].mac) { |
| 2272 | |
| 2273 | if (WLAN_REG_IS_5GHZ_CH(sap_config->acs_cfg. |
| 2274 | pcl_channels[0])) { |
| 2275 | sap_config->acs_cfg.band = |
| 2276 | QCA_ACS_MODE_IEEE80211A; |
| 2277 | hdd_update_acs_channel_list(sap_config, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2278 | BAND_5G); |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 2279 | } else { |
| 2280 | sap_config->acs_cfg.band = |
| 2281 | QCA_ACS_MODE_IEEE80211G; |
| 2282 | hdd_update_acs_channel_list(sap_config, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2283 | BAND_2G); |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 2284 | } |
| 2285 | } |
| 2286 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2287 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2288 | hdd_get_scan_band(hdd_ctx, &adapter->session.ap.sap_config, &band); |
Nachiket Kukade | 3208c16 | 2017-08-29 17:40:59 +0530 | [diff] [blame] | 2289 | |
| 2290 | if (sap_config->acs_cfg.ch_list) { |
| 2291 | /* Copy INI or hostapd provided ACS channel range*/ |
| 2292 | qdf_mem_copy(channel_list, sap_config->acs_cfg.ch_list, |
| 2293 | sap_config->acs_cfg.ch_list_count); |
| 2294 | channel_count = sap_config->acs_cfg.ch_list_count; |
| 2295 | } else { |
| 2296 | /* No channel list provided, copy all valid channels */ |
| 2297 | wlan_hdd_sap_get_valid_channellist(adapter, |
| 2298 | &channel_count, |
| 2299 | channel_list, |
| 2300 | band); |
| 2301 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2302 | |
Lin Bai | fac7797 | 2018-07-05 19:51:49 +0800 | [diff] [blame] | 2303 | sap_config->channel_info = qdf_mem_malloc( |
| 2304 | sizeof(struct hdd_channel_info) * |
| 2305 | channel_count); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 2306 | if (!sap_config->channel_info) |
Lin Bai | fac7797 | 2018-07-05 19:51:49 +0800 | [diff] [blame] | 2307 | return -ENOMEM; |
Lin Bai | fac7797 | 2018-07-05 19:51:49 +0800 | [diff] [blame] | 2308 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2309 | hdd_update_reg_chan_info(adapter, channel_count, channel_list); |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2310 | hdd_get_freq_list(channel_list, freq_list, channel_count); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2311 | /* Get phymode */ |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2312 | phy_mode = adapter->session.ap.sap_config.acs_cfg.hw_mode; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2313 | |
| 2314 | skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 2315 | &(adapter->wdev), |
| 2316 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2317 | QCA_NL80211_VENDOR_SUBCMD_UPDATE_EXTERNAL_ACS_CONFIG, |
| 2318 | GFP_KERNEL); |
| 2319 | |
| 2320 | if (!skb) { |
| 2321 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Lin Bai | fac7797 | 2018-07-05 19:51:49 +0800 | [diff] [blame] | 2322 | qdf_mem_free(sap_config->channel_info); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2323 | return -ENOMEM; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2324 | } |
| 2325 | /* |
| 2326 | * Application expects pcl to be a subset of channel list |
| 2327 | * Remove all channels which are not in channel list from pcl |
| 2328 | * and add weight as zero |
| 2329 | */ |
| 2330 | acs_chan_params.channel_count = channel_count; |
| 2331 | acs_chan_params.channel_list = channel_list; |
| 2332 | acs_chan_params.vendor_pcl_list = vendor_pcl_list; |
| 2333 | acs_chan_params.vendor_weight_list = vendor_weight_list; |
| 2334 | |
| 2335 | hdd_update_vendor_pcl_list(hdd_ctx, &acs_chan_params, |
| 2336 | sap_config); |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2337 | |
| 2338 | if (acs_chan_params.channel_count) { |
| 2339 | hdd_debug("ACS channel list: len: %d", |
| 2340 | acs_chan_params.channel_count); |
| 2341 | for (i = 0; i < acs_chan_params.channel_count; i++) |
| 2342 | hdd_debug("%d ", acs_chan_params.channel_list[i]); |
| 2343 | } |
| 2344 | |
| 2345 | if (acs_chan_params.pcl_count) { |
| 2346 | hdd_debug("ACS PCL list: len: %d", |
| 2347 | acs_chan_params.pcl_count); |
| 2348 | for (i = 0; i < acs_chan_params.pcl_count; i++) |
| 2349 | hdd_debug("channel:%d, weight:%d ", |
| 2350 | acs_chan_params. |
| 2351 | vendor_pcl_list[i], |
| 2352 | acs_chan_params. |
| 2353 | vendor_weight_list[i]); |
| 2354 | } |
| 2355 | |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 2356 | qdf_status = ucfg_mlme_get_external_acs_policy(hdd_ctx->psoc, |
| 2357 | &is_external_acs_policy); |
| 2358 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 2359 | hdd_err("get_external_acs_policy failed, set default"); |
| 2360 | |
| 2361 | if (is_external_acs_policy) { |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2362 | acs_policy = |
| 2363 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_POLICY_PCL_MANDATORY; |
| 2364 | } else { |
| 2365 | acs_policy = |
| 2366 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_POLICY_PCL_PREFERRED; |
| 2367 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2368 | /* Update values in NL buffer */ |
| 2369 | if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_REASON, |
| 2370 | reason) || |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2371 | nla_put_flag(skb, |
| 2372 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_IS_OFFLOAD_ENABLED) || |
| 2373 | nla_put_flag(skb, |
| 2374 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_ADD_CHAN_STATS_SUPPORT) |
| 2375 | || |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2376 | nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_CHAN_WIDTH, |
| 2377 | sap_config->acs_cfg.ch_width) || |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2378 | nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_BAND, |
| 2379 | band) || |
| 2380 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_PHY_MODE, |
| 2381 | phy_mode) || |
SaidiReddy Yenuga | e14cfb8 | 2017-05-04 18:50:37 +0530 | [diff] [blame] | 2382 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_FREQ_LIST, |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2383 | channel_count * sizeof(uint32_t), freq_list)) { |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2384 | hdd_err("nla put fail"); |
| 2385 | goto fail; |
| 2386 | } |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2387 | status = |
| 2388 | hdd_cfg80211_update_pcl(skb, |
| 2389 | acs_chan_params. |
| 2390 | pcl_count, |
| 2391 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_PCL, |
| 2392 | vendor_pcl_list, |
| 2393 | vendor_weight_list); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2394 | |
| 2395 | if (status != 0) |
| 2396 | goto fail; |
| 2397 | |
| 2398 | status = hdd_cfg80211_update_channel_info(skb, sap_config, |
| 2399 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_CHAN_INFO); |
| 2400 | |
| 2401 | if (status != 0) |
| 2402 | goto fail; |
| 2403 | |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2404 | status = nla_put_u32(skb, |
| 2405 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_POLICY, |
| 2406 | acs_policy); |
| 2407 | |
| 2408 | if (status != 0) |
| 2409 | goto fail; |
| 2410 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2411 | cfg80211_vendor_event(skb, GFP_KERNEL); |
Lin Bai | fac7797 | 2018-07-05 19:51:49 +0800 | [diff] [blame] | 2412 | qdf_mem_free(sap_config->channel_info); |
| 2413 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2414 | return 0; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2415 | fail: |
Lin Bai | fac7797 | 2018-07-05 19:51:49 +0800 | [diff] [blame] | 2416 | qdf_mem_free(sap_config->channel_info); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2417 | if (skb) |
| 2418 | kfree_skb(skb); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2419 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2420 | } |
| 2421 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2422 | /** |
| 2423 | * hdd_create_acs_timer(): Initialize vendor ACS timer |
| 2424 | * @adapter: pointer to SAP adapter struct |
| 2425 | * |
| 2426 | * This function initializes the vendor ACS timer. |
| 2427 | * |
| 2428 | * Return: Status of create vendor ACS timer |
| 2429 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 2430 | static int hdd_create_acs_timer(struct hdd_adapter *adapter) |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2431 | { |
| 2432 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2433 | QDF_STATUS status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2434 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2435 | if (adapter->session.ap.vendor_acs_timer_initialized) |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2436 | return 0; |
| 2437 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2438 | hdd_debug("Starting vendor app based ACS"); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2439 | timer_context = qdf_mem_malloc(sizeof(*timer_context)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 2440 | if (!timer_context) |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2441 | return -ENOMEM; |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 2442 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2443 | timer_context->adapter = adapter; |
| 2444 | |
| 2445 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2446 | status = qdf_mc_timer_init(&adapter->session.ap.vendor_acs_timer, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2447 | QDF_TIMER_TYPE_SW, |
| 2448 | hdd_acs_response_timeout_handler, timer_context); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2449 | if (status != QDF_STATUS_SUCCESS) { |
| 2450 | hdd_err("Failed to initialize acs response timeout timer"); |
| 2451 | return -EFAULT; |
| 2452 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2453 | adapter->session.ap.vendor_acs_timer_initialized = true; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2454 | return 0; |
| 2455 | } |
| 2456 | |
Ashish Kumar Dhanotiya | cc770eb | 2017-06-08 19:31:15 +0530 | [diff] [blame] | 2457 | static const struct nla_policy |
| 2458 | wlan_hdd_cfg80211_do_acs_policy[QCA_WLAN_VENDOR_ATTR_ACS_MAX+1] = { |
| 2459 | [QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE] = { .type = NLA_U8 }, |
| 2460 | [QCA_WLAN_VENDOR_ATTR_ACS_HT_ENABLED] = { .type = NLA_FLAG }, |
| 2461 | [QCA_WLAN_VENDOR_ATTR_ACS_HT40_ENABLED] = { .type = NLA_FLAG }, |
| 2462 | [QCA_WLAN_VENDOR_ATTR_ACS_VHT_ENABLED] = { .type = NLA_FLAG }, |
| 2463 | [QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH] = { .type = NLA_U16 }, |
| 2464 | [QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST] = { .type = NLA_UNSPEC }, |
| 2465 | [QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST] = { .type = NLA_UNSPEC }, |
| 2466 | }; |
| 2467 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2468 | int hdd_start_vendor_acs(struct hdd_adapter *adapter) |
| 2469 | { |
| 2470 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2471 | int status; |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 2472 | QDF_STATUS qdf_status; |
| 2473 | bool is_acs_support_for_dfs_ltecoex = cfg_default(CFG_USER_ACS_DFS_LTE); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2474 | |
| 2475 | status = hdd_create_acs_timer(adapter); |
| 2476 | if (status != 0) { |
| 2477 | hdd_err("failed to create acs timer"); |
| 2478 | return status; |
| 2479 | } |
| 2480 | status = hdd_update_acs_timer_reason(adapter, |
| 2481 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT); |
| 2482 | if (status != 0) { |
| 2483 | hdd_err("failed to update acs timer reason"); |
| 2484 | return status; |
| 2485 | } |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 2486 | qdf_status = ucfg_mlme_get_acs_support_for_dfs_ltecoex( |
| 2487 | hdd_ctx->psoc, |
| 2488 | &is_acs_support_for_dfs_ltecoex); |
| 2489 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 2490 | hdd_err("get_acs_support_for_dfs_ltecoex failed, set def"); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2491 | |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 2492 | if (is_acs_support_for_dfs_ltecoex) |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2493 | status = qdf_status_to_os_return(wlan_sap_set_vendor_acs( |
| 2494 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 2495 | true)); |
| 2496 | else |
| 2497 | status = qdf_status_to_os_return(wlan_sap_set_vendor_acs( |
| 2498 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 2499 | false)); |
| 2500 | |
| 2501 | return status; |
| 2502 | } |
| 2503 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2504 | /** |
Ashish Kumar Dhanotiya | cc770eb | 2017-06-08 19:31:15 +0530 | [diff] [blame] | 2505 | * __wlan_hdd_cfg80211_do_acs(): CFG80211 handler function for DO_ACS Vendor CMD |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2506 | * @wiphy: Linux wiphy struct pointer |
| 2507 | * @wdev: Linux wireless device struct pointer |
| 2508 | * @data: ACS information from hostapd |
| 2509 | * @data_len: ACS information length |
| 2510 | * |
| 2511 | * This function handle DO_ACS Vendor command from hostapd, parses ACS config |
| 2512 | * and starts ACS procedure. |
| 2513 | * |
| 2514 | * Return: ACS procedure start status |
| 2515 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2516 | static int __wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy, |
| 2517 | struct wireless_dev *wdev, |
| 2518 | const void *data, int data_len) |
| 2519 | { |
| 2520 | struct net_device *ndev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 2521 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 2522 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 2523 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2524 | struct sk_buff *temp_skbuff; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 2525 | int ret, i, ch_cnt = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2526 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ACS_MAX + 1]; |
| 2527 | bool ht_enabled, ht40_enabled, vht_enabled; |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 2528 | uint8_t ch_width; |
| 2529 | enum qca_wlan_vendor_acs_hw_mode hw_mode; |
Rachit Kankane | def2b17 | 2019-03-07 11:34:44 +0530 | [diff] [blame] | 2530 | enum policy_mgr_con_mode pm_mode; |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 2531 | QDF_STATUS qdf_status; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 2532 | bool skip_etsi13_srd_chan = false; |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 2533 | uint32_t auto_channel_select_weight = |
| 2534 | cfg_default(CFG_AUTO_CHANNEL_SELECT_WEIGHT); |
| 2535 | bool is_vendor_acs_support = |
| 2536 | cfg_default(CFG_USER_AUTO_CHANNEL_SELECTION); |
| 2537 | bool is_external_acs_policy = |
| 2538 | cfg_default(CFG_EXTERNAL_ACS_POLICY); |
Bala Venkatesh | 3d786eb | 2018-11-20 12:59:31 +0530 | [diff] [blame] | 2539 | bool sap_force_11n_for_11ac = 0; |
| 2540 | bool go_force_11n_for_11ac = 0; |
lifeng | 0b46ae5 | 2018-12-13 09:42:27 +0800 | [diff] [blame] | 2541 | bool etsi13_srd_chan; |
Sandeep Puligilla | 3461878 | 2019-01-04 17:42:42 -0800 | [diff] [blame] | 2542 | bool go_11ac_override = 0; |
| 2543 | bool sap_11ac_override = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2544 | |
| 2545 | /* ***Note*** Donot set SME config related to ACS operation here because |
| 2546 | * ACS operation is not synchronouse and ACS for Second AP may come when |
| 2547 | * ACS operation for first AP is going on. So only do_acs is split to |
Jeff Johnson | fa7d960 | 2018-05-06 11:25:31 -0700 | [diff] [blame] | 2548 | * separate start_acs routine. Also SME-PMAC struct that is used to |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2549 | * pass paremeters from HDD to SAP is global. Thus All ACS related SME |
| 2550 | * config shall be set only from start_acs. |
| 2551 | */ |
| 2552 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2553 | hdd_enter_dev(ndev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 2554 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2555 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2556 | hdd_err("Command not allowed in FTM mode"); |
| 2557 | return -EPERM; |
| 2558 | } |
| 2559 | |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2560 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2561 | if (ret) |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 2562 | return ret; |
| 2563 | |
Bala Venkatesh | 3d786eb | 2018-11-20 12:59:31 +0530 | [diff] [blame] | 2564 | ucfg_mlme_get_sap_force_11n_for_11ac(hdd_ctx->psoc, |
| 2565 | &sap_force_11n_for_11ac); |
| 2566 | ucfg_mlme_get_go_force_11n_for_11ac(hdd_ctx->psoc, |
| 2567 | &go_force_11n_for_11ac); |
| 2568 | |
Amar Singhal | f989879 | 2018-08-20 12:13:34 -0700 | [diff] [blame] | 2569 | hdd_debug("current country is %s", hdd_ctx->reg.alpha2); |
| 2570 | |
Hanumanth Reddy Pothula | 89b0dce | 2018-05-18 12:49:43 +0530 | [diff] [blame] | 2571 | if (!((adapter->device_mode == QDF_SAP_MODE) || |
| 2572 | (adapter->device_mode == QDF_P2P_GO_MODE))) { |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 2573 | hdd_err("Invalid device mode %d", adapter->device_mode); |
| 2574 | return -EINVAL; |
| 2575 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2576 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 2577 | if (cds_is_sub_20_mhz_enabled()) { |
| 2578 | hdd_err("ACS not supported in sub 20 MHz ch wd."); |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 2579 | return -EINVAL; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 2580 | } |
| 2581 | |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 2582 | if (qdf_atomic_read(&adapter->session.ap.acs_in_progress) > 0) { |
Abhinav Kumar | 5eda62d | 2018-02-13 13:00:39 +0530 | [diff] [blame] | 2583 | hdd_err("ACS rejected as previous req already in progress"); |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 2584 | return -EINVAL; |
| 2585 | } else { |
| 2586 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 1); |
Abhinav Kumar | 5eda62d | 2018-02-13 13:00:39 +0530 | [diff] [blame] | 2587 | } |
| 2588 | |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2589 | ret = wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_ACS_MAX, data, |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 2590 | data_len, |
| 2591 | wlan_hdd_cfg80211_do_acs_policy); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2592 | if (ret) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2593 | hdd_err("Invalid ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2594 | goto out; |
| 2595 | } |
| 2596 | |
| 2597 | if (!tb[QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2598 | hdd_err("Attr hw_mode failed"); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2599 | ret = -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2600 | goto out; |
| 2601 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2602 | hw_mode = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2603 | |
| 2604 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_HT_ENABLED]) |
| 2605 | ht_enabled = |
| 2606 | nla_get_flag(tb[QCA_WLAN_VENDOR_ATTR_ACS_HT_ENABLED]); |
| 2607 | else |
| 2608 | ht_enabled = 0; |
| 2609 | |
| 2610 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_HT40_ENABLED]) |
| 2611 | ht40_enabled = |
| 2612 | nla_get_flag(tb[QCA_WLAN_VENDOR_ATTR_ACS_HT40_ENABLED]); |
| 2613 | else |
| 2614 | ht40_enabled = 0; |
| 2615 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2616 | hdd_debug("ht40_enabled %d", ht40_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2617 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_VHT_ENABLED]) |
| 2618 | vht_enabled = |
| 2619 | nla_get_flag(tb[QCA_WLAN_VENDOR_ATTR_ACS_VHT_ENABLED]); |
| 2620 | else |
| 2621 | vht_enabled = 0; |
| 2622 | |
Bala Venkatesh | b9cf336 | 2017-11-09 15:48:46 +0530 | [diff] [blame] | 2623 | if (((adapter->device_mode == QDF_SAP_MODE) && |
Bala Venkatesh | 3d786eb | 2018-11-20 12:59:31 +0530 | [diff] [blame] | 2624 | sap_force_11n_for_11ac) || |
| 2625 | ((adapter->device_mode == QDF_P2P_GO_MODE) && |
| 2626 | go_force_11n_for_11ac)) { |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 2627 | vht_enabled = 0; |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 2628 | hdd_info("VHT is Disabled in ACS"); |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 2629 | } |
| 2630 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2631 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH]) { |
| 2632 | ch_width = nla_get_u16(tb[QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH]); |
| 2633 | } else { |
| 2634 | if (ht_enabled && ht40_enabled) |
| 2635 | ch_width = 40; |
| 2636 | else |
| 2637 | ch_width = 20; |
| 2638 | } |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 2639 | |
Bala Venkatesh | b9cf336 | 2017-11-09 15:48:46 +0530 | [diff] [blame] | 2640 | /* this may be possible, when sap_force_11n_for_11ac or |
| 2641 | * go_force_11n_for_11ac is set |
| 2642 | */ |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 2643 | if ((ch_width == 80 || ch_width == 160) && !vht_enabled) { |
| 2644 | if (ht_enabled && ht40_enabled) |
| 2645 | ch_width = 40; |
| 2646 | else |
| 2647 | ch_width = 20; |
| 2648 | } |
| 2649 | |
Hanumanth Reddy Pothula | 560d571 | 2018-03-15 18:11:27 +0530 | [diff] [blame] | 2650 | sap_config = &adapter->session.ap.sap_config; |
| 2651 | |
| 2652 | /* Check and free if memory is already allocated for acs channel list */ |
| 2653 | wlan_hdd_undo_acs(adapter); |
| 2654 | |
| 2655 | qdf_mem_zero(&sap_config->acs_cfg, sizeof(struct sap_acs_cfg)); |
| 2656 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2657 | hdd_debug("channel width =%d", ch_width); |
Himanshu Agarwal | 75e7441 | 2018-02-01 20:51:47 +0530 | [diff] [blame] | 2658 | if (ch_width == 160) |
| 2659 | sap_config->acs_cfg.ch_width = CH_WIDTH_160MHZ; |
| 2660 | else if (ch_width == 80) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2661 | sap_config->acs_cfg.ch_width = CH_WIDTH_80MHZ; |
| 2662 | else if (ch_width == 40) |
| 2663 | sap_config->acs_cfg.ch_width = CH_WIDTH_40MHZ; |
| 2664 | else |
| 2665 | sap_config->acs_cfg.ch_width = CH_WIDTH_20MHZ; |
| 2666 | |
| 2667 | /* hw_mode = a/b/g: QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST and |
| 2668 | * QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST attrs are present, and |
| 2669 | * QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST is used for obtaining the |
| 2670 | * channel list, QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST is ignored |
| 2671 | * since it contains the frequency values of the channels in |
| 2672 | * the channel list. |
| 2673 | * hw_mode = any: only QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST attr |
| 2674 | * is present |
| 2675 | */ |
Himanshu Agarwal | 1b3be70 | 2018-02-20 12:16:57 +0530 | [diff] [blame] | 2676 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2677 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST]) { |
| 2678 | char *tmp = nla_data(tb[QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST]); |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 2679 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2680 | sap_config->acs_cfg.ch_list_count = nla_len( |
| 2681 | tb[QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST]); |
| 2682 | if (sap_config->acs_cfg.ch_list_count) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2683 | sap_config->acs_cfg.ch_list = qdf_mem_malloc( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2684 | sizeof(uint8_t) * |
| 2685 | sap_config->acs_cfg.ch_list_count); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2686 | if (!sap_config->acs_cfg.ch_list) { |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2687 | ret = -ENOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2688 | goto out; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2689 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2690 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2691 | qdf_mem_copy(sap_config->acs_cfg.ch_list, tmp, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2692 | sap_config->acs_cfg.ch_list_count); |
| 2693 | } |
| 2694 | } else if (tb[QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST]) { |
| 2695 | uint32_t *freq = |
| 2696 | nla_data(tb[QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST]); |
| 2697 | sap_config->acs_cfg.ch_list_count = nla_len( |
| 2698 | tb[QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST]) / |
| 2699 | sizeof(uint32_t); |
| 2700 | if (sap_config->acs_cfg.ch_list_count) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2701 | sap_config->acs_cfg.ch_list = qdf_mem_malloc( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2702 | sap_config->acs_cfg.ch_list_count); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2703 | if (!sap_config->acs_cfg.ch_list) { |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2704 | ret = -ENOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2705 | goto out; |
| 2706 | } |
| 2707 | |
| 2708 | /* convert frequency to channel */ |
| 2709 | for (i = 0; i < sap_config->acs_cfg.ch_list_count; i++) |
| 2710 | sap_config->acs_cfg.ch_list[i] = |
| 2711 | ieee80211_frequency_to_channel(freq[i]); |
| 2712 | } |
| 2713 | } |
| 2714 | |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2715 | if (!sap_config->acs_cfg.ch_list_count) { |
Amar Singhal | 5f78313 | 2018-03-29 13:58:50 -0700 | [diff] [blame] | 2716 | hdd_err("acs config chan count 0"); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2717 | ret = -EINVAL; |
| 2718 | goto out; |
| 2719 | } |
| 2720 | |
lifeng | 0b46ae5 | 2018-12-13 09:42:27 +0800 | [diff] [blame] | 2721 | ucfg_mlme_get_etsi13_srd_chan_in_master_mode(hdd_ctx->psoc, |
| 2722 | &etsi13_srd_chan); |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 2723 | skip_etsi13_srd_chan = |
lifeng | 0b46ae5 | 2018-12-13 09:42:27 +0800 | [diff] [blame] | 2724 | !etsi13_srd_chan && |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2725 | wlan_reg_is_etsi13_regdmn(hdd_ctx->pdev); |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 2726 | |
| 2727 | if (skip_etsi13_srd_chan) { |
| 2728 | for (i = 0; i < sap_config->acs_cfg.ch_list_count; i++) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2729 | if (wlan_reg_is_etsi13_srd_chan(hdd_ctx->pdev, |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 2730 | sap_config->acs_cfg. |
| 2731 | ch_list[i])) |
| 2732 | sap_config->acs_cfg.ch_list[i] = 0; |
| 2733 | else |
| 2734 | sap_config->acs_cfg.ch_list[ch_cnt++] = |
| 2735 | sap_config->acs_cfg.ch_list[i]; |
| 2736 | } |
| 2737 | sap_config->acs_cfg.ch_list_count = ch_cnt; |
| 2738 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2739 | hdd_debug("get pcl for DO_ACS vendor command"); |
| 2740 | |
Rachit Kankane | def2b17 | 2019-03-07 11:34:44 +0530 | [diff] [blame] | 2741 | pm_mode = |
| 2742 | policy_mgr_convert_device_mode_to_qdf_type(adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2743 | /* consult policy manager to get PCL */ |
Rachit Kankane | def2b17 | 2019-03-07 11:34:44 +0530 | [diff] [blame] | 2744 | qdf_status = policy_mgr_get_pcl(hdd_ctx->psoc, pm_mode, |
| 2745 | sap_config->acs_cfg.pcl_channels, |
| 2746 | &sap_config->acs_cfg.pcl_ch_count, |
| 2747 | sap_config->acs_cfg. |
| 2748 | pcl_channels_weight_list, |
| 2749 | QDF_MAX_NUM_CHAN); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2750 | if (qdf_status != QDF_STATUS_SUCCESS) |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2751 | hdd_err("Get PCL failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2752 | |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2753 | if (sap_config->acs_cfg.pcl_ch_count) { |
| 2754 | hdd_debug("ACS config PCL: len: %d", |
| 2755 | sap_config->acs_cfg.pcl_ch_count); |
| 2756 | for (i = 0; i < sap_config->acs_cfg.pcl_ch_count; i++) |
| 2757 | hdd_debug("channel:%d, weight:%d ", |
| 2758 | sap_config->acs_cfg. |
| 2759 | pcl_channels[i], |
| 2760 | sap_config->acs_cfg. |
| 2761 | pcl_channels_weight_list[i]); |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 2762 | } |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2763 | sap_config->acs_cfg.band = hw_mode; |
Rachit Kankane | def2b17 | 2019-03-07 11:34:44 +0530 | [diff] [blame] | 2764 | |
| 2765 | qdf_status = ucfg_mlme_get_external_acs_policy(hdd_ctx->psoc, |
| 2766 | &is_external_acs_policy); |
| 2767 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 2768 | hdd_err("get_external_acs_policy failed"); |
| 2769 | |
| 2770 | if (is_external_acs_policy && |
| 2771 | policy_mgr_is_force_scc(hdd_ctx->psoc) && |
| 2772 | policy_mgr_get_connection_count(hdd_ctx->psoc)) { |
| 2773 | policy_mgr_trim_acs_channel_list( |
| 2774 | sap_config->acs_cfg.pcl_channels, |
| 2775 | sap_config->acs_cfg.pcl_ch_count, |
| 2776 | sap_config->acs_cfg.ch_list, |
| 2777 | &sap_config->acs_cfg.ch_list_count); |
| 2778 | |
| 2779 | /* if it is only one channel, send ACS event to upper layer */ |
| 2780 | if (sap_config->acs_cfg.ch_list_count == 1) { |
| 2781 | sap_config->acs_cfg.pri_ch = |
| 2782 | sap_config->acs_cfg.ch_list[0]; |
| 2783 | wlan_sap_set_sap_ctx_acs_cfg( |
| 2784 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), sap_config); |
| 2785 | sap_config_acs_result(hdd_ctx->mac_handle, |
| 2786 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 2787 | sap_config->acs_cfg.ht_sec_ch); |
| 2788 | sap_config->ch_params.ch_width = |
| 2789 | sap_config->acs_cfg.ch_width; |
| 2790 | sap_config->ch_params.sec_ch_offset = |
| 2791 | sap_config->acs_cfg.ht_sec_ch; |
| 2792 | sap_config->ch_params.center_freq_seg0 = |
| 2793 | sap_config->acs_cfg.vht_seg0_center_ch; |
| 2794 | sap_config->ch_params.center_freq_seg1 = |
| 2795 | sap_config->acs_cfg.vht_seg1_center_ch; |
| 2796 | /*notify hostapd about channel override */ |
| 2797 | wlan_hdd_cfg80211_acs_ch_select_evt(adapter); |
| 2798 | ret = 0; |
| 2799 | goto out; |
| 2800 | } |
| 2801 | } |
| 2802 | |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2803 | ret = wlan_hdd_set_acs_ch_range(sap_config, hw_mode, |
Himanshu Agarwal | 8b3d3e9 | 2018-02-08 23:03:54 +0530 | [diff] [blame] | 2804 | ht_enabled, vht_enabled); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2805 | if (ret) { |
Himanshu Agarwal | 8b3d3e9 | 2018-02-08 23:03:54 +0530 | [diff] [blame] | 2806 | hdd_err("set acs channel range failed"); |
| 2807 | goto out; |
| 2808 | } |
| 2809 | |
Sandeep Puligilla | 3461878 | 2019-01-04 17:42:42 -0800 | [diff] [blame] | 2810 | ucfg_mlme_is_go_11ac_override(hdd_ctx->psoc, &go_11ac_override); |
| 2811 | ucfg_mlme_is_sap_11ac_override(hdd_ctx->psoc, &sap_11ac_override); |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 2812 | /* ACS override for android */ |
Himanshu Agarwal | 4ecf6ca | 2018-05-09 16:48:56 +0530 | [diff] [blame] | 2813 | if (ht_enabled && |
Himanshu Agarwal | 8b3d3e9 | 2018-02-08 23:03:54 +0530 | [diff] [blame] | 2814 | sap_config->acs_cfg.end_ch >= WLAN_REG_CH_NUM(CHAN_ENUM_36) && |
Himanshu Agarwal | 4ecf6ca | 2018-05-09 16:48:56 +0530 | [diff] [blame] | 2815 | ((adapter->device_mode == QDF_SAP_MODE && |
Bala Venkatesh | 3d786eb | 2018-11-20 12:59:31 +0530 | [diff] [blame] | 2816 | !sap_force_11n_for_11ac && |
Sandeep Puligilla | 3461878 | 2019-01-04 17:42:42 -0800 | [diff] [blame] | 2817 | sap_11ac_override) || |
Himanshu Agarwal | 4ecf6ca | 2018-05-09 16:48:56 +0530 | [diff] [blame] | 2818 | (adapter->device_mode == QDF_P2P_GO_MODE && |
Bala Venkatesh | 3d786eb | 2018-11-20 12:59:31 +0530 | [diff] [blame] | 2819 | !go_force_11n_for_11ac && |
Sandeep Puligilla | 3461878 | 2019-01-04 17:42:42 -0800 | [diff] [blame] | 2820 | go_11ac_override))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2821 | vht_enabled = 1; |
| 2822 | sap_config->acs_cfg.hw_mode = eCSR_DOT11_MODE_11ac; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2823 | qdf_status = |
| 2824 | ucfg_mlme_get_vht_channel_width(hdd_ctx->psoc, |
| 2825 | &ch_width); |
| 2826 | sap_config->acs_cfg.ch_width = ch_width; |
Himanshu Agarwal | 29a9a3e | 2018-02-21 17:44:37 +0530 | [diff] [blame] | 2827 | } |
| 2828 | |
| 2829 | /* No VHT80 in 2.4G so perform ACS accordingly */ |
| 2830 | if (sap_config->acs_cfg.end_ch <= 14 && |
| 2831 | sap_config->acs_cfg.ch_width == eHT_CHANNEL_WIDTH_80MHZ) { |
| 2832 | sap_config->acs_cfg.ch_width = eHT_CHANNEL_WIDTH_40MHZ; |
| 2833 | hdd_debug("resetting to 40Mhz in 2.4Ghz"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2834 | } |
| 2835 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2836 | hdd_debug("ACS Config for %s: HW_MODE: %d ACS_BW: %d HT: %d VHT: %d START_CH: %d END_CH: %d band %d", |
| 2837 | adapter->dev->name, sap_config->acs_cfg.hw_mode, |
Himanshu Agarwal | 1ed8bff | 2018-02-07 12:50:41 +0530 | [diff] [blame] | 2838 | sap_config->acs_cfg.ch_width, ht_enabled, vht_enabled, |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2839 | sap_config->acs_cfg.start_ch, sap_config->acs_cfg.end_ch, |
| 2840 | sap_config->acs_cfg.band); |
wadesong | cb0ded2 | 2018-02-02 17:57:20 +0800 | [diff] [blame] | 2841 | host_log_acs_req_event(adapter->dev->name, |
| 2842 | csr_phy_mode_str(sap_config->acs_cfg.hw_mode), |
| 2843 | ch_width, ht_enabled, vht_enabled, |
| 2844 | sap_config->acs_cfg.start_ch, |
| 2845 | sap_config->acs_cfg.end_ch); |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 2846 | |
| 2847 | qdf_status = |
| 2848 | ucfg_mlme_get_auto_channel_weight(hdd_ctx->psoc, |
| 2849 | &auto_channel_select_weight); |
| 2850 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 2851 | hdd_err("get_auto_channel_weight failed"); |
| 2852 | |
| 2853 | if (auto_channel_select_weight) |
gaolez | e510894 | 2017-03-31 16:56:42 +0800 | [diff] [blame] | 2854 | sap_config->auto_channel_select_weight = |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 2855 | auto_channel_select_weight; |
gaolez | e510894 | 2017-03-31 16:56:42 +0800 | [diff] [blame] | 2856 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2857 | sap_config->acs_cfg.is_ht_enabled = ht_enabled; |
| 2858 | sap_config->acs_cfg.is_vht_enabled = vht_enabled; |
| 2859 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2860 | if (sap_config->acs_cfg.ch_list_count) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 2861 | hdd_debug("ACS channel list: len: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2862 | sap_config->acs_cfg.ch_list_count); |
| 2863 | for (i = 0; i < sap_config->acs_cfg.ch_list_count; i++) |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 2864 | hdd_debug("%d ", sap_config->acs_cfg.ch_list[i]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2865 | } |
Himanshu Agarwal | 3316398 | 2018-05-17 18:11:10 +0530 | [diff] [blame] | 2866 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2867 | sap_config->acs_cfg.acs_mode = true; |
| 2868 | if (test_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2869 | /* ***Note*** Completion variable usage is not allowed |
| 2870 | * here since ACS scan operation may take max 2.2 sec |
| 2871 | * for 5G band: |
| 2872 | * 9 Active channel X 40 ms active scan time + |
| 2873 | * 16 Passive channel X 110ms passive scan time |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2874 | * Since this CFG80211 call lock rtnl mutex, we cannot hold on |
| 2875 | * for this long. So we split up the scanning part. |
| 2876 | */ |
| 2877 | set_bit(ACS_PENDING, &adapter->event_flags); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 2878 | hdd_debug("ACS Pending for %s", adapter->dev->name); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2879 | ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2880 | } else { |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 2881 | qdf_status = |
| 2882 | ucfg_mlme_get_vendor_acs_support( |
| 2883 | hdd_ctx->psoc, |
| 2884 | &is_vendor_acs_support); |
| 2885 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 2886 | hdd_err("get_vendor_acs_support failed, set default"); |
| 2887 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2888 | /* Check if vendor specific acs is enabled */ |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 2889 | if (is_vendor_acs_support) |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2890 | ret = hdd_start_vendor_acs(adapter); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2891 | else |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2892 | ret = wlan_hdd_cfg80211_start_acs(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2893 | } |
| 2894 | |
| 2895 | out: |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2896 | if (ret == 0) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2897 | temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 2898 | NLMSG_HDRLEN); |
| 2899 | if (temp_skbuff != NULL) |
| 2900 | return cfg80211_vendor_cmd_reply(temp_skbuff); |
| 2901 | } |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 2902 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 2903 | wlan_hdd_undo_acs(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2904 | clear_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags); |
| 2905 | |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2906 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2907 | } |
| 2908 | |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 2909 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2910 | * wlan_hdd_cfg80211_do_acs : CFG80211 handler function for DO_ACS Vendor CMD |
| 2911 | * @wiphy: Linux wiphy struct pointer |
| 2912 | * @wdev: Linux wireless device struct pointer |
| 2913 | * @data: ACS information from hostapd |
| 2914 | * @data_len: ACS information len |
| 2915 | * |
| 2916 | * This function handle DO_ACS Vendor command from hostapd, parses ACS config |
| 2917 | * and starts ACS procedure. |
| 2918 | * |
| 2919 | * Return: ACS procedure start status |
| 2920 | */ |
| 2921 | |
| 2922 | static int wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy, |
| 2923 | struct wireless_dev *wdev, |
| 2924 | const void *data, int data_len) |
| 2925 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 2926 | int errno; |
| 2927 | struct osif_vdev_sync *vdev_sync; |
| 2928 | |
| 2929 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 2930 | if (errno) |
| 2931 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2932 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 2933 | errno = __wlan_hdd_cfg80211_do_acs(wiphy, wdev, data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2934 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 2935 | osif_vdev_sync_op_stop(vdev_sync); |
| 2936 | |
| 2937 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2938 | } |
| 2939 | |
| 2940 | /** |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 2941 | * wlan_hdd_undo_acs : Do cleanup of DO_ACS |
| 2942 | * @adapter: Pointer to adapter struct |
| 2943 | * |
| 2944 | * This function handle cleanup of what was done in DO_ACS, including free |
| 2945 | * memory. |
| 2946 | * |
| 2947 | * Return: void |
| 2948 | */ |
| 2949 | |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 2950 | void wlan_hdd_undo_acs(struct hdd_adapter *adapter) |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 2951 | { |
| 2952 | if (adapter == NULL) |
| 2953 | return; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2954 | if (adapter->session.ap.sap_config.acs_cfg.ch_list) { |
| 2955 | qdf_mem_free(adapter->session.ap.sap_config.acs_cfg.ch_list); |
| 2956 | adapter->session.ap.sap_config.acs_cfg.ch_list = NULL; |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 2957 | } |
| 2958 | } |
| 2959 | |
| 2960 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2961 | * wlan_hdd_cfg80211_start_pending_acs : Start pending ACS procedure for SAP |
| 2962 | * @work: Linux workqueue struct pointer for ACS work |
| 2963 | * |
| 2964 | * This function starts the ACS procedure which was marked pending when an ACS |
| 2965 | * procedure was in progress for a concurrent SAP interface. |
| 2966 | * |
| 2967 | * Return: None |
| 2968 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2969 | static void wlan_hdd_cfg80211_start_pending_acs(struct work_struct *work) |
| 2970 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 2971 | struct hdd_adapter *adapter = container_of(work, struct hdd_adapter, |
Jeff Johnson | 3aa54d4 | 2018-06-26 11:36:50 -0700 | [diff] [blame] | 2972 | acs_pending_work.work); |
Dustin Brown | 4376fed | 2019-03-06 11:00:38 -0800 | [diff] [blame] | 2973 | struct osif_vdev_sync *vdev_sync; |
Jeff Johnson | 3aa54d4 | 2018-06-26 11:36:50 -0700 | [diff] [blame] | 2974 | |
Dustin Brown | 4376fed | 2019-03-06 11:00:38 -0800 | [diff] [blame] | 2975 | if (osif_vdev_sync_op_start(adapter->dev, &vdev_sync)) |
| 2976 | return; |
| 2977 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2978 | wlan_hdd_cfg80211_start_acs(adapter); |
Will Huang | 7049bae | 2018-08-13 17:25:02 +0800 | [diff] [blame] | 2979 | clear_bit(ACS_PENDING, &adapter->event_flags); |
Dustin Brown | 4376fed | 2019-03-06 11:00:38 -0800 | [diff] [blame] | 2980 | |
| 2981 | osif_vdev_sync_op_stop(vdev_sync); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2982 | } |
| 2983 | |
| 2984 | /** |
| 2985 | * wlan_hdd_cfg80211_acs_ch_select_evt: Callback function for ACS evt |
| 2986 | * @adapter: Pointer to SAP adapter struct |
| 2987 | * @pri_channel: SAP ACS procedure selected Primary channel |
| 2988 | * @sec_channel: SAP ACS procedure selected secondary channel |
| 2989 | * |
| 2990 | * This is a callback function from SAP module on ACS procedure is completed. |
| 2991 | * This function send the ACS selected channel information to hostapd |
| 2992 | * |
| 2993 | * Return: None |
| 2994 | */ |
| 2995 | |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 2996 | void wlan_hdd_cfg80211_acs_ch_select_evt(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2997 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 2998 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 2999 | tsap_config_t *sap_cfg = &(WLAN_HDD_GET_AP_CTX_PTR(adapter))->sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3000 | struct sk_buff *vendor_event; |
| 3001 | int ret_val; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 3002 | struct hdd_adapter *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3003 | uint16_t ch_width; |
| 3004 | |
| 3005 | vendor_event = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Ryan Hsu | 9206a4e | 2016-01-19 17:23:13 -0800 | [diff] [blame] | 3006 | &(adapter->wdev), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3007 | 4 * sizeof(u8) + 1 * sizeof(u16) + 4 + NLMSG_HDRLEN, |
| 3008 | QCA_NL80211_VENDOR_SUBCMD_DO_ACS_INDEX, |
| 3009 | GFP_KERNEL); |
| 3010 | |
| 3011 | if (!vendor_event) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 3012 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3013 | return; |
| 3014 | } |
| 3015 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3016 | ret_val = nla_put_u8(vendor_event, |
| 3017 | QCA_WLAN_VENDOR_ATTR_ACS_PRIMARY_CHANNEL, |
| 3018 | sap_cfg->acs_cfg.pri_ch); |
| 3019 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 3020 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_PRIMARY_CHANNEL put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3021 | kfree_skb(vendor_event); |
| 3022 | return; |
| 3023 | } |
| 3024 | |
| 3025 | ret_val = nla_put_u8(vendor_event, |
| 3026 | QCA_WLAN_VENDOR_ATTR_ACS_SECONDARY_CHANNEL, |
| 3027 | sap_cfg->acs_cfg.ht_sec_ch); |
| 3028 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 3029 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_SECONDARY_CHANNEL put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3030 | kfree_skb(vendor_event); |
| 3031 | return; |
| 3032 | } |
| 3033 | |
| 3034 | ret_val = nla_put_u8(vendor_event, |
| 3035 | QCA_WLAN_VENDOR_ATTR_ACS_VHT_SEG0_CENTER_CHANNEL, |
| 3036 | sap_cfg->acs_cfg.vht_seg0_center_ch); |
| 3037 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 3038 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_VHT_SEG0_CENTER_CHANNEL put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3039 | kfree_skb(vendor_event); |
| 3040 | return; |
| 3041 | } |
| 3042 | |
| 3043 | ret_val = nla_put_u8(vendor_event, |
| 3044 | QCA_WLAN_VENDOR_ATTR_ACS_VHT_SEG1_CENTER_CHANNEL, |
| 3045 | sap_cfg->acs_cfg.vht_seg1_center_ch); |
| 3046 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 3047 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_VHT_SEG1_CENTER_CHANNEL put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3048 | kfree_skb(vendor_event); |
| 3049 | return; |
| 3050 | } |
| 3051 | |
Himanshu Agarwal | 75e7441 | 2018-02-01 20:51:47 +0530 | [diff] [blame] | 3052 | if (sap_cfg->acs_cfg.ch_width == CH_WIDTH_160MHZ) |
| 3053 | ch_width = 160; |
| 3054 | else if (sap_cfg->acs_cfg.ch_width == CH_WIDTH_80MHZ) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3055 | ch_width = 80; |
| 3056 | else if (sap_cfg->acs_cfg.ch_width == CH_WIDTH_40MHZ) |
| 3057 | ch_width = 40; |
| 3058 | else |
| 3059 | ch_width = 20; |
| 3060 | |
| 3061 | ret_val = nla_put_u16(vendor_event, |
| 3062 | QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH, |
| 3063 | ch_width); |
| 3064 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 3065 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3066 | kfree_skb(vendor_event); |
| 3067 | return; |
| 3068 | } |
| 3069 | if (sap_cfg->acs_cfg.pri_ch > 14) |
| 3070 | ret_val = nla_put_u8(vendor_event, |
| 3071 | QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE, |
| 3072 | QCA_ACS_MODE_IEEE80211A); |
| 3073 | else |
| 3074 | ret_val = nla_put_u8(vendor_event, |
| 3075 | QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE, |
| 3076 | QCA_ACS_MODE_IEEE80211G); |
| 3077 | |
| 3078 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 3079 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3080 | kfree_skb(vendor_event); |
| 3081 | return; |
| 3082 | } |
| 3083 | |
Mahesh Kumar Kalikot Veetil | ec1da14 | 2017-09-20 10:01:13 -0700 | [diff] [blame] | 3084 | hdd_debug("ACS result for %s: PRI_CH: %d SEC_CH: %d VHT_SEG0: %d VHT_SEG1: %d ACS_BW: %d", |
| 3085 | adapter->dev->name, sap_cfg->acs_cfg.pri_ch, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3086 | sap_cfg->acs_cfg.ht_sec_ch, sap_cfg->acs_cfg.vht_seg0_center_ch, |
| 3087 | sap_cfg->acs_cfg.vht_seg1_center_ch, ch_width); |
| 3088 | |
| 3089 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 3090 | /* ***Note*** As already mentioned Completion variable usage is not |
| 3091 | * allowed here since ACS scan operation may take max 2.2 sec. |
| 3092 | * Further in AP-AP mode pending ACS is resumed here to serailize ACS |
| 3093 | * operation. |
| 3094 | * TODO: Delayed operation is used since SME-PMAC strut is global. Thus |
| 3095 | * when Primary AP ACS is complete and secondary AP ACS is started here |
| 3096 | * immediately, Primary AP start_bss may come inbetween ACS operation |
Jeff Johnson | 60ed45a | 2018-05-06 15:28:49 -0700 | [diff] [blame] | 3097 | * and overwrite Sec AP ACS parameters. Thus Sec AP ACS is executed with |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3098 | * delay. This path and below constraint will be removed on sessionizing |
| 3099 | * SAP acs parameters and decoupling SAP from PMAC (WIP). |
| 3100 | * As per design constraint user space control application must take |
| 3101 | * care of serailizing hostapd start for each VIF in AP-AP mode to avoid |
| 3102 | * this code path. Sec AP hostapd should be started after Primary AP |
| 3103 | * start beaconing which can be confirmed by getchannel iwpriv command |
| 3104 | */ |
| 3105 | |
| 3106 | con_sap_adapter = hdd_get_con_sap_adapter(adapter, false); |
| 3107 | if (con_sap_adapter && |
| 3108 | test_bit(ACS_PENDING, &con_sap_adapter->event_flags)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3109 | INIT_DELAYED_WORK(&con_sap_adapter->acs_pending_work, |
| 3110 | wlan_hdd_cfg80211_start_pending_acs); |
hqu | 71a1a3b | 2018-01-23 15:38:13 +0800 | [diff] [blame] | 3111 | /* Lets give 1500ms for OBSS + START_BSS to complete */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3112 | schedule_delayed_work(&con_sap_adapter->acs_pending_work, |
hqu | 71a1a3b | 2018-01-23 15:38:13 +0800 | [diff] [blame] | 3113 | msecs_to_jiffies(1500)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3114 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3115 | } |
| 3116 | |
Sourav Mohapatra | c457ae6 | 2018-12-06 15:19:41 +0530 | [diff] [blame] | 3117 | /** |
| 3118 | * hdd_is_wlm_latency_manager_supported - Checks if WLM Latency manager is |
| 3119 | * supported |
| 3120 | * @hdd_ctx: The HDD context |
| 3121 | * |
| 3122 | * Return: True if supported, false otherwise |
| 3123 | */ |
| 3124 | static inline |
| 3125 | bool hdd_is_wlm_latency_manager_supported(struct hdd_context *hdd_ctx) |
| 3126 | { |
| 3127 | bool latency_enable; |
| 3128 | |
| 3129 | if (QDF_IS_STATUS_ERROR(ucfg_mlme_get_latency_enable |
| 3130 | (hdd_ctx->psoc, &latency_enable))) |
| 3131 | return false; |
| 3132 | |
| 3133 | if (latency_enable && |
| 3134 | sme_is_feature_supported_by_fw(VDEV_LATENCY_CONFIG)) |
| 3135 | return true; |
| 3136 | else |
| 3137 | return false; |
| 3138 | } |
| 3139 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3140 | static int |
| 3141 | __wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy, |
| 3142 | struct wireless_dev *wdev, |
| 3143 | const void *data, |
| 3144 | int data_len) |
| 3145 | { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3146 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3147 | struct sk_buff *skb = NULL; |
| 3148 | uint32_t fset = 0; |
| 3149 | int ret; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 3150 | #ifdef FEATURE_WLAN_TDLS |
| 3151 | bool bvalue; |
| 3152 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3153 | |
Srinivas Girigowda | dbfb264 | 2016-08-28 21:32:38 -0700 | [diff] [blame] | 3154 | /* ENTER_DEV() intentionally not used in a frequently invoked API */ |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3155 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3156 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3157 | hdd_err("Command not allowed in FTM mode"); |
| 3158 | return -EPERM; |
| 3159 | } |
| 3160 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3161 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3162 | if (ret) |
| 3163 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3164 | |
| 3165 | if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3166 | hdd_debug("Infra Station mode is supported by driver"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3167 | fset |= WIFI_FEATURE_INFRA; |
| 3168 | } |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3169 | if (true == hdd_is_5g_supported(hdd_ctx)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3170 | hdd_debug("INFRA_5G is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3171 | fset |= WIFI_FEATURE_INFRA_5G; |
| 3172 | } |
| 3173 | #ifdef WLAN_FEATURE_P2P |
| 3174 | if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) && |
| 3175 | (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3176 | hdd_debug("WiFi-Direct is supported by driver"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3177 | fset |= WIFI_FEATURE_P2P; |
| 3178 | } |
| 3179 | #endif |
| 3180 | fset |= WIFI_FEATURE_SOFT_AP; |
| 3181 | |
| 3182 | /* HOTSPOT is a supplicant feature, enable it by default */ |
| 3183 | fset |= WIFI_FEATURE_HOTSPOT; |
| 3184 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 3185 | if (ucfg_extscan_get_enable(hdd_ctx->psoc) && |
Manjeet Singh | 0f2ce5c | 2016-09-01 12:08:57 +0530 | [diff] [blame] | 3186 | sme_is_feature_supported_by_fw(EXTENDED_SCAN)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3187 | hdd_debug("EXTScan is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3188 | fset |= WIFI_FEATURE_EXTSCAN | WIFI_FEATURE_HAL_EPNO; |
| 3189 | } |
Nachiket Kukade | 989bb35 | 2018-07-31 18:01:17 +0530 | [diff] [blame] | 3190 | if (wlan_hdd_nan_is_supported(hdd_ctx)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3191 | hdd_debug("NAN is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3192 | fset |= WIFI_FEATURE_NAN; |
| 3193 | } |
Sourav Mohapatra | 9e014cf | 2018-12-11 09:39:33 +0530 | [diff] [blame] | 3194 | if (sme_is_feature_supported_by_fw(RTT) && |
| 3195 | hdd_ctx->config->enable_rtt_support) { |
| 3196 | hdd_debug("RTT is supported by firmware and framework"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3197 | fset |= WIFI_FEATURE_D2D_RTT; |
| 3198 | fset |= WIFI_FEATURE_D2AP_RTT; |
| 3199 | } |
| 3200 | #ifdef FEATURE_WLAN_SCAN_PNO |
Pragaspathi Thilagaraj | 24789d3 | 2018-12-10 22:28:03 +0530 | [diff] [blame] | 3201 | if (ucfg_scan_get_pno_scan_support(hdd_ctx->psoc) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3202 | sme_is_feature_supported_by_fw(PNO)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3203 | hdd_debug("PNO is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3204 | fset |= WIFI_FEATURE_PNO; |
| 3205 | } |
| 3206 | #endif |
| 3207 | fset |= WIFI_FEATURE_ADDITIONAL_STA; |
| 3208 | #ifdef FEATURE_WLAN_TDLS |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 3209 | cfg_tdls_get_support_enable(hdd_ctx->psoc, &bvalue); |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 3210 | if ((bvalue) && sme_is_feature_supported_by_fw(TDLS)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3211 | hdd_debug("TDLS is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3212 | fset |= WIFI_FEATURE_TDLS; |
| 3213 | } |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 3214 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 3215 | cfg_tdls_get_off_channel_enable(hdd_ctx->psoc, &bvalue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3216 | if (sme_is_feature_supported_by_fw(TDLS) && |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 3217 | bvalue && sme_is_feature_supported_by_fw(TDLS_OFF_CHANNEL)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3218 | hdd_debug("TDLS off-channel is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3219 | fset |= WIFI_FEATURE_TDLS_OFFCHANNEL; |
| 3220 | } |
| 3221 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3222 | fset |= WIFI_FEATURE_AP_STA; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3223 | fset |= WIFI_FEATURE_RSSI_MONITOR; |
Srinivas Girigowda | a2cad3e | 2016-10-25 14:14:23 -0700 | [diff] [blame] | 3224 | fset |= WIFI_FEATURE_TX_TRANSMIT_POWER; |
Srinivas Girigowda | 5a1da62 | 2017-07-12 17:07:44 -0700 | [diff] [blame] | 3225 | fset |= WIFI_FEATURE_SET_TX_POWER_LIMIT; |
Sourav Mohapatra | 804359e | 2017-12-07 13:52:05 +0530 | [diff] [blame] | 3226 | fset |= WIFI_FEATURE_CONFIG_NDO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3227 | |
| 3228 | if (hdd_link_layer_stats_supported()) |
| 3229 | fset |= WIFI_FEATURE_LINK_LAYER_STATS; |
| 3230 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3231 | if (hdd_roaming_supported(hdd_ctx)) |
Srinivas Girigowda | 8df27ea | 2017-01-06 12:42:16 -0800 | [diff] [blame] | 3232 | fset |= WIFI_FEATURE_CONTROL_ROAMING; |
| 3233 | |
| 3234 | if (hdd_scan_random_mac_addr_supported()) |
| 3235 | fset |= WIFI_FEATURE_SCAN_RAND; |
| 3236 | |
Sourav Mohapatra | c457ae6 | 2018-12-06 15:19:41 +0530 | [diff] [blame] | 3237 | if (hdd_is_wlm_latency_manager_supported(hdd_ctx)) |
| 3238 | fset |= WIFI_FEATURE_SET_LATENCY_MODE; |
| 3239 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3240 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) + |
| 3241 | NLMSG_HDRLEN); |
| 3242 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3243 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3244 | return -EINVAL; |
| 3245 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3246 | hdd_debug("Supported Features : 0x%x", fset); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3247 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3248 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3249 | goto nla_put_failure; |
| 3250 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3251 | ret = cfg80211_vendor_cmd_reply(skb); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3252 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3253 | nla_put_failure: |
| 3254 | kfree_skb(skb); |
| 3255 | return -EINVAL; |
| 3256 | } |
| 3257 | |
| 3258 | /** |
| 3259 | * wlan_hdd_cfg80211_get_supported_features() - get supported features |
| 3260 | * @wiphy: pointer to wireless wiphy structure. |
| 3261 | * @wdev: pointer to wireless_dev structure. |
| 3262 | * @data: Pointer to the data to be passed via vendor interface |
| 3263 | * @data_len:Length of the data to be passed |
| 3264 | * |
| 3265 | * Return: Return the Success or Failure code. |
| 3266 | */ |
| 3267 | static int |
| 3268 | wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy, |
| 3269 | struct wireless_dev *wdev, |
| 3270 | const void *data, int data_len) |
| 3271 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 3272 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 3273 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 3274 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 3275 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 3276 | if (errno) |
| 3277 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3278 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 3279 | errno = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, |
| 3280 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3281 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 3282 | osif_psoc_sync_op_stop(psoc_sync); |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 3283 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 3284 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3285 | } |
| 3286 | |
| 3287 | /** |
| 3288 | * __wlan_hdd_cfg80211_set_scanning_mac_oui() - set scan MAC |
| 3289 | * @wiphy: pointer to wireless wiphy structure. |
| 3290 | * @wdev: pointer to wireless_dev structure. |
| 3291 | * @data: Pointer to the data to be passed via vendor interface |
| 3292 | * @data_len:Length of the data to be passed |
| 3293 | * |
| 3294 | * Set the MAC address that is to be used for scanning. |
| 3295 | * |
| 3296 | * Return: Return the Success or Failure code. |
| 3297 | */ |
| 3298 | static int |
| 3299 | __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy, |
| 3300 | struct wireless_dev *wdev, |
| 3301 | const void *data, |
| 3302 | int data_len) |
| 3303 | { |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3304 | struct scan_mac_oui scan_mac_oui = { {0} }; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3305 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3306 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1]; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3307 | QDF_STATUS status; |
Pragaspathi Thilagaraj | f37f393 | 2019-01-11 00:25:43 +0530 | [diff] [blame] | 3308 | int ret, len; |
Rajeev Kumar Sirasanagandla | 686abd9 | 2017-06-08 18:09:01 +0530 | [diff] [blame] | 3309 | struct net_device *ndev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 3310 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3311 | mac_handle_t mac_handle; |
Pragaspathi Thilagaraj | f37f393 | 2019-01-11 00:25:43 +0530 | [diff] [blame] | 3312 | bool mac_spoofing_enabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3313 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3314 | hdd_enter_dev(wdev->netdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3315 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3316 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3317 | hdd_err("Command not allowed in FTM mode"); |
| 3318 | return -EPERM; |
| 3319 | } |
| 3320 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3321 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3322 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3323 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3324 | |
Pragaspathi Thilagaraj | f37f393 | 2019-01-11 00:25:43 +0530 | [diff] [blame] | 3325 | mac_spoofing_enabled = ucfg_scan_is_mac_spoofing_enabled(hdd_ctx->psoc); |
| 3326 | if (!mac_spoofing_enabled) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 3327 | hdd_debug("MAC address spoofing is not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3328 | return -ENOTSUPP; |
| 3329 | } |
| 3330 | |
Jeff Johnson | 63d1ac8 | 2017-06-01 09:06:48 -0700 | [diff] [blame] | 3331 | /* |
| 3332 | * audit note: it is ok to pass a NULL policy here since only |
| 3333 | * one attribute is parsed and it is explicitly validated |
| 3334 | */ |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3335 | if (wlan_cfg80211_nla_parse(tb, |
| 3336 | QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX, |
| 3337 | data, data_len, NULL)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3338 | hdd_err("Invalid ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3339 | return -EINVAL; |
| 3340 | } |
Jeff Johnson | 63d1ac8 | 2017-06-01 09:06:48 -0700 | [diff] [blame] | 3341 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3342 | if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3343 | hdd_err("attr mac oui failed"); |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3344 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3345 | } |
Jeff Johnson | 63d1ac8 | 2017-06-01 09:06:48 -0700 | [diff] [blame] | 3346 | |
| 3347 | len = nla_len(tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]); |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3348 | if (len != sizeof(scan_mac_oui.oui)) { |
Jeff Johnson | 63d1ac8 | 2017-06-01 09:06:48 -0700 | [diff] [blame] | 3349 | hdd_err("attr mac oui invalid size %d expected %zu", |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3350 | len, sizeof(scan_mac_oui.oui)); |
| 3351 | return -EINVAL; |
Jeff Johnson | 63d1ac8 | 2017-06-01 09:06:48 -0700 | [diff] [blame] | 3352 | } |
| 3353 | |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3354 | nla_memcpy(scan_mac_oui.oui, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3355 | tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI], |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3356 | sizeof(scan_mac_oui.oui)); |
Rajeev Kumar Sirasanagandla | 686abd9 | 2017-06-08 18:09:01 +0530 | [diff] [blame] | 3357 | |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3358 | /* populate rest of scan_mac_oui for mac addr randomization */ |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 3359 | scan_mac_oui.vdev_id = adapter->vdev_id; |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3360 | scan_mac_oui.enb_probe_req_sno_randomization = true; |
Rajeev Kumar Sirasanagandla | 686abd9 | 2017-06-08 18:09:01 +0530 | [diff] [blame] | 3361 | |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3362 | hdd_debug("Oui (%02x:%02x:%02x), vdev_id = %d", |
| 3363 | scan_mac_oui.oui[0], scan_mac_oui.oui[1], |
| 3364 | scan_mac_oui.oui[2], scan_mac_oui.vdev_id); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 3365 | |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3366 | hdd_update_ie_whitelist_attr(&scan_mac_oui.ie_whitelist, hdd_ctx); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 3367 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3368 | mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3369 | status = sme_set_scanning_mac_oui(mac_handle, &scan_mac_oui); |
| 3370 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3371 | hdd_err("sme_set_scanning_mac_oui failed(err=%d)", status); |
Jeff Johnson | 9d45f33 | 2019-01-29 08:42:00 -0800 | [diff] [blame] | 3372 | |
| 3373 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3374 | } |
| 3375 | |
| 3376 | /** |
| 3377 | * wlan_hdd_cfg80211_set_scanning_mac_oui() - set scan MAC |
| 3378 | * @wiphy: pointer to wireless wiphy structure. |
| 3379 | * @wdev: pointer to wireless_dev structure. |
| 3380 | * @data: Pointer to the data to be passed via vendor interface |
| 3381 | * @data_len:Length of the data to be passed |
| 3382 | * |
| 3383 | * Set the MAC address that is to be used for scanning. This is an |
| 3384 | * SSR-protecting wrapper function. |
| 3385 | * |
| 3386 | * Return: Return the Success or Failure code. |
| 3387 | */ |
| 3388 | static int |
| 3389 | wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy, |
| 3390 | struct wireless_dev *wdev, |
| 3391 | const void *data, |
| 3392 | int data_len) |
| 3393 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 3394 | int errno; |
| 3395 | struct osif_vdev_sync *vdev_sync; |
| 3396 | |
| 3397 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 3398 | if (errno) |
| 3399 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3400 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 3401 | errno = __wlan_hdd_cfg80211_set_scanning_mac_oui(wiphy, wdev, |
| 3402 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3403 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 3404 | osif_vdev_sync_op_stop(vdev_sync); |
| 3405 | |
| 3406 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3407 | } |
| 3408 | |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3409 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3410 | * wlan_hdd_cfg80211_set_feature() - Set the bitmask for supported features |
| 3411 | * @feature_flags: pointer to the byte array of features. |
| 3412 | * @feature: Feature to be turned ON in the byte array. |
| 3413 | * |
| 3414 | * Return: None |
| 3415 | * |
| 3416 | * This is called to turn ON or SET the feature flag for the requested feature. |
| 3417 | **/ |
| 3418 | #define NUM_BITS_IN_BYTE 8 |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 3419 | static void wlan_hdd_cfg80211_set_feature(uint8_t *feature_flags, |
| 3420 | uint8_t feature) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3421 | { |
| 3422 | uint32_t index; |
| 3423 | uint8_t bit_mask; |
| 3424 | |
| 3425 | index = feature / NUM_BITS_IN_BYTE; |
| 3426 | bit_mask = 1 << (feature % NUM_BITS_IN_BYTE); |
| 3427 | feature_flags[index] |= bit_mask; |
| 3428 | } |
| 3429 | |
| 3430 | /** |
| 3431 | * __wlan_hdd_cfg80211_get_features() - Get the Driver Supported features |
| 3432 | * @wiphy: pointer to wireless wiphy structure. |
| 3433 | * @wdev: pointer to wireless_dev structure. |
| 3434 | * @data: Pointer to the data to be passed via vendor interface |
| 3435 | * @data_len:Length of the data to be passed |
| 3436 | * |
| 3437 | * This is called when wlan driver needs to send supported feature set to |
| 3438 | * supplicant upon a request/query from the supplicant. |
| 3439 | * |
| 3440 | * Return: Return the Success or Failure code. |
| 3441 | **/ |
| 3442 | #define MAX_CONCURRENT_CHAN_ON_24G 2 |
| 3443 | #define MAX_CONCURRENT_CHAN_ON_5G 2 |
| 3444 | static int |
| 3445 | __wlan_hdd_cfg80211_get_features(struct wiphy *wiphy, |
| 3446 | struct wireless_dev *wdev, |
| 3447 | const void *data, int data_len) |
| 3448 | { |
| 3449 | struct sk_buff *skb = NULL; |
| 3450 | uint32_t dbs_capability = 0; |
| 3451 | bool one_by_one_dbs, two_by_two_dbs; |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 3452 | bool value; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3453 | QDF_STATUS ret = QDF_STATUS_E_FAILURE; |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 3454 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3455 | int ret_val; |
| 3456 | |
| 3457 | uint8_t feature_flags[(NUM_QCA_WLAN_VENDOR_FEATURES + 7) / 8] = {0}; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3458 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3459 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3460 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 3461 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3462 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3463 | if (ret_val) |
| 3464 | return ret_val; |
| 3465 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3466 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3467 | hdd_err("Command not allowed in FTM mode"); |
| 3468 | return -EPERM; |
| 3469 | } |
| 3470 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3471 | if (roaming_offload_enabled(hdd_ctx)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3472 | hdd_debug("Key Mgmt Offload is supported"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3473 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3474 | QCA_WLAN_VENDOR_FEATURE_KEY_MGMT_OFFLOAD); |
| 3475 | } |
| 3476 | |
| 3477 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3478 | QCA_WLAN_VENDOR_FEATURE_SUPPORT_HW_MODE_ANY); |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 3479 | if (policy_mgr_is_scan_simultaneous_capable(hdd_ctx->psoc)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3480 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3481 | QCA_WLAN_VENDOR_FEATURE_OFFCHANNEL_SIMULTANEOUS); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 3482 | |
| 3483 | if (wma_is_p2p_lo_capable()) |
| 3484 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3485 | QCA_WLAN_VENDOR_FEATURE_P2P_LISTEN_OFFLOAD); |
| 3486 | |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 3487 | value = 0; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 3488 | status = ucfg_mlme_get_oce_sta_enabled_info(hdd_ctx->psoc, &value); |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 3489 | if (QDF_IS_STATUS_ERROR(status)) |
| 3490 | hdd_err("could not get OCE STA enable info"); |
| 3491 | if (value) |
yeshwanth sriram guntuka | 1413dfb | 2017-06-23 14:09:48 +0530 | [diff] [blame] | 3492 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3493 | QCA_WLAN_VENDOR_FEATURE_OCE_STA); |
| 3494 | |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 3495 | value = 0; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 3496 | status = ucfg_mlme_get_oce_sap_enabled_info(hdd_ctx->psoc, &value); |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 3497 | if (QDF_IS_STATUS_ERROR(status)) |
| 3498 | hdd_err("could not get OCE SAP enable info"); |
| 3499 | if (value) |
yeshwanth sriram guntuka | 1413dfb | 2017-06-23 14:09:48 +0530 | [diff] [blame] | 3500 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3501 | QCA_WLAN_VENDOR_FEATURE_OCE_STA_CFON); |
| 3502 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 3503 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 3504 | * has support for processing user cell_base hints when wiphy is |
| 3505 | * self managed or check the backport flag for the same. |
| 3506 | */ |
| 3507 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 3508 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
| 3509 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3510 | QCA_WLAN_VENDOR_FEATURE_SELF_MANAGED_REGULATORY); |
| 3511 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3512 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(feature_flags) + |
| 3513 | NLMSG_HDRLEN); |
| 3514 | |
| 3515 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3516 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3517 | return -ENOMEM; |
| 3518 | } |
| 3519 | |
| 3520 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_FLAGS, |
| 3521 | sizeof(feature_flags), feature_flags)) |
| 3522 | goto nla_put_failure; |
| 3523 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 3524 | ret = policy_mgr_get_dbs_hw_modes(hdd_ctx->psoc, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3525 | &one_by_one_dbs, &two_by_two_dbs); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3526 | if (QDF_STATUS_SUCCESS == ret) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3527 | if (one_by_one_dbs) |
| 3528 | dbs_capability = DRV_DBS_CAPABILITY_1X1; |
| 3529 | |
| 3530 | if (two_by_two_dbs) |
| 3531 | dbs_capability = DRV_DBS_CAPABILITY_2X2; |
| 3532 | |
| 3533 | if (!one_by_one_dbs && !two_by_two_dbs) |
| 3534 | dbs_capability = DRV_DBS_CAPABILITY_DISABLED; |
| 3535 | } else { |
| 3536 | hdd_err("wma_get_dbs_hw_mode failed"); |
| 3537 | dbs_capability = DRV_DBS_CAPABILITY_DISABLED; |
| 3538 | } |
| 3539 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3540 | hdd_debug("dbs_capability is %d", dbs_capability); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3541 | |
| 3542 | if (nla_put_u32(skb, |
Ganesh Kondabattini | d921ed9 | 2017-06-20 16:40:48 +0530 | [diff] [blame] | 3543 | QCA_WLAN_VENDOR_ATTR_CONCURRENCY_CAPA, |
| 3544 | dbs_capability)) |
| 3545 | goto nla_put_failure; |
| 3546 | |
| 3547 | |
| 3548 | if (nla_put_u32(skb, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3549 | QCA_WLAN_VENDOR_ATTR_MAX_CONCURRENT_CHANNELS_2_4_BAND, |
| 3550 | MAX_CONCURRENT_CHAN_ON_24G)) |
| 3551 | goto nla_put_failure; |
| 3552 | |
| 3553 | if (nla_put_u32(skb, |
| 3554 | QCA_WLAN_VENDOR_ATTR_MAX_CONCURRENT_CHANNELS_5_0_BAND, |
| 3555 | MAX_CONCURRENT_CHAN_ON_5G)) |
| 3556 | goto nla_put_failure; |
| 3557 | |
| 3558 | return cfg80211_vendor_cmd_reply(skb); |
| 3559 | |
| 3560 | nla_put_failure: |
| 3561 | kfree_skb(skb); |
| 3562 | return -EINVAL; |
| 3563 | } |
| 3564 | |
| 3565 | /** |
| 3566 | * wlan_hdd_cfg80211_get_features() - Get the Driver Supported features |
| 3567 | * @wiphy: pointer to wireless wiphy structure. |
| 3568 | * @wdev: pointer to wireless_dev structure. |
| 3569 | * @data: Pointer to the data to be passed via vendor interface |
| 3570 | * @data_len:Length of the data to be passed |
| 3571 | * |
| 3572 | * This is called when wlan driver needs to send supported feature set to |
| 3573 | * supplicant upon a request/query from the supplicant. |
| 3574 | * |
| 3575 | * Return: Return the Success or Failure code. |
| 3576 | */ |
| 3577 | static int |
| 3578 | wlan_hdd_cfg80211_get_features(struct wiphy *wiphy, |
| 3579 | struct wireless_dev *wdev, |
| 3580 | const void *data, int data_len) |
| 3581 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 3582 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 3583 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 3584 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 3585 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 3586 | if (errno) |
| 3587 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3588 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 3589 | errno = __wlan_hdd_cfg80211_get_features(wiphy, wdev, data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3590 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 3591 | osif_psoc_sync_op_stop(psoc_sync); |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 3592 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 3593 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3594 | } |
| 3595 | |
Hanumanth Reddy Pothula | a1259ef | 2017-02-21 17:14:43 +0530 | [diff] [blame] | 3596 | #define PARAM_NUM_NW \ |
| 3597 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID_NUM_NETWORKS |
| 3598 | #define PARAM_SET_BSSID \ |
| 3599 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_BSSID |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3600 | #define PARAM_SSID_LIST QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID_LIST |
Hanumanth Reddy Pothula | a1259ef | 2017-02-21 17:14:43 +0530 | [diff] [blame] | 3601 | #define PARAM_LIST_SSID QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID |
Ravi Kumar Bokka | 6cb9b37 | 2017-06-08 20:12:39 +0530 | [diff] [blame] | 3602 | #define MAX_ROAMING_PARAM \ |
| 3603 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3604 | #define PARAM_NUM_BSSID \ |
| 3605 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_NUM_BSSID |
| 3606 | #define PARAM_BSSID_PREFS \ |
| 3607 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS |
| 3608 | #define PARAM_ROAM_BSSID \ |
| 3609 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_BSSID |
| 3610 | #define PARAM_RSSI_MODIFIER \ |
| 3611 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_RSSI_MODIFIER |
| 3612 | #define PARAMS_NUM_BSSID \ |
| 3613 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_NUM_BSSID |
| 3614 | #define PARAM_BSSID_PARAMS \ |
| 3615 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS |
| 3616 | #define PARAM_A_BAND_BOOST_THLD \ |
| 3617 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_THRESHOLD |
| 3618 | #define PARAM_A_BAND_PELT_THLD \ |
| 3619 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_THRESHOLD |
| 3620 | #define PARAM_A_BAND_BOOST_FACTOR \ |
| 3621 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_FACTOR |
| 3622 | #define PARAM_A_BAND_PELT_FACTOR \ |
| 3623 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_FACTOR |
| 3624 | #define PARAM_A_BAND_MAX_BOOST \ |
| 3625 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_MAX_BOOST |
| 3626 | #define PARAM_ROAM_HISTERESYS \ |
| 3627 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_LAZY_ROAM_HISTERESYS |
| 3628 | #define PARAM_RSSI_TRIGGER \ |
| 3629 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_ALERT_ROAM_RSSI_TRIGGER |
| 3630 | #define PARAM_ROAM_ENABLE \ |
| 3631 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_ENABLE |
| 3632 | |
Ravi Kumar Bokka | 6cb9b37 | 2017-06-08 20:12:39 +0530 | [diff] [blame] | 3633 | |
| 3634 | static const struct nla_policy |
| 3635 | wlan_hdd_set_roam_param_policy[MAX_ROAMING_PARAM + 1] = { |
| 3636 | [QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD] = {.type = NLA_U32}, |
| 3637 | [QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID] = {.type = NLA_U32}, |
| 3638 | [PARAM_NUM_NW] = {.type = NLA_U32}, |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3639 | [PARAM_A_BAND_BOOST_FACTOR] = {.type = NLA_U32}, |
| 3640 | [PARAM_A_BAND_PELT_FACTOR] = {.type = NLA_U32}, |
| 3641 | [PARAM_A_BAND_MAX_BOOST] = {.type = NLA_U32}, |
| 3642 | [PARAM_ROAM_HISTERESYS] = {.type = NLA_S32}, |
| 3643 | [PARAM_A_BAND_BOOST_THLD] = {.type = NLA_S32}, |
Srinivas Girigowda | 4ffe7c8 | 2017-07-18 11:45:23 -0700 | [diff] [blame] | 3644 | [PARAM_A_BAND_PELT_THLD] = {.type = NLA_S32}, |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3645 | [PARAM_RSSI_TRIGGER] = {.type = NLA_U32}, |
| 3646 | [PARAM_ROAM_ENABLE] = { .type = NLA_S32}, |
| 3647 | [PARAM_NUM_BSSID] = {.type = NLA_U32}, |
| 3648 | [PARAM_RSSI_MODIFIER] = {.type = NLA_U32}, |
| 3649 | [PARAMS_NUM_BSSID] = {.type = NLA_U32}, |
| 3650 | [PARAM_ROAM_BSSID] = {.type = NLA_UNSPEC, .len = QDF_MAC_ADDR_SIZE}, |
| 3651 | [PARAM_SET_BSSID] = {.type = NLA_UNSPEC, .len = QDF_MAC_ADDR_SIZE}, |
Ravi Kumar Bokka | 6cb9b37 | 2017-06-08 20:12:39 +0530 | [diff] [blame] | 3652 | }; |
| 3653 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3654 | /** |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3655 | * hdd_set_white_list() - parse white list |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3656 | * @hdd_ctx: HDD context |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3657 | * @roam_params: roam params |
| 3658 | * @tb: list of attributes |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3659 | * @vdev_id: vdev id |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3660 | * |
| 3661 | * Return: 0 on success; error number on failure |
| 3662 | */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3663 | static int hdd_set_white_list(struct hdd_context *hdd_ctx, |
| 3664 | struct roam_ext_params *roam_params, |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3665 | struct nlattr **tb, uint8_t vdev_id) |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3666 | { |
| 3667 | int rem, i; |
| 3668 | uint32_t buf_len = 0, count; |
| 3669 | struct nlattr *tb2[MAX_ROAMING_PARAM + 1]; |
| 3670 | struct nlattr *curr_attr = NULL; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3671 | mac_handle_t mac_handle; |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3672 | |
| 3673 | i = 0; |
| 3674 | if (tb[PARAM_NUM_NW]) { |
| 3675 | count = nla_get_u32(tb[PARAM_NUM_NW]); |
| 3676 | } else { |
| 3677 | hdd_err("Number of networks is not provided"); |
| 3678 | goto fail; |
| 3679 | } |
| 3680 | |
| 3681 | if (count && tb[PARAM_SSID_LIST]) { |
| 3682 | nla_for_each_nested(curr_attr, |
| 3683 | tb[PARAM_SSID_LIST], rem) { |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3684 | if (wlan_cfg80211_nla_parse(tb2, |
| 3685 | QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_MAX, |
| 3686 | nla_data(curr_attr), |
| 3687 | nla_len(curr_attr), |
| 3688 | wlan_hdd_set_roam_param_policy)) { |
| 3689 | hdd_err("nla_parse failed"); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3690 | goto fail; |
| 3691 | } |
| 3692 | /* Parse and Fetch allowed SSID list*/ |
| 3693 | if (!tb2[PARAM_LIST_SSID]) { |
| 3694 | hdd_err("attr allowed ssid failed"); |
| 3695 | goto fail; |
| 3696 | } |
| 3697 | buf_len = nla_len(tb2[PARAM_LIST_SSID]); |
| 3698 | /* |
| 3699 | * Upper Layers include a null termination |
| 3700 | * character. Check for the actual permissible |
| 3701 | * length of SSID and also ensure not to copy |
| 3702 | * the NULL termination character to the driver |
| 3703 | * buffer. |
| 3704 | */ |
| 3705 | if (buf_len && (i < MAX_SSID_ALLOWED_LIST) && |
| 3706 | ((buf_len - 1) <= SIR_MAC_MAX_SSID_LENGTH)) { |
| 3707 | nla_memcpy(roam_params->ssid_allowed_list[i].ssId, |
| 3708 | tb2[PARAM_LIST_SSID], buf_len - 1); |
| 3709 | roam_params->ssid_allowed_list[i].length = buf_len - 1; |
| 3710 | hdd_debug("SSID[%d]: %.*s,length = %d", |
| 3711 | i, |
| 3712 | roam_params->ssid_allowed_list[i].length, |
| 3713 | roam_params->ssid_allowed_list[i].ssId, |
| 3714 | roam_params->ssid_allowed_list[i].length); |
| 3715 | i++; |
| 3716 | } else { |
| 3717 | hdd_err("Invalid buffer length"); |
| 3718 | } |
| 3719 | } |
| 3720 | } |
| 3721 | |
| 3722 | if (i != count) { |
| 3723 | hdd_err("Invalid number of SSIDs i = %d, count = %d", i, count); |
| 3724 | goto fail; |
| 3725 | } |
| 3726 | |
| 3727 | roam_params->num_ssid_allowed_list = i; |
| 3728 | hdd_debug("Num of Allowed SSID %d", roam_params->num_ssid_allowed_list); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3729 | mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3730 | sme_update_roam_params(mac_handle, vdev_id, |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3731 | roam_params, REASON_ROAM_SET_SSID_ALLOWED); |
| 3732 | return 0; |
| 3733 | |
| 3734 | fail: |
| 3735 | return -EINVAL; |
| 3736 | } |
| 3737 | |
| 3738 | /** |
| 3739 | * hdd_set_bssid_prefs() - parse set bssid prefs |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3740 | * @hdd_ctx: HDD context |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3741 | * @roam_params: roam params |
| 3742 | * @tb: list of attributes |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3743 | * @vdev_id: vdev id |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3744 | * |
| 3745 | * Return: 0 on success; error number on failure |
| 3746 | */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3747 | static int hdd_set_bssid_prefs(struct hdd_context *hdd_ctx, |
| 3748 | struct roam_ext_params *roam_params, |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3749 | struct nlattr **tb, uint8_t vdev_id) |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3750 | { |
| 3751 | int rem, i; |
| 3752 | uint32_t count; |
| 3753 | struct nlattr *tb2[MAX_ROAMING_PARAM + 1]; |
| 3754 | struct nlattr *curr_attr = NULL; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3755 | mac_handle_t mac_handle; |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3756 | |
| 3757 | /* Parse and fetch number of preferred BSSID */ |
| 3758 | if (!tb[PARAM_NUM_BSSID]) { |
| 3759 | hdd_err("attr num of preferred bssid failed"); |
| 3760 | goto fail; |
| 3761 | } |
| 3762 | count = nla_get_u32(tb[PARAM_NUM_BSSID]); |
| 3763 | if (count > MAX_BSSID_FAVORED) { |
| 3764 | hdd_err("Preferred BSSID count %u exceeds max %u", |
| 3765 | count, MAX_BSSID_FAVORED); |
| 3766 | goto fail; |
| 3767 | } |
| 3768 | hdd_debug("Num of Preferred BSSID (%d)", count); |
| 3769 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS]) { |
| 3770 | hdd_err("attr Preferred BSSID failed"); |
| 3771 | goto fail; |
| 3772 | } |
| 3773 | |
| 3774 | i = 0; |
| 3775 | nla_for_each_nested(curr_attr, |
| 3776 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS], |
| 3777 | rem) { |
| 3778 | if (i == count) { |
| 3779 | hdd_warn("Ignoring excess Preferred BSSID"); |
| 3780 | break; |
| 3781 | } |
| 3782 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3783 | if (wlan_cfg80211_nla_parse(tb2, |
| 3784 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX, |
| 3785 | nla_data(curr_attr), |
| 3786 | nla_len(curr_attr), |
| 3787 | wlan_hdd_set_roam_param_policy)) { |
| 3788 | hdd_err("nla_parse failed"); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3789 | goto fail; |
| 3790 | } |
| 3791 | /* Parse and fetch MAC address */ |
| 3792 | if (!tb2[PARAM_ROAM_BSSID]) { |
| 3793 | hdd_err("attr mac address failed"); |
| 3794 | goto fail; |
| 3795 | } |
| 3796 | nla_memcpy(roam_params->bssid_favored[i].bytes, |
| 3797 | tb2[PARAM_ROAM_BSSID], |
| 3798 | QDF_MAC_ADDR_SIZE); |
| 3799 | hdd_debug(MAC_ADDRESS_STR, |
| 3800 | MAC_ADDR_ARRAY(roam_params->bssid_favored[i].bytes)); |
| 3801 | /* Parse and fetch preference factor*/ |
| 3802 | if (!tb2[PARAM_RSSI_MODIFIER]) { |
| 3803 | hdd_err("BSSID Preference score failed"); |
| 3804 | goto fail; |
| 3805 | } |
| 3806 | roam_params->bssid_favored_factor[i] = nla_get_u32( |
| 3807 | tb2[PARAM_RSSI_MODIFIER]); |
| 3808 | hdd_debug("BSSID Preference score (%d)", |
| 3809 | roam_params->bssid_favored_factor[i]); |
| 3810 | i++; |
| 3811 | } |
| 3812 | if (i < count) |
| 3813 | hdd_warn("Num Preferred BSSID %u less than expected %u", |
| 3814 | i, count); |
| 3815 | |
| 3816 | roam_params->num_bssid_favored = i; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3817 | mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3818 | sme_update_roam_params(mac_handle, vdev_id, |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3819 | roam_params, REASON_ROAM_SET_FAVORED_BSSID); |
| 3820 | |
| 3821 | return 0; |
| 3822 | |
| 3823 | fail: |
| 3824 | return -EINVAL; |
| 3825 | } |
| 3826 | |
| 3827 | /** |
| 3828 | * hdd_set_blacklist_bssid() - parse set blacklist bssid |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3829 | * @hdd_ctx: HDD context |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3830 | * @roam_params: roam params |
| 3831 | * @tb: list of attributes |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3832 | * @vdev_id: vdev id |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3833 | * |
| 3834 | * Return: 0 on success; error number on failure |
| 3835 | */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3836 | static int hdd_set_blacklist_bssid(struct hdd_context *hdd_ctx, |
| 3837 | struct roam_ext_params *roam_params, |
| 3838 | struct nlattr **tb, |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3839 | uint8_t vdev_id) |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3840 | { |
| 3841 | int rem, i; |
| 3842 | uint32_t count; |
| 3843 | struct nlattr *tb2[MAX_ROAMING_PARAM + 1]; |
| 3844 | struct nlattr *curr_attr = NULL; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3845 | mac_handle_t mac_handle; |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3846 | |
| 3847 | /* Parse and fetch number of blacklist BSSID */ |
| 3848 | if (!tb[PARAMS_NUM_BSSID]) { |
| 3849 | hdd_err("attr num of blacklist bssid failed"); |
| 3850 | goto fail; |
| 3851 | } |
| 3852 | count = nla_get_u32(tb[PARAMS_NUM_BSSID]); |
| 3853 | if (count > MAX_BSSID_AVOID_LIST) { |
| 3854 | hdd_err("Blacklist BSSID count %u exceeds max %u", |
| 3855 | count, MAX_BSSID_AVOID_LIST); |
| 3856 | goto fail; |
| 3857 | } |
| 3858 | hdd_debug("Num of blacklist BSSID (%d)", count); |
| 3859 | |
| 3860 | i = 0; |
| 3861 | if (count && tb[PARAM_BSSID_PARAMS]) { |
| 3862 | nla_for_each_nested(curr_attr, |
| 3863 | tb[PARAM_BSSID_PARAMS], |
| 3864 | rem) { |
| 3865 | if (i == count) { |
| 3866 | hdd_warn("Ignoring excess Blacklist BSSID"); |
| 3867 | break; |
| 3868 | } |
| 3869 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3870 | if (wlan_cfg80211_nla_parse(tb2, |
Dustin Brown | 3fb1504 | 2017-08-15 15:54:49 -0700 | [diff] [blame] | 3871 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX, |
| 3872 | nla_data(curr_attr), |
| 3873 | nla_len(curr_attr), |
| 3874 | wlan_hdd_set_roam_param_policy)) { |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3875 | hdd_err("nla_parse failed"); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3876 | goto fail; |
| 3877 | } |
| 3878 | /* Parse and fetch MAC address */ |
| 3879 | if (!tb2[PARAM_SET_BSSID]) { |
| 3880 | hdd_err("attr blacklist addr failed"); |
| 3881 | goto fail; |
| 3882 | } |
| 3883 | nla_memcpy(roam_params->bssid_avoid_list[i].bytes, |
| 3884 | tb2[PARAM_SET_BSSID], QDF_MAC_ADDR_SIZE); |
| 3885 | hdd_debug(MAC_ADDRESS_STR, |
| 3886 | MAC_ADDR_ARRAY(roam_params->bssid_avoid_list[i].bytes)); |
| 3887 | i++; |
| 3888 | } |
| 3889 | } |
| 3890 | |
| 3891 | if (i < count) |
| 3892 | hdd_warn("Num Blacklist BSSID %u less than expected %u", |
| 3893 | i, count); |
| 3894 | |
| 3895 | roam_params->num_bssid_avoid_list = i; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3896 | mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3897 | sme_update_roam_params(mac_handle, vdev_id, |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3898 | roam_params, REASON_ROAM_SET_BLACKLIST_BSSID); |
| 3899 | |
| 3900 | return 0; |
| 3901 | fail: |
| 3902 | return -EINVAL; |
| 3903 | } |
| 3904 | |
| 3905 | /** |
| 3906 | * hdd_set_ext_roam_params() - parse ext roam params |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3907 | * @hdd_ctx: HDD context |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3908 | * @roam_params: roam params |
| 3909 | * @tb: list of attributes |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3910 | * @vdev_id: vdev id |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3911 | * |
| 3912 | * Return: 0 on success; error number on failure |
| 3913 | */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3914 | static int hdd_set_ext_roam_params(struct hdd_context *hdd_ctx, |
| 3915 | const void *data, int data_len, |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3916 | uint8_t vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3917 | struct roam_ext_params *roam_params) |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3918 | { |
| 3919 | uint32_t cmd_type, req_id; |
| 3920 | struct nlattr *tb[MAX_ROAMING_PARAM + 1]; |
| 3921 | int ret; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3922 | mac_handle_t mac_handle; |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3923 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3924 | if (wlan_cfg80211_nla_parse(tb, MAX_ROAMING_PARAM, data, data_len, |
| 3925 | wlan_hdd_set_roam_param_policy)) { |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3926 | hdd_err("Invalid ATTR"); |
| 3927 | return -EINVAL; |
| 3928 | } |
| 3929 | /* Parse and fetch Command Type */ |
| 3930 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD]) { |
| 3931 | hdd_err("roam cmd type failed"); |
| 3932 | goto fail; |
| 3933 | } |
| 3934 | |
| 3935 | cmd_type = nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD]); |
| 3936 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID]) { |
| 3937 | hdd_err("attr request id failed"); |
| 3938 | goto fail; |
| 3939 | } |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 3940 | mac_handle = hdd_ctx->mac_handle; |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3941 | req_id = nla_get_u32( |
| 3942 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID]); |
| 3943 | hdd_debug("Req Id: %u Cmd Type: %u", req_id, cmd_type); |
| 3944 | switch (cmd_type) { |
| 3945 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SSID_WHITE_LIST: |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3946 | ret = hdd_set_white_list(hdd_ctx, roam_params, tb, vdev_id); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3947 | if (ret) |
| 3948 | goto fail; |
| 3949 | break; |
| 3950 | |
| 3951 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_EXTSCAN_ROAM_PARAMS: |
| 3952 | /* Parse and fetch 5G Boost Threshold */ |
| 3953 | if (!tb[PARAM_A_BAND_BOOST_THLD]) { |
| 3954 | hdd_err("5G boost threshold failed"); |
| 3955 | goto fail; |
| 3956 | } |
| 3957 | roam_params->raise_rssi_thresh_5g = nla_get_s32( |
| 3958 | tb[PARAM_A_BAND_BOOST_THLD]); |
| 3959 | hdd_debug("5G Boost Threshold (%d)", |
| 3960 | roam_params->raise_rssi_thresh_5g); |
| 3961 | /* Parse and fetch 5G Penalty Threshold */ |
Srinivas Girigowda | 4ffe7c8 | 2017-07-18 11:45:23 -0700 | [diff] [blame] | 3962 | if (!tb[PARAM_A_BAND_PELT_THLD]) { |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3963 | hdd_err("5G penalty threshold failed"); |
| 3964 | goto fail; |
| 3965 | } |
| 3966 | roam_params->drop_rssi_thresh_5g = nla_get_s32( |
Srinivas Girigowda | 4ffe7c8 | 2017-07-18 11:45:23 -0700 | [diff] [blame] | 3967 | tb[PARAM_A_BAND_PELT_THLD]); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3968 | hdd_debug("5G Penalty Threshold (%d)", |
| 3969 | roam_params->drop_rssi_thresh_5g); |
| 3970 | /* Parse and fetch 5G Boost Factor */ |
| 3971 | if (!tb[PARAM_A_BAND_BOOST_FACTOR]) { |
| 3972 | hdd_err("5G boost Factor failed"); |
| 3973 | goto fail; |
| 3974 | } |
| 3975 | roam_params->raise_factor_5g = nla_get_u32( |
| 3976 | tb[PARAM_A_BAND_BOOST_FACTOR]); |
| 3977 | hdd_debug("5G Boost Factor (%d)", |
| 3978 | roam_params->raise_factor_5g); |
| 3979 | /* Parse and fetch 5G Penalty factor */ |
| 3980 | if (!tb[PARAM_A_BAND_PELT_FACTOR]) { |
| 3981 | hdd_err("5G Penalty Factor failed"); |
| 3982 | goto fail; |
| 3983 | } |
| 3984 | roam_params->drop_factor_5g = nla_get_u32( |
| 3985 | tb[PARAM_A_BAND_PELT_FACTOR]); |
| 3986 | hdd_debug("5G Penalty factor (%d)", |
| 3987 | roam_params->drop_factor_5g); |
| 3988 | /* Parse and fetch 5G Max Boost */ |
| 3989 | if (!tb[PARAM_A_BAND_MAX_BOOST]) { |
| 3990 | hdd_err("5G Max Boost failed"); |
| 3991 | goto fail; |
| 3992 | } |
| 3993 | roam_params->max_raise_rssi_5g = nla_get_u32( |
| 3994 | tb[PARAM_A_BAND_MAX_BOOST]); |
| 3995 | hdd_debug("5G Max Boost (%d)", |
| 3996 | roam_params->max_raise_rssi_5g); |
| 3997 | /* Parse and fetch Rssi Diff */ |
| 3998 | if (!tb[PARAM_ROAM_HISTERESYS]) { |
| 3999 | hdd_err("Rssi Diff failed"); |
| 4000 | goto fail; |
| 4001 | } |
| 4002 | roam_params->rssi_diff = nla_get_s32( |
| 4003 | tb[PARAM_ROAM_HISTERESYS]); |
| 4004 | hdd_debug("RSSI Diff (%d)", |
| 4005 | roam_params->rssi_diff); |
| 4006 | /* Parse and fetch Alert Rssi Threshold */ |
| 4007 | if (!tb[PARAM_RSSI_TRIGGER]) { |
| 4008 | hdd_err("Alert Rssi Threshold failed"); |
| 4009 | goto fail; |
| 4010 | } |
| 4011 | roam_params->alert_rssi_threshold = nla_get_u32( |
| 4012 | tb[PARAM_RSSI_TRIGGER]); |
| 4013 | hdd_debug("Alert RSSI Threshold (%d)", |
| 4014 | roam_params->alert_rssi_threshold); |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 4015 | sme_update_roam_params(mac_handle, vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4016 | roam_params, |
| 4017 | REASON_ROAM_EXT_SCAN_PARAMS_CHANGED); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4018 | break; |
| 4019 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_LAZY_ROAM: |
| 4020 | /* Parse and fetch Activate Good Rssi Roam */ |
| 4021 | if (!tb[PARAM_ROAM_ENABLE]) { |
| 4022 | hdd_err("Activate Good Rssi Roam failed"); |
| 4023 | goto fail; |
| 4024 | } |
| 4025 | roam_params->good_rssi_roam = nla_get_s32( |
| 4026 | tb[PARAM_ROAM_ENABLE]); |
| 4027 | hdd_debug("Activate Good Rssi Roam (%d)", |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4028 | roam_params->good_rssi_roam); |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 4029 | sme_update_roam_params(mac_handle, vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4030 | roam_params, |
| 4031 | REASON_ROAM_GOOD_RSSI_CHANGED); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4032 | break; |
| 4033 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_BSSID_PREFS: |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 4034 | ret = hdd_set_bssid_prefs(hdd_ctx, roam_params, tb, vdev_id); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4035 | if (ret) |
| 4036 | goto fail; |
| 4037 | break; |
| 4038 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_BLACKLIST_BSSID: |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4039 | ret = hdd_set_blacklist_bssid(hdd_ctx, roam_params, |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 4040 | tb, vdev_id); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4041 | if (ret) |
| 4042 | goto fail; |
| 4043 | break; |
| 4044 | } |
| 4045 | |
| 4046 | return 0; |
| 4047 | |
| 4048 | fail: |
| 4049 | return -EINVAL; |
| 4050 | } |
| 4051 | |
| 4052 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4053 | * __wlan_hdd_cfg80211_set_ext_roam_params() - Settings for roaming parameters |
| 4054 | * @wiphy: The wiphy structure |
| 4055 | * @wdev: The wireless device |
| 4056 | * @data: Data passed by framework |
| 4057 | * @data_len: Parameters to be configured passed as data |
| 4058 | * |
| 4059 | * The roaming related parameters are configured by the framework |
| 4060 | * using this interface. |
| 4061 | * |
| 4062 | * Return: Return either success or failure code. |
| 4063 | */ |
| 4064 | static int |
| 4065 | __wlan_hdd_cfg80211_set_ext_roam_params(struct wiphy *wiphy, |
| 4066 | struct wireless_dev *wdev, const void *data, int data_len) |
| 4067 | { |
| 4068 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 4069 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 4070 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4071 | struct roam_ext_params *roam_params = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4072 | int ret; |
| 4073 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4074 | hdd_enter_dev(dev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 4075 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4076 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4077 | hdd_err("Command not allowed in FTM mode"); |
| 4078 | return -EPERM; |
| 4079 | } |
| 4080 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 4081 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4082 | if (ret) |
| 4083 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4084 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 4085 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 4086 | hdd_err("Driver Modules are closed"); |
| 4087 | return -EINVAL; |
| 4088 | } |
| 4089 | |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4090 | roam_params = qdf_mem_malloc(sizeof(*roam_params)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 4091 | if (!roam_params) |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4092 | return -ENOMEM; |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4093 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 4094 | ret = hdd_set_ext_roam_params(hdd_ctx, data, data_len, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 4095 | adapter->vdev_id, roam_params); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4096 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4097 | goto fail; |
Hanumanth Reddy Pothula | a1259ef | 2017-02-21 17:14:43 +0530 | [diff] [blame] | 4098 | |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4099 | if (roam_params) |
| 4100 | qdf_mem_free(roam_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4101 | return 0; |
| 4102 | fail: |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4103 | if (roam_params) |
| 4104 | qdf_mem_free(roam_params); |
| 4105 | |
| 4106 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4107 | } |
Hanumanth Reddy Pothula | a1259ef | 2017-02-21 17:14:43 +0530 | [diff] [blame] | 4108 | #undef PARAM_NUM_NW |
| 4109 | #undef PARAM_SET_BSSID |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4110 | #undef PARAM_SSID_LIST |
Hanumanth Reddy Pothula | a1259ef | 2017-02-21 17:14:43 +0530 | [diff] [blame] | 4111 | #undef PARAM_LIST_SSID |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4112 | #undef MAX_ROAMING_PARAM |
| 4113 | #undef PARAM_NUM_BSSID |
| 4114 | #undef PARAM_BSSID_PREFS |
| 4115 | #undef PARAM_ROAM_BSSID |
| 4116 | #undef PARAM_RSSI_MODIFIER |
| 4117 | #undef PARAMS_NUM_BSSID |
| 4118 | #undef PARAM_BSSID_PARAMS |
| 4119 | #undef PARAM_A_BAND_BOOST_THLD |
| 4120 | #undef PARAM_A_BAND_PELT_THLD |
| 4121 | #undef PARAM_A_BAND_BOOST_FACTOR |
| 4122 | #undef PARAM_A_BAND_PELT_FACTOR |
| 4123 | #undef PARAM_A_BAND_MAX_BOOST |
| 4124 | #undef PARAM_ROAM_HISTERESYS |
| 4125 | #undef PARAM_RSSI_TRIGGER |
| 4126 | #undef PARAM_ROAM_ENABLE |
Hanumanth Reddy Pothula | a1259ef | 2017-02-21 17:14:43 +0530 | [diff] [blame] | 4127 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4128 | |
| 4129 | /** |
| 4130 | * wlan_hdd_cfg80211_set_ext_roam_params() - set ext scan roam params |
| 4131 | * @wiphy: pointer to wireless wiphy structure. |
| 4132 | * @wdev: pointer to wireless_dev structure. |
| 4133 | * @data: Pointer to the data to be passed via vendor interface |
| 4134 | * @data_len:Length of the data to be passed |
| 4135 | * |
| 4136 | * Return: Return the Success or Failure code. |
| 4137 | */ |
| 4138 | static int |
| 4139 | wlan_hdd_cfg80211_set_ext_roam_params(struct wiphy *wiphy, |
| 4140 | struct wireless_dev *wdev, |
| 4141 | const void *data, |
| 4142 | int data_len) |
| 4143 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 4144 | int errno; |
| 4145 | struct osif_vdev_sync *vdev_sync; |
| 4146 | |
| 4147 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 4148 | if (errno) |
| 4149 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4150 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 4151 | errno = __wlan_hdd_cfg80211_set_ext_roam_params(wiphy, wdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4152 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4153 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 4154 | osif_vdev_sync_op_stop(vdev_sync); |
| 4155 | |
| 4156 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4157 | } |
| 4158 | |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4159 | #define PWR_SAVE_FAIL_CMD_INDEX \ |
| 4160 | QCA_NL80211_VENDOR_SUBCMD_PWR_SAVE_FAIL_DETECTED_INDEX |
Jeff Johnson | b7fa256 | 2018-07-02 08:36:17 -0700 | [diff] [blame] | 4161 | |
| 4162 | void hdd_chip_pwr_save_fail_detected_cb(hdd_handle_t hdd_handle, |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4163 | struct chip_pwr_save_fail_detected_params |
| 4164 | *data) |
| 4165 | { |
Jeff Johnson | b7fa256 | 2018-07-02 08:36:17 -0700 | [diff] [blame] | 4166 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4167 | struct sk_buff *skb; |
| 4168 | int flags = cds_get_gfp_flags(); |
| 4169 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4170 | hdd_enter(); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4171 | |
| 4172 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 4173 | return; |
| 4174 | |
| 4175 | if (!data) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4176 | hdd_debug("data is null"); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4177 | return; |
| 4178 | } |
| 4179 | |
| 4180 | skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 4181 | NULL, NLMSG_HDRLEN + |
| 4182 | sizeof(data->failure_reason_code) + |
| 4183 | NLMSG_HDRLEN, PWR_SAVE_FAIL_CMD_INDEX, |
| 4184 | flags); |
| 4185 | |
| 4186 | if (!skb) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 4187 | hdd_info("cfg80211_vendor_event_alloc failed"); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4188 | return; |
| 4189 | } |
| 4190 | |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 4191 | hdd_debug("failure reason code: %u", data->failure_reason_code); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4192 | |
| 4193 | if (nla_put_u32(skb, |
| 4194 | QCA_ATTR_CHIP_POWER_SAVE_FAILURE_REASON, |
| 4195 | data->failure_reason_code)) |
| 4196 | goto fail; |
| 4197 | |
| 4198 | cfg80211_vendor_event(skb, flags); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4199 | hdd_exit(); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4200 | return; |
| 4201 | |
| 4202 | fail: |
| 4203 | kfree_skb(skb); |
| 4204 | } |
| 4205 | #undef PWR_SAVE_FAIL_CMD_INDEX |
| 4206 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4207 | static const struct nla_policy |
| 4208 | wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX |
| 4209 | +1] = { |
| 4210 | [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 }, |
| 4211 | }; |
| 4212 | |
| 4213 | /** |
| 4214 | * wlan_hdd_check_dfs_channel_for_adapter() - check dfs channel in adapter |
| 4215 | * @hdd_ctx: HDD context |
| 4216 | * @device_mode: device mode |
| 4217 | * Return: bool |
| 4218 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4219 | static bool wlan_hdd_check_dfs_channel_for_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 4220 | enum QDF_OPMODE device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4221 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 4222 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 4223 | struct hdd_ap_ctx *ap_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 4224 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4225 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4226 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4227 | if ((device_mode == adapter->device_mode) && |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 4228 | (device_mode == QDF_SAP_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4229 | ap_ctx = |
| 4230 | WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 4231 | |
| 4232 | /* |
| 4233 | * if there is SAP already running on DFS channel, |
| 4234 | * do not disable scan on dfs channels. Note that |
| 4235 | * with SAP on DFS, there cannot be conurrency on |
| 4236 | * single radio. But then we can have multiple |
| 4237 | * radios !! |
| 4238 | */ |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 4239 | if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state( |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 4240 | hdd_ctx->pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 4241 | ap_ctx->operating_channel)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 4242 | hdd_err("SAP running on DFS channel"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4243 | return true; |
| 4244 | } |
| 4245 | } |
| 4246 | |
| 4247 | if ((device_mode == adapter->device_mode) && |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 4248 | (device_mode == QDF_STA_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4249 | sta_ctx = |
| 4250 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 4251 | |
| 4252 | /* |
| 4253 | * if STA is already connected on DFS channel, |
| 4254 | * do not disable scan on dfs channels |
| 4255 | */ |
| 4256 | if (hdd_conn_is_connected(sta_ctx) && |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 4257 | (CHANNEL_STATE_DFS == |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 4258 | wlan_reg_get_channel_state(hdd_ctx->pdev, |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 4259 | sta_ctx->conn_info.channel))) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 4260 | hdd_err("client connected on DFS channel"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4261 | return true; |
| 4262 | } |
| 4263 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4264 | } |
| 4265 | |
| 4266 | return false; |
| 4267 | } |
| 4268 | |
| 4269 | /** |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4270 | * wlan_hdd_enable_dfs_chan_scan() - disable/enable DFS channels |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4271 | * @hdd_ctx: HDD context within host driver |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4272 | * @enable_dfs_channels: If true, DFS channels can be used for scanning |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4273 | * |
| 4274 | * Loops through devices to see who is operating on DFS channels |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4275 | * and then disables/enables DFS channels. |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4276 | * Fails the disable request if any device is active on a DFS channel. |
| 4277 | * |
| 4278 | * Return: 0 or other error codes. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4279 | */ |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4280 | |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4281 | int wlan_hdd_enable_dfs_chan_scan(struct hdd_context *hdd_ctx, |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4282 | bool enable_dfs_channels) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4283 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4284 | QDF_STATUS status; |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4285 | bool err; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4286 | mac_handle_t mac_handle; |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 4287 | bool enable_dfs_scan = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4288 | |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 4289 | ucfg_scan_cfg_get_dfs_chan_scan_allowed(hdd_ctx->psoc, |
| 4290 | &enable_dfs_scan); |
| 4291 | |
| 4292 | if (enable_dfs_channels == enable_dfs_scan) { |
Dustin Brown | 6a8d39b | 2018-08-14 15:27:26 -0700 | [diff] [blame] | 4293 | hdd_debug("DFS channels are already %s", |
| 4294 | enable_dfs_channels ? "enabled" : "disabled"); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4295 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4296 | } |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4297 | |
| 4298 | if (!enable_dfs_channels) { |
| 4299 | err = wlan_hdd_check_dfs_channel_for_adapter(hdd_ctx, |
| 4300 | QDF_STA_MODE); |
| 4301 | if (err) |
| 4302 | return -EOPNOTSUPP; |
| 4303 | |
| 4304 | err = wlan_hdd_check_dfs_channel_for_adapter(hdd_ctx, |
| 4305 | QDF_SAP_MODE); |
| 4306 | if (err) |
| 4307 | return -EOPNOTSUPP; |
| 4308 | } |
| 4309 | |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 4310 | ucfg_scan_cfg_set_dfs_chan_scan_allowed(hdd_ctx->psoc, |
| 4311 | enable_dfs_channels); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4312 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4313 | mac_handle = hdd_ctx->mac_handle; |
| 4314 | status = sme_enable_dfs_chan_scan(mac_handle, enable_dfs_channels); |
Min Liu | 5eaf724 | 2018-03-13 17:32:15 +0800 | [diff] [blame] | 4315 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4316 | hdd_err("Failed to set DFS channel scan flag to %d", |
| 4317 | enable_dfs_channels); |
| 4318 | return qdf_status_to_os_return(status); |
| 4319 | } |
| 4320 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4321 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 4322 | |
| 4323 | /* pass dfs channel status to regulatory component */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 4324 | status = ucfg_reg_enable_dfs_channels(hdd_ctx->pdev, |
| 4325 | enable_dfs_channels); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4326 | |
| 4327 | if (QDF_IS_STATUS_ERROR(status)) |
| 4328 | hdd_err("Failed to %s DFS channels", |
| 4329 | enable_dfs_channels ? "enable" : "disable"); |
| 4330 | |
| 4331 | return qdf_status_to_os_return(status); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4332 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4333 | |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4334 | /** |
| 4335 | * __wlan_hdd_cfg80211_disable_dfs_chan_scan() - DFS channel configuration |
| 4336 | * @wiphy: corestack handler |
| 4337 | * @wdev: wireless device |
| 4338 | * @data: data |
| 4339 | * @data_len: data length |
| 4340 | * Return: success(0) or reason code for failure |
| 4341 | */ |
| 4342 | static int __wlan_hdd_cfg80211_disable_dfs_chan_scan(struct wiphy *wiphy, |
| 4343 | struct wireless_dev *wdev, |
| 4344 | const void *data, |
| 4345 | int data_len) |
| 4346 | { |
| 4347 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4348 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4349 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1]; |
| 4350 | int ret_val; |
| 4351 | uint32_t no_dfs_flag = 0; |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 4352 | bool enable_dfs_scan = true; |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4353 | hdd_enter_dev(dev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 4354 | |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4355 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4356 | if (ret_val) |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4357 | return ret_val; |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4358 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 4359 | if (wlan_cfg80211_nla_parse(tb, |
| 4360 | QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX, |
| 4361 | data, data_len, |
| 4362 | wlan_hdd_set_no_dfs_flag_config_policy)) { |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4363 | hdd_err("invalid attr"); |
| 4364 | return -EINVAL; |
| 4365 | } |
| 4366 | |
| 4367 | if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) { |
| 4368 | hdd_err("attr dfs flag failed"); |
| 4369 | return -EINVAL; |
| 4370 | } |
| 4371 | |
| 4372 | no_dfs_flag = nla_get_u32( |
| 4373 | tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]); |
| 4374 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 4375 | hdd_debug("DFS flag: %d", no_dfs_flag); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4376 | |
| 4377 | if (no_dfs_flag > 1) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 4378 | hdd_err("invalid value of dfs flag"); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4379 | return -EINVAL; |
| 4380 | } |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 4381 | ucfg_scan_cfg_get_dfs_chan_scan_allowed(hdd_ctx->psoc, |
| 4382 | &enable_dfs_scan); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4383 | |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 4384 | if (enable_dfs_scan) { |
bings | 50112bb | 2018-12-21 15:51:51 +0800 | [diff] [blame] | 4385 | ret_val = wlan_hdd_enable_dfs_chan_scan(hdd_ctx, !no_dfs_flag); |
| 4386 | } else { |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 4387 | if ((!no_dfs_flag) != enable_dfs_scan) { |
bings | 50112bb | 2018-12-21 15:51:51 +0800 | [diff] [blame] | 4388 | hdd_err("DFS chan ini configured %d, no dfs flag: %d", |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 4389 | enable_dfs_scan, |
bings | 50112bb | 2018-12-21 15:51:51 +0800 | [diff] [blame] | 4390 | no_dfs_flag); |
| 4391 | return -EINVAL; |
| 4392 | } |
| 4393 | } |
| 4394 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4395 | return ret_val; |
| 4396 | } |
| 4397 | |
| 4398 | /** |
| 4399 | * wlan_hdd_cfg80211_disable_dfs_chan_scan () - DFS scan vendor command |
| 4400 | * |
| 4401 | * @wiphy: wiphy device pointer |
| 4402 | * @wdev: wireless device pointer |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4403 | * @data: Vendor command data buffer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4404 | * @data_len: Buffer length |
| 4405 | * |
| 4406 | * Handles QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX. Validate it and |
| 4407 | * call wlan_hdd_disable_dfs_chan_scan to send it to firmware. |
| 4408 | * |
| 4409 | * Return: EOK or other error codes. |
| 4410 | */ |
| 4411 | |
| 4412 | static int wlan_hdd_cfg80211_disable_dfs_chan_scan(struct wiphy *wiphy, |
| 4413 | struct wireless_dev *wdev, |
| 4414 | const void *data, |
| 4415 | int data_len) |
| 4416 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 4417 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4418 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 4419 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 4420 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4421 | if (errno) |
| 4422 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4423 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4424 | errno = __wlan_hdd_cfg80211_disable_dfs_chan_scan(wiphy, wdev, |
| 4425 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4426 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 4427 | osif_psoc_sync_op_stop(psoc_sync); |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 4428 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4429 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4430 | } |
| 4431 | |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4432 | static const struct nla_policy |
| 4433 | wlan_hdd_wisa_cmd_policy[QCA_WLAN_VENDOR_ATTR_WISA_MAX + 1] = { |
| 4434 | [QCA_WLAN_VENDOR_ATTR_WISA_MODE] = {.type = NLA_U32 }, |
| 4435 | }; |
| 4436 | |
| 4437 | /** |
| 4438 | * __wlan_hdd_cfg80211_handle_wisa_cmd() - Handle WISA vendor cmd |
| 4439 | * @wiphy: wiphy device pointer |
| 4440 | * @wdev: wireless device pointer |
| 4441 | * @data: Vendor command data buffer |
| 4442 | * @data_len: Buffer length |
| 4443 | * |
| 4444 | * Handles QCA_WLAN_VENDOR_SUBCMD_WISA. Validate cmd attributes and |
| 4445 | * setup WISA Mode features. |
| 4446 | * |
| 4447 | * Return: Success(0) or reason code for failure |
| 4448 | */ |
| 4449 | static int __wlan_hdd_cfg80211_handle_wisa_cmd(struct wiphy *wiphy, |
| 4450 | struct wireless_dev *wdev, const void *data, int data_len) |
| 4451 | { |
| 4452 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 4453 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4454 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4455 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WISA_MAX + 1]; |
| 4456 | struct sir_wisa_params wisa; |
| 4457 | int ret_val; |
| 4458 | QDF_STATUS status; |
| 4459 | bool wisa_mode; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4460 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 4461 | void *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4462 | mac_handle_t mac_handle; |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4463 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4464 | hdd_enter_dev(dev); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4465 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 4466 | if (ret_val) |
| 4467 | goto err; |
| 4468 | |
| 4469 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 4470 | hdd_err("Command not allowed in FTM mode"); |
| 4471 | return -EPERM; |
| 4472 | } |
| 4473 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 4474 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WISA_MAX, data, |
| 4475 | data_len, wlan_hdd_wisa_cmd_policy)) { |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4476 | hdd_err("Invalid WISA cmd attributes"); |
| 4477 | ret_val = -EINVAL; |
| 4478 | goto err; |
| 4479 | } |
| 4480 | if (!tb[QCA_WLAN_VENDOR_ATTR_WISA_MODE]) { |
| 4481 | hdd_err("Invalid WISA mode"); |
| 4482 | ret_val = -EINVAL; |
| 4483 | goto err; |
| 4484 | } |
| 4485 | |
| 4486 | wisa_mode = !!nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_WISA_MODE]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 4487 | hdd_debug("WISA Mode: %d", wisa_mode); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4488 | wisa.mode = wisa_mode; |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 4489 | wisa.vdev_id = adapter->vdev_id; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4490 | mac_handle = hdd_ctx->mac_handle; |
| 4491 | status = sme_set_wisa_params(mac_handle, &wisa); |
Manikandan Mohan | b6315dd | 2016-05-10 16:16:36 -0700 | [diff] [blame] | 4492 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 4493 | hdd_err("Unable to set WISA mode: %d to FW", wisa_mode); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4494 | ret_val = -EINVAL; |
Manikandan Mohan | b6315dd | 2016-05-10 16:16:36 -0700 | [diff] [blame] | 4495 | } |
| 4496 | if (QDF_IS_STATUS_SUCCESS(status) || wisa_mode == false) |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4497 | cdp_set_wisa_mode(soc, |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4498 | (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc, |
| 4499 | (struct cdp_pdev *)pdev, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 4500 | adapter->vdev_id), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4501 | wisa_mode); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4502 | err: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4503 | hdd_exit(); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4504 | return ret_val; |
| 4505 | } |
| 4506 | |
| 4507 | /** |
| 4508 | * wlan_hdd_cfg80211_handle_wisa_cmd() - Handle WISA vendor cmd |
| 4509 | * @wiphy: corestack handler |
| 4510 | * @wdev: wireless device |
| 4511 | * @data: data |
| 4512 | * @data_len: data length |
| 4513 | * |
| 4514 | * Handles QCA_WLAN_VENDOR_SUBCMD_WISA. Validate cmd attributes and |
| 4515 | * setup WISA mode features. |
| 4516 | * |
| 4517 | * Return: Success(0) or reason code for failure |
| 4518 | */ |
| 4519 | static int wlan_hdd_cfg80211_handle_wisa_cmd(struct wiphy *wiphy, |
| 4520 | struct wireless_dev *wdev, |
| 4521 | const void *data, |
| 4522 | int data_len) |
| 4523 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 4524 | int errno; |
| 4525 | struct osif_vdev_sync *vdev_sync; |
| 4526 | |
| 4527 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 4528 | if (errno) |
| 4529 | return errno; |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4530 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 4531 | errno = __wlan_hdd_cfg80211_handle_wisa_cmd(wiphy, wdev, |
| 4532 | data, data_len); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4533 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 4534 | osif_vdev_sync_op_stop(vdev_sync); |
| 4535 | |
| 4536 | return errno; |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4537 | } |
| 4538 | |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 4539 | struct hdd_station_info *hdd_get_stainfo(struct hdd_station_info *astainfo, |
| 4540 | struct qdf_mac_addr mac_addr) |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4541 | { |
Jeff Johnson | 8215592 | 2017-09-30 16:54:14 -0700 | [diff] [blame] | 4542 | struct hdd_station_info *stainfo = NULL; |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4543 | int i; |
| 4544 | |
| 4545 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 4546 | if (!qdf_mem_cmp(&astainfo[i].sta_mac, |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4547 | &mac_addr, |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 4548 | QDF_MAC_ADDR_SIZE)) { |
| 4549 | stainfo = &astainfo[i]; |
| 4550 | break; |
| 4551 | } |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4552 | } |
| 4553 | |
| 4554 | return stainfo; |
| 4555 | } |
| 4556 | |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4557 | /* |
| 4558 | * undef short names defined for get station command |
| 4559 | * used by __wlan_hdd_cfg80211_get_station_cmd() |
| 4560 | */ |
| 4561 | #undef STATION_INVALID |
| 4562 | #undef STATION_INFO |
| 4563 | #undef STATION_ASSOC_FAIL_REASON |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4564 | #undef STATION_REMOTE |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4565 | #undef STATION_MAX |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4566 | #undef LINK_INFO_STANDARD_NL80211_ATTR |
| 4567 | #undef AP_INFO_STANDARD_NL80211_ATTR |
| 4568 | #undef INFO_ROAM_COUNT |
| 4569 | #undef INFO_AKM |
| 4570 | #undef WLAN802_11_MODE |
| 4571 | #undef AP_INFO_HS20_INDICATION |
| 4572 | #undef HT_OPERATION |
| 4573 | #undef VHT_OPERATION |
| 4574 | #undef INFO_ASSOC_FAIL_REASON |
| 4575 | #undef REMOTE_MAX_PHY_RATE |
| 4576 | #undef REMOTE_TX_PACKETS |
| 4577 | #undef REMOTE_TX_BYTES |
| 4578 | #undef REMOTE_RX_PACKETS |
| 4579 | #undef REMOTE_RX_BYTES |
| 4580 | #undef REMOTE_LAST_TX_RATE |
| 4581 | #undef REMOTE_LAST_RX_RATE |
| 4582 | #undef REMOTE_WMM |
| 4583 | #undef REMOTE_SUPPORTED_MODE |
| 4584 | #undef REMOTE_AMPDU |
| 4585 | #undef REMOTE_TX_STBC |
| 4586 | #undef REMOTE_RX_STBC |
| 4587 | #undef REMOTE_CH_WIDTH |
| 4588 | #undef REMOTE_SGI_ENABLE |
| 4589 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
| 4590 | #undef REMOTE_PAD |
| 4591 | #endif |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4592 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4593 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 4594 | /** |
| 4595 | * __wlan_hdd_cfg80211_keymgmt_set_key() - Store the Keys in the driver session |
| 4596 | * @wiphy: pointer to wireless wiphy structure. |
| 4597 | * @wdev: pointer to wireless_dev structure. |
| 4598 | * @data: Pointer to the Key data |
| 4599 | * @data_len:Length of the data passed |
| 4600 | * |
| 4601 | * This is called when wlan driver needs to save the keys received via |
| 4602 | * vendor specific command. |
| 4603 | * |
| 4604 | * Return: Return the Success or Failure code. |
| 4605 | */ |
| 4606 | static int __wlan_hdd_cfg80211_keymgmt_set_key(struct wiphy *wiphy, |
| 4607 | struct wireless_dev *wdev, |
| 4608 | const void *data, int data_len) |
| 4609 | { |
| 4610 | uint8_t local_pmk[SIR_ROAM_SCAN_PSK_SIZE]; |
| 4611 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4612 | struct hdd_adapter *hdd_adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4613 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4614 | int status; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4615 | struct pmkid_mode_bits pmkid_modes; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4616 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4617 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4618 | hdd_enter_dev(dev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 4619 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4620 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4621 | hdd_err("Command not allowed in FTM mode"); |
| 4622 | return -EPERM; |
| 4623 | } |
| 4624 | |
Hanumanth Reddy Pothula | 5387485 | 2018-03-08 19:57:49 +0530 | [diff] [blame] | 4625 | if ((data == NULL) || (data_len <= 0) || |
| 4626 | (data_len > SIR_ROAM_SCAN_PSK_SIZE)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 4627 | hdd_err("Invalid data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4628 | return -EINVAL; |
| 4629 | } |
| 4630 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4631 | hdd_ctx = WLAN_HDD_GET_CTX(hdd_adapter); |
| 4632 | if (!hdd_ctx) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 4633 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4634 | return -EINVAL; |
| 4635 | } |
| 4636 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4637 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4638 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4639 | return status; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4640 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4641 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4642 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4643 | mac_handle = hdd_ctx->mac_handle; |
| 4644 | sme_update_roam_key_mgmt_offload_enabled(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 4645 | hdd_adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4646 | true, &pmkid_modes); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4647 | qdf_mem_zero(&local_pmk, SIR_ROAM_SCAN_PSK_SIZE); |
| 4648 | qdf_mem_copy(local_pmk, data, data_len); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 4649 | sme_roam_set_psk_pmk(mac_handle, hdd_adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 4650 | local_pmk, data_len); |
Ashish Kumar Dhanotiya | 3651083 | 2019-02-20 22:13:25 +0530 | [diff] [blame] | 4651 | qdf_mem_zero(&local_pmk, SIR_ROAM_SCAN_PSK_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4652 | return 0; |
| 4653 | } |
| 4654 | |
| 4655 | /** |
| 4656 | * wlan_hdd_cfg80211_keymgmt_set_key() - Store the Keys in the driver session |
| 4657 | * @wiphy: pointer to wireless wiphy structure. |
| 4658 | * @wdev: pointer to wireless_dev structure. |
| 4659 | * @data: Pointer to the Key data |
| 4660 | * @data_len:Length of the data passed |
| 4661 | * |
| 4662 | * This is called when wlan driver needs to save the keys received via |
| 4663 | * vendor specific command. |
| 4664 | * |
| 4665 | * Return: Return the Success or Failure code. |
| 4666 | */ |
| 4667 | static int wlan_hdd_cfg80211_keymgmt_set_key(struct wiphy *wiphy, |
| 4668 | struct wireless_dev *wdev, |
| 4669 | const void *data, int data_len) |
| 4670 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 4671 | int errno; |
| 4672 | struct osif_vdev_sync *vdev_sync; |
| 4673 | |
| 4674 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 4675 | if (errno) |
| 4676 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4677 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 4678 | errno = __wlan_hdd_cfg80211_keymgmt_set_key(wiphy, wdev, |
| 4679 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4680 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 4681 | osif_vdev_sync_op_stop(vdev_sync); |
| 4682 | |
| 4683 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4684 | } |
Varun Reddy Yeturu | bbbbe23 | 2016-02-29 14:01:57 -0800 | [diff] [blame] | 4685 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4686 | |
| 4687 | static const struct nla_policy qca_wlan_vendor_get_wifi_info_policy[ |
| 4688 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1] = { |
| 4689 | [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 }, |
| 4690 | [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 }, |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4691 | [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX] = {.type = NLA_U32 }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4692 | }; |
| 4693 | |
| 4694 | /** |
| 4695 | * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info |
| 4696 | * @wiphy: pointer to wireless wiphy structure. |
| 4697 | * @wdev: pointer to wireless_dev structure. |
| 4698 | * @data: Pointer to the data to be passed via vendor interface |
| 4699 | * @data_len:Length of the data to be passed |
| 4700 | * |
| 4701 | * This is called when wlan driver needs to send wifi driver related info |
| 4702 | * (driver/fw version) to the user space application upon request. |
| 4703 | * |
| 4704 | * Return: Return the Success or Failure code. |
| 4705 | */ |
| 4706 | static int |
| 4707 | __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy, |
| 4708 | struct wireless_dev *wdev, |
| 4709 | const void *data, int data_len) |
| 4710 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4711 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4712 | struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1]; |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4713 | tSirVersionString driver_version; |
| 4714 | tSirVersionString firmware_version; |
Varun Reddy Yeturu | eb29332 | 2017-04-16 21:53:13 -0700 | [diff] [blame] | 4715 | const char *hw_version; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4716 | uint32_t major_spid = 0, minor_spid = 0, siid = 0, crmid = 0; |
Varun Reddy Yeturu | eb29332 | 2017-04-16 21:53:13 -0700 | [diff] [blame] | 4717 | uint32_t sub_id = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4718 | int status; |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4719 | struct sk_buff *reply_skb; |
| 4720 | uint32_t skb_len = 0, count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4721 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4722 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 4723 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4724 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4725 | hdd_err("Command not allowed in FTM mode"); |
| 4726 | return -EPERM; |
| 4727 | } |
| 4728 | |
| 4729 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4730 | if (status) |
| 4731 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4732 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 4733 | if (wlan_cfg80211_nla_parse(tb_vendor, |
| 4734 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, |
| 4735 | data, data_len, |
| 4736 | qca_wlan_vendor_get_wifi_info_policy)) { |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4737 | hdd_err("WIFI_INFO_GET NL CMD parsing failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4738 | return -EINVAL; |
| 4739 | } |
| 4740 | |
| 4741 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) { |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 4742 | hdd_debug("Rcvd req for Driver version"); |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4743 | strlcpy(driver_version, QWLAN_VERSIONSTR, |
| 4744 | sizeof(driver_version)); |
| 4745 | skb_len += strlen(driver_version) + 1; |
| 4746 | count++; |
| 4747 | } |
| 4748 | |
| 4749 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 4750 | hdd_debug("Rcvd req for FW version"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4751 | hdd_get_fw_version(hdd_ctx, &major_spid, &minor_spid, &siid, |
| 4752 | &crmid); |
Varun Reddy Yeturu | eb29332 | 2017-04-16 21:53:13 -0700 | [diff] [blame] | 4753 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 4754 | hw_version = hdd_ctx->target_hw_name; |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4755 | snprintf(firmware_version, sizeof(firmware_version), |
Varun Reddy Yeturu | eb29332 | 2017-04-16 21:53:13 -0700 | [diff] [blame] | 4756 | "FW:%d.%d.%d.%d.%d HW:%s", major_spid, minor_spid, |
| 4757 | siid, crmid, sub_id, hw_version); |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4758 | skb_len += strlen(firmware_version) + 1; |
| 4759 | count++; |
| 4760 | } |
| 4761 | |
Rajeev Kumar Sirasanagandla | 551613d | 2018-05-16 17:21:01 +0530 | [diff] [blame] | 4762 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX]) { |
| 4763 | hdd_debug("Rcvd req for Radio index"); |
| 4764 | skb_len += sizeof(uint32_t); |
| 4765 | count++; |
| 4766 | } |
| 4767 | |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4768 | if (count == 0) { |
| 4769 | hdd_err("unknown attribute in get_wifi_info request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4770 | return -EINVAL; |
| 4771 | } |
| 4772 | |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4773 | skb_len += (NLA_HDRLEN * count) + NLMSG_HDRLEN; |
| 4774 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, skb_len); |
| 4775 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4776 | if (!reply_skb) { |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4777 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4778 | return -ENOMEM; |
| 4779 | } |
| 4780 | |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4781 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) { |
| 4782 | if (nla_put_string(reply_skb, |
| 4783 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION, |
| 4784 | driver_version)) |
| 4785 | goto error_nla_fail; |
| 4786 | } |
| 4787 | |
Hanumanth Reddy Pothula | 1046ccc | 2016-10-14 14:33:44 +0530 | [diff] [blame] | 4788 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) { |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4789 | if (nla_put_string(reply_skb, |
| 4790 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION, |
| 4791 | firmware_version)) |
| 4792 | goto error_nla_fail; |
| 4793 | } |
| 4794 | |
| 4795 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX]) { |
| 4796 | if (nla_put_u32(reply_skb, |
| 4797 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX, |
| 4798 | hdd_ctx->radio_index)) |
| 4799 | goto error_nla_fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4800 | } |
| 4801 | |
| 4802 | return cfg80211_vendor_cmd_reply(reply_skb); |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 4803 | |
| 4804 | error_nla_fail: |
| 4805 | hdd_err("nla put fail"); |
| 4806 | kfree_skb(reply_skb); |
| 4807 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4808 | } |
| 4809 | |
| 4810 | /** |
| 4811 | * wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info |
| 4812 | * @wiphy: pointer to wireless wiphy structure. |
| 4813 | * @wdev: pointer to wireless_dev structure. |
| 4814 | * @data: Pointer to the data to be passed via vendor interface |
| 4815 | * @data_len:Length of the data to be passed |
| 4816 | * |
| 4817 | * This is called when wlan driver needs to send wifi driver related info |
| 4818 | * (driver/fw version) to the user space application upon request. |
| 4819 | * |
| 4820 | * Return: Return the Success or Failure code. |
| 4821 | */ |
| 4822 | static int |
| 4823 | wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy, |
| 4824 | struct wireless_dev *wdev, |
| 4825 | const void *data, int data_len) |
| 4826 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 4827 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4828 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4829 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 4830 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4831 | if (errno) |
| 4832 | return errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 4833 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4834 | errno = __wlan_hdd_cfg80211_get_wifi_info(wiphy, wdev, data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4835 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 4836 | osif_psoc_sync_op_stop(psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4837 | |
| 4838 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4839 | } |
| 4840 | |
| 4841 | /** |
| 4842 | * __wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features |
| 4843 | * @wiphy: pointer to wireless wiphy structure. |
| 4844 | * @wdev: pointer to wireless_dev structure. |
| 4845 | * @data: Pointer to the data to be passed via vendor interface |
| 4846 | * @data_len:Length of the data to be passed |
| 4847 | * |
| 4848 | * This is called by userspace to know the supported logger features |
| 4849 | * |
| 4850 | * Return: Return the Success or Failure code. |
| 4851 | */ |
| 4852 | static int |
| 4853 | __wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy, |
| 4854 | struct wireless_dev *wdev, |
| 4855 | const void *data, int data_len) |
| 4856 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4857 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4858 | int status; |
| 4859 | uint32_t features; |
| 4860 | struct sk_buff *reply_skb = NULL; |
| 4861 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4862 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 4863 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4864 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4865 | hdd_err("Command not allowed in FTM mode"); |
| 4866 | return -EPERM; |
| 4867 | } |
| 4868 | |
| 4869 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4870 | if (status) |
| 4871 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4872 | |
| 4873 | features = 0; |
| 4874 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4875 | features |= WIFI_LOGGER_PER_PACKET_TX_RX_STATUS_SUPPORTED; |
| 4876 | features |= WIFI_LOGGER_CONNECT_EVENT_SUPPORTED; |
| 4877 | features |= WIFI_LOGGER_WAKE_LOCK_SUPPORTED; |
Srinivas Girigowda | a26eac0 | 2018-01-23 12:49:20 -0800 | [diff] [blame] | 4878 | features |= WIFI_LOGGER_DRIVER_DUMP_SUPPORTED; |
Dundi Raviteja | b189b74 | 2018-05-08 15:59:57 +0530 | [diff] [blame] | 4879 | features |= WIFI_LOGGER_PACKET_FATE_SUPPORTED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4880 | |
| 4881 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 4882 | sizeof(uint32_t) + NLA_HDRLEN + NLMSG_HDRLEN); |
| 4883 | if (!reply_skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 4884 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4885 | return -ENOMEM; |
| 4886 | } |
| 4887 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 4888 | hdd_debug("Supported logger features: 0x%0x", features); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4889 | if (nla_put_u32(reply_skb, QCA_WLAN_VENDOR_ATTR_LOGGER_SUPPORTED, |
| 4890 | features)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 4891 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4892 | kfree_skb(reply_skb); |
| 4893 | return -EINVAL; |
| 4894 | } |
| 4895 | |
| 4896 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 4897 | } |
| 4898 | |
| 4899 | /** |
| 4900 | * wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features |
| 4901 | * @wiphy: pointer to wireless wiphy structure. |
| 4902 | * @wdev: pointer to wireless_dev structure. |
| 4903 | * @data: Pointer to the data to be passed via vendor interface |
| 4904 | * @data_len:Length of the data to be passed |
| 4905 | * |
| 4906 | * This is called by userspace to know the supported logger features |
| 4907 | * |
| 4908 | * Return: Return the Success or Failure code. |
| 4909 | */ |
| 4910 | static int |
| 4911 | wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy, |
| 4912 | struct wireless_dev *wdev, |
| 4913 | const void *data, int data_len) |
| 4914 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 4915 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4916 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 4917 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 4918 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4919 | if (errno) |
| 4920 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4921 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4922 | errno = __wlan_hdd_cfg80211_get_logger_supp_feature(wiphy, wdev, |
| 4923 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4924 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 4925 | osif_psoc_sync_op_stop(psoc_sync); |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 4926 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 4927 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4928 | } |
| 4929 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4930 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 4931 | void wlan_hdd_save_gtk_offload_params(struct hdd_adapter *adapter, |
| 4932 | uint8_t *kck_ptr, uint8_t *kek_ptr, |
| 4933 | uint32_t kek_len, uint8_t *replay_ctr, |
| 4934 | bool big_endian) |
| 4935 | { |
| 4936 | struct hdd_station_ctx *hdd_sta_ctx; |
| 4937 | uint8_t *buf; |
| 4938 | int i; |
| 4939 | struct pmo_gtk_req *gtk_req = NULL; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4940 | struct wlan_objmgr_vdev *vdev; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4941 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 4942 | |
| 4943 | gtk_req = qdf_mem_malloc(sizeof(*gtk_req)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 4944 | if (!gtk_req) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4945 | return; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4946 | |
| 4947 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 4948 | if (kck_ptr) |
| 4949 | qdf_mem_copy(gtk_req->kck, kck_ptr, NL80211_KCK_LEN); |
| 4950 | |
Jeff Johnson | e1f2b0e | 2017-11-14 14:42:55 -0800 | [diff] [blame] | 4951 | if (kek_ptr) { |
| 4952 | /* paranoia */ |
| 4953 | if (kek_len > sizeof(gtk_req->kek)) { |
| 4954 | kek_len = sizeof(gtk_req->kek); |
| 4955 | QDF_ASSERT(0); |
| 4956 | } |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4957 | qdf_mem_copy(gtk_req->kek, kek_ptr, kek_len); |
Jeff Johnson | e1f2b0e | 2017-11-14 14:42:55 -0800 | [diff] [blame] | 4958 | } |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4959 | |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 4960 | qdf_copy_macaddr(>k_req->bssid, &hdd_sta_ctx->conn_info.bssid); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4961 | |
| 4962 | gtk_req->kek_len = kek_len; |
gaurank kathpalia | 82a1b2b | 2018-07-10 16:49:10 +0530 | [diff] [blame] | 4963 | gtk_req->is_fils_connection = hdd_is_fils_connection(adapter); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4964 | |
| 4965 | /* convert big to little endian since driver work on little endian */ |
| 4966 | buf = (uint8_t *)>k_req->replay_counter; |
| 4967 | for (i = 0; i < 8; i++) |
| 4968 | buf[7 - i] = replay_ctr[i]; |
| 4969 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4970 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4971 | if (!vdev) |
| 4972 | goto end; |
| 4973 | status = ucfg_pmo_cache_gtk_offload_req(vdev, gtk_req); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4974 | hdd_objmgr_put_vdev(vdev); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4975 | if (status != QDF_STATUS_SUCCESS) |
| 4976 | hdd_err("Failed to cache GTK Offload"); |
| 4977 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4978 | end: |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4979 | qdf_mem_free(gtk_req); |
| 4980 | } |
| 4981 | #else |
| 4982 | void wlan_hdd_save_gtk_offload_params(struct hdd_adapter *adapter, |
| 4983 | uint8_t *kck_ptr, |
| 4984 | uint8_t *kek_ptr, |
| 4985 | uint32_t kek_len, |
| 4986 | uint8_t *replay_ctr, |
| 4987 | bool big_endian) |
| 4988 | { |
| 4989 | } |
| 4990 | #endif |
| 4991 | |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 4992 | #if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 4993 | /** |
| 4994 | * wlan_hdd_add_fils_params_roam_auth_event() - Adds FILS params in roam auth |
| 4995 | * @skb: SK buffer |
| 4996 | * @roam_info: Roam info |
| 4997 | * |
| 4998 | * API adds fils params[pmk, pmkid, next sequence number] to roam auth event |
| 4999 | * |
| 5000 | * Return: zero on success, error code on failure |
| 5001 | */ |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5002 | static int |
| 5003 | wlan_hdd_add_fils_params_roam_auth_event(struct sk_buff *skb, |
| 5004 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5005 | { |
| 5006 | if (roam_info->pmk_len && |
| 5007 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_PMK, |
| 5008 | roam_info->pmk_len, roam_info->pmk)) { |
| 5009 | hdd_err("pmk send fail"); |
| 5010 | return -EINVAL; |
| 5011 | } |
| 5012 | |
| 5013 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_PMKID, |
| 5014 | SIR_PMKID_LEN, roam_info->pmkid)) { |
| 5015 | hdd_err("pmkid send fail"); |
| 5016 | return -EINVAL; |
| 5017 | } |
| 5018 | |
Vignesh Viswanathan | 8da68cf | 2017-09-07 14:00:04 +0530 | [diff] [blame] | 5019 | hdd_debug("Update ERP Seq Num %d, Next ERP Seq Num %d", |
| 5020 | roam_info->update_erp_next_seq_num, |
| 5021 | roam_info->next_erp_seq_num); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5022 | if (roam_info->update_erp_next_seq_num && |
| 5023 | nla_put_u16(skb, |
| 5024 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_FILS_ERP_NEXT_SEQ_NUM, |
| 5025 | roam_info->next_erp_seq_num)) { |
| 5026 | hdd_err("ERP seq num send fail"); |
| 5027 | return -EINVAL; |
| 5028 | } |
| 5029 | |
| 5030 | return 0; |
| 5031 | } |
| 5032 | #else |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5033 | static inline int |
| 5034 | wlan_hdd_add_fils_params_roam_auth_event(struct sk_buff *skb, |
| 5035 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5036 | { |
| 5037 | return 0; |
| 5038 | } |
| 5039 | #endif |
| 5040 | |
Varun Reddy Yeturu | bbbbe23 | 2016-02-29 14:01:57 -0800 | [diff] [blame] | 5041 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5042 | /** |
| 5043 | * wlan_hdd_send_roam_auth_event() - Send the roamed and authorized event |
Prakash Dhavali | 989127d | 2016-11-29 14:56:44 +0530 | [diff] [blame] | 5044 | * @adapter: Pointer to adapter struct |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5045 | * @bssid: pointer to bssid of roamed AP. |
| 5046 | * @req_rsn_ie: Pointer to request RSN IE |
| 5047 | * @req_rsn_len: Length of the request RSN IE |
| 5048 | * @rsp_rsn_ie: Pointer to response RSN IE |
| 5049 | * @rsp_rsn_len: Length of the response RSN IE |
| 5050 | * @roam_info_ptr: Pointer to the roaming related information |
| 5051 | * |
| 5052 | * This is called when wlan driver needs to send the roaming and |
| 5053 | * authorization information after roaming. |
| 5054 | * |
| 5055 | * The information that would be sent is the request RSN IE, response |
| 5056 | * RSN IE and BSSID of the newly roamed AP. |
| 5057 | * |
| 5058 | * If the Authorized status is authenticated, then additional parameters |
| 5059 | * like PTK's KCK and KEK and Replay Counter would also be passed to the |
| 5060 | * supplicant. |
| 5061 | * |
| 5062 | * The supplicant upon receiving this event would ignore the legacy |
| 5063 | * cfg80211_roamed call and use the entire information from this event. |
| 5064 | * The cfg80211_roamed should still co-exist since the kernel will |
| 5065 | * make use of the parameters even if the supplicant ignores it. |
| 5066 | * |
| 5067 | * Return: Return the Success or Failure code. |
| 5068 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 5069 | int wlan_hdd_send_roam_auth_event(struct hdd_adapter *adapter, uint8_t *bssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5070 | uint8_t *req_rsn_ie, uint32_t req_rsn_len, uint8_t *rsp_rsn_ie, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5071 | uint32_t rsp_rsn_len, struct csr_roam_info *roam_info_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5072 | { |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 5073 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5074 | struct sk_buff *skb = NULL; |
Varun Reddy Yeturu | 16e8f01 | 2016-02-03 17:21:09 -0800 | [diff] [blame] | 5075 | eCsrAuthType auth_type; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5076 | uint32_t fils_params_len; |
| 5077 | int status; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5078 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5079 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5080 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 5081 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5082 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5083 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 5084 | if (!roaming_offload_enabled(hdd_ctx) || |
| 5085 | !roam_info_ptr->roamSynchInProgress) |
Prashanth Bhatta | bfc2529 | 2015-11-05 11:16:21 -0800 | [diff] [blame] | 5086 | return 0; |
| 5087 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5088 | /* |
| 5089 | * PMK is sent from FW in Roam Synch Event for FILS Roaming. |
| 5090 | * In that case, add three more NL attributes.ie. PMK, PMKID |
| 5091 | * and ERP next sequence number. Add corresponding lengths |
| 5092 | * with 3 extra NL message headers for each of the |
| 5093 | * aforementioned params. |
| 5094 | */ |
| 5095 | fils_params_len = roam_info_ptr->pmk_len + SIR_PMKID_LEN + |
| 5096 | sizeof(uint16_t) + (3 * NLMSG_HDRLEN); |
| 5097 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 5098 | skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Prakash Dhavali | 989127d | 2016-11-29 14:56:44 +0530 | [diff] [blame] | 5099 | &(adapter->wdev), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5100 | ETH_ALEN + req_rsn_len + rsp_rsn_len + |
| 5101 | sizeof(uint8_t) + SIR_REPLAY_CTR_LEN + |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5102 | SIR_KCK_KEY_LEN + roam_info_ptr->kek_len + |
| 5103 | sizeof(uint8_t) + (8 * NLMSG_HDRLEN) + |
| 5104 | fils_params_len, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5105 | QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH_INDEX, |
| 5106 | GFP_KERNEL); |
| 5107 | |
| 5108 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 5109 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5110 | return -EINVAL; |
| 5111 | } |
| 5112 | |
| 5113 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_BSSID, |
| 5114 | ETH_ALEN, bssid) || |
| 5115 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_REQ_IE, |
| 5116 | req_rsn_len, req_rsn_ie) || |
| 5117 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_RESP_IE, |
| 5118 | rsp_rsn_len, rsp_rsn_ie)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 5119 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5120 | goto nla_put_failure; |
| 5121 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5122 | if (roam_info_ptr->synchAuthStatus == |
| 5123 | CSR_ROAM_AUTH_STATUS_AUTHENTICATED) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 5124 | hdd_debug("Include Auth Params TLV's"); |
Naveen Rawat | 14298b9 | 2015-11-25 16:27:41 -0800 | [diff] [blame] | 5125 | if (nla_put_u8(skb, |
| 5126 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_AUTHORIZED, true)) { |
| 5127 | hdd_err("nla put fail"); |
| 5128 | goto nla_put_failure; |
| 5129 | } |
Varun Reddy Yeturu | 16e8f01 | 2016-02-03 17:21:09 -0800 | [diff] [blame] | 5130 | auth_type = roam_info_ptr->u.pConnectedProfile->AuthType; |
| 5131 | /* if FT or CCKM connection: dont send replay counter */ |
| 5132 | if (auth_type != eCSR_AUTH_TYPE_FT_RSN && |
| 5133 | auth_type != eCSR_AUTH_TYPE_FT_RSN_PSK && |
Pragaspathi Thilagaraj | 96259b2 | 2019-02-15 01:08:27 +0530 | [diff] [blame] | 5134 | auth_type != eCSR_AUTH_TYPE_FT_SAE && |
| 5135 | auth_type != eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384 && |
Varun Reddy Yeturu | 16e8f01 | 2016-02-03 17:21:09 -0800 | [diff] [blame] | 5136 | auth_type != eCSR_AUTH_TYPE_CCKM_WPA && |
| 5137 | auth_type != eCSR_AUTH_TYPE_CCKM_RSN && |
| 5138 | nla_put(skb, |
| 5139 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_KEY_REPLAY_CTR, |
| 5140 | SIR_REPLAY_CTR_LEN, |
| 5141 | roam_info_ptr->replay_ctr)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 5142 | hdd_err("non FT/non CCKM connection"); |
| 5143 | hdd_err("failed to send replay counter"); |
Naveen Rawat | 14298b9 | 2015-11-25 16:27:41 -0800 | [diff] [blame] | 5144 | goto nla_put_failure; |
| 5145 | } |
Vignesh Viswanathan | 62d9899 | 2017-11-30 12:30:37 +0530 | [diff] [blame] | 5146 | if (roam_info_ptr->kek_len > SIR_KEK_KEY_LEN_FILS || |
| 5147 | nla_put(skb, |
Naveen Rawat | 14298b9 | 2015-11-25 16:27:41 -0800 | [diff] [blame] | 5148 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_PTK_KCK, |
| 5149 | SIR_KCK_KEY_LEN, roam_info_ptr->kck) || |
| 5150 | nla_put(skb, |
| 5151 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_PTK_KEK, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5152 | roam_info_ptr->kek_len, roam_info_ptr->kek)) { |
Vignesh Viswanathan | 62d9899 | 2017-11-30 12:30:37 +0530 | [diff] [blame] | 5153 | hdd_err("nla put fail, kek_len %d", |
| 5154 | roam_info_ptr->kek_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5155 | goto nla_put_failure; |
| 5156 | } |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5157 | |
| 5158 | status = wlan_hdd_add_fils_params_roam_auth_event(skb, |
| 5159 | roam_info_ptr); |
| 5160 | if (status) |
| 5161 | goto nla_put_failure; |
| 5162 | |
| 5163 | /* |
| 5164 | * Save the gtk rekey parameters in HDD STA context. They will |
| 5165 | * be used next time when host enables GTK offload and goes |
| 5166 | * into power save state. |
| 5167 | */ |
| 5168 | wlan_hdd_save_gtk_offload_params(adapter, roam_info_ptr->kck, |
| 5169 | roam_info_ptr->kek, |
| 5170 | roam_info_ptr->kek_len, |
| 5171 | roam_info_ptr->replay_ctr, |
| 5172 | true); |
| 5173 | hdd_debug("roam_info_ptr->replay_ctr 0x%llx", |
| 5174 | *((uint64_t *)roam_info_ptr->replay_ctr)); |
| 5175 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5176 | } else { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 5177 | hdd_debug("No Auth Params TLV's"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5178 | if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_AUTHORIZED, |
| 5179 | false)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 5180 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5181 | goto nla_put_failure; |
| 5182 | } |
| 5183 | } |
| 5184 | |
Selvaraj, Sridhar | d1225e6 | 2017-03-17 12:56:58 +0530 | [diff] [blame] | 5185 | hdd_debug("Auth Status = %d Subnet Change Status = %d", |
| 5186 | roam_info_ptr->synchAuthStatus, |
| 5187 | roam_info_ptr->subnet_change_status); |
Ravi Joshi | 277ae9b | 2015-11-13 11:30:43 -0800 | [diff] [blame] | 5188 | |
| 5189 | /* |
| 5190 | * Add subnet change status if subnet has changed |
| 5191 | * 0 = unchanged |
| 5192 | * 1 = changed |
| 5193 | * 2 = unknown |
| 5194 | */ |
| 5195 | if (roam_info_ptr->subnet_change_status) { |
| 5196 | if (nla_put_u8(skb, |
| 5197 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_SUBNET_STATUS, |
| 5198 | roam_info_ptr->subnet_change_status)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 5199 | hdd_err("nla put fail"); |
Ravi Joshi | 277ae9b | 2015-11-13 11:30:43 -0800 | [diff] [blame] | 5200 | goto nla_put_failure; |
| 5201 | } |
| 5202 | } |
| 5203 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5204 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 5205 | return 0; |
| 5206 | |
| 5207 | nla_put_failure: |
| 5208 | kfree_skb(skb); |
| 5209 | return -EINVAL; |
| 5210 | } |
Varun Reddy Yeturu | bbbbe23 | 2016-02-29 14:01:57 -0800 | [diff] [blame] | 5211 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5212 | |
Jeff Johnson | 91f90ff | 2018-11-16 07:53:37 -0800 | [diff] [blame] | 5213 | #define ANT_DIV_SET_PERIOD(probe_period, stay_period) \ |
| 5214 | ((1 << 26) | \ |
| 5215 | (((probe_period) & 0x1fff) << 13) | \ |
| 5216 | ((stay_period) & 0x1fff)) |
| 5217 | |
| 5218 | #define ANT_DIV_SET_SNR_DIFF(snr_diff) \ |
| 5219 | ((1 << 27) | \ |
| 5220 | ((snr_diff) & 0x1fff)) |
| 5221 | |
| 5222 | #define ANT_DIV_SET_PROBE_DWELL_TIME(probe_dwell_time) \ |
| 5223 | ((1 << 28) | \ |
| 5224 | ((probe_dwell_time) & 0x1fff)) |
| 5225 | |
| 5226 | #define ANT_DIV_SET_WEIGHT(mgmt_snr_weight, data_snr_weight, ack_snr_weight) \ |
| 5227 | ((1 << 29) | \ |
| 5228 | (((mgmt_snr_weight) & 0xff) << 16) | \ |
| 5229 | (((data_snr_weight) & 0xff) << 8) | \ |
| 5230 | ((ack_snr_weight) & 0xff)) |
| 5231 | |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5232 | #define RX_REORDER_TIMEOUT_VOICE \ |
| 5233 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_REORDER_TIMEOUT_VOICE |
| 5234 | #define RX_REORDER_TIMEOUT_VIDEO \ |
| 5235 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_REORDER_TIMEOUT_VIDEO |
| 5236 | #define RX_REORDER_TIMEOUT_BESTEFFORT \ |
| 5237 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_REORDER_TIMEOUT_BESTEFFORT |
| 5238 | #define RX_REORDER_TIMEOUT_BACKGROUND \ |
| 5239 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_REORDER_TIMEOUT_BACKGROUND |
| 5240 | #define RX_BLOCKSIZE_PEER_MAC \ |
| 5241 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_BLOCKSIZE_PEER_MAC |
| 5242 | #define RX_BLOCKSIZE_WINLIMIT \ |
| 5243 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_BLOCKSIZE_WINLIMIT |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5244 | static const struct nla_policy |
| 5245 | wlan_hdd_wifi_config_policy[QCA_WLAN_VENDOR_ATTR_CONFIG_MAX + 1] = { |
| 5246 | |
| 5247 | [QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM] = {.type = NLA_U32 }, |
| 5248 | [QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR] = {.type = NLA_U16 }, |
| 5249 | [QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME] = {.type = NLA_U32 }, |
Jeff Johnson | 79f6a60 | 2017-06-15 09:48:25 -0700 | [diff] [blame] | 5250 | [QCA_WLAN_VENDOR_ATTR_CONFIG_FINE_TIME_MEASUREMENT] = {.type = NLA_U32}, |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 5251 | [QCA_WLAN_VENDOR_ATTR_CONFIG_CHANNEL_AVOIDANCE_IND] = {.type = NLA_U8 }, |
Padma, Santhosh Kumar | a711967 | 2016-08-16 16:05:14 +0530 | [diff] [blame] | 5252 | [QCA_WLAN_VENDOR_ATTR_CONFIG_TX_MPDU_AGGREGATION] = {.type = NLA_U8 }, |
| 5253 | [QCA_WLAN_VENDOR_ATTR_CONFIG_RX_MPDU_AGGREGATION] = {.type = NLA_U8 }, |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 5254 | [QCA_WLAN_VENDOR_ATTR_CONFIG_NON_AGG_RETRY] = {.type = NLA_U8 }, |
| 5255 | [QCA_WLAN_VENDOR_ATTR_CONFIG_AGG_RETRY] = {.type = NLA_U8 }, |
| 5256 | [QCA_WLAN_VENDOR_ATTR_CONFIG_MGMT_RETRY] = {.type = NLA_U8 }, |
| 5257 | [QCA_WLAN_VENDOR_ATTR_CONFIG_CTRL_RETRY] = {.type = NLA_U8 }, |
| 5258 | [QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_DELAY] = {.type = NLA_U8 }, |
Jeff Johnson | 8fb9ded | 2018-11-15 20:44:56 -0800 | [diff] [blame] | 5259 | [QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_ABS_DELAY] = { |
| 5260 | .type = NLA_U32 }, |
Agrawal, Ashish | b45599a | 2016-10-27 14:55:30 +0530 | [diff] [blame] | 5261 | [QCA_WLAN_VENDOR_ATTR_CONFIG_TX_FAIL_COUNT] = {.type = NLA_U32 }, |
Jeff Johnson | 7bf20cb | 2018-11-16 17:38:27 -0800 | [diff] [blame] | 5262 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_PERIOD] = {.type = NLA_U32}, |
| 5263 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_STAY_PERIOD] = {.type = NLA_U32}, |
Jeff Johnson | 91f90ff | 2018-11-16 07:53:37 -0800 | [diff] [blame] | 5264 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SNR_DIFF] = {.type = NLA_U32}, |
Jeff Johnson | 77177bc | 2018-11-16 08:14:20 -0800 | [diff] [blame] | 5265 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_DWELL_TIME] = { |
| 5266 | .type = NLA_U32}, |
Jeff Johnson | 1350e62 | 2018-11-16 18:36:55 -0800 | [diff] [blame] | 5267 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_MGMT_SNR_WEIGHT] = { |
| 5268 | .type = NLA_U32}, |
| 5269 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_DATA_SNR_WEIGHT] = { |
| 5270 | .type = NLA_U32}, |
| 5271 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_ACK_SNR_WEIGHT] = { |
| 5272 | .type = NLA_U32}, |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5273 | [QCA_WLAN_VENDOR_ATTR_CONFIG_RESTRICT_OFFCHANNEL] = {.type = NLA_U8}, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5274 | [RX_REORDER_TIMEOUT_VOICE] = {.type = NLA_U32}, |
| 5275 | [RX_REORDER_TIMEOUT_VIDEO] = {.type = NLA_U32}, |
| 5276 | [RX_REORDER_TIMEOUT_BESTEFFORT] = {.type = NLA_U32}, |
| 5277 | [RX_REORDER_TIMEOUT_BACKGROUND] = {.type = NLA_U32}, |
Jeff Johnson | 19a5a7e | 2017-06-15 14:51:26 -0700 | [diff] [blame] | 5278 | [RX_BLOCKSIZE_PEER_MAC] = { |
| 5279 | .type = NLA_UNSPEC, |
| 5280 | .len = QDF_MAC_ADDR_SIZE}, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5281 | [RX_BLOCKSIZE_WINLIMIT] = {.type = NLA_U32}, |
Mukul Sharma | 6398b25 | 2017-05-01 17:58:12 +0530 | [diff] [blame] | 5282 | [QCA_WLAN_VENDOR_ATTR_CONFIG_LISTEN_INTERVAL] = {.type = NLA_U32 }, |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 5283 | [QCA_WLAN_VENDOR_ATTR_CONFIG_LRO] = {.type = NLA_U8 }, |
Jeff Johnson | 1feb8a6 | 2018-11-14 13:18:41 -0800 | [diff] [blame] | 5284 | [QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER] = {.type = NLA_U8 }, |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 5285 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_ENA] = {.type = NLA_U32 }, |
| 5286 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_CHAIN] = {.type = NLA_U32 }, |
| 5287 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SELFTEST] = {.type = NLA_U32 }, |
| 5288 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SELFTEST_INTVL] = {.type = NLA_U32 }, |
Paul Zhang | 99fe884 | 2017-12-08 14:43:46 +0800 | [diff] [blame] | 5289 | [QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL] = {.type = NLA_U16 }, |
Nachiket Kukade | aaf8a71 | 2017-07-27 19:15:36 +0530 | [diff] [blame] | 5290 | [QCA_WLAN_VENDOR_ATTR_CONFIG_TOTAL_BEACON_MISS_COUNT] = {.type = NLA_U8}, |
Sandeep Puligilla | 24b7aa7 | 2017-10-13 18:05:14 -0700 | [diff] [blame] | 5291 | [QCA_WLAN_VENDOR_ATTR_CONFIG_SCAN_ENABLE] = {.type = NLA_U8 }, |
Abhishek Singh | 6454ad3 | 2017-12-20 10:42:21 +0530 | [diff] [blame] | 5292 | [QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE] = {.type = NLA_U8}, |
Ashish Kumar Dhanotiya | 1e20bcc | 2018-06-15 11:28:51 +0530 | [diff] [blame] | 5293 | [QCA_WLAN_VENDOR_ATTR_CONFIG_GTX] = {.type = NLA_U8}, |
Jeff Johnson | affc4da | 2018-11-16 14:10:07 -0800 | [diff] [blame] | 5294 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY] = {.type = NLA_U32 }, |
| 5295 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY_IE_LIST] = { |
| 5296 | .type = NLA_BINARY, |
| 5297 | .len = SIR_MAC_MAX_IE_LENGTH + 2}, |
| 5298 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5299 | }; |
| 5300 | |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 5301 | static const struct nla_policy |
Kiran Kumar Lokere | acd107d | 2019-01-09 15:02:11 -0800 | [diff] [blame] | 5302 | qca_wlan_vendor_attr_he_omi_tx_policy [QCA_WLAN_VENDOR_ATTR_HE_OMI_MAX + 1] = { |
| 5303 | [QCA_WLAN_VENDOR_ATTR_HE_OMI_RX_NSS] = {.type = NLA_U8 }, |
| 5304 | [QCA_WLAN_VENDOR_ATTR_HE_OMI_CH_BW] = {.type = NLA_U8 }, |
| 5305 | [QCA_WLAN_VENDOR_ATTR_HE_OMI_ULMU_DISABLE] = {.type = NLA_U8 }, |
| 5306 | [QCA_WLAN_VENDOR_ATTR_HE_OMI_TX_NSTS] = {.type = NLA_U8 }, |
Kiran Kumar Lokere | 49e3aff | 2019-02-06 17:00:48 -0800 | [diff] [blame] | 5307 | [QCA_WLAN_VENDOR_ATTR_HE_OMI_ULMU_DATA_DISABLE] = {.type = NLA_U8 }, |
Kiran Kumar Lokere | acd107d | 2019-01-09 15:02:11 -0800 | [diff] [blame] | 5308 | }; |
| 5309 | |
| 5310 | static const struct nla_policy |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 5311 | wlan_hdd_wifi_test_config_policy[ |
| 5312 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_MAX + 1] = { |
| 5313 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WMM_ENABLE] = { |
| 5314 | .type = NLA_U8}, |
| 5315 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ACCEPT_ADDBA_REQ] = { |
| 5316 | .type = NLA_U8}, |
Kiran Kumar Lokere | 96246e5 | 2018-01-24 16:44:35 -0800 | [diff] [blame] | 5317 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_MCS] = { |
| 5318 | .type = NLA_U8}, |
Kiran Kumar Lokere | a934561 | 2018-02-08 14:28:24 -0800 | [diff] [blame] | 5319 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_SEND_ADDBA_REQ] = { |
| 5320 | .type = NLA_U8}, |
Kiran Kumar Lokere | 5cc2f0d | 2018-02-08 17:10:05 -0800 | [diff] [blame] | 5321 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_FRAGMENTATION] = { |
| 5322 | .type = NLA_U8}, |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 5323 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WEP_TKIP_IN_HE] = { |
| 5324 | .type = NLA_U8}, |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 5325 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADD_DEL_BA_SESSION] = { |
| 5326 | .type = NLA_U8}, |
| 5327 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_BA_TID] = { |
| 5328 | .type = NLA_U8}, |
| 5329 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADDBA_BUFF_SIZE] = { |
Kiran Kumar Lokere | eac7fe9 | 2018-07-24 16:56:01 -0700 | [diff] [blame] | 5330 | .type = NLA_U16}, |
Kiran Kumar Lokere | 3324f63 | 2018-03-01 21:43:21 -0800 | [diff] [blame] | 5331 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ENABLE_NO_ACK] = { |
| 5332 | .type = NLA_U8}, |
| 5333 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_NO_ACK_AC] = { |
| 5334 | .type = NLA_U8}, |
Kiran Kumar Lokere | a006a30 | 2018-03-07 20:58:13 -0800 | [diff] [blame] | 5335 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_LTF] = { |
| 5336 | .type = NLA_U8}, |
Kiran Kumar Lokere | 6c7f3fa | 2018-05-14 18:12:27 -0700 | [diff] [blame] | 5337 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ENABLE_TX_BEAMFORMEE] = { |
| 5338 | .type = NLA_U8}, |
Kiran Kumar Lokere | f304485 | 2018-06-27 14:14:24 -0700 | [diff] [blame] | 5339 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_TX_BEAMFORMEE_NSTS] = { |
| 5340 | .type = NLA_U8}, |
Kiran Kumar Lokere | f54b855 | 2018-07-10 00:53:38 -0700 | [diff] [blame] | 5341 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_MAC_PADDING_DUR] = { |
| 5342 | .type = NLA_U8}, |
Kiran Kumar Lokere | 8d685d1 | 2018-07-23 17:17:26 -0700 | [diff] [blame] | 5343 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_MU_EDCA_AC] = { |
| 5344 | .type = NLA_U8}, |
| 5345 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_OVERRIDE_MU_EDCA] = { |
| 5346 | .type = NLA_U8}, |
Kiran Kumar Lokere | f1a96f4 | 2018-08-29 18:53:47 -0700 | [diff] [blame] | 5347 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_OM_CTRL_SUPP] = { |
| 5348 | .type = NLA_U8}, |
Kiran Kumar Lokere | 9463415 | 2018-09-24 19:08:35 -0700 | [diff] [blame] | 5349 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_OM_CTRL_BW] = { |
| 5350 | .type = NLA_U8}, |
| 5351 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_OM_CTRL_NSS] = { |
| 5352 | .type = NLA_U8}, |
| 5353 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_CLEAR_HE_OM_CTRL_CONFIG] = { |
| 5354 | .type = NLA_FLAG}, |
Kiran Kumar Lokere | efdbd0b | 2018-09-25 18:53:46 -0700 | [diff] [blame] | 5355 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_TX_SUPPDU] = { |
| 5356 | .type = NLA_U8}, |
Kiran Kumar Lokere | acd107d | 2019-01-09 15:02:11 -0800 | [diff] [blame] | 5357 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_HTC_HE_SUPP] = { |
| 5358 | .type = NLA_U8}, |
| 5359 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_OMI_TX] = { |
| 5360 | .type = NLA_NESTED}, |
Kiran Kumar Lokere | ee20577 | 2018-09-27 00:27:27 -0700 | [diff] [blame] | 5361 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_ACTION_TX_TB_PPDU] = { |
| 5362 | .type = NLA_U8}, |
Kiran Kumar Lokere | 921b5a5 | 2019-02-24 21:53:20 -0800 | [diff] [blame] | 5363 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_SET_HE_TESTBED_DEFAULTS] |
| 5364 | = {.type = NLA_U8}, |
Kiran Kumar Lokere | a1c29ec | 2019-02-25 18:19:00 -0800 | [diff] [blame] | 5365 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ENABLE_2G_VHT] = { |
| 5366 | .type = NLA_U8}, |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 5367 | }; |
| 5368 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5369 | /** |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 5370 | * wlan_hdd_add_qcn_ie() - Add QCN IE to a given IE buffer |
| 5371 | * @ie_data: IE buffer |
| 5372 | * @ie_len: length of the @ie_data |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 5373 | * |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 5374 | * Return: QDF_STATUS |
| 5375 | */ |
| 5376 | static QDF_STATUS wlan_hdd_add_qcn_ie(uint8_t *ie_data, uint16_t *ie_len) |
| 5377 | { |
| 5378 | tDot11fIEQCN_IE qcn_ie; |
| 5379 | uint8_t qcn_ie_hdr[QCN_IE_HDR_LEN] |
| 5380 | = {IE_EID_VENDOR, DOT11F_IE_QCN_IE_MAX_LEN, |
| 5381 | 0x8C, 0xFD, 0xF0, 0x1}; |
| 5382 | |
| 5383 | if (((*ie_len) + QCN_IE_HDR_LEN + |
| 5384 | QCN_IE_VERSION_SUBATTR_DATA_LEN) > MAX_DEFAULT_SCAN_IE_LEN) { |
| 5385 | hdd_err("IE buffer not enough for QCN IE"); |
| 5386 | return QDF_STATUS_E_FAILURE; |
| 5387 | } |
| 5388 | |
| 5389 | /* Add QCN IE header */ |
| 5390 | qdf_mem_copy(ie_data + (*ie_len), qcn_ie_hdr, QCN_IE_HDR_LEN); |
| 5391 | (*ie_len) += QCN_IE_HDR_LEN; |
| 5392 | |
| 5393 | /* Retrieve Version sub-attribute data */ |
| 5394 | populate_dot11f_qcn_ie(&qcn_ie); |
| 5395 | |
| 5396 | /* Add QCN IE data[version sub attribute] */ |
| 5397 | qdf_mem_copy(ie_data + (*ie_len), qcn_ie.version, |
| 5398 | (QCN_IE_VERSION_SUBATTR_LEN)); |
| 5399 | (*ie_len) += (QCN_IE_VERSION_SUBATTR_LEN); |
| 5400 | |
| 5401 | return QDF_STATUS_SUCCESS; |
| 5402 | } |
| 5403 | |
| 5404 | /** |
| 5405 | * wlan_hdd_save_default_scan_ies() - API to store the default scan IEs |
| 5406 | * @hdd_ctx: HDD context |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 5407 | * @adapter: Pointer to HDD adapter |
| 5408 | * @ie_data: Pointer to Scan IEs buffer |
| 5409 | * @ie_len: Length of Scan IEs |
| 5410 | * |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 5411 | * This API is used to store the default scan ies received from |
| 5412 | * supplicant. Also saves QCN IE if g_qcn_ie_support INI is enabled |
| 5413 | * |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 5414 | * Return: 0 on success; error number otherwise |
| 5415 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 5416 | static int wlan_hdd_save_default_scan_ies(struct hdd_context *hdd_ctx, |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 5417 | struct hdd_adapter *adapter, |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 5418 | uint8_t *ie_data, uint16_t ie_len) |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 5419 | { |
Jeff Johnson | 3758894 | 2017-08-15 16:11:41 -0700 | [diff] [blame] | 5420 | struct hdd_scan_info *scan_info = &adapter->scan_info; |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 5421 | bool add_qcn_ie; |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 5422 | |
| 5423 | if (!scan_info) |
| 5424 | return -EINVAL; |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 5425 | |
| 5426 | if (scan_info->default_scan_ies) { |
| 5427 | qdf_mem_free(scan_info->default_scan_ies); |
| 5428 | scan_info->default_scan_ies = NULL; |
| 5429 | } |
| 5430 | |
Selvaraj, Sridhar | 8048dea | 2017-04-20 10:02:19 +0530 | [diff] [blame] | 5431 | scan_info->default_scan_ies_len = ie_len; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5432 | ucfg_mlme_get_qcn_ie_support(hdd_ctx->psoc, &add_qcn_ie); |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 5433 | if (add_qcn_ie) |
Selvaraj, Sridhar | 8048dea | 2017-04-20 10:02:19 +0530 | [diff] [blame] | 5434 | ie_len += (QCN_IE_HDR_LEN + QCN_IE_VERSION_SUBATTR_LEN); |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 5435 | |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 5436 | scan_info->default_scan_ies = qdf_mem_malloc(ie_len); |
Selvaraj, Sridhar | 8048dea | 2017-04-20 10:02:19 +0530 | [diff] [blame] | 5437 | if (!scan_info->default_scan_ies) { |
| 5438 | scan_info->default_scan_ies_len = 0; |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 5439 | return -ENOMEM; |
Selvaraj, Sridhar | 8048dea | 2017-04-20 10:02:19 +0530 | [diff] [blame] | 5440 | } |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 5441 | |
Selvaraj, Sridhar | 8048dea | 2017-04-20 10:02:19 +0530 | [diff] [blame] | 5442 | qdf_mem_copy(scan_info->default_scan_ies, ie_data, |
| 5443 | scan_info->default_scan_ies_len); |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 5444 | |
| 5445 | /* Add QCN IE if g_qcn_ie_support INI is enabled */ |
| 5446 | if (add_qcn_ie) |
| 5447 | wlan_hdd_add_qcn_ie(scan_info->default_scan_ies, |
| 5448 | &(scan_info->default_scan_ies_len)); |
| 5449 | |
| 5450 | hdd_debug("Saved default scan IE:"); |
| 5451 | qdf_trace_hex_dump(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG, |
| 5452 | (uint8_t *) scan_info->default_scan_ies, |
| 5453 | scan_info->default_scan_ies_len); |
| 5454 | |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 5455 | return 0; |
| 5456 | } |
| 5457 | |
| 5458 | /** |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5459 | * wlan_hdd_handle_restrict_offchan_config() - |
| 5460 | * Handle wifi configuration attribute : |
| 5461 | * QCA_WLAN_VENDOR_ATTR_CONFIG_RESTRICT_OFFCHANNEL |
| 5462 | * @adapter: Pointer to HDD adapter |
| 5463 | * @restrict_offchan: Restrict offchannel setting done by |
| 5464 | * application |
| 5465 | * |
| 5466 | * Return: 0 on success; error number otherwise |
| 5467 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 5468 | static int wlan_hdd_handle_restrict_offchan_config(struct hdd_adapter *adapter, |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5469 | u8 restrict_offchan) |
| 5470 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 5471 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 5472 | enum QDF_OPMODE dev_mode = adapter->device_mode; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5473 | struct wlan_objmgr_vdev *vdev; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5474 | int ret_val = 0; |
| 5475 | |
| 5476 | if (!(dev_mode == QDF_SAP_MODE || dev_mode == QDF_P2P_GO_MODE)) { |
| 5477 | hdd_err("Invalid interface type:%d", dev_mode); |
| 5478 | return -EINVAL; |
| 5479 | } |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5480 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5481 | if (!vdev) |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 5482 | return -EINVAL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5483 | if (restrict_offchan == 1) { |
| 5484 | enum policy_mgr_con_mode pmode = |
| 5485 | policy_mgr_convert_device_mode_to_qdf_type(dev_mode); |
| 5486 | int chan; |
| 5487 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5488 | u32 vdev_id = wlan_vdev_get_id(vdev); |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5489 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5490 | wlan_vdev_obj_lock(vdev); |
| 5491 | wlan_vdev_mlme_cap_set(vdev, WLAN_VDEV_C_RESTRICT_OFFCHAN); |
| 5492 | wlan_vdev_obj_unlock(vdev); |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 5493 | chan = policy_mgr_get_channel(hdd_ctx->psoc, pmode, |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 5494 | &vdev_id); |
| 5495 | if (!chan || |
| 5496 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, chan)) { |
| 5497 | hdd_err("unable to send avoid_freq"); |
| 5498 | ret_val = -EINVAL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5499 | } |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 5500 | hdd_info("vdev %d mode %d dnbs enabled", vdev_id, dev_mode); |
| 5501 | } else if (restrict_offchan == 0) { |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5502 | wlan_vdev_obj_lock(vdev); |
| 5503 | wlan_vdev_mlme_cap_clear(vdev, WLAN_VDEV_C_RESTRICT_OFFCHAN); |
| 5504 | wlan_vdev_obj_unlock(vdev); |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 5505 | if (wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0)) { |
| 5506 | hdd_err("unable to clear avoid_freq"); |
| 5507 | ret_val = -EINVAL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5508 | } |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 5509 | hdd_info("vdev mode %d dnbs disabled", dev_mode); |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5510 | } else { |
| 5511 | ret_val = -EINVAL; |
| 5512 | hdd_err("Invalid RESTRICT_OFFCHAN setting"); |
| 5513 | } |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5514 | hdd_objmgr_put_vdev(vdev); |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5515 | return ret_val; |
| 5516 | } |
| 5517 | |
| 5518 | /** |
Jeff Johnson | 0dd687e | 2018-11-16 20:11:27 -0800 | [diff] [blame] | 5519 | * wlan_hdd_cfg80211_wifi_set_reorder_timeout() - set reorder timeout |
| 5520 | * @adapter: Pointer to HDD adapter |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5521 | * @tb: array of pointer to struct nlattr |
| 5522 | * |
| 5523 | * Return: 0 on success; error number otherwise |
| 5524 | */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 5525 | static |
Jeff Johnson | 0dd687e | 2018-11-16 20:11:27 -0800 | [diff] [blame] | 5526 | int wlan_hdd_cfg80211_wifi_set_reorder_timeout(struct hdd_adapter *adapter, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 5527 | struct nlattr *tb[]) |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5528 | { |
Jeff Johnson | 0dd687e | 2018-11-16 20:11:27 -0800 | [diff] [blame] | 5529 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 5530 | int ret_val = 0; |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5531 | QDF_STATUS qdf_status; |
| 5532 | struct sir_set_rx_reorder_timeout_val reorder_timeout; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 5533 | mac_handle_t mac_handle; |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5534 | |
| 5535 | #define RX_TIMEOUT_VAL_MIN 10 |
| 5536 | #define RX_TIMEOUT_VAL_MAX 1000 |
| 5537 | |
| 5538 | if (tb[RX_REORDER_TIMEOUT_VOICE] || |
| 5539 | tb[RX_REORDER_TIMEOUT_VIDEO] || |
| 5540 | tb[RX_REORDER_TIMEOUT_BESTEFFORT] || |
| 5541 | tb[RX_REORDER_TIMEOUT_BACKGROUND]) { |
| 5542 | |
| 5543 | /* if one is specified, all must be specified */ |
| 5544 | if (!tb[RX_REORDER_TIMEOUT_VOICE] || |
| 5545 | !tb[RX_REORDER_TIMEOUT_VIDEO] || |
| 5546 | !tb[RX_REORDER_TIMEOUT_BESTEFFORT] || |
| 5547 | !tb[RX_REORDER_TIMEOUT_BACKGROUND]) { |
| 5548 | hdd_err("four AC timeout val are required MAC"); |
| 5549 | return -EINVAL; |
| 5550 | } |
| 5551 | |
| 5552 | reorder_timeout.rx_timeout_pri[0] = nla_get_u32( |
| 5553 | tb[RX_REORDER_TIMEOUT_VOICE]); |
| 5554 | reorder_timeout.rx_timeout_pri[1] = nla_get_u32( |
| 5555 | tb[RX_REORDER_TIMEOUT_VIDEO]); |
| 5556 | reorder_timeout.rx_timeout_pri[2] = nla_get_u32( |
| 5557 | tb[RX_REORDER_TIMEOUT_BESTEFFORT]); |
| 5558 | reorder_timeout.rx_timeout_pri[3] = nla_get_u32( |
| 5559 | tb[RX_REORDER_TIMEOUT_BACKGROUND]); |
| 5560 | /* timeout value is required to be in the rang 10 to 1000ms */ |
| 5561 | if (reorder_timeout.rx_timeout_pri[0] >= RX_TIMEOUT_VAL_MIN && |
| 5562 | reorder_timeout.rx_timeout_pri[0] <= RX_TIMEOUT_VAL_MAX && |
| 5563 | reorder_timeout.rx_timeout_pri[1] >= RX_TIMEOUT_VAL_MIN && |
| 5564 | reorder_timeout.rx_timeout_pri[1] <= RX_TIMEOUT_VAL_MAX && |
| 5565 | reorder_timeout.rx_timeout_pri[2] >= RX_TIMEOUT_VAL_MIN && |
| 5566 | reorder_timeout.rx_timeout_pri[2] <= RX_TIMEOUT_VAL_MAX && |
| 5567 | reorder_timeout.rx_timeout_pri[3] >= RX_TIMEOUT_VAL_MIN && |
| 5568 | reorder_timeout.rx_timeout_pri[3] <= RX_TIMEOUT_VAL_MAX) { |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 5569 | mac_handle = hdd_ctx->mac_handle; |
| 5570 | qdf_status = sme_set_reorder_timeout(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5571 | &reorder_timeout); |
| 5572 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 5573 | hdd_err("failed to set reorder timeout err %d", |
| 5574 | qdf_status); |
| 5575 | ret_val = -EPERM; |
| 5576 | } |
| 5577 | } else { |
| 5578 | hdd_err("one of the timeout value is not in range"); |
| 5579 | ret_val = -EINVAL; |
| 5580 | } |
| 5581 | } |
| 5582 | |
| 5583 | return ret_val; |
| 5584 | } |
| 5585 | |
| 5586 | /** |
Jeff Johnson | 339ede8 | 2018-11-16 20:27:52 -0800 | [diff] [blame] | 5587 | * wlan_hdd_cfg80211_wifi_set_rx_blocksize() - set rx blocksize |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5588 | * @adapter: hdd adapter |
| 5589 | * @tb: array of pointer to struct nlattr |
| 5590 | * |
| 5591 | * Return: 0 on success; error number otherwise |
| 5592 | */ |
Jeff Johnson | 339ede8 | 2018-11-16 20:27:52 -0800 | [diff] [blame] | 5593 | static int wlan_hdd_cfg80211_wifi_set_rx_blocksize(struct hdd_adapter *adapter, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5594 | struct nlattr *tb[]) |
| 5595 | { |
Jeff Johnson | 339ede8 | 2018-11-16 20:27:52 -0800 | [diff] [blame] | 5596 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 5597 | int ret_val = 0; |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5598 | uint32_t set_value; |
| 5599 | QDF_STATUS qdf_status; |
| 5600 | struct sir_peer_set_rx_blocksize rx_blocksize; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 5601 | mac_handle_t mac_handle; |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5602 | |
| 5603 | #define WINDOW_SIZE_VAL_MIN 1 |
| 5604 | #define WINDOW_SIZE_VAL_MAX 64 |
| 5605 | |
| 5606 | if (tb[RX_BLOCKSIZE_PEER_MAC] || |
| 5607 | tb[RX_BLOCKSIZE_WINLIMIT]) { |
| 5608 | |
| 5609 | /* if one is specified, both must be specified */ |
| 5610 | if (!tb[RX_BLOCKSIZE_PEER_MAC] || |
| 5611 | !tb[RX_BLOCKSIZE_WINLIMIT]) { |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 5612 | hdd_err("Both Peer MAC and windows limit required"); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5613 | return -EINVAL; |
| 5614 | } |
| 5615 | |
| 5616 | memcpy(&rx_blocksize.peer_macaddr, |
| 5617 | nla_data(tb[RX_BLOCKSIZE_PEER_MAC]), |
| 5618 | sizeof(rx_blocksize.peer_macaddr)), |
| 5619 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 5620 | rx_blocksize.vdev_id = adapter->vdev_id; |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5621 | set_value = nla_get_u32(tb[RX_BLOCKSIZE_WINLIMIT]); |
| 5622 | /* maximum window size is 64 */ |
| 5623 | if (set_value >= WINDOW_SIZE_VAL_MIN && |
| 5624 | set_value <= WINDOW_SIZE_VAL_MAX) { |
| 5625 | rx_blocksize.rx_block_ack_win_limit = set_value; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 5626 | mac_handle = hdd_ctx->mac_handle; |
| 5627 | qdf_status = sme_set_rx_set_blocksize(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 5628 | &rx_blocksize); |
| 5629 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 5630 | hdd_err("failed to set aggr sizes err %d", |
| 5631 | qdf_status); |
| 5632 | ret_val = -EPERM; |
| 5633 | } |
| 5634 | } else { |
| 5635 | hdd_err("window size val is not in range"); |
| 5636 | ret_val = -EINVAL; |
| 5637 | } |
| 5638 | } |
| 5639 | |
| 5640 | return ret_val; |
| 5641 | } |
| 5642 | |
Jeff Johnson | affc4da | 2018-11-16 14:10:07 -0800 | [diff] [blame] | 5643 | static int hdd_config_access_policy(struct hdd_adapter *adapter, |
| 5644 | struct nlattr *tb[]) |
| 5645 | { |
| 5646 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5647 | struct nlattr *policy_attr = |
| 5648 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY]; |
| 5649 | struct nlattr *ielist_attr = |
| 5650 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY_IE_LIST]; |
| 5651 | uint32_t access_policy; |
| 5652 | uint8_t ie[SIR_MAC_MAX_IE_LENGTH + 2]; |
| 5653 | QDF_STATUS status; |
| 5654 | |
| 5655 | /* nothing to do if neither attribute is present */ |
| 5656 | if (!ielist_attr && !policy_attr) |
| 5657 | return 0; |
| 5658 | |
| 5659 | /* if one is present, both must be present */ |
| 5660 | if (!ielist_attr || !policy_attr) { |
| 5661 | hdd_err("Missing attribute for %s", |
| 5662 | policy_attr ? |
| 5663 | "ACCESS_POLICY_IE_LIST" : "ACCESS_POLICY"); |
| 5664 | return -EINVAL; |
| 5665 | } |
| 5666 | |
| 5667 | /* validate the access policy */ |
| 5668 | access_policy = nla_get_u32(policy_attr); |
| 5669 | switch (access_policy) { |
| 5670 | case QCA_ACCESS_POLICY_ACCEPT_UNLESS_LISTED: |
| 5671 | case QCA_ACCESS_POLICY_DENY_UNLESS_LISTED: |
| 5672 | /* valid */ |
| 5673 | break; |
| 5674 | default: |
| 5675 | hdd_err("Invalid value. access_policy %u", access_policy); |
| 5676 | return -EINVAL; |
| 5677 | } |
| 5678 | |
| 5679 | /* |
| 5680 | * ie length is validated by the nla_policy. need to make a |
| 5681 | * copy since SME will always read SIR_MAC_MAX_IE_LENGTH+2 bytes |
| 5682 | */ |
| 5683 | nla_memcpy(ie, ielist_attr, sizeof(ie)); |
| 5684 | |
| 5685 | hdd_debug("calling sme_update_access_policy_vendor_ie"); |
| 5686 | status = sme_update_access_policy_vendor_ie(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 5687 | adapter->vdev_id, |
Jeff Johnson | affc4da | 2018-11-16 14:10:07 -0800 | [diff] [blame] | 5688 | ie, access_policy); |
| 5689 | if (QDF_IS_STATUS_ERROR(status)) |
| 5690 | hdd_err("Failed to set vendor ie and access policy, %d", |
| 5691 | status); |
| 5692 | |
| 5693 | return qdf_status_to_os_return(status); |
| 5694 | } |
| 5695 | |
Jeff Johnson | 0fbb43b | 2018-11-16 15:38:56 -0800 | [diff] [blame] | 5696 | static int hdd_config_mpdu_aggregation(struct hdd_adapter *adapter, |
| 5697 | struct nlattr *tb[]) |
| 5698 | { |
| 5699 | struct nlattr *tx_attr = |
| 5700 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_MPDU_AGGREGATION]; |
| 5701 | struct nlattr *rx_attr = |
| 5702 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RX_MPDU_AGGREGATION]; |
| 5703 | uint8_t tx_size, rx_size; |
| 5704 | struct sir_set_tx_rx_aggregation_size request; |
| 5705 | QDF_STATUS status; |
| 5706 | |
| 5707 | /* nothing to do if neither attribute is present */ |
| 5708 | if (!tx_attr && !rx_attr) |
| 5709 | return 0; |
| 5710 | |
| 5711 | /* if one is present, both must be present */ |
| 5712 | if (!tx_attr || !rx_attr) { |
| 5713 | hdd_err("Missing attribute for %s", |
| 5714 | tx_attr ? "RX" : "TX"); |
| 5715 | return -EINVAL; |
| 5716 | } |
| 5717 | |
| 5718 | tx_size = nla_get_u8(tx_attr); |
| 5719 | rx_size = nla_get_u8(rx_attr); |
| 5720 | if (!cfg_in_range(CFG_TX_AGGREGATION_SIZE, tx_size) || |
| 5721 | !cfg_in_range(CFG_RX_AGGREGATION_SIZE, rx_size)) { |
| 5722 | hdd_err("TX %d RX %d MPDU aggr size not in range", |
| 5723 | tx_size, rx_size); |
| 5724 | |
| 5725 | return -EINVAL; |
| 5726 | } |
| 5727 | |
| 5728 | qdf_mem_zero(&request, sizeof(request)); |
| 5729 | request.tx_aggregation_size = tx_size; |
| 5730 | request.rx_aggregation_size = rx_size; |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 5731 | request.vdev_id = adapter->vdev_id; |
Jeff Johnson | 0fbb43b | 2018-11-16 15:38:56 -0800 | [diff] [blame] | 5732 | request.aggr_type = WMI_VDEV_CUSTOM_AGGR_TYPE_AMPDU; |
| 5733 | |
| 5734 | status = wma_set_tx_rx_aggregation_size(&request); |
| 5735 | if (QDF_IS_STATUS_ERROR(status)) |
| 5736 | hdd_err("failed to set aggr sizes err %d", status); |
| 5737 | |
| 5738 | return qdf_status_to_os_return(status); |
| 5739 | } |
| 5740 | |
Jeff Johnson | 7bf20cb | 2018-11-16 17:38:27 -0800 | [diff] [blame] | 5741 | static int hdd_config_ant_div_period(struct hdd_adapter *adapter, |
| 5742 | struct nlattr *tb[]) |
| 5743 | { |
| 5744 | struct nlattr *probe_attr = |
| 5745 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_PERIOD]; |
| 5746 | struct nlattr *stay_attr = |
| 5747 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_STAY_PERIOD]; |
| 5748 | uint32_t probe_period, stay_period, ant_div_usrcfg; |
| 5749 | int errno; |
| 5750 | |
| 5751 | /* nothing to do if neither attribute is present */ |
| 5752 | if (!probe_attr && !stay_attr) |
| 5753 | return 0; |
| 5754 | |
| 5755 | /* if one is present, both must be present */ |
| 5756 | if (!probe_attr || !stay_attr) { |
| 5757 | hdd_err("Missing attribute for %s", |
| 5758 | probe_attr ? "STAY" : "PROBE"); |
| 5759 | return -EINVAL; |
| 5760 | } |
| 5761 | |
| 5762 | probe_period = nla_get_u32(probe_attr); |
| 5763 | stay_period = nla_get_u32(stay_attr); |
| 5764 | ant_div_usrcfg = ANT_DIV_SET_PERIOD(probe_period, stay_period); |
| 5765 | hdd_debug("ant div set period: %x", ant_div_usrcfg); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 5766 | errno = wma_cli_set_command(adapter->vdev_id, |
Jeff Johnson | 7bf20cb | 2018-11-16 17:38:27 -0800 | [diff] [blame] | 5767 | WMI_PDEV_PARAM_ANT_DIV_USRCFG, |
| 5768 | ant_div_usrcfg, PDEV_CMD); |
| 5769 | if (errno) |
| 5770 | hdd_err("Failed to set ant div period, %d", errno); |
| 5771 | |
| 5772 | return errno; |
| 5773 | } |
| 5774 | |
Jeff Johnson | 1350e62 | 2018-11-16 18:36:55 -0800 | [diff] [blame] | 5775 | static int hdd_config_ant_div_snr_weight(struct hdd_adapter *adapter, |
| 5776 | struct nlattr *tb[]) |
| 5777 | { |
| 5778 | struct nlattr *mgmt_attr = |
| 5779 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_MGMT_SNR_WEIGHT]; |
| 5780 | struct nlattr *data_attr = |
| 5781 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_DATA_SNR_WEIGHT]; |
| 5782 | struct nlattr *ack_attr = |
| 5783 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_ACK_SNR_WEIGHT]; |
| 5784 | uint32_t mgmt_snr, data_snr, ack_snr, ant_div_usrcfg; |
| 5785 | int errno; |
| 5786 | |
| 5787 | /* nothing to do if none of the attributes are present */ |
| 5788 | if (!mgmt_attr && !data_attr && !ack_attr) |
| 5789 | return 0; |
| 5790 | |
| 5791 | /* if one is present, all must be present */ |
| 5792 | if (!mgmt_attr || !data_attr || !ack_attr) { |
| 5793 | hdd_err("Missing attribute"); |
| 5794 | return -EINVAL; |
| 5795 | } |
| 5796 | |
| 5797 | mgmt_snr = nla_get_u32(mgmt_attr); |
| 5798 | data_snr = nla_get_u32(data_attr); |
| 5799 | ack_snr = nla_get_u32(ack_attr); |
| 5800 | ant_div_usrcfg = ANT_DIV_SET_WEIGHT(mgmt_snr, data_snr, ack_snr); |
| 5801 | hdd_debug("ant div set weight: %x", ant_div_usrcfg); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 5802 | errno = wma_cli_set_command(adapter->vdev_id, |
Jeff Johnson | 1350e62 | 2018-11-16 18:36:55 -0800 | [diff] [blame] | 5803 | WMI_PDEV_PARAM_ANT_DIV_USRCFG, |
| 5804 | ant_div_usrcfg, PDEV_CMD); |
| 5805 | if (errno) |
| 5806 | hdd_err("Failed to set ant div weight, %d", errno); |
| 5807 | |
| 5808 | return errno; |
| 5809 | } |
| 5810 | |
Jeff Johnson | 7f4fd70 | 2018-11-14 11:19:52 -0800 | [diff] [blame] | 5811 | static int hdd_config_fine_time_measurement(struct hdd_adapter *adapter, |
| 5812 | const struct nlattr *attr) |
| 5813 | { |
| 5814 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5815 | uint32_t user_capability; |
| 5816 | uint32_t target_capability; |
| 5817 | uint32_t final_capability; |
| 5818 | QDF_STATUS status; |
| 5819 | |
| 5820 | user_capability = nla_get_u32(attr); |
| 5821 | target_capability = hdd_ctx->fine_time_meas_cap_target; |
| 5822 | final_capability = user_capability & target_capability; |
| 5823 | |
| 5824 | status = ucfg_mlme_set_fine_time_meas_cap(hdd_ctx->psoc, |
| 5825 | final_capability); |
| 5826 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5827 | hdd_err("Unable to set value, status %d", status); |
| 5828 | return -EINVAL; |
| 5829 | } |
| 5830 | |
| 5831 | sme_update_fine_time_measurement_capab(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 5832 | adapter->vdev_id, |
Jeff Johnson | 7f4fd70 | 2018-11-14 11:19:52 -0800 | [diff] [blame] | 5833 | final_capability); |
| 5834 | ucfg_wifi_pos_set_ftm_cap(hdd_ctx->psoc, final_capability); |
| 5835 | |
| 5836 | hdd_debug("user: 0x%x, target: 0x%x, final: 0x%x", |
| 5837 | user_capability, target_capability, final_capability); |
| 5838 | |
| 5839 | return 0; |
| 5840 | } |
| 5841 | |
Jeff Johnson | bcaeafb | 2018-11-14 12:14:24 -0800 | [diff] [blame] | 5842 | static int hdd_config_modulated_dtim(struct hdd_adapter *adapter, |
| 5843 | const struct nlattr *attr) |
| 5844 | { |
| 5845 | struct wlan_objmgr_vdev *vdev; |
| 5846 | uint32_t modulated_dtim; |
| 5847 | QDF_STATUS status; |
| 5848 | |
| 5849 | modulated_dtim = nla_get_u32(attr); |
| 5850 | |
| 5851 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5852 | if (!vdev) |
| 5853 | return -EINVAL; |
| 5854 | |
| 5855 | status = ucfg_pmo_config_modulated_dtim(vdev, modulated_dtim); |
| 5856 | |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5857 | hdd_objmgr_put_vdev(vdev); |
Jeff Johnson | bcaeafb | 2018-11-14 12:14:24 -0800 | [diff] [blame] | 5858 | |
| 5859 | return qdf_status_to_os_return(status); |
| 5860 | } |
| 5861 | |
Jeff Johnson | 6db9162 | 2018-11-14 12:33:28 -0800 | [diff] [blame] | 5862 | static int hdd_config_listen_interval(struct hdd_adapter *adapter, |
| 5863 | const struct nlattr *attr) |
| 5864 | { |
| 5865 | struct wlan_objmgr_vdev *vdev; |
| 5866 | uint32_t listen_interval; |
| 5867 | QDF_STATUS status; |
| 5868 | |
| 5869 | listen_interval = nla_get_u32(attr); |
| 5870 | if (listen_interval > cfg_max(CFG_PMO_ENABLE_DYNAMIC_DTIM)) { |
| 5871 | hdd_err_rl("Invalid value for listen interval - %d", |
| 5872 | listen_interval); |
| 5873 | return -EINVAL; |
| 5874 | } |
| 5875 | |
| 5876 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5877 | if (!vdev) |
| 5878 | return -EINVAL; |
| 5879 | |
| 5880 | status = ucfg_pmo_config_listen_interval(vdev, listen_interval); |
| 5881 | |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5882 | hdd_objmgr_put_vdev(vdev); |
Jeff Johnson | 6db9162 | 2018-11-14 12:33:28 -0800 | [diff] [blame] | 5883 | |
| 5884 | return qdf_status_to_os_return(status); |
| 5885 | } |
| 5886 | |
Jeff Johnson | 9381d03 | 2018-11-14 12:42:22 -0800 | [diff] [blame] | 5887 | static int hdd_config_lro(struct hdd_adapter *adapter, |
| 5888 | const struct nlattr *attr) |
| 5889 | { |
| 5890 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5891 | uint8_t enable_flag; |
| 5892 | |
| 5893 | enable_flag = nla_get_u8(attr); |
| 5894 | |
| 5895 | return hdd_lro_set_reset(hdd_ctx, adapter, enable_flag); |
| 5896 | } |
| 5897 | |
Jeff Johnson | 3d4f64c | 2018-11-14 13:13:04 -0800 | [diff] [blame] | 5898 | static int hdd_config_scan_enable(struct hdd_adapter *adapter, |
| 5899 | const struct nlattr *attr) |
| 5900 | { |
| 5901 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5902 | uint8_t enable_flag; |
| 5903 | |
| 5904 | enable_flag = nla_get_u8(attr); |
| 5905 | if (enable_flag) |
| 5906 | ucfg_scan_psoc_set_enable(hdd_ctx->psoc, |
| 5907 | REASON_USER_SPACE); |
| 5908 | else |
| 5909 | ucfg_scan_psoc_set_disable(hdd_ctx->psoc, |
| 5910 | REASON_USER_SPACE); |
| 5911 | |
| 5912 | return 0; |
| 5913 | } |
| 5914 | |
Jeff Johnson | 1feb8a6 | 2018-11-14 13:18:41 -0800 | [diff] [blame] | 5915 | static int hdd_config_qpower(struct hdd_adapter *adapter, |
| 5916 | const struct nlattr *attr) |
| 5917 | { |
| 5918 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5919 | uint8_t qpower; |
| 5920 | |
| 5921 | qpower = nla_get_u8(attr); |
| 5922 | |
| 5923 | return hdd_set_qpower_config(hdd_ctx, adapter, qpower); |
| 5924 | } |
| 5925 | |
Jeff Johnson | f15ede0 | 2018-11-14 13:27:13 -0800 | [diff] [blame] | 5926 | static int hdd_config_stats_avg_factor(struct hdd_adapter *adapter, |
| 5927 | const struct nlattr *attr) |
| 5928 | { |
| 5929 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5930 | uint16_t stats_avg_factor; |
| 5931 | QDF_STATUS status; |
| 5932 | |
| 5933 | stats_avg_factor = nla_get_u16(attr); |
| 5934 | status = sme_configure_stats_avg_factor(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 5935 | adapter->vdev_id, |
Jeff Johnson | f15ede0 | 2018-11-14 13:27:13 -0800 | [diff] [blame] | 5936 | stats_avg_factor); |
| 5937 | |
| 5938 | return qdf_status_to_os_return(status); |
| 5939 | } |
| 5940 | |
Jeff Johnson | f382750 | 2018-11-14 14:00:58 -0800 | [diff] [blame] | 5941 | static int hdd_config_non_agg_retry(struct hdd_adapter *adapter, |
| 5942 | const struct nlattr *attr) |
| 5943 | { |
| 5944 | uint8_t retry; |
| 5945 | int param_id; |
| 5946 | |
| 5947 | retry = nla_get_u8(attr); |
| 5948 | retry = retry > CFG_NON_AGG_RETRY_MAX ? |
| 5949 | CFG_NON_AGG_RETRY_MAX : retry; |
| 5950 | param_id = WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH; |
| 5951 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 5952 | return wma_cli_set_command(adapter->vdev_id, param_id, |
Jeff Johnson | f382750 | 2018-11-14 14:00:58 -0800 | [diff] [blame] | 5953 | retry, PDEV_CMD); |
| 5954 | } |
| 5955 | |
Jeff Johnson | b902100 | 2018-11-15 15:51:36 -0800 | [diff] [blame] | 5956 | static int hdd_config_agg_retry(struct hdd_adapter *adapter, |
| 5957 | const struct nlattr *attr) |
| 5958 | { |
| 5959 | uint8_t retry; |
| 5960 | int param_id; |
| 5961 | |
| 5962 | retry = nla_get_u8(attr); |
| 5963 | retry = retry > CFG_AGG_RETRY_MAX ? |
| 5964 | CFG_AGG_RETRY_MAX : retry; |
| 5965 | |
| 5966 | /* Value less than CFG_AGG_RETRY_MIN has side effect to t-put */ |
| 5967 | retry = ((retry > 0) && (retry < CFG_AGG_RETRY_MIN)) ? |
| 5968 | CFG_AGG_RETRY_MIN : retry; |
| 5969 | param_id = WMI_PDEV_PARAM_AGG_SW_RETRY_TH; |
| 5970 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 5971 | return wma_cli_set_command(adapter->vdev_id, param_id, |
Jeff Johnson | b902100 | 2018-11-15 15:51:36 -0800 | [diff] [blame] | 5972 | retry, PDEV_CMD); |
| 5973 | } |
| 5974 | |
Jeff Johnson | 0e8259c | 2018-11-15 19:44:57 -0800 | [diff] [blame] | 5975 | static int hdd_config_mgmt_retry(struct hdd_adapter *adapter, |
| 5976 | const struct nlattr *attr) |
| 5977 | { |
| 5978 | uint8_t retry; |
| 5979 | int param_id; |
| 5980 | |
| 5981 | retry = nla_get_u8(attr); |
| 5982 | retry = retry > CFG_MGMT_RETRY_MAX ? |
| 5983 | CFG_MGMT_RETRY_MAX : retry; |
| 5984 | param_id = WMI_PDEV_PARAM_MGMT_RETRY_LIMIT; |
| 5985 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 5986 | return wma_cli_set_command(adapter->vdev_id, param_id, |
Jeff Johnson | 0e8259c | 2018-11-15 19:44:57 -0800 | [diff] [blame] | 5987 | retry, PDEV_CMD); |
| 5988 | } |
| 5989 | |
Jeff Johnson | 6b48a2f | 2018-11-15 19:48:47 -0800 | [diff] [blame] | 5990 | static int hdd_config_ctrl_retry(struct hdd_adapter *adapter, |
| 5991 | const struct nlattr *attr) |
| 5992 | { |
| 5993 | uint8_t retry; |
| 5994 | int param_id; |
| 5995 | |
| 5996 | retry = nla_get_u8(attr); |
| 5997 | retry = retry > CFG_CTRL_RETRY_MAX ? |
| 5998 | CFG_CTRL_RETRY_MAX : retry; |
| 5999 | param_id = WMI_PDEV_PARAM_CTRL_RETRY_LIMIT; |
| 6000 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6001 | return wma_cli_set_command(adapter->vdev_id, param_id, |
Jeff Johnson | 6b48a2f | 2018-11-15 19:48:47 -0800 | [diff] [blame] | 6002 | retry, PDEV_CMD); |
| 6003 | } |
| 6004 | |
Jeff Johnson | 9821474 | 2018-11-15 19:56:37 -0800 | [diff] [blame] | 6005 | static int hdd_config_propagation_delay(struct hdd_adapter *adapter, |
| 6006 | const struct nlattr *attr) |
| 6007 | { |
| 6008 | uint8_t delay; |
| 6009 | uint32_t abs_delay; |
| 6010 | int param_id; |
| 6011 | |
| 6012 | delay = nla_get_u8(attr); |
| 6013 | delay = delay > CFG_PROPAGATION_DELAY_MAX ? |
| 6014 | CFG_PROPAGATION_DELAY_MAX : delay; |
| 6015 | abs_delay = delay + CFG_PROPAGATION_DELAY_BASE; |
| 6016 | param_id = WMI_PDEV_PARAM_PROPAGATION_DELAY; |
| 6017 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6018 | return wma_cli_set_command(adapter->vdev_id, param_id, |
Jeff Johnson | 9821474 | 2018-11-15 19:56:37 -0800 | [diff] [blame] | 6019 | abs_delay, PDEV_CMD); |
| 6020 | } |
| 6021 | |
Jeff Johnson | 8fb9ded | 2018-11-15 20:44:56 -0800 | [diff] [blame] | 6022 | static int hdd_config_propagation_abs_delay(struct hdd_adapter *adapter, |
| 6023 | const struct nlattr *attr) |
| 6024 | { |
| 6025 | uint32_t abs_delay; |
| 6026 | int param_id; |
| 6027 | |
| 6028 | abs_delay = nla_get_u32(attr); |
| 6029 | param_id = WMI_PDEV_PARAM_PROPAGATION_DELAY; |
| 6030 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6031 | return wma_cli_set_command(adapter->vdev_id, param_id, |
Jeff Johnson | 8fb9ded | 2018-11-15 20:44:56 -0800 | [diff] [blame] | 6032 | abs_delay, PDEV_CMD); |
| 6033 | } |
| 6034 | |
Jeff Johnson | 7c5e6dc | 2018-11-15 21:20:18 -0800 | [diff] [blame] | 6035 | static int hdd_config_tx_fail_count(struct hdd_adapter *adapter, |
| 6036 | const struct nlattr *attr) |
| 6037 | { |
| 6038 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6039 | uint32_t tx_fail_count; |
| 6040 | QDF_STATUS status; |
| 6041 | |
| 6042 | tx_fail_count = nla_get_u32(attr); |
| 6043 | if (!tx_fail_count) |
| 6044 | return 0; |
| 6045 | |
| 6046 | status = sme_update_tx_fail_cnt_threshold(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6047 | adapter->vdev_id, |
Jeff Johnson | 7c5e6dc | 2018-11-15 21:20:18 -0800 | [diff] [blame] | 6048 | tx_fail_count); |
| 6049 | if (QDF_IS_STATUS_ERROR(status)) |
| 6050 | hdd_err("sme_update_tx_fail_cnt_threshold (err=%d)", |
| 6051 | status); |
| 6052 | |
| 6053 | return qdf_status_to_os_return(status); |
| 6054 | } |
| 6055 | |
Jeff Johnson | 7766fd2 | 2018-11-15 21:52:37 -0800 | [diff] [blame] | 6056 | static int hdd_config_channel_avoidance_ind(struct hdd_adapter *adapter, |
| 6057 | const struct nlattr *attr) |
| 6058 | { |
| 6059 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6060 | uint8_t set_value; |
| 6061 | |
| 6062 | set_value = nla_get_u8(attr); |
| 6063 | hdd_debug("set_value: %d", set_value); |
| 6064 | |
| 6065 | return hdd_enable_disable_ca_event(hdd_ctx, set_value); |
| 6066 | } |
| 6067 | |
Jeff Johnson | 47e2e84 | 2018-11-14 13:49:43 -0800 | [diff] [blame] | 6068 | static int hdd_config_guard_time(struct hdd_adapter *adapter, |
| 6069 | const struct nlattr *attr) |
| 6070 | { |
| 6071 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6072 | uint32_t guard_time; |
| 6073 | QDF_STATUS status; |
| 6074 | |
| 6075 | guard_time = nla_get_u32(attr); |
| 6076 | status = sme_configure_guard_time(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6077 | adapter->vdev_id, |
Jeff Johnson | 47e2e84 | 2018-11-14 13:49:43 -0800 | [diff] [blame] | 6078 | guard_time); |
| 6079 | |
| 6080 | return qdf_status_to_os_return(status); |
| 6081 | } |
| 6082 | |
Jeff Johnson | 3b2abe9 | 2017-12-15 09:03:47 -0800 | [diff] [blame] | 6083 | static int hdd_config_scan_default_ies(struct hdd_adapter *adapter, |
| 6084 | const struct nlattr *attr) |
| 6085 | { |
| 6086 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6087 | uint8_t *scan_ie; |
| 6088 | uint16_t scan_ie_len; |
| 6089 | QDF_STATUS status; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6090 | mac_handle_t mac_handle; |
Jeff Johnson | 3b2abe9 | 2017-12-15 09:03:47 -0800 | [diff] [blame] | 6091 | |
Jeff Johnson | 3b2abe9 | 2017-12-15 09:03:47 -0800 | [diff] [blame] | 6092 | scan_ie_len = nla_len(attr); |
| 6093 | hdd_debug("IE len %d session %d device mode %d", |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6094 | scan_ie_len, adapter->vdev_id, adapter->device_mode); |
Jeff Johnson | 3b2abe9 | 2017-12-15 09:03:47 -0800 | [diff] [blame] | 6095 | |
| 6096 | if (!scan_ie_len) { |
| 6097 | hdd_err("zero-length IE prohibited"); |
| 6098 | return -EINVAL; |
| 6099 | } |
| 6100 | |
| 6101 | if (scan_ie_len > MAX_DEFAULT_SCAN_IE_LEN) { |
| 6102 | hdd_err("IE length %d exceeds max of %d", |
| 6103 | scan_ie_len, MAX_DEFAULT_SCAN_IE_LEN); |
| 6104 | return -EINVAL; |
| 6105 | } |
| 6106 | |
| 6107 | scan_ie = nla_data(attr); |
Jeff Johnson | 4933c3a | 2018-01-10 19:33:33 -0800 | [diff] [blame] | 6108 | if (!wlan_is_ie_valid(scan_ie, scan_ie_len)) { |
Jeff Johnson | 3b2abe9 | 2017-12-15 09:03:47 -0800 | [diff] [blame] | 6109 | hdd_err("Invalid default scan IEs"); |
| 6110 | return -EINVAL; |
| 6111 | } |
| 6112 | |
| 6113 | if (wlan_hdd_save_default_scan_ies(hdd_ctx, adapter, |
| 6114 | scan_ie, scan_ie_len)) |
| 6115 | hdd_err("Failed to save default scan IEs"); |
| 6116 | |
| 6117 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6118 | mac_handle = hdd_ctx->mac_handle; |
| 6119 | status = sme_set_default_scan_ie(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6120 | adapter->vdev_id, scan_ie, |
Jeff Johnson | 3b2abe9 | 2017-12-15 09:03:47 -0800 | [diff] [blame] | 6121 | scan_ie_len); |
| 6122 | if (QDF_STATUS_SUCCESS != status) { |
| 6123 | hdd_err("failed to set default scan IEs in sme: %d", |
| 6124 | status); |
| 6125 | return -EPERM; |
| 6126 | } |
| 6127 | } |
| 6128 | |
| 6129 | return 0; |
| 6130 | } |
| 6131 | |
Jeff Johnson | f9871e4 | 2018-11-15 22:24:06 -0800 | [diff] [blame] | 6132 | static int hdd_config_ant_div_ena(struct hdd_adapter *adapter, |
| 6133 | const struct nlattr *attr) |
| 6134 | { |
| 6135 | uint32_t antdiv_enable; |
| 6136 | int errno; |
| 6137 | |
| 6138 | antdiv_enable = nla_get_u32(attr); |
| 6139 | hdd_debug("antdiv_enable: %d", antdiv_enable); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6140 | errno = wma_cli_set_command(adapter->vdev_id, |
Jeff Johnson | f9871e4 | 2018-11-15 22:24:06 -0800 | [diff] [blame] | 6141 | WMI_PDEV_PARAM_ENA_ANT_DIV, |
| 6142 | antdiv_enable, PDEV_CMD); |
| 6143 | if (errno) |
| 6144 | hdd_err("Failed to set antdiv_enable, %d", errno); |
| 6145 | |
| 6146 | return errno; |
| 6147 | } |
| 6148 | |
Jeff Johnson | 91f90ff | 2018-11-16 07:53:37 -0800 | [diff] [blame] | 6149 | static int hdd_config_ant_div_snr_diff(struct hdd_adapter *adapter, |
| 6150 | const struct nlattr *attr) |
| 6151 | { |
| 6152 | uint32_t ant_div_snr_diff; |
| 6153 | uint32_t ant_div_usrcfg; |
| 6154 | int errno; |
| 6155 | |
| 6156 | ant_div_snr_diff = nla_get_u32(attr); |
| 6157 | hdd_debug("snr diff: %x", ant_div_snr_diff); |
| 6158 | |
| 6159 | ant_div_usrcfg = ANT_DIV_SET_SNR_DIFF(ant_div_snr_diff); |
| 6160 | hdd_debug("usrcfg: %x", ant_div_usrcfg); |
| 6161 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6162 | errno = wma_cli_set_command(adapter->vdev_id, |
Jeff Johnson | 91f90ff | 2018-11-16 07:53:37 -0800 | [diff] [blame] | 6163 | WMI_PDEV_PARAM_ANT_DIV_USRCFG, |
| 6164 | ant_div_usrcfg, PDEV_CMD); |
| 6165 | if (errno) |
| 6166 | hdd_err("Failed to set snr diff, %d", errno); |
| 6167 | |
| 6168 | return errno; |
| 6169 | } |
| 6170 | |
Jeff Johnson | 77177bc | 2018-11-16 08:14:20 -0800 | [diff] [blame] | 6171 | static int hdd_config_ant_div_probe_dwell_time(struct hdd_adapter *adapter, |
| 6172 | const struct nlattr *attr) |
| 6173 | { |
| 6174 | uint32_t dwell_time; |
| 6175 | uint32_t ant_div_usrcfg; |
| 6176 | int errno; |
| 6177 | |
| 6178 | dwell_time = nla_get_u32(attr); |
| 6179 | hdd_debug("dwell time: %x", dwell_time); |
| 6180 | |
| 6181 | ant_div_usrcfg = ANT_DIV_SET_PROBE_DWELL_TIME(dwell_time); |
| 6182 | hdd_debug("usrcfg: %x", ant_div_usrcfg); |
| 6183 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6184 | errno = wma_cli_set_command(adapter->vdev_id, |
Jeff Johnson | 77177bc | 2018-11-16 08:14:20 -0800 | [diff] [blame] | 6185 | WMI_PDEV_PARAM_ANT_DIV_USRCFG, |
| 6186 | ant_div_usrcfg, PDEV_CMD); |
| 6187 | if (errno) |
| 6188 | hdd_err("Failed to set probe dwell time, %d", errno); |
| 6189 | |
| 6190 | return errno; |
| 6191 | } |
| 6192 | |
Jeff Johnson | aa17222 | 2018-11-16 09:16:11 -0800 | [diff] [blame] | 6193 | static int hdd_config_ant_div_chain(struct hdd_adapter *adapter, |
| 6194 | const struct nlattr *attr) |
| 6195 | { |
| 6196 | uint32_t antdiv_chain; |
| 6197 | int errno; |
| 6198 | |
| 6199 | antdiv_chain = nla_get_u32(attr); |
| 6200 | hdd_debug("antdiv_chain: %d", antdiv_chain); |
| 6201 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6202 | errno = wma_cli_set_command(adapter->vdev_id, |
Jeff Johnson | aa17222 | 2018-11-16 09:16:11 -0800 | [diff] [blame] | 6203 | WMI_PDEV_PARAM_FORCE_CHAIN_ANT, |
| 6204 | antdiv_chain, PDEV_CMD); |
| 6205 | if (errno) |
| 6206 | hdd_err("Failed to set chain, %d", errno); |
| 6207 | |
| 6208 | return errno; |
| 6209 | } |
| 6210 | |
Jeff Johnson | ef427ad | 2018-11-16 09:22:17 -0800 | [diff] [blame] | 6211 | static int hdd_config_ant_div_selftest(struct hdd_adapter *adapter, |
| 6212 | const struct nlattr *attr) |
| 6213 | { |
| 6214 | uint32_t antdiv_selftest; |
| 6215 | int errno; |
| 6216 | |
| 6217 | antdiv_selftest = nla_get_u32(attr); |
| 6218 | hdd_debug("antdiv_selftest: %d", antdiv_selftest); |
| 6219 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6220 | errno = wma_cli_set_command(adapter->vdev_id, |
Jeff Johnson | ef427ad | 2018-11-16 09:22:17 -0800 | [diff] [blame] | 6221 | WMI_PDEV_PARAM_ANT_DIV_SELFTEST, |
| 6222 | antdiv_selftest, PDEV_CMD); |
| 6223 | if (errno) |
| 6224 | hdd_err("Failed to set selftest, %d", errno); |
| 6225 | |
| 6226 | return errno; |
| 6227 | } |
| 6228 | |
Jeff Johnson | ae21be8 | 2018-11-16 09:43:53 -0800 | [diff] [blame] | 6229 | static int hdd_config_ant_div_selftest_intvl(struct hdd_adapter *adapter, |
| 6230 | const struct nlattr *attr) |
| 6231 | { |
| 6232 | uint32_t antdiv_selftest_intvl; |
| 6233 | int errno; |
| 6234 | |
| 6235 | antdiv_selftest_intvl = nla_get_u32(attr); |
| 6236 | hdd_debug("antdiv_selftest_intvl: %d", antdiv_selftest_intvl); |
| 6237 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6238 | errno = wma_cli_set_command(adapter->vdev_id, |
Jeff Johnson | ae21be8 | 2018-11-16 09:43:53 -0800 | [diff] [blame] | 6239 | WMI_PDEV_PARAM_ANT_DIV_SELFTEST_INTVL, |
| 6240 | antdiv_selftest_intvl, PDEV_CMD); |
| 6241 | if (errno) |
| 6242 | hdd_err("Failed to set selftest interval, %d", errno); |
| 6243 | |
| 6244 | return errno; |
| 6245 | } |
| 6246 | |
Jeff Johnson | 3a25de8 | 2018-11-16 07:26:46 -0800 | [diff] [blame] | 6247 | static int hdd_config_ignore_assoc_disallowed(struct hdd_adapter *adapter, |
| 6248 | const struct nlattr *attr) |
| 6249 | { |
| 6250 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6251 | uint8_t ignore_assoc_disallowed; |
| 6252 | |
| 6253 | ignore_assoc_disallowed = nla_get_u8(attr); |
| 6254 | hdd_debug("%u", ignore_assoc_disallowed); |
| 6255 | if ((ignore_assoc_disallowed < QCA_IGNORE_ASSOC_DISALLOWED_DISABLE) || |
| 6256 | (ignore_assoc_disallowed > QCA_IGNORE_ASSOC_DISALLOWED_ENABLE)) |
| 6257 | return -EINVAL; |
| 6258 | |
| 6259 | sme_update_session_param(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6260 | adapter->vdev_id, |
Jeff Johnson | 3a25de8 | 2018-11-16 07:26:46 -0800 | [diff] [blame] | 6261 | SIR_PARAM_IGNORE_ASSOC_DISALLOWED, |
| 6262 | ignore_assoc_disallowed); |
| 6263 | |
| 6264 | return 0; |
| 6265 | } |
| 6266 | |
Jeff Johnson | 72dc91e | 2018-11-16 08:46:12 -0800 | [diff] [blame] | 6267 | static int hdd_config_restrict_offchannel(struct hdd_adapter *adapter, |
| 6268 | const struct nlattr *attr) |
| 6269 | { |
| 6270 | uint8_t restrict_offchan; |
| 6271 | |
| 6272 | restrict_offchan = nla_get_u8(attr); |
| 6273 | hdd_debug("%u", restrict_offchan); |
| 6274 | |
| 6275 | if (restrict_offchan > 1) { |
| 6276 | hdd_err("Invalid value %u", restrict_offchan); |
| 6277 | return -EINVAL; |
| 6278 | } |
| 6279 | |
| 6280 | return wlan_hdd_handle_restrict_offchan_config(adapter, |
| 6281 | restrict_offchan); |
| 6282 | } |
| 6283 | |
Jeff Johnson | 320feeb | 2018-11-16 10:14:24 -0800 | [diff] [blame] | 6284 | static int hdd_config_total_beacon_miss_count(struct hdd_adapter *adapter, |
| 6285 | const struct nlattr *attr) |
| 6286 | { |
| 6287 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6288 | uint8_t first_miss_count; |
| 6289 | uint8_t final_miss_count; |
| 6290 | uint8_t total_miss_count; |
| 6291 | QDF_STATUS status; |
| 6292 | |
| 6293 | total_miss_count = nla_get_u8(attr); |
| 6294 | ucfg_mlme_get_roam_bmiss_first_bcnt(hdd_ctx->psoc, |
| 6295 | &first_miss_count); |
| 6296 | if (total_miss_count <= first_miss_count) { |
| 6297 | hdd_err("Total %u needs to exceed first %u", |
| 6298 | total_miss_count, first_miss_count); |
| 6299 | return -EINVAL; |
| 6300 | } |
| 6301 | |
| 6302 | final_miss_count = total_miss_count - first_miss_count; |
| 6303 | |
| 6304 | hdd_debug("First count %u, final count %u", |
| 6305 | first_miss_count, final_miss_count); |
| 6306 | |
| 6307 | /***** |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 6308 | * TODO: research why is 0 being passed for vdev id??? |
Jeff Johnson | 320feeb | 2018-11-16 10:14:24 -0800 | [diff] [blame] | 6309 | */ |
| 6310 | status = sme_set_roam_bmiss_final_bcnt(hdd_ctx->mac_handle, |
| 6311 | 0, |
| 6312 | final_miss_count); |
| 6313 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6314 | hdd_err("Failed to set final count, status %u", status); |
| 6315 | return qdf_status_to_os_return(status); |
| 6316 | } |
| 6317 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6318 | status = sme_set_bmiss_bcnt(adapter->vdev_id, |
Jeff Johnson | 320feeb | 2018-11-16 10:14:24 -0800 | [diff] [blame] | 6319 | first_miss_count, |
| 6320 | final_miss_count); |
| 6321 | if (QDF_IS_STATUS_ERROR(status)) |
| 6322 | hdd_err("Failed to set count, status %u", status); |
| 6323 | |
| 6324 | return qdf_status_to_os_return(status); |
| 6325 | } |
| 6326 | |
Jeff Johnson | 2502ddd | 2018-11-16 10:59:30 -0800 | [diff] [blame] | 6327 | static int hdd_config_latency_level(struct hdd_adapter *adapter, |
| 6328 | const struct nlattr *attr) |
| 6329 | { |
| 6330 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6331 | uint16_t latency_level; |
| 6332 | QDF_STATUS status; |
| 6333 | |
| 6334 | latency_level = nla_get_u16(attr); |
| 6335 | switch (latency_level) { |
| 6336 | case QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL_NORMAL: |
| 6337 | case QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL_MODERATE: |
| 6338 | case QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL_LOW: |
| 6339 | case QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL_ULTRALOW: |
| 6340 | /* valid values */ |
| 6341 | break; |
| 6342 | default: |
| 6343 | hdd_err("Invalid value %u", latency_level); |
| 6344 | return -EINVAL; |
| 6345 | } |
| 6346 | |
| 6347 | /* Map the latency value to the level which fw expected |
| 6348 | * 0 - normal, 1 - moderate, 2 - low, 3 - ultralow |
| 6349 | */ |
| 6350 | latency_level = latency_level - 1; |
| 6351 | status = sme_set_wlm_latency_level(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6352 | adapter->vdev_id, |
Jeff Johnson | 2502ddd | 2018-11-16 10:59:30 -0800 | [diff] [blame] | 6353 | latency_level); |
| 6354 | if (QDF_IS_STATUS_ERROR(status)) |
| 6355 | hdd_err("set latency level failed, %u", status); |
| 6356 | |
| 6357 | return qdf_status_to_os_return(status); |
| 6358 | } |
| 6359 | |
Jeff Johnson | 0a31591 | 2018-11-16 11:18:21 -0800 | [diff] [blame] | 6360 | static int hdd_config_disable_fils(struct hdd_adapter *adapter, |
| 6361 | const struct nlattr *attr) |
| 6362 | { |
| 6363 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6364 | uint8_t disable_fils; |
| 6365 | bool enabled; |
| 6366 | QDF_STATUS status; |
| 6367 | |
| 6368 | /* ignore unless in STA mode */ |
| 6369 | if (adapter->device_mode != QDF_STA_MODE) |
| 6370 | return 0; |
| 6371 | |
| 6372 | disable_fils = nla_get_u8(attr); |
| 6373 | hdd_debug("%u", disable_fils); |
| 6374 | |
| 6375 | enabled = !disable_fils; |
| 6376 | status = ucfg_mlme_set_fils_enabled_info(hdd_ctx->psoc, enabled); |
| 6377 | if (QDF_IS_STATUS_ERROR(status)) |
| 6378 | hdd_err("could not set fils enabled info, %d", status); |
| 6379 | |
| 6380 | status = ucfg_mlme_set_enable_bcast_probe_rsp(hdd_ctx->psoc, enabled); |
| 6381 | if (QDF_IS_STATUS_ERROR(status)) |
| 6382 | hdd_err("could not set enable bcast probe resp info, %d", |
| 6383 | status); |
| 6384 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6385 | status = wma_cli_set_command(adapter->vdev_id, |
Jeff Johnson | 0a31591 | 2018-11-16 11:18:21 -0800 | [diff] [blame] | 6386 | WMI_VDEV_PARAM_ENABLE_BCAST_PROBE_RESPONSE, |
| 6387 | !disable_fils, VDEV_CMD); |
| 6388 | if (QDF_IS_STATUS_ERROR(status)) |
| 6389 | hdd_err("failed to set enable bcast probe resp, %d", |
| 6390 | status); |
| 6391 | |
| 6392 | return qdf_status_to_os_return(status); |
| 6393 | } |
| 6394 | |
Jeff Johnson | 0bdbb96 | 2018-11-16 11:42:10 -0800 | [diff] [blame] | 6395 | static int hdd_config_rsn_ie(struct hdd_adapter *adapter, |
| 6396 | const struct nlattr *attr) |
| 6397 | { |
| 6398 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6399 | bool override_enabled; |
| 6400 | uint8_t force_rsne_override; |
| 6401 | |
| 6402 | /* ignore unless support explicitly enabled */ |
| 6403 | ucfg_mlme_get_force_rsne_override(hdd_ctx->psoc, &override_enabled); |
| 6404 | if (!override_enabled) |
| 6405 | return 0; |
| 6406 | |
| 6407 | force_rsne_override = nla_get_u8(attr); |
| 6408 | if (force_rsne_override > 1) { |
| 6409 | hdd_err("Invalid value %d", force_rsne_override); |
| 6410 | return -EINVAL; |
| 6411 | } |
| 6412 | |
| 6413 | hdd_ctx->force_rsne_override = force_rsne_override; |
| 6414 | hdd_debug("force_rsne_override - %d", force_rsne_override); |
| 6415 | |
| 6416 | return 0; |
| 6417 | } |
| 6418 | |
Jeff Johnson | 7acca0d | 2018-11-16 11:53:18 -0800 | [diff] [blame] | 6419 | static int hdd_config_gtx(struct hdd_adapter *adapter, |
| 6420 | const struct nlattr *attr) |
| 6421 | { |
| 6422 | uint8_t config_gtx; |
| 6423 | int errno; |
| 6424 | |
| 6425 | config_gtx = nla_get_u8(attr); |
| 6426 | if (config_gtx > 1) { |
| 6427 | hdd_err_rl("Invalid config_gtx value %d", config_gtx); |
| 6428 | return -EINVAL; |
| 6429 | } |
| 6430 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6431 | errno = sme_cli_set_command(adapter->vdev_id, |
Jeff Johnson | 7acca0d | 2018-11-16 11:53:18 -0800 | [diff] [blame] | 6432 | WMI_VDEV_PARAM_GTX_ENABLE, |
| 6433 | config_gtx, VDEV_CMD); |
| 6434 | if (errno) |
| 6435 | hdd_err("Failed to set GTX, %d", errno); |
| 6436 | |
| 6437 | return errno; |
| 6438 | } |
| 6439 | |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6440 | /** |
Jeff Johnson | b48efe2 | 2018-11-15 11:53:09 -0800 | [diff] [blame] | 6441 | * typedef independent_setter_fn - independent attribute handler |
| 6442 | * @adapter: The adapter being configured |
| 6443 | * @attr: The nl80211 attribute being applied |
| 6444 | * |
| 6445 | * Defines the signature of functions in the independent attribute vtable |
| 6446 | * |
| 6447 | * Return: 0 if the attribute was handled successfully, otherwise an errno |
| 6448 | */ |
| 6449 | typedef int (*independent_setter_fn)(struct hdd_adapter *adapter, |
| 6450 | const struct nlattr *attr); |
| 6451 | |
| 6452 | /** |
| 6453 | * struct independent_setters |
| 6454 | * @id: vendor attribute which this entry handles |
| 6455 | * @cb: callback function to invoke to process the attribute when present |
| 6456 | */ |
| 6457 | struct independent_setters { |
| 6458 | uint32_t id; |
| 6459 | independent_setter_fn cb; |
| 6460 | }; |
| 6461 | |
| 6462 | /* vtable for independent setters */ |
| 6463 | static const struct independent_setters independent_setters[] = { |
Jeff Johnson | 522464b | 2018-11-15 13:07:26 -0800 | [diff] [blame] | 6464 | {QCA_WLAN_VENDOR_ATTR_CONFIG_SCAN_DEFAULT_IES, |
| 6465 | hdd_config_scan_default_ies}, |
Jeff Johnson | 7f4fd70 | 2018-11-14 11:19:52 -0800 | [diff] [blame] | 6466 | {QCA_WLAN_VENDOR_ATTR_CONFIG_FINE_TIME_MEASUREMENT, |
| 6467 | hdd_config_fine_time_measurement}, |
Jeff Johnson | bcaeafb | 2018-11-14 12:14:24 -0800 | [diff] [blame] | 6468 | {QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM, |
| 6469 | hdd_config_modulated_dtim}, |
Jeff Johnson | 6db9162 | 2018-11-14 12:33:28 -0800 | [diff] [blame] | 6470 | {QCA_WLAN_VENDOR_ATTR_CONFIG_LISTEN_INTERVAL, |
| 6471 | hdd_config_listen_interval}, |
Jeff Johnson | 9381d03 | 2018-11-14 12:42:22 -0800 | [diff] [blame] | 6472 | {QCA_WLAN_VENDOR_ATTR_CONFIG_LRO, |
| 6473 | hdd_config_lro}, |
Jeff Johnson | 3d4f64c | 2018-11-14 13:13:04 -0800 | [diff] [blame] | 6474 | {QCA_WLAN_VENDOR_ATTR_CONFIG_SCAN_ENABLE, |
| 6475 | hdd_config_scan_enable}, |
Jeff Johnson | 1feb8a6 | 2018-11-14 13:18:41 -0800 | [diff] [blame] | 6476 | {QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER, |
| 6477 | hdd_config_qpower}, |
Jeff Johnson | f15ede0 | 2018-11-14 13:27:13 -0800 | [diff] [blame] | 6478 | {QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR, |
| 6479 | hdd_config_stats_avg_factor}, |
Jeff Johnson | 47e2e84 | 2018-11-14 13:49:43 -0800 | [diff] [blame] | 6480 | {QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME, |
| 6481 | hdd_config_guard_time}, |
Jeff Johnson | f382750 | 2018-11-14 14:00:58 -0800 | [diff] [blame] | 6482 | {QCA_WLAN_VENDOR_ATTR_CONFIG_NON_AGG_RETRY, |
| 6483 | hdd_config_non_agg_retry}, |
Jeff Johnson | b902100 | 2018-11-15 15:51:36 -0800 | [diff] [blame] | 6484 | {QCA_WLAN_VENDOR_ATTR_CONFIG_AGG_RETRY, |
| 6485 | hdd_config_agg_retry}, |
Jeff Johnson | 0e8259c | 2018-11-15 19:44:57 -0800 | [diff] [blame] | 6486 | {QCA_WLAN_VENDOR_ATTR_CONFIG_MGMT_RETRY, |
| 6487 | hdd_config_mgmt_retry}, |
Jeff Johnson | 6b48a2f | 2018-11-15 19:48:47 -0800 | [diff] [blame] | 6488 | {QCA_WLAN_VENDOR_ATTR_CONFIG_CTRL_RETRY, |
| 6489 | hdd_config_ctrl_retry}, |
Jeff Johnson | 9821474 | 2018-11-15 19:56:37 -0800 | [diff] [blame] | 6490 | {QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_DELAY, |
| 6491 | hdd_config_propagation_delay}, |
Jeff Johnson | 8fb9ded | 2018-11-15 20:44:56 -0800 | [diff] [blame] | 6492 | {QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_ABS_DELAY, |
| 6493 | hdd_config_propagation_abs_delay}, |
Jeff Johnson | 7c5e6dc | 2018-11-15 21:20:18 -0800 | [diff] [blame] | 6494 | {QCA_WLAN_VENDOR_ATTR_CONFIG_TX_FAIL_COUNT, |
| 6495 | hdd_config_tx_fail_count}, |
Jeff Johnson | 7766fd2 | 2018-11-15 21:52:37 -0800 | [diff] [blame] | 6496 | {QCA_WLAN_VENDOR_ATTR_CONFIG_CHANNEL_AVOIDANCE_IND, |
| 6497 | hdd_config_channel_avoidance_ind}, |
Jeff Johnson | f9871e4 | 2018-11-15 22:24:06 -0800 | [diff] [blame] | 6498 | {QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_ENA, |
| 6499 | hdd_config_ant_div_ena}, |
Jeff Johnson | 91f90ff | 2018-11-16 07:53:37 -0800 | [diff] [blame] | 6500 | {QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SNR_DIFF, |
| 6501 | hdd_config_ant_div_snr_diff}, |
Jeff Johnson | 77177bc | 2018-11-16 08:14:20 -0800 | [diff] [blame] | 6502 | {QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_DWELL_TIME, |
| 6503 | hdd_config_ant_div_probe_dwell_time}, |
Jeff Johnson | aa17222 | 2018-11-16 09:16:11 -0800 | [diff] [blame] | 6504 | {QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_CHAIN, |
| 6505 | hdd_config_ant_div_chain}, |
Jeff Johnson | ef427ad | 2018-11-16 09:22:17 -0800 | [diff] [blame] | 6506 | {QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SELFTEST, |
| 6507 | hdd_config_ant_div_selftest}, |
Jeff Johnson | ae21be8 | 2018-11-16 09:43:53 -0800 | [diff] [blame] | 6508 | {QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SELFTEST_INTVL, |
| 6509 | hdd_config_ant_div_selftest_intvl}, |
Jeff Johnson | 3a25de8 | 2018-11-16 07:26:46 -0800 | [diff] [blame] | 6510 | {QCA_WLAN_VENDOR_ATTR_CONFIG_IGNORE_ASSOC_DISALLOWED, |
| 6511 | hdd_config_ignore_assoc_disallowed}, |
Jeff Johnson | 72dc91e | 2018-11-16 08:46:12 -0800 | [diff] [blame] | 6512 | {QCA_WLAN_VENDOR_ATTR_CONFIG_RESTRICT_OFFCHANNEL, |
| 6513 | hdd_config_restrict_offchannel}, |
Jeff Johnson | 320feeb | 2018-11-16 10:14:24 -0800 | [diff] [blame] | 6514 | {QCA_WLAN_VENDOR_ATTR_CONFIG_TOTAL_BEACON_MISS_COUNT, |
| 6515 | hdd_config_total_beacon_miss_count}, |
Jeff Johnson | 2502ddd | 2018-11-16 10:59:30 -0800 | [diff] [blame] | 6516 | {QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL, |
| 6517 | hdd_config_latency_level}, |
Jeff Johnson | 0a31591 | 2018-11-16 11:18:21 -0800 | [diff] [blame] | 6518 | {QCA_WLAN_VENDOR_ATTR_CONFIG_DISABLE_FILS, |
| 6519 | hdd_config_disable_fils}, |
Jeff Johnson | 0bdbb96 | 2018-11-16 11:42:10 -0800 | [diff] [blame] | 6520 | {QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE, |
| 6521 | hdd_config_rsn_ie}, |
Jeff Johnson | 7acca0d | 2018-11-16 11:53:18 -0800 | [diff] [blame] | 6522 | {QCA_WLAN_VENDOR_ATTR_CONFIG_GTX, |
| 6523 | hdd_config_gtx}, |
Jeff Johnson | b48efe2 | 2018-11-15 11:53:09 -0800 | [diff] [blame] | 6524 | }; |
| 6525 | |
| 6526 | /** |
| 6527 | * hdd_set_independent_configuration() - Handle independent attributes |
| 6528 | * @adapter: adapter upon which the vendor command was received |
| 6529 | * @tb: parsed attribute array |
| 6530 | * |
| 6531 | * This is a table-driven function which dispatches independent |
| 6532 | * attributes in a QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION |
| 6533 | * vendor command. An attribute is considered independent if it |
| 6534 | * doesn't depend upon any other attributes |
| 6535 | * |
| 6536 | * Return: 0 if there were no issues, otherwise errno of the last issue |
| 6537 | */ |
| 6538 | static int hdd_set_independent_configuration(struct hdd_adapter *adapter, |
| 6539 | struct nlattr **tb) |
| 6540 | { |
| 6541 | uint32_t i; |
| 6542 | uint32_t id; |
| 6543 | struct nlattr *attr; |
| 6544 | independent_setter_fn cb; |
| 6545 | int errno = 0; |
| 6546 | int ret; |
| 6547 | |
| 6548 | for (i = 0; i < QDF_ARRAY_SIZE(independent_setters); i++) { |
| 6549 | id = independent_setters[i].id; |
| 6550 | attr = tb[id]; |
| 6551 | if (!attr) |
| 6552 | continue; |
| 6553 | |
| 6554 | cb = independent_setters[i].cb; |
| 6555 | ret = cb(adapter, attr); |
| 6556 | if (ret) |
| 6557 | errno = ret; |
| 6558 | } |
| 6559 | |
| 6560 | return errno; |
| 6561 | } |
| 6562 | |
| 6563 | /** |
| 6564 | * typedef interdependent_setter_fn - interdependent attribute handler |
| 6565 | * @adapter: The adapter being configured |
| 6566 | * @tb: The parsed nl80211 attributes being applied |
| 6567 | * |
| 6568 | * Defines the signature of functions in the interdependent attribute vtable |
| 6569 | * |
| 6570 | * Return: 0 if attributes were handled successfully, otherwise an errno |
| 6571 | */ |
| 6572 | typedef int (*interdependent_setter_fn)(struct hdd_adapter *adapter, |
| 6573 | struct nlattr **tb); |
| 6574 | |
| 6575 | /* vtable for interdependent setters */ |
| 6576 | static const interdependent_setter_fn interdependent_setters[] = { |
Jeff Johnson | affc4da | 2018-11-16 14:10:07 -0800 | [diff] [blame] | 6577 | hdd_config_access_policy, |
Jeff Johnson | 0fbb43b | 2018-11-16 15:38:56 -0800 | [diff] [blame] | 6578 | hdd_config_mpdu_aggregation, |
Jeff Johnson | 7bf20cb | 2018-11-16 17:38:27 -0800 | [diff] [blame] | 6579 | hdd_config_ant_div_period, |
Jeff Johnson | 1350e62 | 2018-11-16 18:36:55 -0800 | [diff] [blame] | 6580 | hdd_config_ant_div_snr_weight, |
Jeff Johnson | 0dd687e | 2018-11-16 20:11:27 -0800 | [diff] [blame] | 6581 | wlan_hdd_cfg80211_wifi_set_reorder_timeout, |
Jeff Johnson | 339ede8 | 2018-11-16 20:27:52 -0800 | [diff] [blame] | 6582 | wlan_hdd_cfg80211_wifi_set_rx_blocksize, |
Jeff Johnson | b48efe2 | 2018-11-15 11:53:09 -0800 | [diff] [blame] | 6583 | }; |
| 6584 | |
| 6585 | /** |
| 6586 | * hdd_set_interdependent_configuration() - Handle interdependent attributes |
| 6587 | * @adapter: adapter upon which the vendor command was received |
| 6588 | * @tb: parsed attribute array |
| 6589 | * |
| 6590 | * This is a table-driven function which handles interdependent |
| 6591 | * attributes in a QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION |
| 6592 | * vendor command. A set of attributes is considered interdependent if |
| 6593 | * they depend upon each other. In the typical case if one of the |
| 6594 | * attributes is present in the the attribute array, then all of the |
| 6595 | * attributes must be present. |
| 6596 | * |
| 6597 | * Return: 0 if there were no issues, otherwise errno of the last issue |
| 6598 | */ |
| 6599 | static int hdd_set_interdependent_configuration(struct hdd_adapter *adapter, |
| 6600 | struct nlattr **tb) |
| 6601 | { |
| 6602 | uint32_t i; |
| 6603 | interdependent_setter_fn cb; |
| 6604 | int errno = 0; |
| 6605 | int ret; |
| 6606 | |
| 6607 | for (i = 0; i < QDF_ARRAY_SIZE(interdependent_setters); i++) { |
| 6608 | cb = interdependent_setters[i]; |
| 6609 | ret = cb(adapter, tb); |
| 6610 | if (ret) |
| 6611 | errno = ret; |
| 6612 | } |
| 6613 | |
| 6614 | return errno; |
| 6615 | } |
| 6616 | |
| 6617 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6618 | * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration |
| 6619 | * vendor command |
| 6620 | * |
| 6621 | * @wiphy: wiphy device pointer |
| 6622 | * @wdev: wireless device pointer |
| 6623 | * @data: Vendor command data buffer |
| 6624 | * @data_len: Buffer length |
| 6625 | * |
| 6626 | * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX. |
| 6627 | * |
| 6628 | * Return: Error code. |
| 6629 | */ |
| 6630 | static int |
| 6631 | __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, |
| 6632 | struct wireless_dev *wdev, |
| 6633 | const void *data, |
| 6634 | int data_len) |
| 6635 | { |
| 6636 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 6637 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 6638 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6639 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_CONFIG_MAX + 1]; |
Jeff Johnson | b48efe2 | 2018-11-15 11:53:09 -0800 | [diff] [blame] | 6640 | int errno; |
Jeff Johnson | 3b2abe9 | 2017-12-15 09:03:47 -0800 | [diff] [blame] | 6641 | int ret; |
Deepak Dhamdhere | b106ae5 | 2016-08-10 20:55:30 +0530 | [diff] [blame] | 6642 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 6643 | hdd_enter_dev(dev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 6644 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6645 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6646 | hdd_err("Command not allowed in FTM mode"); |
| 6647 | return -EPERM; |
| 6648 | } |
| 6649 | |
Jeff Johnson | b48efe2 | 2018-11-15 11:53:09 -0800 | [diff] [blame] | 6650 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 6651 | if (errno) |
| 6652 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6653 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 6654 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_CONFIG_MAX, data, |
| 6655 | data_len, wlan_hdd_wifi_config_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6656 | hdd_err("invalid attr"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6657 | return -EINVAL; |
| 6658 | } |
| 6659 | |
Jeff Johnson | b48efe2 | 2018-11-15 11:53:09 -0800 | [diff] [blame] | 6660 | ret = hdd_set_independent_configuration(adapter, tb); |
| 6661 | if (ret) |
| 6662 | errno = ret; |
| 6663 | |
| 6664 | ret = hdd_set_interdependent_configuration(adapter, tb); |
| 6665 | if (ret) |
| 6666 | errno = ret; |
| 6667 | |
Jeff Johnson | b48efe2 | 2018-11-15 11:53:09 -0800 | [diff] [blame] | 6668 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6669 | } |
| 6670 | |
| 6671 | /** |
| 6672 | * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration |
| 6673 | * vendor command |
| 6674 | * |
| 6675 | * @wiphy: wiphy device pointer |
| 6676 | * @wdev: wireless device pointer |
| 6677 | * @data: Vendor command data buffer |
| 6678 | * @data_len: Buffer length |
| 6679 | * |
| 6680 | * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX. |
| 6681 | * |
| 6682 | * Return: EOK or other error codes. |
| 6683 | */ |
| 6684 | static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, |
| 6685 | struct wireless_dev *wdev, |
| 6686 | const void *data, |
| 6687 | int data_len) |
| 6688 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 6689 | int errno; |
| 6690 | struct osif_vdev_sync *vdev_sync; |
| 6691 | |
| 6692 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 6693 | if (errno) |
| 6694 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6695 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 6696 | errno = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev, |
| 6697 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6698 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 6699 | osif_vdev_sync_op_stop(vdev_sync); |
| 6700 | |
| 6701 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6702 | } |
| 6703 | |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6704 | /** |
| 6705 | * __wlan_hdd_cfg80211_set_wifi_test_config() - Wifi test configuration |
| 6706 | * vendor command |
| 6707 | * |
| 6708 | * @wiphy: wiphy device pointer |
| 6709 | * @wdev: wireless device pointer |
| 6710 | * @data: Vendor command data buffer |
| 6711 | * @data_len: Buffer length |
| 6712 | * |
| 6713 | * Handles QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_MAX |
| 6714 | * |
| 6715 | * Return: Error code. |
| 6716 | */ |
| 6717 | static int |
| 6718 | __wlan_hdd_cfg80211_set_wifi_test_config(struct wiphy *wiphy, |
Srinivas Girigowda | a19eafd | 2018-09-07 15:28:21 -0700 | [diff] [blame] | 6719 | struct wireless_dev *wdev, const void *data, int data_len) |
| 6720 | { |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6721 | struct net_device *dev = wdev->netdev; |
| 6722 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6723 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 6724 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_MAX + 1]; |
| 6725 | int ret_val = 0; |
| 6726 | uint8_t cfg_val = 0; |
Kiran Kumar Lokere | a934561 | 2018-02-08 14:28:24 -0800 | [diff] [blame] | 6727 | uint8_t set_val = 0; |
Jeff Johnson | 46b4f0e | 2019-03-08 10:48:35 -0800 | [diff] [blame] | 6728 | struct sme_config_params *sme_config; |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 6729 | bool update_sme_cfg = false; |
Kiran Kumar Lokere | 3324f63 | 2018-03-01 21:43:21 -0800 | [diff] [blame] | 6730 | uint8_t tid = 0, ac; |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6731 | uint16_t buff_size = 0; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6732 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6733 | QDF_STATUS status; |
| 6734 | bool bval = false; |
| 6735 | uint8_t value = 0; |
Abhinav Kumar | 7d6f1ac | 2018-09-01 18:33:56 +0530 | [diff] [blame] | 6736 | uint8_t wmm_mode = 0; |
Kiran Kumar Lokere | 9463415 | 2018-09-24 19:08:35 -0700 | [diff] [blame] | 6737 | uint32_t cmd_id; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6738 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 6739 | hdd_enter_dev(dev); |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6740 | |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 6741 | sme_config = qdf_mem_malloc(sizeof(*sme_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 6742 | if (!sme_config) |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 6743 | return -ENOMEM; |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 6744 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6745 | mac_handle = hdd_ctx->mac_handle; |
| 6746 | sme_get_config_param(mac_handle, sme_config); |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 6747 | |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6748 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 6749 | hdd_err("Command not allowed in FTM mode"); |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6750 | ret_val = -EPERM; |
| 6751 | goto send_err; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6752 | } |
| 6753 | |
| 6754 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 6755 | if (ret_val) |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6756 | goto send_err; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6757 | |
| 6758 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 6759 | hdd_err("Driver Modules are closed, can not start logger"); |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6760 | ret_val = -EINVAL; |
| 6761 | goto send_err; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6762 | } |
| 6763 | |
| 6764 | if (wlan_cfg80211_nla_parse(tb, |
| 6765 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_MAX, |
| 6766 | data, data_len, wlan_hdd_wifi_test_config_policy)) { |
| 6767 | hdd_err("invalid attr"); |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6768 | ret_val = -EINVAL; |
| 6769 | goto send_err; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6770 | } |
| 6771 | |
| 6772 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ACCEPT_ADDBA_REQ]) { |
| 6773 | cfg_val = nla_get_u8(tb[ |
| 6774 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ACCEPT_ADDBA_REQ] |
| 6775 | ); |
| 6776 | hdd_debug("set addba accept req from peer value %d", cfg_val); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6777 | ret_val = sme_set_addba_accept(mac_handle, adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6778 | cfg_val); |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6779 | if (ret_val) |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6780 | goto send_err; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6781 | } |
| 6782 | |
Kiran Kumar Lokere | 96246e5 | 2018-01-24 16:44:35 -0800 | [diff] [blame] | 6783 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_MCS]) { |
| 6784 | cfg_val = nla_get_u8(tb[ |
| 6785 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_MCS]); |
| 6786 | hdd_debug("set HE MCS value 0x%0X", cfg_val); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6787 | ret_val = sme_update_he_mcs(mac_handle, adapter->vdev_id, |
Kiran Kumar Lokere | 96246e5 | 2018-01-24 16:44:35 -0800 | [diff] [blame] | 6788 | cfg_val); |
| 6789 | if (ret_val) |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6790 | goto send_err; |
Kiran Kumar Lokere | 96246e5 | 2018-01-24 16:44:35 -0800 | [diff] [blame] | 6791 | } |
| 6792 | |
Krunal Soni | 707eb78 | 2018-01-18 12:04:19 -0800 | [diff] [blame] | 6793 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WMM_ENABLE]) { |
| 6794 | cfg_val = nla_get_u8(tb[ |
| 6795 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WMM_ENABLE]); |
Krunal Soni | 707eb78 | 2018-01-18 12:04:19 -0800 | [diff] [blame] | 6796 | if (!cfg_val) { |
| 6797 | sme_config->csrConfig.WMMSupportMode = |
| 6798 | hdd_to_csr_wmm_mode(HDD_WMM_USER_MODE_NO_QOS); |
| 6799 | hdd_debug("wmm is disabled"); |
| 6800 | } else { |
Abhinav Kumar | 7d6f1ac | 2018-09-01 18:33:56 +0530 | [diff] [blame] | 6801 | status = ucfg_mlme_get_wmm_mode(hdd_ctx->psoc, |
| 6802 | &wmm_mode); |
| 6803 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 6804 | hdd_err("Get wmm_mode failed"); |
| 6805 | return QDF_STATUS_E_FAILURE; |
| 6806 | } |
Krunal Soni | 707eb78 | 2018-01-18 12:04:19 -0800 | [diff] [blame] | 6807 | sme_config->csrConfig.WMMSupportMode = |
Abhinav Kumar | 7d6f1ac | 2018-09-01 18:33:56 +0530 | [diff] [blame] | 6808 | hdd_to_csr_wmm_mode(wmm_mode); |
Krunal Soni | 707eb78 | 2018-01-18 12:04:19 -0800 | [diff] [blame] | 6809 | hdd_debug("using wmm default value"); |
| 6810 | } |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 6811 | update_sme_cfg = true; |
Krunal Soni | 707eb78 | 2018-01-18 12:04:19 -0800 | [diff] [blame] | 6812 | } |
| 6813 | |
Kiran Kumar Lokere | a934561 | 2018-02-08 14:28:24 -0800 | [diff] [blame] | 6814 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_SEND_ADDBA_REQ]) { |
| 6815 | cfg_val = nla_get_u8(tb[ |
| 6816 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_SEND_ADDBA_REQ]); |
| 6817 | if (cfg_val) { |
| 6818 | /*Auto BA mode*/ |
| 6819 | set_val = 0; |
| 6820 | hdd_debug("BA operating mode is set to auto"); |
| 6821 | } else { |
| 6822 | /*Manual BA mode*/ |
| 6823 | set_val = 1; |
| 6824 | hdd_debug("BA operating mode is set to Manual"); |
| 6825 | } |
| 6826 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6827 | ret_val = wma_cli_set_command(adapter->vdev_id, |
Kiran Kumar Lokere | a934561 | 2018-02-08 14:28:24 -0800 | [diff] [blame] | 6828 | WMI_VDEV_PARAM_BA_MODE, set_val, VDEV_CMD); |
Kiran Kumar Lokere | 015f77f | 2018-04-24 18:25:28 -0700 | [diff] [blame] | 6829 | if (ret_val) { |
| 6830 | hdd_err("Set BA operating mode failed"); |
| 6831 | goto send_err; |
| 6832 | } |
| 6833 | if (!cfg_val) { |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6834 | ret_val = wma_cli_set_command(adapter->vdev_id, |
Kiran Kumar Lokere | 015f77f | 2018-04-24 18:25:28 -0700 | [diff] [blame] | 6835 | WMI_VDEV_PARAM_AMSDU_AGGREGATION_SIZE_OPTIMIZATION, |
| 6836 | 0, VDEV_CMD); |
| 6837 | } |
Kiran Kumar Lokere | a934561 | 2018-02-08 14:28:24 -0800 | [diff] [blame] | 6838 | } |
| 6839 | |
Kiran Kumar Lokere | 5cc2f0d | 2018-02-08 17:10:05 -0800 | [diff] [blame] | 6840 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_FRAGMENTATION]) { |
| 6841 | cfg_val = nla_get_u8(tb[ |
| 6842 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_FRAGMENTATION] |
| 6843 | ); |
| 6844 | if (cfg_val > HE_FRAG_LEVEL1) |
| 6845 | set_val = HE_FRAG_LEVEL1; |
| 6846 | else |
| 6847 | set_val = cfg_val; |
| 6848 | |
| 6849 | hdd_debug("set HE fragmention to %d", set_val); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6850 | ret_val = sme_update_he_frag_supp(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6851 | adapter->vdev_id, set_val); |
Kiran Kumar Lokere | 5cc2f0d | 2018-02-08 17:10:05 -0800 | [diff] [blame] | 6852 | } |
| 6853 | |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 6854 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WEP_TKIP_IN_HE]) { |
| 6855 | cfg_val = nla_get_u8(tb[ |
| 6856 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WEP_TKIP_IN_HE]); |
| 6857 | sme_config->csrConfig.wep_tkip_in_he = cfg_val; |
| 6858 | hdd_debug("Set WEP/TKIP allow in HE %d", cfg_val); |
| 6859 | |
| 6860 | update_sme_cfg = true; |
| 6861 | } |
| 6862 | |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6863 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADD_DEL_BA_SESSION]) { |
| 6864 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_BA_TID]) { |
| 6865 | tid = nla_get_u8(tb[ |
| 6866 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_BA_TID]); |
| 6867 | } else { |
| 6868 | hdd_err("TID is not set for ADD/DEL BA cfg"); |
| 6869 | ret_val = -EINVAL; |
| 6870 | goto send_err; |
| 6871 | } |
| 6872 | cfg_val = nla_get_u8(tb[ |
| 6873 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADD_DEL_BA_SESSION]); |
| 6874 | if (cfg_val == QCA_WLAN_ADD_BA) { |
| 6875 | if (tb[ |
| 6876 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADDBA_BUFF_SIZE]) |
Kiran Kumar Lokere | eac7fe9 | 2018-07-24 16:56:01 -0700 | [diff] [blame] | 6877 | buff_size = nla_get_u16(tb[ |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6878 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADDBA_BUFF_SIZE]); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6879 | ret_val = sme_send_addba_req(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6880 | adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6881 | tid, buff_size); |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6882 | } else if (cfg_val == QCA_WLAN_DELETE_BA) { |
| 6883 | } else { |
| 6884 | hdd_err("Invalid BA session cfg"); |
| 6885 | ret_val = -EINVAL; |
| 6886 | goto send_err; |
| 6887 | } |
| 6888 | } else if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADDBA_BUFF_SIZE]) { |
Kiran Kumar Lokere | eac7fe9 | 2018-07-24 16:56:01 -0700 | [diff] [blame] | 6889 | buff_size = nla_get_u16(tb[ |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6890 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADDBA_BUFF_SIZE]); |
| 6891 | hdd_debug("set buff size to %d for all tids", buff_size); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6892 | ret_val = sme_set_ba_buff_size(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6893 | adapter->vdev_id, buff_size); |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6894 | if (ret_val) |
| 6895 | goto send_err; |
| 6896 | if (buff_size > 64) |
| 6897 | /* Configure ADDBA req buffer size to 256 */ |
| 6898 | set_val = 3; |
| 6899 | else |
| 6900 | /* Configure ADDBA req buffer size to 64 */ |
| 6901 | set_val = 2; |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6902 | ret_val = wma_cli_set_command(adapter->vdev_id, |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6903 | WMI_VDEV_PARAM_BA_MODE, set_val, VDEV_CMD); |
Kiran Kumar Lokere | 427a20f | 2018-08-23 18:47:27 -0700 | [diff] [blame] | 6904 | if (ret_val) |
| 6905 | hdd_err("Failed to set BA operating mode %d", set_val); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6906 | ret_val = wma_cli_set_command(adapter->vdev_id, |
Kiran Kumar Lokere | 427a20f | 2018-08-23 18:47:27 -0700 | [diff] [blame] | 6907 | GEN_VDEV_PARAM_AMPDU, |
| 6908 | buff_size, GEN_CMD); |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6909 | } |
| 6910 | |
Kiran Kumar Lokere | 3324f63 | 2018-03-01 21:43:21 -0800 | [diff] [blame] | 6911 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ENABLE_NO_ACK]) { |
Kiran Kumar Lokere | 30313a3 | 2018-04-30 18:20:06 -0700 | [diff] [blame] | 6912 | int he_mcs_val; |
Srinivas Girigowda | 5033534 | 2018-09-07 15:21:01 -0700 | [diff] [blame] | 6913 | |
Kiran Kumar Lokere | 3324f63 | 2018-03-01 21:43:21 -0800 | [diff] [blame] | 6914 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_NO_ACK_AC]) { |
| 6915 | ac = nla_get_u8(tb[ |
| 6916 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_NO_ACK_AC]); |
| 6917 | } else { |
| 6918 | hdd_err("AC is not set for NO ACK policy config"); |
| 6919 | ret_val = -EINVAL; |
| 6920 | goto send_err; |
| 6921 | } |
| 6922 | cfg_val = nla_get_u8(tb[ |
| 6923 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ENABLE_NO_ACK]); |
| 6924 | hdd_debug("Set NO_ACK to %d for ac %d", cfg_val, ac); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6925 | ret_val = sme_set_no_ack_policy(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6926 | adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6927 | cfg_val, ac); |
Kiran Kumar Lokere | 30313a3 | 2018-04-30 18:20:06 -0700 | [diff] [blame] | 6928 | if (cfg_val) { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6929 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, |
| 6930 | &bval); |
| 6931 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 6932 | hdd_err("unable to get vht_enable2x2"); |
| 6933 | if (bval) |
Kiran Kumar Lokere | 30313a3 | 2018-04-30 18:20:06 -0700 | [diff] [blame] | 6934 | /*2x2 MCS 5 value*/ |
| 6935 | he_mcs_val = 0x45; |
| 6936 | else |
| 6937 | /*1x1 MCS 5 value*/ |
| 6938 | he_mcs_val = 0x25; |
| 6939 | |
| 6940 | if (hdd_set_11ax_rate(adapter, he_mcs_val, NULL)) |
| 6941 | hdd_err("HE MCS set failed, MCS val %0x", |
| 6942 | he_mcs_val); |
| 6943 | } else { |
| 6944 | if (hdd_set_11ax_rate(adapter, 0xFF, NULL)) |
| 6945 | hdd_err("disable fixed rate failed"); |
| 6946 | } |
Kiran Kumar Lokere | 3324f63 | 2018-03-01 21:43:21 -0800 | [diff] [blame] | 6947 | } |
| 6948 | |
Kiran Kumar Lokere | a006a30 | 2018-03-07 20:58:13 -0800 | [diff] [blame] | 6949 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_LTF]) { |
| 6950 | cfg_val = nla_get_u8(tb[ |
| 6951 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_LTF]); |
| 6952 | hdd_debug("Set HE LTF to %d", cfg_val); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6953 | ret_val = sme_set_auto_rate_he_ltf(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6954 | adapter->vdev_id, |
Kiran Kumar Lokere | a006a30 | 2018-03-07 20:58:13 -0800 | [diff] [blame] | 6955 | cfg_val); |
| 6956 | if (ret_val) |
| 6957 | sme_err("Failed to set auto rate HE LTF"); |
| 6958 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6959 | ret_val = wma_cli_set_command(adapter->vdev_id, |
Kiran Kumar Lokere | a006a30 | 2018-03-07 20:58:13 -0800 | [diff] [blame] | 6960 | WMI_VDEV_PARAM_HE_LTF, |
| 6961 | cfg_val, VDEV_CMD); |
| 6962 | if (ret_val) |
| 6963 | goto send_err; |
| 6964 | } |
| 6965 | |
Kiran Kumar Lokere | 6c7f3fa | 2018-05-14 18:12:27 -0700 | [diff] [blame] | 6966 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ENABLE_TX_BEAMFORMEE]) { |
| 6967 | cfg_val = nla_get_u8(tb[ |
| 6968 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ENABLE_TX_BEAMFORMEE]); |
| 6969 | hdd_debug("Set Tx beamformee to %d", cfg_val); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 6970 | ret_val = sme_update_tx_bfee_supp(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6971 | adapter->vdev_id, |
Kiran Kumar Lokere | 6c7f3fa | 2018-05-14 18:12:27 -0700 | [diff] [blame] | 6972 | cfg_val); |
| 6973 | if (ret_val) |
| 6974 | sme_err("Failed to set Tx beamformee cap"); |
| 6975 | |
| 6976 | } |
| 6977 | |
Kiran Kumar Lokere | f304485 | 2018-06-27 14:14:24 -0700 | [diff] [blame] | 6978 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_TX_BEAMFORMEE_NSTS]) { |
| 6979 | cfg_val = nla_get_u8(tb[ |
| 6980 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_TX_BEAMFORMEE_NSTS]); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6981 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 6982 | &value); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6983 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 6984 | hdd_err("unable to get tx_bfee_ant_supp"); |
| 6985 | |
Kiran Kumar Lokere | a67af05 | 2018-12-12 19:18:51 -0800 | [diff] [blame] | 6986 | if (!cfg_in_range(CFG_VHT_BEAMFORMEE_ANT_SUPP, cfg_val)) { |
Kiran Kumar Lokere | f304485 | 2018-06-27 14:14:24 -0700 | [diff] [blame] | 6987 | hdd_err("NSTS %d not supported, supp_val %d", cfg_val, |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6988 | value); |
Kiran Kumar Lokere | f304485 | 2018-06-27 14:14:24 -0700 | [diff] [blame] | 6989 | ret_val = -ENOTSUPP; |
| 6990 | goto send_err; |
| 6991 | } |
| 6992 | hdd_debug("Set Tx beamformee NSTS to %d", cfg_val); |
| 6993 | ret_val = sme_update_tx_bfee_nsts(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 6994 | adapter->vdev_id, |
Kiran Kumar Lokere | f304485 | 2018-06-27 14:14:24 -0700 | [diff] [blame] | 6995 | cfg_val, |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6996 | value); |
Kiran Kumar Lokere | f304485 | 2018-06-27 14:14:24 -0700 | [diff] [blame] | 6997 | if (ret_val) |
| 6998 | sme_err("Failed to set Tx beamformee cap"); |
| 6999 | |
| 7000 | } |
| 7001 | |
Kiran Kumar Lokere | f54b855 | 2018-07-10 00:53:38 -0700 | [diff] [blame] | 7002 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_MAC_PADDING_DUR]) { |
| 7003 | cfg_val = nla_get_u8(tb[ |
| 7004 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_MAC_PADDING_DUR]); |
| 7005 | if (cfg_val) { |
Kiran Kumar Lokere | 427a20f | 2018-08-23 18:47:27 -0700 | [diff] [blame] | 7006 | hdd_debug("Set HE mac padding dur to %d", cfg_val); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7007 | ret_val = sme_cli_set_command(adapter->vdev_id, |
Kiran Kumar Lokere | f54b855 | 2018-07-10 00:53:38 -0700 | [diff] [blame] | 7008 | WMI_VDEV_PARAM_MU_EDCA_FW_UPDATE_EN, |
| 7009 | 0, VDEV_CMD); |
| 7010 | if (ret_val) |
| 7011 | hdd_err("MU_EDCA update disable failed"); |
| 7012 | sme_set_usr_cfg_mu_edca(hdd_ctx->mac_handle, true); |
| 7013 | sme_set_he_mu_edca_def_cfg(hdd_ctx->mac_handle); |
| 7014 | if (sme_update_mu_edca_params(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7015 | adapter->vdev_id)) |
Kiran Kumar Lokere | f54b855 | 2018-07-10 00:53:38 -0700 | [diff] [blame] | 7016 | hdd_err("Failed to send mu edca params"); |
| 7017 | } else { |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7018 | ret_val = sme_cli_set_command(adapter->vdev_id, |
Kiran Kumar Lokere | f54b855 | 2018-07-10 00:53:38 -0700 | [diff] [blame] | 7019 | WMI_VDEV_PARAM_MU_EDCA_FW_UPDATE_EN, |
| 7020 | 1, VDEV_CMD); |
| 7021 | sme_set_usr_cfg_mu_edca(hdd_ctx->mac_handle, false); |
| 7022 | } |
| 7023 | ret_val = sme_update_he_trigger_frm_mac_pad(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7024 | adapter->vdev_id, |
Kiran Kumar Lokere | f54b855 | 2018-07-10 00:53:38 -0700 | [diff] [blame] | 7025 | cfg_val); |
| 7026 | if (ret_val) |
| 7027 | hdd_err("Failed to set Trig frame mac padding cap"); |
| 7028 | } |
| 7029 | |
Kiran Kumar Lokere | 8d685d1 | 2018-07-23 17:17:26 -0700 | [diff] [blame] | 7030 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_OVERRIDE_MU_EDCA]) { |
| 7031 | cfg_val = nla_get_u8(tb[ |
| 7032 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_OVERRIDE_MU_EDCA]); |
| 7033 | if (cfg_val) { |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7034 | ret_val = sme_cli_set_command(adapter->vdev_id, |
Kiran Kumar Lokere | 8d685d1 | 2018-07-23 17:17:26 -0700 | [diff] [blame] | 7035 | WMI_VDEV_PARAM_MU_EDCA_FW_UPDATE_EN, |
| 7036 | 0, VDEV_CMD); |
| 7037 | if (ret_val) |
| 7038 | hdd_err("MU_EDCA update disable failed"); |
| 7039 | sme_set_usr_cfg_mu_edca(hdd_ctx->mac_handle, true); |
| 7040 | sme_set_he_mu_edca_def_cfg(hdd_ctx->mac_handle); |
| 7041 | if (sme_update_mu_edca_params(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7042 | adapter->vdev_id)) |
Kiran Kumar Lokere | 8d685d1 | 2018-07-23 17:17:26 -0700 | [diff] [blame] | 7043 | hdd_err("Failed to send mu edca params"); |
| 7044 | } else { |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7045 | ret_val = sme_cli_set_command(adapter->vdev_id, |
Kiran Kumar Lokere | 8d685d1 | 2018-07-23 17:17:26 -0700 | [diff] [blame] | 7046 | WMI_VDEV_PARAM_MU_EDCA_FW_UPDATE_EN, |
| 7047 | 1, VDEV_CMD); |
| 7048 | sme_set_usr_cfg_mu_edca(hdd_ctx->mac_handle, false); |
| 7049 | } |
| 7050 | } |
Kiran Kumar Lokere | f1a96f4 | 2018-08-29 18:53:47 -0700 | [diff] [blame] | 7051 | |
| 7052 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_OM_CTRL_SUPP]) { |
| 7053 | cfg_val = nla_get_u8(tb[ |
| 7054 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_OM_CTRL_SUPP]); |
| 7055 | ret_val = sme_update_he_om_ctrl_supp(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7056 | adapter->vdev_id, |
Kiran Kumar Lokere | f1a96f4 | 2018-08-29 18:53:47 -0700 | [diff] [blame] | 7057 | cfg_val); |
| 7058 | } |
| 7059 | |
Kiran Kumar Lokere | acd107d | 2019-01-09 15:02:11 -0800 | [diff] [blame] | 7060 | cmd_id = QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_OMI_TX; |
Kiran Kumar Lokere | 9463415 | 2018-09-24 19:08:35 -0700 | [diff] [blame] | 7061 | if (tb[cmd_id]) { |
Kiran Kumar Lokere | acd107d | 2019-01-09 15:02:11 -0800 | [diff] [blame] | 7062 | struct nlattr *tb2[QCA_WLAN_VENDOR_ATTR_HE_OMI_MAX + 1]; |
| 7063 | struct nlattr *curr_attr; |
| 7064 | int tmp, rc; |
| 7065 | nla_for_each_nested(curr_attr, tb[cmd_id], tmp) { |
| 7066 | rc = wlan_cfg80211_nla_parse( |
| 7067 | tb2, QCA_WLAN_VENDOR_ATTR_HE_OMI_MAX, |
| 7068 | nla_data(curr_attr), |
| 7069 | nla_len(curr_attr), |
| 7070 | qca_wlan_vendor_attr_he_omi_tx_policy); |
| 7071 | if (rc) { |
| 7072 | hdd_err("Invalid ATTR"); |
| 7073 | goto send_err; |
| 7074 | } |
| 7075 | cmd_id = QCA_WLAN_VENDOR_ATTR_HE_OMI_CH_BW; |
| 7076 | if (tb2[cmd_id]) { |
| 7077 | cfg_val = nla_get_u8(tb2[cmd_id]); |
| 7078 | ret_val = sme_set_he_om_ctrl_param( |
| 7079 | hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7080 | adapter->vdev_id, |
Kiran Kumar Lokere | acd107d | 2019-01-09 15:02:11 -0800 | [diff] [blame] | 7081 | cmd_id, cfg_val); |
| 7082 | } |
| 7083 | cmd_id = QCA_WLAN_VENDOR_ATTR_HE_OMI_RX_NSS; |
| 7084 | if (tb2[cmd_id]) { |
| 7085 | cfg_val = nla_get_u8(tb2[cmd_id]); |
| 7086 | ret_val = sme_set_he_om_ctrl_param( |
| 7087 | hdd_ctx->mac_handle, |
| 7088 | adapter->vdev_id, |
| 7089 | cmd_id, cfg_val); |
| 7090 | } |
| 7091 | |
| 7092 | cmd_id = QCA_WLAN_VENDOR_ATTR_HE_OMI_ULMU_DISABLE; |
| 7093 | if (tb2[cmd_id]) { |
| 7094 | cfg_val = nla_get_u8(tb2[cmd_id]); |
| 7095 | ret_val = sme_set_he_om_ctrl_param( |
| 7096 | hdd_ctx->mac_handle, |
| 7097 | adapter->vdev_id, |
| 7098 | cmd_id, cfg_val); |
| 7099 | } |
| 7100 | |
| 7101 | cmd_id = QCA_WLAN_VENDOR_ATTR_HE_OMI_TX_NSTS; |
| 7102 | if (tb2[cmd_id]) { |
| 7103 | cfg_val = nla_get_u8(tb2[cmd_id]); |
| 7104 | ret_val = sme_set_he_om_ctrl_param( |
| 7105 | hdd_ctx->mac_handle, |
| 7106 | adapter->vdev_id, |
| 7107 | cmd_id, cfg_val); |
| 7108 | } |
Kiran Kumar Lokere | 49e3aff | 2019-02-06 17:00:48 -0800 | [diff] [blame] | 7109 | |
| 7110 | cmd_id = QCA_WLAN_VENDOR_ATTR_HE_OMI_ULMU_DATA_DISABLE; |
| 7111 | if (tb2[cmd_id]) { |
| 7112 | cfg_val = nla_get_u8(tb2[cmd_id]); |
| 7113 | ret_val = sme_set_he_om_ctrl_param( |
| 7114 | hdd_ctx->mac_handle, |
| 7115 | adapter->vdev_id, |
| 7116 | cmd_id, cfg_val); |
| 7117 | } |
| 7118 | |
Kiran Kumar Lokere | acd107d | 2019-01-09 15:02:11 -0800 | [diff] [blame] | 7119 | } |
| 7120 | if (ret_val) { |
| 7121 | sme_reset_he_om_ctrl(hdd_ctx->mac_handle); |
| 7122 | goto send_err; |
| 7123 | } |
| 7124 | ret_val = sme_send_he_om_ctrl_update(hdd_ctx->mac_handle, |
| 7125 | adapter->vdev_id); |
Kiran Kumar Lokere | 9463415 | 2018-09-24 19:08:35 -0700 | [diff] [blame] | 7126 | } |
| 7127 | |
| 7128 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_CLEAR_HE_OM_CTRL_CONFIG]) |
| 7129 | sme_reset_he_om_ctrl(hdd_ctx->mac_handle); |
| 7130 | |
Kiran Kumar Lokere | efdbd0b | 2018-09-25 18:53:46 -0700 | [diff] [blame] | 7131 | cmd_id = QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_TX_SUPPDU; |
| 7132 | if (tb[cmd_id]) { |
| 7133 | cfg_val = nla_get_u8(tb[cmd_id]); |
| 7134 | hdd_debug("Configure Tx SU PPDU enable %d", cfg_val); |
| 7135 | if (cfg_val) |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7136 | sme_config_su_ppdu_queue(adapter->vdev_id, true); |
Kiran Kumar Lokere | efdbd0b | 2018-09-25 18:53:46 -0700 | [diff] [blame] | 7137 | else |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7138 | sme_config_su_ppdu_queue(adapter->vdev_id, false); |
Kiran Kumar Lokere | efdbd0b | 2018-09-25 18:53:46 -0700 | [diff] [blame] | 7139 | } |
| 7140 | |
Kiran Kumar Lokere | a1c29ec | 2019-02-25 18:19:00 -0800 | [diff] [blame] | 7141 | cmd_id = QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ENABLE_2G_VHT; |
| 7142 | if (tb[cmd_id]) { |
| 7143 | cfg_val = nla_get_u8(tb[cmd_id]); |
| 7144 | hdd_debug("Configure 2G VHT support %d", cfg_val); |
| 7145 | ucfg_mlme_set_vht_for_24ghz(hdd_ctx->psoc, |
| 7146 | (cfg_val ? true : false)); |
| 7147 | } |
| 7148 | |
Kiran Kumar Lokere | acd107d | 2019-01-09 15:02:11 -0800 | [diff] [blame] | 7149 | cmd_id = QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_HTC_HE_SUPP; |
| 7150 | if (tb[cmd_id]) { |
| 7151 | cfg_val = nla_get_u8(tb[cmd_id]); |
| 7152 | hdd_debug("Configure +HTC_HE support %d", cfg_val); |
| 7153 | sme_update_he_htc_he_supp(hdd_ctx->mac_handle, |
| 7154 | adapter->vdev_id, |
| 7155 | (cfg_val ? true : false)); |
| 7156 | } |
| 7157 | |
Kiran Kumar Lokere | 921b5a5 | 2019-02-24 21:53:20 -0800 | [diff] [blame] | 7158 | cmd_id = QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_SET_HE_TESTBED_DEFAULTS; |
| 7159 | if (tb[cmd_id]) { |
| 7160 | cfg_val = nla_get_u8(tb[cmd_id]); |
| 7161 | hdd_debug("Configure HE testbed defaults %d", cfg_val); |
| 7162 | if (!cfg_val) |
| 7163 | sme_reset_he_caps(hdd_ctx->mac_handle, |
| 7164 | adapter->vdev_id); |
| 7165 | else |
| 7166 | sme_set_he_testbed_def(hdd_ctx->mac_handle, |
| 7167 | adapter->vdev_id); |
| 7168 | } |
| 7169 | |
Kiran Kumar Lokere | ee20577 | 2018-09-27 00:27:27 -0700 | [diff] [blame] | 7170 | cmd_id = QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_ACTION_TX_TB_PPDU; |
| 7171 | if (tb[cmd_id]) { |
| 7172 | cfg_val = nla_get_u8(tb[cmd_id]); |
| 7173 | hdd_debug("Configure Action frame Tx in TB PPDU %d", cfg_val); |
| 7174 | sme_config_action_tx_in_tb_ppdu(hdd_ctx->mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 7175 | adapter->vdev_id, cfg_val); |
Kiran Kumar Lokere | ee20577 | 2018-09-27 00:27:27 -0700 | [diff] [blame] | 7176 | } |
| 7177 | |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 7178 | if (update_sme_cfg) |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 7179 | sme_update_config(mac_handle, sme_config); |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 7180 | |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 7181 | send_err: |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 7182 | qdf_mem_free(sme_config); |
| 7183 | |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7184 | return ret_val; |
| 7185 | } |
| 7186 | |
| 7187 | /** |
| 7188 | * wlan_hdd_cfg80211_set_wifi_test_config() - Wifi test configuration |
| 7189 | * vendor command |
| 7190 | * |
| 7191 | * @wiphy: wiphy device pointer |
| 7192 | * @wdev: wireless device pointer |
| 7193 | * @data: Vendor command data buffer |
| 7194 | * @data_len: Buffer length |
| 7195 | * |
| 7196 | * Handles QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_MAX |
| 7197 | * |
| 7198 | * Return: EOK or other error codes. |
| 7199 | */ |
| 7200 | static int wlan_hdd_cfg80211_set_wifi_test_config(struct wiphy *wiphy, |
| 7201 | struct wireless_dev *wdev, const void *data, int data_len) |
| 7202 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 7203 | int errno; |
| 7204 | struct osif_vdev_sync *vdev_sync; |
| 7205 | |
| 7206 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 7207 | if (errno) |
| 7208 | return errno; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7209 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 7210 | errno = __wlan_hdd_cfg80211_set_wifi_test_config(wiphy, wdev, |
| 7211 | data, data_len); |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7212 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 7213 | osif_vdev_sync_op_stop(vdev_sync); |
| 7214 | |
| 7215 | return errno; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7216 | } |
| 7217 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7218 | static const struct |
| 7219 | nla_policy |
| 7220 | qca_wlan_vendor_wifi_logger_start_policy |
| 7221 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = { |
| 7222 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID] |
| 7223 | = {.type = NLA_U32 }, |
| 7224 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL] |
| 7225 | = {.type = NLA_U32 }, |
| 7226 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS] |
| 7227 | = {.type = NLA_U32 }, |
| 7228 | }; |
| 7229 | |
| 7230 | /** |
| 7231 | * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable |
| 7232 | * or disable the collection of packet statistics from the firmware |
| 7233 | * @wiphy: WIPHY structure pointer |
| 7234 | * @wdev: Wireless device structure pointer |
| 7235 | * @data: Pointer to the data received |
| 7236 | * @data_len: Length of the data received |
| 7237 | * |
| 7238 | * This function enables or disables the collection of packet statistics from |
| 7239 | * the firmware |
| 7240 | * |
| 7241 | * Return: 0 on success and errno on failure |
| 7242 | */ |
| 7243 | static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy, |
| 7244 | struct wireless_dev *wdev, |
| 7245 | const void *data, |
| 7246 | int data_len) |
| 7247 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7248 | QDF_STATUS status; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 7249 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7250 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1]; |
Hanumanth Reddy Pothula | e9af116 | 2018-06-13 13:41:44 +0530 | [diff] [blame] | 7251 | struct sir_wifi_start_log start_log = { 0 }; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 7252 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7253 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 7254 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 7255 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7256 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7257 | hdd_err("Command not allowed in FTM mode"); |
| 7258 | return -EPERM; |
| 7259 | } |
| 7260 | |
| 7261 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7262 | if (status) |
| 7263 | return status; |
| 7264 | |
Ashish Kumar Dhanotiya | 3c30842 | 2017-03-02 16:48:56 +0530 | [diff] [blame] | 7265 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 7266 | hdd_err("Driver Modules are closed, can not start logger"); |
| 7267 | return -EINVAL; |
| 7268 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7269 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 7270 | if (wlan_cfg80211_nla_parse(tb, |
| 7271 | QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX, |
| 7272 | data, data_len, |
| 7273 | qca_wlan_vendor_wifi_logger_start_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7274 | hdd_err("Invalid attribute"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7275 | return -EINVAL; |
| 7276 | } |
| 7277 | |
| 7278 | /* Parse and fetch ring id */ |
| 7279 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7280 | hdd_err("attr ATTR failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7281 | return -EINVAL; |
| 7282 | } |
| 7283 | start_log.ring_id = nla_get_u32( |
| 7284 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7285 | hdd_debug("Ring ID=%d", start_log.ring_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7286 | |
| 7287 | /* Parse and fetch verbose level */ |
| 7288 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7289 | hdd_err("attr verbose_level failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7290 | return -EINVAL; |
| 7291 | } |
| 7292 | start_log.verbose_level = nla_get_u32( |
| 7293 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7294 | hdd_debug("verbose_level=%d", start_log.verbose_level); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7295 | |
| 7296 | /* Parse and fetch flag */ |
| 7297 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7298 | hdd_err("attr flag failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7299 | return -EINVAL; |
| 7300 | } |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 7301 | start_log.is_iwpriv_command = nla_get_u32( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7302 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7303 | |
Hanumanth Reddy Pothula | e9af116 | 2018-06-13 13:41:44 +0530 | [diff] [blame] | 7304 | start_log.user_triggered = 1; |
| 7305 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7306 | /* size is buff size which can be set using iwpriv command*/ |
| 7307 | start_log.size = 0; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 7308 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7309 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7310 | cds_set_ring_log_level(start_log.ring_id, start_log.verbose_level); |
| 7311 | |
| 7312 | if (start_log.ring_id == RING_ID_WAKELOCK) { |
| 7313 | /* Start/stop wakelock events */ |
| 7314 | if (start_log.verbose_level > WLAN_LOG_LEVEL_OFF) |
| 7315 | cds_set_wakelock_logging(true); |
| 7316 | else |
| 7317 | cds_set_wakelock_logging(false); |
| 7318 | return 0; |
| 7319 | } |
| 7320 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 7321 | mac_handle = hdd_ctx->mac_handle; |
| 7322 | status = sme_wifi_start_logger(mac_handle, start_log); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7323 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7324 | hdd_err("sme_wifi_start_logger failed(err=%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7325 | status); |
| 7326 | return -EINVAL; |
| 7327 | } |
| 7328 | return 0; |
| 7329 | } |
| 7330 | |
| 7331 | /** |
| 7332 | * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable |
| 7333 | * or disable the collection of packet statistics from the firmware |
| 7334 | * @wiphy: WIPHY structure pointer |
| 7335 | * @wdev: Wireless device structure pointer |
| 7336 | * @data: Pointer to the data received |
| 7337 | * @data_len: Length of the data received |
| 7338 | * |
| 7339 | * This function is used to enable or disable the collection of packet |
| 7340 | * statistics from the firmware |
| 7341 | * |
| 7342 | * Return: 0 on success and errno on failure |
| 7343 | */ |
| 7344 | static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy, |
| 7345 | struct wireless_dev *wdev, |
| 7346 | const void *data, |
| 7347 | int data_len) |
| 7348 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 7349 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 7350 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 7351 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 7352 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 7353 | if (errno) |
| 7354 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7355 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 7356 | errno = __wlan_hdd_cfg80211_wifi_logger_start(wiphy, wdev, |
| 7357 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7358 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 7359 | osif_psoc_sync_op_stop(psoc_sync); |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 7360 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 7361 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7362 | } |
| 7363 | |
| 7364 | static const struct |
| 7365 | nla_policy |
| 7366 | qca_wlan_vendor_wifi_logger_get_ring_data_policy |
| 7367 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = { |
| 7368 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID] |
| 7369 | = {.type = NLA_U32 }, |
| 7370 | }; |
| 7371 | |
| 7372 | /** |
| 7373 | * __wlan_hdd_cfg80211_wifi_logger_get_ring_data() - Flush per packet stats |
| 7374 | * @wiphy: WIPHY structure pointer |
| 7375 | * @wdev: Wireless device structure pointer |
| 7376 | * @data: Pointer to the data received |
| 7377 | * @data_len: Length of the data received |
| 7378 | * |
| 7379 | * This function is used to flush or retrieve the per packet statistics from |
| 7380 | * the driver |
| 7381 | * |
| 7382 | * Return: 0 on success and errno on failure |
| 7383 | */ |
| 7384 | static int __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy, |
| 7385 | struct wireless_dev *wdev, |
| 7386 | const void *data, |
| 7387 | int data_len) |
| 7388 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7389 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7390 | uint32_t ring_id; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 7391 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7392 | struct nlattr *tb |
| 7393 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1]; |
| 7394 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 7395 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 7396 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7397 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7398 | hdd_err("Command not allowed in FTM mode"); |
| 7399 | return -EPERM; |
| 7400 | } |
| 7401 | |
| 7402 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7403 | if (status) |
| 7404 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7405 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 7406 | if (wlan_cfg80211_nla_parse(tb, |
| 7407 | QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX, |
| 7408 | data, data_len, |
| 7409 | qca_wlan_vendor_wifi_logger_get_ring_data_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7410 | hdd_err("Invalid attribute"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7411 | return -EINVAL; |
| 7412 | } |
| 7413 | |
| 7414 | /* Parse and fetch ring id */ |
| 7415 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7416 | hdd_err("attr ATTR failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7417 | return -EINVAL; |
| 7418 | } |
| 7419 | |
| 7420 | ring_id = nla_get_u32( |
| 7421 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]); |
| 7422 | |
| 7423 | if (ring_id == RING_ID_PER_PACKET_STATS) { |
| 7424 | wlan_logging_set_per_pkt_stats(); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7425 | hdd_debug("Flushing/Retrieving packet stats"); |
Sreelakshmi Konamki | c3815ba | 2016-08-18 12:01:57 +0530 | [diff] [blame] | 7426 | } else if (ring_id == RING_ID_DRIVER_DEBUG) { |
| 7427 | /* |
| 7428 | * As part of DRIVER ring ID, flush both driver and fw logs. |
| 7429 | * For other Ring ID's driver doesn't have any rings to flush |
| 7430 | */ |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 7431 | hdd_info("Bug report triggered by framework"); |
Sreelakshmi Konamki | c3815ba | 2016-08-18 12:01:57 +0530 | [diff] [blame] | 7432 | |
| 7433 | status = cds_flush_logs(WLAN_LOG_TYPE_NON_FATAL, |
| 7434 | WLAN_LOG_INDICATOR_FRAMEWORK, |
| 7435 | WLAN_LOG_REASON_CODE_UNUSED, |
| 7436 | true, false); |
| 7437 | if (QDF_STATUS_SUCCESS != status) { |
| 7438 | hdd_err("Failed to trigger bug report"); |
| 7439 | return -EINVAL; |
| 7440 | } |
| 7441 | } else { |
| 7442 | wlan_report_log_completion(WLAN_LOG_TYPE_NON_FATAL, |
| 7443 | WLAN_LOG_INDICATOR_FRAMEWORK, |
Agrawal Ashish | aff2898 | 2017-05-30 15:25:47 +0530 | [diff] [blame] | 7444 | WLAN_LOG_REASON_CODE_UNUSED, |
| 7445 | ring_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7446 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7447 | return 0; |
| 7448 | } |
| 7449 | |
| 7450 | /** |
| 7451 | * wlan_hdd_cfg80211_wifi_logger_get_ring_data() - Wrapper to flush packet stats |
| 7452 | * @wiphy: WIPHY structure pointer |
| 7453 | * @wdev: Wireless device structure pointer |
| 7454 | * @data: Pointer to the data received |
| 7455 | * @data_len: Length of the data received |
| 7456 | * |
| 7457 | * This function is used to flush or retrieve the per packet statistics from |
| 7458 | * the driver |
| 7459 | * |
| 7460 | * Return: 0 on success and errno on failure |
| 7461 | */ |
| 7462 | static int wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy, |
| 7463 | struct wireless_dev *wdev, |
| 7464 | const void *data, |
| 7465 | int data_len) |
| 7466 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 7467 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 7468 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 7469 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 7470 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 7471 | if (errno) |
| 7472 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7473 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 7474 | errno = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy, wdev, |
| 7475 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7476 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 7477 | osif_psoc_sync_op_stop(psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 7478 | |
| 7479 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7480 | } |
| 7481 | |
| 7482 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7483 | /** |
| 7484 | * hdd_map_req_id_to_pattern_id() - map request id to pattern id |
| 7485 | * @hdd_ctx: HDD context |
| 7486 | * @request_id: [input] request id |
| 7487 | * @pattern_id: [output] pattern id |
| 7488 | * |
| 7489 | * This function loops through request id to pattern id array |
| 7490 | * if the slot is available, store the request id and return pattern id |
| 7491 | * if entry exists, return the pattern id |
| 7492 | * |
| 7493 | * Return: 0 on success and errno on failure |
| 7494 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 7495 | static int hdd_map_req_id_to_pattern_id(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7496 | uint32_t request_id, |
| 7497 | uint8_t *pattern_id) |
| 7498 | { |
| 7499 | uint32_t i; |
| 7500 | |
| 7501 | mutex_lock(&hdd_ctx->op_ctx.op_lock); |
| 7502 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7503 | if (hdd_ctx->op_ctx.op_table[i].request_id == MAX_REQUEST_ID) { |
| 7504 | hdd_ctx->op_ctx.op_table[i].request_id = request_id; |
| 7505 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 7506 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 7507 | return 0; |
| 7508 | } else if (hdd_ctx->op_ctx.op_table[i].request_id == |
| 7509 | request_id) { |
| 7510 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 7511 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 7512 | return 0; |
| 7513 | } |
| 7514 | } |
| 7515 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 7516 | return -EINVAL; |
| 7517 | } |
| 7518 | |
| 7519 | /** |
| 7520 | * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id |
| 7521 | * @hdd_ctx: HDD context |
| 7522 | * @request_id: [input] request id |
| 7523 | * @pattern_id: [output] pattern id |
| 7524 | * |
| 7525 | * This function loops through request id to pattern id array |
| 7526 | * reset request id to 0 (slot available again) and |
| 7527 | * return pattern id |
| 7528 | * |
| 7529 | * Return: 0 on success and errno on failure |
| 7530 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 7531 | static int hdd_unmap_req_id_to_pattern_id(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7532 | uint32_t request_id, |
| 7533 | uint8_t *pattern_id) |
| 7534 | { |
| 7535 | uint32_t i; |
| 7536 | |
| 7537 | mutex_lock(&hdd_ctx->op_ctx.op_lock); |
| 7538 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7539 | if (hdd_ctx->op_ctx.op_table[i].request_id == request_id) { |
| 7540 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7541 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 7542 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 7543 | return 0; |
| 7544 | } |
| 7545 | } |
| 7546 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 7547 | return -EINVAL; |
| 7548 | } |
| 7549 | |
| 7550 | |
| 7551 | /* |
| 7552 | * define short names for the global vendor params |
| 7553 | * used by __wlan_hdd_cfg80211_offloaded_packets() |
| 7554 | */ |
| 7555 | #define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX |
| 7556 | #define PARAM_REQUEST_ID \ |
| 7557 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID |
| 7558 | #define PARAM_CONTROL \ |
| 7559 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL |
| 7560 | #define PARAM_IP_PACKET \ |
| 7561 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA |
| 7562 | #define PARAM_SRC_MAC_ADDR \ |
| 7563 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR |
| 7564 | #define PARAM_DST_MAC_ADDR \ |
| 7565 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR |
| 7566 | #define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD |
Arun Kumar Khandavalli | f1f6592 | 2019-02-27 16:00:24 +0530 | [diff] [blame] | 7567 | #define PARAM_PROTO_TYPE \ |
| 7568 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_ETHER_PROTO_TYPE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7569 | |
| 7570 | /** |
| 7571 | * wlan_hdd_add_tx_ptrn() - add tx pattern |
| 7572 | * @adapter: adapter pointer |
| 7573 | * @hdd_ctx: hdd context |
| 7574 | * @tb: nl attributes |
| 7575 | * |
| 7576 | * This function reads the NL attributes and forms a AddTxPtrn message |
| 7577 | * posts it to SME. |
| 7578 | * |
| 7579 | */ |
| 7580 | static int |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 7581 | wlan_hdd_add_tx_ptrn(struct hdd_adapter *adapter, struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7582 | struct nlattr **tb) |
| 7583 | { |
| 7584 | struct sSirAddPeriodicTxPtrn *add_req; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7585 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7586 | uint32_t request_id, ret, len; |
| 7587 | uint8_t pattern_id = 0; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7588 | struct qdf_mac_addr dst_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7589 | uint16_t eth_type = htons(ETH_P_IP); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 7590 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7591 | |
| 7592 | if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7593 | hdd_err("Not in Connected state!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7594 | return -ENOTSUPP; |
| 7595 | } |
| 7596 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7597 | add_req = qdf_mem_malloc(sizeof(*add_req)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 7598 | if (!add_req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7599 | return -ENOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7600 | |
| 7601 | /* Parse and fetch request Id */ |
| 7602 | if (!tb[PARAM_REQUEST_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7603 | hdd_err("attr request id failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7604 | goto fail; |
| 7605 | } |
| 7606 | |
| 7607 | request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); |
| 7608 | if (request_id == MAX_REQUEST_ID) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7609 | hdd_err("request_id cannot be MAX"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 7610 | goto fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7611 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7612 | hdd_debug("Request Id: %u", request_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7613 | |
| 7614 | if (!tb[PARAM_PERIOD]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7615 | hdd_err("attr period failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7616 | goto fail; |
| 7617 | } |
Arun Kumar Khandavalli | f1f6592 | 2019-02-27 16:00:24 +0530 | [diff] [blame] | 7618 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7619 | add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7620 | hdd_debug("Period: %u ms", add_req->usPtrnIntervalMs); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7621 | if (add_req->usPtrnIntervalMs == 0) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7622 | hdd_err("Invalid interval zero, return failure"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7623 | goto fail; |
| 7624 | } |
| 7625 | |
| 7626 | if (!tb[PARAM_SRC_MAC_ADDR]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7627 | hdd_err("attr source mac address failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7628 | goto fail; |
| 7629 | } |
Srinivas Girigowda | 3189655 | 2015-11-18 22:59:52 -0800 | [diff] [blame] | 7630 | nla_memcpy(add_req->mac_address.bytes, tb[PARAM_SRC_MAC_ADDR], |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7631 | QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7632 | hdd_debug("input src mac address: "MAC_ADDRESS_STR, |
Srinivas Girigowda | 3189655 | 2015-11-18 22:59:52 -0800 | [diff] [blame] | 7633 | MAC_ADDR_ARRAY(add_req->mac_address.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7634 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 7635 | if (!qdf_is_macaddr_equal(&add_req->mac_address, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 7636 | &adapter->mac_addr)) { |
Srinivas Girigowda | 3189655 | 2015-11-18 22:59:52 -0800 | [diff] [blame] | 7637 | hdd_err("input src mac address and connected ap bssid are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7638 | goto fail; |
| 7639 | } |
| 7640 | |
| 7641 | if (!tb[PARAM_DST_MAC_ADDR]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7642 | hdd_err("attr dst mac address failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7643 | goto fail; |
| 7644 | } |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7645 | nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7646 | hdd_debug("input dst mac address: "MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7647 | MAC_ADDR_ARRAY(dst_addr.bytes)); |
| 7648 | |
| 7649 | if (!tb[PARAM_IP_PACKET]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7650 | hdd_err("attr ip packet failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7651 | goto fail; |
| 7652 | } |
| 7653 | add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7654 | hdd_debug("IP packet len: %u", add_req->ucPtrnSize); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7655 | |
| 7656 | if (add_req->ucPtrnSize < 0 || |
| 7657 | add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE - |
| 7658 | ETH_HLEN)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7659 | hdd_err("Invalid IP packet len: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7660 | add_req->ucPtrnSize); |
| 7661 | goto fail; |
| 7662 | } |
| 7663 | |
Arun Kumar Khandavalli | f1f6592 | 2019-02-27 16:00:24 +0530 | [diff] [blame] | 7664 | if (!tb[PARAM_PROTO_TYPE]) |
| 7665 | eth_type = htons(ETH_P_IP); |
| 7666 | else |
| 7667 | eth_type = htons(nla_get_u16(tb[PARAM_PROTO_TYPE])); |
| 7668 | |
| 7669 | hdd_debug("packet proto type: %u", eth_type); |
| 7670 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7671 | len = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7672 | qdf_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, QDF_MAC_ADDR_SIZE); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7673 | len += QDF_MAC_ADDR_SIZE; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7674 | qdf_mem_copy(&add_req->ucPattern[len], add_req->mac_address.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7675 | QDF_MAC_ADDR_SIZE); |
| 7676 | len += QDF_MAC_ADDR_SIZE; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7677 | qdf_mem_copy(&add_req->ucPattern[len], ð_type, 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7678 | len += 2; |
| 7679 | |
| 7680 | /* |
| 7681 | * This is the IP packet, add 14 bytes Ethernet (802.3) header |
| 7682 | * ------------------------------------------------------------ |
| 7683 | * | 14 bytes Ethernet (802.3) header | IP header and payload | |
| 7684 | * ------------------------------------------------------------ |
| 7685 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7686 | qdf_mem_copy(&add_req->ucPattern[len], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7687 | nla_data(tb[PARAM_IP_PACKET]), |
| 7688 | add_req->ucPtrnSize); |
| 7689 | add_req->ucPtrnSize += len; |
| 7690 | |
| 7691 | ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id); |
| 7692 | if (ret) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7693 | hdd_err("req id to pattern id failed (ret=%d)", ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7694 | goto fail; |
| 7695 | } |
| 7696 | add_req->ucPtrnId = pattern_id; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7697 | hdd_debug("pattern id: %d", add_req->ucPtrnId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7698 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 7699 | mac_handle = hdd_ctx->mac_handle; |
| 7700 | status = sme_add_periodic_tx_ptrn(mac_handle, add_req); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7701 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7702 | hdd_err("sme_add_periodic_tx_ptrn failed (err=%d)", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7703 | goto fail; |
| 7704 | } |
| 7705 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7706 | hdd_exit(); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7707 | qdf_mem_free(add_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7708 | return 0; |
| 7709 | |
| 7710 | fail: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7711 | qdf_mem_free(add_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7712 | return -EINVAL; |
| 7713 | } |
| 7714 | |
| 7715 | /** |
| 7716 | * wlan_hdd_del_tx_ptrn() - delete tx pattern |
| 7717 | * @adapter: adapter pointer |
| 7718 | * @hdd_ctx: hdd context |
| 7719 | * @tb: nl attributes |
| 7720 | * |
| 7721 | * This function reads the NL attributes and forms a DelTxPtrn message |
| 7722 | * posts it to SME. |
| 7723 | * |
| 7724 | */ |
| 7725 | static int |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 7726 | wlan_hdd_del_tx_ptrn(struct hdd_adapter *adapter, struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7727 | struct nlattr **tb) |
| 7728 | { |
| 7729 | struct sSirDelPeriodicTxPtrn *del_req; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7730 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7731 | uint32_t request_id, ret; |
| 7732 | uint8_t pattern_id = 0; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 7733 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7734 | |
| 7735 | /* Parse and fetch request Id */ |
| 7736 | if (!tb[PARAM_REQUEST_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7737 | hdd_err("attr request id failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7738 | return -EINVAL; |
| 7739 | } |
| 7740 | request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); |
| 7741 | if (request_id == MAX_REQUEST_ID) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7742 | hdd_err("request_id cannot be MAX"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7743 | return -EINVAL; |
| 7744 | } |
| 7745 | |
| 7746 | ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id); |
| 7747 | if (ret) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7748 | hdd_err("req id to pattern id failed (ret=%d)", ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7749 | return -EINVAL; |
| 7750 | } |
| 7751 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7752 | del_req = qdf_mem_malloc(sizeof(*del_req)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 7753 | if (!del_req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7754 | return -ENOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7755 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 7756 | qdf_copy_macaddr(&del_req->mac_address, &adapter->mac_addr); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7757 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->mac_address.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7758 | del_req->ucPtrnId = pattern_id; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7759 | hdd_debug("Request Id: %u Pattern id: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7760 | request_id, del_req->ucPtrnId); |
| 7761 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 7762 | mac_handle = hdd_ctx->mac_handle; |
| 7763 | status = sme_del_periodic_tx_ptrn(mac_handle, del_req); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7764 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7765 | hdd_err("sme_del_periodic_tx_ptrn failed (err=%d)", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7766 | goto fail; |
| 7767 | } |
| 7768 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7769 | hdd_exit(); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7770 | qdf_mem_free(del_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7771 | return 0; |
| 7772 | |
| 7773 | fail: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7774 | qdf_mem_free(del_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7775 | return -EINVAL; |
| 7776 | } |
| 7777 | |
| 7778 | |
| 7779 | /** |
| 7780 | * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets |
| 7781 | * @wiphy: Pointer to wireless phy |
| 7782 | * @wdev: Pointer to wireless device |
| 7783 | * @data: Pointer to data |
| 7784 | * @data_len: Data length |
| 7785 | * |
| 7786 | * Return: 0 on success, negative errno on failure |
| 7787 | */ |
| 7788 | static int |
| 7789 | __wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy, |
| 7790 | struct wireless_dev *wdev, |
| 7791 | const void *data, |
| 7792 | int data_len) |
| 7793 | { |
| 7794 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 7795 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 7796 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7797 | struct nlattr *tb[PARAM_MAX + 1]; |
| 7798 | uint8_t control; |
| 7799 | int ret; |
| 7800 | static const struct nla_policy policy[PARAM_MAX + 1] = { |
| 7801 | [PARAM_REQUEST_ID] = { .type = NLA_U32 }, |
| 7802 | [PARAM_CONTROL] = { .type = NLA_U32 }, |
| 7803 | [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7804 | .len = QDF_MAC_ADDR_SIZE }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7805 | [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7806 | .len = QDF_MAC_ADDR_SIZE }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7807 | [PARAM_PERIOD] = { .type = NLA_U32 }, |
Arun Kumar Khandavalli | f1f6592 | 2019-02-27 16:00:24 +0530 | [diff] [blame] | 7808 | [PARAM_PROTO_TYPE] = {.type = NLA_U16}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7809 | }; |
| 7810 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 7811 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7812 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7813 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7814 | hdd_err("Command not allowed in FTM mode"); |
| 7815 | return -EPERM; |
| 7816 | } |
| 7817 | |
| 7818 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7819 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7820 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7821 | |
| 7822 | if (!sme_is_feature_supported_by_fw(WLAN_PERIODIC_TX_PTRN)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7823 | hdd_err("Periodic Tx Pattern Offload feature is not supported in FW!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7824 | return -ENOTSUPP; |
| 7825 | } |
| 7826 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 7827 | if (wlan_cfg80211_nla_parse(tb, PARAM_MAX, data, data_len, policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7828 | hdd_err("Invalid ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7829 | return -EINVAL; |
| 7830 | } |
| 7831 | |
| 7832 | if (!tb[PARAM_CONTROL]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7833 | hdd_err("attr control failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7834 | return -EINVAL; |
| 7835 | } |
| 7836 | control = nla_get_u32(tb[PARAM_CONTROL]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7837 | hdd_debug("Control: %d", control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7838 | |
| 7839 | if (control == WLAN_START_OFFLOADED_PACKETS) |
| 7840 | return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb); |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 7841 | if (control == WLAN_STOP_OFFLOADED_PACKETS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7842 | return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb); |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 7843 | |
| 7844 | hdd_err("Invalid control: %d", control); |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 7845 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7846 | } |
| 7847 | |
| 7848 | /* |
| 7849 | * done with short names for the global vendor params |
| 7850 | * used by __wlan_hdd_cfg80211_offloaded_packets() |
| 7851 | */ |
| 7852 | #undef PARAM_MAX |
| 7853 | #undef PARAM_REQUEST_ID |
| 7854 | #undef PARAM_CONTROL |
| 7855 | #undef PARAM_IP_PACKET |
| 7856 | #undef PARAM_SRC_MAC_ADDR |
| 7857 | #undef PARAM_DST_MAC_ADDR |
| 7858 | #undef PARAM_PERIOD |
Arun Kumar Khandavalli | f1f6592 | 2019-02-27 16:00:24 +0530 | [diff] [blame] | 7859 | #undef PARAM_PROTO_TYPE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7860 | |
| 7861 | /** |
| 7862 | * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets |
| 7863 | * @wiphy: wiphy structure pointer |
| 7864 | * @wdev: Wireless device structure pointer |
| 7865 | * @data: Pointer to the data received |
| 7866 | * @data_len: Length of @data |
| 7867 | * |
| 7868 | * Return: 0 on success; errno on failure |
| 7869 | */ |
| 7870 | static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy, |
| 7871 | struct wireless_dev *wdev, |
| 7872 | const void *data, |
| 7873 | int data_len) |
| 7874 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 7875 | int errno; |
| 7876 | struct osif_vdev_sync *vdev_sync; |
| 7877 | |
| 7878 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 7879 | if (errno) |
| 7880 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7881 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 7882 | errno = __wlan_hdd_cfg80211_offloaded_packets(wiphy, wdev, |
| 7883 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7884 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 7885 | osif_vdev_sync_op_stop(vdev_sync); |
| 7886 | |
| 7887 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7888 | } |
| 7889 | #endif |
| 7890 | |
Qiwei Cai | 1083f5b | 2018-07-02 19:10:11 +0800 | [diff] [blame] | 7891 | #ifdef WLAN_NS_OFFLOAD |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7892 | static const struct nla_policy |
| 7893 | ns_offload_set_policy[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_MAX + 1] = { |
| 7894 | [QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_FLAG] = {.type = NLA_U8}, |
| 7895 | }; |
| 7896 | |
| 7897 | /** |
| 7898 | * __wlan_hdd_cfg80211_set_ns_offload() - enable/disable NS offload |
| 7899 | * @wiphy: Pointer to wireless phy |
| 7900 | * @wdev: Pointer to wireless device |
| 7901 | * @data: Pointer to data |
| 7902 | * @data_len: Length of @data |
| 7903 | * |
| 7904 | * Return: 0 on success, negative errno on failure |
| 7905 | */ |
| 7906 | static int |
| 7907 | __wlan_hdd_cfg80211_set_ns_offload(struct wiphy *wiphy, |
| 7908 | struct wireless_dev *wdev, |
| 7909 | const void *data, int data_len) |
| 7910 | { |
| 7911 | int status; |
| 7912 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_MAX + 1]; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 7913 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Dustin Brown | d8279d2 | 2016-09-07 14:52:57 -0700 | [diff] [blame] | 7914 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 7915 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7916 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 7917 | hdd_enter_dev(wdev->netdev); |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7918 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 7919 | status = wlan_hdd_validate_context(hdd_ctx); |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7920 | if (0 != status) |
| 7921 | return status; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 7922 | |
| 7923 | if (!ucfg_pmo_is_ns_offloaded(hdd_ctx->psoc)) { |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7924 | hdd_err("ND Offload not supported"); |
| 7925 | return -EINVAL; |
| 7926 | } |
| 7927 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 7928 | if (!ucfg_pmo_is_active_mode_offloaded(hdd_ctx->psoc)) { |
Mukul Sharma | 495df60 | 2017-09-25 14:52:18 +0530 | [diff] [blame] | 7929 | hdd_warn("Active mode offload is disabled"); |
| 7930 | return -EINVAL; |
| 7931 | } |
| 7932 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 7933 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_MAX, |
| 7934 | (struct nlattr *)data, data_len, |
| 7935 | ns_offload_set_policy)) { |
| 7936 | hdd_err("nla_parse failed"); |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7937 | return -EINVAL; |
| 7938 | } |
| 7939 | |
| 7940 | if (!tb[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_FLAG]) { |
| 7941 | hdd_err("ND Offload flag attribute not present"); |
| 7942 | return -EINVAL; |
| 7943 | } |
| 7944 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 7945 | hdd_ctx->ns_offload_enable = |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7946 | nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_FLAG]); |
| 7947 | |
Nachiket Kukade | dbffab8 | 2017-04-25 19:26:02 +0530 | [diff] [blame] | 7948 | if (QDF_IBSS_MODE == adapter->device_mode) { |
| 7949 | hdd_debug("NS Offload is not supported in IBSS mode"); |
| 7950 | return -EINVAL; |
| 7951 | } |
| 7952 | |
Dustin Brown | d8279d2 | 2016-09-07 14:52:57 -0700 | [diff] [blame] | 7953 | /* update ns offload in case it is already enabled/disabled */ |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 7954 | if (hdd_ctx->ns_offload_enable) |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 7955 | hdd_enable_ns_offload(adapter, pmo_ns_offload_dynamic_update); |
| 7956 | else |
| 7957 | hdd_disable_ns_offload(adapter, pmo_ns_offload_dynamic_update); |
Dustin Brown | d8279d2 | 2016-09-07 14:52:57 -0700 | [diff] [blame] | 7958 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7959 | return 0; |
| 7960 | } |
| 7961 | |
| 7962 | /** |
| 7963 | * wlan_hdd_cfg80211_set_ns_offload() - enable/disable NS offload |
| 7964 | * @wiphy: pointer to wireless wiphy structure. |
| 7965 | * @wdev: pointer to wireless_dev structure. |
| 7966 | * @data: Pointer to the data to be passed via vendor interface |
| 7967 | * @data_len:Length of the data to be passed |
| 7968 | * |
| 7969 | * Return: Return the Success or Failure code. |
| 7970 | */ |
| 7971 | static int wlan_hdd_cfg80211_set_ns_offload(struct wiphy *wiphy, |
| 7972 | struct wireless_dev *wdev, |
| 7973 | const void *data, int data_len) |
| 7974 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 7975 | int errno; |
| 7976 | struct osif_vdev_sync *vdev_sync; |
| 7977 | |
| 7978 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 7979 | if (errno) |
| 7980 | return errno; |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7981 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 7982 | errno = __wlan_hdd_cfg80211_set_ns_offload(wiphy, wdev, data, data_len); |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7983 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 7984 | osif_vdev_sync_op_stop(vdev_sync); |
| 7985 | |
| 7986 | return errno; |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7987 | } |
Qiwei Cai | 1083f5b | 2018-07-02 19:10:11 +0800 | [diff] [blame] | 7988 | #endif /* WLAN_NS_OFFLOAD */ |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7989 | |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 7990 | /** |
| 7991 | * struct weighed_pcl: Preferred channel info |
| 7992 | * @freq: Channel frequency |
| 7993 | * @weight: Weightage of the channel |
| 7994 | * @flag: Validity of the channel in p2p negotiation |
| 7995 | */ |
| 7996 | struct weighed_pcl { |
| 7997 | u32 freq; |
| 7998 | u32 weight; |
| 7999 | u32 flag; |
| 8000 | }; |
| 8001 | |
Jeff Johnson | dd7bd3e | 2017-06-05 13:25:24 -0700 | [diff] [blame] | 8002 | static const struct nla_policy get_preferred_freq_list_policy |
| 8003 | [QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_MAX + 1] = { |
| 8004 | [QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_IFACE_TYPE] = { |
| 8005 | .type = NLA_U32}, |
| 8006 | }; |
| 8007 | |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8008 | static uint32_t wlan_hdd_populate_weigh_pcl( |
| 8009 | struct policy_mgr_pcl_chan_weights * |
| 8010 | chan_weights, |
| 8011 | struct weighed_pcl *w_pcl, |
| 8012 | enum policy_mgr_con_mode intf_mode) |
| 8013 | { |
| 8014 | int i, j; |
| 8015 | uint32_t chan_idx = 0; |
| 8016 | uint32_t set = 0; |
| 8017 | uint32_t pcl_len = chan_weights->pcl_len; |
| 8018 | uint32_t valid_weight; |
| 8019 | |
| 8020 | /* convert channel number to frequency */ |
| 8021 | for (i = 0; i < chan_weights->pcl_len; i++) { |
| 8022 | if (chan_weights->pcl_list[i] <= |
| 8023 | ARRAY_SIZE(hdd_channels_2_4_ghz)) |
| 8024 | w_pcl[i].freq = ieee80211_channel_to_frequency( |
| 8025 | chan_weights->pcl_list[i], |
| 8026 | HDD_NL80211_BAND_2GHZ); |
| 8027 | else |
| 8028 | w_pcl[i].freq = ieee80211_channel_to_frequency( |
| 8029 | chan_weights->pcl_list[i], |
| 8030 | HDD_NL80211_BAND_5GHZ); |
| 8031 | w_pcl[i].weight = chan_weights->weight_list[i]; |
| 8032 | |
| 8033 | if (intf_mode == PM_SAP_MODE || intf_mode == PM_P2P_GO_MODE) |
| 8034 | w_pcl[i].flag = set | PCL_CHANNEL_SUPPORT_GO; |
| 8035 | else |
| 8036 | w_pcl[i].flag = set | PCL_CHANNEL_SUPPORT_CLI; |
| 8037 | } |
| 8038 | chan_idx = pcl_len; |
| 8039 | if (chan_weights->weight_list[pcl_len - 1] > |
| 8040 | PCL_GROUPS_WEIGHT_DIFFERENCE) |
| 8041 | /* Set non-pcl channels weight 20 point less than the last PCL entry */ |
| 8042 | valid_weight = chan_weights->weight_list[pcl_len - 1] - |
| 8043 | PCL_GROUPS_WEIGHT_DIFFERENCE; |
| 8044 | else |
| 8045 | valid_weight = 1; |
| 8046 | |
| 8047 | /* Include rest of the valid channels */ |
| 8048 | for (i = 0; i < chan_weights->saved_num_chan; i++) { |
| 8049 | for (j = 0; j < chan_weights->pcl_len; j++) { |
| 8050 | if (chan_weights->saved_chan_list[i] == |
| 8051 | chan_weights->pcl_list[j]) |
| 8052 | break; |
| 8053 | } |
| 8054 | if (j == chan_weights->pcl_len) { |
| 8055 | if (chan_weights->saved_chan_list[i] <= |
| 8056 | ARRAY_SIZE(hdd_channels_2_4_ghz)) |
| 8057 | w_pcl[chan_idx].freq = |
| 8058 | ieee80211_channel_to_frequency( |
| 8059 | chan_weights->saved_chan_list[i], |
| 8060 | HDD_NL80211_BAND_2GHZ); |
| 8061 | else |
| 8062 | w_pcl[chan_idx].freq = |
| 8063 | ieee80211_channel_to_frequency( |
| 8064 | chan_weights->saved_chan_list[i], |
| 8065 | HDD_NL80211_BAND_5GHZ); |
| 8066 | |
| 8067 | if (!chan_weights->weighed_valid_list[i]) { |
| 8068 | w_pcl[chan_idx].flag = |
| 8069 | set | PCL_CHANNEL_EXCLUDE_IN_GO_NEG; |
| 8070 | w_pcl[chan_idx].weight = 0; |
| 8071 | } else { |
| 8072 | if (intf_mode == PM_SAP_MODE || |
| 8073 | intf_mode == PM_P2P_GO_MODE) |
| 8074 | w_pcl[chan_idx].flag = |
| 8075 | set | PCL_CHANNEL_SUPPORT_GO; |
| 8076 | else |
| 8077 | w_pcl[chan_idx].flag = |
| 8078 | set | PCL_CHANNEL_SUPPORT_CLI; |
| 8079 | w_pcl[chan_idx].weight = valid_weight; |
| 8080 | } |
| 8081 | chan_idx++; |
| 8082 | } |
| 8083 | } |
| 8084 | return chan_idx; |
| 8085 | } |
| 8086 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8087 | /** __wlan_hdd_cfg80211_get_preferred_freq_list() - get preferred frequency list |
| 8088 | * @wiphy: Pointer to wireless phy |
| 8089 | * @wdev: Pointer to wireless device |
| 8090 | * @data: Pointer to data |
| 8091 | * @data_len: Data length |
| 8092 | * |
| 8093 | * This function return the preferred frequency list generated by the policy |
| 8094 | * manager. |
| 8095 | * |
| 8096 | * Return: success or failure code |
| 8097 | */ |
| 8098 | static int __wlan_hdd_cfg80211_get_preferred_freq_list(struct wiphy *wiphy, |
| 8099 | struct wireless_dev |
| 8100 | *wdev, const void *data, |
| 8101 | int data_len) |
| 8102 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8103 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8104 | int i, ret = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8105 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8106 | uint32_t pcl_len = 0; |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 8107 | uint32_t freq_list[QDF_MAX_NUM_CHAN]; |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 8108 | enum policy_mgr_con_mode intf_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8109 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_MAX + 1]; |
| 8110 | struct sk_buff *reply_skb; |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8111 | struct weighed_pcl *w_pcl; |
| 8112 | struct nlattr *nla_attr, *channel; |
| 8113 | struct policy_mgr_pcl_chan_weights *chan_weights; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8114 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8115 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 8116 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8117 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8118 | if (ret) |
| 8119 | return -EINVAL; |
| 8120 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8121 | if (wlan_cfg80211_nla_parse(tb, |
| 8122 | QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_MAX, |
| 8123 | data, data_len, |
| 8124 | get_preferred_freq_list_policy)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8125 | hdd_err("Invalid ATTR"); |
| 8126 | return -EINVAL; |
| 8127 | } |
| 8128 | |
| 8129 | if (!tb[QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_IFACE_TYPE]) { |
| 8130 | hdd_err("attr interface type failed"); |
| 8131 | return -EINVAL; |
| 8132 | } |
| 8133 | |
| 8134 | intf_mode = nla_get_u32(tb |
| 8135 | [QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_IFACE_TYPE]); |
| 8136 | |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 8137 | if (intf_mode < PM_STA_MODE || intf_mode >= PM_MAX_NUM_OF_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8138 | hdd_err("Invalid interface type"); |
| 8139 | return -EINVAL; |
| 8140 | } |
| 8141 | |
| 8142 | hdd_debug("Userspace requested pref freq list"); |
| 8143 | |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8144 | chan_weights = |
| 8145 | qdf_mem_malloc(sizeof(struct policy_mgr_pcl_chan_weights)); |
| 8146 | if (!chan_weights) |
| 8147 | return -ENOMEM; |
| 8148 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 8149 | status = policy_mgr_get_pcl(hdd_ctx->psoc, |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8150 | intf_mode, chan_weights->pcl_list, |
| 8151 | &chan_weights->pcl_len, |
| 8152 | chan_weights->weight_list, |
| 8153 | QDF_ARRAY_SIZE(chan_weights->weight_list)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8154 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8155 | hdd_err("Get pcl failed"); |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8156 | qdf_mem_free(chan_weights); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8157 | return -EINVAL; |
| 8158 | } |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8159 | sme_get_valid_channels(chan_weights->saved_chan_list, |
| 8160 | &chan_weights->saved_num_chan); |
| 8161 | policy_mgr_get_valid_chan_weights(hdd_ctx->psoc, chan_weights); |
| 8162 | w_pcl = qdf_mem_malloc(sizeof(struct weighed_pcl) * QDF_MAX_NUM_CHAN); |
| 8163 | if (!w_pcl) { |
| 8164 | qdf_mem_free(chan_weights); |
| 8165 | return -ENOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8166 | } |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8167 | pcl_len = wlan_hdd_populate_weigh_pcl(chan_weights, w_pcl, intf_mode); |
| 8168 | qdf_mem_free(chan_weights); |
| 8169 | |
| 8170 | for (i = 0; i < pcl_len; i++) |
| 8171 | freq_list[i] = w_pcl[i].freq; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8172 | |
| 8173 | /* send the freq_list back to supplicant */ |
| 8174 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) + |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8175 | sizeof(u32) * pcl_len + |
| 8176 | sizeof(struct weighed_pcl) * pcl_len + |
| 8177 | NLMSG_HDRLEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8178 | |
| 8179 | if (!reply_skb) { |
| 8180 | hdd_err("Allocate reply_skb failed"); |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8181 | qdf_mem_free(w_pcl); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8182 | return -EINVAL; |
| 8183 | } |
| 8184 | |
| 8185 | if (nla_put_u32(reply_skb, |
| 8186 | QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_IFACE_TYPE, |
| 8187 | intf_mode) || |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8188 | nla_put(reply_skb, |
| 8189 | QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST, |
| 8190 | sizeof(uint32_t) * pcl_len, |
| 8191 | freq_list)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8192 | hdd_err("nla put fail"); |
| 8193 | kfree_skb(reply_skb); |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8194 | qdf_mem_free(w_pcl); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8195 | return -EINVAL; |
| 8196 | } |
| 8197 | |
Jayachandran Sreekumaran | 91f96ec | 2019-01-09 17:37:33 +0530 | [diff] [blame] | 8198 | i = QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_WEIGHED_PCL; |
| 8199 | nla_attr = nla_nest_start(reply_skb, i); |
| 8200 | |
| 8201 | if (!nla_attr) { |
| 8202 | hdd_err("nla nest start fail"); |
| 8203 | kfree_skb(reply_skb); |
| 8204 | qdf_mem_free(w_pcl); |
| 8205 | return -EINVAL; |
| 8206 | } |
| 8207 | |
| 8208 | for (i = 0; i < pcl_len; i++) { |
| 8209 | channel = nla_nest_start(reply_skb, i); |
| 8210 | if (!channel) { |
| 8211 | hdd_err("updating pcl list failed"); |
| 8212 | kfree_skb(reply_skb); |
| 8213 | qdf_mem_free(w_pcl); |
| 8214 | return -EINVAL; |
| 8215 | } |
| 8216 | if (nla_put_u32(reply_skb, QCA_WLAN_VENDOR_ATTR_PCL_FREQ, |
| 8217 | w_pcl[i].freq) || |
| 8218 | nla_put_u32(reply_skb, QCA_WLAN_VENDOR_ATTR_PCL_WEIGHT, |
| 8219 | w_pcl[i].weight) || |
| 8220 | nla_put_u32(reply_skb, QCA_WLAN_VENDOR_ATTR_PCL_FLAG, |
| 8221 | w_pcl[i].flag)) { |
| 8222 | hdd_err("nla put fail"); |
| 8223 | kfree_skb(reply_skb); |
| 8224 | qdf_mem_free(w_pcl); |
| 8225 | return -EINVAL; |
| 8226 | } |
| 8227 | nla_nest_end(reply_skb, channel); |
| 8228 | } |
| 8229 | nla_nest_end(reply_skb, nla_attr); |
| 8230 | qdf_mem_free(w_pcl); |
| 8231 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8232 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 8233 | } |
| 8234 | |
| 8235 | /** wlan_hdd_cfg80211_get_preferred_freq_list () - get preferred frequency list |
| 8236 | * @wiphy: Pointer to wireless phy |
| 8237 | * @wdev: Pointer to wireless device |
| 8238 | * @data: Pointer to data |
| 8239 | * @data_len: Data length |
| 8240 | * |
| 8241 | * This function return the preferred frequency list generated by the policy |
| 8242 | * manager. |
| 8243 | * |
| 8244 | * Return: success or failure code |
| 8245 | */ |
| 8246 | static int wlan_hdd_cfg80211_get_preferred_freq_list(struct wiphy *wiphy, |
| 8247 | struct wireless_dev |
| 8248 | *wdev, const void *data, |
| 8249 | int data_len) |
| 8250 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 8251 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 8252 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 8253 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 8254 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 8255 | if (errno) |
| 8256 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8257 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 8258 | errno = __wlan_hdd_cfg80211_get_preferred_freq_list(wiphy, wdev, |
| 8259 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8260 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 8261 | osif_psoc_sync_op_stop(psoc_sync); |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 8262 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 8263 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8264 | } |
| 8265 | |
Jeff Johnson | e5f33ba | 2017-06-05 14:48:48 -0700 | [diff] [blame] | 8266 | static const struct nla_policy set_probable_oper_channel_policy |
| 8267 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_MAX + 1] = { |
| 8268 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_IFACE_TYPE] = { |
| 8269 | .type = NLA_U32}, |
| 8270 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_FREQ] = { |
| 8271 | .type = NLA_U32}, |
| 8272 | }; |
| 8273 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8274 | /** |
| 8275 | * __wlan_hdd_cfg80211_set_probable_oper_channel () - set probable channel |
| 8276 | * @wiphy: Pointer to wireless phy |
| 8277 | * @wdev: Pointer to wireless device |
| 8278 | * @data: Pointer to data |
| 8279 | * @data_len: Data length |
| 8280 | * |
| 8281 | * Return: 0 on success, negative errno on failure |
| 8282 | */ |
| 8283 | static int __wlan_hdd_cfg80211_set_probable_oper_channel(struct wiphy *wiphy, |
| 8284 | struct wireless_dev *wdev, |
| 8285 | const void *data, |
| 8286 | int data_len) |
| 8287 | { |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 8288 | struct net_device *ndev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 8289 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8290 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8291 | int ret = 0; |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 8292 | enum policy_mgr_con_mode intf_mode; |
Jeff Johnson | e5f33ba | 2017-06-05 14:48:48 -0700 | [diff] [blame] | 8293 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_MAX + 1]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8294 | uint32_t channel_hint; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8295 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8296 | hdd_enter_dev(ndev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 8297 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8298 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8299 | if (ret) |
| 8300 | return ret; |
| 8301 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8302 | if (wlan_cfg80211_nla_parse(tb, |
| 8303 | QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_MAX, |
| 8304 | data, data_len, |
| 8305 | set_probable_oper_channel_policy)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8306 | hdd_err("Invalid ATTR"); |
| 8307 | return -EINVAL; |
| 8308 | } |
| 8309 | |
| 8310 | if (!tb[QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_IFACE_TYPE]) { |
| 8311 | hdd_err("attr interface type failed"); |
| 8312 | return -EINVAL; |
| 8313 | } |
| 8314 | |
| 8315 | intf_mode = nla_get_u32(tb |
| 8316 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_IFACE_TYPE]); |
| 8317 | |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 8318 | if (intf_mode < PM_STA_MODE || intf_mode >= PM_MAX_NUM_OF_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8319 | hdd_err("Invalid interface type"); |
| 8320 | return -EINVAL; |
| 8321 | } |
| 8322 | |
| 8323 | if (!tb[QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_FREQ]) { |
| 8324 | hdd_err("attr probable freq failed"); |
| 8325 | return -EINVAL; |
| 8326 | } |
| 8327 | |
| 8328 | channel_hint = cds_freq_to_chan(nla_get_u32(tb |
| 8329 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_FREQ])); |
| 8330 | |
| 8331 | /* check pcl table */ |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 8332 | if (!policy_mgr_allow_concurrency(hdd_ctx->psoc, intf_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8333 | channel_hint, HW_MODE_20_MHZ)) { |
| 8334 | hdd_err("Set channel hint failed due to concurrency check"); |
| 8335 | return -EINVAL; |
| 8336 | } |
| 8337 | |
Krunal Soni | 09e5503 | 2016-06-07 10:06:55 -0700 | [diff] [blame] | 8338 | if (0 != wlan_hdd_check_remain_on_channel(adapter)) |
| 8339 | hdd_warn("Remain On Channel Pending"); |
| 8340 | |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 8341 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, channel_hint, |
| 8342 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 8343 | hdd_err("Failed to change hw mode"); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 8344 | return -EINVAL; |
| 8345 | } |
| 8346 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8347 | return 0; |
| 8348 | } |
| 8349 | |
| 8350 | /** |
| 8351 | * wlan_hdd_cfg80211_set_probable_oper_channel () - set probable channel |
| 8352 | * @wiphy: Pointer to wireless phy |
| 8353 | * @wdev: Pointer to wireless device |
| 8354 | * @data: Pointer to data |
| 8355 | * @data_len: Data length |
| 8356 | * |
| 8357 | * Return: 0 on success, negative errno on failure |
| 8358 | */ |
| 8359 | static int wlan_hdd_cfg80211_set_probable_oper_channel(struct wiphy *wiphy, |
| 8360 | struct wireless_dev *wdev, |
| 8361 | const void *data, |
| 8362 | int data_len) |
| 8363 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 8364 | int errno; |
| 8365 | struct osif_vdev_sync *vdev_sync; |
| 8366 | |
| 8367 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 8368 | if (errno) |
| 8369 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8370 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 8371 | errno = __wlan_hdd_cfg80211_set_probable_oper_channel(wiphy, wdev, |
| 8372 | data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8373 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 8374 | osif_vdev_sync_op_stop(vdev_sync); |
| 8375 | |
| 8376 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8377 | } |
| 8378 | |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8379 | static const struct |
| 8380 | nla_policy |
| 8381 | qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = { |
Ashish Kumar Dhanotiya | 81e2acc | 2017-06-21 12:30:32 +0530 | [diff] [blame] | 8382 | [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { |
| 8383 | .type = NLA_BINARY, .len = QDF_MAC_ADDR_SIZE }, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8384 | }; |
| 8385 | |
| 8386 | /** |
| 8387 | * __wlan_hdd_cfg80211_get_link_properties() - Get link properties |
| 8388 | * @wiphy: WIPHY structure pointer |
| 8389 | * @wdev: Wireless device structure pointer |
| 8390 | * @data: Pointer to the data received |
| 8391 | * @data_len: Length of the data received |
| 8392 | * |
| 8393 | * This function is used to get link properties like nss, rate flags and |
| 8394 | * operating frequency for the active connection with the given peer. |
| 8395 | * |
| 8396 | * Return: 0 on success and errno on failure |
| 8397 | */ |
| 8398 | static int __wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy, |
| 8399 | struct wireless_dev *wdev, |
| 8400 | const void *data, |
| 8401 | int data_len) |
| 8402 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8403 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8404 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 8405 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 8406 | struct hdd_station_ctx *hdd_sta_ctx; |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8407 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1]; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8408 | uint8_t peer_mac[QDF_MAC_ADDR_SIZE]; |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8409 | uint32_t sta_id; |
| 8410 | struct sk_buff *reply_skb; |
| 8411 | uint32_t rate_flags = 0; |
| 8412 | uint8_t nss; |
| 8413 | uint8_t final_rate_flags = 0; |
| 8414 | uint32_t freq; |
| 8415 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8416 | hdd_enter_dev(dev); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8417 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8418 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8419 | hdd_err("Command not allowed in FTM mode"); |
| 8420 | return -EPERM; |
| 8421 | } |
| 8422 | |
| 8423 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 8424 | return -EINVAL; |
| 8425 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8426 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, |
| 8427 | data_len, qca_wlan_vendor_attr_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8428 | hdd_err("Invalid attribute"); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8429 | return -EINVAL; |
| 8430 | } |
| 8431 | |
| 8432 | if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8433 | hdd_err("Attribute peerMac not provided for mode=%d", |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8434 | adapter->device_mode); |
| 8435 | return -EINVAL; |
| 8436 | } |
| 8437 | |
Ashish Kumar Dhanotiya | 81e2acc | 2017-06-21 12:30:32 +0530 | [diff] [blame] | 8438 | if (nla_len(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) < QDF_MAC_ADDR_SIZE) { |
| 8439 | hdd_err("Attribute peerMac is invalid for mode=%d", |
| 8440 | adapter->device_mode); |
| 8441 | return -EINVAL; |
| 8442 | } |
| 8443 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8444 | qdf_mem_copy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8445 | QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 8446 | hdd_debug("peerMac="MAC_ADDRESS_STR" for device_mode:%d", |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8447 | MAC_ADDR_ARRAY(peer_mac), adapter->device_mode); |
| 8448 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 8449 | if (adapter->device_mode == QDF_STA_MODE || |
| 8450 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8451 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 8452 | if ((hdd_sta_ctx->conn_info.conn_state != |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8453 | eConnectionState_Associated) || |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 8454 | qdf_mem_cmp(hdd_sta_ctx->conn_info.bssid.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8455 | peer_mac, QDF_MAC_ADDR_SIZE)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8456 | hdd_err("Not Associated to mac "MAC_ADDRESS_STR, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8457 | MAC_ADDR_ARRAY(peer_mac)); |
| 8458 | return -EINVAL; |
| 8459 | } |
| 8460 | |
| 8461 | nss = hdd_sta_ctx->conn_info.nss; |
| 8462 | freq = cds_chan_to_freq( |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 8463 | hdd_sta_ctx->conn_info.channel); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8464 | rate_flags = hdd_sta_ctx->conn_info.rate_flags; |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 8465 | } else if (adapter->device_mode == QDF_P2P_GO_MODE || |
| 8466 | adapter->device_mode == QDF_SAP_MODE) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8467 | |
| 8468 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 8469 | if (adapter->sta_info[sta_id].in_use && |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 8470 | !qdf_is_macaddr_broadcast( |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 8471 | &adapter->sta_info[sta_id].sta_mac) && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8472 | !qdf_mem_cmp( |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 8473 | &adapter->sta_info[sta_id].sta_mac.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8474 | peer_mac, QDF_MAC_ADDR_SIZE)) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8475 | break; |
| 8476 | } |
| 8477 | |
| 8478 | if (WLAN_MAX_STA_COUNT == sta_id) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8479 | hdd_err("No active peer with mac="MAC_ADDRESS_STR, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8480 | MAC_ADDR_ARRAY(peer_mac)); |
| 8481 | return -EINVAL; |
| 8482 | } |
| 8483 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 8484 | nss = adapter->sta_info[sta_id].nss; |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8485 | freq = cds_chan_to_freq( |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 8486 | (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operating_channel); |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 8487 | rate_flags = adapter->sta_info[sta_id].rate_flags; |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8488 | } else { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8489 | hdd_err("Not Associated! with mac "MAC_ADDRESS_STR, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8490 | MAC_ADDR_ARRAY(peer_mac)); |
| 8491 | return -EINVAL; |
| 8492 | } |
| 8493 | |
Naveen Rawat | ea1564b | 2018-05-17 15:56:11 -0700 | [diff] [blame] | 8494 | if (!(rate_flags & TX_RATE_LEGACY)) { |
| 8495 | if (rate_flags & TX_RATE_VHT80) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8496 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8497 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && !defined(WITH_BACKPORTS) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8498 | final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8499 | #endif |
Naveen Rawat | ea1564b | 2018-05-17 15:56:11 -0700 | [diff] [blame] | 8500 | } else if (rate_flags & TX_RATE_VHT40) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8501 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8502 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && !defined(WITH_BACKPORTS) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8503 | final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8504 | #endif |
Naveen Rawat | ea1564b | 2018-05-17 15:56:11 -0700 | [diff] [blame] | 8505 | } else if (rate_flags & TX_RATE_VHT20) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8506 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 8507 | } else if (rate_flags & |
Naveen Rawat | ea1564b | 2018-05-17 15:56:11 -0700 | [diff] [blame] | 8508 | (TX_RATE_HT20 | TX_RATE_HT40)) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8509 | final_rate_flags |= RATE_INFO_FLAGS_MCS; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8510 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && !defined(WITH_BACKPORTS) |
Naveen Rawat | ea1564b | 2018-05-17 15:56:11 -0700 | [diff] [blame] | 8511 | if (rate_flags & TX_RATE_HT40) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8512 | final_rate_flags |= |
| 8513 | RATE_INFO_FLAGS_40_MHZ_WIDTH; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8514 | #endif |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8515 | } |
| 8516 | |
Naveen Rawat | ea1564b | 2018-05-17 15:56:11 -0700 | [diff] [blame] | 8517 | if (rate_flags & TX_RATE_SGI) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8518 | if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS)) |
| 8519 | final_rate_flags |= RATE_INFO_FLAGS_MCS; |
| 8520 | final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 8521 | } |
| 8522 | } |
| 8523 | |
| 8524 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 8525 | sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN); |
| 8526 | |
| 8527 | if (NULL == reply_skb) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8528 | hdd_err("getLinkProperties: skb alloc failed"); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8529 | return -EINVAL; |
| 8530 | } |
| 8531 | |
| 8532 | if (nla_put_u8(reply_skb, |
| 8533 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS, |
| 8534 | nss) || |
| 8535 | nla_put_u8(reply_skb, |
| 8536 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS, |
| 8537 | final_rate_flags) || |
| 8538 | nla_put_u32(reply_skb, |
| 8539 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ, |
| 8540 | freq)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8541 | hdd_err("nla_put failed"); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8542 | kfree_skb(reply_skb); |
| 8543 | return -EINVAL; |
| 8544 | } |
| 8545 | |
| 8546 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 8547 | } |
| 8548 | |
| 8549 | /** |
| 8550 | * wlan_hdd_cfg80211_get_link_properties() - Wrapper function to get link |
| 8551 | * properties. |
| 8552 | * @wiphy: WIPHY structure pointer |
| 8553 | * @wdev: Wireless device structure pointer |
| 8554 | * @data: Pointer to the data received |
| 8555 | * @data_len: Length of the data received |
| 8556 | * |
| 8557 | * This function is used to get link properties like nss, rate flags and |
| 8558 | * operating frequency for the active connection with the given peer. |
| 8559 | * |
| 8560 | * Return: 0 on success and errno on failure |
| 8561 | */ |
| 8562 | static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy, |
| 8563 | struct wireless_dev *wdev, |
| 8564 | const void *data, |
| 8565 | int data_len) |
| 8566 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 8567 | int errno; |
| 8568 | struct osif_vdev_sync *vdev_sync; |
| 8569 | |
| 8570 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 8571 | if (errno) |
| 8572 | return errno; |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8573 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 8574 | errno = __wlan_hdd_cfg80211_get_link_properties(wiphy, wdev, |
| 8575 | data, data_len); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8576 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 8577 | osif_vdev_sync_op_stop(vdev_sync); |
| 8578 | |
| 8579 | return errno; |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8580 | } |
| 8581 | |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 8582 | static const struct nla_policy |
| 8583 | wlan_hdd_sap_config_policy[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_MAX + 1] = { |
| 8584 | [QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHANNEL] = {.type = NLA_U8 }, |
Ganesh Kondabattini | 099e6e8 | 2017-06-28 12:24:20 +0530 | [diff] [blame] | 8585 | [QCA_WLAN_VENDOR_ATTR_SAP_MANDATORY_FREQUENCY_LIST] = { |
| 8586 | .type = NLA_NESTED }, |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 8587 | }; |
| 8588 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 8589 | static const struct nla_policy |
| 8590 | wlan_hdd_set_acs_dfs_config_policy[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MAX + 1] = { |
| 8591 | [QCA_WLAN_VENDOR_ATTR_ACS_DFS_MODE] = {.type = NLA_U8 }, |
| 8592 | [QCA_WLAN_VENDOR_ATTR_ACS_CHANNEL_HINT] = {.type = NLA_U8 }, |
| 8593 | }; |
| 8594 | |
| 8595 | /** |
| 8596 | * __wlan_hdd_cfg80211_acs_dfs_mode() - set ACS DFS mode and channel |
| 8597 | * @wiphy: Pointer to wireless phy |
| 8598 | * @wdev: Pointer to wireless device |
| 8599 | * @data: Pointer to data |
| 8600 | * @data_len: Length of @data |
| 8601 | * |
| 8602 | * This function parses the incoming NL vendor command data attributes and |
| 8603 | * updates the SAP context about channel_hint and DFS mode. |
| 8604 | * If channel_hint is set, SAP will choose that channel |
| 8605 | * as operating channel. |
| 8606 | * |
| 8607 | * If DFS mode is enabled, driver will include DFS channels |
| 8608 | * in ACS else driver will skip DFS channels. |
| 8609 | * |
| 8610 | * Return: 0 on success, negative errno on failure |
| 8611 | */ |
| 8612 | static int |
| 8613 | __wlan_hdd_cfg80211_acs_dfs_mode(struct wiphy *wiphy, |
| 8614 | struct wireless_dev *wdev, |
| 8615 | const void *data, int data_len) |
| 8616 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8617 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 8618 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MAX + 1]; |
| 8619 | int ret; |
| 8620 | struct acs_dfs_policy *acs_policy; |
| 8621 | int mode = DFS_MODE_NONE; |
| 8622 | int channel_hint = 0; |
| 8623 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8624 | hdd_enter_dev(wdev->netdev); |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 8625 | |
| 8626 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 8627 | hdd_err("Command not allowed in FTM mode"); |
| 8628 | return -EINVAL; |
| 8629 | } |
| 8630 | |
| 8631 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8632 | if (0 != ret) |
| 8633 | return ret; |
| 8634 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8635 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_ACS_DFS_MAX, |
| 8636 | data, data_len, |
| 8637 | wlan_hdd_set_acs_dfs_config_policy)) { |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 8638 | hdd_err("invalid attr"); |
| 8639 | return -EINVAL; |
| 8640 | } |
| 8641 | |
| 8642 | acs_policy = &hdd_ctx->acs_policy; |
| 8643 | /* |
| 8644 | * SCM sends this attribute to restrict SAP from choosing |
| 8645 | * DFS channels from ACS. |
| 8646 | */ |
| 8647 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MODE]) |
| 8648 | mode = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MODE]); |
| 8649 | |
| 8650 | if (!IS_DFS_MODE_VALID(mode)) { |
| 8651 | hdd_err("attr acs dfs mode is not valid"); |
| 8652 | return -EINVAL; |
| 8653 | } |
| 8654 | acs_policy->acs_dfs_mode = mode; |
| 8655 | |
| 8656 | /* |
| 8657 | * SCM sends this attribute to provide an active channel, |
| 8658 | * to skip redundant ACS between drivers, and save driver start up time |
| 8659 | */ |
| 8660 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_CHANNEL_HINT]) |
| 8661 | channel_hint = nla_get_u8( |
| 8662 | tb[QCA_WLAN_VENDOR_ATTR_ACS_CHANNEL_HINT]); |
| 8663 | |
| 8664 | if (!IS_CHANNEL_VALID(channel_hint)) { |
| 8665 | hdd_err("acs channel is not valid"); |
| 8666 | return -EINVAL; |
| 8667 | } |
| 8668 | acs_policy->acs_channel = channel_hint; |
| 8669 | |
| 8670 | return 0; |
| 8671 | } |
| 8672 | |
| 8673 | /** |
| 8674 | * wlan_hdd_cfg80211_acs_dfs_mode() - Wrapper to set ACS DFS mode |
| 8675 | * @wiphy: wiphy structure pointer |
| 8676 | * @wdev: Wireless device structure pointer |
| 8677 | * @data: Pointer to the data received |
| 8678 | * @data_len: Length of @data |
| 8679 | * |
| 8680 | * This function parses the incoming NL vendor command data attributes and |
| 8681 | * updates the SAP context about channel_hint and DFS mode. |
| 8682 | * |
| 8683 | * Return: 0 on success; errno on failure |
| 8684 | */ |
| 8685 | static int wlan_hdd_cfg80211_acs_dfs_mode(struct wiphy *wiphy, |
| 8686 | struct wireless_dev *wdev, |
| 8687 | const void *data, int data_len) |
| 8688 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 8689 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 8690 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 8691 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 8692 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 8693 | if (errno) |
| 8694 | return errno; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 8695 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 8696 | errno = __wlan_hdd_cfg80211_acs_dfs_mode(wiphy, wdev, data, data_len); |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 8697 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 8698 | osif_psoc_sync_op_stop(psoc_sync); |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 8699 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 8700 | return errno; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 8701 | } |
| 8702 | |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 8703 | /** |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8704 | * wlan_hdd_get_sta_roam_dfs_mode() - get sta roam dfs mode policy |
| 8705 | * @mode : cfg80211 dfs mode |
| 8706 | * |
| 8707 | * Return: return csr sta roam dfs mode else return NONE |
| 8708 | */ |
| 8709 | static enum sta_roam_policy_dfs_mode wlan_hdd_get_sta_roam_dfs_mode( |
| 8710 | enum dfs_mode mode) |
| 8711 | { |
| 8712 | switch (mode) { |
| 8713 | case DFS_MODE_ENABLE: |
| 8714 | return CSR_STA_ROAM_POLICY_DFS_ENABLED; |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8715 | case DFS_MODE_DISABLE: |
| 8716 | return CSR_STA_ROAM_POLICY_DFS_DISABLED; |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8717 | case DFS_MODE_DEPRIORITIZE: |
| 8718 | return CSR_STA_ROAM_POLICY_DFS_DEPRIORITIZE; |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8719 | default: |
| 8720 | hdd_err("STA Roam policy dfs mode is NONE"); |
| 8721 | return CSR_STA_ROAM_POLICY_NONE; |
| 8722 | } |
| 8723 | } |
| 8724 | |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 8725 | /* |
| 8726 | * hdd_get_sap_operating_band: Get current operating channel |
| 8727 | * for sap. |
| 8728 | * @hdd_ctx: hdd context |
| 8729 | * |
| 8730 | * Return : Corresponding band for SAP operating channel |
| 8731 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8732 | uint8_t hdd_get_sap_operating_band(struct hdd_context *hdd_ctx) |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 8733 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 8734 | struct hdd_adapter *adapter; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 8735 | uint8_t operating_channel = 0; |
| 8736 | uint8_t sap_operating_band = 0; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 8737 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8738 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8739 | if (adapter->device_mode != QDF_SAP_MODE) |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 8740 | continue; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8741 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8742 | operating_channel = adapter->session.ap.operating_channel; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 8743 | if (IS_24G_CH(operating_channel)) |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 8744 | sap_operating_band = BAND_2G; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 8745 | else if (IS_5G_CH(operating_channel)) |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 8746 | sap_operating_band = BAND_5G; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 8747 | else |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 8748 | sap_operating_band = BAND_ALL; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 8749 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8750 | |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 8751 | return sap_operating_band; |
| 8752 | } |
| 8753 | |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8754 | static const struct nla_policy |
| 8755 | wlan_hdd_set_sta_roam_config_policy[ |
| 8756 | QCA_WLAN_VENDOR_ATTR_STA_CONNECT_ROAM_POLICY_MAX + 1] = { |
| 8757 | [QCA_WLAN_VENDOR_ATTR_STA_DFS_MODE] = {.type = NLA_U8 }, |
| 8758 | [QCA_WLAN_VENDOR_ATTR_STA_SKIP_UNSAFE_CHANNEL] = {.type = NLA_U8 }, |
| 8759 | }; |
| 8760 | |
| 8761 | /** |
| 8762 | * __wlan_hdd_cfg80211_sta_roam_policy() - Set params to restrict scan channels |
| 8763 | * for station connection or roaming. |
| 8764 | * @wiphy: Pointer to wireless phy |
| 8765 | * @wdev: Pointer to wireless device |
| 8766 | * @data: Pointer to data |
| 8767 | * @data_len: Length of @data |
| 8768 | * |
| 8769 | * __wlan_hdd_cfg80211_sta_roam_policy will decide if DFS channels or unsafe |
| 8770 | * channels needs to be skipped in scanning or not. |
| 8771 | * If dfs_mode is disabled, driver will not scan DFS channels. |
| 8772 | * If skip_unsafe_channels is set, driver will skip unsafe channels |
| 8773 | * in Scanning. |
| 8774 | * |
| 8775 | * Return: 0 on success, negative errno on failure |
| 8776 | */ |
| 8777 | static int |
| 8778 | __wlan_hdd_cfg80211_sta_roam_policy(struct wiphy *wiphy, |
| 8779 | struct wireless_dev *wdev, |
| 8780 | const void *data, int data_len) |
| 8781 | { |
| 8782 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 8783 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8784 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8785 | struct nlattr *tb[ |
| 8786 | QCA_WLAN_VENDOR_ATTR_STA_CONNECT_ROAM_POLICY_MAX + 1]; |
| 8787 | int ret; |
| 8788 | enum sta_roam_policy_dfs_mode sta_roam_dfs_mode; |
| 8789 | enum dfs_mode mode = DFS_MODE_NONE; |
| 8790 | bool skip_unsafe_channels = false; |
| 8791 | QDF_STATUS status; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 8792 | uint8_t sap_operating_band; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 8793 | mac_handle_t mac_handle; |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8794 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8795 | hdd_enter_dev(dev); |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8796 | |
| 8797 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 8798 | hdd_err("Command not allowed in FTM mode"); |
| 8799 | return -EINVAL; |
| 8800 | } |
| 8801 | |
| 8802 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8803 | if (0 != ret) |
| 8804 | return ret; |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8805 | if (wlan_cfg80211_nla_parse(tb, |
| 8806 | QCA_WLAN_VENDOR_ATTR_STA_CONNECT_ROAM_POLICY_MAX, |
| 8807 | data, data_len, |
| 8808 | wlan_hdd_set_sta_roam_config_policy)) { |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8809 | hdd_err("invalid attr"); |
| 8810 | return -EINVAL; |
| 8811 | } |
| 8812 | if (tb[QCA_WLAN_VENDOR_ATTR_STA_DFS_MODE]) |
| 8813 | mode = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_STA_DFS_MODE]); |
| 8814 | if (!IS_DFS_MODE_VALID(mode)) { |
| 8815 | hdd_err("attr sta roam dfs mode policy is not valid"); |
| 8816 | return -EINVAL; |
| 8817 | } |
| 8818 | |
| 8819 | sta_roam_dfs_mode = wlan_hdd_get_sta_roam_dfs_mode(mode); |
| 8820 | |
| 8821 | if (tb[QCA_WLAN_VENDOR_ATTR_STA_SKIP_UNSAFE_CHANNEL]) |
| 8822 | skip_unsafe_channels = nla_get_u8( |
| 8823 | tb[QCA_WLAN_VENDOR_ATTR_STA_SKIP_UNSAFE_CHANNEL]); |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 8824 | sap_operating_band = hdd_get_sap_operating_band(hdd_ctx); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 8825 | mac_handle = hdd_ctx->mac_handle; |
| 8826 | status = sme_update_sta_roam_policy(mac_handle, sta_roam_dfs_mode, |
| 8827 | skip_unsafe_channels, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 8828 | adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 8829 | sap_operating_band); |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8830 | |
| 8831 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8832 | hdd_err("sme_update_sta_roam_policy (err=%d)", status); |
| 8833 | return -EINVAL; |
| 8834 | } |
| 8835 | return 0; |
| 8836 | } |
| 8837 | |
| 8838 | /** |
| 8839 | * wlan_hdd_cfg80211_sta_roam_policy() - Wrapper to restrict scan channels, |
| 8840 | * connection and roaming for station. |
| 8841 | * @wiphy: wiphy structure pointer |
| 8842 | * @wdev: Wireless device structure pointer |
| 8843 | * @data: Pointer to the data received |
| 8844 | * @data_len: Length of @data |
| 8845 | * |
| 8846 | * __wlan_hdd_cfg80211_sta_roam_policy will decide if DFS channels or unsafe |
| 8847 | * channels needs to be skipped in scanning or not. |
| 8848 | * If dfs_mode is disabled, driver will not scan DFS channels. |
| 8849 | * If skip_unsafe_channels is set, driver will skip unsafe channels |
| 8850 | * in Scanning. |
| 8851 | * Return: 0 on success; errno on failure |
| 8852 | */ |
| 8853 | static int wlan_hdd_cfg80211_sta_roam_policy(struct wiphy *wiphy, |
| 8854 | struct wireless_dev *wdev, |
| 8855 | const void *data, int data_len) |
| 8856 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 8857 | int errno; |
| 8858 | struct osif_vdev_sync *vdev_sync; |
| 8859 | |
| 8860 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 8861 | if (errno) |
| 8862 | return errno; |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8863 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 8864 | errno = __wlan_hdd_cfg80211_sta_roam_policy(wiphy, wdev, |
| 8865 | data, data_len); |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8866 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 8867 | osif_vdev_sync_op_stop(vdev_sync); |
| 8868 | |
| 8869 | return errno; |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8870 | } |
| 8871 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8872 | #ifdef FEATURE_WLAN_CH_AVOID |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 8873 | |
| 8874 | static int hdd_validate_avoid_freq_chanlist( |
| 8875 | struct hdd_context *hdd_ctx, |
| 8876 | struct ch_avoid_ind_type *channel_list) |
| 8877 | { |
| 8878 | unsigned int range_idx, ch_idx; |
| 8879 | unsigned int unsafe_channel_index, unsafe_channel_count = 0; |
| 8880 | bool ch_found = false; |
| 8881 | |
| 8882 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
| 8883 | (uint16_t)NUM_CHANNELS); |
| 8884 | |
| 8885 | for (range_idx = 0; range_idx < channel_list->ch_avoid_range_cnt; |
| 8886 | range_idx++) { |
| 8887 | if ((channel_list->avoid_freq_range[range_idx].start_freq < |
| 8888 | CDS_24_GHZ_CHANNEL_1) || |
| 8889 | (channel_list->avoid_freq_range[range_idx].end_freq > |
| 8890 | CDS_5_GHZ_CHANNEL_165) || |
| 8891 | (channel_list->avoid_freq_range[range_idx].start_freq > |
| 8892 | channel_list->avoid_freq_range[range_idx].end_freq)) |
| 8893 | continue; |
| 8894 | |
| 8895 | for (ch_idx = channel_list-> |
| 8896 | avoid_freq_range[range_idx].start_freq; |
| 8897 | ch_idx <= channel_list-> |
| 8898 | avoid_freq_range[range_idx].end_freq; |
| 8899 | ch_idx++) { |
Ashish Kumar Dhanotiya | aa9fdbb | 2018-12-14 15:29:14 +0530 | [diff] [blame] | 8900 | if (INVALID_CHANNEL == wlan_reg_get_chan_enum(ch_idx)) |
Ashish Kumar Dhanotiya | bf00f82 | 2018-11-30 20:29:09 +0530 | [diff] [blame] | 8901 | continue; |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 8902 | for (unsafe_channel_index = 0; |
| 8903 | unsafe_channel_index < unsafe_channel_count; |
| 8904 | unsafe_channel_index++) { |
| 8905 | if (ch_idx == |
| 8906 | hdd_ctx->unsafe_channel_list[ |
| 8907 | unsafe_channel_index]) { |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 8908 | hdd_info("Duplicate channel %d", |
| 8909 | ch_idx); |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 8910 | ch_found = true; |
| 8911 | break; |
| 8912 | } |
| 8913 | } |
| 8914 | if (!ch_found) { |
| 8915 | hdd_ctx->unsafe_channel_list[ |
| 8916 | unsafe_channel_count++] = ch_idx; |
| 8917 | } |
| 8918 | ch_found = false; |
| 8919 | } |
| 8920 | } |
| 8921 | return unsafe_channel_count; |
| 8922 | } |
| 8923 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8924 | /** |
| 8925 | * __wlan_hdd_cfg80211_avoid_freq() - ask driver to restart SAP if SAP |
| 8926 | * is on unsafe channel. |
| 8927 | * @wiphy: wiphy structure pointer |
| 8928 | * @wdev: Wireless device structure pointer |
| 8929 | * @data: Pointer to the data received |
| 8930 | * @data_len: Length of @data |
| 8931 | * |
| 8932 | * wlan_hdd_cfg80211_avoid_freq do restart the sap if sap is already |
| 8933 | * on any of unsafe channels. |
| 8934 | * If sap is on any of unsafe channel, hdd_unsafe_channel_restart_sap |
| 8935 | * will send WLAN_SVC_LTE_COEX_IND indication to userspace to restart. |
| 8936 | * |
| 8937 | * Return: 0 on success; errno on failure |
| 8938 | */ |
| 8939 | static int |
| 8940 | __wlan_hdd_cfg80211_avoid_freq(struct wiphy *wiphy, |
| 8941 | struct wireless_dev *wdev, |
| 8942 | const void *data, int data_len) |
| 8943 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8944 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8945 | int ret; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8946 | qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8947 | uint16_t *local_unsafe_list; |
hqu | bf1b618 | 2018-08-14 17:22:41 +0800 | [diff] [blame] | 8948 | uint16_t unsafe_channel_count; |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 8949 | uint16_t unsafe_channel_index, local_unsafe_list_count; |
| 8950 | struct ch_avoid_ind_type *channel_list; |
Jeff Johnson | 2e60a14 | 2018-05-20 12:08:12 -0700 | [diff] [blame] | 8951 | enum QDF_GLOBAL_MODE curr_mode; |
Ashish Kumar Dhanotiya | 7e345d0 | 2018-06-28 12:43:41 +0530 | [diff] [blame] | 8952 | uint8_t num_args = 0; |
hqu | bf1b618 | 2018-08-14 17:22:41 +0800 | [diff] [blame] | 8953 | bool user_set_avoid_channel = true; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8954 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8955 | hdd_enter_dev(wdev->netdev); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8956 | |
| 8957 | if (!qdf_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 8958 | hdd_err("qdf_ctx is NULL"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8959 | return -EINVAL; |
| 8960 | } |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 8961 | curr_mode = hdd_get_conparam(); |
| 8962 | if (QDF_GLOBAL_FTM_MODE == curr_mode || |
| 8963 | QDF_GLOBAL_MONITOR_MODE == curr_mode) { |
| 8964 | hdd_err("Command not allowed in FTM/MONITOR mode"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8965 | return -EINVAL; |
| 8966 | } |
| 8967 | |
| 8968 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8969 | if (0 != ret) |
| 8970 | return ret; |
hqu | bf1b618 | 2018-08-14 17:22:41 +0800 | [diff] [blame] | 8971 | if (!data && data_len == 0) { |
| 8972 | hdd_debug("Userspace doesn't set avoid frequency channel list"); |
| 8973 | user_set_avoid_channel = false; |
| 8974 | goto process_unsafe_channel; |
| 8975 | } |
Ashish Kumar Dhanotiya | 7e345d0 | 2018-06-28 12:43:41 +0530 | [diff] [blame] | 8976 | if (!data || data_len < (sizeof(channel_list->ch_avoid_range_cnt) + |
| 8977 | sizeof(struct ch_avoid_freq_type))) { |
| 8978 | hdd_err("Avoid frequency channel list empty"); |
| 8979 | return -EINVAL; |
| 8980 | } |
| 8981 | num_args = (data_len - sizeof(channel_list->ch_avoid_range_cnt)) / |
| 8982 | sizeof(channel_list->avoid_freq_range[0].start_freq); |
| 8983 | |
| 8984 | if (num_args < 2 || num_args > CH_AVOID_MAX_RANGE * 2 || |
| 8985 | num_args % 2 != 0) { |
| 8986 | hdd_err("Invalid avoid frequency channel list"); |
| 8987 | return -EINVAL; |
| 8988 | } |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 8989 | |
| 8990 | channel_list = (struct ch_avoid_ind_type *)data; |
Ashish Kumar Dhanotiya | 7e345d0 | 2018-06-28 12:43:41 +0530 | [diff] [blame] | 8991 | if (channel_list->ch_avoid_range_cnt == 0 || |
| 8992 | channel_list->ch_avoid_range_cnt > CH_AVOID_MAX_RANGE || |
| 8993 | 2 * channel_list->ch_avoid_range_cnt != num_args) { |
| 8994 | hdd_err("Invalid frequency range count %d", |
| 8995 | channel_list->ch_avoid_range_cnt); |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 8996 | return -EINVAL; |
| 8997 | } |
| 8998 | |
hqu | bf1b618 | 2018-08-14 17:22:41 +0800 | [diff] [blame] | 8999 | process_unsafe_channel: |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 9000 | ret = hdd_clone_local_unsafe_chan(hdd_ctx, |
| 9001 | &local_unsafe_list, |
| 9002 | &local_unsafe_list_count); |
| 9003 | if (0 != ret) { |
| 9004 | hdd_err("failed to clone the cur unsafe chan list"); |
| 9005 | return ret; |
| 9006 | } |
| 9007 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 9008 | pld_get_wlan_unsafe_channel(qdf_ctx->dev, hdd_ctx->unsafe_channel_list, |
| 9009 | &(hdd_ctx->unsafe_channel_count), |
| 9010 | sizeof(hdd_ctx->unsafe_channel_list)); |
hqu | bf1b618 | 2018-08-14 17:22:41 +0800 | [diff] [blame] | 9011 | if (user_set_avoid_channel) { |
| 9012 | hdd_ctx->unsafe_channel_count = |
| 9013 | hdd_validate_avoid_freq_chanlist( |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 9014 | hdd_ctx, |
| 9015 | channel_list); |
hqu | bf1b618 | 2018-08-14 17:22:41 +0800 | [diff] [blame] | 9016 | unsafe_channel_count = hdd_ctx->unsafe_channel_count; |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 9017 | |
hqu | bf1b618 | 2018-08-14 17:22:41 +0800 | [diff] [blame] | 9018 | pld_set_wlan_unsafe_channel(qdf_ctx->dev, |
| 9019 | hdd_ctx->unsafe_channel_list, |
| 9020 | hdd_ctx->unsafe_channel_count); |
| 9021 | } else { |
| 9022 | unsafe_channel_count = QDF_MIN( |
| 9023 | (uint16_t)hdd_ctx->unsafe_channel_count, |
| 9024 | (uint16_t)NUM_CHANNELS); |
| 9025 | } |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 9026 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 9027 | for (unsafe_channel_index = 0; |
hqu | bf1b618 | 2018-08-14 17:22:41 +0800 | [diff] [blame] | 9028 | unsafe_channel_index < unsafe_channel_count; |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 9029 | unsafe_channel_index++) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9030 | hdd_debug("Channel %d is not safe", |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 9031 | hdd_ctx->unsafe_channel_list[unsafe_channel_index]); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 9032 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 9033 | if (hdd_local_unsafe_channel_updated(hdd_ctx, local_unsafe_list, |
| 9034 | local_unsafe_list_count)) |
| 9035 | hdd_unsafe_channel_restart_sap(hdd_ctx); |
| 9036 | qdf_mem_free(local_unsafe_list); |
| 9037 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 9038 | return 0; |
| 9039 | } |
| 9040 | |
| 9041 | /** |
| 9042 | * wlan_hdd_cfg80211_avoid_freq() - ask driver to restart SAP if SAP |
| 9043 | * is on unsafe channel. |
| 9044 | * @wiphy: wiphy structure pointer |
| 9045 | * @wdev: Wireless device structure pointer |
| 9046 | * @data: Pointer to the data received |
| 9047 | * @data_len: Length of @data |
| 9048 | * |
| 9049 | * wlan_hdd_cfg80211_avoid_freq do restart the sap if sap is already |
| 9050 | * on any of unsafe channels. |
| 9051 | * If sap is on any of unsafe channel, hdd_unsafe_channel_restart_sap |
| 9052 | * will send WLAN_SVC_LTE_COEX_IND indication to userspace to restart. |
| 9053 | * |
| 9054 | * Return: 0 on success; errno on failure |
| 9055 | */ |
| 9056 | static int wlan_hdd_cfg80211_avoid_freq(struct wiphy *wiphy, |
| 9057 | struct wireless_dev *wdev, |
| 9058 | const void *data, int data_len) |
| 9059 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9060 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9061 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 9062 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9063 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9064 | if (errno) |
| 9065 | return errno; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 9066 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9067 | errno = __wlan_hdd_cfg80211_avoid_freq(wiphy, wdev, data, data_len); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 9068 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9069 | osif_psoc_sync_op_stop(psoc_sync); |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 9070 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9071 | return errno; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 9072 | } |
| 9073 | |
| 9074 | #endif |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 9075 | /** |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9076 | * __wlan_hdd_cfg80211_sap_configuration_set() - ask driver to restart SAP if |
| 9077 | * SAP is on unsafe channel. |
| 9078 | * @wiphy: wiphy structure pointer |
| 9079 | * @wdev: Wireless device structure pointer |
| 9080 | * @data: Pointer to the data received |
| 9081 | * @data_len: Length of @data |
| 9082 | * |
| 9083 | * __wlan_hdd_cfg80211_sap_configuration_set function set SAP params to |
| 9084 | * driver. |
| 9085 | * QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHAN will set sap config channel and |
| 9086 | * will initiate restart of sap. |
| 9087 | * |
| 9088 | * Return: 0 on success; errno on failure |
| 9089 | */ |
| 9090 | static int |
| 9091 | __wlan_hdd_cfg80211_sap_configuration_set(struct wiphy *wiphy, |
| 9092 | struct wireless_dev *wdev, |
| 9093 | const void *data, int data_len) |
| 9094 | { |
| 9095 | struct net_device *ndev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9096 | struct hdd_adapter *hostapd_adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9097 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9098 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_MAX + 1]; |
| 9099 | uint8_t config_channel = 0; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 9100 | struct hdd_ap_ctx *ap_ctx; |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9101 | int ret; |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 9102 | QDF_STATUS status; |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9103 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9104 | hdd_enter(); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9105 | |
| 9106 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9107 | hdd_err("Command not allowed in FTM mode"); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9108 | return -EINVAL; |
| 9109 | } |
| 9110 | |
| 9111 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9112 | if (0 != ret) |
| 9113 | return -EINVAL; |
| 9114 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 9115 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_MAX, |
| 9116 | data, data_len, |
| 9117 | wlan_hdd_sap_config_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9118 | hdd_err("invalid attr"); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9119 | return -EINVAL; |
| 9120 | } |
| 9121 | |
| 9122 | if (tb[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHANNEL]) { |
| 9123 | if (!test_bit(SOFTAP_BSS_STARTED, |
| 9124 | &hostapd_adapter->event_flags)) { |
| 9125 | hdd_err("SAP is not started yet. Restart sap will be invalid"); |
| 9126 | return -EINVAL; |
| 9127 | } |
| 9128 | |
| 9129 | config_channel = |
| 9130 | nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHANNEL]); |
| 9131 | |
| 9132 | if (!((IS_24G_CH(config_channel)) || |
| 9133 | (IS_5G_CH(config_channel)))) { |
| 9134 | hdd_err("Channel %d is not valid to restart SAP", |
| 9135 | config_channel); |
| 9136 | return -ENOTSUPP; |
| 9137 | } |
| 9138 | |
| 9139 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(hostapd_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 9140 | ap_ctx->sap_config.channel = config_channel; |
| 9141 | ap_ctx->sap_config.ch_params.ch_width = |
| 9142 | ap_ctx->sap_config.ch_width_orig; |
hqu | 73bccf2 | 2017-10-28 15:34:17 +0800 | [diff] [blame] | 9143 | ap_ctx->bss_stop_reason = BSS_STOP_DUE_TO_VENDOR_CONFIG_CHAN; |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9144 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 9145 | wlan_reg_set_channel_params(hdd_ctx->pdev, |
| 9146 | ap_ctx->sap_config.channel, |
| 9147 | ap_ctx->sap_config.sec_ch, |
| 9148 | &ap_ctx->sap_config.ch_params); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9149 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 9150 | hdd_restart_sap(hostapd_adapter); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9151 | } |
| 9152 | |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 9153 | if (tb[QCA_WLAN_VENDOR_ATTR_SAP_MANDATORY_FREQUENCY_LIST]) { |
| 9154 | uint32_t freq_len, i; |
| 9155 | uint32_t *freq; |
| 9156 | uint8_t chans[QDF_MAX_NUM_CHAN]; |
| 9157 | |
| 9158 | hdd_debug("setting mandatory freq/chan list"); |
| 9159 | |
| 9160 | freq_len = nla_len( |
| 9161 | tb[QCA_WLAN_VENDOR_ATTR_SAP_MANDATORY_FREQUENCY_LIST])/ |
| 9162 | sizeof(uint32_t); |
| 9163 | |
| 9164 | if (freq_len > QDF_MAX_NUM_CHAN) { |
| 9165 | hdd_err("insufficient space to hold channels"); |
| 9166 | return -ENOMEM; |
| 9167 | } |
| 9168 | |
| 9169 | freq = nla_data( |
| 9170 | tb[QCA_WLAN_VENDOR_ATTR_SAP_MANDATORY_FREQUENCY_LIST]); |
| 9171 | |
| 9172 | hdd_debug("freq_len=%d", freq_len); |
| 9173 | |
| 9174 | for (i = 0; i < freq_len; i++) { |
| 9175 | chans[i] = ieee80211_frequency_to_channel(freq[i]); |
| 9176 | hdd_debug("freq[%d]=%d", i, freq[i]); |
| 9177 | } |
| 9178 | |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 9179 | status = policy_mgr_set_sap_mandatory_channels( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 9180 | hdd_ctx->psoc, chans, freq_len); |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 9181 | if (QDF_IS_STATUS_ERROR(status)) |
| 9182 | return -EINVAL; |
| 9183 | } |
| 9184 | |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9185 | return 0; |
| 9186 | } |
| 9187 | |
| 9188 | /** |
| 9189 | * wlan_hdd_cfg80211_sap_configuration_set() - sap configuration vendor command |
| 9190 | * @wiphy: wiphy structure pointer |
| 9191 | * @wdev: Wireless device structure pointer |
| 9192 | * @data: Pointer to the data received |
| 9193 | * @data_len: Length of @data |
| 9194 | * |
| 9195 | * __wlan_hdd_cfg80211_sap_configuration_set function set SAP params to |
| 9196 | * driver. |
| 9197 | * QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHAN will set sap config channel and |
| 9198 | * will initiate restart of sap. |
| 9199 | * |
| 9200 | * Return: 0 on success; errno on failure |
| 9201 | */ |
| 9202 | static int wlan_hdd_cfg80211_sap_configuration_set(struct wiphy *wiphy, |
| 9203 | struct wireless_dev *wdev, |
| 9204 | const void *data, int data_len) |
| 9205 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 9206 | int errno; |
| 9207 | struct osif_vdev_sync *vdev_sync; |
| 9208 | |
| 9209 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 9210 | if (errno) |
| 9211 | return errno; |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9212 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 9213 | errno = __wlan_hdd_cfg80211_sap_configuration_set(wiphy, wdev, |
| 9214 | data, data_len); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9215 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 9216 | osif_vdev_sync_op_stop(vdev_sync); |
| 9217 | |
| 9218 | return errno; |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 9219 | } |
| 9220 | |
Naveen Rawat | 3ff5cff | 2018-01-29 14:31:16 -0800 | [diff] [blame] | 9221 | #ifndef QCA_SUPPORT_CP_STATS |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9222 | /** |
| 9223 | * define short names for the global vendor params |
| 9224 | * used by wlan_hdd_cfg80211_wakelock_stats_rsp_callback() |
| 9225 | */ |
| 9226 | #define PARAM_TOTAL_CMD_EVENT_WAKE \ |
| 9227 | QCA_WLAN_VENDOR_ATTR_TOTAL_CMD_EVENT_WAKE |
| 9228 | #define PARAM_CMD_EVENT_WAKE_CNT_PTR \ |
| 9229 | QCA_WLAN_VENDOR_ATTR_CMD_EVENT_WAKE_CNT_PTR |
| 9230 | #define PARAM_CMD_EVENT_WAKE_CNT_SZ \ |
| 9231 | QCA_WLAN_VENDOR_ATTR_CMD_EVENT_WAKE_CNT_SZ |
| 9232 | #define PARAM_TOTAL_DRIVER_FW_LOCAL_WAKE \ |
| 9233 | QCA_WLAN_VENDOR_ATTR_TOTAL_DRIVER_FW_LOCAL_WAKE |
| 9234 | #define PARAM_DRIVER_FW_LOCAL_WAKE_CNT_PTR \ |
| 9235 | QCA_WLAN_VENDOR_ATTR_DRIVER_FW_LOCAL_WAKE_CNT_PTR |
| 9236 | #define PARAM_DRIVER_FW_LOCAL_WAKE_CNT_SZ \ |
| 9237 | QCA_WLAN_VENDOR_ATTR_DRIVER_FW_LOCAL_WAKE_CNT_SZ |
| 9238 | #define PARAM_TOTAL_RX_DATA_WAKE \ |
| 9239 | QCA_WLAN_VENDOR_ATTR_TOTAL_RX_DATA_WAKE |
| 9240 | #define PARAM_RX_UNICAST_CNT \ |
| 9241 | QCA_WLAN_VENDOR_ATTR_RX_UNICAST_CNT |
| 9242 | #define PARAM_RX_MULTICAST_CNT \ |
| 9243 | QCA_WLAN_VENDOR_ATTR_RX_MULTICAST_CNT |
| 9244 | #define PARAM_RX_BROADCAST_CNT \ |
| 9245 | QCA_WLAN_VENDOR_ATTR_RX_BROADCAST_CNT |
| 9246 | #define PARAM_ICMP_PKT \ |
| 9247 | QCA_WLAN_VENDOR_ATTR_ICMP_PKT |
| 9248 | #define PARAM_ICMP6_PKT \ |
| 9249 | QCA_WLAN_VENDOR_ATTR_ICMP6_PKT |
| 9250 | #define PARAM_ICMP6_RA \ |
| 9251 | QCA_WLAN_VENDOR_ATTR_ICMP6_RA |
| 9252 | #define PARAM_ICMP6_NA \ |
| 9253 | QCA_WLAN_VENDOR_ATTR_ICMP6_NA |
| 9254 | #define PARAM_ICMP6_NS \ |
| 9255 | QCA_WLAN_VENDOR_ATTR_ICMP6_NS |
| 9256 | #define PARAM_ICMP4_RX_MULTICAST_CNT \ |
| 9257 | QCA_WLAN_VENDOR_ATTR_ICMP4_RX_MULTICAST_CNT |
| 9258 | #define PARAM_ICMP6_RX_MULTICAST_CNT \ |
| 9259 | QCA_WLAN_VENDOR_ATTR_ICMP6_RX_MULTICAST_CNT |
| 9260 | #define PARAM_OTHER_RX_MULTICAST_CNT \ |
| 9261 | QCA_WLAN_VENDOR_ATTR_OTHER_RX_MULTICAST_CNT |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 9262 | #define PARAM_RSSI_BREACH_CNT \ |
| 9263 | QCA_WLAN_VENDOR_ATTR_RSSI_BREACH_CNT |
| 9264 | #define PARAM_LOW_RSSI_CNT \ |
| 9265 | QCA_WLAN_VENDOR_ATTR_LOW_RSSI_CNT |
| 9266 | #define PARAM_GSCAN_CNT \ |
| 9267 | QCA_WLAN_VENDOR_ATTR_GSCAN_CNT |
| 9268 | #define PARAM_PNO_COMPLETE_CNT \ |
| 9269 | QCA_WLAN_VENDOR_ATTR_PNO_COMPLETE_CNT |
| 9270 | #define PARAM_PNO_MATCH_CNT \ |
| 9271 | QCA_WLAN_VENDOR_ATTR_PNO_MATCH_CNT |
| 9272 | |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9273 | /** |
| 9274 | * hdd_send_wakelock_stats() - API to send wakelock stats |
| 9275 | * @ctx: context to be passed to callback |
| 9276 | * @data: data passed to callback |
| 9277 | * |
| 9278 | * This function is used to send wake lock stats to HAL layer |
| 9279 | * |
| 9280 | * Return: 0 on success, error number otherwise. |
| 9281 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9282 | static uint32_t hdd_send_wakelock_stats(struct hdd_context *hdd_ctx, |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9283 | const struct sir_wake_lock_stats *data) |
| 9284 | { |
| 9285 | struct sk_buff *skb; |
| 9286 | uint32_t nl_buf_len; |
| 9287 | uint32_t total_rx_data_wake, rx_multicast_cnt; |
| 9288 | uint32_t ipv6_rx_multicast_addr_cnt; |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 9289 | uint32_t icmpv6_cnt; |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9290 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9291 | hdd_enter(); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9292 | |
| 9293 | nl_buf_len = NLMSG_HDRLEN; |
| 9294 | nl_buf_len += |
| 9295 | QCA_WLAN_VENDOR_GET_WAKE_STATS_MAX * |
| 9296 | (NLMSG_HDRLEN + sizeof(uint32_t)); |
| 9297 | |
| 9298 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 9299 | |
| 9300 | if (!skb) { |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 9301 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9302 | return -ENOMEM; |
| 9303 | } |
| 9304 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9305 | hdd_debug("wow_ucast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9306 | data->wow_ucast_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9307 | hdd_debug("wow_bcast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9308 | data->wow_bcast_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9309 | hdd_debug("wow_ipv4_mcast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9310 | data->wow_ipv4_mcast_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9311 | hdd_debug("wow_ipv6_mcast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9312 | data->wow_ipv6_mcast_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9313 | hdd_debug("wow_ipv6_mcast_ra_stats %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9314 | data->wow_ipv6_mcast_ra_stats); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9315 | hdd_debug("wow_ipv6_mcast_ns_stats %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9316 | data->wow_ipv6_mcast_ns_stats); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9317 | hdd_debug("wow_ipv6_mcast_na_stats %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9318 | data->wow_ipv6_mcast_na_stats); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9319 | hdd_debug("wow_icmpv4_count %d", data->wow_icmpv4_count); |
| 9320 | hdd_debug("wow_icmpv6_count %d", |
Himanshu Agarwal | 4574e28 | 2016-08-10 15:22:45 +0530 | [diff] [blame] | 9321 | data->wow_icmpv6_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9322 | hdd_debug("wow_rssi_breach_wake_up_count %d", |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 9323 | data->wow_rssi_breach_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9324 | hdd_debug("wow_low_rssi_wake_up_count %d", |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 9325 | data->wow_low_rssi_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9326 | hdd_debug("wow_gscan_wake_up_count %d", |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 9327 | data->wow_gscan_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9328 | hdd_debug("wow_pno_complete_wake_up_count %d", |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 9329 | data->wow_pno_complete_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9330 | hdd_debug("wow_pno_match_wake_up_count %d", |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 9331 | data->wow_pno_match_wake_up_count); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9332 | |
| 9333 | ipv6_rx_multicast_addr_cnt = |
Himanshu Agarwal | 4574e28 | 2016-08-10 15:22:45 +0530 | [diff] [blame] | 9334 | data->wow_ipv6_mcast_wake_up_count; |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9335 | |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 9336 | icmpv6_cnt = |
Himanshu Agarwal | 4574e28 | 2016-08-10 15:22:45 +0530 | [diff] [blame] | 9337 | data->wow_icmpv6_count; |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 9338 | |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9339 | rx_multicast_cnt = |
| 9340 | data->wow_ipv4_mcast_wake_up_count + |
| 9341 | ipv6_rx_multicast_addr_cnt; |
| 9342 | |
| 9343 | total_rx_data_wake = |
| 9344 | data->wow_ucast_wake_up_count + |
| 9345 | data->wow_bcast_wake_up_count + |
| 9346 | rx_multicast_cnt; |
| 9347 | |
| 9348 | if (nla_put_u32(skb, PARAM_TOTAL_CMD_EVENT_WAKE, 0) || |
| 9349 | nla_put_u32(skb, PARAM_CMD_EVENT_WAKE_CNT_PTR, 0) || |
| 9350 | nla_put_u32(skb, PARAM_CMD_EVENT_WAKE_CNT_SZ, 0) || |
| 9351 | nla_put_u32(skb, PARAM_TOTAL_DRIVER_FW_LOCAL_WAKE, 0) || |
| 9352 | nla_put_u32(skb, PARAM_DRIVER_FW_LOCAL_WAKE_CNT_PTR, 0) || |
| 9353 | nla_put_u32(skb, PARAM_DRIVER_FW_LOCAL_WAKE_CNT_SZ, 0) || |
| 9354 | nla_put_u32(skb, PARAM_TOTAL_RX_DATA_WAKE, |
| 9355 | total_rx_data_wake) || |
| 9356 | nla_put_u32(skb, PARAM_RX_UNICAST_CNT, |
| 9357 | data->wow_ucast_wake_up_count) || |
| 9358 | nla_put_u32(skb, PARAM_RX_MULTICAST_CNT, |
| 9359 | rx_multicast_cnt) || |
| 9360 | nla_put_u32(skb, PARAM_RX_BROADCAST_CNT, |
| 9361 | data->wow_bcast_wake_up_count) || |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 9362 | nla_put_u32(skb, PARAM_ICMP_PKT, |
| 9363 | data->wow_icmpv4_count) || |
| 9364 | nla_put_u32(skb, PARAM_ICMP6_PKT, |
| 9365 | icmpv6_cnt) || |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9366 | nla_put_u32(skb, PARAM_ICMP6_RA, |
| 9367 | data->wow_ipv6_mcast_ra_stats) || |
| 9368 | nla_put_u32(skb, PARAM_ICMP6_NA, |
| 9369 | data->wow_ipv6_mcast_na_stats) || |
| 9370 | nla_put_u32(skb, PARAM_ICMP6_NS, |
| 9371 | data->wow_ipv6_mcast_ns_stats) || |
| 9372 | nla_put_u32(skb, PARAM_ICMP4_RX_MULTICAST_CNT, |
| 9373 | data->wow_ipv4_mcast_wake_up_count) || |
| 9374 | nla_put_u32(skb, PARAM_ICMP6_RX_MULTICAST_CNT, |
| 9375 | ipv6_rx_multicast_addr_cnt) || |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 9376 | nla_put_u32(skb, PARAM_OTHER_RX_MULTICAST_CNT, 0) || |
| 9377 | nla_put_u32(skb, PARAM_RSSI_BREACH_CNT, |
| 9378 | data->wow_rssi_breach_wake_up_count) || |
| 9379 | nla_put_u32(skb, PARAM_LOW_RSSI_CNT, |
| 9380 | data->wow_low_rssi_wake_up_count) || |
| 9381 | nla_put_u32(skb, PARAM_GSCAN_CNT, |
| 9382 | data->wow_gscan_wake_up_count) || |
| 9383 | nla_put_u32(skb, PARAM_PNO_COMPLETE_CNT, |
| 9384 | data->wow_pno_complete_wake_up_count) || |
| 9385 | nla_put_u32(skb, PARAM_PNO_MATCH_CNT, |
| 9386 | data->wow_pno_match_wake_up_count)) { |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 9387 | hdd_err("nla put fail"); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9388 | goto nla_put_failure; |
| 9389 | } |
| 9390 | |
| 9391 | cfg80211_vendor_cmd_reply(skb); |
| 9392 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9393 | hdd_exit(); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9394 | return 0; |
| 9395 | |
| 9396 | nla_put_failure: |
| 9397 | kfree_skb(skb); |
| 9398 | return -EINVAL; |
| 9399 | } |
Naveen Rawat | 3ff5cff | 2018-01-29 14:31:16 -0800 | [diff] [blame] | 9400 | #endif |
| 9401 | |
| 9402 | #ifdef QCA_SUPPORT_CP_STATS |
| 9403 | static int wlan_hdd_process_wake_lock_stats(struct hdd_context *hdd_ctx) |
| 9404 | { |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 9405 | return wlan_cfg80211_mc_cp_stats_get_wakelock_stats(hdd_ctx->psoc, |
Naveen Rawat | 3ff5cff | 2018-01-29 14:31:16 -0800 | [diff] [blame] | 9406 | hdd_ctx->wiphy); |
| 9407 | } |
| 9408 | #else |
| 9409 | /** |
| 9410 | * wlan_hdd_process_wake_lock_stats() - wrapper function to absract cp_stats |
| 9411 | * or legacy get_wake_lock_stats API. |
| 9412 | * @hdd_ctx: pointer to hdd_ctx |
| 9413 | * |
| 9414 | * Return: 0 on success; error number otherwise. |
| 9415 | */ |
| 9416 | static int wlan_hdd_process_wake_lock_stats(struct hdd_context *hdd_ctx) |
| 9417 | { |
| 9418 | int ret; |
| 9419 | QDF_STATUS qdf_status; |
| 9420 | struct sir_wake_lock_stats wake_lock_stats = {0}; |
| 9421 | |
| 9422 | qdf_status = wma_get_wakelock_stats(&wake_lock_stats); |
| 9423 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 9424 | hdd_err("failed to get wakelock stats(err=%d)", qdf_status); |
| 9425 | return -EINVAL; |
| 9426 | } |
| 9427 | |
| 9428 | ret = hdd_send_wakelock_stats(hdd_ctx, &wake_lock_stats); |
| 9429 | if (ret) |
| 9430 | hdd_err("Failed to post wake lock stats"); |
| 9431 | |
| 9432 | return ret; |
| 9433 | } |
| 9434 | #endif |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9435 | |
| 9436 | /** |
| 9437 | * __wlan_hdd_cfg80211_get_wakelock_stats() - gets wake lock stats |
| 9438 | * @wiphy: wiphy pointer |
| 9439 | * @wdev: pointer to struct wireless_dev |
| 9440 | * @data: pointer to incoming NL vendor data |
| 9441 | * @data_len: length of @data |
| 9442 | * |
| 9443 | * This function parses the incoming NL vendor command data attributes and |
| 9444 | * invokes the SME Api and blocks on a completion variable. |
| 9445 | * WMA copies required data and invokes callback |
| 9446 | * wlan_hdd_cfg80211_wakelock_stats_rsp_callback to send wake lock stats. |
| 9447 | * |
| 9448 | * Return: 0 on success; error number otherwise. |
| 9449 | */ |
| 9450 | static int __wlan_hdd_cfg80211_get_wakelock_stats(struct wiphy *wiphy, |
| 9451 | struct wireless_dev *wdev, |
| 9452 | const void *data, |
| 9453 | int data_len) |
| 9454 | { |
Naveen Rawat | 3ff5cff | 2018-01-29 14:31:16 -0800 | [diff] [blame] | 9455 | int ret; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9456 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9457 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9458 | hdd_enter(); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9459 | |
| 9460 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 9461 | hdd_err("Command not allowed in FTM mode"); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9462 | return -EINVAL; |
| 9463 | } |
| 9464 | |
Naveen Rawat | 3ff5cff | 2018-01-29 14:31:16 -0800 | [diff] [blame] | 9465 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9466 | if (0 != ret) |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9467 | return -EINVAL; |
| 9468 | |
Naveen Rawat | 3ff5cff | 2018-01-29 14:31:16 -0800 | [diff] [blame] | 9469 | ret = wlan_hdd_process_wake_lock_stats(hdd_ctx); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9470 | hdd_exit(); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9471 | return ret; |
| 9472 | } |
| 9473 | |
| 9474 | /** |
| 9475 | * wlan_hdd_cfg80211_get_wakelock_stats() - gets wake lock stats |
| 9476 | * @wiphy: wiphy pointer |
| 9477 | * @wdev: pointer to struct wireless_dev |
| 9478 | * @data: pointer to incoming NL vendor data |
| 9479 | * @data_len: length of @data |
| 9480 | * |
| 9481 | * This function parses the incoming NL vendor command data attributes and |
| 9482 | * invokes the SME Api and blocks on a completion variable. |
| 9483 | * WMA copies required data and invokes callback |
| 9484 | * wlan_hdd_cfg80211_wakelock_stats_rsp_callback to send wake lock stats. |
| 9485 | * |
| 9486 | * Return: 0 on success; error number otherwise. |
| 9487 | */ |
| 9488 | static int wlan_hdd_cfg80211_get_wakelock_stats(struct wiphy *wiphy, |
| 9489 | struct wireless_dev *wdev, |
| 9490 | const void *data, int data_len) |
| 9491 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9492 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9493 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 9494 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9495 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9496 | if (errno) |
| 9497 | return errno; |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9498 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9499 | errno = __wlan_hdd_cfg80211_get_wakelock_stats(wiphy, wdev, |
| 9500 | data, data_len); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9501 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9502 | osif_psoc_sync_op_stop(psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9503 | |
| 9504 | return errno; |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 9505 | } |
| 9506 | |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 9507 | /** |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 9508 | * __wlan_hdd_cfg80211_get_bus_size() - Get WMI Bus size |
| 9509 | * @wiphy: wiphy structure pointer |
| 9510 | * @wdev: Wireless device structure pointer |
| 9511 | * @data: Pointer to the data received |
| 9512 | * @data_len: Length of @data |
| 9513 | * |
| 9514 | * This function reads wmi max bus size and fill in the skb with |
| 9515 | * NL attributes and send up the NL event. |
| 9516 | * Return: 0 on success; errno on failure |
| 9517 | */ |
| 9518 | static int |
| 9519 | __wlan_hdd_cfg80211_get_bus_size(struct wiphy *wiphy, |
| 9520 | struct wireless_dev *wdev, |
| 9521 | const void *data, int data_len) |
| 9522 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9523 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 9524 | int ret_val; |
| 9525 | struct sk_buff *skb; |
| 9526 | uint32_t nl_buf_len; |
| 9527 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9528 | hdd_enter(); |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 9529 | |
| 9530 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 9531 | if (ret_val) |
| 9532 | return ret_val; |
| 9533 | |
| 9534 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 9535 | hdd_err("Command not allowed in FTM mode"); |
| 9536 | return -EINVAL; |
| 9537 | } |
| 9538 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9539 | hdd_debug("WMI Max Bus size: %d", hdd_ctx->wmi_max_len); |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 9540 | |
| 9541 | nl_buf_len = NLMSG_HDRLEN; |
| 9542 | nl_buf_len += (sizeof(hdd_ctx->wmi_max_len) + NLA_HDRLEN); |
| 9543 | |
| 9544 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 9545 | if (!skb) { |
| 9546 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
| 9547 | return -ENOMEM; |
| 9548 | } |
| 9549 | |
| 9550 | if (nla_put_u16(skb, QCA_WLAN_VENDOR_ATTR_DRV_INFO_BUS_SIZE, |
| 9551 | hdd_ctx->wmi_max_len)) { |
| 9552 | hdd_err("nla put failure"); |
| 9553 | goto nla_put_failure; |
| 9554 | } |
| 9555 | |
| 9556 | cfg80211_vendor_cmd_reply(skb); |
| 9557 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9558 | hdd_exit(); |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 9559 | |
| 9560 | return 0; |
| 9561 | |
| 9562 | nla_put_failure: |
| 9563 | kfree_skb(skb); |
| 9564 | return -EINVAL; |
| 9565 | } |
| 9566 | |
| 9567 | /** |
| 9568 | * wlan_hdd_cfg80211_get_bus_size() - SSR Wrapper to Get Bus size |
| 9569 | * @wiphy: wiphy structure pointer |
| 9570 | * @wdev: Wireless device structure pointer |
| 9571 | * @data: Pointer to the data received |
| 9572 | * @data_len: Length of @data |
| 9573 | * |
| 9574 | * Return: 0 on success; errno on failure |
| 9575 | */ |
| 9576 | static int wlan_hdd_cfg80211_get_bus_size(struct wiphy *wiphy, |
| 9577 | struct wireless_dev *wdev, |
| 9578 | const void *data, int data_len) |
| 9579 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9580 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9581 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 9582 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9583 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9584 | if (errno) |
| 9585 | return errno; |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 9586 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9587 | errno = __wlan_hdd_cfg80211_get_bus_size(wiphy, wdev, data, data_len); |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 9588 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9589 | osif_psoc_sync_op_stop(psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 9590 | |
| 9591 | return errno; |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 9592 | } |
| 9593 | |
| 9594 | /** |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 9595 | *__wlan_hdd_cfg80211_setband() - set band |
| 9596 | * @wiphy: Pointer to wireless phy |
| 9597 | * @wdev: Pointer to wireless device |
| 9598 | * @data: Pointer to data |
| 9599 | * @data_len: Length of @data |
| 9600 | * |
| 9601 | * Return: 0 on success, negative errno on failure |
| 9602 | */ |
| 9603 | static int __wlan_hdd_cfg80211_setband(struct wiphy *wiphy, |
| 9604 | struct wireless_dev *wdev, |
| 9605 | const void *data, int data_len) |
| 9606 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9607 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 9608 | struct net_device *dev = wdev->netdev; |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 9609 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1]; |
| 9610 | int ret; |
| 9611 | static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1] |
| 9612 | = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 } }; |
| 9613 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9614 | hdd_enter(); |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 9615 | |
| 9616 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9617 | if (ret) |
| 9618 | return ret; |
| 9619 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 9620 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, |
| 9621 | data, data_len, policy)) { |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 9622 | hdd_err("Invalid ATTR"); |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 9623 | return -EINVAL; |
| 9624 | } |
| 9625 | |
| 9626 | if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) { |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 9627 | hdd_err("attr SETBAND_VALUE failed"); |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 9628 | return -EINVAL; |
| 9629 | } |
| 9630 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 9631 | ret = hdd_reg_set_band(dev, |
| 9632 | nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE])); |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 9633 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9634 | hdd_exit(); |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 9635 | return ret; |
| 9636 | } |
| 9637 | |
| 9638 | /** |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 9639 | *wlan_hdd_validate_acs_channel() - validate channel provided by ACS |
| 9640 | * @adapter: hdd adapter |
| 9641 | * @channel: channel number |
| 9642 | * |
| 9643 | * return: QDF status based on success or failure |
| 9644 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9645 | static QDF_STATUS wlan_hdd_validate_acs_channel(struct hdd_adapter *adapter, |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 9646 | int channel, int chan_bw) |
| 9647 | { |
| 9648 | if (QDF_STATUS_SUCCESS != |
| 9649 | wlan_hdd_validate_operation_channel(adapter, channel)) |
| 9650 | return QDF_STATUS_E_FAILURE; |
| 9651 | if ((wlansap_is_channel_in_nol_list(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9652 | channel, |
| 9653 | PHY_SINGLE_CHANNEL_CENTERED))) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 9654 | hdd_info("channel %d is in nol", channel); |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 9655 | return -EINVAL; |
| 9656 | } |
| 9657 | |
| 9658 | if ((wlansap_is_channel_leaking_in_nol( |
| 9659 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9660 | channel, chan_bw))) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 9661 | hdd_info("channel %d is leaking in nol", channel); |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 9662 | return -EINVAL; |
| 9663 | } |
| 9664 | |
| 9665 | return 0; |
| 9666 | |
| 9667 | } |
| 9668 | |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9669 | static void hdd_update_acs_sap_config(struct hdd_context *hdd_ctx, |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 9670 | tsap_config_t *sap_config, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9671 | struct hdd_vendor_chan_info *channel_list) |
| 9672 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 9673 | uint8_t ch_width; |
| 9674 | QDF_STATUS status; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 9675 | uint32_t channel_bonding_mode; |
| 9676 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9677 | sap_config->channel = channel_list->pri_ch; |
| 9678 | |
| 9679 | sap_config->ch_params.center_freq_seg0 = |
| 9680 | channel_list->vht_seg0_center_ch; |
| 9681 | sap_config->ch_params.center_freq_seg1 = |
| 9682 | channel_list->vht_seg1_center_ch; |
| 9683 | |
| 9684 | sap_config->ch_params.sec_ch_offset = channel_list->ht_sec_ch; |
| 9685 | sap_config->ch_params.ch_width = channel_list->chan_width; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 9686 | if (sap_config->channel >= 36) { |
| 9687 | status = |
| 9688 | ucfg_mlme_get_vht_channel_width(hdd_ctx->psoc, |
| 9689 | &ch_width); |
| 9690 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9691 | hdd_err("Failed to set channel_width"); |
| 9692 | sap_config->ch_width_orig = ch_width; |
| 9693 | } else { |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 9694 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 9695 | &channel_bonding_mode); |
| 9696 | sap_config->ch_width_orig = channel_bonding_mode ? |
| 9697 | eHT_CHANNEL_WIDTH_40MHZ : eHT_CHANNEL_WIDTH_20MHZ; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 9698 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9699 | sap_config->acs_cfg.pri_ch = channel_list->pri_ch; |
| 9700 | sap_config->acs_cfg.ch_width = channel_list->chan_width; |
| 9701 | sap_config->acs_cfg.vht_seg0_center_ch = |
| 9702 | channel_list->vht_seg0_center_ch; |
| 9703 | sap_config->acs_cfg.vht_seg1_center_ch = |
| 9704 | channel_list->vht_seg1_center_ch; |
| 9705 | sap_config->acs_cfg.ht_sec_ch = channel_list->ht_sec_ch; |
| 9706 | } |
| 9707 | |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9708 | static int hdd_update_acs_channel(struct hdd_adapter *adapter, uint8_t reason, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9709 | uint8_t channel_cnt, |
| 9710 | struct hdd_vendor_chan_info *channel_list) |
| 9711 | { |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 9712 | tsap_config_t *sap_config; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 9713 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9714 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9715 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 9716 | mac_handle_t mac_handle; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9717 | |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 9718 | if (!channel_list) { |
| 9719 | hdd_err("channel_list is NULL"); |
| 9720 | return -EINVAL; |
| 9721 | } |
| 9722 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9723 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 9724 | sap_config = &adapter->session.ap.sap_config; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9725 | |
| 9726 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 9727 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9728 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 9729 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9730 | } |
| 9731 | |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 9732 | if (channel_list->pri_ch == 0) { |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9733 | /* Check mode, set default channel */ |
| 9734 | channel_list->pri_ch = 6; |
| 9735 | /* |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 9736 | * sap_select_default_oper_chan(mac_handle, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9737 | * sap_config->acs_cfg.hw_mode); |
| 9738 | */ |
| 9739 | } |
| 9740 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 9741 | mac_handle = hdd_ctx->mac_handle; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9742 | switch (reason) { |
| 9743 | /* SAP init case */ |
| 9744 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 9745 | hdd_update_acs_sap_config(hdd_ctx, sap_config, channel_list); |
| 9746 | /* Update Hostapd */ |
| 9747 | wlan_hdd_cfg80211_acs_ch_select_evt(adapter); |
| 9748 | break; |
| 9749 | |
| 9750 | /* DFS detected on current channel */ |
| 9751 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 9752 | wlan_sap_update_next_channel( |
| 9753 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9754 | channel_list->pri_ch, |
| 9755 | channel_list->chan_width); |
| 9756 | status = sme_update_new_channel_event( |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 9757 | mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 9758 | adapter->vdev_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9759 | break; |
| 9760 | |
| 9761 | /* LTE coex event on current channel */ |
| 9762 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 9763 | sap_config->acs_cfg.pri_ch = channel_list->pri_ch; |
| 9764 | sap_config->acs_cfg.ch_width = channel_list->chan_width; |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 9765 | hdd_ap_ctx->sap_config.ch_width_orig = |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9766 | channel_list->chan_width; |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 9767 | hdd_switch_sap_channel(adapter, sap_config->acs_cfg.pri_ch, |
| 9768 | true); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9769 | break; |
| 9770 | |
| 9771 | default: |
| 9772 | hdd_info("invalid reason for timer invoke"); |
| 9773 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9774 | hdd_exit(); |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 9775 | return qdf_status_to_os_return(status); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9776 | } |
| 9777 | |
| 9778 | /** |
| 9779 | * Define short name for vendor channel set config |
| 9780 | */ |
| 9781 | #define SET_CHAN_REASON QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_REASON |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9782 | #define SET_CHAN_CHAN_LIST QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_LIST |
| 9783 | #define SET_CHAN_PRIMARY_CHANNEL \ |
| 9784 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_PRIMARY |
| 9785 | #define SET_CHAN_SECONDARY_CHANNEL \ |
| 9786 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_SECONDARY |
| 9787 | #define SET_CHAN_SEG0_CENTER_CHANNEL \ |
| 9788 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_CENTER_SEG0 |
| 9789 | #define SET_CHAN_SEG1_CENTER_CHANNEL \ |
| 9790 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_CENTER_SEG1 |
| 9791 | #define SET_CHAN_CHANNEL_WIDTH \ |
| 9792 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_WIDTH |
| 9793 | #define SET_CHAN_MAX QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_MAX |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 9794 | #define SET_EXT_ACS_BAND QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_BAND |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9795 | |
| 9796 | /** |
| 9797 | * hdd_parse_vendor_acs_chan_config() - API to parse vendor acs channel config |
| 9798 | * @channel_list: pointer to hdd_vendor_chan_info |
| 9799 | * @reason: channel change reason |
| 9800 | * @channel_cnt: channel count |
| 9801 | * @data: data |
| 9802 | * @data_len: data len |
| 9803 | * |
| 9804 | * Return: 0 on success, negative errno on failure |
| 9805 | */ |
| 9806 | static int hdd_parse_vendor_acs_chan_config(struct hdd_vendor_chan_info |
| 9807 | **chan_list_ptr, uint8_t *reason, uint8_t *channel_cnt, |
| 9808 | const void *data, int data_len) |
| 9809 | { |
| 9810 | int rem, i = 0; |
| 9811 | struct nlattr *tb[SET_CHAN_MAX + 1]; |
| 9812 | struct nlattr *tb2[SET_CHAN_MAX + 1]; |
| 9813 | struct nlattr *curr_attr; |
| 9814 | struct hdd_vendor_chan_info *channel_list; |
| 9815 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 9816 | if (wlan_cfg80211_nla_parse(tb, SET_CHAN_MAX, data, data_len, NULL)) { |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9817 | hdd_err("Invalid ATTR"); |
| 9818 | return -EINVAL; |
| 9819 | } |
| 9820 | |
| 9821 | if (tb[SET_CHAN_REASON]) |
| 9822 | *reason = nla_get_u8(tb[SET_CHAN_REASON]); |
| 9823 | |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 9824 | nla_for_each_nested(curr_attr, tb[SET_CHAN_CHAN_LIST], rem) |
| 9825 | i++; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9826 | |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 9827 | *channel_cnt = i; |
| 9828 | |
| 9829 | if (i == 0) |
| 9830 | hdd_err("incorrect channel count"); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9831 | |
| 9832 | channel_list = qdf_mem_malloc(sizeof(struct hdd_vendor_chan_info) * |
| 9833 | (*channel_cnt)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9834 | if (!channel_list) |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 9835 | return -ENOMEM; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9836 | |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 9837 | i = 0; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9838 | nla_for_each_nested(curr_attr, tb[SET_CHAN_CHAN_LIST], rem) { |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 9839 | if (wlan_cfg80211_nla_parse(tb2, SET_CHAN_MAX, |
| 9840 | nla_data(curr_attr), |
| 9841 | nla_len(curr_attr), NULL)) { |
| 9842 | hdd_err("nla_parse failed"); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9843 | return -EINVAL; |
| 9844 | } |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 9845 | if (tb2[SET_EXT_ACS_BAND]) { |
| 9846 | channel_list[i].band = |
| 9847 | nla_get_u8(tb2[SET_EXT_ACS_BAND]); |
| 9848 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9849 | /* Parse and Fetch allowed SSID list*/ |
| 9850 | if (tb2[SET_CHAN_PRIMARY_CHANNEL]) { |
| 9851 | channel_list[i].pri_ch = |
| 9852 | nla_get_u8( |
| 9853 | tb2[SET_CHAN_PRIMARY_CHANNEL]); |
| 9854 | } |
| 9855 | if (tb2[SET_CHAN_SECONDARY_CHANNEL]) { |
| 9856 | channel_list[i].ht_sec_ch = |
| 9857 | nla_get_u8(tb2[SET_CHAN_SECONDARY_CHANNEL]); |
| 9858 | } |
| 9859 | if (tb2[SET_CHAN_SEG0_CENTER_CHANNEL]) { |
| 9860 | channel_list[i].vht_seg0_center_ch = |
| 9861 | nla_get_u8(tb2[SET_CHAN_SEG0_CENTER_CHANNEL]); |
| 9862 | } |
| 9863 | if (tb2[SET_CHAN_SEG1_CENTER_CHANNEL]) { |
| 9864 | channel_list[i].vht_seg1_center_ch = |
| 9865 | nla_get_u8(tb2[SET_CHAN_SEG1_CENTER_CHANNEL]); |
| 9866 | } |
| 9867 | if (tb2[SET_CHAN_CHANNEL_WIDTH]) { |
| 9868 | channel_list[i].chan_width = |
| 9869 | nla_get_u8(tb2[SET_CHAN_CHANNEL_WIDTH]); |
| 9870 | } |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 9871 | hdd_debug("index %d pri %d sec %d seg0 %d seg1 %d width %d", |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9872 | i, channel_list[i].pri_ch, |
| 9873 | channel_list[i].ht_sec_ch, |
| 9874 | channel_list[i].vht_seg0_center_ch, |
| 9875 | channel_list[i].vht_seg1_center_ch, |
| 9876 | channel_list[i].chan_width); |
| 9877 | i++; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9878 | } |
| 9879 | *chan_list_ptr = channel_list; |
| 9880 | |
| 9881 | return 0; |
| 9882 | } |
| 9883 | |
| 9884 | /** |
| 9885 | * Undef short names for vendor set channel configuration |
| 9886 | */ |
| 9887 | #undef SET_CHAN_REASON |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9888 | #undef SET_CHAN_CHAN_LIST |
| 9889 | #undef SET_CHAN_PRIMARY_CHANNEL |
| 9890 | #undef SET_CHAN_SECONDARY_CHANNEL |
| 9891 | #undef SET_CHAN_SEG0_CENTER_CHANNEL |
| 9892 | #undef SET_CHAN_SEG1_CENTER_CHANNEL |
| 9893 | #undef SET_CHAN_CHANNEL_WIDTH |
| 9894 | #undef SET_CHAN_MAX |
| 9895 | |
| 9896 | /** |
| 9897 | * __wlan_hdd_cfg80211_update_vendor_channel() - update vendor channel |
| 9898 | * @wiphy: Pointer to wireless phy |
| 9899 | * @wdev: Pointer to wireless device |
| 9900 | * @data: Pointer to data |
| 9901 | * @data_len: Length of @data |
| 9902 | * |
| 9903 | * Return: 0 on success, negative errno on failure |
| 9904 | */ |
| 9905 | static int __wlan_hdd_cfg80211_update_vendor_channel(struct wiphy *wiphy, |
| 9906 | struct wireless_dev *wdev, |
| 9907 | const void *data, int data_len) |
| 9908 | { |
| 9909 | int ret_val; |
| 9910 | QDF_STATUS qdf_status; |
| 9911 | uint8_t channel_cnt = 0, reason = -1; |
| 9912 | struct hdd_vendor_chan_info *channel_list = NULL; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9913 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(wdev->netdev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9914 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 9915 | struct hdd_vendor_chan_info *channel_list_ptr; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9916 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9917 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9918 | |
| 9919 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 9920 | if (ret_val) |
| 9921 | return ret_val; |
| 9922 | |
| 9923 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 9924 | hdd_err("Command not allowed in FTM mode"); |
| 9925 | return -EINVAL; |
| 9926 | } |
| 9927 | |
| 9928 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 9929 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 9930 | else { |
| 9931 | hdd_err("already timeout happened for acs"); |
| 9932 | return -EINVAL; |
| 9933 | } |
| 9934 | |
| 9935 | ret_val = hdd_parse_vendor_acs_chan_config(&channel_list, &reason, |
| 9936 | &channel_cnt, data, data_len); |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 9937 | channel_list_ptr = channel_list; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9938 | if (ret_val) |
| 9939 | return ret_val; |
| 9940 | |
| 9941 | /* Validate channel to be set */ |
| 9942 | while (channel_cnt && channel_list) { |
| 9943 | qdf_status = wlan_hdd_validate_acs_channel(adapter, |
| 9944 | channel_list->pri_ch, |
| 9945 | channel_list->chan_width); |
| 9946 | if (qdf_status == QDF_STATUS_SUCCESS) |
| 9947 | break; |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 9948 | else if (channel_cnt == 1) { |
| 9949 | hdd_err("invalid channel %d received from app", |
| 9950 | channel_list->pri_ch); |
| 9951 | channel_list->pri_ch = 0; |
| 9952 | break; |
| 9953 | } |
| 9954 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9955 | channel_cnt--; |
| 9956 | channel_list++; |
| 9957 | } |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 9958 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9959 | if ((channel_cnt <= 0) || !channel_list) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 9960 | hdd_err("no available channel/chanlist %d/%pK", channel_cnt, |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 9961 | channel_list); |
| 9962 | qdf_mem_free(channel_list_ptr); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9963 | return -EINVAL; |
| 9964 | } |
| 9965 | |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 9966 | hdd_debug("received primary channel as %d", channel_list->pri_ch); |
| 9967 | |
| 9968 | ret_val = hdd_update_acs_channel(adapter, reason, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9969 | channel_cnt, channel_list); |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 9970 | qdf_mem_free(channel_list_ptr); |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 9971 | return ret_val; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9972 | } |
| 9973 | |
| 9974 | /** |
| 9975 | * wlan_hdd_cfg80211_update_vendor_channel() - update vendor channel |
| 9976 | * @wiphy: Pointer to wireless phy |
| 9977 | * @wdev: Pointer to wireless device |
| 9978 | * @data: Pointer to data |
| 9979 | * @data_len: Length of @data |
| 9980 | * |
| 9981 | * Return: 0 on success, negative errno on failure |
| 9982 | */ |
| 9983 | static int wlan_hdd_cfg80211_update_vendor_channel(struct wiphy *wiphy, |
| 9984 | struct wireless_dev *wdev, |
| 9985 | const void *data, int data_len) |
| 9986 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 9987 | int errno; |
| 9988 | struct osif_vdev_sync *vdev_sync; |
| 9989 | |
| 9990 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 9991 | if (errno) |
| 9992 | return errno; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9993 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 9994 | errno = __wlan_hdd_cfg80211_update_vendor_channel(wiphy, wdev, |
| 9995 | data, data_len); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9996 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 9997 | osif_vdev_sync_op_stop(vdev_sync); |
| 9998 | |
| 9999 | return errno; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 10000 | } |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 10001 | |
| 10002 | /** |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 10003 | * wlan_hdd_cfg80211_setband() - Wrapper to setband |
| 10004 | * @wiphy: wiphy structure pointer |
| 10005 | * @wdev: Wireless device structure pointer |
| 10006 | * @data: Pointer to the data received |
| 10007 | * @data_len: Length of @data |
| 10008 | * |
| 10009 | * Return: 0 on success; errno on failure |
| 10010 | */ |
| 10011 | static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy, |
| 10012 | struct wireless_dev *wdev, |
| 10013 | const void *data, int data_len) |
| 10014 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 10015 | int errno; |
| 10016 | struct osif_vdev_sync *vdev_sync; |
| 10017 | |
| 10018 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 10019 | if (errno) |
| 10020 | return errno; |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 10021 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 10022 | errno = __wlan_hdd_cfg80211_setband(wiphy, wdev, data, data_len); |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 10023 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 10024 | osif_vdev_sync_op_stop(vdev_sync); |
| 10025 | |
| 10026 | return errno; |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 10027 | } |
| 10028 | |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10029 | /** |
| 10030 | * wlan_hdd_cfg80211_sar_convert_limit_set() - Convert limit set value |
| 10031 | * @nl80211_value: Vendor command attribute value |
| 10032 | * @wmi_value: Pointer to return converted WMI return value |
| 10033 | * |
| 10034 | * Convert NL80211 vendor command value for SAR limit set to WMI value |
| 10035 | * Return: 0 on success, -1 on invalid value |
| 10036 | */ |
| 10037 | static int wlan_hdd_cfg80211_sar_convert_limit_set(u32 nl80211_value, |
| 10038 | u32 *wmi_value) |
| 10039 | { |
| 10040 | int ret = 0; |
| 10041 | |
| 10042 | switch (nl80211_value) { |
| 10043 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_NONE: |
| 10044 | *wmi_value = WMI_SAR_FEATURE_OFF; |
| 10045 | break; |
| 10046 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF0: |
| 10047 | *wmi_value = WMI_SAR_FEATURE_ON_SET_0; |
| 10048 | break; |
| 10049 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF1: |
| 10050 | *wmi_value = WMI_SAR_FEATURE_ON_SET_1; |
| 10051 | break; |
| 10052 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF2: |
| 10053 | *wmi_value = WMI_SAR_FEATURE_ON_SET_2; |
| 10054 | break; |
| 10055 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF3: |
| 10056 | *wmi_value = WMI_SAR_FEATURE_ON_SET_3; |
| 10057 | break; |
| 10058 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF4: |
| 10059 | *wmi_value = WMI_SAR_FEATURE_ON_SET_4; |
| 10060 | break; |
| 10061 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_USER: |
| 10062 | *wmi_value = WMI_SAR_FEATURE_ON_USER_DEFINED; |
| 10063 | break; |
Kabilan Kannan | caa8550 | 2018-04-13 18:04:58 -0700 | [diff] [blame] | 10064 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_V2_0: |
| 10065 | *wmi_value = WMI_SAR_FEATURE_ON_SAR_V2_0; |
| 10066 | break; |
| 10067 | |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10068 | default: |
| 10069 | ret = -1; |
| 10070 | } |
| 10071 | return ret; |
| 10072 | } |
| 10073 | |
Jeff Johnson | 354c20b | 2018-07-17 20:15:56 -0700 | [diff] [blame] | 10074 | #ifdef WLAN_FEATURE_SARV1_TO_SARV2 |
| 10075 | /** |
| 10076 | * hdd_convert_sarv1_to_sarv2() - convert SAR V1 BDF reference to SAR V2 |
| 10077 | * @hdd_ctx: The HDD global context |
| 10078 | * @tb: The parsed array of netlink attributes |
| 10079 | * @sar_limit_cmd: The WMI command to be filled |
| 10080 | * |
| 10081 | * This feature/function is designed to solve the following problem: |
| 10082 | * 1) Userspace application was written to use SARv1 BDF entries |
| 10083 | * 2) Product is configured with SAR V2 BDF entries |
| 10084 | * |
| 10085 | * So if this feature is enabled, and if the firmware is configured |
| 10086 | * with SAR V2 support, and if the incoming request is to enable a SAR |
| 10087 | * V1 BDF entry, then the WMI command is generated to actually |
| 10088 | * configure a SAR V2 BDF entry. |
| 10089 | * |
| 10090 | * Return: true if conversion was performed and @sar_limit_cmd is |
| 10091 | * ready to be sent to firmware. Otherwise false in which case the |
| 10092 | * normal parsing logic should be applied. |
| 10093 | */ |
| 10094 | |
| 10095 | static bool |
| 10096 | hdd_convert_sarv1_to_sarv2(struct hdd_context *hdd_ctx, |
| 10097 | struct nlattr *tb[], |
| 10098 | struct sar_limit_cmd_params *sar_limit_cmd) |
| 10099 | { |
| 10100 | struct nlattr *attr; |
| 10101 | uint32_t bdf_index, set; |
| 10102 | struct sar_limit_cmd_row *row; |
| 10103 | |
| 10104 | if (hdd_ctx->sar_version != SAR_VERSION_2) { |
| 10105 | hdd_debug("SAR version: %d", hdd_ctx->sar_version); |
| 10106 | return false; |
| 10107 | } |
| 10108 | |
| 10109 | attr = tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SAR_ENABLE]; |
| 10110 | if (!attr) |
| 10111 | return false; |
| 10112 | |
| 10113 | bdf_index = nla_get_u32(attr); |
| 10114 | |
| 10115 | if ((bdf_index >= QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF0) && |
| 10116 | (bdf_index <= QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF4)) { |
| 10117 | set = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_V2_0; |
| 10118 | } else if (bdf_index == QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_NONE) { |
| 10119 | set = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_NONE; |
| 10120 | bdf_index = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF0; |
| 10121 | } else { |
| 10122 | return false; |
| 10123 | } |
| 10124 | |
| 10125 | /* Need two rows to hold the per-chain V2 power index |
| 10126 | * To disable SARv2 limit, send chain, num_limits_row and |
| 10127 | * power limit set to 0 (except power index 0xff) |
| 10128 | */ |
| 10129 | row = qdf_mem_malloc(2 * sizeof(*row)); |
| 10130 | if (!row) |
| 10131 | return false; |
| 10132 | |
| 10133 | if (wlan_hdd_cfg80211_sar_convert_limit_set( |
| 10134 | set, &sar_limit_cmd->sar_enable)) { |
| 10135 | hdd_err("Failed to convert SAR limit to WMI value"); |
| 10136 | return false; |
| 10137 | } |
| 10138 | |
| 10139 | sar_limit_cmd->commit_limits = 1; |
| 10140 | sar_limit_cmd->num_limit_rows = 2; |
| 10141 | sar_limit_cmd->sar_limit_row_list = row; |
| 10142 | row[0].limit_value = bdf_index; |
| 10143 | row[1].limit_value = row[0].limit_value; |
| 10144 | row[0].chain_id = 0; |
| 10145 | row[1].chain_id = 1; |
| 10146 | row[0].validity_bitmap = WMI_SAR_CHAIN_ID_VALID_MASK; |
| 10147 | row[1].validity_bitmap = WMI_SAR_CHAIN_ID_VALID_MASK; |
| 10148 | |
| 10149 | return true; |
| 10150 | } |
| 10151 | |
| 10152 | #else /* WLAN_FEATURE_SARV1_TO_SARV2 */ |
| 10153 | |
| 10154 | static bool |
| 10155 | hdd_convert_sarv1_to_sarv2(struct hdd_context *hdd_ctx, |
| 10156 | struct nlattr *tb[], |
| 10157 | struct sar_limit_cmd_params *sar_limit_cmd) |
| 10158 | { |
| 10159 | return false; |
| 10160 | } |
| 10161 | |
| 10162 | #endif /* WLAN_FEATURE_SARV1_TO_SARV2 */ |
| 10163 | |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10164 | /** |
| 10165 | * wlan_hdd_cfg80211_sar_convert_band() - Convert WLAN band value |
| 10166 | * @nl80211_value: Vendor command attribute value |
| 10167 | * @wmi_value: Pointer to return converted WMI return value |
| 10168 | * |
| 10169 | * Convert NL80211 vendor command value for SAR BAND to WMI value |
| 10170 | * Return: 0 on success, -1 on invalid value |
| 10171 | */ |
| 10172 | static int wlan_hdd_cfg80211_sar_convert_band(u32 nl80211_value, u32 *wmi_value) |
| 10173 | { |
| 10174 | int ret = 0; |
| 10175 | |
| 10176 | switch (nl80211_value) { |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 10177 | case HDD_NL80211_BAND_2GHZ: |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10178 | *wmi_value = WMI_SAR_2G_ID; |
| 10179 | break; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 10180 | case HDD_NL80211_BAND_5GHZ: |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10181 | *wmi_value = WMI_SAR_5G_ID; |
| 10182 | break; |
| 10183 | default: |
| 10184 | ret = -1; |
| 10185 | } |
| 10186 | return ret; |
| 10187 | } |
| 10188 | |
| 10189 | /** |
| 10190 | * wlan_hdd_cfg80211_sar_convert_modulation() - Convert WLAN modulation value |
| 10191 | * @nl80211_value: Vendor command attribute value |
| 10192 | * @wmi_value: Pointer to return converted WMI return value |
| 10193 | * |
| 10194 | * Convert NL80211 vendor command value for SAR Modulation to WMI value |
| 10195 | * Return: 0 on success, -1 on invalid value |
| 10196 | */ |
| 10197 | static int wlan_hdd_cfg80211_sar_convert_modulation(u32 nl80211_value, |
| 10198 | u32 *wmi_value) |
| 10199 | { |
| 10200 | int ret = 0; |
| 10201 | |
| 10202 | switch (nl80211_value) { |
| 10203 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION_CCK: |
| 10204 | *wmi_value = WMI_SAR_MOD_CCK; |
| 10205 | break; |
| 10206 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION_OFDM: |
| 10207 | *wmi_value = WMI_SAR_MOD_OFDM; |
| 10208 | break; |
| 10209 | default: |
| 10210 | ret = -1; |
| 10211 | } |
| 10212 | return ret; |
| 10213 | } |
| 10214 | |
Jeff Johnson | b17a93c | 2017-06-02 12:26:55 -0700 | [diff] [blame] | 10215 | static const struct nla_policy |
| 10216 | sar_limits_policy[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX + 1] = { |
| 10217 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SAR_ENABLE] = {.type = NLA_U32}, |
| 10218 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_NUM_SPECS] = {.type = NLA_U32}, |
| 10219 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND] = {.type = NLA_U32}, |
| 10220 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_CHAIN] = {.type = NLA_U32}, |
| 10221 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION] = {.type = NLA_U32}, |
| 10222 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT] = {.type = NLA_U32}, |
Kabilan Kannan | caa8550 | 2018-04-13 18:04:58 -0700 | [diff] [blame] | 10223 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT_INDEX] = {.type = NLA_U32}, |
Jeff Johnson | b17a93c | 2017-06-02 12:26:55 -0700 | [diff] [blame] | 10224 | }; |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10225 | |
| 10226 | /** |
| 10227 | * __wlan_hdd_set_sar_power_limits() - Set SAR power limits |
| 10228 | * @wiphy: Pointer to wireless phy |
| 10229 | * @wdev: Pointer to wireless device |
| 10230 | * @data: Pointer to data |
| 10231 | * @data_len: Length of @data |
| 10232 | * |
| 10233 | * This function is used to setup Specific Absorption Rate limit specs. |
| 10234 | * |
| 10235 | * Return: 0 on success, negative errno on failure |
| 10236 | */ |
| 10237 | static int __wlan_hdd_set_sar_power_limits(struct wiphy *wiphy, |
| 10238 | struct wireless_dev *wdev, |
| 10239 | const void *data, int data_len) |
| 10240 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 10241 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10242 | struct nlattr *sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX + 1], |
| 10243 | *tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX + 1], |
| 10244 | *sar_spec_list; |
| 10245 | struct sar_limit_cmd_params sar_limit_cmd = {0}; |
| 10246 | int ret = -EINVAL, i = 0, rem = 0; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 10247 | mac_handle_t mac_handle; |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10248 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10249 | hdd_enter(); |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10250 | |
| 10251 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 10252 | hdd_err("Command not allowed in FTM mode"); |
| 10253 | return -EPERM; |
| 10254 | } |
| 10255 | |
| 10256 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 10257 | return -EINVAL; |
| 10258 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 10259 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX, |
| 10260 | data, data_len, sar_limits_policy)) { |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10261 | hdd_err("Invalid SAR attributes"); |
| 10262 | return -EINVAL; |
| 10263 | } |
| 10264 | |
Jeff Johnson | 354c20b | 2018-07-17 20:15:56 -0700 | [diff] [blame] | 10265 | /* is special SAR V1 => SAR V2 logic enabled and applicable? */ |
| 10266 | if (hdd_convert_sarv1_to_sarv2(hdd_ctx, tb, &sar_limit_cmd)) |
| 10267 | goto send_sar_limits; |
| 10268 | |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10269 | /* Vendor command manadates all SAR Specs in single call */ |
| 10270 | sar_limit_cmd.commit_limits = 1; |
| 10271 | sar_limit_cmd.sar_enable = WMI_SAR_FEATURE_NO_CHANGE; |
| 10272 | if (tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SAR_ENABLE]) { |
| 10273 | if (wlan_hdd_cfg80211_sar_convert_limit_set(nla_get_u32( |
| 10274 | tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SAR_ENABLE]), |
| 10275 | &sar_limit_cmd.sar_enable) < 0) { |
| 10276 | hdd_err("Invalid SAR Enable attr"); |
| 10277 | goto fail; |
| 10278 | } |
| 10279 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 10280 | hdd_debug("attr sar sar_enable %d", sar_limit_cmd.sar_enable); |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10281 | |
| 10282 | if (tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_NUM_SPECS]) { |
| 10283 | sar_limit_cmd.num_limit_rows = nla_get_u32( |
| 10284 | tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_NUM_SPECS]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 10285 | hdd_debug("attr sar num_limit_rows %d", |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10286 | sar_limit_cmd.num_limit_rows); |
| 10287 | } |
| 10288 | if (sar_limit_cmd.num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) { |
| 10289 | hdd_err("SAR Spec list exceed supported size"); |
| 10290 | goto fail; |
| 10291 | } |
| 10292 | if (sar_limit_cmd.num_limit_rows == 0) |
| 10293 | goto send_sar_limits; |
| 10294 | sar_limit_cmd.sar_limit_row_list = qdf_mem_malloc(sizeof( |
| 10295 | struct sar_limit_cmd_row) * |
| 10296 | sar_limit_cmd.num_limit_rows); |
| 10297 | if (!sar_limit_cmd.sar_limit_row_list) { |
| 10298 | ret = -ENOMEM; |
| 10299 | goto fail; |
| 10300 | } |
| 10301 | if (!tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC]) { |
| 10302 | hdd_err("Invalid SAR SPECs list"); |
| 10303 | goto fail; |
| 10304 | } |
| 10305 | |
| 10306 | nla_for_each_nested(sar_spec_list, |
| 10307 | tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC], rem) { |
| 10308 | if (i == sar_limit_cmd.num_limit_rows) { |
| 10309 | hdd_warn("SAR Cmd has excess SPECs in list"); |
| 10310 | break; |
| 10311 | } |
| 10312 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 10313 | if (wlan_cfg80211_nla_parse(sar_spec, |
| 10314 | QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX, |
| 10315 | nla_data(sar_spec_list), |
| 10316 | nla_len(sar_spec_list), |
| 10317 | sar_limits_policy)) { |
| 10318 | hdd_err("nla_parse failed for SAR Spec list"); |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10319 | goto fail; |
| 10320 | } |
| 10321 | sar_limit_cmd.sar_limit_row_list[i].validity_bitmap = 0; |
| 10322 | if (sar_spec[ |
| 10323 | QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT]) { |
| 10324 | sar_limit_cmd.sar_limit_row_list[i].limit_value = |
| 10325 | nla_get_u32(sar_spec[ |
| 10326 | QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT]); |
Kabilan Kannan | caa8550 | 2018-04-13 18:04:58 -0700 | [diff] [blame] | 10327 | } else if (sar_spec[ |
| 10328 | QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT_INDEX]) { |
| 10329 | sar_limit_cmd.sar_limit_row_list[i].limit_value = |
| 10330 | nla_get_u32(sar_spec[ |
| 10331 | QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT_INDEX]); |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10332 | } else { |
Kabilan Kannan | caa8550 | 2018-04-13 18:04:58 -0700 | [diff] [blame] | 10333 | hdd_err("SAR Spec does not have power limit or index value"); |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10334 | goto fail; |
| 10335 | } |
| 10336 | |
| 10337 | if (sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND]) { |
| 10338 | if (wlan_hdd_cfg80211_sar_convert_band(nla_get_u32( |
| 10339 | sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND]), |
| 10340 | &sar_limit_cmd.sar_limit_row_list[i].band_id) |
| 10341 | < 0) { |
| 10342 | hdd_err("Invalid SAR Band attr"); |
| 10343 | goto fail; |
| 10344 | } |
| 10345 | sar_limit_cmd.sar_limit_row_list[i].validity_bitmap |= |
| 10346 | WMI_SAR_BAND_ID_VALID_MASK; |
| 10347 | } |
| 10348 | if (sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_CHAIN]) { |
| 10349 | sar_limit_cmd.sar_limit_row_list[i].chain_id = |
| 10350 | nla_get_u32(sar_spec[ |
| 10351 | QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_CHAIN]); |
| 10352 | sar_limit_cmd.sar_limit_row_list[i].validity_bitmap |= |
| 10353 | WMI_SAR_CHAIN_ID_VALID_MASK; |
| 10354 | } |
| 10355 | if (sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION]) { |
| 10356 | if (wlan_hdd_cfg80211_sar_convert_modulation(nla_get_u32( |
| 10357 | sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION]), |
| 10358 | &sar_limit_cmd.sar_limit_row_list[i].mod_id) |
| 10359 | < 0) { |
| 10360 | hdd_err("Invalid SAR Modulation attr"); |
| 10361 | goto fail; |
| 10362 | } |
| 10363 | sar_limit_cmd.sar_limit_row_list[i].validity_bitmap |= |
| 10364 | WMI_SAR_MOD_ID_VALID_MASK; |
| 10365 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 10366 | hdd_debug("Spec_ID: %d, Band: %d Chain: %d Mod: %d POW_Limit: %d Validity_Bitmap: %d", |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10367 | i, sar_limit_cmd.sar_limit_row_list[i].band_id, |
| 10368 | sar_limit_cmd.sar_limit_row_list[i].chain_id, |
| 10369 | sar_limit_cmd.sar_limit_row_list[i].mod_id, |
| 10370 | sar_limit_cmd.sar_limit_row_list[i].limit_value, |
| 10371 | sar_limit_cmd.sar_limit_row_list[i].validity_bitmap); |
| 10372 | i++; |
| 10373 | } |
| 10374 | |
| 10375 | if (i < sar_limit_cmd.num_limit_rows) { |
| 10376 | hdd_warn("SAR Cmd has less SPECs in list"); |
| 10377 | sar_limit_cmd.num_limit_rows = i; |
| 10378 | } |
| 10379 | |
| 10380 | send_sar_limits: |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 10381 | mac_handle = hdd_ctx->mac_handle; |
| 10382 | if (sme_set_sar_power_limits(mac_handle, &sar_limit_cmd) == |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10383 | QDF_STATUS_SUCCESS) |
| 10384 | ret = 0; |
| 10385 | fail: |
| 10386 | qdf_mem_free(sar_limit_cmd.sar_limit_row_list); |
| 10387 | return ret; |
| 10388 | } |
| 10389 | |
| 10390 | /** |
| 10391 | * wlan_hdd_cfg80211_set_sar_power_limits() - Set SAR power limits |
| 10392 | * @wiphy: Pointer to wireless phy |
| 10393 | * @wdev: Pointer to wireless device |
| 10394 | * @data: Pointer to data |
| 10395 | * @data_len: Length of @data |
| 10396 | * |
| 10397 | * Wrapper function of __wlan_hdd_cfg80211_set_sar_power_limits() |
| 10398 | * |
| 10399 | * Return: 0 on success, negative errno on failure |
| 10400 | */ |
| 10401 | static int wlan_hdd_cfg80211_set_sar_power_limits(struct wiphy *wiphy, |
| 10402 | struct wireless_dev *wdev, |
| 10403 | const void *data, |
| 10404 | int data_len) |
| 10405 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 10406 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 10407 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 10408 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 10409 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 10410 | if (errno) |
| 10411 | return errno; |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10412 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 10413 | errno = __wlan_hdd_set_sar_power_limits(wiphy, wdev, data, data_len); |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10414 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 10415 | osif_psoc_sync_op_stop(psoc_sync); |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 10416 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 10417 | return errno; |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 10418 | } |
| 10419 | |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10420 | static const struct |
| 10421 | nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] = { |
| 10422 | [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = {.type = NLA_U32}, |
| 10423 | [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = {.type = NLA_BINARY, |
| 10424 | .len = QDF_MAC_ADDR_SIZE}, |
| 10425 | }; |
| 10426 | |
Jeff Johnson | 4397514 | 2018-07-04 15:33:47 -0700 | [diff] [blame] | 10427 | void wlan_hdd_rso_cmd_status_cb(hdd_handle_t hdd_handle, |
| 10428 | struct rso_cmd_status *rso_status) |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10429 | { |
Jeff Johnson | 4397514 | 2018-07-04 15:33:47 -0700 | [diff] [blame] | 10430 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 10431 | struct hdd_adapter *adapter; |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10432 | |
| 10433 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rso_status->vdev_id); |
| 10434 | if (!adapter) { |
| 10435 | hdd_err("adapter NULL"); |
| 10436 | return; |
| 10437 | } |
| 10438 | |
| 10439 | adapter->lfr_fw_status.is_disabled = rso_status->status; |
| 10440 | complete(&adapter->lfr_fw_status.disable_lfr_event); |
| 10441 | } |
| 10442 | |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10443 | /** |
| 10444 | * __wlan_hdd_cfg80211_set_fast_roaming() - enable/disable roaming |
| 10445 | * @wiphy: Pointer to wireless phy |
| 10446 | * @wdev: Pointer to wireless device |
| 10447 | * @data: Pointer to data |
| 10448 | * @data_len: Length of @data |
| 10449 | * |
| 10450 | * This function is used to enable/disable roaming using vendor commands |
| 10451 | * |
| 10452 | * Return: 0 on success, negative errno on failure |
| 10453 | */ |
| 10454 | static int __wlan_hdd_cfg80211_set_fast_roaming(struct wiphy *wiphy, |
| 10455 | struct wireless_dev *wdev, |
| 10456 | const void *data, int data_len) |
| 10457 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 10458 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10459 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 10460 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10461 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1]; |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 10462 | uint32_t is_fast_roam_enabled; |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10463 | int ret; |
Selvaraj, Sridhar | d753e7c | 2017-01-12 20:19:27 +0530 | [diff] [blame] | 10464 | QDF_STATUS qdf_status; |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10465 | unsigned long rc; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 10466 | struct hdd_station_ctx *hdd_sta_ctx = |
| 10467 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10468 | mac_handle_t mac_handle; |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10469 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 10470 | hdd_enter_dev(dev); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10471 | |
| 10472 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10473 | if (0 != ret) |
| 10474 | return ret; |
| 10475 | |
| 10476 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 10477 | hdd_err("Command not allowed in FTM mode"); |
| 10478 | return -EINVAL; |
| 10479 | } |
| 10480 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 10481 | ret = wlan_cfg80211_nla_parse(tb, |
| 10482 | QCA_WLAN_VENDOR_ATTR_MAX, data, data_len, |
| 10483 | qca_wlan_vendor_attr); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10484 | if (ret) { |
| 10485 | hdd_err("Invalid ATTR"); |
| 10486 | return -EINVAL; |
| 10487 | } |
| 10488 | |
| 10489 | /* Parse and fetch Enable flag */ |
| 10490 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) { |
| 10491 | hdd_err("attr enable failed"); |
| 10492 | return -EINVAL; |
| 10493 | } |
| 10494 | |
| 10495 | is_fast_roam_enabled = nla_get_u32( |
| 10496 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]); |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 10497 | hdd_debug("isFastRoamEnabled %d", is_fast_roam_enabled); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10498 | |
| 10499 | /* Update roaming */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 10500 | mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 10501 | qdf_status = sme_config_fast_roaming(mac_handle, adapter->vdev_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 10502 | is_fast_roam_enabled); |
Selvaraj, Sridhar | d753e7c | 2017-01-12 20:19:27 +0530 | [diff] [blame] | 10503 | if (qdf_status != QDF_STATUS_SUCCESS) |
| 10504 | hdd_err("sme_config_fast_roaming failed with status=%d", |
| 10505 | qdf_status); |
| 10506 | ret = qdf_status_to_os_return(qdf_status); |
| 10507 | |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 10508 | if (eConnectionState_Associated == hdd_sta_ctx->conn_info.conn_state && |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 10509 | QDF_IS_STATUS_SUCCESS(qdf_status) && !is_fast_roam_enabled) { |
Selvaraj, Sridhar | 4c7411e | 2017-05-04 12:58:41 +0530 | [diff] [blame] | 10510 | |
| 10511 | INIT_COMPLETION(adapter->lfr_fw_status.disable_lfr_event); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10512 | /* |
| 10513 | * wait only for LFR disable in fw as LFR enable |
| 10514 | * is always success |
| 10515 | */ |
| 10516 | rc = wait_for_completion_timeout( |
| 10517 | &adapter->lfr_fw_status.disable_lfr_event, |
| 10518 | msecs_to_jiffies(WAIT_TIME_RSO_CMD_STATUS)); |
| 10519 | if (!rc) { |
| 10520 | hdd_err("Timed out waiting for RSO CMD status"); |
| 10521 | return -ETIMEDOUT; |
| 10522 | } |
| 10523 | |
| 10524 | if (!adapter->lfr_fw_status.is_disabled) { |
| 10525 | hdd_err("Roam disable attempt in FW fails"); |
| 10526 | return -EBUSY; |
| 10527 | } |
| 10528 | } |
| 10529 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10530 | hdd_exit(); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10531 | return ret; |
| 10532 | } |
| 10533 | |
| 10534 | /** |
| 10535 | * wlan_hdd_cfg80211_set_fast_roaming() - enable/disable roaming |
| 10536 | * @wiphy: Pointer to wireless phy |
| 10537 | * @wdev: Pointer to wireless device |
| 10538 | * @data: Pointer to data |
| 10539 | * @data_len: Length of @data |
| 10540 | * |
| 10541 | * Wrapper function of __wlan_hdd_cfg80211_set_fast_roaming() |
| 10542 | * |
| 10543 | * Return: 0 on success, negative errno on failure |
| 10544 | */ |
| 10545 | static int wlan_hdd_cfg80211_set_fast_roaming(struct wiphy *wiphy, |
| 10546 | struct wireless_dev *wdev, |
| 10547 | const void *data, int data_len) |
| 10548 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 10549 | int errno; |
| 10550 | struct osif_vdev_sync *vdev_sync; |
| 10551 | |
| 10552 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 10553 | if (errno) |
| 10554 | return errno; |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10555 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 10556 | errno = __wlan_hdd_cfg80211_set_fast_roaming(wiphy, wdev, |
| 10557 | data, data_len); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10558 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 10559 | osif_vdev_sync_op_stop(vdev_sync); |
| 10560 | |
| 10561 | return errno; |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 10562 | } |
| 10563 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10564 | /* |
| 10565 | * define short names for the global vendor params |
| 10566 | * used by wlan_hdd_cfg80211_setarp_stats_cmd() |
| 10567 | */ |
| 10568 | #define STATS_SET_INVALID \ |
| 10569 | QCA_ATTR_NUD_STATS_SET_INVALID |
| 10570 | #define STATS_SET_START \ |
| 10571 | QCA_ATTR_NUD_STATS_SET_START |
| 10572 | #define STATS_GW_IPV4 \ |
| 10573 | QCA_ATTR_NUD_STATS_GW_IPV4 |
| 10574 | #define STATS_SET_DATA_PKT_INFO \ |
| 10575 | QCA_ATTR_NUD_STATS_SET_DATA_PKT_INFO |
| 10576 | #define STATS_SET_MAX \ |
| 10577 | QCA_ATTR_NUD_STATS_SET_MAX |
| 10578 | |
| 10579 | const struct nla_policy |
| 10580 | qca_wlan_vendor_set_nud_stats[STATS_SET_MAX + 1] = { |
| 10581 | [STATS_SET_START] = {.type = NLA_FLAG }, |
| 10582 | [STATS_GW_IPV4] = {.type = NLA_U32 }, |
| 10583 | [STATS_SET_DATA_PKT_INFO] = {.type = NLA_U32 }, |
| 10584 | }; |
| 10585 | |
| 10586 | /* define short names for the global vendor params */ |
| 10587 | #define CONNECTIVITY_STATS_SET_INVALID \ |
| 10588 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_SET_INVALID |
| 10589 | #define STATS_PKT_INFO_TYPE \ |
| 10590 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_STATS_PKT_INFO_TYPE |
| 10591 | #define STATS_DNS_DOMAIN_NAME \ |
| 10592 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_DNS_DOMAIN_NAME |
| 10593 | #define STATS_SRC_PORT \ |
| 10594 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_SRC_PORT |
| 10595 | #define STATS_DEST_PORT \ |
| 10596 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_DEST_PORT |
| 10597 | #define STATS_DEST_IPV4 \ |
| 10598 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_DEST_IPV4 |
| 10599 | #define STATS_DEST_IPV6 \ |
| 10600 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_DEST_IPV6 |
| 10601 | #define CONNECTIVITY_STATS_SET_MAX \ |
| 10602 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_SET_MAX |
| 10603 | |
| 10604 | const struct nla_policy |
| 10605 | qca_wlan_vendor_set_connectivity_check_stats[CONNECTIVITY_STATS_SET_MAX + 1] = { |
| 10606 | [STATS_PKT_INFO_TYPE] = {.type = NLA_U32 }, |
Sourav Mohapatra | aaa0f88 | 2019-03-07 09:28:40 +0530 | [diff] [blame] | 10607 | [STATS_DNS_DOMAIN_NAME] = {.type = NLA_NUL_STRING, |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10608 | .len = DNS_DOMAIN_NAME_MAX_LEN }, |
| 10609 | [STATS_SRC_PORT] = {.type = NLA_U32 }, |
| 10610 | [STATS_DEST_PORT] = {.type = NLA_U32 }, |
| 10611 | [STATS_DEST_IPV4] = {.type = NLA_U32 }, |
| 10612 | [STATS_DEST_IPV6] = {.type = NLA_BINARY, |
| 10613 | .len = ICMPv6_ADDR_LEN }, |
| 10614 | }; |
| 10615 | |
| 10616 | /** |
| 10617 | * hdd_dns_unmake_name_query() - Convert an uncompressed DNS name to a |
| 10618 | * NUL-terminated string |
| 10619 | * @name: DNS name |
| 10620 | * |
| 10621 | * Return: Produce a printable version of a DNS name. |
| 10622 | */ |
| 10623 | static inline uint8_t *hdd_dns_unmake_name_query(uint8_t *name) |
| 10624 | { |
| 10625 | uint8_t *p; |
| 10626 | unsigned int len; |
| 10627 | |
| 10628 | p = name; |
| 10629 | while ((len = *p)) { |
| 10630 | *(p++) = '.'; |
| 10631 | p += len; |
| 10632 | } |
| 10633 | |
| 10634 | return name + 1; |
| 10635 | } |
| 10636 | |
| 10637 | /** |
| 10638 | * hdd_dns_make_name_query() - Convert a standard NUL-terminated string |
| 10639 | * to DNS name |
| 10640 | * @string: Name as a NUL-terminated string |
| 10641 | * @buf: Buffer in which to place DNS name |
| 10642 | * |
| 10643 | * DNS names consist of "<length>element" pairs. |
| 10644 | * |
| 10645 | * Return: Byte following constructed DNS name |
| 10646 | */ |
Sourav Mohapatra | 47710c3 | 2018-11-30 16:27:05 +0530 | [diff] [blame] | 10647 | static uint8_t *hdd_dns_make_name_query(const uint8_t *string, |
| 10648 | uint8_t *buf, uint8_t len) |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10649 | { |
| 10650 | uint8_t *length_byte = buf++; |
| 10651 | uint8_t c; |
| 10652 | |
Sourav Mohapatra | 47710c3 | 2018-11-30 16:27:05 +0530 | [diff] [blame] | 10653 | if (string[len - 1]) { |
| 10654 | hdd_debug("DNS name is not null terminated"); |
| 10655 | return NULL; |
| 10656 | } |
| 10657 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10658 | while ((c = *(string++))) { |
| 10659 | if (c == '.') { |
| 10660 | *length_byte = buf - length_byte - 1; |
| 10661 | length_byte = buf; |
| 10662 | } |
| 10663 | *(buf++) = c; |
| 10664 | } |
| 10665 | *length_byte = buf - length_byte - 1; |
| 10666 | *(buf++) = '\0'; |
| 10667 | return buf; |
| 10668 | } |
| 10669 | |
| 10670 | /** |
| 10671 | * hdd_set_clear_connectivity_check_stats_info() - set/clear stats info |
| 10672 | * @adapter: Pointer to hdd adapter |
| 10673 | * @arp_stats_params: arp stats structure to be sent to FW |
| 10674 | * @tb: nl attribute |
| 10675 | * @is_set_stats: set/clear stats |
| 10676 | * |
| 10677 | * |
| 10678 | * Return: 0 on success, negative errno on failure |
| 10679 | */ |
| 10680 | static int hdd_set_clear_connectivity_check_stats_info( |
| 10681 | struct hdd_adapter *adapter, |
| 10682 | struct set_arp_stats_params *arp_stats_params, |
| 10683 | struct nlattr **tb, bool is_set_stats) |
| 10684 | { |
| 10685 | struct nlattr *tb2[CONNECTIVITY_STATS_SET_MAX + 1]; |
| 10686 | struct nlattr *curr_attr = NULL; |
| 10687 | int err = 0; |
| 10688 | uint32_t pkt_bitmap; |
| 10689 | int rem; |
| 10690 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10691 | /* Set NUD command for start tracking is received. */ |
| 10692 | nla_for_each_nested(curr_attr, |
| 10693 | tb[STATS_SET_DATA_PKT_INFO], |
| 10694 | rem) { |
| 10695 | |
| 10696 | if (wlan_cfg80211_nla_parse(tb2, |
| 10697 | CONNECTIVITY_STATS_SET_MAX, |
| 10698 | nla_data(curr_attr), nla_len(curr_attr), |
| 10699 | qca_wlan_vendor_set_connectivity_check_stats)) { |
| 10700 | hdd_err("nla_parse failed"); |
| 10701 | err = -EINVAL; |
| 10702 | goto end; |
| 10703 | } |
| 10704 | |
| 10705 | if (tb2[STATS_PKT_INFO_TYPE]) { |
| 10706 | pkt_bitmap = nla_get_u32(tb2[STATS_PKT_INFO_TYPE]); |
| 10707 | if (!pkt_bitmap) { |
| 10708 | hdd_err("pkt tracking bitmap is empty"); |
| 10709 | err = -EINVAL; |
| 10710 | goto end; |
| 10711 | } |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 10712 | |
| 10713 | if (is_set_stats) { |
| 10714 | arp_stats_params->pkt_type_bitmap = pkt_bitmap; |
| 10715 | arp_stats_params->flag = true; |
| 10716 | adapter->pkt_type_bitmap |= |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10717 | arp_stats_params->pkt_type_bitmap; |
| 10718 | |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 10719 | if (pkt_bitmap & CONNECTIVITY_CHECK_SET_ARP) { |
Srinivas Girigowda | 683726a | 2018-09-07 15:10:40 -0700 | [diff] [blame] | 10720 | if (!tb[STATS_GW_IPV4]) { |
| 10721 | hdd_err("GW ipv4 address is not present"); |
| 10722 | err = -EINVAL; |
| 10723 | goto end; |
| 10724 | } |
| 10725 | arp_stats_params->ip_addr = |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10726 | nla_get_u32(tb[STATS_GW_IPV4]); |
Srinivas Girigowda | 683726a | 2018-09-07 15:10:40 -0700 | [diff] [blame] | 10727 | arp_stats_params->pkt_type = |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10728 | WLAN_NUD_STATS_ARP_PKT_TYPE; |
Srinivas Girigowda | 683726a | 2018-09-07 15:10:40 -0700 | [diff] [blame] | 10729 | adapter->track_arp_ip = |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10730 | arp_stats_params->ip_addr; |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10731 | } |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 10732 | |
| 10733 | if (pkt_bitmap & CONNECTIVITY_CHECK_SET_DNS) { |
| 10734 | uint8_t *domain_name; |
| 10735 | |
| 10736 | if (!tb2[STATS_DNS_DOMAIN_NAME]) { |
| 10737 | hdd_err("DNS domain id is not present"); |
| 10738 | err = -EINVAL; |
| 10739 | goto end; |
| 10740 | } |
| 10741 | domain_name = nla_data( |
| 10742 | tb2[STATS_DNS_DOMAIN_NAME]); |
| 10743 | adapter->track_dns_domain_len = |
| 10744 | nla_len(tb2[ |
| 10745 | STATS_DNS_DOMAIN_NAME]); |
Sourav Mohapatra | 47710c3 | 2018-11-30 16:27:05 +0530 | [diff] [blame] | 10746 | if (!hdd_dns_make_name_query( |
| 10747 | domain_name, |
| 10748 | adapter->dns_payload, |
| 10749 | adapter->track_dns_domain_len)) |
| 10750 | adapter->track_dns_domain_len = |
| 10751 | 0; |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 10752 | /* DNStracking isn't supported in FW. */ |
| 10753 | arp_stats_params->pkt_type_bitmap &= |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10754 | ~CONNECTIVITY_CHECK_SET_DNS; |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10755 | } |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 10756 | |
| 10757 | if (pkt_bitmap & |
| 10758 | CONNECTIVITY_CHECK_SET_TCP_HANDSHAKE) { |
| 10759 | if (!tb2[STATS_SRC_PORT] || |
| 10760 | !tb2[STATS_DEST_PORT]) { |
| 10761 | hdd_err("Source/Dest port is not present"); |
| 10762 | err = -EINVAL; |
| 10763 | goto end; |
| 10764 | } |
| 10765 | arp_stats_params->tcp_src_port = |
| 10766 | nla_get_u32( |
| 10767 | tb2[STATS_SRC_PORT]); |
| 10768 | arp_stats_params->tcp_dst_port = |
| 10769 | nla_get_u32( |
| 10770 | tb2[STATS_DEST_PORT]); |
| 10771 | adapter->track_src_port = |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10772 | arp_stats_params->tcp_src_port; |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 10773 | adapter->track_dest_port = |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10774 | arp_stats_params->tcp_dst_port; |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10775 | } |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 10776 | |
| 10777 | if (pkt_bitmap & |
| 10778 | CONNECTIVITY_CHECK_SET_ICMPV4) { |
| 10779 | if (!tb2[STATS_DEST_IPV4]) { |
| 10780 | hdd_err("destination ipv4 address to track ping packets is not present"); |
| 10781 | err = -EINVAL; |
| 10782 | goto end; |
| 10783 | } |
| 10784 | arp_stats_params->icmp_ipv4 = |
| 10785 | nla_get_u32( |
| 10786 | tb2[STATS_DEST_IPV4]); |
| 10787 | adapter->track_dest_ipv4 = |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10788 | arp_stats_params->icmp_ipv4; |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 10789 | } |
| 10790 | } else { |
| 10791 | /* clear stats command received */ |
| 10792 | arp_stats_params->pkt_type_bitmap = pkt_bitmap; |
| 10793 | arp_stats_params->flag = false; |
| 10794 | adapter->pkt_type_bitmap &= |
| 10795 | (~arp_stats_params->pkt_type_bitmap); |
| 10796 | |
| 10797 | if (pkt_bitmap & CONNECTIVITY_CHECK_SET_ARP) { |
| 10798 | arp_stats_params->pkt_type = |
| 10799 | WLAN_NUD_STATS_ARP_PKT_TYPE; |
| 10800 | qdf_mem_zero(&adapter->hdd_stats. |
| 10801 | hdd_arp_stats, |
| 10802 | sizeof(adapter->hdd_stats. |
| 10803 | hdd_arp_stats)); |
| 10804 | adapter->track_arp_ip = 0; |
| 10805 | } |
| 10806 | |
| 10807 | if (pkt_bitmap & CONNECTIVITY_CHECK_SET_DNS) { |
| 10808 | /* DNStracking isn't supported in FW. */ |
| 10809 | arp_stats_params->pkt_type_bitmap &= |
| 10810 | ~CONNECTIVITY_CHECK_SET_DNS; |
| 10811 | qdf_mem_zero(&adapter->hdd_stats. |
| 10812 | hdd_dns_stats, |
| 10813 | sizeof(adapter->hdd_stats. |
| 10814 | hdd_dns_stats)); |
| 10815 | qdf_mem_zero(adapter->dns_payload, |
| 10816 | adapter->track_dns_domain_len); |
| 10817 | adapter->track_dns_domain_len = 0; |
| 10818 | } |
| 10819 | |
| 10820 | if (pkt_bitmap & |
| 10821 | CONNECTIVITY_CHECK_SET_TCP_HANDSHAKE) { |
| 10822 | qdf_mem_zero(&adapter->hdd_stats. |
| 10823 | hdd_tcp_stats, |
| 10824 | sizeof(adapter->hdd_stats. |
| 10825 | hdd_tcp_stats)); |
| 10826 | adapter->track_src_port = 0; |
| 10827 | adapter->track_dest_port = 0; |
| 10828 | } |
| 10829 | |
| 10830 | if (pkt_bitmap & |
| 10831 | CONNECTIVITY_CHECK_SET_ICMPV4) { |
| 10832 | qdf_mem_zero(&adapter->hdd_stats. |
| 10833 | hdd_icmpv4_stats, |
| 10834 | sizeof(adapter->hdd_stats. |
| 10835 | hdd_icmpv4_stats)); |
| 10836 | adapter->track_dest_ipv4 = 0; |
| 10837 | } |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10838 | } |
| 10839 | } else { |
| 10840 | hdd_err("stats list empty"); |
| 10841 | err = -EINVAL; |
| 10842 | goto end; |
| 10843 | } |
| 10844 | } |
| 10845 | |
| 10846 | end: |
| 10847 | return err; |
| 10848 | } |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10849 | |
Jeff Johnson | f6182e4 | 2018-07-03 14:46:17 -0700 | [diff] [blame] | 10850 | void hdd_update_cca_info_cb(hdd_handle_t hdd_handle, uint32_t congestion, |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10851 | uint32_t vdev_id) |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10852 | { |
Jeff Johnson | f6182e4 | 2018-07-03 14:46:17 -0700 | [diff] [blame] | 10853 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10854 | int status; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 10855 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10856 | struct hdd_station_ctx *hdd_sta_ctx; |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10857 | |
| 10858 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10859 | if (status != 0) |
| 10860 | return; |
| 10861 | |
| 10862 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 10863 | if (adapter == NULL) { |
| 10864 | hdd_err("vdev_id %d does not exist with host", vdev_id); |
| 10865 | return; |
| 10866 | } |
| 10867 | |
| 10868 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10869 | hdd_sta_ctx->conn_info.cca = congestion; |
| 10870 | hdd_info("congestion:%d", congestion); |
| 10871 | } |
| 10872 | |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 10873 | static const struct nla_policy qca_wlan_vendor_set_trace_level_policy[ |
| 10874 | QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MAX + 1] = { |
| 10875 | [QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_PARAM] = {.type = NLA_NESTED }, |
| 10876 | [QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MODULE_ID] = {.type = NLA_U32 }, |
| 10877 | [QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_TRACE_MASK] = {.type = NLA_U32 }, |
| 10878 | }; |
| 10879 | |
| 10880 | /** |
| 10881 | * __wlan_hdd_cfg80211_set_trace_level() - Set the trace level |
| 10882 | * @wiphy: Pointer to wireless phy |
| 10883 | * @wdev: Pointer to wireless device |
| 10884 | * @data: Pointer to data |
| 10885 | * @data_len: Length of @data |
| 10886 | * |
| 10887 | * Return: 0 on success, negative errno on failure |
| 10888 | */ |
| 10889 | static int |
| 10890 | __wlan_hdd_cfg80211_set_trace_level(struct wiphy *wiphy, |
| 10891 | struct wireless_dev *wdev, |
| 10892 | const void *data, |
| 10893 | int data_len) |
| 10894 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 10895 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 10896 | struct nlattr *tb1[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MAX + 1]; |
| 10897 | struct nlattr *tb2[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MAX + 1]; |
| 10898 | struct nlattr *apth; |
| 10899 | int rem; |
| 10900 | int ret = 1; |
| 10901 | int print_idx = -1; |
| 10902 | int module_id = -1; |
| 10903 | int bit_mask = -1; |
| 10904 | int status; |
| 10905 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10906 | hdd_enter(); |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 10907 | |
| 10908 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 10909 | hdd_err("Command not allowed in FTM mode"); |
| 10910 | return -EINVAL; |
| 10911 | } |
| 10912 | |
| 10913 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10914 | if (ret != 0) |
| 10915 | return -EINVAL; |
| 10916 | |
| 10917 | print_idx = qdf_get_pidx(); |
| 10918 | if (print_idx < 0 || print_idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 10919 | hdd_err("Invalid print controle object index"); |
| 10920 | return -EINVAL; |
| 10921 | } |
| 10922 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 10923 | if (wlan_cfg80211_nla_parse(tb1, |
| 10924 | QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MAX, |
| 10925 | data, data_len, |
| 10926 | qca_wlan_vendor_set_trace_level_policy)) { |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 10927 | hdd_err("Invalid attr"); |
| 10928 | return -EINVAL; |
| 10929 | } |
| 10930 | |
| 10931 | if (!tb1[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_PARAM]) { |
| 10932 | hdd_err("attr trace level param failed"); |
| 10933 | return -EINVAL; |
| 10934 | } |
| 10935 | |
| 10936 | nla_for_each_nested(apth, |
| 10937 | tb1[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_PARAM], rem) { |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 10938 | if (wlan_cfg80211_nla_parse(tb2, |
| 10939 | QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MAX, |
| 10940 | nla_data(apth), nla_len(apth), NULL)) { |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 10941 | hdd_err("Invalid attr"); |
| 10942 | return -EINVAL; |
| 10943 | } |
| 10944 | |
| 10945 | if (!tb2[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MODULE_ID]) { |
| 10946 | hdd_err("attr Module ID failed"); |
| 10947 | return -EINVAL; |
| 10948 | } |
| 10949 | module_id = nla_get_u32 |
| 10950 | (tb2[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MODULE_ID]); |
| 10951 | |
| 10952 | if (!tb2[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_TRACE_MASK]) { |
| 10953 | hdd_err("attr Verbose mask failed"); |
| 10954 | return -EINVAL; |
| 10955 | } |
| 10956 | bit_mask = nla_get_u32 |
| 10957 | (tb2[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_TRACE_MASK]); |
| 10958 | |
| 10959 | status = hdd_qdf_trace_enable(module_id, bit_mask); |
| 10960 | |
| 10961 | if (status != 0) |
| 10962 | hdd_err("can not set verbose mask %d for the category %d", |
| 10963 | bit_mask, module_id); |
| 10964 | } |
| 10965 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10966 | hdd_exit(); |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 10967 | return ret; |
| 10968 | } |
| 10969 | |
| 10970 | /** |
Ashish Kumar Dhanotiya | eb4fe4b | 2017-02-20 16:04:00 +0530 | [diff] [blame] | 10971 | * wlan_hdd_cfg80211_set_trace_level() - Set the trace level |
| 10972 | * @wiphy: Pointer to wireless phy |
| 10973 | * @wdev: Pointer to wireless device |
| 10974 | * @data: Pointer to data |
| 10975 | * @data_len: Length of @data |
| 10976 | * |
| 10977 | * Wrapper function of __wlan_hdd_cfg80211_set_trace_level() |
| 10978 | * |
| 10979 | * Return: 0 on success, negative errno on failure |
| 10980 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 10981 | |
| 10982 | static int wlan_hdd_cfg80211_set_trace_level(struct wiphy *wiphy, |
| 10983 | struct wireless_dev *wdev, |
| 10984 | const void *data, |
| 10985 | int data_len) |
| 10986 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 10987 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 10988 | int errno; |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 10989 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 10990 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 10991 | if (errno) |
| 10992 | return errno; |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 10993 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 10994 | errno = __wlan_hdd_cfg80211_set_trace_level(wiphy, wdev, |
| 10995 | data, data_len); |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 10996 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 10997 | osif_psoc_sync_op_stop(psoc_sync); |
Arunk Khandavalli | 99716d1 | 2018-11-14 15:02:02 +0530 | [diff] [blame] | 10998 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 10999 | return errno; |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 11000 | } |
| 11001 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11002 | /** |
| 11003 | * __wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware |
| 11004 | * @wiphy: pointer to wireless wiphy structure. |
| 11005 | * @wdev: pointer to wireless_dev structure. |
| 11006 | * @data: pointer to apfind configuration data. |
| 11007 | * @data_len: the length in byte of apfind data. |
| 11008 | * |
| 11009 | * This is called when wlan driver needs to send arp stats to |
| 11010 | * firmware. |
| 11011 | * |
| 11012 | * Return: An error code or 0 on success. |
| 11013 | */ |
| 11014 | static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy, |
| 11015 | struct wireless_dev *wdev, |
| 11016 | const void *data, int data_len) |
| 11017 | { |
| 11018 | struct nlattr *tb[STATS_SET_MAX + 1]; |
| 11019 | struct net_device *dev = wdev->netdev; |
| 11020 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 11021 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11022 | struct set_arp_stats_params arp_stats_params = {0}; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11023 | int err = 0; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 11024 | mac_handle_t mac_handle; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11025 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11026 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11027 | |
Anurag Chouhan | 9fb2bd5 | 2018-01-04 12:25:48 +0530 | [diff] [blame] | 11028 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 11029 | hdd_err("Command not allowed in FTM mode"); |
| 11030 | return -EINVAL; |
| 11031 | } |
| 11032 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11033 | err = wlan_hdd_validate_context(hdd_ctx); |
| 11034 | if (0 != err) |
| 11035 | return err; |
| 11036 | |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 11037 | if (adapter->vdev_id == WLAN_UMAC_VDEV_ID_MAX) { |
| 11038 | hdd_err("Invalid vdev id"); |
Yeshwanth Sriram Guntuka | d5aae7f | 2017-11-27 14:33:51 +0530 | [diff] [blame] | 11039 | return -EINVAL; |
| 11040 | } |
| 11041 | |
Poddar, Siddarth | df07667 | 2018-02-26 14:21:45 +0530 | [diff] [blame] | 11042 | if (adapter->device_mode != QDF_STA_MODE) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11043 | hdd_err("STATS supported in only STA mode!"); |
Poddar, Siddarth | df07667 | 2018-02-26 14:21:45 +0530 | [diff] [blame] | 11044 | return -EINVAL; |
| 11045 | } |
| 11046 | |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 11047 | err = wlan_cfg80211_nla_parse(tb, STATS_SET_MAX, data, data_len, |
| 11048 | qca_wlan_vendor_set_nud_stats); |
| 11049 | if (err) { |
| 11050 | hdd_err("STATS_SET_START ATTR"); |
| 11051 | return err; |
| 11052 | } |
| 11053 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11054 | if (tb[STATS_SET_START]) { |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11055 | /* tracking is enabled for stats other than arp. */ |
| 11056 | if (tb[STATS_SET_DATA_PKT_INFO]) { |
| 11057 | err = hdd_set_clear_connectivity_check_stats_info( |
| 11058 | adapter, |
| 11059 | &arp_stats_params, tb, true); |
| 11060 | if (err) |
| 11061 | return -EINVAL; |
| 11062 | |
| 11063 | /* |
| 11064 | * if only tracking dns, then don't send |
| 11065 | * wmi command to FW. |
| 11066 | */ |
| 11067 | if (!arp_stats_params.pkt_type_bitmap) |
| 11068 | return err; |
| 11069 | } else { |
| 11070 | if (!tb[STATS_GW_IPV4]) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11071 | hdd_err("STATS_SET_START CMD"); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11072 | return -EINVAL; |
| 11073 | } |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 11074 | |
| 11075 | arp_stats_params.pkt_type_bitmap = |
| 11076 | CONNECTIVITY_CHECK_SET_ARP; |
| 11077 | adapter->pkt_type_bitmap |= |
| 11078 | arp_stats_params.pkt_type_bitmap; |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11079 | arp_stats_params.flag = true; |
| 11080 | arp_stats_params.ip_addr = |
| 11081 | nla_get_u32(tb[STATS_GW_IPV4]); |
| 11082 | adapter->track_arp_ip = arp_stats_params.ip_addr; |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11083 | arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11084 | } |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11085 | } else { |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 11086 | /* clear stats command received. */ |
| 11087 | if (tb[STATS_SET_DATA_PKT_INFO]) { |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11088 | err = hdd_set_clear_connectivity_check_stats_info( |
| 11089 | adapter, |
| 11090 | &arp_stats_params, tb, false); |
| 11091 | if (err) |
| 11092 | return -EINVAL; |
| 11093 | |
| 11094 | /* |
| 11095 | * if only tracking dns, then don't send |
| 11096 | * wmi command to FW. |
| 11097 | */ |
| 11098 | if (!arp_stats_params.pkt_type_bitmap) |
| 11099 | return err; |
| 11100 | } else { |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 11101 | arp_stats_params.pkt_type_bitmap = |
| 11102 | CONNECTIVITY_CHECK_SET_ARP; |
| 11103 | adapter->pkt_type_bitmap &= |
| 11104 | (~arp_stats_params.pkt_type_bitmap); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11105 | arp_stats_params.flag = false; |
| 11106 | qdf_mem_zero(&adapter->hdd_stats.hdd_arp_stats, |
| 11107 | sizeof(adapter->hdd_stats.hdd_arp_stats)); |
| 11108 | arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE; |
| 11109 | } |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11110 | } |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11111 | |
Abhinav Kumar | 50d4dc7 | 2018-06-15 16:35:50 +0530 | [diff] [blame] | 11112 | hdd_debug("STATS_SET_START Received flag %d!", arp_stats_params.flag); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11113 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 11114 | arp_stats_params.vdev_id = adapter->vdev_id; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11115 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 11116 | mac_handle = hdd_ctx->mac_handle; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11117 | if (QDF_STATUS_SUCCESS != |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 11118 | sme_set_nud_debug_stats(mac_handle, &arp_stats_params)) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11119 | hdd_err("STATS_SET_START CMD Failed!"); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11120 | return -EINVAL; |
| 11121 | } |
| 11122 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11123 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11124 | |
| 11125 | return err; |
| 11126 | } |
| 11127 | |
| 11128 | /** |
| 11129 | * wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware |
| 11130 | * @wiphy: pointer to wireless wiphy structure. |
| 11131 | * @wdev: pointer to wireless_dev structure. |
| 11132 | * @data: pointer to apfind configuration data. |
| 11133 | * @data_len: the length in byte of apfind data. |
| 11134 | * |
| 11135 | * This is called when wlan driver needs to send arp stats to |
| 11136 | * firmware. |
| 11137 | * |
| 11138 | * Return: An error code or 0 on success. |
| 11139 | */ |
| 11140 | static int wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy, |
| 11141 | struct wireless_dev *wdev, |
| 11142 | const void *data, int data_len) |
| 11143 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 11144 | int errno; |
| 11145 | struct osif_vdev_sync *vdev_sync; |
| 11146 | |
| 11147 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 11148 | if (errno) |
| 11149 | return errno; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11150 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 11151 | errno = __wlan_hdd_cfg80211_set_nud_stats(wiphy, wdev, data, data_len); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11152 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 11153 | osif_vdev_sync_op_stop(vdev_sync); |
| 11154 | |
| 11155 | return errno; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11156 | } |
| 11157 | |
| 11158 | #undef STATS_SET_INVALID |
| 11159 | #undef STATS_SET_START |
| 11160 | #undef STATS_GW_IPV4 |
| 11161 | #undef STATS_SET_MAX |
| 11162 | |
| 11163 | /* |
| 11164 | * define short names for the global vendor params |
| 11165 | * used by wlan_hdd_cfg80211_setarp_stats_cmd() |
| 11166 | */ |
| 11167 | #define STATS_GET_INVALID \ |
| 11168 | QCA_ATTR_NUD_STATS_SET_INVALID |
| 11169 | #define COUNT_FROM_NETDEV \ |
| 11170 | QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV |
| 11171 | #define COUNT_TO_LOWER_MAC \ |
| 11172 | QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC |
| 11173 | #define RX_COUNT_BY_LOWER_MAC \ |
| 11174 | QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC |
| 11175 | #define COUNT_TX_SUCCESS \ |
| 11176 | QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS |
| 11177 | #define RSP_RX_COUNT_BY_LOWER_MAC \ |
| 11178 | QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC |
| 11179 | #define RSP_RX_COUNT_BY_UPPER_MAC \ |
| 11180 | QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC |
| 11181 | #define RSP_COUNT_TO_NETDEV \ |
| 11182 | QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV |
| 11183 | #define RSP_COUNT_OUT_OF_ORDER_DROP \ |
| 11184 | QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP |
| 11185 | #define AP_LINK_ACTIVE \ |
| 11186 | QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE |
| 11187 | #define AP_LINK_DAD \ |
| 11188 | QCA_ATTR_NUD_STATS_IS_DAD |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11189 | #define DATA_PKT_STATS \ |
| 11190 | QCA_ATTR_NUD_STATS_DATA_PKT_STATS |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11191 | #define STATS_GET_MAX \ |
| 11192 | QCA_ATTR_NUD_STATS_GET_MAX |
| 11193 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11194 | #define CHECK_STATS_INVALID \ |
| 11195 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_INVALID |
| 11196 | #define CHECK_STATS_PKT_TYPE \ |
| 11197 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_TYPE |
| 11198 | #define CHECK_STATS_PKT_DNS_DOMAIN_NAME \ |
| 11199 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_DNS_DOMAIN_NAME |
| 11200 | #define CHECK_STATS_PKT_SRC_PORT \ |
| 11201 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_SRC_PORT |
| 11202 | #define CHECK_STATS_PKT_DEST_PORT \ |
| 11203 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_DEST_PORT |
| 11204 | #define CHECK_STATS_PKT_DEST_IPV4 \ |
| 11205 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_DEST_IPV4 |
| 11206 | #define CHECK_STATS_PKT_DEST_IPV6 \ |
| 11207 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_DEST_IPV6 |
| 11208 | #define CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV \ |
| 11209 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV |
| 11210 | #define CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC \ |
| 11211 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC |
| 11212 | #define CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC \ |
| 11213 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC |
| 11214 | #define CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS \ |
| 11215 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS |
| 11216 | #define CHECK_STATS_PKT_RSP_RX_COUNT_BY_LOWER_MAC \ |
| 11217 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_RSP_RX_COUNT_BY_LOWER_MAC |
| 11218 | #define CHECK_STATS_PKT_RSP_RX_COUNT_BY_UPPER_MAC \ |
| 11219 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_RSP_RX_COUNT_BY_UPPER_MAC |
| 11220 | #define CHECK_STATS_PKT_RSP_COUNT_TO_NETDEV \ |
| 11221 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_RSP_COUNT_TO_NETDEV |
| 11222 | #define CHECK_STATS_PKT_RSP_COUNT_OUT_OF_ORDER_DROP \ |
| 11223 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_RSP_COUNT_OUT_OF_ORDER_DROP |
| 11224 | #define CHECK_DATA_STATS_MAX \ |
| 11225 | QCA_ATTR_CONNECTIVITY_CHECK_DATA_STATS_MAX |
| 11226 | |
| 11227 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11228 | const struct nla_policy |
| 11229 | qca_wlan_vendor_get_nud_stats[STATS_GET_MAX + 1] = { |
| 11230 | [COUNT_FROM_NETDEV] = {.type = NLA_U16 }, |
| 11231 | [COUNT_TO_LOWER_MAC] = {.type = NLA_U16 }, |
| 11232 | [RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 }, |
| 11233 | [COUNT_TX_SUCCESS] = {.type = NLA_U16 }, |
| 11234 | [RSP_RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 }, |
| 11235 | [RSP_RX_COUNT_BY_UPPER_MAC] = {.type = NLA_U16 }, |
| 11236 | [RSP_COUNT_TO_NETDEV] = {.type = NLA_U16 }, |
| 11237 | [RSP_COUNT_OUT_OF_ORDER_DROP] = {.type = NLA_U16 }, |
| 11238 | [AP_LINK_ACTIVE] = {.type = NLA_FLAG }, |
| 11239 | [AP_LINK_DAD] = {.type = NLA_FLAG }, |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11240 | [DATA_PKT_STATS] = {.type = NLA_U16 }, |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11241 | }; |
| 11242 | |
| 11243 | /** |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11244 | * hdd_populate_dns_stats_info() - send dns stats info to network stack |
| 11245 | * @adapter: pointer to adapter context |
| 11246 | * @skb: pointer to skb |
| 11247 | * |
| 11248 | * |
| 11249 | * Return: An error code or 0 on success. |
| 11250 | */ |
| 11251 | static int hdd_populate_dns_stats_info(struct hdd_adapter *adapter, |
| 11252 | struct sk_buff *skb) |
| 11253 | { |
| 11254 | uint8_t *dns_query; |
| 11255 | |
| 11256 | dns_query = qdf_mem_malloc(adapter->track_dns_domain_len + 1); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 11257 | if (!dns_query) |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11258 | return -EINVAL; |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11259 | |
| 11260 | qdf_mem_copy(dns_query, adapter->dns_payload, |
| 11261 | adapter->track_dns_domain_len); |
| 11262 | |
| 11263 | if (nla_put_u16(skb, CHECK_STATS_PKT_TYPE, |
| 11264 | CONNECTIVITY_CHECK_SET_DNS) || |
| 11265 | nla_put(skb, CHECK_STATS_PKT_DNS_DOMAIN_NAME, |
| 11266 | adapter->track_dns_domain_len, |
| 11267 | hdd_dns_unmake_name_query(dns_query)) || |
| 11268 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV, |
| 11269 | adapter->hdd_stats.hdd_dns_stats.tx_dns_req_count) || |
| 11270 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC, |
| 11271 | adapter->hdd_stats.hdd_dns_stats.tx_host_fw_sent) || |
| 11272 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC, |
| 11273 | adapter->hdd_stats.hdd_dns_stats.tx_host_fw_sent) || |
| 11274 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS, |
| 11275 | adapter->hdd_stats.hdd_dns_stats.tx_ack_cnt) || |
| 11276 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_RX_COUNT_BY_UPPER_MAC, |
| 11277 | adapter->hdd_stats.hdd_dns_stats.rx_dns_rsp_count) || |
| 11278 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_COUNT_TO_NETDEV, |
| 11279 | adapter->hdd_stats.hdd_dns_stats.rx_delivered) || |
| 11280 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_COUNT_OUT_OF_ORDER_DROP, |
| 11281 | adapter->hdd_stats.hdd_dns_stats.rx_host_drop)) { |
| 11282 | hdd_err("nla put fail"); |
| 11283 | qdf_mem_free(dns_query); |
| 11284 | kfree_skb(skb); |
| 11285 | return -EINVAL; |
| 11286 | } |
| 11287 | qdf_mem_free(dns_query); |
| 11288 | return 0; |
| 11289 | } |
| 11290 | |
| 11291 | /** |
| 11292 | * hdd_populate_tcp_stats_info() - send tcp stats info to network stack |
| 11293 | * @adapter: pointer to adapter context |
| 11294 | * @skb: pointer to skb |
| 11295 | * @pkt_type: tcp pkt type |
| 11296 | * |
| 11297 | * Return: An error code or 0 on success. |
| 11298 | */ |
| 11299 | static int hdd_populate_tcp_stats_info(struct hdd_adapter *adapter, |
| 11300 | struct sk_buff *skb, |
| 11301 | uint8_t pkt_type) |
| 11302 | { |
| 11303 | switch (pkt_type) { |
| 11304 | case CONNECTIVITY_CHECK_SET_TCP_SYN: |
| 11305 | /* Fill info for tcp syn packets (tx packet) */ |
| 11306 | if (nla_put_u16(skb, CHECK_STATS_PKT_TYPE, |
| 11307 | CONNECTIVITY_CHECK_SET_TCP_SYN) || |
| 11308 | nla_put_u16(skb, CHECK_STATS_PKT_SRC_PORT, |
| 11309 | adapter->track_src_port) || |
| 11310 | nla_put_u16(skb, CHECK_STATS_PKT_DEST_PORT, |
| 11311 | adapter->track_dest_port) || |
| 11312 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV, |
| 11313 | adapter->hdd_stats.hdd_tcp_stats.tx_tcp_syn_count) || |
| 11314 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC, |
| 11315 | adapter->hdd_stats.hdd_tcp_stats. |
| 11316 | tx_tcp_syn_host_fw_sent) || |
| 11317 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC, |
| 11318 | adapter->hdd_stats.hdd_tcp_stats. |
| 11319 | tx_tcp_syn_host_fw_sent) || |
| 11320 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS, |
| 11321 | adapter->hdd_stats.hdd_tcp_stats.tx_tcp_syn_ack_cnt)) { |
| 11322 | hdd_err("nla put fail"); |
| 11323 | kfree_skb(skb); |
| 11324 | return -EINVAL; |
| 11325 | } |
| 11326 | break; |
| 11327 | case CONNECTIVITY_CHECK_SET_TCP_SYN_ACK: |
| 11328 | /* Fill info for tcp syn-ack packets (rx packet) */ |
| 11329 | if (nla_put_u16(skb, CHECK_STATS_PKT_TYPE, |
| 11330 | CONNECTIVITY_CHECK_SET_TCP_SYN_ACK) || |
| 11331 | nla_put_u16(skb, CHECK_STATS_PKT_SRC_PORT, |
| 11332 | adapter->track_src_port) || |
| 11333 | nla_put_u16(skb, CHECK_STATS_PKT_DEST_PORT, |
| 11334 | adapter->track_dest_port) || |
| 11335 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_RX_COUNT_BY_LOWER_MAC, |
| 11336 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt) || |
| 11337 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_RX_COUNT_BY_UPPER_MAC, |
| 11338 | adapter->hdd_stats.hdd_tcp_stats. |
| 11339 | rx_tcp_syn_ack_count) || |
| 11340 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_COUNT_TO_NETDEV, |
| 11341 | adapter->hdd_stats.hdd_tcp_stats.rx_delivered) || |
| 11342 | nla_put_u16(skb, |
| 11343 | CHECK_STATS_PKT_RSP_COUNT_OUT_OF_ORDER_DROP, |
| 11344 | adapter->hdd_stats.hdd_tcp_stats.rx_host_drop)) { |
| 11345 | hdd_err("nla put fail"); |
| 11346 | kfree_skb(skb); |
| 11347 | return -EINVAL; |
| 11348 | } |
| 11349 | break; |
| 11350 | case CONNECTIVITY_CHECK_SET_TCP_ACK: |
| 11351 | /* Fill info for tcp ack packets (tx packet) */ |
| 11352 | if (nla_put_u16(skb, CHECK_STATS_PKT_TYPE, |
| 11353 | CONNECTIVITY_CHECK_SET_TCP_ACK) || |
| 11354 | nla_put_u16(skb, CHECK_STATS_PKT_SRC_PORT, |
| 11355 | adapter->track_src_port) || |
| 11356 | nla_put_u16(skb, CHECK_STATS_PKT_DEST_PORT, |
| 11357 | adapter->track_dest_port) || |
| 11358 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV, |
| 11359 | adapter->hdd_stats.hdd_tcp_stats.tx_tcp_ack_count) || |
| 11360 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC, |
| 11361 | adapter->hdd_stats.hdd_tcp_stats. |
| 11362 | tx_tcp_ack_host_fw_sent) || |
| 11363 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC, |
| 11364 | adapter->hdd_stats.hdd_tcp_stats. |
| 11365 | tx_tcp_ack_host_fw_sent) || |
| 11366 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS, |
| 11367 | adapter->hdd_stats.hdd_tcp_stats.tx_tcp_ack_ack_cnt)) { |
| 11368 | hdd_err("nla put fail"); |
| 11369 | kfree_skb(skb); |
| 11370 | return -EINVAL; |
| 11371 | } |
| 11372 | break; |
| 11373 | default: |
| 11374 | break; |
| 11375 | } |
| 11376 | return 0; |
| 11377 | } |
| 11378 | |
| 11379 | /** |
| 11380 | * hdd_populate_icmpv4_stats_info() - send icmpv4 stats info to network stack |
| 11381 | * @adapter: pointer to adapter context |
| 11382 | * @skb: pointer to skb |
| 11383 | * |
| 11384 | * |
| 11385 | * Return: An error code or 0 on success. |
| 11386 | */ |
| 11387 | static int hdd_populate_icmpv4_stats_info(struct hdd_adapter *adapter, |
| 11388 | struct sk_buff *skb) |
| 11389 | { |
| 11390 | if (nla_put_u16(skb, CHECK_STATS_PKT_TYPE, |
| 11391 | CONNECTIVITY_CHECK_SET_ICMPV4) || |
| 11392 | nla_put_u32(skb, CHECK_STATS_PKT_DEST_IPV4, |
| 11393 | adapter->track_dest_ipv4) || |
| 11394 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV, |
| 11395 | adapter->hdd_stats.hdd_icmpv4_stats.tx_icmpv4_req_count) || |
| 11396 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC, |
| 11397 | adapter->hdd_stats.hdd_icmpv4_stats.tx_host_fw_sent) || |
| 11398 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC, |
| 11399 | adapter->hdd_stats.hdd_icmpv4_stats.tx_host_fw_sent) || |
| 11400 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS, |
| 11401 | adapter->hdd_stats.hdd_icmpv4_stats.tx_ack_cnt) || |
| 11402 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_RX_COUNT_BY_LOWER_MAC, |
| 11403 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt) || |
| 11404 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_RX_COUNT_BY_UPPER_MAC, |
| 11405 | adapter->hdd_stats.hdd_icmpv4_stats.rx_icmpv4_rsp_count) || |
| 11406 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_COUNT_TO_NETDEV, |
| 11407 | adapter->hdd_stats.hdd_icmpv4_stats.rx_delivered) || |
| 11408 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_COUNT_OUT_OF_ORDER_DROP, |
| 11409 | adapter->hdd_stats.hdd_icmpv4_stats.rx_host_drop)) { |
| 11410 | hdd_err("nla put fail"); |
| 11411 | kfree_skb(skb); |
| 11412 | return -EINVAL; |
| 11413 | } |
| 11414 | return 0; |
| 11415 | } |
| 11416 | |
| 11417 | /** |
| 11418 | * hdd_populate_connectivity_check_stats_info() - send connectivity stats info |
| 11419 | * to network stack |
| 11420 | * @adapter: pointer to adapter context |
| 11421 | * @skb: pointer to skb |
| 11422 | * |
| 11423 | * |
| 11424 | * Return: An error code or 0 on success. |
| 11425 | */ |
| 11426 | |
| 11427 | static int hdd_populate_connectivity_check_stats_info( |
| 11428 | struct hdd_adapter *adapter, struct sk_buff *skb) |
| 11429 | { |
| 11430 | struct nlattr *connect_stats, *connect_info; |
| 11431 | uint32_t count = 0; |
| 11432 | |
| 11433 | connect_stats = nla_nest_start(skb, DATA_PKT_STATS); |
| 11434 | if (connect_stats == NULL) { |
| 11435 | hdd_err("nla_nest_start failed"); |
| 11436 | return -EINVAL; |
| 11437 | } |
| 11438 | |
| 11439 | if (adapter->pkt_type_bitmap & CONNECTIVITY_CHECK_SET_DNS) { |
| 11440 | connect_info = nla_nest_start(skb, count); |
| 11441 | if (connect_info == NULL) { |
| 11442 | hdd_err("nla_nest_start failed count %u", count); |
| 11443 | return -EINVAL; |
| 11444 | } |
| 11445 | |
| 11446 | if (hdd_populate_dns_stats_info(adapter, skb)) |
| 11447 | goto put_attr_fail; |
| 11448 | nla_nest_end(skb, connect_info); |
| 11449 | count++; |
| 11450 | } |
| 11451 | |
| 11452 | if (adapter->pkt_type_bitmap & CONNECTIVITY_CHECK_SET_TCP_HANDSHAKE) { |
| 11453 | connect_info = nla_nest_start(skb, count); |
| 11454 | if (connect_info == NULL) { |
| 11455 | hdd_err("nla_nest_start failed count %u", count); |
| 11456 | return -EINVAL; |
| 11457 | } |
| 11458 | if (hdd_populate_tcp_stats_info(adapter, skb, |
| 11459 | CONNECTIVITY_CHECK_SET_TCP_SYN)) |
| 11460 | goto put_attr_fail; |
| 11461 | nla_nest_end(skb, connect_info); |
| 11462 | count++; |
| 11463 | |
| 11464 | connect_info = nla_nest_start(skb, count); |
| 11465 | if (connect_info == NULL) { |
| 11466 | hdd_err("nla_nest_start failed count %u", count); |
| 11467 | return -EINVAL; |
| 11468 | } |
| 11469 | if (hdd_populate_tcp_stats_info(adapter, skb, |
| 11470 | CONNECTIVITY_CHECK_SET_TCP_SYN_ACK)) |
| 11471 | goto put_attr_fail; |
| 11472 | nla_nest_end(skb, connect_info); |
| 11473 | count++; |
| 11474 | |
| 11475 | connect_info = nla_nest_start(skb, count); |
| 11476 | if (connect_info == NULL) { |
| 11477 | hdd_err("nla_nest_start failed count %u", count); |
| 11478 | return -EINVAL; |
| 11479 | } |
| 11480 | if (hdd_populate_tcp_stats_info(adapter, skb, |
| 11481 | CONNECTIVITY_CHECK_SET_TCP_ACK)) |
| 11482 | goto put_attr_fail; |
| 11483 | nla_nest_end(skb, connect_info); |
| 11484 | count++; |
| 11485 | } |
| 11486 | |
| 11487 | if (adapter->pkt_type_bitmap & CONNECTIVITY_CHECK_SET_ICMPV4) { |
| 11488 | connect_info = nla_nest_start(skb, count); |
| 11489 | if (connect_info == NULL) { |
| 11490 | hdd_err("nla_nest_start failed count %u", count); |
| 11491 | return -EINVAL; |
| 11492 | } |
| 11493 | |
| 11494 | if (hdd_populate_icmpv4_stats_info(adapter, skb)) |
| 11495 | goto put_attr_fail; |
| 11496 | nla_nest_end(skb, connect_info); |
| 11497 | count++; |
| 11498 | } |
| 11499 | |
| 11500 | nla_nest_end(skb, connect_stats); |
| 11501 | return 0; |
| 11502 | |
| 11503 | put_attr_fail: |
| 11504 | hdd_err("QCA_WLAN_VENDOR_ATTR put fail. count %u", count); |
| 11505 | return -EINVAL; |
| 11506 | } |
| 11507 | |
| 11508 | |
| 11509 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11510 | * __wlan_hdd_cfg80211_get_nud_stats() - get arp stats command to firmware |
| 11511 | * @wiphy: pointer to wireless wiphy structure. |
| 11512 | * @wdev: pointer to wireless_dev structure. |
| 11513 | * @data: pointer to apfind configuration data. |
| 11514 | * @data_len: the length in byte of apfind data. |
| 11515 | * |
| 11516 | * This is called when wlan driver needs to get arp stats to |
| 11517 | * firmware. |
| 11518 | * |
| 11519 | * Return: An error code or 0 on success. |
| 11520 | */ |
| 11521 | static int __wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy, |
| 11522 | struct wireless_dev *wdev, |
| 11523 | const void *data, int data_len) |
| 11524 | { |
| 11525 | int err = 0; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11526 | struct net_device *dev = wdev->netdev; |
| 11527 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 11528 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 11529 | struct get_arp_stats_params arp_stats_params; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 11530 | mac_handle_t mac_handle; |
Poddar, Siddarth | db56816 | 2017-07-27 18:16:38 +0530 | [diff] [blame] | 11531 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11532 | uint32_t pkt_type_bitmap; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11533 | struct sk_buff *skb; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11534 | struct osif_request *request = NULL; |
| 11535 | static const struct osif_request_params params = { |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11536 | .priv_size = 0, |
| 11537 | .timeout_ms = WLAN_WAIT_TIME_NUD_STATS, |
| 11538 | }; |
| 11539 | void *cookie = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11540 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11541 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11542 | |
Anurag Chouhan | 9fb2bd5 | 2018-01-04 12:25:48 +0530 | [diff] [blame] | 11543 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 11544 | hdd_err("Command not allowed in FTM mode"); |
| 11545 | return -EINVAL; |
| 11546 | } |
| 11547 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11548 | err = wlan_hdd_validate_context(hdd_ctx); |
| 11549 | if (0 != err) |
| 11550 | return err; |
| 11551 | |
Rajeev Kumar | 7f28e8a3 | 2017-08-23 15:41:30 -0700 | [diff] [blame] | 11552 | err = hdd_validate_adapter(adapter); |
| 11553 | if (err) |
| 11554 | return err; |
| 11555 | |
Poddar, Siddarth | df07667 | 2018-02-26 14:21:45 +0530 | [diff] [blame] | 11556 | if (adapter->device_mode != QDF_STA_MODE) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11557 | hdd_err("STATS supported in only STA mode!"); |
Poddar, Siddarth | df07667 | 2018-02-26 14:21:45 +0530 | [diff] [blame] | 11558 | return -EINVAL; |
| 11559 | } |
| 11560 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11561 | request = osif_request_alloc(¶ms); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11562 | if (!request) { |
| 11563 | hdd_err("Request allocation failure"); |
| 11564 | return -ENOMEM; |
| 11565 | } |
| 11566 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11567 | cookie = osif_request_cookie(request); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11568 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11569 | arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE; |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 11570 | arp_stats_params.vdev_id = adapter->vdev_id; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11571 | |
Poddar, Siddarth | 762c547 | 2018-03-20 14:55:35 +0530 | [diff] [blame] | 11572 | pkt_type_bitmap = adapter->pkt_type_bitmap; |
| 11573 | |
| 11574 | /* send NUD failure event only when ARP tracking is enabled. */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 11575 | if (cdp_cfg_get(soc, cfg_dp_enable_data_stall) && |
Poddar, Siddarth | 762c547 | 2018-03-20 14:55:35 +0530 | [diff] [blame] | 11576 | (pkt_type_bitmap & CONNECTIVITY_CHECK_SET_ARP)) |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 11577 | cdp_post_data_stall_event(soc, |
| 11578 | DATA_STALL_LOG_INDICATOR_FRAMEWORK, |
Poddar, Siddarth | db56816 | 2017-07-27 18:16:38 +0530 | [diff] [blame] | 11579 | DATA_STALL_LOG_NUD_FAILURE, |
| 11580 | 0xFF, 0XFF, |
| 11581 | DATA_STALL_LOG_RECOVERY_TRIGGER_PDR); |
| 11582 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 11583 | mac_handle = hdd_ctx->mac_handle; |
| 11584 | if (sme_set_nud_debug_stats_cb(mac_handle, hdd_get_nud_stats_cb, |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11585 | cookie) != QDF_STATUS_SUCCESS) { |
| 11586 | hdd_err("Setting NUD debug stats callback failure"); |
| 11587 | err = -EINVAL; |
| 11588 | goto exit; |
| 11589 | } |
| 11590 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11591 | if (QDF_STATUS_SUCCESS != |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 11592 | sme_get_nud_debug_stats(mac_handle, &arp_stats_params)) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11593 | hdd_err("STATS_SET_START CMD Failed!"); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11594 | err = -EINVAL; |
| 11595 | goto exit; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11596 | } |
| 11597 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11598 | err = osif_request_wait_for_response(request); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11599 | if (err) { |
| 11600 | hdd_err("SME timedout while retrieving NUD stats"); |
| 11601 | err = -ETIMEDOUT; |
| 11602 | goto exit; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11603 | } |
| 11604 | |
| 11605 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 11606 | WLAN_NUD_STATS_LEN); |
| 11607 | if (!skb) { |
| 11608 | hdd_err("%s: cfg80211_vendor_cmd_alloc_reply_skb failed", |
| 11609 | __func__); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11610 | err = -ENOMEM; |
| 11611 | goto exit; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11612 | } |
| 11613 | |
| 11614 | if (nla_put_u16(skb, COUNT_FROM_NETDEV, |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 11615 | adapter->hdd_stats.hdd_arp_stats.tx_arp_req_count) || |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11616 | nla_put_u16(skb, COUNT_TO_LOWER_MAC, |
| 11617 | adapter->hdd_stats.hdd_arp_stats.tx_host_fw_sent) || |
| 11618 | nla_put_u16(skb, RX_COUNT_BY_LOWER_MAC, |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 11619 | adapter->hdd_stats.hdd_arp_stats.tx_host_fw_sent) || |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11620 | nla_put_u16(skb, COUNT_TX_SUCCESS, |
| 11621 | adapter->hdd_stats.hdd_arp_stats.tx_ack_cnt) || |
| 11622 | nla_put_u16(skb, RSP_RX_COUNT_BY_LOWER_MAC, |
| 11623 | adapter->hdd_stats.hdd_arp_stats.rx_fw_cnt) || |
| 11624 | nla_put_u16(skb, RSP_RX_COUNT_BY_UPPER_MAC, |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 11625 | adapter->hdd_stats.hdd_arp_stats.rx_arp_rsp_count) || |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11626 | nla_put_u16(skb, RSP_COUNT_TO_NETDEV, |
| 11627 | adapter->hdd_stats.hdd_arp_stats.rx_delivered) || |
| 11628 | nla_put_u16(skb, RSP_COUNT_OUT_OF_ORDER_DROP, |
| 11629 | adapter->hdd_stats.hdd_arp_stats. |
| 11630 | rx_host_drop_reorder)) { |
| 11631 | hdd_err("nla put fail"); |
| 11632 | kfree_skb(skb); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11633 | err = -EINVAL; |
| 11634 | goto exit; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11635 | } |
| 11636 | if (adapter->con_status) |
| 11637 | nla_put_flag(skb, AP_LINK_ACTIVE); |
| 11638 | if (adapter->dad) |
| 11639 | nla_put_flag(skb, AP_LINK_DAD); |
| 11640 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11641 | /* ARP tracking is done above. */ |
| 11642 | pkt_type_bitmap &= ~CONNECTIVITY_CHECK_SET_ARP; |
| 11643 | |
| 11644 | if (pkt_type_bitmap) { |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11645 | if (hdd_populate_connectivity_check_stats_info(adapter, skb)) { |
| 11646 | err = -EINVAL; |
| 11647 | goto exit; |
| 11648 | } |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11649 | } |
| 11650 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11651 | cfg80211_vendor_cmd_reply(skb); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11652 | exit: |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11653 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11654 | return err; |
| 11655 | } |
| 11656 | |
| 11657 | /** |
| 11658 | * wlan_hdd_cfg80211_get_nud_stats() - get arp stats command to firmware |
| 11659 | * @wiphy: pointer to wireless wiphy structure. |
| 11660 | * @wdev: pointer to wireless_dev structure. |
| 11661 | * @data: pointer to apfind configuration data. |
| 11662 | * @data_len: the length in byte of apfind data. |
| 11663 | * |
| 11664 | * This is called when wlan driver needs to get arp stats to |
| 11665 | * firmware. |
| 11666 | * |
| 11667 | * Return: An error code or 0 on success. |
| 11668 | */ |
| 11669 | static int wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy, |
| 11670 | struct wireless_dev *wdev, |
| 11671 | const void *data, int data_len) |
| 11672 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 11673 | int errno; |
| 11674 | struct osif_vdev_sync *vdev_sync; |
| 11675 | |
| 11676 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 11677 | if (errno) |
| 11678 | return errno; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11679 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 11680 | errno = __wlan_hdd_cfg80211_get_nud_stats(wiphy, wdev, data, data_len); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11681 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 11682 | osif_vdev_sync_op_stop(vdev_sync); |
| 11683 | |
| 11684 | return errno; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11685 | } |
| 11686 | |
| 11687 | #undef QCA_ATTR_NUD_STATS_SET_INVALID |
| 11688 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV |
| 11689 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC |
| 11690 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC |
| 11691 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS |
| 11692 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC |
| 11693 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC |
| 11694 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV |
| 11695 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP |
| 11696 | #undef QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE |
| 11697 | #undef QCA_ATTR_NUD_STATS_GET_MAX |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 11698 | |
Jeff Johnson | d0b6c7e | 2018-07-04 14:53:06 -0700 | [diff] [blame] | 11699 | void hdd_bt_activity_cb(hdd_handle_t hdd_handle, uint32_t bt_activity) |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 11700 | { |
Jeff Johnson | d0b6c7e | 2018-07-04 14:53:06 -0700 | [diff] [blame] | 11701 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 11702 | int status; |
| 11703 | |
| 11704 | status = wlan_hdd_validate_context(hdd_ctx); |
| 11705 | if (0 != status) |
| 11706 | return; |
| 11707 | |
| 11708 | if (bt_activity == WLAN_COEX_EVENT_BT_A2DP_PROFILE_ADD) |
| 11709 | hdd_ctx->bt_a2dp_active = 1; |
| 11710 | else if (bt_activity == WLAN_COEX_EVENT_BT_A2DP_PROFILE_REMOVE) |
| 11711 | hdd_ctx->bt_a2dp_active = 0; |
| 11712 | else if (bt_activity == WLAN_COEX_EVENT_BT_VOICE_PROFILE_ADD) |
| 11713 | hdd_ctx->bt_vo_active = 1; |
| 11714 | else if (bt_activity == WLAN_COEX_EVENT_BT_VOICE_PROFILE_REMOVE) |
| 11715 | hdd_ctx->bt_vo_active = 0; |
| 11716 | else |
| 11717 | return; |
| 11718 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 11719 | ucfg_scan_set_bt_activity(hdd_ctx->psoc, hdd_ctx->bt_a2dp_active); |
Srinivas Girigowda | 6598eea | 2017-07-06 19:26:19 -0700 | [diff] [blame] | 11720 | hdd_debug("a2dp_active: %d vo_active: %d", hdd_ctx->bt_a2dp_active, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 11721 | hdd_ctx->bt_vo_active); |
| 11722 | } |
| 11723 | |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11724 | struct chain_rssi_priv { |
| 11725 | struct chain_rssi_result chain_rssi; |
| 11726 | }; |
| 11727 | |
| 11728 | /** |
| 11729 | * hdd_get_chain_rssi_cb() - Callback function to get chain rssi |
| 11730 | * @context: opaque context originally passed to SME. HDD always passes |
| 11731 | * a cookie for the request context |
| 11732 | * @data: struct for get chain rssi |
| 11733 | * |
| 11734 | * This function receives the response/data from the lower layer and |
| 11735 | * checks to see if the thread is still waiting then post the results to |
| 11736 | * upper layer, if the request has timed out then ignore. |
| 11737 | * |
| 11738 | * Return: None |
| 11739 | */ |
| 11740 | static void hdd_get_chain_rssi_cb(void *context, |
| 11741 | struct chain_rssi_result *data) |
| 11742 | { |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11743 | struct osif_request *request; |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11744 | struct chain_rssi_priv *priv; |
| 11745 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11746 | hdd_enter(); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11747 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11748 | request = osif_request_get(context); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11749 | if (!request) { |
| 11750 | hdd_err("Obsolete request"); |
| 11751 | return; |
| 11752 | } |
| 11753 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11754 | priv = osif_request_priv(request); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11755 | priv->chain_rssi = *data; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11756 | osif_request_complete(request); |
| 11757 | osif_request_put(request); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11758 | } |
| 11759 | |
| 11760 | /** |
| 11761 | * hdd_post_get_chain_rssi_rsp - send rsp to user space |
| 11762 | * @hdd_ctx: pointer to hdd context |
| 11763 | * @result: chain rssi result |
| 11764 | * |
| 11765 | * Return: 0 for success, non-zero for failure |
| 11766 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 11767 | static int hdd_post_get_chain_rssi_rsp(struct hdd_context *hdd_ctx, |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11768 | struct chain_rssi_result *result) |
| 11769 | { |
| 11770 | struct sk_buff *skb; |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11771 | |
| 11772 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, |
lifeng | fe6c3e2 | 2018-04-03 12:10:04 +0800 | [diff] [blame] | 11773 | (sizeof(result->chain_rssi) + NLA_HDRLEN) + |
stonez | 396a973 | 2019-01-16 12:29:16 +0800 | [diff] [blame] | 11774 | (sizeof(result->chain_evm) + NLA_HDRLEN) + |
lifeng | fe6c3e2 | 2018-04-03 12:10:04 +0800 | [diff] [blame] | 11775 | (sizeof(result->ant_id) + NLA_HDRLEN) + |
| 11776 | NLMSG_HDRLEN); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11777 | |
| 11778 | if (!skb) { |
| 11779 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 11780 | return -ENOMEM; |
| 11781 | } |
| 11782 | |
lifeng | fe6c3e2 | 2018-04-03 12:10:04 +0800 | [diff] [blame] | 11783 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_CHAIN_RSSI, |
stonez | 396a973 | 2019-01-16 12:29:16 +0800 | [diff] [blame] | 11784 | sizeof(result->chain_rssi), |
| 11785 | result->chain_rssi)) { |
| 11786 | hdd_err("put fail"); |
| 11787 | goto nla_put_failure; |
| 11788 | } |
| 11789 | |
| 11790 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_CHAIN_EVM, |
| 11791 | sizeof(result->chain_evm), |
| 11792 | result->chain_evm)) { |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11793 | hdd_err("put fail"); |
| 11794 | goto nla_put_failure; |
| 11795 | } |
| 11796 | |
lifeng | fe6c3e2 | 2018-04-03 12:10:04 +0800 | [diff] [blame] | 11797 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_ANTENNA_INFO, |
stonez | 396a973 | 2019-01-16 12:29:16 +0800 | [diff] [blame] | 11798 | sizeof(result->ant_id), |
| 11799 | result->ant_id)) { |
lifeng | fe6c3e2 | 2018-04-03 12:10:04 +0800 | [diff] [blame] | 11800 | hdd_err("put fail"); |
| 11801 | goto nla_put_failure; |
| 11802 | } |
| 11803 | |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11804 | cfg80211_vendor_cmd_reply(skb); |
| 11805 | return 0; |
| 11806 | |
| 11807 | nla_put_failure: |
| 11808 | kfree_skb(skb); |
| 11809 | return -EINVAL; |
| 11810 | } |
| 11811 | |
| 11812 | /** |
| 11813 | * __wlan_hdd_cfg80211_get_chain_rssi() - get chain rssi |
| 11814 | * @wiphy: wiphy pointer |
| 11815 | * @wdev: pointer to struct wireless_dev |
| 11816 | * @data: pointer to incoming NL vendor data |
| 11817 | * @data_len: length of @data |
| 11818 | * |
| 11819 | * Return: 0 on success; error number otherwise. |
| 11820 | */ |
| 11821 | static int __wlan_hdd_cfg80211_get_chain_rssi(struct wiphy *wiphy, |
| 11822 | struct wireless_dev *wdev, |
| 11823 | const void *data, |
| 11824 | int data_len) |
| 11825 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 11826 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(wdev->netdev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 11827 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 11828 | mac_handle_t mac_handle; |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11829 | struct get_chain_rssi_req_params req_msg; |
| 11830 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1]; |
| 11831 | QDF_STATUS status; |
| 11832 | int retval; |
| 11833 | void *cookie; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11834 | struct osif_request *request; |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11835 | struct chain_rssi_priv *priv; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11836 | static const struct osif_request_params params = { |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11837 | .priv_size = sizeof(*priv), |
| 11838 | .timeout_ms = WLAN_WAIT_TIME_STATS, |
| 11839 | }; |
| 11840 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11841 | hdd_enter(); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11842 | |
| 11843 | retval = wlan_hdd_validate_context(hdd_ctx); |
| 11844 | if (0 != retval) |
| 11845 | return retval; |
| 11846 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 11847 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, |
| 11848 | data, data_len, NULL)) { |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11849 | hdd_err("Invalid ATTR"); |
| 11850 | return -EINVAL; |
| 11851 | } |
| 11852 | |
| 11853 | if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) { |
| 11854 | hdd_err("attr mac addr failed"); |
| 11855 | return -EINVAL; |
| 11856 | } |
| 11857 | if (nla_len(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) != |
| 11858 | QDF_MAC_ADDR_SIZE) { |
| 11859 | hdd_err("incorrect mac size"); |
| 11860 | return -EINVAL; |
| 11861 | } |
| 11862 | memcpy(&req_msg.peer_macaddr, |
| 11863 | nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]), |
| 11864 | QDF_MAC_ADDR_SIZE); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 11865 | req_msg.session_id = adapter->vdev_id; |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11866 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11867 | request = osif_request_alloc(¶ms); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11868 | if (!request) { |
| 11869 | hdd_err("Request allocation failure"); |
| 11870 | return -ENOMEM; |
| 11871 | } |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11872 | cookie = osif_request_cookie(request); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11873 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 11874 | mac_handle = hdd_ctx->mac_handle; |
| 11875 | status = sme_get_chain_rssi(mac_handle, |
| 11876 | &req_msg, |
| 11877 | hdd_get_chain_rssi_cb, |
| 11878 | cookie); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11879 | if (QDF_STATUS_SUCCESS != status) { |
| 11880 | hdd_err("Unable to get chain rssi"); |
| 11881 | retval = qdf_status_to_os_return(status); |
| 11882 | } else { |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11883 | retval = osif_request_wait_for_response(request); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11884 | if (retval) { |
| 11885 | hdd_err("Target response timed out"); |
| 11886 | } else { |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11887 | priv = osif_request_priv(request); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11888 | retval = hdd_post_get_chain_rssi_rsp(hdd_ctx, |
| 11889 | &priv->chain_rssi); |
| 11890 | if (retval) |
| 11891 | hdd_err("Failed to post chain rssi"); |
| 11892 | } |
| 11893 | } |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11894 | osif_request_put(request); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11895 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11896 | hdd_exit(); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11897 | return retval; |
| 11898 | } |
| 11899 | |
| 11900 | /** |
| 11901 | * wlan_hdd_cfg80211_get_chain_rssi() - get chain rssi |
| 11902 | * @wiphy: wiphy pointer |
| 11903 | * @wdev: pointer to struct wireless_dev |
| 11904 | * @data: pointer to incoming NL vendor data |
| 11905 | * @data_len: length of @data |
| 11906 | * |
| 11907 | * Return: 0 on success; error number otherwise. |
| 11908 | */ |
| 11909 | static int wlan_hdd_cfg80211_get_chain_rssi(struct wiphy *wiphy, |
| 11910 | struct wireless_dev *wdev, |
| 11911 | const void *data, |
| 11912 | int data_len) |
| 11913 | { |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 11914 | int errno; |
| 11915 | struct osif_vdev_sync *vdev_sync; |
| 11916 | |
| 11917 | errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); |
| 11918 | if (errno) |
| 11919 | return errno; |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11920 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 11921 | errno = __wlan_hdd_cfg80211_get_chain_rssi(wiphy, wdev, data, data_len); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11922 | |
Dustin Brown | a09acf4 | 2018-11-08 12:32:26 +0530 | [diff] [blame] | 11923 | osif_vdev_sync_op_stop(vdev_sync); |
| 11924 | |
| 11925 | return errno; |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 11926 | } |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 11927 | |
Ganesh Kondabattini | b1960e7 | 2017-09-01 09:09:50 +0530 | [diff] [blame] | 11928 | /** |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11929 | * wlan_hdd_fill_intf_info() - Fill skb buffer with interface info |
| 11930 | * @skb: Pointer to skb |
| 11931 | * @info: mac mode info |
| 11932 | * @index: attribute type index for nla_nest_start() |
| 11933 | * |
| 11934 | * Return : 0 on success and errno on failure |
| 11935 | */ |
| 11936 | static int wlan_hdd_fill_intf_info(struct sk_buff *skb, |
| 11937 | struct connection_info *info, int index) |
| 11938 | { |
| 11939 | struct nlattr *attr; |
| 11940 | uint32_t freq; |
| 11941 | struct hdd_context *hdd_ctx; |
| 11942 | struct hdd_adapter *hdd_adapter; |
| 11943 | |
| 11944 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11945 | if (!hdd_ctx) |
| 11946 | goto error; |
| 11947 | |
| 11948 | hdd_adapter = hdd_get_adapter_by_vdev(hdd_ctx, info->vdev_id); |
| 11949 | if (!hdd_adapter) |
| 11950 | goto error; |
| 11951 | |
| 11952 | attr = nla_nest_start(skb, index); |
| 11953 | if (!attr) |
| 11954 | goto error; |
| 11955 | |
| 11956 | freq = sme_chn_to_freq(info->channel); |
| 11957 | |
| 11958 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_MAC_IFACE_INFO_IFINDEX, |
| 11959 | hdd_adapter->dev->ifindex) || |
| 11960 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_MAC_IFACE_INFO_FREQ, freq)) |
| 11961 | goto error; |
| 11962 | |
| 11963 | nla_nest_end(skb, attr); |
| 11964 | |
| 11965 | return 0; |
| 11966 | error: |
| 11967 | hdd_err("Fill buffer with interface info failed"); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11968 | return -EINVAL; |
| 11969 | } |
| 11970 | |
| 11971 | /** |
| 11972 | * wlan_hdd_fill_mac_info() - Fill skb buffer with mac info |
| 11973 | * @skb: Pointer to skb |
| 11974 | * @info: mac mode info |
| 11975 | * @mac_id: MAC id |
| 11976 | * @conn_count: number of current connections |
| 11977 | * |
| 11978 | * Return : 0 on success and errno on failure |
| 11979 | */ |
| 11980 | static int wlan_hdd_fill_mac_info(struct sk_buff *skb, |
| 11981 | struct connection_info *info, uint32_t mac_id, |
| 11982 | uint32_t conn_count) |
| 11983 | { |
| 11984 | struct nlattr *attr, *intf_attr; |
| 11985 | uint32_t band = 0, i = 0, j = 0; |
| 11986 | bool present = false; |
| 11987 | |
| 11988 | while (i < conn_count) { |
| 11989 | if (info[i].mac_id == mac_id) { |
| 11990 | present = true; |
| 11991 | if (info[i].channel <= SIR_11B_CHANNEL_END) |
| 11992 | band |= 1 << NL80211_BAND_2GHZ; |
| 11993 | else if (info[i].channel <= SIR_11A_CHANNEL_END) |
| 11994 | band |= 1 << NL80211_BAND_5GHZ; |
| 11995 | } |
| 11996 | i++; |
| 11997 | } |
| 11998 | |
| 11999 | if (!present) |
| 12000 | return 0; |
| 12001 | |
| 12002 | i = 0; |
| 12003 | attr = nla_nest_start(skb, mac_id); |
| 12004 | if (!attr) |
| 12005 | goto error; |
| 12006 | |
| 12007 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_MAC_INFO_MAC_ID, mac_id) || |
| 12008 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_MAC_INFO_BAND, band)) |
| 12009 | goto error; |
| 12010 | |
| 12011 | intf_attr = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_MAC_IFACE_INFO); |
| 12012 | if (!intf_attr) |
| 12013 | goto error; |
| 12014 | |
| 12015 | while (i < conn_count) { |
| 12016 | if (info[i].mac_id == mac_id) { |
| 12017 | if (wlan_hdd_fill_intf_info(skb, &info[i], j)) |
| 12018 | return -EINVAL; |
| 12019 | j++; |
| 12020 | } |
| 12021 | i++; |
| 12022 | } |
| 12023 | |
| 12024 | nla_nest_end(skb, intf_attr); |
| 12025 | |
| 12026 | nla_nest_end(skb, attr); |
| 12027 | |
| 12028 | return 0; |
| 12029 | error: |
| 12030 | hdd_err("Fill buffer with mac info failed"); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 12031 | return -EINVAL; |
| 12032 | } |
| 12033 | |
| 12034 | |
| 12035 | int wlan_hdd_send_mode_change_event(void) |
| 12036 | { |
| 12037 | int err; |
| 12038 | struct hdd_context *hdd_ctx; |
| 12039 | struct sk_buff *skb; |
| 12040 | struct nlattr *attr; |
| 12041 | struct connection_info info[MAX_NUMBER_OF_CONC_CONNECTIONS]; |
| 12042 | uint32_t conn_count, mac_id; |
| 12043 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12044 | hdd_enter(); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 12045 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12046 | if (!hdd_ctx) { |
| 12047 | hdd_err("HDD context is NULL"); |
| 12048 | return -EINVAL; |
| 12049 | } |
| 12050 | |
| 12051 | err = wlan_hdd_validate_context(hdd_ctx); |
| 12052 | if (0 != err) |
| 12053 | return err; |
| 12054 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 12055 | conn_count = policy_mgr_get_connection_info(hdd_ctx->psoc, info); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 12056 | if (!conn_count) |
| 12057 | return -EINVAL; |
| 12058 | |
| 12059 | skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, NULL, |
| 12060 | (sizeof(uint32_t) * 4) * |
| 12061 | MAX_NUMBER_OF_CONC_CONNECTIONS + NLMSG_HDRLEN, |
| 12062 | QCA_NL80211_VENDOR_SUBCMD_WLAN_MAC_INFO_INDEX, |
| 12063 | GFP_KERNEL); |
| 12064 | if (!skb) { |
| 12065 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
| 12066 | return -ENOMEM; |
| 12067 | } |
| 12068 | |
| 12069 | attr = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_MAC_INFO); |
| 12070 | if (!attr) { |
| 12071 | hdd_err("nla_nest_start failed"); |
| 12072 | kfree_skb(skb); |
| 12073 | return -EINVAL; |
| 12074 | } |
| 12075 | |
| 12076 | for (mac_id = 0; mac_id < MAX_MAC; mac_id++) { |
Lin Bai | fac7797 | 2018-07-05 19:51:49 +0800 | [diff] [blame] | 12077 | if (wlan_hdd_fill_mac_info(skb, info, mac_id, conn_count)) { |
| 12078 | kfree_skb(skb); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 12079 | return -EINVAL; |
Lin Bai | fac7797 | 2018-07-05 19:51:49 +0800 | [diff] [blame] | 12080 | } |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 12081 | } |
| 12082 | |
| 12083 | nla_nest_end(skb, attr); |
| 12084 | |
| 12085 | cfg80211_vendor_event(skb, GFP_KERNEL); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12086 | hdd_exit(); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 12087 | |
| 12088 | return err; |
| 12089 | } |
| 12090 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12091 | const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] = { |
| 12092 | { |
| 12093 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12094 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY, |
| 12095 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
Srinivas Dasari | 947abd7 | 2016-09-02 12:11:33 +0530 | [diff] [blame] | 12096 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12097 | .doit = is_driver_dfs_capable |
| 12098 | }, |
| 12099 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12100 | #ifdef WLAN_FEATURE_STATS_EXT |
| 12101 | { |
| 12102 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12103 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_STATS_EXT, |
| 12104 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12105 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12106 | .doit = wlan_hdd_cfg80211_stats_ext_request |
| 12107 | }, |
| 12108 | #endif |
| 12109 | #ifdef FEATURE_WLAN_EXTSCAN |
| 12110 | { |
| 12111 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12112 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START, |
| 12113 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12114 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12115 | .doit = wlan_hdd_cfg80211_extscan_start |
| 12116 | }, |
| 12117 | { |
| 12118 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12119 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP, |
| 12120 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12121 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12122 | .doit = wlan_hdd_cfg80211_extscan_stop |
| 12123 | }, |
| 12124 | { |
| 12125 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12126 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS, |
Manjeet Singh | 3abd730 | 2017-01-11 16:07:42 +0530 | [diff] [blame] | 12127 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12128 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12129 | .doit = wlan_hdd_cfg80211_extscan_get_valid_channels |
| 12130 | }, |
| 12131 | { |
| 12132 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12133 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES, |
| 12134 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12135 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12136 | .doit = wlan_hdd_cfg80211_extscan_get_capabilities |
| 12137 | }, |
| 12138 | { |
| 12139 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12140 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS, |
| 12141 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12142 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12143 | .doit = wlan_hdd_cfg80211_extscan_get_cached_results |
| 12144 | }, |
| 12145 | { |
| 12146 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12147 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST, |
| 12148 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12149 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12150 | .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist |
| 12151 | }, |
| 12152 | { |
| 12153 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12154 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST, |
| 12155 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12156 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12157 | .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist |
| 12158 | }, |
| 12159 | { |
| 12160 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12161 | .info.subcmd = |
| 12162 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE, |
| 12163 | .flags = |
| 12164 | WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12165 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12166 | .doit = wlan_hdd_cfg80211_extscan_set_significant_change |
| 12167 | }, |
| 12168 | { |
| 12169 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12170 | .info.subcmd = |
| 12171 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE, |
| 12172 | .flags = |
| 12173 | WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12174 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12175 | .doit = wlan_hdd_cfg80211_extscan_reset_significant_change |
| 12176 | }, |
| 12177 | { |
| 12178 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12179 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_LIST, |
| 12180 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12181 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12182 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12183 | .doit = wlan_hdd_cfg80211_set_epno_list |
| 12184 | }, |
| 12185 | #endif /* FEATURE_WLAN_EXTSCAN */ |
| 12186 | |
| 12187 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 12188 | { |
| 12189 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12190 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR, |
| 12191 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12192 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12193 | .doit = wlan_hdd_cfg80211_ll_stats_clear |
| 12194 | }, |
| 12195 | |
| 12196 | { |
| 12197 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12198 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET, |
| 12199 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12200 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12201 | .doit = wlan_hdd_cfg80211_ll_stats_set |
| 12202 | }, |
| 12203 | |
| 12204 | { |
| 12205 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12206 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET, |
| 12207 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12208 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12209 | .doit = wlan_hdd_cfg80211_ll_stats_get |
| 12210 | }, |
| 12211 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 12212 | #ifdef FEATURE_WLAN_TDLS |
| 12213 | { |
| 12214 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12215 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE, |
| 12216 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12217 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12218 | .doit = wlan_hdd_cfg80211_exttdls_enable |
| 12219 | }, |
| 12220 | { |
| 12221 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12222 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE, |
| 12223 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12224 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12225 | .doit = wlan_hdd_cfg80211_exttdls_disable |
| 12226 | }, |
| 12227 | { |
| 12228 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12229 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS, |
| 12230 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 12231 | .doit = wlan_hdd_cfg80211_exttdls_get_status |
| 12232 | }, |
| 12233 | #endif |
| 12234 | { |
| 12235 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12236 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES, |
| 12237 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 12238 | .doit = wlan_hdd_cfg80211_get_supported_features |
| 12239 | }, |
| 12240 | { |
| 12241 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12242 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SCANNING_MAC_OUI, |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 12243 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12244 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12245 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12246 | .doit = wlan_hdd_cfg80211_set_scanning_mac_oui |
| 12247 | }, |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 12248 | |
| 12249 | FEATURE_CONCURRENCY_MATRIX_VENDOR_COMMANDS |
| 12250 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12251 | { |
| 12252 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12253 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG, |
| 12254 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 12255 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12256 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12257 | .doit = wlan_hdd_cfg80211_disable_dfs_chan_scan |
| 12258 | }, |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 12259 | { |
| 12260 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12261 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WISA, |
| 12262 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 12263 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12264 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 12265 | .doit = wlan_hdd_cfg80211_handle_wisa_cmd |
| 12266 | }, |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 12267 | |
| 12268 | FEATURE_STATION_INFO_VENDOR_COMMANDS |
| 12269 | |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 12270 | { |
| 12271 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12272 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DO_ACS, |
| 12273 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12274 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12275 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12276 | .doit = wlan_hdd_cfg80211_do_acs |
| 12277 | }, |
| 12278 | |
| 12279 | { |
| 12280 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12281 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES, |
| 12282 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12283 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 12284 | .doit = wlan_hdd_cfg80211_get_features |
| 12285 | }, |
| 12286 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 12287 | { |
| 12288 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12289 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_SET_KEY, |
| 12290 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12291 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12292 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12293 | .doit = wlan_hdd_cfg80211_keymgmt_set_key |
| 12294 | }, |
| 12295 | #endif |
| 12296 | #ifdef FEATURE_WLAN_EXTSCAN |
| 12297 | { |
| 12298 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12299 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST, |
| 12300 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12301 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12302 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12303 | .doit = wlan_hdd_cfg80211_set_passpoint_list |
| 12304 | }, |
| 12305 | { |
| 12306 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12307 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_RESET_PASSPOINT_LIST, |
| 12308 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12309 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12310 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12311 | .doit = wlan_hdd_cfg80211_reset_passpoint_list |
| 12312 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12313 | #endif /* FEATURE_WLAN_EXTSCAN */ |
| 12314 | { |
| 12315 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12316 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO, |
| 12317 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12318 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 12319 | .doit = wlan_hdd_cfg80211_get_wifi_info |
| 12320 | }, |
Paul Zhang | 3a210c5 | 2016-12-08 10:18:12 +0800 | [diff] [blame] | 12321 | #ifndef WLAN_UMAC_CONVERGENCE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12322 | { |
| 12323 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12324 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION, |
| 12325 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12326 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12327 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12328 | .doit = wlan_hdd_cfg80211_wifi_configuration_set |
| 12329 | }, |
Paul Zhang | 3a210c5 | 2016-12-08 10:18:12 +0800 | [diff] [blame] | 12330 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12331 | { |
| 12332 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 12333 | .info.subcmd = |
| 12334 | QCA_NL80211_VENDOR_SUBCMD_WIFI_TEST_CONFIGURATION, |
| 12335 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12336 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12337 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12338 | .doit = wlan_hdd_cfg80211_set_wifi_test_config |
| 12339 | }, |
| 12340 | |
| 12341 | { |
| 12342 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12343 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAM, |
| 12344 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 12345 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12346 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12347 | .doit = wlan_hdd_cfg80211_set_ext_roam_params |
| 12348 | }, |
| 12349 | { |
| 12350 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12351 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START, |
| 12352 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 12353 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12354 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12355 | .doit = wlan_hdd_cfg80211_wifi_logger_start |
| 12356 | }, |
| 12357 | { |
| 12358 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12359 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA, |
| 12360 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 12361 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12362 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12363 | .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data |
| 12364 | }, |
| 12365 | { |
| 12366 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12367 | .info.subcmd = |
| 12368 | QCA_NL80211_VENDOR_SUBCMD_GET_PREFERRED_FREQ_LIST, |
| 12369 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12370 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12371 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12372 | .doit = wlan_hdd_cfg80211_get_preferred_freq_list |
| 12373 | }, |
| 12374 | { |
| 12375 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12376 | .info.subcmd = |
| 12377 | QCA_NL80211_VENDOR_SUBCMD_SET_PROBABLE_OPER_CHANNEL, |
| 12378 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12379 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12380 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12381 | .doit = wlan_hdd_cfg80211_set_probable_oper_channel |
| 12382 | }, |
Manikandan Mohan | 5356c2b | 2016-04-03 15:51:35 -0700 | [diff] [blame] | 12383 | #ifdef WLAN_FEATURE_TSF |
| 12384 | { |
| 12385 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12386 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TSF, |
| 12387 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12388 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12389 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12390 | .doit = wlan_hdd_cfg80211_handle_tsf_cmd |
| 12391 | }, |
| 12392 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12393 | #ifdef FEATURE_WLAN_TDLS |
| 12394 | { |
| 12395 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12396 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_CAPABILITIES, |
| 12397 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12398 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12399 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12400 | .doit = wlan_hdd_cfg80211_get_tdls_capabilities |
| 12401 | }, |
| 12402 | #endif |
| 12403 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 12404 | { |
| 12405 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12406 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS, |
| 12407 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12408 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12409 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12410 | .doit = wlan_hdd_cfg80211_offloaded_packets |
| 12411 | }, |
| 12412 | #endif |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 12413 | FEATURE_RSSI_MONITOR_VENDOR_COMMANDS |
| 12414 | |
Qiwei Cai | 1083f5b | 2018-07-02 19:10:11 +0800 | [diff] [blame] | 12415 | #ifdef WLAN_NS_OFFLOAD |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12416 | { |
| 12417 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 12418 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ND_OFFLOAD, |
| 12419 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12420 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12421 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12422 | .doit = wlan_hdd_cfg80211_set_ns_offload |
| 12423 | }, |
Qiwei Cai | 1083f5b | 2018-07-02 19:10:11 +0800 | [diff] [blame] | 12424 | #endif /* WLAN_NS_OFFLOAD */ |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 12425 | { |
| 12426 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12427 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_LOGGER_FEATURE_SET, |
| 12428 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
Sourav Mohapatra | 412ceb9 | 2018-03-07 18:41:16 +0530 | [diff] [blame] | 12429 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12430 | .doit = wlan_hdd_cfg80211_get_logger_supp_feature |
| 12431 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12432 | { |
| 12433 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12434 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TRIGGER_SCAN, |
| 12435 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12436 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12437 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12438 | .doit = wlan_hdd_cfg80211_vendor_scan |
| 12439 | }, |
| 12440 | |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 12441 | /* Vendor abort scan */ |
| 12442 | { |
| 12443 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12444 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ABORT_SCAN, |
| 12445 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12446 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12447 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12448 | .doit = wlan_hdd_vendor_abort_scan |
| 12449 | }, |
| 12450 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12451 | /* OCB commands */ |
| 12452 | { |
| 12453 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12454 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_SET_CONFIG, |
| 12455 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12456 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12457 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12458 | .doit = wlan_hdd_cfg80211_ocb_set_config |
| 12459 | }, |
| 12460 | { |
| 12461 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12462 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_SET_UTC_TIME, |
| 12463 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12464 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12465 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12466 | .doit = wlan_hdd_cfg80211_ocb_set_utc_time |
| 12467 | }, |
| 12468 | { |
| 12469 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12470 | .info.subcmd = |
| 12471 | QCA_NL80211_VENDOR_SUBCMD_OCB_START_TIMING_ADVERT, |
| 12472 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12473 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12474 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12475 | .doit = wlan_hdd_cfg80211_ocb_start_timing_advert |
| 12476 | }, |
| 12477 | { |
| 12478 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12479 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_STOP_TIMING_ADVERT, |
| 12480 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12481 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12482 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12483 | .doit = wlan_hdd_cfg80211_ocb_stop_timing_advert |
| 12484 | }, |
| 12485 | { |
| 12486 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12487 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_GET_TSF_TIMER, |
| 12488 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12489 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12490 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12491 | .doit = wlan_hdd_cfg80211_ocb_get_tsf_timer |
| 12492 | }, |
| 12493 | { |
| 12494 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12495 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_GET_STATS, |
| 12496 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12497 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12498 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12499 | .doit = wlan_hdd_cfg80211_dcc_get_stats |
| 12500 | }, |
| 12501 | { |
| 12502 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12503 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_CLEAR_STATS, |
| 12504 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12505 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12506 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12507 | .doit = wlan_hdd_cfg80211_dcc_clear_stats |
| 12508 | }, |
| 12509 | { |
| 12510 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12511 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_UPDATE_NDL, |
| 12512 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12513 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12514 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12515 | .doit = wlan_hdd_cfg80211_dcc_update_ndl |
| 12516 | }, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 12517 | { |
| 12518 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12519 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES, |
| 12520 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12521 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12522 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12523 | .doit = wlan_hdd_cfg80211_get_link_properties |
| 12524 | }, |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 12525 | |
| 12526 | FEATURE_OTA_TEST_VENDOR_COMMANDS |
| 12527 | |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 12528 | #ifdef FEATURE_LFR_SUBNET_DETECTION |
| 12529 | { |
| 12530 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12531 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GW_PARAM_CONFIG, |
| 12532 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12533 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12534 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12535 | .doit = wlan_hdd_cfg80211_set_gateway_params |
| 12536 | }, |
| 12537 | #endif /* FEATURE_LFR_SUBNET_DETECTION */ |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 12538 | |
| 12539 | FEATURE_TX_POWER_VENDOR_COMMANDS |
| 12540 | |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 12541 | #ifdef FEATURE_WLAN_APF |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 12542 | { |
| 12543 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12544 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_PACKET_FILTER, |
| 12545 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12546 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12547 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 12548 | .doit = wlan_hdd_cfg80211_apf_offload |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 12549 | }, |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 12550 | #endif /* FEATURE_WLAN_APF */ |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 12551 | { |
| 12552 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12553 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ACS_POLICY, |
| 12554 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12555 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12556 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12557 | .doit = wlan_hdd_cfg80211_acs_dfs_mode |
| 12558 | }, |
| 12559 | { |
| 12560 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 12561 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_STA_CONNECT_ROAM_POLICY, |
| 12562 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12563 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12564 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12565 | .doit = wlan_hdd_cfg80211_sta_roam_policy |
| 12566 | }, |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 12567 | #ifdef FEATURE_WLAN_CH_AVOID |
| 12568 | { |
| 12569 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12570 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY, |
| 12571 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12572 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12573 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12574 | .doit = wlan_hdd_cfg80211_avoid_freq |
| 12575 | }, |
| 12576 | #endif |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 12577 | { |
| 12578 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 12579 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_SAP_CONFIG, |
| 12580 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12581 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12582 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12583 | .doit = wlan_hdd_cfg80211_sap_configuration_set |
| 12584 | }, |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 12585 | |
| 12586 | FEATURE_P2P_LISTEN_OFFLOAD_VENDOR_COMMANDS |
| 12587 | |
| 12588 | FEATURE_SAP_COND_CHAN_SWITCH_VENDOR_COMMANDS |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 12589 | { |
| 12590 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12591 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WAKE_REASON_STATS, |
| 12592 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12593 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12594 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12595 | .doit = wlan_hdd_cfg80211_get_wakelock_stats |
| 12596 | }, |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 12597 | { |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 12598 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12599 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_BUS_SIZE, |
| 12600 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12601 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12602 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12603 | .doit = wlan_hdd_cfg80211_get_bus_size |
| 12604 | }, |
| 12605 | { |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 12606 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12607 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTERNAL_ACS, |
| 12608 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12609 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12610 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12611 | .doit = wlan_hdd_cfg80211_update_vendor_channel |
| 12612 | }, |
| 12613 | { |
bings | d09dea3 | 2017-03-17 10:08:26 +0800 | [diff] [blame] | 12614 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 12615 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND, |
| 12616 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12617 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12618 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12619 | .doit = wlan_hdd_cfg80211_setband |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 12620 | }, |
| 12621 | { |
| 12622 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12623 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING, |
| 12624 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12625 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12626 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12627 | .doit = wlan_hdd_cfg80211_set_fast_roaming |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 12628 | }, |
| 12629 | #ifdef WLAN_FEATURE_DISA |
| 12630 | { |
| 12631 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12632 | .info.subcmd = |
| 12633 | QCA_NL80211_VENDOR_SUBCMD_ENCRYPTION_TEST, |
| 12634 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12635 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12636 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12637 | .doit = wlan_hdd_cfg80211_encrypt_decrypt_msg |
| 12638 | }, |
| 12639 | #endif |
Kabilan Kannan | d053aaf | 2016-10-26 02:06:14 -0700 | [diff] [blame] | 12640 | #ifdef FEATURE_WLAN_TDLS |
| 12641 | { |
| 12642 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12643 | .info.subcmd = |
| 12644 | QCA_NL80211_VENDOR_SUBCMD_CONFIGURE_TDLS, |
| 12645 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12646 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12647 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12648 | .doit = wlan_hdd_cfg80211_configure_tdls_mode |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 12649 | }, |
Kabilan Kannan | d053aaf | 2016-10-26 02:06:14 -0700 | [diff] [blame] | 12650 | #endif |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 12651 | FEATURE_SAR_LIMITS_VENDOR_COMMANDS |
| 12652 | |
Jeff Johnson | 8c83f13 | 2017-12-18 16:41:37 -0800 | [diff] [blame] | 12653 | { |
| 12654 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 12655 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS, |
| 12656 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12657 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12658 | .doit = wlan_hdd_cfg80211_set_sar_power_limits |
| 12659 | }, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 12660 | { |
| 12661 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12662 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_TRACE_LEVEL, |
| 12663 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12664 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12665 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12666 | .doit = wlan_hdd_cfg80211_set_trace_level |
| 12667 | }, |
Zhang Qian | 4ead8f0 | 2017-03-27 14:21:47 +0800 | [diff] [blame] | 12668 | { |
| 12669 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12670 | .info.subcmd = |
| 12671 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_EXT, |
| 12672 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12673 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12674 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12675 | .doit = wlan_hdd_cfg80211_ll_stats_ext_set_param |
| 12676 | }, |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12677 | { |
| 12678 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12679 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_SET, |
| 12680 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12681 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12682 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12683 | .doit = wlan_hdd_cfg80211_set_nud_stats |
| 12684 | }, |
| 12685 | { |
| 12686 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12687 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET, |
| 12688 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12689 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12690 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12691 | .doit = wlan_hdd_cfg80211_get_nud_stats |
| 12692 | }, |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 12693 | |
| 12694 | FEATURE_BSS_TRANSITION_VENDOR_COMMANDS |
Sandeep Puligilla | 063a434 | 2018-01-10 02:50:14 -0800 | [diff] [blame] | 12695 | FEATURE_SPECTRAL_SCAN_VENDOR_COMMANDS |
Paul Zhang | 3a210c5 | 2016-12-08 10:18:12 +0800 | [diff] [blame] | 12696 | #ifdef WLAN_UMAC_CONVERGENCE |
| 12697 | COMMON_VENDOR_COMMANDS |
| 12698 | #endif |
Krishna Kumaar Natarajan | f567650 | 2017-03-06 10:28:44 -0800 | [diff] [blame] | 12699 | FEATURE_11AX_VENDOR_COMMANDS |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 12700 | |
| 12701 | { |
| 12702 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 12703 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CHAIN_RSSI, |
| 12704 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 12705 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 12706 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 12707 | .doit = wlan_hdd_cfg80211_get_chain_rssi |
| 12708 | }, |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 12709 | |
| 12710 | FEATURE_ACTIVE_TOS_VENDOR_COMMANDS |
Nachiket Kukade | a6a70a9 | 2018-10-09 20:07:21 +0530 | [diff] [blame] | 12711 | FEATURE_NAN_VENDOR_COMMANDS |
Qun Zhang | ef65562 | 2019-02-25 10:48:10 +0800 | [diff] [blame] | 12712 | FEATURE_FW_STATE_COMMANDS |
Jiani Liu | a5f1722 | 2019-03-04 16:22:33 +0800 | [diff] [blame^] | 12713 | FEATURE_COEX_CONFIG_COMMANDS |
stonez | 2d68648 | 2019-03-12 14:54:26 +0800 | [diff] [blame] | 12714 | FEATURE_MPTA_HELPER_COMMANDS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12715 | }; |
| 12716 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12717 | struct hdd_context *hdd_cfg80211_wiphy_alloc(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12718 | { |
| 12719 | struct wiphy *wiphy; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 12720 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 12721 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12722 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12723 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12724 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, sizeof(*hdd_ctx)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12725 | if (!wiphy) { |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12726 | hdd_err("failed to allocate wiphy!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12727 | return NULL; |
| 12728 | } |
| 12729 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 12730 | hdd_ctx = wiphy_priv(wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 12731 | hdd_ctx->wiphy = wiphy; |
| 12732 | |
| 12733 | return hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12734 | } |
| 12735 | |
Jeff Johnson | 459d273 | 2019-03-02 10:13:25 -0800 | [diff] [blame] | 12736 | int wlan_hdd_cfg80211_update_band(struct hdd_context *hdd_ctx, |
| 12737 | struct wiphy *wiphy, |
| 12738 | enum band_info new_band) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12739 | { |
| 12740 | int i, j; |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 12741 | enum channel_state channelEnabledState; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12742 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12743 | hdd_enter(); |
Srinivas Girigowda | 5da651b | 2017-08-04 11:22:54 -0700 | [diff] [blame] | 12744 | |
| 12745 | for (i = 0; i < HDD_NUM_NL80211_BANDS; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12746 | |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 12747 | if (NULL == wiphy->bands[i]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12748 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12749 | |
| 12750 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) { |
| 12751 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 12752 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 12753 | channelEnabledState = wlan_reg_get_channel_state( |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12754 | hdd_ctx->pdev, |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 12755 | band->channels[j].hw_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12756 | |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 12757 | if (HDD_NL80211_BAND_2GHZ == i && |
Jeff Johnson | 459d273 | 2019-03-02 10:13:25 -0800 | [diff] [blame] | 12758 | BAND_5G == new_band) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12759 | /* 5G only */ |
| 12760 | #ifdef WLAN_ENABLE_SOCIAL_CHANNELS_5G_ONLY |
| 12761 | /* Enable Social channels for P2P */ |
| 12762 | if (WLAN_HDD_IS_SOCIAL_CHANNEL |
| 12763 | (band->channels[j].center_freq) |
| 12764 | && CHANNEL_STATE_ENABLE == |
| 12765 | channelEnabledState) |
| 12766 | band->channels[j].flags &= |
| 12767 | ~IEEE80211_CHAN_DISABLED; |
| 12768 | else |
| 12769 | #endif |
| 12770 | band->channels[j].flags |= |
| 12771 | IEEE80211_CHAN_DISABLED; |
| 12772 | continue; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 12773 | } else if (HDD_NL80211_BAND_5GHZ == i && |
Jeff Johnson | 459d273 | 2019-03-02 10:13:25 -0800 | [diff] [blame] | 12774 | BAND_2G == new_band) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12775 | /* 2G only */ |
| 12776 | band->channels[j].flags |= |
| 12777 | IEEE80211_CHAN_DISABLED; |
| 12778 | continue; |
| 12779 | } |
| 12780 | |
Amar Singhal | 6842e8f | 2016-02-23 16:30:32 -0800 | [diff] [blame] | 12781 | if (CHANNEL_STATE_DISABLE != channelEnabledState) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12782 | band->channels[j].flags &= |
| 12783 | ~IEEE80211_CHAN_DISABLED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12784 | } |
| 12785 | } |
| 12786 | return 0; |
| 12787 | } |
| 12788 | |
Rajeev Kumar Sirasanagandla | 686abd9 | 2017-06-08 18:09:01 +0530 | [diff] [blame] | 12789 | #if defined(CFG80211_SCAN_RANDOM_MAC_ADDR) || \ |
| 12790 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) |
| 12791 | static void wlan_hdd_cfg80211_scan_randomization_init(struct wiphy *wiphy) |
| 12792 | { |
Pragaspathi Thilagaraj | f37f393 | 2019-01-11 00:25:43 +0530 | [diff] [blame] | 12793 | wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR; |
| 12794 | wiphy->features |= NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR; |
Rajeev Kumar Sirasanagandla | 686abd9 | 2017-06-08 18:09:01 +0530 | [diff] [blame] | 12795 | } |
| 12796 | #else |
| 12797 | static void wlan_hdd_cfg80211_scan_randomization_init(struct wiphy *wiphy) |
| 12798 | { |
| 12799 | } |
| 12800 | #endif |
| 12801 | |
Peng Xu | acfdda1 | 2017-02-06 16:15:38 -0800 | [diff] [blame] | 12802 | #define WLAN_HDD_MAX_NUM_CSA_COUNTERS 2 |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 12803 | |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 12804 | #if defined(CFG80211_RAND_TA_FOR_PUBLIC_ACTION_FRAME) || \ |
| 12805 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
| 12806 | /** |
| 12807 | * wlan_hdd_cfg80211_action_frame_randomization_init() - Randomize SA of MA |
| 12808 | * frames |
| 12809 | * @wiphy: Pointer to wiphy |
| 12810 | * |
| 12811 | * This function is used to indicate the support of source mac address |
| 12812 | * randomization of management action frames |
| 12813 | * |
| 12814 | * Return: None |
| 12815 | */ |
| 12816 | static void |
| 12817 | wlan_hdd_cfg80211_action_frame_randomization_init(struct wiphy *wiphy) |
| 12818 | { |
| 12819 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA); |
| 12820 | } |
| 12821 | #else |
| 12822 | static void |
| 12823 | wlan_hdd_cfg80211_action_frame_randomization_init(struct wiphy *wiphy) |
| 12824 | { |
| 12825 | } |
| 12826 | #endif |
| 12827 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 12828 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 12829 | (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 12830 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 12831 | static void wlan_hdd_cfg80211_set_wiphy_fils_feature(struct wiphy *wiphy) |
| 12832 | { |
| 12833 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_FILS_SK_OFFLOAD); |
| 12834 | } |
| 12835 | #else |
| 12836 | static void wlan_hdd_cfg80211_set_wiphy_fils_feature(struct wiphy *wiphy) |
| 12837 | { |
| 12838 | } |
| 12839 | #endif |
| 12840 | |
gaurank kathpalia | a398d5f | 2018-02-27 16:42:22 +0530 | [diff] [blame] | 12841 | #if defined (CFG80211_SCAN_DBS_CONTROL_SUPPORT) || \ |
| 12842 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)) |
| 12843 | static void wlan_hdd_cfg80211_set_wiphy_scan_flags(struct wiphy *wiphy) |
| 12844 | { |
| 12845 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_LOW_SPAN_SCAN); |
| 12846 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_LOW_POWER_SCAN); |
| 12847 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_HIGH_ACCURACY_SCAN); |
| 12848 | } |
| 12849 | #else |
| 12850 | static void wlan_hdd_cfg80211_set_wiphy_scan_flags(struct wiphy *wiphy) |
| 12851 | { |
| 12852 | } |
| 12853 | #endif |
| 12854 | |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 12855 | #if defined(WLAN_FEATURE_SAE) && \ |
| 12856 | defined(CFG80211_EXTERNAL_AUTH_SUPPORT) |
Padma, Santhosh Kumar | 3e47c63 | 2017-09-01 20:15:27 +0530 | [diff] [blame] | 12857 | /** |
| 12858 | * wlan_hdd_cfg80211_set_wiphy_sae_feature() - Indicates support of SAE feature |
| 12859 | * @wiphy: Pointer to wiphy |
Padma, Santhosh Kumar | 3e47c63 | 2017-09-01 20:15:27 +0530 | [diff] [blame] | 12860 | * |
| 12861 | * This function is used to indicate the support of SAE |
| 12862 | * |
| 12863 | * Return: None |
| 12864 | */ |
Manikandan Mohan | 66df7fc | 2019-01-08 17:57:05 -0800 | [diff] [blame] | 12865 | static void wlan_hdd_cfg80211_set_wiphy_sae_feature(struct wiphy *wiphy) |
Padma, Santhosh Kumar | 3e47c63 | 2017-09-01 20:15:27 +0530 | [diff] [blame] | 12866 | { |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 12867 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 12868 | |
Manikandan Mohan | 66df7fc | 2019-01-08 17:57:05 -0800 | [diff] [blame] | 12869 | if (ucfg_fwol_get_sae_enable(hdd_ctx->psoc)) |
Manikandan Mohan | 5dba1c7 | 2019-01-07 16:57:03 -0800 | [diff] [blame] | 12870 | wiphy->features |= NL80211_FEATURE_SAE; |
Padma, Santhosh Kumar | 3e47c63 | 2017-09-01 20:15:27 +0530 | [diff] [blame] | 12871 | } |
| 12872 | #else |
Manikandan Mohan | 66df7fc | 2019-01-08 17:57:05 -0800 | [diff] [blame] | 12873 | static void wlan_hdd_cfg80211_set_wiphy_sae_feature(struct wiphy *wiphy) |
Padma, Santhosh Kumar | 3e47c63 | 2017-09-01 20:15:27 +0530 | [diff] [blame] | 12874 | { |
| 12875 | } |
| 12876 | #endif |
| 12877 | |
Peng Xu | 8e8b039 | 2018-04-30 11:32:34 -0700 | [diff] [blame] | 12878 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)) || \ |
| 12879 | defined(CFG80211_DFS_OFFLOAD_BACKPORT) |
| 12880 | static void wlan_hdd_cfg80211_set_dfs_offload_feature(struct wiphy *wiphy) |
| 12881 | { |
| 12882 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_DFS_OFFLOAD); |
| 12883 | } |
| 12884 | #else |
| 12885 | static void wlan_hdd_cfg80211_set_dfs_offload_feature(struct wiphy *wiphy) |
| 12886 | { |
| 12887 | wiphy->flags |= WIPHY_FLAG_DFS_OFFLOAD; |
| 12888 | } |
| 12889 | #endif |
| 12890 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 12891 | #ifdef WLAN_FEATURE_DSRC |
| 12892 | static void wlan_hdd_get_num_dsrc_ch_and_len(struct hdd_config *hdd_cfg, |
| 12893 | int *num_ch, int *ch_len) |
| 12894 | { |
| 12895 | *num_ch = QDF_ARRAY_SIZE(hdd_channels_dot11p); |
| 12896 | *ch_len = sizeof(hdd_channels_dot11p); |
| 12897 | } |
| 12898 | |
| 12899 | static void wlan_hdd_copy_dsrc_ch(char *ch_ptr, int ch_arr_len) |
| 12900 | { |
| 12901 | if (!ch_arr_len) |
| 12902 | return; |
| 12903 | qdf_mem_copy(ch_ptr, &hdd_channels_dot11p[0], ch_arr_len); |
| 12904 | } |
| 12905 | |
| 12906 | static void wlan_hdd_get_num_srd_ch_and_len(struct hdd_config *hdd_cfg, |
| 12907 | int *num_ch, int *ch_len) |
| 12908 | { |
| 12909 | *num_ch = 0; |
| 12910 | *ch_len = 0; |
| 12911 | } |
| 12912 | |
| 12913 | static void wlan_hdd_copy_srd_ch(char *ch_ptr, int ch_arr_len) |
| 12914 | { |
| 12915 | } |
| 12916 | |
Rajeev Kumar Sirasanagandla | 9770bba | 2018-09-24 20:12:28 +0530 | [diff] [blame] | 12917 | /** |
| 12918 | * wlan_hdd_populate_srd_chan_info() - Populate SRD chan info in hdd context |
| 12919 | * @hdd_ctx: pointer to hdd context |
| 12920 | * @index: SRD channel beginning index in chan_info of @hdd_ctx |
| 12921 | * |
| 12922 | * Return: Number of SRD channels populated |
| 12923 | */ |
| 12924 | static uint32_t |
| 12925 | wlan_hdd_populate_srd_chan_info(struct hdd_context *hdd_ctx, uint32_t index) |
| 12926 | { |
| 12927 | return 0; |
| 12928 | } |
| 12929 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 12930 | #else |
| 12931 | |
| 12932 | static void wlan_hdd_get_num_dsrc_ch_and_len(struct hdd_config *hdd_cfg, |
| 12933 | int *num_ch, int *ch_len) |
| 12934 | { |
| 12935 | *num_ch = 0; |
| 12936 | *ch_len = 0; |
| 12937 | } |
| 12938 | |
| 12939 | static void wlan_hdd_copy_dsrc_ch(char *ch_ptr, int ch_arr_len) |
| 12940 | { |
| 12941 | } |
| 12942 | |
| 12943 | static void wlan_hdd_get_num_srd_ch_and_len(struct hdd_config *hdd_cfg, |
| 12944 | int *num_ch, int *ch_len) |
| 12945 | { |
| 12946 | *num_ch = QDF_ARRAY_SIZE(hdd_etsi13_srd_ch); |
| 12947 | *ch_len = sizeof(hdd_etsi13_srd_ch); |
| 12948 | } |
| 12949 | |
| 12950 | static void wlan_hdd_copy_srd_ch(char *ch_ptr, int ch_arr_len) |
| 12951 | { |
| 12952 | if (!ch_arr_len) |
| 12953 | return; |
| 12954 | qdf_mem_copy(ch_ptr, &hdd_etsi13_srd_ch[0], ch_arr_len); |
| 12955 | } |
Rajeev Kumar Sirasanagandla | 9770bba | 2018-09-24 20:12:28 +0530 | [diff] [blame] | 12956 | |
| 12957 | /** |
| 12958 | * wlan_hdd_populate_srd_chan_info() - Populate SRD chan info in hdd context |
| 12959 | * @hdd_ctx: pointer to hdd context |
| 12960 | * @index: SRD channel beginning index in chan_info of @hdd_ctx |
| 12961 | * |
| 12962 | * Return: Number of SRD channels populated |
| 12963 | */ |
| 12964 | static uint32_t |
| 12965 | wlan_hdd_populate_srd_chan_info(struct hdd_context *hdd_ctx, uint32_t index) |
| 12966 | { |
| 12967 | uint32_t num_srd_ch, i; |
| 12968 | struct scan_chan_info *chan_info; |
| 12969 | |
| 12970 | num_srd_ch = QDF_ARRAY_SIZE(hdd_etsi13_srd_ch); |
| 12971 | chan_info = hdd_ctx->chan_info; |
| 12972 | |
| 12973 | for (i = 0; i < num_srd_ch; i++) |
| 12974 | chan_info[index + i].freq = hdd_etsi13_srd_ch[i].center_freq; |
| 12975 | |
| 12976 | return num_srd_ch; |
| 12977 | } |
| 12978 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 12979 | #endif |
| 12980 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12981 | /* |
| 12982 | * FUNCTION: wlan_hdd_cfg80211_init |
| 12983 | * This function is called by hdd_wlan_startup() |
| 12984 | * during initialization. |
| 12985 | * This function is used to initialize and register wiphy structure. |
| 12986 | */ |
| 12987 | int wlan_hdd_cfg80211_init(struct device *dev, |
Jeff Johnson | 30f5bba | 2019-03-08 11:58:08 -0800 | [diff] [blame] | 12988 | struct wiphy *wiphy, struct hdd_config *config) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12989 | { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 12990 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 12991 | int len_5g_ch = 0, num_ch, ch_arr_size; |
| 12992 | int num_dsrc_ch, len_dsrc_ch, num_srd_ch, len_srd_ch; |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 12993 | uint32_t *cipher_suites; |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 12994 | uint8_t allow_mcc_go_diff_bi = 0, enable_mcc = 0; |
Pragaspathi Thilagaraj | f37f393 | 2019-01-11 00:25:43 +0530 | [diff] [blame] | 12995 | bool mac_spoofing_enabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12996 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12997 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12998 | |
| 12999 | /* Now bind the underlying wlan device with wiphy */ |
| 13000 | set_wiphy_dev(wiphy, dev); |
| 13001 | |
| 13002 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
| 13003 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13004 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 13005 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 13006 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
| 13007 | #ifdef FEATURE_WLAN_STA_4ADDR_SCHEME |
| 13008 | | WIPHY_FLAG_4ADDR_STATION |
| 13009 | #endif |
| 13010 | | WIPHY_FLAG_OFFCHAN_TX; |
| 13011 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13012 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 13013 | wiphy->wowlan = &wowlan_support_cfg80211_init; |
| 13014 | #else |
| 13015 | wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT; |
| 13016 | wiphy->wowlan.n_patterns = WOWL_MAX_PTRNS_ALLOWED; |
| 13017 | wiphy->wowlan.pattern_min_len = 1; |
| 13018 | wiphy->wowlan.pattern_max_len = WOWL_PTRN_MAX_SIZE; |
| 13019 | #endif |
| 13020 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13021 | #ifdef FEATURE_WLAN_TDLS |
| 13022 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 13023 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 13024 | #endif |
| 13025 | |
| 13026 | wiphy->features |= NL80211_FEATURE_HT_IBSS; |
| 13027 | |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 13028 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) |
| 13029 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS); |
| 13030 | #endif |
| 13031 | |
gaurank kathpalia | a398d5f | 2018-02-27 16:42:22 +0530 | [diff] [blame] | 13032 | wlan_hdd_cfg80211_set_wiphy_scan_flags(wiphy); |
| 13033 | |
Manikandan Mohan | 66df7fc | 2019-01-08 17:57:05 -0800 | [diff] [blame] | 13034 | wlan_hdd_cfg80211_set_wiphy_sae_feature(wiphy); |
Padma, Santhosh Kumar | 3e47c63 | 2017-09-01 20:15:27 +0530 | [diff] [blame] | 13035 | |
Pragaspathi Thilagaraj | 24789d3 | 2018-12-10 22:28:03 +0530 | [diff] [blame] | 13036 | wlan_scan_cfg80211_add_connected_pno_support(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13037 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13038 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 13039 | |
| 13040 | wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH; |
| 13041 | |
| 13042 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 13043 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13044 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
| 13045 | | BIT(NL80211_IFTYPE_ADHOC) |
| 13046 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 13047 | | BIT(NL80211_IFTYPE_P2P_GO) |
| 13048 | | BIT(NL80211_IFTYPE_AP) |
| 13049 | | BIT(NL80211_IFTYPE_MONITOR); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13050 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 13051 | if (QDF_STATUS_SUCCESS != |
| 13052 | ucfg_policy_mgr_get_allow_mcc_go_diff_bi(hdd_ctx->psoc, |
| 13053 | &allow_mcc_go_diff_bi)) |
| 13054 | hdd_err("can't get mcc_go_diff_bi value, use default"); |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 13055 | if (QDF_STATUS_SUCCESS != |
| 13056 | ucfg_mlme_get_mcc_feature(hdd_ctx->psoc, &enable_mcc)) |
| 13057 | hdd_err("can't get enable_mcc value, use default"); |
Jeff Johnson | 30f5bba | 2019-03-08 11:58:08 -0800 | [diff] [blame] | 13058 | if (config->advertiseConcurrentOperation) { |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 13059 | if (enable_mcc) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13060 | int i; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 13061 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13062 | for (i = 0; |
| 13063 | i < ARRAY_SIZE(wlan_hdd_iface_combination); |
| 13064 | i++) { |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 13065 | if (!allow_mcc_go_diff_bi) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13066 | wlan_hdd_iface_combination[i]. |
| 13067 | beacon_int_infra_match = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13068 | } |
| 13069 | } |
| 13070 | wiphy->n_iface_combinations = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13071 | ARRAY_SIZE(wlan_hdd_iface_combination); |
| 13072 | wiphy->iface_combinations = wlan_hdd_iface_combination; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13073 | } |
| 13074 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 13075 | /* |
| 13076 | * In case of static linked driver at the time of driver unload, |
| 13077 | * module exit doesn't happens. Module cleanup helps in cleaning |
| 13078 | * of static memory. |
| 13079 | * If driver load happens statically, at the time of driver unload, |
| 13080 | * wiphy flags don't get reset because of static memory. |
| 13081 | * It's better not to store channel in static memory. |
| 13082 | */ |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 13083 | wiphy->bands[HDD_NL80211_BAND_2GHZ] = &wlan_hdd_band_2_4_ghz; |
| 13084 | wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels = |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 13085 | qdf_mem_malloc(sizeof(hdd_channels_2_4_ghz)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 13086 | if (!wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels) |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 13087 | return -ENOMEM; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 13088 | qdf_mem_copy(wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels, |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 13089 | &hdd_channels_2_4_ghz[0], |
| 13090 | sizeof(hdd_channels_2_4_ghz)); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 13091 | if ((hdd_is_5g_supported(hdd_ctx)) && |
Jeff Johnson | 30f5bba | 2019-03-08 11:58:08 -0800 | [diff] [blame] | 13092 | ((eHDD_DOT11_MODE_11b != config->dot11Mode) && |
| 13093 | (eHDD_DOT11_MODE_11g != config->dot11Mode) && |
| 13094 | (eHDD_DOT11_MODE_11b_ONLY != config->dot11Mode) && |
| 13095 | (eHDD_DOT11_MODE_11g_ONLY != config->dot11Mode))) { |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 13096 | wiphy->bands[HDD_NL80211_BAND_5GHZ] = &wlan_hdd_band_5_ghz; |
Jeff Johnson | 30f5bba | 2019-03-08 11:58:08 -0800 | [diff] [blame] | 13097 | wlan_hdd_get_num_dsrc_ch_and_len(config, &num_dsrc_ch, |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 13098 | &len_dsrc_ch); |
Jeff Johnson | 30f5bba | 2019-03-08 11:58:08 -0800 | [diff] [blame] | 13099 | wlan_hdd_get_num_srd_ch_and_len(config, &num_srd_ch, |
| 13100 | &len_srd_ch); |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 13101 | num_ch = QDF_ARRAY_SIZE(hdd_channels_5_ghz) + num_dsrc_ch + |
| 13102 | num_srd_ch; |
| 13103 | len_5g_ch = sizeof(hdd_channels_5_ghz); |
| 13104 | ch_arr_size = len_5g_ch + len_dsrc_ch + len_srd_ch; |
Ashish Kumar Dhanotiya | cc2e0d3 | 2017-08-24 20:13:08 +0530 | [diff] [blame] | 13105 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 13106 | wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels = |
| 13107 | qdf_mem_malloc(ch_arr_size); |
| 13108 | if (!wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels) |
| 13109 | goto mem_fail; |
| 13110 | wiphy->bands[HDD_NL80211_BAND_5GHZ]->n_channels = num_ch; |
Ashish Kumar Dhanotiya | cc2e0d3 | 2017-08-24 20:13:08 +0530 | [diff] [blame] | 13111 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 13112 | qdf_mem_copy(wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels, |
| 13113 | &hdd_channels_5_ghz[0], len_5g_ch); |
| 13114 | if (num_dsrc_ch) |
| 13115 | wlan_hdd_copy_dsrc_ch((char *)wiphy->bands[ |
| 13116 | HDD_NL80211_BAND_5GHZ]->channels + |
| 13117 | len_5g_ch, len_dsrc_ch); |
| 13118 | if (num_srd_ch) |
| 13119 | wlan_hdd_copy_srd_ch((char *)wiphy->bands[ |
| 13120 | HDD_NL80211_BAND_5GHZ]->channels + |
| 13121 | len_5g_ch, len_srd_ch); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13122 | } |
| 13123 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13124 | /*Initialise the supported cipher suite details */ |
Manikandan Mohan | 66df7fc | 2019-01-08 17:57:05 -0800 | [diff] [blame] | 13125 | if (ucfg_fwol_get_gcmp_enable(hdd_ctx->psoc)) { |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 13126 | cipher_suites = qdf_mem_malloc(sizeof(hdd_cipher_suites) + |
| 13127 | sizeof(hdd_gcmp_cipher_suits)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 13128 | if (!cipher_suites) |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 13129 | return -ENOMEM; |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 13130 | wiphy->n_cipher_suites = QDF_ARRAY_SIZE(hdd_cipher_suites) + |
| 13131 | QDF_ARRAY_SIZE(hdd_gcmp_cipher_suits); |
| 13132 | qdf_mem_copy(cipher_suites, &hdd_cipher_suites, |
| 13133 | sizeof(hdd_cipher_suites)); |
| 13134 | qdf_mem_copy(cipher_suites + QDF_ARRAY_SIZE(hdd_cipher_suites), |
| 13135 | &hdd_gcmp_cipher_suits, |
| 13136 | sizeof(hdd_gcmp_cipher_suits)); |
| 13137 | } else { |
| 13138 | cipher_suites = qdf_mem_malloc(sizeof(hdd_cipher_suites)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 13139 | if (!cipher_suites) |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 13140 | return -ENOMEM; |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 13141 | wiphy->n_cipher_suites = QDF_ARRAY_SIZE(hdd_cipher_suites); |
| 13142 | qdf_mem_copy(cipher_suites, &hdd_cipher_suites, |
| 13143 | sizeof(hdd_cipher_suites)); |
| 13144 | } |
| 13145 | wiphy->cipher_suites = cipher_suites; |
| 13146 | cipher_suites = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13147 | /*signal strength in mBm (100*dBm) */ |
| 13148 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 13149 | wiphy->max_remain_on_channel_duration = MAX_REMAIN_ON_CHANNEL_DURATION; |
| 13150 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13151 | if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13152 | wiphy->n_vendor_commands = |
| 13153 | ARRAY_SIZE(hdd_wiphy_vendor_commands); |
| 13154 | wiphy->vendor_commands = hdd_wiphy_vendor_commands; |
| 13155 | |
| 13156 | wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events; |
| 13157 | wiphy->n_vendor_events = |
| 13158 | ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events); |
| 13159 | } |
| 13160 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13161 | #ifdef QCA_HT_2040_COEX |
| 13162 | wiphy->features |= NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE; |
| 13163 | #endif |
Agrawal, Ashish | 4e5fa1c | 2016-09-21 19:03:43 +0530 | [diff] [blame] | 13164 | wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER; |
wadesong | a75734c | 2017-02-07 16:03:25 +0800 | [diff] [blame] | 13165 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 13166 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) || \ |
wadesong | a75734c | 2017-02-07 16:03:25 +0800 | [diff] [blame] | 13167 | defined(CFG80211_BEACON_TX_RATE_CUSTOM_BACKPORT) |
| 13168 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_LEGACY); |
| 13169 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_HT); |
| 13170 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_VHT); |
| 13171 | #endif |
| 13172 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 13173 | hdd_add_channel_switch_support(&wiphy->flags); |
Peng Xu | acfdda1 | 2017-02-06 16:15:38 -0800 | [diff] [blame] | 13174 | wiphy->max_num_csa_counters = WLAN_HDD_MAX_NUM_CSA_COUNTERS; |
Pragaspathi Thilagaraj | f37f393 | 2019-01-11 00:25:43 +0530 | [diff] [blame] | 13175 | mac_spoofing_enabled = ucfg_scan_is_mac_spoofing_enabled(hdd_ctx->psoc); |
| 13176 | if (mac_spoofing_enabled) |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 13177 | wlan_hdd_cfg80211_scan_randomization_init(wiphy); |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 13178 | wlan_hdd_cfg80211_action_frame_randomization_init(wiphy); |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 13179 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 13180 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13181 | return 0; |
Ashish Kumar Dhanotiya | cc2e0d3 | 2017-08-24 20:13:08 +0530 | [diff] [blame] | 13182 | |
| 13183 | mem_fail: |
| 13184 | hdd_err("Not enough memory to allocate channels"); |
| 13185 | if (wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels != NULL) { |
| 13186 | qdf_mem_free(wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels); |
| 13187 | wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels = NULL; |
| 13188 | } |
| 13189 | return -ENOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13190 | } |
| 13191 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 13192 | /** |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 13193 | * wlan_hdd_cfg80211_deinit() - Deinit cfg80211 |
| 13194 | * @wiphy: the wiphy to validate against |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 13195 | * |
| 13196 | * this function deinit cfg80211 and cleanup the |
Abhishek Singh | 3e6172f | 2016-05-04 16:56:48 +0530 | [diff] [blame] | 13197 | * memory allocated in wlan_hdd_cfg80211_init also |
| 13198 | * reset the global reg params. |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 13199 | * |
| 13200 | * Return: void |
| 13201 | */ |
| 13202 | void wlan_hdd_cfg80211_deinit(struct wiphy *wiphy) |
| 13203 | { |
| 13204 | int i; |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 13205 | const uint32_t *cipher_suites; |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 13206 | |
Srinivas Girigowda | 5da651b | 2017-08-04 11:22:54 -0700 | [diff] [blame] | 13207 | for (i = 0; i < HDD_NUM_NL80211_BANDS; i++) { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 13208 | if (NULL != wiphy->bands[i] && |
| 13209 | (NULL != wiphy->bands[i]->channels)) { |
| 13210 | qdf_mem_free(wiphy->bands[i]->channels); |
| 13211 | wiphy->bands[i]->channels = NULL; |
| 13212 | } |
| 13213 | } |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 13214 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 13215 | cipher_suites = wiphy->cipher_suites; |
| 13216 | wiphy->cipher_suites = NULL; |
| 13217 | wiphy->n_cipher_suites = 0; |
| 13218 | qdf_mem_free((uint32_t *)cipher_suites); |
| 13219 | cipher_suites = NULL; |
Abhishek Singh | 3e6172f | 2016-05-04 16:56:48 +0530 | [diff] [blame] | 13220 | hdd_reset_global_reg_params(); |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 13221 | } |
| 13222 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 13223 | /** |
| 13224 | * wlan_hdd_update_band_cap() - update capabilities for supported bands |
| 13225 | * @hdd_ctx: HDD context |
| 13226 | * |
| 13227 | * this function will update capabilities for supported bands |
| 13228 | * |
| 13229 | * Return: void |
| 13230 | */ |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13231 | static void wlan_hdd_update_ht_cap(struct hdd_context *hdd_ctx) |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 13232 | { |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13233 | struct mlme_ht_capabilities_info ht_cap_info = {0}; |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 13234 | QDF_STATUS status; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 13235 | uint32_t channel_bonding_mode; |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 13236 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 13237 | status = ucfg_mlme_get_ht_cap_info(hdd_ctx->psoc, &ht_cap_info); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13238 | if (QDF_STATUS_SUCCESS != status) |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 13239 | hdd_err("could not get HT capability info"); |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 13240 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 13241 | if (ht_cap_info.tx_stbc) { |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 13242 | if (NULL != hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]) |
| 13243 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]->ht_cap.cap |= |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 13244 | IEEE80211_HT_CAP_TX_STBC; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 13245 | if (NULL != hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]) |
| 13246 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]->ht_cap.cap |= |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 13247 | IEEE80211_HT_CAP_TX_STBC; |
| 13248 | } |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 13249 | |
| 13250 | if (!sme_is_feature_supported_by_fw(DOT11AC)) { |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 13251 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]-> |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 13252 | vht_cap.vht_supported = 0; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 13253 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]->vht_cap.cap = 0; |
| 13254 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]-> |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 13255 | vht_cap.vht_supported = 0; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 13256 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]->vht_cap.cap = 0; |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 13257 | } |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13258 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 13259 | if (!ht_cap_info.short_gi_20_mhz) { |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13260 | wlan_hdd_band_2_4_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 13261 | wlan_hdd_band_5_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 13262 | } |
| 13263 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 13264 | if (!ht_cap_info.short_gi_40_mhz) |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13265 | wlan_hdd_band_5_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 13266 | |
| 13267 | ucfg_mlme_get_channel_bonding_5ghz(hdd_ctx->psoc, &channel_bonding_mode); |
| 13268 | if (!channel_bonding_mode) |
| 13269 | wlan_hdd_band_5_ghz.ht_cap.cap &= |
| 13270 | ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 13271 | } |
| 13272 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 13273 | /** |
| 13274 | * wlan_hdd_update_band_cap_in_wiphy() - update channel flags based on band cap |
| 13275 | * @hdd_ctx: HDD context |
| 13276 | * |
| 13277 | * This function updates the channel flags based on the band capability set |
| 13278 | * in the MLME CFG |
| 13279 | * |
| 13280 | * Return: void |
| 13281 | */ |
| 13282 | static void wlan_hdd_update_band_cap_in_wiphy(struct hdd_context *hdd_ctx) |
| 13283 | { |
| 13284 | int i, j; |
| 13285 | uint8_t band_capability; |
| 13286 | QDF_STATUS status; |
| 13287 | struct ieee80211_supported_band *band; |
| 13288 | |
| 13289 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 13290 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13291 | hdd_err("Failed to get MLME Band Capability"); |
| 13292 | return; |
| 13293 | } |
| 13294 | |
| 13295 | for (i = 0; i < HDD_NUM_NL80211_BANDS; i++) { |
| 13296 | if (NULL == hdd_ctx->wiphy->bands[i]) |
| 13297 | continue; |
| 13298 | |
| 13299 | for (j = 0; j < hdd_ctx->wiphy->bands[i]->n_channels; j++) { |
| 13300 | band = hdd_ctx->wiphy->bands[i]; |
| 13301 | |
| 13302 | if (HDD_NL80211_BAND_2GHZ == i && |
| 13303 | BAND_5G == band_capability) { |
| 13304 | /* 5G only */ |
| 13305 | #ifdef WLAN_ENABLE_SOCIAL_CHANNELS_5G_ONLY |
| 13306 | /* Enable social channels for P2P */ |
| 13307 | if (WLAN_HDD_IS_SOCIAL_CHANNEL |
| 13308 | (band->channels[j].center_freq)) |
| 13309 | band->channels[j].flags &= |
| 13310 | ~IEEE80211_CHAN_DISABLED; |
| 13311 | else |
| 13312 | #endif |
| 13313 | band->channels[j].flags |= |
| 13314 | IEEE80211_CHAN_DISABLED; |
| 13315 | continue; |
| 13316 | } else if (HDD_NL80211_BAND_5GHZ == i && |
| 13317 | BAND_2G == band_capability) { |
| 13318 | /* 2G only */ |
| 13319 | band->channels[j].flags |= |
| 13320 | IEEE80211_CHAN_DISABLED; |
| 13321 | continue; |
| 13322 | } |
| 13323 | } |
| 13324 | } |
| 13325 | } |
| 13326 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 13327 | #ifdef FEATURE_WLAN_ESE |
| 13328 | /** |
| 13329 | * wlan_hdd_update_lfr_wiphy() - update LFR flag based on configures |
| 13330 | * @hdd_ctx: HDD context |
| 13331 | * |
| 13332 | * This function updates the LFR flag based on LFR configures |
| 13333 | * |
| 13334 | * Return: void |
| 13335 | */ |
| 13336 | static void wlan_hdd_update_lfr_wiphy(struct hdd_context *hdd_ctx) |
| 13337 | { |
| 13338 | bool fast_transition_enabled; |
| 13339 | bool lfr_enabled; |
| 13340 | bool ese_enabled; |
| 13341 | |
| 13342 | ucfg_mlme_is_fast_transition_enabled(hdd_ctx->psoc, |
| 13343 | &fast_transition_enabled); |
| 13344 | ucfg_mlme_is_lfr_enabled(hdd_ctx->psoc, &lfr_enabled); |
| 13345 | ucfg_mlme_is_ese_enabled(hdd_ctx->psoc, &ese_enabled); |
| 13346 | if (fast_transition_enabled || lfr_enabled || ese_enabled) |
| 13347 | hdd_ctx->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 13348 | } |
| 13349 | #else |
| 13350 | static void wlan_hdd_update_lfr_wiphy(struct hdd_context *hdd_ctx) |
| 13351 | { |
| 13352 | bool fast_transition_enabled; |
| 13353 | bool lfr_enabled; |
| 13354 | |
| 13355 | ucfg_mlme_is_fast_transition_enabled(hdd_ctx->psoc, |
| 13356 | &fast_transition_enabled); |
| 13357 | ucfg_mlme_is_lfr_enabled(hdd_ctx->psoc, &lfr_enabled); |
| 13358 | if (fast_transition_enabled || lfr_enabled) |
| 13359 | hdd_ctx->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 13360 | } |
| 13361 | #endif |
| 13362 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13363 | /* |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 13364 | * In this function, wiphy structure is updated after QDF |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13365 | * initialization. In wlan_hdd_cfg80211_init, only the |
| 13366 | * default values will be initialized. The final initialization |
| 13367 | * of all required members can be done here. |
| 13368 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 13369 | void wlan_hdd_update_wiphy(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13370 | { |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 13371 | int value; |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 13372 | bool fils_enabled; |
Arif Hussain | 88d1fdd | 2018-09-26 16:12:24 -0700 | [diff] [blame] | 13373 | bool dfs_master_capable = true; |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 13374 | QDF_STATUS status; |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 13375 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 13376 | ucfg_mlme_get_sap_max_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 13377 | hdd_ctx->wiphy->max_ap_assoc_sta = value; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13378 | wlan_hdd_update_ht_cap(hdd_ctx); |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 13379 | wlan_hdd_update_band_cap_in_wiphy(hdd_ctx); |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 13380 | wlan_hdd_update_lfr_wiphy(hdd_ctx); |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 13381 | |
| 13382 | fils_enabled = 0; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 13383 | status = ucfg_mlme_get_fils_enabled_info(hdd_ctx->psoc, |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 13384 | &fils_enabled); |
| 13385 | if (QDF_IS_STATUS_ERROR(status)) |
| 13386 | hdd_err("could not get fils enabled info"); |
| 13387 | if (fils_enabled) |
| 13388 | wlan_hdd_cfg80211_set_wiphy_fils_feature(hdd_ctx->wiphy); |
Arif Hussain | 88d1fdd | 2018-09-26 16:12:24 -0700 | [diff] [blame] | 13389 | |
| 13390 | status = ucfg_mlme_get_dfs_master_capability(hdd_ctx->psoc, |
| 13391 | &dfs_master_capable); |
| 13392 | if (QDF_IS_STATUS_SUCCESS(status) && dfs_master_capable) |
| 13393 | wlan_hdd_cfg80211_set_dfs_offload_feature(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13394 | } |
| 13395 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 13396 | /** |
| 13397 | * wlan_hdd_update_11n_mode - update 11n mode in hdd cfg |
| 13398 | * @cfg: hdd cfg |
| 13399 | * |
| 13400 | * this function update 11n mode in hdd cfg |
| 13401 | * |
| 13402 | * Return: void |
| 13403 | */ |
Sandeep Puligilla | 3461878 | 2019-01-04 17:42:42 -0800 | [diff] [blame] | 13404 | void wlan_hdd_update_11n_mode(struct hdd_context *hdd_ctx) |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 13405 | { |
Sandeep Puligilla | 3461878 | 2019-01-04 17:42:42 -0800 | [diff] [blame] | 13406 | struct hdd_config *cfg = hdd_ctx->config; |
| 13407 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 13408 | if (sme_is_feature_supported_by_fw(DOT11AC)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 13409 | hdd_debug("support 11ac"); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 13410 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 13411 | hdd_debug("not support 11ac"); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 13412 | if ((cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) || |
| 13413 | (cfg->dot11Mode == eHDD_DOT11_MODE_11ac)) { |
| 13414 | cfg->dot11Mode = eHDD_DOT11_MODE_11n; |
Sandeep Puligilla | 3461878 | 2019-01-04 17:42:42 -0800 | [diff] [blame] | 13415 | ucfg_mlme_set_sap_11ac_override(hdd_ctx->psoc, 0); |
| 13416 | ucfg_mlme_set_go_11ac_override(hdd_ctx->psoc, 0); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 13417 | } |
| 13418 | } |
| 13419 | } |
| 13420 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13421 | /* In this function we are registering wiphy. */ |
| 13422 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 13423 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 13424 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13425 | /* Register our wiphy dev with cfg80211 */ |
| 13426 | if (0 > wiphy_register(wiphy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 13427 | hdd_err("wiphy register failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13428 | return -EIO; |
| 13429 | } |
| 13430 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 13431 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13432 | return 0; |
| 13433 | } |
| 13434 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13435 | /* This function registers for all frame which supplicant is interested in */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 13436 | int wlan_hdd_cfg80211_register_frames(struct hdd_adapter *adapter) |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13437 | { |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13438 | mac_handle_t mac_handle = hdd_adapter_get_mac_handle(adapter); |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13439 | /* Register for all P2P action, public action etc frames */ |
| 13440 | uint16_t type = (SIR_MAC_MGMT_FRAME << 2) | (SIR_MAC_MGMT_ACTION << 4); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13441 | QDF_STATUS status; |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13442 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 13443 | hdd_enter(); |
Sourav Mohapatra | a094392 | 2018-11-21 21:26:29 +0530 | [diff] [blame] | 13444 | if (adapter->device_mode == QDF_FTM_MODE) { |
| 13445 | hdd_info("No need to register frames in FTM mode"); |
| 13446 | return 0; |
| 13447 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13448 | |
| 13449 | /* Register frame indication call back */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13450 | status = sme_register_mgmt_frame_ind_callback(mac_handle, |
| 13451 | hdd_indicate_mgmt_frame); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13452 | if (status != QDF_STATUS_SUCCESS) { |
| 13453 | hdd_err("Failed to register hdd_indicate_mgmt_frame"); |
| 13454 | goto ret_status; |
| 13455 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13456 | |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13457 | /* Right now we are registering these frame when driver is getting |
| 13458 | * initialized. Once we will move to 2.6.37 kernel, in which we have |
| 13459 | * frame register ops, we will move this code as a part of that |
| 13460 | */ |
| 13461 | |
| 13462 | /* GAS Initial Request */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13463 | status = sme_register_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
| 13464 | (uint8_t *) GAS_INITIAL_REQ, |
| 13465 | GAS_INITIAL_REQ_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13466 | if (status != QDF_STATUS_SUCCESS) { |
| 13467 | hdd_err("Failed to register GAS_INITIAL_REQ"); |
| 13468 | goto ret_status; |
| 13469 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13470 | |
| 13471 | /* GAS Initial Response */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13472 | status = sme_register_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
| 13473 | (uint8_t *) GAS_INITIAL_RSP, |
| 13474 | GAS_INITIAL_RSP_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13475 | if (status != QDF_STATUS_SUCCESS) { |
| 13476 | hdd_err("Failed to register GAS_INITIAL_RSP"); |
| 13477 | goto dereg_gas_initial_req; |
| 13478 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13479 | |
| 13480 | /* GAS Comeback Request */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13481 | status = sme_register_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
| 13482 | (uint8_t *) GAS_COMEBACK_REQ, |
| 13483 | GAS_COMEBACK_REQ_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13484 | if (status != QDF_STATUS_SUCCESS) { |
| 13485 | hdd_err("Failed to register GAS_COMEBACK_REQ"); |
| 13486 | goto dereg_gas_initial_rsp; |
| 13487 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13488 | |
| 13489 | /* GAS Comeback Response */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13490 | status = sme_register_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
| 13491 | (uint8_t *) GAS_COMEBACK_RSP, |
| 13492 | GAS_COMEBACK_RSP_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13493 | if (status != QDF_STATUS_SUCCESS) { |
| 13494 | hdd_err("Failed to register GAS_COMEBACK_RSP"); |
| 13495 | goto dereg_gas_comeback_req; |
| 13496 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13497 | |
| 13498 | /* WNM BSS Transition Request frame */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13499 | status = sme_register_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
| 13500 | (uint8_t *) WNM_BSS_ACTION_FRAME, |
| 13501 | WNM_BSS_ACTION_FRAME_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13502 | if (status != QDF_STATUS_SUCCESS) { |
| 13503 | hdd_err("Failed to register WNM_BSS_ACTION_FRAME"); |
| 13504 | goto dereg_gas_comeback_rsp; |
| 13505 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13506 | |
| 13507 | /* WNM-Notification */ |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 13508 | status = sme_register_mgmt_frame(mac_handle, adapter->vdev_id, type, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13509 | (uint8_t *) WNM_NOTIFICATION_FRAME, |
| 13510 | WNM_NOTIFICATION_FRAME_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13511 | if (status != QDF_STATUS_SUCCESS) { |
| 13512 | hdd_err("Failed to register WNM_NOTIFICATION_FRAME"); |
| 13513 | goto dereg_wnm_bss_action_frm; |
| 13514 | } |
| 13515 | |
Dustin Brown | 237baee | 2018-05-10 13:22:18 -0700 | [diff] [blame] | 13516 | return 0; |
| 13517 | |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13518 | dereg_wnm_bss_action_frm: |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13519 | sme_deregister_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
| 13520 | (uint8_t *) WNM_BSS_ACTION_FRAME, |
| 13521 | WNM_BSS_ACTION_FRAME_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13522 | dereg_gas_comeback_rsp: |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13523 | sme_deregister_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
| 13524 | (uint8_t *) GAS_COMEBACK_RSP, |
| 13525 | GAS_COMEBACK_RSP_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13526 | dereg_gas_comeback_req: |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13527 | sme_deregister_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
| 13528 | (uint8_t *) GAS_COMEBACK_REQ, |
| 13529 | GAS_COMEBACK_REQ_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13530 | dereg_gas_initial_rsp: |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13531 | sme_deregister_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
| 13532 | (uint8_t *) GAS_INITIAL_RSP, |
| 13533 | GAS_INITIAL_RSP_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13534 | dereg_gas_initial_req: |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13535 | sme_deregister_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
| 13536 | (uint8_t *) GAS_INITIAL_REQ, |
| 13537 | GAS_INITIAL_REQ_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 13538 | ret_status: |
| 13539 | return qdf_status_to_os_return(status); |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 13540 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13541 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 13542 | void wlan_hdd_cfg80211_deregister_frames(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13543 | { |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13544 | mac_handle_t mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 13545 | /* Deregister for all P2P action, public action etc frames */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13546 | uint16_t type = (SIR_MAC_MGMT_FRAME << 2) | (SIR_MAC_MGMT_ACTION << 4); |
| 13547 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 13548 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13549 | |
| 13550 | /* Right now we are registering these frame when driver is getting |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 13551 | * initialized. Once we will move to 2.6.37 kernel, in which we have |
| 13552 | * frame register ops, we will move this code as a part of that |
| 13553 | */ |
| 13554 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13555 | /* GAS Initial Request */ |
| 13556 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13557 | sme_deregister_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13558 | (uint8_t *) GAS_INITIAL_REQ, |
| 13559 | GAS_INITIAL_REQ_SIZE); |
| 13560 | |
| 13561 | /* GAS Initial Response */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13562 | sme_deregister_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13563 | (uint8_t *) GAS_INITIAL_RSP, |
| 13564 | GAS_INITIAL_RSP_SIZE); |
| 13565 | |
| 13566 | /* GAS Comeback Request */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13567 | sme_deregister_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13568 | (uint8_t *) GAS_COMEBACK_REQ, |
| 13569 | GAS_COMEBACK_REQ_SIZE); |
| 13570 | |
| 13571 | /* GAS Comeback Response */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13572 | sme_deregister_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13573 | (uint8_t *) GAS_COMEBACK_RSP, |
| 13574 | GAS_COMEBACK_RSP_SIZE); |
| 13575 | |
| 13576 | /* P2P Public Action */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13577 | sme_deregister_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13578 | (uint8_t *) P2P_PUBLIC_ACTION_FRAME, |
| 13579 | P2P_PUBLIC_ACTION_FRAME_SIZE); |
| 13580 | |
| 13581 | /* P2P Action */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13582 | sme_deregister_mgmt_frame(mac_handle, SME_SESSION_ID_ANY, type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13583 | (uint8_t *) P2P_ACTION_FRAME, |
| 13584 | P2P_ACTION_FRAME_SIZE); |
| 13585 | |
| 13586 | /* WNM-Notification */ |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 13587 | sme_deregister_mgmt_frame(mac_handle, adapter->vdev_id, type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13588 | (uint8_t *) WNM_NOTIFICATION_FRAME, |
| 13589 | WNM_NOTIFICATION_FRAME_SIZE); |
| 13590 | } |
| 13591 | |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 13592 | #if defined(FEATURE_WLAN_WAPI) && !defined(CRYPTO_SET_KEY_CONVERGED) |
Sourav Mohapatra | d21fc6b | 2018-06-01 11:31:14 +0530 | [diff] [blame] | 13593 | static void wlan_hdd_cfg80211_set_key_wapi(struct hdd_adapter *adapter, |
| 13594 | uint8_t key_index, |
| 13595 | const uint8_t *mac_addr, |
| 13596 | const uint8_t *key, |
| 13597 | int key_Len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13598 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13599 | tCsrRoamSetKey setKey; |
| 13600 | bool isConnected = true; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13601 | QDF_STATUS status; |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 13602 | uint32_t roam_id = INVALID_ROAM_ID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13603 | uint8_t *pKeyPtr = NULL; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13604 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13605 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 13606 | hdd_debug("Device_mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 13607 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13608 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 13609 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13610 | setKey.keyId = key_index; /* Store Key ID */ |
| 13611 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; /* SET WAPI Encryption */ |
| 13612 | setKey.keyDirection = eSIR_TX_RX; /* Key Directionn both TX and RX */ |
| 13613 | setKey.paeRole = 0; /* the PAE role */ |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 13614 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 13615 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 13616 | else |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 13617 | qdf_mem_copy(setKey.peerMac.bytes, mac_addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 13618 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13619 | setKey.keyLength = key_Len; |
| 13620 | pKeyPtr = setKey.Key; |
| 13621 | memcpy(pKeyPtr, key, key_Len); |
| 13622 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 13623 | hdd_debug("WAPI KEY LENGTH:0x%04x", key_Len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13624 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13625 | if (isConnected) { |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13626 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 13627 | status = sme_roam_set_key(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 13628 | adapter->vdev_id, |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 13629 | &setKey, &roam_id); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13630 | if (status != QDF_STATUS_SUCCESS) |
Jeff Johnson | fee20aa | 2017-10-30 21:33:14 -0700 | [diff] [blame] | 13631 | hdd_err("sme_roam_set_key failed status: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13632 | } |
| 13633 | } |
| 13634 | #endif /* FEATURE_WLAN_WAPI */ |
| 13635 | |
Krunal Soni | 364e087 | 2017-05-10 21:24:34 -0700 | [diff] [blame] | 13636 | bool wlan_hdd_is_ap_supports_immediate_power_save(uint8_t *ies, int length) |
| 13637 | { |
Naveen Rawat | 08db88f | 2017-09-08 15:07:48 -0700 | [diff] [blame] | 13638 | const uint8_t *vendor_ie; |
Krunal Soni | 364e087 | 2017-05-10 21:24:34 -0700 | [diff] [blame] | 13639 | |
| 13640 | if (length < 2) { |
| 13641 | hdd_debug("bss size is less than expected"); |
| 13642 | return true; |
| 13643 | } |
| 13644 | if (!ies) { |
| 13645 | hdd_debug("invalid IE pointer"); |
| 13646 | return true; |
| 13647 | } |
Naveen Rawat | 08db88f | 2017-09-08 15:07:48 -0700 | [diff] [blame] | 13648 | vendor_ie = wlan_get_vendor_ie_ptr_from_oui(VENDOR1_AP_OUI_TYPE, |
Krunal Soni | 364e087 | 2017-05-10 21:24:34 -0700 | [diff] [blame] | 13649 | VENDOR1_AP_OUI_TYPE_SIZE, ies, length); |
| 13650 | if (vendor_ie) { |
| 13651 | hdd_debug("AP can't support immediate powersave. defer it"); |
| 13652 | return false; |
| 13653 | } |
| 13654 | return true; |
| 13655 | } |
| 13656 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13657 | /* |
| 13658 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 13659 | * called by wlan_hdd_cfg80211_start_bss() and |
| 13660 | * wlan_hdd_set_channel() |
| 13661 | * This function validates whether given channel is part of valid |
| 13662 | * channel list. |
| 13663 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 13664 | QDF_STATUS wlan_hdd_validate_operation_channel(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13665 | int channel) |
| 13666 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13667 | uint32_t num_ch = 0; |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 13668 | u8 valid_ch[CFG_VALID_CHANNEL_LIST_LEN]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13669 | u32 indx = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13670 | uint8_t fValidChannel = false, count = 0; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 13671 | QDF_STATUS status; |
| 13672 | bool value; |
| 13673 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13674 | |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 13675 | num_ch = CFG_VALID_CHANNEL_LIST_LEN; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 13676 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 13677 | status = ucfg_mlme_get_sap_allow_all_channels(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 13678 | if (status != QDF_STATUS_SUCCESS) |
| 13679 | hdd_err("Unable to fetch sap allow all channels"); |
| 13680 | if (value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13681 | /* Validate the channel */ |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 13682 | for (count = CHAN_ENUM_1; count <= CHAN_ENUM_173; count++) { |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13683 | if (channel == WLAN_REG_CH_NUM(count)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13684 | fValidChannel = true; |
| 13685 | break; |
| 13686 | } |
| 13687 | } |
| 13688 | if (fValidChannel != true) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 13689 | hdd_err("Invalid Channel: %d", channel); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13690 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13691 | } |
| 13692 | } else { |
Wu Gao | f3cbeaf | 2019-01-15 18:26:25 +0800 | [diff] [blame] | 13693 | ucfg_mlme_get_valid_channel_list(hdd_ctx->psoc, valid_ch, |
| 13694 | &num_ch); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13695 | for (indx = 0; indx < num_ch; indx++) { |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 13696 | if (channel == valid_ch[indx]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13697 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13698 | } |
| 13699 | |
| 13700 | if (indx >= num_ch) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 13701 | hdd_err("Invalid Channel: %d", channel); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13702 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13703 | } |
| 13704 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13705 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13706 | |
| 13707 | } |
| 13708 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13709 | static int __wlan_hdd_cfg80211_change_bss(struct wiphy *wiphy, |
| 13710 | struct net_device *dev, |
| 13711 | struct bss_parameters *params) |
| 13712 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 13713 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13714 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13715 | int ret = 0; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 13716 | QDF_STATUS qdf_ret_status; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13717 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13718 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 13719 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13720 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13721 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 13722 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13723 | return -EINVAL; |
| 13724 | } |
| 13725 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 13726 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13727 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13728 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 13729 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 13730 | TRACE_CODE_HDD_CFG80211_CHANGE_BSS, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 13731 | adapter->vdev_id, params->ap_isolate); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 13732 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 13733 | hdd_debug("Device_mode %s(%d), ap_isolate = %d", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 13734 | qdf_opmode_str(adapter->device_mode), |
| 13735 | adapter->device_mode, params->ap_isolate); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13736 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 13737 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 13738 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13739 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13740 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13741 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 13742 | if (!(adapter->device_mode == QDF_SAP_MODE || |
| 13743 | adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13744 | return -EOPNOTSUPP; |
| 13745 | } |
| 13746 | |
| 13747 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 13748 | * want to update this parameter |
| 13749 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13750 | if (-1 != params->ap_isolate) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13751 | adapter->session.ap.disable_intrabss_fwd = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13752 | !!params->ap_isolate; |
| 13753 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 13754 | mac_handle = hdd_ctx->mac_handle; |
| 13755 | qdf_ret_status = sme_ap_disable_intra_bss_fwd(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 13756 | adapter->vdev_id, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13757 | adapter->session. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13758 | ap. |
Jeff Johnson | 82ceb08 | 2017-10-27 14:52:42 -0700 | [diff] [blame] | 13759 | disable_intrabss_fwd); |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 13760 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13761 | ret = -EINVAL; |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 13762 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 13763 | ucfg_ipa_set_ap_ibss_fwd(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 13764 | adapter->session.ap. |
| 13765 | disable_intrabss_fwd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13766 | } |
| 13767 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 13768 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13769 | return ret; |
| 13770 | } |
| 13771 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 13772 | /** |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13773 | * hdd_change_adapter_mode() - change @adapter's operating mode to @new_mode |
| 13774 | * @adapter: the adapter to change modes on |
| 13775 | * @new_mode: the new operating mode to change to |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 13776 | * |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13777 | * Return: Errno |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 13778 | */ |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13779 | static int hdd_change_adapter_mode(struct hdd_adapter *adapter, |
| 13780 | enum QDF_OPMODE new_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13781 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 13782 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13783 | struct net_device *netdev = adapter->dev; |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 13784 | struct hdd_config *config = hdd_ctx->config; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 13785 | struct csr_roam_profile *roam_profile; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 13786 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13787 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 13788 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13789 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 13790 | if (test_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags)) { |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13791 | hdd_warn("Can't change interface: ACS in progress"); |
Sandeep Puligilla | 1e6da36 | 2017-04-07 14:16:03 -0700 | [diff] [blame] | 13792 | return -EBUSY; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13793 | } |
| 13794 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 13795 | hdd_stop_adapter(hdd_ctx, adapter); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 13796 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Dustin Brown | 194aeca | 2018-10-12 15:37:36 -0700 | [diff] [blame] | 13797 | adapter->device_mode = new_mode; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13798 | memset(&adapter->session, 0, sizeof(adapter->session)); |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13799 | hdd_set_station_ops(netdev); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 13800 | |
| 13801 | roam_profile = hdd_roam_profile(adapter); |
| 13802 | roam_profile->pAddIEScan = adapter->scan_info.scan_add_ie.addIEdata; |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13803 | roam_profile->nAddIEScanLength = adapter->scan_info.scan_add_ie.length; |
| 13804 | |
| 13805 | if (new_mode == QDF_IBSS_MODE) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 13806 | status = hdd_start_station_adapter(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 13807 | roam_profile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 13808 | roam_profile->phyMode = |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 13809 | hdd_cfg_xlate_to_csr_phy_mode(config->dot11Mode); |
| 13810 | } |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13811 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 13812 | hdd_exit(); |
Sandeep Puligilla | 1e6da36 | 2017-04-07 14:16:03 -0700 | [diff] [blame] | 13813 | |
| 13814 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13815 | } |
| 13816 | |
| 13817 | static int wlan_hdd_cfg80211_change_bss(struct wiphy *wiphy, |
| 13818 | struct net_device *dev, |
| 13819 | struct bss_parameters *params) |
| 13820 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 13821 | int errno; |
| 13822 | struct osif_vdev_sync *vdev_sync; |
| 13823 | |
| 13824 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 13825 | if (errno) |
| 13826 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13827 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 13828 | errno = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13829 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 13830 | osif_vdev_sync_op_stop(vdev_sync); |
| 13831 | |
| 13832 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13833 | } |
| 13834 | |
Rajeev Kumar | 98edb77 | 2016-01-19 12:42:19 -0800 | [diff] [blame] | 13835 | /** |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 13836 | * hdd_nl_to_policy_mgr_iface_type() - map nl80211_iftype to policy_mgr_con_mode |
| 13837 | * @type: the input NL80211 interface type to map |
| 13838 | * |
| 13839 | * Return: policy_mgr_con_mode |
| 13840 | */ |
| 13841 | static enum policy_mgr_con_mode |
| 13842 | hdd_nl_to_policy_mgr_iface_type(enum nl80211_iftype type) |
| 13843 | { |
| 13844 | switch (type) { |
| 13845 | case NL80211_IFTYPE_STATION: |
| 13846 | return PM_STA_MODE; |
| 13847 | case NL80211_IFTYPE_P2P_CLIENT: |
| 13848 | return PM_P2P_CLIENT_MODE; |
| 13849 | case NL80211_IFTYPE_P2P_GO: |
| 13850 | return PM_P2P_GO_MODE; |
| 13851 | case NL80211_IFTYPE_AP: |
| 13852 | return PM_SAP_MODE; |
| 13853 | case NL80211_IFTYPE_ADHOC: |
| 13854 | return PM_IBSS_MODE; |
| 13855 | default: |
| 13856 | hdd_err("Unsupported interface type: %d", type); |
| 13857 | return PM_MAX_NUM_OF_MODE; |
| 13858 | } |
| 13859 | } |
| 13860 | |
| 13861 | static bool hdd_is_client_mode(enum QDF_OPMODE mode) |
| 13862 | { |
| 13863 | switch (mode) { |
| 13864 | case QDF_STA_MODE: |
| 13865 | case QDF_P2P_CLIENT_MODE: |
| 13866 | case QDF_P2P_DEVICE_MODE: |
| 13867 | case QDF_IBSS_MODE: |
| 13868 | return true; |
| 13869 | default: |
| 13870 | return false; |
| 13871 | } |
| 13872 | } |
| 13873 | |
| 13874 | static bool hdd_is_ap_mode(enum QDF_OPMODE mode) |
| 13875 | { |
| 13876 | switch (mode) { |
| 13877 | case QDF_SAP_MODE: |
| 13878 | case QDF_P2P_GO_MODE: |
| 13879 | return true; |
| 13880 | default: |
| 13881 | return false; |
| 13882 | } |
| 13883 | } |
| 13884 | |
| 13885 | /** |
Rajeev Kumar | 98edb77 | 2016-01-19 12:42:19 -0800 | [diff] [blame] | 13886 | * __wlan_hdd_cfg80211_change_iface() - change interface cfg80211 op |
| 13887 | * @wiphy: Pointer to the wiphy structure |
| 13888 | * @ndev: Pointer to the net device |
| 13889 | * @type: Interface type |
| 13890 | * @flags: Flags for change interface |
| 13891 | * @params: Pointer to change interface parameters |
| 13892 | * |
| 13893 | * Return: 0 for success, error number on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13894 | */ |
| 13895 | static int __wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy, |
| 13896 | struct net_device *ndev, |
| 13897 | enum nl80211_iftype type, |
| 13898 | u32 *flags, |
| 13899 | struct vif_params *params) |
| 13900 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 13901 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 13902 | struct hdd_context *hdd_ctx; |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13903 | bool iff_up = ndev->flags & IFF_UP; |
| 13904 | enum QDF_OPMODE new_mode; |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 13905 | bool ap_random_bssid_enabled; |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13906 | QDF_STATUS status; |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 13907 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13908 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 13909 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13910 | |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 13911 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 13912 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13913 | return -EINVAL; |
| 13914 | } |
| 13915 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 13916 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 2ab5a97 | 2018-10-09 17:19:37 -0700 | [diff] [blame] | 13917 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13918 | if (errno) |
| 13919 | return errno; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 13920 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 13921 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 13922 | TRACE_CODE_HDD_CFG80211_CHANGE_IFACE, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 13923 | adapter->vdev_id, type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13924 | |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13925 | status = hdd_nl_to_qdf_iface_type(type, &new_mode); |
| 13926 | if (QDF_IS_STATUS_ERROR(status)) |
| 13927 | return qdf_status_to_os_return(status); |
| 13928 | |
Dustin Brown | 194aeca | 2018-10-12 15:37:36 -0700 | [diff] [blame] | 13929 | /* A userspace issue leads to it sending a 'change to station mode' |
| 13930 | * request on a "p2p" device, expecting the driver do execute a 'change |
| 13931 | * to p2p-device mode' request instead. The (unfortunate) work around |
| 13932 | * here is implemented by overriding the new mode if the net_device name |
| 13933 | * starts with "p2p" and the requested mode was station. |
| 13934 | */ |
| 13935 | if (strnstr(ndev->name, "p2p", 3) && new_mode == QDF_STA_MODE) |
| 13936 | new_mode = QDF_P2P_DEVICE_MODE; |
| 13937 | |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13938 | hdd_debug("Changing mode for '%s' from %s to %s", |
| 13939 | ndev->name, |
| 13940 | qdf_opmode_str(adapter->device_mode), |
| 13941 | qdf_opmode_str(new_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13942 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 13943 | errno = hdd_psoc_idle_restart(hdd_ctx); |
Dustin Brown | 2ab5a97 | 2018-10-09 17:19:37 -0700 | [diff] [blame] | 13944 | if (errno) { |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 13945 | hdd_err("Failed to restart psoc; errno:%d", errno); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13946 | return -EINVAL; |
| 13947 | } |
| 13948 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 13949 | if (!policy_mgr_allow_concurrency(hdd_ctx->psoc, |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 13950 | hdd_nl_to_policy_mgr_iface_type(type), |
| 13951 | 0, HW_MODE_20_MHZ)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 13952 | hdd_debug("This concurrency combination is not allowed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13953 | return -EINVAL; |
| 13954 | } |
| 13955 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13956 | /* Reset the current device mode bit mask */ |
Dustin Brown | 2ab5a97 | 2018-10-09 17:19:37 -0700 | [diff] [blame] | 13957 | policy_mgr_clear_concurrency_mode(hdd_ctx->psoc, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13958 | |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 13959 | if (hdd_is_client_mode(adapter->device_mode)) { |
| 13960 | if (hdd_is_client_mode(new_mode)) { |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13961 | if (new_mode == QDF_IBSS_MODE) |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 13962 | hdd_deregister_tx_flow_control(adapter); |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13963 | |
| 13964 | errno = hdd_change_adapter_mode(adapter, new_mode); |
Liangwei Dong | 4d35cad | 2018-11-02 02:38:50 -0400 | [diff] [blame] | 13965 | if (errno) { |
| 13966 | hdd_err("change intf mode fail %d", errno); |
| 13967 | goto err; |
| 13968 | } |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 13969 | } else if (hdd_is_ap_mode(new_mode)) { |
| 13970 | if (new_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13971 | wlan_hdd_cancel_existing_remain_on_channel |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 13972 | (adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13973 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 13974 | hdd_stop_adapter(hdd_ctx, adapter); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 13975 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Dustin Brown | 2ab5a97 | 2018-10-09 17:19:37 -0700 | [diff] [blame] | 13976 | memset(&adapter->session, 0, sizeof(adapter->session)); |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 13977 | adapter->device_mode = new_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13978 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 13979 | status = ucfg_mlme_get_ap_random_bssid_enable( |
| 13980 | hdd_ctx->psoc, |
| 13981 | &ap_random_bssid_enabled); |
| 13982 | if (QDF_IS_STATUS_ERROR(status)) |
| 13983 | return qdf_status_to_os_return(status); |
| 13984 | |
Dustin Brown | 2ab5a97 | 2018-10-09 17:19:37 -0700 | [diff] [blame] | 13985 | if (adapter->device_mode == QDF_SAP_MODE && |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 13986 | ap_random_bssid_enabled) { |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 13987 | /* To meet Android requirements create |
| 13988 | * a randomized MAC address of the |
| 13989 | * form 02:1A:11:Fx:xx:xx |
| 13990 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13991 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 13992 | ndev->dev_addr[0] = 0x02; |
| 13993 | ndev->dev_addr[1] = 0x1A; |
| 13994 | ndev->dev_addr[2] = 0x11; |
| 13995 | ndev->dev_addr[3] |= 0xF0; |
Dustin Brown | 2ab5a97 | 2018-10-09 17:19:37 -0700 | [diff] [blame] | 13996 | memcpy(adapter->mac_addr.bytes, ndev->dev_addr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13997 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13998 | pr_info("wlan: Generated HotSpot BSSID " |
| 13999 | MAC_ADDRESS_STR "\n", |
| 14000 | MAC_ADDR_ARRAY(ndev->dev_addr)); |
| 14001 | } |
| 14002 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14003 | hdd_set_ap_ops(adapter->dev); |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 14004 | } else { |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 14005 | hdd_err("Changing to device mode '%s' is not supported", |
| 14006 | qdf_opmode_str(new_mode)); |
Liangwei Dong | 4d35cad | 2018-11-02 02:38:50 -0400 | [diff] [blame] | 14007 | errno = -EOPNOTSUPP; |
| 14008 | goto err; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14009 | } |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 14010 | } else if (hdd_is_ap_mode(adapter->device_mode)) { |
| 14011 | if (hdd_is_client_mode(new_mode)) { |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 14012 | errno = hdd_change_adapter_mode(adapter, new_mode); |
Liangwei Dong | 4d35cad | 2018-11-02 02:38:50 -0400 | [diff] [blame] | 14013 | if (errno) { |
| 14014 | hdd_err("change mode fail %d", errno); |
| 14015 | goto err; |
| 14016 | } |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 14017 | } else if (hdd_is_ap_mode(new_mode)) { |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 14018 | adapter->device_mode = new_mode; |
| 14019 | |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 14020 | /* avoid starting the adapter, since it never stopped */ |
| 14021 | iff_up = false; |
| 14022 | } else { |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 14023 | hdd_err("Changing to device mode '%s' is not supported", |
| 14024 | qdf_opmode_str(new_mode)); |
Liangwei Dong | 4d35cad | 2018-11-02 02:38:50 -0400 | [diff] [blame] | 14025 | errno = -EOPNOTSUPP; |
| 14026 | goto err; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14027 | } |
| 14028 | } else { |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 14029 | hdd_err("Changing from device mode '%s' is not supported", |
| 14030 | qdf_opmode_str(adapter->device_mode)); |
Liangwei Dong | 4d35cad | 2018-11-02 02:38:50 -0400 | [diff] [blame] | 14031 | errno = -EOPNOTSUPP; |
| 14032 | goto err; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14033 | } |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 14034 | |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 14035 | /* restart the adapter if it was up before the change iface request */ |
| 14036 | if (iff_up) { |
| 14037 | errno = hdd_start_adapter(adapter); |
| 14038 | if (errno) { |
| 14039 | hdd_err("Failed to start adapter"); |
Liangwei Dong | 4d35cad | 2018-11-02 02:38:50 -0400 | [diff] [blame] | 14040 | errno = -EINVAL; |
| 14041 | goto err; |
Dustin Brown | 63fe492 | 2018-10-12 15:02:26 -0700 | [diff] [blame] | 14042 | } |
| 14043 | } |
| 14044 | |
| 14045 | ndev->ieee80211_ptr->iftype = type; |
Liangwei Dong | 4d35cad | 2018-11-02 02:38:50 -0400 | [diff] [blame] | 14046 | hdd_lpass_notify_mode_change(adapter); |
| 14047 | err: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14048 | /* Set bitmask based on updated value */ |
Dustin Brown | 2ab5a97 | 2018-10-09 17:19:37 -0700 | [diff] [blame] | 14049 | policy_mgr_set_concurrency_mode(hdd_ctx->psoc, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14050 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 14051 | hdd_exit(); |
Dustin Brown | 2ab5a97 | 2018-10-09 17:19:37 -0700 | [diff] [blame] | 14052 | |
Liangwei Dong | 4d35cad | 2018-11-02 02:38:50 -0400 | [diff] [blame] | 14053 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14054 | } |
| 14055 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 14056 | static int _wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy, |
| 14057 | struct net_device *net_dev, |
| 14058 | enum nl80211_iftype type, |
| 14059 | u32 *flags, |
| 14060 | struct vif_params *params) |
| 14061 | { |
| 14062 | int errno; |
| 14063 | struct osif_vdev_sync *vdev_sync; |
| 14064 | |
| 14065 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 14066 | if (errno) |
| 14067 | return errno; |
| 14068 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 14069 | errno = __wlan_hdd_cfg80211_change_iface(wiphy, net_dev, type, |
| 14070 | flags, params); |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 14071 | |
| 14072 | osif_vdev_sync_trans_stop(vdev_sync); |
| 14073 | |
| 14074 | return errno; |
| 14075 | } |
| 14076 | |
Dustin Brown | 9ed30a5 | 2017-08-16 13:59:38 -0700 | [diff] [blame] | 14077 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) |
Rajeev Kumar | 98edb77 | 2016-01-19 12:42:19 -0800 | [diff] [blame] | 14078 | /** |
| 14079 | * wlan_hdd_cfg80211_change_iface() - change interface cfg80211 op |
| 14080 | * @wiphy: Pointer to the wiphy structure |
| 14081 | * @ndev: Pointer to the net device |
| 14082 | * @type: Interface type |
| 14083 | * @flags: Flags for change interface |
| 14084 | * @params: Pointer to change interface parameters |
| 14085 | * |
| 14086 | * Return: 0 for success, error number on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14087 | */ |
| 14088 | static int wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy, |
| 14089 | struct net_device *ndev, |
| 14090 | enum nl80211_iftype type, |
| 14091 | u32 *flags, |
| 14092 | struct vif_params *params) |
| 14093 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 14094 | return _wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, |
| 14095 | flags, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14096 | } |
Dustin Brown | 9ed30a5 | 2017-08-16 13:59:38 -0700 | [diff] [blame] | 14097 | #else |
| 14098 | static int wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy, |
| 14099 | struct net_device *ndev, |
| 14100 | enum nl80211_iftype type, |
| 14101 | struct vif_params *params) |
| 14102 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 14103 | return _wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, |
Dustin Brown | 9ed30a5 | 2017-08-16 13:59:38 -0700 | [diff] [blame] | 14104 | ¶ms->flags, params); |
Dustin Brown | 9ed30a5 | 2017-08-16 13:59:38 -0700 | [diff] [blame] | 14105 | } |
| 14106 | #endif /* KERNEL_VERSION(4, 12, 0) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14107 | |
Ashish Kumar Dhanotiya | 42b0378 | 2018-01-16 10:55:16 +0530 | [diff] [blame] | 14108 | QDF_STATUS wlan_hdd_send_sta_authorized_event( |
| 14109 | struct hdd_adapter *adapter, |
| 14110 | struct hdd_context *hdd_ctx, |
| 14111 | const struct qdf_mac_addr *mac_addr) |
| 14112 | { |
| 14113 | struct sk_buff *vendor_event; |
| 14114 | QDF_STATUS status; |
| 14115 | struct nl80211_sta_flag_update sta_flags; |
| 14116 | |
| 14117 | hdd_enter(); |
| 14118 | if (!hdd_ctx) { |
| 14119 | hdd_err("HDD context is null"); |
| 14120 | return QDF_STATUS_E_INVAL; |
| 14121 | } |
| 14122 | |
| 14123 | vendor_event = |
| 14124 | cfg80211_vendor_event_alloc( |
| 14125 | hdd_ctx->wiphy, &adapter->wdev, sizeof(sta_flags) + |
| 14126 | QDF_MAC_ADDR_SIZE + NLMSG_HDRLEN, |
| 14127 | QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES_INDEX, |
| 14128 | GFP_KERNEL); |
| 14129 | if (!vendor_event) { |
| 14130 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 14131 | return QDF_STATUS_E_FAILURE; |
| 14132 | } |
| 14133 | |
| 14134 | sta_flags.mask |= BIT(NL80211_STA_FLAG_AUTHORIZED); |
| 14135 | sta_flags.set = true; |
| 14136 | |
| 14137 | status = nla_put(vendor_event, |
| 14138 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_STA_FLAGS, |
| 14139 | sizeof(struct nl80211_sta_flag_update), |
| 14140 | &sta_flags); |
| 14141 | if (status) { |
| 14142 | hdd_err("STA flag put fails"); |
| 14143 | kfree_skb(vendor_event); |
| 14144 | return QDF_STATUS_E_FAILURE; |
| 14145 | } |
| 14146 | status = nla_put(vendor_event, |
| 14147 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_MAC_ADDR, |
| 14148 | QDF_MAC_ADDR_SIZE, mac_addr->bytes); |
| 14149 | if (status) { |
| 14150 | hdd_err("STA MAC put fails"); |
| 14151 | kfree_skb(vendor_event); |
| 14152 | return QDF_STATUS_E_FAILURE; |
| 14153 | } |
| 14154 | |
| 14155 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 14156 | |
| 14157 | hdd_exit(); |
| 14158 | return QDF_STATUS_SUCCESS; |
| 14159 | } |
| 14160 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14161 | /** |
| 14162 | * __wlan_hdd_change_station() - change station |
| 14163 | * @wiphy: Pointer to the wiphy structure |
| 14164 | * @dev: Pointer to the net device. |
| 14165 | * @mac: bssid |
| 14166 | * @params: Pointer to station parameters |
| 14167 | * |
| 14168 | * Return: 0 for success, error number on failure. |
| 14169 | */ |
| 14170 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 14171 | static int __wlan_hdd_change_station(struct wiphy *wiphy, |
| 14172 | struct net_device *dev, |
| 14173 | const uint8_t *mac, |
| 14174 | struct station_parameters *params) |
| 14175 | #else |
| 14176 | static int __wlan_hdd_change_station(struct wiphy *wiphy, |
| 14177 | struct net_device *dev, |
| 14178 | uint8_t *mac, |
| 14179 | struct station_parameters *params) |
| 14180 | #endif |
| 14181 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14182 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14183 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 14184 | struct hdd_context *hdd_ctx; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 14185 | struct hdd_station_ctx *sta_ctx; |
Vignesh Viswanathan | 597d901 | 2018-07-06 15:26:08 +0530 | [diff] [blame] | 14186 | struct hdd_ap_ctx *ap_ctx; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14187 | struct qdf_mac_addr STAMacAddress; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14188 | int ret; |
| 14189 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 14190 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14191 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14192 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 14193 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14194 | return -EINVAL; |
| 14195 | } |
| 14196 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 14197 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 14198 | TRACE_CODE_HDD_CHANGE_STATION, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 14199 | adapter->vdev_id, params->listen_interval); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14200 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 14201 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14202 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14203 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14204 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 14205 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14206 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14207 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14208 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 14209 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14210 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14211 | qdf_mem_copy(STAMacAddress.bytes, mac, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14212 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14213 | if ((adapter->device_mode == QDF_SAP_MODE) || |
| 14214 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14215 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
Vignesh Viswanathan | 597d901 | 2018-07-06 15:26:08 +0530 | [diff] [blame] | 14216 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 14217 | /* |
| 14218 | * For Encrypted SAP session, this will be done as |
| 14219 | * part of eSAP_STA_SET_KEY_EVENT |
| 14220 | */ |
| 14221 | if (ap_ctx->encryption_type != |
| 14222 | eCSR_ENCRYPT_TYPE_NONE) { |
| 14223 | hdd_debug("Encrypt type %d, not setting peer authorized now", |
| 14224 | ap_ctx->encryption_type); |
| 14225 | return 0; |
| 14226 | } |
| 14227 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14228 | status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14229 | hdd_softap_change_sta_state(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14230 | &STAMacAddress, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 14231 | OL_TXRX_PEER_STATE_AUTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14232 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14233 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14234 | hdd_debug("Not able to change TL state to AUTHENTICATED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14235 | return -EINVAL; |
| 14236 | } |
Ashish Kumar Dhanotiya | 42b0378 | 2018-01-16 10:55:16 +0530 | [diff] [blame] | 14237 | status = wlan_hdd_send_sta_authorized_event( |
| 14238 | adapter, |
| 14239 | hdd_ctx, |
| 14240 | &STAMacAddress); |
| 14241 | if (status != QDF_STATUS_SUCCESS) { |
| 14242 | return -EINVAL; |
| 14243 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14244 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14245 | } else if ((adapter->device_mode == QDF_STA_MODE) || |
| 14246 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14247 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Frank Liu | d1a2846 | 2017-09-06 22:55:48 +0800 | [diff] [blame] | 14248 | #if defined(FEATURE_WLAN_TDLS) |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 14249 | struct wlan_objmgr_vdev *vdev; |
| 14250 | |
| 14251 | vdev = hdd_objmgr_get_vdev(adapter); |
| 14252 | if (!vdev) |
| 14253 | return -EINVAL; |
| 14254 | ret = wlan_cfg80211_tdls_update_peer(vdev, mac, params); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 14255 | hdd_objmgr_put_vdev(vdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14256 | #endif |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14257 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14258 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 14259 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14260 | return ret; |
| 14261 | } |
| 14262 | |
| 14263 | /** |
| 14264 | * wlan_hdd_change_station() - cfg80211 change station handler function |
| 14265 | * @wiphy: Pointer to the wiphy structure |
| 14266 | * @dev: Pointer to the net device. |
| 14267 | * @mac: bssid |
| 14268 | * @params: Pointer to station parameters |
| 14269 | * |
| 14270 | * This is the cfg80211 change station handler function which invokes |
| 14271 | * the internal function @__wlan_hdd_change_station with |
| 14272 | * SSR protection. |
| 14273 | * |
| 14274 | * Return: 0 for success, error number on failure. |
| 14275 | */ |
| 14276 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) || defined(WITH_BACKPORTS) |
| 14277 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 14278 | struct net_device *dev, |
| 14279 | const u8 *mac, |
| 14280 | struct station_parameters *params) |
| 14281 | #else |
| 14282 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 14283 | struct net_device *dev, |
| 14284 | u8 *mac, |
| 14285 | struct station_parameters *params) |
| 14286 | #endif |
| 14287 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 14288 | int errno; |
| 14289 | struct osif_vdev_sync *vdev_sync; |
| 14290 | |
| 14291 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 14292 | if (errno) |
| 14293 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14294 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 14295 | errno = __wlan_hdd_change_station(wiphy, dev, mac, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14296 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 14297 | osif_vdev_sync_op_stop(vdev_sync); |
| 14298 | |
| 14299 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14300 | } |
| 14301 | |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14302 | #ifdef CRYPTO_SET_KEY_CONVERGED |
| 14303 | #ifdef FEATURE_WLAN_ESE |
| 14304 | static bool hdd_is_krk_enc_type(uint32_t cipher_type) |
| 14305 | { |
| 14306 | if (cipher_type == WLAN_CIPHER_SUITE_KRK) |
| 14307 | return true; |
| 14308 | |
| 14309 | return false; |
| 14310 | } |
| 14311 | #else |
| 14312 | static bool hdd_is_krk_enc_type(uint32_t cipher_type) |
| 14313 | { |
| 14314 | return false; |
| 14315 | } |
| 14316 | #endif |
| 14317 | |
| 14318 | #if defined(FEATURE_WLAN_ESE) && defined(WLAN_FEATURE_ROAM_OFFLOAD) |
| 14319 | static bool hdd_is_btk_enc_type(uint32_t cipher_type) |
| 14320 | { |
| 14321 | if (cipher_type == WLAN_CIPHER_SUITE_BTK) |
| 14322 | return true; |
| 14323 | |
| 14324 | return false; |
| 14325 | } |
| 14326 | #else |
| 14327 | static bool hdd_is_btk_enc_type(uint32_t cipher_type) |
| 14328 | { |
| 14329 | return false; |
| 14330 | } |
| 14331 | #endif |
| 14332 | #endif |
| 14333 | |
| 14334 | #ifdef CRYPTO_SET_KEY_CONVERGED |
| 14335 | static int wlan_hdd_add_key_ibss(struct hdd_adapter *adapter, |
| 14336 | bool pairwise, u8 key_index, |
| 14337 | const u8 *mac_addr, struct key_params *params, |
| 14338 | bool *key_already_installed) |
| 14339 | { |
| 14340 | struct wlan_objmgr_vdev *vdev; |
| 14341 | int errno; |
| 14342 | |
| 14343 | if (pairwise) |
| 14344 | return 0; |
| 14345 | /* if a key is already installed, block all subsequent ones */ |
| 14346 | if (adapter->session.station.ibss_enc_key_installed) { |
| 14347 | hdd_debug("IBSS key installed already"); |
| 14348 | *key_already_installed = true; |
| 14349 | return 0; |
| 14350 | } |
| 14351 | /*Set the group key */ |
| 14352 | vdev = hdd_objmgr_get_vdev(adapter); |
| 14353 | if (!vdev) |
| 14354 | return -EINVAL; |
Kiran Kumar Lokere | 47d0dac | 2019-01-24 18:38:33 -0800 | [diff] [blame] | 14355 | errno = wlan_cfg80211_crypto_add_key(vdev, WLAN_CRYPTO_KEY_TYPE_GROUP, |
| 14356 | key_index); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14357 | if (errno) { |
| 14358 | hdd_err("add_ibss_key failed, errno: %d", errno); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 14359 | hdd_objmgr_put_vdev(vdev); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14360 | return errno; |
| 14361 | } |
| 14362 | /* Save the keys here and call set_key for setting |
| 14363 | * the PTK after peer joins the IBSS network |
| 14364 | */ |
Kiran Kumar Lokere | 47d0dac | 2019-01-24 18:38:33 -0800 | [diff] [blame] | 14365 | wlan_cfg80211_store_key(vdev, key_index, WLAN_CRYPTO_KEY_TYPE_UNICAST, |
| 14366 | mac_addr, params); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 14367 | hdd_objmgr_put_vdev(vdev); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14368 | adapter->session.station.ibss_enc_key_installed = 1; |
| 14369 | |
| 14370 | return 0; |
| 14371 | } |
| 14372 | |
| 14373 | static int wlan_hdd_add_key_sap(struct hdd_adapter *adapter, |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 14374 | bool pairwise, u8 key_index, |
| 14375 | enum wlan_crypto_cipher_type cipher) |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14376 | { |
| 14377 | struct wlan_objmgr_vdev *vdev; |
| 14378 | int errno = 0; |
| 14379 | struct hdd_hostapd_state *hostapd_state = |
| 14380 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
| 14381 | |
| 14382 | vdev = hdd_objmgr_get_vdev(adapter); |
| 14383 | if (!vdev) |
| 14384 | return -EINVAL; |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 14385 | if (hostapd_state->bss_state == BSS_START) { |
Kiran Kumar Lokere | 47d0dac | 2019-01-24 18:38:33 -0800 | [diff] [blame] | 14386 | errno = |
| 14387 | wlan_cfg80211_crypto_add_key(vdev, (pairwise ? |
| 14388 | WLAN_CRYPTO_KEY_TYPE_UNICAST : |
| 14389 | WLAN_CRYPTO_KEY_TYPE_GROUP), |
| 14390 | key_index); |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 14391 | if (!errno) |
| 14392 | wma_update_set_key(adapter->vdev_id, pairwise, |
| 14393 | key_index, cipher); |
| 14394 | } |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 14395 | hdd_objmgr_put_vdev(vdev); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14396 | |
| 14397 | return errno; |
| 14398 | } |
| 14399 | |
| 14400 | static int wlan_hdd_add_key_sta(struct hdd_adapter *adapter, |
| 14401 | bool pairwise, u8 key_index, |
| 14402 | mac_handle_t mac_handle, bool *ft_mode) |
| 14403 | { |
| 14404 | struct wlan_objmgr_vdev *vdev; |
| 14405 | struct hdd_station_ctx *sta_ctx = |
| 14406 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 14407 | int errno; |
| 14408 | QDF_STATUS status; |
| 14409 | |
| 14410 | if (!pairwise) { |
| 14411 | /* set group key */ |
| 14412 | if (sta_ctx->roam_info.defer_key_complete) { |
| 14413 | hdd_debug("Perform Set key Complete"); |
| 14414 | hdd_perform_roam_set_key_complete(adapter); |
| 14415 | } |
| 14416 | } |
| 14417 | /* The supplicant may attempt to set the PTK once |
| 14418 | * pre-authentication is done. Save the key in the |
| 14419 | * UMAC and include it in the ADD BSS request |
| 14420 | */ |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 14421 | status = sme_check_ft_status(mac_handle, adapter->vdev_id); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14422 | if (status == QDF_STATUS_SUCCESS) { |
| 14423 | *ft_mode = true; |
| 14424 | return 0; |
| 14425 | } |
| 14426 | vdev = hdd_objmgr_get_vdev(adapter); |
| 14427 | if (!vdev) |
| 14428 | return -EINVAL; |
Kiran Kumar Lokere | 47d0dac | 2019-01-24 18:38:33 -0800 | [diff] [blame] | 14429 | errno = wlan_cfg80211_crypto_add_key(vdev, (pairwise ? |
| 14430 | WLAN_CRYPTO_KEY_TYPE_UNICAST : |
| 14431 | WLAN_CRYPTO_KEY_TYPE_GROUP), |
| 14432 | key_index); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 14433 | hdd_objmgr_put_vdev(vdev); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14434 | if (!errno && adapter->send_mode_change) { |
| 14435 | wlan_hdd_send_mode_change_event(); |
| 14436 | adapter->send_mode_change = false; |
| 14437 | } |
| 14438 | |
| 14439 | return errno; |
| 14440 | } |
| 14441 | |
| 14442 | static int __wlan_hdd_cfg80211_add_key(struct wiphy *wiphy, |
| 14443 | struct net_device *ndev, |
| 14444 | u8 key_index, bool pairwise, |
| 14445 | const u8 *mac_addr, |
| 14446 | struct key_params *params) |
| 14447 | { |
| 14448 | struct hdd_context *hdd_ctx; |
| 14449 | mac_handle_t mac_handle; |
| 14450 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 14451 | struct wlan_objmgr_vdev *vdev; |
| 14452 | bool key_already_installed = false, ft_mode = false; |
| 14453 | enum wlan_crypto_cipher_type cipher; |
| 14454 | int errno; |
Kiran Kumar Lokere | 47d0dac | 2019-01-24 18:38:33 -0800 | [diff] [blame] | 14455 | struct qdf_mac_addr mac_address; |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14456 | |
| 14457 | hdd_enter(); |
| 14458 | |
| 14459 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 14460 | hdd_err("Command not allowed in FTM mode"); |
| 14461 | return -EINVAL; |
| 14462 | } |
| 14463 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 14464 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14465 | return -EINVAL; |
| 14466 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 14467 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 14468 | TRACE_CODE_HDD_CFG80211_ADD_KEY, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 14469 | adapter->vdev_id, params->key_len); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 14470 | |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14471 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14472 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 14473 | if (errno) |
| 14474 | return errno; |
| 14475 | |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 14476 | hdd_debug("converged Device_mode %s(%d) index %d, pairwise %d", |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14477 | qdf_opmode_str(adapter->device_mode), |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 14478 | adapter->device_mode, key_index, pairwise); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14479 | mac_handle = hdd_ctx->mac_handle; |
| 14480 | |
| 14481 | if (hdd_is_btk_enc_type(params->cipher)) |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 14482 | return sme_add_key_btk(mac_handle, adapter->vdev_id, |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14483 | params->key, params->key_len); |
| 14484 | if (hdd_is_krk_enc_type(params->cipher)) |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 14485 | return sme_add_key_krk(mac_handle, adapter->vdev_id, |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14486 | params->key, params->key_len); |
| 14487 | |
| 14488 | vdev = hdd_objmgr_get_vdev(adapter); |
| 14489 | if (!vdev) |
| 14490 | return -EINVAL; |
Kiran Kumar Lokere | 47d0dac | 2019-01-24 18:38:33 -0800 | [diff] [blame] | 14491 | if (!pairwise && ((adapter->device_mode == QDF_STA_MODE) || |
| 14492 | (adapter->device_mode == QDF_P2P_CLIENT_MODE))) { |
| 14493 | qdf_mem_copy(mac_address.bytes, |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 14494 | adapter->session.station.conn_info.bssid.bytes, |
Kiran Kumar Lokere | 47d0dac | 2019-01-24 18:38:33 -0800 | [diff] [blame] | 14495 | QDF_MAC_ADDR_SIZE); |
| 14496 | } else { |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 14497 | if (mac_addr) |
| 14498 | qdf_mem_copy(mac_address.bytes, mac_addr, |
| 14499 | QDF_MAC_ADDR_SIZE); |
Kiran Kumar Lokere | 47d0dac | 2019-01-24 18:38:33 -0800 | [diff] [blame] | 14500 | } |
| 14501 | errno = wlan_cfg80211_store_key(vdev, key_index, |
| 14502 | (pairwise ? |
| 14503 | WLAN_CRYPTO_KEY_TYPE_UNICAST : |
| 14504 | WLAN_CRYPTO_KEY_TYPE_GROUP), |
| 14505 | mac_address.bytes, params); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 14506 | hdd_objmgr_put_vdev(vdev); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14507 | if (errno) |
| 14508 | return errno; |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 14509 | cipher = osif_nl_to_crypto_cipher_type(params->cipher); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14510 | switch (adapter->device_mode) { |
| 14511 | case QDF_IBSS_MODE: |
| 14512 | errno = wlan_hdd_add_key_ibss(adapter, pairwise, key_index, |
| 14513 | mac_addr, params, |
| 14514 | &key_already_installed); |
| 14515 | if (key_already_installed) |
| 14516 | return 0; |
| 14517 | break; |
| 14518 | case QDF_SAP_MODE: |
| 14519 | case QDF_P2P_GO_MODE: |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 14520 | errno = wlan_hdd_add_key_sap(adapter, pairwise, |
| 14521 | key_index, cipher); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14522 | break; |
| 14523 | case QDF_STA_MODE: |
| 14524 | case QDF_P2P_CLIENT_MODE: |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 14525 | errno = wlan_hdd_add_key_sta(adapter, pairwise, key_index, |
| 14526 | mac_handle, &ft_mode); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14527 | if (ft_mode) |
| 14528 | return 0; |
| 14529 | break; |
| 14530 | default: |
| 14531 | break; |
| 14532 | } |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 14533 | if (!errno && (adapter->device_mode != QDF_SAP_MODE)) |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 14534 | wma_update_set_key(adapter->vdev_id, pairwise, key_index, |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14535 | cipher); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14536 | hdd_exit(); |
| 14537 | |
| 14538 | return errno; |
| 14539 | } |
| 14540 | #else /* !CRYPTO_SET_KEY_CONVERGED */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14541 | /* |
| 14542 | * FUNCTION: __wlan_hdd_cfg80211_add_key |
| 14543 | * This function is used to initialize the key information |
| 14544 | */ |
| 14545 | static int __wlan_hdd_cfg80211_add_key(struct wiphy *wiphy, |
| 14546 | struct net_device *ndev, |
| 14547 | u8 key_index, bool pairwise, |
| 14548 | const u8 *mac_addr, |
| 14549 | struct key_params *params) |
| 14550 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14551 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14552 | tCsrRoamSetKey setKey; |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14553 | int errno; |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 14554 | uint32_t roam_id = INVALID_ROAM_ID; |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14555 | QDF_STATUS status; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 14556 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 14557 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14558 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 14559 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14560 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14561 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 14562 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14563 | return -EINVAL; |
| 14564 | } |
| 14565 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 14566 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14567 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14568 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 14569 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 14570 | TRACE_CODE_HDD_CFG80211_ADD_KEY, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 14571 | adapter->vdev_id, params->key_len); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 14572 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14573 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14574 | errno = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14575 | |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14576 | if (errno) |
| 14577 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14578 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14579 | hdd_debug("Device_mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 14580 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14581 | |
| 14582 | if (CSR_MAX_NUM_KEY <= key_index) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 14583 | hdd_err("Invalid key index %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14584 | |
| 14585 | return -EINVAL; |
| 14586 | } |
| 14587 | |
| 14588 | if (CSR_MAX_KEY_LEN < params->key_len) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 14589 | hdd_err("Invalid key length %d", params->key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14590 | |
| 14591 | return -EINVAL; |
| 14592 | } |
| 14593 | |
Jeff Johnson | b05f4fd | 2017-10-18 15:08:21 -0700 | [diff] [blame] | 14594 | if (CSR_MAX_RSC_LEN < params->seq_len) { |
| 14595 | hdd_err("Invalid seq length %d", params->seq_len); |
| 14596 | |
| 14597 | return -EINVAL; |
| 14598 | } |
| 14599 | |
| 14600 | hdd_debug("key index %d, key length %d, seq length %d", |
| 14601 | key_index, params->key_len, params->seq_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14602 | |
| 14603 | /*extract key idx, key len and key */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14604 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14605 | setKey.keyId = key_index; |
| 14606 | setKey.keyLength = params->key_len; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14607 | qdf_mem_copy(&setKey.Key[0], params->key, params->key_len); |
Jeff Johnson | b05f4fd | 2017-10-18 15:08:21 -0700 | [diff] [blame] | 14608 | qdf_mem_copy(&setKey.keyRsc[0], params->seq, params->seq_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14609 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 14610 | mac_handle = hdd_ctx->mac_handle; |
| 14611 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14612 | switch (params->cipher) { |
| 14613 | case WLAN_CIPHER_SUITE_WEP40: |
| 14614 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 14615 | break; |
| 14616 | |
| 14617 | case WLAN_CIPHER_SUITE_WEP104: |
| 14618 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 14619 | break; |
| 14620 | |
| 14621 | case WLAN_CIPHER_SUITE_TKIP: |
| 14622 | { |
| 14623 | u8 *pKey = &setKey.Key[0]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14624 | |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 14625 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14626 | qdf_mem_zero(pKey, CSR_MAX_KEY_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14627 | |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 14628 | /* Supplicant sends the 32bytes key in this order |
| 14629 | * |
| 14630 | * |--------------|----------|----------| |
| 14631 | * | Tk1 |TX-MIC | RX Mic | |
| 14632 | * |--------------|----------|----------| |
| 14633 | * <---16bytes---><--8bytes--><--8bytes--> |
| 14634 | * |
| 14635 | * Sme expects the 32 bytes key to be in the below order |
| 14636 | * |
| 14637 | * |--------------|----------|----------| |
| 14638 | * | Tk1 |RX-MIC | TX Mic | |
| 14639 | * |--------------|----------|----------| |
| 14640 | * <---16bytes---><--8bytes--><--8bytes--> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14641 | */ |
| 14642 | /* Copy the Temporal Key 1 (TK1) */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14643 | qdf_mem_copy(pKey, params->key, 16); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14644 | |
| 14645 | /*Copy the rx mic first */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14646 | qdf_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14647 | |
| 14648 | /*Copy the tx mic */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14649 | qdf_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14650 | |
| 14651 | break; |
| 14652 | } |
| 14653 | |
| 14654 | case WLAN_CIPHER_SUITE_CCMP: |
| 14655 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 14656 | break; |
| 14657 | |
| 14658 | #ifdef FEATURE_WLAN_WAPI |
| 14659 | case WLAN_CIPHER_SUITE_SMS4: |
| 14660 | { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14661 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14662 | wlan_hdd_cfg80211_set_key_wapi(adapter, key_index, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14663 | mac_addr, params->key, |
| 14664 | params->key_len); |
| 14665 | return 0; |
| 14666 | } |
| 14667 | #endif |
| 14668 | |
| 14669 | #ifdef FEATURE_WLAN_ESE |
| 14670 | case WLAN_CIPHER_SUITE_KRK: |
| 14671 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 14672 | break; |
| 14673 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 14674 | case WLAN_CIPHER_SUITE_BTK: |
| 14675 | setKey.encType = eCSR_ENCRYPT_TYPE_BTK; |
| 14676 | break; |
| 14677 | #endif |
| 14678 | #endif |
| 14679 | |
| 14680 | #ifdef WLAN_FEATURE_11W |
| 14681 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 14682 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
| 14683 | break; |
Padma, Santhosh Kumar | 4117d7a | 2017-12-20 17:39:33 +0530 | [diff] [blame] | 14684 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) |
| 14685 | case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
| 14686 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_GMAC_128; |
| 14687 | break; |
| 14688 | case WLAN_CIPHER_SUITE_BIP_GMAC_256: |
| 14689 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_GMAC_256; |
| 14690 | break; |
| 14691 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14692 | #endif |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 14693 | case WLAN_CIPHER_SUITE_GCMP: |
| 14694 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_GCMP; |
| 14695 | break; |
| 14696 | case WLAN_CIPHER_SUITE_GCMP_256: |
| 14697 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_GCMP_256; |
| 14698 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14699 | |
| 14700 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14701 | hdd_err("Unsupported cipher type: %u", params->cipher); |
Ashish Kumar Dhanotiya | 0213793 | 2019-02-26 21:43:32 +0530 | [diff] [blame] | 14702 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14703 | return -EOPNOTSUPP; |
| 14704 | } |
| 14705 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14706 | hdd_debug("encryption type %d", setKey.encType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14707 | |
| 14708 | if (!pairwise) { |
| 14709 | /* set group key */ |
Jeff Johnson | 96aa2ac | 2017-10-18 15:55:36 -0700 | [diff] [blame] | 14710 | hdd_debug("setting Broadcast key"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14711 | setKey.keyDirection = eSIR_RX_ONLY; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 14712 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14713 | } else { |
| 14714 | /* set pairwise key */ |
Jeff Johnson | 96aa2ac | 2017-10-18 15:55:36 -0700 | [diff] [blame] | 14715 | hdd_debug("setting pairwise key"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14716 | setKey.keyDirection = eSIR_TX_RX; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14717 | qdf_mem_copy(setKey.peerMac.bytes, mac_addr, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14718 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14719 | if ((QDF_IBSS_MODE == adapter->device_mode) && !pairwise) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14720 | /* if a key is already installed, block all subsequent ones */ |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 14721 | if (adapter->session.station.ibss_enc_key_installed) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14722 | hdd_debug("IBSS key installed already"); |
Ashish Kumar Dhanotiya | 0213793 | 2019-02-26 21:43:32 +0530 | [diff] [blame] | 14723 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14724 | return 0; |
| 14725 | } |
| 14726 | |
| 14727 | setKey.keyDirection = eSIR_TX_RX; |
| 14728 | /*Set the group key */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 14729 | status = sme_roam_set_key(mac_handle, |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 14730 | adapter->vdev_id, &setKey, &roam_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14731 | |
| 14732 | if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14733 | hdd_err("sme_roam_set_key failed, status: %d", status); |
Ashish Kumar Dhanotiya | 0213793 | 2019-02-26 21:43:32 +0530 | [diff] [blame] | 14734 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14735 | return -EINVAL; |
| 14736 | } |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 14737 | /* Save the keys here and call sme_roam_set_key for setting |
| 14738 | * the PTK after peer joins the IBSS network |
| 14739 | */ |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 14740 | qdf_mem_copy(&adapter->session.station.ibss_enc_key, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14741 | &setKey, sizeof(tCsrRoamSetKey)); |
| 14742 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 14743 | adapter->session.station.ibss_enc_key_installed = 1; |
Ashish Kumar Dhanotiya | 0213793 | 2019-02-26 21:43:32 +0530 | [diff] [blame] | 14744 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14745 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14746 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14747 | if ((adapter->device_mode == QDF_SAP_MODE) || |
| 14748 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 14749 | struct hdd_hostapd_state *hostapd_state = |
| 14750 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
| 14751 | struct hdd_ap_ctx *ap_ctx = |
| 14752 | WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 14753 | |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 14754 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 6ba30a1 | 2016-09-13 13:59:43 -0700 | [diff] [blame] | 14755 | status = wlansap_set_key_sta( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14756 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), &setKey); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14757 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14758 | hdd_err("wlansap_set_key_sta failed status: %d", |
| 14759 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14760 | } |
| 14761 | } |
| 14762 | |
Jeff Johnson | 413c15f | 2017-10-27 18:56:35 -0700 | [diff] [blame] | 14763 | /* Save the key in ap ctx for use on START_BSS and restart */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14764 | if (pairwise || |
| 14765 | eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 14766 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType) |
Jeff Johnson | 3d73136 | 2017-10-27 19:06:41 -0700 | [diff] [blame] | 14767 | qdf_mem_copy(&ap_ctx->wep_key[key_index], &setKey, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14768 | sizeof(tCsrRoamSetKey)); |
| 14769 | else |
Jeff Johnson | 413c15f | 2017-10-27 18:56:35 -0700 | [diff] [blame] | 14770 | qdf_mem_copy(&ap_ctx->group_key, &setKey, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14771 | sizeof(tCsrRoamSetKey)); |
| 14772 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14773 | } else if ((adapter->device_mode == QDF_STA_MODE) || |
| 14774 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 14775 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14776 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 14777 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14778 | |
| 14779 | if (!pairwise) { |
| 14780 | /* set group key */ |
Jeff Johnson | af2ae4b | 2017-11-01 11:38:50 -0700 | [diff] [blame] | 14781 | if (sta_ctx->roam_info.defer_key_complete) { |
Jeff Johnson | 96aa2ac | 2017-10-18 15:55:36 -0700 | [diff] [blame] | 14782 | hdd_debug("Perform Set key Complete"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14783 | hdd_perform_roam_set_key_complete(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14784 | } |
| 14785 | } |
| 14786 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 14787 | roam_profile = hdd_roam_profile(adapter); |
| 14788 | roam_profile->Keys.KeyLength[key_index] = params->key_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14789 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 14790 | roam_profile->Keys.defaultIndex = key_index; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14791 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 14792 | qdf_mem_copy(&roam_profile->Keys.KeyMaterial[key_index][0], |
| 14793 | params->key, params->key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14794 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14795 | hdd_debug("Set key for peerMac "MAC_ADDRESS_STR" direction %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14796 | MAC_ADDR_ARRAY(setKey.peerMac.bytes), |
| 14797 | setKey.keyDirection); |
| 14798 | |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 14799 | /* The supplicant may attempt to set the PTK once |
| 14800 | * pre-authentication is done. Save the key in the |
| 14801 | * UMAC and include it in the ADD BSS request |
| 14802 | */ |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14803 | status = sme_ft_update_key(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 14804 | adapter->vdev_id, &setKey); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14805 | if (status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14806 | hdd_debug("Update PreAuth Key success"); |
Ashish Kumar Dhanotiya | 0213793 | 2019-02-26 21:43:32 +0530 | [diff] [blame] | 14807 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14808 | return 0; |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14809 | } else if (status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 14810 | hdd_err("Update PreAuth Key failed"); |
Ashish Kumar Dhanotiya | 0213793 | 2019-02-26 21:43:32 +0530 | [diff] [blame] | 14811 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14812 | return -EINVAL; |
| 14813 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14814 | |
| 14815 | /* issue set key request to SME */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 14816 | status = sme_roam_set_key(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 14817 | adapter->vdev_id, &setKey, |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 14818 | &roam_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14819 | |
| 14820 | if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14821 | hdd_err("sme_roam_set_key failed, status: %d", status); |
Ashish Kumar Dhanotiya | 0213793 | 2019-02-26 21:43:32 +0530 | [diff] [blame] | 14822 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14823 | return -EINVAL; |
| 14824 | } |
| 14825 | |
Yeshwanth Sriram Guntuka | 4fe30bd | 2018-06-13 11:41:42 +0530 | [diff] [blame] | 14826 | if (adapter->send_mode_change) { |
| 14827 | wlan_hdd_send_mode_change_event(); |
| 14828 | adapter->send_mode_change = false; |
| 14829 | } |
| 14830 | |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 14831 | /* in case of IBSS as there was no information |
| 14832 | * available about WEP keys during IBSS join, group |
Jeff Johnson | 5e19a94 | 2018-05-06 15:37:39 -0700 | [diff] [blame] | 14833 | * key initialized with NULL key, so re-initialize |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 14834 | * group key with correct value |
| 14835 | */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 14836 | if ((eCSR_BSS_TYPE_START_IBSS == roam_profile->BSSType) && |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 14837 | !((HDD_AUTH_KEY_MGMT_802_1X == |
| 14838 | (sta_ctx->auth_key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14839 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 14840 | sta_ctx->conn_info.auth_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14841 | ) |
| 14842 | && ((WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 14843 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 14844 | ) |
| 14845 | ) { |
| 14846 | setKey.keyDirection = eSIR_RX_ONLY; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 14847 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14848 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14849 | hdd_debug("Set key peerMac "MAC_ADDRESS_STR" direction %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14850 | MAC_ADDR_ARRAY(setKey.peerMac.bytes), |
| 14851 | setKey.keyDirection); |
| 14852 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 14853 | status = sme_roam_set_key(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 14854 | adapter->vdev_id, &setKey, |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 14855 | &roam_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14856 | |
| 14857 | if (0 != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 14858 | hdd_err("sme_roam_set_key failed for group key (IBSS), returned %d", status); |
Ashish Kumar Dhanotiya | 0213793 | 2019-02-26 21:43:32 +0530 | [diff] [blame] | 14859 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14860 | return -EINVAL; |
| 14861 | } |
| 14862 | } |
| 14863 | } |
Ashish Kumar Dhanotiya | 0213793 | 2019-02-26 21:43:32 +0530 | [diff] [blame] | 14864 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 14865 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14866 | return 0; |
| 14867 | } |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 14868 | #endif /* CRYPTO_SET_KEY_CONVERGED */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14869 | |
| 14870 | static int wlan_hdd_cfg80211_add_key(struct wiphy *wiphy, |
| 14871 | struct net_device *ndev, |
| 14872 | u8 key_index, bool pairwise, |
| 14873 | const u8 *mac_addr, |
| 14874 | struct key_params *params) |
| 14875 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 14876 | int errno; |
| 14877 | struct osif_vdev_sync *vdev_sync; |
| 14878 | |
| 14879 | errno = osif_vdev_sync_op_start(ndev, &vdev_sync); |
| 14880 | if (errno) |
| 14881 | return errno; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 14882 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 14883 | errno = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise, |
| 14884 | mac_addr, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14885 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 14886 | osif_vdev_sync_op_stop(vdev_sync); |
| 14887 | |
| 14888 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14889 | } |
| 14890 | |
| 14891 | /* |
| 14892 | * FUNCTION: __wlan_hdd_cfg80211_get_key |
| 14893 | * This function is used to get the key information |
| 14894 | */ |
| 14895 | static int __wlan_hdd_cfg80211_get_key(struct wiphy *wiphy, |
| 14896 | struct net_device *ndev, |
| 14897 | u8 key_index, bool pairwise, |
| 14898 | const u8 *mac_addr, void *cookie, |
| 14899 | void (*callback)(void *cookie, |
| 14900 | struct key_params *) |
| 14901 | ) |
| 14902 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 14903 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 14904 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14905 | struct key_params params; |
| 14906 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 14907 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14908 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14909 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 14910 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14911 | return -EINVAL; |
| 14912 | } |
| 14913 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 14914 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Jiachao Wu | d58cfc9 | 2017-12-27 14:15:23 +0800 | [diff] [blame] | 14915 | return -EINVAL; |
Jiachao Wu | d58cfc9 | 2017-12-27 14:15:23 +0800 | [diff] [blame] | 14916 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14917 | hdd_debug("Device_mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 14918 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14919 | |
| 14920 | memset(¶ms, 0, sizeof(params)); |
| 14921 | |
| 14922 | if (CSR_MAX_NUM_KEY <= key_index) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 14923 | hdd_err("Invalid key index: %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14924 | return -EINVAL; |
| 14925 | } |
| 14926 | |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 14927 | if ((adapter->device_mode == QDF_SAP_MODE) || |
| 14928 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
| 14929 | struct hdd_ap_ctx *ap_ctx = |
| 14930 | WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 14931 | |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 14932 | roam_profile = |
| 14933 | wlan_sap_get_roam_profile(ap_ctx->sap_context); |
| 14934 | } else { |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 14935 | roam_profile = hdd_roam_profile(adapter); |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 14936 | } |
| 14937 | |
Jiachao Wu | d58cfc9 | 2017-12-27 14:15:23 +0800 | [diff] [blame] | 14938 | if (roam_profile == NULL) { |
| 14939 | hdd_err("Get roam profile failed!"); |
| 14940 | return -EINVAL; |
| 14941 | } |
| 14942 | |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 14943 | switch (roam_profile->EncryptionType.encryptionType[0]) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14944 | case eCSR_ENCRYPT_TYPE_NONE: |
| 14945 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 14946 | break; |
| 14947 | |
| 14948 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 14949 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 14950 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 14951 | break; |
| 14952 | |
| 14953 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 14954 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 14955 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 14956 | break; |
| 14957 | |
| 14958 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 14959 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 14960 | break; |
| 14961 | |
| 14962 | case eCSR_ENCRYPT_TYPE_AES: |
| 14963 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 14964 | break; |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 14965 | case eCSR_ENCRYPT_TYPE_AES_GCMP: |
| 14966 | params.cipher = WLAN_CIPHER_SUITE_GCMP; |
| 14967 | break; |
| 14968 | case eCSR_ENCRYPT_TYPE_AES_GCMP_256: |
| 14969 | params.cipher = WLAN_CIPHER_SUITE_GCMP_256; |
| 14970 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14971 | default: |
| 14972 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 14973 | break; |
| 14974 | } |
| 14975 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 14976 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 14977 | TRACE_CODE_HDD_CFG80211_GET_KEY, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 14978 | adapter->vdev_id, params.cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14979 | |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 14980 | params.key_len = roam_profile->Keys.KeyLength[key_index]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14981 | params.seq_len = 0; |
| 14982 | params.seq = NULL; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 14983 | params.key = &roam_profile->Keys.KeyMaterial[key_index][0]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14984 | callback(cookie, ¶ms); |
| 14985 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 14986 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14987 | return 0; |
| 14988 | } |
| 14989 | |
| 14990 | static int wlan_hdd_cfg80211_get_key(struct wiphy *wiphy, |
| 14991 | struct net_device *ndev, |
| 14992 | u8 key_index, bool pairwise, |
| 14993 | const u8 *mac_addr, void *cookie, |
| 14994 | void (*callback)(void *cookie, |
| 14995 | struct key_params *) |
| 14996 | ) |
| 14997 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 14998 | int errno; |
| 14999 | struct osif_vdev_sync *vdev_sync; |
| 15000 | |
| 15001 | errno = osif_vdev_sync_op_start(ndev, &vdev_sync); |
| 15002 | if (errno) |
| 15003 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15004 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 15005 | errno = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise, |
| 15006 | mac_addr, cookie, callback); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15007 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 15008 | osif_vdev_sync_op_stop(vdev_sync); |
| 15009 | |
| 15010 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15011 | } |
| 15012 | |
| 15013 | /** |
| 15014 | * __wlan_hdd_cfg80211_del_key() - Delete the encryption key for station |
| 15015 | * @wiphy: wiphy interface context |
| 15016 | * @ndev: pointer to net device |
| 15017 | * @key_index: Key index used in 802.11 frames |
| 15018 | * @unicast: true if it is unicast key |
| 15019 | * @multicast: true if it is multicast key |
| 15020 | * |
| 15021 | * This function is required for cfg80211_ops API. |
| 15022 | * It is used to delete the key information |
| 15023 | * Underlying hardware implementation does not have API to delete the |
| 15024 | * encryption key. It is automatically deleted when the peer is |
| 15025 | * removed. Hence this function currently does nothing. |
| 15026 | * Future implementation may interprete delete key operation to |
| 15027 | * replacing the key with a random junk value, effectively making it |
| 15028 | * useless. |
| 15029 | * |
| 15030 | * Return: status code, always 0. |
| 15031 | */ |
| 15032 | |
| 15033 | static int __wlan_hdd_cfg80211_del_key(struct wiphy *wiphy, |
| 15034 | struct net_device *ndev, |
| 15035 | u8 key_index, |
| 15036 | bool pairwise, const u8 *mac_addr) |
| 15037 | { |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 15038 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15039 | return 0; |
| 15040 | } |
| 15041 | |
| 15042 | /** |
| 15043 | * wlan_hdd_cfg80211_del_key() - cfg80211 delete key handler function |
| 15044 | * @wiphy: Pointer to wiphy structure. |
| 15045 | * @dev: Pointer to net_device structure. |
| 15046 | * @key_index: key index |
| 15047 | * @pairwise: pairwise |
| 15048 | * @mac_addr: mac address |
| 15049 | * |
| 15050 | * This is the cfg80211 delete key handler function which invokes |
| 15051 | * the internal function @__wlan_hdd_cfg80211_del_key with |
| 15052 | * SSR protection. |
| 15053 | * |
| 15054 | * Return: 0 for success, error number on failure. |
| 15055 | */ |
| 15056 | static int wlan_hdd_cfg80211_del_key(struct wiphy *wiphy, |
| 15057 | struct net_device *dev, |
| 15058 | u8 key_index, |
| 15059 | bool pairwise, const u8 *mac_addr) |
| 15060 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 15061 | int errno; |
| 15062 | struct osif_vdev_sync *vdev_sync; |
| 15063 | |
| 15064 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 15065 | if (errno) |
| 15066 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15067 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 15068 | errno = __wlan_hdd_cfg80211_del_key(wiphy, dev, key_index, |
| 15069 | pairwise, mac_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15070 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 15071 | osif_vdev_sync_op_stop(vdev_sync); |
| 15072 | |
| 15073 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15074 | } |
| 15075 | |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 15076 | #ifndef CRYPTO_SET_KEY_CONVERGED |
Hu Wang | c314884 | 2017-06-20 19:03:29 +0800 | [diff] [blame] | 15077 | #ifdef FEATURE_WLAN_WAPI |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 15078 | static bool hdd_is_wapi_enc_type(eCsrEncryptionType encrypt_type) |
Hu Wang | c314884 | 2017-06-20 19:03:29 +0800 | [diff] [blame] | 15079 | { |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 15080 | if (encrypt_type == eCSR_ENCRYPT_TYPE_WPI) |
Hu Wang | c314884 | 2017-06-20 19:03:29 +0800 | [diff] [blame] | 15081 | return true; |
| 15082 | |
| 15083 | return false; |
| 15084 | } |
| 15085 | #else |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 15086 | static bool hdd_is_wapi_enc_type(eCsrEncryptionType encrypt_type) |
Hu Wang | c314884 | 2017-06-20 19:03:29 +0800 | [diff] [blame] | 15087 | { |
| 15088 | return false; |
| 15089 | } |
| 15090 | #endif |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 15091 | #endif |
Hu Wang | c314884 | 2017-06-20 19:03:29 +0800 | [diff] [blame] | 15092 | |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 15093 | #ifdef CRYPTO_SET_KEY_CONVERGED |
| 15094 | static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, |
| 15095 | struct net_device *ndev, |
| 15096 | u8 key_index, |
| 15097 | bool unicast, bool multicast) |
| 15098 | { |
| 15099 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 15100 | struct hdd_context *hdd_ctx; |
| 15101 | struct qdf_mac_addr bssid = QDF_MAC_ADDR_BCAST_INIT; |
| 15102 | struct hdd_station_ctx *sta_ctx; |
| 15103 | struct wlan_crypto_key *crypto_key; |
| 15104 | int ret; |
| 15105 | QDF_STATUS status; |
| 15106 | |
| 15107 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 15108 | hdd_err("Command not allowed in FTM mode"); |
| 15109 | return -EINVAL; |
| 15110 | } |
| 15111 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 15112 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 15113 | return -EINVAL; |
| 15114 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 15115 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 15116 | TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 15117 | adapter->vdev_id, key_index); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 15118 | |
| 15119 | hdd_debug("Device_mode %s(%d) key_index = %d", |
| 15120 | qdf_opmode_str(adapter->device_mode), |
| 15121 | adapter->device_mode, key_index); |
| 15122 | |
| 15123 | if (CSR_MAX_NUM_KEY <= key_index) { |
| 15124 | hdd_err("Invalid key index: %d", key_index); |
| 15125 | return -EINVAL; |
| 15126 | } |
| 15127 | |
| 15128 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 15129 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 15130 | |
| 15131 | if (0 != ret) |
| 15132 | return ret; |
| 15133 | crypto_key = wlan_crypto_get_key(adapter->vdev, key_index); |
| 15134 | hdd_debug("unicast %d, cipher %d", unicast, crypto_key->cipher_type); |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 15135 | if (!IS_WEP_CIPHER(crypto_key->cipher_type)) |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 15136 | return 0; |
| 15137 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 15138 | if (unicast) |
| 15139 | status = |
| 15140 | wlan_cfg80211_set_default_key(adapter->vdev, key_index, |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 15141 | &sta_ctx->conn_info.bssid); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 15142 | else |
| 15143 | status = wlan_cfg80211_set_default_key(adapter->vdev, key_index, |
| 15144 | &bssid); |
| 15145 | if (QDF_STATUS_SUCCESS != status) { |
| 15146 | hdd_err("ret fail status %d", ret); |
| 15147 | return -EINVAL; |
| 15148 | } |
| 15149 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 15150 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Kiran Kumar Lokere | 47d0dac | 2019-01-24 18:38:33 -0800 | [diff] [blame] | 15151 | ret = |
| 15152 | wlan_cfg80211_crypto_add_key(adapter->vdev, (unicast ? |
| 15153 | WLAN_CRYPTO_KEY_TYPE_UNICAST : |
| 15154 | WLAN_CRYPTO_KEY_TYPE_GROUP), |
| 15155 | key_index); |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 15156 | wma_update_set_key(adapter->vdev_id, unicast, key_index, |
| 15157 | crypto_key->cipher_type); |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 15158 | } |
| 15159 | |
| 15160 | return ret; |
| 15161 | } |
| 15162 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15163 | /* |
| 15164 | * FUNCTION: __wlan_hdd_cfg80211_set_default_key |
| 15165 | * This function is used to set the default tx key index |
| 15166 | */ |
| 15167 | static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, |
| 15168 | struct net_device *ndev, |
| 15169 | u8 key_index, |
| 15170 | bool unicast, bool multicast) |
| 15171 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15172 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15173 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 15174 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15175 | int status; |
| 15176 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15177 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15178 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 15179 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 15180 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15181 | return -EINVAL; |
| 15182 | } |
| 15183 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 15184 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 15185 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 15186 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 15187 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 15188 | TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 15189 | adapter->vdev_id, key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15190 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15191 | hdd_debug("Device_mode %s(%d) key_index = %d", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 15192 | qdf_opmode_str(adapter->device_mode), |
| 15193 | adapter->device_mode, key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15194 | |
| 15195 | if (CSR_MAX_NUM_KEY <= key_index) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15196 | hdd_err("Invalid key index: %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15197 | return -EINVAL; |
| 15198 | } |
| 15199 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15200 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15201 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15202 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 15203 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15204 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15205 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 15206 | mac_handle = hdd_ctx->mac_handle; |
| 15207 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15208 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 15209 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 15210 | struct hdd_station_ctx *sta_ctx = |
| 15211 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 15212 | struct csr_roam_profile *roam_profile; |
| 15213 | |
| 15214 | roam_profile = hdd_roam_profile(adapter); |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 15215 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15216 | if ((eCSR_ENCRYPT_TYPE_TKIP != |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 15217 | sta_ctx->conn_info.uc_encrypt_type) && |
Hu Wang | c314884 | 2017-06-20 19:03:29 +0800 | [diff] [blame] | 15218 | !hdd_is_wapi_enc_type( |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 15219 | sta_ctx->conn_info.uc_encrypt_type) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15220 | (eCSR_ENCRYPT_TYPE_AES != |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 15221 | sta_ctx->conn_info.uc_encrypt_type) && |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 15222 | (eCSR_ENCRYPT_TYPE_AES_GCMP != |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 15223 | sta_ctx->conn_info.uc_encrypt_type) && |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 15224 | (eCSR_ENCRYPT_TYPE_AES_GCMP_256 != |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 15225 | sta_ctx->conn_info.uc_encrypt_type)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15226 | /* If default key index is not same as previous one, |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 15227 | * then update the default key index |
| 15228 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15229 | |
| 15230 | tCsrRoamSetKey setKey; |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 15231 | uint32_t roam_id = INVALID_ROAM_ID; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 15232 | tCsrKeys *Keys = &roam_profile->Keys; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15233 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15234 | hdd_debug("Default tx key index %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15235 | Keys->defaultIndex = (u8) key_index; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 15236 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15237 | setKey.keyId = key_index; |
| 15238 | setKey.keyLength = Keys->KeyLength[key_index]; |
| 15239 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 15240 | qdf_mem_copy(&setKey.Key[0], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15241 | &Keys->KeyMaterial[key_index][0], |
| 15242 | Keys->KeyLength[key_index]); |
| 15243 | |
| 15244 | setKey.keyDirection = eSIR_TX_RX; |
| 15245 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 15246 | qdf_copy_macaddr(&setKey.peerMac, |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 15247 | &sta_ctx->conn_info.bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15248 | |
| 15249 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 15250 | roam_profile->EncryptionType. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15251 | encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP104) { |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 15252 | /* In the case of dynamic wep |
| 15253 | * supplicant hardcodes DWEP type to |
| 15254 | * eCSR_ENCRYPT_TYPE_WEP104 even |
| 15255 | * though ap is configured for WEP-40 |
| 15256 | * encryption. In this canse the key |
| 15257 | * length is 5 but the encryption type |
| 15258 | * is 104 hence checking the key |
Jeff Johnson | fe8e949 | 2018-05-06 15:40:52 -0700 | [diff] [blame] | 15259 | * length(5) and encryption type(104) |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 15260 | * and switching encryption type to 40 |
| 15261 | */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 15262 | roam_profile->EncryptionType. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15263 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 15264 | roam_profile->mcEncryptionType. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15265 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WEP40; |
| 15266 | } |
| 15267 | |
| 15268 | setKey.encType = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 15269 | roam_profile->EncryptionType. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15270 | encryptionType[0]; |
| 15271 | |
| 15272 | /* Issue set key request */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 15273 | status = sme_roam_set_key(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 15274 | adapter->vdev_id, &setKey, |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 15275 | &roam_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15276 | |
| 15277 | if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15278 | hdd_err("sme_roam_set_key failed, status: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15279 | status); |
| 15280 | return -EINVAL; |
| 15281 | } |
| 15282 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15283 | } else if (QDF_SAP_MODE == adapter->device_mode) { |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 15284 | struct hdd_ap_ctx *ap_ctx = |
| 15285 | WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 15286 | struct csr_roam_profile *profile = |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 15287 | wlan_sap_get_roam_profile(ap_ctx->sap_context); |
| 15288 | |
| 15289 | if (!profile) { |
| 15290 | hdd_err("Failed to get SAP Roam Profile"); |
| 15291 | return -EINVAL; |
| 15292 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15293 | /* In SoftAp mode setting key direction for default mode */ |
| 15294 | if ((eCSR_ENCRYPT_TYPE_TKIP != |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 15295 | profile->EncryptionType.encryptionType[0]) && |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 15296 | (eCSR_ENCRYPT_TYPE_AES != |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 15297 | profile->EncryptionType.encryptionType[0]) && |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 15298 | (eCSR_ENCRYPT_TYPE_AES_GCMP != |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 15299 | profile->EncryptionType.encryptionType[0]) && |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 15300 | (eCSR_ENCRYPT_TYPE_AES_GCMP_256 != |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 15301 | profile->EncryptionType.encryptionType[0])) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15302 | /* Saving key direction for default key index to TX default */ |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 15303 | ap_ctx->wep_key[key_index].keyDirection = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15304 | eSIR_TX_DEFAULT; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15305 | hdd_debug("WEP default key index set to SAP context %d", |
Masti, Narayanraddi | ab712a7 | 2016-08-04 11:59:11 +0530 | [diff] [blame] | 15306 | key_index); |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 15307 | ap_ctx->wep_def_key_idx = key_index; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15308 | } |
| 15309 | } |
| 15310 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 15311 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15312 | return status; |
| 15313 | } |
Kiran Kumar Lokere | 7d6e4c9 | 2018-09-19 13:45:47 -0700 | [diff] [blame] | 15314 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15315 | |
| 15316 | static int wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, |
| 15317 | struct net_device *ndev, |
| 15318 | u8 key_index, |
| 15319 | bool unicast, bool multicast) |
| 15320 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 15321 | int errno; |
| 15322 | struct osif_vdev_sync *vdev_sync; |
| 15323 | |
| 15324 | errno = osif_vdev_sync_op_start(ndev, &vdev_sync); |
| 15325 | if (errno) |
| 15326 | return errno; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 15327 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 15328 | errno = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, |
| 15329 | unicast, multicast); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15330 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 15331 | osif_vdev_sync_op_stop(vdev_sync); |
| 15332 | |
| 15333 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15334 | } |
| 15335 | |
Abhishek Singh | 85283ae | 2019-03-08 12:00:51 +0530 | [diff] [blame] | 15336 | void wlan_hdd_cfg80211_unlink_bss(struct hdd_adapter *adapter, |
| 15337 | tSirMacAddr bssid) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15338 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15339 | struct net_device *dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15340 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 15341 | struct wiphy *wiphy = wdev->wiphy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15342 | struct cfg80211_bss *bss = NULL; |
| 15343 | |
Abhishek Singh | 59cdca1 | 2019-03-08 13:48:20 +0530 | [diff] [blame] | 15344 | bss = wlan_cfg80211_get_bss(wiphy, NULL, bssid, NULL, 0); |
Abhishek Singh | 85283ae | 2019-03-08 12:00:51 +0530 | [diff] [blame] | 15345 | if (!bss) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 15346 | hdd_err("BSS not present"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15347 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15348 | hdd_debug("cfg80211_unlink_bss called for BSSID " |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 15349 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(bssid)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15350 | cfg80211_unlink_bss(wiphy, bss); |
Abhishek Singh | 85283ae | 2019-03-08 12:00:51 +0530 | [diff] [blame] | 15351 | /* cfg80211_get_bss get bss with ref count so release it */ |
| 15352 | cfg80211_put_bss(wiphy, bss); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15353 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15354 | } |
| 15355 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15356 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15357 | static inline int |
| 15358 | wlan_hdd_get_frame_len(struct bss_description *bss_desc) |
| 15359 | { |
| 15360 | return GET_IE_LEN_IN_BSS(bss_desc->length) + sizeof(qcom_ie_age); |
| 15361 | } |
| 15362 | |
| 15363 | static inline void wlan_hdd_add_age_ie(struct ieee80211_mgmt *mgmt, |
Abhishek Singh | f1c1676 | 2018-03-07 10:48:46 +0530 | [diff] [blame] | 15364 | uint32_t *ie_length, struct bss_description *bss_desc) |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15365 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15366 | qcom_ie_age *qie_age = NULL; |
Nachiket Kukade | 348ede7 | 2017-04-28 16:34:24 +0530 | [diff] [blame] | 15367 | |
| 15368 | /* |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15369 | * GPS Requirement: need age ie per entry. Using vendor specific. |
| 15370 | * Assuming this is the last IE, copy at the end |
Nachiket Kukade | 348ede7 | 2017-04-28 16:34:24 +0530 | [diff] [blame] | 15371 | */ |
Abhishek Singh | f1c1676 | 2018-03-07 10:48:46 +0530 | [diff] [blame] | 15372 | *ie_length -= sizeof(qcom_ie_age); |
| 15373 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + *ie_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15374 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 15375 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 15376 | qie_age->oui_1 = QCOM_OUI1; |
| 15377 | qie_age->oui_2 = QCOM_OUI2; |
| 15378 | qie_age->oui_3 = QCOM_OUI3; |
| 15379 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
Deepthi Gowri | 6acee34 | 2016-10-28 15:00:38 +0530 | [diff] [blame] | 15380 | /* |
| 15381 | * Lowi expects the timestamp of bss in units of 1/10 ms. In driver |
| 15382 | * all bss related timestamp is in units of ms. Due to this when scan |
| 15383 | * results are sent to lowi the scan age is high.To address this, |
| 15384 | * send age in units of 1/10 ms. |
| 15385 | */ |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15386 | qie_age->age = (uint32_t)(qdf_mc_timer_get_system_time() - |
| 15387 | bss_desc->received_time)/10; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15388 | qie_age->tsf_delta = bss_desc->tsf_delta; |
Krishna Kumaar Natarajan | a4e1224 | 2016-04-01 18:44:39 -0700 | [diff] [blame] | 15389 | memcpy(&qie_age->beacon_tsf, bss_desc->timeStamp, |
| 15390 | sizeof(qie_age->beacon_tsf)); |
Krishna Kumaar Natarajan | 89a99d4 | 2016-08-04 15:44:38 -0700 | [diff] [blame] | 15391 | memcpy(&qie_age->seq_ctrl, &bss_desc->seq_ctrl, |
| 15392 | sizeof(qie_age->seq_ctrl)); |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15393 | } |
| 15394 | #else |
| 15395 | static inline int |
| 15396 | wlan_hdd_get_frame_len(struct bss_description *bss_desc) |
| 15397 | { |
| 15398 | return GET_IE_LEN_IN_BSS(bss_desc->length); |
| 15399 | } |
| 15400 | static inline void wlan_hdd_add_age_ie(struct ieee80211_mgmt *mgmt, |
Abhishek Singh | f1c1676 | 2018-03-07 10:48:46 +0530 | [diff] [blame] | 15401 | uint32_t *ie_length, struct bss_description *bss_desc) |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15402 | { |
| 15403 | } |
| 15404 | #endif /* WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15405 | |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15406 | |
| 15407 | struct cfg80211_bss * |
| 15408 | wlan_hdd_inform_bss_frame(struct hdd_adapter *adapter, |
| 15409 | struct bss_description *bss_desc) |
| 15410 | { |
| 15411 | struct wireless_dev *wdev = adapter->dev->ieee80211_ptr; |
| 15412 | struct wiphy *wiphy = wdev->wiphy; |
Abhishek Singh | f1c1676 | 2018-03-07 10:48:46 +0530 | [diff] [blame] | 15413 | uint32_t ie_length = wlan_hdd_get_frame_len(bss_desc); |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15414 | const char *ie = |
| 15415 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields : NULL); |
| 15416 | uint32_t freq, i; |
| 15417 | struct cfg80211_bss *bss_status = NULL; |
| 15418 | struct hdd_context *hdd_ctx; |
| 15419 | struct timespec ts; |
| 15420 | struct hdd_config *cfg_param; |
| 15421 | struct wlan_cfg80211_inform_bss bss_data = {0}; |
| 15422 | |
| 15423 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 15424 | /* |
| 15425 | * wlan_hdd_validate_context should not be used here, In validate ctx |
| 15426 | * start_modules_in_progress or stop_modules_in_progress is validated, |
| 15427 | * If the start_modules_in_progress is set to true means the interface |
| 15428 | * is not UP yet if the stop_modules_in_progress means that interface |
| 15429 | * is already down. So in both the two scenario's driver should not be |
| 15430 | * informing bss to kernel. Hence removing the validate context. |
| 15431 | */ |
| 15432 | |
| 15433 | if (!hdd_ctx || !hdd_ctx->config) { |
| 15434 | hdd_debug("HDD context is Null"); |
| 15435 | return NULL; |
| 15436 | } |
| 15437 | |
| 15438 | if (cds_is_driver_recovering() || |
| 15439 | cds_is_load_or_unload_in_progress()) { |
| 15440 | hdd_debug("Recovery or load/unload in progress. State: 0x%x", |
| 15441 | cds_get_driver_state()); |
| 15442 | return NULL; |
| 15443 | } |
| 15444 | |
| 15445 | cfg_param = hdd_ctx->config; |
| 15446 | bss_data.frame_len = ie_length + offsetof(struct ieee80211_mgmt, |
| 15447 | u.probe_resp.variable); |
| 15448 | bss_data.mgmt = qdf_mem_malloc(bss_data.frame_len); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 15449 | if (!bss_data.mgmt) |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15450 | return NULL; |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15451 | |
| 15452 | memcpy(bss_data.mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
| 15453 | |
| 15454 | /* Android does not want the timestamp from the frame. |
| 15455 | * Instead it wants a monotonic increasing value |
| 15456 | */ |
| 15457 | get_monotonic_boottime(&ts); |
| 15458 | bss_data.mgmt->u.probe_resp.timestamp = |
| 15459 | ((u64) ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 15460 | |
| 15461 | bss_data.mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 15462 | bss_data.mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
| 15463 | |
Abhishek Singh | f1c1676 | 2018-03-07 10:48:46 +0530 | [diff] [blame] | 15464 | wlan_hdd_add_age_ie(bss_data.mgmt, &ie_length, bss_desc); |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15465 | |
| 15466 | memcpy(bss_data.mgmt->u.probe_resp.variable, ie, ie_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15467 | if (bss_desc->fProbeRsp) { |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15468 | bss_data.mgmt->frame_control |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15469 | (u16) (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 15470 | } else { |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15471 | bss_data.mgmt->frame_control |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15472 | (u16) (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 15473 | } |
| 15474 | |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15475 | if (bss_desc->channelId <= ARRAY_SIZE(hdd_channels_2_4_ghz) && |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15476 | (wiphy->bands[HDD_NL80211_BAND_2GHZ] != NULL)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15477 | freq = |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15478 | ieee80211_channel_to_frequency(bss_desc->channelId, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 15479 | HDD_NL80211_BAND_2GHZ); |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15480 | } else if ((bss_desc->channelId > ARRAY_SIZE(hdd_channels_2_4_ghz)) |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15481 | && (wiphy->bands[HDD_NL80211_BAND_5GHZ] != NULL)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15482 | freq = |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15483 | ieee80211_channel_to_frequency(bss_desc->channelId, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 15484 | HDD_NL80211_BAND_5GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15485 | } else { |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15486 | hdd_err("Invalid channel: %d", bss_desc->channelId); |
| 15487 | qdf_mem_free(bss_data.mgmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15488 | return NULL; |
| 15489 | } |
| 15490 | |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15491 | bss_data.chan = ieee80211_get_channel(wiphy, freq); |
| 15492 | if (!bss_data.chan) { |
Deepthi Gowri | 084c24d | 2016-09-01 15:55:09 +0530 | [diff] [blame] | 15493 | hdd_err("chan pointer is NULL, chan_no: %d freq: %d", |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15494 | bss_desc->channelId, freq); |
| 15495 | qdf_mem_free(bss_data.mgmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15496 | return NULL; |
| 15497 | } |
| 15498 | |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15499 | /* |
| 15500 | * Based on .ini configuration, raw rssi can be reported for bss. |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 15501 | * Raw rssi is typically used for estimating power. |
| 15502 | */ |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15503 | bss_data.rssi = (cfg_param->inform_bss_rssi_raw) ? bss_desc->rssi_raw : |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 15504 | bss_desc->rssi; |
| 15505 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15506 | /* Supplicant takes the signal strength in terms of mBm(100*dBm) */ |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15507 | bss_data.rssi = QDF_MIN(bss_data.rssi, 0) * 100; |
| 15508 | |
| 15509 | bss_data.boottime_ns = bss_desc->scansystimensec; |
| 15510 | |
| 15511 | /* Set all per chain rssi as invalid */ |
| 15512 | for (i = 0; i < WLAN_MGMT_TXRX_HOST_MAX_ANTENNA; i++) |
Yeshwanth Sriram Guntuka | 14ab04c | 2018-09-21 15:06:49 +0530 | [diff] [blame] | 15513 | bss_data.per_chain_rssi[i] = WLAN_INVALID_PER_CHAIN_RSSI; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15514 | |
Abhishek Singh | ef6f38c | 2018-12-20 13:51:29 +0530 | [diff] [blame] | 15515 | hdd_debug("BSSID: " MAC_ADDRESS_STR " Channel:%d RSSI:%d TSF %u seq %d", |
| 15516 | MAC_ADDR_ARRAY(bss_data.mgmt->bssid), |
| 15517 | bss_data.chan->center_freq, (int)(bss_data.rssi / 100), |
| 15518 | bss_desc->timeStamp[0], ((bss_desc->seq_ctrl.seqNumHi << |
| 15519 | HIGH_SEQ_NUM_OFFSET) | bss_desc->seq_ctrl.seqNumLo)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15520 | |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15521 | bss_status = wlan_cfg80211_inform_bss_frame_data(wiphy, &bss_data); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15522 | hdd_ctx->beacon_probe_rsp_cnt_per_scan++; |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15523 | qdf_mem_free(bss_data.mgmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15524 | return bss_status; |
| 15525 | } |
| 15526 | |
| 15527 | /** |
| 15528 | * wlan_hdd_cfg80211_update_bss_db() - update bss database of CF80211 |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15529 | * @adapter: Pointer to adapter |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 15530 | * @roam_info: Pointer to roam info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15531 | * |
| 15532 | * This function is used to update the BSS data base of CFG8011 |
| 15533 | * |
| 15534 | * Return: struct cfg80211_bss pointer |
| 15535 | */ |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 15536 | struct cfg80211_bss * |
| 15537 | wlan_hdd_cfg80211_update_bss_db(struct hdd_adapter *adapter, |
| 15538 | struct csr_roam_info *roam_info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15539 | { |
| 15540 | tCsrRoamConnectedProfile roamProfile; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 15541 | mac_handle_t mac_handle = hdd_adapter_get_mac_handle(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15542 | struct cfg80211_bss *bss = NULL; |
| 15543 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15544 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 15545 | sme_roam_get_connect_profile(mac_handle, adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 15546 | &roamProfile); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15547 | |
| 15548 | if (NULL != roamProfile.pBssDesc) { |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15549 | bss = wlan_hdd_inform_bss_frame(adapter, roamProfile.pBssDesc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15550 | |
| 15551 | if (NULL == bss) |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 15552 | hdd_debug("wlan_hdd_inform_bss_frame returned NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15553 | |
Naveen Rawat | df0a7e7 | 2016-01-06 18:35:53 -0800 | [diff] [blame] | 15554 | sme_roam_free_connect_profile(&roamProfile); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15555 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 15556 | hdd_err("roamProfile.pBssDesc is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15557 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15558 | return bss; |
| 15559 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15560 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15561 | /** |
| 15562 | * wlan_hdd_cfg80211_pmksa_candidate_notify() - notify a new PMSKA candidate |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15563 | * @adapter: Pointer to adapter |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 15564 | * @roam_info: Pointer to roam info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15565 | * @index: Index |
| 15566 | * @preauth: Preauth flag |
| 15567 | * |
| 15568 | * This function is used to notify the supplicant of a new PMKSA candidate. |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 15569 | * PMK value is notified to supplicant whether PMK caching or OKC is enabled |
| 15570 | * in firmware or not. Supplicant needs this value becaue it uses PMK caching |
| 15571 | * by default. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15572 | * |
| 15573 | * Return: 0 for success, non-zero for failure |
| 15574 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15575 | int wlan_hdd_cfg80211_pmksa_candidate_notify(struct hdd_adapter *adapter, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 15576 | struct csr_roam_info *roam_info, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15577 | int index, bool preauth) |
| 15578 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15579 | struct net_device *dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15580 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15581 | hdd_enter(); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15582 | hdd_debug("is going to notify supplicant of:"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15583 | |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 15584 | if (NULL == roam_info) { |
| 15585 | hdd_err("roam_info is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15586 | return -EINVAL; |
| 15587 | } |
| 15588 | |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 15589 | hdd_info(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(roam_info->bssid.bytes)); |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 15590 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 15591 | roam_info->bssid.bytes, |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 15592 | preauth, GFP_KERNEL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15593 | return 0; |
| 15594 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15595 | |
| 15596 | #ifdef FEATURE_WLAN_LFR_METRICS |
| 15597 | /** |
| 15598 | * wlan_hdd_cfg80211_roam_metrics_preauth() - roam metrics preauth |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15599 | * @adapter: Pointer to adapter |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 15600 | * @roam_info: Pointer to roam info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15601 | * |
| 15602 | * 802.11r/LFR metrics reporting function to report preauth initiation |
| 15603 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 15604 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15605 | */ |
| 15606 | #define MAX_LFR_METRICS_EVENT_LENGTH 100 |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 15607 | QDF_STATUS |
| 15608 | wlan_hdd_cfg80211_roam_metrics_preauth(struct hdd_adapter *adapter, |
| 15609 | struct csr_roam_info *roam_info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15610 | { |
| 15611 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 15612 | union iwreq_data wrqu; |
| 15613 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15614 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15615 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15616 | if (NULL == adapter) { |
| 15617 | hdd_err("adapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15618 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15619 | } |
| 15620 | |
| 15621 | /* create the event */ |
| 15622 | memset(&wrqu, 0, sizeof(wrqu)); |
| 15623 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 15624 | |
| 15625 | wrqu.data.pointer = metrics_notification; |
| 15626 | wrqu.data.length = scnprintf(metrics_notification, |
| 15627 | sizeof(metrics_notification), |
| 15628 | "QCOM: LFR_PREAUTH_INIT " MAC_ADDRESS_STR, |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 15629 | MAC_ADDR_ARRAY(roam_info->bssid.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15630 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15631 | wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15632 | metrics_notification); |
| 15633 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 15634 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15635 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15636 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15637 | } |
| 15638 | |
| 15639 | /** |
| 15640 | * wlan_hdd_cfg80211_roam_metrics_handover() - roam metrics hand over |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15641 | * @adapter: Pointer to adapter |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 15642 | * @roam_info: Pointer to roam info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15643 | * @preauth_status: Preauth status |
| 15644 | * |
| 15645 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 15646 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 15647 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15648 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15649 | QDF_STATUS |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15650 | wlan_hdd_cfg80211_roam_metrics_preauth_status(struct hdd_adapter *adapter, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 15651 | struct csr_roam_info *roam_info, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15652 | bool preauth_status) |
| 15653 | { |
| 15654 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 15655 | union iwreq_data wrqu; |
| 15656 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15657 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15658 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15659 | if (NULL == adapter) { |
| 15660 | hdd_err("adapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15661 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15662 | } |
| 15663 | |
| 15664 | /* create the event */ |
| 15665 | memset(&wrqu, 0, sizeof(wrqu)); |
| 15666 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 15667 | |
| 15668 | scnprintf(metrics_notification, sizeof(metrics_notification), |
| 15669 | "QCOM: LFR_PREAUTH_STATUS " MAC_ADDRESS_STR, |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 15670 | MAC_ADDR_ARRAY(roam_info->bssid.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15671 | |
| 15672 | if (1 == preauth_status) |
| 15673 | strlcat(metrics_notification, " true", |
| 15674 | sizeof(metrics_notification)); |
| 15675 | else |
| 15676 | strlcat(metrics_notification, " false", |
| 15677 | sizeof(metrics_notification)); |
| 15678 | |
| 15679 | wrqu.data.pointer = metrics_notification; |
| 15680 | wrqu.data.length = strlen(metrics_notification); |
| 15681 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15682 | wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15683 | metrics_notification); |
| 15684 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 15685 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15686 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15687 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15688 | } |
| 15689 | |
| 15690 | /** |
| 15691 | * wlan_hdd_cfg80211_roam_metrics_handover() - roam metrics hand over |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15692 | * @adapter: Pointer to adapter |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 15693 | * @roam_info: Pointer to roam info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15694 | * |
| 15695 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 15696 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 15697 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15698 | */ |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 15699 | QDF_STATUS |
| 15700 | wlan_hdd_cfg80211_roam_metrics_handover(struct hdd_adapter *adapter, |
| 15701 | struct csr_roam_info *roam_info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15702 | { |
| 15703 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 15704 | union iwreq_data wrqu; |
| 15705 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15706 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15707 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15708 | if (NULL == adapter) { |
| 15709 | hdd_err("adapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15710 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15711 | } |
| 15712 | |
| 15713 | /* create the event */ |
| 15714 | memset(&wrqu, 0, sizeof(wrqu)); |
| 15715 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 15716 | |
| 15717 | wrqu.data.pointer = metrics_notification; |
| 15718 | wrqu.data.length = scnprintf(metrics_notification, |
| 15719 | sizeof(metrics_notification), |
| 15720 | "QCOM: LFR_PREAUTH_HANDOVER " |
| 15721 | MAC_ADDRESS_STR, |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 15722 | MAC_ADDR_ARRAY(roam_info->bssid.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15723 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15724 | wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15725 | metrics_notification); |
| 15726 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 15727 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15728 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15729 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15730 | } |
| 15731 | #endif |
| 15732 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15733 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 15734 | static |
| 15735 | void hdd_mon_select_cbmode(struct hdd_adapter *adapter, |
| 15736 | uint8_t operationChannel, |
| 15737 | struct ch_params *ch_params) |
| 15738 | { |
| 15739 | struct hdd_station_ctx *station_ctx = |
| 15740 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 15741 | struct hdd_mon_set_ch_info *ch_info = &station_ctx->ch_info; |
| 15742 | enum hdd_dot11_mode hdd_dot11_mode; |
| 15743 | uint8_t ini_dot11_mode = |
| 15744 | (WLAN_HDD_GET_CTX(adapter))->config->dot11Mode; |
| 15745 | |
| 15746 | hdd_debug("Dot11Mode is %u", ini_dot11_mode); |
| 15747 | switch (ini_dot11_mode) { |
| 15748 | case eHDD_DOT11_MODE_AUTO: |
| 15749 | case eHDD_DOT11_MODE_11ax: |
| 15750 | case eHDD_DOT11_MODE_11ax_ONLY: |
| 15751 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 15752 | hdd_dot11_mode = eHDD_DOT11_MODE_11ax; |
| 15753 | else if (sme_is_feature_supported_by_fw(DOT11AC)) |
| 15754 | hdd_dot11_mode = eHDD_DOT11_MODE_11ac; |
| 15755 | else |
| 15756 | hdd_dot11_mode = eHDD_DOT11_MODE_11n; |
| 15757 | break; |
| 15758 | case eHDD_DOT11_MODE_11ac: |
| 15759 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 15760 | if (sme_is_feature_supported_by_fw(DOT11AC)) |
| 15761 | hdd_dot11_mode = eHDD_DOT11_MODE_11ac; |
| 15762 | else |
| 15763 | hdd_dot11_mode = eHDD_DOT11_MODE_11n; |
| 15764 | break; |
| 15765 | case eHDD_DOT11_MODE_11n: |
| 15766 | case eHDD_DOT11_MODE_11n_ONLY: |
| 15767 | hdd_dot11_mode = eHDD_DOT11_MODE_11n; |
| 15768 | break; |
| 15769 | default: |
| 15770 | hdd_dot11_mode = ini_dot11_mode; |
| 15771 | break; |
| 15772 | } |
| 15773 | ch_info->channel_width = ch_params->ch_width; |
| 15774 | ch_info->phy_mode = |
| 15775 | hdd_cfg_xlate_to_csr_phy_mode(hdd_dot11_mode); |
| 15776 | ch_info->channel = operationChannel; |
| 15777 | ch_info->cb_mode = ch_params->ch_width; |
| 15778 | hdd_debug("ch_info width %d, phymode %d channel %d", |
| 15779 | ch_info->channel_width, ch_info->phy_mode, |
| 15780 | ch_info->channel); |
| 15781 | } |
| 15782 | #else |
| 15783 | static |
| 15784 | void hdd_mon_select_cbmode(struct hdd_adapter *adapter, |
| 15785 | uint8_t operationChannel, |
| 15786 | struct ch_params *ch_params) |
| 15787 | { |
| 15788 | } |
| 15789 | #endif |
| 15790 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15791 | /** |
| 15792 | * hdd_select_cbmode() - select channel bonding mode |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15793 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15794 | * @operatingChannel: Operating channel |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 15795 | * @ch_params: channel info struct to populate |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15796 | * |
| 15797 | * Return: none |
| 15798 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15799 | void hdd_select_cbmode(struct hdd_adapter *adapter, uint8_t operationChannel, |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 15800 | struct ch_params *ch_params) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15801 | { |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 15802 | uint8_t sec_ch = 0; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15803 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 15804 | struct hdd_station_ctx *station_ctx = |
| 15805 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 15806 | eConnectionState connstate; |
| 15807 | bool cbmode_select = false; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 15808 | |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 15809 | /* |
| 15810 | * CDS api expects secondary channel for calculating |
| 15811 | * the channel params |
| 15812 | */ |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 15813 | if ((ch_params->ch_width == CH_WIDTH_40MHZ) && |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 15814 | (WLAN_REG_IS_24GHZ_CH(operationChannel))) { |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 15815 | if (operationChannel >= 1 && operationChannel <= 5) |
| 15816 | sec_ch = operationChannel + 4; |
| 15817 | else if (operationChannel >= 6 && operationChannel <= 13) |
| 15818 | sec_ch = operationChannel - 4; |
| 15819 | } |
| 15820 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15821 | /* This call decides required channel bonding mode */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 15822 | wlan_reg_set_channel_params(hdd_ctx->pdev, operationChannel, |
| 15823 | sec_ch, ch_params); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 15824 | |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 15825 | if (adapter->device_mode == QDF_STA_MODE && |
Pragaspathi Thilagaraj | a889375 | 2019-02-06 19:58:59 +0530 | [diff] [blame] | 15826 | ucfg_mlme_is_change_channel_bandwidth_enabled(hdd_ctx->psoc)) { |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 15827 | connstate = station_ctx->conn_info.conn_state; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 15828 | if (!(eConnectionState_Associated == connstate || |
| 15829 | eConnectionState_Connecting == connstate)) { |
| 15830 | cbmode_select = true; |
| 15831 | } |
| 15832 | } |
| 15833 | |
| 15834 | if (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE || cbmode_select) |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15835 | hdd_mon_select_cbmode(adapter, operationChannel, ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15836 | } |
| 15837 | |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 15838 | /** |
| 15839 | * wlan_hdd_handle_sap_sta_dfs_conc() - to handle SAP STA DFS conc |
| 15840 | * @adapter: STA adapter |
| 15841 | * @roam_profile: STA roam profile |
| 15842 | * |
| 15843 | * This routine will move SAP from dfs to non-dfs, if sta is coming up. |
| 15844 | * |
| 15845 | * Return: false if sta-sap conc is not allowed, else return true |
| 15846 | */ |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 15847 | static |
| 15848 | bool wlan_hdd_handle_sap_sta_dfs_conc(struct hdd_adapter *adapter, |
| 15849 | struct csr_roam_profile *roam_profile) |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 15850 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 15851 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 15852 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 15853 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 15854 | struct hdd_hostapd_state *hostapd_state; |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 15855 | uint8_t channel = 0; |
| 15856 | QDF_STATUS status; |
| 15857 | |
| 15858 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 15859 | if (!hdd_ctx) { |
| 15860 | hdd_err("HDD context is NULL"); |
| 15861 | return true; |
| 15862 | } |
| 15863 | |
| 15864 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 15865 | /* probably no sap running, no handling required */ |
| 15866 | if (ap_adapter == NULL) |
| 15867 | return true; |
| 15868 | |
| 15869 | /* |
| 15870 | * sap is not in started state, so it is fine to go ahead with sta. |
| 15871 | * if sap is currently doing CAC then don't allow sta to go further. |
| 15872 | */ |
| 15873 | if (!test_bit(SOFTAP_BSS_STARTED, &(ap_adapter)->event_flags) && |
| 15874 | (hdd_ctx->dev_dfs_cac_status != DFS_CAC_IN_PROGRESS)) |
| 15875 | return true; |
| 15876 | |
| 15877 | if (hdd_ctx->dev_dfs_cac_status == DFS_CAC_IN_PROGRESS) { |
| 15878 | hdd_err("Concurrent SAP is in CAC state, STA is not allowed"); |
| 15879 | return false; |
| 15880 | } |
| 15881 | |
| 15882 | /* |
| 15883 | * log and return error, if we allow STA to go through, we don't |
| 15884 | * know what is going to happen better stop sta connection |
| 15885 | */ |
| 15886 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 15887 | if (NULL == hdd_ap_ctx) { |
| 15888 | hdd_err("AP context not found"); |
| 15889 | return false; |
| 15890 | } |
| 15891 | |
| 15892 | /* sap is on non-dfs channel, nothing to handle */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 15893 | if (!wlan_reg_is_dfs_ch(hdd_ctx->pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 15894 | hdd_ap_ctx->operating_channel)) { |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 15895 | hdd_info("sap is on non-dfs channel, sta is allowed"); |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 15896 | return true; |
| 15897 | } |
| 15898 | /* |
| 15899 | * find out by looking in to scan cache where sta is going to |
Nitesh Shah | 5977452 | 2016-09-16 15:14:21 +0530 | [diff] [blame] | 15900 | * connect by passing its roam_profile. |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 15901 | */ |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 15902 | status = policy_mgr_get_channel_from_scan_result(hdd_ctx->psoc, |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 15903 | roam_profile, &channel); |
| 15904 | |
Nitesh Shah | 5977452 | 2016-09-16 15:14:21 +0530 | [diff] [blame] | 15905 | /* |
| 15906 | * If the STA's channel is 2.4 GHz, then set pcl with only 2.4 GHz |
| 15907 | * channels for roaming case. |
| 15908 | */ |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 15909 | if (WLAN_REG_IS_24GHZ_CH(channel)) { |
| 15910 | hdd_info("sap is on dfs, new sta conn on 2.4 is allowed"); |
Nitesh Shah | 5977452 | 2016-09-16 15:14:21 +0530 | [diff] [blame] | 15911 | return true; |
| 15912 | } |
| 15913 | |
| 15914 | /* |
Jeff Johnson | dcf84ce | 2017-10-05 09:26:24 -0700 | [diff] [blame] | 15915 | * If channel is 0 or DFS or LTE unsafe then better to call pcl and |
Tushnim Bhattacharyya | 9a92999 | 2017-06-18 00:59:09 -0700 | [diff] [blame] | 15916 | * find out the best channel. If channel is non-dfs 5 GHz then |
| 15917 | * better move SAP to STA's channel to make scc, so we have room |
| 15918 | * for 3port MCC scenario. |
Nitesh Shah | 5977452 | 2016-09-16 15:14:21 +0530 | [diff] [blame] | 15919 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 15920 | if (!channel || wlan_reg_is_dfs_ch(hdd_ctx->pdev, channel) || |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 15921 | !policy_mgr_is_safe_channel(hdd_ctx->psoc, channel)) |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 15922 | channel = policy_mgr_get_nondfs_preferred_channel( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 15923 | hdd_ctx->psoc, PM_SAP_MODE, true); |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 15924 | |
| 15925 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 15926 | qdf_event_reset(&hostapd_state->qdf_event); |
| 15927 | status = wlansap_set_channel_change_with_csa( |
| 15928 | WLAN_HDD_GET_SAP_CTX_PTR(ap_adapter), channel, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 15929 | hdd_ap_ctx->sap_config.ch_width_orig, false); |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 15930 | |
| 15931 | if (QDF_STATUS_SUCCESS != status) { |
| 15932 | hdd_err("Set channel with CSA IE failed, can't allow STA"); |
| 15933 | return false; |
| 15934 | } |
| 15935 | |
| 15936 | /* |
| 15937 | * wait here for SAP to finish the channel switch. When channel |
| 15938 | * switch happens, SAP sends few beacons with CSA_IE. After |
| 15939 | * successfully Transmission of those beacons, it will move its |
| 15940 | * state from started to disconnected and move to new channel. |
| 15941 | * once it moves to new channel, sap again moves its state |
| 15942 | * machine from disconnected to started and set this event. |
| 15943 | * wait for 10 secs to finish this. |
| 15944 | */ |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 15945 | status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, 10000); |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 15946 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 15947 | hdd_err("wait for qdf_event failed, STA not allowed!!"); |
| 15948 | return false; |
| 15949 | } |
| 15950 | |
| 15951 | return true; |
| 15952 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15953 | |
Abhishek Singh | cfb4448 | 2017-03-10 12:42:37 +0530 | [diff] [blame] | 15954 | #ifdef WLAN_FEATURE_11W |
| 15955 | /** |
| 15956 | * wlan_hdd_cfg80211_check_pmf_valid() - check if pmf status is ok |
| 15957 | * @roam_profile: pointer to roam profile |
| 15958 | * |
| 15959 | * if MFPEnabled is set but the peer AP is non-PMF i.e 80211w=2 |
| 15960 | * or pmf=2 is an explicit configuration in the supplicant |
| 15961 | * configuration, drop the connection request. |
| 15962 | * |
| 15963 | * Return: 0 if check result is valid, otherwise return error code |
| 15964 | */ |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 15965 | static |
| 15966 | int wlan_hdd_cfg80211_check_pmf_valid(struct csr_roam_profile *roam_profile) |
Abhishek Singh | cfb4448 | 2017-03-10 12:42:37 +0530 | [diff] [blame] | 15967 | { |
| 15968 | if (roam_profile->MFPEnabled && |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 15969 | !(roam_profile->MFPRequired || roam_profile->MFPCapable)) { |
Abhishek Singh | cfb4448 | 2017-03-10 12:42:37 +0530 | [diff] [blame] | 15970 | hdd_err("Drop connect req as supplicant has indicated PMF required for the non-PMF peer. MFPEnabled %d MFPRequired %d MFPCapable %d", |
| 15971 | roam_profile->MFPEnabled, |
| 15972 | roam_profile->MFPRequired, |
| 15973 | roam_profile->MFPCapable); |
| 15974 | return -EINVAL; |
| 15975 | } |
| 15976 | return 0; |
| 15977 | } |
| 15978 | #else |
| 15979 | static inline |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 15980 | int wlan_hdd_cfg80211_check_pmf_valid(struct csr_roam_profile *roam_profile) |
Abhishek Singh | cfb4448 | 2017-03-10 12:42:37 +0530 | [diff] [blame] | 15981 | { |
| 15982 | return 0; |
| 15983 | } |
| 15984 | #endif |
| 15985 | |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 15986 | /** |
| 15987 | * wlan_hdd_cfg80211_connect_start() - to start the association process |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15988 | * @adapter: Pointer to adapter |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 15989 | * @ssid: Pointer to ssid |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15990 | * @ssid_len: Length of ssid |
| 15991 | * @bssid: Pointer to bssid |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 15992 | * @bssid_hint: Pointer to bssid hint |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15993 | * @operatingChannel: Operating channel |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 15994 | * @ch_width: channel width. this is needed only for IBSS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15995 | * |
| 15996 | * This function is used to start the association process |
| 15997 | * |
| 15998 | * Return: 0 for success, non-zero for failure |
| 15999 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16000 | static int wlan_hdd_cfg80211_connect_start(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16001 | const u8 *ssid, size_t ssid_len, |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 16002 | const u8 *bssid, const u8 *bssid_hint, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 16003 | u8 operatingChannel, |
| 16004 | enum nl80211_chan_width ch_width) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16005 | { |
| 16006 | int status = 0; |
Rajeev Kumar | d31e154 | 2017-01-13 14:37:42 -0800 | [diff] [blame] | 16007 | QDF_STATUS qdf_status; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16008 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 16009 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 16010 | uint32_t roam_id = INVALID_ROAM_ID; |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 16011 | struct csr_roam_profile *roam_profile; |
Jeff Johnson | 784efe2 | 2019-03-09 18:31:13 -0800 | [diff] [blame] | 16012 | eCsrAuthType rsn_auth_type; |
Jeff Johnson | 46b4f0e | 2019-03-08 10:48:35 -0800 | [diff] [blame] | 16013 | struct sme_config_params *sme_config; |
Nitesh Shah | 044fd67 | 2016-10-13 18:53:25 +0530 | [diff] [blame] | 16014 | uint8_t channel = 0; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 16015 | mac_handle_t mac_handle; |
Abhinav Kumar | 7d6f1ac | 2018-09-01 18:33:56 +0530 | [diff] [blame] | 16016 | uint8_t wmm_mode = 0; |
| 16017 | uint8_t value = 0; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 16018 | struct wlan_objmgr_vdev *vdev; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 16019 | uint32_t channel_bonding_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16020 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 16021 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16022 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16023 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 16024 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16025 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16026 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 16027 | if (status) |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16028 | goto ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16029 | |
| 16030 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16031 | hdd_err("wrong SSID len"); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16032 | status = -EINVAL; |
| 16033 | goto ret_status; |
| 16034 | } |
| 16035 | |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 16036 | if (true == hdd_is_connection_in_progress(NULL, NULL)) { |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16037 | hdd_err("Connection refused: conn in progress"); |
| 16038 | status = -EINVAL; |
| 16039 | goto ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16040 | } |
| 16041 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 16042 | /* Disable roaming on all other adapters before connect start */ |
| 16043 | wlan_hdd_disable_roaming(adapter); |
| 16044 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 16045 | vdev = hdd_objmgr_get_vdev(adapter); |
| 16046 | if (!vdev) { |
| 16047 | status = -EINVAL; |
| 16048 | goto ret_status; |
| 16049 | } |
| 16050 | hdd_notify_teardown_tdls_links(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 16051 | hdd_objmgr_put_vdev(vdev); |
Nitesh Shah | 273e4e5 | 2017-04-03 12:53:36 +0530 | [diff] [blame] | 16052 | |
Anurag Chouhan | d939d3d | 2016-07-20 17:45:48 +0530 | [diff] [blame] | 16053 | qdf_mem_zero(&hdd_sta_ctx->conn_info.conn_flag, |
| 16054 | sizeof(hdd_sta_ctx->conn_info.conn_flag)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16055 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16056 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16057 | if (roam_profile) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16058 | struct hdd_station_ctx *sta_ctx; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 16059 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16060 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16061 | |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16062 | /* Restart the opportunistic timer |
| 16063 | * |
| 16064 | * If hw_mode_change_in_progress is true, then wait |
| 16065 | * till firmware sends the callback for hw_mode change. |
| 16066 | * |
| 16067 | * Else set connect_in_progress as true and proceed. |
| 16068 | */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 16069 | policy_mgr_restart_opportunistic_timer( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 16070 | hdd_ctx->psoc, false); |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 16071 | if (policy_mgr_is_hw_mode_change_in_progress( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 16072 | hdd_ctx->psoc)) { |
Abhishek Singh | 471652b | 2017-04-14 12:28:32 +0530 | [diff] [blame] | 16073 | qdf_status = policy_mgr_wait_for_connection_update( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 16074 | hdd_ctx->psoc); |
Abhishek Singh | 471652b | 2017-04-14 12:28:32 +0530 | [diff] [blame] | 16075 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16076 | hdd_err("qdf wait for event failed!!"); |
| 16077 | status = -EINVAL; |
| 16078 | goto ret_status; |
| 16079 | } |
| 16080 | } |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 16081 | hdd_set_connection_in_progress(true); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16082 | |
Abhinav Kumar | 7d6f1ac | 2018-09-01 18:33:56 +0530 | [diff] [blame] | 16083 | status = ucfg_mlme_get_wmm_mode(hdd_ctx->psoc, &wmm_mode); |
| 16084 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 16085 | hdd_err("Get wmm_mode failed"); |
| 16086 | status = -EINVAL; |
| 16087 | goto ret_status; |
| 16088 | } |
| 16089 | if (HDD_WMM_USER_MODE_NO_QOS == wmm_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16090 | /*QoS not enabled in cfg file */ |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16091 | roam_profile->uapsd_mask = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16092 | } else { |
| 16093 | /*QoS enabled, update uapsd mask from cfg file */ |
Abhinav Kumar | 7d6f1ac | 2018-09-01 18:33:56 +0530 | [diff] [blame] | 16094 | status = ucfg_mlme_get_wmm_uapsd_mask(hdd_ctx->psoc, |
| 16095 | &value); |
| 16096 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 16097 | hdd_err("Get uapsd_mask failed"); |
| 16098 | status = -EINVAL; |
| 16099 | goto ret_status; |
| 16100 | } |
| 16101 | roam_profile->uapsd_mask = value; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16102 | } |
| 16103 | |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16104 | roam_profile->SSIDs.numOfSSIDs = 1; |
| 16105 | roam_profile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 16106 | qdf_mem_zero(roam_profile->SSIDs.SSIDList->SSID.ssId, |
| 16107 | sizeof(roam_profile->SSIDs.SSIDList->SSID.ssId)); |
| 16108 | qdf_mem_copy((void *)(roam_profile->SSIDs.SSIDList->SSID.ssId), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16109 | ssid, ssid_len); |
| 16110 | |
Abhishek Singh | 3c9910e | 2017-01-06 17:56:47 +0530 | [diff] [blame] | 16111 | /* cleanup bssid hint */ |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16112 | qdf_mem_zero(roam_profile->bssid_hint.bytes, |
Abhishek Singh | 3c9910e | 2017-01-06 17:56:47 +0530 | [diff] [blame] | 16113 | QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16114 | qdf_mem_zero((void *)(roam_profile->BSSIDs.bssid), |
Abhishek Singh | 3c9910e | 2017-01-06 17:56:47 +0530 | [diff] [blame] | 16115 | QDF_MAC_ADDR_SIZE); |
| 16116 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16117 | if (bssid) { |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16118 | roam_profile->BSSIDs.numOfBSSIDs = 1; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16119 | qdf_mem_copy((void *)(roam_profile->BSSIDs.bssid), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 16120 | bssid, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 16121 | /* |
Jeff Johnson | fa7d960 | 2018-05-06 11:25:31 -0700 | [diff] [blame] | 16122 | * Save BSSID in separate variable as |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16123 | * roam_profile's BSSID is getting zeroed out in the |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 16124 | * association process. In case of join failure |
| 16125 | * we should send valid BSSID to supplicant |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16126 | */ |
Jeff Johnson | 731bc32 | 2017-10-14 19:53:44 -0700 | [diff] [blame] | 16127 | qdf_mem_copy(sta_ctx->requested_bssid.bytes, |
| 16128 | bssid, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16129 | hdd_debug("bssid is given by upper layer %pM", bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16130 | } else if (bssid_hint) { |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16131 | qdf_mem_copy(roam_profile->bssid_hint.bytes, |
Abhishek Singh | 3c9910e | 2017-01-06 17:56:47 +0530 | [diff] [blame] | 16132 | bssid_hint, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 16133 | /* |
| 16134 | * Save BSSID in a separate variable as |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16135 | * roam_profile's BSSID is getting zeroed out in the |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 16136 | * association process. In case of join failure |
| 16137 | * we should send valid BSSID to supplicant |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16138 | */ |
Jeff Johnson | 731bc32 | 2017-10-14 19:53:44 -0700 | [diff] [blame] | 16139 | qdf_mem_copy(sta_ctx->requested_bssid.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 16140 | bssid_hint, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16141 | hdd_debug("bssid_hint is given by upper layer %pM", |
Krunal Soni | 35b404c | 2016-07-14 23:36:00 -0700 | [diff] [blame] | 16142 | bssid_hint); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16143 | } |
| 16144 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16145 | hdd_debug("Connect to SSID: %.*s operating Channel: %u", |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16146 | roam_profile->SSIDs.SSIDList->SSID.length, |
| 16147 | roam_profile->SSIDs.SSIDList->SSID.ssId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16148 | operatingChannel); |
| 16149 | |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 16150 | if (hdd_sta_ctx->wpa_versions) { |
Jeff Johnson | 784efe2 | 2019-03-09 18:31:13 -0800 | [diff] [blame] | 16151 | hdd_set_genie_to_csr(adapter, &rsn_auth_type); |
| 16152 | hdd_set_csr_auth_type(adapter, rsn_auth_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16153 | } |
| 16154 | #ifdef FEATURE_WLAN_WAPI |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 16155 | if (adapter->wapi_info.wapi_mode) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16156 | hdd_debug("Setting WAPI AUTH Type and Encryption Mode values"); |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 16157 | switch (adapter->wapi_info.wapi_auth_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16158 | case WAPI_AUTH_MODE_PSK: |
| 16159 | { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16160 | hdd_debug("WAPI AUTH TYPE: PSK: %d", |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 16161 | adapter->wapi_info.wapi_auth_mode); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16162 | roam_profile->AuthType.authType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16163 | eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 16164 | break; |
| 16165 | } |
| 16166 | case WAPI_AUTH_MODE_CERT: |
| 16167 | { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16168 | hdd_debug("WAPI AUTH TYPE: CERT: %d", |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 16169 | adapter->wapi_info.wapi_auth_mode); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16170 | roam_profile->AuthType.authType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16171 | eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 16172 | break; |
| 16173 | } |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 16174 | default: |
| 16175 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16176 | } /* End of switch */ |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 16177 | if (adapter->wapi_info.wapi_auth_mode == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16178 | WAPI_AUTH_MODE_PSK |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 16179 | || adapter->wapi_info.wapi_auth_mode == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16180 | WAPI_AUTH_MODE_CERT) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16181 | hdd_debug("WAPI PAIRWISE/GROUP ENCRYPTION: WPI"); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16182 | roam_profile->AuthType.numEntries = 1; |
| 16183 | roam_profile->EncryptionType.numEntries = 1; |
| 16184 | roam_profile->EncryptionType.encryptionType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16185 | eCSR_ENCRYPT_TYPE_WPI; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16186 | roam_profile->mcEncryptionType.numEntries = 1; |
| 16187 | roam_profile->mcEncryptionType. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16188 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 16189 | } |
| 16190 | } |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 16191 | #endif |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 16192 | vdev = hdd_objmgr_get_vdev(adapter); |
| 16193 | if (!vdev) { |
| 16194 | status = -EINVAL; |
| 16195 | goto conn_failure; |
| 16196 | } |
| 16197 | ucfg_pmo_flush_gtk_offload_req(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 16198 | hdd_objmgr_put_vdev(vdev); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16199 | roam_profile->csrPersona = adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16200 | |
| 16201 | if (operatingChannel) { |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16202 | roam_profile->ChannelInfo.ChannelList = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16203 | &operatingChannel; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16204 | roam_profile->ChannelInfo.numOfChannels = 1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16205 | } else { |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16206 | roam_profile->ChannelInfo.ChannelList = NULL; |
| 16207 | roam_profile->ChannelInfo.numOfChannels = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16208 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16209 | if ((QDF_IBSS_MODE == adapter->device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16210 | && operatingChannel) { |
| 16211 | /* |
| 16212 | * Need to post the IBSS power save parameters |
| 16213 | * to WMA. WMA will configure this parameters |
| 16214 | * to firmware if power save is enabled by the |
| 16215 | * firmware. |
| 16216 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16217 | qdf_status = hdd_set_ibss_power_save_params(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16218 | |
Abhishek Singh | 471652b | 2017-04-14 12:28:32 +0530 | [diff] [blame] | 16219 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16220 | hdd_err("Set IBSS Power Save Params Failed"); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16221 | status = -EINVAL; |
| 16222 | goto conn_failure; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16223 | } |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16224 | roam_profile->ch_params.ch_width = |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 16225 | hdd_map_nl_chan_width(ch_width); |
Nitesh Shah | 87335a5 | 2016-09-05 15:47:32 +0530 | [diff] [blame] | 16226 | /* |
| 16227 | * In IBSS mode while operating in 2.4 GHz, |
| 16228 | * the device supports only 20 MHz. |
| 16229 | */ |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 16230 | if (WLAN_REG_IS_24GHZ_CH(operatingChannel)) |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16231 | roam_profile->ch_params.ch_width = |
Nitesh Shah | 87335a5 | 2016-09-05 15:47:32 +0530 | [diff] [blame] | 16232 | CH_WIDTH_20MHZ; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16233 | hdd_select_cbmode(adapter, operatingChannel, |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16234 | &roam_profile->ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16235 | } |
| 16236 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16237 | if (wlan_hdd_cfg80211_check_pmf_valid(roam_profile)) { |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16238 | status = -EINVAL; |
| 16239 | goto conn_failure; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16240 | } |
| 16241 | |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 16242 | /* |
| 16243 | * After 8-way handshake supplicant should give the scan command |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16244 | * in that it update the additional IEs, But because of scan |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 16245 | * enhancements, the supplicant is not issuing the scan command |
| 16246 | * now. So the unicast frames which are sent from the host are |
| 16247 | * not having the additional IEs. If it is P2P CLIENT and there |
| 16248 | * is no additional IE present in roamProfile, then use the |
| 16249 | * addtional IE form scan_info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16250 | */ |
| 16251 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16252 | if ((adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16253 | (!roam_profile->pAddIEScan)) { |
| 16254 | roam_profile->pAddIEScan = |
Jeff Johnson | 37fa040 | 2017-10-28 12:42:29 -0700 | [diff] [blame] | 16255 | &adapter->scan_info.scan_add_ie.addIEdata[0]; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16256 | roam_profile->nAddIEScanLength = |
Jeff Johnson | 37fa040 | 2017-10-28 12:42:29 -0700 | [diff] [blame] | 16257 | adapter->scan_info.scan_add_ie.length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16258 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16259 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 16260 | if ((policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc) == true) |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16261 | && (false == wlan_hdd_handle_sap_sta_dfs_conc(adapter, |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16262 | roam_profile))) { |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 16263 | hdd_err("sap-sta conc will fail, can't allow sta"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16264 | hdd_conn_set_connection_state(adapter, |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 16265 | eConnectionState_NotConnected); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16266 | status = -ENOMEM; |
| 16267 | goto conn_failure; |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 16268 | } |
| 16269 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16270 | sme_config = qdf_mem_malloc(sizeof(*sme_config)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16271 | if (!sme_config) { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16272 | hdd_conn_set_connection_state(adapter, |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 16273 | eConnectionState_NotConnected); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16274 | status = -ENOMEM; |
| 16275 | goto conn_failure; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16276 | } |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 16277 | |
| 16278 | mac_handle = hdd_ctx->mac_handle; |
| 16279 | sme_get_config_param(mac_handle, sme_config); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16280 | /* These values are not sessionized. So, any change in these SME |
| 16281 | * configs on an older or parallel interface will affect the |
| 16282 | * cb mode. So, restoring the default INI params before starting |
| 16283 | * interfaces such as sta, cli etc., |
| 16284 | */ |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 16285 | ucfg_mlme_get_channel_bonding_5ghz(hdd_ctx->psoc, |
| 16286 | &channel_bonding_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16287 | sme_config->csrConfig.channelBondingMode5GHz = |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 16288 | channel_bonding_mode; |
| 16289 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 16290 | &channel_bonding_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16291 | sme_config->csrConfig.channelBondingMode24GHz = |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 16292 | channel_bonding_mode; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 16293 | sme_update_config(mac_handle, sme_config); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16294 | qdf_mem_free(sme_config); |
Agrawal Ashish | 6b01576 | 2016-05-05 11:22:18 +0530 | [diff] [blame] | 16295 | /* |
| 16296 | * Change conn_state to connecting before sme_roam_connect(), |
| 16297 | * because sme_roam_connect() has a direct path to call |
| 16298 | * hdd_sme_roam_callback(), which will change the conn_state |
| 16299 | * If direct path, conn_state will be accordingly changed to |
| 16300 | * NotConnected or Associated by either |
| 16301 | * hdd_association_completion_handler() or |
| 16302 | * hdd_dis_connect_handler() in sme_RoamCallback()if |
| 16303 | * sme_RomConnect is to be queued, |
| 16304 | * Connecting state will remain until it is completed. |
| 16305 | * |
| 16306 | * If connection state is not changed, connection state will |
| 16307 | * remain in eConnectionState_NotConnected state. |
| 16308 | * In hdd_association_completion_handler, "hddDisconInProgress" |
| 16309 | * is set to true if conn state is |
| 16310 | * eConnectionState_NotConnected. |
| 16311 | * If "hddDisconInProgress" is set to true then cfg80211 layer |
| 16312 | * is not informed of connect result indication which |
| 16313 | * is an issue. |
| 16314 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16315 | if (QDF_STA_MODE == adapter->device_mode || |
| 16316 | QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 16317 | hdd_conn_set_connection_state(adapter, |
Agrawal Ashish | 6b01576 | 2016-05-05 11:22:18 +0530 | [diff] [blame] | 16318 | eConnectionState_Connecting); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16319 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 16320 | hdd_set_disconnect_status(adapter, false); |
| 16321 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 16322 | qdf_runtime_pm_prevent_suspend( |
| 16323 | &hdd_ctx->runtime_context.connect); |
Padma, Santhosh Kumar | c88de48 | 2018-04-09 16:17:04 +0530 | [diff] [blame] | 16324 | hdd_prevent_suspend_timeout(HDD_WAKELOCK_CONNECT_COMPLETE, |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 16325 | WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 16326 | qdf_status = sme_roam_connect(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 16327 | adapter->vdev_id, roam_profile, |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 16328 | &roam_id); |
Abhishek Singh | 471652b | 2017-04-14 12:28:32 +0530 | [diff] [blame] | 16329 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 16330 | status = qdf_status_to_os_return(qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16331 | |
Rajeev Kumar | d31e154 | 2017-01-13 14:37:42 -0800 | [diff] [blame] | 16332 | if ((QDF_STATUS_SUCCESS != qdf_status) && |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16333 | (QDF_STA_MODE == adapter->device_mode || |
| 16334 | QDF_P2P_CLIENT_MODE == adapter->device_mode)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16335 | hdd_err("sme_roam_connect (session %d) failed with " |
Rajeev Kumar | d31e154 | 2017-01-13 14:37:42 -0800 | [diff] [blame] | 16336 | "qdf_status %d. -> NotConnected", |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 16337 | adapter->vdev_id, qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16338 | /* change back to NotAssociated */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16339 | hdd_conn_set_connection_state(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16340 | eConnectionState_NotConnected); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 16341 | qdf_runtime_pm_allow_suspend( |
| 16342 | &hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 16343 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16344 | } |
| 16345 | |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16346 | /* Reset connect_in_progress */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 16347 | hdd_set_connection_in_progress(false); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16348 | |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16349 | roam_profile->ChannelInfo.ChannelList = NULL; |
| 16350 | roam_profile->ChannelInfo.numOfChannels = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16351 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16352 | if ((QDF_STA_MODE == adapter->device_mode) |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 16353 | && policy_mgr_is_current_hwmode_dbs(hdd_ctx->psoc) |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 16354 | && !policy_mgr_is_hw_dbs_2x2_capable( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 16355 | hdd_ctx->psoc)) { |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 16356 | policy_mgr_get_channel_from_scan_result( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 16357 | hdd_ctx->psoc, |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16358 | roam_profile, &channel); |
Archana Ramachandran | cc0ffb1 | 2017-02-17 18:30:43 -0800 | [diff] [blame] | 16359 | hdd_info("Move to single MAC mode(optimization) if applicable"); |
Nitesh Shah | 044fd67 | 2016-10-13 18:53:25 +0530 | [diff] [blame] | 16360 | if (channel) |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 16361 | policy_mgr_checkn_update_hw_mode_single_mac_mode( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 16362 | hdd_ctx->psoc, channel); |
Nitesh Shah | 044fd67 | 2016-10-13 18:53:25 +0530 | [diff] [blame] | 16363 | } |
| 16364 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16365 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16366 | hdd_err("No valid Roam profile"); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16367 | status = -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16368 | } |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16369 | goto ret_status; |
| 16370 | |
| 16371 | conn_failure: |
| 16372 | /* Reset connect_in_progress */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 16373 | hdd_set_connection_in_progress(false); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 16374 | |
| 16375 | ret_status: |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 16376 | /* |
| 16377 | * Enable roaming on other STA adapter for failure case. |
| 16378 | * For success case, it is enabled in assoc completion handler |
| 16379 | */ |
| 16380 | if (status) |
| 16381 | wlan_hdd_enable_roaming(adapter); |
| 16382 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 16383 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16384 | return status; |
| 16385 | } |
| 16386 | |
| 16387 | /** |
| 16388 | * wlan_hdd_cfg80211_set_auth_type() - set auth type |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16389 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16390 | * @auth_type: Auth type |
| 16391 | * |
| 16392 | * This function is used to set the authentication type (OPEN/SHARED). |
| 16393 | * |
| 16394 | * Return: 0 for success, non-zero for failure |
| 16395 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16396 | static int wlan_hdd_cfg80211_set_auth_type(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16397 | enum nl80211_auth_type auth_type) |
| 16398 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16399 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16400 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16401 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16402 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16403 | /*set authentication type */ |
| 16404 | switch (auth_type) { |
| 16405 | case NL80211_AUTHTYPE_AUTOMATIC: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16406 | hdd_debug("set authentication type to AUTOSWITCH"); |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 16407 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_AUTOSWITCH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16408 | break; |
| 16409 | |
| 16410 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16411 | case NL80211_AUTHTYPE_FT: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16412 | hdd_debug("set authentication type to OPEN"); |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 16413 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16414 | break; |
| 16415 | |
| 16416 | case NL80211_AUTHTYPE_SHARED_KEY: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16417 | hdd_debug("set authentication type to SHARED"); |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 16418 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_SHARED_KEY; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16419 | break; |
| 16420 | #ifdef FEATURE_WLAN_ESE |
| 16421 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16422 | hdd_debug("set authentication type to CCKM WPA"); |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 16423 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_CCKM_WPA; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16424 | break; |
| 16425 | #endif |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 16426 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 16427 | (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 16428 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16429 | case NL80211_AUTHTYPE_FILS_SK: |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 16430 | hdd_debug("set authentication type to FILS SHARED"); |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 16431 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16432 | break; |
| 16433 | #endif |
Padma, Santhosh Kumar | 07eb80b | 2017-07-05 16:10:06 +0530 | [diff] [blame] | 16434 | case NL80211_AUTHTYPE_SAE: |
| 16435 | hdd_debug("set authentication type to SAE"); |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 16436 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_SAE; |
Padma, Santhosh Kumar | 07eb80b | 2017-07-05 16:10:06 +0530 | [diff] [blame] | 16437 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16438 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16439 | hdd_err("Unsupported authentication type: %d", auth_type); |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 16440 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_UNKNOWN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16441 | return -EINVAL; |
| 16442 | } |
| 16443 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16444 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 16445 | roam_profile->AuthType.authType[0] = sta_ctx->conn_info.auth_type; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16446 | return 0; |
| 16447 | } |
| 16448 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 16449 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 16450 | (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 16451 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16452 | static bool hdd_validate_fils_info_ptr(struct csr_roam_profile *roam_profile) |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16453 | { |
| 16454 | struct cds_fils_connection_info *fils_con_info; |
| 16455 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16456 | fils_con_info = roam_profile->fils_con_info; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16457 | if (!fils_con_info) { |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 16458 | hdd_err("No valid Roam profile"); |
| 16459 | return false; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16460 | } |
| 16461 | |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 16462 | return true; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16463 | } |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 16464 | |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16465 | static enum eAniAuthType wlan_hdd_get_fils_auth_type( |
| 16466 | enum nl80211_auth_type auth) |
| 16467 | { |
| 16468 | switch (auth) { |
| 16469 | case NL80211_AUTHTYPE_FILS_SK: |
| 16470 | return SIR_FILS_SK_WITHOUT_PFS; |
| 16471 | case NL80211_AUTHTYPE_FILS_SK_PFS: |
| 16472 | return SIR_FILS_SK_WITH_PFS; |
| 16473 | case NL80211_AUTHTYPE_FILS_PK: |
| 16474 | return SIR_FILS_PK_AUTH; |
| 16475 | default: |
| 16476 | return eSIR_DONOT_USE_AUTH_TYPE; |
| 16477 | } |
| 16478 | } |
| 16479 | |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 16480 | static bool wlan_hdd_fils_data_in_limits(struct cfg80211_connect_params *req) |
| 16481 | { |
| 16482 | hdd_debug("seq=%d auth=%d lengths: user=%zu rrk=%zu realm=%zu", |
| 16483 | req->fils_erp_next_seq_num, req->auth_type, |
| 16484 | req->fils_erp_username_len, req->fils_erp_rrk_len, |
| 16485 | req->fils_erp_realm_len); |
| 16486 | if (!req->fils_erp_rrk_len || !req->fils_erp_realm_len || |
| 16487 | !req->fils_erp_username_len || |
| 16488 | req->fils_erp_rrk_len > FILS_MAX_RRK_LENGTH || |
| 16489 | req->fils_erp_realm_len > FILS_MAX_REALM_LEN || |
| 16490 | req->fils_erp_username_len > FILS_MAX_KEYNAME_NAI_LENGTH) { |
| 16491 | hdd_err("length incorrect, user=%zu rrk=%zu realm=%zu", |
| 16492 | req->fils_erp_username_len, req->fils_erp_rrk_len, |
| 16493 | req->fils_erp_realm_len); |
| 16494 | return false; |
| 16495 | } |
| 16496 | |
bings | 77a35ac | 2018-06-01 15:10:44 +0800 | [diff] [blame] | 16497 | if (!req->fils_erp_rrk || !req->fils_erp_realm || |
| 16498 | !req->fils_erp_username) { |
| 16499 | hdd_err("buffer incorrect, user=%pK rrk=%pK realm=%pK", |
| 16500 | req->fils_erp_username, req->fils_erp_rrk, |
| 16501 | req->fils_erp_realm); |
| 16502 | return false; |
| 16503 | } |
| 16504 | |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 16505 | return true; |
| 16506 | } |
| 16507 | |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16508 | /** |
| 16509 | * wlan_hdd_cfg80211_set_fils_config() - set fils config params during connect |
| 16510 | * @adapter: Pointer to adapter |
| 16511 | * @req: Pointer to fils parameters |
| 16512 | * |
| 16513 | * Return: 0 for success, non-zero for failure |
| 16514 | */ |
| 16515 | static int wlan_hdd_cfg80211_set_fils_config(struct hdd_adapter *adapter, |
| 16516 | struct cfg80211_connect_params *req) |
| 16517 | { |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 16518 | struct csr_roam_profile *roam_profile; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16519 | enum eAniAuthType auth_type; |
| 16520 | uint8_t *buf; |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 16521 | bool value; |
| 16522 | QDF_STATUS status; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16523 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 16524 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16525 | roam_profile = hdd_roam_profile(adapter); |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16526 | |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 16527 | value = 0; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 16528 | status = ucfg_mlme_get_fils_enabled_info(hdd_ctx->psoc, &value); |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 16529 | if (QDF_IS_STATUS_ERROR(status) || !value) { |
| 16530 | hdd_err("get_fils_enabled status: %d fils_enabled: %d", |
| 16531 | status, value); |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16532 | return -EINVAL; |
| 16533 | } |
Karthik Kantamneni | 2231a23 | 2018-09-11 15:45:55 +0530 | [diff] [blame] | 16534 | |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16535 | hdd_clear_fils_connection_info(adapter); |
| 16536 | roam_profile->fils_con_info = |
| 16537 | qdf_mem_malloc(sizeof(*roam_profile->fils_con_info)); |
| 16538 | |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 16539 | if (!roam_profile->fils_con_info) |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16540 | return -EINVAL; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16541 | /* |
| 16542 | * The initial connection for FILS may happen with an OPEN |
| 16543 | * auth type. Hence we need to allow the connection to go |
| 16544 | * through in that case as well. Below is_fils_connection |
| 16545 | * flag is propagated down to CSR and PE sessions through |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 16546 | * the JOIN request. As the flag is used, do not free the |
| 16547 | * memory allocated to fils_con_info and return success. |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16548 | */ |
| 16549 | if (req->auth_type != NL80211_AUTHTYPE_FILS_SK) { |
| 16550 | roam_profile->fils_con_info->is_fils_connection = false; |
| 16551 | return 0; |
| 16552 | } |
| 16553 | |
| 16554 | /* |
| 16555 | * Once above check is done, then we can check for valid FILS |
| 16556 | * auth types. Currently only NL80211_AUTHTYPE_FILS_SK is |
| 16557 | * supported. Once all auth types are supported, then we can |
| 16558 | * merge these 2 conditions into one. |
| 16559 | */ |
| 16560 | auth_type = wlan_hdd_get_fils_auth_type(req->auth_type); |
| 16561 | if (auth_type == eSIR_DONOT_USE_AUTH_TYPE) { |
| 16562 | hdd_err("invalid auth type for fils %d", req->auth_type); |
Varun Reddy Yeturu | 82e39cd | 2017-10-16 12:04:05 -0700 | [diff] [blame] | 16563 | goto fils_conn_fail; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16564 | } |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 16565 | if (!wlan_hdd_fils_data_in_limits(req)) |
Jeff Johnson | b8adae4 | 2018-02-27 16:12:00 -0800 | [diff] [blame] | 16566 | goto fils_conn_fail; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16567 | |
| 16568 | roam_profile->fils_con_info->is_fils_connection = true; |
| 16569 | roam_profile->fils_con_info->sequence_number = |
Pragaspathi Thilagaraj | 87a60af | 2019-02-20 20:42:47 +0530 | [diff] [blame] | 16570 | (req->fils_erp_next_seq_num + 1); |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16571 | roam_profile->fils_con_info->auth_type = auth_type; |
| 16572 | |
| 16573 | roam_profile->fils_con_info->r_rk_length = |
| 16574 | req->fils_erp_rrk_len; |
| 16575 | if (req->fils_erp_rrk_len) |
| 16576 | qdf_mem_copy(roam_profile->fils_con_info->r_rk, |
| 16577 | req->fils_erp_rrk, |
| 16578 | roam_profile->fils_con_info->r_rk_length); |
| 16579 | |
| 16580 | roam_profile->fils_con_info->realm_len = req->fils_erp_realm_len; |
| 16581 | if (req->fils_erp_realm_len) |
| 16582 | qdf_mem_copy(roam_profile->fils_con_info->realm, |
| 16583 | req->fils_erp_realm, |
| 16584 | roam_profile->fils_con_info->realm_len); |
| 16585 | |
| 16586 | roam_profile->fils_con_info->key_nai_length = |
| 16587 | req->fils_erp_username_len + sizeof(char) + |
| 16588 | req->fils_erp_realm_len; |
| 16589 | hdd_debug("key_nai_length = %d", |
| 16590 | roam_profile->fils_con_info->key_nai_length); |
Varun Reddy Yeturu | 82e39cd | 2017-10-16 12:04:05 -0700 | [diff] [blame] | 16591 | if (roam_profile->fils_con_info->key_nai_length > |
| 16592 | FILS_MAX_KEYNAME_NAI_LENGTH) { |
| 16593 | hdd_err("Do not allow FILS conn due to excess NAI Length %d", |
| 16594 | roam_profile->fils_con_info->key_nai_length); |
| 16595 | goto fils_conn_fail; |
| 16596 | } |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 16597 | buf = roam_profile->fils_con_info->keyname_nai; |
| 16598 | qdf_mem_copy(buf, req->fils_erp_username, req->fils_erp_username_len); |
| 16599 | buf += req->fils_erp_username_len; |
| 16600 | *buf++ = '@'; |
| 16601 | qdf_mem_copy(buf, req->fils_erp_realm, req->fils_erp_realm_len); |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16602 | |
| 16603 | return 0; |
Varun Reddy Yeturu | 82e39cd | 2017-10-16 12:04:05 -0700 | [diff] [blame] | 16604 | |
| 16605 | fils_conn_fail: |
| 16606 | if (roam_profile->fils_con_info) { |
| 16607 | qdf_mem_free(roam_profile->fils_con_info); |
| 16608 | roam_profile->fils_con_info = NULL; |
| 16609 | } |
| 16610 | return -EINVAL; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16611 | } |
| 16612 | |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 16613 | static bool wlan_hdd_is_akm_suite_fils(uint32_t key_mgmt) |
| 16614 | { |
| 16615 | switch (key_mgmt) { |
| 16616 | case WLAN_AKM_SUITE_FILS_SHA256: |
| 16617 | case WLAN_AKM_SUITE_FILS_SHA384: |
| 16618 | case WLAN_AKM_SUITE_FT_FILS_SHA256: |
| 16619 | case WLAN_AKM_SUITE_FT_FILS_SHA384: |
| 16620 | return true; |
| 16621 | default: |
| 16622 | return false; |
| 16623 | } |
| 16624 | } |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16625 | |
| 16626 | static bool wlan_hdd_is_conn_type_fils(struct cfg80211_connect_params *req) |
| 16627 | { |
| 16628 | enum nl80211_auth_type auth_type = req->auth_type; |
| 16629 | /* |
| 16630 | * Below n_akm_suites is defined as int in the kernel, even though it |
| 16631 | * is supposed to be unsigned. |
| 16632 | */ |
| 16633 | int num_akm_suites = req->crypto.n_akm_suites; |
| 16634 | uint32_t key_mgmt = req->crypto.akm_suites[0]; |
| 16635 | enum eAniAuthType fils_auth_type = |
| 16636 | wlan_hdd_get_fils_auth_type(req->auth_type); |
| 16637 | |
| 16638 | hdd_debug("Num of AKM suites = %d", num_akm_suites); |
| 16639 | if (num_akm_suites <= 0) |
| 16640 | return false; |
| 16641 | |
| 16642 | /* |
| 16643 | * Auth type will be either be OPEN or FILS type for a FILS connection |
| 16644 | */ |
| 16645 | if ((auth_type != NL80211_AUTHTYPE_OPEN_SYSTEM) && |
| 16646 | (fils_auth_type == eSIR_DONOT_USE_AUTH_TYPE)) { |
| 16647 | hdd_debug("Not a FILS auth type, auth = %d, fils auth = %d", |
| 16648 | auth_type, fils_auth_type); |
| 16649 | return false; |
| 16650 | } |
| 16651 | |
| 16652 | if (!wlan_hdd_is_akm_suite_fils(key_mgmt)) { |
| 16653 | hdd_debug("Not a FILS AKM SUITE %d", key_mgmt); |
| 16654 | return false; |
| 16655 | } |
| 16656 | |
| 16657 | return true; |
| 16658 | } |
| 16659 | |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 16660 | #else |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16661 | static bool hdd_validate_fils_info_ptr(struct csr_roam_profile *roam_profile) |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16662 | { |
| 16663 | return true; |
| 16664 | } |
| 16665 | |
| 16666 | static int wlan_hdd_cfg80211_set_fils_config(struct hdd_adapter *adapter, |
| 16667 | struct cfg80211_connect_params *req) |
| 16668 | { |
| 16669 | return 0; |
| 16670 | } |
| 16671 | |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 16672 | static bool wlan_hdd_is_akm_suite_fils(uint32_t key_mgmt) |
| 16673 | { |
| 16674 | return false; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16675 | } |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 16676 | |
| 16677 | static bool wlan_hdd_is_conn_type_fils(struct cfg80211_connect_params *req) |
| 16678 | { |
| 16679 | return false; |
| 16680 | } |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16681 | #endif |
| 16682 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16683 | /** |
| 16684 | * wlan_hdd_set_akm_suite() - set key management type |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16685 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16686 | * @key_mgmt: Key management type |
| 16687 | * |
| 16688 | * This function is used to set the key mgmt type(PSK/8021x). |
| 16689 | * |
| 16690 | * Return: 0 for success, non-zero for failure |
| 16691 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16692 | static int wlan_hdd_set_akm_suite(struct hdd_adapter *adapter, u32 key_mgmt) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16693 | { |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16694 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 16695 | struct csr_roam_profile *roam_profile; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16696 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16697 | roam_profile = hdd_roam_profile(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16698 | |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 16699 | if (wlan_hdd_is_akm_suite_fils(key_mgmt) && |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16700 | !hdd_validate_fils_info_ptr(roam_profile)) |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 16701 | return -EINVAL; |
Vidyullatha Kanchanapally | 7b5bee0 | 2017-04-13 14:00:56 +0530 | [diff] [blame] | 16702 | #ifndef WLAN_AKM_SUITE_8021X_SHA256 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16703 | #define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05 |
Vidyullatha Kanchanapally | 7b5bee0 | 2017-04-13 14:00:56 +0530 | [diff] [blame] | 16704 | #endif |
| 16705 | #ifndef WLAN_AKM_SUITE_PSK_SHA256 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16706 | #define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06 |
Vidyullatha Kanchanapally | 7b5bee0 | 2017-04-13 14:00:56 +0530 | [diff] [blame] | 16707 | #endif |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16708 | |
| 16709 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 16710 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16711 | /*set key mgmt type */ |
| 16712 | switch (key_mgmt) { |
| 16713 | case WLAN_AKM_SUITE_PSK: |
| 16714 | case WLAN_AKM_SUITE_PSK_SHA256: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16715 | case WLAN_AKM_SUITE_FT_PSK: |
Abhishek Singh | 02cb9e0 | 2017-08-30 17:39:50 +0530 | [diff] [blame] | 16716 | case WLAN_AKM_SUITE_DPP_RSN: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16717 | hdd_debug("setting key mgmt type to PSK"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16718 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_PSK; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16719 | break; |
| 16720 | |
| 16721 | case WLAN_AKM_SUITE_8021X_SHA256: |
| 16722 | case WLAN_AKM_SUITE_8021X: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16723 | case WLAN_AKM_SUITE_FT_8021X: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16724 | hdd_debug("setting key mgmt type to 8021x"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16725 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16726 | break; |
| 16727 | #ifdef FEATURE_WLAN_ESE |
| 16728 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16729 | case WLAN_AKM_SUITE_CCKM: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16730 | hdd_debug("setting key mgmt type to CCKM"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16731 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_CCKM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16732 | break; |
| 16733 | #endif |
| 16734 | #ifndef WLAN_AKM_SUITE_OSEN |
| 16735 | #define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */ |
| 16736 | #endif |
| 16737 | case WLAN_AKM_SUITE_OSEN: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16738 | hdd_debug("setting key mgmt type to OSEN"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16739 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16740 | break; |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 16741 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 16742 | (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 16743 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) |
Sridhar Selvaraj | 6cf642f | 2017-08-21 14:28:10 +0530 | [diff] [blame] | 16744 | case WLAN_AKM_SUITE_FILS_SHA256: |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16745 | hdd_debug("setting key mgmt type to FILS SHA256"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16746 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16747 | roam_profile->fils_con_info->akm_type = |
| 16748 | eCSR_AUTH_TYPE_FILS_SHA256; |
| 16749 | break; |
| 16750 | |
| 16751 | case WLAN_AKM_SUITE_FILS_SHA384: |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 16752 | hdd_debug("setting key mgmt type to FILS SHA384"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16753 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16754 | roam_profile->fils_con_info->akm_type = |
| 16755 | eCSR_AUTH_TYPE_FILS_SHA384; |
| 16756 | break; |
| 16757 | |
| 16758 | case WLAN_AKM_SUITE_FT_FILS_SHA256: |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 16759 | hdd_debug("setting key mgmt type to FILS FT SHA256"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16760 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16761 | roam_profile->fils_con_info->akm_type = |
| 16762 | eCSR_AUTH_TYPE_FT_FILS_SHA256; |
| 16763 | break; |
| 16764 | |
| 16765 | case WLAN_AKM_SUITE_FT_FILS_SHA384: |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 16766 | hdd_debug("setting key mgmt type to FILS FT SHA384"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16767 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 16768 | roam_profile->fils_con_info->akm_type = |
| 16769 | eCSR_AUTH_TYPE_FT_FILS_SHA384; |
Sridhar Selvaraj | 6cf642f | 2017-08-21 14:28:10 +0530 | [diff] [blame] | 16770 | break; |
| 16771 | #endif |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 16772 | |
| 16773 | case WLAN_AKM_SUITE_OWE: |
| 16774 | hdd_debug("setting key mgmt type to OWE"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16775 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 16776 | break; |
| 16777 | |
Padma, Santhosh Kumar | e587a5c | 2017-12-21 12:44:46 +0530 | [diff] [blame] | 16778 | case WLAN_AKM_SUITE_EAP_SHA256: |
| 16779 | hdd_debug("setting key mgmt type to EAP_SHA256"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16780 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Padma, Santhosh Kumar | e587a5c | 2017-12-21 12:44:46 +0530 | [diff] [blame] | 16781 | break; |
| 16782 | case WLAN_AKM_SUITE_EAP_SHA384: |
| 16783 | hdd_debug("setting key mgmt type to EAP_SHA384"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16784 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Padma, Santhosh Kumar | e587a5c | 2017-12-21 12:44:46 +0530 | [diff] [blame] | 16785 | break; |
| 16786 | |
Padma, Santhosh Kumar | 07eb80b | 2017-07-05 16:10:06 +0530 | [diff] [blame] | 16787 | case WLAN_AKM_SUITE_SAE: |
| 16788 | hdd_debug("setting key mgmt type to SAE"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16789 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Padma, Santhosh Kumar | 07eb80b | 2017-07-05 16:10:06 +0530 | [diff] [blame] | 16790 | break; |
| 16791 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16792 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16793 | hdd_err("Unsupported key mgmt type: %d", key_mgmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16794 | return -EINVAL; |
| 16795 | |
| 16796 | } |
| 16797 | return 0; |
| 16798 | } |
| 16799 | |
| 16800 | /** |
| 16801 | * wlan_hdd_cfg80211_set_cipher() - set encryption type |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16802 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16803 | * @cipher: Cipher type |
| 16804 | * @ucast: Unicast flag |
| 16805 | * |
| 16806 | * This function is used to set the encryption type |
| 16807 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 16808 | * |
| 16809 | * Return: 0 for success, non-zero for failure |
| 16810 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16811 | static int wlan_hdd_cfg80211_set_cipher(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16812 | u32 cipher, bool ucast) |
| 16813 | { |
| 16814 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16815 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16816 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16817 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16818 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16819 | if (!cipher) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16820 | hdd_debug("received cipher %d - considering none", cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16821 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 16822 | } else { |
| 16823 | |
| 16824 | /*set encryption method */ |
| 16825 | switch (cipher) { |
| 16826 | case IW_AUTH_CIPHER_NONE: |
| 16827 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 16828 | break; |
| 16829 | |
| 16830 | case WLAN_CIPHER_SUITE_WEP40: |
| 16831 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
| 16832 | break; |
| 16833 | |
| 16834 | case WLAN_CIPHER_SUITE_WEP104: |
| 16835 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
| 16836 | break; |
| 16837 | |
| 16838 | case WLAN_CIPHER_SUITE_TKIP: |
| 16839 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 16840 | break; |
| 16841 | |
| 16842 | case WLAN_CIPHER_SUITE_CCMP: |
| 16843 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 16844 | break; |
| 16845 | #ifdef FEATURE_WLAN_WAPI |
| 16846 | case WLAN_CIPHER_SUITE_SMS4: |
| 16847 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 16848 | break; |
| 16849 | #endif |
| 16850 | |
| 16851 | #ifdef FEATURE_WLAN_ESE |
| 16852 | case WLAN_CIPHER_SUITE_KRK: |
| 16853 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 16854 | break; |
| 16855 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 16856 | case WLAN_CIPHER_SUITE_BTK: |
| 16857 | encryptionType = eCSR_ENCRYPT_TYPE_BTK; |
| 16858 | break; |
| 16859 | #endif |
| 16860 | #endif |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 16861 | case WLAN_CIPHER_SUITE_GCMP: |
| 16862 | encryptionType = eCSR_ENCRYPT_TYPE_AES_GCMP; |
| 16863 | break; |
| 16864 | case WLAN_CIPHER_SUITE_GCMP_256: |
| 16865 | encryptionType = eCSR_ENCRYPT_TYPE_AES_GCMP_256; |
| 16866 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16867 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16868 | hdd_err("Unsupported cipher type: %d", cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16869 | return -EOPNOTSUPP; |
| 16870 | } |
| 16871 | } |
| 16872 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16873 | roam_profile = hdd_roam_profile(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16874 | if (ucast) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16875 | hdd_debug("setting unicast cipher type to %d", encryptionType); |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 16876 | sta_ctx->conn_info.uc_encrypt_type = encryptionType; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16877 | roam_profile->EncryptionType.numEntries = 1; |
| 16878 | roam_profile->EncryptionType.encryptionType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16879 | encryptionType; |
| 16880 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16881 | hdd_debug("setting mcast cipher type to %d", encryptionType); |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 16882 | sta_ctx->conn_info.mc_encrypt_type = encryptionType; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16883 | roam_profile->mcEncryptionType.numEntries = 1; |
| 16884 | roam_profile->mcEncryptionType.encryptionType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16885 | encryptionType; |
| 16886 | } |
| 16887 | |
| 16888 | return 0; |
| 16889 | } |
| 16890 | |
| 16891 | /** |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 16892 | * wlan_hdd_add_assoc_ie() - Add Assoc IE to roamProfile |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16893 | * @adapter: Pointer to adapter |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 16894 | * @gen_ie: Pointer to IE data |
| 16895 | * @len: length of IE data |
| 16896 | * |
| 16897 | * Return: 0 for success, non-zero for failure |
| 16898 | */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16899 | static int wlan_hdd_add_assoc_ie(struct hdd_adapter *adapter, |
| 16900 | const uint8_t *gen_ie, uint16_t len) |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 16901 | { |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16902 | struct csr_roam_profile *roam_profile; |
| 16903 | tSirAddie *assoc_add_ie; |
| 16904 | uint16_t cur_add_ie_len; |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 16905 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16906 | assoc_add_ie = hdd_assoc_additional_ie(adapter); |
| 16907 | cur_add_ie_len = assoc_add_ie->length; |
| 16908 | if (SIR_MAC_MAX_ADD_IE_LENGTH < (cur_add_ie_len + len)) { |
| 16909 | hdd_err("current len %u, new ie of len %u will overflow", |
| 16910 | cur_add_ie_len, len); |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 16911 | return -ENOMEM; |
| 16912 | } |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16913 | memcpy(assoc_add_ie->addIEdata + cur_add_ie_len, gen_ie, len); |
| 16914 | assoc_add_ie->length += len; |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 16915 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16916 | roam_profile = hdd_roam_profile(adapter); |
| 16917 | roam_profile->pAddIEAssoc = assoc_add_ie->addIEdata; |
| 16918 | roam_profile->nAddIEAssocLength = assoc_add_ie->length; |
| 16919 | |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 16920 | return 0; |
| 16921 | } |
| 16922 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 16923 | #ifdef WLAN_FEATURE_FILS_SK |
| 16924 | /** |
| 16925 | * wlan_hdd_save_hlp_ie - API to save HLP IE |
| 16926 | * @roam_profile: Pointer to roam profile |
| 16927 | * @gen_ie: IE buffer to store |
| 16928 | * @len: length of the IE buffer @gen_ie |
| 16929 | * @flush: Flush the older saved HLP if any |
| 16930 | * |
| 16931 | * Return: None |
| 16932 | */ |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 16933 | static void wlan_hdd_save_hlp_ie(struct csr_roam_profile *roam_profile, |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16934 | const uint8_t *gen_ie, uint16_t len, |
| 16935 | bool flush) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 16936 | { |
| 16937 | uint8_t *hlp_ie = roam_profile->hlp_ie; |
| 16938 | |
| 16939 | if (flush) { |
| 16940 | roam_profile->hlp_ie_len = 0; |
| 16941 | if (hlp_ie) { |
| 16942 | qdf_mem_free(hlp_ie); |
| 16943 | roam_profile->hlp_ie = NULL; |
| 16944 | } |
| 16945 | } |
| 16946 | |
| 16947 | if ((roam_profile->hlp_ie_len + |
| 16948 | len) > FILS_MAX_HLP_DATA_LEN) { |
| 16949 | hdd_err("HLP len exceeds: hlp_ie_len %d len %d", |
| 16950 | roam_profile->hlp_ie_len, len); |
| 16951 | return; |
| 16952 | } |
| 16953 | |
| 16954 | if (!roam_profile->hlp_ie) { |
| 16955 | roam_profile->hlp_ie = |
| 16956 | qdf_mem_malloc(FILS_MAX_HLP_DATA_LEN); |
| 16957 | hlp_ie = roam_profile->hlp_ie; |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 16958 | if (!hlp_ie) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 16959 | return; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 16960 | } |
| 16961 | |
| 16962 | qdf_mem_copy(hlp_ie + roam_profile->hlp_ie_len, gen_ie, len); |
| 16963 | roam_profile->hlp_ie_len += len; |
| 16964 | } |
| 16965 | #else |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 16966 | static inline void wlan_hdd_save_hlp_ie(struct csr_roam_profile *roam_profile, |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16967 | const uint8_t *gen_ie, uint16_t len, |
| 16968 | bool flush) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 16969 | {} |
| 16970 | #endif |
Arif Hussain | f8f6b3b | 2019-01-10 19:42:09 -0800 | [diff] [blame] | 16971 | |
| 16972 | #ifdef WLAN_CONV_CRYPTO_SUPPORTED |
| 16973 | /** |
| 16974 | * hdd_populate_crypto_auth_type() - populate auth type for crypto |
| 16975 | * @vdev: pointed to vdev obmgr |
| 16976 | * @auth_type: legacy auth_type |
| 16977 | * |
| 16978 | * set the crypto auth type for corresponding auth type received |
| 16979 | * from NL |
| 16980 | * |
| 16981 | * Return: None |
| 16982 | */ |
| 16983 | static void hdd_populate_crypto_auth_type(struct wlan_objmgr_vdev *vdev, |
| 16984 | enum nl80211_auth_type auth_type) |
| 16985 | { |
| 16986 | QDF_STATUS status; |
| 16987 | uint32_t set_val = 0; |
| 16988 | wlan_crypto_auth_mode crypto_auth_type = |
| 16989 | osif_nl_to_crypto_auth_type(auth_type); |
| 16990 | |
| 16991 | hdd_debug("set auth type %d to crypto component", crypto_auth_type); |
| 16992 | HDD_SET_BIT(set_val, crypto_auth_type); |
| 16993 | status = wlan_crypto_set_vdev_param(vdev, |
| 16994 | WLAN_CRYPTO_PARAM_AUTH_MODE, |
| 16995 | set_val); |
| 16996 | if (QDF_IS_STATUS_ERROR(status)) |
| 16997 | hdd_err("Failed to set auth type %0X to crypto component", |
| 16998 | set_val); |
| 16999 | } |
| 17000 | |
| 17001 | /** |
| 17002 | * hdd_populate_crypto_akm_type() - populate akm type for crypto |
| 17003 | * @vdev: pointed to vdev obmgr |
| 17004 | * @akm_type: legacy akm_type |
| 17005 | * |
| 17006 | * set the crypto akm type for corresponding akm type received |
| 17007 | * from NL |
| 17008 | * |
| 17009 | * Return: None |
| 17010 | */ |
| 17011 | static void hdd_populate_crypto_akm_type(struct wlan_objmgr_vdev *vdev, |
| 17012 | u32 key_mgmt) |
| 17013 | { |
| 17014 | QDF_STATUS status; |
| 17015 | uint32_t set_val = 0; |
| 17016 | wlan_crypto_key_mgmt crypto_akm_type = |
| 17017 | osif_nl_to_crypto_akm_type(key_mgmt); |
| 17018 | |
| 17019 | hdd_debug("set akm type %d to crypto component", crypto_akm_type); |
| 17020 | HDD_SET_BIT(set_val, crypto_akm_type); |
| 17021 | |
| 17022 | status = wlan_crypto_set_vdev_param(vdev, |
| 17023 | WLAN_CRYPTO_PARAM_KEY_MGMT, |
| 17024 | set_val); |
| 17025 | if (QDF_IS_STATUS_ERROR(status)) |
| 17026 | hdd_err("Failed to set akm type %0x to crypto component", |
| 17027 | set_val); |
| 17028 | } |
| 17029 | |
| 17030 | /** |
| 17031 | * hdd_populate_crypto_cipher_type() - populate cipher type for crypto |
| 17032 | * @cipher: legacy cipher type |
| 17033 | * @vdev: pointed to vdev obmgr |
| 17034 | * @cipher_param_type: param type, UCST/MCAST |
| 17035 | * |
| 17036 | * set the crypto cipher type for corresponding cipher type received |
| 17037 | * from NL |
| 17038 | * |
| 17039 | * Return: None |
| 17040 | */ |
| 17041 | static void hdd_populate_crypto_cipher_type(u32 cipher, |
| 17042 | struct wlan_objmgr_vdev *vdev, |
| 17043 | wlan_crypto_param_type |
| 17044 | cipher_param_type) |
| 17045 | { |
| 17046 | QDF_STATUS status; |
| 17047 | uint32_t set_val = 0; |
| 17048 | wlan_crypto_cipher_type crypto_cipher_type = |
| 17049 | osif_nl_to_crypto_cipher_type(cipher); |
| 17050 | |
| 17051 | hdd_debug("set cipher params %d type %d to crypto", |
| 17052 | cipher_param_type, crypto_cipher_type); |
| 17053 | HDD_SET_BIT(set_val, crypto_cipher_type); |
| 17054 | status = wlan_crypto_set_vdev_param(vdev, cipher_param_type, set_val); |
| 17055 | if (QDF_IS_STATUS_ERROR(status)) |
| 17056 | hdd_err("Failed to set cipher params %d type %0x to crypto", |
| 17057 | cipher_param_type, set_val); |
| 17058 | } |
| 17059 | |
| 17060 | /** |
| 17061 | * hdd_populate_crypto_params() - set crypto params |
| 17062 | * @vdev: Pointer to vdev obh mgr |
| 17063 | * @req: Pointer to security parameters |
| 17064 | * |
| 17065 | * Set Auth, Akm and Cipher type for crypto |
| 17066 | * |
| 17067 | * Return: None |
| 17068 | */ |
| 17069 | static void hdd_populate_crypto_params(struct wlan_objmgr_vdev *vdev, |
| 17070 | struct cfg80211_connect_params *req) |
| 17071 | { |
| 17072 | hdd_populate_crypto_auth_type(vdev, req->auth_type); |
| 17073 | |
| 17074 | if (req->crypto.n_akm_suites) |
| 17075 | hdd_populate_crypto_akm_type(vdev, req->crypto.akm_suites[0]); |
| 17076 | |
| 17077 | if (req->crypto.n_ciphers_pairwise) { |
| 17078 | hdd_populate_crypto_cipher_type(req->crypto.ciphers_pairwise[0], |
| 17079 | vdev, |
| 17080 | WLAN_CRYPTO_PARAM_UCAST_CIPHER); |
| 17081 | } else { |
| 17082 | /* Reset previous cipher suite to none */ |
| 17083 | hdd_populate_crypto_cipher_type(0, vdev, |
| 17084 | WLAN_CRYPTO_PARAM_UCAST_CIPHER); |
| 17085 | } |
| 17086 | |
| 17087 | hdd_populate_crypto_cipher_type(req->crypto.cipher_group, |
| 17088 | vdev, |
| 17089 | WLAN_CRYPTO_PARAM_MCAST_CIPHER); |
| 17090 | } |
| 17091 | |
| 17092 | /** |
| 17093 | * hdd_set_crypto_key_mgmt_param() - Set key mgmt param. |
| 17094 | * @adapter: Pointer to adapter. |
| 17095 | * |
| 17096 | * Return: None |
| 17097 | */ |
| 17098 | static void hdd_set_crypto_key_mgmt_param(struct hdd_adapter *adapter) |
| 17099 | { |
| 17100 | uint32_t key_mgmt = 0; |
| 17101 | struct wlan_objmgr_vdev *vdev; |
| 17102 | |
| 17103 | if (!adapter) { |
| 17104 | hdd_err("adapter is null"); |
| 17105 | return; |
| 17106 | } |
| 17107 | |
| 17108 | vdev = hdd_objmgr_get_vdev(adapter); |
| 17109 | if (!vdev) |
| 17110 | return; |
| 17111 | |
| 17112 | if (adapter->wapi_info.wapi_auth_mode == WAPI_AUTH_MODE_PSK) |
| 17113 | HDD_SET_BIT(key_mgmt, WLAN_CRYPTO_KEY_MGMT_WAPI_PSK); |
| 17114 | if (adapter->wapi_info.wapi_auth_mode == WAPI_AUTH_MODE_CERT) |
| 17115 | HDD_SET_BIT(key_mgmt, WLAN_CRYPTO_KEY_MGMT_WAPI_CERT); |
| 17116 | |
| 17117 | wlan_crypto_set_vdev_param(vdev, WLAN_CRYPTO_PARAM_KEY_MGMT, key_mgmt); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 17118 | hdd_objmgr_put_vdev(vdev); |
Arif Hussain | f8f6b3b | 2019-01-10 19:42:09 -0800 | [diff] [blame] | 17119 | } |
| 17120 | |
| 17121 | #else |
| 17122 | |
| 17123 | static inline |
| 17124 | void hdd_populate_crypto_auth_type(struct wlan_objmgr_vdev *vdev, |
| 17125 | enum nl80211_auth_type auth_type) |
| 17126 | { |
| 17127 | } |
| 17128 | |
| 17129 | static inline |
| 17130 | void hdd_populate_crypto_akm_type(struct wlan_objmgr_vdev *vdev, |
| 17131 | u32 key_mgmt) |
| 17132 | { |
| 17133 | } |
| 17134 | |
| 17135 | static inline |
| 17136 | void hdd_populate_crypto_cipher_type(u32 cipher, |
| 17137 | struct wlan_objmgr_vdev *vdev, |
| 17138 | wlan_crypto_param_type |
| 17139 | cipher_param_type) |
| 17140 | { |
| 17141 | } |
| 17142 | |
| 17143 | static inline |
| 17144 | void hdd_populate_crypto_params(struct wlan_objmgr_vdev *vdev, |
| 17145 | struct cfg80211_connect_params *req) |
| 17146 | { |
| 17147 | } |
| 17148 | |
| 17149 | static inline void hdd_set_crypto_key_mgmt_param(struct hdd_adapter *adapter) |
| 17150 | { |
| 17151 | } |
| 17152 | |
| 17153 | #endif |
| 17154 | |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 17155 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17156 | * wlan_hdd_cfg80211_set_ie() - set IEs |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17157 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17158 | * @ie: Pointer ot ie |
| 17159 | * @ie: IE length |
| 17160 | * |
| 17161 | * Return: 0 for success, non-zero for failure |
| 17162 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17163 | static int wlan_hdd_cfg80211_set_ie(struct hdd_adapter *adapter, |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 17164 | const uint8_t *ie, |
| 17165 | size_t ie_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17166 | { |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17167 | struct csr_roam_profile *roam_profile; |
| 17168 | tSirAddie *assoc_add_ie; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17169 | const uint8_t *genie = ie; |
| 17170 | uint16_t remLen = ie_len; |
| 17171 | #ifdef FEATURE_WLAN_WAPI |
| 17172 | uint32_t akmsuite[MAX_NUM_AKM_SUITES]; |
tinlin | 8a44b64 | 2018-04-25 13:56:06 +0800 | [diff] [blame] | 17173 | uint8_t *tmp; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17174 | uint16_t akmsuiteCount; |
tinlin | 8a44b64 | 2018-04-25 13:56:06 +0800 | [diff] [blame] | 17175 | uint32_t *akmlist; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17176 | #endif |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 17177 | int status; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17178 | uint8_t *security_ie; |
| 17179 | |
| 17180 | roam_profile = hdd_roam_profile(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17181 | |
| 17182 | /* clear previous assocAddIE */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17183 | assoc_add_ie = hdd_assoc_additional_ie(adapter); |
| 17184 | assoc_add_ie->length = 0; |
| 17185 | roam_profile->bWPSAssociation = false; |
| 17186 | roam_profile->bOSENAssociation = false; |
| 17187 | security_ie = hdd_security_ie(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17188 | |
| 17189 | while (remLen >= 2) { |
| 17190 | uint16_t eLen = 0; |
| 17191 | uint8_t elementId; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 17192 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17193 | elementId = *genie++; |
| 17194 | eLen = *genie++; |
| 17195 | remLen -= 2; |
| 17196 | |
Nachiket Kukade | 4bea8b4 | 2017-06-13 11:53:19 +0530 | [diff] [blame] | 17197 | /* Sanity check on eLen */ |
| 17198 | if (eLen > remLen) { |
| 17199 | hdd_err("%s: Invalid IE length[%d] for IE[0x%X]", |
| 17200 | __func__, eLen, elementId); |
| 17201 | QDF_ASSERT(0); |
| 17202 | return -EINVAL; |
| 17203 | } |
| 17204 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17205 | hdd_debug("IE[0x%X], LEN[%d]", elementId, eLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17206 | |
| 17207 | switch (elementId) { |
| 17208 | case DOT11F_EID_WPA: |
| 17209 | if (4 > eLen) { /* should have at least OUI which is 4 bytes so extra 2 bytes not needed */ |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 17210 | hdd_err("Invalid WPA IE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17211 | return -EINVAL; |
| 17212 | } else if (0 == |
| 17213 | memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) { |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17214 | uint16_t curAddIELen = assoc_add_ie->length; |
| 17215 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17216 | hdd_debug("Set WPS IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17217 | |
| 17218 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17219 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 17220 | hdd_err("Cannot accommodate assocAddIE. Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 17221 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17222 | return -ENOMEM; |
| 17223 | } |
| 17224 | /* WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17225 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17226 | curAddIELen, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17227 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17228 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17229 | roam_profile->bWPSAssociation = true; |
| 17230 | roam_profile->pAddIEAssoc = |
| 17231 | assoc_add_ie->addIEdata; |
| 17232 | roam_profile->nAddIEAssocLength = |
| 17233 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17234 | } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) { |
Nachiket Kukade | 2f6509f | 2017-06-13 17:45:46 +0530 | [diff] [blame] | 17235 | if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) { |
| 17236 | hdd_err("%s: Invalid WPA IE length[%d]", |
| 17237 | __func__, eLen); |
| 17238 | QDF_ASSERT(0); |
| 17239 | return -EINVAL; |
| 17240 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17241 | hdd_debug("Set WPA IE (len %d)", eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17242 | memset(security_ie, 0, MAX_WPA_RSN_IE_LEN); |
| 17243 | memcpy(security_ie, genie - 2, (eLen + 2)); |
| 17244 | roam_profile->pWPAReqIE = security_ie; |
| 17245 | roam_profile->nWPAReqIELength = eLen + 2; /* ie_len; */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17246 | } else if ((0 == memcmp(&genie[0], P2P_OUI_TYPE, |
| 17247 | P2P_OUI_TYPE_SIZE))) { |
| 17248 | uint16_t curAddIELen = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17249 | assoc_add_ie->length; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17250 | hdd_debug("Set P2P IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17251 | |
| 17252 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17253 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 17254 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 17255 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17256 | return -ENOMEM; |
| 17257 | } |
| 17258 | /* P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17259 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17260 | curAddIELen, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17261 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17262 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17263 | roam_profile->pAddIEAssoc = |
| 17264 | assoc_add_ie->addIEdata; |
| 17265 | roam_profile->nAddIEAssocLength = |
| 17266 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17267 | } |
| 17268 | #ifdef WLAN_FEATURE_WFD |
| 17269 | else if ((0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 17270 | WFD_OUI_TYPE_SIZE)) && |
| 17271 | /* Consider WFD IE, only for P2P Client */ |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 17272 | (QDF_P2P_CLIENT_MODE == |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17273 | adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17274 | uint16_t curAddIELen = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17275 | assoc_add_ie->length; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17276 | hdd_debug("Set WFD IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17277 | |
| 17278 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17279 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 17280 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 17281 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17282 | return -ENOMEM; |
| 17283 | } |
| 17284 | /* WFD IE is saved to Additional IE ; it should |
| 17285 | * be accumulated to handle WPS IE + P2P IE + |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 17286 | * WFD IE |
| 17287 | */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17288 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17289 | curAddIELen, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17290 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17291 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17292 | roam_profile->pAddIEAssoc = |
| 17293 | assoc_add_ie->addIEdata; |
| 17294 | roam_profile->nAddIEAssocLength = |
| 17295 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17296 | } |
| 17297 | #endif |
| 17298 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
| 17299 | else if ((0 == memcmp(&genie[0], HS20_OUI_TYPE, |
| 17300 | HS20_OUI_TYPE_SIZE))) { |
| 17301 | uint16_t curAddIELen = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17302 | assoc_add_ie->length; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17303 | hdd_debug("Set HS20 IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17304 | |
| 17305 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17306 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 17307 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 17308 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17309 | return -ENOMEM; |
| 17310 | } |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17311 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17312 | curAddIELen, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17313 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17314 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17315 | roam_profile->pAddIEAssoc = |
| 17316 | assoc_add_ie->addIEdata; |
| 17317 | roam_profile->nAddIEAssocLength = |
| 17318 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17319 | } |
| 17320 | /* Appending OSEN Information Element in Assiciation Request */ |
| 17321 | else if ((0 == memcmp(&genie[0], OSEN_OUI_TYPE, |
| 17322 | OSEN_OUI_TYPE_SIZE))) { |
| 17323 | uint16_t curAddIELen = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17324 | assoc_add_ie->length; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17325 | hdd_debug("Set OSEN IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17326 | |
| 17327 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17328 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 17329 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 17330 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17331 | return -ENOMEM; |
| 17332 | } |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17333 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17334 | curAddIELen, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17335 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17336 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17337 | roam_profile->bOSENAssociation = true; |
| 17338 | roam_profile->pAddIEAssoc = |
| 17339 | assoc_add_ie->addIEdata; |
| 17340 | roam_profile->nAddIEAssocLength = |
| 17341 | assoc_add_ie->length; |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 17342 | } else if ((0 == memcmp(&genie[0], MBO_OUI_TYPE, |
| 17343 | MBO_OUI_TYPE_SIZE))){ |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17344 | hdd_debug("Set MBO IE(len %d)", eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17345 | status = wlan_hdd_add_assoc_ie(adapter, |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 17346 | genie - 2, eLen + 2); |
| 17347 | if (status) |
| 17348 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17349 | } else { |
| 17350 | uint16_t add_ie_len = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17351 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17352 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17353 | hdd_debug("Set OSEN IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17354 | |
| 17355 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17356 | (assoc_add_ie->length + eLen)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17357 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 17358 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17359 | return -ENOMEM; |
| 17360 | } |
| 17361 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17362 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17363 | add_ie_len, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17364 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17365 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17366 | roam_profile->pAddIEAssoc = |
| 17367 | assoc_add_ie->addIEdata; |
| 17368 | roam_profile->nAddIEAssocLength = |
| 17369 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17370 | } |
| 17371 | break; |
| 17372 | case DOT11F_EID_RSN: |
tinlin | 8a44b64 | 2018-04-25 13:56:06 +0800 | [diff] [blame] | 17373 | if (eLen > DOT11F_IE_RSN_MAX_LEN) { |
Vignesh Viswanathan | 96e0e70 | 2017-12-05 19:42:46 +0530 | [diff] [blame] | 17374 | hdd_err("%s: Invalid WPA RSN IE length[%d]", |
tinlin | 8a44b64 | 2018-04-25 13:56:06 +0800 | [diff] [blame] | 17375 | __func__, eLen); |
Vignesh Viswanathan | 96e0e70 | 2017-12-05 19:42:46 +0530 | [diff] [blame] | 17376 | return -EINVAL; |
| 17377 | } |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17378 | memset(security_ie, 0, MAX_WPA_RSN_IE_LEN); |
| 17379 | memcpy(security_ie, genie - 2, (eLen + 2)); |
| 17380 | roam_profile->pRSNReqIE = security_ie; |
| 17381 | roam_profile->nRSNReqIELength = eLen + 2; /* ie_len; */ |
tinlin | 8a44b64 | 2018-04-25 13:56:06 +0800 | [diff] [blame] | 17382 | hdd_debug("Set RSN IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17383 | break; |
| 17384 | /* |
| 17385 | * Appending Extended Capabilities with Interworking bit set |
| 17386 | * in Assoc Req. |
| 17387 | * |
| 17388 | * In assoc req this EXT Cap will only be taken into account if |
| 17389 | * interworkingService bit is set to 1. Currently |
| 17390 | * driver is only interested in interworkingService capability |
| 17391 | * from supplicant. If in future any other EXT Cap info is |
| 17392 | * required from supplicat, it needs to be handled while |
| 17393 | * sending Assoc Req in LIM. |
| 17394 | */ |
| 17395 | case DOT11F_EID_EXTCAP: |
| 17396 | { |
| 17397 | uint16_t curAddIELen = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17398 | assoc_add_ie->length; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17399 | hdd_debug("Set Extended CAPS IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17400 | |
| 17401 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17402 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 17403 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 17404 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17405 | return -ENOMEM; |
| 17406 | } |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17407 | memcpy(assoc_add_ie->addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 17408 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17409 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17410 | roam_profile->pAddIEAssoc = assoc_add_ie->addIEdata; |
| 17411 | roam_profile->nAddIEAssocLength = assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17412 | break; |
| 17413 | } |
| 17414 | #ifdef FEATURE_WLAN_WAPI |
| 17415 | case WLAN_EID_WAPI: |
| 17416 | /* Setting WAPI Mode to ON=1 */ |
tinlin | 8a44b64 | 2018-04-25 13:56:06 +0800 | [diff] [blame] | 17417 | adapter->wapi_info.wapi_mode = 1; |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 17418 | hdd_debug("WAPI MODE IS %u", adapter->wapi_info.wapi_mode); |
Abhinav Kumar | f56c81f | 2018-06-06 16:07:01 +0530 | [diff] [blame] | 17419 | /* genie is pointing to data field of WAPI IE's buffer */ |
| 17420 | tmp = (uint8_t *)genie; |
| 17421 | /* Validate length for Version(2 bytes) and Number |
| 17422 | * of AKM suite (2 bytes) in WAPI IE buffer, coming from |
| 17423 | * supplicant*/ |
| 17424 | if (eLen < 4) { |
| 17425 | hdd_err("Invalid IE Len: %u", eLen); |
| 17426 | return -EINVAL; |
| 17427 | } |
| 17428 | tmp = tmp + 2; /* Skip Version */ |
tinlin | 8a44b64 | 2018-04-25 13:56:06 +0800 | [diff] [blame] | 17429 | /* Get the number of AKM suite */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17430 | akmsuiteCount = WPA_GET_LE16(tmp); |
tinlin | 8a44b64 | 2018-04-25 13:56:06 +0800 | [diff] [blame] | 17431 | /* Skip the number of AKM suite */ |
| 17432 | tmp = tmp + 2; |
Abhinav Kumar | f56c81f | 2018-06-06 16:07:01 +0530 | [diff] [blame] | 17433 | /* Validate total length for WAPI IE's buffer */ |
| 17434 | if (eLen < (4 + (akmsuiteCount * sizeof(uint32_t)))) { |
| 17435 | hdd_err("Invalid IE Len: %u", eLen); |
| 17436 | return -EINVAL; |
| 17437 | } |
tinlin | 8a44b64 | 2018-04-25 13:56:06 +0800 | [diff] [blame] | 17438 | /* AKM suite list, each OUI contains 4 bytes */ |
| 17439 | akmlist = (uint32_t *)(tmp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17440 | if (akmsuiteCount <= MAX_NUM_AKM_SUITES) { |
Vignesh Viswanathan | 845bd47 | 2018-06-11 18:45:45 +0530 | [diff] [blame] | 17441 | qdf_mem_copy(akmsuite, akmlist, |
| 17442 | sizeof(uint32_t) * akmsuiteCount); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17443 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17444 | hdd_err("Invalid akmSuite count: %u", |
| 17445 | akmsuiteCount); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 17446 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17447 | return -EINVAL; |
| 17448 | } |
| 17449 | |
| 17450 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17451 | hdd_debug("WAPI AUTH MODE SET TO PSK"); |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 17452 | adapter->wapi_info.wapi_auth_mode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17453 | WAPI_AUTH_MODE_PSK; |
| 17454 | } |
| 17455 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17456 | hdd_debug("WAPI AUTH MODE SET TO CERTIFICATE"); |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 17457 | adapter->wapi_info.wapi_auth_mode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17458 | WAPI_AUTH_MODE_CERT; |
| 17459 | } |
Arif Hussain | f8f6b3b | 2019-01-10 19:42:09 -0800 | [diff] [blame] | 17460 | |
| 17461 | hdd_set_crypto_key_mgmt_param(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17462 | break; |
| 17463 | #endif |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 17464 | case DOT11F_EID_SUPPOPERATINGCLASSES: |
| 17465 | { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17466 | hdd_debug("Set Supported Operating Classes IE(len %d)", eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17467 | status = wlan_hdd_add_assoc_ie(adapter, |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 17468 | genie - 2, eLen + 2); |
| 17469 | if (status) |
| 17470 | return status; |
| 17471 | break; |
| 17472 | } |
Sridhar Selvaraj | 6d3e0d7 | 2017-08-17 17:32:37 +0530 | [diff] [blame] | 17473 | case SIR_MAC_REQUEST_EID_MAX: |
| 17474 | { |
| 17475 | if (genie[0] == SIR_FILS_HLP_EXT_EID) { |
| 17476 | hdd_debug("Set HLP EXT IE(len %d)", |
| 17477 | eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17478 | wlan_hdd_save_hlp_ie(roam_profile, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 17479 | genie - 2, eLen + 2, |
| 17480 | true); |
Sridhar Selvaraj | 6d3e0d7 | 2017-08-17 17:32:37 +0530 | [diff] [blame] | 17481 | status = wlan_hdd_add_assoc_ie( |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17482 | adapter, genie - 2, |
Sridhar Selvaraj | 6d3e0d7 | 2017-08-17 17:32:37 +0530 | [diff] [blame] | 17483 | eLen + 2); |
| 17484 | if (status) |
| 17485 | return status; |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 17486 | } else if (genie[0] == |
| 17487 | SIR_DH_PARAMETER_ELEMENT_EXT_EID) { |
| 17488 | hdd_debug("Set DH EXT IE(len %d)", |
| 17489 | eLen + 2); |
| 17490 | status = wlan_hdd_add_assoc_ie( |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17491 | adapter, genie - 2, |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 17492 | eLen + 2); |
| 17493 | if (status) |
| 17494 | return status; |
Sridhar Selvaraj | 6d3e0d7 | 2017-08-17 17:32:37 +0530 | [diff] [blame] | 17495 | } else { |
| 17496 | hdd_err("UNKNOWN EID: %X", genie[0]); |
| 17497 | } |
| 17498 | break; |
| 17499 | } |
| 17500 | case DOT11F_EID_FRAGMENT_IE: |
| 17501 | { |
| 17502 | hdd_debug("Set Fragment IE(len %d)", eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17503 | wlan_hdd_save_hlp_ie(roam_profile, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 17504 | genie - 2, eLen + 2, |
| 17505 | false); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17506 | status = wlan_hdd_add_assoc_ie(adapter, |
Sridhar Selvaraj | 6d3e0d7 | 2017-08-17 17:32:37 +0530 | [diff] [blame] | 17507 | genie - 2, eLen + 2); |
| 17508 | if (status) |
| 17509 | return status; |
| 17510 | break; |
| 17511 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17512 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17513 | hdd_err("Set UNKNOWN IE: %X", elementId); |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 17514 | /* when Unknown IE is received we break |
| 17515 | * and continue to the next IE in the buffer |
| 17516 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17517 | break; |
| 17518 | } |
| 17519 | genie += eLen; |
| 17520 | remLen -= eLen; |
| 17521 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17522 | return 0; |
| 17523 | } |
| 17524 | |
| 17525 | /** |
| 17526 | * hdd_is_wpaie_present() - check for WPA ie |
| 17527 | * @ie: Pointer to ie |
| 17528 | * @ie_len: Ie length |
| 17529 | * |
| 17530 | * Parse the received IE to find the WPA IE |
| 17531 | * |
| 17532 | * Return: true if wpa ie is found else false |
| 17533 | */ |
| 17534 | static bool hdd_is_wpaie_present(const uint8_t *ie, uint8_t ie_len) |
| 17535 | { |
| 17536 | uint8_t eLen = 0; |
| 17537 | uint16_t remLen = ie_len; |
| 17538 | uint8_t elementId = 0; |
| 17539 | |
| 17540 | while (remLen >= 2) { |
| 17541 | elementId = *ie++; |
| 17542 | eLen = *ie++; |
| 17543 | remLen -= 2; |
| 17544 | if (eLen > remLen) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17545 | hdd_err("Invalid IE length: %d", eLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17546 | return false; |
| 17547 | } |
| 17548 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) { |
| 17549 | /* OUI - 0x00 0X50 0XF2 |
| 17550 | * WPA Information Element - 0x01 |
| 17551 | * WPA version - 0x01 |
| 17552 | */ |
| 17553 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 17554 | return true; |
| 17555 | } |
| 17556 | ie += eLen; |
| 17557 | remLen -= eLen; |
| 17558 | } |
| 17559 | return false; |
| 17560 | } |
| 17561 | |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 17562 | #ifdef CRYPTO_SET_KEY_CONVERGED |
| 17563 | static void wlan_hdd_cfg80211_store_wep_key(struct hdd_adapter *adapter, |
| 17564 | struct wlan_objmgr_vdev *vdev, |
| 17565 | struct cfg80211_connect_params *req) |
| 17566 | { |
| 17567 | struct key_params params; |
| 17568 | |
| 17569 | qdf_mem_zero(¶ms, sizeof(params)); |
| 17570 | params.cipher = req->crypto.ciphers_pairwise[0]; |
| 17571 | params.key_len = req->key_len; |
| 17572 | params.key = req->key; |
| 17573 | wlan_cfg80211_store_key(vdev, req->key_idx, |
| 17574 | WLAN_CRYPTO_KEY_TYPE_UNICAST, |
| 17575 | NULL, ¶ms); |
| 17576 | } |
| 17577 | #else |
| 17578 | static void wlan_hdd_cfg80211_store_wep_key(struct hdd_adapter *adapter, |
| 17579 | struct wlan_objmgr_vdev *vdev, |
| 17580 | struct cfg80211_connect_params *req) |
| 17581 | { |
| 17582 | struct csr_roam_profile *roam_profile; |
| 17583 | |
| 17584 | roam_profile = hdd_roam_profile(adapter); |
| 17585 | hdd_debug("setting default wep key, key_idx = %hu key_len %hu", |
| 17586 | req->key_idx, req->key_len); |
| 17587 | qdf_mem_copy(&roam_profile->Keys.KeyMaterial[req->key_idx][0], |
| 17588 | req->key, req->key_len); |
| 17589 | roam_profile->Keys.KeyLength[req->key_idx] = req->key_len; |
| 17590 | roam_profile->Keys.defaultIndex = req->key_idx; |
| 17591 | } |
| 17592 | #endif /* !CRYPTO_SET_KEY_CONVERGED */ |
| 17593 | |
Harprit Chhabada | 6c641ba | 2018-06-28 14:45:10 -0700 | [diff] [blame] | 17594 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17595 | * wlan_hdd_cfg80211_set_privacy() - set security parameters during connection |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17596 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17597 | * @req: Pointer to security parameters |
| 17598 | * |
| 17599 | * Return: 0 for success, non-zero for failure |
| 17600 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17601 | static int wlan_hdd_cfg80211_set_privacy(struct hdd_adapter *adapter, |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 17602 | struct cfg80211_connect_params *req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17603 | { |
| 17604 | int status = 0; |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 17605 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17606 | struct csr_roam_profile *roam_profile; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 17607 | struct wlan_objmgr_vdev *vdev; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 17608 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 17609 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17610 | |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 17611 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 17612 | sta_ctx->wpa_versions = req->crypto.wpa_versions; |
| 17613 | hdd_debug("set wpa version to %d", sta_ctx->wpa_versions); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17614 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17615 | roam_profile = hdd_roam_profile(adapter); |
| 17616 | |
Harprit Chhabada | 6c641ba | 2018-06-28 14:45:10 -0700 | [diff] [blame] | 17617 | /* populate auth,akm and cipher params for crypto */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 17618 | vdev = hdd_objmgr_get_vdev(adapter); |
| 17619 | if (!vdev) |
| 17620 | return -EINVAL; |
| 17621 | hdd_populate_crypto_params(vdev, req); |
Harprit Chhabada | 6c641ba | 2018-06-28 14:45:10 -0700 | [diff] [blame] | 17622 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17623 | /*set authentication type */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17624 | status = wlan_hdd_cfg80211_set_auth_type(adapter, req->auth_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17625 | |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 17626 | if (wlan_hdd_is_conn_type_fils(req)) { |
| 17627 | status = wlan_hdd_cfg80211_set_fils_config(adapter, req); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 17628 | |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 17629 | if (0 > status) { |
| 17630 | hdd_err("Failed to set fils config"); |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 17631 | goto release_vdev_ref; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 17632 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17633 | } |
| 17634 | |
| 17635 | /*set key mgmt type */ |
| 17636 | if (req->crypto.n_akm_suites) { |
| 17637 | status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17638 | wlan_hdd_set_akm_suite(adapter, req->crypto.akm_suites[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17639 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17640 | hdd_err("Failed to set akm suite"); |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 17641 | goto release_vdev_ref; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17642 | } |
| 17643 | } |
| 17644 | |
| 17645 | /*set pairwise cipher type */ |
| 17646 | if (req->crypto.n_ciphers_pairwise) { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17647 | status = wlan_hdd_cfg80211_set_cipher(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17648 | req->crypto. |
| 17649 | ciphers_pairwise[0], |
| 17650 | true); |
| 17651 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17652 | hdd_err("Failed to set unicast cipher type"); |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 17653 | goto release_vdev_ref; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17654 | } |
| 17655 | } else { |
| 17656 | /*Reset previous cipher suite to none */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17657 | status = wlan_hdd_cfg80211_set_cipher(adapter, 0, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17658 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17659 | hdd_err("Failed to set unicast cipher type"); |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 17660 | goto release_vdev_ref; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17661 | } |
| 17662 | } |
| 17663 | |
| 17664 | /*set group cipher type */ |
| 17665 | status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17666 | wlan_hdd_cfg80211_set_cipher(adapter, req->crypto.cipher_group, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17667 | false); |
| 17668 | |
| 17669 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17670 | hdd_err("Failed to set mcast cipher type"); |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 17671 | goto release_vdev_ref; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17672 | } |
| 17673 | #ifdef WLAN_FEATURE_11W |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17674 | roam_profile->MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17675 | #endif |
| 17676 | |
| 17677 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile */ |
| 17678 | if (req->ie_len) { |
| 17679 | status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17680 | wlan_hdd_cfg80211_set_ie(adapter, req->ie, req->ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17681 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17682 | hdd_err("Failed to parse the WPA/RSN IE"); |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 17683 | goto release_vdev_ref; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17684 | } |
| 17685 | } |
| 17686 | |
| 17687 | /*incase of WEP set default key information */ |
| 17688 | if (req->key && req->key_len) { |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 17689 | u32 cipher = req->crypto.ciphers_pairwise[0]; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 17690 | |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 17691 | if ((WLAN_CIPHER_SUITE_WEP40 == cipher) || |
| 17692 | (WLAN_CIPHER_SUITE_WEP104 == cipher)) { |
| 17693 | enum hdd_auth_key_mgmt key_mgmt = |
| 17694 | sta_ctx->auth_key_mgmt; |
| 17695 | |
| 17696 | if (key_mgmt & HDD_AUTH_KEY_MGMT_802_1X) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 17697 | hdd_err("Dynamic WEP not supported"); |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 17698 | status = -EOPNOTSUPP; |
| 17699 | goto release_vdev_ref; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 17700 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17701 | |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 17702 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= |
| 17703 | req->key_len) && (CSR_MAX_NUM_KEY > req->key_idx)) |
| 17704 | wlan_hdd_cfg80211_store_wep_key(adapter, |
| 17705 | vdev, req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17706 | } |
| 17707 | } |
Varun Reddy Yeturu | ff4c998 | 2019-02-15 15:59:24 -0800 | [diff] [blame] | 17708 | release_vdev_ref: |
| 17709 | hdd_objmgr_put_vdev(vdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17710 | |
| 17711 | return status; |
| 17712 | } |
| 17713 | |
wadesong | caad7c7 | 2018-08-06 13:26:27 +0800 | [diff] [blame] | 17714 | /** |
| 17715 | * wlan_hdd_clear_wapi_privacy() - reset WAPI settings in HDD layer |
| 17716 | * @adapter: pointer to HDD adapter object |
| 17717 | * |
| 17718 | * This function resets all WAPI related parameters imposed before STA |
| 17719 | * connection starts. It's invoked when privacy checking against concurrency |
| 17720 | * fails, to make sure no improper WAPI settings are still populated before |
| 17721 | * returning an error to the upper layer requester. |
| 17722 | * |
| 17723 | * Return: none |
| 17724 | */ |
| 17725 | #ifdef FEATURE_WLAN_WAPI |
| 17726 | static inline void wlan_hdd_clear_wapi_privacy(struct hdd_adapter *adapter) |
| 17727 | { |
| 17728 | adapter->wapi_info.wapi_mode = 0; |
| 17729 | adapter->wapi_info.wapi_auth_mode = WAPI_AUTH_MODE_OPEN; |
| 17730 | } |
| 17731 | #else |
| 17732 | static inline void wlan_hdd_clear_wapi_privacy(struct hdd_adapter *adapter) |
| 17733 | { |
| 17734 | } |
| 17735 | #endif |
| 17736 | |
| 17737 | /** |
| 17738 | * wlan_hdd_cfg80211_clear_privacy() - reset STA security parameters |
| 17739 | * @adapter: pointer to HDD adapter object |
| 17740 | * |
| 17741 | * This function resets all privacy related parameters imposed |
| 17742 | * before STA connection starts. It's invoked when privacy checking |
| 17743 | * against concurrency fails, to make sure no improper settings are |
| 17744 | * still populated before returning an error to the upper layer requester. |
| 17745 | * |
| 17746 | * Return: none |
| 17747 | */ |
| 17748 | static void wlan_hdd_cfg80211_clear_privacy(struct hdd_adapter *adapter) |
| 17749 | { |
| 17750 | struct hdd_station_ctx *hdd_sta_ctx = |
| 17751 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 17752 | |
| 17753 | hdd_debug("resetting all privacy configurations"); |
| 17754 | |
| 17755 | hdd_sta_ctx->wpa_versions = 0; |
| 17756 | |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 17757 | hdd_sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_NONE; |
wadesong | caad7c7 | 2018-08-06 13:26:27 +0800 | [diff] [blame] | 17758 | hdd_sta_ctx->roam_profile.AuthType.authType[0] = eCSR_AUTH_TYPE_NONE; |
| 17759 | |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 17760 | hdd_sta_ctx->conn_info.uc_encrypt_type = eCSR_ENCRYPT_TYPE_NONE; |
wadesong | caad7c7 | 2018-08-06 13:26:27 +0800 | [diff] [blame] | 17761 | hdd_sta_ctx->roam_profile.EncryptionType.numEntries = 0; |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 17762 | hdd_sta_ctx->conn_info.mc_encrypt_type = eCSR_ENCRYPT_TYPE_NONE; |
wadesong | caad7c7 | 2018-08-06 13:26:27 +0800 | [diff] [blame] | 17763 | hdd_sta_ctx->roam_profile.mcEncryptionType.numEntries = 0; |
| 17764 | |
| 17765 | wlan_hdd_clear_wapi_privacy(adapter); |
| 17766 | } |
| 17767 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17768 | int wlan_hdd_try_disconnect(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17769 | { |
| 17770 | unsigned long rc; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 17771 | struct hdd_station_ctx *sta_ctx; |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 17772 | int status, result = 0; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 17773 | mac_handle_t mac_handle; |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 17774 | uint32_t wait_time = SME_DISCONNECT_TIMEOUT; |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 17775 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17776 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 17777 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 17778 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 17779 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17780 | if (adapter->device_mode == QDF_STA_MODE) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17781 | hdd_debug("Stop firmware roaming"); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 17782 | sme_stop_roaming(mac_handle, adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 17783 | eCsrForcedDisassoc); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 17784 | |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 17785 | /* |
| 17786 | * If firmware has already started roaming process, driver |
| 17787 | * needs to wait for processing of this disconnect request. |
| 17788 | * |
| 17789 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17790 | INIT_COMPLETION(adapter->roaming_comp_var); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 17791 | if (hdd_is_roaming_in_progress(hdd_ctx)) { |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 17792 | rc = wait_for_completion_timeout( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17793 | &adapter->roaming_comp_var, |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 17794 | msecs_to_jiffies(WLAN_WAIT_TIME_STOP_ROAM)); |
| 17795 | if (!rc) { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 17796 | hdd_err("roaming comp var timed out vdev id: %d", |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 17797 | adapter->vdev_id); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 17798 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17799 | if (adapter->roam_ho_fail) { |
| 17800 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 17801 | hdd_conn_set_connection_state(adapter, |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 17802 | eConnectionState_Disconnecting); |
| 17803 | } |
| 17804 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 17805 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17806 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17807 | if ((QDF_IBSS_MODE == adapter->device_mode) || |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 17808 | (eConnectionState_Associated == sta_ctx->conn_info.conn_state) || |
| 17809 | (eConnectionState_Connecting == sta_ctx->conn_info.conn_state) || |
| 17810 | (eConnectionState_IbssConnected == sta_ctx->conn_info.conn_state)) { |
Abhishek Singh | 0edeba0 | 2018-06-05 10:04:08 +0530 | [diff] [blame] | 17811 | eConnectionState prev_conn_state; |
| 17812 | |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 17813 | prev_conn_state = sta_ctx->conn_info.conn_state; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17814 | hdd_conn_set_connection_state(adapter, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 17815 | eConnectionState_Disconnecting); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17816 | /* Issue disconnect to CSR */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17817 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 17818 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 17819 | status = sme_roam_disconnect(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 17820 | adapter->vdev_id, |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 17821 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Abhishek Singh | 0edeba0 | 2018-06-05 10:04:08 +0530 | [diff] [blame] | 17822 | |
| 17823 | if ((status == QDF_STATUS_CMD_NOT_QUEUED) && |
| 17824 | prev_conn_state != eConnectionState_Connecting) { |
| 17825 | hdd_debug("Already disconnect in progress"); |
| 17826 | result = 0; |
| 17827 | /* |
| 17828 | * Wait here instead of returning directly. This will |
| 17829 | * block the connect command and allow processing |
| 17830 | * of the disconnect in SME. As disconnect is already |
| 17831 | * in progress, wait here for 1 sec instead of 5 sec. |
| 17832 | */ |
| 17833 | wait_time = WLAN_WAIT_DISCONNECT_ALREADY_IN_PROGRESS; |
| 17834 | } else if (status == QDF_STATUS_CMD_NOT_QUEUED) { |
| 17835 | /* |
| 17836 | * Wait here instead of returning directly, this will |
| 17837 | * block the connect command and allow processing |
| 17838 | * of the scan for ssid and the previous connect command |
| 17839 | * in CSR. |
| 17840 | */ |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17841 | hdd_debug("Already disconnected or connect was in sme/roam pending list and removed by disconnect"); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 17842 | } else if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17843 | hdd_err("sme_roam_disconnect failure, status: %d", |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 17844 | (int)status); |
Jeff Johnson | 8380f23 | 2017-10-25 12:39:44 -0700 | [diff] [blame] | 17845 | sta_ctx->sta_debug_state = status; |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 17846 | result = -EINVAL; |
| 17847 | goto disconnected; |
| 17848 | } |
| 17849 | |
Abhishek Singh | 0edeba0 | 2018-06-05 10:04:08 +0530 | [diff] [blame] | 17850 | rc = wait_for_completion_timeout(&adapter->disconnect_comp_var, |
| 17851 | msecs_to_jiffies(wait_time)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 17852 | if (!rc && (QDF_STATUS_CMD_NOT_QUEUED != status)) { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 17853 | hdd_err("Sme disconnect event timed out vdev id: %d sta_debug_state: %d", |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 17854 | adapter->vdev_id, sta_ctx->sta_debug_state); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 17855 | result = -ETIMEDOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17856 | } |
| 17857 | } else if (eConnectionState_Disconnecting == |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 17858 | sta_ctx->conn_info.conn_state) { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17859 | rc = wait_for_completion_timeout(&adapter->disconnect_comp_var, |
Abhishek Singh | 0edeba0 | 2018-06-05 10:04:08 +0530 | [diff] [blame] | 17860 | msecs_to_jiffies(wait_time)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17861 | if (!rc) { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 17862 | hdd_err("Disconnect event timed out vdev id: %d sta_debug_state: %d", |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 17863 | adapter->vdev_id, sta_ctx->sta_debug_state); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 17864 | result = -ETIMEDOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17865 | } |
| 17866 | } |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 17867 | disconnected: |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17868 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 17869 | return result; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17870 | } |
| 17871 | |
| 17872 | /** |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 17873 | * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present |
| 17874 | * @adapter: Pointer to the HDD adapter |
| 17875 | * @req: Pointer to the structure cfg_connect_params receieved from user space |
| 17876 | * |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 17877 | * This function will start reassociation if prev_bssid is set and bssid/ |
| 17878 | * bssid_hint, channel/channel_hint parameters are present in connect request. |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 17879 | * |
Vignesh Viswanathan | 75af0a6 | 2018-05-08 17:08:54 +0530 | [diff] [blame] | 17880 | * Return: 0 if connect was for ReAssociation, non-zero error code otherwise |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 17881 | */ |
Selvaraj, Sridhar | a11edcb | 2016-09-07 18:49:14 +0530 | [diff] [blame] | 17882 | #if defined(CFG80211_CONNECT_PREV_BSSID) || \ |
| 17883 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
Vignesh Viswanathan | 75af0a6 | 2018-05-08 17:08:54 +0530 | [diff] [blame] | 17884 | static int wlan_hdd_reassoc_bssid_hint(struct hdd_adapter *adapter, |
| 17885 | struct cfg80211_connect_params *req) |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 17886 | { |
Vignesh Viswanathan | 75af0a6 | 2018-05-08 17:08:54 +0530 | [diff] [blame] | 17887 | int status = -EINVAL; |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 17888 | const uint8_t *bssid = NULL; |
| 17889 | uint16_t channel = 0; |
Jeff Johnson | 731bc32 | 2017-10-14 19:53:44 -0700 | [diff] [blame] | 17890 | struct hdd_station_ctx *sta_ctx; |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 17891 | |
| 17892 | if (req->bssid) |
| 17893 | bssid = req->bssid; |
| 17894 | else if (req->bssid_hint) |
| 17895 | bssid = req->bssid_hint; |
| 17896 | |
| 17897 | if (req->channel) |
| 17898 | channel = req->channel->hw_value; |
| 17899 | else if (req->channel_hint) |
| 17900 | channel = req->channel_hint->hw_value; |
| 17901 | |
| 17902 | if (bssid && channel && req->prev_bssid) { |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 17903 | hdd_debug("REASSOC Attempt on channel %d to " MAC_ADDRESS_STR, |
| 17904 | channel, MAC_ADDR_ARRAY(bssid)); |
Arif Hussain | 43354e6 | 2017-05-24 11:24:25 -0700 | [diff] [blame] | 17905 | /* |
| 17906 | * Save BSSID in a separate variable as |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17907 | * roam_profile's BSSID is getting zeroed out in the |
Arif Hussain | 43354e6 | 2017-05-24 11:24:25 -0700 | [diff] [blame] | 17908 | * association process. In case of join failure |
| 17909 | * we should send valid BSSID to supplicant |
| 17910 | */ |
Jeff Johnson | 731bc32 | 2017-10-14 19:53:44 -0700 | [diff] [blame] | 17911 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 17912 | qdf_mem_copy(sta_ctx->requested_bssid.bytes, bssid, |
Arif Hussain | 43354e6 | 2017-05-24 11:24:25 -0700 | [diff] [blame] | 17913 | QDF_MAC_ADDR_SIZE); |
| 17914 | |
Vignesh Viswanathan | 75af0a6 | 2018-05-08 17:08:54 +0530 | [diff] [blame] | 17915 | status = hdd_reassoc(adapter, bssid, channel, |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 17916 | CONNECT_CMD_USERSPACE); |
Vignesh Viswanathan | 75af0a6 | 2018-05-08 17:08:54 +0530 | [diff] [blame] | 17917 | hdd_debug("hdd_reassoc: status: %d", status); |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 17918 | } |
Vignesh Viswanathan | 75af0a6 | 2018-05-08 17:08:54 +0530 | [diff] [blame] | 17919 | return status; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 17920 | } |
| 17921 | #else |
Vignesh Viswanathan | 75af0a6 | 2018-05-08 17:08:54 +0530 | [diff] [blame] | 17922 | static int wlan_hdd_reassoc_bssid_hint(struct hdd_adapter *adapter, |
| 17923 | struct cfg80211_connect_params *req) |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 17924 | { |
Vignesh Viswanathan | 75af0a6 | 2018-05-08 17:08:54 +0530 | [diff] [blame] | 17925 | return -ENOTSUPP; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 17926 | } |
| 17927 | #endif |
| 17928 | |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 17929 | |
| 17930 | /** |
| 17931 | * wlan_hdd_check_ht20_ht40_ind() - check if Supplicant has indicated to |
| 17932 | * connect in HT20 mode |
| 17933 | * @hdd_ctx: hdd context |
| 17934 | * @adapter: Pointer to the HDD adapter |
| 17935 | * @req: Pointer to the structure cfg_connect_params receieved from user space |
| 17936 | * |
| 17937 | * This function will check if supplicant has indicated to to connect in HT20 |
| 17938 | * mode. this is currently applicable only for 2.4Ghz mode only. |
| 17939 | * if feature is enabled and supplicant indicate HT20 set |
| 17940 | * force_24ghz_in_ht20 to true to force 2.4Ghz in HT20 else set it to false. |
| 17941 | * |
| 17942 | * Return: void |
| 17943 | */ |
| 17944 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17945 | static void |
| 17946 | wlan_hdd_check_ht20_ht40_ind(struct hdd_context *hdd_ctx, |
| 17947 | struct hdd_adapter *adapter, |
| 17948 | struct cfg80211_connect_params *req) |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 17949 | { |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 17950 | struct csr_roam_profile *roam_profile; |
Wu Gao | fc81ecf | 2018-11-22 11:38:41 +0800 | [diff] [blame] | 17951 | bool is_override_ht20_40_24g; |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 17952 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17953 | roam_profile = hdd_roam_profile(adapter); |
| 17954 | |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 17955 | roam_profile->force_24ghz_in_ht20 = false; |
| 17956 | |
Wu Gao | fc81ecf | 2018-11-22 11:38:41 +0800 | [diff] [blame] | 17957 | ucfg_mlme_is_override_ht20_40_24g(hdd_ctx->psoc, |
| 17958 | &is_override_ht20_40_24g); |
| 17959 | if (is_override_ht20_40_24g && |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17960 | !(req->ht_capa.cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40)) |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 17961 | roam_profile->force_24ghz_in_ht20 = true; |
| 17962 | |
| 17963 | hdd_debug("req->ht_capa.cap_info %x override_ht20_40_24g %d", |
| 17964 | req->ht_capa.cap_info, |
Wu Gao | fc81ecf | 2018-11-22 11:38:41 +0800 | [diff] [blame] | 17965 | is_override_ht20_40_24g); |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 17966 | } |
| 17967 | #else |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17968 | static inline void |
| 17969 | wlan_hdd_check_ht20_ht40_ind(struct hdd_context *hdd_ctx, |
| 17970 | struct hdd_adapter *adapter, |
| 17971 | struct cfg80211_connect_params *req) |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 17972 | { |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 17973 | struct csr_roam_profile *roam_profile; |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 17974 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17975 | roam_profile = hdd_roam_profile(adapter); |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 17976 | |
| 17977 | roam_profile->force_24ghz_in_ht20 = false; |
| 17978 | } |
| 17979 | #endif |
| 17980 | |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 17981 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17982 | * __wlan_hdd_cfg80211_connect() - cfg80211 connect api |
| 17983 | * @wiphy: Pointer to wiphy |
| 17984 | * @dev: Pointer to network device |
| 17985 | * @req: Pointer to cfg80211 connect request |
| 17986 | * |
| 17987 | * This function is used to start the association process |
| 17988 | * |
| 17989 | * Return: 0 for success, non-zero for failure |
| 17990 | */ |
| 17991 | static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy, |
| 17992 | struct net_device *ndev, |
| 17993 | struct cfg80211_connect_params *req) |
| 17994 | { |
| 17995 | int status; |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 17996 | u16 channel; |
Arif Hussain | ee67701 | 2017-01-26 17:50:13 -0800 | [diff] [blame] | 17997 | const u8 *bssid = NULL; |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 17998 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) |
| 17999 | const u8 *bssid_hint = req->bssid_hint; |
| 18000 | #else |
| 18001 | const u8 *bssid_hint = NULL; |
| 18002 | #endif |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18003 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18004 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18005 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 18006 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18007 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 18008 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18009 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18010 | return -EINVAL; |
| 18011 | } |
| 18012 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 18013 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 18014 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 18015 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 18016 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 18017 | TRACE_CODE_HDD_CFG80211_CONNECT, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18018 | adapter->vdev_id, adapter->device_mode); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 18019 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18020 | hdd_debug("Device_mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 18021 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18022 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18023 | if (adapter->device_mode != QDF_STA_MODE && |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 18024 | adapter->device_mode != QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18025 | hdd_err("Device_mode %s(%d) is not supported", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 18026 | qdf_opmode_str(adapter->device_mode), |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18027 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18028 | return -EINVAL; |
| 18029 | } |
| 18030 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18031 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18032 | if (!hdd_ctx) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18033 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18034 | return -EINVAL; |
| 18035 | } |
| 18036 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18037 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 18038 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18039 | return status; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 18040 | |
Nachiket Kukade | 413c5fa | 2019-02-19 17:57:19 +0530 | [diff] [blame] | 18041 | /* |
| 18042 | * Disable NAN Discovery if incoming connection is P2P or if a STA |
| 18043 | * connection already exists and if this is a case of STA+STA. |
| 18044 | */ |
| 18045 | if (adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 18046 | policy_mgr_mode_specific_connection_count(hdd_ctx->psoc, |
| 18047 | PM_STA_MODE, NULL)) |
Nachiket Kukade | 089b983 | 2018-12-12 16:38:17 +0530 | [diff] [blame] | 18048 | ucfg_nan_disable_concurrency(hdd_ctx->psoc); |
| 18049 | |
Nachiket Kukade | 413c5fa | 2019-02-19 17:57:19 +0530 | [diff] [blame] | 18050 | /* |
| 18051 | * STA+NDI concurrency gets preference over NDI+NDI. Disable |
| 18052 | * first NDI in case an NDI+NDI concurrency exists. |
| 18053 | */ |
| 18054 | ucfg_nan_check_and_disable_unsupported_ndi(hdd_ctx->psoc); |
| 18055 | |
Arif Hussain | ee67701 | 2017-01-26 17:50:13 -0800 | [diff] [blame] | 18056 | if (req->bssid) |
| 18057 | bssid = req->bssid; |
| 18058 | else if (bssid_hint) |
| 18059 | bssid = bssid_hint; |
| 18060 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18061 | if (bssid && hdd_get_adapter_by_macaddr(hdd_ctx, (uint8_t *)bssid)) { |
Arif Hussain | 7631afa | 2017-02-08 14:35:00 -0800 | [diff] [blame] | 18062 | hdd_err("adapter exist with same mac address " MAC_ADDRESS_STR, |
| 18063 | MAC_ADDR_ARRAY(bssid)); |
| 18064 | return -EINVAL; |
Arif Hussain | ee67701 | 2017-01-26 17:50:13 -0800 | [diff] [blame] | 18065 | } |
| 18066 | |
Vignesh Viswanathan | 75af0a6 | 2018-05-08 17:08:54 +0530 | [diff] [blame] | 18067 | /* |
| 18068 | * Check if this is reassoc to same bssid, if reassoc is success, return |
| 18069 | */ |
| 18070 | status = wlan_hdd_reassoc_bssid_hint(adapter, req); |
Padma, Santhosh Kumar | 4155278 | 2018-06-29 15:31:25 +0530 | [diff] [blame] | 18071 | if (!status) { |
| 18072 | hdd_set_roaming_in_progress(true); |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 18073 | return status; |
Padma, Santhosh Kumar | 4155278 | 2018-06-29 15:31:25 +0530 | [diff] [blame] | 18074 | } |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 18075 | |
Agrawal Ashish | f156e94 | 2016-08-04 14:54:47 +0530 | [diff] [blame] | 18076 | /* Try disconnecting if already in connected state */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18077 | status = wlan_hdd_try_disconnect(adapter); |
Agrawal Ashish | f156e94 | 2016-08-04 14:54:47 +0530 | [diff] [blame] | 18078 | if (0 > status) { |
| 18079 | hdd_err("Failed to disconnect the existing connection"); |
| 18080 | return -EALREADY; |
| 18081 | } |
| 18082 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 18083 | /*initialise security parameters */ |
| 18084 | status = wlan_hdd_cfg80211_set_privacy(adapter, req); |
| 18085 | |
| 18086 | if (status < 0) { |
| 18087 | hdd_err("Failed to set security params"); |
| 18088 | return status; |
| 18089 | } |
| 18090 | |
| 18091 | /* |
| 18092 | * Check for max concurrent connections after doing disconnect if any, |
| 18093 | * must be called after the invocation of wlan_hdd_cfg80211_set_privacy |
| 18094 | * so privacy is already set for the current adapter before it's |
| 18095 | * checked against concurrency. |
| 18096 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18097 | if (req->channel) { |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 18098 | bool ok = false; |
Ajit Pal Singh | 90a45a4 | 2017-04-18 18:53:46 +0530 | [diff] [blame] | 18099 | |
| 18100 | if (req->channel->hw_value && policy_mgr_is_chan_ok_for_dnbs( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 18101 | hdd_ctx->psoc, |
Ajit Pal Singh | 90a45a4 | 2017-04-18 18:53:46 +0530 | [diff] [blame] | 18102 | req->channel->hw_value, |
| 18103 | &ok)) { |
| 18104 | hdd_warn("Unable to get channel:%d eligibility for DNBS", |
| 18105 | req->channel->hw_value); |
| 18106 | return -EINVAL; |
| 18107 | } |
| 18108 | /** |
| 18109 | * Send connection timedout, so that Android framework does not |
| 18110 | * blacklist us. |
| 18111 | */ |
| 18112 | if (!ok) { |
| 18113 | struct ieee80211_channel *chan = |
Dustin Brown | 2eb1e45 | 2017-08-15 12:40:34 -0700 | [diff] [blame] | 18114 | ieee80211_get_channel(wiphy, |
Ajit Pal Singh | 90a45a4 | 2017-04-18 18:53:46 +0530 | [diff] [blame] | 18115 | wlan_chan_to_freq(req->channel->hw_value)); |
| 18116 | struct cfg80211_bss *bss; |
| 18117 | |
| 18118 | hdd_warn("Channel:%d not OK for DNBS", |
| 18119 | req->channel->hw_value); |
| 18120 | if (chan) { |
Abhishek Singh | 59cdca1 | 2019-03-08 13:48:20 +0530 | [diff] [blame] | 18121 | bss = wlan_cfg80211_get_bss(wiphy, chan, |
| 18122 | req->bssid, |
| 18123 | req->ssid, |
| 18124 | req->ssid_len); |
Ajit Pal Singh | 90a45a4 | 2017-04-18 18:53:46 +0530 | [diff] [blame] | 18125 | if (bss) { |
| 18126 | cfg80211_assoc_timeout(ndev, bss); |
| 18127 | return -ETIMEDOUT; |
| 18128 | } |
| 18129 | } |
| 18130 | return -EINVAL; |
| 18131 | } |
| 18132 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 18133 | if (!policy_mgr_allow_concurrency(hdd_ctx->psoc, |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 18134 | policy_mgr_convert_device_mode_to_qdf_type( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18135 | adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18136 | req->channel->hw_value, HW_MODE_20_MHZ)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18137 | hdd_warn("This concurrency combination is not allowed"); |
wadesong | caad7c7 | 2018-08-06 13:26:27 +0800 | [diff] [blame] | 18138 | status = -ECONNREFUSED; |
| 18139 | goto con_chk_failed; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18140 | } |
| 18141 | } else { |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 18142 | if (!policy_mgr_allow_concurrency(hdd_ctx->psoc, |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 18143 | policy_mgr_convert_device_mode_to_qdf_type( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18144 | adapter->device_mode), 0, HW_MODE_20_MHZ)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18145 | hdd_warn("This concurrency combination is not allowed"); |
wadesong | caad7c7 | 2018-08-06 13:26:27 +0800 | [diff] [blame] | 18146 | status = -ECONNREFUSED; |
| 18147 | goto con_chk_failed; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18148 | } |
| 18149 | } |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 18150 | |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 18151 | if (req->channel) |
| 18152 | channel = req->channel->hw_value; |
| 18153 | else |
| 18154 | channel = 0; |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 18155 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18156 | wlan_hdd_check_ht20_ht40_ind(hdd_ctx, adapter, req); |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 18157 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18158 | status = wlan_hdd_cfg80211_connect_start(adapter, req->ssid, |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 18159 | req->ssid_len, req->bssid, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 18160 | bssid_hint, channel, 0); |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 18161 | if (0 > status) |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18162 | hdd_err("connect failed"); |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 18163 | |
wadesong | caad7c7 | 2018-08-06 13:26:27 +0800 | [diff] [blame] | 18164 | return status; |
| 18165 | |
| 18166 | con_chk_failed: |
| 18167 | wlan_hdd_cfg80211_clear_privacy(adapter); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 18168 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18169 | return status; |
| 18170 | } |
| 18171 | |
| 18172 | /** |
| 18173 | * wlan_hdd_cfg80211_connect() - cfg80211 connect api |
| 18174 | * @wiphy: Pointer to wiphy |
| 18175 | * @dev: Pointer to network device |
| 18176 | * @req: Pointer to cfg80211 connect request |
| 18177 | * |
| 18178 | * Return: 0 for success, non-zero for failure |
| 18179 | */ |
| 18180 | static int wlan_hdd_cfg80211_connect(struct wiphy *wiphy, |
| 18181 | struct net_device *ndev, |
| 18182 | struct cfg80211_connect_params *req) |
| 18183 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18184 | int errno; |
| 18185 | struct osif_vdev_sync *vdev_sync; |
| 18186 | |
| 18187 | errno = osif_vdev_sync_op_start(ndev, &vdev_sync); |
| 18188 | if (errno) |
| 18189 | return errno; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 18190 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18191 | errno = __wlan_hdd_cfg80211_connect(wiphy, ndev, req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18192 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18193 | osif_vdev_sync_op_stop(vdev_sync); |
| 18194 | |
| 18195 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18196 | } |
| 18197 | |
Himanshu Agarwal | 6c3607a | 2018-01-12 12:04:19 +0530 | [diff] [blame] | 18198 | int wlan_hdd_disconnect(struct hdd_adapter *adapter, u16 reason) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18199 | { |
Dundi Raviteja | cc95c56 | 2018-07-27 12:30:24 +0530 | [diff] [blame] | 18200 | QDF_STATUS status; |
| 18201 | int result = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18202 | unsigned long rc; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18203 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18204 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Padma, Santhosh Kumar | 52456c6 | 2017-01-05 12:14:08 +0530 | [diff] [blame] | 18205 | eConnectionState prev_conn_state; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18206 | mac_handle_t mac_handle; |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 18207 | uint32_t wait_time = SME_DISCONNECT_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18208 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 18209 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 18210 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18211 | mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18212 | if (adapter->device_mode == QDF_STA_MODE) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18213 | hdd_debug("Stop firmware roaming"); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18214 | status = sme_stop_roaming(mac_handle, adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18215 | eCsrForcedDisassoc); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 18216 | /* |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 18217 | * If firmware has already started roaming process, driver |
| 18218 | * needs to wait for processing of this disconnect request. |
| 18219 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 18220 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18221 | INIT_COMPLETION(adapter->roaming_comp_var); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 18222 | if (hdd_is_roaming_in_progress(hdd_ctx)) { |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 18223 | rc = wait_for_completion_timeout( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18224 | &adapter->roaming_comp_var, |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 18225 | msecs_to_jiffies(WLAN_WAIT_TIME_STOP_ROAM)); |
| 18226 | if (!rc) { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 18227 | hdd_err("roaming comp var timed out vdev id: %d", |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18228 | adapter->vdev_id); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 18229 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18230 | if (adapter->roam_ho_fail) { |
| 18231 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 18232 | hdd_debug("Disabling queues"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18233 | wlan_hdd_netif_queue_control(adapter, |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 18234 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 18235 | WLAN_CONTROL_PATH); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18236 | hdd_conn_set_connection_state(adapter, |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 18237 | eConnectionState_Disconnecting); |
| 18238 | goto wait_for_disconnect; |
| 18239 | } |
| 18240 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 18241 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18242 | |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 18243 | prev_conn_state = sta_ctx->conn_info.conn_state; |
Srinivas Girigowda | 6598eea | 2017-07-06 19:26:19 -0700 | [diff] [blame] | 18244 | /*stop tx queues */ |
| 18245 | hdd_info("Disabling queues"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18246 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 18247 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, WLAN_CONTROL_PATH); |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 18248 | hdd_debug("Set HDD conn_state to eConnectionState_Disconnecting"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18249 | hdd_conn_set_connection_state(adapter, eConnectionState_Disconnecting); |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 18250 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18251 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18252 | |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 18253 | /* issue disconnect */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18254 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18255 | status = sme_roam_disconnect(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18256 | adapter->vdev_id, reason); |
Padma, Santhosh Kumar | 52456c6 | 2017-01-05 12:14:08 +0530 | [diff] [blame] | 18257 | if ((QDF_STATUS_CMD_NOT_QUEUED == status) && |
| 18258 | prev_conn_state != eConnectionState_Connecting) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18259 | hdd_debug("status = %d, already disconnected", status); |
Padma, Santhosh Kumar | 52456c6 | 2017-01-05 12:14:08 +0530 | [diff] [blame] | 18260 | result = 0; |
Abhishek Singh | e9706cc | 2017-10-12 17:25:06 +0530 | [diff] [blame] | 18261 | /* |
| 18262 | * Wait here instead of returning directly. This will block the |
| 18263 | * next connect command and allow processing of the disconnect |
| 18264 | * in SME else we might hit some race conditions leading to SME |
| 18265 | * and HDD out of sync. As disconnect is already in progress, |
| 18266 | * wait here for 1 sec instead of 5 sec. |
| 18267 | */ |
| 18268 | wait_time = WLAN_WAIT_DISCONNECT_ALREADY_IN_PROGRESS; |
Padma, Santhosh Kumar | 52456c6 | 2017-01-05 12:14:08 +0530 | [diff] [blame] | 18269 | } else if (QDF_STATUS_CMD_NOT_QUEUED == status) { |
| 18270 | /* |
| 18271 | * Wait here instead of returning directly, this will block the |
| 18272 | * next connect command and allow processing of the scan for |
| 18273 | * ssid and the previous connect command in CSR. Else we might |
| 18274 | * hit some race conditions leading to SME and HDD out of sync. |
| 18275 | */ |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18276 | hdd_debug("Already disconnected or connect was in sme/roam pending list and removed by disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18277 | } else if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18278 | hdd_err("csr_roam_disconnect failure, status: %d", (int)status); |
Jeff Johnson | 8380f23 | 2017-10-25 12:39:44 -0700 | [diff] [blame] | 18279 | sta_ctx->sta_debug_state = status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18280 | result = -EINVAL; |
| 18281 | goto disconnected; |
| 18282 | } |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 18283 | wait_for_disconnect: |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18284 | rc = wait_for_completion_timeout(&adapter->disconnect_comp_var, |
Abhishek Singh | e9706cc | 2017-10-12 17:25:06 +0530 | [diff] [blame] | 18285 | msecs_to_jiffies(wait_time)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18286 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 18287 | if (!rc && (QDF_STATUS_CMD_NOT_QUEUED != status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18288 | hdd_err("Failed to disconnect, timed out"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18289 | result = -ETIMEDOUT; |
| 18290 | } |
| 18291 | disconnected: |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18292 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18293 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0) |
| 18294 | /* Sending disconnect event to userspace for kernel version < 3.11 |
| 18295 | * is handled by __cfg80211_disconnect call to __cfg80211_disconnected |
| 18296 | */ |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18297 | hdd_debug("Send disconnected event to userspace"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18298 | wlan_hdd_cfg80211_indicate_disconnect(adapter->dev, true, |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 18299 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18300 | #endif |
| 18301 | |
| 18302 | return result; |
| 18303 | } |
| 18304 | |
| 18305 | /** |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 18306 | * hdd_ieee80211_reason_code_to_str() - return string conversion of reason code |
| 18307 | * @reason: ieee80211 reason code. |
| 18308 | * |
| 18309 | * This utility function helps log string conversion of reason code. |
| 18310 | * |
| 18311 | * Return: string conversion of reason code, if match found; |
| 18312 | * "Unknown" otherwise. |
| 18313 | */ |
| 18314 | static const char *hdd_ieee80211_reason_code_to_str(uint16_t reason) |
| 18315 | { |
| 18316 | switch (reason) { |
| 18317 | CASE_RETURN_STRING(WLAN_REASON_UNSPECIFIED); |
| 18318 | CASE_RETURN_STRING(WLAN_REASON_PREV_AUTH_NOT_VALID); |
| 18319 | CASE_RETURN_STRING(WLAN_REASON_DEAUTH_LEAVING); |
| 18320 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY); |
| 18321 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_AP_BUSY); |
| 18322 | CASE_RETURN_STRING(WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA); |
| 18323 | CASE_RETURN_STRING(WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); |
| 18324 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_STA_HAS_LEFT); |
| 18325 | CASE_RETURN_STRING(WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH); |
| 18326 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_BAD_POWER); |
| 18327 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_BAD_SUPP_CHAN); |
| 18328 | CASE_RETURN_STRING(WLAN_REASON_INVALID_IE); |
| 18329 | CASE_RETURN_STRING(WLAN_REASON_MIC_FAILURE); |
| 18330 | CASE_RETURN_STRING(WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT); |
| 18331 | CASE_RETURN_STRING(WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT); |
| 18332 | CASE_RETURN_STRING(WLAN_REASON_IE_DIFFERENT); |
| 18333 | CASE_RETURN_STRING(WLAN_REASON_INVALID_GROUP_CIPHER); |
| 18334 | CASE_RETURN_STRING(WLAN_REASON_INVALID_PAIRWISE_CIPHER); |
| 18335 | CASE_RETURN_STRING(WLAN_REASON_INVALID_AKMP); |
| 18336 | CASE_RETURN_STRING(WLAN_REASON_UNSUPP_RSN_VERSION); |
| 18337 | CASE_RETURN_STRING(WLAN_REASON_INVALID_RSN_IE_CAP); |
| 18338 | CASE_RETURN_STRING(WLAN_REASON_IEEE8021X_FAILED); |
| 18339 | CASE_RETURN_STRING(WLAN_REASON_CIPHER_SUITE_REJECTED); |
| 18340 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_UNSPECIFIED_QOS); |
| 18341 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH); |
| 18342 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_LOW_ACK); |
| 18343 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP); |
| 18344 | CASE_RETURN_STRING(WLAN_REASON_QSTA_LEAVE_QBSS); |
| 18345 | CASE_RETURN_STRING(WLAN_REASON_QSTA_NOT_USE); |
| 18346 | CASE_RETURN_STRING(WLAN_REASON_QSTA_REQUIRE_SETUP); |
| 18347 | CASE_RETURN_STRING(WLAN_REASON_QSTA_TIMEOUT); |
| 18348 | CASE_RETURN_STRING(WLAN_REASON_QSTA_CIPHER_NOT_SUPP); |
| 18349 | CASE_RETURN_STRING(WLAN_REASON_MESH_PEER_CANCELED); |
| 18350 | CASE_RETURN_STRING(WLAN_REASON_MESH_MAX_PEERS); |
| 18351 | CASE_RETURN_STRING(WLAN_REASON_MESH_CONFIG); |
| 18352 | CASE_RETURN_STRING(WLAN_REASON_MESH_CLOSE); |
| 18353 | CASE_RETURN_STRING(WLAN_REASON_MESH_MAX_RETRIES); |
| 18354 | CASE_RETURN_STRING(WLAN_REASON_MESH_CONFIRM_TIMEOUT); |
| 18355 | CASE_RETURN_STRING(WLAN_REASON_MESH_INVALID_GTK); |
| 18356 | CASE_RETURN_STRING(WLAN_REASON_MESH_INCONSISTENT_PARAM); |
| 18357 | CASE_RETURN_STRING(WLAN_REASON_MESH_INVALID_SECURITY); |
| 18358 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_ERROR); |
| 18359 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_NOFORWARD); |
| 18360 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_DEST_UNREACHABLE); |
| 18361 | CASE_RETURN_STRING(WLAN_REASON_MAC_EXISTS_IN_MBSS); |
| 18362 | CASE_RETURN_STRING(WLAN_REASON_MESH_CHAN_REGULATORY); |
| 18363 | CASE_RETURN_STRING(WLAN_REASON_MESH_CHAN); |
| 18364 | default: |
| 18365 | return "Unknown"; |
| 18366 | } |
| 18367 | } |
| 18368 | |
| 18369 | /** |
Srinivas Girigowda | 44cff5c | 2018-04-16 15:49:30 -0700 | [diff] [blame] | 18370 | * hdd_print_netdev_txq_status() - print netdev tx queue status |
| 18371 | * @dev: Pointer to network device |
| 18372 | * |
| 18373 | * This function is used to print netdev tx queue status |
| 18374 | * |
| 18375 | * Return: none |
| 18376 | */ |
| 18377 | static void hdd_print_netdev_txq_status(struct net_device *dev) |
| 18378 | { |
| 18379 | unsigned int i; |
| 18380 | |
| 18381 | if (!dev) |
| 18382 | return; |
| 18383 | |
| 18384 | for (i = 0; i < dev->num_tx_queues; i++) { |
| 18385 | struct netdev_queue *txq = netdev_get_tx_queue(dev, i); |
| 18386 | |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 18387 | hdd_debug("netdev tx queue[%u] state: 0x%lx", i, txq->state); |
Srinivas Girigowda | 44cff5c | 2018-04-16 15:49:30 -0700 | [diff] [blame] | 18388 | } |
| 18389 | } |
| 18390 | |
| 18391 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18392 | * __wlan_hdd_cfg80211_disconnect() - cfg80211 disconnect api |
| 18393 | * @wiphy: Pointer to wiphy |
| 18394 | * @dev: Pointer to network device |
| 18395 | * @reason: Disconnect reason code |
| 18396 | * |
| 18397 | * This function is used to issue a disconnect request to SME |
| 18398 | * |
| 18399 | * Return: 0 for success, non-zero for failure |
| 18400 | */ |
| 18401 | static int __wlan_hdd_cfg80211_disconnect(struct wiphy *wiphy, |
| 18402 | struct net_device *dev, u16 reason) |
| 18403 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18404 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18405 | int status; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18406 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18407 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 18408 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 18409 | struct wlan_objmgr_vdev *vdev; |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 18410 | bool enable_deauth_to_disassoc_map; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18411 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 18412 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18413 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 18414 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18415 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18416 | return -EINVAL; |
| 18417 | } |
| 18418 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 18419 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 18420 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 18421 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 18422 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 18423 | TRACE_CODE_HDD_CFG80211_DISCONNECT, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18424 | adapter->vdev_id, reason); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 18425 | |
Srinivas Girigowda | 44cff5c | 2018-04-16 15:49:30 -0700 | [diff] [blame] | 18426 | hdd_print_netdev_txq_status(dev); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18427 | hdd_debug("Device_mode %s(%d) reason code(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 18428 | qdf_opmode_str(adapter->device_mode), |
| 18429 | adapter->device_mode, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18430 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18431 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18432 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 18433 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18434 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18435 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 18436 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 18437 | if (adapter->disconnection_in_progress) { |
| 18438 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 18439 | hdd_debug("Disconnect is already in progress"); |
| 18440 | return 0; |
| 18441 | } |
| 18442 | adapter->disconnection_in_progress = true; |
| 18443 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 18444 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18445 | /* Issue disconnect request to SME, if station is in connected state */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 18446 | if ((sta_ctx->conn_info.conn_state == eConnectionState_Associated) || |
| 18447 | (sta_ctx->conn_info.conn_state == eConnectionState_Connecting)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18448 | eCsrRoamDisconnectReason reasonCode = |
| 18449 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18450 | |
| 18451 | switch (reason) { |
| 18452 | case WLAN_REASON_MIC_FAILURE: |
| 18453 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 18454 | break; |
| 18455 | |
| 18456 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 18457 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 18458 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 18459 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 18460 | break; |
| 18461 | |
| 18462 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 18463 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 18464 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 18465 | break; |
| 18466 | |
| 18467 | case WLAN_REASON_DEAUTH_LEAVING: |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 18468 | status = ucfg_mlme_get_enable_deauth_to_disassoc_map( |
| 18469 | hdd_ctx->psoc, |
| 18470 | &enable_deauth_to_disassoc_map); |
| 18471 | if (QDF_IS_STATUS_ERROR(status)) |
| 18472 | return -EINVAL; |
| 18473 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18474 | reasonCode = |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 18475 | enable_deauth_to_disassoc_map ? |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18476 | eCSR_DISCONNECT_REASON_STA_HAS_LEFT : |
| 18477 | eCSR_DISCONNECT_REASON_DEAUTH; |
Mohit Khanna | ceb9778 | 2017-04-05 16:27:08 -0700 | [diff] [blame] | 18478 | qdf_dp_trace_dump_all( |
| 18479 | WLAN_DEAUTH_DPTRACE_DUMP_COUNT, |
| 18480 | QDF_TRACE_DEFAULT_PDEV_ID); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18481 | break; |
| 18482 | case WLAN_REASON_DISASSOC_STA_HAS_LEFT: |
| 18483 | reasonCode = eCSR_DISCONNECT_REASON_STA_HAS_LEFT; |
| 18484 | break; |
| 18485 | default: |
| 18486 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 18487 | break; |
| 18488 | } |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 18489 | |
| 18490 | vdev = hdd_objmgr_get_vdev(adapter); |
| 18491 | if (!vdev) |
| 18492 | return -EINVAL; |
| 18493 | if (ucfg_scan_get_vdev_status(vdev) != |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 18494 | SCAN_NOT_IN_PROGRESS) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18495 | hdd_debug("Disconnect is in progress, Aborting Scan"); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 18496 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18497 | adapter->vdev_id, INVALID_SCAN_ID, |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 18498 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18499 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18500 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18501 | /* First clean up the tdls peers if any */ |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18502 | hdd_notify_sta_disconnect(adapter->vdev_id, |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 18503 | false, true, vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 18504 | hdd_objmgr_put_vdev(vdev); |
Kabilan Kannan | b6153b1 | 2017-07-13 17:54:02 -0700 | [diff] [blame] | 18505 | |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 18506 | hdd_info("Disconnect from userspace; reason:%d (%s)", |
| 18507 | reason, hdd_ieee80211_reason_code_to_str(reason)); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18508 | status = wlan_hdd_disconnect(adapter, reasonCode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18509 | if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18510 | hdd_err("wlan_hdd_disconnect failed, status: %d", status); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 18511 | hdd_set_disconnect_status(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18512 | return -EINVAL; |
| 18513 | } |
| 18514 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18515 | hdd_err("Unexpected cfg disconnect called while in state: %d", |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 18516 | sta_ctx->conn_info.conn_state); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 18517 | hdd_set_disconnect_status(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18518 | } |
| 18519 | |
| 18520 | return status; |
| 18521 | } |
| 18522 | |
| 18523 | /** |
| 18524 | * wlan_hdd_cfg80211_disconnect() - cfg80211 disconnect api |
| 18525 | * @wiphy: Pointer to wiphy |
| 18526 | * @dev: Pointer to network device |
| 18527 | * @reason: Disconnect reason code |
| 18528 | * |
| 18529 | * Return: 0 for success, non-zero for failure |
| 18530 | */ |
| 18531 | static int wlan_hdd_cfg80211_disconnect(struct wiphy *wiphy, |
| 18532 | struct net_device *dev, u16 reason) |
| 18533 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18534 | int errno; |
| 18535 | struct osif_vdev_sync *vdev_sync; |
| 18536 | |
| 18537 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 18538 | if (errno) |
| 18539 | return errno; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 18540 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18541 | errno = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18542 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18543 | osif_vdev_sync_op_stop(vdev_sync); |
| 18544 | |
| 18545 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18546 | } |
| 18547 | |
| 18548 | /** |
| 18549 | * wlan_hdd_cfg80211_set_privacy_ibss() - set ibss privacy |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18550 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18551 | * @param: Pointer to IBSS parameters |
| 18552 | * |
| 18553 | * This function is used to initialize the security settings in IBSS mode |
| 18554 | * |
| 18555 | * Return: 0 for success, non-zero for failure |
| 18556 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18557 | static int wlan_hdd_cfg80211_set_privacy_ibss(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18558 | struct cfg80211_ibss_params |
| 18559 | *params) |
| 18560 | { |
Naveen Rawat | 72475db | 2017-12-13 18:07:35 -0800 | [diff] [blame] | 18561 | uint32_t ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18562 | int status = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18563 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18564 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18565 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18566 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18567 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 18568 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18569 | |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 18570 | sta_ctx->wpa_versions = 0; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18571 | qdf_mem_zero(&sta_ctx->ibss_enc_key, sizeof(tCsrRoamSetKey)); |
| 18572 | sta_ctx->ibss_enc_key_installed = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18573 | |
| 18574 | if (params->ie_len && (NULL != params->ie)) { |
Naveen Rawat | 08db88f | 2017-09-08 15:07:48 -0700 | [diff] [blame] | 18575 | if (wlan_get_ie_ptr_from_eid(WLAN_EID_RSN, params->ie, |
| 18576 | params->ie_len)) { |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 18577 | sta_ctx->wpa_versions = NL80211_WPA_VERSION_2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18578 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 18579 | } else if (hdd_is_wpaie_present(params->ie, params->ie_len)) { |
Jeff Johnson | 6a2c0ca | 2019-03-09 22:08:45 -0800 | [diff] [blame] | 18580 | tDot11fIEWPA dot11_wpa_ie; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18581 | mac_handle_t mac_handle = |
| 18582 | hdd_adapter_get_mac_handle(adapter); |
Naveen Rawat | 08db88f | 2017-09-08 15:07:48 -0700 | [diff] [blame] | 18583 | const u8 *ie; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18584 | |
Jeff Johnson | 6a2c0ca | 2019-03-09 22:08:45 -0800 | [diff] [blame] | 18585 | memset(&dot11_wpa_ie, 0, sizeof(dot11_wpa_ie)); |
Naveen Rawat | 08db88f | 2017-09-08 15:07:48 -0700 | [diff] [blame] | 18586 | ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_WPA, |
| 18587 | params->ie, params->ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18588 | if (NULL != ie) { |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 18589 | sta_ctx->wpa_versions = NL80211_WPA_VERSION_1; |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 18590 | /* Unpack the WPA IE |
| 18591 | * Skip past the EID byte and length byte |
| 18592 | * and four byte WiFi OUI |
| 18593 | */ |
Hanumanth Reddy Pothula | f6e3db3 | 2018-01-24 17:54:15 +0530 | [diff] [blame] | 18594 | if (ie[1] < DOT11F_IE_WPA_MIN_LEN || |
| 18595 | ie[1] > DOT11F_IE_WPA_MAX_LEN) { |
| 18596 | hdd_err("invalid ie len:%d", ie[1]); |
| 18597 | return -EINVAL; |
| 18598 | } |
Naveen Rawat | 72475db | 2017-12-13 18:07:35 -0800 | [diff] [blame] | 18599 | ret = dot11f_unpack_ie_wpa( |
Jeff Johnson | 034f3c9 | 2018-11-09 10:46:21 -0800 | [diff] [blame] | 18600 | MAC_CONTEXT(mac_handle), |
Naveen Rawat | 72475db | 2017-12-13 18:07:35 -0800 | [diff] [blame] | 18601 | (uint8_t *)&ie[2 + 4], |
Jeff Johnson | 6a2c0ca | 2019-03-09 22:08:45 -0800 | [diff] [blame] | 18602 | ie[1] - 4, &dot11_wpa_ie, false); |
Naveen Rawat | 72475db | 2017-12-13 18:07:35 -0800 | [diff] [blame] | 18603 | if (DOT11F_FAILED(ret)) { |
| 18604 | hdd_err("unpack failed ret: 0x%x", ret); |
| 18605 | return -EINVAL; |
| 18606 | } |
Selvaraj, Sridhar | 75afbeb | 2017-04-03 17:08:59 +0530 | [diff] [blame] | 18607 | /* |
| 18608 | * Extract the multicast cipher, the |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 18609 | * encType for unicast cipher for |
| 18610 | * wpa-none is none |
| 18611 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18612 | encryptionType = |
| 18613 | hdd_translate_wpa_to_csr_encryption_type |
Jeff Johnson | 6a2c0ca | 2019-03-09 22:08:45 -0800 | [diff] [blame] | 18614 | (dot11_wpa_ie.multicast_cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18615 | } |
| 18616 | } |
| 18617 | |
| 18618 | status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18619 | wlan_hdd_cfg80211_set_ie(adapter, params->ie, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18620 | params->ie_len); |
| 18621 | |
| 18622 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18623 | hdd_err("Failed to parse WPA/RSN IE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18624 | return status; |
| 18625 | } |
| 18626 | } |
| 18627 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18628 | roam_profile = hdd_roam_profile(adapter); |
| 18629 | roam_profile->AuthType.authType[0] = |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 18630 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18631 | |
| 18632 | if (params->privacy) { |
| 18633 | /* Security enabled IBSS, At this time there is no information |
Jeff Johnson | 60ed45a | 2018-05-06 15:28:49 -0700 | [diff] [blame] | 18634 | * available about the security parameters, so initialise the |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18635 | * encryption type to eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
| 18636 | * The correct security parameters will be updated later in |
| 18637 | * wlan_hdd_cfg80211_add_key Hal expects encryption type to be |
| 18638 | * set inorder enable privacy bit in beacons |
| 18639 | */ |
| 18640 | |
| 18641 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 18642 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18643 | hdd_debug("encryptionType=%d", encryptionType); |
Jeff Johnson | b195984 | 2019-02-27 13:04:04 -0800 | [diff] [blame] | 18644 | sta_ctx->conn_info.uc_encrypt_type = encryptionType; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18645 | roam_profile->EncryptionType.numEntries = 1; |
| 18646 | roam_profile->EncryptionType.encryptionType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18647 | encryptionType; |
| 18648 | return status; |
| 18649 | } |
| 18650 | |
| 18651 | /** |
| 18652 | * __wlan_hdd_cfg80211_join_ibss() - join ibss |
| 18653 | * @wiphy: Pointer to wiphy |
| 18654 | * @dev: Pointer to network device |
| 18655 | * @param: Pointer to IBSS join parameters |
| 18656 | * |
| 18657 | * This function is used to create/join an IBSS network |
| 18658 | * |
| 18659 | * Return: 0 for success, non-zero for failure |
| 18660 | */ |
| 18661 | static int __wlan_hdd_cfg80211_join_ibss(struct wiphy *wiphy, |
| 18662 | struct net_device *dev, |
| 18663 | struct cfg80211_ibss_params *params) |
| 18664 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18665 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 18666 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18667 | int status; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18668 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18669 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 18670 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 18671 | struct qdf_mac_addr bssid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18672 | u8 channelNum = 0; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18673 | mac_handle_t mac_handle; |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 18674 | struct wlan_mlme_ibss_cfg ibss_cfg = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18675 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 18676 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18677 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 18678 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18679 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18680 | return -EINVAL; |
| 18681 | } |
| 18682 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 18683 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 18684 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 18685 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 18686 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 18687 | TRACE_CODE_HDD_CFG80211_JOIN_IBSS, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18688 | adapter->vdev_id, adapter->device_mode); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 18689 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18690 | hdd_debug("Device_mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 18691 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18692 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18693 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18694 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 18695 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18696 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18697 | |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 18698 | if (QDF_IS_STATUS_ERROR(ucfg_mlme_get_ibss_cfg(hdd_ctx->psoc, |
| 18699 | &ibss_cfg))) { |
| 18700 | return -EINVAL; |
| 18701 | } |
| 18702 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18703 | mac_handle = hdd_ctx->mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18704 | if (NULL != |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 18705 | params->chandef.chan) { |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 18706 | uint32_t numChans = CFG_VALID_CHANNEL_LIST_LEN; |
| 18707 | uint8_t validChan[CFG_VALID_CHANNEL_LIST_LEN]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18708 | int indx; |
| 18709 | |
| 18710 | /* Get channel number */ |
| 18711 | channelNum = ieee80211_frequency_to_channel( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18712 | params-> |
| 18713 | chandef. |
| 18714 | chan-> |
| 18715 | center_freq); |
Wu Gao | f3cbeaf | 2019-01-15 18:26:25 +0800 | [diff] [blame] | 18716 | ucfg_mlme_get_valid_channel_list(hdd_ctx->psoc, validChan, |
| 18717 | &numChans); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18718 | |
| 18719 | for (indx = 0; indx < numChans; indx++) { |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 18720 | if (channelNum == validChan[indx]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18721 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18722 | } |
| 18723 | if (indx >= numChans) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18724 | hdd_err("Not valid Channel: %d", channelNum); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18725 | return -EINVAL; |
| 18726 | } |
| 18727 | } |
| 18728 | |
Nachiket Kukade | 089b983 | 2018-12-12 16:38:17 +0530 | [diff] [blame] | 18729 | /* Disable NAN Discovery if enabled */ |
| 18730 | ucfg_nan_disable_concurrency(hdd_ctx->psoc); |
| 18731 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 18732 | if (!policy_mgr_allow_concurrency(hdd_ctx->psoc, |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 18733 | PM_IBSS_MODE, channelNum, HW_MODE_20_MHZ)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18734 | hdd_err("This concurrency combination is not allowed"); |
| 18735 | return -ECONNREFUSED; |
| 18736 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18737 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 18738 | status = policy_mgr_reset_connection_update(hdd_ctx->psoc); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 18739 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18740 | hdd_err("qdf_reset_connection_update failed status: %d", status); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 18741 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 18742 | status = policy_mgr_current_connections_update(hdd_ctx->psoc, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18743 | adapter->vdev_id, channelNum, |
Tushnim Bhattacharyya | 3b99f4b | 2018-03-26 14:19:24 -0700 | [diff] [blame] | 18744 | POLICY_MGR_UPDATE_REASON_JOIN_IBSS); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 18745 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18746 | hdd_err("connections update failed!!"); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 18747 | return -EINVAL; |
| 18748 | } |
| 18749 | |
| 18750 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 18751 | status = policy_mgr_wait_for_connection_update( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 18752 | hdd_ctx->psoc); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 18753 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18754 | hdd_err("qdf wait for event failed!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18755 | return -EINVAL; |
| 18756 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18757 | } |
| 18758 | |
| 18759 | /*Try disconnecting if already in connected state */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18760 | status = wlan_hdd_try_disconnect(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18761 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18762 | hdd_err("Failed to disconnect the existing IBSS connection"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18763 | return -EALREADY; |
| 18764 | } |
| 18765 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18766 | roam_profile = hdd_roam_profile(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18767 | |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 18768 | if (eCSR_BSS_TYPE_START_IBSS != roam_profile->BSSType) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18769 | hdd_err("Interface type is not set to IBSS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18770 | return -EINVAL; |
| 18771 | } |
| 18772 | |
| 18773 | /* enable selected protection checks in IBSS mode */ |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 18774 | roam_profile->cfg_protection = IBSS_CFG_PROTECTION_ENABLE_MASK; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18775 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18776 | /* BSSID is provided by upper layers hence no need to AUTO generate */ |
| 18777 | if (NULL != params->bssid) { |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 18778 | if (ucfg_mlme_set_ibss_auto_bssid(hdd_ctx->psoc, 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 18779 | == QDF_STATUS_E_FAILURE) { |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 18780 | hdd_err("Unable to update MLME IBSS Auto BSSID config"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18781 | return -EIO; |
| 18782 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 18783 | qdf_mem_copy(bssid.bytes, params->bssid, QDF_MAC_ADDR_SIZE); |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 18784 | } else if (ibss_cfg.coalesing_enable == 0) { |
| 18785 | if (ucfg_mlme_set_ibss_auto_bssid(hdd_ctx->psoc, 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 18786 | == QDF_STATUS_E_FAILURE) { |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 18787 | hdd_err("Unable to update MLME IBSS Auto BSSID config"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18788 | return -EIO; |
| 18789 | } |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 18790 | qdf_copy_macaddr(&bssid, &ibss_cfg.bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18791 | } |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 18792 | |
| 18793 | if (cfg_in_range(CFG_BEACON_INTERVAL, params->beacon_interval)) |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 18794 | roam_profile->beaconInterval = params->beacon_interval; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 18795 | else |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 18796 | roam_profile->beaconInterval = cfg_get(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 18797 | CFG_BEACON_INTERVAL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18798 | |
| 18799 | /* Set Channel */ |
| 18800 | if (channelNum) { |
| 18801 | /* Set the Operational Channel */ |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18802 | hdd_debug("set channel %d", channelNum); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 18803 | roam_profile->ChannelInfo.numOfChannels = 1; |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 18804 | sta_ctx->conn_info.channel = channelNum; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 18805 | roam_profile->ChannelInfo.ChannelList = |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 18806 | &sta_ctx->conn_info.channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18807 | } |
| 18808 | |
| 18809 | /* Initialize security parameters */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18810 | status = wlan_hdd_cfg80211_set_privacy_ibss(adapter, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18811 | if (status < 0) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18812 | hdd_err("failed to set security parameters"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18813 | return status; |
| 18814 | } |
| 18815 | |
| 18816 | /* Issue connect start */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18817 | status = wlan_hdd_cfg80211_connect_start(adapter, params->ssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18818 | params->ssid_len, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 18819 | bssid.bytes, NULL, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18820 | sta_ctx->conn_info. |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 18821 | channel, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 18822 | params->chandef.width); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18823 | |
| 18824 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18825 | hdd_err("connect failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18826 | return status; |
| 18827 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 18828 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18829 | return 0; |
| 18830 | } |
| 18831 | |
| 18832 | /** |
| 18833 | * wlan_hdd_cfg80211_join_ibss() - join ibss |
| 18834 | * @wiphy: Pointer to wiphy |
| 18835 | * @dev: Pointer to network device |
| 18836 | * @param: Pointer to IBSS join parameters |
| 18837 | * |
| 18838 | * This function is used to create/join an IBSS network |
| 18839 | * |
| 18840 | * Return: 0 for success, non-zero for failure |
| 18841 | */ |
| 18842 | static int wlan_hdd_cfg80211_join_ibss(struct wiphy *wiphy, |
| 18843 | struct net_device *dev, |
| 18844 | struct cfg80211_ibss_params *params) |
| 18845 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18846 | int errno; |
| 18847 | struct osif_vdev_sync *vdev_sync; |
| 18848 | |
| 18849 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 18850 | if (errno) |
| 18851 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18852 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18853 | errno = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18854 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18855 | osif_vdev_sync_op_stop(vdev_sync); |
| 18856 | |
| 18857 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18858 | } |
| 18859 | |
| 18860 | /** |
| 18861 | * __wlan_hdd_cfg80211_leave_ibss() - leave ibss |
| 18862 | * @wiphy: Pointer to wiphy |
| 18863 | * @dev: Pointer to network device |
| 18864 | * |
| 18865 | * This function is used to leave an IBSS network |
| 18866 | * |
| 18867 | * Return: 0 for success, non-zero for failure |
| 18868 | */ |
| 18869 | static int __wlan_hdd_cfg80211_leave_ibss(struct wiphy *wiphy, |
| 18870 | struct net_device *dev) |
| 18871 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18872 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 18873 | struct csr_roam_profile *roam_profile; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18874 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18875 | int status; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18876 | mac_handle_t mac_handle; |
Chandrasekaran, Manishekar | 12a818a | 2015-12-18 11:44:56 +0530 | [diff] [blame] | 18877 | unsigned long rc; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 18878 | tSirUpdateIE updateIE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18879 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 18880 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18881 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 18882 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18883 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18884 | return -EINVAL; |
| 18885 | } |
| 18886 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 18887 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 18888 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 18889 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 18890 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 18891 | TRACE_CODE_HDD_CFG80211_LEAVE_IBSS, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18892 | adapter->vdev_id, eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 18893 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18894 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 18895 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18896 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18897 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18898 | hdd_debug("Device_mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 18899 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18900 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18901 | roam_profile = hdd_roam_profile(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18902 | |
| 18903 | /* Issue disconnect only if interface type is set to IBSS */ |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 18904 | if (eCSR_BSS_TYPE_START_IBSS != roam_profile->BSSType) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18905 | hdd_err("BSS Type is not set to IBSS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18906 | return -EINVAL; |
| 18907 | } |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 18908 | /* Clearing add IE of beacon */ |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 18909 | qdf_mem_copy(updateIE.bssid.bytes, adapter->mac_addr.bytes, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 18910 | sizeof(tSirMacAddr)); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18911 | updateIE.smeSessionId = adapter->vdev_id; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 18912 | updateIE.ieBufferlength = 0; |
| 18913 | updateIE.pAdditionIEBuffer = NULL; |
| 18914 | updateIE.append = true; |
| 18915 | updateIE.notify = true; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18916 | mac_handle = hdd_ctx->mac_handle; |
| 18917 | if (sme_update_add_ie(mac_handle, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 18918 | &updateIE, |
| 18919 | eUPDATE_IE_PROBE_BCN) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18920 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 18921 | } |
| 18922 | |
| 18923 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18924 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18925 | |
| 18926 | /* Issue Disconnect request */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18927 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18928 | status = sme_roam_disconnect(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 18929 | adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18930 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 18931 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18932 | hdd_err("sme_roam_disconnect failed status: %d", |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 18933 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18934 | return -EAGAIN; |
| 18935 | } |
Chandrasekaran, Manishekar | 12a818a | 2015-12-18 11:44:56 +0530 | [diff] [blame] | 18936 | |
| 18937 | /* wait for mc thread to cleanup and then return to upper stack |
| 18938 | * so by the time upper layer calls the change interface, we are |
| 18939 | * all set to proceed further |
| 18940 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18941 | rc = wait_for_completion_timeout(&adapter->disconnect_comp_var, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 18942 | msecs_to_jiffies(SME_DISCONNECT_TIMEOUT)); |
Chandrasekaran, Manishekar | 12a818a | 2015-12-18 11:44:56 +0530 | [diff] [blame] | 18943 | if (!rc) { |
| 18944 | hdd_err("Failed to disconnect, timed out"); |
| 18945 | return -ETIMEDOUT; |
| 18946 | } |
| 18947 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 18948 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18949 | return 0; |
| 18950 | } |
| 18951 | |
| 18952 | /** |
| 18953 | * wlan_hdd_cfg80211_leave_ibss() - leave ibss |
| 18954 | * @wiphy: Pointer to wiphy |
| 18955 | * @dev: Pointer to network device |
| 18956 | * |
| 18957 | * This function is used to leave an IBSS network |
| 18958 | * |
| 18959 | * Return: 0 for success, non-zero for failure |
| 18960 | */ |
| 18961 | static int wlan_hdd_cfg80211_leave_ibss(struct wiphy *wiphy, |
| 18962 | struct net_device *dev) |
| 18963 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18964 | int errno; |
| 18965 | struct osif_vdev_sync *vdev_sync; |
| 18966 | |
| 18967 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 18968 | if (errno) |
| 18969 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18970 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18971 | errno = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18972 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 18973 | osif_vdev_sync_op_stop(vdev_sync); |
| 18974 | |
| 18975 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18976 | } |
| 18977 | |
| 18978 | /** |
| 18979 | * __wlan_hdd_cfg80211_set_wiphy_params() - set wiphy parameters |
| 18980 | * @wiphy: Pointer to wiphy |
| 18981 | * @changed: Parameters changed |
| 18982 | * |
| 18983 | * This function is used to set the phy parameters. RTS Threshold/FRAG |
| 18984 | * Threshold/Retry Count etc. |
| 18985 | * |
| 18986 | * Return: 0 for success, non-zero for failure |
| 18987 | */ |
| 18988 | static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
| 18989 | u32 changed) |
| 18990 | { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18991 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18992 | int status; |
| 18993 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 18994 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18995 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 18996 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 18997 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18998 | return -EINVAL; |
| 18999 | } |
| 19000 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 19001 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 19002 | TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS, |
| 19003 | NO_SESSION, wiphy->rts_threshold); |
| 19004 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19005 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19006 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19007 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19008 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19009 | |
| 19010 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
| 19011 | u32 rts_threshold = (wiphy->rts_threshold == -1) ? |
Harprit Chhabada | bec6de4 | 2018-09-10 10:21:15 -0700 | [diff] [blame] | 19012 | cfg_max(CFG_RTS_THRESHOLD) : |
| 19013 | wiphy->rts_threshold; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19014 | |
Harprit Chhabada | bec6de4 | 2018-09-10 10:21:15 -0700 | [diff] [blame] | 19015 | if ((cfg_min(CFG_RTS_THRESHOLD) > rts_threshold) || |
| 19016 | (cfg_max(CFG_RTS_THRESHOLD) < rts_threshold)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19017 | hdd_err("Invalid RTS Threshold value: %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19018 | rts_threshold); |
| 19019 | return -EINVAL; |
| 19020 | } |
| 19021 | |
Harprit Chhabada | bec6de4 | 2018-09-10 10:21:15 -0700 | [diff] [blame] | 19022 | if (0 != ucfg_mlme_set_rts_threshold(hdd_ctx->psoc, |
| 19023 | rts_threshold)) { |
| 19024 | hdd_err("mlme_set_rts_threshold failed for val %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19025 | rts_threshold); |
| 19026 | return -EIO; |
| 19027 | } |
| 19028 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19029 | hdd_debug("set rts threshold %u", rts_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19030 | } |
| 19031 | |
| 19032 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
| 19033 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
Harprit Chhabada | bec6de4 | 2018-09-10 10:21:15 -0700 | [diff] [blame] | 19034 | cfg_max(CFG_FRAG_THRESHOLD) : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19035 | wiphy->frag_threshold; |
| 19036 | |
Harprit Chhabada | bec6de4 | 2018-09-10 10:21:15 -0700 | [diff] [blame] | 19037 | if ((cfg_min(CFG_FRAG_THRESHOLD) > frag_threshold) || |
| 19038 | (cfg_max(CFG_FRAG_THRESHOLD) < frag_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19039 | hdd_err("Invalid frag_threshold value %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19040 | frag_threshold); |
| 19041 | return -EINVAL; |
| 19042 | } |
| 19043 | |
Harprit Chhabada | bec6de4 | 2018-09-10 10:21:15 -0700 | [diff] [blame] | 19044 | if (0 != ucfg_mlme_set_frag_threshold(hdd_ctx->psoc, |
| 19045 | frag_threshold)) { |
| 19046 | hdd_err("mlme_set_frag_threshold failed for val %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19047 | frag_threshold); |
| 19048 | return -EIO; |
| 19049 | } |
| 19050 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19051 | hdd_debug("set frag threshold %hu", frag_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19052 | } |
| 19053 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 19054 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19055 | return 0; |
| 19056 | } |
| 19057 | |
| 19058 | /** |
| 19059 | * wlan_hdd_cfg80211_set_wiphy_params() - set wiphy parameters |
| 19060 | * @wiphy: Pointer to wiphy |
| 19061 | * @changed: Parameters changed |
| 19062 | * |
| 19063 | * Return: 0 for success, non-zero for failure |
| 19064 | */ |
| 19065 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 19066 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 19067 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 19068 | int errno; |
Arunk Khandavalli | 447837f | 2018-11-08 14:32:53 +0530 | [diff] [blame] | 19069 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 19070 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 19071 | if (errno) |
| 19072 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19073 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 19074 | errno = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19075 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 19076 | osif_psoc_sync_op_stop(psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 19077 | |
| 19078 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19079 | } |
| 19080 | |
| 19081 | /** |
| 19082 | * __wlan_hdd_set_default_mgmt_key() - dummy implementation of set default mgmt |
| 19083 | * key |
| 19084 | * @wiphy: Pointer to wiphy |
| 19085 | * @dev: Pointer to network device |
| 19086 | * @key_index: Key index |
| 19087 | * |
| 19088 | * Return: 0 |
| 19089 | */ |
| 19090 | static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 19091 | struct net_device *netdev, |
| 19092 | u8 key_index) |
| 19093 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19094 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19095 | return 0; |
| 19096 | } |
| 19097 | |
| 19098 | /** |
| 19099 | * wlan_hdd_set_default_mgmt_key() - SSR wrapper for |
| 19100 | * wlan_hdd_set_default_mgmt_key |
| 19101 | * @wiphy: pointer to wiphy |
| 19102 | * @netdev: pointer to net_device structure |
| 19103 | * @key_index: key index |
| 19104 | * |
| 19105 | * Return: 0 on success, error number on failure |
| 19106 | */ |
| 19107 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 19108 | struct net_device *netdev, |
| 19109 | u8 key_index) |
| 19110 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19111 | int errno; |
| 19112 | struct osif_vdev_sync *vdev_sync; |
| 19113 | |
| 19114 | errno = osif_vdev_sync_op_start(netdev, &vdev_sync); |
| 19115 | if (errno) |
| 19116 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19117 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19118 | errno = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19119 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19120 | osif_vdev_sync_op_stop(vdev_sync); |
| 19121 | |
| 19122 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19123 | } |
| 19124 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19125 | /** |
| 19126 | * __wlan_hdd_set_txq_params() - dummy implementation of set tx queue params |
| 19127 | * @wiphy: Pointer to wiphy |
| 19128 | * @dev: Pointer to network device |
| 19129 | * @params: Pointer to tx queue parameters |
| 19130 | * |
| 19131 | * Return: 0 |
| 19132 | */ |
| 19133 | static int __wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 19134 | struct net_device *dev, |
| 19135 | struct ieee80211_txq_params *params) |
| 19136 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19137 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19138 | return 0; |
| 19139 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19140 | |
| 19141 | /** |
| 19142 | * wlan_hdd_set_txq_params() - SSR wrapper for wlan_hdd_set_txq_params |
| 19143 | * @wiphy: pointer to wiphy |
| 19144 | * @netdev: pointer to net_device structure |
| 19145 | * @params: pointer to ieee80211_txq_params |
| 19146 | * |
| 19147 | * Return: 0 on success, error number on failure |
| 19148 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19149 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 19150 | struct net_device *dev, |
| 19151 | struct ieee80211_txq_params *params) |
| 19152 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19153 | int errno; |
| 19154 | struct osif_vdev_sync *vdev_sync; |
| 19155 | |
| 19156 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 19157 | if (errno) |
| 19158 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19159 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19160 | errno = __wlan_hdd_set_txq_params(wiphy, dev, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19161 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19162 | osif_vdev_sync_op_stop(vdev_sync); |
| 19163 | |
| 19164 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19165 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19166 | |
| 19167 | /** |
| 19168 | * __wlan_hdd_cfg80211_del_station() - delete station v2 |
| 19169 | * @wiphy: Pointer to wiphy |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 19170 | * @dev: Underlying net device |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19171 | * @param: Pointer to delete station parameter |
| 19172 | * |
| 19173 | * Return: 0 for success, non-zero for failure |
| 19174 | */ |
| 19175 | static |
| 19176 | int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 19177 | struct net_device *dev, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 19178 | struct csr_del_sta_params *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19179 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19180 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19181 | struct hdd_context *hdd_ctx; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 19182 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 19183 | struct hdd_hostapd_state *hapd_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19184 | int status; |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 19185 | uint8_t sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19186 | uint8_t *mac; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19187 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19188 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19189 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19190 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19191 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19192 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19193 | return -EINVAL; |
| 19194 | } |
| 19195 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 19196 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19197 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19198 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 19199 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 19200 | TRACE_CODE_HDD_CFG80211_DEL_STA, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19201 | adapter->vdev_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19202 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19203 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19204 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19205 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19206 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19207 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19208 | |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 19209 | mac = (uint8_t *) param->peerMacAddr.bytes; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19210 | mac_handle = hdd_ctx->mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19211 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19212 | if ((QDF_SAP_MODE == adapter->device_mode) || |
| 19213 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19214 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19215 | hapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19216 | if (!hapd_state) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19217 | hdd_err("Hostapd State is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19218 | return 0; |
| 19219 | } |
| 19220 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 19221 | if (qdf_is_macaddr_broadcast((struct qdf_mac_addr *) mac)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19222 | uint16_t i; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 19223 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19224 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 19225 | if ((adapter->sta_info[i].in_use) && |
| 19226 | (!adapter->sta_info[i]. |
Jeff Johnson | e4f5d93 | 2017-10-21 13:21:15 -0700 | [diff] [blame] | 19227 | is_deauth_in_progress)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 19228 | qdf_mem_copy( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19229 | mac, |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 19230 | adapter->sta_info[i]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 19231 | sta_mac.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19232 | QDF_MAC_ADDR_SIZE); |
Yun Park | a4bb37c | 2017-12-08 16:14:22 -0800 | [diff] [blame] | 19233 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19234 | hdd_debug("Delete STA with MAC::" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19235 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19236 | MAC_ADDR_ARRAY(mac)); |
| 19237 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19238 | if (hdd_ctx->dev_dfs_cac_status == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19239 | DFS_CAC_IN_PROGRESS) |
| 19240 | goto fn_end; |
| 19241 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 19242 | qdf_event_reset(&hapd_state->qdf_sta_disassoc_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 19243 | qdf_status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19244 | hdd_softap_sta_deauth(adapter, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 19245 | param); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 19246 | if (QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 19247 | adapter->sta_info[i]. |
Jeff Johnson | e4f5d93 | 2017-10-21 13:21:15 -0700 | [diff] [blame] | 19248 | is_deauth_in_progress = true; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 19249 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 19250 | qdf_wait_for_event_completion( |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 19251 | &hapd_state-> |
| 19252 | qdf_sta_disassoc_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 19253 | SME_PEER_DISCONNECT_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 19254 | if (!QDF_IS_STATUS_SUCCESS( |
| 19255 | qdf_status)) |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19256 | hdd_warn("Deauth wait time expired"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19257 | } |
| 19258 | } |
| 19259 | } |
| 19260 | } else { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 19261 | qdf_status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19262 | hdd_softap_get_sta_id(adapter, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19263 | (struct qdf_mac_addr *) mac, |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 19264 | &sta_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 19265 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19266 | hdd_debug("Skip DEL STA as this is not used::" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19267 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19268 | MAC_ADDR_ARRAY(mac)); |
| 19269 | return -ENOENT; |
| 19270 | } |
| 19271 | |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 19272 | if (adapter->sta_info[sta_id].is_deauth_in_progress == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19273 | true) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19274 | hdd_debug("Skip DEL STA as deauth is in progress::" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19275 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19276 | MAC_ADDR_ARRAY(mac)); |
| 19277 | return -ENOENT; |
| 19278 | } |
| 19279 | |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 19280 | adapter->sta_info[sta_id].is_deauth_in_progress = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19281 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19282 | hdd_debug("Delete STA with MAC::" MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19283 | MAC_ADDR_ARRAY(mac)); |
| 19284 | |
| 19285 | /* Case: SAP in ACS selected DFS ch and client connected |
| 19286 | * Now Radar detected. Then if random channel is another |
| 19287 | * DFS ch then new CAC is initiated and no TX allowed. |
| 19288 | * So do not send any mgmt frames as it will timeout |
| 19289 | * during CAC. |
| 19290 | */ |
| 19291 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19292 | if (hdd_ctx->dev_dfs_cac_status == DFS_CAC_IN_PROGRESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19293 | goto fn_end; |
| 19294 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 19295 | qdf_event_reset(&hapd_state->qdf_sta_disassoc_event); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19296 | sme_send_disassoc_req_frame(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19297 | adapter->vdev_id, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 19298 | (uint8_t *)¶m->peerMacAddr, |
| 19299 | param->reason_code, 0); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19300 | qdf_status = hdd_softap_sta_deauth(adapter, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 19301 | param); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 19302 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 19303 | adapter->sta_info[sta_id].is_deauth_in_progress = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19304 | false; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19305 | hdd_debug("STA removal failed for ::" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19306 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19307 | MAC_ADDR_ARRAY(mac)); |
| 19308 | return -ENOENT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19309 | } |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 19310 | qdf_status = qdf_wait_for_event_completion( |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 19311 | &hapd_state-> |
| 19312 | qdf_sta_disassoc_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 19313 | SME_PEER_DISCONNECT_TIMEOUT); |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 19314 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 19315 | hdd_warn("Deauth wait time expired"); |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 19316 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19317 | } |
| 19318 | } |
| 19319 | |
| 19320 | fn_end: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 19321 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19322 | return 0; |
| 19323 | } |
| 19324 | |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 19325 | #if defined(USE_CFG80211_DEL_STA_V2) |
| 19326 | /** |
| 19327 | * wlan_hdd_del_station() - delete station wrapper |
| 19328 | * @adapter: pointer to the hdd adapter |
| 19329 | * |
| 19330 | * Return: None |
| 19331 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 19332 | void wlan_hdd_del_station(struct hdd_adapter *adapter) |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 19333 | { |
| 19334 | struct station_del_parameters del_sta; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 19335 | |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 19336 | del_sta.mac = NULL; |
| 19337 | del_sta.subtype = SIR_MAC_MGMT_DEAUTH >> 4; |
| 19338 | del_sta.reason_code = eCsrForcedDeauthSta; |
| 19339 | |
| 19340 | wlan_hdd_cfg80211_del_station(adapter->wdev.wiphy, adapter->dev, |
| 19341 | &del_sta); |
| 19342 | } |
| 19343 | #else |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 19344 | void wlan_hdd_del_station(struct hdd_adapter *adapter) |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 19345 | { |
| 19346 | wlan_hdd_cfg80211_del_station(adapter->wdev.wiphy, adapter->dev, NULL); |
| 19347 | } |
| 19348 | #endif |
| 19349 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19350 | /** |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19351 | * wlan_hdd_cfg80211_del_station() - delete station entry handler |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19352 | * @wiphy: Pointer to wiphy |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19353 | * @dev: net_device to operate against |
| 19354 | * @mac: binary mac address |
| 19355 | * @reason_code: reason for the deauthorization/disassociation |
| 19356 | * @subtype: management frame subtype to indicate removal |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19357 | * |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19358 | * Return: Errno |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19359 | */ |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19360 | static int _wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 19361 | struct net_device *dev, |
| 19362 | const uint8_t *mac, |
| 19363 | uint16_t reason_code, |
| 19364 | uint8_t subtype) |
| 19365 | { |
| 19366 | int errno; |
| 19367 | struct csr_del_sta_params delStaParams; |
| 19368 | struct osif_vdev_sync *vdev_sync; |
| 19369 | |
| 19370 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 19371 | if (errno) |
| 19372 | return errno; |
| 19373 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19374 | wlansap_populate_del_sta_params(mac, reason_code, subtype, |
| 19375 | &delStaParams); |
| 19376 | errno = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams); |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19377 | |
| 19378 | osif_vdev_sync_op_stop(vdev_sync); |
| 19379 | |
| 19380 | return errno; |
| 19381 | } |
| 19382 | |
| 19383 | #ifdef USE_CFG80211_DEL_STA_V2 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19384 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 19385 | struct net_device *dev, |
| 19386 | struct station_del_parameters *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19387 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19388 | if (!param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19389 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19390 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19391 | return _wlan_hdd_cfg80211_del_station(wiphy, dev, param->mac, |
| 19392 | param->reason_code, |
| 19393 | param->subtype); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19394 | } |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19395 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 19396 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, struct net_device *dev, |
| 19397 | const uint8_t *mac) |
| 19398 | { |
| 19399 | uint16_t reason = eSIR_MAC_DEAUTH_LEAVING_BSS_REASON; |
| 19400 | uint8_t subtype = SIR_MAC_MGMT_DEAUTH >> 4; |
| 19401 | |
| 19402 | return _wlan_hdd_cfg80211_del_station(wiphy, dev, mac, reason, subtype); |
| 19403 | } |
| 19404 | #else |
| 19405 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, struct net_device *dev, |
| 19406 | uint8_t *mac) |
| 19407 | { |
| 19408 | uint16_t reason = eSIR_MAC_DEAUTH_LEAVING_BSS_REASON; |
| 19409 | uint8_t subtype = SIR_MAC_MGMT_DEAUTH >> 4; |
| 19410 | |
| 19411 | return _wlan_hdd_cfg80211_del_station(wiphy, dev, mac, reason, subtype); |
| 19412 | } |
| 19413 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19414 | |
| 19415 | /** |
| 19416 | * __wlan_hdd_cfg80211_add_station() - add station |
| 19417 | * @wiphy: Pointer to wiphy |
| 19418 | * @mac: Pointer to station mac address |
| 19419 | * @pmksa: Pointer to add station parameter |
| 19420 | * |
| 19421 | * Return: 0 for success, non-zero for failure |
| 19422 | */ |
| 19423 | static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 19424 | struct net_device *dev, |
| 19425 | const uint8_t *mac, |
| 19426 | struct station_parameters *params) |
| 19427 | { |
| 19428 | int status = -EPERM; |
| 19429 | #ifdef FEATURE_WLAN_TDLS |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19430 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19431 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19432 | u32 mask, set; |
| 19433 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19434 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19435 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19436 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19437 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19438 | return -EINVAL; |
| 19439 | } |
| 19440 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 19441 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19442 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19443 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 19444 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 19445 | TRACE_CODE_HDD_CFG80211_ADD_STA, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19446 | adapter->vdev_id, params->listen_interval); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19447 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19448 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19449 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19450 | |
| 19451 | mask = params->sta_flags_mask; |
| 19452 | |
| 19453 | set = params->sta_flags_set; |
| 19454 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19455 | hdd_debug("mask 0x%x set 0x%x " MAC_ADDRESS_STR, mask, set, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19456 | MAC_ADDR_ARRAY(mac)); |
| 19457 | |
| 19458 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 19459 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 19460 | struct wlan_objmgr_vdev *vdev; |
| 19461 | |
| 19462 | vdev = hdd_objmgr_get_vdev(adapter); |
| 19463 | if (vdev) { |
| 19464 | status = wlan_cfg80211_tdls_add_peer(vdev, |
| 19465 | mac); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 19466 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 19467 | } |
| 19468 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19469 | } |
| 19470 | #endif |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 19471 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19472 | return status; |
| 19473 | } |
| 19474 | |
| 19475 | /** |
| 19476 | * wlan_hdd_cfg80211_add_station() - add station |
| 19477 | * @wiphy: Pointer to wiphy |
| 19478 | * @mac: Pointer to station mac address |
| 19479 | * @pmksa: Pointer to add station parameter |
| 19480 | * |
| 19481 | * Return: 0 for success, non-zero for failure |
| 19482 | */ |
| 19483 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 19484 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 19485 | struct net_device *dev, |
| 19486 | const uint8_t *mac, |
| 19487 | struct station_parameters *params) |
| 19488 | #else |
| 19489 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 19490 | struct net_device *dev, uint8_t *mac, |
| 19491 | struct station_parameters *params) |
| 19492 | #endif |
| 19493 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19494 | int errno; |
| 19495 | struct osif_vdev_sync *vdev_sync; |
| 19496 | |
| 19497 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 19498 | if (errno) |
| 19499 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19500 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19501 | errno = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19502 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19503 | osif_vdev_sync_op_stop(vdev_sync); |
| 19504 | |
| 19505 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19506 | } |
| 19507 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 19508 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 19509 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19510 | /* |
| 19511 | * wlan_hdd_is_pmksa_valid: API to validate pmksa |
| 19512 | * @pmksa: pointer to cfg80211_pmksa structure |
| 19513 | * |
| 19514 | * Return: True if valid else false |
| 19515 | */ |
| 19516 | static inline bool wlan_hdd_is_pmksa_valid(struct cfg80211_pmksa *pmksa) |
| 19517 | { |
| 19518 | if (!pmksa->bssid) { |
Vignesh Viswanathan | fa90d62 | 2017-12-22 13:13:26 +0530 | [diff] [blame] | 19519 | hdd_warn("bssid (%pK) is NULL", |
| 19520 | pmksa->bssid); |
| 19521 | if (!pmksa->ssid || !pmksa->cache_id) { |
| 19522 | hdd_err("either ssid (%pK) or cache_id (%pK) are NULL", |
| 19523 | pmksa->ssid, pmksa->cache_id); |
| 19524 | return false; |
| 19525 | } |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19526 | } |
| 19527 | return true; |
| 19528 | } |
| 19529 | |
| 19530 | /* |
| 19531 | * hdd_fill_pmksa_info: API to update tPmkidCacheInfo from cfg80211_pmksa |
gaurank kathpalia | 99d06c1 | 2018-05-16 16:28:35 +0530 | [diff] [blame] | 19532 | * @adapter: Pointer to hdd adapter |
| 19533 | * @pmk_cache: pmk that needs to be udated |
| 19534 | * @pmksa: pmk from supplicant |
| 19535 | * @is_delete: Bool to decide set or delete PMK |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19536 | * Return: None |
| 19537 | */ |
gaurank kathpalia | 99d06c1 | 2018-05-16 16:28:35 +0530 | [diff] [blame] | 19538 | static void hdd_fill_pmksa_info(struct hdd_adapter *adapter, |
| 19539 | tPmkidCacheInfo *pmk_cache, |
| 19540 | struct cfg80211_pmksa *pmksa, bool is_delete) |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19541 | { |
| 19542 | if (pmksa->bssid) { |
| 19543 | hdd_debug("%s PMKSA for " MAC_ADDRESS_STR, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 19544 | is_delete ? "Delete" : "Set", |
| 19545 | MAC_ADDR_ARRAY(pmksa->bssid)); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19546 | qdf_mem_copy(pmk_cache->BSSID.bytes, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 19547 | pmksa->bssid, QDF_MAC_ADDR_SIZE); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19548 | } else { |
Jeff Johnson | 9c749db | 2018-05-07 12:50:46 -0700 | [diff] [blame] | 19549 | qdf_mem_copy(pmk_cache->ssid, pmksa->ssid, pmksa->ssid_len); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 19550 | qdf_mem_copy(pmk_cache->cache_id, pmksa->cache_id, |
| 19551 | CACHE_ID_LEN); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19552 | pmk_cache->ssid_len = pmksa->ssid_len; |
| 19553 | hdd_debug("%s PMKSA for ssid %*.*s cache_id %x %x", |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 19554 | is_delete ? "Delete" : "Set", |
| 19555 | pmk_cache->ssid_len, pmk_cache->ssid_len, |
| 19556 | pmk_cache->ssid, pmk_cache->cache_id[0], |
| 19557 | pmk_cache->cache_id[1]); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19558 | } |
| 19559 | |
| 19560 | if (is_delete) |
| 19561 | return; |
| 19562 | |
| 19563 | qdf_mem_copy(pmk_cache->PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE); |
| 19564 | if (pmksa->pmk_len && (pmksa->pmk_len <= CSR_RSN_MAX_PMK_LEN)) { |
| 19565 | qdf_mem_copy(pmk_cache->pmk, pmksa->pmk, pmksa->pmk_len); |
| 19566 | pmk_cache->pmk_len = pmksa->pmk_len; |
| 19567 | } else |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 19568 | hdd_debug("pmk len is %zu", pmksa->pmk_len); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19569 | } |
| 19570 | #else |
| 19571 | /* |
| 19572 | * wlan_hdd_is_pmksa_valid: API to validate pmksa |
| 19573 | * @pmksa: pointer to cfg80211_pmksa structure |
| 19574 | * |
| 19575 | * Return: True if valid else false |
| 19576 | */ |
| 19577 | static inline bool wlan_hdd_is_pmksa_valid(struct cfg80211_pmksa *pmksa) |
| 19578 | { |
| 19579 | if (!pmksa->bssid) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 19580 | hdd_err("both bssid is NULL %pK", pmksa->bssid); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19581 | return false; |
| 19582 | } |
| 19583 | return true; |
| 19584 | } |
| 19585 | |
| 19586 | /* |
| 19587 | * hdd_fill_pmksa_info: API to update tPmkidCacheInfo from cfg80211_pmksa |
gaurank kathpalia | 99d06c1 | 2018-05-16 16:28:35 +0530 | [diff] [blame] | 19588 | * @adapter: Pointer to hdd adapter |
| 19589 | * @pmk_cache: pmk which needs to be updated |
| 19590 | * @pmksa: pmk from supplicant |
| 19591 | * @is_delete: Bool to decide whether to set or delete PMK |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19592 | * |
| 19593 | * Return: None |
| 19594 | */ |
gaurank kathpalia | 99d06c1 | 2018-05-16 16:28:35 +0530 | [diff] [blame] | 19595 | static void hdd_fill_pmksa_info(struct hdd_adapter *adapter, |
| 19596 | tPmkidCacheInfo *pmk_cache, |
| 19597 | struct cfg80211_pmksa *pmksa, bool is_delete) |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19598 | { |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19599 | mac_handle_t mac_handle; |
Srinivas Girigowda | 5033534 | 2018-09-07 15:21:01 -0700 | [diff] [blame] | 19600 | |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19601 | hdd_debug("%s PMKSA for " MAC_ADDRESS_STR, is_delete ? "Delete" : "Set", |
| 19602 | MAC_ADDR_ARRAY(pmksa->bssid)); |
| 19603 | qdf_mem_copy(pmk_cache->BSSID.bytes, |
| 19604 | pmksa->bssid, QDF_MAC_ADDR_SIZE); |
| 19605 | |
| 19606 | if (is_delete) |
| 19607 | return; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19608 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19609 | sme_get_pmk_info(mac_handle, adapter->vdev_id, pmk_cache); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19610 | qdf_mem_copy(pmk_cache->PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE); |
| 19611 | } |
| 19612 | #endif |
| 19613 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19614 | /** |
| 19615 | * __wlan_hdd_cfg80211_set_pmksa() - set pmksa |
| 19616 | * @wiphy: Pointer to wiphy |
| 19617 | * @dev: Pointer to network device |
| 19618 | * @pmksa: Pointer to set pmksa parameter |
| 19619 | * |
| 19620 | * Return: 0 for success, non-zero for failure |
| 19621 | */ |
| 19622 | static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, |
| 19623 | struct net_device *dev, |
| 19624 | struct cfg80211_pmksa *pmksa) |
| 19625 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19626 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 19627 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19628 | mac_handle_t mac_handle; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 19629 | QDF_STATUS result = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19630 | int status; |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19631 | tPmkidCacheInfo pmk_cache; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19632 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19633 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19634 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19635 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19636 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19637 | return -EINVAL; |
| 19638 | } |
| 19639 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 19640 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19641 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19642 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19643 | if (!pmksa) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19644 | hdd_err("pmksa is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19645 | return -EINVAL; |
| 19646 | } |
| 19647 | |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19648 | if (!pmksa->pmkid) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 19649 | hdd_err("pmksa->pmkid(%pK) is NULL", |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19650 | pmksa->pmkid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19651 | return -EINVAL; |
| 19652 | } |
| 19653 | |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19654 | if (!wlan_hdd_is_pmksa_valid(pmksa)) |
| 19655 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19656 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19657 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19658 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19659 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19660 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19661 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19662 | mac_handle = hdd_ctx->mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19663 | |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19664 | qdf_mem_zero(&pmk_cache, sizeof(pmk_cache)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19665 | |
gaurank kathpalia | 99d06c1 | 2018-05-16 16:28:35 +0530 | [diff] [blame] | 19666 | hdd_fill_pmksa_info(adapter, &pmk_cache, pmksa, false); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19667 | |
| 19668 | /* |
| 19669 | * Add to the PMKSA Cache in CSR |
| 19670 | * PMKSA cache will be having following |
| 19671 | * 1. pmkid id |
| 19672 | * 2. pmk |
| 19673 | * 3. bssid or cache identifier |
| 19674 | */ |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19675 | result = sme_roam_set_pmkid_cache(mac_handle, adapter->vdev_id, |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19676 | &pmk_cache, 1, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19677 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 19678 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 19679 | TRACE_CODE_HDD_CFG80211_SET_PMKSA, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19680 | adapter->vdev_id, result); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19681 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19682 | sme_set_del_pmkid_cache(mac_handle, adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19683 | &pmk_cache, true); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 19684 | |
Ashish Kumar Dhanotiya | 3651083 | 2019-02-20 22:13:25 +0530 | [diff] [blame] | 19685 | qdf_mem_zero(&pmk_cache, sizeof(pmk_cache)); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 19686 | hdd_exit(); |
Ashish Kumar Dhanotiya | 3651083 | 2019-02-20 22:13:25 +0530 | [diff] [blame] | 19687 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 19688 | return QDF_IS_STATUS_SUCCESS(result) ? 0 : -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19689 | } |
| 19690 | |
| 19691 | /** |
| 19692 | * wlan_hdd_cfg80211_set_pmksa() - set pmksa |
| 19693 | * @wiphy: Pointer to wiphy |
| 19694 | * @dev: Pointer to network device |
| 19695 | * @pmksa: Pointer to set pmksa parameter |
| 19696 | * |
| 19697 | * Return: 0 for success, non-zero for failure |
| 19698 | */ |
| 19699 | static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, |
| 19700 | struct net_device *dev, |
| 19701 | struct cfg80211_pmksa *pmksa) |
| 19702 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19703 | int errno; |
| 19704 | struct osif_vdev_sync *vdev_sync; |
| 19705 | |
| 19706 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 19707 | if (errno) |
| 19708 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19709 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19710 | errno = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19711 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19712 | osif_vdev_sync_op_stop(vdev_sync); |
| 19713 | |
| 19714 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19715 | } |
| 19716 | |
| 19717 | /** |
| 19718 | * __wlan_hdd_cfg80211_del_pmksa() - delete pmksa |
| 19719 | * @wiphy: Pointer to wiphy |
| 19720 | * @dev: Pointer to network device |
| 19721 | * @pmksa: Pointer to pmksa parameter |
| 19722 | * |
| 19723 | * Return: 0 for success, non-zero for failure |
| 19724 | */ |
| 19725 | static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, |
| 19726 | struct net_device *dev, |
| 19727 | struct cfg80211_pmksa *pmksa) |
| 19728 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19729 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 19730 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19731 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19732 | int status = 0; |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19733 | tPmkidCacheInfo pmk_cache; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19734 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19735 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19736 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19737 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19738 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19739 | return -EINVAL; |
| 19740 | } |
| 19741 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 19742 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19743 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19744 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19745 | if (!pmksa) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19746 | hdd_err("pmksa is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19747 | return -EINVAL; |
| 19748 | } |
| 19749 | |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19750 | if (!wlan_hdd_is_pmksa_valid(pmksa)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19751 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19752 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19753 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19754 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19755 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19756 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19757 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19758 | mac_handle = hdd_ctx->mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19759 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 19760 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 19761 | TRACE_CODE_HDD_CFG80211_DEL_PMKSA, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19762 | adapter->vdev_id, 0); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19763 | |
| 19764 | qdf_mem_zero(&pmk_cache, sizeof(pmk_cache)); |
| 19765 | |
gaurank kathpalia | 99d06c1 | 2018-05-16 16:28:35 +0530 | [diff] [blame] | 19766 | hdd_fill_pmksa_info(adapter, &pmk_cache, pmksa, true); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 19767 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19768 | /* Delete the PMKID CSR cache */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 19769 | if (QDF_STATUS_SUCCESS != |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19770 | sme_roam_del_pmkid_from_cache(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19771 | adapter->vdev_id, &pmk_cache, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19772 | false)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19773 | hdd_err("Failed to delete PMKSA for " MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19774 | MAC_ADDR_ARRAY(pmksa->bssid)); |
| 19775 | status = -EINVAL; |
| 19776 | } |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 19777 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19778 | sme_set_del_pmkid_cache(mac_handle, adapter->vdev_id, &pmk_cache, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19779 | false); |
Ashish Kumar Dhanotiya | 3651083 | 2019-02-20 22:13:25 +0530 | [diff] [blame] | 19780 | qdf_mem_zero(&pmk_cache, sizeof(pmk_cache)); |
| 19781 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 19782 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19783 | return status; |
| 19784 | } |
| 19785 | |
| 19786 | /** |
| 19787 | * wlan_hdd_cfg80211_del_pmksa() - delete pmksa |
| 19788 | * @wiphy: Pointer to wiphy |
| 19789 | * @dev: Pointer to network device |
| 19790 | * @pmksa: Pointer to pmksa parameter |
| 19791 | * |
| 19792 | * Return: 0 for success, non-zero for failure |
| 19793 | */ |
| 19794 | static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, |
| 19795 | struct net_device *dev, |
| 19796 | struct cfg80211_pmksa *pmksa) |
| 19797 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19798 | int errno; |
| 19799 | struct osif_vdev_sync *vdev_sync; |
| 19800 | |
| 19801 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 19802 | if (errno) |
| 19803 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19804 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19805 | errno = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19806 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19807 | osif_vdev_sync_op_stop(vdev_sync); |
| 19808 | |
| 19809 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19810 | |
| 19811 | } |
| 19812 | |
| 19813 | /** |
| 19814 | * __wlan_hdd_cfg80211_flush_pmksa() - flush pmksa |
| 19815 | * @wiphy: Pointer to wiphy |
| 19816 | * @dev: Pointer to network device |
| 19817 | * |
| 19818 | * Return: 0 for success, non-zero for failure |
| 19819 | */ |
| 19820 | static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, |
| 19821 | struct net_device *dev) |
| 19822 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19823 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 19824 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19825 | mac_handle_t mac_handle; |
| 19826 | int errno; |
| 19827 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19828 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19829 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19830 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19831 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19832 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19833 | return -EINVAL; |
| 19834 | } |
| 19835 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 19836 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19837 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19838 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19839 | hdd_debug("Flushing PMKSA"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19840 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19841 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19842 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 19843 | if (errno) |
| 19844 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19845 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19846 | mac_handle = hdd_ctx->mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19847 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19848 | status = sme_roam_del_pmkid_from_cache(mac_handle, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19849 | adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19850 | NULL, true); |
| 19851 | if (QDF_IS_STATUS_ERROR(status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19852 | hdd_err("Cannot flush PMKIDCache"); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19853 | errno = -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19854 | } |
Vignesh Viswanathan | e8a26b2 | 2017-10-11 20:38:47 +0530 | [diff] [blame] | 19855 | |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19856 | sme_set_del_pmkid_cache(mac_handle, adapter->vdev_id, NULL, false); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 19857 | hdd_exit(); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19858 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19859 | } |
| 19860 | |
| 19861 | /** |
| 19862 | * wlan_hdd_cfg80211_flush_pmksa() - flush pmksa |
| 19863 | * @wiphy: Pointer to wiphy |
| 19864 | * @dev: Pointer to network device |
| 19865 | * |
| 19866 | * Return: 0 for success, non-zero for failure |
| 19867 | */ |
| 19868 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, |
| 19869 | struct net_device *dev) |
| 19870 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19871 | int errno; |
| 19872 | struct osif_vdev_sync *vdev_sync; |
| 19873 | |
| 19874 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 19875 | if (errno) |
| 19876 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19877 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19878 | errno = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19879 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19880 | osif_vdev_sync_op_stop(vdev_sync); |
| 19881 | |
| 19882 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19883 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19884 | |
Deepak Dhamdhere | 9f09e75 | 2016-01-09 23:17:25 -0800 | [diff] [blame] | 19885 | #if defined(KERNEL_SUPPORT_11R_CFG80211) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19886 | /** |
| 19887 | * __wlan_hdd_cfg80211_update_ft_ies() - update fast transition ies |
| 19888 | * @wiphy: Pointer to wiphy |
| 19889 | * @dev: Pointer to network device |
| 19890 | * @ftie: Pointer to fast transition ie parameter |
| 19891 | * |
| 19892 | * Return: 0 for success, non-zero for failure |
| 19893 | */ |
| 19894 | static int |
| 19895 | __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 19896 | struct net_device *dev, |
| 19897 | struct cfg80211_update_ft_ies_params *ftie) |
| 19898 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 19899 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19900 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19901 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19902 | int status; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19903 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19904 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19905 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19906 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19907 | status = wlan_hdd_validate_context(hdd_ctx); |
| 19908 | if (status) |
| 19909 | return status; |
| 19910 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19911 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19912 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19913 | return -EINVAL; |
| 19914 | } |
| 19915 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 19916 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19917 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19918 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 19919 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 19920 | TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES, |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 19921 | adapter->vdev_id, sta_ctx->conn_info.conn_state); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 19922 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19923 | /* Added for debug on reception of Re-assoc Req. */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 19924 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19925 | hdd_err("Called with Ie of length = %zu when not associated", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19926 | ftie->ie_len); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19927 | hdd_err("Should be Re-assoc Req IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19928 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19929 | hdd_debug("%s called with Ie of length = %zu", __func__, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19930 | ftie->ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19931 | |
| 19932 | /* Pass the received FT IEs to SME */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 19933 | mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 19934 | sme_set_ft_ies(mac_handle, adapter->vdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19935 | (const u8 *)ftie->ie, ftie->ie_len); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 19936 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19937 | return 0; |
| 19938 | } |
| 19939 | |
| 19940 | /** |
| 19941 | * wlan_hdd_cfg80211_update_ft_ies() - update fast transition ies |
| 19942 | * @wiphy: Pointer to wiphy |
| 19943 | * @dev: Pointer to network device |
| 19944 | * @ftie: Pointer to fast transition ie parameter |
| 19945 | * |
| 19946 | * Return: 0 for success, non-zero for failure |
| 19947 | */ |
| 19948 | static int |
| 19949 | wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 19950 | struct net_device *dev, |
| 19951 | struct cfg80211_update_ft_ies_params *ftie) |
| 19952 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19953 | int errno; |
| 19954 | struct osif_vdev_sync *vdev_sync; |
| 19955 | |
| 19956 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 19957 | if (errno) |
| 19958 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19959 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19960 | errno = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19961 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 19962 | osif_vdev_sync_op_stop(vdev_sync); |
| 19963 | |
| 19964 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19965 | } |
| 19966 | #endif |
| 19967 | |
Min Liu | 0daa098 | 2019-02-01 17:50:44 +0800 | [diff] [blame] | 19968 | #ifdef CFG80211_EXTERNAL_DH_UPDATE_SUPPORT |
| 19969 | /** |
| 19970 | * __wlan_hdd_cfg80211_update_owe_info() - update OWE info |
| 19971 | * @wiphy: Pointer to wiphy |
| 19972 | * @dev: Pointer to network device |
| 19973 | * @owe_info: Pointer to OWE info |
| 19974 | * |
| 19975 | * Return: 0 for success, non-zero for failure |
| 19976 | */ |
| 19977 | static int |
| 19978 | __wlan_hdd_cfg80211_update_owe_info(struct wiphy *wiphy, |
| 19979 | struct net_device *dev, |
| 19980 | struct cfg80211_update_owe_info *owe_info) |
| 19981 | { |
| 19982 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 19983 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 19984 | QDF_STATUS status; |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 19985 | int errno; |
Min Liu | 0daa098 | 2019-02-01 17:50:44 +0800 | [diff] [blame] | 19986 | |
| 19987 | hdd_enter_dev(dev); |
| 19988 | |
| 19989 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 19990 | if (errno) |
| 19991 | return errno; |
| 19992 | |
| 19993 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 19994 | hdd_err("Command not allowed in FTM mode"); |
| 19995 | return -EINVAL; |
| 19996 | } |
| 19997 | |
Jeff Johnson | a6b398d | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 19998 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) { |
| 19999 | hdd_err("invalid vdev id: %d", adapter->vdev_id); |
Min Liu | 0daa098 | 2019-02-01 17:50:44 +0800 | [diff] [blame] | 20000 | return -EINVAL; |
| 20001 | } |
| 20002 | |
| 20003 | hdd_debug("owe_status %d", owe_info->status); |
| 20004 | |
| 20005 | status = wlansap_update_owe_info(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 20006 | owe_info->bssid, owe_info->ie, |
| 20007 | owe_info->ie_len, owe_info->status); |
| 20008 | if (QDF_IS_STATUS_ERROR(status)) { |
| 20009 | hdd_err("Failed to update OWE info"); |
| 20010 | errno = qdf_status_to_os_return(status); |
| 20011 | } |
| 20012 | |
| 20013 | hdd_exit(); |
| 20014 | return errno; |
| 20015 | } |
| 20016 | |
| 20017 | /** |
| 20018 | * wlan_hdd_cfg80211_update_owe_info() - update OWE info |
| 20019 | * @wiphy: Pointer to wiphy |
| 20020 | * @dev: Pointer to network device |
| 20021 | * @owe_info: Pointer to OWE info |
| 20022 | * |
| 20023 | * Return: 0 for success, non-zero for failure |
| 20024 | */ |
| 20025 | static int |
| 20026 | wlan_hdd_cfg80211_update_owe_info(struct wiphy *wiphy, |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 20027 | struct net_device *net_dev, |
Min Liu | 0daa098 | 2019-02-01 17:50:44 +0800 | [diff] [blame] | 20028 | struct cfg80211_update_owe_info *owe_info) |
| 20029 | { |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 20030 | struct osif_vdev_sync *vdev_sync; |
| 20031 | int errno; |
Min Liu | 0daa098 | 2019-02-01 17:50:44 +0800 | [diff] [blame] | 20032 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 20033 | errno = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 20034 | if (errno) |
| 20035 | return errno; |
Min Liu | 0daa098 | 2019-02-01 17:50:44 +0800 | [diff] [blame] | 20036 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 20037 | errno = __wlan_hdd_cfg80211_update_owe_info(wiphy, net_dev, owe_info); |
| 20038 | |
| 20039 | osif_vdev_sync_op_stop(vdev_sync); |
| 20040 | |
| 20041 | return errno; |
Min Liu | 0daa098 | 2019-02-01 17:50:44 +0800 | [diff] [blame] | 20042 | } |
| 20043 | #endif |
| 20044 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 20045 | void wlan_hdd_cfg80211_update_replay_counter_cb( |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20046 | void *cb_ctx, struct pmo_gtk_rsp_params *gtk_rsp_param) |
| 20047 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20048 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20049 | struct hdd_adapter *adapter = (struct hdd_adapter *)cb_ctx; |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20050 | uint8_t temp_replay_counter[8]; |
| 20051 | int i; |
| 20052 | uint8_t *p; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20053 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20054 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20055 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20056 | if (!adapter) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20057 | hdd_err("HDD adapter is Null"); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20058 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20059 | } |
| 20060 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20061 | if (!gtk_rsp_param) { |
| 20062 | hdd_err("gtk_rsp_param is Null"); |
| 20063 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20064 | } |
| 20065 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20066 | if (gtk_rsp_param->status_flag != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20067 | hdd_err("wlan Failed to get replay counter value"); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20068 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20069 | } |
| 20070 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20071 | hdd_debug("updated replay counter: %llu from fwr", |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20072 | gtk_rsp_param->replay_counter); |
| 20073 | /* convert little to big endian since supplicant works on big endian */ |
| 20074 | p = (uint8_t *)>k_rsp_param->replay_counter; |
| 20075 | for (i = 0; i < 8; i++) |
| 20076 | temp_replay_counter[7 - i] = (uint8_t) p[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20077 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20078 | hdd_debug("gtk_rsp_param bssid %pM", gtk_rsp_param->bssid.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20079 | /* Update replay counter to NL */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20080 | cfg80211_gtk_rekey_notify(adapter->dev, |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20081 | gtk_rsp_param->bssid.bytes, |
| 20082 | temp_replay_counter, GFP_KERNEL); |
| 20083 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20084 | hdd_exit(); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20085 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20086 | } |
| 20087 | |
Wu Gao | a9d336b | 2018-05-30 14:48:04 +0800 | [diff] [blame] | 20088 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20089 | /** |
| 20090 | * wlan_hdd_copy_gtk_kek - Copy the KEK from GTK rekey data to GTK request |
| 20091 | * @gtk_req: Pointer to GTK request |
| 20092 | * @data: Pointer to rekey data |
| 20093 | * |
| 20094 | * Return: none |
| 20095 | */ |
| 20096 | #ifdef CFG80211_REKEY_DATA_KEK_LEN |
| 20097 | static |
| 20098 | void wlan_hdd_copy_gtk_kek(struct pmo_gtk_req *gtk_req, |
| 20099 | struct cfg80211_gtk_rekey_data *data) |
| 20100 | { |
| 20101 | qdf_mem_copy(gtk_req->kek, data->kek, data->kek_len); |
| 20102 | gtk_req->kek_len = data->kek_len; |
| 20103 | } |
| 20104 | #else |
| 20105 | static |
| 20106 | void wlan_hdd_copy_gtk_kek(struct pmo_gtk_req *gtk_req, |
| 20107 | struct cfg80211_gtk_rekey_data *data) |
| 20108 | { |
| 20109 | qdf_mem_copy(gtk_req->kek, data->kek, NL80211_KEK_LEN); |
| 20110 | gtk_req->kek_len = NL80211_KEK_LEN; |
| 20111 | } |
| 20112 | #endif |
| 20113 | |
| 20114 | /** |
| 20115 | * __wlan_hdd_cfg80211_set_rekey_data() - set rekey data |
| 20116 | * @wiphy: Pointer to wiphy |
| 20117 | * @dev: Pointer to network device |
| 20118 | * @data: Pointer to rekey data |
| 20119 | * |
| 20120 | * This function is used to offload GTK rekeying job to the firmware. |
| 20121 | * |
| 20122 | * Return: 0 for success, non-zero for failure |
| 20123 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 20124 | static |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20125 | int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20126 | struct net_device *dev, |
| 20127 | struct cfg80211_gtk_rekey_data *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20128 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20129 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20130 | int result, i; |
| 20131 | struct pmo_gtk_req *gtk_req = NULL; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20132 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20133 | uint8_t *buf; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 20134 | struct wlan_objmgr_vdev *vdev; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20135 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20136 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20137 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20138 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 20139 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20140 | hdd_err("Command not allowed in FTM mode"); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20141 | result = -EINVAL; |
| 20142 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20143 | } |
| 20144 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 20145 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) { |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20146 | result = -EINVAL; |
| 20147 | goto out; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 20148 | } |
| 20149 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 20150 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 20151 | TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 20152 | adapter->vdev_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20153 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20154 | result = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 20155 | if (0 != result) |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20156 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20157 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20158 | gtk_req = qdf_mem_malloc(sizeof(*gtk_req)); |
| 20159 | if (!gtk_req) { |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20160 | result = -ENOMEM; |
| 20161 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20162 | } |
| 20163 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20164 | /* convert big to little endian since driver work on little endian */ |
| 20165 | buf = (uint8_t *)>k_req->replay_counter; |
| 20166 | for (i = 0; i < 8; i++) |
| 20167 | buf[7 - i] = data->replay_ctr[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20168 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20169 | hdd_debug("current replay counter: %llu in user space", |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20170 | gtk_req->replay_counter); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20171 | |
| 20172 | wlan_hdd_copy_gtk_kek(gtk_req, data); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20173 | qdf_mem_copy(gtk_req->kck, data->kck, NL80211_KCK_LEN); |
gaurank kathpalia | 82a1b2b | 2018-07-10 16:49:10 +0530 | [diff] [blame] | 20174 | gtk_req->is_fils_connection = hdd_is_fils_connection(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 20175 | vdev = hdd_objmgr_get_vdev(adapter); |
| 20176 | if (!vdev) { |
| 20177 | result = -EINVAL; |
| 20178 | goto out; |
| 20179 | } |
| 20180 | status = ucfg_pmo_cache_gtk_offload_req(vdev, gtk_req); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 20181 | hdd_objmgr_put_vdev(vdev); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20182 | if (status != QDF_STATUS_SUCCESS) { |
| 20183 | hdd_err("Failed to cache GTK Offload"); |
| 20184 | result = qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20185 | } |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20186 | out: |
| 20187 | if (gtk_req) |
| 20188 | qdf_mem_free(gtk_req); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20189 | hdd_exit(); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 20190 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20191 | return result; |
| 20192 | } |
| 20193 | |
| 20194 | /** |
| 20195 | * wlan_hdd_cfg80211_set_rekey_data() - set rekey data |
| 20196 | * @wiphy: Pointer to wiphy |
| 20197 | * @dev: Pointer to network device |
| 20198 | * @data: Pointer to rekey data |
| 20199 | * |
| 20200 | * This function is used to offload GTK rekeying job to the firmware. |
| 20201 | * |
| 20202 | * Return: 0 for success, non-zero for failure |
| 20203 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 20204 | static |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20205 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, |
| 20206 | struct net_device *dev, |
| 20207 | struct cfg80211_gtk_rekey_data *data) |
| 20208 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20209 | int errno; |
| 20210 | struct osif_vdev_sync *vdev_sync; |
| 20211 | |
| 20212 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 20213 | if (errno) |
| 20214 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20215 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20216 | errno = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20217 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20218 | osif_vdev_sync_op_stop(vdev_sync); |
| 20219 | |
| 20220 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20221 | } |
Wu Gao | a9d336b | 2018-05-30 14:48:04 +0800 | [diff] [blame] | 20222 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20223 | |
| 20224 | /** |
| 20225 | * __wlan_hdd_cfg80211_set_mac_acl() - set access control policy |
| 20226 | * @wiphy: Pointer to wiphy |
| 20227 | * @dev: Pointer to network device |
| 20228 | * @param: Pointer to access control parameter |
| 20229 | * |
| 20230 | * Return: 0 for success, non-zero for failure |
| 20231 | */ |
| 20232 | static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 20233 | struct net_device *dev, |
| 20234 | const struct cfg80211_acl_data *params) |
| 20235 | { |
| 20236 | int i; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20237 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 5c19ade | 2017-10-04 09:52:12 -0700 | [diff] [blame] | 20238 | struct hdd_hostapd_state *hostapd_state; |
Jeff Johnson | 954903d | 2019-03-07 20:41:27 -0800 | [diff] [blame] | 20239 | tsap_config_t *config; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20240 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20241 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20242 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20243 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20244 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20245 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 20246 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20247 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20248 | return -EINVAL; |
| 20249 | } |
| 20250 | |
| 20251 | if (NULL == params) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20252 | hdd_err("params is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20253 | return -EINVAL; |
| 20254 | } |
| 20255 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20256 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20257 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20258 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 20259 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20260 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20261 | |
Jeff Johnson | 5c19ade | 2017-10-04 09:52:12 -0700 | [diff] [blame] | 20262 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20263 | |
Jeff Johnson | 5c19ade | 2017-10-04 09:52:12 -0700 | [diff] [blame] | 20264 | if (NULL == hostapd_state) { |
| 20265 | hdd_err("hostapd_state is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20266 | return -EINVAL; |
| 20267 | } |
| 20268 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20269 | hdd_debug("acl policy: %d num acl entries: %d", params->acl_policy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20270 | params->n_acl_entries); |
| 20271 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 20272 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 20273 | TRACE_CODE_HDD_CFG80211_SET_MAC_ACL, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 20274 | adapter->vdev_id, adapter->device_mode); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 20275 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20276 | if (QDF_SAP_MODE == adapter->device_mode) { |
Jeff Johnson | 954903d | 2019-03-07 20:41:27 -0800 | [diff] [blame] | 20277 | config = &adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20278 | |
| 20279 | /* default value */ |
Jeff Johnson | 954903d | 2019-03-07 20:41:27 -0800 | [diff] [blame] | 20280 | config->num_accept_mac = 0; |
| 20281 | config->num_deny_mac = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20282 | |
| 20283 | /** |
| 20284 | * access control policy |
| 20285 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 20286 | * listed in hostapd.deny file. |
| 20287 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 20288 | * listed in hostapd.accept file. |
| 20289 | */ |
| 20290 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) { |
Jeff Johnson | 954903d | 2019-03-07 20:41:27 -0800 | [diff] [blame] | 20291 | config->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20292 | } else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == |
| 20293 | params->acl_policy) { |
Jeff Johnson | 954903d | 2019-03-07 20:41:27 -0800 | [diff] [blame] | 20294 | config->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20295 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20296 | hdd_warn("Acl Policy : %d is not supported", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20297 | params->acl_policy); |
| 20298 | return -ENOTSUPP; |
| 20299 | } |
| 20300 | |
Jeff Johnson | 954903d | 2019-03-07 20:41:27 -0800 | [diff] [blame] | 20301 | if (eSAP_DENY_UNLESS_ACCEPTED == config->SapMacaddr_acl) { |
| 20302 | config->num_accept_mac = params->n_acl_entries; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20303 | for (i = 0; i < params->n_acl_entries; i++) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20304 | hdd_debug("** Add ACL MAC entry %i in WhiletList :" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20305 | MAC_ADDRESS_STR, i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20306 | MAC_ADDR_ARRAY( |
| 20307 | params->mac_addrs[i].addr)); |
| 20308 | |
Jeff Johnson | 954903d | 2019-03-07 20:41:27 -0800 | [diff] [blame] | 20309 | qdf_mem_copy(&config->accept_mac[i], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20310 | params->mac_addrs[i].addr, |
| 20311 | sizeof(qcmacaddr)); |
| 20312 | } |
Jeff Johnson | 954903d | 2019-03-07 20:41:27 -0800 | [diff] [blame] | 20313 | } else if (eSAP_ACCEPT_UNLESS_DENIED == config->SapMacaddr_acl) { |
| 20314 | config->num_deny_mac = params->n_acl_entries; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20315 | for (i = 0; i < params->n_acl_entries; i++) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20316 | hdd_debug("** Add ACL MAC entry %i in BlackList :" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20317 | MAC_ADDRESS_STR, i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20318 | MAC_ADDR_ARRAY( |
| 20319 | params->mac_addrs[i].addr)); |
| 20320 | |
Jeff Johnson | 954903d | 2019-03-07 20:41:27 -0800 | [diff] [blame] | 20321 | qdf_mem_copy(&config->deny_mac[i], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20322 | params->mac_addrs[i].addr, |
| 20323 | sizeof(qcmacaddr)); |
| 20324 | } |
| 20325 | } |
Dustin Brown | 6ba30a1 | 2016-09-13 13:59:43 -0700 | [diff] [blame] | 20326 | qdf_status = wlansap_set_mac_acl( |
Jeff Johnson | 954903d | 2019-03-07 20:41:27 -0800 | [diff] [blame] | 20327 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), config); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20328 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20329 | hdd_err("SAP Set Mac Acl fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20330 | return -EINVAL; |
| 20331 | } |
| 20332 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20333 | hdd_debug("Invalid device_mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 20334 | qdf_opmode_str(adapter->device_mode), |
| 20335 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20336 | return -EINVAL; |
| 20337 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20338 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20339 | return 0; |
| 20340 | } |
| 20341 | |
| 20342 | /** |
| 20343 | * wlan_hdd_cfg80211_set_mac_acl() - SSR wrapper for |
| 20344 | * __wlan_hdd_cfg80211_set_mac_acl |
| 20345 | * @wiphy: pointer to wiphy structure |
| 20346 | * @dev: pointer to net_device |
| 20347 | * @params: pointer to cfg80211_acl_data |
| 20348 | * |
| 20349 | * Return; 0 on success, error number otherwise |
| 20350 | */ |
| 20351 | static int |
| 20352 | wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 20353 | struct net_device *dev, |
| 20354 | const struct cfg80211_acl_data *params) |
| 20355 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20356 | int errno; |
| 20357 | struct osif_vdev_sync *vdev_sync; |
| 20358 | |
| 20359 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 20360 | if (errno) |
| 20361 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20362 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20363 | errno = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20364 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20365 | osif_vdev_sync_op_stop(vdev_sync); |
| 20366 | |
| 20367 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20368 | } |
| 20369 | |
| 20370 | #ifdef WLAN_NL80211_TESTMODE |
| 20371 | #ifdef FEATURE_WLAN_LPHB |
| 20372 | /** |
| 20373 | * wlan_hdd_cfg80211_lphb_ind_handler() - handle low power heart beat indication |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20374 | * @hdd_ctx: Pointer to hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20375 | * @lphbInd: Pointer to low power heart beat indication parameter |
| 20376 | * |
| 20377 | * Return: none |
| 20378 | */ |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20379 | static void wlan_hdd_cfg80211_lphb_ind_handler(void *hdd_ctx, |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 20380 | struct pmo_lphb_rsp *lphb_ind) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20381 | { |
| 20382 | struct sk_buff *skb; |
| 20383 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20384 | hdd_debug("LPHB indication arrived"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20385 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20386 | if (0 != wlan_hdd_validate_context((struct hdd_context *) hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20387 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20388 | |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 20389 | if (!lphb_ind) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20390 | hdd_err("invalid argument lphbInd"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20391 | return; |
| 20392 | } |
| 20393 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20394 | skb = cfg80211_testmode_alloc_event_skb(((struct hdd_context *) hdd_ctx)-> |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 20395 | wiphy, sizeof(*lphb_ind), GFP_ATOMIC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20396 | if (!skb) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20397 | hdd_err("LPHB timeout, NL buffer alloc fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20398 | return; |
| 20399 | } |
| 20400 | |
| 20401 | if (nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20402 | hdd_err("WLAN_HDD_TM_ATTR_CMD put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20403 | goto nla_put_failure; |
| 20404 | } |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 20405 | if (nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphb_ind->protocol_type)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20406 | hdd_err("WLAN_HDD_TM_ATTR_TYPE put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20407 | goto nla_put_failure; |
| 20408 | } |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 20409 | if (nla_put(skb, WLAN_HDD_TM_ATTR_DATA, sizeof(*lphb_ind), |
| 20410 | lphb_ind)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20411 | hdd_err("WLAN_HDD_TM_ATTR_DATA put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20412 | goto nla_put_failure; |
| 20413 | } |
| 20414 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 20415 | return; |
| 20416 | |
| 20417 | nla_put_failure: |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20418 | hdd_err("NLA Put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20419 | kfree_skb(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20420 | } |
| 20421 | #endif /* FEATURE_WLAN_LPHB */ |
| 20422 | |
| 20423 | /** |
| 20424 | * __wlan_hdd_cfg80211_testmode() - test mode |
| 20425 | * @wiphy: Pointer to wiphy |
| 20426 | * @data: Data pointer |
| 20427 | * @len: Data length |
| 20428 | * |
| 20429 | * Return: 0 for success, non-zero for failure |
| 20430 | */ |
| 20431 | static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, |
| 20432 | void *data, int len) |
| 20433 | { |
| 20434 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 20435 | int err; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20436 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20437 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20438 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 20439 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20440 | err = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20441 | if (err) |
| 20442 | return err; |
| 20443 | |
Ryan Hsu | 4df4138 | 2018-06-15 15:45:22 -0700 | [diff] [blame] | 20444 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 20445 | hdd_err("Driver Modules are closed"); |
| 20446 | return -EINVAL; |
| 20447 | } |
| 20448 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 20449 | err = wlan_cfg80211_nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, |
| 20450 | len, wlan_hdd_tm_policy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20451 | if (err) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20452 | hdd_err("Testmode INV ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20453 | return err; |
| 20454 | } |
| 20455 | |
| 20456 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20457 | hdd_err("Testmode INV CMD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20458 | return -EINVAL; |
| 20459 | } |
| 20460 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 20461 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 20462 | TRACE_CODE_HDD_CFG80211_TESTMODE, |
| 20463 | NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])); |
| 20464 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20465 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) { |
| 20466 | #ifdef FEATURE_WLAN_LPHB |
| 20467 | /* Low Power Heartbeat configuration request */ |
| 20468 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 20469 | { |
| 20470 | int buf_len; |
| 20471 | void *buf; |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 20472 | struct pmo_lphb_req *hb_params = NULL; |
| 20473 | struct pmo_lphb_req *hb_params_temp = NULL; |
| 20474 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20475 | |
| 20476 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20477 | hdd_err("Testmode INV DATA"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20478 | return -EINVAL; |
| 20479 | } |
| 20480 | |
| 20481 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 20482 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 20483 | |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 20484 | hb_params_temp = (struct pmo_lphb_req *) buf; |
| 20485 | if ((hb_params_temp->cmd == pmo_lphb_set_tcp_pararm_indid) |
| 20486 | && (hb_params_temp->params.lphb_tcp_params. |
| 20487 | time_period_sec == 0)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20488 | return -EINVAL; |
| 20489 | |
Manjeet Singh | 00b2a56 | 2017-01-03 12:08:10 +0530 | [diff] [blame] | 20490 | if (buf_len > sizeof(*hb_params)) { |
| 20491 | hdd_err("buf_len=%d exceeded hb_params size limit", |
| 20492 | buf_len); |
| 20493 | return -ERANGE; |
| 20494 | } |
| 20495 | |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 20496 | hb_params = (struct pmo_lphb_req *)qdf_mem_malloc( |
| 20497 | sizeof(*hb_params)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 20498 | if (!hb_params) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20499 | return -ENOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20500 | |
Ashish Kumar Dhanotiya | 0fa8ee0 | 2017-07-13 14:04:31 +0530 | [diff] [blame] | 20501 | qdf_mem_zero(hb_params, sizeof(*hb_params)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 20502 | qdf_mem_copy(hb_params, buf, buf_len); |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 20503 | status = ucfg_pmo_lphb_config_req( |
| 20504 | hdd_ctx->psoc, |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20505 | hb_params, (void *)hdd_ctx, |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 20506 | wlan_hdd_cfg80211_lphb_ind_handler); |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 20507 | if (status != QDF_STATUS_SUCCESS) |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20508 | hdd_err("LPHB Config Fail, disable"); |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 20509 | |
| 20510 | qdf_mem_free(hb_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20511 | return 0; |
| 20512 | } |
| 20513 | #endif /* FEATURE_WLAN_LPHB */ |
| 20514 | |
| 20515 | #if defined(QCA_WIFI_FTM) |
| 20516 | case WLAN_HDD_TM_CMD_WLAN_FTM: |
| 20517 | { |
Ryan Hsu | 4df4138 | 2018-06-15 15:45:22 -0700 | [diff] [blame] | 20518 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
| 20519 | hdd_err("Command not allowed in FTM mode, mode %d", |
| 20520 | hdd_get_conparam()); |
| 20521 | return -EINVAL; |
| 20522 | } |
| 20523 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 20524 | err = wlan_cfg80211_ftm_testmode_cmd(hdd_ctx->pdev, |
Ryan Hsu | c8b27a4 | 2018-01-02 13:57:56 -0800 | [diff] [blame] | 20525 | data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20526 | break; |
| 20527 | } |
| 20528 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20529 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20530 | hdd_err("command: %d not supported", |
Ryan Hsu | c8b27a4 | 2018-01-02 13:57:56 -0800 | [diff] [blame] | 20531 | nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20532 | return -EOPNOTSUPP; |
| 20533 | } |
Ryan Hsu | c8b27a4 | 2018-01-02 13:57:56 -0800 | [diff] [blame] | 20534 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20535 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20536 | return err; |
| 20537 | } |
| 20538 | |
| 20539 | /** |
| 20540 | * wlan_hdd_cfg80211_testmode() - test mode |
| 20541 | * @wiphy: Pointer to wiphy |
| 20542 | * @dev: Pointer to network device |
| 20543 | * @data: Data pointer |
| 20544 | * @len: Data length |
| 20545 | * |
| 20546 | * Return: 0 for success, non-zero for failure |
| 20547 | */ |
| 20548 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, |
| 20549 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) |
| 20550 | struct wireless_dev *wdev, |
| 20551 | #endif |
| 20552 | void *data, int len) |
| 20553 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 20554 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 20555 | int errno; |
Arunk Khandavalli | 447837f | 2018-11-08 14:32:53 +0530 | [diff] [blame] | 20556 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 20557 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 20558 | if (errno) |
| 20559 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20560 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 20561 | errno = __wlan_hdd_cfg80211_testmode(wiphy, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20562 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 20563 | osif_psoc_sync_op_stop(psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 20564 | |
| 20565 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20566 | } |
| 20567 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20568 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 20569 | |
| 20570 | #ifdef QCA_HT_2040_COEX |
| 20571 | /** |
| 20572 | * __wlan_hdd_cfg80211_set_ap_channel_width() - set ap channel bandwidth |
| 20573 | * @wiphy: Pointer to wiphy |
| 20574 | * @dev: Pointer to network device |
| 20575 | * @chandef: Pointer to channel definition parameter |
| 20576 | * |
| 20577 | * Return: 0 for success, non-zero for failure |
| 20578 | */ |
| 20579 | static int |
| 20580 | __wlan_hdd_cfg80211_set_ap_channel_width(struct wiphy *wiphy, |
| 20581 | struct net_device *dev, |
| 20582 | struct cfg80211_chan_def *chandef) |
| 20583 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20584 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20585 | struct hdd_context *hdd_ctx; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20586 | QDF_STATUS status; |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 20587 | int retval = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20588 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 20589 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20590 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20591 | return -EINVAL; |
| 20592 | } |
| 20593 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 20594 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 20595 | return -EINVAL; |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 20596 | |
Abhishek Singh | 9d5f458 | 2017-10-11 17:59:48 +0530 | [diff] [blame] | 20597 | if (!(adapter->device_mode == QDF_SAP_MODE || |
| 20598 | adapter->device_mode == QDF_P2P_GO_MODE)) |
| 20599 | return -EOPNOTSUPP; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 20600 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20601 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20602 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 20603 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20604 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20605 | |
Abhishek Singh | 9d5f458 | 2017-10-11 17:59:48 +0530 | [diff] [blame] | 20606 | hdd_debug("Channel width changed to %d ", |
| 20607 | cfg80211_get_chandef_type(chandef)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20608 | |
| 20609 | /* Change SAP ht2040 mode */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20610 | status = hdd_set_sap_ht2040_mode(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20611 | cfg80211_get_chandef_type(chandef)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20612 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20613 | hdd_err("Cannot set SAP HT20/40 mode!"); |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 20614 | retval = -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20615 | } |
| 20616 | |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 20617 | return retval; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20618 | } |
| 20619 | |
| 20620 | /** |
| 20621 | * wlan_hdd_cfg80211_set_ap_channel_width() - set ap channel bandwidth |
| 20622 | * @wiphy: Pointer to wiphy |
| 20623 | * @dev: Pointer to network device |
| 20624 | * @chandef: Pointer to channel definition parameter |
| 20625 | * |
| 20626 | * Return: 0 for success, non-zero for failure |
| 20627 | */ |
| 20628 | static int |
| 20629 | wlan_hdd_cfg80211_set_ap_channel_width(struct wiphy *wiphy, |
| 20630 | struct net_device *dev, |
| 20631 | struct cfg80211_chan_def *chandef) |
| 20632 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20633 | int errno; |
| 20634 | struct osif_vdev_sync *vdev_sync; |
| 20635 | |
| 20636 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 20637 | if (errno) |
| 20638 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20639 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20640 | errno = __wlan_hdd_cfg80211_set_ap_channel_width(wiphy, dev, chandef); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20641 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20642 | osif_vdev_sync_op_stop(vdev_sync); |
| 20643 | |
| 20644 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20645 | } |
| 20646 | #endif |
| 20647 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 20648 | #ifdef CHANNEL_SWITCH_SUPPORTED |
| 20649 | /** |
| 20650 | * __wlan_hdd_cfg80211_channel_switch()- function to switch |
| 20651 | * channel in SAP/GO |
| 20652 | * @wiphy: wiphy pointer |
| 20653 | * @dev: dev pointer. |
| 20654 | * @csa_params: Change channel params |
| 20655 | * |
| 20656 | * This function is called to switch channel in SAP/GO |
| 20657 | * |
| 20658 | * Return: 0 if success else return non zero |
| 20659 | */ |
| 20660 | static int __wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy, |
| 20661 | struct net_device *dev, |
| 20662 | struct cfg80211_csa_settings *csa_params) |
| 20663 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 20664 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 20665 | struct hdd_context *hdd_ctx; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 20666 | uint8_t channel; |
| 20667 | uint16_t freq; |
| 20668 | int ret; |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 20669 | enum phy_ch_width ch_width; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 20670 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20671 | hdd_debug("Set Freq %d", |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 20672 | csa_params->chandef.chan->center_freq); |
| 20673 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 20674 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 20675 | return -EINVAL; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 20676 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 20677 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 20678 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 20679 | |
| 20680 | if (0 != ret) |
| 20681 | return ret; |
| 20682 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 20683 | if ((QDF_P2P_GO_MODE != adapter->device_mode) && |
| 20684 | (QDF_SAP_MODE != adapter->device_mode)) |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 20685 | return -ENOTSUPP; |
| 20686 | |
| 20687 | freq = csa_params->chandef.chan->center_freq; |
| 20688 | channel = cds_freq_to_chan(freq); |
| 20689 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 20690 | ch_width = hdd_map_nl_chan_width(csa_params->chandef.width); |
| 20691 | |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 20692 | ret = hdd_softap_set_channel_change(dev, channel, ch_width, false); |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 20693 | return ret; |
| 20694 | } |
| 20695 | |
| 20696 | /** |
| 20697 | * wlan_hdd_cfg80211_channel_switch()- function to switch |
| 20698 | * channel in SAP/GO |
| 20699 | * @wiphy: wiphy pointer |
| 20700 | * @dev: dev pointer. |
| 20701 | * @csa_params: Change channel params |
| 20702 | * |
| 20703 | * This function is called to switch channel in SAP/GO |
| 20704 | * |
| 20705 | * Return: 0 if success else return non zero |
| 20706 | */ |
| 20707 | static int wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy, |
| 20708 | struct net_device *dev, |
| 20709 | struct cfg80211_csa_settings *csa_params) |
| 20710 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20711 | int errno; |
| 20712 | struct osif_vdev_sync *vdev_sync; |
| 20713 | |
| 20714 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 20715 | if (errno) |
| 20716 | return errno; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 20717 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20718 | errno = __wlan_hdd_cfg80211_channel_switch(wiphy, dev, csa_params); |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 20719 | |
| 20720 | osif_vdev_sync_op_stop(vdev_sync); |
| 20721 | |
| 20722 | return errno; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 20723 | } |
| 20724 | #endif |
| 20725 | |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 20726 | int wlan_hdd_change_hw_mode_for_given_chnl(struct hdd_adapter *adapter, |
| 20727 | uint8_t channel, |
| 20728 | enum policy_mgr_conn_update_reason reason) |
| 20729 | { |
| 20730 | QDF_STATUS status; |
| 20731 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 20732 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20733 | hdd_enter(); |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 20734 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 20735 | return -EINVAL; |
| 20736 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 20737 | status = policy_mgr_reset_connection_update(hdd_ctx->psoc); |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 20738 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 20739 | hdd_err("clearing event failed"); |
| 20740 | |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 20741 | status = policy_mgr_current_connections_update(hdd_ctx->psoc, |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 20742 | adapter->vdev_id, channel, reason); |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 20743 | switch (status) { |
| 20744 | case QDF_STATUS_E_FAILURE: |
| 20745 | /* |
Jeff Johnson | 11d7c9d | 2018-05-06 15:44:09 -0700 | [diff] [blame] | 20746 | * QDF_STATUS_E_FAILURE indicates that some error has occurred |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 20747 | * while changing the hw mode |
| 20748 | */ |
| 20749 | hdd_err("ERROR: connections update failed!!"); |
| 20750 | return -EINVAL; |
| 20751 | |
| 20752 | case QDF_STATUS_SUCCESS: |
| 20753 | /* |
| 20754 | * QDF_STATUS_SUCCESS indicates that HW mode change has been |
| 20755 | * triggered and wait for it to finish. |
| 20756 | */ |
| 20757 | status = policy_mgr_wait_for_connection_update( |
Dustin Brown | 76cd293 | 2018-09-11 16:03:05 -0700 | [diff] [blame] | 20758 | hdd_ctx->psoc); |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 20759 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 20760 | hdd_err("ERROR: qdf wait for event failed!!"); |
| 20761 | return -EINVAL; |
| 20762 | } |
| 20763 | if (QDF_MONITOR_MODE == adapter->device_mode) |
| 20764 | hdd_info("Monitor mode:channel:%d (SMM->DBS)", channel); |
| 20765 | break; |
| 20766 | |
| 20767 | default: |
| 20768 | /* |
| 20769 | * QDF_STATUS_E_NOSUPPORT indicates that no HW mode change is |
| 20770 | * required, so caller can proceed further. |
| 20771 | */ |
| 20772 | break; |
| 20773 | |
| 20774 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20775 | hdd_exit(); |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 20776 | |
| 20777 | return 0; |
| 20778 | } |
| 20779 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 20780 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20781 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20782 | * wlan_hdd_cfg80211_set_mon_ch() - Set monitor mode capture channel |
| 20783 | * @wiphy: Handle to struct wiphy to get handle to module context. |
| 20784 | * @chandef: Contains information about the capture channel to be set. |
| 20785 | * |
| 20786 | * This interface is called if and only if monitor mode interface alone is |
| 20787 | * active. |
| 20788 | * |
| 20789 | * Return: 0 success or error code on failure. |
| 20790 | */ |
| 20791 | static int __wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy, |
| 20792 | struct cfg80211_chan_def *chandef) |
| 20793 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 20794 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 20795 | struct hdd_adapter *adapter; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 20796 | struct hdd_station_ctx *sta_ctx; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20797 | struct hdd_mon_set_ch_info *ch_info; |
| 20798 | QDF_STATUS status; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 20799 | mac_handle_t mac_handle; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20800 | struct qdf_mac_addr bssid; |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 20801 | struct csr_roam_profile roam_profile; |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 20802 | struct ch_params ch_params; |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 20803 | uint8_t sec_ch = 0; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20804 | int ret; |
| 20805 | uint16_t chan_num = cds_freq_to_chan(chandef->chan->center_freq); |
| 20806 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20807 | hdd_enter(); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20808 | |
| 20809 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 20810 | if (ret) |
| 20811 | return ret; |
| 20812 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 20813 | mac_handle = hdd_ctx->mac_handle; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20814 | |
| 20815 | adapter = hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE); |
| 20816 | if (!adapter) |
| 20817 | return -EIO; |
| 20818 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20819 | hdd_debug("%s: set monitor mode Channel %d and freq %d", |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20820 | adapter->dev->name, chan_num, chandef->chan->center_freq); |
| 20821 | |
| 20822 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 20823 | ch_info = &sta_ctx->ch_info; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20824 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 20825 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 20826 | roam_profile.phyMode = ch_info->phy_mode; |
Naveen Rawat | 3184dd8 | 2017-07-05 14:58:18 -0700 | [diff] [blame] | 20827 | roam_profile.ch_params.ch_width = hdd_map_nl_chan_width(chandef->width); |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 20828 | hdd_select_cbmode(adapter, chan_num, &roam_profile.ch_params); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20829 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 20830 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20831 | QDF_MAC_ADDR_SIZE); |
| 20832 | |
Naveen Rawat | 3184dd8 | 2017-07-05 14:58:18 -0700 | [diff] [blame] | 20833 | ch_params.ch_width = hdd_map_nl_chan_width(chandef->width); |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 20834 | /* |
| 20835 | * CDS api expects secondary channel for calculating |
| 20836 | * the channel params |
| 20837 | */ |
| 20838 | if ((ch_params.ch_width == CH_WIDTH_40MHZ) && |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 20839 | (WLAN_REG_IS_24GHZ_CH(chan_num))) { |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 20840 | if (chan_num >= 1 && chan_num <= 5) |
| 20841 | sec_ch = chan_num + 4; |
| 20842 | else if (chan_num >= 6 && chan_num <= 13) |
| 20843 | sec_ch = chan_num - 4; |
| 20844 | } |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 20845 | wlan_reg_set_channel_params(hdd_ctx->pdev, chan_num, |
| 20846 | sec_ch, &ch_params); |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 20847 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan_num, |
| 20848 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 20849 | hdd_err("Failed to change hw mode"); |
| 20850 | return -EINVAL; |
| 20851 | } |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 20852 | status = sme_roam_channel_change_req(mac_handle, bssid, &ch_params, |
| 20853 | &roam_profile); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20854 | if (status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20855 | hdd_err("Failed to set sme_RoamChannel for monitor mode status: %d", |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20856 | status); |
| 20857 | ret = qdf_status_to_os_return(status); |
| 20858 | return ret; |
| 20859 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20860 | hdd_exit(); |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 20861 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20862 | return 0; |
| 20863 | } |
| 20864 | |
| 20865 | /** |
| 20866 | * wlan_hdd_cfg80211_set_mon_ch() - Set monitor mode capture channel |
| 20867 | * @wiphy: Handle to struct wiphy to get handle to module context. |
| 20868 | * @chandef: Contains information about the capture channel to be set. |
| 20869 | * |
| 20870 | * This interface is called if and only if monitor mode interface alone is |
| 20871 | * active. |
| 20872 | * |
| 20873 | * Return: 0 success or error code on failure. |
| 20874 | */ |
| 20875 | static int wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy, |
| 20876 | struct cfg80211_chan_def *chandef) |
| 20877 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 20878 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 20879 | int errno; |
Arunk Khandavalli | 447837f | 2018-11-08 14:32:53 +0530 | [diff] [blame] | 20880 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 20881 | errno = osif_psoc_sync_op_start(wiphy_dev(wiphy), &psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 20882 | if (errno) |
| 20883 | return errno; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20884 | |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 20885 | errno = __wlan_hdd_cfg80211_set_mon_ch(wiphy, chandef); |
Arunk Khandavalli | 447837f | 2018-11-08 14:32:53 +0530 | [diff] [blame] | 20886 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 20887 | osif_psoc_sync_op_stop(psoc_sync); |
Dustin Brown | f0f0061 | 2019-01-31 16:02:24 -0800 | [diff] [blame] | 20888 | |
| 20889 | return errno; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20890 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 20891 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 20892 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 20893 | #define CNT_DIFF(cur, prev) \ |
| 20894 | ((cur >= prev) ? (cur - prev) : (cur + (MAX_COUNT - (prev) + 1))) |
| 20895 | #define MAX_COUNT 0xffffffff |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 20896 | static void hdd_update_chan_info(struct hdd_context *hdd_ctx, |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 20897 | struct scan_chan_info *chan, |
| 20898 | struct scan_chan_info *info, uint32_t cmd_flag) |
| 20899 | { |
| 20900 | if ((info->cmd_flag != WMI_CHAN_InFO_START_RESP) && |
| 20901 | (info->cmd_flag != WMI_CHAN_InFO_END_RESP)) |
| 20902 | hdd_err("cmd flag is invalid: %d", info->cmd_flag); |
| 20903 | |
| 20904 | mutex_lock(&hdd_ctx->chan_info_lock); |
| 20905 | |
| 20906 | if (info->cmd_flag == WMI_CHAN_InFO_START_RESP) |
| 20907 | qdf_mem_zero(chan, sizeof(*chan)); |
| 20908 | |
| 20909 | chan->freq = info->freq; |
| 20910 | chan->noise_floor = info->noise_floor; |
| 20911 | chan->clock_freq = info->clock_freq; |
| 20912 | chan->cmd_flag = info->cmd_flag; |
| 20913 | chan->cycle_count = CNT_DIFF(info->cycle_count, chan->cycle_count); |
| 20914 | |
| 20915 | chan->rx_clear_count = |
| 20916 | CNT_DIFF(info->rx_clear_count, chan->rx_clear_count); |
| 20917 | |
| 20918 | chan->tx_frame_count = |
| 20919 | CNT_DIFF(info->tx_frame_count, chan->tx_frame_count); |
| 20920 | |
| 20921 | mutex_unlock(&hdd_ctx->chan_info_lock); |
| 20922 | |
| 20923 | } |
| 20924 | #undef CNT_DIFF |
| 20925 | #undef MAX_COUNT |
| 20926 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20927 | #if defined(WLAN_FEATURE_FILS_SK) &&\ |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 20928 | defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) &&\ |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20929 | (defined(CFG80211_UPDATE_CONNECT_PARAMS) ||\ |
| 20930 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0))) |
| 20931 | |
| 20932 | #ifndef UPDATE_FILS_ERP_INFO |
| 20933 | #define UPDATE_FILS_ERP_INFO BIT(1) |
| 20934 | #endif |
| 20935 | |
| 20936 | #ifndef UPDATE_FILS_AUTH_TYPE |
| 20937 | #define UPDATE_FILS_AUTH_TYPE BIT(2) |
| 20938 | #endif |
| 20939 | |
| 20940 | /** |
| 20941 | * __wlan_hdd_cfg80211_update_connect_params - update connect params |
| 20942 | * @wiphy: Handle to struct wiphy to get handle to module context. |
| 20943 | * @dev: Pointer to network device |
| 20944 | * @req: Pointer to connect params |
| 20945 | * @changed: Bitmap used to indicate the changed params |
| 20946 | * |
| 20947 | * Update the connect parameters while connected to a BSS. The updated |
| 20948 | * parameters can be used by driver/firmware for subsequent BSS selection |
| 20949 | * (roaming) decisions and to form the Authentication/(Re)Association |
| 20950 | * Request frames. This call does not request an immediate disassociation |
| 20951 | * or reassociation with the current BSS, i.e., this impacts only |
| 20952 | * subsequent (re)associations. The bits in changed are defined in enum |
| 20953 | * cfg80211_connect_params_changed |
| 20954 | * |
| 20955 | * Return: zero for success, non-zero for failure |
| 20956 | */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 20957 | static int |
| 20958 | __wlan_hdd_cfg80211_update_connect_params(struct wiphy *wiphy, |
| 20959 | struct net_device *dev, |
| 20960 | struct cfg80211_connect_params *req, |
| 20961 | uint32_t changed) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20962 | { |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 20963 | struct csr_roam_profile *roam_profile; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20964 | uint8_t *buf; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 20965 | int ret; |
| 20966 | enum eAniAuthType auth_type; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20967 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 20968 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 20969 | QDF_STATUS status; |
| 20970 | struct cds_fils_connection_info *fils_info; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 20971 | mac_handle_t mac_handle; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20972 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 20973 | hdd_enter_dev(dev); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20974 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 20975 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20976 | return -EINVAL; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20977 | |
| 20978 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 20979 | if (ret) |
| 20980 | return -EINVAL; |
| 20981 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 20982 | roam_profile = hdd_roam_profile(adapter); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20983 | fils_info = roam_profile->fils_con_info; |
| 20984 | |
| 20985 | if (!fils_info) { |
| 20986 | hdd_err("No valid FILS conn info"); |
| 20987 | return -EINVAL; |
| 20988 | } |
| 20989 | |
| 20990 | if (req->ie_len) |
| 20991 | wlan_hdd_cfg80211_set_ie(adapter, req->ie, req->ie_len); |
| 20992 | |
| 20993 | if (changed) |
| 20994 | fils_info->is_fils_connection = true; |
| 20995 | |
| 20996 | if (changed & UPDATE_FILS_ERP_INFO) { |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 20997 | if (!wlan_hdd_fils_data_in_limits(req)) |
Jeff Johnson | b8adae4 | 2018-02-27 16:12:00 -0800 | [diff] [blame] | 20998 | return -EINVAL; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20999 | fils_info->key_nai_length = req->fils_erp_username_len + |
| 21000 | sizeof(char) + |
| 21001 | req->fils_erp_realm_len; |
Dundi Raviteja | 170d287 | 2018-03-23 15:49:54 +0530 | [diff] [blame] | 21002 | if (fils_info->key_nai_length > |
| 21003 | FILS_MAX_KEYNAME_NAI_LENGTH) { |
| 21004 | hdd_err("Key NAI Length %d", |
| 21005 | fils_info->key_nai_length); |
| 21006 | return -EINVAL; |
| 21007 | } |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21008 | if (req->fils_erp_username_len && req->fils_erp_username) { |
| 21009 | buf = fils_info->keyname_nai; |
| 21010 | qdf_mem_copy(buf, req->fils_erp_username, |
| 21011 | req->fils_erp_username_len); |
| 21012 | buf += req->fils_erp_username_len; |
| 21013 | *buf++ = '@'; |
| 21014 | qdf_mem_copy(buf, req->fils_erp_realm, |
| 21015 | req->fils_erp_realm_len); |
| 21016 | } |
| 21017 | |
Pragaspathi Thilagaraj | 87a60af | 2019-02-20 20:42:47 +0530 | [diff] [blame] | 21018 | fils_info->sequence_number = req->fils_erp_next_seq_num + 1; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21019 | fils_info->r_rk_length = req->fils_erp_rrk_len; |
| 21020 | |
| 21021 | if (req->fils_erp_rrk_len && req->fils_erp_rrk) |
| 21022 | qdf_mem_copy(fils_info->r_rk, req->fils_erp_rrk, |
| 21023 | fils_info->r_rk_length); |
| 21024 | |
| 21025 | fils_info->realm_len = req->fils_erp_realm_len; |
| 21026 | if (req->fils_erp_realm_len && req->fils_erp_realm) |
| 21027 | qdf_mem_copy(fils_info->realm, req->fils_erp_realm, |
| 21028 | fils_info->realm_len); |
| 21029 | } |
| 21030 | |
| 21031 | if (changed & UPDATE_FILS_AUTH_TYPE) { |
| 21032 | auth_type = wlan_hdd_get_fils_auth_type(req->auth_type); |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 21033 | if (auth_type == eSIR_DONOT_USE_AUTH_TYPE) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21034 | hdd_err("invalid auth type for fils %d", |
| 21035 | req->auth_type); |
| 21036 | return -EINVAL; |
| 21037 | } |
| 21038 | |
| 21039 | roam_profile->fils_con_info->auth_type = auth_type; |
| 21040 | } |
| 21041 | |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 21042 | hdd_debug("fils conn update: changed %x is_fils %d keyname nai len %d", |
| 21043 | changed, roam_profile->fils_con_info->is_fils_connection, |
| 21044 | roam_profile->fils_con_info->key_nai_length); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21045 | |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 21046 | if (!hdd_ctx->is_fils_roaming_supported) { |
| 21047 | hdd_debug("FILS roaming support %d", |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 21048 | hdd_ctx->is_fils_roaming_supported); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21049 | return 0; |
| 21050 | } |
| 21051 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 21052 | mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | cf07c31 | 2019-02-04 13:53:29 -0800 | [diff] [blame] | 21053 | status = sme_update_fils_config(mac_handle, adapter->vdev_id, |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 21054 | roam_profile); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21055 | if (QDF_IS_STATUS_ERROR(status)) |
| 21056 | hdd_err("Update FILS connect params to Fw failed %d", status); |
| 21057 | |
| 21058 | return 0; |
| 21059 | } |
| 21060 | |
| 21061 | /** |
| 21062 | * wlan_hdd_cfg80211_update_connect_params - SSR wrapper for |
| 21063 | * __wlan_hdd_cfg80211_update_connect_params |
| 21064 | * @wiphy: Pointer to wiphy structure |
| 21065 | * @dev: Pointer to net_device |
| 21066 | * @req: Pointer to connect params |
| 21067 | * @changed: flags used to indicate the changed params |
| 21068 | * |
| 21069 | * Return: zero for success, non-zero for failure |
| 21070 | */ |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 21071 | static int |
| 21072 | wlan_hdd_cfg80211_update_connect_params(struct wiphy *wiphy, |
| 21073 | struct net_device *dev, |
| 21074 | struct cfg80211_connect_params *req, |
| 21075 | uint32_t changed) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21076 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 21077 | int errno; |
| 21078 | struct osif_vdev_sync *vdev_sync; |
| 21079 | |
| 21080 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 21081 | if (errno) |
| 21082 | return errno; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21083 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 21084 | errno = __wlan_hdd_cfg80211_update_connect_params(wiphy, dev, |
| 21085 | req, changed); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21086 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 21087 | osif_vdev_sync_op_stop(vdev_sync); |
| 21088 | |
| 21089 | return errno; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21090 | } |
| 21091 | #endif |
| 21092 | |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21093 | #if defined(WLAN_FEATURE_SAE) && \ |
| 21094 | defined(CFG80211_EXTERNAL_AUTH_SUPPORT) |
Srinivas Dasari | 29186ca | 2019-02-11 18:45:48 +0530 | [diff] [blame] | 21095 | #if defined(CFG80211_EXTERNAL_AUTH_AP_SUPPORT) |
| 21096 | /** |
| 21097 | * wlan_hdd_extauth_cache_pmkid() - Extract and cache pmkid |
| 21098 | * @adapter: hdd vdev/net_device context |
| 21099 | * @mac_handle: Handle to the MAC |
| 21100 | * @params: Pointer to external auth params. |
| 21101 | * |
| 21102 | * Extract the PMKID and BSS from external auth params and add to the |
| 21103 | * PMKSA Cache in CSR. |
| 21104 | */ |
| 21105 | static void |
| 21106 | wlan_hdd_extauth_cache_pmkid(struct hdd_adapter *adapter, |
| 21107 | mac_handle_t mac_handle, |
| 21108 | struct cfg80211_external_auth_params *params) |
| 21109 | { |
| 21110 | tPmkidCacheInfo pmk_cache; |
| 21111 | QDF_STATUS result; |
| 21112 | if (params->pmkid) { |
| 21113 | qdf_mem_zero(&pmk_cache, sizeof(pmk_cache)); |
| 21114 | qdf_mem_copy(pmk_cache.BSSID.bytes, params->bssid, |
| 21115 | QDF_MAC_ADDR_SIZE); |
| 21116 | qdf_mem_copy(pmk_cache.PMKID, params->pmkid, |
| 21117 | CSR_RSN_PMKID_SIZE); |
| 21118 | result = sme_roam_set_pmkid_cache(mac_handle, adapter->vdev_id, |
| 21119 | &pmk_cache, 1, false); |
| 21120 | if (!QDF_IS_STATUS_SUCCESS(result)) |
| 21121 | hdd_debug("external_auth: Failed to cache PMKID"); |
| 21122 | } |
| 21123 | } |
| 21124 | #else |
| 21125 | static void |
| 21126 | wlan_hdd_extauth_cache_pmkid(struct hdd_adapter *adapter, |
| 21127 | mac_handle_t mac_handle, |
| 21128 | struct cfg80211_external_auth_params *params) |
| 21129 | {} |
| 21130 | #endif |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21131 | /** |
| 21132 | * __wlan_hdd_cfg80211_external_auth() - Handle external auth |
Srinivas Dasari | 29186ca | 2019-02-11 18:45:48 +0530 | [diff] [blame] | 21133 | * |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21134 | * @wiphy: Pointer to wireless phy |
| 21135 | * @dev: net device |
Srinivas Dasari | 29186ca | 2019-02-11 18:45:48 +0530 | [diff] [blame] | 21136 | * @params: Pointer to external auth params. |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21137 | * Return: 0 on success, negative errno on failure |
Srinivas Dasari | 29186ca | 2019-02-11 18:45:48 +0530 | [diff] [blame] | 21138 | * |
| 21139 | * Userspace sends status of the external authentication(e.g., SAE) with a peer. |
| 21140 | * The message carries BSSID of the peer and auth status (WLAN_STATUS_SUCCESS/ |
| 21141 | * WLAN_STATUS_UNSPECIFIED_FAILURE) in params. |
| 21142 | * Userspace may send PMKID in params, which can be used for |
| 21143 | * further connections. |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21144 | */ |
| 21145 | static int |
| 21146 | __wlan_hdd_cfg80211_external_auth(struct wiphy *wiphy, |
| 21147 | struct net_device *dev, |
| 21148 | struct cfg80211_external_auth_params *params) |
| 21149 | { |
| 21150 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 21151 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 21152 | int ret; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 21153 | mac_handle_t mac_handle; |
Srinivas Dasari | e854ff0 | 2019-02-11 17:24:48 +0530 | [diff] [blame] | 21154 | struct qdf_mac_addr peer_mac_addr; |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21155 | |
| 21156 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 21157 | hdd_err("Command not allowed in FTM mode"); |
| 21158 | return -EPERM; |
| 21159 | } |
| 21160 | |
Jeff Johnson | 4836302 | 2019-02-24 16:26:51 -0800 | [diff] [blame] | 21161 | if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21162 | return -EINVAL; |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21163 | |
| 21164 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 21165 | if (ret) |
| 21166 | return ret; |
| 21167 | |
Srinivas Dasari | e854ff0 | 2019-02-11 17:24:48 +0530 | [diff] [blame] | 21168 | hdd_debug("external_auth status: %d peer mac: " QDF_MAC_ADDR_STR, |
| 21169 | params->status, QDF_MAC_ADDR_ARRAY(params->bssid)); |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 21170 | mac_handle = hdd_ctx->mac_handle; |
Srinivas Dasari | e854ff0 | 2019-02-11 17:24:48 +0530 | [diff] [blame] | 21171 | qdf_mem_copy(peer_mac_addr.bytes, params->bssid, QDF_MAC_ADDR_SIZE); |
Srinivas Dasari | 29186ca | 2019-02-11 18:45:48 +0530 | [diff] [blame] | 21172 | |
| 21173 | wlan_hdd_extauth_cache_pmkid(adapter, mac_handle, params); |
| 21174 | |
Srinivas Dasari | e854ff0 | 2019-02-11 17:24:48 +0530 | [diff] [blame] | 21175 | sme_handle_sae_msg(mac_handle, adapter->vdev_id, params->status, |
| 21176 | peer_mac_addr); |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21177 | |
| 21178 | return ret; |
| 21179 | } |
| 21180 | |
| 21181 | /** |
| 21182 | * wlan_hdd_cfg80211_external_auth() - Handle external auth |
| 21183 | * @wiphy: Pointer to wireless phy |
| 21184 | * @dev: net device |
| 21185 | * @params: Pointer to external auth params |
| 21186 | * |
| 21187 | * Return: 0 on success, negative errno on failure |
| 21188 | */ |
| 21189 | static int |
| 21190 | wlan_hdd_cfg80211_external_auth(struct wiphy *wiphy, |
| 21191 | struct net_device *dev, |
| 21192 | struct cfg80211_external_auth_params *params) |
| 21193 | { |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 21194 | int errno; |
| 21195 | struct osif_vdev_sync *vdev_sync; |
| 21196 | |
| 21197 | errno = osif_vdev_sync_op_start(dev, &vdev_sync); |
| 21198 | if (errno) |
| 21199 | return errno; |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21200 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 21201 | errno = __wlan_hdd_cfg80211_external_auth(wiphy, dev, params); |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21202 | |
Dustin Brown | 1d31b08 | 2018-11-22 14:41:20 +0530 | [diff] [blame] | 21203 | osif_vdev_sync_op_stop(vdev_sync); |
| 21204 | |
| 21205 | return errno; |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21206 | } |
| 21207 | #endif |
| 21208 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21209 | /** |
| 21210 | * wlan_hdd_chan_info_cb() - channel info callback |
| 21211 | * @chan_info: struct scan_chan_info |
| 21212 | * |
| 21213 | * Store channel info into HDD context |
| 21214 | * |
| 21215 | * Return: None. |
| 21216 | */ |
| 21217 | static void wlan_hdd_chan_info_cb(struct scan_chan_info *info) |
| 21218 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 21219 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21220 | struct scan_chan_info *chan; |
| 21221 | uint8_t idx; |
| 21222 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 21223 | hdd_enter(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21224 | |
| 21225 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 21226 | if (wlan_hdd_validate_context(hdd_ctx) != 0) { |
| 21227 | hdd_err("hdd_ctx is invalid"); |
| 21228 | return; |
| 21229 | } |
| 21230 | |
| 21231 | if (!hdd_ctx->chan_info) { |
| 21232 | hdd_err("chan_info is NULL"); |
| 21233 | return; |
| 21234 | } |
| 21235 | |
| 21236 | chan = hdd_ctx->chan_info; |
| 21237 | for (idx = 0; idx < SIR_MAX_NUM_CHANNELS; idx++) { |
| 21238 | if (chan[idx].freq == info->freq) { |
| 21239 | hdd_update_chan_info(hdd_ctx, &chan[idx], info, |
| 21240 | info->cmd_flag); |
Rajeev Kumar | eb6ec17 | 2018-09-26 20:45:36 -0700 | [diff] [blame] | 21241 | hdd_debug("cmd:%d freq:%u nf:%d cc:%u rcc:%u clk:%u cmd:%d tfc:%d index:%d", |
| 21242 | chan[idx].cmd_flag, chan[idx].freq, |
| 21243 | chan[idx].noise_floor, |
| 21244 | chan[idx].cycle_count, |
| 21245 | chan[idx].rx_clear_count, |
| 21246 | chan[idx].clock_freq, chan[idx].cmd_flag, |
| 21247 | chan[idx].tx_frame_count, idx); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21248 | if (chan[idx].freq == 0) |
| 21249 | break; |
| 21250 | |
| 21251 | } |
| 21252 | } |
| 21253 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 21254 | hdd_exit(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21255 | } |
| 21256 | |
| 21257 | /** |
| 21258 | * wlan_hdd_init_chan_info() - init chan info in hdd context |
| 21259 | * @hdd_ctx: HDD context pointer |
| 21260 | * |
| 21261 | * Return: none |
| 21262 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 21263 | void wlan_hdd_init_chan_info(struct hdd_context *hdd_ctx) |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21264 | { |
Rajeev Kumar Sirasanagandla | 9770bba | 2018-09-24 20:12:28 +0530 | [diff] [blame] | 21265 | uint32_t num_2g, num_5g, index = 0; |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 21266 | mac_handle_t mac_handle; |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21267 | |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 21268 | hdd_ctx->chan_info = NULL; |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21269 | if (!hdd_ctx->config->fEnableSNRMonitoring) { |
Dustin Brown | 3111677 | 2018-08-15 14:59:21 -0700 | [diff] [blame] | 21270 | hdd_debug("SNR monitoring is disabled"); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21271 | return; |
| 21272 | } |
| 21273 | |
| 21274 | hdd_ctx->chan_info = |
| 21275 | qdf_mem_malloc(sizeof(struct scan_chan_info) |
| 21276 | * QDF_MAX_NUM_CHAN); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 21277 | if (!hdd_ctx->chan_info) |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21278 | return; |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21279 | mutex_init(&hdd_ctx->chan_info_lock); |
| 21280 | |
| 21281 | num_2g = QDF_ARRAY_SIZE(hdd_channels_2_4_ghz); |
| 21282 | for (; index < num_2g; index++) { |
| 21283 | hdd_ctx->chan_info[index].freq = |
| 21284 | hdd_channels_2_4_ghz[index].center_freq; |
| 21285 | } |
| 21286 | |
| 21287 | num_5g = QDF_ARRAY_SIZE(hdd_channels_5_ghz); |
| 21288 | for (; (index - num_2g) < num_5g; index++) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 21289 | if (wlan_reg_is_dsrc_chan(hdd_ctx->pdev, |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 21290 | hdd_channels_5_ghz[index - num_2g].hw_value)) |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21291 | continue; |
| 21292 | hdd_ctx->chan_info[index].freq = |
| 21293 | hdd_channels_5_ghz[index - num_2g].center_freq; |
| 21294 | } |
Rajeev Kumar Sirasanagandla | 9770bba | 2018-09-24 20:12:28 +0530 | [diff] [blame] | 21295 | |
| 21296 | index = num_2g + num_5g; |
| 21297 | index = wlan_hdd_populate_srd_chan_info(hdd_ctx, index); |
| 21298 | |
Jeff Johnson | 34fc63a | 2018-06-14 10:10:02 -0700 | [diff] [blame] | 21299 | mac_handle = hdd_ctx->mac_handle; |
| 21300 | sme_set_chan_info_callback(mac_handle, |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21301 | &wlan_hdd_chan_info_cb); |
| 21302 | } |
| 21303 | |
| 21304 | /** |
| 21305 | * wlan_hdd_deinit_chan_info() - deinit chan info in hdd context |
| 21306 | * @hdd_ctx: hdd context pointer |
| 21307 | * |
| 21308 | * Return: none |
| 21309 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 21310 | void wlan_hdd_deinit_chan_info(struct hdd_context *hdd_ctx) |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 21311 | { |
| 21312 | struct scan_chan_info *chan; |
| 21313 | |
| 21314 | chan = hdd_ctx->chan_info; |
| 21315 | hdd_ctx->chan_info = NULL; |
| 21316 | if (chan) |
| 21317 | qdf_mem_free(chan); |
| 21318 | } |
| 21319 | |
Dustin Brown | 32cb479 | 2017-06-15 15:33:42 -0700 | [diff] [blame] | 21320 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || defined(WITH_BACKPORTS) |
| 21321 | static enum rate_info_bw hdd_map_hdd_bw_to_os(enum hdd_rate_info_bw hdd_bw) |
| 21322 | { |
| 21323 | switch (hdd_bw) { |
| 21324 | case HDD_RATE_BW_5: |
| 21325 | return RATE_INFO_BW_5; |
| 21326 | case HDD_RATE_BW_10: |
| 21327 | return RATE_INFO_BW_10; |
| 21328 | case HDD_RATE_BW_20: |
| 21329 | return RATE_INFO_BW_20; |
| 21330 | case HDD_RATE_BW_40: |
| 21331 | return RATE_INFO_BW_40; |
| 21332 | case HDD_RATE_BW_80: |
| 21333 | return RATE_INFO_BW_80; |
| 21334 | case HDD_RATE_BW_160: |
| 21335 | return RATE_INFO_BW_160; |
| 21336 | } |
| 21337 | |
| 21338 | hdd_err("Unhandled HDD_RATE_BW: %d", hdd_bw); |
| 21339 | |
| 21340 | return RATE_INFO_BW_20; |
| 21341 | } |
| 21342 | |
| 21343 | void hdd_set_rate_bw(struct rate_info *info, enum hdd_rate_info_bw hdd_bw) |
| 21344 | { |
| 21345 | info->bw = hdd_map_hdd_bw_to_os(hdd_bw); |
| 21346 | } |
| 21347 | #else |
| 21348 | static enum rate_info_flags hdd_map_hdd_bw_to_os(enum hdd_rate_info_bw hdd_bw) |
| 21349 | { |
| 21350 | switch (hdd_bw) { |
| 21351 | case HDD_RATE_BW_5: |
| 21352 | case HDD_RATE_BW_10: |
| 21353 | case HDD_RATE_BW_20: |
| 21354 | return (enum rate_info_flags)0; |
| 21355 | case HDD_RATE_BW_40: |
| 21356 | return RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 21357 | case HDD_RATE_BW_80: |
| 21358 | return RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 21359 | case HDD_RATE_BW_160: |
| 21360 | return RATE_INFO_FLAGS_160_MHZ_WIDTH; |
| 21361 | } |
| 21362 | |
| 21363 | hdd_err("Unhandled HDD_RATE_BW: %d", hdd_bw); |
| 21364 | |
| 21365 | return (enum rate_info_flags)0; |
| 21366 | } |
| 21367 | |
| 21368 | void hdd_set_rate_bw(struct rate_info *info, enum hdd_rate_info_bw hdd_bw) |
| 21369 | { |
| 21370 | const enum rate_info_flags all_bws = |
| 21371 | RATE_INFO_FLAGS_40_MHZ_WIDTH | |
| 21372 | RATE_INFO_FLAGS_80_MHZ_WIDTH | |
| 21373 | RATE_INFO_FLAGS_80P80_MHZ_WIDTH | |
| 21374 | RATE_INFO_FLAGS_160_MHZ_WIDTH; |
| 21375 | |
| 21376 | info->flags &= ~all_bws; |
| 21377 | info->flags |= hdd_map_hdd_bw_to_os(hdd_bw); |
| 21378 | } |
| 21379 | #endif |
| 21380 | |
Min Liu | e34708a | 2019-02-01 15:00:34 +0800 | [diff] [blame] | 21381 | #ifdef CFG80211_EXTERNAL_DH_UPDATE_SUPPORT |
| 21382 | void hdd_send_update_owe_info_event(struct hdd_adapter *adapter, |
| 21383 | uint8_t sta_addr[], |
| 21384 | uint8_t *owe_ie, |
| 21385 | uint32_t owe_ie_len) |
| 21386 | { |
| 21387 | struct cfg80211_update_owe_info owe_info; |
| 21388 | struct net_device *dev = adapter->dev; |
| 21389 | |
| 21390 | hdd_enter_dev(dev); |
| 21391 | |
| 21392 | qdf_mem_copy(owe_info.bssid, sta_addr, ETH_ALEN); |
| 21393 | owe_info.ie = owe_ie; |
| 21394 | owe_info.ie_len = owe_ie_len; |
| 21395 | |
| 21396 | cfg80211_update_owe_info_event(dev, &owe_info, GFP_KERNEL); |
| 21397 | |
| 21398 | hdd_exit(); |
| 21399 | } |
| 21400 | #endif |
| 21401 | |
Mahesh A Saptasagar | 6dda202 | 2016-09-03 12:59:09 +0530 | [diff] [blame] | 21402 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21403 | * struct cfg80211_ops - cfg80211_ops |
| 21404 | * |
| 21405 | * @add_virtual_intf: Add virtual interface |
| 21406 | * @del_virtual_intf: Delete virtual interface |
| 21407 | * @change_virtual_intf: Change virtual interface |
| 21408 | * @change_station: Change station |
| 21409 | * @add_beacon: Add beacon in sap mode |
| 21410 | * @del_beacon: Delete beacon in sap mode |
| 21411 | * @set_beacon: Set beacon in sap mode |
| 21412 | * @start_ap: Start ap |
| 21413 | * @change_beacon: Change beacon |
| 21414 | * @stop_ap: Stop ap |
| 21415 | * @change_bss: Change bss |
| 21416 | * @add_key: Add key |
| 21417 | * @get_key: Get key |
| 21418 | * @del_key: Delete key |
| 21419 | * @set_default_key: Set default key |
| 21420 | * @set_channel: Set channel |
| 21421 | * @scan: Scan |
| 21422 | * @connect: Connect |
| 21423 | * @disconnect: Disconnect |
| 21424 | * @join_ibss = Join ibss |
| 21425 | * @leave_ibss = Leave ibss |
| 21426 | * @set_wiphy_params = Set wiphy params |
| 21427 | * @set_tx_power = Set tx power |
| 21428 | * @get_tx_power = get tx power |
| 21429 | * @remain_on_channel = Remain on channel |
| 21430 | * @cancel_remain_on_channel = Cancel remain on channel |
| 21431 | * @mgmt_tx = Tx management frame |
| 21432 | * @mgmt_tx_cancel_wait = Cancel management tx wait |
| 21433 | * @set_default_mgmt_key = Set default management key |
| 21434 | * @set_txq_params = Set tx queue parameters |
| 21435 | * @get_station = Get station |
| 21436 | * @set_power_mgmt = Set power management |
| 21437 | * @del_station = Delete station |
| 21438 | * @add_station = Add station |
| 21439 | * @set_pmksa = Set pmksa |
| 21440 | * @del_pmksa = Delete pmksa |
| 21441 | * @flush_pmksa = Flush pmksa |
| 21442 | * @update_ft_ies = Update FT IEs |
| 21443 | * @tdls_mgmt = Tdls management |
| 21444 | * @tdls_oper = Tdls operation |
| 21445 | * @set_rekey_data = Set rekey data |
| 21446 | * @sched_scan_start = Scheduled scan start |
| 21447 | * @sched_scan_stop = Scheduled scan stop |
| 21448 | * @resume = Resume wlan |
| 21449 | * @suspend = Suspend wlan |
| 21450 | * @set_mac_acl = Set mac acl |
| 21451 | * @testmode_cmd = Test mode command |
| 21452 | * @set_ap_chanwidth = Set AP channel bandwidth |
| 21453 | * @dump_survey = Dump survey |
| 21454 | * @key_mgmt_set_pmk = Set pmk key management |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21455 | * @update_connect_params = Update connect params |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21456 | */ |
| 21457 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = { |
| 21458 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 21459 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 21460 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 21461 | .change_station = wlan_hdd_change_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21462 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 21463 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 21464 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21465 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 21466 | .add_key = wlan_hdd_cfg80211_add_key, |
| 21467 | .get_key = wlan_hdd_cfg80211_get_key, |
| 21468 | .del_key = wlan_hdd_cfg80211_del_key, |
| 21469 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
| 21470 | .scan = wlan_hdd_cfg80211_scan, |
| 21471 | .connect = wlan_hdd_cfg80211_connect, |
| 21472 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 21473 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 21474 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 21475 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 21476 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 21477 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
| 21478 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 21479 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 21480 | .mgmt_tx = wlan_hdd_mgmt_tx, |
| 21481 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 21482 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 21483 | .set_txq_params = wlan_hdd_set_txq_params, |
Himanshu Agarwal | 37e4241 | 2016-07-21 14:35:09 +0530 | [diff] [blame] | 21484 | .dump_station = wlan_hdd_cfg80211_dump_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21485 | .get_station = wlan_hdd_cfg80211_get_station, |
| 21486 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 21487 | .del_station = wlan_hdd_cfg80211_del_station, |
| 21488 | .add_station = wlan_hdd_cfg80211_add_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21489 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 21490 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 21491 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
Deepak Dhamdhere | 9f09e75 | 2016-01-09 23:17:25 -0800 | [diff] [blame] | 21492 | #if defined(KERNEL_SUPPORT_11R_CFG80211) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21493 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 21494 | #endif |
Min Liu | 0daa098 | 2019-02-01 17:50:44 +0800 | [diff] [blame] | 21495 | #ifdef CFG80211_EXTERNAL_DH_UPDATE_SUPPORT |
| 21496 | .update_owe_info = wlan_hdd_cfg80211_update_owe_info, |
| 21497 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21498 | #ifdef FEATURE_WLAN_TDLS |
| 21499 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 21500 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 21501 | #endif |
| 21502 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 21503 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 21504 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
| 21505 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 21506 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 21507 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 21508 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
| 21509 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 21510 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
| 21511 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
| 21512 | #ifdef WLAN_NL80211_TESTMODE |
| 21513 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 21514 | #endif |
| 21515 | #ifdef QCA_HT_2040_COEX |
| 21516 | .set_ap_chanwidth = wlan_hdd_cfg80211_set_ap_channel_width, |
| 21517 | #endif |
| 21518 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 21519 | #ifdef CHANNEL_SWITCH_SUPPORTED |
| 21520 | .channel_switch = wlan_hdd_cfg80211_channel_switch, |
| 21521 | #endif |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 21522 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 21523 | .set_monitor_channel = wlan_hdd_cfg80211_set_mon_ch, |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 21524 | #endif |
Vidyullatha, Kanchanapally | 528789e | 2016-05-11 20:38:37 +0530 | [diff] [blame] | 21525 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)) || \ |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 21526 | defined(CFG80211_ABORT_SCAN) |
Vidyullatha, Kanchanapally | 528789e | 2016-05-11 20:38:37 +0530 | [diff] [blame] | 21527 | .abort_scan = wlan_hdd_cfg80211_abort_scan, |
| 21528 | #endif |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21529 | #if defined(WLAN_FEATURE_FILS_SK) &&\ |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 21530 | defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) &&\ |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21531 | (defined(CFG80211_UPDATE_CONNECT_PARAMS) ||\ |
| 21532 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0))) |
| 21533 | .update_connect_params = wlan_hdd_cfg80211_update_connect_params, |
| 21534 | #endif |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 21535 | #if defined(WLAN_FEATURE_SAE) && \ |
| 21536 | defined(CFG80211_EXTERNAL_AUTH_SUPPORT) |
| 21537 | .external_auth = wlan_hdd_cfg80211_external_auth, |
| 21538 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21539 | }; |