Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Vignesh Viswanathan | fa90d62 | 2017-12-22 13:13:26 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: wlan_hdd_cfg80211.c |
| 30 | * |
| 31 | * WLAN Host Device Driver cfg80211 APIs implementation |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | #include <linux/version.h> |
| 36 | #include <linux/module.h> |
| 37 | #include <linux/kernel.h> |
| 38 | #include <linux/init.h> |
| 39 | #include <linux/etherdevice.h> |
| 40 | #include <linux/wireless.h> |
| 41 | #include <wlan_hdd_includes.h> |
| 42 | #include <net/arp.h> |
| 43 | #include <net/cfg80211.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 44 | #include <wlan_hdd_wowl.h> |
| 45 | #include <ani_global.h> |
| 46 | #include "sir_params.h" |
| 47 | #include "dot11f.h" |
| 48 | #include "wlan_hdd_assoc.h" |
| 49 | #include "wlan_hdd_wext.h" |
| 50 | #include "sme_api.h" |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 51 | #include "sme_power_save_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 52 | #include "wlan_hdd_p2p.h" |
| 53 | #include "wlan_hdd_cfg80211.h" |
| 54 | #include "wlan_hdd_hostapd.h" |
| 55 | #include "wlan_hdd_softap_tx_rx.h" |
| 56 | #include "wlan_hdd_main.h" |
| 57 | #include "wlan_hdd_power.h" |
| 58 | #include "wlan_hdd_trace.h" |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 59 | #include "qdf_str.h" |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 60 | #include "qdf_trace.h" |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 61 | #include "qdf_types.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 62 | #include "cds_utils.h" |
| 63 | #include "cds_sched.h" |
| 64 | #include "wlan_hdd_scan.h" |
| 65 | #include <qc_sap_ioctl.h> |
| 66 | #include "wlan_hdd_tdls.h" |
| 67 | #include "wlan_hdd_wmm.h" |
| 68 | #include "wma_types.h" |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 69 | #include "wma.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 70 | #include "wlan_hdd_misc.h" |
| 71 | #include "wlan_hdd_nan.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 72 | #include "wlan_logging_sock_svc.h" |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 73 | #include "sap_api.h" |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 74 | #include "csr_api.h" |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 75 | #include "pld_common.h" |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 76 | #include "wmi_unified_param.h" |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 77 | |
Paul Zhang | 3a210c5 | 2016-12-08 10:18:12 +0800 | [diff] [blame] | 78 | #ifdef WLAN_UMAC_CONVERGENCE |
| 79 | #include "wlan_cfg80211.h" |
| 80 | #endif |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 81 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 82 | #include <wlan_cfg80211_scan.h> |
Ryan Hsu | c8b27a4 | 2018-01-02 13:57:56 -0800 | [diff] [blame] | 83 | #include <wlan_cfg80211_ftm.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 84 | |
| 85 | #ifdef FEATURE_WLAN_EXTSCAN |
| 86 | #include "wlan_hdd_ext_scan.h" |
| 87 | #endif |
| 88 | |
| 89 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 90 | #include "wlan_hdd_stats.h" |
| 91 | #endif |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 92 | #include "cds_api.h" |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 93 | #include "wlan_policy_mgr_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 94 | #include "qwlan_version.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 95 | |
| 96 | #include "wlan_hdd_ocb.h" |
Manikandan Mohan | 5356c2b | 2016-04-03 15:51:35 -0700 | [diff] [blame] | 97 | #include "wlan_hdd_tsf.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 98 | |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 99 | #include "wlan_hdd_subnet_detect.h" |
Abhishek Singh | 3e6172f | 2016-05-04 16:56:48 +0530 | [diff] [blame] | 100 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 101 | #include "wlan_hdd_lpass.h" |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 102 | #include "wlan_hdd_nan_datapath.h" |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 103 | #include "wlan_hdd_disa.h" |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 104 | #include "wlan_hdd_request_manager.h" |
Krishna Kumaar Natarajan | f567650 | 2017-03-06 10:28:44 -0800 | [diff] [blame] | 105 | #include "wlan_hdd_he.h" |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 106 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 107 | #include <cdp_txrx_cmn.h> |
| 108 | #include <cdp_txrx_misc.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 109 | #include <qca_vendor.h> |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 110 | #include "wlan_pmo_ucfg_api.h" |
Naveen Rawat | 5f040ba | 2017-03-06 12:20:25 -0800 | [diff] [blame] | 111 | #include "os_if_wifi_pos.h" |
Ajit Pal Singh | 90a45a4 | 2017-04-18 18:53:46 +0530 | [diff] [blame] | 112 | #include "wlan_utility.h" |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 113 | #include "wlan_reg_ucfg_api.h" |
Naveen Rawat | d2657be | 2017-10-10 14:31:23 -0700 | [diff] [blame] | 114 | #include "wifi_pos_api.h" |
Sandeep Puligilla | 063a434 | 2018-01-10 02:50:14 -0800 | [diff] [blame] | 115 | #include "wlan_hdd_spectralscan.h" |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 116 | #include "wlan_ipa_ucfg_api.h" |
| 117 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 118 | #define g_mode_rates_size (12) |
| 119 | #define a_mode_rates_size (8) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 120 | |
| 121 | /* |
| 122 | * Android CTS verifier needs atleast this much wait time (in msec) |
| 123 | */ |
| 124 | #define MAX_REMAIN_ON_CHANNEL_DURATION (5000) |
| 125 | |
| 126 | /* |
| 127 | * Refer @tCfgProtection structure for definition of the bit map. |
| 128 | * below value is obtained by setting the following bit-fields. |
| 129 | * enable obss, fromllb, overlapOBSS and overlapFromllb protection. |
| 130 | */ |
| 131 | #define IBSS_CFG_PROTECTION_ENABLE_MASK 0x8282 |
| 132 | |
| 133 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 134 | .band = HDD_NL80211_BAND_2GHZ, \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 135 | .center_freq = (freq), \ |
| 136 | .hw_value = (chan), \ |
| 137 | .flags = (flag), \ |
| 138 | .max_antenna_gain = 0, \ |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 139 | .max_power = 0, \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 143 | .band = HDD_NL80211_BAND_5GHZ, \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 144 | .center_freq = (freq), \ |
| 145 | .hw_value = (chan), \ |
| 146 | .flags = (flag), \ |
| 147 | .max_antenna_gain = 0, \ |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 148 | .max_power = 0, \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag) \ |
| 152 | { \ |
| 153 | .bitrate = rate, \ |
| 154 | .hw_value = rate_id, \ |
| 155 | .flags = flag, \ |
| 156 | } |
| 157 | |
Dustin Brown | 5f7d38e | 2017-08-16 11:30:08 -0700 | [diff] [blame] | 158 | #ifndef WLAN_AKM_SUITE_FT_8021X |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 159 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
Dustin Brown | 5f7d38e | 2017-08-16 11:30:08 -0700 | [diff] [blame] | 160 | #endif |
| 161 | |
Dustin Brown | 234d45f | 2017-08-16 11:45:05 -0700 | [diff] [blame] | 162 | #ifndef WLAN_AKM_SUITE_FT_PSK |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 163 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
Dustin Brown | 234d45f | 2017-08-16 11:45:05 -0700 | [diff] [blame] | 164 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 165 | |
| 166 | #define HDD_CHANNEL_14 14 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 167 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 168 | #define IS_DFS_MODE_VALID(mode) ((mode >= DFS_MODE_NONE && \ |
| 169 | mode <= DFS_MODE_DEPRIORITIZE)) |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 170 | |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 171 | #define MAX_TXPOWER_SCALE 4 |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 172 | #define CDS_MAX_FEATURE_SET 8 |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 173 | |
Mohit Khanna | ceb9778 | 2017-04-05 16:27:08 -0700 | [diff] [blame] | 174 | /* |
| 175 | * Number of DPTRACE records to dump when a cfg80211 disconnect with reason |
| 176 | * WLAN_REASON_DEAUTH_LEAVING DEAUTH is received from user-space. |
| 177 | */ |
| 178 | #define WLAN_DEAUTH_DPTRACE_DUMP_COUNT 100 |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 179 | #ifndef WLAN_CIPHER_SUITE_GCMP |
| 180 | #define WLAN_CIPHER_SUITE_GCMP 0x000FAC08 |
| 181 | #endif |
| 182 | #ifndef WLAN_CIPHER_SUITE_GCMP_256 |
| 183 | #define WLAN_CIPHER_SUITE_GCMP_256 0x000FAC09 |
| 184 | #endif |
Mohit Khanna | ceb9778 | 2017-04-05 16:27:08 -0700 | [diff] [blame] | 185 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 186 | static const u32 hdd_gcmp_cipher_suits[] = { |
| 187 | WLAN_CIPHER_SUITE_GCMP, |
| 188 | WLAN_CIPHER_SUITE_GCMP_256, |
| 189 | }; |
| 190 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 191 | static const u32 hdd_cipher_suites[] = { |
| 192 | WLAN_CIPHER_SUITE_WEP40, |
| 193 | WLAN_CIPHER_SUITE_WEP104, |
| 194 | WLAN_CIPHER_SUITE_TKIP, |
| 195 | #ifdef FEATURE_WLAN_ESE |
| 196 | #define WLAN_CIPHER_SUITE_BTK 0x004096fe /* use for BTK */ |
| 197 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 198 | WLAN_CIPHER_SUITE_BTK, |
| 199 | WLAN_CIPHER_SUITE_KRK, |
| 200 | WLAN_CIPHER_SUITE_CCMP, |
| 201 | #else |
| 202 | WLAN_CIPHER_SUITE_CCMP, |
| 203 | #endif |
| 204 | #ifdef FEATURE_WLAN_WAPI |
| 205 | WLAN_CIPHER_SUITE_SMS4, |
| 206 | #endif |
| 207 | #ifdef WLAN_FEATURE_11W |
| 208 | WLAN_CIPHER_SUITE_AES_CMAC, |
Padma, Santhosh Kumar | 4117d7a | 2017-12-20 17:39:33 +0530 | [diff] [blame] | 209 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) |
| 210 | WLAN_CIPHER_SUITE_BIP_GMAC_128, |
| 211 | WLAN_CIPHER_SUITE_BIP_GMAC_256, |
| 212 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 213 | #endif |
| 214 | }; |
| 215 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 216 | static const struct ieee80211_channel hdd_channels_2_4_ghz[] = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 217 | HDD2GHZCHAN(2412, 1, 0), |
| 218 | HDD2GHZCHAN(2417, 2, 0), |
| 219 | HDD2GHZCHAN(2422, 3, 0), |
| 220 | HDD2GHZCHAN(2427, 4, 0), |
| 221 | HDD2GHZCHAN(2432, 5, 0), |
| 222 | HDD2GHZCHAN(2437, 6, 0), |
| 223 | HDD2GHZCHAN(2442, 7, 0), |
| 224 | HDD2GHZCHAN(2447, 8, 0), |
| 225 | HDD2GHZCHAN(2452, 9, 0), |
| 226 | HDD2GHZCHAN(2457, 10, 0), |
| 227 | HDD2GHZCHAN(2462, 11, 0), |
| 228 | HDD2GHZCHAN(2467, 12, 0), |
| 229 | HDD2GHZCHAN(2472, 13, 0), |
| 230 | HDD2GHZCHAN(2484, 14, 0), |
| 231 | }; |
| 232 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 233 | static const struct ieee80211_channel hdd_channels_5_ghz[] = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 234 | HDD5GHZCHAN(5180, 36, 0), |
| 235 | HDD5GHZCHAN(5200, 40, 0), |
| 236 | HDD5GHZCHAN(5220, 44, 0), |
| 237 | HDD5GHZCHAN(5240, 48, 0), |
| 238 | HDD5GHZCHAN(5260, 52, 0), |
| 239 | HDD5GHZCHAN(5280, 56, 0), |
| 240 | HDD5GHZCHAN(5300, 60, 0), |
| 241 | HDD5GHZCHAN(5320, 64, 0), |
| 242 | HDD5GHZCHAN(5500, 100, 0), |
| 243 | HDD5GHZCHAN(5520, 104, 0), |
| 244 | HDD5GHZCHAN(5540, 108, 0), |
| 245 | HDD5GHZCHAN(5560, 112, 0), |
| 246 | HDD5GHZCHAN(5580, 116, 0), |
| 247 | HDD5GHZCHAN(5600, 120, 0), |
| 248 | HDD5GHZCHAN(5620, 124, 0), |
| 249 | HDD5GHZCHAN(5640, 128, 0), |
| 250 | HDD5GHZCHAN(5660, 132, 0), |
| 251 | HDD5GHZCHAN(5680, 136, 0), |
| 252 | HDD5GHZCHAN(5700, 140, 0), |
| 253 | HDD5GHZCHAN(5720, 144, 0), |
| 254 | HDD5GHZCHAN(5745, 149, 0), |
| 255 | HDD5GHZCHAN(5765, 153, 0), |
| 256 | HDD5GHZCHAN(5785, 157, 0), |
| 257 | HDD5GHZCHAN(5805, 161, 0), |
| 258 | HDD5GHZCHAN(5825, 165, 0), |
Ashish Kumar Dhanotiya | cc2e0d3 | 2017-08-24 20:13:08 +0530 | [diff] [blame] | 259 | }; |
| 260 | |
| 261 | static const struct ieee80211_channel hdd_channels_dot11p[] = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 262 | HDD5GHZCHAN(5852, 170, 0), |
| 263 | HDD5GHZCHAN(5855, 171, 0), |
| 264 | HDD5GHZCHAN(5860, 172, 0), |
| 265 | HDD5GHZCHAN(5865, 173, 0), |
| 266 | HDD5GHZCHAN(5870, 174, 0), |
| 267 | HDD5GHZCHAN(5875, 175, 0), |
| 268 | HDD5GHZCHAN(5880, 176, 0), |
| 269 | HDD5GHZCHAN(5885, 177, 0), |
| 270 | HDD5GHZCHAN(5890, 178, 0), |
| 271 | HDD5GHZCHAN(5895, 179, 0), |
| 272 | HDD5GHZCHAN(5900, 180, 0), |
| 273 | HDD5GHZCHAN(5905, 181, 0), |
| 274 | HDD5GHZCHAN(5910, 182, 0), |
| 275 | HDD5GHZCHAN(5915, 183, 0), |
| 276 | HDD5GHZCHAN(5920, 184, 0), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 277 | }; |
| 278 | |
| 279 | static struct ieee80211_rate g_mode_rates[] = { |
| 280 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 281 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 282 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 283 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 284 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 285 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 286 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 287 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 288 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 289 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 290 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
| 291 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 292 | }; |
| 293 | |
| 294 | static struct ieee80211_rate a_mode_rates[] = { |
| 295 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 296 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 297 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 298 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 299 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 300 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 301 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
| 302 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 303 | }; |
| 304 | |
| 305 | static struct ieee80211_supported_band wlan_hdd_band_2_4_ghz = { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 306 | .channels = NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 307 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_ghz), |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 308 | .band = HDD_NL80211_BAND_2GHZ, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 309 | .bitrates = g_mode_rates, |
| 310 | .n_bitrates = g_mode_rates_size, |
| 311 | .ht_cap.ht_supported = 1, |
| 312 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 313 | | IEEE80211_HT_CAP_GRN_FLD |
| 314 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 315 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 316 | | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 317 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 318 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 319 | .ht_cap.mcs.rx_mask = {0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0,}, |
| 320 | .ht_cap.mcs.rx_highest = cpu_to_le16(72), |
| 321 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 322 | }; |
| 323 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 324 | static struct ieee80211_supported_band wlan_hdd_band_5_ghz = { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 325 | .channels = NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 326 | .n_channels = ARRAY_SIZE(hdd_channels_5_ghz), |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 327 | .band = HDD_NL80211_BAND_5GHZ, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 328 | .bitrates = a_mode_rates, |
| 329 | .n_bitrates = a_mode_rates_size, |
| 330 | .ht_cap.ht_supported = 1, |
| 331 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 332 | | IEEE80211_HT_CAP_GRN_FLD |
| 333 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 334 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 335 | | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 336 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 337 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 338 | .ht_cap.mcs.rx_mask = {0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0,}, |
| 339 | .ht_cap.mcs.rx_highest = cpu_to_le16(72), |
| 340 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 341 | .vht_cap.vht_supported = 1, |
| 342 | }; |
| 343 | |
| 344 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 345 | * TX/RX direction for each kind of interface |
| 346 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 347 | static const struct ieee80211_txrx_stypes |
| 348 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 349 | [NL80211_IFTYPE_STATION] = { |
| 350 | .tx = 0xffff, |
| 351 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
Padma, Santhosh Kumar | 1ccc133 | 2017-09-13 17:39:01 +0530 | [diff] [blame] | 352 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 353 | BIT(SIR_MAC_MGMT_AUTH), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 354 | }, |
| 355 | [NL80211_IFTYPE_AP] = { |
| 356 | .tx = 0xffff, |
| 357 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 358 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 359 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 360 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 361 | BIT(SIR_MAC_MGMT_AUTH) | |
| 362 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 363 | BIT(SIR_MAC_MGMT_ACTION), |
| 364 | }, |
| 365 | [NL80211_IFTYPE_ADHOC] = { |
| 366 | .tx = 0xffff, |
| 367 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 368 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 369 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 370 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 371 | BIT(SIR_MAC_MGMT_AUTH) | |
| 372 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 373 | BIT(SIR_MAC_MGMT_ACTION), |
| 374 | }, |
| 375 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 376 | .tx = 0xffff, |
| 377 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 378 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 379 | }, |
| 380 | [NL80211_IFTYPE_P2P_GO] = { |
| 381 | /* This is also same as for SoftAP */ |
| 382 | .tx = 0xffff, |
| 383 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 384 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 385 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 386 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 387 | BIT(SIR_MAC_MGMT_AUTH) | |
| 388 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 389 | BIT(SIR_MAC_MGMT_ACTION), |
| 390 | }, |
| 391 | }; |
| 392 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 393 | /* Interface limits and combinations registered by the driver */ |
| 394 | |
| 395 | /* STA ( + STA ) combination */ |
| 396 | static const struct ieee80211_iface_limit |
| 397 | wlan_hdd_sta_iface_limit[] = { |
| 398 | { |
| 399 | .max = 3, /* p2p0 is a STA as well */ |
| 400 | .types = BIT(NL80211_IFTYPE_STATION), |
| 401 | }, |
| 402 | }; |
| 403 | |
| 404 | /* ADHOC (IBSS) limit */ |
| 405 | static const struct ieee80211_iface_limit |
| 406 | wlan_hdd_adhoc_iface_limit[] = { |
| 407 | { |
| 408 | .max = 1, |
| 409 | .types = BIT(NL80211_IFTYPE_STATION), |
| 410 | }, |
| 411 | { |
| 412 | .max = 1, |
| 413 | .types = BIT(NL80211_IFTYPE_ADHOC), |
| 414 | }, |
| 415 | }; |
| 416 | |
| 417 | /* AP ( + AP ) combination */ |
| 418 | static const struct ieee80211_iface_limit |
| 419 | wlan_hdd_ap_iface_limit[] = { |
| 420 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 421 | .max = (QDF_MAX_NO_OF_SAP_MODE + SAP_MAX_OBSS_STA_CNT), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 422 | .types = BIT(NL80211_IFTYPE_AP), |
| 423 | }, |
| 424 | }; |
| 425 | |
| 426 | /* P2P limit */ |
| 427 | static const struct ieee80211_iface_limit |
| 428 | wlan_hdd_p2p_iface_limit[] = { |
| 429 | { |
| 430 | .max = 1, |
| 431 | .types = BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 432 | }, |
| 433 | { |
| 434 | .max = 1, |
| 435 | .types = BIT(NL80211_IFTYPE_P2P_GO), |
| 436 | }, |
| 437 | }; |
| 438 | |
| 439 | static const struct ieee80211_iface_limit |
| 440 | wlan_hdd_sta_ap_iface_limit[] = { |
| 441 | { |
| 442 | /* We need 1 extra STA interface for OBSS scan when SAP starts |
| 443 | * with HT40 in STA+SAP concurrency mode |
| 444 | */ |
| 445 | .max = (1 + SAP_MAX_OBSS_STA_CNT), |
| 446 | .types = BIT(NL80211_IFTYPE_STATION), |
| 447 | }, |
| 448 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 449 | .max = QDF_MAX_NO_OF_SAP_MODE, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 450 | .types = BIT(NL80211_IFTYPE_AP), |
| 451 | }, |
| 452 | }; |
| 453 | |
| 454 | /* STA + P2P combination */ |
| 455 | static const struct ieee80211_iface_limit |
| 456 | wlan_hdd_sta_p2p_iface_limit[] = { |
| 457 | { |
| 458 | /* One reserved for dedicated P2PDEV usage */ |
| 459 | .max = 2, |
| 460 | .types = BIT(NL80211_IFTYPE_STATION) |
| 461 | }, |
| 462 | { |
| 463 | /* Support for two identical (GO + GO or CLI + CLI) |
| 464 | * or dissimilar (GO + CLI) P2P interfaces |
| 465 | */ |
| 466 | .max = 2, |
| 467 | .types = BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 468 | }, |
| 469 | }; |
| 470 | |
| 471 | /* STA + AP + P2PGO combination */ |
| 472 | static const struct ieee80211_iface_limit |
| 473 | wlan_hdd_sta_ap_p2pgo_iface_limit[] = { |
| 474 | /* Support for AP+P2PGO interfaces */ |
| 475 | { |
| 476 | .max = 2, |
| 477 | .types = BIT(NL80211_IFTYPE_STATION) |
| 478 | }, |
| 479 | { |
| 480 | .max = 1, |
| 481 | .types = BIT(NL80211_IFTYPE_P2P_GO) |
| 482 | }, |
| 483 | { |
| 484 | .max = 1, |
| 485 | .types = BIT(NL80211_IFTYPE_AP) |
| 486 | } |
| 487 | }; |
| 488 | |
| 489 | /* SAP + P2P combination */ |
| 490 | static const struct ieee80211_iface_limit |
| 491 | wlan_hdd_sap_p2p_iface_limit[] = { |
| 492 | { |
| 493 | /* 1 dedicated for p2p0 which is a STA type */ |
| 494 | .max = 1, |
| 495 | .types = BIT(NL80211_IFTYPE_STATION) |
| 496 | }, |
| 497 | { |
| 498 | /* The p2p interface in SAP+P2P can be GO/CLI. |
| 499 | * The p2p connection can be formed on p2p0 or p2p-p2p0-x. |
| 500 | */ |
| 501 | .max = 1, |
| 502 | .types = BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 503 | }, |
| 504 | { |
| 505 | /* SAP+GO to support only one SAP interface */ |
| 506 | .max = 1, |
| 507 | .types = BIT(NL80211_IFTYPE_AP) |
| 508 | } |
| 509 | }; |
| 510 | |
| 511 | /* P2P + P2P combination */ |
| 512 | static const struct ieee80211_iface_limit |
| 513 | wlan_hdd_p2p_p2p_iface_limit[] = { |
| 514 | { |
| 515 | /* 1 dedicated for p2p0 which is a STA type */ |
| 516 | .max = 1, |
| 517 | .types = BIT(NL80211_IFTYPE_STATION) |
| 518 | }, |
| 519 | { |
| 520 | /* The p2p interface in P2P+P2P can be GO/CLI. |
| 521 | * For P2P+P2P, the new interfaces are formed on p2p-p2p0-x. |
| 522 | */ |
| 523 | .max = 2, |
| 524 | .types = BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 525 | }, |
| 526 | }; |
| 527 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 528 | static const struct ieee80211_iface_limit |
| 529 | wlan_hdd_mon_iface_limit[] = { |
| 530 | { |
| 531 | .max = 3, /* Monitor interface */ |
| 532 | .types = BIT(NL80211_IFTYPE_MONITOR), |
| 533 | }, |
| 534 | }; |
| 535 | |
| 536 | static struct ieee80211_iface_combination |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 537 | wlan_hdd_iface_combination[] = { |
| 538 | /* STA */ |
| 539 | { |
| 540 | .limits = wlan_hdd_sta_iface_limit, |
| 541 | .num_different_channels = 2, |
| 542 | .max_interfaces = 3, |
| 543 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_iface_limit), |
| 544 | }, |
| 545 | /* ADHOC */ |
| 546 | { |
| 547 | .limits = wlan_hdd_adhoc_iface_limit, |
Krunal Soni | 2c68f23 | 2015-10-26 20:52:51 -0700 | [diff] [blame] | 548 | .num_different_channels = 2, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 549 | .max_interfaces = 2, |
| 550 | .n_limits = ARRAY_SIZE(wlan_hdd_adhoc_iface_limit), |
| 551 | }, |
| 552 | /* AP */ |
| 553 | { |
| 554 | .limits = wlan_hdd_ap_iface_limit, |
| 555 | .num_different_channels = 2, |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 556 | .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] | 557 | .n_limits = ARRAY_SIZE(wlan_hdd_ap_iface_limit), |
hqu | 3c4ed3d | 2017-09-19 11:42:35 +0800 | [diff] [blame] | 558 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) || \ |
| 559 | defined(CFG80211_BEACON_INTERVAL_BACKPORT) |
| 560 | .beacon_int_min_gcd = 1, |
| 561 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 562 | }, |
| 563 | /* P2P */ |
| 564 | { |
| 565 | .limits = wlan_hdd_p2p_iface_limit, |
| 566 | .num_different_channels = 2, |
| 567 | .max_interfaces = 2, |
| 568 | .n_limits = ARRAY_SIZE(wlan_hdd_p2p_iface_limit), |
| 569 | }, |
| 570 | /* STA + AP */ |
| 571 | { |
| 572 | .limits = wlan_hdd_sta_ap_iface_limit, |
| 573 | .num_different_channels = 2, |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 574 | .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] | 575 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_ap_iface_limit), |
| 576 | .beacon_int_infra_match = true, |
hqu | 3c4ed3d | 2017-09-19 11:42:35 +0800 | [diff] [blame] | 577 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) || \ |
| 578 | defined(CFG80211_BEACON_INTERVAL_BACKPORT) |
| 579 | .beacon_int_min_gcd = 1, |
| 580 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 581 | }, |
| 582 | /* STA + P2P */ |
| 583 | { |
| 584 | .limits = wlan_hdd_sta_p2p_iface_limit, |
| 585 | .num_different_channels = 2, |
| 586 | /* one interface reserved for P2PDEV dedicated usage */ |
| 587 | .max_interfaces = 4, |
| 588 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_p2p_iface_limit), |
| 589 | .beacon_int_infra_match = true, |
| 590 | }, |
| 591 | /* STA + P2P GO + SAP */ |
| 592 | { |
| 593 | .limits = wlan_hdd_sta_ap_p2pgo_iface_limit, |
| 594 | /* we can allow 3 channels for three different persona |
| 595 | * but due to firmware limitation, allow max 2 concrnt channels. |
| 596 | */ |
| 597 | .num_different_channels = 2, |
| 598 | /* one interface reserved for P2PDEV dedicated usage */ |
| 599 | .max_interfaces = 4, |
| 600 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_ap_p2pgo_iface_limit), |
| 601 | .beacon_int_infra_match = true, |
| 602 | }, |
| 603 | /* SAP + P2P */ |
| 604 | { |
| 605 | .limits = wlan_hdd_sap_p2p_iface_limit, |
| 606 | .num_different_channels = 2, |
| 607 | /* 1-p2p0 + 1-SAP + 1-P2P (on p2p0 or p2p-p2p0-x) */ |
| 608 | .max_interfaces = 3, |
| 609 | .n_limits = ARRAY_SIZE(wlan_hdd_sap_p2p_iface_limit), |
| 610 | .beacon_int_infra_match = true, |
| 611 | }, |
| 612 | /* P2P + P2P */ |
| 613 | { |
| 614 | .limits = wlan_hdd_p2p_p2p_iface_limit, |
| 615 | .num_different_channels = 2, |
| 616 | /* 1-p2p0 + 2-P2P (on p2p-p2p0-x) */ |
| 617 | .max_interfaces = 3, |
| 618 | .n_limits = ARRAY_SIZE(wlan_hdd_p2p_p2p_iface_limit), |
| 619 | .beacon_int_infra_match = true, |
| 620 | }, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 621 | /* Monitor */ |
| 622 | { |
| 623 | .limits = wlan_hdd_mon_iface_limit, |
| 624 | .max_interfaces = 3, |
| 625 | .num_different_channels = 2, |
| 626 | .n_limits = ARRAY_SIZE(wlan_hdd_mon_iface_limit), |
| 627 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 628 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 629 | |
| 630 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 631 | |
| 632 | #ifdef WLAN_NL80211_TESTMODE |
| 633 | enum wlan_hdd_tm_attr { |
| 634 | WLAN_HDD_TM_ATTR_INVALID = 0, |
| 635 | WLAN_HDD_TM_ATTR_CMD = 1, |
| 636 | WLAN_HDD_TM_ATTR_DATA = 2, |
| 637 | WLAN_HDD_TM_ATTR_STREAM_ID = 3, |
| 638 | WLAN_HDD_TM_ATTR_TYPE = 4, |
| 639 | /* keep last */ |
| 640 | WLAN_HDD_TM_ATTR_AFTER_LAST, |
| 641 | WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1, |
| 642 | }; |
| 643 | |
| 644 | enum wlan_hdd_tm_cmd { |
| 645 | WLAN_HDD_TM_CMD_WLAN_FTM = 0, |
| 646 | WLAN_HDD_TM_CMD_WLAN_HB = 1, |
| 647 | }; |
| 648 | |
| 649 | #define WLAN_HDD_TM_DATA_MAX_LEN 5000 |
| 650 | |
| 651 | static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] = { |
| 652 | [WLAN_HDD_TM_ATTR_CMD] = {.type = NLA_U32}, |
| 653 | [WLAN_HDD_TM_ATTR_DATA] = {.type = NLA_BINARY, |
| 654 | .len = WLAN_HDD_TM_DATA_MAX_LEN}, |
| 655 | }; |
| 656 | #endif /* WLAN_NL80211_TESTMODE */ |
| 657 | |
Lin Bai | a016e9a | 2017-08-29 19:10:42 +0800 | [diff] [blame] | 658 | enum wlan_hdd_vendor_ie_access_policy { |
| 659 | WLAN_HDD_VENDOR_IE_ACCESS_NONE = 0, |
| 660 | WLAN_HDD_VENDOR_IE_ACCESS_ALLOW_IF_LISTED, |
| 661 | }; |
| 662 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 663 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 664 | static const struct wiphy_wowlan_support wowlan_support_cfg80211_init = { |
| 665 | .flags = WIPHY_WOWLAN_MAGIC_PKT, |
| 666 | .n_patterns = WOWL_MAX_PTRNS_ALLOWED, |
| 667 | .pattern_min_len = 1, |
| 668 | .pattern_max_len = WOWL_PTRN_MAX_SIZE, |
| 669 | }; |
| 670 | #endif |
| 671 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 672 | /** |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 673 | * hdd_add_channel_switch_support()- Adds Channel Switch flag if supported |
| 674 | * @flags: Pointer to the flags to Add channel switch flag. |
| 675 | * |
| 676 | * This Function adds Channel Switch support flag, if channel switch is |
| 677 | * supported by kernel. |
| 678 | * Return: void. |
| 679 | */ |
| 680 | #ifdef CHANNEL_SWITCH_SUPPORTED |
| 681 | static inline void hdd_add_channel_switch_support(uint32_t *flags) |
| 682 | { |
Krishna Kumaar Natarajan | 8a8df26 | 2015-12-04 11:43:46 -0800 | [diff] [blame] | 683 | *flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 684 | } |
| 685 | #else |
| 686 | static inline void hdd_add_channel_switch_support(uint32_t *flags) |
| 687 | { |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 688 | } |
| 689 | #endif |
| 690 | |
Manikandan Mohan | 22b8372 | 2015-12-15 15:03:23 -0800 | [diff] [blame] | 691 | #ifdef FEATURE_WLAN_TDLS |
| 692 | |
| 693 | /* TDLS capabilities params */ |
| 694 | #define PARAM_MAX_TDLS_SESSION \ |
| 695 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_CAPS_MAX_CONC_SESSIONS |
| 696 | #define PARAM_TDLS_FEATURE_SUPPORT \ |
| 697 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_CAPS_FEATURES_SUPPORTED |
| 698 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 699 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 700 | * __wlan_hdd_cfg80211_get_tdls_capabilities() - Provide TDLS Capabilites. |
| 701 | * @wiphy: WIPHY structure pointer |
| 702 | * @wdev: Wireless device structure pointer |
| 703 | * @data: Pointer to the data received |
| 704 | * @data_len: Length of the data received |
| 705 | * |
| 706 | * This function provides TDLS capabilities |
| 707 | * |
| 708 | * Return: 0 on success and errno on failure |
| 709 | */ |
| 710 | static int __wlan_hdd_cfg80211_get_tdls_capabilities(struct wiphy *wiphy, |
| 711 | struct wireless_dev *wdev, |
| 712 | const void *data, |
| 713 | int data_len) |
| 714 | { |
| 715 | int status; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 716 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 717 | struct sk_buff *skb; |
| 718 | uint32_t set = 0; |
Frank Liu | 5c63dc8 | 2017-09-07 14:49:05 +0800 | [diff] [blame] | 719 | uint32_t max_num_tdls_sta = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 720 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 721 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 722 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 723 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 724 | hdd_err("Command not allowed in FTM mode"); |
| 725 | return -EPERM; |
| 726 | } |
| 727 | |
| 728 | status = wlan_hdd_validate_context(hdd_ctx); |
| 729 | if (status) |
| 730 | return status; |
| 731 | |
| 732 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, (2 * sizeof(u32)) + |
| 733 | NLMSG_HDRLEN); |
| 734 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 735 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 736 | goto fail; |
| 737 | } |
| 738 | |
| 739 | if (false == hdd_ctx->config->fEnableTDLSSupport) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 740 | hdd_debug("TDLS feature not Enabled or Not supported in FW"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 741 | if (nla_put_u32(skb, PARAM_MAX_TDLS_SESSION, 0) || |
| 742 | nla_put_u32(skb, PARAM_TDLS_FEATURE_SUPPORT, 0)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 743 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 744 | goto fail; |
| 745 | } |
| 746 | } else { |
| 747 | set = set | WIFI_TDLS_SUPPORT; |
| 748 | set = set | (hdd_ctx->config->fTDLSExternalControl ? |
| 749 | WIFI_TDLS_EXTERNAL_CONTROL_SUPPORT : 0); |
| 750 | set = set | (hdd_ctx->config->fEnableTDLSOffChannel ? |
| 751 | WIIF_TDLS_OFFCHANNEL_SUPPORT : 0); |
Frank Liu | 5c63dc8 | 2017-09-07 14:49:05 +0800 | [diff] [blame] | 752 | if (hdd_ctx->config->fEnableTDLSSleepSta || |
| 753 | hdd_ctx->config->fEnableTDLSBufferSta || |
| 754 | hdd_ctx->config->fEnableTDLSOffChannel) |
| 755 | max_num_tdls_sta = HDD_MAX_NUM_TDLS_STA_P_UAPSD_OFFCHAN; |
| 756 | else |
| 757 | max_num_tdls_sta = HDD_MAX_NUM_TDLS_STA; |
| 758 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 759 | hdd_debug("TDLS Feature supported value %x", set); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 760 | if (nla_put_u32(skb, PARAM_MAX_TDLS_SESSION, |
Frank Liu | 5c63dc8 | 2017-09-07 14:49:05 +0800 | [diff] [blame] | 761 | max_num_tdls_sta) || |
| 762 | nla_put_u32(skb, PARAM_TDLS_FEATURE_SUPPORT, set)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 763 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 764 | goto fail; |
| 765 | } |
| 766 | } |
| 767 | return cfg80211_vendor_cmd_reply(skb); |
| 768 | fail: |
| 769 | if (skb) |
| 770 | kfree_skb(skb); |
| 771 | return -EINVAL; |
| 772 | } |
| 773 | |
| 774 | /** |
| 775 | * wlan_hdd_cfg80211_get_tdls_capabilities() - Provide TDLS Capabilites. |
| 776 | * @wiphy: WIPHY structure pointer |
| 777 | * @wdev: Wireless device structure pointer |
| 778 | * @data: Pointer to the data received |
| 779 | * @data_len: Length of the data received |
| 780 | * |
| 781 | * This function provides TDLS capabilities |
| 782 | * |
| 783 | * Return: 0 on success and errno on failure |
| 784 | */ |
| 785 | static int |
| 786 | wlan_hdd_cfg80211_get_tdls_capabilities(struct wiphy *wiphy, |
| 787 | struct wireless_dev *wdev, |
| 788 | const void *data, |
| 789 | int data_len) |
| 790 | { |
| 791 | int ret; |
| 792 | |
| 793 | cds_ssr_protect(__func__); |
| 794 | ret = __wlan_hdd_cfg80211_get_tdls_capabilities(wiphy, wdev, |
| 795 | data, data_len); |
| 796 | cds_ssr_unprotect(__func__); |
| 797 | |
| 798 | return ret; |
| 799 | } |
| 800 | #endif |
| 801 | |
| 802 | #ifdef QCA_HT_2040_COEX |
| 803 | static void wlan_hdd_cfg80211_start_pending_acs(struct work_struct *work); |
| 804 | #endif |
| 805 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 806 | int wlan_hdd_merge_avoid_freqs(struct ch_avoid_ind_type *destFreqList, |
| 807 | struct ch_avoid_ind_type *srcFreqList) |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 808 | { |
| 809 | int i; |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 810 | struct ch_avoid_freq_type *avoid_range = |
| 811 | &destFreqList->avoid_freq_range[destFreqList->ch_avoid_range_cnt]; |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 812 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 813 | destFreqList->ch_avoid_range_cnt += srcFreqList->ch_avoid_range_cnt; |
Jeff Johnson | 31304cc | 2017-09-30 19:08:09 -0700 | [diff] [blame] | 814 | if (destFreqList->ch_avoid_range_cnt > CH_AVOID_MAX_RANGE) { |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 815 | hdd_err("avoid freq overflow"); |
| 816 | return -EINVAL; |
| 817 | } |
| 818 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 819 | for (i = 0; i < srcFreqList->ch_avoid_range_cnt; i++) { |
| 820 | avoid_range->start_freq = |
| 821 | srcFreqList->avoid_freq_range[i].start_freq; |
| 822 | avoid_range->end_freq = |
| 823 | srcFreqList->avoid_freq_range[i].end_freq; |
| 824 | avoid_range++; |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 825 | } |
| 826 | return 0; |
| 827 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 828 | /* |
| 829 | * FUNCTION: wlan_hdd_send_avoid_freq_event |
| 830 | * This is called when wlan driver needs to send vendor specific |
| 831 | * avoid frequency range event to userspace |
| 832 | */ |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 833 | 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] | 834 | struct ch_avoid_ind_type *avoid_freq_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 835 | { |
| 836 | struct sk_buff *vendor_event; |
| 837 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 838 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 839 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 840 | if (!hdd_ctx) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 841 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 842 | return -EINVAL; |
| 843 | } |
| 844 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 845 | if (!avoid_freq_list) { |
| 846 | hdd_err("avoid_freq_list is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 847 | return -EINVAL; |
| 848 | } |
| 849 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 850 | vendor_event = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 851 | NULL, sizeof(struct ch_avoid_ind_type), |
| 852 | QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX, |
| 853 | GFP_KERNEL); |
| 854 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 855 | if (!vendor_event) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 856 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 857 | return -EINVAL; |
| 858 | } |
| 859 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 860 | memcpy(skb_put(vendor_event, sizeof(struct ch_avoid_ind_type)), |
| 861 | (void *)avoid_freq_list, sizeof(struct ch_avoid_ind_type)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 862 | |
| 863 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 864 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 865 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 866 | return 0; |
| 867 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 868 | |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 869 | /* |
| 870 | * define short names for the global vendor params |
| 871 | * used by QCA_NL80211_VENDOR_SUBCMD_HANG |
| 872 | */ |
| 873 | #define HANG_REASON_INDEX QCA_NL80211_VENDOR_SUBCMD_HANG_REASON_INDEX |
| 874 | |
| 875 | /** |
| 876 | * hdd_convert_hang_reason() - Convert cds recovery reason to vendor specific |
| 877 | * hang reason |
| 878 | * @reason: cds recovery reason |
| 879 | * |
| 880 | * Return: Vendor specific reason code |
| 881 | */ |
| 882 | static enum qca_wlan_vendor_hang_reason |
| 883 | hdd_convert_hang_reason(enum qdf_hang_reason reason) |
| 884 | { |
Mahesh Kumar Kalikot Veetil | 9111a57 | 2017-10-10 16:11:11 -0700 | [diff] [blame] | 885 | u32 ret_val; |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 886 | |
| 887 | switch (reason) { |
| 888 | case QDF_RX_HASH_NO_ENTRY_FOUND: |
| 889 | ret_val = QCA_WLAN_HANG_RX_HASH_NO_ENTRY_FOUND; |
| 890 | break; |
| 891 | case QDF_PEER_DELETION_TIMEDOUT: |
| 892 | ret_val = QCA_WLAN_HANG_PEER_DELETION_TIMEDOUT; |
| 893 | break; |
| 894 | case QDF_PEER_UNMAP_TIMEDOUT: |
| 895 | ret_val = QCA_WLAN_HANG_PEER_UNMAP_TIMEDOUT; |
| 896 | break; |
| 897 | case QDF_SCAN_REQ_EXPIRED: |
| 898 | ret_val = QCA_WLAN_HANG_SCAN_REQ_EXPIRED; |
| 899 | break; |
| 900 | case QDF_SCAN_ATTEMPT_FAILURES: |
| 901 | ret_val = QCA_WLAN_HANG_SCAN_ATTEMPT_FAILURES; |
| 902 | break; |
| 903 | case QDF_GET_MSG_BUFF_FAILURE: |
| 904 | ret_val = QCA_WLAN_HANG_GET_MSG_BUFF_FAILURE; |
| 905 | break; |
| 906 | case QDF_ACTIVE_LIST_TIMEOUT: |
| 907 | ret_val = QCA_WLAN_HANG_ACTIVE_LIST_TIMEOUT; |
| 908 | break; |
| 909 | case QDF_SUSPEND_TIMEOUT: |
| 910 | ret_val = QCA_WLAN_HANG_SUSPEND_TIMEOUT; |
| 911 | break; |
| 912 | case QDF_RESUME_TIMEOUT: |
| 913 | ret_val = QCA_WLAN_HANG_RESUME_TIMEOUT; |
| 914 | break; |
| 915 | case QDF_REASON_UNSPECIFIED: |
| 916 | default: |
| 917 | ret_val = QCA_WLAN_HANG_REASON_UNSPECIFIED; |
| 918 | } |
| 919 | return ret_val; |
| 920 | } |
| 921 | |
| 922 | /** |
| 923 | * wlan_hdd_send_hang_reason_event() - Send hang reason to the userspace |
| 924 | * @hdd_ctx: Pointer to hdd context |
| 925 | * @reason: cds recovery reason |
| 926 | * |
| 927 | * Return: 0 on success or failure reason |
| 928 | */ |
| 929 | int wlan_hdd_send_hang_reason_event(struct hdd_context *hdd_ctx, |
| 930 | enum qdf_hang_reason reason) |
| 931 | { |
| 932 | struct sk_buff *vendor_event; |
| 933 | enum qca_wlan_vendor_hang_reason hang_reason; |
| 934 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 935 | hdd_enter(); |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 936 | |
| 937 | if (!hdd_ctx) { |
| 938 | hdd_err("HDD context is null"); |
| 939 | return -EINVAL; |
| 940 | } |
| 941 | |
| 942 | vendor_event = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 943 | NULL, |
| 944 | sizeof(uint32_t), |
| 945 | HANG_REASON_INDEX, |
| 946 | GFP_KERNEL); |
| 947 | if (!vendor_event) { |
| 948 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 949 | return -ENOMEM; |
| 950 | } |
| 951 | |
| 952 | hang_reason = hdd_convert_hang_reason(reason); |
| 953 | |
| 954 | 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] | 955 | (uint32_t)hang_reason)) { |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 956 | hdd_err("QCA_WLAN_VENDOR_ATTR_HANG_REASON put fail"); |
| 957 | kfree_skb(vendor_event); |
| 958 | return -EINVAL; |
| 959 | } |
| 960 | |
| 961 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 962 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 963 | hdd_exit(); |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 964 | return 0; |
| 965 | } |
Mahesh Kumar Kalikot Veetil | 9111a57 | 2017-10-10 16:11:11 -0700 | [diff] [blame] | 966 | |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 967 | #undef HANG_REASON_INDEX |
| 968 | |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 969 | /** |
| 970 | * wlan_hdd_get_adjacent_chan(): Gets next/previous channel |
| 971 | * with respect to the channel passed. |
| 972 | * @chan: Channel |
| 973 | * @upper: If "true" then next channel is returned or else |
| 974 | * previous channel is returned. |
| 975 | * |
| 976 | * This function returns the next/previous adjacent-channel to |
| 977 | * the channel passed. If "upper = true" then next channel is |
| 978 | * returned else previous is returned. |
| 979 | */ |
| 980 | int wlan_hdd_get_adjacent_chan(uint8_t chan, bool upper) |
| 981 | { |
| 982 | enum channel_enum ch_idx = reg_get_chan_enum(chan); |
| 983 | |
| 984 | if (ch_idx == INVALID_CHANNEL) |
| 985 | return -EINVAL; |
| 986 | |
| 987 | if (upper && (ch_idx < (NUM_CHANNELS - 1))) |
| 988 | ch_idx++; |
| 989 | else if (!upper && (ch_idx > CHAN_ENUM_1)) |
| 990 | ch_idx--; |
| 991 | else |
| 992 | return -EINVAL; |
| 993 | |
| 994 | return WLAN_REG_CH_NUM(ch_idx); |
| 995 | } |
| 996 | |
| 997 | /** |
| 998 | * wlan_hdd_send_avoid_freq_for_dnbs(): Sends list of frequencies to be |
| 999 | * avoided when Do_Not_Break_Stream is active. |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1000 | * @hdd_ctx: HDD Context |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1001 | * @op_chan: AP/P2P-GO operating channel |
| 1002 | * |
| 1003 | * This function sends list of frequencies to be avoided when |
| 1004 | * Do_Not_Break_Stream is active. |
| 1005 | * To clear the avoid_frequency_list in the application, |
| 1006 | * op_chan = 0 can be passed. |
| 1007 | * |
| 1008 | * Return: 0 on success and errno on failure |
| 1009 | */ |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1010 | 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] | 1011 | { |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1012 | struct ch_avoid_ind_type p2p_avoid_freq_list; |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1013 | uint8_t min_chan, max_chan; |
| 1014 | int ret; |
| 1015 | int chan; |
| 1016 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 1017 | hdd_enter(); |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1018 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1019 | if (!hdd_ctx) { |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1020 | hdd_err("invalid param"); |
| 1021 | return -EINVAL; |
| 1022 | } |
| 1023 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1024 | 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] | 1025 | /* |
| 1026 | * If channel passed is zero, clear the avoid_freq list in application. |
| 1027 | */ |
| 1028 | if (!op_chan) { |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1029 | #ifdef FEATURE_WLAN_CH_AVOID |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1030 | mutex_lock(&hdd_ctx->avoid_freq_lock); |
| 1031 | qdf_mem_zero(&hdd_ctx->dnbs_avoid_freq_list, |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1032 | sizeof(struct ch_avoid_ind_type)); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1033 | if (hdd_ctx->coex_avoid_freq_list.ch_avoid_range_cnt) |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1034 | memcpy(&p2p_avoid_freq_list, |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1035 | &hdd_ctx->coex_avoid_freq_list, |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1036 | sizeof(struct ch_avoid_ind_type)); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1037 | mutex_unlock(&hdd_ctx->avoid_freq_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1038 | #endif |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1039 | ret = wlan_hdd_send_avoid_freq_event(hdd_ctx, |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1040 | &p2p_avoid_freq_list); |
| 1041 | if (ret) |
| 1042 | hdd_err("wlan_hdd_send_avoid_freq_event error:%d", |
| 1043 | ret); |
| 1044 | |
| 1045 | return ret; |
| 1046 | } |
| 1047 | |
| 1048 | if (WLAN_REG_IS_24GHZ_CH(op_chan)) { |
| 1049 | min_chan = REG_MIN_24GHZ_CH_NUM; |
| 1050 | max_chan = REG_MAX_24GHZ_CH_NUM; |
| 1051 | } else if WLAN_REG_IS_5GHZ_CH(op_chan) { |
| 1052 | min_chan = REG_MIN_5GHZ_CH_NUM; |
| 1053 | max_chan = REG_MAX_5GHZ_CH_NUM; |
| 1054 | } else { |
| 1055 | hdd_err("invalid channel:%d", op_chan); |
| 1056 | return -EINVAL; |
| 1057 | } |
| 1058 | |
| 1059 | if ((op_chan > min_chan) && (op_chan < max_chan)) { |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1060 | p2p_avoid_freq_list.ch_avoid_range_cnt = 2; |
| 1061 | p2p_avoid_freq_list.avoid_freq_range[0].start_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1062 | wlan_chan_to_freq(min_chan); |
| 1063 | |
| 1064 | /* Get channel before the op_chan */ |
| 1065 | chan = wlan_hdd_get_adjacent_chan(op_chan, false); |
| 1066 | if (chan < 0) |
| 1067 | return -EINVAL; |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1068 | p2p_avoid_freq_list.avoid_freq_range[0].end_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1069 | wlan_chan_to_freq(chan); |
| 1070 | |
| 1071 | /* Get channel next to the op_chan */ |
| 1072 | chan = wlan_hdd_get_adjacent_chan(op_chan, true); |
| 1073 | if (chan < 0) |
| 1074 | return -EINVAL; |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1075 | p2p_avoid_freq_list.avoid_freq_range[1].start_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1076 | wlan_chan_to_freq(chan); |
| 1077 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1078 | p2p_avoid_freq_list.avoid_freq_range[1].end_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1079 | wlan_chan_to_freq(max_chan); |
| 1080 | } else if (op_chan == min_chan) { |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1081 | p2p_avoid_freq_list.ch_avoid_range_cnt = 1; |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1082 | |
| 1083 | chan = wlan_hdd_get_adjacent_chan(op_chan, true); |
| 1084 | if (chan < 0) |
| 1085 | return -EINVAL; |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1086 | p2p_avoid_freq_list.avoid_freq_range[0].start_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1087 | wlan_chan_to_freq(chan); |
| 1088 | |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1089 | p2p_avoid_freq_list.avoid_freq_range[0].end_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1090 | wlan_chan_to_freq(max_chan); |
| 1091 | } else { |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1092 | p2p_avoid_freq_list.ch_avoid_range_cnt = 1; |
| 1093 | p2p_avoid_freq_list.avoid_freq_range[0].start_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1094 | wlan_chan_to_freq(min_chan); |
| 1095 | |
| 1096 | chan = wlan_hdd_get_adjacent_chan(op_chan, false); |
| 1097 | if (chan < 0) |
| 1098 | return -EINVAL; |
Kiran Kumar Lokere | 4879579 | 2017-07-07 15:34:29 -0700 | [diff] [blame] | 1099 | p2p_avoid_freq_list.avoid_freq_range[0].end_freq = |
Ajit Pal Singh | 5edd698 | 2017-05-10 11:04:13 +0530 | [diff] [blame] | 1100 | wlan_chan_to_freq(chan); |
| 1101 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1102 | #ifdef FEATURE_WLAN_CH_AVOID |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1103 | mutex_lock(&hdd_ctx->avoid_freq_lock); |
| 1104 | hdd_ctx->dnbs_avoid_freq_list = p2p_avoid_freq_list; |
| 1105 | if (hdd_ctx->coex_avoid_freq_list.ch_avoid_range_cnt) { |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1106 | ret = wlan_hdd_merge_avoid_freqs(&p2p_avoid_freq_list, |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1107 | &hdd_ctx->coex_avoid_freq_list); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1108 | if (ret) { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1109 | mutex_unlock(&hdd_ctx->avoid_freq_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1110 | hdd_err("avoid freq merge failed"); |
| 1111 | return ret; |
| 1112 | } |
| 1113 | } |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1114 | mutex_unlock(&hdd_ctx->avoid_freq_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 1115 | #endif |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 1116 | 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] | 1117 | if (ret) |
| 1118 | hdd_err("wlan_hdd_send_avoid_freq_event error:%d", ret); |
| 1119 | |
| 1120 | return ret; |
| 1121 | } |
| 1122 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1123 | /* vendor specific events */ |
| 1124 | static const struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1125 | [QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX] = { |
| 1126 | .vendor_id = |
| 1127 | QCA_NL80211_VENDOR_ID, |
| 1128 | .subcmd = |
| 1129 | QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY |
| 1130 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1131 | |
| 1132 | #ifdef WLAN_FEATURE_NAN |
| 1133 | [QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX] = { |
| 1134 | .vendor_id = |
| 1135 | QCA_NL80211_VENDOR_ID, |
| 1136 | .subcmd = |
| 1137 | QCA_NL80211_VENDOR_SUBCMD_NAN |
| 1138 | }, |
| 1139 | #endif |
| 1140 | |
| 1141 | #ifdef WLAN_FEATURE_STATS_EXT |
| 1142 | [QCA_NL80211_VENDOR_SUBCMD_STATS_EXT_INDEX] = { |
| 1143 | .vendor_id = |
| 1144 | QCA_NL80211_VENDOR_ID, |
| 1145 | .subcmd = |
| 1146 | QCA_NL80211_VENDOR_SUBCMD_STATS_EXT |
| 1147 | }, |
| 1148 | #endif /* WLAN_FEATURE_STATS_EXT */ |
| 1149 | #ifdef FEATURE_WLAN_EXTSCAN |
| 1150 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX] = { |
| 1151 | .vendor_id = |
| 1152 | QCA_NL80211_VENDOR_ID, |
| 1153 | .subcmd = |
| 1154 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START |
| 1155 | }, |
| 1156 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX] = { |
| 1157 | .vendor_id = |
| 1158 | QCA_NL80211_VENDOR_ID, |
| 1159 | .subcmd = |
| 1160 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP |
| 1161 | }, |
| 1162 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX] = { |
| 1163 | . |
| 1164 | vendor_id |
| 1165 | = |
| 1166 | QCA_NL80211_VENDOR_ID, |
| 1167 | .subcmd = |
| 1168 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES |
| 1169 | }, |
| 1170 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX] = { |
| 1171 | . |
| 1172 | vendor_id |
| 1173 | = |
| 1174 | QCA_NL80211_VENDOR_ID, |
| 1175 | . |
| 1176 | subcmd = |
| 1177 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS |
| 1178 | }, |
| 1179 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX] = { |
| 1180 | . |
| 1181 | vendor_id |
| 1182 | = |
| 1183 | QCA_NL80211_VENDOR_ID, |
| 1184 | . |
| 1185 | subcmd |
| 1186 | = |
| 1187 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE |
| 1188 | }, |
| 1189 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX] = { |
| 1190 | . |
| 1191 | vendor_id |
| 1192 | = |
| 1193 | QCA_NL80211_VENDOR_ID, |
| 1194 | .subcmd = |
| 1195 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT |
| 1196 | }, |
| 1197 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX] = { |
| 1198 | .vendor_id = |
| 1199 | QCA_NL80211_VENDOR_ID, |
| 1200 | .subcmd = |
| 1201 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT |
| 1202 | }, |
| 1203 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX] = { |
| 1204 | . |
| 1205 | vendor_id |
| 1206 | = |
| 1207 | QCA_NL80211_VENDOR_ID, |
| 1208 | .subcmd = |
| 1209 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND |
| 1210 | }, |
| 1211 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX] = { |
| 1212 | . |
| 1213 | vendor_id |
| 1214 | = |
| 1215 | QCA_NL80211_VENDOR_ID, |
| 1216 | .subcmd = |
| 1217 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST |
| 1218 | }, |
| 1219 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX] = { |
| 1220 | . |
| 1221 | vendor_id |
| 1222 | = |
| 1223 | QCA_NL80211_VENDOR_ID, |
| 1224 | . |
| 1225 | subcmd |
| 1226 | = |
| 1227 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST |
| 1228 | }, |
| 1229 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX] = { |
| 1230 | . |
| 1231 | vendor_id |
| 1232 | = |
| 1233 | QCA_NL80211_VENDOR_ID, |
| 1234 | . |
| 1235 | subcmd = |
| 1236 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE |
| 1237 | }, |
| 1238 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX] = { |
| 1239 | . |
| 1240 | vendor_id |
| 1241 | = |
| 1242 | QCA_NL80211_VENDOR_ID, |
| 1243 | . |
| 1244 | subcmd |
| 1245 | = |
| 1246 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE |
| 1247 | }, |
| 1248 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX] = { |
| 1249 | . |
| 1250 | vendor_id |
| 1251 | = |
| 1252 | QCA_NL80211_VENDOR_ID, |
| 1253 | . |
| 1254 | subcmd |
| 1255 | = |
| 1256 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE |
| 1257 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1258 | #endif /* FEATURE_WLAN_EXTSCAN */ |
| 1259 | |
| 1260 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 1261 | [QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET_INDEX] = { |
| 1262 | .vendor_id = |
| 1263 | QCA_NL80211_VENDOR_ID, |
| 1264 | .subcmd = |
| 1265 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET |
| 1266 | }, |
| 1267 | [QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET_INDEX] = { |
| 1268 | .vendor_id = |
| 1269 | QCA_NL80211_VENDOR_ID, |
| 1270 | .subcmd = |
| 1271 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET |
| 1272 | }, |
| 1273 | [QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR_INDEX] = { |
| 1274 | .vendor_id = |
| 1275 | QCA_NL80211_VENDOR_ID, |
| 1276 | .subcmd = |
| 1277 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR |
| 1278 | }, |
| 1279 | [QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX] = { |
| 1280 | .vendor_id = |
| 1281 | QCA_NL80211_VENDOR_ID, |
| 1282 | .subcmd = |
| 1283 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS |
| 1284 | }, |
| 1285 | [QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX] = { |
| 1286 | .vendor_id = |
| 1287 | QCA_NL80211_VENDOR_ID, |
| 1288 | .subcmd = |
| 1289 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS |
| 1290 | }, |
| 1291 | [QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX] = { |
| 1292 | .vendor_id = |
| 1293 | QCA_NL80211_VENDOR_ID, |
| 1294 | .subcmd = |
| 1295 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS |
| 1296 | }, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 1297 | [QCA_NL80211_VENDOR_SUBCMD_LL_STATS_EXT_INDEX] = { |
| 1298 | .vendor_id = |
| 1299 | QCA_NL80211_VENDOR_ID, |
| 1300 | .subcmd = |
| 1301 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_EXT |
| 1302 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1303 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 1304 | [QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX] = { |
| 1305 | .vendor_id = |
| 1306 | QCA_NL80211_VENDOR_ID, |
| 1307 | .subcmd = |
| 1308 | QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE |
| 1309 | }, |
| 1310 | [QCA_NL80211_VENDOR_SUBCMD_DO_ACS_INDEX] = { |
| 1311 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1312 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_DO_ACS |
| 1313 | }, |
| 1314 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1315 | [QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH_INDEX] = { |
| 1316 | .vendor_id = |
| 1317 | QCA_NL80211_VENDOR_ID, |
| 1318 | .subcmd = |
| 1319 | QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH |
| 1320 | }, |
| 1321 | #endif |
| 1322 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_STARTED_INDEX] = { |
| 1323 | .vendor_id = |
| 1324 | QCA_NL80211_VENDOR_ID, |
| 1325 | .subcmd = |
| 1326 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_STARTED |
| 1327 | }, |
| 1328 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_FINISHED_INDEX] = { |
| 1329 | .vendor_id = |
| 1330 | QCA_NL80211_VENDOR_ID, |
| 1331 | .subcmd = |
| 1332 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_FINISHED |
| 1333 | }, |
| 1334 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_ABORTED_INDEX] = { |
| 1335 | .vendor_id = |
| 1336 | QCA_NL80211_VENDOR_ID, |
| 1337 | .subcmd = |
| 1338 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_ABORTED |
| 1339 | }, |
| 1340 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_NOP_FINISHED_INDEX] = { |
| 1341 | .vendor_id = |
| 1342 | QCA_NL80211_VENDOR_ID, |
| 1343 | .subcmd = |
| 1344 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_NOP_FINISHED |
| 1345 | }, |
| 1346 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_RADAR_DETECTED_INDEX] = { |
| 1347 | .vendor_id = |
| 1348 | QCA_NL80211_VENDOR_ID, |
| 1349 | .subcmd = |
| 1350 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_RADAR_DETECTED |
| 1351 | }, |
| 1352 | #ifdef FEATURE_WLAN_EXTSCAN |
| 1353 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_NETWORK_FOUND_INDEX] = { |
| 1354 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1355 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_NETWORK_FOUND |
| 1356 | }, |
| 1357 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_PASSPOINT_NETWORK_FOUND_INDEX] = { |
| 1358 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1359 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_PASSPOINT_NETWORK_FOUND |
| 1360 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1361 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = { |
| 1362 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1363 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST |
| 1364 | }, |
| 1365 | #endif /* FEATURE_WLAN_EXTSCAN */ |
| 1366 | [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = { |
| 1367 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1368 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI |
| 1369 | }, |
Manikandan Mohan | 5356c2b | 2016-04-03 15:51:35 -0700 | [diff] [blame] | 1370 | #ifdef WLAN_FEATURE_TSF |
| 1371 | [QCA_NL80211_VENDOR_SUBCMD_TSF_INDEX] = { |
| 1372 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1373 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_TSF |
| 1374 | }, |
| 1375 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1376 | [QCA_NL80211_VENDOR_SUBCMD_SCAN_DONE_INDEX] = { |
| 1377 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1378 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_SCAN_DONE |
| 1379 | }, |
| 1380 | [QCA_NL80211_VENDOR_SUBCMD_SCAN_INDEX] = { |
| 1381 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1382 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_TRIGGER_SCAN |
| 1383 | }, |
| 1384 | /* OCB events */ |
| 1385 | [QCA_NL80211_VENDOR_SUBCMD_DCC_STATS_EVENT_INDEX] = { |
| 1386 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1387 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_STATS_EVENT |
| 1388 | }, |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 1389 | #ifdef FEATURE_LFR_SUBNET_DETECTION |
| 1390 | [QCA_NL80211_VENDOR_SUBCMD_GW_PARAM_CONFIG_INDEX] = { |
| 1391 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1392 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_GW_PARAM_CONFIG |
| 1393 | }, |
| 1394 | #endif /*FEATURE_LFR_SUBNET_DETECTION */ |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 1395 | |
| 1396 | #ifdef WLAN_FEATURE_NAN_DATAPATH |
| 1397 | [QCA_NL80211_VENDOR_SUBCMD_NDP_INDEX] = { |
| 1398 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1399 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_NDP |
| 1400 | }, |
| 1401 | #endif /* WLAN_FEATURE_NAN_DATAPATH */ |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 1402 | |
| 1403 | [QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX] = { |
| 1404 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1405 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_P2P_LISTEN_OFFLOAD_STOP |
| 1406 | }, |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 1407 | [QCA_NL80211_VENDOR_SUBCMD_SAP_CONDITIONAL_CHAN_SWITCH_INDEX] = { |
| 1408 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1409 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_SAP_CONDITIONAL_CHAN_SWITCH |
| 1410 | }, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 1411 | [QCA_NL80211_VENDOR_SUBCMD_UPDATE_EXTERNAL_ACS_CONFIG] = { |
| 1412 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1413 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTERNAL_ACS |
| 1414 | }, |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 1415 | [QCA_NL80211_VENDOR_SUBCMD_PWR_SAVE_FAIL_DETECTED_INDEX] = { |
| 1416 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1417 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_CHIP_PWRSAVE_FAILURE |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 1418 | }, |
| 1419 | [QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX] = { |
| 1420 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1421 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET, |
| 1422 | }, |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 1423 | [QCA_NL80211_VENDOR_SUBCMD_HANG_REASON_INDEX] = { |
| 1424 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1425 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_HANG, |
| 1426 | }, |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 1427 | [QCA_NL80211_VENDOR_SUBCMD_WLAN_MAC_INFO_INDEX] = { |
| 1428 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1429 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_WLAN_MAC_INFO, |
| 1430 | }, |
Paul Zhang | 3a210c5 | 2016-12-08 10:18:12 +0800 | [diff] [blame] | 1431 | #ifdef WLAN_UMAC_CONVERGENCE |
| 1432 | COMMON_VENDOR_EVENTS |
| 1433 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1434 | }; |
| 1435 | |
| 1436 | /** |
| 1437 | * __is_driver_dfs_capable() - get driver DFS capability |
| 1438 | * @wiphy: pointer to wireless wiphy structure. |
| 1439 | * @wdev: pointer to wireless_dev structure. |
| 1440 | * @data: Pointer to the data to be passed via vendor interface |
| 1441 | * @data_len:Length of the data to be passed |
| 1442 | * |
| 1443 | * This function is called by userspace to indicate whether or not |
| 1444 | * the driver supports DFS offload. |
| 1445 | * |
| 1446 | * Return: 0 on success, negative errno on failure |
| 1447 | */ |
| 1448 | static int __is_driver_dfs_capable(struct wiphy *wiphy, |
| 1449 | struct wireless_dev *wdev, |
| 1450 | const void *data, |
| 1451 | int data_len) |
| 1452 | { |
| 1453 | u32 dfs_capability = 0; |
| 1454 | struct sk_buff *temp_skbuff; |
| 1455 | int ret_val; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 1456 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1457 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 1458 | hdd_enter_dev(wdev->netdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1459 | |
| 1460 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 1461 | if (ret_val) |
| 1462 | return ret_val; |
| 1463 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1464 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1465 | hdd_err("Command not allowed in FTM mode"); |
| 1466 | return -EPERM; |
| 1467 | } |
| 1468 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1469 | dfs_capability = !!(wiphy->flags & WIPHY_FLAG_DFS_OFFLOAD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1470 | |
| 1471 | temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) + |
| 1472 | NLMSG_HDRLEN); |
| 1473 | |
| 1474 | if (temp_skbuff != NULL) { |
| 1475 | ret_val = nla_put_u32(temp_skbuff, QCA_WLAN_VENDOR_ATTR_DFS, |
| 1476 | dfs_capability); |
| 1477 | if (ret_val) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1478 | hdd_err("QCA_WLAN_VENDOR_ATTR_DFS put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1479 | kfree_skb(temp_skbuff); |
| 1480 | |
| 1481 | return ret_val; |
| 1482 | } |
| 1483 | |
| 1484 | return cfg80211_vendor_cmd_reply(temp_skbuff); |
| 1485 | } |
| 1486 | |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1487 | hdd_err("dfs capability: buffer alloc fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1488 | return -ENOMEM; |
| 1489 | } |
| 1490 | |
| 1491 | /** |
| 1492 | * is_driver_dfs_capable() - get driver DFS capability |
| 1493 | * @wiphy: pointer to wireless wiphy structure. |
| 1494 | * @wdev: pointer to wireless_dev structure. |
| 1495 | * @data: Pointer to the data to be passed via vendor interface |
| 1496 | * @data_len:Length of the data to be passed |
| 1497 | * |
| 1498 | * This function is called by userspace to indicate whether or not |
| 1499 | * the driver supports DFS offload. This is an SSR-protected |
| 1500 | * wrapper function. |
| 1501 | * |
| 1502 | * Return: 0 on success, negative errno on failure |
| 1503 | */ |
| 1504 | static int is_driver_dfs_capable(struct wiphy *wiphy, |
| 1505 | struct wireless_dev *wdev, |
| 1506 | const void *data, |
| 1507 | int data_len) |
| 1508 | { |
| 1509 | int ret; |
| 1510 | |
| 1511 | cds_ssr_protect(__func__); |
| 1512 | ret = __is_driver_dfs_capable(wiphy, wdev, data, data_len); |
| 1513 | cds_ssr_unprotect(__func__); |
| 1514 | |
| 1515 | return ret; |
| 1516 | } |
| 1517 | |
| 1518 | /** |
| 1519 | * wlan_hdd_sap_cfg_dfs_override() - DFS MCC restriction check |
| 1520 | * |
| 1521 | * @adapter: SAP adapter pointer |
| 1522 | * |
| 1523 | * DFS in MCC is not supported for Multi bssid SAP mode due to single physical |
| 1524 | * radio. So in case of DFS MCC scenario override current SAP given config |
| 1525 | * to follow concurrent SAP DFS config |
| 1526 | * |
| 1527 | * Return: 0 - No DFS issue, 1 - Override done and negative error codes |
| 1528 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 1529 | int wlan_hdd_sap_cfg_dfs_override(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1530 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 1531 | struct hdd_adapter *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1532 | tsap_Config_t *sap_config, *con_sap_config; |
| 1533 | int con_ch; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 1534 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1535 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1536 | if (!hdd_ctx) { |
| 1537 | hdd_err("hdd context is NULL"); |
| 1538 | return 0; |
| 1539 | } |
| 1540 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1541 | /* |
| 1542 | * Check if AP+AP case, once primary AP chooses a DFS |
| 1543 | * channel secondary AP should always follow primary APs channel |
| 1544 | */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 1545 | if (!policy_mgr_concurrent_beaconing_sessions_running( |
| 1546 | hdd_ctx->hdd_psoc)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1547 | return 0; |
| 1548 | |
| 1549 | con_sap_adapter = hdd_get_con_sap_adapter(adapter, true); |
| 1550 | if (!con_sap_adapter) |
| 1551 | return 0; |
| 1552 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 1553 | sap_config = &adapter->session.ap.sap_config; |
| 1554 | con_sap_config = &con_sap_adapter->session.ap.sap_config; |
| 1555 | con_ch = con_sap_adapter->session.ap.operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1556 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1557 | if (!wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, con_ch)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1558 | return 0; |
| 1559 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 1560 | 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] | 1561 | sap_config->channel, con_ch); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 1562 | hdd_debug("Overriding guest AP's channel"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1563 | sap_config->channel = con_ch; |
| 1564 | |
| 1565 | if (con_sap_config->acs_cfg.acs_mode == true) { |
| 1566 | if (con_ch != con_sap_config->acs_cfg.pri_ch && |
| 1567 | con_ch != con_sap_config->acs_cfg.ht_sec_ch) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1568 | hdd_err("Primary AP channel config error"); |
| 1569 | hdd_err("Operating ch: %d ACS ch: %d %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1570 | con_ch, con_sap_config->acs_cfg.pri_ch, |
| 1571 | con_sap_config->acs_cfg.ht_sec_ch); |
| 1572 | return -EINVAL; |
| 1573 | } |
| 1574 | /* Sec AP ACS info is overwritten with Pri AP due to DFS |
| 1575 | * MCC restriction. So free ch list allocated in do_acs |
| 1576 | * func for Sec AP and realloc for Pri AP ch list size |
| 1577 | */ |
| 1578 | if (sap_config->acs_cfg.ch_list) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1579 | qdf_mem_free(sap_config->acs_cfg.ch_list); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1580 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1581 | qdf_mem_copy(&sap_config->acs_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1582 | &con_sap_config->acs_cfg, |
| 1583 | sizeof(struct sap_acs_cfg)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1584 | sap_config->acs_cfg.ch_list = qdf_mem_malloc( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1585 | sizeof(uint8_t) * |
| 1586 | con_sap_config->acs_cfg.ch_list_count); |
| 1587 | if (!sap_config->acs_cfg.ch_list) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1588 | hdd_err("ACS config alloc fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1589 | return -ENOMEM; |
| 1590 | } |
| 1591 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1592 | qdf_mem_copy(sap_config->acs_cfg.ch_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1593 | con_sap_config->acs_cfg.ch_list, |
| 1594 | con_sap_config->acs_cfg.ch_list_count); |
| 1595 | |
| 1596 | } else { |
| 1597 | sap_config->acs_cfg.pri_ch = con_ch; |
| 1598 | if (sap_config->acs_cfg.ch_width > eHT_CHANNEL_WIDTH_20MHZ) |
| 1599 | sap_config->acs_cfg.ht_sec_ch = con_sap_config->sec_ch; |
| 1600 | } |
| 1601 | |
| 1602 | return con_ch; |
| 1603 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1604 | |
| 1605 | /** |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 1606 | * wlan_hdd_reset_force_acs_chan_range: Set acs channel ranges as per force ACS |
| 1607 | * configuration. |
| 1608 | * @hdd_ctx: pointer to hdd context |
| 1609 | * @sap_config: pointer to SAP config struct |
| 1610 | * |
| 1611 | * Return: 0 if success else error code |
| 1612 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 1613 | static int wlan_hdd_reset_force_acs_chan_range(struct hdd_context *hdd_ctx, |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 1614 | tsap_Config_t *sap_config) |
| 1615 | { |
| 1616 | bool is_dfs_mode_enabled = false; |
| 1617 | uint32_t i, num_channels = 0; |
| 1618 | uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 1619 | eCsrPhyMode hw_mode; |
| 1620 | tSirMacHTChannelWidth ch_width; |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 1621 | |
| 1622 | if (hdd_ctx->config->force_sap_acs_st_ch > |
| 1623 | hdd_ctx->config->force_sap_acs_end_ch) { |
| 1624 | hdd_err("invalid configuration for start and end channel"); |
| 1625 | return -EINVAL; |
| 1626 | } |
| 1627 | if (hdd_ctx->config->enableDFSMasterCap) |
| 1628 | is_dfs_mode_enabled = true; |
| 1629 | |
| 1630 | sap_config->acs_cfg.start_ch = |
| 1631 | hdd_ctx->config->force_sap_acs_st_ch; |
| 1632 | sap_config->acs_cfg.end_ch = |
| 1633 | hdd_ctx->config->force_sap_acs_end_ch; |
| 1634 | |
| 1635 | for (i = sap_config->acs_cfg.start_ch; |
| 1636 | i <= sap_config->acs_cfg.end_ch; i++) { |
| 1637 | if ((CHANNEL_STATE_ENABLE == |
| 1638 | wlan_reg_get_channel_state(hdd_ctx->hdd_pdev, i)) || |
| 1639 | (is_dfs_mode_enabled && |
| 1640 | CHANNEL_STATE_DFS == |
| 1641 | wlan_reg_get_channel_state(hdd_ctx->hdd_pdev, i))) { |
| 1642 | channels[num_channels] = i; |
| 1643 | num_channels++; |
| 1644 | } |
| 1645 | } |
| 1646 | if (sap_config->acs_cfg.ch_list) |
| 1647 | qdf_mem_free(sap_config->acs_cfg.ch_list); |
| 1648 | |
| 1649 | sap_config->acs_cfg.ch_list = qdf_mem_malloc(num_channels); |
| 1650 | if (!sap_config->acs_cfg.ch_list) { |
| 1651 | hdd_err("ACS config alloc fail"); |
| 1652 | return -ENOMEM; |
| 1653 | } |
| 1654 | qdf_mem_copy(sap_config->acs_cfg.ch_list, channels, num_channels); |
| 1655 | sap_config->acs_cfg.ch_list_count = num_channels; |
| 1656 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 1657 | /* Derive ACS HW mode */ |
| 1658 | hw_mode = hdd_cfg_xlate_to_csr_phy_mode(hdd_ctx->config->dot11Mode); |
| 1659 | if (hw_mode == eCSR_DOT11_MODE_AUTO) { |
| 1660 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 1661 | hw_mode = eCSR_DOT11_MODE_11ax; |
| 1662 | else |
| 1663 | hw_mode = eCSR_DOT11_MODE_11ac; |
| 1664 | } |
| 1665 | |
| 1666 | if (hdd_ctx->config->sap_force_11n_for_11ac) { |
| 1667 | if (hw_mode == eCSR_DOT11_MODE_11ac || |
| 1668 | hw_mode == eCSR_DOT11_MODE_11ac_ONLY) |
| 1669 | hw_mode = eCSR_DOT11_MODE_11n; |
| 1670 | } |
| 1671 | |
| 1672 | if ((hw_mode == eCSR_DOT11_MODE_11b || |
| 1673 | hw_mode == eCSR_DOT11_MODE_11g || |
| 1674 | hw_mode == eCSR_DOT11_MODE_11g_ONLY) && |
| 1675 | sap_config->acs_cfg.start_ch > 14) { |
| 1676 | hdd_err("Invalid ACS HW Mode %d + CH range <%d - %d>", |
| 1677 | hw_mode, sap_config->acs_cfg.start_ch, |
| 1678 | sap_config->acs_cfg.end_ch); |
| 1679 | return -EINVAL; |
| 1680 | } |
| 1681 | sap_config->acs_cfg.hw_mode = hw_mode; |
| 1682 | |
| 1683 | /* Derive ACS BW */ |
| 1684 | ch_width = eHT_CHANNEL_WIDTH_20MHZ; |
| 1685 | if (hw_mode == eCSR_DOT11_MODE_11ac || |
| 1686 | hw_mode == eCSR_DOT11_MODE_11ac_ONLY || |
| 1687 | hw_mode == eCSR_DOT11_MODE_11ax || |
| 1688 | hw_mode == eCSR_DOT11_MODE_11ax_ONLY) { |
| 1689 | ch_width = hdd_ctx->config->vhtChannelWidth; |
| 1690 | /* VHT in 2.4G depends on gChannelBondingMode24GHz INI param */ |
| 1691 | if (sap_config->acs_cfg.end_ch <= 14) |
| 1692 | ch_width = |
| 1693 | hdd_ctx->config->nChannelBondingMode24GHz ? |
| 1694 | eHT_CHANNEL_WIDTH_40MHZ : |
| 1695 | eHT_CHANNEL_WIDTH_20MHZ; |
| 1696 | } |
| 1697 | |
| 1698 | if (hw_mode == eCSR_DOT11_MODE_11n || |
| 1699 | hw_mode == eCSR_DOT11_MODE_11n_ONLY) { |
| 1700 | if (sap_config->acs_cfg.end_ch <= 14) |
| 1701 | ch_width = |
| 1702 | hdd_ctx->config->nChannelBondingMode24GHz ? |
| 1703 | eHT_CHANNEL_WIDTH_40MHZ : |
| 1704 | eHT_CHANNEL_WIDTH_20MHZ; |
| 1705 | else |
| 1706 | ch_width = |
| 1707 | hdd_ctx->config->nChannelBondingMode5GHz ? |
| 1708 | eHT_CHANNEL_WIDTH_40MHZ : |
| 1709 | eHT_CHANNEL_WIDTH_20MHZ; |
| 1710 | } |
| 1711 | sap_config->acs_cfg.ch_width = ch_width; |
| 1712 | |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 1713 | return 0; |
| 1714 | } |
| 1715 | |
| 1716 | /** |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1717 | * 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] | 1718 | * @sap_cfg: pointer to SAP config struct |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1719 | * @hw_mode: hw mode retrieved from vendor command buffer |
| 1720 | * @ht_enabled: whether HT phy mode is enabled |
| 1721 | * @vht_enabled: whether VHT phy mode is enabled |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1722 | * |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1723 | * This function populates the ACS hw mode based on the configuration retrieved |
| 1724 | * from the vendor command buffer; and sets ACS start and end channel for the |
| 1725 | * given band. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1726 | * |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1727 | * Return: 0 if success; -EINVAL if ACS channel list is NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1728 | */ |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1729 | static int wlan_hdd_set_acs_ch_range( |
| 1730 | tsap_Config_t *sap_cfg, enum qca_wlan_vendor_acs_hw_mode hw_mode, |
| 1731 | bool ht_enabled, bool vht_enabled) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1732 | { |
| 1733 | int i; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 1734 | |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1735 | if (hw_mode == QCA_ACS_MODE_IEEE80211B) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1736 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11b; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1737 | sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_1); |
| 1738 | sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_14); |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1739 | } else if (hw_mode == QCA_ACS_MODE_IEEE80211G) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1740 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11g; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1741 | sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_1); |
| 1742 | sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_13); |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1743 | } else if (hw_mode == QCA_ACS_MODE_IEEE80211A) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1744 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11a; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1745 | sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_36); |
| 1746 | sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_165); |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 1747 | } else if (hw_mode == QCA_ACS_MODE_IEEE80211ANY) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1748 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_abg; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1749 | sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_1); |
| 1750 | sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_165); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1751 | } |
| 1752 | |
| 1753 | if (ht_enabled) |
| 1754 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11n; |
| 1755 | |
| 1756 | if (vht_enabled) |
| 1757 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11ac; |
| 1758 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1759 | /* Parse ACS Chan list from hostapd */ |
| 1760 | if (!sap_cfg->acs_cfg.ch_list) |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 1761 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1762 | |
| 1763 | sap_cfg->acs_cfg.start_ch = sap_cfg->acs_cfg.ch_list[0]; |
| 1764 | sap_cfg->acs_cfg.end_ch = |
| 1765 | sap_cfg->acs_cfg.ch_list[sap_cfg->acs_cfg.ch_list_count - 1]; |
| 1766 | for (i = 0; i < sap_cfg->acs_cfg.ch_list_count; i++) { |
Manjeet Singh | 2d3b0c5 | 2016-09-02 13:31:48 +0530 | [diff] [blame] | 1767 | /* avoid channel as start channel */ |
| 1768 | if (sap_cfg->acs_cfg.start_ch > sap_cfg->acs_cfg.ch_list[i] && |
| 1769 | sap_cfg->acs_cfg.ch_list[i] != 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1770 | sap_cfg->acs_cfg.start_ch = sap_cfg->acs_cfg.ch_list[i]; |
| 1771 | if (sap_cfg->acs_cfg.end_ch < sap_cfg->acs_cfg.ch_list[i]) |
| 1772 | sap_cfg->acs_cfg.end_ch = sap_cfg->acs_cfg.ch_list[i]; |
| 1773 | } |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 1774 | |
| 1775 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1776 | } |
| 1777 | |
| 1778 | |
| 1779 | static void wlan_hdd_cfg80211_start_pending_acs(struct work_struct *work); |
| 1780 | |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1781 | |
| 1782 | 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] | 1783 | enum band_info band) |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1784 | { |
| 1785 | int i, temp_count = 0; |
| 1786 | int acs_list_count = sap_config->acs_cfg.ch_list_count; |
| 1787 | |
| 1788 | for (i = 0; i < acs_list_count; i++) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1789 | if (BAND_2G == band) { |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1790 | if (WLAN_REG_IS_24GHZ_CH( |
| 1791 | sap_config->acs_cfg.ch_list[i])) { |
| 1792 | sap_config->acs_cfg.ch_list[temp_count] = |
| 1793 | sap_config->acs_cfg.ch_list[i]; |
| 1794 | temp_count++; |
| 1795 | } |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1796 | } else if (BAND_5G == band) { |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1797 | if (WLAN_REG_IS_5GHZ_CH( |
| 1798 | sap_config->acs_cfg.ch_list[i])) { |
| 1799 | sap_config->acs_cfg.ch_list[temp_count] = |
| 1800 | sap_config->acs_cfg.ch_list[i]; |
| 1801 | temp_count++; |
| 1802 | } |
| 1803 | } |
| 1804 | } |
| 1805 | sap_config->acs_cfg.ch_list_count = temp_count; |
| 1806 | } |
| 1807 | |
| 1808 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1809 | /** |
| 1810 | * wlan_hdd_cfg80211_start_acs : Start ACS Procedure for SAP |
| 1811 | * @adapter: pointer to SAP adapter struct |
| 1812 | * |
| 1813 | * This function starts the ACS procedure if there are no |
| 1814 | * constraints like MBSSID DFS restrictions. |
| 1815 | * |
| 1816 | * Return: Status of ACS Start procedure |
| 1817 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 1818 | int wlan_hdd_cfg80211_start_acs(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1819 | { |
| 1820 | |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 1821 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1822 | tsap_Config_t *sap_config; |
| 1823 | tpWLAN_SAPEventCB acs_event_callback; |
| 1824 | int status; |
| 1825 | |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 1826 | if (!adapter) { |
| 1827 | hdd_err("adapater is NULL"); |
| 1828 | return -EINVAL; |
| 1829 | } |
| 1830 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 1831 | sap_config = &adapter->session.ap.sap_config; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 1832 | if (hdd_ctx->acs_policy.acs_channel) |
| 1833 | sap_config->channel = hdd_ctx->acs_policy.acs_channel; |
| 1834 | else |
| 1835 | sap_config->channel = AUTO_CHANNEL_SELECT; |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1836 | /* |
| 1837 | * No DFS SCC is allowed in Auto use case. Hence not |
| 1838 | * calling DFS override |
| 1839 | */ |
| 1840 | if (QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION != |
| 1841 | hdd_ctx->config->WlanMccToSccSwitchMode) { |
| 1842 | status = wlan_hdd_sap_cfg_dfs_override(adapter); |
| 1843 | if (status < 0) |
| 1844 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1845 | |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1846 | if (status > 0) { |
| 1847 | /*notify hostapd about channel override */ |
| 1848 | wlan_hdd_cfg80211_acs_ch_select_evt(adapter); |
| 1849 | clear_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags); |
| 1850 | return 0; |
| 1851 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1852 | } |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1853 | /* When first 2 connections are on the same frequency band, |
| 1854 | * then PCL would include only channels from the other |
| 1855 | * frequency band on which no connections are active |
| 1856 | */ |
| 1857 | if ((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 2) && |
| 1858 | (sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211ANY)) { |
| 1859 | struct policy_mgr_conc_connection_info *conc_connection_info; |
| 1860 | uint32_t i; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 1861 | |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1862 | conc_connection_info = policy_mgr_get_conn_info(&i); |
| 1863 | if (conc_connection_info[0].mac == |
| 1864 | conc_connection_info[1].mac) { |
| 1865 | if (WLAN_REG_IS_5GHZ_CH(sap_config->acs_cfg. |
| 1866 | pcl_channels[0])) { |
| 1867 | sap_config->acs_cfg.band = |
| 1868 | QCA_ACS_MODE_IEEE80211A; |
| 1869 | hdd_update_acs_channel_list(sap_config, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1870 | BAND_5G); |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1871 | } else { |
| 1872 | sap_config->acs_cfg.band = |
| 1873 | QCA_ACS_MODE_IEEE80211G; |
| 1874 | hdd_update_acs_channel_list(sap_config, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1875 | BAND_2G); |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 1876 | } |
| 1877 | } |
| 1878 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1879 | status = wlan_hdd_config_acs(hdd_ctx, adapter); |
| 1880 | if (status) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1881 | hdd_err("ACS config failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1882 | return -EINVAL; |
| 1883 | } |
| 1884 | |
| 1885 | acs_event_callback = hdd_hostapd_sap_event_cb; |
| 1886 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1887 | qdf_mem_copy(sap_config->self_macaddr.bytes, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 1888 | adapter->mac_addr.bytes, sizeof(struct qdf_mac_addr)); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 1889 | hdd_info("ACS Started for %s", adapter->dev->name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1890 | status = wlansap_acs_chselect( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1891 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1892 | acs_event_callback, sap_config, adapter->dev); |
| 1893 | |
| 1894 | |
| 1895 | if (status) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1896 | hdd_err("ACS channel select failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1897 | return -EINVAL; |
| 1898 | } |
bings | 394afdd | 2017-01-09 11:22:38 +0800 | [diff] [blame] | 1899 | if (sap_is_auto_channel_select(WLAN_HDD_GET_SAP_CTX_PTR(adapter))) |
| 1900 | sap_config->acs_cfg.acs_mode = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1901 | set_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags); |
| 1902 | |
| 1903 | return 0; |
| 1904 | } |
| 1905 | |
| 1906 | /** |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 1907 | * hdd_update_vendor_pcl_list() - This API will return unsorted pcl list |
| 1908 | * @hdd_ctx: hdd context |
| 1909 | * @acs_chan_params: external acs channel params |
| 1910 | * @sap_config: SAP config |
| 1911 | * |
| 1912 | * This API provides unsorted pcl list. |
| 1913 | * this list is a subset of the valid channel list given by hostapd. |
| 1914 | * if channel is not present in pcl, weightage will be given as zero |
| 1915 | * |
| 1916 | * Return: Zero on success, non-zero on failure |
| 1917 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 1918 | static void hdd_update_vendor_pcl_list(struct hdd_context *hdd_ctx, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 1919 | struct hdd_vendor_acs_chan_params *acs_chan_params, |
| 1920 | tsap_Config_t *sap_config) |
| 1921 | { |
| 1922 | int i, j; |
Adesh Keremane | 25ce2dc | 2017-05-29 17:55:39 +0530 | [diff] [blame] | 1923 | /* |
| 1924 | * PCL shall contain only the preferred channels from the |
| 1925 | * application. If those channels are not present in the |
| 1926 | * driver PCL, then set the weight to zero |
| 1927 | */ |
| 1928 | for (i = 0; i < sap_config->acs_cfg.ch_list_count; i++) { |
| 1929 | acs_chan_params->vendor_pcl_list[i] = |
| 1930 | sap_config->acs_cfg.ch_list[i]; |
| 1931 | acs_chan_params->vendor_weight_list[i] = 0; |
| 1932 | for (j = 0; j < sap_config->acs_cfg.pcl_ch_count; j++) { |
| 1933 | if (sap_config->acs_cfg.ch_list[i] == |
| 1934 | sap_config->acs_cfg.pcl_channels[j]) { |
| 1935 | acs_chan_params->vendor_weight_list[i] = |
| 1936 | sap_config-> |
| 1937 | acs_cfg.pcl_channels_weight_list[j]; |
| 1938 | break; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 1939 | } |
| 1940 | } |
| 1941 | } |
Adesh Keremane | 25ce2dc | 2017-05-29 17:55:39 +0530 | [diff] [blame] | 1942 | acs_chan_params->pcl_count = sap_config->acs_cfg.ch_list_count; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 1943 | } |
| 1944 | |
| 1945 | /** |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1946 | * hdd_update_reg_chan_info : This API contructs channel info |
| 1947 | * for all the given channel |
| 1948 | * @adapter: pointer to SAP adapter struct |
| 1949 | * @channel_count: channel count |
| 1950 | * @channel_list: channel list |
| 1951 | * |
| 1952 | * Return: Status of of channel information updation |
| 1953 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 1954 | static int hdd_update_reg_chan_info(struct hdd_adapter *adapter, |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1955 | uint32_t channel_count, |
| 1956 | uint8_t *channel_list) |
| 1957 | { |
| 1958 | int i; |
| 1959 | struct hdd_channel_info *icv; |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 1960 | struct ch_params ch_params = {0}; |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1961 | uint8_t bw_offset = 0, chan = 0; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 1962 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 1963 | tsap_Config_t *sap_config = &adapter->session.ap.sap_config; |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1964 | |
| 1965 | /* memory allocation */ |
| 1966 | sap_config->channel_info = qdf_mem_malloc( |
| 1967 | sizeof(struct hdd_channel_info) * |
| 1968 | channel_count); |
| 1969 | if (!sap_config->channel_info) { |
| 1970 | hdd_err("memory allocation failed"); |
| 1971 | return -ENOMEM; |
| 1972 | |
| 1973 | } |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 1974 | sap_config->channel_info_count = channel_count; |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1975 | for (i = 0; i < channel_count; i++) { |
| 1976 | icv = &sap_config->channel_info[i]; |
| 1977 | chan = channel_list[i]; |
| 1978 | |
| 1979 | if (chan == 0) |
| 1980 | continue; |
| 1981 | |
| 1982 | if (sap_config->acs_cfg.ch_width == CH_WIDTH_40MHZ) |
| 1983 | bw_offset = 1 << BW_40_OFFSET_BIT; |
| 1984 | else if (sap_config->acs_cfg.ch_width == CH_WIDTH_20MHZ) |
| 1985 | bw_offset = 1 << BW_20_OFFSET_BIT; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1986 | icv->freq = wlan_reg_get_channel_freq(hdd_ctx->hdd_pdev, chan); |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1987 | icv->ieee_chan_number = chan; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1988 | icv->max_reg_power = wlan_reg_get_channel_reg_power( |
| 1989 | hdd_ctx->hdd_pdev, chan); |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 1990 | |
| 1991 | /* filling demo values */ |
| 1992 | icv->max_radio_power = HDD_MAX_TX_POWER; |
| 1993 | icv->min_radio_power = HDD_MIN_TX_POWER; |
| 1994 | /* not supported in current driver */ |
| 1995 | icv->max_antenna_gain = 0; |
| 1996 | |
| 1997 | icv->reg_class_id = wlan_hdd_find_opclass( |
| 1998 | WLAN_HDD_GET_HAL_CTX(adapter), |
| 1999 | chan, bw_offset); |
| 2000 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 2001 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2002 | ch_params.ch_width = sap_config->acs_cfg.ch_width; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 2003 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, |
| 2004 | 0, &ch_params); |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2005 | icv->vht_center_freq_seg0 = ch_params.center_freq_seg0; |
| 2006 | icv->vht_center_freq_seg1 = ch_params.center_freq_seg1; |
| 2007 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 2008 | |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2009 | icv->flags = 0; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 2010 | icv->flags = cds_get_vendor_reg_flags(hdd_ctx->hdd_pdev, chan, |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2011 | sap_config->acs_cfg.ch_width, |
| 2012 | sap_config->acs_cfg.is_ht_enabled, |
| 2013 | sap_config->acs_cfg.is_vht_enabled, |
| 2014 | hdd_ctx->config->enable_sub_20_channel_width); |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2015 | if (icv->flags & IEEE80211_CHAN_PASSIVE) |
| 2016 | icv->flagext |= IEEE80211_CHAN_DFS; |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2017 | |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 2018 | 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] | 2019 | icv->freq, icv->flags, |
| 2020 | icv->flagext, icv->ieee_chan_number, |
| 2021 | icv->max_reg_power, icv->max_radio_power, |
| 2022 | icv->min_radio_power, icv->reg_class_id, |
| 2023 | icv->max_antenna_gain, icv->vht_center_freq_seg0, |
| 2024 | icv->vht_center_freq_seg1); |
| 2025 | } |
| 2026 | return 0; |
| 2027 | } |
| 2028 | |
| 2029 | /* Short name for QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_CHAN_INFO event */ |
| 2030 | #define CHAN_INFO_ATTR_FLAGS \ |
| 2031 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_FLAGS |
| 2032 | #define CHAN_INFO_ATTR_FLAG_EXT \ |
| 2033 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_FLAG_EXT |
| 2034 | #define CHAN_INFO_ATTR_FREQ \ |
| 2035 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_FREQ |
| 2036 | #define CHAN_INFO_ATTR_MAX_REG_POWER \ |
| 2037 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_MAX_REG_POWER |
| 2038 | #define CHAN_INFO_ATTR_MAX_POWER \ |
| 2039 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_MAX_POWER |
| 2040 | #define CHAN_INFO_ATTR_MIN_POWER \ |
| 2041 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_MIN_POWER |
| 2042 | #define CHAN_INFO_ATTR_REG_CLASS_ID \ |
| 2043 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_REG_CLASS_ID |
| 2044 | #define CHAN_INFO_ATTR_ANTENNA_GAIN \ |
| 2045 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_ANTENNA_GAIN |
| 2046 | #define CHAN_INFO_ATTR_VHT_SEG_0 \ |
| 2047 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_VHT_SEG_0 |
| 2048 | #define CHAN_INFO_ATTR_VHT_SEG_1 \ |
| 2049 | QCA_WLAN_VENDOR_EXTERNAL_ACS_EVENT_CHAN_INFO_ATTR_VHT_SEG_1 |
| 2050 | |
| 2051 | /** |
| 2052 | * hdd_cfg80211_update_channel_info() - add channel info attributes |
| 2053 | * @skb: pointer to sk buff |
| 2054 | * @hdd_ctx: pointer to hdd station context |
| 2055 | * @idx: attribute index |
| 2056 | * |
| 2057 | * Return: Success(0) or reason code for failure |
| 2058 | */ |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2059 | static int32_t |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2060 | hdd_cfg80211_update_channel_info(struct sk_buff *skb, |
| 2061 | tsap_Config_t *sap_config, int idx) |
| 2062 | { |
| 2063 | struct nlattr *nla_attr, *channel; |
| 2064 | struct hdd_channel_info *icv; |
| 2065 | int i; |
| 2066 | |
| 2067 | nla_attr = nla_nest_start(skb, idx); |
| 2068 | if (!nla_attr) |
| 2069 | goto fail; |
| 2070 | |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2071 | for (i = 0; i < sap_config->channel_info_count; i++) { |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2072 | channel = nla_nest_start(skb, i); |
| 2073 | if (!channel) |
| 2074 | goto fail; |
| 2075 | |
| 2076 | icv = &sap_config->channel_info[i]; |
| 2077 | if (!icv) { |
| 2078 | hdd_err("channel info not found"); |
| 2079 | goto fail; |
| 2080 | } |
| 2081 | if (nla_put_u16(skb, CHAN_INFO_ATTR_FREQ, |
| 2082 | icv->freq) || |
| 2083 | nla_put_u32(skb, CHAN_INFO_ATTR_FLAGS, |
| 2084 | icv->flags) || |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2085 | nla_put_u32(skb, CHAN_INFO_ATTR_FLAG_EXT, |
Kapil Gupta | 086c620 | 2016-12-11 18:17:06 +0530 | [diff] [blame] | 2086 | icv->flagext) || |
| 2087 | nla_put_u8(skb, CHAN_INFO_ATTR_MAX_REG_POWER, |
| 2088 | icv->max_reg_power) || |
| 2089 | nla_put_u8(skb, CHAN_INFO_ATTR_MAX_POWER, |
| 2090 | icv->max_radio_power) || |
| 2091 | nla_put_u8(skb, CHAN_INFO_ATTR_MIN_POWER, |
| 2092 | icv->min_radio_power) || |
| 2093 | nla_put_u8(skb, CHAN_INFO_ATTR_REG_CLASS_ID, |
| 2094 | icv->reg_class_id) || |
| 2095 | nla_put_u8(skb, CHAN_INFO_ATTR_ANTENNA_GAIN, |
| 2096 | icv->max_antenna_gain) || |
| 2097 | nla_put_u8(skb, CHAN_INFO_ATTR_VHT_SEG_0, |
| 2098 | icv->vht_center_freq_seg0) || |
| 2099 | nla_put_u8(skb, CHAN_INFO_ATTR_VHT_SEG_1, |
| 2100 | icv->vht_center_freq_seg1)) { |
| 2101 | hdd_err("put fail"); |
| 2102 | goto fail; |
| 2103 | } |
| 2104 | nla_nest_end(skb, channel); |
| 2105 | } |
| 2106 | nla_nest_end(skb, nla_attr); |
| 2107 | return 0; |
| 2108 | fail: |
| 2109 | hdd_err("nl channel update failed"); |
| 2110 | return -EINVAL; |
| 2111 | } |
| 2112 | #undef CHAN_INFO_ATTR_FLAGS |
| 2113 | #undef CHAN_INFO_ATTR_FLAG_EXT |
| 2114 | #undef CHAN_INFO_ATTR_FREQ |
| 2115 | #undef CHAN_INFO_ATTR_MAX_REG_POWER |
| 2116 | #undef CHAN_INFO_ATTR_MAX_POWER |
| 2117 | #undef CHAN_INFO_ATTR_MIN_POWER |
| 2118 | #undef CHAN_INFO_ATTR_REG_CLASS_ID |
| 2119 | #undef CHAN_INFO_ATTR_ANTENNA_GAIN |
| 2120 | #undef CHAN_INFO_ATTR_VHT_SEG_0 |
| 2121 | #undef CHAN_INFO_ATTR_VHT_SEG_1 |
| 2122 | |
| 2123 | /** |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2124 | * hdd_cfg80211_update_pcl() - add pcl info attributes |
| 2125 | * @skb: pointer to sk buff |
| 2126 | * @hdd_ctx: pointer to hdd station context |
| 2127 | * @idx: attribute index |
| 2128 | * @vendor_pcl_list: PCL list |
| 2129 | * @vendor_weight_list: PCL weights |
| 2130 | * |
| 2131 | * Return: Success(0) or reason code for failure |
| 2132 | */ |
| 2133 | static int32_t |
| 2134 | hdd_cfg80211_update_pcl(struct sk_buff *skb, |
| 2135 | uint8_t ch_list_count, int idx, |
| 2136 | uint8_t *vendor_pcl_list, uint8_t *vendor_weight_list) |
| 2137 | { |
| 2138 | struct nlattr *nla_attr, *channel; |
| 2139 | int i; |
| 2140 | |
| 2141 | nla_attr = nla_nest_start(skb, idx); |
| 2142 | |
| 2143 | if (!nla_attr) |
| 2144 | goto fail; |
| 2145 | |
| 2146 | for (i = 0; i < ch_list_count; i++) { |
| 2147 | channel = nla_nest_start(skb, i); |
| 2148 | if (!channel) |
| 2149 | goto fail; |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2150 | if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_PCL_CHANNEL, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2151 | vendor_pcl_list[i]) || |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2152 | nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_PCL_WEIGHT, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2153 | vendor_weight_list[i])) { |
| 2154 | hdd_err("put fail"); |
| 2155 | goto fail; |
| 2156 | } |
| 2157 | nla_nest_end(skb, channel); |
| 2158 | } |
| 2159 | nla_nest_end(skb, nla_attr); |
| 2160 | |
| 2161 | return 0; |
| 2162 | fail: |
| 2163 | hdd_err("updating pcl list failed"); |
| 2164 | return -EINVAL; |
| 2165 | } |
| 2166 | |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 2167 | static void hdd_get_scan_band(struct hdd_context *hdd_ctx, |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2168 | tsap_Config_t *sap_config, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2169 | enum band_info *band) |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2170 | { |
| 2171 | /* Get scan band */ |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2172 | if ((sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211B) || |
| 2173 | (sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211G)) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2174 | *band = BAND_2G; |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2175 | } else if (sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211A) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2176 | *band = BAND_5G; |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2177 | } else if (sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211ANY) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2178 | *band = BAND_ALL; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2179 | } |
| 2180 | /* Auto is not supported currently */ |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2181 | if (!((*band == BAND_2G) || (BAND_5G == *band))) { |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2182 | hdd_err("invalid band"); |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2183 | if (HDD_EXTERNAL_ACS_FREQ_BAND_24GHZ == |
| 2184 | hdd_ctx->config->external_acs_freq_band) |
Himanshu Agarwal | e994970 | 2018-03-01 17:30:01 +0530 | [diff] [blame] | 2185 | *band = BAND_2G; |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2186 | else |
Himanshu Agarwal | e994970 | 2018-03-01 17:30:01 +0530 | [diff] [blame] | 2187 | *band = BAND_5G; |
| 2188 | |
| 2189 | hdd_update_acs_channel_list(sap_config, *band); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2190 | } |
Himanshu Agarwal | e994970 | 2018-03-01 17:30:01 +0530 | [diff] [blame] | 2191 | |
| 2192 | if (*band == BAND_2G && |
| 2193 | (sap_config->acs_cfg.ch_width == CH_WIDTH_80MHZ || |
| 2194 | sap_config->acs_cfg.ch_width == CH_WIDTH_160MHZ || |
| 2195 | sap_config->acs_cfg.ch_width == CH_WIDTH_80P80MHZ)) |
| 2196 | sap_config->acs_cfg.ch_width = CH_WIDTH_40MHZ; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2197 | } |
| 2198 | |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2199 | |
| 2200 | /** |
| 2201 | * hdd_get_freq_list: API to get Frequency list based on channel list |
| 2202 | * @channel_list: channel list |
| 2203 | * @freq_list: frequency list |
| 2204 | * @channel_count: channel count |
| 2205 | * |
| 2206 | * Return: None |
| 2207 | */ |
| 2208 | static void hdd_get_freq_list(uint8_t *channel_list, uint32_t *freq_list, |
| 2209 | uint32_t channel_count) |
| 2210 | { |
| 2211 | int count; |
| 2212 | |
| 2213 | for (count = 0; count < channel_count ; count++) |
| 2214 | freq_list[count] = cds_chan_to_freq(channel_list[count]); |
| 2215 | } |
| 2216 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2217 | int hdd_cfg80211_update_acs_config(struct hdd_adapter *adapter, |
| 2218 | uint8_t reason) |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2219 | { |
| 2220 | struct sk_buff *skb; |
| 2221 | tsap_Config_t *sap_config; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2222 | uint32_t channel_count = 0, status = -EINVAL; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2223 | uint8_t channel_list[QDF_MAX_NUM_CHAN] = {0}; |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2224 | uint32_t freq_list[QDF_MAX_NUM_CHAN] = {0}; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2225 | uint8_t vendor_pcl_list[QDF_MAX_NUM_CHAN] = {0}; |
| 2226 | uint8_t vendor_weight_list[QDF_MAX_NUM_CHAN] = {0}; |
| 2227 | struct hdd_vendor_acs_chan_params acs_chan_params; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 2228 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2229 | enum band_info band = BAND_2G; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2230 | eCsrPhyMode phy_mode; |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2231 | enum qca_wlan_vendor_attr_external_acs_policy acs_policy; |
| 2232 | uint32_t i; |
| 2233 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2234 | |
| 2235 | if (!hdd_ctx) { |
| 2236 | hdd_err("HDD context is NULL"); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2237 | return -EINVAL; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2238 | } |
| 2239 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 2240 | hdd_enter(); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2241 | sap_config = &adapter->session.ap.sap_config; |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 2242 | /* When first 2 connections are on the same frequency band, |
| 2243 | * then PCL would include only channels from the other |
| 2244 | * frequency band on which no connections are active |
| 2245 | */ |
| 2246 | if ((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 2) && |
| 2247 | (sap_config->acs_cfg.band == QCA_ACS_MODE_IEEE80211ANY)) { |
| 2248 | struct policy_mgr_conc_connection_info *conc_connection_info; |
| 2249 | |
| 2250 | conc_connection_info = policy_mgr_get_conn_info(&i); |
| 2251 | if (conc_connection_info[0].mac == |
| 2252 | conc_connection_info[1].mac) { |
| 2253 | |
| 2254 | if (WLAN_REG_IS_5GHZ_CH(sap_config->acs_cfg. |
| 2255 | pcl_channels[0])) { |
| 2256 | sap_config->acs_cfg.band = |
| 2257 | QCA_ACS_MODE_IEEE80211A; |
| 2258 | hdd_update_acs_channel_list(sap_config, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2259 | BAND_5G); |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 2260 | } else { |
| 2261 | sap_config->acs_cfg.band = |
| 2262 | QCA_ACS_MODE_IEEE80211G; |
| 2263 | hdd_update_acs_channel_list(sap_config, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2264 | BAND_2G); |
Jayachandran Sreekumaran | 5c7cd97 | 2017-09-27 18:51:41 +0530 | [diff] [blame] | 2265 | } |
| 2266 | } |
| 2267 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2268 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2269 | hdd_get_scan_band(hdd_ctx, &adapter->session.ap.sap_config, &band); |
Nachiket Kukade | 3208c16 | 2017-08-29 17:40:59 +0530 | [diff] [blame] | 2270 | |
| 2271 | if (sap_config->acs_cfg.ch_list) { |
| 2272 | /* Copy INI or hostapd provided ACS channel range*/ |
| 2273 | qdf_mem_copy(channel_list, sap_config->acs_cfg.ch_list, |
| 2274 | sap_config->acs_cfg.ch_list_count); |
| 2275 | channel_count = sap_config->acs_cfg.ch_list_count; |
| 2276 | } else { |
| 2277 | /* No channel list provided, copy all valid channels */ |
| 2278 | wlan_hdd_sap_get_valid_channellist(adapter, |
| 2279 | &channel_count, |
| 2280 | channel_list, |
| 2281 | band); |
| 2282 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2283 | |
| 2284 | hdd_update_reg_chan_info(adapter, channel_count, channel_list); |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2285 | hdd_get_freq_list(channel_list, freq_list, channel_count); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2286 | /* Get phymode */ |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2287 | phy_mode = adapter->session.ap.sap_config.acs_cfg.hw_mode; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2288 | |
| 2289 | skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 2290 | &(adapter->wdev), |
| 2291 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2292 | QCA_NL80211_VENDOR_SUBCMD_UPDATE_EXTERNAL_ACS_CONFIG, |
| 2293 | GFP_KERNEL); |
| 2294 | |
| 2295 | if (!skb) { |
| 2296 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2297 | return -ENOMEM; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2298 | } |
| 2299 | /* |
| 2300 | * Application expects pcl to be a subset of channel list |
| 2301 | * Remove all channels which are not in channel list from pcl |
| 2302 | * and add weight as zero |
| 2303 | */ |
| 2304 | acs_chan_params.channel_count = channel_count; |
| 2305 | acs_chan_params.channel_list = channel_list; |
| 2306 | acs_chan_params.vendor_pcl_list = vendor_pcl_list; |
| 2307 | acs_chan_params.vendor_weight_list = vendor_weight_list; |
| 2308 | |
| 2309 | hdd_update_vendor_pcl_list(hdd_ctx, &acs_chan_params, |
| 2310 | sap_config); |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2311 | |
| 2312 | if (acs_chan_params.channel_count) { |
| 2313 | hdd_debug("ACS channel list: len: %d", |
| 2314 | acs_chan_params.channel_count); |
| 2315 | for (i = 0; i < acs_chan_params.channel_count; i++) |
| 2316 | hdd_debug("%d ", acs_chan_params.channel_list[i]); |
| 2317 | } |
| 2318 | |
| 2319 | if (acs_chan_params.pcl_count) { |
| 2320 | hdd_debug("ACS PCL list: len: %d", |
| 2321 | acs_chan_params.pcl_count); |
| 2322 | for (i = 0; i < acs_chan_params.pcl_count; i++) |
| 2323 | hdd_debug("channel:%d, weight:%d ", |
| 2324 | acs_chan_params. |
| 2325 | vendor_pcl_list[i], |
| 2326 | acs_chan_params. |
| 2327 | vendor_weight_list[i]); |
| 2328 | } |
| 2329 | |
| 2330 | if (HDD_EXTERNAL_ACS_PCL_MANDATORY == |
| 2331 | hdd_ctx->config->external_acs_policy) { |
| 2332 | acs_policy = |
| 2333 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_POLICY_PCL_MANDATORY; |
| 2334 | } else { |
| 2335 | acs_policy = |
| 2336 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_POLICY_PCL_PREFERRED; |
| 2337 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2338 | /* Update values in NL buffer */ |
| 2339 | if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_REASON, |
| 2340 | reason) || |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2341 | nla_put_flag(skb, |
| 2342 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_IS_OFFLOAD_ENABLED) || |
| 2343 | nla_put_flag(skb, |
| 2344 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_ADD_CHAN_STATS_SUPPORT) |
| 2345 | || |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2346 | nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_CHAN_WIDTH, |
| 2347 | sap_config->acs_cfg.ch_width) || |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2348 | nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_BAND, |
| 2349 | band) || |
| 2350 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_PHY_MODE, |
| 2351 | phy_mode) || |
SaidiReddy Yenuga | e14cfb8 | 2017-05-04 18:50:37 +0530 | [diff] [blame] | 2352 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_FREQ_LIST, |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2353 | channel_count * sizeof(uint32_t), freq_list)) { |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2354 | hdd_err("nla put fail"); |
| 2355 | goto fail; |
| 2356 | } |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2357 | status = |
| 2358 | hdd_cfg80211_update_pcl(skb, |
| 2359 | acs_chan_params. |
| 2360 | pcl_count, |
| 2361 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_PCL, |
| 2362 | vendor_pcl_list, |
| 2363 | vendor_weight_list); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2364 | |
| 2365 | if (status != 0) |
| 2366 | goto fail; |
| 2367 | |
| 2368 | status = hdd_cfg80211_update_channel_info(skb, sap_config, |
| 2369 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_CHAN_INFO); |
| 2370 | |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 2371 | qdf_mem_free(sap_config->channel_info); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2372 | if (status != 0) |
| 2373 | goto fail; |
| 2374 | |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2375 | status = nla_put_u32(skb, |
| 2376 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_EVENT_POLICY, |
| 2377 | acs_policy); |
| 2378 | |
| 2379 | if (status != 0) |
| 2380 | goto fail; |
| 2381 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2382 | cfg80211_vendor_event(skb, GFP_KERNEL); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2383 | return 0; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2384 | fail: |
| 2385 | if (skb) |
| 2386 | kfree_skb(skb); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2387 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2388 | } |
| 2389 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2390 | /** |
| 2391 | * hdd_create_acs_timer(): Initialize vendor ACS timer |
| 2392 | * @adapter: pointer to SAP adapter struct |
| 2393 | * |
| 2394 | * This function initializes the vendor ACS timer. |
| 2395 | * |
| 2396 | * Return: Status of create vendor ACS timer |
| 2397 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 2398 | static int hdd_create_acs_timer(struct hdd_adapter *adapter) |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2399 | { |
| 2400 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2401 | QDF_STATUS status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2402 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2403 | if (adapter->session.ap.vendor_acs_timer_initialized) |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2404 | return 0; |
| 2405 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2406 | hdd_debug("Starting vendor app based ACS"); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2407 | timer_context = qdf_mem_malloc(sizeof(*timer_context)); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2408 | if (!timer_context) { |
| 2409 | hdd_err("Could not allocate for timer_context"); |
| 2410 | return -ENOMEM; |
| 2411 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2412 | timer_context->adapter = adapter; |
| 2413 | |
| 2414 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2415 | status = qdf_mc_timer_init(&adapter->session.ap.vendor_acs_timer, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2416 | QDF_TIMER_TYPE_SW, |
| 2417 | hdd_acs_response_timeout_handler, timer_context); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2418 | if (status != QDF_STATUS_SUCCESS) { |
| 2419 | hdd_err("Failed to initialize acs response timeout timer"); |
| 2420 | return -EFAULT; |
| 2421 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2422 | adapter->session.ap.vendor_acs_timer_initialized = true; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2423 | return 0; |
| 2424 | } |
| 2425 | |
Ashish Kumar Dhanotiya | cc770eb | 2017-06-08 19:31:15 +0530 | [diff] [blame] | 2426 | static const struct nla_policy |
| 2427 | wlan_hdd_cfg80211_do_acs_policy[QCA_WLAN_VENDOR_ATTR_ACS_MAX+1] = { |
| 2428 | [QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE] = { .type = NLA_U8 }, |
| 2429 | [QCA_WLAN_VENDOR_ATTR_ACS_HT_ENABLED] = { .type = NLA_FLAG }, |
| 2430 | [QCA_WLAN_VENDOR_ATTR_ACS_HT40_ENABLED] = { .type = NLA_FLAG }, |
| 2431 | [QCA_WLAN_VENDOR_ATTR_ACS_VHT_ENABLED] = { .type = NLA_FLAG }, |
| 2432 | [QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH] = { .type = NLA_U16 }, |
| 2433 | [QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST] = { .type = NLA_UNSPEC }, |
| 2434 | [QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST] = { .type = NLA_UNSPEC }, |
| 2435 | }; |
| 2436 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2437 | int hdd_start_vendor_acs(struct hdd_adapter *adapter) |
| 2438 | { |
| 2439 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2440 | int status; |
| 2441 | |
| 2442 | status = hdd_create_acs_timer(adapter); |
| 2443 | if (status != 0) { |
| 2444 | hdd_err("failed to create acs timer"); |
| 2445 | return status; |
| 2446 | } |
| 2447 | status = hdd_update_acs_timer_reason(adapter, |
| 2448 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT); |
| 2449 | if (status != 0) { |
| 2450 | hdd_err("failed to update acs timer reason"); |
| 2451 | return status; |
| 2452 | } |
| 2453 | |
| 2454 | if (hdd_ctx->config->acs_support_for_dfs_ltecoex) |
| 2455 | status = qdf_status_to_os_return(wlan_sap_set_vendor_acs( |
| 2456 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 2457 | true)); |
| 2458 | else |
| 2459 | status = qdf_status_to_os_return(wlan_sap_set_vendor_acs( |
| 2460 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 2461 | false)); |
| 2462 | |
| 2463 | return status; |
| 2464 | } |
| 2465 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2466 | /** |
Ashish Kumar Dhanotiya | cc770eb | 2017-06-08 19:31:15 +0530 | [diff] [blame] | 2467 | * __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] | 2468 | * @wiphy: Linux wiphy struct pointer |
| 2469 | * @wdev: Linux wireless device struct pointer |
| 2470 | * @data: ACS information from hostapd |
| 2471 | * @data_len: ACS information length |
| 2472 | * |
| 2473 | * This function handle DO_ACS Vendor command from hostapd, parses ACS config |
| 2474 | * and starts ACS procedure. |
| 2475 | * |
| 2476 | * Return: ACS procedure start status |
| 2477 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2478 | static int __wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy, |
| 2479 | struct wireless_dev *wdev, |
| 2480 | const void *data, int data_len) |
| 2481 | { |
| 2482 | struct net_device *ndev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 2483 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 2484 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2485 | tsap_Config_t *sap_config; |
| 2486 | struct sk_buff *temp_skbuff; |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2487 | int ret, i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2488 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ACS_MAX + 1]; |
| 2489 | bool ht_enabled, ht40_enabled, vht_enabled; |
wadesong | 1795e14 | 2018-01-05 11:13:07 +0800 | [diff] [blame] | 2490 | uint8_t ch_width; |
| 2491 | enum qca_wlan_vendor_acs_hw_mode hw_mode; |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 2492 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2493 | |
| 2494 | /* ***Note*** Donot set SME config related to ACS operation here because |
| 2495 | * ACS operation is not synchronouse and ACS for Second AP may come when |
| 2496 | * ACS operation for first AP is going on. So only do_acs is split to |
| 2497 | * seperate start_acs routine. Also SME-PMAC struct that is used to |
| 2498 | * pass paremeters from HDD to SAP is global. Thus All ACS related SME |
| 2499 | * config shall be set only from start_acs. |
| 2500 | */ |
| 2501 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2502 | hdd_enter_dev(ndev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 2503 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2504 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2505 | hdd_err("Command not allowed in FTM mode"); |
| 2506 | return -EPERM; |
| 2507 | } |
| 2508 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2509 | if (hdd_ctx->config->force_sap_acs && |
| 2510 | !hdd_ctx->config->vendor_acs_support) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2511 | hdd_err("Hostapd ACS rejected as Driver ACS enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2512 | return -EPERM; |
| 2513 | } |
| 2514 | |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2515 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2516 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2517 | goto out; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2518 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 2519 | if (cds_is_sub_20_mhz_enabled()) { |
| 2520 | hdd_err("ACS not supported in sub 20 MHz ch wd."); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2521 | ret = -EINVAL; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 2522 | goto out; |
| 2523 | } |
| 2524 | |
Abhinav Kumar | 5eda62d | 2018-02-13 13:00:39 +0530 | [diff] [blame] | 2525 | if (qdf_atomic_inc_return(&hdd_ctx->is_acs_allowed) > 1) { |
| 2526 | hdd_err("ACS rejected as previous req already in progress"); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2527 | ret = -EINVAL; |
Abhinav Kumar | 5eda62d | 2018-02-13 13:00:39 +0530 | [diff] [blame] | 2528 | goto out; |
| 2529 | } |
| 2530 | |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2531 | 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] | 2532 | data_len, |
| 2533 | wlan_hdd_cfg80211_do_acs_policy); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2534 | if (ret) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2535 | hdd_err("Invalid ATTR"); |
Abhinav Kumar | 5eda62d | 2018-02-13 13:00:39 +0530 | [diff] [blame] | 2536 | qdf_atomic_set(&hdd_ctx->is_acs_allowed, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2537 | goto out; |
| 2538 | } |
| 2539 | |
| 2540 | if (!tb[QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2541 | hdd_err("Attr hw_mode failed"); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2542 | ret = -EINVAL; |
Abhinav Kumar | 5eda62d | 2018-02-13 13:00:39 +0530 | [diff] [blame] | 2543 | qdf_atomic_set(&hdd_ctx->is_acs_allowed, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2544 | goto out; |
| 2545 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2546 | 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] | 2547 | |
| 2548 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_HT_ENABLED]) |
| 2549 | ht_enabled = |
| 2550 | nla_get_flag(tb[QCA_WLAN_VENDOR_ATTR_ACS_HT_ENABLED]); |
| 2551 | else |
| 2552 | ht_enabled = 0; |
| 2553 | |
| 2554 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_HT40_ENABLED]) |
| 2555 | ht40_enabled = |
| 2556 | nla_get_flag(tb[QCA_WLAN_VENDOR_ATTR_ACS_HT40_ENABLED]); |
| 2557 | else |
| 2558 | ht40_enabled = 0; |
| 2559 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2560 | hdd_debug("ht40_enabled %d", ht40_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2561 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_VHT_ENABLED]) |
| 2562 | vht_enabled = |
| 2563 | nla_get_flag(tb[QCA_WLAN_VENDOR_ATTR_ACS_VHT_ENABLED]); |
| 2564 | else |
| 2565 | vht_enabled = 0; |
| 2566 | |
Bala Venkatesh | b9cf336 | 2017-11-09 15:48:46 +0530 | [diff] [blame] | 2567 | if (((adapter->device_mode == QDF_SAP_MODE) && |
| 2568 | (hdd_ctx->config->sap_force_11n_for_11ac)) || |
| 2569 | ((adapter->device_mode == QDF_P2P_GO_MODE) && |
| 2570 | (hdd_ctx->config->go_force_11n_for_11ac))) { |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 2571 | vht_enabled = 0; |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 2572 | hdd_info("VHT is Disabled in ACS"); |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 2573 | } |
| 2574 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2575 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH]) { |
| 2576 | ch_width = nla_get_u16(tb[QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH]); |
| 2577 | } else { |
| 2578 | if (ht_enabled && ht40_enabled) |
| 2579 | ch_width = 40; |
| 2580 | else |
| 2581 | ch_width = 20; |
| 2582 | } |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 2583 | |
Bala Venkatesh | b9cf336 | 2017-11-09 15:48:46 +0530 | [diff] [blame] | 2584 | /* this may be possible, when sap_force_11n_for_11ac or |
| 2585 | * go_force_11n_for_11ac is set |
| 2586 | */ |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 2587 | if ((ch_width == 80 || ch_width == 160) && !vht_enabled) { |
| 2588 | if (ht_enabled && ht40_enabled) |
| 2589 | ch_width = 40; |
| 2590 | else |
| 2591 | ch_width = 20; |
| 2592 | } |
| 2593 | |
Hanumanth Reddy Pothula | 560d571 | 2018-03-15 18:11:27 +0530 | [diff] [blame] | 2594 | sap_config = &adapter->session.ap.sap_config; |
| 2595 | |
| 2596 | /* Check and free if memory is already allocated for acs channel list */ |
| 2597 | wlan_hdd_undo_acs(adapter); |
| 2598 | |
| 2599 | qdf_mem_zero(&sap_config->acs_cfg, sizeof(struct sap_acs_cfg)); |
| 2600 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2601 | hdd_debug("channel width =%d", ch_width); |
Himanshu Agarwal | 75e7441 | 2018-02-01 20:51:47 +0530 | [diff] [blame] | 2602 | if (ch_width == 160) |
| 2603 | sap_config->acs_cfg.ch_width = CH_WIDTH_160MHZ; |
| 2604 | else if (ch_width == 80) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2605 | sap_config->acs_cfg.ch_width = CH_WIDTH_80MHZ; |
| 2606 | else if (ch_width == 40) |
| 2607 | sap_config->acs_cfg.ch_width = CH_WIDTH_40MHZ; |
| 2608 | else |
| 2609 | sap_config->acs_cfg.ch_width = CH_WIDTH_20MHZ; |
| 2610 | |
| 2611 | /* hw_mode = a/b/g: QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST and |
| 2612 | * QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST attrs are present, and |
| 2613 | * QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST is used for obtaining the |
| 2614 | * channel list, QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST is ignored |
| 2615 | * since it contains the frequency values of the channels in |
| 2616 | * the channel list. |
| 2617 | * hw_mode = any: only QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST attr |
| 2618 | * is present |
| 2619 | */ |
Himanshu Agarwal | 1b3be70 | 2018-02-20 12:16:57 +0530 | [diff] [blame] | 2620 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2621 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST]) { |
| 2622 | char *tmp = nla_data(tb[QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST]); |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 2623 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2624 | sap_config->acs_cfg.ch_list_count = nla_len( |
| 2625 | tb[QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST]); |
| 2626 | if (sap_config->acs_cfg.ch_list_count) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2627 | sap_config->acs_cfg.ch_list = qdf_mem_malloc( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2628 | sizeof(uint8_t) * |
| 2629 | sap_config->acs_cfg.ch_list_count); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2630 | if (!sap_config->acs_cfg.ch_list) { |
| 2631 | hdd_err("ACS config alloc fail"); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2632 | ret = -ENOMEM; |
Abhinav Kumar | 5eda62d | 2018-02-13 13:00:39 +0530 | [diff] [blame] | 2633 | qdf_atomic_set(&hdd_ctx->is_acs_allowed, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2634 | goto out; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2635 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2636 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2637 | qdf_mem_copy(sap_config->acs_cfg.ch_list, tmp, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2638 | sap_config->acs_cfg.ch_list_count); |
| 2639 | } |
| 2640 | } else if (tb[QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST]) { |
| 2641 | uint32_t *freq = |
| 2642 | nla_data(tb[QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST]); |
| 2643 | sap_config->acs_cfg.ch_list_count = nla_len( |
| 2644 | tb[QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST]) / |
| 2645 | sizeof(uint32_t); |
| 2646 | if (sap_config->acs_cfg.ch_list_count) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2647 | sap_config->acs_cfg.ch_list = qdf_mem_malloc( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2648 | sap_config->acs_cfg.ch_list_count); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2649 | if (!sap_config->acs_cfg.ch_list) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2650 | hdd_err("ACS config alloc fail"); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2651 | ret = -ENOMEM; |
Abhinav Kumar | 5eda62d | 2018-02-13 13:00:39 +0530 | [diff] [blame] | 2652 | qdf_atomic_set(&hdd_ctx->is_acs_allowed, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2653 | goto out; |
| 2654 | } |
| 2655 | |
| 2656 | /* convert frequency to channel */ |
| 2657 | for (i = 0; i < sap_config->acs_cfg.ch_list_count; i++) |
| 2658 | sap_config->acs_cfg.ch_list[i] = |
| 2659 | ieee80211_frequency_to_channel(freq[i]); |
| 2660 | } |
| 2661 | } |
| 2662 | |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2663 | if (!sap_config->acs_cfg.ch_list_count) { |
| 2664 | ret = -EINVAL; |
| 2665 | goto out; |
| 2666 | } |
| 2667 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2668 | hdd_debug("get pcl for DO_ACS vendor command"); |
| 2669 | |
| 2670 | /* consult policy manager to get PCL */ |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 2671 | qdf_status = policy_mgr_get_pcl(hdd_ctx->hdd_psoc, PM_SAP_MODE, |
Manishekar Chandrasekaran | 7009f25 | 2016-04-21 19:14:15 +0530 | [diff] [blame] | 2672 | sap_config->acs_cfg.pcl_channels, |
| 2673 | &sap_config->acs_cfg.pcl_ch_count, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2674 | sap_config->acs_cfg.pcl_channels_weight_list, |
| 2675 | QDF_MAX_NUM_CHAN); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2676 | if (qdf_status != QDF_STATUS_SUCCESS) |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2677 | hdd_err("Get PCL failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2678 | |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2679 | if (sap_config->acs_cfg.pcl_ch_count) { |
| 2680 | hdd_debug("ACS config PCL: len: %d", |
| 2681 | sap_config->acs_cfg.pcl_ch_count); |
| 2682 | for (i = 0; i < sap_config->acs_cfg.pcl_ch_count; i++) |
| 2683 | hdd_debug("channel:%d, weight:%d ", |
| 2684 | sap_config->acs_cfg. |
| 2685 | pcl_channels[i], |
| 2686 | sap_config->acs_cfg. |
| 2687 | pcl_channels_weight_list[i]); |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 2688 | } |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 2689 | |
Tushnim Bhattacharyya | 087bff3 | 2018-02-21 13:25:15 -0800 | [diff] [blame] | 2690 | if (hw_mode == QCA_ACS_MODE_IEEE80211ANY) |
| 2691 | policy_mgr_trim_acs_channel_list(hdd_ctx->hdd_psoc, |
| 2692 | sap_config->acs_cfg.ch_list, |
| 2693 | &sap_config->acs_cfg.ch_list_count); |
| 2694 | |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 2695 | if (hdd_ctx->config->force_sap_acs) { |
| 2696 | hdd_debug("forcing SAP acs start and end channel"); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2697 | ret = wlan_hdd_reset_force_acs_chan_range(hdd_ctx, |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 2698 | sap_config); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2699 | if (ret) { |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2700 | hdd_err("reset force acs channel range failed"); |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 2701 | goto out; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2702 | } |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 2703 | } |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2704 | |
| 2705 | sap_config->acs_cfg.band = hw_mode; |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2706 | ret = wlan_hdd_set_acs_ch_range(sap_config, hw_mode, |
Himanshu Agarwal | 8b3d3e9 | 2018-02-08 23:03:54 +0530 | [diff] [blame] | 2707 | ht_enabled, vht_enabled); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2708 | if (ret) { |
Himanshu Agarwal | 8b3d3e9 | 2018-02-08 23:03:54 +0530 | [diff] [blame] | 2709 | hdd_err("set acs channel range failed"); |
| 2710 | goto out; |
| 2711 | } |
| 2712 | |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 2713 | /* ACS override for android */ |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 2714 | if (hdd_ctx->config->sap_p2p_11ac_override && ht_enabled && |
Himanshu Agarwal | 8b3d3e9 | 2018-02-08 23:03:54 +0530 | [diff] [blame] | 2715 | sap_config->acs_cfg.end_ch >= WLAN_REG_CH_NUM(CHAN_ENUM_36) && |
Bala Venkatesh | b9cf336 | 2017-11-09 15:48:46 +0530 | [diff] [blame] | 2716 | !(((adapter->device_mode == QDF_SAP_MODE) && |
| 2717 | (hdd_ctx->config->sap_force_11n_for_11ac)) || |
| 2718 | ((adapter->device_mode == QDF_P2P_GO_MODE) && |
| 2719 | (hdd_ctx->config->go_force_11n_for_11ac)))) { |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2720 | hdd_debug("ACS Config override for 11AC vhtChannelWidth %d", |
| 2721 | hdd_ctx->config->vhtChannelWidth); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2722 | vht_enabled = 1; |
| 2723 | sap_config->acs_cfg.hw_mode = eCSR_DOT11_MODE_11ac; |
| 2724 | sap_config->acs_cfg.ch_width = |
| 2725 | hdd_ctx->config->vhtChannelWidth; |
Himanshu Agarwal | 29a9a3e | 2018-02-21 17:44:37 +0530 | [diff] [blame] | 2726 | } |
| 2727 | |
| 2728 | /* No VHT80 in 2.4G so perform ACS accordingly */ |
| 2729 | if (sap_config->acs_cfg.end_ch <= 14 && |
| 2730 | sap_config->acs_cfg.ch_width == eHT_CHANNEL_WIDTH_80MHZ) { |
| 2731 | sap_config->acs_cfg.ch_width = eHT_CHANNEL_WIDTH_40MHZ; |
| 2732 | hdd_debug("resetting to 40Mhz in 2.4Ghz"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2733 | } |
| 2734 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2735 | hdd_debug("ACS Config for %s: HW_MODE: %d ACS_BW: %d HT: %d VHT: %d START_CH: %d END_CH: %d band %d", |
| 2736 | adapter->dev->name, sap_config->acs_cfg.hw_mode, |
Himanshu Agarwal | 1ed8bff | 2018-02-07 12:50:41 +0530 | [diff] [blame] | 2737 | sap_config->acs_cfg.ch_width, ht_enabled, vht_enabled, |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 2738 | sap_config->acs_cfg.start_ch, sap_config->acs_cfg.end_ch, |
| 2739 | sap_config->acs_cfg.band); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2740 | |
gaolez | e510894 | 2017-03-31 16:56:42 +0800 | [diff] [blame] | 2741 | if (hdd_ctx->config->auto_channel_select_weight) |
| 2742 | sap_config->auto_channel_select_weight = |
| 2743 | hdd_ctx->config->auto_channel_select_weight; |
| 2744 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2745 | sap_config->acs_cfg.is_ht_enabled = ht_enabled; |
| 2746 | sap_config->acs_cfg.is_vht_enabled = vht_enabled; |
| 2747 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2748 | if (sap_config->acs_cfg.ch_list_count) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 2749 | hdd_debug("ACS channel list: len: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2750 | sap_config->acs_cfg.ch_list_count); |
| 2751 | for (i = 0; i < sap_config->acs_cfg.ch_list_count; i++) |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 2752 | hdd_debug("%d ", sap_config->acs_cfg.ch_list[i]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2753 | } |
| 2754 | sap_config->acs_cfg.acs_mode = true; |
| 2755 | if (test_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2756 | /* ***Note*** Completion variable usage is not allowed |
| 2757 | * here since ACS scan operation may take max 2.2 sec |
| 2758 | * for 5G band: |
| 2759 | * 9 Active channel X 40 ms active scan time + |
| 2760 | * 16 Passive channel X 110ms passive scan time |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2761 | * Since this CFG80211 call lock rtnl mutex, we cannot hold on |
| 2762 | * for this long. So we split up the scanning part. |
| 2763 | */ |
| 2764 | set_bit(ACS_PENDING, &adapter->event_flags); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 2765 | hdd_debug("ACS Pending for %s", adapter->dev->name); |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2766 | ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2767 | } else { |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 2768 | /* Check if vendor specific acs is enabled */ |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2769 | if (hdd_ctx->config->vendor_acs_support) |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2770 | ret = hdd_start_vendor_acs(adapter); |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 2771 | else |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2772 | ret = wlan_hdd_cfg80211_start_acs(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2773 | } |
| 2774 | |
| 2775 | out: |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2776 | if (ret == 0) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2777 | temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 2778 | NLMSG_HDRLEN); |
| 2779 | if (temp_skbuff != NULL) |
| 2780 | return cfg80211_vendor_cmd_reply(temp_skbuff); |
| 2781 | } |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 2782 | wlan_hdd_undo_acs(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2783 | clear_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags); |
| 2784 | |
Yeshwanth Sriram Guntuka | d1f8ca7 | 2018-03-02 12:31:38 +0530 | [diff] [blame] | 2785 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2786 | } |
| 2787 | |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 2788 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2789 | * wlan_hdd_cfg80211_do_acs : CFG80211 handler function for DO_ACS Vendor CMD |
| 2790 | * @wiphy: Linux wiphy struct pointer |
| 2791 | * @wdev: Linux wireless device struct pointer |
| 2792 | * @data: ACS information from hostapd |
| 2793 | * @data_len: ACS information len |
| 2794 | * |
| 2795 | * This function handle DO_ACS Vendor command from hostapd, parses ACS config |
| 2796 | * and starts ACS procedure. |
| 2797 | * |
| 2798 | * Return: ACS procedure start status |
| 2799 | */ |
| 2800 | |
| 2801 | static int wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy, |
| 2802 | struct wireless_dev *wdev, |
| 2803 | const void *data, int data_len) |
| 2804 | { |
| 2805 | int ret; |
| 2806 | |
| 2807 | cds_ssr_protect(__func__); |
| 2808 | ret = __wlan_hdd_cfg80211_do_acs(wiphy, wdev, data, data_len); |
| 2809 | cds_ssr_unprotect(__func__); |
| 2810 | |
| 2811 | return ret; |
| 2812 | } |
| 2813 | |
| 2814 | /** |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 2815 | * wlan_hdd_undo_acs : Do cleanup of DO_ACS |
| 2816 | * @adapter: Pointer to adapter struct |
| 2817 | * |
| 2818 | * This function handle cleanup of what was done in DO_ACS, including free |
| 2819 | * memory. |
| 2820 | * |
| 2821 | * Return: void |
| 2822 | */ |
| 2823 | |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 2824 | void wlan_hdd_undo_acs(struct hdd_adapter *adapter) |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 2825 | { |
| 2826 | if (adapter == NULL) |
| 2827 | return; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 2828 | if (adapter->session.ap.sap_config.acs_cfg.ch_list) { |
| 2829 | qdf_mem_free(adapter->session.ap.sap_config.acs_cfg.ch_list); |
| 2830 | adapter->session.ap.sap_config.acs_cfg.ch_list = NULL; |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 2831 | } |
| 2832 | } |
| 2833 | |
| 2834 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2835 | * wlan_hdd_cfg80211_start_pending_acs : Start pending ACS procedure for SAP |
| 2836 | * @work: Linux workqueue struct pointer for ACS work |
| 2837 | * |
| 2838 | * This function starts the ACS procedure which was marked pending when an ACS |
| 2839 | * procedure was in progress for a concurrent SAP interface. |
| 2840 | * |
| 2841 | * Return: None |
| 2842 | */ |
| 2843 | |
| 2844 | static void wlan_hdd_cfg80211_start_pending_acs(struct work_struct *work) |
| 2845 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 2846 | struct hdd_adapter *adapter = container_of(work, struct hdd_adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2847 | acs_pending_work.work); |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 2848 | if (!adapter) |
| 2849 | return; |
| 2850 | clear_bit(ACS_PENDING, &adapter->event_flags); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2851 | wlan_hdd_cfg80211_start_acs(adapter); |
| 2852 | } |
| 2853 | |
| 2854 | /** |
| 2855 | * wlan_hdd_cfg80211_acs_ch_select_evt: Callback function for ACS evt |
| 2856 | * @adapter: Pointer to SAP adapter struct |
| 2857 | * @pri_channel: SAP ACS procedure selected Primary channel |
| 2858 | * @sec_channel: SAP ACS procedure selected secondary channel |
| 2859 | * |
| 2860 | * This is a callback function from SAP module on ACS procedure is completed. |
| 2861 | * This function send the ACS selected channel information to hostapd |
| 2862 | * |
| 2863 | * Return: None |
| 2864 | */ |
| 2865 | |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 2866 | void wlan_hdd_cfg80211_acs_ch_select_evt(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2867 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 2868 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 2869 | 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] | 2870 | struct sk_buff *vendor_event; |
| 2871 | int ret_val; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 2872 | struct hdd_adapter *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2873 | uint16_t ch_width; |
| 2874 | |
| 2875 | vendor_event = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Ryan Hsu | 9206a4e | 2016-01-19 17:23:13 -0800 | [diff] [blame] | 2876 | &(adapter->wdev), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2877 | 4 * sizeof(u8) + 1 * sizeof(u16) + 4 + NLMSG_HDRLEN, |
| 2878 | QCA_NL80211_VENDOR_SUBCMD_DO_ACS_INDEX, |
| 2879 | GFP_KERNEL); |
| 2880 | |
| 2881 | if (!vendor_event) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 2882 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2883 | return; |
| 2884 | } |
| 2885 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2886 | ret_val = nla_put_u8(vendor_event, |
| 2887 | QCA_WLAN_VENDOR_ATTR_ACS_PRIMARY_CHANNEL, |
| 2888 | sap_cfg->acs_cfg.pri_ch); |
| 2889 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 2890 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_PRIMARY_CHANNEL put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2891 | kfree_skb(vendor_event); |
| 2892 | return; |
| 2893 | } |
| 2894 | |
| 2895 | ret_val = nla_put_u8(vendor_event, |
| 2896 | QCA_WLAN_VENDOR_ATTR_ACS_SECONDARY_CHANNEL, |
| 2897 | sap_cfg->acs_cfg.ht_sec_ch); |
| 2898 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 2899 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_SECONDARY_CHANNEL put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2900 | kfree_skb(vendor_event); |
| 2901 | return; |
| 2902 | } |
| 2903 | |
| 2904 | ret_val = nla_put_u8(vendor_event, |
| 2905 | QCA_WLAN_VENDOR_ATTR_ACS_VHT_SEG0_CENTER_CHANNEL, |
| 2906 | sap_cfg->acs_cfg.vht_seg0_center_ch); |
| 2907 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 2908 | 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] | 2909 | kfree_skb(vendor_event); |
| 2910 | return; |
| 2911 | } |
| 2912 | |
| 2913 | ret_val = nla_put_u8(vendor_event, |
| 2914 | QCA_WLAN_VENDOR_ATTR_ACS_VHT_SEG1_CENTER_CHANNEL, |
| 2915 | sap_cfg->acs_cfg.vht_seg1_center_ch); |
| 2916 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 2917 | 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] | 2918 | kfree_skb(vendor_event); |
| 2919 | return; |
| 2920 | } |
| 2921 | |
Himanshu Agarwal | 75e7441 | 2018-02-01 20:51:47 +0530 | [diff] [blame] | 2922 | if (sap_cfg->acs_cfg.ch_width == CH_WIDTH_160MHZ) |
| 2923 | ch_width = 160; |
| 2924 | else if (sap_cfg->acs_cfg.ch_width == CH_WIDTH_80MHZ) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2925 | ch_width = 80; |
| 2926 | else if (sap_cfg->acs_cfg.ch_width == CH_WIDTH_40MHZ) |
| 2927 | ch_width = 40; |
| 2928 | else |
| 2929 | ch_width = 20; |
| 2930 | |
| 2931 | ret_val = nla_put_u16(vendor_event, |
| 2932 | QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH, |
| 2933 | ch_width); |
| 2934 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 2935 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2936 | kfree_skb(vendor_event); |
| 2937 | return; |
| 2938 | } |
| 2939 | if (sap_cfg->acs_cfg.pri_ch > 14) |
| 2940 | ret_val = nla_put_u8(vendor_event, |
| 2941 | QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE, |
| 2942 | QCA_ACS_MODE_IEEE80211A); |
| 2943 | else |
| 2944 | ret_val = nla_put_u8(vendor_event, |
| 2945 | QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE, |
| 2946 | QCA_ACS_MODE_IEEE80211G); |
| 2947 | |
| 2948 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 2949 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2950 | kfree_skb(vendor_event); |
| 2951 | return; |
| 2952 | } |
| 2953 | |
Mahesh Kumar Kalikot Veetil | ec1da14 | 2017-09-20 10:01:13 -0700 | [diff] [blame] | 2954 | hdd_debug("ACS result for %s: PRI_CH: %d SEC_CH: %d VHT_SEG0: %d VHT_SEG1: %d ACS_BW: %d", |
| 2955 | adapter->dev->name, sap_cfg->acs_cfg.pri_ch, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2956 | sap_cfg->acs_cfg.ht_sec_ch, sap_cfg->acs_cfg.vht_seg0_center_ch, |
| 2957 | sap_cfg->acs_cfg.vht_seg1_center_ch, ch_width); |
| 2958 | |
| 2959 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 2960 | /* ***Note*** As already mentioned Completion variable usage is not |
| 2961 | * allowed here since ACS scan operation may take max 2.2 sec. |
| 2962 | * Further in AP-AP mode pending ACS is resumed here to serailize ACS |
| 2963 | * operation. |
| 2964 | * TODO: Delayed operation is used since SME-PMAC strut is global. Thus |
| 2965 | * when Primary AP ACS is complete and secondary AP ACS is started here |
| 2966 | * immediately, Primary AP start_bss may come inbetween ACS operation |
| 2967 | * and overwrite Sec AP ACS paramters. Thus Sec AP ACS is executed with |
| 2968 | * delay. This path and below constraint will be removed on sessionizing |
| 2969 | * SAP acs parameters and decoupling SAP from PMAC (WIP). |
| 2970 | * As per design constraint user space control application must take |
| 2971 | * care of serailizing hostapd start for each VIF in AP-AP mode to avoid |
| 2972 | * this code path. Sec AP hostapd should be started after Primary AP |
| 2973 | * start beaconing which can be confirmed by getchannel iwpriv command |
| 2974 | */ |
| 2975 | |
| 2976 | con_sap_adapter = hdd_get_con_sap_adapter(adapter, false); |
| 2977 | if (con_sap_adapter && |
| 2978 | test_bit(ACS_PENDING, &con_sap_adapter->event_flags)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2979 | INIT_DELAYED_WORK(&con_sap_adapter->acs_pending_work, |
| 2980 | wlan_hdd_cfg80211_start_pending_acs); |
hqu | 71a1a3b | 2018-01-23 15:38:13 +0800 | [diff] [blame] | 2981 | /* Lets give 1500ms for OBSS + START_BSS to complete */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2982 | schedule_delayed_work(&con_sap_adapter->acs_pending_work, |
hqu | 71a1a3b | 2018-01-23 15:38:13 +0800 | [diff] [blame] | 2983 | msecs_to_jiffies(1500)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2984 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2985 | } |
| 2986 | |
| 2987 | static int |
| 2988 | __wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy, |
| 2989 | struct wireless_dev *wdev, |
| 2990 | const void *data, |
| 2991 | int data_len) |
| 2992 | { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 2993 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2994 | struct sk_buff *skb = NULL; |
| 2995 | uint32_t fset = 0; |
| 2996 | int ret; |
| 2997 | |
Srinivas Girigowda | dbfb264 | 2016-08-28 21:32:38 -0700 | [diff] [blame] | 2998 | /* ENTER_DEV() intentionally not used in a frequently invoked API */ |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2999 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3000 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3001 | hdd_err("Command not allowed in FTM mode"); |
| 3002 | return -EPERM; |
| 3003 | } |
| 3004 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3005 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3006 | if (ret) |
| 3007 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3008 | |
| 3009 | if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3010 | hdd_debug("Infra Station mode is supported by driver"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3011 | fset |= WIFI_FEATURE_INFRA; |
| 3012 | } |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3013 | if (true == hdd_is_5g_supported(hdd_ctx)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3014 | hdd_debug("INFRA_5G is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3015 | fset |= WIFI_FEATURE_INFRA_5G; |
| 3016 | } |
| 3017 | #ifdef WLAN_FEATURE_P2P |
| 3018 | if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) && |
| 3019 | (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3020 | hdd_debug("WiFi-Direct is supported by driver"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3021 | fset |= WIFI_FEATURE_P2P; |
| 3022 | } |
| 3023 | #endif |
| 3024 | fset |= WIFI_FEATURE_SOFT_AP; |
| 3025 | |
| 3026 | /* HOTSPOT is a supplicant feature, enable it by default */ |
| 3027 | fset |= WIFI_FEATURE_HOTSPOT; |
| 3028 | |
| 3029 | #ifdef FEATURE_WLAN_EXTSCAN |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3030 | if (hdd_ctx->config->extscan_enabled && |
Manjeet Singh | 0f2ce5c | 2016-09-01 12:08:57 +0530 | [diff] [blame] | 3031 | sme_is_feature_supported_by_fw(EXTENDED_SCAN)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3032 | hdd_debug("EXTScan is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3033 | fset |= WIFI_FEATURE_EXTSCAN | WIFI_FEATURE_HAL_EPNO; |
| 3034 | } |
| 3035 | #endif |
| 3036 | if (wlan_hdd_nan_is_supported()) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3037 | hdd_debug("NAN is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3038 | fset |= WIFI_FEATURE_NAN; |
| 3039 | } |
| 3040 | if (sme_is_feature_supported_by_fw(RTT)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3041 | hdd_debug("RTT is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3042 | fset |= WIFI_FEATURE_D2D_RTT; |
| 3043 | fset |= WIFI_FEATURE_D2AP_RTT; |
| 3044 | } |
| 3045 | #ifdef FEATURE_WLAN_SCAN_PNO |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3046 | if (hdd_ctx->config->configPNOScanSupport && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3047 | sme_is_feature_supported_by_fw(PNO)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3048 | hdd_debug("PNO is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3049 | fset |= WIFI_FEATURE_PNO; |
| 3050 | } |
| 3051 | #endif |
| 3052 | fset |= WIFI_FEATURE_ADDITIONAL_STA; |
| 3053 | #ifdef FEATURE_WLAN_TDLS |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3054 | if ((true == hdd_ctx->config->fEnableTDLSSupport) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3055 | sme_is_feature_supported_by_fw(TDLS)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3056 | hdd_debug("TDLS is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3057 | fset |= WIFI_FEATURE_TDLS; |
| 3058 | } |
| 3059 | if (sme_is_feature_supported_by_fw(TDLS) && |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3060 | (true == hdd_ctx->config->fEnableTDLSOffChannel) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3061 | sme_is_feature_supported_by_fw(TDLS_OFF_CHANNEL)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3062 | hdd_debug("TDLS off-channel is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3063 | fset |= WIFI_FEATURE_TDLS_OFFCHANNEL; |
| 3064 | } |
| 3065 | #endif |
| 3066 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 3067 | fset |= WIFI_FEATURE_AP_STA; |
| 3068 | #endif |
| 3069 | fset |= WIFI_FEATURE_RSSI_MONITOR; |
Srinivas Girigowda | a2cad3e | 2016-10-25 14:14:23 -0700 | [diff] [blame] | 3070 | fset |= WIFI_FEATURE_TX_TRANSMIT_POWER; |
Srinivas Girigowda | 5a1da62 | 2017-07-12 17:07:44 -0700 | [diff] [blame] | 3071 | fset |= WIFI_FEATURE_SET_TX_POWER_LIMIT; |
Sourav Mohapatra | 804359e | 2017-12-07 13:52:05 +0530 | [diff] [blame] | 3072 | fset |= WIFI_FEATURE_CONFIG_NDO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3073 | |
| 3074 | if (hdd_link_layer_stats_supported()) |
| 3075 | fset |= WIFI_FEATURE_LINK_LAYER_STATS; |
| 3076 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3077 | if (hdd_roaming_supported(hdd_ctx)) |
Srinivas Girigowda | 8df27ea | 2017-01-06 12:42:16 -0800 | [diff] [blame] | 3078 | fset |= WIFI_FEATURE_CONTROL_ROAMING; |
| 3079 | |
| 3080 | if (hdd_scan_random_mac_addr_supported()) |
| 3081 | fset |= WIFI_FEATURE_SCAN_RAND; |
| 3082 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3083 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) + |
| 3084 | NLMSG_HDRLEN); |
| 3085 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3086 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3087 | return -EINVAL; |
| 3088 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3089 | hdd_debug("Supported Features : 0x%x", fset); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3090 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3091 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3092 | goto nla_put_failure; |
| 3093 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3094 | ret = cfg80211_vendor_cmd_reply(skb); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3095 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3096 | nla_put_failure: |
| 3097 | kfree_skb(skb); |
| 3098 | return -EINVAL; |
| 3099 | } |
| 3100 | |
| 3101 | /** |
| 3102 | * wlan_hdd_cfg80211_get_supported_features() - get supported features |
| 3103 | * @wiphy: pointer to wireless wiphy structure. |
| 3104 | * @wdev: pointer to wireless_dev structure. |
| 3105 | * @data: Pointer to the data to be passed via vendor interface |
| 3106 | * @data_len:Length of the data to be passed |
| 3107 | * |
| 3108 | * Return: Return the Success or Failure code. |
| 3109 | */ |
| 3110 | static int |
| 3111 | wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy, |
| 3112 | struct wireless_dev *wdev, |
| 3113 | const void *data, int data_len) |
| 3114 | { |
| 3115 | int ret = 0; |
| 3116 | |
| 3117 | cds_ssr_protect(__func__); |
| 3118 | ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, |
| 3119 | data, data_len); |
| 3120 | cds_ssr_unprotect(__func__); |
| 3121 | |
| 3122 | return ret; |
| 3123 | } |
| 3124 | |
| 3125 | /** |
| 3126 | * __wlan_hdd_cfg80211_set_scanning_mac_oui() - set scan MAC |
| 3127 | * @wiphy: pointer to wireless wiphy structure. |
| 3128 | * @wdev: pointer to wireless_dev structure. |
| 3129 | * @data: Pointer to the data to be passed via vendor interface |
| 3130 | * @data_len:Length of the data to be passed |
| 3131 | * |
| 3132 | * Set the MAC address that is to be used for scanning. |
| 3133 | * |
| 3134 | * Return: Return the Success or Failure code. |
| 3135 | */ |
| 3136 | static int |
| 3137 | __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy, |
| 3138 | struct wireless_dev *wdev, |
| 3139 | const void *data, |
| 3140 | int data_len) |
| 3141 | { |
| 3142 | tpSirScanMacOui pReqMsg = NULL; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3143 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3144 | 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] | 3145 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3146 | int ret; |
Jeff Johnson | 63d1ac8 | 2017-06-01 09:06:48 -0700 | [diff] [blame] | 3147 | int len; |
Rajeev Kumar Sirasanagandla | 686abd9 | 2017-06-08 18:09:01 +0530 | [diff] [blame] | 3148 | struct net_device *ndev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 3149 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3150 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3151 | hdd_enter_dev(wdev->netdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3152 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3153 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3154 | hdd_err("Command not allowed in FTM mode"); |
| 3155 | return -EPERM; |
| 3156 | } |
| 3157 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3158 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3159 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3160 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3161 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3162 | if (false == hdd_ctx->config->enable_mac_spoofing) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3163 | hdd_warn("MAC address spoofing is not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3164 | return -ENOTSUPP; |
| 3165 | } |
| 3166 | |
Jeff Johnson | 63d1ac8 | 2017-06-01 09:06:48 -0700 | [diff] [blame] | 3167 | /* |
| 3168 | * audit note: it is ok to pass a NULL policy here since only |
| 3169 | * one attribute is parsed and it is explicitly validated |
| 3170 | */ |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3171 | if (wlan_cfg80211_nla_parse(tb, |
| 3172 | QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX, |
| 3173 | data, data_len, NULL)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3174 | hdd_err("Invalid ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3175 | return -EINVAL; |
| 3176 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3177 | pReqMsg = qdf_mem_malloc(sizeof(*pReqMsg)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3178 | if (!pReqMsg) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3179 | hdd_err("qdf_mem_malloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3180 | return -ENOMEM; |
| 3181 | } |
Jeff Johnson | 63d1ac8 | 2017-06-01 09:06:48 -0700 | [diff] [blame] | 3182 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3183 | if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3184 | hdd_err("attr mac oui failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3185 | goto fail; |
| 3186 | } |
Jeff Johnson | 63d1ac8 | 2017-06-01 09:06:48 -0700 | [diff] [blame] | 3187 | |
| 3188 | len = nla_len(tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]); |
| 3189 | if (len != sizeof(pReqMsg->oui)) { |
| 3190 | hdd_err("attr mac oui invalid size %d expected %zu", |
| 3191 | len, sizeof(pReqMsg->oui)); |
| 3192 | goto fail; |
| 3193 | } |
| 3194 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3195 | nla_memcpy(&pReqMsg->oui[0], |
| 3196 | tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI], |
| 3197 | sizeof(pReqMsg->oui)); |
Rajeev Kumar Sirasanagandla | 686abd9 | 2017-06-08 18:09:01 +0530 | [diff] [blame] | 3198 | |
| 3199 | /* populate pReqMsg for mac addr randomization */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3200 | pReqMsg->vdev_id = adapter->session_id; |
Rajeev Kumar Sirasanagandla | 686abd9 | 2017-06-08 18:09:01 +0530 | [diff] [blame] | 3201 | pReqMsg->enb_probe_req_sno_randomization = true; |
| 3202 | |
| 3203 | hdd_debug("Oui (%02x:%02x:%02x), vdev_id = %d", pReqMsg->oui[0], |
| 3204 | pReqMsg->oui[1], pReqMsg->oui[2], pReqMsg->vdev_id); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 3205 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3206 | hdd_update_ie_whitelist_attr(&pReqMsg->ie_whitelist, hdd_ctx->config); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 3207 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3208 | status = sme_set_scanning_mac_oui(hdd_ctx->hHal, pReqMsg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3209 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3210 | hdd_err("sme_set_scanning_mac_oui failed(err=%d)", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3211 | goto fail; |
| 3212 | } |
| 3213 | return 0; |
| 3214 | fail: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3215 | qdf_mem_free(pReqMsg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3216 | return -EINVAL; |
| 3217 | } |
| 3218 | |
| 3219 | /** |
| 3220 | * wlan_hdd_cfg80211_set_scanning_mac_oui() - set scan MAC |
| 3221 | * @wiphy: pointer to wireless wiphy structure. |
| 3222 | * @wdev: pointer to wireless_dev structure. |
| 3223 | * @data: Pointer to the data to be passed via vendor interface |
| 3224 | * @data_len:Length of the data to be passed |
| 3225 | * |
| 3226 | * Set the MAC address that is to be used for scanning. This is an |
| 3227 | * SSR-protecting wrapper function. |
| 3228 | * |
| 3229 | * Return: Return the Success or Failure code. |
| 3230 | */ |
| 3231 | static int |
| 3232 | wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy, |
| 3233 | struct wireless_dev *wdev, |
| 3234 | const void *data, |
| 3235 | int data_len) |
| 3236 | { |
| 3237 | int ret; |
| 3238 | |
| 3239 | cds_ssr_protect(__func__); |
| 3240 | ret = __wlan_hdd_cfg80211_set_scanning_mac_oui(wiphy, wdev, |
| 3241 | data, data_len); |
| 3242 | cds_ssr_unprotect(__func__); |
| 3243 | |
| 3244 | return ret; |
| 3245 | } |
| 3246 | |
Rajeev Kumar Sirasanagandla | bff450c | 2017-06-05 19:03:25 +0530 | [diff] [blame] | 3247 | #define MAX_CONCURRENT_MATRIX \ |
| 3248 | QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX |
| 3249 | #define MATRIX_CONFIG_PARAM_SET_SIZE_MAX \ |
| 3250 | QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX |
| 3251 | static const struct nla_policy |
| 3252 | wlan_hdd_get_concurrency_matrix_policy[MAX_CONCURRENT_MATRIX + 1] = { |
| 3253 | [MATRIX_CONFIG_PARAM_SET_SIZE_MAX] = {.type = NLA_U32}, |
| 3254 | }; |
| 3255 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3256 | /** |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3257 | * __wlan_hdd_cfg80211_get_concurrency_matrix() - to retrieve concurrency matrix |
| 3258 | * @wiphy: pointer phy adapter |
| 3259 | * @wdev: pointer to wireless device structure |
| 3260 | * @data: pointer to data buffer |
| 3261 | * @data_len: length of data |
| 3262 | * |
| 3263 | * This routine will give concurrency matrix |
| 3264 | * |
| 3265 | * Return: int status code |
| 3266 | */ |
| 3267 | static int __wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy, |
| 3268 | struct wireless_dev *wdev, |
| 3269 | const void *data, |
| 3270 | int data_len) |
| 3271 | { |
| 3272 | uint32_t feature_set_matrix[CDS_MAX_FEATURE_SET] = {0}; |
| 3273 | uint8_t i, feature_sets, max_feature_sets; |
Rajeev Kumar Sirasanagandla | bff450c | 2017-06-05 19:03:25 +0530 | [diff] [blame] | 3274 | struct nlattr *tb[MAX_CONCURRENT_MATRIX + 1]; |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3275 | struct sk_buff *reply_skb; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 3276 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3277 | int ret; |
| 3278 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3279 | hdd_enter_dev(wdev->netdev); |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3280 | |
| 3281 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 3282 | hdd_err("Command not allowed in FTM mode"); |
| 3283 | return -EPERM; |
| 3284 | } |
| 3285 | |
| 3286 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3287 | if (ret) |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3288 | return ret; |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3289 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3290 | if (wlan_cfg80211_nla_parse(tb, MAX_CONCURRENT_MATRIX, data, data_len, |
| 3291 | wlan_hdd_get_concurrency_matrix_policy)) { |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3292 | hdd_err("Invalid ATTR"); |
| 3293 | return -EINVAL; |
| 3294 | } |
| 3295 | |
| 3296 | /* Parse and fetch max feature set */ |
Rajeev Kumar Sirasanagandla | bff450c | 2017-06-05 19:03:25 +0530 | [diff] [blame] | 3297 | if (!tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) { |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3298 | hdd_err("Attr max feature set size failed"); |
| 3299 | return -EINVAL; |
| 3300 | } |
Rajeev Kumar Sirasanagandla | bff450c | 2017-06-05 19:03:25 +0530 | [diff] [blame] | 3301 | max_feature_sets = nla_get_u32(tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3302 | hdd_debug("Max feature set size: %d", max_feature_sets); |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3303 | |
| 3304 | /* Fill feature combination matrix */ |
| 3305 | feature_sets = 0; |
| 3306 | feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA | |
Srinivas Girigowda | ca42292 | 2016-08-17 18:29:42 -0700 | [diff] [blame] | 3307 | WIFI_FEATURE_P2P; |
| 3308 | feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA | |
| 3309 | WIFI_FEATURE_NAN; |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3310 | /* Add more feature combinations here */ |
| 3311 | |
| 3312 | feature_sets = QDF_MIN(feature_sets, max_feature_sets); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3313 | hdd_debug("Number of feature sets: %d", feature_sets); |
| 3314 | hdd_debug("Feature set matrix"); |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3315 | for (i = 0; i < feature_sets; i++) |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3316 | hdd_debug("[%d] 0x%02X", i, feature_set_matrix[i]); |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3317 | |
| 3318 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) + |
| 3319 | sizeof(u32) * feature_sets + NLMSG_HDRLEN); |
| 3320 | if (!reply_skb) { |
| 3321 | hdd_err("Feature set matrix: buffer alloc fail"); |
| 3322 | return -ENOMEM; |
| 3323 | } |
| 3324 | |
| 3325 | if (nla_put_u32(reply_skb, |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 3326 | QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE, |
| 3327 | feature_sets) || |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3328 | nla_put(reply_skb, |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 3329 | QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET, |
| 3330 | sizeof(u32) * feature_sets, |
| 3331 | feature_set_matrix)) { |
| 3332 | hdd_err("nla put fail"); |
| 3333 | kfree_skb(reply_skb); |
| 3334 | return -EINVAL; |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3335 | } |
| 3336 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 3337 | } |
| 3338 | |
Rajeev Kumar Sirasanagandla | bff450c | 2017-06-05 19:03:25 +0530 | [diff] [blame] | 3339 | #undef MAX_CONCURRENT_MATRIX |
| 3340 | #undef MATRIX_CONFIG_PARAM_SET_SIZE_MAX |
| 3341 | |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 3342 | /** |
| 3343 | * wlan_hdd_cfg80211_get_concurrency_matrix() - get concurrency matrix |
| 3344 | * @wiphy: pointer to wireless wiphy structure. |
| 3345 | * @wdev: pointer to wireless_dev structure. |
| 3346 | * @data: Pointer to the data to be passed via vendor interface |
| 3347 | * @data_len:Length of the data to be passed |
| 3348 | * |
| 3349 | * Retrieves the concurrency feature set matrix |
| 3350 | * |
| 3351 | * Return: 0 on success, negative errno on failure |
| 3352 | */ |
| 3353 | static int |
| 3354 | wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy, |
| 3355 | struct wireless_dev *wdev, |
| 3356 | const void *data, |
| 3357 | int data_len) |
| 3358 | { |
| 3359 | int ret; |
| 3360 | |
| 3361 | cds_ssr_protect(__func__); |
| 3362 | ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, |
| 3363 | data, data_len); |
| 3364 | cds_ssr_unprotect(__func__); |
| 3365 | |
| 3366 | return ret; |
| 3367 | } |
| 3368 | |
| 3369 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3370 | * wlan_hdd_cfg80211_set_feature() - Set the bitmask for supported features |
| 3371 | * @feature_flags: pointer to the byte array of features. |
| 3372 | * @feature: Feature to be turned ON in the byte array. |
| 3373 | * |
| 3374 | * Return: None |
| 3375 | * |
| 3376 | * This is called to turn ON or SET the feature flag for the requested feature. |
| 3377 | **/ |
| 3378 | #define NUM_BITS_IN_BYTE 8 |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 3379 | static void wlan_hdd_cfg80211_set_feature(uint8_t *feature_flags, |
| 3380 | uint8_t feature) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3381 | { |
| 3382 | uint32_t index; |
| 3383 | uint8_t bit_mask; |
| 3384 | |
| 3385 | index = feature / NUM_BITS_IN_BYTE; |
| 3386 | bit_mask = 1 << (feature % NUM_BITS_IN_BYTE); |
| 3387 | feature_flags[index] |= bit_mask; |
| 3388 | } |
| 3389 | |
| 3390 | /** |
| 3391 | * __wlan_hdd_cfg80211_get_features() - Get the Driver Supported features |
| 3392 | * @wiphy: pointer to wireless wiphy structure. |
| 3393 | * @wdev: pointer to wireless_dev structure. |
| 3394 | * @data: Pointer to the data to be passed via vendor interface |
| 3395 | * @data_len:Length of the data to be passed |
| 3396 | * |
| 3397 | * This is called when wlan driver needs to send supported feature set to |
| 3398 | * supplicant upon a request/query from the supplicant. |
| 3399 | * |
| 3400 | * Return: Return the Success or Failure code. |
| 3401 | **/ |
| 3402 | #define MAX_CONCURRENT_CHAN_ON_24G 2 |
| 3403 | #define MAX_CONCURRENT_CHAN_ON_5G 2 |
| 3404 | static int |
| 3405 | __wlan_hdd_cfg80211_get_features(struct wiphy *wiphy, |
| 3406 | struct wireless_dev *wdev, |
| 3407 | const void *data, int data_len) |
| 3408 | { |
| 3409 | struct sk_buff *skb = NULL; |
| 3410 | uint32_t dbs_capability = 0; |
| 3411 | bool one_by_one_dbs, two_by_two_dbs; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3412 | QDF_STATUS ret = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3413 | int ret_val; |
| 3414 | |
| 3415 | uint8_t feature_flags[(NUM_QCA_WLAN_VENDOR_FEATURES + 7) / 8] = {0}; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 3416 | struct hdd_context *hdd_ctx_ptr = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3417 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3418 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 3419 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3420 | ret_val = wlan_hdd_validate_context(hdd_ctx_ptr); |
| 3421 | if (ret_val) |
| 3422 | return ret_val; |
| 3423 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3424 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3425 | hdd_err("Command not allowed in FTM mode"); |
| 3426 | return -EPERM; |
| 3427 | } |
| 3428 | |
Varun Reddy Yeturu | d351a6c | 2016-03-16 14:01:00 -0700 | [diff] [blame] | 3429 | if (roaming_offload_enabled(hdd_ctx_ptr)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3430 | hdd_debug("Key Mgmt Offload is supported"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3431 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3432 | QCA_WLAN_VENDOR_FEATURE_KEY_MGMT_OFFLOAD); |
| 3433 | } |
| 3434 | |
| 3435 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3436 | QCA_WLAN_VENDOR_FEATURE_SUPPORT_HW_MODE_ANY); |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 3437 | if (policy_mgr_is_scan_simultaneous_capable(hdd_ctx_ptr->hdd_psoc)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3438 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3439 | QCA_WLAN_VENDOR_FEATURE_OFFCHANNEL_SIMULTANEOUS); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 3440 | |
| 3441 | if (wma_is_p2p_lo_capable()) |
| 3442 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3443 | QCA_WLAN_VENDOR_FEATURE_P2P_LISTEN_OFFLOAD); |
| 3444 | |
yeshwanth sriram guntuka | 1413dfb | 2017-06-23 14:09:48 +0530 | [diff] [blame] | 3445 | if (hdd_ctx_ptr->config->oce_sta_enabled) |
| 3446 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3447 | QCA_WLAN_VENDOR_FEATURE_OCE_STA); |
| 3448 | |
| 3449 | if (hdd_ctx_ptr->config->oce_sap_enabled) |
| 3450 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 3451 | QCA_WLAN_VENDOR_FEATURE_OCE_STA_CFON); |
| 3452 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3453 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(feature_flags) + |
| 3454 | NLMSG_HDRLEN); |
| 3455 | |
| 3456 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3457 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3458 | return -ENOMEM; |
| 3459 | } |
| 3460 | |
| 3461 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_FLAGS, |
| 3462 | sizeof(feature_flags), feature_flags)) |
| 3463 | goto nla_put_failure; |
| 3464 | |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 3465 | ret = policy_mgr_get_dbs_hw_modes(hdd_ctx_ptr->hdd_psoc, |
| 3466 | &one_by_one_dbs, &two_by_two_dbs); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3467 | if (QDF_STATUS_SUCCESS == ret) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3468 | if (one_by_one_dbs) |
| 3469 | dbs_capability = DRV_DBS_CAPABILITY_1X1; |
| 3470 | |
| 3471 | if (two_by_two_dbs) |
| 3472 | dbs_capability = DRV_DBS_CAPABILITY_2X2; |
| 3473 | |
| 3474 | if (!one_by_one_dbs && !two_by_two_dbs) |
| 3475 | dbs_capability = DRV_DBS_CAPABILITY_DISABLED; |
| 3476 | } else { |
| 3477 | hdd_err("wma_get_dbs_hw_mode failed"); |
| 3478 | dbs_capability = DRV_DBS_CAPABILITY_DISABLED; |
| 3479 | } |
| 3480 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 3481 | hdd_debug("dbs_capability is %d", dbs_capability); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3482 | |
| 3483 | if (nla_put_u32(skb, |
Ganesh Kondabattini | d921ed9 | 2017-06-20 16:40:48 +0530 | [diff] [blame] | 3484 | QCA_WLAN_VENDOR_ATTR_CONCURRENCY_CAPA, |
| 3485 | dbs_capability)) |
| 3486 | goto nla_put_failure; |
| 3487 | |
| 3488 | |
| 3489 | if (nla_put_u32(skb, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3490 | QCA_WLAN_VENDOR_ATTR_MAX_CONCURRENT_CHANNELS_2_4_BAND, |
| 3491 | MAX_CONCURRENT_CHAN_ON_24G)) |
| 3492 | goto nla_put_failure; |
| 3493 | |
| 3494 | if (nla_put_u32(skb, |
| 3495 | QCA_WLAN_VENDOR_ATTR_MAX_CONCURRENT_CHANNELS_5_0_BAND, |
| 3496 | MAX_CONCURRENT_CHAN_ON_5G)) |
| 3497 | goto nla_put_failure; |
| 3498 | |
| 3499 | return cfg80211_vendor_cmd_reply(skb); |
| 3500 | |
| 3501 | nla_put_failure: |
| 3502 | kfree_skb(skb); |
| 3503 | return -EINVAL; |
| 3504 | } |
| 3505 | |
| 3506 | /** |
| 3507 | * wlan_hdd_cfg80211_get_features() - Get the Driver Supported features |
| 3508 | * @wiphy: pointer to wireless wiphy structure. |
| 3509 | * @wdev: pointer to wireless_dev structure. |
| 3510 | * @data: Pointer to the data to be passed via vendor interface |
| 3511 | * @data_len:Length of the data to be passed |
| 3512 | * |
| 3513 | * This is called when wlan driver needs to send supported feature set to |
| 3514 | * supplicant upon a request/query from the supplicant. |
| 3515 | * |
| 3516 | * Return: Return the Success or Failure code. |
| 3517 | */ |
| 3518 | static int |
| 3519 | wlan_hdd_cfg80211_get_features(struct wiphy *wiphy, |
| 3520 | struct wireless_dev *wdev, |
| 3521 | const void *data, int data_len) |
| 3522 | { |
| 3523 | int ret; |
| 3524 | |
| 3525 | cds_ssr_protect(__func__); |
| 3526 | ret = __wlan_hdd_cfg80211_get_features(wiphy, wdev, |
| 3527 | data, data_len); |
| 3528 | cds_ssr_unprotect(__func__); |
| 3529 | |
| 3530 | return ret; |
| 3531 | } |
| 3532 | |
Hanumanth Reddy Pothula | a1259ef | 2017-02-21 17:14:43 +0530 | [diff] [blame] | 3533 | #define PARAM_NUM_NW \ |
| 3534 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID_NUM_NETWORKS |
| 3535 | #define PARAM_SET_BSSID \ |
| 3536 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_BSSID |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3537 | #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] | 3538 | #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] | 3539 | #define MAX_ROAMING_PARAM \ |
| 3540 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3541 | #define PARAM_NUM_BSSID \ |
| 3542 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_NUM_BSSID |
| 3543 | #define PARAM_BSSID_PREFS \ |
| 3544 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS |
| 3545 | #define PARAM_ROAM_BSSID \ |
| 3546 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_BSSID |
| 3547 | #define PARAM_RSSI_MODIFIER \ |
| 3548 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_RSSI_MODIFIER |
| 3549 | #define PARAMS_NUM_BSSID \ |
| 3550 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_NUM_BSSID |
| 3551 | #define PARAM_BSSID_PARAMS \ |
| 3552 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS |
| 3553 | #define PARAM_A_BAND_BOOST_THLD \ |
| 3554 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_THRESHOLD |
| 3555 | #define PARAM_A_BAND_PELT_THLD \ |
| 3556 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_THRESHOLD |
| 3557 | #define PARAM_A_BAND_BOOST_FACTOR \ |
| 3558 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_FACTOR |
| 3559 | #define PARAM_A_BAND_PELT_FACTOR \ |
| 3560 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_FACTOR |
| 3561 | #define PARAM_A_BAND_MAX_BOOST \ |
| 3562 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_MAX_BOOST |
| 3563 | #define PARAM_ROAM_HISTERESYS \ |
| 3564 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_LAZY_ROAM_HISTERESYS |
| 3565 | #define PARAM_RSSI_TRIGGER \ |
| 3566 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_ALERT_ROAM_RSSI_TRIGGER |
| 3567 | #define PARAM_ROAM_ENABLE \ |
| 3568 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_ENABLE |
| 3569 | |
Ravi Kumar Bokka | 6cb9b37 | 2017-06-08 20:12:39 +0530 | [diff] [blame] | 3570 | |
| 3571 | static const struct nla_policy |
| 3572 | wlan_hdd_set_roam_param_policy[MAX_ROAMING_PARAM + 1] = { |
| 3573 | [QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD] = {.type = NLA_U32}, |
| 3574 | [QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID] = {.type = NLA_U32}, |
| 3575 | [PARAM_NUM_NW] = {.type = NLA_U32}, |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3576 | [PARAM_A_BAND_BOOST_FACTOR] = {.type = NLA_U32}, |
| 3577 | [PARAM_A_BAND_PELT_FACTOR] = {.type = NLA_U32}, |
| 3578 | [PARAM_A_BAND_MAX_BOOST] = {.type = NLA_U32}, |
| 3579 | [PARAM_ROAM_HISTERESYS] = {.type = NLA_S32}, |
| 3580 | [PARAM_A_BAND_BOOST_THLD] = {.type = NLA_S32}, |
Srinivas Girigowda | 4ffe7c8 | 2017-07-18 11:45:23 -0700 | [diff] [blame] | 3581 | [PARAM_A_BAND_PELT_THLD] = {.type = NLA_S32}, |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3582 | [PARAM_RSSI_TRIGGER] = {.type = NLA_U32}, |
| 3583 | [PARAM_ROAM_ENABLE] = { .type = NLA_S32}, |
| 3584 | [PARAM_NUM_BSSID] = {.type = NLA_U32}, |
| 3585 | [PARAM_RSSI_MODIFIER] = {.type = NLA_U32}, |
| 3586 | [PARAMS_NUM_BSSID] = {.type = NLA_U32}, |
| 3587 | [PARAM_ROAM_BSSID] = {.type = NLA_UNSPEC, .len = QDF_MAC_ADDR_SIZE}, |
| 3588 | [PARAM_SET_BSSID] = {.type = NLA_UNSPEC, .len = QDF_MAC_ADDR_SIZE}, |
Ravi Kumar Bokka | 6cb9b37 | 2017-06-08 20:12:39 +0530 | [diff] [blame] | 3589 | }; |
| 3590 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3591 | /** |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3592 | * hdd_set_white_list() - parse white list |
| 3593 | * @hddctx: HDD context |
| 3594 | * @roam_params: roam params |
| 3595 | * @tb: list of attributes |
| 3596 | * @session_id: session id |
| 3597 | * |
| 3598 | * Return: 0 on success; error number on failure |
| 3599 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 3600 | static int hdd_set_white_list(struct hdd_context *hddctx, |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3601 | struct roam_ext_params *roam_params, |
| 3602 | struct nlattr **tb, uint8_t session_id) |
| 3603 | { |
| 3604 | int rem, i; |
| 3605 | uint32_t buf_len = 0, count; |
| 3606 | struct nlattr *tb2[MAX_ROAMING_PARAM + 1]; |
| 3607 | struct nlattr *curr_attr = NULL; |
| 3608 | |
| 3609 | i = 0; |
| 3610 | if (tb[PARAM_NUM_NW]) { |
| 3611 | count = nla_get_u32(tb[PARAM_NUM_NW]); |
| 3612 | } else { |
| 3613 | hdd_err("Number of networks is not provided"); |
| 3614 | goto fail; |
| 3615 | } |
| 3616 | |
| 3617 | if (count && tb[PARAM_SSID_LIST]) { |
| 3618 | nla_for_each_nested(curr_attr, |
| 3619 | tb[PARAM_SSID_LIST], rem) { |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3620 | if (wlan_cfg80211_nla_parse(tb2, |
| 3621 | QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_MAX, |
| 3622 | nla_data(curr_attr), |
| 3623 | nla_len(curr_attr), |
| 3624 | wlan_hdd_set_roam_param_policy)) { |
| 3625 | hdd_err("nla_parse failed"); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3626 | goto fail; |
| 3627 | } |
| 3628 | /* Parse and Fetch allowed SSID list*/ |
| 3629 | if (!tb2[PARAM_LIST_SSID]) { |
| 3630 | hdd_err("attr allowed ssid failed"); |
| 3631 | goto fail; |
| 3632 | } |
| 3633 | buf_len = nla_len(tb2[PARAM_LIST_SSID]); |
| 3634 | /* |
| 3635 | * Upper Layers include a null termination |
| 3636 | * character. Check for the actual permissible |
| 3637 | * length of SSID and also ensure not to copy |
| 3638 | * the NULL termination character to the driver |
| 3639 | * buffer. |
| 3640 | */ |
| 3641 | if (buf_len && (i < MAX_SSID_ALLOWED_LIST) && |
| 3642 | ((buf_len - 1) <= SIR_MAC_MAX_SSID_LENGTH)) { |
| 3643 | nla_memcpy(roam_params->ssid_allowed_list[i].ssId, |
| 3644 | tb2[PARAM_LIST_SSID], buf_len - 1); |
| 3645 | roam_params->ssid_allowed_list[i].length = buf_len - 1; |
| 3646 | hdd_debug("SSID[%d]: %.*s,length = %d", |
| 3647 | i, |
| 3648 | roam_params->ssid_allowed_list[i].length, |
| 3649 | roam_params->ssid_allowed_list[i].ssId, |
| 3650 | roam_params->ssid_allowed_list[i].length); |
| 3651 | i++; |
| 3652 | } else { |
| 3653 | hdd_err("Invalid buffer length"); |
| 3654 | } |
| 3655 | } |
| 3656 | } |
| 3657 | |
| 3658 | if (i != count) { |
| 3659 | hdd_err("Invalid number of SSIDs i = %d, count = %d", i, count); |
| 3660 | goto fail; |
| 3661 | } |
| 3662 | |
| 3663 | roam_params->num_ssid_allowed_list = i; |
| 3664 | hdd_debug("Num of Allowed SSID %d", roam_params->num_ssid_allowed_list); |
| 3665 | sme_update_roam_params(hddctx->hHal, session_id, |
| 3666 | roam_params, REASON_ROAM_SET_SSID_ALLOWED); |
| 3667 | return 0; |
| 3668 | |
| 3669 | fail: |
| 3670 | return -EINVAL; |
| 3671 | } |
| 3672 | |
| 3673 | /** |
| 3674 | * hdd_set_bssid_prefs() - parse set bssid prefs |
| 3675 | * @hddctx: HDD context |
| 3676 | * @roam_params: roam params |
| 3677 | * @tb: list of attributes |
| 3678 | * @session_id: session id |
| 3679 | * |
| 3680 | * Return: 0 on success; error number on failure |
| 3681 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 3682 | static int hdd_set_bssid_prefs(struct hdd_context *hddctx, |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3683 | struct roam_ext_params *roam_params, |
| 3684 | struct nlattr **tb, uint8_t session_id) |
| 3685 | { |
| 3686 | int rem, i; |
| 3687 | uint32_t count; |
| 3688 | struct nlattr *tb2[MAX_ROAMING_PARAM + 1]; |
| 3689 | struct nlattr *curr_attr = NULL; |
| 3690 | |
| 3691 | /* Parse and fetch number of preferred BSSID */ |
| 3692 | if (!tb[PARAM_NUM_BSSID]) { |
| 3693 | hdd_err("attr num of preferred bssid failed"); |
| 3694 | goto fail; |
| 3695 | } |
| 3696 | count = nla_get_u32(tb[PARAM_NUM_BSSID]); |
| 3697 | if (count > MAX_BSSID_FAVORED) { |
| 3698 | hdd_err("Preferred BSSID count %u exceeds max %u", |
| 3699 | count, MAX_BSSID_FAVORED); |
| 3700 | goto fail; |
| 3701 | } |
| 3702 | hdd_debug("Num of Preferred BSSID (%d)", count); |
| 3703 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS]) { |
| 3704 | hdd_err("attr Preferred BSSID failed"); |
| 3705 | goto fail; |
| 3706 | } |
| 3707 | |
| 3708 | i = 0; |
| 3709 | nla_for_each_nested(curr_attr, |
| 3710 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS], |
| 3711 | rem) { |
| 3712 | if (i == count) { |
| 3713 | hdd_warn("Ignoring excess Preferred BSSID"); |
| 3714 | break; |
| 3715 | } |
| 3716 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3717 | if (wlan_cfg80211_nla_parse(tb2, |
| 3718 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX, |
| 3719 | nla_data(curr_attr), |
| 3720 | nla_len(curr_attr), |
| 3721 | wlan_hdd_set_roam_param_policy)) { |
| 3722 | hdd_err("nla_parse failed"); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3723 | goto fail; |
| 3724 | } |
| 3725 | /* Parse and fetch MAC address */ |
| 3726 | if (!tb2[PARAM_ROAM_BSSID]) { |
| 3727 | hdd_err("attr mac address failed"); |
| 3728 | goto fail; |
| 3729 | } |
| 3730 | nla_memcpy(roam_params->bssid_favored[i].bytes, |
| 3731 | tb2[PARAM_ROAM_BSSID], |
| 3732 | QDF_MAC_ADDR_SIZE); |
| 3733 | hdd_debug(MAC_ADDRESS_STR, |
| 3734 | MAC_ADDR_ARRAY(roam_params->bssid_favored[i].bytes)); |
| 3735 | /* Parse and fetch preference factor*/ |
| 3736 | if (!tb2[PARAM_RSSI_MODIFIER]) { |
| 3737 | hdd_err("BSSID Preference score failed"); |
| 3738 | goto fail; |
| 3739 | } |
| 3740 | roam_params->bssid_favored_factor[i] = nla_get_u32( |
| 3741 | tb2[PARAM_RSSI_MODIFIER]); |
| 3742 | hdd_debug("BSSID Preference score (%d)", |
| 3743 | roam_params->bssid_favored_factor[i]); |
| 3744 | i++; |
| 3745 | } |
| 3746 | if (i < count) |
| 3747 | hdd_warn("Num Preferred BSSID %u less than expected %u", |
| 3748 | i, count); |
| 3749 | |
| 3750 | roam_params->num_bssid_favored = i; |
| 3751 | sme_update_roam_params(hddctx->hHal, session_id, |
| 3752 | roam_params, REASON_ROAM_SET_FAVORED_BSSID); |
| 3753 | |
| 3754 | return 0; |
| 3755 | |
| 3756 | fail: |
| 3757 | return -EINVAL; |
| 3758 | } |
| 3759 | |
| 3760 | /** |
| 3761 | * hdd_set_blacklist_bssid() - parse set blacklist bssid |
| 3762 | * @hddctx: HDD context |
| 3763 | * @roam_params: roam params |
| 3764 | * @tb: list of attributes |
| 3765 | * @session_id: session id |
| 3766 | * |
| 3767 | * Return: 0 on success; error number on failure |
| 3768 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 3769 | static int hdd_set_blacklist_bssid(struct hdd_context *hddctx, |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3770 | struct roam_ext_params *roam_params, |
| 3771 | struct nlattr **tb, |
| 3772 | uint8_t session_id) |
| 3773 | { |
| 3774 | int rem, i; |
| 3775 | uint32_t count; |
| 3776 | struct nlattr *tb2[MAX_ROAMING_PARAM + 1]; |
| 3777 | struct nlattr *curr_attr = NULL; |
| 3778 | |
| 3779 | /* Parse and fetch number of blacklist BSSID */ |
| 3780 | if (!tb[PARAMS_NUM_BSSID]) { |
| 3781 | hdd_err("attr num of blacklist bssid failed"); |
| 3782 | goto fail; |
| 3783 | } |
| 3784 | count = nla_get_u32(tb[PARAMS_NUM_BSSID]); |
| 3785 | if (count > MAX_BSSID_AVOID_LIST) { |
| 3786 | hdd_err("Blacklist BSSID count %u exceeds max %u", |
| 3787 | count, MAX_BSSID_AVOID_LIST); |
| 3788 | goto fail; |
| 3789 | } |
| 3790 | hdd_debug("Num of blacklist BSSID (%d)", count); |
| 3791 | |
| 3792 | i = 0; |
| 3793 | if (count && tb[PARAM_BSSID_PARAMS]) { |
| 3794 | nla_for_each_nested(curr_attr, |
| 3795 | tb[PARAM_BSSID_PARAMS], |
| 3796 | rem) { |
| 3797 | if (i == count) { |
| 3798 | hdd_warn("Ignoring excess Blacklist BSSID"); |
| 3799 | break; |
| 3800 | } |
| 3801 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3802 | if (wlan_cfg80211_nla_parse(tb2, |
Dustin Brown | 3fb1504 | 2017-08-15 15:54:49 -0700 | [diff] [blame] | 3803 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX, |
| 3804 | nla_data(curr_attr), |
| 3805 | nla_len(curr_attr), |
| 3806 | wlan_hdd_set_roam_param_policy)) { |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3807 | hdd_err("nla_parse failed"); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3808 | goto fail; |
| 3809 | } |
| 3810 | /* Parse and fetch MAC address */ |
| 3811 | if (!tb2[PARAM_SET_BSSID]) { |
| 3812 | hdd_err("attr blacklist addr failed"); |
| 3813 | goto fail; |
| 3814 | } |
| 3815 | nla_memcpy(roam_params->bssid_avoid_list[i].bytes, |
| 3816 | tb2[PARAM_SET_BSSID], QDF_MAC_ADDR_SIZE); |
| 3817 | hdd_debug(MAC_ADDRESS_STR, |
| 3818 | MAC_ADDR_ARRAY(roam_params->bssid_avoid_list[i].bytes)); |
| 3819 | i++; |
| 3820 | } |
| 3821 | } |
| 3822 | |
| 3823 | if (i < count) |
| 3824 | hdd_warn("Num Blacklist BSSID %u less than expected %u", |
| 3825 | i, count); |
| 3826 | |
| 3827 | roam_params->num_bssid_avoid_list = i; |
| 3828 | sme_update_roam_params(hddctx->hHal, session_id, |
| 3829 | roam_params, REASON_ROAM_SET_BLACKLIST_BSSID); |
| 3830 | |
| 3831 | return 0; |
| 3832 | fail: |
| 3833 | return -EINVAL; |
| 3834 | } |
| 3835 | |
| 3836 | /** |
| 3837 | * hdd_set_ext_roam_params() - parse ext roam params |
| 3838 | * @hddctx: HDD context |
| 3839 | * @roam_params: roam params |
| 3840 | * @tb: list of attributes |
| 3841 | * @session_id: session id |
| 3842 | * |
| 3843 | * Return: 0 on success; error number on failure |
| 3844 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 3845 | static int hdd_set_ext_roam_params(struct hdd_context *hddctx, |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3846 | const void *data, int data_len, |
| 3847 | uint8_t session_id, |
| 3848 | struct roam_ext_params *roam_params) |
| 3849 | { |
| 3850 | uint32_t cmd_type, req_id; |
| 3851 | struct nlattr *tb[MAX_ROAMING_PARAM + 1]; |
| 3852 | int ret; |
| 3853 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 3854 | if (wlan_cfg80211_nla_parse(tb, MAX_ROAMING_PARAM, data, data_len, |
| 3855 | wlan_hdd_set_roam_param_policy)) { |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3856 | hdd_err("Invalid ATTR"); |
| 3857 | return -EINVAL; |
| 3858 | } |
| 3859 | /* Parse and fetch Command Type */ |
| 3860 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD]) { |
| 3861 | hdd_err("roam cmd type failed"); |
| 3862 | goto fail; |
| 3863 | } |
| 3864 | |
| 3865 | cmd_type = nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD]); |
| 3866 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID]) { |
| 3867 | hdd_err("attr request id failed"); |
| 3868 | goto fail; |
| 3869 | } |
| 3870 | req_id = nla_get_u32( |
| 3871 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID]); |
| 3872 | hdd_debug("Req Id: %u Cmd Type: %u", req_id, cmd_type); |
| 3873 | switch (cmd_type) { |
| 3874 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SSID_WHITE_LIST: |
| 3875 | ret = hdd_set_white_list(hddctx, roam_params, tb, session_id); |
| 3876 | if (ret) |
| 3877 | goto fail; |
| 3878 | break; |
| 3879 | |
| 3880 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_EXTSCAN_ROAM_PARAMS: |
| 3881 | /* Parse and fetch 5G Boost Threshold */ |
| 3882 | if (!tb[PARAM_A_BAND_BOOST_THLD]) { |
| 3883 | hdd_err("5G boost threshold failed"); |
| 3884 | goto fail; |
| 3885 | } |
| 3886 | roam_params->raise_rssi_thresh_5g = nla_get_s32( |
| 3887 | tb[PARAM_A_BAND_BOOST_THLD]); |
| 3888 | hdd_debug("5G Boost Threshold (%d)", |
| 3889 | roam_params->raise_rssi_thresh_5g); |
| 3890 | /* Parse and fetch 5G Penalty Threshold */ |
Srinivas Girigowda | 4ffe7c8 | 2017-07-18 11:45:23 -0700 | [diff] [blame] | 3891 | if (!tb[PARAM_A_BAND_PELT_THLD]) { |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3892 | hdd_err("5G penalty threshold failed"); |
| 3893 | goto fail; |
| 3894 | } |
| 3895 | roam_params->drop_rssi_thresh_5g = nla_get_s32( |
Srinivas Girigowda | 4ffe7c8 | 2017-07-18 11:45:23 -0700 | [diff] [blame] | 3896 | tb[PARAM_A_BAND_PELT_THLD]); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3897 | hdd_debug("5G Penalty Threshold (%d)", |
| 3898 | roam_params->drop_rssi_thresh_5g); |
| 3899 | /* Parse and fetch 5G Boost Factor */ |
| 3900 | if (!tb[PARAM_A_BAND_BOOST_FACTOR]) { |
| 3901 | hdd_err("5G boost Factor failed"); |
| 3902 | goto fail; |
| 3903 | } |
| 3904 | roam_params->raise_factor_5g = nla_get_u32( |
| 3905 | tb[PARAM_A_BAND_BOOST_FACTOR]); |
| 3906 | hdd_debug("5G Boost Factor (%d)", |
| 3907 | roam_params->raise_factor_5g); |
| 3908 | /* Parse and fetch 5G Penalty factor */ |
| 3909 | if (!tb[PARAM_A_BAND_PELT_FACTOR]) { |
| 3910 | hdd_err("5G Penalty Factor failed"); |
| 3911 | goto fail; |
| 3912 | } |
| 3913 | roam_params->drop_factor_5g = nla_get_u32( |
| 3914 | tb[PARAM_A_BAND_PELT_FACTOR]); |
| 3915 | hdd_debug("5G Penalty factor (%d)", |
| 3916 | roam_params->drop_factor_5g); |
| 3917 | /* Parse and fetch 5G Max Boost */ |
| 3918 | if (!tb[PARAM_A_BAND_MAX_BOOST]) { |
| 3919 | hdd_err("5G Max Boost failed"); |
| 3920 | goto fail; |
| 3921 | } |
| 3922 | roam_params->max_raise_rssi_5g = nla_get_u32( |
| 3923 | tb[PARAM_A_BAND_MAX_BOOST]); |
| 3924 | hdd_debug("5G Max Boost (%d)", |
| 3925 | roam_params->max_raise_rssi_5g); |
| 3926 | /* Parse and fetch Rssi Diff */ |
| 3927 | if (!tb[PARAM_ROAM_HISTERESYS]) { |
| 3928 | hdd_err("Rssi Diff failed"); |
| 3929 | goto fail; |
| 3930 | } |
| 3931 | roam_params->rssi_diff = nla_get_s32( |
| 3932 | tb[PARAM_ROAM_HISTERESYS]); |
| 3933 | hdd_debug("RSSI Diff (%d)", |
| 3934 | roam_params->rssi_diff); |
| 3935 | /* Parse and fetch Alert Rssi Threshold */ |
| 3936 | if (!tb[PARAM_RSSI_TRIGGER]) { |
| 3937 | hdd_err("Alert Rssi Threshold failed"); |
| 3938 | goto fail; |
| 3939 | } |
| 3940 | roam_params->alert_rssi_threshold = nla_get_u32( |
| 3941 | tb[PARAM_RSSI_TRIGGER]); |
| 3942 | hdd_debug("Alert RSSI Threshold (%d)", |
| 3943 | roam_params->alert_rssi_threshold); |
| 3944 | sme_update_roam_params(hddctx->hHal, session_id, |
| 3945 | roam_params, |
| 3946 | REASON_ROAM_EXT_SCAN_PARAMS_CHANGED); |
| 3947 | break; |
| 3948 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_LAZY_ROAM: |
| 3949 | /* Parse and fetch Activate Good Rssi Roam */ |
| 3950 | if (!tb[PARAM_ROAM_ENABLE]) { |
| 3951 | hdd_err("Activate Good Rssi Roam failed"); |
| 3952 | goto fail; |
| 3953 | } |
| 3954 | roam_params->good_rssi_roam = nla_get_s32( |
| 3955 | tb[PARAM_ROAM_ENABLE]); |
| 3956 | hdd_debug("Activate Good Rssi Roam (%d)", |
| 3957 | roam_params->good_rssi_roam); |
| 3958 | sme_update_roam_params(hddctx->hHal, session_id, |
| 3959 | roam_params, REASON_ROAM_GOOD_RSSI_CHANGED); |
| 3960 | break; |
| 3961 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_BSSID_PREFS: |
| 3962 | ret = hdd_set_bssid_prefs(hddctx, roam_params, tb, session_id); |
| 3963 | if (ret) |
| 3964 | goto fail; |
| 3965 | break; |
| 3966 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_BLACKLIST_BSSID: |
| 3967 | ret = hdd_set_blacklist_bssid(hddctx, roam_params, tb, session_id); |
| 3968 | if (ret) |
| 3969 | goto fail; |
| 3970 | break; |
| 3971 | } |
| 3972 | |
| 3973 | return 0; |
| 3974 | |
| 3975 | fail: |
| 3976 | return -EINVAL; |
| 3977 | } |
| 3978 | |
| 3979 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3980 | * __wlan_hdd_cfg80211_set_ext_roam_params() - Settings for roaming parameters |
| 3981 | * @wiphy: The wiphy structure |
| 3982 | * @wdev: The wireless device |
| 3983 | * @data: Data passed by framework |
| 3984 | * @data_len: Parameters to be configured passed as data |
| 3985 | * |
| 3986 | * The roaming related parameters are configured by the framework |
| 3987 | * using this interface. |
| 3988 | * |
| 3989 | * Return: Return either success or failure code. |
| 3990 | */ |
| 3991 | static int |
| 3992 | __wlan_hdd_cfg80211_set_ext_roam_params(struct wiphy *wiphy, |
| 3993 | struct wireless_dev *wdev, const void *data, int data_len) |
| 3994 | { |
| 3995 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 3996 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 3997 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 3998 | struct roam_ext_params *roam_params = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3999 | int ret; |
| 4000 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4001 | hdd_enter_dev(dev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 4002 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4003 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4004 | hdd_err("Command not allowed in FTM mode"); |
| 4005 | return -EPERM; |
| 4006 | } |
| 4007 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 4008 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4009 | if (ret) |
| 4010 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4011 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 4012 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 4013 | hdd_err("Driver Modules are closed"); |
| 4014 | return -EINVAL; |
| 4015 | } |
| 4016 | |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4017 | roam_params = qdf_mem_malloc(sizeof(*roam_params)); |
| 4018 | if (!roam_params) { |
| 4019 | hdd_err("failed to allocate memory"); |
| 4020 | return -ENOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4021 | } |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4022 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 4023 | ret = hdd_set_ext_roam_params(hdd_ctx, data, data_len, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4024 | adapter->session_id, roam_params); |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4025 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4026 | goto fail; |
Hanumanth Reddy Pothula | a1259ef | 2017-02-21 17:14:43 +0530 | [diff] [blame] | 4027 | |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4028 | if (roam_params) |
| 4029 | qdf_mem_free(roam_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4030 | return 0; |
| 4031 | fail: |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4032 | if (roam_params) |
| 4033 | qdf_mem_free(roam_params); |
| 4034 | |
| 4035 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4036 | } |
Hanumanth Reddy Pothula | a1259ef | 2017-02-21 17:14:43 +0530 | [diff] [blame] | 4037 | #undef PARAM_NUM_NW |
| 4038 | #undef PARAM_SET_BSSID |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4039 | #undef PARAM_SSID_LIST |
Hanumanth Reddy Pothula | a1259ef | 2017-02-21 17:14:43 +0530 | [diff] [blame] | 4040 | #undef PARAM_LIST_SSID |
Srinivas Girigowda | 72f3039 | 2017-07-13 18:55:09 -0700 | [diff] [blame] | 4041 | #undef MAX_ROAMING_PARAM |
| 4042 | #undef PARAM_NUM_BSSID |
| 4043 | #undef PARAM_BSSID_PREFS |
| 4044 | #undef PARAM_ROAM_BSSID |
| 4045 | #undef PARAM_RSSI_MODIFIER |
| 4046 | #undef PARAMS_NUM_BSSID |
| 4047 | #undef PARAM_BSSID_PARAMS |
| 4048 | #undef PARAM_A_BAND_BOOST_THLD |
| 4049 | #undef PARAM_A_BAND_PELT_THLD |
| 4050 | #undef PARAM_A_BAND_BOOST_FACTOR |
| 4051 | #undef PARAM_A_BAND_PELT_FACTOR |
| 4052 | #undef PARAM_A_BAND_MAX_BOOST |
| 4053 | #undef PARAM_ROAM_HISTERESYS |
| 4054 | #undef PARAM_RSSI_TRIGGER |
| 4055 | #undef PARAM_ROAM_ENABLE |
Hanumanth Reddy Pothula | a1259ef | 2017-02-21 17:14:43 +0530 | [diff] [blame] | 4056 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4057 | |
| 4058 | /** |
| 4059 | * wlan_hdd_cfg80211_set_ext_roam_params() - set ext scan roam params |
| 4060 | * @wiphy: pointer to wireless wiphy structure. |
| 4061 | * @wdev: pointer to wireless_dev structure. |
| 4062 | * @data: Pointer to the data to be passed via vendor interface |
| 4063 | * @data_len:Length of the data to be passed |
| 4064 | * |
| 4065 | * Return: Return the Success or Failure code. |
| 4066 | */ |
| 4067 | static int |
| 4068 | wlan_hdd_cfg80211_set_ext_roam_params(struct wiphy *wiphy, |
| 4069 | struct wireless_dev *wdev, |
| 4070 | const void *data, |
| 4071 | int data_len) |
| 4072 | { |
| 4073 | int ret; |
| 4074 | |
| 4075 | cds_ssr_protect(__func__); |
| 4076 | ret = __wlan_hdd_cfg80211_set_ext_roam_params(wiphy, wdev, |
| 4077 | data, data_len); |
| 4078 | cds_ssr_unprotect(__func__); |
| 4079 | |
| 4080 | return ret; |
| 4081 | } |
| 4082 | |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4083 | #define PWR_SAVE_FAIL_CMD_INDEX \ |
| 4084 | QCA_NL80211_VENDOR_SUBCMD_PWR_SAVE_FAIL_DETECTED_INDEX |
| 4085 | /** |
| 4086 | * hdd_chip_pwr_save_fail_detected_cb() - chip power save failure detected |
| 4087 | * callback |
| 4088 | * @hddctx: HDD context |
| 4089 | * @data: chip power save failure detected data |
| 4090 | * |
| 4091 | * This function reads the chip power save failure detected data and fill in |
| 4092 | * the skb with NL attributes and send up the NL event. |
| 4093 | * This callback execute in atomic context and must not invoke any |
| 4094 | * blocking calls. |
| 4095 | * |
| 4096 | * Return: none |
| 4097 | */ |
| 4098 | void hdd_chip_pwr_save_fail_detected_cb(void *hddctx, |
| 4099 | struct chip_pwr_save_fail_detected_params |
| 4100 | *data) |
| 4101 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4102 | struct hdd_context *hdd_ctx = hddctx; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4103 | struct sk_buff *skb; |
| 4104 | int flags = cds_get_gfp_flags(); |
| 4105 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4106 | hdd_enter(); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4107 | |
| 4108 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 4109 | return; |
| 4110 | |
| 4111 | if (!data) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4112 | hdd_debug("data is null"); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4113 | return; |
| 4114 | } |
| 4115 | |
| 4116 | skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 4117 | NULL, NLMSG_HDRLEN + |
| 4118 | sizeof(data->failure_reason_code) + |
| 4119 | NLMSG_HDRLEN, PWR_SAVE_FAIL_CMD_INDEX, |
| 4120 | flags); |
| 4121 | |
| 4122 | if (!skb) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 4123 | hdd_info("cfg80211_vendor_event_alloc failed"); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4124 | return; |
| 4125 | } |
| 4126 | |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 4127 | hdd_debug("failure reason code: %u", data->failure_reason_code); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4128 | |
| 4129 | if (nla_put_u32(skb, |
| 4130 | QCA_ATTR_CHIP_POWER_SAVE_FAILURE_REASON, |
| 4131 | data->failure_reason_code)) |
| 4132 | goto fail; |
| 4133 | |
| 4134 | cfg80211_vendor_event(skb, flags); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4135 | hdd_exit(); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 4136 | return; |
| 4137 | |
| 4138 | fail: |
| 4139 | kfree_skb(skb); |
| 4140 | } |
| 4141 | #undef PWR_SAVE_FAIL_CMD_INDEX |
| 4142 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4143 | static const struct nla_policy |
| 4144 | wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX |
| 4145 | +1] = { |
| 4146 | [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 }, |
| 4147 | }; |
| 4148 | |
| 4149 | /** |
| 4150 | * wlan_hdd_check_dfs_channel_for_adapter() - check dfs channel in adapter |
| 4151 | * @hdd_ctx: HDD context |
| 4152 | * @device_mode: device mode |
| 4153 | * Return: bool |
| 4154 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4155 | 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] | 4156 | enum QDF_OPMODE device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4157 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 4158 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 4159 | struct hdd_ap_ctx *ap_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 4160 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4161 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4162 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4163 | if ((device_mode == adapter->device_mode) && |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 4164 | (device_mode == QDF_SAP_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4165 | ap_ctx = |
| 4166 | WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 4167 | |
| 4168 | /* |
| 4169 | * if there is SAP already running on DFS channel, |
| 4170 | * do not disable scan on dfs channels. Note that |
| 4171 | * with SAP on DFS, there cannot be conurrency on |
| 4172 | * single radio. But then we can have multiple |
| 4173 | * radios !! |
| 4174 | */ |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 4175 | if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state( |
| 4176 | hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 4177 | ap_ctx->operating_channel)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 4178 | hdd_err("SAP running on DFS channel"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4179 | return true; |
| 4180 | } |
| 4181 | } |
| 4182 | |
| 4183 | if ((device_mode == adapter->device_mode) && |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 4184 | (device_mode == QDF_STA_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4185 | sta_ctx = |
| 4186 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 4187 | |
| 4188 | /* |
| 4189 | * if STA is already connected on DFS channel, |
| 4190 | * do not disable scan on dfs channels |
| 4191 | */ |
| 4192 | if (hdd_conn_is_connected(sta_ctx) && |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 4193 | (CHANNEL_STATE_DFS == |
| 4194 | wlan_reg_get_channel_state(hdd_ctx->hdd_pdev, |
| 4195 | sta_ctx->conn_info.operationChannel))) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 4196 | hdd_err("client connected on DFS channel"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4197 | return true; |
| 4198 | } |
| 4199 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4200 | } |
| 4201 | |
| 4202 | return false; |
| 4203 | } |
| 4204 | |
| 4205 | /** |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4206 | * wlan_hdd_enable_dfs_chan_scan() - disable/enable DFS channels |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4207 | * @hdd_ctx: HDD context within host driver |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4208 | * @enable_dfs_channels: If true, DFS channels can be used for scanning |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4209 | * |
| 4210 | * Loops through devices to see who is operating on DFS channels |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4211 | * and then disables/enables DFS channels. |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4212 | * Fails the disable request if any device is active on a DFS channel. |
| 4213 | * |
| 4214 | * Return: 0 or other error codes. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4215 | */ |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4216 | |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4217 | 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] | 4218 | bool enable_dfs_channels) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4219 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4220 | QDF_STATUS status; |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4221 | bool err; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4222 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4223 | if (enable_dfs_channels == hdd_ctx->config->enableDFSChnlScan) { |
| 4224 | hdd_info("DFS channels are already %s", |
| 4225 | enable_dfs_channels ? "enabled" : "disabled"); |
| 4226 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4227 | } |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4228 | |
| 4229 | if (!enable_dfs_channels) { |
| 4230 | err = wlan_hdd_check_dfs_channel_for_adapter(hdd_ctx, |
| 4231 | QDF_STA_MODE); |
| 4232 | if (err) |
| 4233 | return -EOPNOTSUPP; |
| 4234 | |
| 4235 | err = wlan_hdd_check_dfs_channel_for_adapter(hdd_ctx, |
| 4236 | QDF_SAP_MODE); |
| 4237 | if (err) |
| 4238 | return -EOPNOTSUPP; |
| 4239 | } |
| 4240 | |
| 4241 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_channels; |
| 4242 | |
Min Liu | 5eaf724 | 2018-03-13 17:32:15 +0800 | [diff] [blame] | 4243 | status = sme_enable_dfs_chan_scan(hdd_ctx->hHal, enable_dfs_channels); |
| 4244 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4245 | hdd_err("Failed to set DFS channel scan flag to %d", |
| 4246 | enable_dfs_channels); |
| 4247 | return qdf_status_to_os_return(status); |
| 4248 | } |
| 4249 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4250 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 4251 | |
| 4252 | /* pass dfs channel status to regulatory component */ |
| 4253 | status = ucfg_reg_enable_dfs_channels(hdd_ctx->hdd_pdev, |
| 4254 | enable_dfs_channels); |
| 4255 | |
| 4256 | if (QDF_IS_STATUS_ERROR(status)) |
| 4257 | hdd_err("Failed to %s DFS channels", |
| 4258 | enable_dfs_channels ? "enable" : "disable"); |
| 4259 | |
| 4260 | return qdf_status_to_os_return(status); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4261 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4262 | |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4263 | /** |
| 4264 | * __wlan_hdd_cfg80211_disable_dfs_chan_scan() - DFS channel configuration |
| 4265 | * @wiphy: corestack handler |
| 4266 | * @wdev: wireless device |
| 4267 | * @data: data |
| 4268 | * @data_len: data length |
| 4269 | * Return: success(0) or reason code for failure |
| 4270 | */ |
| 4271 | static int __wlan_hdd_cfg80211_disable_dfs_chan_scan(struct wiphy *wiphy, |
| 4272 | struct wireless_dev *wdev, |
| 4273 | const void *data, |
| 4274 | int data_len) |
| 4275 | { |
| 4276 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4277 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4278 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1]; |
| 4279 | int ret_val; |
| 4280 | uint32_t no_dfs_flag = 0; |
| 4281 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4282 | hdd_enter_dev(dev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 4283 | |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4284 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4285 | if (ret_val) |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4286 | return ret_val; |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4287 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 4288 | if (wlan_cfg80211_nla_parse(tb, |
| 4289 | QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX, |
| 4290 | data, data_len, |
| 4291 | wlan_hdd_set_no_dfs_flag_config_policy)) { |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4292 | hdd_err("invalid attr"); |
| 4293 | return -EINVAL; |
| 4294 | } |
| 4295 | |
| 4296 | if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) { |
| 4297 | hdd_err("attr dfs flag failed"); |
| 4298 | return -EINVAL; |
| 4299 | } |
| 4300 | |
| 4301 | no_dfs_flag = nla_get_u32( |
| 4302 | tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]); |
| 4303 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 4304 | hdd_debug("DFS flag: %d", no_dfs_flag); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4305 | |
| 4306 | if (no_dfs_flag > 1) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 4307 | hdd_err("invalid value of dfs flag"); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 4308 | return -EINVAL; |
| 4309 | } |
| 4310 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 4311 | ret_val = wlan_hdd_enable_dfs_chan_scan(hdd_ctx, !no_dfs_flag); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4312 | return ret_val; |
| 4313 | } |
| 4314 | |
| 4315 | /** |
| 4316 | * wlan_hdd_cfg80211_disable_dfs_chan_scan () - DFS scan vendor command |
| 4317 | * |
| 4318 | * @wiphy: wiphy device pointer |
| 4319 | * @wdev: wireless device pointer |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4320 | * @data: Vendor command data buffer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4321 | * @data_len: Buffer length |
| 4322 | * |
| 4323 | * Handles QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX. Validate it and |
| 4324 | * call wlan_hdd_disable_dfs_chan_scan to send it to firmware. |
| 4325 | * |
| 4326 | * Return: EOK or other error codes. |
| 4327 | */ |
| 4328 | |
| 4329 | static int wlan_hdd_cfg80211_disable_dfs_chan_scan(struct wiphy *wiphy, |
| 4330 | struct wireless_dev *wdev, |
| 4331 | const void *data, |
| 4332 | int data_len) |
| 4333 | { |
| 4334 | int ret; |
| 4335 | |
| 4336 | cds_ssr_protect(__func__); |
| 4337 | ret = __wlan_hdd_cfg80211_disable_dfs_chan_scan(wiphy, wdev, |
| 4338 | data, data_len); |
| 4339 | cds_ssr_unprotect(__func__); |
| 4340 | |
| 4341 | return ret; |
| 4342 | } |
| 4343 | |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4344 | static const struct nla_policy |
| 4345 | wlan_hdd_wisa_cmd_policy[QCA_WLAN_VENDOR_ATTR_WISA_MAX + 1] = { |
| 4346 | [QCA_WLAN_VENDOR_ATTR_WISA_MODE] = {.type = NLA_U32 }, |
| 4347 | }; |
| 4348 | |
| 4349 | /** |
| 4350 | * __wlan_hdd_cfg80211_handle_wisa_cmd() - Handle WISA vendor cmd |
| 4351 | * @wiphy: wiphy device pointer |
| 4352 | * @wdev: wireless device pointer |
| 4353 | * @data: Vendor command data buffer |
| 4354 | * @data_len: Buffer length |
| 4355 | * |
| 4356 | * Handles QCA_WLAN_VENDOR_SUBCMD_WISA. Validate cmd attributes and |
| 4357 | * setup WISA Mode features. |
| 4358 | * |
| 4359 | * Return: Success(0) or reason code for failure |
| 4360 | */ |
| 4361 | static int __wlan_hdd_cfg80211_handle_wisa_cmd(struct wiphy *wiphy, |
| 4362 | struct wireless_dev *wdev, const void *data, int data_len) |
| 4363 | { |
| 4364 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 4365 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4366 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4367 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WISA_MAX + 1]; |
| 4368 | struct sir_wisa_params wisa; |
| 4369 | int ret_val; |
| 4370 | QDF_STATUS status; |
| 4371 | bool wisa_mode; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4372 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 4373 | void *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4374 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4375 | hdd_enter_dev(dev); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4376 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 4377 | if (ret_val) |
| 4378 | goto err; |
| 4379 | |
| 4380 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 4381 | hdd_err("Command not allowed in FTM mode"); |
| 4382 | return -EPERM; |
| 4383 | } |
| 4384 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 4385 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WISA_MAX, data, |
| 4386 | data_len, wlan_hdd_wisa_cmd_policy)) { |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4387 | hdd_err("Invalid WISA cmd attributes"); |
| 4388 | ret_val = -EINVAL; |
| 4389 | goto err; |
| 4390 | } |
| 4391 | if (!tb[QCA_WLAN_VENDOR_ATTR_WISA_MODE]) { |
| 4392 | hdd_err("Invalid WISA mode"); |
| 4393 | ret_val = -EINVAL; |
| 4394 | goto err; |
| 4395 | } |
| 4396 | |
| 4397 | wisa_mode = !!nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_WISA_MODE]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 4398 | hdd_debug("WISA Mode: %d", wisa_mode); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4399 | wisa.mode = wisa_mode; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4400 | wisa.vdev_id = adapter->session_id; |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4401 | status = sme_set_wisa_params(hdd_ctx->hHal, &wisa); |
Manikandan Mohan | b6315dd | 2016-05-10 16:16:36 -0700 | [diff] [blame] | 4402 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 4403 | hdd_err("Unable to set WISA mode: %d to FW", wisa_mode); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4404 | ret_val = -EINVAL; |
Manikandan Mohan | b6315dd | 2016-05-10 16:16:36 -0700 | [diff] [blame] | 4405 | } |
| 4406 | if (QDF_IS_STATUS_SUCCESS(status) || wisa_mode == false) |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4407 | cdp_set_wisa_mode(soc, |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4408 | (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc, |
| 4409 | (struct cdp_pdev *)pdev, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4410 | adapter->session_id), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4411 | wisa_mode); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4412 | err: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4413 | hdd_exit(); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 4414 | return ret_val; |
| 4415 | } |
| 4416 | |
| 4417 | /** |
| 4418 | * wlan_hdd_cfg80211_handle_wisa_cmd() - Handle WISA vendor cmd |
| 4419 | * @wiphy: corestack handler |
| 4420 | * @wdev: wireless device |
| 4421 | * @data: data |
| 4422 | * @data_len: data length |
| 4423 | * |
| 4424 | * Handles QCA_WLAN_VENDOR_SUBCMD_WISA. Validate cmd attributes and |
| 4425 | * setup WISA mode features. |
| 4426 | * |
| 4427 | * Return: Success(0) or reason code for failure |
| 4428 | */ |
| 4429 | static int wlan_hdd_cfg80211_handle_wisa_cmd(struct wiphy *wiphy, |
| 4430 | struct wireless_dev *wdev, |
| 4431 | const void *data, |
| 4432 | int data_len) |
| 4433 | { |
| 4434 | int ret; |
| 4435 | |
| 4436 | cds_ssr_protect(__func__); |
| 4437 | ret = __wlan_hdd_cfg80211_handle_wisa_cmd(wiphy, wdev, data, data_len); |
| 4438 | cds_ssr_unprotect(__func__); |
| 4439 | |
| 4440 | return ret; |
| 4441 | } |
| 4442 | |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4443 | /* |
| 4444 | * define short names for the global vendor params |
| 4445 | * used by __wlan_hdd_cfg80211_get_station_cmd() |
| 4446 | */ |
| 4447 | #define STATION_INVALID \ |
| 4448 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INVALID |
| 4449 | #define STATION_INFO \ |
| 4450 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO |
| 4451 | #define STATION_ASSOC_FAIL_REASON \ |
| 4452 | QCA_WLAN_VENDOR_ATTR_GET_STATION_ASSOC_FAIL_REASON |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4453 | #define STATION_REMOTE \ |
| 4454 | QCA_WLAN_VENDOR_ATTR_GET_STATION_REMOTE |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4455 | #define STATION_MAX \ |
| 4456 | QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX |
| 4457 | |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4458 | /* define short names for get station info attributes */ |
| 4459 | #define LINK_INFO_STANDARD_NL80211_ATTR \ |
| 4460 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_LINK_STANDARD_NL80211_ATTR |
| 4461 | #define AP_INFO_STANDARD_NL80211_ATTR \ |
| 4462 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_AP_STANDARD_NL80211_ATTR |
| 4463 | #define INFO_ROAM_COUNT \ |
| 4464 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_ROAM_COUNT |
| 4465 | #define INFO_AKM \ |
| 4466 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_AKM |
| 4467 | #define WLAN802_11_MODE \ |
| 4468 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_802_11_MODE |
| 4469 | #define AP_INFO_HS20_INDICATION \ |
| 4470 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_AP_HS20_INDICATION |
| 4471 | #define HT_OPERATION \ |
| 4472 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_HT_OPERATION |
| 4473 | #define VHT_OPERATION \ |
| 4474 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_VHT_OPERATION |
| 4475 | #define INFO_ASSOC_FAIL_REASON \ |
| 4476 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_ASSOC_FAIL_REASON |
| 4477 | #define REMOTE_MAX_PHY_RATE \ |
| 4478 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_MAX_PHY_RATE |
| 4479 | #define REMOTE_TX_PACKETS \ |
| 4480 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_TX_PACKETS |
| 4481 | #define REMOTE_TX_BYTES \ |
| 4482 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_TX_BYTES |
| 4483 | #define REMOTE_RX_PACKETS \ |
| 4484 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_RX_PACKETS |
| 4485 | #define REMOTE_RX_BYTES \ |
| 4486 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_RX_BYTES |
| 4487 | #define REMOTE_LAST_TX_RATE \ |
| 4488 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_LAST_TX_RATE |
| 4489 | #define REMOTE_LAST_RX_RATE \ |
| 4490 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_LAST_RX_RATE |
| 4491 | #define REMOTE_WMM \ |
| 4492 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_WMM |
| 4493 | #define REMOTE_SUPPORTED_MODE \ |
| 4494 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_SUPPORTED_MODE |
| 4495 | #define REMOTE_AMPDU \ |
| 4496 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_AMPDU |
| 4497 | #define REMOTE_TX_STBC \ |
| 4498 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_TX_STBC |
| 4499 | #define REMOTE_RX_STBC \ |
| 4500 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_RX_STBC |
| 4501 | #define REMOTE_CH_WIDTH\ |
| 4502 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_CH_WIDTH |
| 4503 | #define REMOTE_SGI_ENABLE\ |
| 4504 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_REMOTE_SGI_ENABLE |
| 4505 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
| 4506 | #define REMOTE_PAD\ |
| 4507 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO_PAD |
| 4508 | #endif |
| 4509 | |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4510 | static const struct nla_policy |
| 4511 | hdd_get_station_policy[STATION_MAX + 1] = { |
| 4512 | [STATION_INFO] = {.type = NLA_FLAG}, |
| 4513 | [STATION_ASSOC_FAIL_REASON] = {.type = NLA_FLAG}, |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4514 | [STATION_REMOTE] = {.type = NLA_BINARY, .len = QDF_MAC_ADDR_SIZE}, |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4515 | }; |
| 4516 | |
| 4517 | /** |
| 4518 | * hdd_get_station_assoc_fail() - Handle get station assoc fail |
| 4519 | * @hdd_ctx: HDD context within host driver |
| 4520 | * @wdev: wireless device |
| 4521 | * |
| 4522 | * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION_ASSOC_FAIL. |
| 4523 | * Validate cmd attributes and send the station info to upper layers. |
| 4524 | * |
| 4525 | * Return: Success(0) or reason code for failure |
| 4526 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4527 | static int hdd_get_station_assoc_fail(struct hdd_context *hdd_ctx, |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 4528 | struct hdd_adapter *adapter) |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4529 | { |
| 4530 | struct sk_buff *skb = NULL; |
| 4531 | uint32_t nl_buf_len; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 4532 | struct hdd_station_ctx *hdd_sta_ctx; |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4533 | |
| 4534 | nl_buf_len = NLMSG_HDRLEN; |
| 4535 | nl_buf_len += sizeof(uint32_t); |
| 4536 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 4537 | |
| 4538 | if (!skb) { |
| 4539 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
| 4540 | return -ENOMEM; |
| 4541 | } |
| 4542 | |
| 4543 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 4544 | |
| 4545 | if (nla_put_u32(skb, INFO_ASSOC_FAIL_REASON, |
| 4546 | hdd_sta_ctx->conn_info.assoc_status_code)) { |
| 4547 | hdd_err("put fail"); |
| 4548 | goto fail; |
| 4549 | } |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 4550 | |
| 4551 | hdd_info("congestion:%d", hdd_sta_ctx->conn_info.cca); |
| 4552 | if (nla_put_u32(skb, NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY, |
| 4553 | hdd_sta_ctx->conn_info.cca)) { |
| 4554 | hdd_err("put fail"); |
| 4555 | goto fail; |
| 4556 | } |
| 4557 | |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4558 | return cfg80211_vendor_cmd_reply(skb); |
| 4559 | fail: |
| 4560 | if (skb) |
| 4561 | kfree_skb(skb); |
| 4562 | return -EINVAL; |
| 4563 | } |
| 4564 | |
| 4565 | /** |
| 4566 | * hdd_map_auth_type() - transform auth type specific to |
| 4567 | * vendor command |
| 4568 | * @auth_type: csr auth type |
| 4569 | * |
| 4570 | * Return: Success(0) or reason code for failure |
| 4571 | */ |
| 4572 | static int hdd_convert_auth_type(uint32_t auth_type) |
| 4573 | { |
| 4574 | uint32_t ret_val; |
| 4575 | |
| 4576 | switch (auth_type) { |
| 4577 | case eCSR_AUTH_TYPE_OPEN_SYSTEM: |
| 4578 | ret_val = QCA_WLAN_AUTH_TYPE_OPEN; |
| 4579 | break; |
| 4580 | case eCSR_AUTH_TYPE_SHARED_KEY: |
| 4581 | ret_val = QCA_WLAN_AUTH_TYPE_SHARED; |
| 4582 | break; |
| 4583 | case eCSR_AUTH_TYPE_WPA: |
| 4584 | ret_val = QCA_WLAN_AUTH_TYPE_WPA; |
| 4585 | break; |
| 4586 | case eCSR_AUTH_TYPE_WPA_PSK: |
| 4587 | ret_val = QCA_WLAN_AUTH_TYPE_WPA_PSK; |
| 4588 | break; |
| 4589 | case eCSR_AUTH_TYPE_AUTOSWITCH: |
| 4590 | ret_val = QCA_WLAN_AUTH_TYPE_AUTOSWITCH; |
| 4591 | break; |
| 4592 | case eCSR_AUTH_TYPE_WPA_NONE: |
| 4593 | ret_val = QCA_WLAN_AUTH_TYPE_WPA_NONE; |
| 4594 | break; |
| 4595 | case eCSR_AUTH_TYPE_RSN: |
| 4596 | ret_val = QCA_WLAN_AUTH_TYPE_RSN; |
| 4597 | break; |
| 4598 | case eCSR_AUTH_TYPE_RSN_PSK: |
| 4599 | ret_val = QCA_WLAN_AUTH_TYPE_RSN_PSK; |
| 4600 | break; |
| 4601 | case eCSR_AUTH_TYPE_FT_RSN: |
| 4602 | ret_val = QCA_WLAN_AUTH_TYPE_FT; |
| 4603 | break; |
| 4604 | case eCSR_AUTH_TYPE_FT_RSN_PSK: |
| 4605 | ret_val = QCA_WLAN_AUTH_TYPE_FT_PSK; |
| 4606 | break; |
| 4607 | case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE: |
| 4608 | ret_val = QCA_WLAN_AUTH_TYPE_WAI; |
| 4609 | break; |
| 4610 | case eCSR_AUTH_TYPE_WAPI_WAI_PSK: |
| 4611 | ret_val = QCA_WLAN_AUTH_TYPE_WAI_PSK; |
| 4612 | break; |
| 4613 | case eCSR_AUTH_TYPE_CCKM_WPA: |
| 4614 | ret_val = QCA_WLAN_AUTH_TYPE_CCKM_WPA; |
| 4615 | break; |
| 4616 | case eCSR_AUTH_TYPE_CCKM_RSN: |
| 4617 | ret_val = QCA_WLAN_AUTH_TYPE_CCKM_RSN; |
| 4618 | break; |
| 4619 | case eCSR_AUTH_TYPE_RSN_PSK_SHA256: |
| 4620 | ret_val = QCA_WLAN_AUTH_TYPE_SHA256_PSK; |
| 4621 | break; |
| 4622 | case eCSR_AUTH_TYPE_RSN_8021X_SHA256: |
| 4623 | ret_val = QCA_WLAN_AUTH_TYPE_SHA256; |
| 4624 | break; |
| 4625 | case eCSR_NUM_OF_SUPPORT_AUTH_TYPE: |
| 4626 | case eCSR_AUTH_TYPE_FAILED: |
| 4627 | case eCSR_AUTH_TYPE_NONE: |
| 4628 | default: |
| 4629 | ret_val = QCA_WLAN_AUTH_TYPE_INVALID; |
| 4630 | break; |
| 4631 | } |
| 4632 | return ret_val; |
| 4633 | } |
| 4634 | |
| 4635 | /** |
| 4636 | * hdd_map_dot_11_mode() - transform dot11mode type specific to |
| 4637 | * vendor command |
| 4638 | * @dot11mode: dot11mode |
| 4639 | * |
| 4640 | * Return: Success(0) or reason code for failure |
| 4641 | */ |
| 4642 | static int hdd_convert_dot11mode(uint32_t dot11mode) |
| 4643 | { |
| 4644 | uint32_t ret_val; |
| 4645 | |
| 4646 | switch (dot11mode) { |
| 4647 | case eCSR_CFG_DOT11_MODE_11A: |
| 4648 | ret_val = QCA_WLAN_802_11_MODE_11A; |
| 4649 | break; |
| 4650 | case eCSR_CFG_DOT11_MODE_11B: |
| 4651 | ret_val = QCA_WLAN_802_11_MODE_11B; |
| 4652 | break; |
| 4653 | case eCSR_CFG_DOT11_MODE_11G: |
| 4654 | ret_val = QCA_WLAN_802_11_MODE_11G; |
| 4655 | break; |
| 4656 | case eCSR_CFG_DOT11_MODE_11N: |
| 4657 | ret_val = QCA_WLAN_802_11_MODE_11N; |
| 4658 | break; |
| 4659 | case eCSR_CFG_DOT11_MODE_11AC: |
| 4660 | ret_val = QCA_WLAN_802_11_MODE_11AC; |
| 4661 | break; |
| 4662 | case eCSR_CFG_DOT11_MODE_AUTO: |
| 4663 | case eCSR_CFG_DOT11_MODE_ABG: |
| 4664 | default: |
| 4665 | ret_val = QCA_WLAN_802_11_MODE_INVALID; |
| 4666 | } |
| 4667 | return ret_val; |
| 4668 | } |
| 4669 | |
| 4670 | /** |
| 4671 | * hdd_add_tx_bitrate() - add tx bitrate attribute |
| 4672 | * @skb: pointer to sk buff |
| 4673 | * @hdd_sta_ctx: pointer to hdd station context |
| 4674 | * @idx: attribute index |
| 4675 | * |
| 4676 | * Return: Success(0) or reason code for failure |
| 4677 | */ |
| 4678 | static int32_t hdd_add_tx_bitrate(struct sk_buff *skb, |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 4679 | struct hdd_station_ctx *hdd_sta_ctx, |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4680 | int idx) |
| 4681 | { |
| 4682 | struct nlattr *nla_attr; |
| 4683 | uint32_t bitrate, bitrate_compat; |
| 4684 | |
| 4685 | nla_attr = nla_nest_start(skb, idx); |
| 4686 | if (!nla_attr) |
| 4687 | goto fail; |
| 4688 | /* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */ |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4689 | bitrate = cfg80211_calculate_bitrate(&hdd_sta_ctx-> |
| 4690 | cache_conn_info.txrate); |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4691 | |
| 4692 | /* report 16-bit bitrate only if we can */ |
| 4693 | bitrate_compat = bitrate < (1UL << 16) ? bitrate : 0; |
| 4694 | if (bitrate > 0 && |
| 4695 | nla_put_u32(skb, NL80211_RATE_INFO_BITRATE32, bitrate)) { |
| 4696 | hdd_err("put fail"); |
| 4697 | goto fail; |
| 4698 | } |
| 4699 | if (bitrate_compat > 0 && |
| 4700 | nla_put_u16(skb, NL80211_RATE_INFO_BITRATE, bitrate_compat)) { |
| 4701 | hdd_err("put fail"); |
| 4702 | goto fail; |
| 4703 | } |
| 4704 | if (nla_put_u8(skb, NL80211_RATE_INFO_VHT_NSS, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4705 | hdd_sta_ctx->cache_conn_info.txrate.nss)) { |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4706 | hdd_err("put fail"); |
| 4707 | goto fail; |
| 4708 | } |
| 4709 | nla_nest_end(skb, nla_attr); |
| 4710 | return 0; |
| 4711 | fail: |
| 4712 | return -EINVAL; |
| 4713 | } |
| 4714 | |
| 4715 | /** |
| 4716 | * hdd_add_sta_info() - add station info attribute |
| 4717 | * @skb: pointer to sk buff |
| 4718 | * @hdd_sta_ctx: pointer to hdd station context |
| 4719 | * @idx: attribute index |
| 4720 | * |
| 4721 | * Return: Success(0) or reason code for failure |
| 4722 | */ |
| 4723 | static int32_t hdd_add_sta_info(struct sk_buff *skb, |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 4724 | struct hdd_station_ctx *hdd_sta_ctx, int idx) |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4725 | { |
| 4726 | struct nlattr *nla_attr; |
| 4727 | |
| 4728 | nla_attr = nla_nest_start(skb, idx); |
| 4729 | if (!nla_attr) |
| 4730 | goto fail; |
| 4731 | if (nla_put_u8(skb, NL80211_STA_INFO_SIGNAL, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4732 | (hdd_sta_ctx->cache_conn_info.signal + 100))) { |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4733 | hdd_err("put fail"); |
| 4734 | goto fail; |
| 4735 | } |
| 4736 | if (hdd_add_tx_bitrate(skb, hdd_sta_ctx, NL80211_STA_INFO_TX_BITRATE)) |
| 4737 | goto fail; |
| 4738 | nla_nest_end(skb, nla_attr); |
| 4739 | return 0; |
| 4740 | fail: |
| 4741 | return -EINVAL; |
| 4742 | } |
| 4743 | |
| 4744 | /** |
| 4745 | * hdd_add_survey_info() - add survey info attribute |
| 4746 | * @skb: pointer to sk buff |
| 4747 | * @hdd_sta_ctx: pointer to hdd station context |
| 4748 | * @idx: attribute index |
| 4749 | * |
| 4750 | * Return: Success(0) or reason code for failure |
| 4751 | */ |
| 4752 | static int32_t hdd_add_survey_info(struct sk_buff *skb, |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 4753 | struct hdd_station_ctx *hdd_sta_ctx, |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4754 | int idx) |
| 4755 | { |
| 4756 | struct nlattr *nla_attr; |
| 4757 | |
| 4758 | nla_attr = nla_nest_start(skb, idx); |
| 4759 | if (!nla_attr) |
| 4760 | goto fail; |
| 4761 | if (nla_put_u32(skb, NL80211_SURVEY_INFO_FREQUENCY, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4762 | hdd_sta_ctx->cache_conn_info.freq) || |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4763 | nla_put_u8(skb, NL80211_SURVEY_INFO_NOISE, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4764 | (hdd_sta_ctx->cache_conn_info.noise + 100))) { |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4765 | hdd_err("put fail"); |
| 4766 | goto fail; |
| 4767 | } |
| 4768 | nla_nest_end(skb, nla_attr); |
| 4769 | return 0; |
| 4770 | fail: |
| 4771 | return -EINVAL; |
| 4772 | } |
| 4773 | |
| 4774 | /** |
| 4775 | * hdd_add_link_standard_info() - add link info attribute |
| 4776 | * @skb: pointer to sk buff |
| 4777 | * @hdd_sta_ctx: pointer to hdd station context |
| 4778 | * @idx: attribute index |
| 4779 | * |
| 4780 | * Return: Success(0) or reason code for failure |
| 4781 | */ |
| 4782 | static int32_t |
| 4783 | hdd_add_link_standard_info(struct sk_buff *skb, |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 4784 | struct hdd_station_ctx *hdd_sta_ctx, int idx) |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4785 | { |
| 4786 | struct nlattr *nla_attr; |
| 4787 | |
| 4788 | nla_attr = nla_nest_start(skb, idx); |
| 4789 | if (!nla_attr) |
| 4790 | goto fail; |
| 4791 | if (nla_put(skb, |
| 4792 | NL80211_ATTR_SSID, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4793 | hdd_sta_ctx->cache_conn_info.last_ssid.SSID.length, |
| 4794 | hdd_sta_ctx->cache_conn_info.last_ssid.SSID.ssId)) { |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4795 | hdd_err("put fail"); |
| 4796 | goto fail; |
| 4797 | } |
Ashish Kumar Dhanotiya | 6e27060 | 2018-01-18 15:14:58 +0530 | [diff] [blame] | 4798 | if (nla_put(skb, NL80211_ATTR_MAC, QDF_MAC_ADDR_SIZE, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4799 | hdd_sta_ctx->cache_conn_info.bssId.bytes)) { |
Ashish Kumar Dhanotiya | 6e27060 | 2018-01-18 15:14:58 +0530 | [diff] [blame] | 4800 | goto fail; |
| 4801 | } |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4802 | if (hdd_add_survey_info(skb, hdd_sta_ctx, NL80211_ATTR_SURVEY_INFO)) |
| 4803 | goto fail; |
| 4804 | if (hdd_add_sta_info(skb, hdd_sta_ctx, NL80211_ATTR_STA_INFO)) |
| 4805 | goto fail; |
| 4806 | nla_nest_end(skb, nla_attr); |
| 4807 | return 0; |
| 4808 | fail: |
| 4809 | return -EINVAL; |
| 4810 | } |
| 4811 | |
| 4812 | /** |
| 4813 | * hdd_add_ap_standard_info() - add ap info attribute |
| 4814 | * @skb: pointer to sk buff |
| 4815 | * @hdd_sta_ctx: pointer to hdd station context |
| 4816 | * @idx: attribute index |
| 4817 | * |
| 4818 | * Return: Success(0) or reason code for failure |
| 4819 | */ |
| 4820 | static int32_t |
| 4821 | hdd_add_ap_standard_info(struct sk_buff *skb, |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 4822 | struct hdd_station_ctx *hdd_sta_ctx, int idx) |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4823 | { |
| 4824 | struct nlattr *nla_attr; |
| 4825 | |
| 4826 | nla_attr = nla_nest_start(skb, idx); |
| 4827 | if (!nla_attr) |
| 4828 | goto fail; |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4829 | if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_present) |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4830 | if (nla_put(skb, NL80211_ATTR_VHT_CAPABILITY, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4831 | sizeof(hdd_sta_ctx->cache_conn_info.vht_caps), |
| 4832 | &hdd_sta_ctx->cache_conn_info.vht_caps)) { |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4833 | hdd_err("put fail"); |
| 4834 | goto fail; |
| 4835 | } |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4836 | if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_present) |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4837 | if (nla_put(skb, NL80211_ATTR_HT_CAPABILITY, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4838 | sizeof(hdd_sta_ctx->cache_conn_info.ht_caps), |
| 4839 | &hdd_sta_ctx->cache_conn_info.ht_caps)) { |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4840 | hdd_err("put fail"); |
| 4841 | goto fail; |
| 4842 | } |
| 4843 | nla_nest_end(skb, nla_attr); |
| 4844 | return 0; |
| 4845 | fail: |
| 4846 | return -EINVAL; |
| 4847 | } |
| 4848 | |
| 4849 | /** |
| 4850 | * hdd_get_station_info() - send BSS information to supplicant |
| 4851 | * @hdd_ctx: pointer to hdd context |
| 4852 | * @adapter: pointer to adapter |
| 4853 | * |
| 4854 | * Return: 0 if success else error status |
| 4855 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 4856 | static int hdd_get_station_info(struct hdd_context *hdd_ctx, |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 4857 | struct hdd_adapter *adapter) |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4858 | { |
| 4859 | struct sk_buff *skb = NULL; |
| 4860 | uint8_t *tmp_hs20 = NULL; |
| 4861 | uint32_t nl_buf_len; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 4862 | struct hdd_station_ctx *hdd_sta_ctx; |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4863 | |
| 4864 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 4865 | |
| 4866 | nl_buf_len = NLMSG_HDRLEN; |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4867 | nl_buf_len += sizeof(hdd_sta_ctx-> |
| 4868 | cache_conn_info.last_ssid.SSID.length) + |
Ashish Kumar Dhanotiya | 6e27060 | 2018-01-18 15:14:58 +0530 | [diff] [blame] | 4869 | QDF_MAC_ADDR_SIZE + |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4870 | sizeof(hdd_sta_ctx->cache_conn_info.freq) + |
| 4871 | sizeof(hdd_sta_ctx->cache_conn_info.noise) + |
| 4872 | sizeof(hdd_sta_ctx->cache_conn_info.signal) + |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4873 | (sizeof(uint32_t) * 2) + |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4874 | sizeof(hdd_sta_ctx->cache_conn_info.txrate.nss) + |
| 4875 | sizeof(hdd_sta_ctx->cache_conn_info.roam_count) + |
| 4876 | sizeof(hdd_sta_ctx->cache_conn_info.last_auth_type) + |
| 4877 | sizeof(hdd_sta_ctx->cache_conn_info.dot11Mode); |
| 4878 | if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_present) |
| 4879 | nl_buf_len += sizeof(hdd_sta_ctx->cache_conn_info.vht_caps); |
| 4880 | if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_present) |
| 4881 | nl_buf_len += sizeof(hdd_sta_ctx->cache_conn_info.ht_caps); |
| 4882 | if (hdd_sta_ctx->cache_conn_info.conn_flag.hs20_present) { |
| 4883 | tmp_hs20 = (uint8_t *)&(hdd_sta_ctx-> |
| 4884 | cache_conn_info.hs20vendor_ie); |
| 4885 | nl_buf_len += (sizeof(hdd_sta_ctx-> |
| 4886 | cache_conn_info.hs20vendor_ie) - 1); |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4887 | } |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4888 | if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_op_present) |
| 4889 | nl_buf_len += sizeof(hdd_sta_ctx-> |
| 4890 | cache_conn_info.ht_operation); |
| 4891 | if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_op_present) |
| 4892 | nl_buf_len += sizeof(hdd_sta_ctx-> |
| 4893 | cache_conn_info.vht_operation); |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4894 | |
| 4895 | |
| 4896 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 4897 | if (!skb) { |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 4898 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4899 | return -ENOMEM; |
| 4900 | } |
| 4901 | |
| 4902 | if (hdd_add_link_standard_info(skb, hdd_sta_ctx, |
| 4903 | LINK_INFO_STANDARD_NL80211_ATTR)) { |
| 4904 | hdd_err("put fail"); |
| 4905 | goto fail; |
| 4906 | } |
| 4907 | if (hdd_add_ap_standard_info(skb, hdd_sta_ctx, |
| 4908 | AP_INFO_STANDARD_NL80211_ATTR)) { |
| 4909 | hdd_err("put fail"); |
| 4910 | goto fail; |
| 4911 | } |
| 4912 | if (nla_put_u32(skb, INFO_ROAM_COUNT, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4913 | hdd_sta_ctx->cache_conn_info.roam_count) || |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4914 | nla_put_u32(skb, INFO_AKM, |
| 4915 | hdd_convert_auth_type( |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4916 | hdd_sta_ctx->cache_conn_info.last_auth_type)) || |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4917 | nla_put_u32(skb, WLAN802_11_MODE, |
| 4918 | hdd_convert_dot11mode( |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4919 | hdd_sta_ctx->cache_conn_info.dot11Mode))) { |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4920 | hdd_err("put fail"); |
| 4921 | goto fail; |
| 4922 | } |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4923 | if (hdd_sta_ctx->cache_conn_info.conn_flag.ht_op_present) |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4924 | if (nla_put(skb, HT_OPERATION, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4925 | (sizeof(hdd_sta_ctx->cache_conn_info.ht_operation)), |
| 4926 | &hdd_sta_ctx->cache_conn_info.ht_operation)) { |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4927 | hdd_err("put fail"); |
| 4928 | goto fail; |
| 4929 | } |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4930 | if (hdd_sta_ctx->cache_conn_info.conn_flag.vht_op_present) |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4931 | if (nla_put(skb, VHT_OPERATION, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4932 | (sizeof(hdd_sta_ctx-> |
| 4933 | cache_conn_info.vht_operation)), |
| 4934 | &hdd_sta_ctx->cache_conn_info.vht_operation)) { |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4935 | hdd_err("put fail"); |
| 4936 | goto fail; |
| 4937 | } |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4938 | if (hdd_sta_ctx->cache_conn_info.conn_flag.hs20_present) |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4939 | if (nla_put(skb, AP_INFO_HS20_INDICATION, |
Ashish Kumar Dhanotiya | 36d19b0 | 2018-02-22 00:59:49 +0530 | [diff] [blame] | 4940 | (sizeof(hdd_sta_ctx->cache_conn_info.hs20vendor_ie) |
| 4941 | - 1), |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 4942 | tmp_hs20 + 1)) { |
| 4943 | hdd_err("put fail"); |
| 4944 | goto fail; |
| 4945 | } |
| 4946 | |
| 4947 | return cfg80211_vendor_cmd_reply(skb); |
| 4948 | fail: |
| 4949 | if (skb) |
| 4950 | kfree_skb(skb); |
| 4951 | return -EINVAL; |
| 4952 | } |
| 4953 | |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 4954 | struct hdd_station_info *hdd_get_stainfo(struct hdd_station_info *astainfo, |
| 4955 | struct qdf_mac_addr mac_addr) |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4956 | { |
Jeff Johnson | 8215592 | 2017-09-30 16:54:14 -0700 | [diff] [blame] | 4957 | struct hdd_station_info *stainfo = NULL; |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4958 | int i; |
| 4959 | |
| 4960 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 4961 | if (!qdf_mem_cmp(&astainfo[i].sta_mac, |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4962 | &mac_addr, |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 4963 | QDF_MAC_ADDR_SIZE)) { |
| 4964 | stainfo = &astainfo[i]; |
| 4965 | break; |
| 4966 | } |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 4967 | } |
| 4968 | |
| 4969 | return stainfo; |
| 4970 | } |
| 4971 | |
| 4972 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
| 4973 | static inline int32_t remote_station_put_u64(struct sk_buff *skb, |
| 4974 | int32_t attrtype, |
| 4975 | uint64_t value) |
| 4976 | { |
| 4977 | return nla_put_u64_64bit(skb, attrtype, value, REMOTE_PAD); |
| 4978 | } |
| 4979 | #else |
| 4980 | static inline int32_t remote_station_put_u64(struct sk_buff *skb, |
| 4981 | int32_t attrtype, |
| 4982 | uint64_t value) |
| 4983 | { |
| 4984 | return nla_put_u64(skb, attrtype, value); |
| 4985 | } |
| 4986 | #endif |
| 4987 | |
| 4988 | /** |
Hanumanth Reddy Pothula | f79fbdf | 2017-10-23 20:10:46 +0530 | [diff] [blame] | 4989 | * hdd_add_survey_info_sap_get_len - get data length used in |
| 4990 | * hdd_add_survey_info_sap() |
| 4991 | * |
| 4992 | * This function calculates the data length used in hdd_add_survey_info_sap() |
| 4993 | * |
| 4994 | * Return: total data length used in hdd_add_survey_info_sap() |
| 4995 | */ |
| 4996 | static uint32_t hdd_add_survey_info_sap_get_len(void) |
| 4997 | { |
| 4998 | return ((NLA_HDRLEN) + (sizeof(uint32_t) + NLA_HDRLEN)); |
| 4999 | } |
| 5000 | |
| 5001 | /** |
| 5002 | * hdd_add_survey_info - add survey info attribute |
| 5003 | * @skb: pointer to response skb buffer |
| 5004 | * @stainfo: station information |
| 5005 | * @idx: attribute type index for nla_next_start() |
| 5006 | * |
| 5007 | * This function adds survey info attribute to response skb buffer |
| 5008 | * |
| 5009 | * Return : 0 on success and errno on failure |
| 5010 | */ |
| 5011 | static int32_t hdd_add_survey_info_sap(struct sk_buff *skb, |
| 5012 | struct hdd_station_info *stainfo, |
| 5013 | int idx) |
| 5014 | { |
| 5015 | struct nlattr *nla_attr; |
| 5016 | |
| 5017 | nla_attr = nla_nest_start(skb, idx); |
| 5018 | if (!nla_attr) |
| 5019 | goto fail; |
| 5020 | if (nla_put_u32(skb, NL80211_SURVEY_INFO_FREQUENCY, |
| 5021 | stainfo->freq)) { |
| 5022 | hdd_err("put fail"); |
| 5023 | goto fail; |
| 5024 | } |
| 5025 | nla_nest_end(skb, nla_attr); |
| 5026 | return 0; |
| 5027 | fail: |
| 5028 | return -EINVAL; |
| 5029 | } |
| 5030 | |
| 5031 | /** |
| 5032 | * hdd_add_tx_bitrate_sap_get_len - get data length used in |
| 5033 | * hdd_add_tx_bitrate_sap() |
| 5034 | * |
| 5035 | * This function calculates the data length used in hdd_add_tx_bitrate_sap() |
| 5036 | * |
| 5037 | * Return: total data length used in hdd_add_tx_bitrate_sap() |
| 5038 | */ |
| 5039 | static uint32_t hdd_add_tx_bitrate_sap_get_len(void) |
| 5040 | { |
| 5041 | return ((NLA_HDRLEN) + (sizeof(uint8_t) + NLA_HDRLEN)); |
| 5042 | } |
| 5043 | |
| 5044 | /** |
| 5045 | * hdd_add_tx_bitrate_sap - add vhs nss info attribute |
| 5046 | * @skb: pointer to response skb buffer |
| 5047 | * @stainfo: station information |
| 5048 | * @idx: attribute type index for nla_next_start() |
| 5049 | * |
| 5050 | * This function adds vht nss attribute to response skb buffer |
| 5051 | * |
| 5052 | * Return : 0 on success and errno on failure |
| 5053 | */ |
| 5054 | static int hdd_add_tx_bitrate_sap(struct sk_buff *skb, |
| 5055 | struct hdd_station_info *stainfo, |
| 5056 | int idx) |
| 5057 | { |
| 5058 | struct nlattr *nla_attr; |
| 5059 | |
| 5060 | nla_attr = nla_nest_start(skb, idx); |
| 5061 | if (!nla_attr) |
| 5062 | goto fail; |
| 5063 | |
| 5064 | if (nla_put_u8(skb, NL80211_RATE_INFO_VHT_NSS, |
| 5065 | stainfo->nss)) { |
| 5066 | hdd_err("put fail"); |
| 5067 | goto fail; |
| 5068 | } |
| 5069 | nla_nest_end(skb, nla_attr); |
| 5070 | return 0; |
| 5071 | fail: |
| 5072 | return -EINVAL; |
| 5073 | } |
| 5074 | |
| 5075 | /** |
| 5076 | * hdd_add_sta_info_sap_get_len - get data length used in |
| 5077 | * hdd_add_sta_info_sap() |
| 5078 | * |
| 5079 | * This function calculates the data length used in hdd_add_sta_info_sap() |
| 5080 | * |
| 5081 | * Return: total data length used in hdd_add_sta_info_sap() |
| 5082 | */ |
| 5083 | static uint32_t hdd_add_sta_info_sap_get_len(void) |
| 5084 | { |
| 5085 | return ((NLA_HDRLEN) + (sizeof(uint8_t) + NLA_HDRLEN) + |
| 5086 | hdd_add_tx_bitrate_sap_get_len()); |
| 5087 | } |
| 5088 | |
| 5089 | /** |
| 5090 | * hdd_add_sta_info_sap - add sta signal info attribute |
| 5091 | * @skb: pointer to response skb buffer |
| 5092 | * @stainfo: station information |
| 5093 | * @idx: attribute type index for nla_next_start() |
| 5094 | * |
| 5095 | * This function adds sta signal attribute to response skb buffer |
| 5096 | * |
| 5097 | * Return : 0 on success and errno on failure |
| 5098 | */ |
| 5099 | static int32_t hdd_add_sta_info_sap(struct sk_buff *skb, int8_t rssi, |
| 5100 | struct hdd_station_info *stainfo, int idx) |
| 5101 | { |
| 5102 | struct nlattr *nla_attr; |
| 5103 | |
| 5104 | nla_attr = nla_nest_start(skb, idx); |
| 5105 | if (!nla_attr) |
| 5106 | goto fail; |
| 5107 | |
| 5108 | if (nla_put_u8(skb, NL80211_STA_INFO_SIGNAL, rssi)) { |
| 5109 | hdd_err("put fail"); |
| 5110 | goto fail; |
| 5111 | } |
| 5112 | if (hdd_add_tx_bitrate_sap(skb, stainfo, NL80211_STA_INFO_TX_BITRATE)) |
| 5113 | goto fail; |
| 5114 | |
| 5115 | nla_nest_end(skb, nla_attr); |
| 5116 | return 0; |
| 5117 | fail: |
| 5118 | return -EINVAL; |
| 5119 | } |
| 5120 | |
| 5121 | /** |
| 5122 | * hdd_add_link_standard_info_sap_get_len - get data length used in |
| 5123 | * hdd_add_link_standard_info_sap() |
| 5124 | * |
| 5125 | * This function calculates the data length used in |
| 5126 | * hdd_add_link_standard_info_sap() |
| 5127 | * |
| 5128 | * Return: total data length used in hdd_add_link_standard_info_sap() |
| 5129 | */ |
| 5130 | static uint32_t hdd_add_link_standard_info_sap_get_len(void) |
| 5131 | { |
| 5132 | return ((NLA_HDRLEN) + |
| 5133 | hdd_add_survey_info_sap_get_len() + |
| 5134 | hdd_add_sta_info_sap_get_len() + |
| 5135 | (sizeof(uint32_t) + NLA_HDRLEN)); |
| 5136 | } |
| 5137 | |
| 5138 | /** |
| 5139 | * hdd_add_link_standard_info_sap - add add link info attribut |
| 5140 | * @skb: pointer to response skb buffer |
| 5141 | * @stainfo: station information |
| 5142 | * @idx: attribute type index for nla_next_start() |
| 5143 | * |
| 5144 | * This function adds link info attribut to response skb buffer |
| 5145 | * |
| 5146 | * Return : 0 on success and errno on failure |
| 5147 | */ |
| 5148 | static int hdd_add_link_standard_info_sap(struct sk_buff *skb, int8_t rssi, |
| 5149 | struct hdd_station_info *stainfo, |
| 5150 | int idx) |
| 5151 | { |
| 5152 | struct nlattr *nla_attr; |
| 5153 | |
| 5154 | nla_attr = nla_nest_start(skb, idx); |
| 5155 | if (!nla_attr) |
| 5156 | goto fail; |
| 5157 | if (hdd_add_survey_info_sap(skb, stainfo, NL80211_ATTR_SURVEY_INFO)) |
| 5158 | goto fail; |
| 5159 | if (hdd_add_sta_info_sap(skb, rssi, stainfo, NL80211_ATTR_STA_INFO)) |
| 5160 | goto fail; |
| 5161 | |
| 5162 | if (nla_put_u32(skb, NL80211_ATTR_REASON_CODE, stainfo->reason_code)) { |
| 5163 | hdd_err("Reason code put fail"); |
| 5164 | goto fail; |
| 5165 | } |
| 5166 | |
| 5167 | nla_nest_end(skb, nla_attr); |
| 5168 | return 0; |
| 5169 | fail: |
| 5170 | return -EINVAL; |
| 5171 | } |
| 5172 | |
| 5173 | /** |
| 5174 | * hdd_add_ap_standard_info_sap_get_len - get data length used in |
| 5175 | * hdd_add_ap_standard_info_sap() |
| 5176 | * @stainfo: station information |
| 5177 | * |
| 5178 | * This function calculates the data length used in |
| 5179 | * hdd_add_ap_standard_info_sap() |
| 5180 | * |
| 5181 | * Return: total data length used in hdd_add_ap_standard_info_sap() |
| 5182 | */ |
| 5183 | static uint32_t hdd_add_ap_standard_info_sap_get_len( |
| 5184 | struct hdd_station_info *stainfo) |
| 5185 | { |
| 5186 | uint32_t len; |
| 5187 | |
| 5188 | len = NLA_HDRLEN; |
| 5189 | if (stainfo->vht_present) |
| 5190 | len += (sizeof(stainfo->vht_caps) + NLA_HDRLEN); |
| 5191 | if (stainfo->ht_present) |
| 5192 | len += (sizeof(stainfo->ht_caps) + NLA_HDRLEN); |
| 5193 | |
| 5194 | return len; |
| 5195 | } |
| 5196 | |
| 5197 | /** |
| 5198 | * hdd_add_ap_standard_info_sap - add HT and VHT info attributes |
| 5199 | * @skb: pointer to response skb buffer |
| 5200 | * @stainfo: station information |
| 5201 | * @idx: attribute type index for nla_next_start() |
| 5202 | * |
| 5203 | * This function adds HT and VHT info attributes to response skb buffer |
| 5204 | * |
| 5205 | * Return : 0 on success and errno on failure |
| 5206 | */ |
| 5207 | static int hdd_add_ap_standard_info_sap(struct sk_buff *skb, |
| 5208 | struct hdd_station_info *stainfo, |
| 5209 | int idx) |
| 5210 | { |
| 5211 | struct nlattr *nla_attr; |
| 5212 | |
| 5213 | nla_attr = nla_nest_start(skb, idx); |
| 5214 | if (!nla_attr) |
| 5215 | goto fail; |
| 5216 | |
| 5217 | if (stainfo->vht_present) { |
| 5218 | if (nla_put(skb, NL80211_ATTR_VHT_CAPABILITY, |
| 5219 | sizeof(stainfo->vht_caps), |
| 5220 | &stainfo->vht_caps)) { |
| 5221 | hdd_err("put fail"); |
| 5222 | goto fail; |
| 5223 | } |
| 5224 | } |
| 5225 | if (stainfo->ht_present) { |
| 5226 | if (nla_put(skb, NL80211_ATTR_HT_CAPABILITY, |
| 5227 | sizeof(stainfo->ht_caps), |
| 5228 | &stainfo->ht_caps)) { |
| 5229 | hdd_err("put fail"); |
| 5230 | goto fail; |
| 5231 | } |
| 5232 | } |
| 5233 | nla_nest_end(skb, nla_attr); |
| 5234 | return 0; |
| 5235 | fail: |
| 5236 | return -EINVAL; |
| 5237 | } |
| 5238 | |
| 5239 | /** |
| 5240 | * hdd_decode_ch_width - decode channel band width based |
| 5241 | * @ch_width: encoded enum value holding channel band width |
| 5242 | * |
| 5243 | * This function decodes channel band width from the given encoded enum value. |
| 5244 | * |
| 5245 | * Returns: decoded channel band width. |
| 5246 | */ |
| 5247 | static uint8_t hdd_decode_ch_width(tSirMacHTChannelWidth ch_width) |
| 5248 | { |
| 5249 | switch (ch_width) { |
| 5250 | case 0: |
| 5251 | return 20; |
| 5252 | case 1: |
| 5253 | return 40; |
| 5254 | case 2: |
| 5255 | return 80; |
| 5256 | case 3: |
| 5257 | case 4: |
| 5258 | return 160; |
| 5259 | default: |
| 5260 | hdd_debug("invalid enum: %d", ch_width); |
| 5261 | return 20; |
| 5262 | } |
| 5263 | } |
| 5264 | |
| 5265 | /** |
| 5266 | * hdd_get_cached_station_remote() - get cached(deleted) peer's info |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5267 | * @hdd_ctx: hdd context |
| 5268 | * @adapter: hostapd interface |
| 5269 | * @mac_addr: mac address of requested peer |
| 5270 | * |
Hanumanth Reddy Pothula | f79fbdf | 2017-10-23 20:10:46 +0530 | [diff] [blame] | 5271 | * This function collect and indicate the cached(deleted) peer's info |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5272 | * |
| 5273 | * Return: 0 on success, otherwise error value |
| 5274 | */ |
Hanumanth Reddy Pothula | f79fbdf | 2017-10-23 20:10:46 +0530 | [diff] [blame] | 5275 | |
| 5276 | static int hdd_get_cached_station_remote(struct hdd_context *hdd_ctx, |
| 5277 | struct hdd_adapter *adapter, |
| 5278 | struct qdf_mac_addr mac_addr) |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5279 | { |
Hanumanth Reddy Pothula | f79fbdf | 2017-10-23 20:10:46 +0530 | [diff] [blame] | 5280 | struct hdd_station_info *stainfo = hdd_get_stainfo( |
| 5281 | adapter->cache_sta_info, |
| 5282 | mac_addr); |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5283 | struct sk_buff *skb = NULL; |
Hanumanth Reddy Pothula | f79fbdf | 2017-10-23 20:10:46 +0530 | [diff] [blame] | 5284 | uint32_t nl_buf_len = NLMSG_HDRLEN; |
| 5285 | uint8_t channel_width; |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5286 | |
| 5287 | if (!stainfo) { |
| 5288 | hdd_err("peer " MAC_ADDRESS_STR " not found", |
| 5289 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
Hanumanth Reddy Pothula | f79fbdf | 2017-10-23 20:10:46 +0530 | [diff] [blame] | 5290 | return -EINVAL; |
| 5291 | } |
| 5292 | |
| 5293 | nl_buf_len += hdd_add_link_standard_info_sap_get_len() + |
| 5294 | hdd_add_ap_standard_info_sap_get_len(stainfo) + |
Ashish Kumar Dhanotiya | d523f0d | 2017-10-26 14:15:48 +0530 | [diff] [blame] | 5295 | (sizeof(stainfo->dot11_mode) + NLA_HDRLEN) + |
Hanumanth Reddy Pothula | f79fbdf | 2017-10-23 20:10:46 +0530 | [diff] [blame] | 5296 | (sizeof(stainfo->ch_width) + NLA_HDRLEN) + |
| 5297 | (sizeof(stainfo->tx_rate) + NLA_HDRLEN) + |
| 5298 | (sizeof(stainfo->rx_rate) + NLA_HDRLEN); |
| 5299 | |
| 5300 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 5301 | if (!skb) { |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 5302 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Hanumanth Reddy Pothula | f79fbdf | 2017-10-23 20:10:46 +0530 | [diff] [blame] | 5303 | return -ENOMEM; |
| 5304 | } |
| 5305 | |
| 5306 | if (hdd_add_link_standard_info_sap(skb, stainfo->rssi, stainfo, |
| 5307 | LINK_INFO_STANDARD_NL80211_ATTR)) { |
| 5308 | hdd_err("link standard put fail"); |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5309 | goto fail; |
| 5310 | } |
| 5311 | |
Hanumanth Reddy Pothula | f79fbdf | 2017-10-23 20:10:46 +0530 | [diff] [blame] | 5312 | if (hdd_add_ap_standard_info_sap(skb, stainfo, |
| 5313 | AP_INFO_STANDARD_NL80211_ATTR)) { |
| 5314 | hdd_err("ap standard put fail"); |
| 5315 | goto fail; |
| 5316 | } |
| 5317 | |
| 5318 | /* upper layer expects decoded channel BW */ |
| 5319 | channel_width = hdd_decode_ch_width(stainfo->ch_width); |
| 5320 | |
| 5321 | if (nla_put_u32(skb, REMOTE_SUPPORTED_MODE, |
| 5322 | hdd_convert_dot11mode( |
| 5323 | stainfo->mode)) || |
| 5324 | nla_put_u8(skb, REMOTE_CH_WIDTH, channel_width)) { |
| 5325 | hdd_err("remote ch put fail"); |
| 5326 | goto fail; |
| 5327 | } |
| 5328 | if (nla_put_u32(skb, REMOTE_LAST_TX_RATE, stainfo->tx_rate)) { |
| 5329 | hdd_err("tx rate put fail"); |
| 5330 | goto fail; |
| 5331 | } |
| 5332 | if (nla_put_u32(skb, REMOTE_LAST_RX_RATE, stainfo->rx_rate)) { |
| 5333 | hdd_err("rx rate put fail"); |
| 5334 | goto fail; |
| 5335 | } |
| 5336 | |
| 5337 | qdf_mem_zero(stainfo, sizeof(*stainfo)); |
| 5338 | |
| 5339 | return cfg80211_vendor_cmd_reply(skb); |
| 5340 | fail: |
| 5341 | if (skb) |
| 5342 | kfree_skb(skb); |
| 5343 | |
| 5344 | return -EINVAL; |
| 5345 | } |
| 5346 | |
| 5347 | /** |
| 5348 | * hdd_get_cached_station_remote() - get connected peer's info |
| 5349 | * @hdd_ctx: hdd context |
| 5350 | * @adapter: hostapd interface |
| 5351 | * @mac_addr: mac address of requested peer |
| 5352 | * |
| 5353 | * This function collect and indicate the connected peer's info |
| 5354 | * |
| 5355 | * Return: 0 on success, otherwise error value |
| 5356 | */ |
| 5357 | static int hdd_get_connected_station_info(struct hdd_context *hdd_ctx, |
| 5358 | struct hdd_adapter *adapter, |
| 5359 | struct qdf_mac_addr mac_addr, |
| 5360 | struct hdd_station_info *stainfo) |
| 5361 | { |
| 5362 | struct sk_buff *skb = NULL; |
| 5363 | uint32_t nl_buf_len; |
| 5364 | struct sir_peer_info_ext peer_info; |
| 5365 | bool txrx_rate = true; |
| 5366 | |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5367 | nl_buf_len = NLMSG_HDRLEN; |
| 5368 | nl_buf_len += (sizeof(stainfo->max_phy_rate) + NLA_HDRLEN) + |
| 5369 | (sizeof(stainfo->tx_packets) + NLA_HDRLEN) + |
| 5370 | (sizeof(stainfo->tx_bytes) + NLA_HDRLEN) + |
| 5371 | (sizeof(stainfo->rx_packets) + NLA_HDRLEN) + |
| 5372 | (sizeof(stainfo->rx_bytes) + NLA_HDRLEN) + |
Jeff Johnson | 65fda11 | 2017-10-21 13:46:10 -0700 | [diff] [blame] | 5373 | (sizeof(stainfo->is_qos_enabled) + NLA_HDRLEN) + |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5374 | (sizeof(stainfo->mode) + NLA_HDRLEN); |
| 5375 | |
| 5376 | if (!hdd_ctx->config->sap_get_peer_info || |
| 5377 | wlan_hdd_get_peer_info(adapter, mac_addr, &peer_info)) { |
| 5378 | hdd_err("fail to get tx/rx rate"); |
| 5379 | txrx_rate = false; |
| 5380 | } else { |
| 5381 | stainfo->tx_rate = peer_info.tx_rate; |
| 5382 | stainfo->rx_rate = peer_info.rx_rate; |
| 5383 | nl_buf_len += (sizeof(stainfo->tx_rate) + NLA_HDRLEN) + |
| 5384 | (sizeof(stainfo->rx_rate) + NLA_HDRLEN); |
| 5385 | } |
| 5386 | |
| 5387 | /* below info is only valid for HT/VHT mode */ |
| 5388 | if (stainfo->mode > SIR_SME_PHY_MODE_LEGACY) |
| 5389 | nl_buf_len += (sizeof(stainfo->ampdu) + NLA_HDRLEN) + |
| 5390 | (sizeof(stainfo->tx_stbc) + NLA_HDRLEN) + |
| 5391 | (sizeof(stainfo->rx_stbc) + NLA_HDRLEN) + |
| 5392 | (sizeof(stainfo->ch_width) + NLA_HDRLEN) + |
| 5393 | (sizeof(stainfo->sgi_enable) + NLA_HDRLEN); |
| 5394 | |
| 5395 | hdd_info("buflen %d hdrlen %d", nl_buf_len, NLMSG_HDRLEN); |
| 5396 | |
| 5397 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, |
| 5398 | nl_buf_len); |
| 5399 | if (!skb) { |
| 5400 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
| 5401 | goto fail; |
| 5402 | } |
| 5403 | |
| 5404 | hdd_info("stainfo"); |
| 5405 | hdd_info("maxrate %x tx_pkts %x tx_bytes %llx", |
| 5406 | stainfo->max_phy_rate, stainfo->tx_packets, |
| 5407 | stainfo->tx_bytes); |
| 5408 | hdd_info("rx_pkts %x rx_bytes %llx mode %x", |
| 5409 | stainfo->rx_packets, stainfo->rx_bytes, |
| 5410 | stainfo->mode); |
| 5411 | if (stainfo->mode > SIR_SME_PHY_MODE_LEGACY) { |
| 5412 | hdd_info("ampdu %d tx_stbc %d rx_stbc %d", |
| 5413 | stainfo->ampdu, stainfo->tx_stbc, |
| 5414 | stainfo->rx_stbc); |
| 5415 | hdd_info("wmm %d chwidth %d sgi %d", |
Jeff Johnson | 65fda11 | 2017-10-21 13:46:10 -0700 | [diff] [blame] | 5416 | stainfo->is_qos_enabled, |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5417 | stainfo->ch_width, |
| 5418 | stainfo->sgi_enable); |
| 5419 | } |
| 5420 | |
| 5421 | if (nla_put_u32(skb, REMOTE_MAX_PHY_RATE, stainfo->max_phy_rate) || |
| 5422 | nla_put_u32(skb, REMOTE_TX_PACKETS, stainfo->tx_packets) || |
| 5423 | remote_station_put_u64(skb, REMOTE_TX_BYTES, stainfo->tx_bytes) || |
| 5424 | nla_put_u32(skb, REMOTE_RX_PACKETS, stainfo->rx_packets) || |
| 5425 | remote_station_put_u64(skb, REMOTE_RX_BYTES, stainfo->rx_bytes) || |
Jeff Johnson | 65fda11 | 2017-10-21 13:46:10 -0700 | [diff] [blame] | 5426 | nla_put_u8(skb, REMOTE_WMM, stainfo->is_qos_enabled) || |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5427 | nla_put_u8(skb, REMOTE_SUPPORTED_MODE, stainfo->mode)) { |
| 5428 | hdd_err("put fail"); |
| 5429 | goto fail; |
| 5430 | } |
| 5431 | |
| 5432 | if (txrx_rate) { |
| 5433 | if (nla_put_u32(skb, REMOTE_LAST_TX_RATE, stainfo->tx_rate) || |
| 5434 | nla_put_u32(skb, REMOTE_LAST_RX_RATE, stainfo->rx_rate)) { |
| 5435 | hdd_err("put fail"); |
| 5436 | goto fail; |
| 5437 | } else { |
| 5438 | hdd_info("tx_rate %x rx_rate %x", |
| 5439 | stainfo->tx_rate, stainfo->rx_rate); |
| 5440 | } |
| 5441 | } |
| 5442 | |
| 5443 | if (stainfo->mode > SIR_SME_PHY_MODE_LEGACY) { |
| 5444 | if (nla_put_u8(skb, REMOTE_AMPDU, stainfo->ampdu) || |
| 5445 | nla_put_u8(skb, REMOTE_TX_STBC, stainfo->tx_stbc) || |
| 5446 | nla_put_u8(skb, REMOTE_RX_STBC, stainfo->rx_stbc) || |
| 5447 | nla_put_u8(skb, REMOTE_CH_WIDTH, stainfo->ch_width) || |
| 5448 | nla_put_u8(skb, REMOTE_SGI_ENABLE, stainfo->sgi_enable)) { |
| 5449 | hdd_err("put fail"); |
| 5450 | goto fail; |
| 5451 | } |
| 5452 | } |
| 5453 | |
| 5454 | return cfg80211_vendor_cmd_reply(skb); |
| 5455 | |
| 5456 | fail: |
| 5457 | if (skb) |
| 5458 | kfree_skb(skb); |
| 5459 | |
| 5460 | return -EINVAL; |
| 5461 | } |
| 5462 | |
| 5463 | /** |
Hanumanth Reddy Pothula | f79fbdf | 2017-10-23 20:10:46 +0530 | [diff] [blame] | 5464 | * hdd_get_station_remote() - get remote peer's info |
| 5465 | * @hdd_ctx: hdd context |
| 5466 | * @adapter: hostapd interface |
| 5467 | * @mac_addr: mac address of requested peer |
| 5468 | * |
| 5469 | * This function collect and indicate the remote peer's info |
| 5470 | * |
| 5471 | * Return: 0 on success, otherwise error value |
| 5472 | */ |
| 5473 | static int hdd_get_station_remote(struct hdd_context *hdd_ctx, |
| 5474 | struct hdd_adapter *adapter, |
| 5475 | struct qdf_mac_addr mac_addr) |
| 5476 | { |
| 5477 | struct hdd_station_info *stainfo = hdd_get_stainfo(adapter->sta_info, |
| 5478 | mac_addr); |
| 5479 | int status = 0; |
| 5480 | bool is_associated = false; |
| 5481 | |
| 5482 | if (!stainfo) { |
| 5483 | status = hdd_get_cached_station_remote(hdd_ctx, adapter, |
| 5484 | mac_addr); |
| 5485 | return status; |
| 5486 | } |
| 5487 | |
| 5488 | is_associated = hdd_is_peer_associated(adapter, &mac_addr); |
| 5489 | if (!is_associated) { |
| 5490 | status = hdd_get_cached_station_remote(hdd_ctx, adapter, |
| 5491 | mac_addr); |
| 5492 | return status; |
| 5493 | } |
| 5494 | |
| 5495 | status = hdd_get_connected_station_info(hdd_ctx, adapter, |
| 5496 | mac_addr, stainfo); |
| 5497 | return status; |
| 5498 | } |
| 5499 | |
| 5500 | /** |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 5501 | * __hdd_cfg80211_get_station_cmd() - Handle get station vendor cmd |
| 5502 | * @wiphy: corestack handler |
| 5503 | * @wdev: wireless device |
| 5504 | * @data: data |
| 5505 | * @data_len: data length |
| 5506 | * |
| 5507 | * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION. |
| 5508 | * Validate cmd attributes and send the station info to upper layers. |
| 5509 | * |
| 5510 | * Return: Success(0) or reason code for failure |
| 5511 | */ |
Anurag Chouhan | d939d3d | 2016-07-20 17:45:48 +0530 | [diff] [blame] | 5512 | static int |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 5513 | __hdd_cfg80211_get_station_cmd(struct wiphy *wiphy, |
| 5514 | struct wireless_dev *wdev, |
| 5515 | const void *data, |
| 5516 | int data_len) |
| 5517 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 5518 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 5519 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 5520 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 5521 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX + 1]; |
| 5522 | int32_t status; |
| 5523 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 5524 | hdd_enter_dev(dev); |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 5525 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5526 | hdd_err("Command not allowed in FTM mode"); |
| 5527 | status = -EPERM; |
| 5528 | goto out; |
| 5529 | } |
| 5530 | |
| 5531 | status = wlan_hdd_validate_context(hdd_ctx); |
| 5532 | if (0 != status) |
| 5533 | goto out; |
| 5534 | |
| 5535 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 5536 | status = wlan_cfg80211_nla_parse(tb, |
| 5537 | QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX, |
| 5538 | data, data_len, |
| 5539 | hdd_get_station_policy); |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 5540 | if (status) { |
| 5541 | hdd_err("Invalid ATTR"); |
| 5542 | goto out; |
| 5543 | } |
| 5544 | |
| 5545 | /* Parse and fetch Command Type*/ |
| 5546 | if (tb[STATION_INFO]) { |
| 5547 | status = hdd_get_station_info(hdd_ctx, adapter); |
| 5548 | } else if (tb[STATION_ASSOC_FAIL_REASON]) { |
| 5549 | status = hdd_get_station_assoc_fail(hdd_ctx, adapter); |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5550 | } else if (tb[STATION_REMOTE]) { |
| 5551 | struct qdf_mac_addr mac_addr; |
| 5552 | |
| 5553 | if (adapter->device_mode != QDF_SAP_MODE && |
| 5554 | adapter->device_mode != QDF_P2P_GO_MODE) { |
| 5555 | hdd_err("invalid device_mode:%d", adapter->device_mode); |
| 5556 | status = -EINVAL; |
| 5557 | goto out; |
| 5558 | } |
| 5559 | |
| 5560 | nla_memcpy(mac_addr.bytes, tb[STATION_REMOTE], |
| 5561 | QDF_MAC_ADDR_SIZE); |
| 5562 | |
| 5563 | hdd_debug("STATION_REMOTE " MAC_ADDRESS_STR, |
| 5564 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 5565 | |
| 5566 | status = hdd_get_station_remote(hdd_ctx, adapter, mac_addr); |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 5567 | } else { |
| 5568 | hdd_err("get station info cmd type failed"); |
| 5569 | status = -EINVAL; |
| 5570 | goto out; |
| 5571 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5572 | hdd_exit(); |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 5573 | out: |
| 5574 | return status; |
| 5575 | } |
| 5576 | |
| 5577 | /** |
| 5578 | * wlan_hdd_cfg80211_get_station_cmd() - Handle get station vendor cmd |
| 5579 | * @wiphy: corestack handler |
| 5580 | * @wdev: wireless device |
| 5581 | * @data: data |
| 5582 | * @data_len: data length |
| 5583 | * |
| 5584 | * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION. |
| 5585 | * Validate cmd attributes and send the station info to upper layers. |
| 5586 | * |
| 5587 | * Return: Success(0) or reason code for failure |
| 5588 | */ |
| 5589 | static int32_t |
| 5590 | hdd_cfg80211_get_station_cmd(struct wiphy *wiphy, |
| 5591 | struct wireless_dev *wdev, |
| 5592 | const void *data, |
| 5593 | int data_len) |
| 5594 | { |
| 5595 | int ret; |
| 5596 | |
| 5597 | cds_ssr_protect(__func__); |
| 5598 | ret = __hdd_cfg80211_get_station_cmd(wiphy, wdev, data, data_len); |
| 5599 | cds_ssr_unprotect(__func__); |
| 5600 | |
| 5601 | return ret; |
| 5602 | } |
| 5603 | |
| 5604 | /* |
| 5605 | * undef short names defined for get station command |
| 5606 | * used by __wlan_hdd_cfg80211_get_station_cmd() |
| 5607 | */ |
| 5608 | #undef STATION_INVALID |
| 5609 | #undef STATION_INFO |
| 5610 | #undef STATION_ASSOC_FAIL_REASON |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5611 | #undef STATION_REMOTE |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 5612 | #undef STATION_MAX |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 5613 | #undef LINK_INFO_STANDARD_NL80211_ATTR |
| 5614 | #undef AP_INFO_STANDARD_NL80211_ATTR |
| 5615 | #undef INFO_ROAM_COUNT |
| 5616 | #undef INFO_AKM |
| 5617 | #undef WLAN802_11_MODE |
| 5618 | #undef AP_INFO_HS20_INDICATION |
| 5619 | #undef HT_OPERATION |
| 5620 | #undef VHT_OPERATION |
| 5621 | #undef INFO_ASSOC_FAIL_REASON |
| 5622 | #undef REMOTE_MAX_PHY_RATE |
| 5623 | #undef REMOTE_TX_PACKETS |
| 5624 | #undef REMOTE_TX_BYTES |
| 5625 | #undef REMOTE_RX_PACKETS |
| 5626 | #undef REMOTE_RX_BYTES |
| 5627 | #undef REMOTE_LAST_TX_RATE |
| 5628 | #undef REMOTE_LAST_RX_RATE |
| 5629 | #undef REMOTE_WMM |
| 5630 | #undef REMOTE_SUPPORTED_MODE |
| 5631 | #undef REMOTE_AMPDU |
| 5632 | #undef REMOTE_TX_STBC |
| 5633 | #undef REMOTE_RX_STBC |
| 5634 | #undef REMOTE_CH_WIDTH |
| 5635 | #undef REMOTE_SGI_ENABLE |
| 5636 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
| 5637 | #undef REMOTE_PAD |
| 5638 | #endif |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 5639 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5640 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 5641 | /** |
| 5642 | * __wlan_hdd_cfg80211_keymgmt_set_key() - Store the Keys in the driver session |
| 5643 | * @wiphy: pointer to wireless wiphy structure. |
| 5644 | * @wdev: pointer to wireless_dev structure. |
| 5645 | * @data: Pointer to the Key data |
| 5646 | * @data_len:Length of the data passed |
| 5647 | * |
| 5648 | * This is called when wlan driver needs to save the keys received via |
| 5649 | * vendor specific command. |
| 5650 | * |
| 5651 | * Return: Return the Success or Failure code. |
| 5652 | */ |
| 5653 | static int __wlan_hdd_cfg80211_keymgmt_set_key(struct wiphy *wiphy, |
| 5654 | struct wireless_dev *wdev, |
| 5655 | const void *data, int data_len) |
| 5656 | { |
| 5657 | uint8_t local_pmk[SIR_ROAM_SCAN_PSK_SIZE]; |
| 5658 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 5659 | struct hdd_adapter *hdd_adapter_ptr = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 5660 | struct hdd_context *hdd_ctx_ptr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5661 | int status; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5662 | struct pmkid_mode_bits pmkid_modes; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5663 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 5664 | hdd_enter_dev(dev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 5665 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5666 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5667 | hdd_err("Command not allowed in FTM mode"); |
| 5668 | return -EPERM; |
| 5669 | } |
| 5670 | |
Hanumanth Reddy Pothula | 5387485 | 2018-03-08 19:57:49 +0530 | [diff] [blame] | 5671 | if ((data == NULL) || (data_len <= 0) || |
| 5672 | (data_len > SIR_ROAM_SCAN_PSK_SIZE)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 5673 | hdd_err("Invalid data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5674 | return -EINVAL; |
| 5675 | } |
| 5676 | |
| 5677 | hdd_ctx_ptr = WLAN_HDD_GET_CTX(hdd_adapter_ptr); |
| 5678 | if (!hdd_ctx_ptr) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 5679 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5680 | return -EINVAL; |
| 5681 | } |
| 5682 | |
| 5683 | status = wlan_hdd_validate_context(hdd_ctx_ptr); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5684 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5685 | return status; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5686 | |
| 5687 | hdd_get_pmkid_modes(hdd_ctx_ptr, &pmkid_modes); |
| 5688 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5689 | sme_update_roam_key_mgmt_offload_enabled(hdd_ctx_ptr->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5690 | hdd_adapter_ptr->session_id, |
Deepak Dhamdhere | f2a7d8b | 2016-08-19 16:17:38 -0700 | [diff] [blame] | 5691 | true, |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5692 | &pmkid_modes); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5693 | qdf_mem_zero(&local_pmk, SIR_ROAM_SCAN_PSK_SIZE); |
| 5694 | qdf_mem_copy(local_pmk, data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5695 | sme_roam_set_psk_pmk(WLAN_HDD_GET_HAL_CTX(hdd_adapter_ptr), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5696 | hdd_adapter_ptr->session_id, local_pmk, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5697 | return 0; |
| 5698 | } |
| 5699 | |
| 5700 | /** |
| 5701 | * wlan_hdd_cfg80211_keymgmt_set_key() - Store the Keys in the driver session |
| 5702 | * @wiphy: pointer to wireless wiphy structure. |
| 5703 | * @wdev: pointer to wireless_dev structure. |
| 5704 | * @data: Pointer to the Key data |
| 5705 | * @data_len:Length of the data passed |
| 5706 | * |
| 5707 | * This is called when wlan driver needs to save the keys received via |
| 5708 | * vendor specific command. |
| 5709 | * |
| 5710 | * Return: Return the Success or Failure code. |
| 5711 | */ |
| 5712 | static int wlan_hdd_cfg80211_keymgmt_set_key(struct wiphy *wiphy, |
| 5713 | struct wireless_dev *wdev, |
| 5714 | const void *data, int data_len) |
| 5715 | { |
| 5716 | int ret; |
| 5717 | |
| 5718 | cds_ssr_protect(__func__); |
| 5719 | ret = __wlan_hdd_cfg80211_keymgmt_set_key(wiphy, wdev, data, data_len); |
| 5720 | cds_ssr_unprotect(__func__); |
| 5721 | |
| 5722 | return ret; |
| 5723 | } |
Varun Reddy Yeturu | bbbbe23 | 2016-02-29 14:01:57 -0800 | [diff] [blame] | 5724 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5725 | |
| 5726 | static const struct nla_policy qca_wlan_vendor_get_wifi_info_policy[ |
| 5727 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1] = { |
| 5728 | [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 }, |
| 5729 | [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 }, |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 5730 | [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX] = {.type = NLA_U32 }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5731 | }; |
| 5732 | |
| 5733 | /** |
| 5734 | * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info |
| 5735 | * @wiphy: pointer to wireless wiphy structure. |
| 5736 | * @wdev: pointer to wireless_dev structure. |
| 5737 | * @data: Pointer to the data to be passed via vendor interface |
| 5738 | * @data_len:Length of the data to be passed |
| 5739 | * |
| 5740 | * This is called when wlan driver needs to send wifi driver related info |
| 5741 | * (driver/fw version) to the user space application upon request. |
| 5742 | * |
| 5743 | * Return: Return the Success or Failure code. |
| 5744 | */ |
| 5745 | static int |
| 5746 | __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy, |
| 5747 | struct wireless_dev *wdev, |
| 5748 | const void *data, int data_len) |
| 5749 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 5750 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5751 | 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] | 5752 | tSirVersionString driver_version; |
| 5753 | tSirVersionString firmware_version; |
Varun Reddy Yeturu | eb29332 | 2017-04-16 21:53:13 -0700 | [diff] [blame] | 5754 | const char *hw_version; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5755 | 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] | 5756 | uint32_t sub_id = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5757 | int status; |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 5758 | struct sk_buff *reply_skb; |
| 5759 | uint32_t skb_len = 0, count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5760 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 5761 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 5762 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5763 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5764 | hdd_err("Command not allowed in FTM mode"); |
| 5765 | return -EPERM; |
| 5766 | } |
| 5767 | |
| 5768 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5769 | if (status) |
| 5770 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5771 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 5772 | if (wlan_cfg80211_nla_parse(tb_vendor, |
| 5773 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, |
| 5774 | data, data_len, |
| 5775 | qca_wlan_vendor_get_wifi_info_policy)) { |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 5776 | hdd_err("WIFI_INFO_GET NL CMD parsing failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5777 | return -EINVAL; |
| 5778 | } |
| 5779 | |
| 5780 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) { |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 5781 | hdd_debug("Rcvd req for Driver version"); |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 5782 | strlcpy(driver_version, QWLAN_VERSIONSTR, |
| 5783 | sizeof(driver_version)); |
| 5784 | skb_len += strlen(driver_version) + 1; |
| 5785 | count++; |
| 5786 | } |
| 5787 | |
| 5788 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 5789 | hdd_debug("Rcvd req for FW version"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5790 | hdd_get_fw_version(hdd_ctx, &major_spid, &minor_spid, &siid, |
| 5791 | &crmid); |
Varun Reddy Yeturu | eb29332 | 2017-04-16 21:53:13 -0700 | [diff] [blame] | 5792 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 5793 | hw_version = hdd_ctx->target_hw_name; |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 5794 | snprintf(firmware_version, sizeof(firmware_version), |
Varun Reddy Yeturu | eb29332 | 2017-04-16 21:53:13 -0700 | [diff] [blame] | 5795 | "FW:%d.%d.%d.%d.%d HW:%s", major_spid, minor_spid, |
| 5796 | siid, crmid, sub_id, hw_version); |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 5797 | skb_len += strlen(firmware_version) + 1; |
| 5798 | count++; |
| 5799 | } |
| 5800 | |
| 5801 | if (count == 0) { |
| 5802 | hdd_err("unknown attribute in get_wifi_info request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5803 | return -EINVAL; |
| 5804 | } |
| 5805 | |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 5806 | skb_len += (NLA_HDRLEN * count) + NLMSG_HDRLEN; |
| 5807 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, skb_len); |
| 5808 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5809 | if (!reply_skb) { |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 5810 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5811 | return -ENOMEM; |
| 5812 | } |
| 5813 | |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 5814 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) { |
| 5815 | if (nla_put_string(reply_skb, |
| 5816 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION, |
| 5817 | driver_version)) |
| 5818 | goto error_nla_fail; |
| 5819 | } |
| 5820 | |
Hanumanth Reddy Pothula | 1046ccc | 2016-10-14 14:33:44 +0530 | [diff] [blame] | 5821 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) { |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 5822 | if (nla_put_string(reply_skb, |
| 5823 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION, |
| 5824 | firmware_version)) |
| 5825 | goto error_nla_fail; |
| 5826 | } |
| 5827 | |
| 5828 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX]) { |
| 5829 | if (nla_put_u32(reply_skb, |
| 5830 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX, |
| 5831 | hdd_ctx->radio_index)) |
| 5832 | goto error_nla_fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5833 | } |
| 5834 | |
| 5835 | return cfg80211_vendor_cmd_reply(reply_skb); |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 5836 | |
| 5837 | error_nla_fail: |
| 5838 | hdd_err("nla put fail"); |
| 5839 | kfree_skb(reply_skb); |
| 5840 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5841 | } |
| 5842 | |
| 5843 | /** |
| 5844 | * wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info |
| 5845 | * @wiphy: pointer to wireless wiphy structure. |
| 5846 | * @wdev: pointer to wireless_dev structure. |
| 5847 | * @data: Pointer to the data to be passed via vendor interface |
| 5848 | * @data_len:Length of the data to be passed |
| 5849 | * |
| 5850 | * This is called when wlan driver needs to send wifi driver related info |
| 5851 | * (driver/fw version) to the user space application upon request. |
| 5852 | * |
| 5853 | * Return: Return the Success or Failure code. |
| 5854 | */ |
| 5855 | static int |
| 5856 | wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy, |
| 5857 | struct wireless_dev *wdev, |
| 5858 | const void *data, int data_len) |
| 5859 | { |
| 5860 | int ret; |
| 5861 | |
| 5862 | cds_ssr_protect(__func__); |
| 5863 | ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy, wdev, data, data_len); |
| 5864 | cds_ssr_unprotect(__func__); |
| 5865 | |
| 5866 | return ret; |
| 5867 | } |
| 5868 | |
| 5869 | /** |
| 5870 | * __wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features |
| 5871 | * @wiphy: pointer to wireless wiphy structure. |
| 5872 | * @wdev: pointer to wireless_dev structure. |
| 5873 | * @data: Pointer to the data to be passed via vendor interface |
| 5874 | * @data_len:Length of the data to be passed |
| 5875 | * |
| 5876 | * This is called by userspace to know the supported logger features |
| 5877 | * |
| 5878 | * Return: Return the Success or Failure code. |
| 5879 | */ |
| 5880 | static int |
| 5881 | __wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy, |
| 5882 | struct wireless_dev *wdev, |
| 5883 | const void *data, int data_len) |
| 5884 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 5885 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5886 | int status; |
| 5887 | uint32_t features; |
| 5888 | struct sk_buff *reply_skb = NULL; |
| 5889 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 5890 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 5891 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5892 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5893 | hdd_err("Command not allowed in FTM mode"); |
| 5894 | return -EPERM; |
| 5895 | } |
| 5896 | |
| 5897 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 5898 | if (status) |
| 5899 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5900 | |
| 5901 | features = 0; |
| 5902 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5903 | features |= WIFI_LOGGER_PER_PACKET_TX_RX_STATUS_SUPPORTED; |
| 5904 | features |= WIFI_LOGGER_CONNECT_EVENT_SUPPORTED; |
| 5905 | features |= WIFI_LOGGER_WAKE_LOCK_SUPPORTED; |
Srinivas Girigowda | a26eac0 | 2018-01-23 12:49:20 -0800 | [diff] [blame] | 5906 | features |= WIFI_LOGGER_DRIVER_DUMP_SUPPORTED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5907 | |
| 5908 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 5909 | sizeof(uint32_t) + NLA_HDRLEN + NLMSG_HDRLEN); |
| 5910 | if (!reply_skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 5911 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5912 | return -ENOMEM; |
| 5913 | } |
| 5914 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 5915 | hdd_debug("Supported logger features: 0x%0x", features); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5916 | if (nla_put_u32(reply_skb, QCA_WLAN_VENDOR_ATTR_LOGGER_SUPPORTED, |
| 5917 | features)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 5918 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5919 | kfree_skb(reply_skb); |
| 5920 | return -EINVAL; |
| 5921 | } |
| 5922 | |
| 5923 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 5924 | } |
| 5925 | |
| 5926 | /** |
| 5927 | * wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features |
| 5928 | * @wiphy: pointer to wireless wiphy structure. |
| 5929 | * @wdev: pointer to wireless_dev structure. |
| 5930 | * @data: Pointer to the data to be passed via vendor interface |
| 5931 | * @data_len:Length of the data to be passed |
| 5932 | * |
| 5933 | * This is called by userspace to know the supported logger features |
| 5934 | * |
| 5935 | * Return: Return the Success or Failure code. |
| 5936 | */ |
| 5937 | static int |
| 5938 | wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy, |
| 5939 | struct wireless_dev *wdev, |
| 5940 | const void *data, int data_len) |
| 5941 | { |
| 5942 | int ret; |
| 5943 | |
| 5944 | cds_ssr_protect(__func__); |
| 5945 | ret = __wlan_hdd_cfg80211_get_logger_supp_feature(wiphy, wdev, |
| 5946 | data, data_len); |
| 5947 | cds_ssr_unprotect(__func__); |
| 5948 | |
| 5949 | return ret; |
| 5950 | } |
| 5951 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5952 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 5953 | void wlan_hdd_save_gtk_offload_params(struct hdd_adapter *adapter, |
| 5954 | uint8_t *kck_ptr, uint8_t *kek_ptr, |
| 5955 | uint32_t kek_len, uint8_t *replay_ctr, |
| 5956 | bool big_endian) |
| 5957 | { |
| 5958 | struct hdd_station_ctx *hdd_sta_ctx; |
| 5959 | uint8_t *buf; |
| 5960 | int i; |
| 5961 | struct pmo_gtk_req *gtk_req = NULL; |
| 5962 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 5963 | |
| 5964 | gtk_req = qdf_mem_malloc(sizeof(*gtk_req)); |
| 5965 | if (!gtk_req) { |
| 5966 | hdd_err("cannot allocate gtk_req"); |
| 5967 | return; |
| 5968 | } |
| 5969 | |
| 5970 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5971 | if (kck_ptr) |
| 5972 | qdf_mem_copy(gtk_req->kck, kck_ptr, NL80211_KCK_LEN); |
| 5973 | |
Jeff Johnson | e1f2b0e | 2017-11-14 14:42:55 -0800 | [diff] [blame] | 5974 | if (kek_ptr) { |
| 5975 | /* paranoia */ |
| 5976 | if (kek_len > sizeof(gtk_req->kek)) { |
| 5977 | kek_len = sizeof(gtk_req->kek); |
| 5978 | QDF_ASSERT(0); |
| 5979 | } |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5980 | qdf_mem_copy(gtk_req->kek, kek_ptr, kek_len); |
Jeff Johnson | e1f2b0e | 2017-11-14 14:42:55 -0800 | [diff] [blame] | 5981 | } |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5982 | |
| 5983 | qdf_copy_macaddr(>k_req->bssid, &hdd_sta_ctx->conn_info.bssId); |
| 5984 | |
| 5985 | gtk_req->kek_len = kek_len; |
| 5986 | |
| 5987 | /* convert big to little endian since driver work on little endian */ |
| 5988 | buf = (uint8_t *)>k_req->replay_counter; |
| 5989 | for (i = 0; i < 8; i++) |
| 5990 | buf[7 - i] = replay_ctr[i]; |
| 5991 | |
| 5992 | status = pmo_ucfg_cache_gtk_offload_req(adapter->hdd_vdev, gtk_req); |
| 5993 | if (status != QDF_STATUS_SUCCESS) |
| 5994 | hdd_err("Failed to cache GTK Offload"); |
| 5995 | |
| 5996 | qdf_mem_free(gtk_req); |
| 5997 | } |
| 5998 | #else |
| 5999 | void wlan_hdd_save_gtk_offload_params(struct hdd_adapter *adapter, |
| 6000 | uint8_t *kck_ptr, |
| 6001 | uint8_t *kek_ptr, |
| 6002 | uint32_t kek_len, |
| 6003 | uint8_t *replay_ctr, |
| 6004 | bool big_endian) |
| 6005 | { |
| 6006 | } |
| 6007 | #endif |
| 6008 | |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 6009 | #if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6010 | /** |
| 6011 | * wlan_hdd_add_fils_params_roam_auth_event() - Adds FILS params in roam auth |
| 6012 | * @skb: SK buffer |
| 6013 | * @roam_info: Roam info |
| 6014 | * |
| 6015 | * API adds fils params[pmk, pmkid, next sequence number] to roam auth event |
| 6016 | * |
| 6017 | * Return: zero on success, error code on failure |
| 6018 | */ |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6019 | static int |
| 6020 | wlan_hdd_add_fils_params_roam_auth_event(struct sk_buff *skb, |
| 6021 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6022 | { |
| 6023 | if (roam_info->pmk_len && |
| 6024 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_PMK, |
| 6025 | roam_info->pmk_len, roam_info->pmk)) { |
| 6026 | hdd_err("pmk send fail"); |
| 6027 | return -EINVAL; |
| 6028 | } |
| 6029 | |
| 6030 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_PMKID, |
| 6031 | SIR_PMKID_LEN, roam_info->pmkid)) { |
| 6032 | hdd_err("pmkid send fail"); |
| 6033 | return -EINVAL; |
| 6034 | } |
| 6035 | |
Vignesh Viswanathan | 8da68cf | 2017-09-07 14:00:04 +0530 | [diff] [blame] | 6036 | hdd_debug("Update ERP Seq Num %d, Next ERP Seq Num %d", |
| 6037 | roam_info->update_erp_next_seq_num, |
| 6038 | roam_info->next_erp_seq_num); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6039 | if (roam_info->update_erp_next_seq_num && |
| 6040 | nla_put_u16(skb, |
| 6041 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_FILS_ERP_NEXT_SEQ_NUM, |
| 6042 | roam_info->next_erp_seq_num)) { |
| 6043 | hdd_err("ERP seq num send fail"); |
| 6044 | return -EINVAL; |
| 6045 | } |
| 6046 | |
| 6047 | return 0; |
| 6048 | } |
| 6049 | #else |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6050 | static inline int |
| 6051 | wlan_hdd_add_fils_params_roam_auth_event(struct sk_buff *skb, |
| 6052 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6053 | { |
| 6054 | return 0; |
| 6055 | } |
| 6056 | #endif |
| 6057 | |
Varun Reddy Yeturu | bbbbe23 | 2016-02-29 14:01:57 -0800 | [diff] [blame] | 6058 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6059 | /** |
| 6060 | * wlan_hdd_send_roam_auth_event() - Send the roamed and authorized event |
Prakash Dhavali | 989127d | 2016-11-29 14:56:44 +0530 | [diff] [blame] | 6061 | * @adapter: Pointer to adapter struct |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6062 | * @bssid: pointer to bssid of roamed AP. |
| 6063 | * @req_rsn_ie: Pointer to request RSN IE |
| 6064 | * @req_rsn_len: Length of the request RSN IE |
| 6065 | * @rsp_rsn_ie: Pointer to response RSN IE |
| 6066 | * @rsp_rsn_len: Length of the response RSN IE |
| 6067 | * @roam_info_ptr: Pointer to the roaming related information |
| 6068 | * |
| 6069 | * This is called when wlan driver needs to send the roaming and |
| 6070 | * authorization information after roaming. |
| 6071 | * |
| 6072 | * The information that would be sent is the request RSN IE, response |
| 6073 | * RSN IE and BSSID of the newly roamed AP. |
| 6074 | * |
| 6075 | * If the Authorized status is authenticated, then additional parameters |
| 6076 | * like PTK's KCK and KEK and Replay Counter would also be passed to the |
| 6077 | * supplicant. |
| 6078 | * |
| 6079 | * The supplicant upon receiving this event would ignore the legacy |
| 6080 | * cfg80211_roamed call and use the entire information from this event. |
| 6081 | * The cfg80211_roamed should still co-exist since the kernel will |
| 6082 | * make use of the parameters even if the supplicant ignores it. |
| 6083 | * |
| 6084 | * Return: Return the Success or Failure code. |
| 6085 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 6086 | 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] | 6087 | 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] | 6088 | uint32_t rsp_rsn_len, struct csr_roam_info *roam_info_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6089 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 6090 | struct hdd_context *hdd_ctx_ptr = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6091 | struct sk_buff *skb = NULL; |
Varun Reddy Yeturu | 16e8f01 | 2016-02-03 17:21:09 -0800 | [diff] [blame] | 6092 | eCsrAuthType auth_type; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6093 | uint32_t fils_params_len; |
| 6094 | int status; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6095 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6096 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6097 | |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6098 | if (wlan_hdd_validate_context(hdd_ctx_ptr)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6099 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6100 | |
Varun Reddy Yeturu | d351a6c | 2016-03-16 14:01:00 -0700 | [diff] [blame] | 6101 | if (!roaming_offload_enabled(hdd_ctx_ptr) || |
Prashanth Bhatta | bfc2529 | 2015-11-05 11:16:21 -0800 | [diff] [blame] | 6102 | !roam_info_ptr->roamSynchInProgress) |
| 6103 | return 0; |
| 6104 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6105 | /* |
| 6106 | * PMK is sent from FW in Roam Synch Event for FILS Roaming. |
| 6107 | * In that case, add three more NL attributes.ie. PMK, PMKID |
| 6108 | * and ERP next sequence number. Add corresponding lengths |
| 6109 | * with 3 extra NL message headers for each of the |
| 6110 | * aforementioned params. |
| 6111 | */ |
| 6112 | fils_params_len = roam_info_ptr->pmk_len + SIR_PMKID_LEN + |
| 6113 | sizeof(uint16_t) + (3 * NLMSG_HDRLEN); |
| 6114 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6115 | skb = cfg80211_vendor_event_alloc(hdd_ctx_ptr->wiphy, |
Prakash Dhavali | 989127d | 2016-11-29 14:56:44 +0530 | [diff] [blame] | 6116 | &(adapter->wdev), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6117 | ETH_ALEN + req_rsn_len + rsp_rsn_len + |
| 6118 | sizeof(uint8_t) + SIR_REPLAY_CTR_LEN + |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6119 | SIR_KCK_KEY_LEN + roam_info_ptr->kek_len + |
| 6120 | sizeof(uint8_t) + (8 * NLMSG_HDRLEN) + |
| 6121 | fils_params_len, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6122 | QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH_INDEX, |
| 6123 | GFP_KERNEL); |
| 6124 | |
| 6125 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 6126 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6127 | return -EINVAL; |
| 6128 | } |
| 6129 | |
| 6130 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_BSSID, |
| 6131 | ETH_ALEN, bssid) || |
| 6132 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_REQ_IE, |
| 6133 | req_rsn_len, req_rsn_ie) || |
| 6134 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_RESP_IE, |
| 6135 | rsp_rsn_len, rsp_rsn_ie)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 6136 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6137 | goto nla_put_failure; |
| 6138 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6139 | if (roam_info_ptr->synchAuthStatus == |
| 6140 | CSR_ROAM_AUTH_STATUS_AUTHENTICATED) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 6141 | hdd_debug("Include Auth Params TLV's"); |
Naveen Rawat | 14298b9 | 2015-11-25 16:27:41 -0800 | [diff] [blame] | 6142 | if (nla_put_u8(skb, |
| 6143 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_AUTHORIZED, true)) { |
| 6144 | hdd_err("nla put fail"); |
| 6145 | goto nla_put_failure; |
| 6146 | } |
Varun Reddy Yeturu | 16e8f01 | 2016-02-03 17:21:09 -0800 | [diff] [blame] | 6147 | auth_type = roam_info_ptr->u.pConnectedProfile->AuthType; |
| 6148 | /* if FT or CCKM connection: dont send replay counter */ |
| 6149 | if (auth_type != eCSR_AUTH_TYPE_FT_RSN && |
| 6150 | auth_type != eCSR_AUTH_TYPE_FT_RSN_PSK && |
| 6151 | auth_type != eCSR_AUTH_TYPE_CCKM_WPA && |
| 6152 | auth_type != eCSR_AUTH_TYPE_CCKM_RSN && |
| 6153 | nla_put(skb, |
| 6154 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_KEY_REPLAY_CTR, |
| 6155 | SIR_REPLAY_CTR_LEN, |
| 6156 | roam_info_ptr->replay_ctr)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 6157 | hdd_err("non FT/non CCKM connection"); |
| 6158 | hdd_err("failed to send replay counter"); |
Naveen Rawat | 14298b9 | 2015-11-25 16:27:41 -0800 | [diff] [blame] | 6159 | goto nla_put_failure; |
| 6160 | } |
Vignesh Viswanathan | 62d9899 | 2017-11-30 12:30:37 +0530 | [diff] [blame] | 6161 | if (roam_info_ptr->kek_len > SIR_KEK_KEY_LEN_FILS || |
| 6162 | nla_put(skb, |
Naveen Rawat | 14298b9 | 2015-11-25 16:27:41 -0800 | [diff] [blame] | 6163 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_PTK_KCK, |
| 6164 | SIR_KCK_KEY_LEN, roam_info_ptr->kck) || |
| 6165 | nla_put(skb, |
| 6166 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_PTK_KEK, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6167 | roam_info_ptr->kek_len, roam_info_ptr->kek)) { |
Vignesh Viswanathan | 62d9899 | 2017-11-30 12:30:37 +0530 | [diff] [blame] | 6168 | hdd_err("nla put fail, kek_len %d", |
| 6169 | roam_info_ptr->kek_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6170 | goto nla_put_failure; |
| 6171 | } |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6172 | |
| 6173 | status = wlan_hdd_add_fils_params_roam_auth_event(skb, |
| 6174 | roam_info_ptr); |
| 6175 | if (status) |
| 6176 | goto nla_put_failure; |
| 6177 | |
| 6178 | /* |
| 6179 | * Save the gtk rekey parameters in HDD STA context. They will |
| 6180 | * be used next time when host enables GTK offload and goes |
| 6181 | * into power save state. |
| 6182 | */ |
| 6183 | wlan_hdd_save_gtk_offload_params(adapter, roam_info_ptr->kck, |
| 6184 | roam_info_ptr->kek, |
| 6185 | roam_info_ptr->kek_len, |
| 6186 | roam_info_ptr->replay_ctr, |
| 6187 | true); |
| 6188 | hdd_debug("roam_info_ptr->replay_ctr 0x%llx", |
| 6189 | *((uint64_t *)roam_info_ptr->replay_ctr)); |
| 6190 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6191 | } else { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 6192 | hdd_debug("No Auth Params TLV's"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6193 | if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_AUTHORIZED, |
| 6194 | false)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 6195 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6196 | goto nla_put_failure; |
| 6197 | } |
| 6198 | } |
| 6199 | |
Selvaraj, Sridhar | d1225e6 | 2017-03-17 12:56:58 +0530 | [diff] [blame] | 6200 | hdd_debug("Auth Status = %d Subnet Change Status = %d", |
| 6201 | roam_info_ptr->synchAuthStatus, |
| 6202 | roam_info_ptr->subnet_change_status); |
Ravi Joshi | 277ae9b | 2015-11-13 11:30:43 -0800 | [diff] [blame] | 6203 | |
| 6204 | /* |
| 6205 | * Add subnet change status if subnet has changed |
| 6206 | * 0 = unchanged |
| 6207 | * 1 = changed |
| 6208 | * 2 = unknown |
| 6209 | */ |
| 6210 | if (roam_info_ptr->subnet_change_status) { |
| 6211 | if (nla_put_u8(skb, |
| 6212 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_SUBNET_STATUS, |
| 6213 | roam_info_ptr->subnet_change_status)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 6214 | hdd_err("nla put fail"); |
Ravi Joshi | 277ae9b | 2015-11-13 11:30:43 -0800 | [diff] [blame] | 6215 | goto nla_put_failure; |
| 6216 | } |
| 6217 | } |
| 6218 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6219 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 6220 | return 0; |
| 6221 | |
| 6222 | nla_put_failure: |
| 6223 | kfree_skb(skb); |
| 6224 | return -EINVAL; |
| 6225 | } |
Varun Reddy Yeturu | bbbbe23 | 2016-02-29 14:01:57 -0800 | [diff] [blame] | 6226 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6227 | |
lifeng | 907edd6 | 2017-05-12 10:10:36 +0800 | [diff] [blame] | 6228 | #define ANT_DIV_PROBE_PERIOD \ |
| 6229 | QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_PERIOD |
| 6230 | #define ANT_DIV_STAY_PERIOD \ |
| 6231 | QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_STAY_PERIOD |
| 6232 | #define ANT_DIV_SNR_DIFF \ |
| 6233 | QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SNR_DIFF |
| 6234 | #define ANT_DIV_PROBE_DWELL_TIME \ |
| 6235 | QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_PROBE_DWELL_TIME |
| 6236 | #define ANT_DIV_MGMT_SNR_WEIGHT \ |
| 6237 | QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_MGMT_SNR_WEIGHT |
| 6238 | #define ANT_DIV_DATA_SNR_WEIGHT \ |
| 6239 | QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_DATA_SNR_WEIGHT |
| 6240 | #define ANT_DIV_ACK_SNR_WEIGHT \ |
| 6241 | QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_ACK_SNR_WEIGHT |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6242 | #define RX_REORDER_TIMEOUT_VOICE \ |
| 6243 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_REORDER_TIMEOUT_VOICE |
| 6244 | #define RX_REORDER_TIMEOUT_VIDEO \ |
| 6245 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_REORDER_TIMEOUT_VIDEO |
| 6246 | #define RX_REORDER_TIMEOUT_BESTEFFORT \ |
| 6247 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_REORDER_TIMEOUT_BESTEFFORT |
| 6248 | #define RX_REORDER_TIMEOUT_BACKGROUND \ |
| 6249 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_REORDER_TIMEOUT_BACKGROUND |
| 6250 | #define RX_BLOCKSIZE_PEER_MAC \ |
| 6251 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_BLOCKSIZE_PEER_MAC |
| 6252 | #define RX_BLOCKSIZE_WINLIMIT \ |
| 6253 | QCA_WLAN_VENDOR_ATTR_CONFIG_RX_BLOCKSIZE_WINLIMIT |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6254 | static const struct nla_policy |
| 6255 | wlan_hdd_wifi_config_policy[QCA_WLAN_VENDOR_ATTR_CONFIG_MAX + 1] = { |
| 6256 | |
| 6257 | [QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM] = {.type = NLA_U32 }, |
| 6258 | [QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR] = {.type = NLA_U16 }, |
| 6259 | [QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME] = {.type = NLA_U32 }, |
Jeff Johnson | 79f6a60 | 2017-06-15 09:48:25 -0700 | [diff] [blame] | 6260 | [QCA_WLAN_VENDOR_ATTR_CONFIG_FINE_TIME_MEASUREMENT] = {.type = NLA_U32}, |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 6261 | [QCA_WLAN_VENDOR_ATTR_CONFIG_CHANNEL_AVOIDANCE_IND] = {.type = NLA_U8 }, |
Padma, Santhosh Kumar | a711967 | 2016-08-16 16:05:14 +0530 | [diff] [blame] | 6262 | [QCA_WLAN_VENDOR_ATTR_CONFIG_TX_MPDU_AGGREGATION] = {.type = NLA_U8 }, |
| 6263 | [QCA_WLAN_VENDOR_ATTR_CONFIG_RX_MPDU_AGGREGATION] = {.type = NLA_U8 }, |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 6264 | [QCA_WLAN_VENDOR_ATTR_CONFIG_NON_AGG_RETRY] = {.type = NLA_U8 }, |
| 6265 | [QCA_WLAN_VENDOR_ATTR_CONFIG_AGG_RETRY] = {.type = NLA_U8 }, |
| 6266 | [QCA_WLAN_VENDOR_ATTR_CONFIG_MGMT_RETRY] = {.type = NLA_U8 }, |
| 6267 | [QCA_WLAN_VENDOR_ATTR_CONFIG_CTRL_RETRY] = {.type = NLA_U8 }, |
| 6268 | [QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_DELAY] = {.type = NLA_U8 }, |
Agrawal, Ashish | b45599a | 2016-10-27 14:55:30 +0530 | [diff] [blame] | 6269 | [QCA_WLAN_VENDOR_ATTR_CONFIG_TX_FAIL_COUNT] = {.type = NLA_U32 }, |
lifeng | 907edd6 | 2017-05-12 10:10:36 +0800 | [diff] [blame] | 6270 | [ANT_DIV_PROBE_PERIOD] = {.type = NLA_U32}, |
| 6271 | [ANT_DIV_STAY_PERIOD] = {.type = NLA_U32}, |
| 6272 | [ANT_DIV_SNR_DIFF] = {.type = NLA_U32}, |
| 6273 | [ANT_DIV_PROBE_DWELL_TIME] = {.type = NLA_U32}, |
| 6274 | [ANT_DIV_MGMT_SNR_WEIGHT] = {.type = NLA_U32}, |
| 6275 | [ANT_DIV_DATA_SNR_WEIGHT] = {.type = NLA_U32}, |
| 6276 | [ANT_DIV_ACK_SNR_WEIGHT] = {.type = NLA_U32}, |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 6277 | [QCA_WLAN_VENDOR_ATTR_CONFIG_RESTRICT_OFFCHANNEL] = {.type = NLA_U8}, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6278 | [RX_REORDER_TIMEOUT_VOICE] = {.type = NLA_U32}, |
| 6279 | [RX_REORDER_TIMEOUT_VIDEO] = {.type = NLA_U32}, |
| 6280 | [RX_REORDER_TIMEOUT_BESTEFFORT] = {.type = NLA_U32}, |
| 6281 | [RX_REORDER_TIMEOUT_BACKGROUND] = {.type = NLA_U32}, |
Jeff Johnson | 19a5a7e | 2017-06-15 14:51:26 -0700 | [diff] [blame] | 6282 | [RX_BLOCKSIZE_PEER_MAC] = { |
| 6283 | .type = NLA_UNSPEC, |
| 6284 | .len = QDF_MAC_ADDR_SIZE}, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6285 | [RX_BLOCKSIZE_WINLIMIT] = {.type = NLA_U32}, |
Mukul Sharma | 6398b25 | 2017-05-01 17:58:12 +0530 | [diff] [blame] | 6286 | [QCA_WLAN_VENDOR_ATTR_CONFIG_LISTEN_INTERVAL] = {.type = NLA_U32 }, |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 6287 | [QCA_WLAN_VENDOR_ATTR_CONFIG_LRO] = {.type = NLA_U8 }, |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 6288 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_ENA] = {.type = NLA_U32 }, |
| 6289 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_CHAIN] = {.type = NLA_U32 }, |
| 6290 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SELFTEST] = {.type = NLA_U32 }, |
| 6291 | [QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SELFTEST_INTVL] = {.type = NLA_U32 }, |
Paul Zhang | 99fe884 | 2017-12-08 14:43:46 +0800 | [diff] [blame] | 6292 | [QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL] = {.type = NLA_U16 }, |
Nachiket Kukade | aaf8a71 | 2017-07-27 19:15:36 +0530 | [diff] [blame] | 6293 | [QCA_WLAN_VENDOR_ATTR_CONFIG_TOTAL_BEACON_MISS_COUNT] = {.type = NLA_U8}, |
Sandeep Puligilla | 24b7aa7 | 2017-10-13 18:05:14 -0700 | [diff] [blame] | 6294 | [QCA_WLAN_VENDOR_ATTR_CONFIG_SCAN_ENABLE] = {.type = NLA_U8 }, |
Abhishek Singh | 6454ad3 | 2017-12-20 10:42:21 +0530 | [diff] [blame] | 6295 | [QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE] = {.type = NLA_U8}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6296 | }; |
| 6297 | |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6298 | static const struct nla_policy |
| 6299 | wlan_hdd_wifi_test_config_policy[ |
| 6300 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_MAX + 1] = { |
| 6301 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WMM_ENABLE] = { |
| 6302 | .type = NLA_U8}, |
| 6303 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ACCEPT_ADDBA_REQ] = { |
| 6304 | .type = NLA_U8}, |
Kiran Kumar Lokere | 96246e5 | 2018-01-24 16:44:35 -0800 | [diff] [blame] | 6305 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_MCS] = { |
| 6306 | .type = NLA_U8}, |
Kiran Kumar Lokere | a934561 | 2018-02-08 14:28:24 -0800 | [diff] [blame] | 6307 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_SEND_ADDBA_REQ] = { |
| 6308 | .type = NLA_U8}, |
Kiran Kumar Lokere | 5cc2f0d | 2018-02-08 17:10:05 -0800 | [diff] [blame] | 6309 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_FRAGMENTATION] = { |
| 6310 | .type = NLA_U8}, |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 6311 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WEP_TKIP_IN_HE] = { |
| 6312 | .type = NLA_U8}, |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 6313 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADD_DEL_BA_SESSION] = { |
| 6314 | .type = NLA_U8}, |
| 6315 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_BA_TID] = { |
| 6316 | .type = NLA_U8}, |
| 6317 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADDBA_BUFF_SIZE] = { |
| 6318 | .type = NLA_U8}, |
Kiran Kumar Lokere | 3324f63 | 2018-03-01 21:43:21 -0800 | [diff] [blame] | 6319 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ENABLE_NO_ACK] = { |
| 6320 | .type = NLA_U8}, |
| 6321 | [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_NO_ACK_AC] = { |
| 6322 | .type = NLA_U8}, |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 6323 | }; |
| 6324 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6325 | /** |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 6326 | * wlan_hdd_add_qcn_ie() - Add QCN IE to a given IE buffer |
| 6327 | * @ie_data: IE buffer |
| 6328 | * @ie_len: length of the @ie_data |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 6329 | * |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 6330 | * Return: QDF_STATUS |
| 6331 | */ |
| 6332 | static QDF_STATUS wlan_hdd_add_qcn_ie(uint8_t *ie_data, uint16_t *ie_len) |
| 6333 | { |
| 6334 | tDot11fIEQCN_IE qcn_ie; |
| 6335 | uint8_t qcn_ie_hdr[QCN_IE_HDR_LEN] |
| 6336 | = {IE_EID_VENDOR, DOT11F_IE_QCN_IE_MAX_LEN, |
| 6337 | 0x8C, 0xFD, 0xF0, 0x1}; |
| 6338 | |
| 6339 | if (((*ie_len) + QCN_IE_HDR_LEN + |
| 6340 | QCN_IE_VERSION_SUBATTR_DATA_LEN) > MAX_DEFAULT_SCAN_IE_LEN) { |
| 6341 | hdd_err("IE buffer not enough for QCN IE"); |
| 6342 | return QDF_STATUS_E_FAILURE; |
| 6343 | } |
| 6344 | |
| 6345 | /* Add QCN IE header */ |
| 6346 | qdf_mem_copy(ie_data + (*ie_len), qcn_ie_hdr, QCN_IE_HDR_LEN); |
| 6347 | (*ie_len) += QCN_IE_HDR_LEN; |
| 6348 | |
| 6349 | /* Retrieve Version sub-attribute data */ |
| 6350 | populate_dot11f_qcn_ie(&qcn_ie); |
| 6351 | |
| 6352 | /* Add QCN IE data[version sub attribute] */ |
| 6353 | qdf_mem_copy(ie_data + (*ie_len), qcn_ie.version, |
| 6354 | (QCN_IE_VERSION_SUBATTR_LEN)); |
| 6355 | (*ie_len) += (QCN_IE_VERSION_SUBATTR_LEN); |
| 6356 | |
| 6357 | return QDF_STATUS_SUCCESS; |
| 6358 | } |
| 6359 | |
| 6360 | /** |
| 6361 | * wlan_hdd_save_default_scan_ies() - API to store the default scan IEs |
| 6362 | * @hdd_ctx: HDD context |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 6363 | * @adapter: Pointer to HDD adapter |
| 6364 | * @ie_data: Pointer to Scan IEs buffer |
| 6365 | * @ie_len: Length of Scan IEs |
| 6366 | * |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 6367 | * This API is used to store the default scan ies received from |
| 6368 | * supplicant. Also saves QCN IE if g_qcn_ie_support INI is enabled |
| 6369 | * |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 6370 | * Return: 0 on success; error number otherwise |
| 6371 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 6372 | 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] | 6373 | struct hdd_adapter *adapter, |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 6374 | uint8_t *ie_data, uint16_t ie_len) |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 6375 | { |
Jeff Johnson | 3758894 | 2017-08-15 16:11:41 -0700 | [diff] [blame] | 6376 | struct hdd_scan_info *scan_info = &adapter->scan_info; |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 6377 | bool add_qcn_ie = hdd_ctx->config->qcn_ie_support; |
| 6378 | |
| 6379 | if (!scan_info) |
| 6380 | return -EINVAL; |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 6381 | |
| 6382 | if (scan_info->default_scan_ies) { |
| 6383 | qdf_mem_free(scan_info->default_scan_ies); |
| 6384 | scan_info->default_scan_ies = NULL; |
| 6385 | } |
| 6386 | |
Selvaraj, Sridhar | 8048dea | 2017-04-20 10:02:19 +0530 | [diff] [blame] | 6387 | scan_info->default_scan_ies_len = ie_len; |
| 6388 | |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 6389 | if (add_qcn_ie) |
Selvaraj, Sridhar | 8048dea | 2017-04-20 10:02:19 +0530 | [diff] [blame] | 6390 | ie_len += (QCN_IE_HDR_LEN + QCN_IE_VERSION_SUBATTR_LEN); |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 6391 | |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 6392 | scan_info->default_scan_ies = qdf_mem_malloc(ie_len); |
Selvaraj, Sridhar | 8048dea | 2017-04-20 10:02:19 +0530 | [diff] [blame] | 6393 | if (!scan_info->default_scan_ies) { |
| 6394 | scan_info->default_scan_ies_len = 0; |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 6395 | return -ENOMEM; |
Selvaraj, Sridhar | 8048dea | 2017-04-20 10:02:19 +0530 | [diff] [blame] | 6396 | } |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 6397 | |
Selvaraj, Sridhar | 8048dea | 2017-04-20 10:02:19 +0530 | [diff] [blame] | 6398 | qdf_mem_copy(scan_info->default_scan_ies, ie_data, |
| 6399 | scan_info->default_scan_ies_len); |
Selvaraj, Sridhar | 021ee0a | 2017-04-07 16:53:31 +0530 | [diff] [blame] | 6400 | |
| 6401 | /* Add QCN IE if g_qcn_ie_support INI is enabled */ |
| 6402 | if (add_qcn_ie) |
| 6403 | wlan_hdd_add_qcn_ie(scan_info->default_scan_ies, |
| 6404 | &(scan_info->default_scan_ies_len)); |
| 6405 | |
| 6406 | hdd_debug("Saved default scan IE:"); |
| 6407 | qdf_trace_hex_dump(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG, |
| 6408 | (uint8_t *) scan_info->default_scan_ies, |
| 6409 | scan_info->default_scan_ies_len); |
| 6410 | |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 6411 | return 0; |
| 6412 | } |
| 6413 | |
| 6414 | /** |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 6415 | * wlan_hdd_handle_restrict_offchan_config() - |
| 6416 | * Handle wifi configuration attribute : |
| 6417 | * QCA_WLAN_VENDOR_ATTR_CONFIG_RESTRICT_OFFCHANNEL |
| 6418 | * @adapter: Pointer to HDD adapter |
| 6419 | * @restrict_offchan: Restrict offchannel setting done by |
| 6420 | * application |
| 6421 | * |
| 6422 | * Return: 0 on success; error number otherwise |
| 6423 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 6424 | 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] | 6425 | u8 restrict_offchan) |
| 6426 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 6427 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6428 | enum QDF_OPMODE dev_mode = adapter->device_mode; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 6429 | int ret_val = 0; |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 6430 | QDF_STATUS status; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 6431 | |
| 6432 | if (!(dev_mode == QDF_SAP_MODE || dev_mode == QDF_P2P_GO_MODE)) { |
| 6433 | hdd_err("Invalid interface type:%d", dev_mode); |
| 6434 | return -EINVAL; |
| 6435 | } |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 6436 | status = wlan_objmgr_vdev_try_get_ref(adapter->hdd_vdev, WLAN_OSIF_ID); |
| 6437 | if (status != QDF_STATUS_SUCCESS) { |
| 6438 | hdd_err("Access hdd_vdev failed: %d", status); |
| 6439 | return -EINVAL; |
| 6440 | } |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 6441 | if (restrict_offchan == 1) { |
| 6442 | enum policy_mgr_con_mode pmode = |
| 6443 | policy_mgr_convert_device_mode_to_qdf_type(dev_mode); |
| 6444 | int chan; |
| 6445 | |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 6446 | u32 vdev_id = wlan_vdev_get_id(adapter->hdd_vdev); |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 6447 | |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 6448 | wlan_vdev_obj_lock(adapter->hdd_vdev); |
| 6449 | wlan_vdev_mlme_cap_set(adapter->hdd_vdev, |
| 6450 | WLAN_VDEV_C_RESTRICT_OFFCHAN); |
| 6451 | wlan_vdev_obj_unlock(adapter->hdd_vdev); |
| 6452 | chan = policy_mgr_get_channel(hdd_ctx->hdd_psoc, pmode, |
| 6453 | &vdev_id); |
| 6454 | if (!chan || |
| 6455 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, chan)) { |
| 6456 | hdd_err("unable to send avoid_freq"); |
| 6457 | ret_val = -EINVAL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 6458 | } |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 6459 | hdd_info("vdev %d mode %d dnbs enabled", vdev_id, dev_mode); |
| 6460 | } else if (restrict_offchan == 0) { |
| 6461 | wlan_vdev_obj_lock(adapter->hdd_vdev); |
| 6462 | wlan_vdev_mlme_cap_clear(adapter->hdd_vdev, |
| 6463 | WLAN_VDEV_C_RESTRICT_OFFCHAN); |
| 6464 | wlan_vdev_obj_unlock(adapter->hdd_vdev); |
| 6465 | if (wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0)) { |
| 6466 | hdd_err("unable to clear avoid_freq"); |
| 6467 | ret_val = -EINVAL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 6468 | } |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 6469 | hdd_info("vdev mode %d dnbs disabled", dev_mode); |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 6470 | } else { |
| 6471 | ret_val = -EINVAL; |
| 6472 | hdd_err("Invalid RESTRICT_OFFCHAN setting"); |
| 6473 | } |
Liangwei Dong | cf5a506 | 2017-12-28 00:51:32 -0500 | [diff] [blame] | 6474 | wlan_objmgr_vdev_release_ref(adapter->hdd_vdev, WLAN_OSIF_ID); |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 6475 | return ret_val; |
| 6476 | } |
| 6477 | |
| 6478 | /** |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6479 | * wlan_hdd_cfg80211_wifi_set_reorder_timeout - set reorder timeout |
| 6480 | * |
| 6481 | * @hdd_ctx: hdd context |
| 6482 | * @tb: array of pointer to struct nlattr |
| 6483 | * |
| 6484 | * Return: 0 on success; error number otherwise |
| 6485 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 6486 | static int wlan_hdd_cfg80211_wifi_set_reorder_timeout(struct hdd_context *hdd_ctx, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6487 | struct nlattr *tb[]) |
| 6488 | { |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 6489 | int ret_val = 0; |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6490 | QDF_STATUS qdf_status; |
| 6491 | struct sir_set_rx_reorder_timeout_val reorder_timeout; |
| 6492 | |
| 6493 | #define RX_TIMEOUT_VAL_MIN 10 |
| 6494 | #define RX_TIMEOUT_VAL_MAX 1000 |
| 6495 | |
| 6496 | if (tb[RX_REORDER_TIMEOUT_VOICE] || |
| 6497 | tb[RX_REORDER_TIMEOUT_VIDEO] || |
| 6498 | tb[RX_REORDER_TIMEOUT_BESTEFFORT] || |
| 6499 | tb[RX_REORDER_TIMEOUT_BACKGROUND]) { |
| 6500 | |
| 6501 | /* if one is specified, all must be specified */ |
| 6502 | if (!tb[RX_REORDER_TIMEOUT_VOICE] || |
| 6503 | !tb[RX_REORDER_TIMEOUT_VIDEO] || |
| 6504 | !tb[RX_REORDER_TIMEOUT_BESTEFFORT] || |
| 6505 | !tb[RX_REORDER_TIMEOUT_BACKGROUND]) { |
| 6506 | hdd_err("four AC timeout val are required MAC"); |
| 6507 | return -EINVAL; |
| 6508 | } |
| 6509 | |
| 6510 | reorder_timeout.rx_timeout_pri[0] = nla_get_u32( |
| 6511 | tb[RX_REORDER_TIMEOUT_VOICE]); |
| 6512 | reorder_timeout.rx_timeout_pri[1] = nla_get_u32( |
| 6513 | tb[RX_REORDER_TIMEOUT_VIDEO]); |
| 6514 | reorder_timeout.rx_timeout_pri[2] = nla_get_u32( |
| 6515 | tb[RX_REORDER_TIMEOUT_BESTEFFORT]); |
| 6516 | reorder_timeout.rx_timeout_pri[3] = nla_get_u32( |
| 6517 | tb[RX_REORDER_TIMEOUT_BACKGROUND]); |
| 6518 | /* timeout value is required to be in the rang 10 to 1000ms */ |
| 6519 | if (reorder_timeout.rx_timeout_pri[0] >= RX_TIMEOUT_VAL_MIN && |
| 6520 | reorder_timeout.rx_timeout_pri[0] <= RX_TIMEOUT_VAL_MAX && |
| 6521 | reorder_timeout.rx_timeout_pri[1] >= RX_TIMEOUT_VAL_MIN && |
| 6522 | reorder_timeout.rx_timeout_pri[1] <= RX_TIMEOUT_VAL_MAX && |
| 6523 | reorder_timeout.rx_timeout_pri[2] >= RX_TIMEOUT_VAL_MIN && |
| 6524 | reorder_timeout.rx_timeout_pri[2] <= RX_TIMEOUT_VAL_MAX && |
| 6525 | reorder_timeout.rx_timeout_pri[3] >= RX_TIMEOUT_VAL_MIN && |
| 6526 | reorder_timeout.rx_timeout_pri[3] <= RX_TIMEOUT_VAL_MAX) { |
| 6527 | qdf_status = sme_set_reorder_timeout(hdd_ctx->hHal, |
| 6528 | &reorder_timeout); |
| 6529 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 6530 | hdd_err("failed to set reorder timeout err %d", |
| 6531 | qdf_status); |
| 6532 | ret_val = -EPERM; |
| 6533 | } |
| 6534 | } else { |
| 6535 | hdd_err("one of the timeout value is not in range"); |
| 6536 | ret_val = -EINVAL; |
| 6537 | } |
| 6538 | } |
| 6539 | |
| 6540 | return ret_val; |
| 6541 | } |
| 6542 | |
| 6543 | /** |
| 6544 | * wlan_hdd_cfg80211_wifi_set_rx_blocksize - set rx blocksize |
| 6545 | * |
| 6546 | * @hdd_ctx: hdd context |
| 6547 | * @adapter: hdd adapter |
| 6548 | * @tb: array of pointer to struct nlattr |
| 6549 | * |
| 6550 | * Return: 0 on success; error number otherwise |
| 6551 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 6552 | static int wlan_hdd_cfg80211_wifi_set_rx_blocksize(struct hdd_context *hdd_ctx, |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 6553 | struct hdd_adapter *adapter, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6554 | struct nlattr *tb[]) |
| 6555 | { |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 6556 | int ret_val = 0; |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6557 | uint32_t set_value; |
| 6558 | QDF_STATUS qdf_status; |
| 6559 | struct sir_peer_set_rx_blocksize rx_blocksize; |
| 6560 | |
| 6561 | #define WINDOW_SIZE_VAL_MIN 1 |
| 6562 | #define WINDOW_SIZE_VAL_MAX 64 |
| 6563 | |
| 6564 | if (tb[RX_BLOCKSIZE_PEER_MAC] || |
| 6565 | tb[RX_BLOCKSIZE_WINLIMIT]) { |
| 6566 | |
| 6567 | /* if one is specified, both must be specified */ |
| 6568 | if (!tb[RX_BLOCKSIZE_PEER_MAC] || |
| 6569 | !tb[RX_BLOCKSIZE_WINLIMIT]) { |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 6570 | hdd_err("Both Peer MAC and windows limit required"); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6571 | return -EINVAL; |
| 6572 | } |
| 6573 | |
| 6574 | memcpy(&rx_blocksize.peer_macaddr, |
| 6575 | nla_data(tb[RX_BLOCKSIZE_PEER_MAC]), |
| 6576 | sizeof(rx_blocksize.peer_macaddr)), |
| 6577 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6578 | rx_blocksize.vdev_id = adapter->session_id; |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6579 | set_value = nla_get_u32(tb[RX_BLOCKSIZE_WINLIMIT]); |
| 6580 | /* maximum window size is 64 */ |
| 6581 | if (set_value >= WINDOW_SIZE_VAL_MIN && |
| 6582 | set_value <= WINDOW_SIZE_VAL_MAX) { |
| 6583 | rx_blocksize.rx_block_ack_win_limit = set_value; |
| 6584 | qdf_status = sme_set_rx_set_blocksize(hdd_ctx->hHal, |
| 6585 | &rx_blocksize); |
| 6586 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 6587 | hdd_err("failed to set aggr sizes err %d", |
| 6588 | qdf_status); |
| 6589 | ret_val = -EPERM; |
| 6590 | } |
| 6591 | } else { |
| 6592 | hdd_err("window size val is not in range"); |
| 6593 | ret_val = -EINVAL; |
| 6594 | } |
| 6595 | } |
| 6596 | |
| 6597 | return ret_val; |
| 6598 | } |
| 6599 | |
Jeff Johnson | 3b2abe9 | 2017-12-15 09:03:47 -0800 | [diff] [blame] | 6600 | static int hdd_config_scan_default_ies(struct hdd_adapter *adapter, |
| 6601 | const struct nlattr *attr) |
| 6602 | { |
| 6603 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6604 | uint8_t *scan_ie; |
| 6605 | uint16_t scan_ie_len; |
| 6606 | QDF_STATUS status; |
| 6607 | |
| 6608 | if (!attr) |
| 6609 | return 0; |
| 6610 | |
| 6611 | scan_ie_len = nla_len(attr); |
| 6612 | hdd_debug("IE len %d session %d device mode %d", |
| 6613 | scan_ie_len, adapter->session_id, adapter->device_mode); |
| 6614 | |
| 6615 | if (!scan_ie_len) { |
| 6616 | hdd_err("zero-length IE prohibited"); |
| 6617 | return -EINVAL; |
| 6618 | } |
| 6619 | |
| 6620 | if (scan_ie_len > MAX_DEFAULT_SCAN_IE_LEN) { |
| 6621 | hdd_err("IE length %d exceeds max of %d", |
| 6622 | scan_ie_len, MAX_DEFAULT_SCAN_IE_LEN); |
| 6623 | return -EINVAL; |
| 6624 | } |
| 6625 | |
| 6626 | scan_ie = nla_data(attr); |
Jeff Johnson | 4933c3a | 2018-01-10 19:33:33 -0800 | [diff] [blame] | 6627 | if (!wlan_is_ie_valid(scan_ie, scan_ie_len)) { |
Jeff Johnson | 3b2abe9 | 2017-12-15 09:03:47 -0800 | [diff] [blame] | 6628 | hdd_err("Invalid default scan IEs"); |
| 6629 | return -EINVAL; |
| 6630 | } |
| 6631 | |
| 6632 | if (wlan_hdd_save_default_scan_ies(hdd_ctx, adapter, |
| 6633 | scan_ie, scan_ie_len)) |
| 6634 | hdd_err("Failed to save default scan IEs"); |
| 6635 | |
| 6636 | if (adapter->device_mode == QDF_STA_MODE) { |
| 6637 | status = sme_set_default_scan_ie(hdd_ctx->hHal, |
| 6638 | adapter->session_id, scan_ie, |
| 6639 | scan_ie_len); |
| 6640 | if (QDF_STATUS_SUCCESS != status) { |
| 6641 | hdd_err("failed to set default scan IEs in sme: %d", |
| 6642 | status); |
| 6643 | return -EPERM; |
| 6644 | } |
| 6645 | } |
| 6646 | |
| 6647 | return 0; |
| 6648 | } |
| 6649 | |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 6650 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6651 | * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration |
| 6652 | * vendor command |
| 6653 | * |
| 6654 | * @wiphy: wiphy device pointer |
| 6655 | * @wdev: wireless device pointer |
| 6656 | * @data: Vendor command data buffer |
| 6657 | * @data_len: Buffer length |
| 6658 | * |
| 6659 | * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX. |
| 6660 | * |
| 6661 | * Return: Error code. |
| 6662 | */ |
| 6663 | static int |
| 6664 | __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, |
| 6665 | struct wireless_dev *wdev, |
| 6666 | const void *data, |
| 6667 | int data_len) |
| 6668 | { |
| 6669 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 6670 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 6671 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6672 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_CONFIG_MAX + 1]; |
Jeff Johnson | 3b2abe9 | 2017-12-15 09:03:47 -0800 | [diff] [blame] | 6673 | const struct nlattr *attr; |
| 6674 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6675 | int ret_val = 0; |
Mukul Sharma | 6398b25 | 2017-05-01 17:58:12 +0530 | [diff] [blame] | 6676 | u32 modulated_dtim, override_li; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6677 | u16 stats_avg_factor; |
| 6678 | u32 guard_time; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 6679 | uint8_t set_value; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 6680 | u32 ftm_capab; |
Dustin Brown | 10a7b71 | 2016-10-07 10:31:16 -0700 | [diff] [blame] | 6681 | u8 qpower; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6682 | QDF_STATUS status; |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 6683 | int attr_len; |
| 6684 | int access_policy = 0; |
| 6685 | char vendor_ie[SIR_MAC_MAX_IE_LENGTH + 2]; |
| 6686 | bool vendor_ie_present = false, access_policy_present = false; |
Padma, Santhosh Kumar | a711967 | 2016-08-16 16:05:14 +0530 | [diff] [blame] | 6687 | struct sir_set_tx_rx_aggregation_size request; |
| 6688 | QDF_STATUS qdf_status; |
Sandeep Puligilla | 24b7aa7 | 2017-10-13 18:05:14 -0700 | [diff] [blame] | 6689 | uint8_t retry, delay, enable_flag; |
Zhang Qian | e9fd14b | 2017-03-08 11:29:00 +0800 | [diff] [blame] | 6690 | uint32_t abs_delay; |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 6691 | int param_id; |
Agrawal, Ashish | b45599a | 2016-10-27 14:55:30 +0530 | [diff] [blame] | 6692 | uint32_t tx_fail_count; |
lifeng | 907edd6 | 2017-05-12 10:10:36 +0800 | [diff] [blame] | 6693 | uint32_t ant_div_usrcfg; |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 6694 | uint32_t antdiv_enable, antdiv_chain; |
| 6695 | uint32_t antdiv_selftest, antdiv_selftest_intvl; |
Nachiket Kukade | aaf8a71 | 2017-07-27 19:15:36 +0530 | [diff] [blame] | 6696 | uint8_t bmiss_bcnt; |
Paul Zhang | 99fe884 | 2017-12-08 14:43:46 +0800 | [diff] [blame] | 6697 | uint16_t latency_level; |
Deepak Dhamdhere | b106ae5 | 2016-08-10 20:55:30 +0530 | [diff] [blame] | 6698 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 6699 | hdd_enter_dev(dev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 6700 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6701 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6702 | hdd_err("Command not allowed in FTM mode"); |
| 6703 | return -EPERM; |
| 6704 | } |
| 6705 | |
| 6706 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6707 | if (ret_val) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6708 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6709 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 6710 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_CONFIG_MAX, data, |
| 6711 | data_len, wlan_hdd_wifi_config_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6712 | hdd_err("invalid attr"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6713 | return -EINVAL; |
| 6714 | } |
| 6715 | |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 6716 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_FINE_TIME_MEASUREMENT]) { |
| 6717 | ftm_capab = nla_get_u32(tb[ |
| 6718 | QCA_WLAN_VENDOR_ATTR_CONFIG_FINE_TIME_MEASUREMENT]); |
| 6719 | hdd_ctx->config->fine_time_meas_cap = |
| 6720 | hdd_ctx->fine_time_meas_cap_target & ftm_capab; |
| 6721 | sme_update_fine_time_measurement_capab(hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6722 | adapter->session_id, |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 6723 | hdd_ctx->config->fine_time_meas_cap); |
Naveen Rawat | d2657be | 2017-10-10 14:31:23 -0700 | [diff] [blame] | 6724 | ucfg_wifi_pos_set_ftm_cap(hdd_ctx->hdd_psoc, |
Naveen Rawat | 5f040ba | 2017-03-06 12:20:25 -0800 | [diff] [blame] | 6725 | hdd_ctx->config->fine_time_meas_cap); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 6726 | hdd_debug("FTM capability: user value: 0x%x, target value: 0x%x, final value: 0x%x", |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 6727 | ftm_capab, hdd_ctx->fine_time_meas_cap_target, |
| 6728 | hdd_ctx->config->fine_time_meas_cap); |
| 6729 | } |
| 6730 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6731 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM]) { |
| 6732 | modulated_dtim = nla_get_u32( |
| 6733 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM]); |
| 6734 | |
| 6735 | status = sme_configure_modulated_dtim(hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6736 | adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6737 | modulated_dtim); |
| 6738 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6739 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6740 | ret_val = -EPERM; |
| 6741 | } |
| 6742 | |
Mukul Sharma | 6398b25 | 2017-05-01 17:58:12 +0530 | [diff] [blame] | 6743 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_LISTEN_INTERVAL]) { |
| 6744 | override_li = nla_get_u32( |
| 6745 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_LISTEN_INTERVAL]); |
| 6746 | |
| 6747 | status = sme_override_listen_interval(hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6748 | adapter->session_id, |
Mukul Sharma | 6398b25 | 2017-05-01 17:58:12 +0530 | [diff] [blame] | 6749 | override_li); |
| 6750 | |
| 6751 | if (status != QDF_STATUS_SUCCESS) |
| 6752 | ret_val = -EPERM; |
| 6753 | } |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 6754 | |
| 6755 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_LRO]) { |
| 6756 | enable_flag = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_LRO]); |
| 6757 | ret_val = hdd_lro_set_reset(hdd_ctx, adapter, |
| 6758 | enable_flag); |
| 6759 | } |
| 6760 | |
Sandeep Puligilla | 24b7aa7 | 2017-10-13 18:05:14 -0700 | [diff] [blame] | 6761 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_SCAN_ENABLE]) { |
| 6762 | enable_flag = |
| 6763 | nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_SCAN_ENABLE]); |
| 6764 | sme_set_scan_disable(hdd_ctx->hHal, !enable_flag); |
| 6765 | } |
Mukul Sharma | 6398b25 | 2017-05-01 17:58:12 +0530 | [diff] [blame] | 6766 | |
Kapil Gupta | 6213c01 | 2016-09-02 19:39:09 +0530 | [diff] [blame] | 6767 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER]) { |
| 6768 | qpower = nla_get_u8( |
| 6769 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER]); |
| 6770 | if (hdd_set_qpower_config(hdd_ctx, adapter, qpower) != 0) |
| 6771 | ret_val = -EINVAL; |
| 6772 | } |
| 6773 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6774 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR]) { |
| 6775 | stats_avg_factor = nla_get_u16( |
| 6776 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR]); |
| 6777 | status = sme_configure_stats_avg_factor(hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6778 | adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6779 | stats_avg_factor); |
| 6780 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6781 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6782 | ret_val = -EPERM; |
| 6783 | } |
| 6784 | |
| 6785 | |
| 6786 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME]) { |
| 6787 | guard_time = nla_get_u32( |
| 6788 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME]); |
| 6789 | status = sme_configure_guard_time(hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6790 | adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6791 | guard_time); |
| 6792 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6793 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6794 | ret_val = -EPERM; |
| 6795 | } |
| 6796 | |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 6797 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY_IE_LIST]) { |
| 6798 | qdf_mem_zero(&vendor_ie[0], SIR_MAC_MAX_IE_LENGTH + 2); |
| 6799 | attr_len = nla_len( |
| 6800 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY_IE_LIST]); |
| 6801 | if (attr_len < 0 || attr_len > SIR_MAC_MAX_IE_LENGTH + 2) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 6802 | hdd_err("Invalid value. attr_len %d", |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 6803 | attr_len); |
| 6804 | return -EINVAL; |
| 6805 | } |
| 6806 | |
| 6807 | nla_memcpy(&vendor_ie, |
| 6808 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY_IE_LIST], |
| 6809 | attr_len); |
| 6810 | vendor_ie_present = true; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 6811 | hdd_debug("Access policy vendor ie present.attr_len %d", |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 6812 | attr_len); |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 6813 | } |
| 6814 | |
| 6815 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY]) { |
| 6816 | access_policy = (int) nla_get_u32( |
| 6817 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY]); |
| 6818 | if ((access_policy < QCA_ACCESS_POLICY_ACCEPT_UNLESS_LISTED) || |
| 6819 | (access_policy > |
| 6820 | QCA_ACCESS_POLICY_DENY_UNLESS_LISTED)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 6821 | hdd_err("Invalid value. access_policy %d", |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 6822 | access_policy); |
| 6823 | return -EINVAL; |
| 6824 | } |
| 6825 | access_policy_present = true; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 6826 | hdd_debug("Access policy present. access_policy %d", |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 6827 | access_policy); |
| 6828 | } |
| 6829 | |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 6830 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_NON_AGG_RETRY]) { |
| 6831 | retry = nla_get_u8(tb[ |
| 6832 | QCA_WLAN_VENDOR_ATTR_CONFIG_NON_AGG_RETRY]); |
| 6833 | retry = retry > CFG_NON_AGG_RETRY_MAX ? |
| 6834 | CFG_NON_AGG_RETRY_MAX : retry; |
| 6835 | param_id = WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6836 | ret_val = wma_cli_set_command(adapter->session_id, param_id, |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 6837 | retry, PDEV_CMD); |
| 6838 | } |
| 6839 | |
| 6840 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_AGG_RETRY]) { |
| 6841 | retry = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_AGG_RETRY]); |
| 6842 | retry = retry > CFG_AGG_RETRY_MAX ? |
| 6843 | CFG_AGG_RETRY_MAX : retry; |
| 6844 | |
| 6845 | /* Value less than CFG_AGG_RETRY_MIN has side effect to t-put */ |
| 6846 | retry = ((retry > 0) && (retry < CFG_AGG_RETRY_MIN)) ? |
| 6847 | CFG_AGG_RETRY_MIN : retry; |
| 6848 | param_id = WMI_PDEV_PARAM_AGG_SW_RETRY_TH; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6849 | ret_val = wma_cli_set_command(adapter->session_id, param_id, |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 6850 | retry, PDEV_CMD); |
| 6851 | } |
| 6852 | |
| 6853 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_MGMT_RETRY]) { |
| 6854 | retry = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_MGMT_RETRY]); |
| 6855 | retry = retry > CFG_MGMT_RETRY_MAX ? |
| 6856 | CFG_MGMT_RETRY_MAX : retry; |
| 6857 | param_id = WMI_PDEV_PARAM_MGMT_RETRY_LIMIT; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6858 | ret_val = wma_cli_set_command(adapter->session_id, param_id, |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 6859 | retry, PDEV_CMD); |
| 6860 | } |
| 6861 | |
| 6862 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_CTRL_RETRY]) { |
| 6863 | retry = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_CTRL_RETRY]); |
| 6864 | retry = retry > CFG_CTRL_RETRY_MAX ? |
| 6865 | CFG_CTRL_RETRY_MAX : retry; |
| 6866 | param_id = WMI_PDEV_PARAM_CTRL_RETRY_LIMIT; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6867 | ret_val = wma_cli_set_command(adapter->session_id, param_id, |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 6868 | retry, PDEV_CMD); |
| 6869 | } |
| 6870 | |
| 6871 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_DELAY]) { |
| 6872 | delay = nla_get_u8(tb[ |
| 6873 | QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_DELAY]); |
| 6874 | delay = delay > CFG_PROPAGATION_DELAY_MAX ? |
| 6875 | CFG_PROPAGATION_DELAY_MAX : delay; |
Zhang Qian | e9fd14b | 2017-03-08 11:29:00 +0800 | [diff] [blame] | 6876 | abs_delay = delay + CFG_PROPAGATION_DELAY_BASE; |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 6877 | param_id = WMI_PDEV_PARAM_PROPAGATION_DELAY; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6878 | ret_val = wma_cli_set_command(adapter->session_id, param_id, |
Zhang Qian | e9fd14b | 2017-03-08 11:29:00 +0800 | [diff] [blame] | 6879 | abs_delay, PDEV_CMD); |
| 6880 | } |
| 6881 | |
| 6882 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_ABS_DELAY]) { |
| 6883 | abs_delay = nla_get_u8(tb[ |
| 6884 | QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_ABS_DELAY]); |
| 6885 | param_id = WMI_PDEV_PARAM_PROPAGATION_DELAY; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6886 | ret_val = wma_cli_set_command(adapter->session_id, param_id, |
Zhang Qian | e9fd14b | 2017-03-08 11:29:00 +0800 | [diff] [blame] | 6887 | abs_delay, PDEV_CMD); |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 6888 | } |
| 6889 | |
Agrawal, Ashish | b45599a | 2016-10-27 14:55:30 +0530 | [diff] [blame] | 6890 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_FAIL_COUNT]) { |
| 6891 | tx_fail_count = nla_get_u32( |
| 6892 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_FAIL_COUNT]); |
| 6893 | if (tx_fail_count) { |
| 6894 | status = sme_update_tx_fail_cnt_threshold(hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6895 | adapter->session_id, tx_fail_count); |
Agrawal, Ashish | b45599a | 2016-10-27 14:55:30 +0530 | [diff] [blame] | 6896 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 6897 | hdd_err("sme_update_tx_fail_cnt_threshold (err=%d)", |
Agrawal, Ashish | b45599a | 2016-10-27 14:55:30 +0530 | [diff] [blame] | 6898 | status); |
| 6899 | return -EINVAL; |
| 6900 | } |
| 6901 | } |
| 6902 | } |
| 6903 | |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 6904 | if (vendor_ie_present && access_policy_present) { |
| 6905 | if (access_policy == QCA_ACCESS_POLICY_DENY_UNLESS_LISTED) { |
| 6906 | access_policy = |
| 6907 | WLAN_HDD_VENDOR_IE_ACCESS_ALLOW_IF_LISTED; |
Selvaraj, Sridhar | ac4fcf3 | 2016-09-28 12:57:32 +0530 | [diff] [blame] | 6908 | } else { |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 6909 | access_policy = WLAN_HDD_VENDOR_IE_ACCESS_NONE; |
Selvaraj, Sridhar | ac4fcf3 | 2016-09-28 12:57:32 +0530 | [diff] [blame] | 6910 | } |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 6911 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 6912 | hdd_debug("calling sme_update_access_policy_vendor_ie"); |
Selvaraj, Sridhar | ac4fcf3 | 2016-09-28 12:57:32 +0530 | [diff] [blame] | 6913 | status = sme_update_access_policy_vendor_ie(hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6914 | adapter->session_id, &vendor_ie[0], |
Selvaraj, Sridhar | ac4fcf3 | 2016-09-28 12:57:32 +0530 | [diff] [blame] | 6915 | access_policy); |
| 6916 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 6917 | hdd_err("Failed to set vendor ie and access policy."); |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 6918 | return -EINVAL; |
| 6919 | } |
| 6920 | } |
| 6921 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 6922 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_CHANNEL_AVOIDANCE_IND]) { |
| 6923 | set_value = nla_get_u8( |
| 6924 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_CHANNEL_AVOIDANCE_IND]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 6925 | hdd_debug("set_value: %d", set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 6926 | ret_val = hdd_enable_disable_ca_event(hdd_ctx, set_value); |
| 6927 | } |
| 6928 | |
Jeff Johnson | 3b2abe9 | 2017-12-15 09:03:47 -0800 | [diff] [blame] | 6929 | attr = tb[QCA_WLAN_VENDOR_ATTR_CONFIG_SCAN_DEFAULT_IES]; |
| 6930 | ret = hdd_config_scan_default_ies(adapter, attr); |
| 6931 | if (ret) |
| 6932 | ret_val = ret; |
Padma, Santhosh Kumar | a711967 | 2016-08-16 16:05:14 +0530 | [diff] [blame] | 6933 | |
| 6934 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_MPDU_AGGREGATION] || |
| 6935 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RX_MPDU_AGGREGATION]) { |
| 6936 | /* if one is specified, both must be specified */ |
| 6937 | if (!tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_MPDU_AGGREGATION] || |
| 6938 | !tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RX_MPDU_AGGREGATION]) { |
| 6939 | hdd_err("Both TX and RX MPDU Aggregation required"); |
| 6940 | return -EINVAL; |
| 6941 | } |
| 6942 | |
| 6943 | request.tx_aggregation_size = nla_get_u8( |
| 6944 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_MPDU_AGGREGATION]); |
| 6945 | request.rx_aggregation_size = nla_get_u8( |
| 6946 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RX_MPDU_AGGREGATION]); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6947 | request.vdev_id = adapter->session_id; |
Padma, Santhosh Kumar | a711967 | 2016-08-16 16:05:14 +0530 | [diff] [blame] | 6948 | |
| 6949 | if (request.tx_aggregation_size >= |
| 6950 | CFG_TX_AGGREGATION_SIZE_MIN && |
| 6951 | request.tx_aggregation_size <= |
| 6952 | CFG_TX_AGGREGATION_SIZE_MAX && |
| 6953 | request.rx_aggregation_size >= |
| 6954 | CFG_RX_AGGREGATION_SIZE_MIN && |
| 6955 | request.rx_aggregation_size <= |
| 6956 | CFG_RX_AGGREGATION_SIZE_MAX) { |
| 6957 | qdf_status = wma_set_tx_rx_aggregation_size(&request); |
| 6958 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 6959 | hdd_err("failed to set aggr sizes err %d", |
| 6960 | qdf_status); |
| 6961 | ret_val = -EPERM; |
| 6962 | } |
| 6963 | } else { |
| 6964 | hdd_err("TX %d RX %d MPDU aggr size not in range", |
| 6965 | request.tx_aggregation_size, |
| 6966 | request.rx_aggregation_size); |
| 6967 | ret_val = -EINVAL; |
| 6968 | } |
| 6969 | } |
| 6970 | |
Selvaraj, Sridhar | ac4fcf3 | 2016-09-28 12:57:32 +0530 | [diff] [blame] | 6971 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_IGNORE_ASSOC_DISALLOWED]) { |
| 6972 | uint8_t ignore_assoc_disallowed; |
| 6973 | |
| 6974 | ignore_assoc_disallowed |
| 6975 | = nla_get_u8(tb[ |
| 6976 | QCA_WLAN_VENDOR_ATTR_CONFIG_IGNORE_ASSOC_DISALLOWED]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 6977 | hdd_debug("Set ignore_assoc_disallowed value - %d", |
Selvaraj, Sridhar | ac4fcf3 | 2016-09-28 12:57:32 +0530 | [diff] [blame] | 6978 | ignore_assoc_disallowed); |
| 6979 | if ((ignore_assoc_disallowed < |
| 6980 | QCA_IGNORE_ASSOC_DISALLOWED_DISABLE) || |
| 6981 | (ignore_assoc_disallowed > |
| 6982 | QCA_IGNORE_ASSOC_DISALLOWED_ENABLE)) |
| 6983 | return -EPERM; |
| 6984 | |
| 6985 | sme_update_session_param(hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6986 | adapter->session_id, |
Selvaraj, Sridhar | ac4fcf3 | 2016-09-28 12:57:32 +0530 | [diff] [blame] | 6987 | SIR_PARAM_IGNORE_ASSOC_DISALLOWED, |
| 6988 | ignore_assoc_disallowed); |
| 6989 | } |
| 6990 | |
lifeng | 907edd6 | 2017-05-12 10:10:36 +0800 | [diff] [blame] | 6991 | #define ANT_DIV_SET_PERIOD(probe_period, stay_period) \ |
| 6992 | ((1<<26)|((probe_period&0x1fff)<<13)|(stay_period&0x1fff)) |
| 6993 | |
| 6994 | #define ANT_DIV_SET_SNR_DIFF(snr_diff) \ |
| 6995 | ((1<<27)|(snr_diff&0x1fff)) |
| 6996 | |
| 6997 | #define ANT_DIV_SET_PROBE_DWELL_TIME(probe_dwell_time) \ |
| 6998 | ((1<<28)|(probe_dwell_time&0x1fff)) |
| 6999 | |
| 7000 | #define ANT_DIV_SET_WEIGHT(mgmt_snr_weight, data_snr_weight, ack_snr_weight) \ |
| 7001 | ((1<<29)|((mgmt_snr_weight&0xff)<<16)|((data_snr_weight&0xff)<<8)| \ |
| 7002 | (ack_snr_weight&0xff)) |
| 7003 | |
| 7004 | if (tb[ANT_DIV_PROBE_PERIOD] || |
| 7005 | tb[ANT_DIV_STAY_PERIOD]) { |
| 7006 | |
| 7007 | if (!tb[ANT_DIV_PROBE_PERIOD] || |
| 7008 | !tb[ANT_DIV_STAY_PERIOD]) { |
| 7009 | hdd_err("Both probe and stay period required"); |
| 7010 | return -EINVAL; |
| 7011 | } |
| 7012 | |
| 7013 | ant_div_usrcfg = ANT_DIV_SET_PERIOD( |
| 7014 | nla_get_u32(tb[ANT_DIV_PROBE_PERIOD]), |
| 7015 | nla_get_u32(tb[ANT_DIV_STAY_PERIOD])); |
| 7016 | hdd_debug("ant div set period: %x", ant_div_usrcfg); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7017 | ret_val = wma_cli_set_command((int)adapter->session_id, |
lifeng | 907edd6 | 2017-05-12 10:10:36 +0800 | [diff] [blame] | 7018 | (int)WMI_PDEV_PARAM_ANT_DIV_USRCFG, |
| 7019 | ant_div_usrcfg, PDEV_CMD); |
| 7020 | if (ret_val) { |
| 7021 | hdd_err("Failed to set ant div period"); |
| 7022 | return ret_val; |
| 7023 | } |
| 7024 | } |
| 7025 | |
| 7026 | if (tb[ANT_DIV_SNR_DIFF]) { |
| 7027 | ant_div_usrcfg = ANT_DIV_SET_SNR_DIFF( |
| 7028 | nla_get_u32(tb[ANT_DIV_SNR_DIFF])); |
| 7029 | hdd_debug("ant div set snr diff: %x", ant_div_usrcfg); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7030 | ret_val = wma_cli_set_command((int)adapter->session_id, |
lifeng | 907edd6 | 2017-05-12 10:10:36 +0800 | [diff] [blame] | 7031 | (int)WMI_PDEV_PARAM_ANT_DIV_USRCFG, |
| 7032 | ant_div_usrcfg, PDEV_CMD); |
| 7033 | if (ret_val) { |
| 7034 | hdd_err("Failed to set ant snr diff"); |
| 7035 | return ret_val; |
| 7036 | } |
| 7037 | } |
| 7038 | |
| 7039 | if (tb[ANT_DIV_PROBE_DWELL_TIME]) { |
| 7040 | ant_div_usrcfg = ANT_DIV_SET_PROBE_DWELL_TIME( |
| 7041 | nla_get_u32(tb[ANT_DIV_PROBE_DWELL_TIME])); |
| 7042 | hdd_debug("ant div set probe dewll time: %x", |
| 7043 | ant_div_usrcfg); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7044 | ret_val = wma_cli_set_command((int)adapter->session_id, |
lifeng | 907edd6 | 2017-05-12 10:10:36 +0800 | [diff] [blame] | 7045 | (int)WMI_PDEV_PARAM_ANT_DIV_USRCFG, |
| 7046 | ant_div_usrcfg, PDEV_CMD); |
| 7047 | if (ret_val) { |
| 7048 | hdd_err("Failed to set ant div probe dewll time"); |
| 7049 | return ret_val; |
| 7050 | } |
| 7051 | } |
| 7052 | |
| 7053 | if (tb[ANT_DIV_MGMT_SNR_WEIGHT] || |
| 7054 | tb[ANT_DIV_DATA_SNR_WEIGHT] || |
| 7055 | tb[ANT_DIV_ACK_SNR_WEIGHT]) { |
| 7056 | |
| 7057 | if (!tb[ANT_DIV_MGMT_SNR_WEIGHT] || |
| 7058 | !tb[ANT_DIV_DATA_SNR_WEIGHT] || |
| 7059 | !tb[ANT_DIV_ACK_SNR_WEIGHT]) { |
| 7060 | hdd_err("Mgmt snr, data snr and ack snr weight are required"); |
| 7061 | return -EINVAL; |
| 7062 | } |
| 7063 | |
| 7064 | ant_div_usrcfg = ANT_DIV_SET_WEIGHT( |
| 7065 | nla_get_u32(tb[ANT_DIV_MGMT_SNR_WEIGHT]), |
| 7066 | nla_get_u32(tb[ANT_DIV_DATA_SNR_WEIGHT]), |
| 7067 | nla_get_u32(tb[ANT_DIV_ACK_SNR_WEIGHT])); |
| 7068 | hdd_debug("ant div set weight: %x", ant_div_usrcfg); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7069 | ret_val = wma_cli_set_command((int)adapter->session_id, |
lifeng | 907edd6 | 2017-05-12 10:10:36 +0800 | [diff] [blame] | 7070 | (int)WMI_PDEV_PARAM_ANT_DIV_USRCFG, |
| 7071 | ant_div_usrcfg, PDEV_CMD); |
| 7072 | if (ret_val) { |
| 7073 | hdd_err("Failed to set ant div weight"); |
| 7074 | return ret_val; |
| 7075 | } |
| 7076 | } |
| 7077 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 7078 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RESTRICT_OFFCHANNEL]) { |
| 7079 | u8 restrict_offchan = nla_get_u8( |
| 7080 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RESTRICT_OFFCHANNEL]); |
| 7081 | |
| 7082 | hdd_debug("Restrict offchannel:%d", restrict_offchan); |
| 7083 | if (restrict_offchan <= 1) |
| 7084 | ret_val = |
| 7085 | wlan_hdd_handle_restrict_offchan_config(adapter, |
| 7086 | restrict_offchan); |
| 7087 | else { |
| 7088 | ret_val = -EINVAL; |
| 7089 | hdd_err("Invalid RESTRICT_OFFCHAN setting"); |
| 7090 | } |
| 7091 | } |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 7092 | |
| 7093 | ret_val = |
| 7094 | wlan_hdd_cfg80211_wifi_set_reorder_timeout(hdd_ctx, tb); |
| 7095 | if (ret_val != 0) |
| 7096 | return ret_val; |
| 7097 | |
| 7098 | ret_val = |
| 7099 | wlan_hdd_cfg80211_wifi_set_rx_blocksize(hdd_ctx, adapter, tb); |
| 7100 | if (ret_val != 0) |
| 7101 | return ret_val; |
| 7102 | |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 7103 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_ENA]) { |
| 7104 | antdiv_enable = nla_get_u32( |
| 7105 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_ENA]); |
| 7106 | hdd_debug("antdiv_enable: %d", antdiv_enable); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7107 | ret_val = wma_cli_set_command((int)adapter->session_id, |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 7108 | (int)WMI_PDEV_PARAM_ENA_ANT_DIV, |
| 7109 | antdiv_enable, PDEV_CMD); |
| 7110 | if (ret_val) { |
| 7111 | hdd_err("Failed to set antdiv_enable"); |
| 7112 | return ret_val; |
| 7113 | } |
| 7114 | } |
| 7115 | |
| 7116 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_CHAIN]) { |
| 7117 | antdiv_chain = nla_get_u32( |
| 7118 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_CHAIN]); |
| 7119 | hdd_debug("antdiv_chain: %d", antdiv_chain); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7120 | ret_val = wma_cli_set_command((int)adapter->session_id, |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 7121 | (int)WMI_PDEV_PARAM_FORCE_CHAIN_ANT, |
| 7122 | antdiv_chain, PDEV_CMD); |
| 7123 | if (ret_val) { |
| 7124 | hdd_err("Failed to set antdiv_chain"); |
| 7125 | return ret_val; |
| 7126 | } |
| 7127 | } |
| 7128 | |
| 7129 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SELFTEST]) { |
| 7130 | antdiv_selftest = nla_get_u32( |
| 7131 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SELFTEST]); |
| 7132 | hdd_debug("antdiv_selftest: %d", antdiv_selftest); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7133 | ret_val = wma_cli_set_command((int)adapter->session_id, |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 7134 | (int)WMI_PDEV_PARAM_ANT_DIV_SELFTEST, |
| 7135 | antdiv_selftest, PDEV_CMD); |
| 7136 | if (ret_val) { |
| 7137 | hdd_err("Failed to set antdiv_selftest"); |
| 7138 | return ret_val; |
| 7139 | } |
| 7140 | } |
| 7141 | |
| 7142 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SELFTEST_INTVL]) { |
| 7143 | antdiv_selftest_intvl = nla_get_u32( |
| 7144 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ANT_DIV_SELFTEST_INTVL]); |
| 7145 | hdd_debug("antdiv_selftest_intvl: %d", |
| 7146 | antdiv_selftest_intvl); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7147 | ret_val = wma_cli_set_command((int)adapter->session_id, |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 7148 | (int)WMI_PDEV_PARAM_ANT_DIV_SELFTEST_INTVL, |
| 7149 | antdiv_selftest_intvl, PDEV_CMD); |
| 7150 | if (ret_val) { |
| 7151 | hdd_err("Failed to set antdiv_selftest_intvl"); |
| 7152 | return ret_val; |
| 7153 | } |
| 7154 | } |
| 7155 | |
Nachiket Kukade | aaf8a71 | 2017-07-27 19:15:36 +0530 | [diff] [blame] | 7156 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TOTAL_BEACON_MISS_COUNT]) { |
| 7157 | bmiss_bcnt = nla_get_u8( |
| 7158 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TOTAL_BEACON_MISS_COUNT]); |
| 7159 | if (hdd_ctx->config->nRoamBmissFirstBcnt < bmiss_bcnt) { |
| 7160 | hdd_ctx->config->nRoamBmissFinalBcnt = bmiss_bcnt |
| 7161 | - hdd_ctx->config->nRoamBmissFirstBcnt; |
| 7162 | hdd_debug("Bmiss first cnt(%d), Bmiss final cnt(%d)", |
| 7163 | hdd_ctx->config->nRoamBmissFirstBcnt, |
| 7164 | hdd_ctx->config->nRoamBmissFinalBcnt); |
| 7165 | ret_val = sme_set_roam_bmiss_final_bcnt(hdd_ctx->hHal, |
| 7166 | 0, hdd_ctx->config->nRoamBmissFinalBcnt); |
| 7167 | |
| 7168 | if (ret_val) { |
| 7169 | hdd_err("Failed to set bmiss final Bcnt"); |
| 7170 | return ret_val; |
| 7171 | } |
| 7172 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7173 | ret_val = sme_set_bmiss_bcnt(adapter->session_id, |
Nachiket Kukade | aaf8a71 | 2017-07-27 19:15:36 +0530 | [diff] [blame] | 7174 | hdd_ctx->config->nRoamBmissFirstBcnt, |
| 7175 | hdd_ctx->config->nRoamBmissFinalBcnt); |
| 7176 | if (ret_val) { |
| 7177 | hdd_err("Failed to set bmiss Bcnt"); |
| 7178 | return ret_val; |
| 7179 | } |
| 7180 | } else { |
| 7181 | hdd_err("Bcnt(%d) needs to exceed BmissFirstBcnt(%d)", |
| 7182 | bmiss_bcnt, |
| 7183 | hdd_ctx->config->nRoamBmissFirstBcnt); |
| 7184 | return -EINVAL; |
| 7185 | } |
| 7186 | } |
Paul Zhang | 99fe884 | 2017-12-08 14:43:46 +0800 | [diff] [blame] | 7187 | |
| 7188 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL]) { |
| 7189 | latency_level = nla_get_u16( |
| 7190 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL]); |
| 7191 | |
| 7192 | if ((latency_level > |
| 7193 | QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL_MAX) || |
| 7194 | (latency_level == |
| 7195 | QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL_INVALID)) { |
| 7196 | hdd_err("Invalid Wlan latency level value"); |
| 7197 | return -EINVAL; |
| 7198 | } |
| 7199 | |
| 7200 | /* Mapping the latency value to the level which fw expected |
| 7201 | * 0 - normal, 1 - moderate, 2 - low, 3 - ultralow |
| 7202 | */ |
| 7203 | latency_level = latency_level - 1; |
| 7204 | qdf_status = sme_set_wlm_latency_level(hdd_ctx->hHal, |
| 7205 | adapter->session_id, |
| 7206 | latency_level); |
| 7207 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 7208 | hdd_err("set Wlan latency level failed"); |
| 7209 | ret_val = -EINVAL; |
| 7210 | } |
| 7211 | } |
| 7212 | |
Vignesh Viswanathan | 32761e4 | 2017-09-25 17:10:54 +0530 | [diff] [blame] | 7213 | if (adapter->device_mode == QDF_STA_MODE && |
| 7214 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_DISABLE_FILS]) { |
| 7215 | uint8_t disable_fils; |
| 7216 | |
| 7217 | disable_fils = nla_get_u8(tb[ |
| 7218 | QCA_WLAN_VENDOR_ATTR_CONFIG_DISABLE_FILS]); |
| 7219 | hdd_debug("Set disable_fils - %d", disable_fils); |
| 7220 | |
| 7221 | qdf_status = sme_update_fils_setting(hdd_ctx->hHal, |
| 7222 | adapter->session_id, |
| 7223 | disable_fils); |
| 7224 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 7225 | hdd_err("set disable_fils failed"); |
| 7226 | ret_val = -EINVAL; |
| 7227 | } |
| 7228 | } |
Nachiket Kukade | aaf8a71 | 2017-07-27 19:15:36 +0530 | [diff] [blame] | 7229 | |
Abhishek Singh | 6454ad3 | 2017-12-20 10:42:21 +0530 | [diff] [blame] | 7230 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE] && |
| 7231 | hdd_ctx->config->force_rsne_override) { |
| 7232 | uint8_t force_rsne_override; |
| 7233 | |
| 7234 | force_rsne_override = |
| 7235 | nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE]); |
| 7236 | if (force_rsne_override > 1) { |
| 7237 | hdd_err("Invalid test_mode %d", force_rsne_override); |
| 7238 | ret_val = -EINVAL; |
| 7239 | } |
| 7240 | |
| 7241 | hdd_ctx->force_rsne_override = force_rsne_override; |
| 7242 | hdd_debug("force_rsne_override - %d", |
| 7243 | hdd_ctx->force_rsne_override); |
| 7244 | } |
| 7245 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7246 | return ret_val; |
| 7247 | } |
| 7248 | |
| 7249 | /** |
| 7250 | * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration |
| 7251 | * vendor command |
| 7252 | * |
| 7253 | * @wiphy: wiphy device pointer |
| 7254 | * @wdev: wireless device pointer |
| 7255 | * @data: Vendor command data buffer |
| 7256 | * @data_len: Buffer length |
| 7257 | * |
| 7258 | * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX. |
| 7259 | * |
| 7260 | * Return: EOK or other error codes. |
| 7261 | */ |
| 7262 | static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, |
| 7263 | struct wireless_dev *wdev, |
| 7264 | const void *data, |
| 7265 | int data_len) |
| 7266 | { |
| 7267 | int ret; |
| 7268 | |
| 7269 | cds_ssr_protect(__func__); |
| 7270 | ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev, |
| 7271 | data, data_len); |
| 7272 | cds_ssr_unprotect(__func__); |
| 7273 | |
| 7274 | return ret; |
| 7275 | } |
| 7276 | |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7277 | /** |
| 7278 | * __wlan_hdd_cfg80211_set_wifi_test_config() - Wifi test configuration |
| 7279 | * vendor command |
| 7280 | * |
| 7281 | * @wiphy: wiphy device pointer |
| 7282 | * @wdev: wireless device pointer |
| 7283 | * @data: Vendor command data buffer |
| 7284 | * @data_len: Buffer length |
| 7285 | * |
| 7286 | * Handles QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_MAX |
| 7287 | * |
| 7288 | * Return: Error code. |
| 7289 | */ |
| 7290 | static int |
| 7291 | __wlan_hdd_cfg80211_set_wifi_test_config(struct wiphy *wiphy, |
| 7292 | struct wireless_dev *wdev, const void *data, int data_len) { |
| 7293 | |
| 7294 | struct net_device *dev = wdev->netdev; |
| 7295 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7296 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 7297 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_MAX + 1]; |
| 7298 | int ret_val = 0; |
| 7299 | uint8_t cfg_val = 0; |
Kiran Kumar Lokere | a934561 | 2018-02-08 14:28:24 -0800 | [diff] [blame] | 7300 | uint8_t set_val = 0; |
Krunal Soni | 707eb78 | 2018-01-18 12:04:19 -0800 | [diff] [blame] | 7301 | tSmeConfigParams *sme_config; |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 7302 | bool update_sme_cfg = false; |
Kiran Kumar Lokere | 3324f63 | 2018-03-01 21:43:21 -0800 | [diff] [blame] | 7303 | uint8_t tid = 0, ac; |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 7304 | uint16_t buff_size = 0; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7305 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 7306 | hdd_enter_dev(dev); |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7307 | |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 7308 | sme_config = qdf_mem_malloc(sizeof(*sme_config)); |
| 7309 | if (!sme_config) { |
| 7310 | hdd_err("mem alloc failed for sme_config"); |
| 7311 | return -ENOMEM; |
| 7312 | } |
| 7313 | sme_get_config_param(hdd_ctx->hHal, sme_config); |
| 7314 | |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7315 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 7316 | hdd_err("Command not allowed in FTM mode"); |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 7317 | ret_val = -EPERM; |
| 7318 | goto send_err; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7319 | } |
| 7320 | |
| 7321 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 7322 | if (ret_val) |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 7323 | goto send_err; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7324 | |
| 7325 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 7326 | hdd_err("Driver Modules are closed, can not start logger"); |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 7327 | ret_val = -EINVAL; |
| 7328 | goto send_err; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7329 | } |
| 7330 | |
| 7331 | if (wlan_cfg80211_nla_parse(tb, |
| 7332 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_MAX, |
| 7333 | data, data_len, wlan_hdd_wifi_test_config_policy)) { |
| 7334 | hdd_err("invalid attr"); |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 7335 | ret_val = -EINVAL; |
| 7336 | goto send_err; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7337 | } |
| 7338 | |
| 7339 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ACCEPT_ADDBA_REQ]) { |
| 7340 | cfg_val = nla_get_u8(tb[ |
| 7341 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ACCEPT_ADDBA_REQ] |
| 7342 | ); |
| 7343 | hdd_debug("set addba accept req from peer value %d", cfg_val); |
| 7344 | ret_val = sme_set_addba_accept(hdd_ctx->hHal, |
| 7345 | adapter->session_id, cfg_val); |
| 7346 | if (ret_val) |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 7347 | goto send_err; |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7348 | } |
| 7349 | |
Kiran Kumar Lokere | 96246e5 | 2018-01-24 16:44:35 -0800 | [diff] [blame] | 7350 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_MCS]) { |
| 7351 | cfg_val = nla_get_u8(tb[ |
| 7352 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_MCS]); |
| 7353 | hdd_debug("set HE MCS value 0x%0X", cfg_val); |
| 7354 | ret_val = sme_update_he_mcs(hdd_ctx->hHal, adapter->session_id, |
| 7355 | cfg_val); |
| 7356 | if (ret_val) |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 7357 | goto send_err; |
Kiran Kumar Lokere | 96246e5 | 2018-01-24 16:44:35 -0800 | [diff] [blame] | 7358 | } |
| 7359 | |
Krunal Soni | 707eb78 | 2018-01-18 12:04:19 -0800 | [diff] [blame] | 7360 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WMM_ENABLE]) { |
| 7361 | cfg_val = nla_get_u8(tb[ |
| 7362 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WMM_ENABLE]); |
Krunal Soni | 707eb78 | 2018-01-18 12:04:19 -0800 | [diff] [blame] | 7363 | if (!cfg_val) { |
| 7364 | sme_config->csrConfig.WMMSupportMode = |
| 7365 | hdd_to_csr_wmm_mode(HDD_WMM_USER_MODE_NO_QOS); |
| 7366 | hdd_debug("wmm is disabled"); |
| 7367 | } else { |
| 7368 | sme_config->csrConfig.WMMSupportMode = |
| 7369 | hdd_to_csr_wmm_mode(hdd_ctx->config->WmmMode); |
| 7370 | hdd_debug("using wmm default value"); |
| 7371 | } |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 7372 | update_sme_cfg = true; |
Krunal Soni | 707eb78 | 2018-01-18 12:04:19 -0800 | [diff] [blame] | 7373 | } |
| 7374 | |
Kiran Kumar Lokere | a934561 | 2018-02-08 14:28:24 -0800 | [diff] [blame] | 7375 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_SEND_ADDBA_REQ]) { |
| 7376 | cfg_val = nla_get_u8(tb[ |
| 7377 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_SEND_ADDBA_REQ]); |
| 7378 | if (cfg_val) { |
| 7379 | /*Auto BA mode*/ |
| 7380 | set_val = 0; |
| 7381 | hdd_debug("BA operating mode is set to auto"); |
| 7382 | } else { |
| 7383 | /*Manual BA mode*/ |
| 7384 | set_val = 1; |
| 7385 | hdd_debug("BA operating mode is set to Manual"); |
| 7386 | } |
| 7387 | |
| 7388 | ret_val = wma_cli_set_command(adapter->session_id, |
| 7389 | WMI_VDEV_PARAM_BA_MODE, set_val, VDEV_CMD); |
| 7390 | } |
| 7391 | |
Kiran Kumar Lokere | 5cc2f0d | 2018-02-08 17:10:05 -0800 | [diff] [blame] | 7392 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_FRAGMENTATION]) { |
| 7393 | cfg_val = nla_get_u8(tb[ |
| 7394 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_FRAGMENTATION] |
| 7395 | ); |
| 7396 | if (cfg_val > HE_FRAG_LEVEL1) |
| 7397 | set_val = HE_FRAG_LEVEL1; |
| 7398 | else |
| 7399 | set_val = cfg_val; |
| 7400 | |
| 7401 | hdd_debug("set HE fragmention to %d", set_val); |
| 7402 | ret_val = sme_update_he_frag_supp(hdd_ctx->hHal, |
| 7403 | adapter->session_id, set_val); |
| 7404 | } |
| 7405 | |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 7406 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WEP_TKIP_IN_HE]) { |
| 7407 | cfg_val = nla_get_u8(tb[ |
| 7408 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_WEP_TKIP_IN_HE]); |
| 7409 | sme_config->csrConfig.wep_tkip_in_he = cfg_val; |
| 7410 | hdd_debug("Set WEP/TKIP allow in HE %d", cfg_val); |
| 7411 | |
| 7412 | update_sme_cfg = true; |
| 7413 | } |
| 7414 | |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 7415 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADD_DEL_BA_SESSION]) { |
| 7416 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_BA_TID]) { |
| 7417 | tid = nla_get_u8(tb[ |
| 7418 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_BA_TID]); |
| 7419 | } else { |
| 7420 | hdd_err("TID is not set for ADD/DEL BA cfg"); |
| 7421 | ret_val = -EINVAL; |
| 7422 | goto send_err; |
| 7423 | } |
| 7424 | cfg_val = nla_get_u8(tb[ |
| 7425 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADD_DEL_BA_SESSION]); |
| 7426 | if (cfg_val == QCA_WLAN_ADD_BA) { |
| 7427 | if (tb[ |
| 7428 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADDBA_BUFF_SIZE]) |
| 7429 | buff_size = nla_get_u8(tb[ |
| 7430 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADDBA_BUFF_SIZE]); |
| 7431 | ret_val = sme_send_addba_req(hdd_ctx->hHal, |
| 7432 | adapter->session_id, tid, buff_size); |
| 7433 | } else if (cfg_val == QCA_WLAN_DELETE_BA) { |
| 7434 | } else { |
| 7435 | hdd_err("Invalid BA session cfg"); |
| 7436 | ret_val = -EINVAL; |
| 7437 | goto send_err; |
| 7438 | } |
| 7439 | } else if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADDBA_BUFF_SIZE]) { |
| 7440 | buff_size = nla_get_u8(tb[ |
| 7441 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ADDBA_BUFF_SIZE]); |
| 7442 | hdd_debug("set buff size to %d for all tids", buff_size); |
| 7443 | ret_val = sme_set_ba_buff_size(hdd_ctx->hHal, |
| 7444 | adapter->session_id, buff_size); |
| 7445 | if (ret_val) |
| 7446 | goto send_err; |
| 7447 | if (buff_size > 64) |
| 7448 | /* Configure ADDBA req buffer size to 256 */ |
| 7449 | set_val = 3; |
| 7450 | else |
| 7451 | /* Configure ADDBA req buffer size to 64 */ |
| 7452 | set_val = 2; |
| 7453 | ret_val = wma_cli_set_command(adapter->session_id, |
| 7454 | WMI_VDEV_PARAM_BA_MODE, set_val, VDEV_CMD); |
| 7455 | } |
| 7456 | |
Kiran Kumar Lokere | 3324f63 | 2018-03-01 21:43:21 -0800 | [diff] [blame] | 7457 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ENABLE_NO_ACK]) { |
| 7458 | if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_NO_ACK_AC]) { |
| 7459 | ac = nla_get_u8(tb[ |
| 7460 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_NO_ACK_AC]); |
| 7461 | } else { |
| 7462 | hdd_err("AC is not set for NO ACK policy config"); |
| 7463 | ret_val = -EINVAL; |
| 7464 | goto send_err; |
| 7465 | } |
| 7466 | cfg_val = nla_get_u8(tb[ |
| 7467 | QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_ENABLE_NO_ACK]); |
| 7468 | hdd_debug("Set NO_ACK to %d for ac %d", cfg_val, ac); |
| 7469 | ret_val = sme_set_no_ack_policy(hdd_ctx->hHal, |
| 7470 | adapter->session_id, cfg_val, ac); |
| 7471 | } |
| 7472 | |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 7473 | if (update_sme_cfg) |
| 7474 | sme_update_config(hdd_ctx->hHal, sme_config); |
| 7475 | |
Kiran Kumar Lokere | bc87bec | 2018-02-27 20:06:42 -0800 | [diff] [blame] | 7476 | send_err: |
Kiran Kumar Lokere | 722dccd | 2018-02-23 13:23:52 -0800 | [diff] [blame] | 7477 | qdf_mem_free(sme_config); |
| 7478 | |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 7479 | return ret_val; |
| 7480 | } |
| 7481 | |
| 7482 | /** |
| 7483 | * wlan_hdd_cfg80211_set_wifi_test_config() - Wifi test configuration |
| 7484 | * vendor command |
| 7485 | * |
| 7486 | * @wiphy: wiphy device pointer |
| 7487 | * @wdev: wireless device pointer |
| 7488 | * @data: Vendor command data buffer |
| 7489 | * @data_len: Buffer length |
| 7490 | * |
| 7491 | * Handles QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_MAX |
| 7492 | * |
| 7493 | * Return: EOK or other error codes. |
| 7494 | */ |
| 7495 | static int wlan_hdd_cfg80211_set_wifi_test_config(struct wiphy *wiphy, |
| 7496 | struct wireless_dev *wdev, const void *data, int data_len) |
| 7497 | { |
| 7498 | int ret; |
| 7499 | |
| 7500 | cds_ssr_protect(__func__); |
| 7501 | ret = __wlan_hdd_cfg80211_set_wifi_test_config(wiphy, wdev, |
| 7502 | data, data_len); |
| 7503 | cds_ssr_unprotect(__func__); |
| 7504 | |
| 7505 | return ret; |
| 7506 | } |
| 7507 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7508 | static const struct |
| 7509 | nla_policy |
| 7510 | qca_wlan_vendor_wifi_logger_start_policy |
| 7511 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = { |
| 7512 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID] |
| 7513 | = {.type = NLA_U32 }, |
| 7514 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL] |
| 7515 | = {.type = NLA_U32 }, |
| 7516 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS] |
| 7517 | = {.type = NLA_U32 }, |
| 7518 | }; |
| 7519 | |
| 7520 | /** |
| 7521 | * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable |
| 7522 | * or disable the collection of packet statistics from the firmware |
| 7523 | * @wiphy: WIPHY structure pointer |
| 7524 | * @wdev: Wireless device structure pointer |
| 7525 | * @data: Pointer to the data received |
| 7526 | * @data_len: Length of the data received |
| 7527 | * |
| 7528 | * This function enables or disables the collection of packet statistics from |
| 7529 | * the firmware |
| 7530 | * |
| 7531 | * Return: 0 on success and errno on failure |
| 7532 | */ |
| 7533 | static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy, |
| 7534 | struct wireless_dev *wdev, |
| 7535 | const void *data, |
| 7536 | int data_len) |
| 7537 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7538 | QDF_STATUS status; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 7539 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7540 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1]; |
| 7541 | struct sir_wifi_start_log start_log; |
| 7542 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 7543 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 7544 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7545 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7546 | hdd_err("Command not allowed in FTM mode"); |
| 7547 | return -EPERM; |
| 7548 | } |
| 7549 | |
| 7550 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7551 | if (status) |
| 7552 | return status; |
| 7553 | |
Ashish Kumar Dhanotiya | 3c30842 | 2017-03-02 16:48:56 +0530 | [diff] [blame] | 7554 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 7555 | hdd_err("Driver Modules are closed, can not start logger"); |
| 7556 | return -EINVAL; |
| 7557 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7558 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 7559 | if (wlan_cfg80211_nla_parse(tb, |
| 7560 | QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX, |
| 7561 | data, data_len, |
| 7562 | qca_wlan_vendor_wifi_logger_start_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7563 | hdd_err("Invalid attribute"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7564 | return -EINVAL; |
| 7565 | } |
| 7566 | |
| 7567 | /* Parse and fetch ring id */ |
| 7568 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7569 | hdd_err("attr ATTR failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7570 | return -EINVAL; |
| 7571 | } |
| 7572 | start_log.ring_id = nla_get_u32( |
| 7573 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7574 | hdd_debug("Ring ID=%d", start_log.ring_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7575 | |
| 7576 | /* Parse and fetch verbose level */ |
| 7577 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7578 | hdd_err("attr verbose_level failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7579 | return -EINVAL; |
| 7580 | } |
| 7581 | start_log.verbose_level = nla_get_u32( |
| 7582 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7583 | hdd_debug("verbose_level=%d", start_log.verbose_level); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7584 | |
| 7585 | /* Parse and fetch flag */ |
| 7586 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7587 | hdd_err("attr flag failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7588 | return -EINVAL; |
| 7589 | } |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 7590 | start_log.is_iwpriv_command = nla_get_u32( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7591 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7592 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7593 | /* size is buff size which can be set using iwpriv command*/ |
| 7594 | start_log.size = 0; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 7595 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 7596 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7597 | cds_set_ring_log_level(start_log.ring_id, start_log.verbose_level); |
| 7598 | |
| 7599 | if (start_log.ring_id == RING_ID_WAKELOCK) { |
| 7600 | /* Start/stop wakelock events */ |
| 7601 | if (start_log.verbose_level > WLAN_LOG_LEVEL_OFF) |
| 7602 | cds_set_wakelock_logging(true); |
| 7603 | else |
| 7604 | cds_set_wakelock_logging(false); |
| 7605 | return 0; |
| 7606 | } |
| 7607 | |
| 7608 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7609 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7610 | hdd_err("sme_wifi_start_logger failed(err=%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7611 | status); |
| 7612 | return -EINVAL; |
| 7613 | } |
| 7614 | return 0; |
| 7615 | } |
| 7616 | |
| 7617 | /** |
| 7618 | * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable |
| 7619 | * or disable the collection of packet statistics from the firmware |
| 7620 | * @wiphy: WIPHY structure pointer |
| 7621 | * @wdev: Wireless device structure pointer |
| 7622 | * @data: Pointer to the data received |
| 7623 | * @data_len: Length of the data received |
| 7624 | * |
| 7625 | * This function is used to enable or disable the collection of packet |
| 7626 | * statistics from the firmware |
| 7627 | * |
| 7628 | * Return: 0 on success and errno on failure |
| 7629 | */ |
| 7630 | static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy, |
| 7631 | struct wireless_dev *wdev, |
| 7632 | const void *data, |
| 7633 | int data_len) |
| 7634 | { |
| 7635 | int ret = 0; |
| 7636 | |
| 7637 | cds_ssr_protect(__func__); |
| 7638 | ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy, |
| 7639 | wdev, data, data_len); |
| 7640 | cds_ssr_unprotect(__func__); |
| 7641 | |
| 7642 | return ret; |
| 7643 | } |
| 7644 | |
| 7645 | static const struct |
| 7646 | nla_policy |
| 7647 | qca_wlan_vendor_wifi_logger_get_ring_data_policy |
| 7648 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = { |
| 7649 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID] |
| 7650 | = {.type = NLA_U32 }, |
| 7651 | }; |
| 7652 | |
| 7653 | /** |
| 7654 | * __wlan_hdd_cfg80211_wifi_logger_get_ring_data() - Flush per packet stats |
| 7655 | * @wiphy: WIPHY structure pointer |
| 7656 | * @wdev: Wireless device structure pointer |
| 7657 | * @data: Pointer to the data received |
| 7658 | * @data_len: Length of the data received |
| 7659 | * |
| 7660 | * This function is used to flush or retrieve the per packet statistics from |
| 7661 | * the driver |
| 7662 | * |
| 7663 | * Return: 0 on success and errno on failure |
| 7664 | */ |
| 7665 | static int __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy, |
| 7666 | struct wireless_dev *wdev, |
| 7667 | const void *data, |
| 7668 | int data_len) |
| 7669 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7670 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7671 | uint32_t ring_id; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 7672 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7673 | struct nlattr *tb |
| 7674 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1]; |
| 7675 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 7676 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 7677 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7678 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7679 | hdd_err("Command not allowed in FTM mode"); |
| 7680 | return -EPERM; |
| 7681 | } |
| 7682 | |
| 7683 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7684 | if (status) |
| 7685 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7686 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 7687 | if (wlan_cfg80211_nla_parse(tb, |
| 7688 | QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX, |
| 7689 | data, data_len, |
| 7690 | qca_wlan_vendor_wifi_logger_get_ring_data_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7691 | hdd_err("Invalid attribute"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7692 | return -EINVAL; |
| 7693 | } |
| 7694 | |
| 7695 | /* Parse and fetch ring id */ |
| 7696 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7697 | hdd_err("attr ATTR failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7698 | return -EINVAL; |
| 7699 | } |
| 7700 | |
| 7701 | ring_id = nla_get_u32( |
| 7702 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]); |
| 7703 | |
| 7704 | if (ring_id == RING_ID_PER_PACKET_STATS) { |
| 7705 | wlan_logging_set_per_pkt_stats(); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7706 | hdd_debug("Flushing/Retrieving packet stats"); |
Sreelakshmi Konamki | c3815ba | 2016-08-18 12:01:57 +0530 | [diff] [blame] | 7707 | } else if (ring_id == RING_ID_DRIVER_DEBUG) { |
| 7708 | /* |
| 7709 | * As part of DRIVER ring ID, flush both driver and fw logs. |
| 7710 | * For other Ring ID's driver doesn't have any rings to flush |
| 7711 | */ |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 7712 | hdd_info("Bug report triggered by framework"); |
Sreelakshmi Konamki | c3815ba | 2016-08-18 12:01:57 +0530 | [diff] [blame] | 7713 | |
| 7714 | status = cds_flush_logs(WLAN_LOG_TYPE_NON_FATAL, |
| 7715 | WLAN_LOG_INDICATOR_FRAMEWORK, |
| 7716 | WLAN_LOG_REASON_CODE_UNUSED, |
| 7717 | true, false); |
| 7718 | if (QDF_STATUS_SUCCESS != status) { |
| 7719 | hdd_err("Failed to trigger bug report"); |
| 7720 | return -EINVAL; |
| 7721 | } |
| 7722 | } else { |
| 7723 | wlan_report_log_completion(WLAN_LOG_TYPE_NON_FATAL, |
| 7724 | WLAN_LOG_INDICATOR_FRAMEWORK, |
Agrawal Ashish | aff2898 | 2017-05-30 15:25:47 +0530 | [diff] [blame] | 7725 | WLAN_LOG_REASON_CODE_UNUSED, |
| 7726 | ring_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7727 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7728 | return 0; |
| 7729 | } |
| 7730 | |
| 7731 | /** |
| 7732 | * wlan_hdd_cfg80211_wifi_logger_get_ring_data() - Wrapper to flush packet stats |
| 7733 | * @wiphy: WIPHY structure pointer |
| 7734 | * @wdev: Wireless device structure pointer |
| 7735 | * @data: Pointer to the data received |
| 7736 | * @data_len: Length of the data received |
| 7737 | * |
| 7738 | * This function is used to flush or retrieve the per packet statistics from |
| 7739 | * the driver |
| 7740 | * |
| 7741 | * Return: 0 on success and errno on failure |
| 7742 | */ |
| 7743 | static int wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy, |
| 7744 | struct wireless_dev *wdev, |
| 7745 | const void *data, |
| 7746 | int data_len) |
| 7747 | { |
| 7748 | int ret = 0; |
| 7749 | |
| 7750 | cds_ssr_protect(__func__); |
| 7751 | ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy, |
| 7752 | wdev, data, data_len); |
| 7753 | cds_ssr_unprotect(__func__); |
| 7754 | |
| 7755 | return ret; |
| 7756 | } |
| 7757 | |
| 7758 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7759 | /** |
| 7760 | * hdd_map_req_id_to_pattern_id() - map request id to pattern id |
| 7761 | * @hdd_ctx: HDD context |
| 7762 | * @request_id: [input] request id |
| 7763 | * @pattern_id: [output] pattern id |
| 7764 | * |
| 7765 | * This function loops through request id to pattern id array |
| 7766 | * if the slot is available, store the request id and return pattern id |
| 7767 | * if entry exists, return the pattern id |
| 7768 | * |
| 7769 | * Return: 0 on success and errno on failure |
| 7770 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 7771 | 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] | 7772 | uint32_t request_id, |
| 7773 | uint8_t *pattern_id) |
| 7774 | { |
| 7775 | uint32_t i; |
| 7776 | |
| 7777 | mutex_lock(&hdd_ctx->op_ctx.op_lock); |
| 7778 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7779 | if (hdd_ctx->op_ctx.op_table[i].request_id == MAX_REQUEST_ID) { |
| 7780 | hdd_ctx->op_ctx.op_table[i].request_id = request_id; |
| 7781 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 7782 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 7783 | return 0; |
| 7784 | } else if (hdd_ctx->op_ctx.op_table[i].request_id == |
| 7785 | request_id) { |
| 7786 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 7787 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 7788 | return 0; |
| 7789 | } |
| 7790 | } |
| 7791 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 7792 | return -EINVAL; |
| 7793 | } |
| 7794 | |
| 7795 | /** |
| 7796 | * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id |
| 7797 | * @hdd_ctx: HDD context |
| 7798 | * @request_id: [input] request id |
| 7799 | * @pattern_id: [output] pattern id |
| 7800 | * |
| 7801 | * This function loops through request id to pattern id array |
| 7802 | * reset request id to 0 (slot available again) and |
| 7803 | * return pattern id |
| 7804 | * |
| 7805 | * Return: 0 on success and errno on failure |
| 7806 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 7807 | 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] | 7808 | uint32_t request_id, |
| 7809 | uint8_t *pattern_id) |
| 7810 | { |
| 7811 | uint32_t i; |
| 7812 | |
| 7813 | mutex_lock(&hdd_ctx->op_ctx.op_lock); |
| 7814 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7815 | if (hdd_ctx->op_ctx.op_table[i].request_id == request_id) { |
| 7816 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7817 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 7818 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 7819 | return 0; |
| 7820 | } |
| 7821 | } |
| 7822 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 7823 | return -EINVAL; |
| 7824 | } |
| 7825 | |
| 7826 | |
| 7827 | /* |
| 7828 | * define short names for the global vendor params |
| 7829 | * used by __wlan_hdd_cfg80211_offloaded_packets() |
| 7830 | */ |
| 7831 | #define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX |
| 7832 | #define PARAM_REQUEST_ID \ |
| 7833 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID |
| 7834 | #define PARAM_CONTROL \ |
| 7835 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL |
| 7836 | #define PARAM_IP_PACKET \ |
| 7837 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA |
| 7838 | #define PARAM_SRC_MAC_ADDR \ |
| 7839 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR |
| 7840 | #define PARAM_DST_MAC_ADDR \ |
| 7841 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR |
| 7842 | #define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD |
| 7843 | |
| 7844 | /** |
| 7845 | * wlan_hdd_add_tx_ptrn() - add tx pattern |
| 7846 | * @adapter: adapter pointer |
| 7847 | * @hdd_ctx: hdd context |
| 7848 | * @tb: nl attributes |
| 7849 | * |
| 7850 | * This function reads the NL attributes and forms a AddTxPtrn message |
| 7851 | * posts it to SME. |
| 7852 | * |
| 7853 | */ |
| 7854 | static int |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 7855 | 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] | 7856 | struct nlattr **tb) |
| 7857 | { |
| 7858 | struct sSirAddPeriodicTxPtrn *add_req; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7859 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7860 | uint32_t request_id, ret, len; |
| 7861 | uint8_t pattern_id = 0; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7862 | struct qdf_mac_addr dst_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7863 | uint16_t eth_type = htons(ETH_P_IP); |
| 7864 | |
| 7865 | if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7866 | hdd_err("Not in Connected state!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7867 | return -ENOTSUPP; |
| 7868 | } |
| 7869 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7870 | add_req = qdf_mem_malloc(sizeof(*add_req)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7871 | if (!add_req) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7872 | hdd_err("memory allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7873 | return -ENOMEM; |
| 7874 | } |
| 7875 | |
| 7876 | /* Parse and fetch request Id */ |
| 7877 | if (!tb[PARAM_REQUEST_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7878 | hdd_err("attr request id failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7879 | goto fail; |
| 7880 | } |
| 7881 | |
| 7882 | request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); |
| 7883 | if (request_id == MAX_REQUEST_ID) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7884 | hdd_err("request_id cannot be MAX"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 7885 | goto fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7886 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7887 | hdd_debug("Request Id: %u", request_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7888 | |
| 7889 | if (!tb[PARAM_PERIOD]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7890 | hdd_err("attr period failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7891 | goto fail; |
| 7892 | } |
| 7893 | add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7894 | hdd_debug("Period: %u ms", add_req->usPtrnIntervalMs); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7895 | if (add_req->usPtrnIntervalMs == 0) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7896 | hdd_err("Invalid interval zero, return failure"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7897 | goto fail; |
| 7898 | } |
| 7899 | |
| 7900 | if (!tb[PARAM_SRC_MAC_ADDR]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7901 | hdd_err("attr source mac address failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7902 | goto fail; |
| 7903 | } |
Srinivas Girigowda | 3189655 | 2015-11-18 22:59:52 -0800 | [diff] [blame] | 7904 | nla_memcpy(add_req->mac_address.bytes, tb[PARAM_SRC_MAC_ADDR], |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7905 | QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7906 | hdd_debug("input src mac address: "MAC_ADDRESS_STR, |
Srinivas Girigowda | 3189655 | 2015-11-18 22:59:52 -0800 | [diff] [blame] | 7907 | MAC_ADDR_ARRAY(add_req->mac_address.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7908 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 7909 | if (!qdf_is_macaddr_equal(&add_req->mac_address, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 7910 | &adapter->mac_addr)) { |
Srinivas Girigowda | 3189655 | 2015-11-18 22:59:52 -0800 | [diff] [blame] | 7911 | hdd_err("input src mac address and connected ap bssid are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7912 | goto fail; |
| 7913 | } |
| 7914 | |
| 7915 | if (!tb[PARAM_DST_MAC_ADDR]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7916 | hdd_err("attr dst mac address failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7917 | goto fail; |
| 7918 | } |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7919 | 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] | 7920 | hdd_debug("input dst mac address: "MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7921 | MAC_ADDR_ARRAY(dst_addr.bytes)); |
| 7922 | |
| 7923 | if (!tb[PARAM_IP_PACKET]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7924 | hdd_err("attr ip packet failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7925 | goto fail; |
| 7926 | } |
| 7927 | add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7928 | hdd_debug("IP packet len: %u", add_req->ucPtrnSize); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7929 | |
| 7930 | if (add_req->ucPtrnSize < 0 || |
| 7931 | add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE - |
| 7932 | ETH_HLEN)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7933 | hdd_err("Invalid IP packet len: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7934 | add_req->ucPtrnSize); |
| 7935 | goto fail; |
| 7936 | } |
| 7937 | |
| 7938 | len = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7939 | 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] | 7940 | len += QDF_MAC_ADDR_SIZE; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7941 | qdf_mem_copy(&add_req->ucPattern[len], add_req->mac_address.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7942 | QDF_MAC_ADDR_SIZE); |
| 7943 | len += QDF_MAC_ADDR_SIZE; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7944 | qdf_mem_copy(&add_req->ucPattern[len], ð_type, 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7945 | len += 2; |
| 7946 | |
| 7947 | /* |
| 7948 | * This is the IP packet, add 14 bytes Ethernet (802.3) header |
| 7949 | * ------------------------------------------------------------ |
| 7950 | * | 14 bytes Ethernet (802.3) header | IP header and payload | |
| 7951 | * ------------------------------------------------------------ |
| 7952 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7953 | qdf_mem_copy(&add_req->ucPattern[len], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7954 | nla_data(tb[PARAM_IP_PACKET]), |
| 7955 | add_req->ucPtrnSize); |
| 7956 | add_req->ucPtrnSize += len; |
| 7957 | |
| 7958 | ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id); |
| 7959 | if (ret) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7960 | hdd_err("req id to pattern id failed (ret=%d)", ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7961 | goto fail; |
| 7962 | } |
| 7963 | add_req->ucPtrnId = pattern_id; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 7964 | hdd_debug("pattern id: %d", add_req->ucPtrnId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7965 | |
| 7966 | status = sme_add_periodic_tx_ptrn(hdd_ctx->hHal, add_req); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7967 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7968 | hdd_err("sme_add_periodic_tx_ptrn failed (err=%d)", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7969 | goto fail; |
| 7970 | } |
| 7971 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7972 | hdd_exit(); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7973 | qdf_mem_free(add_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7974 | return 0; |
| 7975 | |
| 7976 | fail: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7977 | qdf_mem_free(add_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7978 | return -EINVAL; |
| 7979 | } |
| 7980 | |
| 7981 | /** |
| 7982 | * wlan_hdd_del_tx_ptrn() - delete tx pattern |
| 7983 | * @adapter: adapter pointer |
| 7984 | * @hdd_ctx: hdd context |
| 7985 | * @tb: nl attributes |
| 7986 | * |
| 7987 | * This function reads the NL attributes and forms a DelTxPtrn message |
| 7988 | * posts it to SME. |
| 7989 | * |
| 7990 | */ |
| 7991 | static int |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 7992 | 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] | 7993 | struct nlattr **tb) |
| 7994 | { |
| 7995 | struct sSirDelPeriodicTxPtrn *del_req; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7996 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7997 | uint32_t request_id, ret; |
| 7998 | uint8_t pattern_id = 0; |
| 7999 | |
| 8000 | /* Parse and fetch request Id */ |
| 8001 | if (!tb[PARAM_REQUEST_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8002 | hdd_err("attr request id failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8003 | return -EINVAL; |
| 8004 | } |
| 8005 | request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); |
| 8006 | if (request_id == MAX_REQUEST_ID) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8007 | hdd_err("request_id cannot be MAX"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8008 | return -EINVAL; |
| 8009 | } |
| 8010 | |
| 8011 | ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id); |
| 8012 | if (ret) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 8013 | hdd_err("req id to pattern id failed (ret=%d)", ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8014 | return -EINVAL; |
| 8015 | } |
| 8016 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8017 | del_req = qdf_mem_malloc(sizeof(*del_req)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8018 | if (!del_req) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8019 | hdd_err("memory allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8020 | return -ENOMEM; |
| 8021 | } |
| 8022 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 8023 | qdf_copy_macaddr(&del_req->mac_address, &adapter->mac_addr); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 8024 | 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] | 8025 | del_req->ucPtrnId = pattern_id; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 8026 | hdd_debug("Request Id: %u Pattern id: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8027 | request_id, del_req->ucPtrnId); |
| 8028 | |
| 8029 | status = sme_del_periodic_tx_ptrn(hdd_ctx->hHal, del_req); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8030 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8031 | hdd_err("sme_del_periodic_tx_ptrn failed (err=%d)", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8032 | goto fail; |
| 8033 | } |
| 8034 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8035 | hdd_exit(); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8036 | qdf_mem_free(del_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8037 | return 0; |
| 8038 | |
| 8039 | fail: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8040 | qdf_mem_free(del_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8041 | return -EINVAL; |
| 8042 | } |
| 8043 | |
| 8044 | |
| 8045 | /** |
| 8046 | * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets |
| 8047 | * @wiphy: Pointer to wireless phy |
| 8048 | * @wdev: Pointer to wireless device |
| 8049 | * @data: Pointer to data |
| 8050 | * @data_len: Data length |
| 8051 | * |
| 8052 | * Return: 0 on success, negative errno on failure |
| 8053 | */ |
| 8054 | static int |
| 8055 | __wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy, |
| 8056 | struct wireless_dev *wdev, |
| 8057 | const void *data, |
| 8058 | int data_len) |
| 8059 | { |
| 8060 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 8061 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8062 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8063 | struct nlattr *tb[PARAM_MAX + 1]; |
| 8064 | uint8_t control; |
| 8065 | int ret; |
| 8066 | static const struct nla_policy policy[PARAM_MAX + 1] = { |
| 8067 | [PARAM_REQUEST_ID] = { .type = NLA_U32 }, |
| 8068 | [PARAM_CONTROL] = { .type = NLA_U32 }, |
| 8069 | [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8070 | .len = QDF_MAC_ADDR_SIZE }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8071 | [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8072 | .len = QDF_MAC_ADDR_SIZE }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8073 | [PARAM_PERIOD] = { .type = NLA_U32 }, |
| 8074 | }; |
| 8075 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8076 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8077 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8078 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8079 | hdd_err("Command not allowed in FTM mode"); |
| 8080 | return -EPERM; |
| 8081 | } |
| 8082 | |
| 8083 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 8084 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8085 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8086 | |
| 8087 | if (!sme_is_feature_supported_by_fw(WLAN_PERIODIC_TX_PTRN)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8088 | hdd_err("Periodic Tx Pattern Offload feature is not supported in FW!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8089 | return -ENOTSUPP; |
| 8090 | } |
| 8091 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8092 | if (wlan_cfg80211_nla_parse(tb, PARAM_MAX, data, data_len, policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8093 | hdd_err("Invalid ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8094 | return -EINVAL; |
| 8095 | } |
| 8096 | |
| 8097 | if (!tb[PARAM_CONTROL]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8098 | hdd_err("attr control failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8099 | return -EINVAL; |
| 8100 | } |
| 8101 | control = nla_get_u32(tb[PARAM_CONTROL]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 8102 | hdd_debug("Control: %d", control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8103 | |
| 8104 | if (control == WLAN_START_OFFLOADED_PACKETS) |
| 8105 | return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb); |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 8106 | if (control == WLAN_STOP_OFFLOADED_PACKETS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8107 | return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb); |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 8108 | |
| 8109 | hdd_err("Invalid control: %d", control); |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 8110 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8111 | } |
| 8112 | |
| 8113 | /* |
| 8114 | * done with short names for the global vendor params |
| 8115 | * used by __wlan_hdd_cfg80211_offloaded_packets() |
| 8116 | */ |
| 8117 | #undef PARAM_MAX |
| 8118 | #undef PARAM_REQUEST_ID |
| 8119 | #undef PARAM_CONTROL |
| 8120 | #undef PARAM_IP_PACKET |
| 8121 | #undef PARAM_SRC_MAC_ADDR |
| 8122 | #undef PARAM_DST_MAC_ADDR |
| 8123 | #undef PARAM_PERIOD |
| 8124 | |
| 8125 | /** |
| 8126 | * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets |
| 8127 | * @wiphy: wiphy structure pointer |
| 8128 | * @wdev: Wireless device structure pointer |
| 8129 | * @data: Pointer to the data received |
| 8130 | * @data_len: Length of @data |
| 8131 | * |
| 8132 | * Return: 0 on success; errno on failure |
| 8133 | */ |
| 8134 | static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy, |
| 8135 | struct wireless_dev *wdev, |
| 8136 | const void *data, |
| 8137 | int data_len) |
| 8138 | { |
| 8139 | int ret = 0; |
| 8140 | |
| 8141 | cds_ssr_protect(__func__); |
| 8142 | ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy, |
| 8143 | wdev, data, data_len); |
| 8144 | cds_ssr_unprotect(__func__); |
| 8145 | |
| 8146 | return ret; |
| 8147 | } |
| 8148 | #endif |
| 8149 | |
| 8150 | /* |
| 8151 | * define short names for the global vendor params |
| 8152 | * used by __wlan_hdd_cfg80211_monitor_rssi() |
| 8153 | */ |
| 8154 | #define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX |
| 8155 | #define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID |
| 8156 | #define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL |
| 8157 | #define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI |
| 8158 | #define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI |
| 8159 | |
| 8160 | /** |
| 8161 | * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi |
| 8162 | * @wiphy: Pointer to wireless phy |
| 8163 | * @wdev: Pointer to wireless device |
| 8164 | * @data: Pointer to data |
| 8165 | * @data_len: Data length |
| 8166 | * |
| 8167 | * Return: 0 on success, negative errno on failure |
| 8168 | */ |
| 8169 | static int |
| 8170 | __wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, |
| 8171 | struct wireless_dev *wdev, |
| 8172 | const void *data, |
| 8173 | int data_len) |
| 8174 | { |
| 8175 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 8176 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8177 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8178 | struct nlattr *tb[PARAM_MAX + 1]; |
| 8179 | struct rssi_monitor_req req; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8180 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8181 | int ret; |
| 8182 | uint32_t control; |
| 8183 | static const struct nla_policy policy[PARAM_MAX + 1] = { |
| 8184 | [PARAM_REQUEST_ID] = { .type = NLA_U32 }, |
| 8185 | [PARAM_CONTROL] = { .type = NLA_U32 }, |
| 8186 | [PARAM_MIN_RSSI] = { .type = NLA_S8 }, |
| 8187 | [PARAM_MAX_RSSI] = { .type = NLA_S8 }, |
| 8188 | }; |
| 8189 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8190 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8191 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8192 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 8193 | hdd_err("invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 8194 | return -EINVAL; |
| 8195 | } |
| 8196 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8197 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 8198 | if (ret) |
| 8199 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8200 | |
| 8201 | if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8202 | hdd_err("Not in Connected state!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8203 | return -ENOTSUPP; |
| 8204 | } |
| 8205 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8206 | if (wlan_cfg80211_nla_parse(tb, PARAM_MAX, data, data_len, policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8207 | hdd_err("Invalid ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8208 | return -EINVAL; |
| 8209 | } |
| 8210 | |
| 8211 | if (!tb[PARAM_REQUEST_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8212 | hdd_err("attr request id failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8213 | return -EINVAL; |
| 8214 | } |
| 8215 | |
| 8216 | if (!tb[PARAM_CONTROL]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8217 | hdd_err("attr control failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8218 | return -EINVAL; |
| 8219 | } |
| 8220 | |
| 8221 | req.request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8222 | req.session_id = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8223 | control = nla_get_u32(tb[PARAM_CONTROL]); |
| 8224 | |
| 8225 | if (control == QCA_WLAN_RSSI_MONITORING_START) { |
| 8226 | req.control = true; |
| 8227 | if (!tb[PARAM_MIN_RSSI]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8228 | hdd_err("attr min rssi failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8229 | return -EINVAL; |
| 8230 | } |
| 8231 | |
| 8232 | if (!tb[PARAM_MAX_RSSI]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8233 | hdd_err("attr max rssi failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8234 | return -EINVAL; |
| 8235 | } |
| 8236 | |
| 8237 | req.min_rssi = nla_get_s8(tb[PARAM_MIN_RSSI]); |
| 8238 | req.max_rssi = nla_get_s8(tb[PARAM_MAX_RSSI]); |
| 8239 | |
| 8240 | if (!(req.min_rssi < req.max_rssi)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8241 | hdd_warn("min_rssi: %d must be less than max_rssi: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8242 | req.min_rssi, req.max_rssi); |
| 8243 | return -EINVAL; |
| 8244 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 8245 | hdd_debug("Min_rssi: %d Max_rssi: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8246 | req.min_rssi, req.max_rssi); |
| 8247 | |
| 8248 | } else if (control == QCA_WLAN_RSSI_MONITORING_STOP) |
| 8249 | req.control = false; |
| 8250 | else { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8251 | hdd_err("Invalid control cmd: %d", control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8252 | return -EINVAL; |
| 8253 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 8254 | hdd_debug("Request Id: %u Session_id: %d Control: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8255 | req.request_id, req.session_id, req.control); |
| 8256 | |
| 8257 | status = sme_set_rssi_monitoring(hdd_ctx->hHal, &req); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8258 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8259 | hdd_err("sme_set_rssi_monitoring failed(err=%d)", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8260 | return -EINVAL; |
| 8261 | } |
| 8262 | |
| 8263 | return 0; |
| 8264 | } |
| 8265 | |
| 8266 | /* |
| 8267 | * done with short names for the global vendor params |
| 8268 | * used by __wlan_hdd_cfg80211_monitor_rssi() |
| 8269 | */ |
| 8270 | #undef PARAM_MAX |
| 8271 | #undef PARAM_CONTROL |
| 8272 | #undef PARAM_REQUEST_ID |
| 8273 | #undef PARAM_MAX_RSSI |
| 8274 | #undef PARAM_MIN_RSSI |
| 8275 | |
| 8276 | /** |
| 8277 | * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring |
| 8278 | * @wiphy: wiphy structure pointer |
| 8279 | * @wdev: Wireless device structure pointer |
| 8280 | * @data: Pointer to the data received |
| 8281 | * @data_len: Length of @data |
| 8282 | * |
| 8283 | * Return: 0 on success; errno on failure |
| 8284 | */ |
| 8285 | static int |
| 8286 | wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 8287 | const void *data, int data_len) |
| 8288 | { |
| 8289 | int ret; |
| 8290 | |
| 8291 | cds_ssr_protect(__func__); |
| 8292 | ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len); |
| 8293 | cds_ssr_unprotect(__func__); |
| 8294 | |
| 8295 | return ret; |
| 8296 | } |
| 8297 | |
| 8298 | /** |
| 8299 | * hdd_rssi_threshold_breached() - rssi breached NL event |
| 8300 | * @hddctx: HDD context |
| 8301 | * @data: rssi breached event data |
| 8302 | * |
| 8303 | * This function reads the rssi breached event %data and fill in the skb with |
| 8304 | * NL attributes and send up the NL event. |
| 8305 | * |
| 8306 | * Return: none |
| 8307 | */ |
| 8308 | void hdd_rssi_threshold_breached(void *hddctx, |
| 8309 | struct rssi_breach_event *data) |
| 8310 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8311 | struct hdd_context *hdd_ctx = hddctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8312 | struct sk_buff *skb; |
| 8313 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8314 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8315 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 8316 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8317 | return; |
| 8318 | if (!data) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8319 | hdd_err("data is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8320 | return; |
| 8321 | } |
| 8322 | |
| 8323 | skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 8324 | NULL, |
| 8325 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 8326 | QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX, |
| 8327 | GFP_KERNEL); |
| 8328 | |
| 8329 | if (!skb) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8330 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8331 | return; |
| 8332 | } |
| 8333 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 8334 | hdd_debug("Req Id: %u Current rssi: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8335 | data->request_id, data->curr_rssi); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 8336 | hdd_debug("Current BSSID: "MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8337 | MAC_ADDR_ARRAY(data->curr_bssid.bytes)); |
| 8338 | |
| 8339 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID, |
| 8340 | data->request_id) || |
| 8341 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID, |
| 8342 | sizeof(data->curr_bssid), data->curr_bssid.bytes) || |
| 8343 | nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI, |
| 8344 | data->curr_rssi)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8345 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8346 | goto fail; |
| 8347 | } |
| 8348 | |
| 8349 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 8350 | return; |
| 8351 | |
| 8352 | fail: |
| 8353 | kfree_skb(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8354 | } |
| 8355 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8356 | static const struct nla_policy |
| 8357 | ns_offload_set_policy[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_MAX + 1] = { |
| 8358 | [QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_FLAG] = {.type = NLA_U8}, |
| 8359 | }; |
| 8360 | |
| 8361 | /** |
| 8362 | * __wlan_hdd_cfg80211_set_ns_offload() - enable/disable NS offload |
| 8363 | * @wiphy: Pointer to wireless phy |
| 8364 | * @wdev: Pointer to wireless device |
| 8365 | * @data: Pointer to data |
| 8366 | * @data_len: Length of @data |
| 8367 | * |
| 8368 | * Return: 0 on success, negative errno on failure |
| 8369 | */ |
| 8370 | static int |
| 8371 | __wlan_hdd_cfg80211_set_ns_offload(struct wiphy *wiphy, |
| 8372 | struct wireless_dev *wdev, |
| 8373 | const void *data, int data_len) |
| 8374 | { |
| 8375 | int status; |
| 8376 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_MAX + 1]; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 8377 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Dustin Brown | d8279d2 | 2016-09-07 14:52:57 -0700 | [diff] [blame] | 8378 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 8379 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8380 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8381 | hdd_enter_dev(wdev->netdev); |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8382 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 8383 | status = wlan_hdd_validate_context(hdd_ctx); |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8384 | if (0 != status) |
| 8385 | return status; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 8386 | if (!hdd_ctx->config->fhostNSOffload) { |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8387 | hdd_err("ND Offload not supported"); |
| 8388 | return -EINVAL; |
| 8389 | } |
| 8390 | |
Mukul Sharma | 495df60 | 2017-09-25 14:52:18 +0530 | [diff] [blame] | 8391 | if (!hdd_ctx->config->active_mode_offload) { |
| 8392 | hdd_warn("Active mode offload is disabled"); |
| 8393 | return -EINVAL; |
| 8394 | } |
| 8395 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8396 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_MAX, |
| 8397 | (struct nlattr *)data, data_len, |
| 8398 | ns_offload_set_policy)) { |
| 8399 | hdd_err("nla_parse failed"); |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8400 | return -EINVAL; |
| 8401 | } |
| 8402 | |
| 8403 | if (!tb[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_FLAG]) { |
| 8404 | hdd_err("ND Offload flag attribute not present"); |
| 8405 | return -EINVAL; |
| 8406 | } |
| 8407 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 8408 | hdd_ctx->ns_offload_enable = |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8409 | nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_FLAG]); |
| 8410 | |
Nachiket Kukade | dbffab8 | 2017-04-25 19:26:02 +0530 | [diff] [blame] | 8411 | if (QDF_IBSS_MODE == adapter->device_mode) { |
| 8412 | hdd_debug("NS Offload is not supported in IBSS mode"); |
| 8413 | return -EINVAL; |
| 8414 | } |
| 8415 | |
Dustin Brown | d8279d2 | 2016-09-07 14:52:57 -0700 | [diff] [blame] | 8416 | /* update ns offload in case it is already enabled/disabled */ |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 8417 | if (hdd_ctx->ns_offload_enable) |
Mukul Sharma | 3ba26b8 | 2017-01-12 21:59:41 +0530 | [diff] [blame] | 8418 | hdd_enable_ns_offload(adapter, pmo_ns_offload_dynamic_update); |
| 8419 | else |
| 8420 | hdd_disable_ns_offload(adapter, pmo_ns_offload_dynamic_update); |
Dustin Brown | d8279d2 | 2016-09-07 14:52:57 -0700 | [diff] [blame] | 8421 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8422 | return 0; |
| 8423 | } |
| 8424 | |
| 8425 | /** |
| 8426 | * wlan_hdd_cfg80211_set_ns_offload() - enable/disable NS offload |
| 8427 | * @wiphy: pointer to wireless wiphy structure. |
| 8428 | * @wdev: pointer to wireless_dev structure. |
| 8429 | * @data: Pointer to the data to be passed via vendor interface |
| 8430 | * @data_len:Length of the data to be passed |
| 8431 | * |
| 8432 | * Return: Return the Success or Failure code. |
| 8433 | */ |
| 8434 | static int wlan_hdd_cfg80211_set_ns_offload(struct wiphy *wiphy, |
| 8435 | struct wireless_dev *wdev, |
| 8436 | const void *data, int data_len) |
| 8437 | { |
| 8438 | int ret; |
| 8439 | |
| 8440 | cds_ssr_protect(__func__); |
| 8441 | ret = __wlan_hdd_cfg80211_set_ns_offload(wiphy, wdev, data, data_len); |
| 8442 | cds_ssr_unprotect(__func__); |
| 8443 | |
| 8444 | return ret; |
| 8445 | } |
| 8446 | |
Jeff Johnson | dd7bd3e | 2017-06-05 13:25:24 -0700 | [diff] [blame] | 8447 | static const struct nla_policy get_preferred_freq_list_policy |
| 8448 | [QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_MAX + 1] = { |
| 8449 | [QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_IFACE_TYPE] = { |
| 8450 | .type = NLA_U32}, |
| 8451 | }; |
| 8452 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8453 | /** __wlan_hdd_cfg80211_get_preferred_freq_list() - get preferred frequency list |
| 8454 | * @wiphy: Pointer to wireless phy |
| 8455 | * @wdev: Pointer to wireless device |
| 8456 | * @data: Pointer to data |
| 8457 | * @data_len: Data length |
| 8458 | * |
| 8459 | * This function return the preferred frequency list generated by the policy |
| 8460 | * manager. |
| 8461 | * |
| 8462 | * Return: success or failure code |
| 8463 | */ |
| 8464 | static int __wlan_hdd_cfg80211_get_preferred_freq_list(struct wiphy *wiphy, |
| 8465 | struct wireless_dev |
| 8466 | *wdev, const void *data, |
| 8467 | int data_len) |
| 8468 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8469 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8470 | int i, ret = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8471 | QDF_STATUS status; |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 8472 | uint8_t pcl[QDF_MAX_NUM_CHAN], weight_list[QDF_MAX_NUM_CHAN]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8473 | uint32_t pcl_len = 0; |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 8474 | uint32_t freq_list[QDF_MAX_NUM_CHAN]; |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 8475 | enum policy_mgr_con_mode intf_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8476 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_MAX + 1]; |
| 8477 | struct sk_buff *reply_skb; |
| 8478 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8479 | hdd_enter_dev(wdev->netdev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 8480 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8481 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8482 | if (ret) |
| 8483 | return -EINVAL; |
| 8484 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8485 | if (wlan_cfg80211_nla_parse(tb, |
| 8486 | QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_MAX, |
| 8487 | data, data_len, |
| 8488 | get_preferred_freq_list_policy)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8489 | hdd_err("Invalid ATTR"); |
| 8490 | return -EINVAL; |
| 8491 | } |
| 8492 | |
| 8493 | if (!tb[QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_IFACE_TYPE]) { |
| 8494 | hdd_err("attr interface type failed"); |
| 8495 | return -EINVAL; |
| 8496 | } |
| 8497 | |
| 8498 | intf_mode = nla_get_u32(tb |
| 8499 | [QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_IFACE_TYPE]); |
| 8500 | |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 8501 | 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] | 8502 | hdd_err("Invalid interface type"); |
| 8503 | return -EINVAL; |
| 8504 | } |
| 8505 | |
| 8506 | hdd_debug("Userspace requested pref freq list"); |
| 8507 | |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 8508 | status = policy_mgr_get_pcl(hdd_ctx->hdd_psoc, |
| 8509 | intf_mode, pcl, &pcl_len, |
Manishekar Chandrasekaran | 7009f25 | 2016-04-21 19:14:15 +0530 | [diff] [blame] | 8510 | weight_list, QDF_ARRAY_SIZE(weight_list)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8511 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8512 | hdd_err("Get pcl failed"); |
| 8513 | return -EINVAL; |
| 8514 | } |
| 8515 | |
| 8516 | /* convert channel number to frequency */ |
| 8517 | for (i = 0; i < pcl_len; i++) { |
| 8518 | if (pcl[i] <= ARRAY_SIZE(hdd_channels_2_4_ghz)) |
| 8519 | freq_list[i] = |
| 8520 | ieee80211_channel_to_frequency(pcl[i], |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 8521 | HDD_NL80211_BAND_2GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8522 | else |
| 8523 | freq_list[i] = |
| 8524 | ieee80211_channel_to_frequency(pcl[i], |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 8525 | HDD_NL80211_BAND_5GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8526 | } |
| 8527 | |
| 8528 | /* send the freq_list back to supplicant */ |
| 8529 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) + |
| 8530 | sizeof(u32) * |
| 8531 | pcl_len + |
| 8532 | NLMSG_HDRLEN); |
| 8533 | |
| 8534 | if (!reply_skb) { |
| 8535 | hdd_err("Allocate reply_skb failed"); |
| 8536 | return -EINVAL; |
| 8537 | } |
| 8538 | |
| 8539 | if (nla_put_u32(reply_skb, |
| 8540 | QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_IFACE_TYPE, |
| 8541 | intf_mode) || |
| 8542 | nla_put(reply_skb, |
| 8543 | QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST, |
| 8544 | sizeof(uint32_t) * pcl_len, |
| 8545 | freq_list)) { |
| 8546 | hdd_err("nla put fail"); |
| 8547 | kfree_skb(reply_skb); |
| 8548 | return -EINVAL; |
| 8549 | } |
| 8550 | |
| 8551 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 8552 | } |
| 8553 | |
| 8554 | /** wlan_hdd_cfg80211_get_preferred_freq_list () - get preferred frequency list |
| 8555 | * @wiphy: Pointer to wireless phy |
| 8556 | * @wdev: Pointer to wireless device |
| 8557 | * @data: Pointer to data |
| 8558 | * @data_len: Data length |
| 8559 | * |
| 8560 | * This function return the preferred frequency list generated by the policy |
| 8561 | * manager. |
| 8562 | * |
| 8563 | * Return: success or failure code |
| 8564 | */ |
| 8565 | static int wlan_hdd_cfg80211_get_preferred_freq_list(struct wiphy *wiphy, |
| 8566 | struct wireless_dev |
| 8567 | *wdev, const void *data, |
| 8568 | int data_len) |
| 8569 | { |
| 8570 | int ret = 0; |
| 8571 | |
| 8572 | cds_ssr_protect(__func__); |
| 8573 | ret = __wlan_hdd_cfg80211_get_preferred_freq_list(wiphy, wdev, |
| 8574 | data, data_len); |
| 8575 | cds_ssr_unprotect(__func__); |
| 8576 | |
| 8577 | return ret; |
| 8578 | } |
| 8579 | |
Jeff Johnson | e5f33ba | 2017-06-05 14:48:48 -0700 | [diff] [blame] | 8580 | static const struct nla_policy set_probable_oper_channel_policy |
| 8581 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_MAX + 1] = { |
| 8582 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_IFACE_TYPE] = { |
| 8583 | .type = NLA_U32}, |
| 8584 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_FREQ] = { |
| 8585 | .type = NLA_U32}, |
| 8586 | }; |
| 8587 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8588 | /** |
| 8589 | * __wlan_hdd_cfg80211_set_probable_oper_channel () - set probable channel |
| 8590 | * @wiphy: Pointer to wireless phy |
| 8591 | * @wdev: Pointer to wireless device |
| 8592 | * @data: Pointer to data |
| 8593 | * @data_len: Data length |
| 8594 | * |
| 8595 | * Return: 0 on success, negative errno on failure |
| 8596 | */ |
| 8597 | static int __wlan_hdd_cfg80211_set_probable_oper_channel(struct wiphy *wiphy, |
| 8598 | struct wireless_dev *wdev, |
| 8599 | const void *data, |
| 8600 | int data_len) |
| 8601 | { |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 8602 | struct net_device *ndev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 8603 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8604 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8605 | int ret = 0; |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 8606 | enum policy_mgr_con_mode intf_mode; |
Jeff Johnson | e5f33ba | 2017-06-05 14:48:48 -0700 | [diff] [blame] | 8607 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_MAX + 1]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8608 | uint32_t channel_hint; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8609 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8610 | hdd_enter_dev(ndev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 8611 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8612 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8613 | if (ret) |
| 8614 | return ret; |
| 8615 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8616 | if (wlan_cfg80211_nla_parse(tb, |
| 8617 | QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_MAX, |
| 8618 | data, data_len, |
| 8619 | set_probable_oper_channel_policy)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8620 | hdd_err("Invalid ATTR"); |
| 8621 | return -EINVAL; |
| 8622 | } |
| 8623 | |
| 8624 | if (!tb[QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_IFACE_TYPE]) { |
| 8625 | hdd_err("attr interface type failed"); |
| 8626 | return -EINVAL; |
| 8627 | } |
| 8628 | |
| 8629 | intf_mode = nla_get_u32(tb |
| 8630 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_IFACE_TYPE]); |
| 8631 | |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 8632 | 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] | 8633 | hdd_err("Invalid interface type"); |
| 8634 | return -EINVAL; |
| 8635 | } |
| 8636 | |
| 8637 | if (!tb[QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_FREQ]) { |
| 8638 | hdd_err("attr probable freq failed"); |
| 8639 | return -EINVAL; |
| 8640 | } |
| 8641 | |
| 8642 | channel_hint = cds_freq_to_chan(nla_get_u32(tb |
| 8643 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_FREQ])); |
| 8644 | |
| 8645 | /* check pcl table */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 8646 | if (!policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc, intf_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8647 | channel_hint, HW_MODE_20_MHZ)) { |
| 8648 | hdd_err("Set channel hint failed due to concurrency check"); |
| 8649 | return -EINVAL; |
| 8650 | } |
| 8651 | |
Krunal Soni | 09e5503 | 2016-06-07 10:06:55 -0700 | [diff] [blame] | 8652 | if (0 != wlan_hdd_check_remain_on_channel(adapter)) |
| 8653 | hdd_warn("Remain On Channel Pending"); |
| 8654 | |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 8655 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, channel_hint, |
| 8656 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 8657 | hdd_err("Failed to change hw mode"); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 8658 | return -EINVAL; |
| 8659 | } |
| 8660 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8661 | return 0; |
| 8662 | } |
| 8663 | |
| 8664 | /** |
| 8665 | * wlan_hdd_cfg80211_set_probable_oper_channel () - set probable channel |
| 8666 | * @wiphy: Pointer to wireless phy |
| 8667 | * @wdev: Pointer to wireless device |
| 8668 | * @data: Pointer to data |
| 8669 | * @data_len: Data length |
| 8670 | * |
| 8671 | * Return: 0 on success, negative errno on failure |
| 8672 | */ |
| 8673 | static int wlan_hdd_cfg80211_set_probable_oper_channel(struct wiphy *wiphy, |
| 8674 | struct wireless_dev *wdev, |
| 8675 | const void *data, |
| 8676 | int data_len) |
| 8677 | { |
| 8678 | int ret = 0; |
| 8679 | |
| 8680 | cds_ssr_protect(__func__); |
| 8681 | ret = __wlan_hdd_cfg80211_set_probable_oper_channel(wiphy, wdev, |
| 8682 | data, data_len); |
| 8683 | cds_ssr_unprotect(__func__); |
| 8684 | |
| 8685 | return ret; |
| 8686 | } |
| 8687 | |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8688 | static const struct |
| 8689 | nla_policy |
| 8690 | qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = { |
Ashish Kumar Dhanotiya | 81e2acc | 2017-06-21 12:30:32 +0530 | [diff] [blame] | 8691 | [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { |
| 8692 | .type = NLA_BINARY, .len = QDF_MAC_ADDR_SIZE }, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8693 | }; |
| 8694 | |
| 8695 | /** |
| 8696 | * __wlan_hdd_cfg80211_get_link_properties() - Get link properties |
| 8697 | * @wiphy: WIPHY structure pointer |
| 8698 | * @wdev: Wireless device structure pointer |
| 8699 | * @data: Pointer to the data received |
| 8700 | * @data_len: Length of the data received |
| 8701 | * |
| 8702 | * This function is used to get link properties like nss, rate flags and |
| 8703 | * operating frequency for the active connection with the given peer. |
| 8704 | * |
| 8705 | * Return: 0 on success and errno on failure |
| 8706 | */ |
| 8707 | static int __wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy, |
| 8708 | struct wireless_dev *wdev, |
| 8709 | const void *data, |
| 8710 | int data_len) |
| 8711 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8712 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8713 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 8714 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 8715 | struct hdd_station_ctx *hdd_sta_ctx; |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8716 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1]; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8717 | uint8_t peer_mac[QDF_MAC_ADDR_SIZE]; |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8718 | uint32_t sta_id; |
| 8719 | struct sk_buff *reply_skb; |
| 8720 | uint32_t rate_flags = 0; |
| 8721 | uint8_t nss; |
| 8722 | uint8_t final_rate_flags = 0; |
| 8723 | uint32_t freq; |
| 8724 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8725 | hdd_enter_dev(dev); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8726 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8727 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8728 | hdd_err("Command not allowed in FTM mode"); |
| 8729 | return -EPERM; |
| 8730 | } |
| 8731 | |
| 8732 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 8733 | return -EINVAL; |
| 8734 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8735 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, |
| 8736 | data_len, qca_wlan_vendor_attr_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8737 | hdd_err("Invalid attribute"); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8738 | return -EINVAL; |
| 8739 | } |
| 8740 | |
| 8741 | if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8742 | hdd_err("Attribute peerMac not provided for mode=%d", |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8743 | adapter->device_mode); |
| 8744 | return -EINVAL; |
| 8745 | } |
| 8746 | |
Ashish Kumar Dhanotiya | 81e2acc | 2017-06-21 12:30:32 +0530 | [diff] [blame] | 8747 | if (nla_len(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) < QDF_MAC_ADDR_SIZE) { |
| 8748 | hdd_err("Attribute peerMac is invalid for mode=%d", |
| 8749 | adapter->device_mode); |
| 8750 | return -EINVAL; |
| 8751 | } |
| 8752 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8753 | 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] | 8754 | QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 8755 | hdd_debug("peerMac="MAC_ADDRESS_STR" for device_mode:%d", |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8756 | MAC_ADDR_ARRAY(peer_mac), adapter->device_mode); |
| 8757 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 8758 | if (adapter->device_mode == QDF_STA_MODE || |
| 8759 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8760 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 8761 | if ((hdd_sta_ctx->conn_info.connState != |
| 8762 | eConnectionState_Associated) || |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8763 | qdf_mem_cmp(hdd_sta_ctx->conn_info.bssId.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8764 | peer_mac, QDF_MAC_ADDR_SIZE)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8765 | hdd_err("Not Associated to mac "MAC_ADDRESS_STR, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8766 | MAC_ADDR_ARRAY(peer_mac)); |
| 8767 | return -EINVAL; |
| 8768 | } |
| 8769 | |
| 8770 | nss = hdd_sta_ctx->conn_info.nss; |
| 8771 | freq = cds_chan_to_freq( |
| 8772 | hdd_sta_ctx->conn_info.operationChannel); |
| 8773 | rate_flags = hdd_sta_ctx->conn_info.rate_flags; |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 8774 | } else if (adapter->device_mode == QDF_P2P_GO_MODE || |
| 8775 | adapter->device_mode == QDF_SAP_MODE) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8776 | |
| 8777 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 8778 | if (adapter->sta_info[sta_id].in_use && |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 8779 | !qdf_is_macaddr_broadcast( |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 8780 | &adapter->sta_info[sta_id].sta_mac) && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8781 | !qdf_mem_cmp( |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 8782 | &adapter->sta_info[sta_id].sta_mac.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8783 | peer_mac, QDF_MAC_ADDR_SIZE)) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8784 | break; |
| 8785 | } |
| 8786 | |
| 8787 | if (WLAN_MAX_STA_COUNT == sta_id) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8788 | hdd_err("No active peer with mac="MAC_ADDRESS_STR, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8789 | MAC_ADDR_ARRAY(peer_mac)); |
| 8790 | return -EINVAL; |
| 8791 | } |
| 8792 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 8793 | nss = adapter->sta_info[sta_id].nss; |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8794 | freq = cds_chan_to_freq( |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 8795 | (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operating_channel); |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 8796 | rate_flags = adapter->sta_info[sta_id].rate_flags; |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8797 | } else { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8798 | hdd_err("Not Associated! with mac "MAC_ADDRESS_STR, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8799 | MAC_ADDR_ARRAY(peer_mac)); |
| 8800 | return -EINVAL; |
| 8801 | } |
| 8802 | |
| 8803 | if (!(rate_flags & eHAL_TX_RATE_LEGACY)) { |
| 8804 | if (rate_flags & eHAL_TX_RATE_VHT80) { |
| 8805 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8806 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && !defined(WITH_BACKPORTS) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8807 | final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8808 | #endif |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8809 | } else if (rate_flags & eHAL_TX_RATE_VHT40) { |
| 8810 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8811 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && !defined(WITH_BACKPORTS) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8812 | final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8813 | #endif |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8814 | } else if (rate_flags & eHAL_TX_RATE_VHT20) { |
| 8815 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 8816 | } else if (rate_flags & |
| 8817 | (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) { |
| 8818 | final_rate_flags |= RATE_INFO_FLAGS_MCS; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8819 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && !defined(WITH_BACKPORTS) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8820 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 8821 | final_rate_flags |= |
| 8822 | RATE_INFO_FLAGS_40_MHZ_WIDTH; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 8823 | #endif |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8824 | } |
| 8825 | |
| 8826 | if (rate_flags & eHAL_TX_RATE_SGI) { |
| 8827 | if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS)) |
| 8828 | final_rate_flags |= RATE_INFO_FLAGS_MCS; |
| 8829 | final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 8830 | } |
| 8831 | } |
| 8832 | |
| 8833 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 8834 | sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN); |
| 8835 | |
| 8836 | if (NULL == reply_skb) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8837 | hdd_err("getLinkProperties: skb alloc failed"); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8838 | return -EINVAL; |
| 8839 | } |
| 8840 | |
| 8841 | if (nla_put_u8(reply_skb, |
| 8842 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS, |
| 8843 | nss) || |
| 8844 | nla_put_u8(reply_skb, |
| 8845 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS, |
| 8846 | final_rate_flags) || |
| 8847 | nla_put_u32(reply_skb, |
| 8848 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ, |
| 8849 | freq)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8850 | hdd_err("nla_put failed"); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8851 | kfree_skb(reply_skb); |
| 8852 | return -EINVAL; |
| 8853 | } |
| 8854 | |
| 8855 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 8856 | } |
| 8857 | |
| 8858 | /** |
| 8859 | * wlan_hdd_cfg80211_get_link_properties() - Wrapper function to get link |
| 8860 | * properties. |
| 8861 | * @wiphy: WIPHY structure pointer |
| 8862 | * @wdev: Wireless device structure pointer |
| 8863 | * @data: Pointer to the data received |
| 8864 | * @data_len: Length of the data received |
| 8865 | * |
| 8866 | * This function is used to get link properties like nss, rate flags and |
| 8867 | * operating frequency for the active connection with the given peer. |
| 8868 | * |
| 8869 | * Return: 0 on success and errno on failure |
| 8870 | */ |
| 8871 | static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy, |
| 8872 | struct wireless_dev *wdev, |
| 8873 | const void *data, |
| 8874 | int data_len) |
| 8875 | { |
| 8876 | int ret = 0; |
| 8877 | |
| 8878 | cds_ssr_protect(__func__); |
| 8879 | ret = __wlan_hdd_cfg80211_get_link_properties(wiphy, |
| 8880 | wdev, data, data_len); |
| 8881 | cds_ssr_unprotect(__func__); |
| 8882 | |
| 8883 | return ret; |
| 8884 | } |
| 8885 | |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8886 | static const struct |
| 8887 | nla_policy |
| 8888 | qca_wlan_vendor_ota_test_policy |
| 8889 | [QCA_WLAN_VENDOR_ATTR_OTA_TEST_MAX + 1] = { |
| 8890 | [QCA_WLAN_VENDOR_ATTR_OTA_TEST_ENABLE] = {.type = NLA_U8 }, |
| 8891 | }; |
| 8892 | |
| 8893 | /** |
| 8894 | * __wlan_hdd_cfg80211_set_ota_test () - enable/disable OTA test |
| 8895 | * @wiphy: Pointer to wireless phy |
| 8896 | * @wdev: Pointer to wireless device |
| 8897 | * @data: Pointer to data |
| 8898 | * @data_len: Data length |
| 8899 | * |
| 8900 | * Return: 0 on success, negative errno on failure |
| 8901 | */ |
| 8902 | static int __wlan_hdd_cfg80211_set_ota_test(struct wiphy *wiphy, |
| 8903 | struct wireless_dev *wdev, |
| 8904 | const void *data, |
| 8905 | int data_len) |
| 8906 | { |
| 8907 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 8908 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8909 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 8910 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8911 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_OTA_TEST_MAX + 1]; |
| 8912 | uint8_t ota_enable = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8913 | QDF_STATUS status; |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8914 | uint32_t current_roam_state; |
| 8915 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8916 | hdd_enter_dev(dev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 8917 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8918 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8919 | hdd_err("Command not allowed in FTM mode"); |
| 8920 | return -EPERM; |
| 8921 | } |
| 8922 | |
| 8923 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 8924 | return -EINVAL; |
| 8925 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 8926 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_OTA_TEST_MAX, |
| 8927 | data, data_len, |
| 8928 | qca_wlan_vendor_ota_test_policy)) { |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8929 | hdd_err("invalid attr"); |
| 8930 | return -EINVAL; |
| 8931 | } |
| 8932 | |
| 8933 | if (!tb[QCA_WLAN_VENDOR_ATTR_OTA_TEST_ENABLE]) { |
| 8934 | hdd_err("attr ota test failed"); |
| 8935 | return -EINVAL; |
| 8936 | } |
| 8937 | |
| 8938 | ota_enable = nla_get_u8( |
| 8939 | tb[QCA_WLAN_VENDOR_ATTR_OTA_TEST_ENABLE]); |
| 8940 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 8941 | hdd_debug(" OTA test enable = %d", ota_enable); |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8942 | if (ota_enable != 1) { |
| 8943 | hdd_err("Invalid value, only enable test mode is supported!"); |
| 8944 | return -EINVAL; |
| 8945 | } |
| 8946 | |
| 8947 | current_roam_state = |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8948 | sme_get_current_roam_state(hal, adapter->session_id); |
| 8949 | status = sme_stop_roaming(hal, adapter->session_id, |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8950 | eCsrHddIssued); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8951 | if (status != QDF_STATUS_SUCCESS) { |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8952 | hdd_err("Enable/Disable roaming failed"); |
| 8953 | return -EINVAL; |
| 8954 | } |
| 8955 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8956 | status = sme_ps_enable_disable(hal, adapter->session_id, |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8957 | SME_PS_DISABLE); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8958 | if (status != QDF_STATUS_SUCCESS) { |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8959 | hdd_err("Enable/Disable power save failed"); |
| 8960 | /* restore previous roaming setting */ |
| 8961 | if (current_roam_state == eCSR_ROAMING_STATE_JOINING || |
| 8962 | current_roam_state == eCSR_ROAMING_STATE_JOINED) |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8963 | status = sme_start_roaming(hal, adapter->session_id, |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8964 | eCsrHddIssued); |
| 8965 | else if (current_roam_state == eCSR_ROAMING_STATE_STOP || |
| 8966 | current_roam_state == eCSR_ROAMING_STATE_IDLE) |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8967 | status = sme_stop_roaming(hal, adapter->session_id, |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8968 | eCsrHddIssued); |
| 8969 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8970 | if (status != QDF_STATUS_SUCCESS) |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8971 | hdd_err("Restoring roaming state failed"); |
| 8972 | |
| 8973 | return -EINVAL; |
| 8974 | } |
| 8975 | |
| 8976 | |
| 8977 | return 0; |
| 8978 | } |
| 8979 | |
| 8980 | /** |
| 8981 | * wlan_hdd_cfg80211_set_ota_test () - Enable or disable OTA test |
| 8982 | * @wiphy: Pointer to wireless phy |
| 8983 | * @wdev: Pointer to wireless device |
| 8984 | * @data: Pointer to data |
| 8985 | * @data_len: Data length |
| 8986 | * |
| 8987 | * Return: 0 on success, negative errno on failure |
| 8988 | */ |
| 8989 | static int wlan_hdd_cfg80211_set_ota_test(struct wiphy *wiphy, |
| 8990 | struct wireless_dev *wdev, |
| 8991 | const void *data, |
| 8992 | int data_len) |
| 8993 | { |
| 8994 | int ret = 0; |
| 8995 | |
| 8996 | cds_ssr_protect(__func__); |
| 8997 | ret = __wlan_hdd_cfg80211_set_ota_test(wiphy, wdev, data, data_len); |
| 8998 | cds_ssr_unprotect(__func__); |
| 8999 | |
| 9000 | return ret; |
| 9001 | } |
| 9002 | |
Dustin Brown | 8f3b056 | 2017-06-06 11:38:45 -0700 | [diff] [blame] | 9003 | static const struct nla_policy |
| 9004 | txpower_scale_policy[QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_MAX + 1] = { |
| 9005 | [QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE] = { .type = NLA_U8 }, |
| 9006 | }; |
| 9007 | |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9008 | /** |
| 9009 | * __wlan_hdd_cfg80211_txpower_scale () - txpower scaling |
| 9010 | * @wiphy: Pointer to wireless phy |
| 9011 | * @wdev: Pointer to wireless device |
| 9012 | * @data: Pointer to data |
| 9013 | * @data_len: Data length |
| 9014 | * |
| 9015 | * Return: 0 on success, negative errno on failure |
| 9016 | */ |
| 9017 | static int __wlan_hdd_cfg80211_txpower_scale(struct wiphy *wiphy, |
| 9018 | struct wireless_dev *wdev, |
| 9019 | const void *data, |
| 9020 | int data_len) |
| 9021 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9022 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9023 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9024 | struct hdd_adapter *adapter; |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 9025 | int ret; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9026 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_MAX + 1]; |
| 9027 | uint8_t scale_value; |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 9028 | QDF_STATUS status; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9029 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9030 | hdd_enter_dev(dev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 9031 | |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9032 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9033 | if (ret) |
| 9034 | return ret; |
| 9035 | |
| 9036 | adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9037 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 9038 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_MAX, |
| 9039 | data, data_len, txpower_scale_policy)) { |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9040 | hdd_err("Invalid ATTR"); |
| 9041 | return -EINVAL; |
| 9042 | } |
| 9043 | |
| 9044 | if (!tb[QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE]) { |
| 9045 | hdd_err("attr tx power scale failed"); |
| 9046 | return -EINVAL; |
| 9047 | } |
| 9048 | |
| 9049 | scale_value = nla_get_u8(tb |
| 9050 | [QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE]); |
| 9051 | |
| 9052 | if (scale_value > MAX_TXPOWER_SCALE) { |
| 9053 | hdd_err("Invalid tx power scale level"); |
| 9054 | return -EINVAL; |
| 9055 | } |
| 9056 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 9057 | status = wma_set_tx_power_scale(adapter->session_id, scale_value); |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9058 | |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 9059 | if (QDF_STATUS_SUCCESS != status) { |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9060 | hdd_err("Set tx power scale failed"); |
| 9061 | return -EINVAL; |
| 9062 | } |
| 9063 | |
| 9064 | return 0; |
| 9065 | } |
| 9066 | |
| 9067 | /** |
| 9068 | * wlan_hdd_cfg80211_txpower_scale () - txpower scaling |
| 9069 | * @wiphy: Pointer to wireless phy |
| 9070 | * @wdev: Pointer to wireless device |
| 9071 | * @data: Pointer to data |
| 9072 | * @data_len: Data length |
| 9073 | * |
| 9074 | * Return: 0 on success, negative errno on failure |
| 9075 | */ |
| 9076 | static int wlan_hdd_cfg80211_txpower_scale(struct wiphy *wiphy, |
| 9077 | struct wireless_dev *wdev, |
| 9078 | const void *data, |
| 9079 | int data_len) |
| 9080 | { |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 9081 | int ret; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9082 | |
| 9083 | cds_ssr_protect(__func__); |
| 9084 | ret = __wlan_hdd_cfg80211_txpower_scale(wiphy, wdev, |
| 9085 | data, data_len); |
| 9086 | cds_ssr_unprotect(__func__); |
| 9087 | |
| 9088 | return ret; |
| 9089 | } |
| 9090 | |
Dustin Brown | 498b11a | 2017-06-06 12:29:43 -0700 | [diff] [blame] | 9091 | static const struct nla_policy txpower_scale_decr_db_policy |
| 9092 | [QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB_MAX + 1] = { |
| 9093 | [QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB] = { .type = NLA_U8 }, |
| 9094 | }; |
| 9095 | |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9096 | /** |
| 9097 | * __wlan_hdd_cfg80211_txpower_scale_decr_db () - txpower scaling |
| 9098 | * @wiphy: Pointer to wireless phy |
| 9099 | * @wdev: Pointer to wireless device |
| 9100 | * @data: Pointer to data |
| 9101 | * @data_len: Data length |
| 9102 | * |
| 9103 | * Return: 0 on success, negative errno on failure |
| 9104 | */ |
| 9105 | static int __wlan_hdd_cfg80211_txpower_scale_decr_db(struct wiphy *wiphy, |
| 9106 | struct wireless_dev *wdev, |
| 9107 | const void *data, |
| 9108 | int data_len) |
| 9109 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9110 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9111 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9112 | struct hdd_adapter *adapter; |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 9113 | int ret; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9114 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB_MAX + 1]; |
| 9115 | uint8_t scale_value; |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 9116 | QDF_STATUS status; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9117 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9118 | hdd_enter_dev(dev); |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 9119 | |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9120 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9121 | if (ret) |
| 9122 | return ret; |
| 9123 | |
| 9124 | adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9125 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 9126 | if (wlan_cfg80211_nla_parse(tb, |
| 9127 | QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB_MAX, |
| 9128 | data, data_len, |
| 9129 | txpower_scale_decr_db_policy)) { |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9130 | hdd_err("Invalid ATTR"); |
| 9131 | return -EINVAL; |
| 9132 | } |
| 9133 | |
| 9134 | if (!tb[QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB]) { |
| 9135 | hdd_err("attr tx power decrease db value failed"); |
| 9136 | return -EINVAL; |
| 9137 | } |
| 9138 | |
| 9139 | scale_value = nla_get_u8(tb |
| 9140 | [QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB]); |
| 9141 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 9142 | status = wma_set_tx_power_scale_decr_db(adapter->session_id, |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 9143 | scale_value); |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9144 | |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 9145 | if (QDF_STATUS_SUCCESS != status) { |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9146 | hdd_err("Set tx power decrease db failed"); |
| 9147 | return -EINVAL; |
| 9148 | } |
| 9149 | |
| 9150 | return 0; |
| 9151 | } |
| 9152 | |
| 9153 | /** |
| 9154 | * wlan_hdd_cfg80211_txpower_scale_decr_db () - txpower scaling |
| 9155 | * @wiphy: Pointer to wireless phy |
| 9156 | * @wdev: Pointer to wireless device |
| 9157 | * @data: Pointer to data |
| 9158 | * @data_len: Data length |
| 9159 | * |
| 9160 | * Return: 0 on success, negative errno on failure |
| 9161 | */ |
| 9162 | static int wlan_hdd_cfg80211_txpower_scale_decr_db(struct wiphy *wiphy, |
| 9163 | struct wireless_dev *wdev, |
| 9164 | const void *data, |
| 9165 | int data_len) |
| 9166 | { |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 9167 | int ret; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9168 | |
| 9169 | cds_ssr_protect(__func__); |
| 9170 | ret = __wlan_hdd_cfg80211_txpower_scale_decr_db(wiphy, wdev, |
| 9171 | data, data_len); |
| 9172 | cds_ssr_unprotect(__func__); |
| 9173 | |
| 9174 | return ret; |
| 9175 | } |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9176 | |
| 9177 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9178 | * __wlan_hdd_cfg80211_conditional_chan_switch() - Conditional channel switch |
| 9179 | * @wiphy: Pointer to wireless phy |
| 9180 | * @wdev: Pointer to wireless device |
| 9181 | * @data: Pointer to data |
| 9182 | * @data_len: Data length |
| 9183 | * |
| 9184 | * Processes the conditional channel switch request and invokes the helper |
| 9185 | * APIs to process the channel switch request. |
| 9186 | * |
| 9187 | * Return: 0 on success, negative errno on failure |
| 9188 | */ |
| 9189 | static int __wlan_hdd_cfg80211_conditional_chan_switch(struct wiphy *wiphy, |
| 9190 | struct wireless_dev *wdev, |
| 9191 | const void *data, |
| 9192 | int data_len) |
| 9193 | { |
| 9194 | int ret; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9195 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9196 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9197 | struct hdd_adapter *adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9198 | struct nlattr |
| 9199 | *tb[QCA_WLAN_VENDOR_ATTR_SAP_CONDITIONAL_CHAN_SWITCH_MAX + 1]; |
| 9200 | uint32_t freq_len, i; |
| 9201 | uint32_t *freq; |
SaidiReddy Yenuga | c0c34cf | 2017-02-13 17:44:40 +0530 | [diff] [blame] | 9202 | uint8_t chans[QDF_MAX_NUM_CHAN] = {0}; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9203 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9204 | hdd_enter_dev(dev); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9205 | |
| 9206 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9207 | if (ret) |
| 9208 | return ret; |
| 9209 | |
| 9210 | if (!hdd_ctx->config->enableDFSMasterCap) { |
| 9211 | hdd_err("DFS master capability is not present in the driver"); |
| 9212 | return -EINVAL; |
| 9213 | } |
| 9214 | |
| 9215 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 9216 | hdd_err("Command not allowed in FTM mode"); |
| 9217 | return -EPERM; |
| 9218 | } |
| 9219 | |
| 9220 | adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9221 | if (adapter->device_mode != QDF_SAP_MODE) { |
| 9222 | hdd_err("Invalid device mode %d", adapter->device_mode); |
| 9223 | return -EINVAL; |
| 9224 | } |
| 9225 | |
Rajeev Kumar | 1c40f07 | 2017-06-05 15:24:05 -0700 | [diff] [blame] | 9226 | /* |
| 9227 | * audit note: it is ok to pass a NULL policy here since only |
| 9228 | * one attribute is parsed which is array of frequencies and |
| 9229 | * it is explicitly validated for both under read and over read |
| 9230 | */ |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 9231 | if (wlan_cfg80211_nla_parse(tb, |
| 9232 | QCA_WLAN_VENDOR_ATTR_SAP_CONDITIONAL_CHAN_SWITCH_MAX, |
| 9233 | data, data_len, NULL)) { |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9234 | hdd_err("Invalid ATTR"); |
| 9235 | return -EINVAL; |
| 9236 | } |
| 9237 | |
| 9238 | if (!tb[QCA_WLAN_VENDOR_ATTR_SAP_CONDITIONAL_CHAN_SWITCH_FREQ_LIST]) { |
| 9239 | hdd_err("Frequency list is missing"); |
| 9240 | return -EINVAL; |
| 9241 | } |
| 9242 | |
| 9243 | freq_len = nla_len( |
| 9244 | tb[QCA_WLAN_VENDOR_ATTR_SAP_CONDITIONAL_CHAN_SWITCH_FREQ_LIST])/ |
| 9245 | sizeof(uint32_t); |
| 9246 | |
| 9247 | if (freq_len > QDF_MAX_NUM_CHAN) { |
| 9248 | hdd_err("insufficient space to hold channels"); |
| 9249 | return -ENOMEM; |
| 9250 | } |
| 9251 | |
| 9252 | hdd_debug("freq_len=%d", freq_len); |
| 9253 | |
| 9254 | freq = nla_data( |
| 9255 | tb[QCA_WLAN_VENDOR_ATTR_SAP_CONDITIONAL_CHAN_SWITCH_FREQ_LIST]); |
| 9256 | |
| 9257 | |
| 9258 | for (i = 0; i < freq_len; i++) { |
| 9259 | if (freq[i] == 0) |
| 9260 | chans[i] = 0; |
| 9261 | else |
| 9262 | chans[i] = ieee80211_frequency_to_channel(freq[i]); |
| 9263 | |
| 9264 | hdd_debug("freq[%d]=%d", i, freq[i]); |
| 9265 | } |
| 9266 | |
| 9267 | /* |
| 9268 | * The input frequency list from user space is designed to be a |
| 9269 | * priority based frequency list. This is only to accommodate any |
| 9270 | * future request. But, current requirement is only to perform CAC |
| 9271 | * on a single channel. So, the first entry from the list is picked. |
| 9272 | * |
| 9273 | * If channel is zero, any channel in the available outdoor regulatory |
| 9274 | * domain will be selected. |
| 9275 | */ |
| 9276 | ret = wlan_hdd_request_pre_cac(chans[0]); |
| 9277 | if (ret) { |
| 9278 | hdd_err("pre cac request failed with reason:%d", ret); |
| 9279 | return ret; |
| 9280 | } |
| 9281 | |
| 9282 | return 0; |
| 9283 | } |
| 9284 | |
Rajeev Kumar | 67f5b87 | 2017-06-06 13:26:57 -0700 | [diff] [blame] | 9285 | /* P2P listen offload device types parameters length in bytes */ |
| 9286 | #define P2P_LO_MAX_REQ_DEV_TYPE_COUNT (10) |
| 9287 | #define P2P_LO_WPS_DEV_TYPE_LEN (8) |
| 9288 | #define P2P_LO_DEV_TYPE_MAX_LEN \ |
| 9289 | (P2P_LO_MAX_REQ_DEV_TYPE_COUNT * P2P_LO_WPS_DEV_TYPE_LEN) |
| 9290 | |
| 9291 | static const struct nla_policy |
| 9292 | p2p_listen_offload_policy[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_MAX + 1] = { |
| 9293 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_CHANNEL] = { .type = NLA_U32 }, |
| 9294 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_PERIOD] = { .type = NLA_U32 }, |
| 9295 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_INTERVAL] = { |
| 9296 | .type = NLA_U32 }, |
| 9297 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_COUNT] = { .type = NLA_U32 }, |
| 9298 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_DEVICE_TYPES] = { |
| 9299 | .type = NLA_BINARY, |
| 9300 | .len = P2P_LO_DEV_TYPE_MAX_LEN }, |
| 9301 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_VENDOR_IE] = { |
| 9302 | .type = NLA_BINARY, |
| 9303 | .len = MAX_GENIE_LEN }, |
| 9304 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_CTRL_FLAG] = { |
| 9305 | .type = NLA_U32 }, |
| 9306 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_CHANNEL] = { .type = NLA_U32 }, |
| 9307 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON] = { |
| 9308 | .type = NLA_U8 }, |
| 9309 | }; |
| 9310 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9311 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9312 | * __wlan_hdd_cfg80211_p2p_lo_start () - start P2P Listen Offload |
| 9313 | * @wiphy: Pointer to wireless phy |
| 9314 | * @wdev: Pointer to wireless device |
| 9315 | * @data: Pointer to data |
| 9316 | * @data_len: Data length |
| 9317 | * |
| 9318 | * This function is to process the p2p listen offload start vendor |
| 9319 | * command. It parses the input parameters and invoke WMA API to |
| 9320 | * send the command to firmware. |
| 9321 | * |
| 9322 | * Return: 0 on success, negative errno on failure |
| 9323 | */ |
| 9324 | static int __wlan_hdd_cfg80211_p2p_lo_start(struct wiphy *wiphy, |
| 9325 | struct wireless_dev *wdev, |
| 9326 | const void *data, |
| 9327 | int data_len) |
| 9328 | { |
| 9329 | int ret; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9330 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9331 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9332 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9333 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_MAX + 1]; |
| 9334 | struct sir_p2p_lo_start params; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9335 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9336 | hdd_enter_dev(dev); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9337 | |
| 9338 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9339 | if (ret) |
| 9340 | return ret; |
| 9341 | |
| 9342 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 9343 | hdd_err("Command not allowed in FTM mode"); |
| 9344 | return -EPERM; |
| 9345 | } |
| 9346 | |
| 9347 | adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9348 | if ((adapter->device_mode != QDF_P2P_DEVICE_MODE) && |
| 9349 | (adapter->device_mode != QDF_P2P_CLIENT_MODE) && |
| 9350 | (adapter->device_mode != QDF_P2P_GO_MODE)) { |
| 9351 | hdd_err("Invalid device mode %d", adapter->device_mode); |
| 9352 | return -EINVAL; |
| 9353 | } |
| 9354 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 9355 | if (wlan_cfg80211_nla_parse(tb, |
| 9356 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_MAX, |
| 9357 | data, data_len, |
| 9358 | p2p_listen_offload_policy)) { |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9359 | hdd_err("Invalid ATTR"); |
| 9360 | return -EINVAL; |
| 9361 | } |
| 9362 | |
| 9363 | memset(¶ms, 0, sizeof(params)); |
| 9364 | |
| 9365 | if (!tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_CTRL_FLAG]) |
| 9366 | params.ctl_flags = 1; /* set to default value */ |
| 9367 | else |
| 9368 | params.ctl_flags = nla_get_u32(tb |
| 9369 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_CTRL_FLAG]); |
| 9370 | |
| 9371 | if (!tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_CHANNEL] || |
| 9372 | !tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_PERIOD] || |
| 9373 | !tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_INTERVAL] || |
| 9374 | !tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_COUNT] || |
| 9375 | !tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_DEVICE_TYPES] || |
| 9376 | !tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_VENDOR_IE]) { |
| 9377 | hdd_err("Attribute parsing failed"); |
| 9378 | return -EINVAL; |
| 9379 | } |
| 9380 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 9381 | params.vdev_id = adapter->session_id; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9382 | params.freq = nla_get_u32(tb |
| 9383 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_CHANNEL]); |
| 9384 | if ((params.freq != 2412) && (params.freq != 2437) && |
| 9385 | (params.freq != 2462)) { |
| 9386 | hdd_err("Invalid listening channel: %d", params.freq); |
| 9387 | return -EINVAL; |
| 9388 | } |
| 9389 | |
| 9390 | params.period = nla_get_u32(tb |
| 9391 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_PERIOD]); |
| 9392 | if (!((params.period > 0) && (params.period < UINT_MAX))) { |
| 9393 | hdd_err("Invalid period: %d", params.period); |
| 9394 | return -EINVAL; |
| 9395 | } |
| 9396 | |
| 9397 | params.interval = nla_get_u32(tb |
| 9398 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_INTERVAL]); |
| 9399 | if (!((params.interval > 0) && (params.interval < UINT_MAX))) { |
| 9400 | hdd_err("Invalid interval: %d", params.interval); |
| 9401 | return -EINVAL; |
| 9402 | } |
| 9403 | |
| 9404 | params.count = nla_get_u32(tb |
| 9405 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_COUNT]); |
Peng Xu | 6d578ef | 2017-01-10 06:22:21 -0800 | [diff] [blame] | 9406 | if (!((params.count >= 0) && (params.count < UINT_MAX))) { |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9407 | hdd_err("Invalid count: %d", params.count); |
| 9408 | return -EINVAL; |
| 9409 | } |
| 9410 | |
| 9411 | params.device_types = nla_data(tb |
| 9412 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_DEVICE_TYPES]); |
| 9413 | if (params.device_types == NULL) { |
| 9414 | hdd_err("Invalid device types"); |
| 9415 | return -EINVAL; |
| 9416 | } |
| 9417 | |
| 9418 | params.dev_types_len = nla_len(tb |
| 9419 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_DEVICE_TYPES]); |
Rajeev Kumar | 67f5b87 | 2017-06-06 13:26:57 -0700 | [diff] [blame] | 9420 | /* device type length has to be multiple of P2P_LO_WPS_DEV_TYPE_LEN */ |
| 9421 | if (0 != (params.dev_types_len % P2P_LO_WPS_DEV_TYPE_LEN)) { |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9422 | hdd_err("Invalid device type length: %d", params.dev_types_len); |
| 9423 | return -EINVAL; |
| 9424 | } |
| 9425 | |
| 9426 | params.probe_resp_tmplt = nla_data(tb |
| 9427 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_VENDOR_IE]); |
| 9428 | if (params.probe_resp_tmplt == NULL) { |
| 9429 | hdd_err("Invalid probe response template"); |
| 9430 | return -EINVAL; |
| 9431 | } |
| 9432 | |
Rajeev Kumar | 67f5b87 | 2017-06-06 13:26:57 -0700 | [diff] [blame] | 9433 | /* |
| 9434 | * IEs minimum length should be 2 bytes: 1 byte for element id |
| 9435 | * and 1 byte for element id length. |
| 9436 | */ |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9437 | params.probe_resp_len = nla_len(tb |
| 9438 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_VENDOR_IE]); |
Rajeev Kumar | 67f5b87 | 2017-06-06 13:26:57 -0700 | [diff] [blame] | 9439 | if (params.probe_resp_len < MIN_GENIE_LEN) { |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9440 | hdd_err("Invalid probe resp template length: %d", |
| 9441 | params.probe_resp_len); |
| 9442 | return -EINVAL; |
| 9443 | } |
| 9444 | |
| 9445 | hdd_debug("P2P LO params: freq=%d, period=%d, interval=%d, count=%d", |
| 9446 | params.freq, params.period, params.interval, params.count); |
| 9447 | |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 9448 | return wlan_hdd_listen_offload_start(adapter, ¶ms); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9449 | } |
| 9450 | |
| 9451 | |
| 9452 | /** |
| 9453 | * wlan_hdd_cfg80211_p2p_lo_start () - start P2P Listen Offload |
| 9454 | * @wiphy: Pointer to wireless phy |
| 9455 | * @wdev: Pointer to wireless device |
| 9456 | * @data: Pointer to data |
| 9457 | * @data_len: Data length |
| 9458 | * |
| 9459 | * This function inovkes internal __wlan_hdd_cfg80211_p2p_lo_start() |
| 9460 | * to process p2p listen offload start vendor command. |
| 9461 | * |
| 9462 | * Return: 0 on success, negative errno on failure |
| 9463 | */ |
| 9464 | static int wlan_hdd_cfg80211_p2p_lo_start(struct wiphy *wiphy, |
| 9465 | struct wireless_dev *wdev, |
| 9466 | const void *data, |
| 9467 | int data_len) |
| 9468 | { |
| 9469 | int ret = 0; |
| 9470 | |
| 9471 | cds_ssr_protect(__func__); |
| 9472 | ret = __wlan_hdd_cfg80211_p2p_lo_start(wiphy, wdev, |
| 9473 | data, data_len); |
| 9474 | cds_ssr_unprotect(__func__); |
| 9475 | |
| 9476 | return ret; |
| 9477 | } |
| 9478 | |
| 9479 | /** |
| 9480 | * __wlan_hdd_cfg80211_p2p_lo_stop () - stop P2P Listen Offload |
| 9481 | * @wiphy: Pointer to wireless phy |
| 9482 | * @wdev: Pointer to wireless device |
| 9483 | * @data: Pointer to data |
| 9484 | * @data_len: Data length |
| 9485 | * |
| 9486 | * This function is to process the p2p listen offload stop vendor |
| 9487 | * command. It invokes WMA API to send command to firmware. |
| 9488 | * |
| 9489 | * Return: 0 on success, negative errno on failure |
| 9490 | */ |
| 9491 | static int __wlan_hdd_cfg80211_p2p_lo_stop(struct wiphy *wiphy, |
| 9492 | struct wireless_dev *wdev, |
| 9493 | const void *data, |
| 9494 | int data_len) |
| 9495 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9496 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9497 | struct net_device *dev = wdev->netdev; |
| 9498 | |
| 9499 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 9500 | hdd_err("Command not allowed in FTM mode"); |
| 9501 | return -EPERM; |
| 9502 | } |
| 9503 | |
| 9504 | adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9505 | if ((adapter->device_mode != QDF_P2P_DEVICE_MODE) && |
| 9506 | (adapter->device_mode != QDF_P2P_CLIENT_MODE) && |
| 9507 | (adapter->device_mode != QDF_P2P_GO_MODE)) { |
| 9508 | hdd_err("Invalid device mode"); |
| 9509 | return -EINVAL; |
| 9510 | } |
| 9511 | |
Wu Gao | 9a704f4 | 2017-03-10 18:42:11 +0800 | [diff] [blame] | 9512 | return wlan_hdd_listen_offload_stop(adapter); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9513 | } |
| 9514 | |
| 9515 | /** |
| 9516 | * wlan_hdd_cfg80211_p2p_lo_stop () - stop P2P Listen Offload |
| 9517 | * @wiphy: Pointer to wireless phy |
| 9518 | * @wdev: Pointer to wireless device |
| 9519 | * @data: Pointer to data |
| 9520 | * @data_len: Data length |
| 9521 | * |
| 9522 | * This function inovkes internal __wlan_hdd_cfg80211_p2p_lo_stop() |
| 9523 | * to process p2p listen offload stop vendor command. |
| 9524 | * |
| 9525 | * Return: 0 on success, negative errno on failure |
| 9526 | */ |
| 9527 | static int wlan_hdd_cfg80211_p2p_lo_stop(struct wiphy *wiphy, |
| 9528 | struct wireless_dev *wdev, |
| 9529 | const void *data, |
| 9530 | int data_len) |
| 9531 | { |
| 9532 | int ret = 0; |
| 9533 | |
| 9534 | cds_ssr_protect(__func__); |
| 9535 | ret = __wlan_hdd_cfg80211_p2p_lo_stop(wiphy, wdev, |
| 9536 | data, data_len); |
| 9537 | cds_ssr_unprotect(__func__); |
| 9538 | |
| 9539 | return ret; |
| 9540 | } |
| 9541 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9542 | /** |
| 9543 | * wlan_hdd_cfg80211_conditional_chan_switch() - SAP conditional channel switch |
| 9544 | * @wiphy: Pointer to wireless phy |
| 9545 | * @wdev: Pointer to wireless device |
| 9546 | * @data: Pointer to data |
| 9547 | * @data_len: Data length |
| 9548 | * |
| 9549 | * Inovkes internal API __wlan_hdd_cfg80211_conditional_chan_switch() |
| 9550 | * to process the conditional channel switch request. |
| 9551 | * |
| 9552 | * Return: 0 on success, negative errno on failure |
| 9553 | */ |
| 9554 | static int wlan_hdd_cfg80211_conditional_chan_switch(struct wiphy *wiphy, |
| 9555 | struct wireless_dev *wdev, |
| 9556 | const void *data, |
| 9557 | int data_len) |
| 9558 | { |
| 9559 | int ret; |
| 9560 | |
| 9561 | cds_ssr_protect(__func__); |
| 9562 | ret = __wlan_hdd_cfg80211_conditional_chan_switch(wiphy, wdev, |
| 9563 | data, data_len); |
| 9564 | cds_ssr_unprotect(__func__); |
| 9565 | |
| 9566 | return ret; |
| 9567 | } |
| 9568 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9569 | /* |
| 9570 | * define short names for the global vendor params |
| 9571 | * used by __wlan_hdd_cfg80211_bpf_offload() |
| 9572 | */ |
| 9573 | #define BPF_INVALID \ |
| 9574 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_INVALID |
| 9575 | #define BPF_SET_RESET \ |
| 9576 | QCA_WLAN_VENDOR_ATTR_SET_RESET_PACKET_FILTER |
| 9577 | #define BPF_VERSION \ |
| 9578 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_VERSION |
| 9579 | #define BPF_FILTER_ID \ |
| 9580 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_ID |
| 9581 | #define BPF_PACKET_SIZE \ |
| 9582 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_SIZE |
| 9583 | #define BPF_CURRENT_OFFSET \ |
| 9584 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_CURRENT_OFFSET |
| 9585 | #define BPF_PROGRAM \ |
| 9586 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_PROGRAM |
| 9587 | #define BPF_MAX \ |
| 9588 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_MAX |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 9589 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9590 | static const struct nla_policy |
| 9591 | wlan_hdd_bpf_offload_policy[BPF_MAX + 1] = { |
| 9592 | [BPF_SET_RESET] = {.type = NLA_U32}, |
| 9593 | [BPF_VERSION] = {.type = NLA_U32}, |
| 9594 | [BPF_FILTER_ID] = {.type = NLA_U32}, |
| 9595 | [BPF_PACKET_SIZE] = {.type = NLA_U32}, |
| 9596 | [BPF_CURRENT_OFFSET] = {.type = NLA_U32}, |
| 9597 | [BPF_PROGRAM] = {.type = NLA_U8}, |
| 9598 | }; |
| 9599 | |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9600 | struct bpf_offload_priv { |
| 9601 | struct sir_bpf_get_offload bpf_get_offload; |
| 9602 | }; |
| 9603 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9604 | /** |
| 9605 | * hdd_get_bpf_offload_cb() - Callback function to BPF Offload |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9606 | * @context: opaque context originally passed to SME. HDD always passes |
| 9607 | * a cookie for the request context |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9608 | * @bpf_get_offload: struct for get offload |
| 9609 | * |
| 9610 | * This function receives the response/data from the lower layer and |
| 9611 | * checks to see if the thread is still waiting then post the results to |
| 9612 | * upper layer, if the request has timed out then ignore. |
| 9613 | * |
| 9614 | * Return: None |
| 9615 | */ |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9616 | static void hdd_get_bpf_offload_cb(void *context, |
Jeff Johnson | a867e0c | 2017-01-26 13:43:51 -0800 | [diff] [blame] | 9617 | struct sir_bpf_get_offload *data) |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9618 | { |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9619 | struct hdd_request *request; |
| 9620 | struct bpf_offload_priv *priv; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9621 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9622 | hdd_enter(); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9623 | |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9624 | request = hdd_request_get(context); |
| 9625 | if (!request) { |
| 9626 | hdd_err("Obsolete request"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9627 | return; |
| 9628 | } |
| 9629 | |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9630 | priv = hdd_request_priv(request); |
| 9631 | priv->bpf_get_offload = *data; |
| 9632 | hdd_request_complete(request); |
| 9633 | hdd_request_put(request); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9634 | } |
| 9635 | |
| 9636 | /** |
| 9637 | * hdd_post_get_bpf_capabilities_rsp() - Callback function to BPF Offload |
| 9638 | * @hdd_context: hdd_context |
| 9639 | * @bpf_get_offload: struct for get offload |
| 9640 | * |
| 9641 | * Return: 0 on success, error number otherwise. |
| 9642 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9643 | static int hdd_post_get_bpf_capabilities_rsp(struct hdd_context *hdd_ctx, |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9644 | struct sir_bpf_get_offload *bpf_get_offload) |
| 9645 | { |
| 9646 | struct sk_buff *skb; |
| 9647 | uint32_t nl_buf_len; |
| 9648 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9649 | hdd_enter(); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9650 | |
| 9651 | nl_buf_len = NLMSG_HDRLEN; |
| 9652 | nl_buf_len += |
| 9653 | (sizeof(bpf_get_offload->max_bytes_for_bpf_inst) + NLA_HDRLEN) + |
| 9654 | (sizeof(bpf_get_offload->bpf_version) + NLA_HDRLEN); |
| 9655 | |
| 9656 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 9657 | if (!skb) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9658 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9659 | return -ENOMEM; |
| 9660 | } |
| 9661 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9662 | hdd_debug("BPF Version: %u BPF max bytes: %u", |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9663 | bpf_get_offload->bpf_version, |
| 9664 | bpf_get_offload->max_bytes_for_bpf_inst); |
| 9665 | |
| 9666 | if (nla_put_u32(skb, BPF_PACKET_SIZE, |
| 9667 | bpf_get_offload->max_bytes_for_bpf_inst) || |
| 9668 | nla_put_u32(skb, BPF_VERSION, bpf_get_offload->bpf_version)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9669 | hdd_err("nla put failure"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9670 | goto nla_put_failure; |
| 9671 | } |
| 9672 | |
| 9673 | cfg80211_vendor_cmd_reply(skb); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9674 | hdd_exit(); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9675 | return 0; |
| 9676 | |
| 9677 | nla_put_failure: |
| 9678 | kfree_skb(skb); |
| 9679 | return -EINVAL; |
| 9680 | } |
| 9681 | |
| 9682 | /** |
| 9683 | * hdd_get_bpf_offload - Get BPF offload Capabilities |
| 9684 | * @hdd_ctx: Hdd context |
| 9685 | * |
| 9686 | * Return: 0 on success, errno on failure |
| 9687 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9688 | static int hdd_get_bpf_offload(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9689 | { |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9690 | QDF_STATUS status; |
| 9691 | int ret; |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9692 | void *cookie; |
| 9693 | struct hdd_request *request; |
| 9694 | struct bpf_offload_priv *priv; |
| 9695 | static const struct hdd_request_params params = { |
| 9696 | .priv_size = sizeof(*priv), |
| 9697 | .timeout_ms = WLAN_WAIT_TIME_BPF, |
| 9698 | }; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9699 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9700 | hdd_enter(); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9701 | |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9702 | request = hdd_request_alloc(¶ms); |
| 9703 | if (!request) { |
| 9704 | hdd_err("Unable to allocate request"); |
| 9705 | return -EINVAL; |
| 9706 | } |
| 9707 | cookie = hdd_request_cookie(request); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9708 | |
Jeff Johnson | a867e0c | 2017-01-26 13:43:51 -0800 | [diff] [blame] | 9709 | status = sme_get_bpf_offload_capabilities(hdd_ctx->hHal, |
| 9710 | hdd_get_bpf_offload_cb, |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9711 | cookie); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9712 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9713 | hdd_err("Unable to retrieve BPF caps"); |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9714 | ret = qdf_status_to_os_return(status); |
| 9715 | goto cleanup; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9716 | } |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9717 | ret = hdd_request_wait_for_response(request); |
| 9718 | if (ret) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9719 | hdd_err("Target response timed out"); |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9720 | goto cleanup; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9721 | } |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9722 | priv = hdd_request_priv(request); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9723 | ret = hdd_post_get_bpf_capabilities_rsp(hdd_ctx, |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9724 | &priv->bpf_get_offload); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9725 | if (ret) |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9726 | hdd_err("Failed to post get bpf capabilities"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9727 | |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9728 | cleanup: |
| 9729 | /* |
| 9730 | * either we never sent a request to SME, we sent a request to |
| 9731 | * SME and timed out, or we sent a request to SME, received a |
| 9732 | * response from SME, and posted the response to userspace. |
| 9733 | * regardless we are done with the request. |
| 9734 | */ |
| 9735 | hdd_request_put(request); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9736 | hdd_exit(); |
Jeff Johnson | cd113fc | 2017-01-26 14:42:44 -0800 | [diff] [blame] | 9737 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9738 | return ret; |
| 9739 | } |
| 9740 | |
| 9741 | /** |
| 9742 | * hdd_set_reset_bpf_offload - Post set/reset bpf to SME |
| 9743 | * @hdd_ctx: Hdd context |
| 9744 | * @tb: Length of @data |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 9745 | * @adapter: pointer to adapter struct |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9746 | * |
| 9747 | * Return: 0 on success; errno on failure |
| 9748 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9749 | static int hdd_set_reset_bpf_offload(struct hdd_context *hdd_ctx, |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9750 | struct nlattr **tb, |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9751 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9752 | { |
| 9753 | struct sir_bpf_set_offload *bpf_set_offload; |
| 9754 | QDF_STATUS status; |
| 9755 | int prog_len; |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 9756 | int ret = 0; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9757 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9758 | hdd_enter(); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9759 | |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 9760 | if (adapter->device_mode == QDF_STA_MODE || |
| 9761 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
| 9762 | if (!hdd_conn_is_connected( |
| 9763 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
| 9764 | hdd_err("Not in Connected state!"); |
| 9765 | return -ENOTSUPP; |
| 9766 | } |
| 9767 | } |
| 9768 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9769 | bpf_set_offload = qdf_mem_malloc(sizeof(*bpf_set_offload)); |
| 9770 | if (bpf_set_offload == NULL) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9771 | hdd_err("qdf_mem_malloc failed for bpf_set_offload"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9772 | return -ENOMEM; |
| 9773 | } |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9774 | |
| 9775 | /* Parse and fetch bpf packet size */ |
| 9776 | if (!tb[BPF_PACKET_SIZE]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9777 | hdd_err("attr bpf packet size failed"); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 9778 | ret = -EINVAL; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9779 | goto fail; |
| 9780 | } |
| 9781 | bpf_set_offload->total_length = nla_get_u32(tb[BPF_PACKET_SIZE]); |
| 9782 | |
| 9783 | if (!bpf_set_offload->total_length) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9784 | hdd_debug("BPF reset packet filter received"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9785 | goto post_sme; |
| 9786 | } |
| 9787 | |
| 9788 | /* Parse and fetch bpf program */ |
| 9789 | if (!tb[BPF_PROGRAM]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9790 | hdd_err("attr bpf program failed"); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 9791 | ret = -EINVAL; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9792 | goto fail; |
| 9793 | } |
| 9794 | |
| 9795 | prog_len = nla_len(tb[BPF_PROGRAM]); |
| 9796 | bpf_set_offload->program = qdf_mem_malloc(sizeof(uint8_t) * prog_len); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 9797 | |
| 9798 | if (bpf_set_offload->program == NULL) { |
| 9799 | hdd_err("qdf_mem_malloc failed for bpf offload program"); |
| 9800 | ret = -ENOMEM; |
| 9801 | goto fail; |
| 9802 | } |
| 9803 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9804 | bpf_set_offload->current_length = prog_len; |
| 9805 | nla_memcpy(bpf_set_offload->program, tb[BPF_PROGRAM], prog_len); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 9806 | bpf_set_offload->session_id = adapter->session_id; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9807 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9808 | hdd_debug("BPF set instructions"); |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 9809 | QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG, |
Rajeev Kumar Sirasanagandla | 62b6303 | 2016-08-22 14:56:57 +0530 | [diff] [blame] | 9810 | bpf_set_offload->program, prog_len); |
| 9811 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9812 | /* Parse and fetch filter Id */ |
| 9813 | if (!tb[BPF_FILTER_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9814 | hdd_err("attr filter id failed"); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 9815 | ret = -EINVAL; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9816 | goto fail; |
| 9817 | } |
| 9818 | bpf_set_offload->filter_id = nla_get_u32(tb[BPF_FILTER_ID]); |
| 9819 | |
| 9820 | /* Parse and fetch current offset */ |
| 9821 | if (!tb[BPF_CURRENT_OFFSET]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9822 | hdd_err("attr current offset failed"); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 9823 | ret = -EINVAL; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9824 | goto fail; |
| 9825 | } |
| 9826 | bpf_set_offload->current_offset = nla_get_u32(tb[BPF_CURRENT_OFFSET]); |
| 9827 | |
| 9828 | post_sme: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 9829 | hdd_debug("Posting BPF SET/RESET to SME, session_id: %d Bpf Version: %d filter ID: %d total_length: %d current_length: %d current offset: %d", |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9830 | bpf_set_offload->session_id, |
| 9831 | bpf_set_offload->version, |
| 9832 | bpf_set_offload->filter_id, |
| 9833 | bpf_set_offload->total_length, |
| 9834 | bpf_set_offload->current_length, |
| 9835 | bpf_set_offload->current_offset); |
| 9836 | |
| 9837 | status = sme_set_bpf_instructions(hdd_ctx->hHal, bpf_set_offload); |
| 9838 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9839 | hdd_err("sme_set_bpf_instructions failed(err=%d)", status); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 9840 | ret = -EINVAL; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9841 | goto fail; |
| 9842 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9843 | hdd_exit(); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9844 | |
| 9845 | fail: |
| 9846 | if (bpf_set_offload->current_length) |
| 9847 | qdf_mem_free(bpf_set_offload->program); |
| 9848 | qdf_mem_free(bpf_set_offload); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 9849 | return ret; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9850 | } |
| 9851 | |
| 9852 | /** |
| 9853 | * wlan_hdd_cfg80211_bpf_offload() - Set/Reset to BPF Offload |
| 9854 | * @wiphy: wiphy structure pointer |
| 9855 | * @wdev: Wireless device structure pointer |
| 9856 | * @data: Pointer to the data received |
| 9857 | * @data_len: Length of @data |
| 9858 | * |
| 9859 | * Return: 0 on success; errno on failure |
| 9860 | */ |
| 9861 | static int |
| 9862 | __wlan_hdd_cfg80211_bpf_offload(struct wiphy *wiphy, |
| 9863 | struct wireless_dev *wdev, |
| 9864 | const void *data, int data_len) |
| 9865 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9866 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9867 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 9868 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9869 | struct nlattr *tb[BPF_MAX + 1]; |
| 9870 | int ret_val, packet_filter_subcmd; |
| 9871 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9872 | hdd_enter(); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9873 | |
| 9874 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 9875 | if (ret_val) |
| 9876 | return ret_val; |
| 9877 | |
| 9878 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9879 | hdd_err("Command not allowed in FTM mode"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9880 | return -EINVAL; |
| 9881 | } |
| 9882 | |
| 9883 | if (!hdd_ctx->bpf_enabled) { |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 9884 | hdd_err("BPF offload is not supported/enabled"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9885 | return -ENOTSUPP; |
| 9886 | } |
| 9887 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 9888 | if (wlan_cfg80211_nla_parse(tb, BPF_MAX, data, data_len, |
| 9889 | wlan_hdd_bpf_offload_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9890 | hdd_err("Invalid ATTR"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9891 | return -EINVAL; |
| 9892 | } |
| 9893 | |
| 9894 | if (!tb[BPF_SET_RESET]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9895 | hdd_err("attr bpf set reset failed"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9896 | return -EINVAL; |
| 9897 | } |
| 9898 | |
| 9899 | packet_filter_subcmd = nla_get_u32(tb[BPF_SET_RESET]); |
| 9900 | |
| 9901 | if (packet_filter_subcmd == QCA_WLAN_GET_PACKET_FILTER) |
| 9902 | return hdd_get_bpf_offload(hdd_ctx); |
| 9903 | else |
| 9904 | return hdd_set_reset_bpf_offload(hdd_ctx, tb, |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 9905 | adapter); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 9906 | } |
| 9907 | |
| 9908 | /** |
| 9909 | * wlan_hdd_cfg80211_bpf_offload() - SSR Wrapper to BPF Offload |
| 9910 | * @wiphy: wiphy structure pointer |
| 9911 | * @wdev: Wireless device structure pointer |
| 9912 | * @data: Pointer to the data received |
| 9913 | * @data_len: Length of @data |
| 9914 | * |
| 9915 | * Return: 0 on success; errno on failure |
| 9916 | */ |
| 9917 | |
| 9918 | static int wlan_hdd_cfg80211_bpf_offload(struct wiphy *wiphy, |
| 9919 | struct wireless_dev *wdev, |
| 9920 | const void *data, int data_len) |
| 9921 | { |
| 9922 | int ret; |
| 9923 | |
| 9924 | cds_ssr_protect(__func__); |
| 9925 | ret = __wlan_hdd_cfg80211_bpf_offload(wiphy, wdev, data, data_len); |
| 9926 | cds_ssr_unprotect(__func__); |
| 9927 | |
| 9928 | return ret; |
| 9929 | } |
| 9930 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9931 | /** |
| 9932 | * wlan_hdd_set_pre_cac_status() - Set the pre cac status |
| 9933 | * @pre_cac_adapter: AP adapter used for pre cac |
| 9934 | * @status: Status (true or false) |
| 9935 | * @handle: Global handle |
| 9936 | * |
| 9937 | * Sets the status of pre cac i.e., whether the pre cac is active or not |
| 9938 | * |
| 9939 | * Return: Zero on success, non-zero on failure |
| 9940 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9941 | static int wlan_hdd_set_pre_cac_status(struct hdd_adapter *pre_cac_adapter, |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9942 | bool status, tHalHandle handle) |
| 9943 | { |
| 9944 | QDF_STATUS ret; |
| 9945 | |
| 9946 | ret = wlan_sap_set_pre_cac_status( |
| 9947 | WLAN_HDD_GET_SAP_CTX_PTR(pre_cac_adapter), status, handle); |
| 9948 | if (QDF_IS_STATUS_ERROR(ret)) |
| 9949 | return -EINVAL; |
| 9950 | |
| 9951 | return 0; |
| 9952 | } |
| 9953 | |
| 9954 | /** |
| 9955 | * wlan_hdd_set_chan_before_pre_cac() - Save the channel before pre cac |
| 9956 | * @ap_adapter: AP adapter |
| 9957 | * @chan_before_pre_cac: Channel |
| 9958 | * |
| 9959 | * Saves the channel which the AP was beaconing on before moving to the pre |
| 9960 | * cac channel. If radar is detected on the pre cac channel, this saved |
| 9961 | * channel will be used for AP operations. |
| 9962 | * |
| 9963 | * Return: Zero on success, non-zero on failure |
| 9964 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9965 | static int wlan_hdd_set_chan_before_pre_cac(struct hdd_adapter *ap_adapter, |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 9966 | uint8_t chan_before_pre_cac) |
| 9967 | { |
| 9968 | QDF_STATUS ret; |
| 9969 | |
| 9970 | ret = wlan_sap_set_chan_before_pre_cac( |
| 9971 | WLAN_HDD_GET_SAP_CTX_PTR(ap_adapter), chan_before_pre_cac); |
| 9972 | if (QDF_IS_STATUS_ERROR(ret)) |
| 9973 | return -EINVAL; |
| 9974 | |
| 9975 | return 0; |
| 9976 | } |
| 9977 | |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 9978 | int wlan_hdd_sap_get_valid_channellist(struct hdd_adapter *adapter, |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 9979 | uint32_t *channel_count, |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 9980 | uint8_t *channel_list, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 9981 | enum band_info band) |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 9982 | { |
| 9983 | tsap_Config_t *sap_config; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 9984 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 9985 | uint8_t tmp_chan_list[QDF_MAX_NUM_CHAN] = {0}; |
| 9986 | uint32_t chan_count; |
| 9987 | uint8_t i; |
| 9988 | QDF_STATUS status; |
bings | d79e606 | 2018-01-30 15:40:16 +0800 | [diff] [blame] | 9989 | struct wlan_objmgr_pdev *pdev = hdd_ctx->hdd_pdev; |
| 9990 | uint8_t tmp_chan; |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 9991 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 9992 | sap_config = &adapter->session.ap.sap_config; |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 9993 | |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 9994 | status = |
| 9995 | policy_mgr_get_valid_chans(hdd_ctx->hdd_psoc, |
| 9996 | tmp_chan_list, |
| 9997 | &chan_count); |
| 9998 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9999 | hdd_err("Failed to get channel list"); |
| 10000 | return -EINVAL; |
| 10001 | } |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 10002 | |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 10003 | for (i = 0; i < chan_count; i++) { |
bings | d79e606 | 2018-01-30 15:40:16 +0800 | [diff] [blame] | 10004 | tmp_chan = tmp_chan_list[i]; |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 10005 | if (*channel_count < QDF_MAX_NUM_CHAN) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 10006 | if ((BAND_2G == band) && |
bings | d79e606 | 2018-01-30 15:40:16 +0800 | [diff] [blame] | 10007 | (WLAN_REG_IS_24GHZ_CH(tmp_chan)) && |
| 10008 | (!wlan_reg_is_disable_ch(pdev, tmp_chan))) { |
| 10009 | channel_list[*channel_count] = tmp_chan; |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 10010 | *channel_count += 1; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 10011 | } else if ((BAND_5G == band) && |
bings | d79e606 | 2018-01-30 15:40:16 +0800 | [diff] [blame] | 10012 | (WLAN_REG_IS_5GHZ_CH(tmp_chan)) && |
| 10013 | (!wlan_reg_is_disable_ch(pdev, tmp_chan))) { |
| 10014 | channel_list[*channel_count] = tmp_chan; |
Jayachandran Sreekumaran | 68c952c | 2017-04-24 12:42:03 +0530 | [diff] [blame] | 10015 | *channel_count += 1; |
| 10016 | } |
| 10017 | } else { |
| 10018 | break; |
| 10019 | } |
| 10020 | } |
bings | d79e606 | 2018-01-30 15:40:16 +0800 | [diff] [blame] | 10021 | |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 10022 | if (*channel_count == 0) { |
| 10023 | hdd_err("no valid channel found"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10024 | return -EINVAL; |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 10025 | } |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10026 | |
| 10027 | return 0; |
| 10028 | } |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10029 | |
| 10030 | /** |
| 10031 | * wlan_hdd_validate_and_get_pre_cac_ch() - Validate and get pre cac channel |
| 10032 | * @hdd_ctx: HDD context |
| 10033 | * @ap_adapter: AP adapter |
| 10034 | * @channel: Channel requested by userspace |
| 10035 | * @pre_cac_chan: Pointer to the pre CAC channel |
| 10036 | * |
| 10037 | * Validates the channel provided by userspace. If user provided channel 0, |
| 10038 | * a valid outdoor channel must be selected from the regulatory channel. |
| 10039 | * |
| 10040 | * Return: Zero on success and non zero value on error |
| 10041 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 10042 | static int wlan_hdd_validate_and_get_pre_cac_ch(struct hdd_context *hdd_ctx, |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 10043 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 10044 | uint8_t channel, |
| 10045 | uint8_t *pre_cac_chan) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10046 | { |
bings | d79e606 | 2018-01-30 15:40:16 +0800 | [diff] [blame] | 10047 | uint32_t i; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10048 | QDF_STATUS status; |
bings | d79e606 | 2018-01-30 15:40:16 +0800 | [diff] [blame] | 10049 | uint32_t weight_len = 0; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10050 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 10051 | uint8_t channel_list[QDF_MAX_NUM_CHAN] = {0}; |
| 10052 | uint8_t pcl_weights[QDF_MAX_NUM_CHAN] = {0}; |
| 10053 | |
| 10054 | if (0 == channel) { |
| 10055 | /* Channel is not obtained from PCL because PCL may not have |
| 10056 | * the entire channel list. For example: if SAP is up on |
| 10057 | * channel 6 and PCL is queried for the next SAP interface, |
| 10058 | * if SCC is preferred, the PCL will contain only the channel |
| 10059 | * 6. But, we are in need of a DFS channel. So, going with the |
| 10060 | * first channel from the valid channel list. |
| 10061 | */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 10062 | status = policy_mgr_get_valid_chans(hdd_ctx->hdd_psoc, |
| 10063 | channel_list, &len); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10064 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10065 | hdd_err("Failed to get channel list"); |
| 10066 | return -EINVAL; |
| 10067 | } |
Tushnim Bhattacharyya | abc5885 | 2017-07-26 13:14:52 -0700 | [diff] [blame] | 10068 | policy_mgr_update_with_safe_channel_list(hdd_ctx->hdd_psoc, |
| 10069 | channel_list, &len, pcl_weights, weight_len); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10070 | for (i = 0; i < len; i++) { |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 10071 | if (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
| 10072 | channel_list[i])) { |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10073 | *pre_cac_chan = channel_list[i]; |
| 10074 | break; |
| 10075 | } |
| 10076 | } |
| 10077 | if (*pre_cac_chan == 0) { |
| 10078 | hdd_err("unable to find outdoor channel"); |
| 10079 | return -EINVAL; |
| 10080 | } |
| 10081 | } else { |
| 10082 | /* Only when driver selects a channel, check is done for |
| 10083 | * unnsafe and NOL channels. When user provides a fixed channel |
| 10084 | * the user is expected to take care of this. |
| 10085 | */ |
| 10086 | if (!sme_is_channel_valid(hdd_ctx->hHal, channel) || |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 10087 | !wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, channel)) { |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10088 | hdd_err("Invalid channel for pre cac:%d", channel); |
| 10089 | return -EINVAL; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10090 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 10091 | *pre_cac_chan = channel; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10092 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 10093 | hdd_debug("selected pre cac channel:%d", *pre_cac_chan); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10094 | return 0; |
| 10095 | } |
| 10096 | |
| 10097 | /** |
| 10098 | * wlan_hdd_request_pre_cac() - Start pre CAC in the driver |
| 10099 | * @channel: Channel option provided by userspace |
| 10100 | * |
| 10101 | * Sets the driver to the required hardware mode and start an adapater for |
| 10102 | * pre CAC which will mimic an AP. |
| 10103 | * |
| 10104 | * Return: Zero on success, non-zero value on error |
| 10105 | */ |
| 10106 | int wlan_hdd_request_pre_cac(uint8_t channel) |
| 10107 | { |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 10108 | uint8_t pre_cac_chan = 0, *mac_addr; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 10109 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10110 | int ret; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 10111 | struct hdd_adapter *ap_adapter, *pre_cac_adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 10112 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10113 | QDF_STATUS status; |
| 10114 | struct wiphy *wiphy; |
| 10115 | struct net_device *dev; |
| 10116 | struct cfg80211_chan_def chandef; |
| 10117 | enum nl80211_channel_type channel_type; |
| 10118 | uint32_t freq; |
| 10119 | struct ieee80211_channel *chan; |
| 10120 | tHalHandle handle; |
| 10121 | bool val; |
| 10122 | |
| 10123 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10124 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 10125 | return -EINVAL; |
| 10126 | |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 10127 | if (policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) > 1) { |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10128 | hdd_err("pre cac not allowed in concurrency"); |
| 10129 | return -EINVAL; |
| 10130 | } |
| 10131 | |
| 10132 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 10133 | if (!ap_adapter) { |
| 10134 | hdd_err("unable to get SAP adapter"); |
| 10135 | return -EINVAL; |
| 10136 | } |
| 10137 | |
| 10138 | handle = WLAN_HDD_GET_HAL_CTX(ap_adapter); |
| 10139 | if (!handle) { |
| 10140 | hdd_err("Invalid handle"); |
| 10141 | return -EINVAL; |
| 10142 | } |
| 10143 | |
| 10144 | val = wlan_sap_is_pre_cac_active(handle); |
| 10145 | if (val) { |
| 10146 | hdd_err("pre cac is already in progress"); |
| 10147 | return -EINVAL; |
| 10148 | } |
| 10149 | |
| 10150 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 10151 | if (!hdd_ap_ctx) { |
| 10152 | hdd_err("SAP context is NULL"); |
| 10153 | return -EINVAL; |
| 10154 | } |
| 10155 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 10156 | if (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 10157 | hdd_ap_ctx->operating_channel)) { |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10158 | hdd_err("SAP is already on DFS channel:%d", |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 10159 | hdd_ap_ctx->operating_channel); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10160 | return -EINVAL; |
| 10161 | } |
| 10162 | |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 10163 | if (!WLAN_REG_IS_24GHZ_CH(hdd_ap_ctx->operating_channel)) { |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10164 | hdd_err("pre CAC alllowed only when SAP is in 2.4GHz:%d", |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 10165 | hdd_ap_ctx->operating_channel); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10166 | return -EINVAL; |
| 10167 | } |
| 10168 | |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 10169 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 10170 | if (!mac_addr) { |
| 10171 | hdd_err("can't add virtual intf: Not getting valid mac addr"); |
| 10172 | return -EINVAL; |
| 10173 | } |
| 10174 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 10175 | hdd_debug("channel:%d", channel); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10176 | |
| 10177 | ret = wlan_hdd_validate_and_get_pre_cac_ch(hdd_ctx, ap_adapter, channel, |
| 10178 | &pre_cac_chan); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 10179 | if (ret != 0) { |
| 10180 | hdd_err("can't validate pre-cac channel"); |
| 10181 | goto release_intf_addr_and_return_failure; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10182 | } |
| 10183 | |
| 10184 | hdd_debug("starting pre cac SAP adapter"); |
| 10185 | |
| 10186 | /* Starting a SAP adapter: |
| 10187 | * Instead of opening an adapter, we could just do a SME open session |
| 10188 | * for AP type. But, start BSS would still need an adapter. |
| 10189 | * So, this option is not taken. |
| 10190 | * |
| 10191 | * hdd open adapter is going to register this precac interface with |
| 10192 | * user space. This interface though exposed to user space will be in |
| 10193 | * DOWN state. Consideration was done to avoid this registration to the |
| 10194 | * user space. But, as part of SAP operations multiple events are sent |
| 10195 | * to user space. Some of these events received from unregistered |
| 10196 | * interface was causing crashes. So, retaining the registration. |
| 10197 | * |
| 10198 | * So, this interface would remain registered and will remain in DOWN |
| 10199 | * state for the CAC duration. We will add notes in the feature |
| 10200 | * announcement to not use this temporary interface for any activity |
| 10201 | * from user space. |
| 10202 | */ |
| 10203 | pre_cac_adapter = hdd_open_adapter(hdd_ctx, QDF_SAP_MODE, "precac%d", |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 10204 | mac_addr, NET_NAME_UNKNOWN, true); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10205 | if (!pre_cac_adapter) { |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 10206 | hdd_err("error opening the pre cac adapter"); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 10207 | goto release_intf_addr_and_return_failure; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10208 | } |
| 10209 | |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 10210 | /* |
| 10211 | * This interface is internally created by the driver. So, no interface |
| 10212 | * up comes for this interface from user space and hence starting |
| 10213 | * the adapter internally. |
| 10214 | */ |
| 10215 | if (hdd_start_adapter(pre_cac_adapter)) { |
| 10216 | hdd_err("error starting the pre cac adapter"); |
| 10217 | goto close_pre_cac_adapter; |
| 10218 | } |
| 10219 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10220 | hdd_debug("preparing for start ap/bss on the pre cac adapter"); |
| 10221 | |
| 10222 | wiphy = hdd_ctx->wiphy; |
| 10223 | dev = pre_cac_adapter->dev; |
| 10224 | |
| 10225 | /* Since this is only a dummy interface lets us use the IEs from the |
| 10226 | * other active SAP interface. In regular scenarios, these IEs would |
| 10227 | * come from the user space entity |
| 10228 | */ |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 10229 | pre_cac_adapter->session.ap.beacon = qdf_mem_malloc( |
| 10230 | sizeof(*ap_adapter->session.ap.beacon)); |
| 10231 | if (!pre_cac_adapter->session.ap.beacon) { |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10232 | hdd_err("failed to alloc mem for beacon"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 10233 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10234 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 10235 | qdf_mem_copy(pre_cac_adapter->session.ap.beacon, |
| 10236 | ap_adapter->session.ap.beacon, |
| 10237 | sizeof(*pre_cac_adapter->session.ap.beacon)); |
| 10238 | pre_cac_adapter->session.ap.sap_config.ch_width_orig = |
| 10239 | ap_adapter->session.ap.sap_config.ch_width_orig; |
| 10240 | pre_cac_adapter->session.ap.sap_config.authType = |
| 10241 | ap_adapter->session.ap.sap_config.authType; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10242 | |
| 10243 | /* Premise is that on moving from 2.4GHz to 5GHz, the SAP will continue |
| 10244 | * to operate on the same bandwidth as that of the 2.4GHz operations. |
| 10245 | * Only bandwidths 20MHz/40MHz are possible on 2.4GHz band. |
| 10246 | */ |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 10247 | switch (ap_adapter->session.ap.sap_config.ch_width_orig) { |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10248 | case CH_WIDTH_20MHZ: |
| 10249 | channel_type = NL80211_CHAN_HT20; |
| 10250 | break; |
| 10251 | case CH_WIDTH_40MHZ: |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 10252 | if (ap_adapter->session.ap.sap_config.sec_ch > |
| 10253 | ap_adapter->session.ap.sap_config.channel) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10254 | channel_type = NL80211_CHAN_HT40PLUS; |
| 10255 | else |
| 10256 | channel_type = NL80211_CHAN_HT40MINUS; |
| 10257 | break; |
| 10258 | default: |
| 10259 | channel_type = NL80211_CHAN_NO_HT; |
| 10260 | break; |
| 10261 | } |
| 10262 | |
| 10263 | freq = cds_chan_to_freq(pre_cac_chan); |
Dustin Brown | 2eb1e45 | 2017-08-15 12:40:34 -0700 | [diff] [blame] | 10264 | chan = ieee80211_get_channel(wiphy, freq); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10265 | if (!chan) { |
| 10266 | hdd_err("channel converion failed"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 10267 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10268 | } |
| 10269 | |
| 10270 | cfg80211_chandef_create(&chandef, chan, channel_type); |
| 10271 | |
| 10272 | hdd_debug("orig width:%d channel_type:%d freq:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 10273 | ap_adapter->session.ap.sap_config.ch_width_orig, |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10274 | channel_type, freq); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 10275 | /* |
| 10276 | * Doing update after opening and starting pre-cac adapter will make |
| 10277 | * sure that driver won't do hardware mode change if there are any |
| 10278 | * initial hick-ups or issues in pre-cac adapter's configuration. |
| 10279 | * Since current SAP is in 2.4GHz and pre CAC channel is in 5GHz, this |
| 10280 | * connection update should result in DBS mode |
| 10281 | */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 10282 | status = policy_mgr_update_and_wait_for_connection_update( |
Tushnim Bhattacharyya | 3b99f4b | 2018-03-26 14:19:24 -0700 | [diff] [blame] | 10283 | hdd_ctx->hdd_psoc, |
| 10284 | ap_adapter->session_id, |
| 10285 | pre_cac_chan, |
| 10286 | POLICY_MGR_UPDATE_REASON_PRE_CAC); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 10287 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10288 | hdd_err("error in moving to DBS mode"); |
| 10289 | goto stop_close_pre_cac_adapter; |
| 10290 | } |
| 10291 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10292 | |
| 10293 | ret = wlan_hdd_set_channel(wiphy, dev, &chandef, channel_type); |
| 10294 | if (0 != ret) { |
| 10295 | hdd_err("failed to set channel"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 10296 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10297 | } |
| 10298 | |
| 10299 | status = wlan_hdd_cfg80211_start_bss(pre_cac_adapter, NULL, |
| 10300 | PRE_CAC_SSID, qdf_str_len(PRE_CAC_SSID), |
Mahesh Kumar Kalikot Veetil | c637fc9 | 2017-09-27 16:06:21 -0700 | [diff] [blame] | 10301 | NL80211_HIDDEN_SSID_NOT_IN_USE, false); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10302 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10303 | hdd_err("start bss failed"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 10304 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10305 | } |
| 10306 | |
| 10307 | /* |
| 10308 | * The pre cac status is set here. But, it would not be reset explicitly |
| 10309 | * anywhere, since after the pre cac success/failure, the pre cac |
| 10310 | * adapter itself would be removed. |
| 10311 | */ |
| 10312 | ret = wlan_hdd_set_pre_cac_status(pre_cac_adapter, true, handle); |
| 10313 | if (0 != ret) { |
| 10314 | hdd_err("failed to set pre cac status"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 10315 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10316 | } |
| 10317 | |
| 10318 | ret = wlan_hdd_set_chan_before_pre_cac(ap_adapter, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 10319 | hdd_ap_ctx->operating_channel); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10320 | if (0 != ret) { |
| 10321 | hdd_err("failed to set channel before pre cac"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 10322 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10323 | } |
| 10324 | |
| 10325 | ap_adapter->pre_cac_chan = pre_cac_chan; |
| 10326 | |
| 10327 | return 0; |
| 10328 | |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 10329 | stop_close_pre_cac_adapter: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 10330 | hdd_stop_adapter(hdd_ctx, pre_cac_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 10331 | qdf_mem_free(pre_cac_adapter->session.ap.beacon); |
| 10332 | pre_cac_adapter->session.ap.beacon = NULL; |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 10333 | close_pre_cac_adapter: |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10334 | hdd_close_adapter(hdd_ctx, pre_cac_adapter, false); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 10335 | release_intf_addr_and_return_failure: |
| 10336 | /* |
| 10337 | * Release the interface address as the adapter |
| 10338 | * failed to start, if you don't release then next |
| 10339 | * adapter which is trying to come wouldn't get valid |
| 10340 | * mac address. Remember we have limited pool of mac addresses |
| 10341 | */ |
| 10342 | wlan_hdd_release_intf_addr(hdd_ctx, mac_addr); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 10343 | return -EINVAL; |
| 10344 | } |
| 10345 | |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10346 | static const struct nla_policy |
| 10347 | wlan_hdd_sap_config_policy[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_MAX + 1] = { |
| 10348 | [QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHANNEL] = {.type = NLA_U8 }, |
Ganesh Kondabattini | 099e6e8 | 2017-06-28 12:24:20 +0530 | [diff] [blame] | 10349 | [QCA_WLAN_VENDOR_ATTR_SAP_MANDATORY_FREQUENCY_LIST] = { |
| 10350 | .type = NLA_NESTED }, |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10351 | }; |
| 10352 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 10353 | static const struct nla_policy |
| 10354 | wlan_hdd_set_acs_dfs_config_policy[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MAX + 1] = { |
| 10355 | [QCA_WLAN_VENDOR_ATTR_ACS_DFS_MODE] = {.type = NLA_U8 }, |
| 10356 | [QCA_WLAN_VENDOR_ATTR_ACS_CHANNEL_HINT] = {.type = NLA_U8 }, |
| 10357 | }; |
| 10358 | |
Ganesh Kondabattini | b1960e7 | 2017-09-01 09:09:50 +0530 | [diff] [blame] | 10359 | static const struct nla_policy |
| 10360 | wlan_hdd_set_limit_off_channel_param_policy |
| 10361 | [QCA_WLAN_VENDOR_ATTR_ACTIVE_TOS_MAX + 1] = { |
| 10362 | [QCA_WLAN_VENDOR_ATTR_ACTIVE_TOS] = {.type = NLA_U8 }, |
| 10363 | [QCA_WLAN_VENDOR_ATTR_ACTIVE_TOS_START] = {.type = NLA_U8 }, |
| 10364 | }; |
| 10365 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 10366 | /** |
| 10367 | * __wlan_hdd_cfg80211_acs_dfs_mode() - set ACS DFS mode and channel |
| 10368 | * @wiphy: Pointer to wireless phy |
| 10369 | * @wdev: Pointer to wireless device |
| 10370 | * @data: Pointer to data |
| 10371 | * @data_len: Length of @data |
| 10372 | * |
| 10373 | * This function parses the incoming NL vendor command data attributes and |
| 10374 | * updates the SAP context about channel_hint and DFS mode. |
| 10375 | * If channel_hint is set, SAP will choose that channel |
| 10376 | * as operating channel. |
| 10377 | * |
| 10378 | * If DFS mode is enabled, driver will include DFS channels |
| 10379 | * in ACS else driver will skip DFS channels. |
| 10380 | * |
| 10381 | * Return: 0 on success, negative errno on failure |
| 10382 | */ |
| 10383 | static int |
| 10384 | __wlan_hdd_cfg80211_acs_dfs_mode(struct wiphy *wiphy, |
| 10385 | struct wireless_dev *wdev, |
| 10386 | const void *data, int data_len) |
| 10387 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 10388 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 10389 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MAX + 1]; |
| 10390 | int ret; |
| 10391 | struct acs_dfs_policy *acs_policy; |
| 10392 | int mode = DFS_MODE_NONE; |
| 10393 | int channel_hint = 0; |
| 10394 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 10395 | hdd_enter_dev(wdev->netdev); |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 10396 | |
| 10397 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 10398 | hdd_err("Command not allowed in FTM mode"); |
| 10399 | return -EINVAL; |
| 10400 | } |
| 10401 | |
| 10402 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10403 | if (0 != ret) |
| 10404 | return ret; |
| 10405 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 10406 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_ACS_DFS_MAX, |
| 10407 | data, data_len, |
| 10408 | wlan_hdd_set_acs_dfs_config_policy)) { |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 10409 | hdd_err("invalid attr"); |
| 10410 | return -EINVAL; |
| 10411 | } |
| 10412 | |
| 10413 | acs_policy = &hdd_ctx->acs_policy; |
| 10414 | /* |
| 10415 | * SCM sends this attribute to restrict SAP from choosing |
| 10416 | * DFS channels from ACS. |
| 10417 | */ |
| 10418 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MODE]) |
| 10419 | mode = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MODE]); |
| 10420 | |
| 10421 | if (!IS_DFS_MODE_VALID(mode)) { |
| 10422 | hdd_err("attr acs dfs mode is not valid"); |
| 10423 | return -EINVAL; |
| 10424 | } |
| 10425 | acs_policy->acs_dfs_mode = mode; |
| 10426 | |
| 10427 | /* |
| 10428 | * SCM sends this attribute to provide an active channel, |
| 10429 | * to skip redundant ACS between drivers, and save driver start up time |
| 10430 | */ |
| 10431 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_CHANNEL_HINT]) |
| 10432 | channel_hint = nla_get_u8( |
| 10433 | tb[QCA_WLAN_VENDOR_ATTR_ACS_CHANNEL_HINT]); |
| 10434 | |
| 10435 | if (!IS_CHANNEL_VALID(channel_hint)) { |
| 10436 | hdd_err("acs channel is not valid"); |
| 10437 | return -EINVAL; |
| 10438 | } |
| 10439 | acs_policy->acs_channel = channel_hint; |
| 10440 | |
| 10441 | return 0; |
| 10442 | } |
| 10443 | |
| 10444 | /** |
| 10445 | * wlan_hdd_cfg80211_acs_dfs_mode() - Wrapper to set ACS DFS mode |
| 10446 | * @wiphy: wiphy structure pointer |
| 10447 | * @wdev: Wireless device structure pointer |
| 10448 | * @data: Pointer to the data received |
| 10449 | * @data_len: Length of @data |
| 10450 | * |
| 10451 | * This function parses the incoming NL vendor command data attributes and |
| 10452 | * updates the SAP context about channel_hint and DFS mode. |
| 10453 | * |
| 10454 | * Return: 0 on success; errno on failure |
| 10455 | */ |
| 10456 | static int wlan_hdd_cfg80211_acs_dfs_mode(struct wiphy *wiphy, |
| 10457 | struct wireless_dev *wdev, |
| 10458 | const void *data, int data_len) |
| 10459 | { |
| 10460 | int ret; |
| 10461 | |
| 10462 | cds_ssr_protect(__func__); |
| 10463 | ret = __wlan_hdd_cfg80211_acs_dfs_mode(wiphy, wdev, data, data_len); |
| 10464 | cds_ssr_unprotect(__func__); |
| 10465 | |
| 10466 | return ret; |
| 10467 | } |
| 10468 | |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10469 | /** |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10470 | * wlan_hdd_get_sta_roam_dfs_mode() - get sta roam dfs mode policy |
| 10471 | * @mode : cfg80211 dfs mode |
| 10472 | * |
| 10473 | * Return: return csr sta roam dfs mode else return NONE |
| 10474 | */ |
| 10475 | static enum sta_roam_policy_dfs_mode wlan_hdd_get_sta_roam_dfs_mode( |
| 10476 | enum dfs_mode mode) |
| 10477 | { |
| 10478 | switch (mode) { |
| 10479 | case DFS_MODE_ENABLE: |
| 10480 | return CSR_STA_ROAM_POLICY_DFS_ENABLED; |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10481 | case DFS_MODE_DISABLE: |
| 10482 | return CSR_STA_ROAM_POLICY_DFS_DISABLED; |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10483 | case DFS_MODE_DEPRIORITIZE: |
| 10484 | return CSR_STA_ROAM_POLICY_DFS_DEPRIORITIZE; |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10485 | default: |
| 10486 | hdd_err("STA Roam policy dfs mode is NONE"); |
| 10487 | return CSR_STA_ROAM_POLICY_NONE; |
| 10488 | } |
| 10489 | } |
| 10490 | |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10491 | /* |
| 10492 | * hdd_get_sap_operating_band: Get current operating channel |
| 10493 | * for sap. |
| 10494 | * @hdd_ctx: hdd context |
| 10495 | * |
| 10496 | * Return : Corresponding band for SAP operating channel |
| 10497 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 10498 | uint8_t hdd_get_sap_operating_band(struct hdd_context *hdd_ctx) |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10499 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 10500 | struct hdd_adapter *adapter; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10501 | uint8_t operating_channel = 0; |
| 10502 | uint8_t sap_operating_band = 0; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 10503 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10504 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 10505 | if (adapter->device_mode != QDF_SAP_MODE) |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10506 | continue; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10507 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 10508 | operating_channel = adapter->session.ap.operating_channel; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10509 | if (IS_24G_CH(operating_channel)) |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 10510 | sap_operating_band = BAND_2G; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10511 | else if (IS_5G_CH(operating_channel)) |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 10512 | sap_operating_band = BAND_5G; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10513 | else |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 10514 | sap_operating_band = BAND_ALL; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10515 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10516 | |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10517 | return sap_operating_band; |
| 10518 | } |
| 10519 | |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10520 | static const struct nla_policy |
| 10521 | wlan_hdd_set_sta_roam_config_policy[ |
| 10522 | QCA_WLAN_VENDOR_ATTR_STA_CONNECT_ROAM_POLICY_MAX + 1] = { |
| 10523 | [QCA_WLAN_VENDOR_ATTR_STA_DFS_MODE] = {.type = NLA_U8 }, |
| 10524 | [QCA_WLAN_VENDOR_ATTR_STA_SKIP_UNSAFE_CHANNEL] = {.type = NLA_U8 }, |
| 10525 | }; |
| 10526 | |
| 10527 | /** |
| 10528 | * __wlan_hdd_cfg80211_sta_roam_policy() - Set params to restrict scan channels |
| 10529 | * for station connection or roaming. |
| 10530 | * @wiphy: Pointer to wireless phy |
| 10531 | * @wdev: Pointer to wireless device |
| 10532 | * @data: Pointer to data |
| 10533 | * @data_len: Length of @data |
| 10534 | * |
| 10535 | * __wlan_hdd_cfg80211_sta_roam_policy will decide if DFS channels or unsafe |
| 10536 | * channels needs to be skipped in scanning or not. |
| 10537 | * If dfs_mode is disabled, driver will not scan DFS channels. |
| 10538 | * If skip_unsafe_channels is set, driver will skip unsafe channels |
| 10539 | * in Scanning. |
| 10540 | * |
| 10541 | * Return: 0 on success, negative errno on failure |
| 10542 | */ |
| 10543 | static int |
| 10544 | __wlan_hdd_cfg80211_sta_roam_policy(struct wiphy *wiphy, |
| 10545 | struct wireless_dev *wdev, |
| 10546 | const void *data, int data_len) |
| 10547 | { |
| 10548 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 10549 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 10550 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10551 | struct nlattr *tb[ |
| 10552 | QCA_WLAN_VENDOR_ATTR_STA_CONNECT_ROAM_POLICY_MAX + 1]; |
| 10553 | int ret; |
| 10554 | enum sta_roam_policy_dfs_mode sta_roam_dfs_mode; |
| 10555 | enum dfs_mode mode = DFS_MODE_NONE; |
| 10556 | bool skip_unsafe_channels = false; |
| 10557 | QDF_STATUS status; |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10558 | uint8_t sap_operating_band; |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10559 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 10560 | hdd_enter_dev(dev); |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10561 | |
| 10562 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 10563 | hdd_err("Command not allowed in FTM mode"); |
| 10564 | return -EINVAL; |
| 10565 | } |
| 10566 | |
| 10567 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10568 | if (0 != ret) |
| 10569 | return ret; |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 10570 | if (wlan_cfg80211_nla_parse(tb, |
| 10571 | QCA_WLAN_VENDOR_ATTR_STA_CONNECT_ROAM_POLICY_MAX, |
| 10572 | data, data_len, |
| 10573 | wlan_hdd_set_sta_roam_config_policy)) { |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10574 | hdd_err("invalid attr"); |
| 10575 | return -EINVAL; |
| 10576 | } |
| 10577 | if (tb[QCA_WLAN_VENDOR_ATTR_STA_DFS_MODE]) |
| 10578 | mode = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_STA_DFS_MODE]); |
| 10579 | if (!IS_DFS_MODE_VALID(mode)) { |
| 10580 | hdd_err("attr sta roam dfs mode policy is not valid"); |
| 10581 | return -EINVAL; |
| 10582 | } |
| 10583 | |
| 10584 | sta_roam_dfs_mode = wlan_hdd_get_sta_roam_dfs_mode(mode); |
| 10585 | |
| 10586 | if (tb[QCA_WLAN_VENDOR_ATTR_STA_SKIP_UNSAFE_CHANNEL]) |
| 10587 | skip_unsafe_channels = nla_get_u8( |
| 10588 | tb[QCA_WLAN_VENDOR_ATTR_STA_SKIP_UNSAFE_CHANNEL]); |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10589 | sap_operating_band = hdd_get_sap_operating_band(hdd_ctx); |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10590 | status = sme_update_sta_roam_policy(hdd_ctx->hHal, sta_roam_dfs_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10591 | skip_unsafe_channels, adapter->session_id, |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 10592 | sap_operating_band); |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10593 | |
| 10594 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10595 | hdd_err("sme_update_sta_roam_policy (err=%d)", status); |
| 10596 | return -EINVAL; |
| 10597 | } |
| 10598 | return 0; |
| 10599 | } |
| 10600 | |
| 10601 | /** |
| 10602 | * wlan_hdd_cfg80211_sta_roam_policy() - Wrapper to restrict scan channels, |
| 10603 | * connection and roaming for station. |
| 10604 | * @wiphy: wiphy structure pointer |
| 10605 | * @wdev: Wireless device structure pointer |
| 10606 | * @data: Pointer to the data received |
| 10607 | * @data_len: Length of @data |
| 10608 | * |
| 10609 | * __wlan_hdd_cfg80211_sta_roam_policy will decide if DFS channels or unsafe |
| 10610 | * channels needs to be skipped in scanning or not. |
| 10611 | * If dfs_mode is disabled, driver will not scan DFS channels. |
| 10612 | * If skip_unsafe_channels is set, driver will skip unsafe channels |
| 10613 | * in Scanning. |
| 10614 | * Return: 0 on success; errno on failure |
| 10615 | */ |
| 10616 | static int wlan_hdd_cfg80211_sta_roam_policy(struct wiphy *wiphy, |
| 10617 | struct wireless_dev *wdev, |
| 10618 | const void *data, int data_len) |
| 10619 | { |
| 10620 | int ret; |
| 10621 | |
| 10622 | cds_ssr_protect(__func__); |
| 10623 | ret = __wlan_hdd_cfg80211_sta_roam_policy(wiphy, wdev, data, data_len); |
| 10624 | cds_ssr_unprotect(__func__); |
| 10625 | |
| 10626 | return ret; |
| 10627 | } |
| 10628 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10629 | #ifdef FEATURE_WLAN_CH_AVOID |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 10630 | |
| 10631 | static int hdd_validate_avoid_freq_chanlist( |
| 10632 | struct hdd_context *hdd_ctx, |
| 10633 | struct ch_avoid_ind_type *channel_list) |
| 10634 | { |
| 10635 | unsigned int range_idx, ch_idx; |
| 10636 | unsigned int unsafe_channel_index, unsafe_channel_count = 0; |
| 10637 | bool ch_found = false; |
| 10638 | |
| 10639 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
| 10640 | (uint16_t)NUM_CHANNELS); |
| 10641 | |
| 10642 | for (range_idx = 0; range_idx < channel_list->ch_avoid_range_cnt; |
| 10643 | range_idx++) { |
| 10644 | if ((channel_list->avoid_freq_range[range_idx].start_freq < |
| 10645 | CDS_24_GHZ_CHANNEL_1) || |
| 10646 | (channel_list->avoid_freq_range[range_idx].end_freq > |
| 10647 | CDS_5_GHZ_CHANNEL_165) || |
| 10648 | (channel_list->avoid_freq_range[range_idx].start_freq > |
| 10649 | channel_list->avoid_freq_range[range_idx].end_freq)) |
| 10650 | continue; |
| 10651 | |
| 10652 | for (ch_idx = channel_list-> |
| 10653 | avoid_freq_range[range_idx].start_freq; |
| 10654 | ch_idx <= channel_list-> |
| 10655 | avoid_freq_range[range_idx].end_freq; |
| 10656 | ch_idx++) { |
| 10657 | for (unsafe_channel_index = 0; |
| 10658 | unsafe_channel_index < unsafe_channel_count; |
| 10659 | unsafe_channel_index++) { |
| 10660 | if (ch_idx == |
| 10661 | hdd_ctx->unsafe_channel_list[ |
| 10662 | unsafe_channel_index]) { |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 10663 | hdd_info("Duplicate channel %d", |
| 10664 | ch_idx); |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 10665 | ch_found = true; |
| 10666 | break; |
| 10667 | } |
| 10668 | } |
| 10669 | if (!ch_found) { |
| 10670 | hdd_ctx->unsafe_channel_list[ |
| 10671 | unsafe_channel_count++] = ch_idx; |
| 10672 | } |
| 10673 | ch_found = false; |
| 10674 | } |
| 10675 | } |
| 10676 | return unsafe_channel_count; |
| 10677 | } |
| 10678 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10679 | /** |
| 10680 | * __wlan_hdd_cfg80211_avoid_freq() - ask driver to restart SAP if SAP |
| 10681 | * is on unsafe channel. |
| 10682 | * @wiphy: wiphy structure pointer |
| 10683 | * @wdev: Wireless device structure pointer |
| 10684 | * @data: Pointer to the data received |
| 10685 | * @data_len: Length of @data |
| 10686 | * |
| 10687 | * wlan_hdd_cfg80211_avoid_freq do restart the sap if sap is already |
| 10688 | * on any of unsafe channels. |
| 10689 | * If sap is on any of unsafe channel, hdd_unsafe_channel_restart_sap |
| 10690 | * will send WLAN_SVC_LTE_COEX_IND indication to userspace to restart. |
| 10691 | * |
| 10692 | * Return: 0 on success; errno on failure |
| 10693 | */ |
| 10694 | static int |
| 10695 | __wlan_hdd_cfg80211_avoid_freq(struct wiphy *wiphy, |
| 10696 | struct wireless_dev *wdev, |
| 10697 | const void *data, int data_len) |
| 10698 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 10699 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10700 | int ret; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10701 | 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] | 10702 | uint16_t *local_unsafe_list; |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 10703 | uint16_t unsafe_channel_index, local_unsafe_list_count; |
| 10704 | struct ch_avoid_ind_type *channel_list; |
| 10705 | enum tQDF_GLOBAL_CON_MODE curr_mode; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10706 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 10707 | hdd_enter_dev(wdev->netdev); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10708 | |
| 10709 | if (!qdf_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 10710 | hdd_err("qdf_ctx is NULL"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10711 | return -EINVAL; |
| 10712 | } |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 10713 | curr_mode = hdd_get_conparam(); |
| 10714 | if (QDF_GLOBAL_FTM_MODE == curr_mode || |
| 10715 | QDF_GLOBAL_MONITOR_MODE == curr_mode) { |
| 10716 | hdd_err("Command not allowed in FTM/MONITOR mode"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10717 | return -EINVAL; |
| 10718 | } |
| 10719 | |
| 10720 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10721 | if (0 != ret) |
| 10722 | return ret; |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 10723 | |
| 10724 | channel_list = (struct ch_avoid_ind_type *)data; |
| 10725 | if (!channel_list) { |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 10726 | hdd_err("Avoid frequency channel list empty"); |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 10727 | return -EINVAL; |
| 10728 | } |
| 10729 | |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 10730 | ret = hdd_clone_local_unsafe_chan(hdd_ctx, |
| 10731 | &local_unsafe_list, |
| 10732 | &local_unsafe_list_count); |
| 10733 | if (0 != ret) { |
| 10734 | hdd_err("failed to clone the cur unsafe chan list"); |
| 10735 | return ret; |
| 10736 | } |
| 10737 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10738 | pld_get_wlan_unsafe_channel(qdf_ctx->dev, hdd_ctx->unsafe_channel_list, |
| 10739 | &(hdd_ctx->unsafe_channel_count), |
| 10740 | sizeof(hdd_ctx->unsafe_channel_list)); |
| 10741 | |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 10742 | hdd_ctx->unsafe_channel_count = hdd_validate_avoid_freq_chanlist( |
| 10743 | hdd_ctx, |
| 10744 | channel_list); |
| 10745 | |
| 10746 | pld_set_wlan_unsafe_channel(qdf_ctx->dev, hdd_ctx->unsafe_channel_list, |
| 10747 | hdd_ctx->unsafe_channel_count); |
| 10748 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10749 | for (unsafe_channel_index = 0; |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 10750 | unsafe_channel_index < hdd_ctx->unsafe_channel_count; |
| 10751 | unsafe_channel_index++) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 10752 | hdd_debug("Channel %d is not safe", |
Ashish Kumar Dhanotiya | 4be2a7b | 2018-02-09 20:08:21 +0530 | [diff] [blame] | 10753 | hdd_ctx->unsafe_channel_list[unsafe_channel_index]); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10754 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 10755 | if (hdd_local_unsafe_channel_updated(hdd_ctx, local_unsafe_list, |
| 10756 | local_unsafe_list_count)) |
| 10757 | hdd_unsafe_channel_restart_sap(hdd_ctx); |
| 10758 | qdf_mem_free(local_unsafe_list); |
| 10759 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 10760 | return 0; |
| 10761 | } |
| 10762 | |
| 10763 | /** |
| 10764 | * wlan_hdd_cfg80211_avoid_freq() - ask driver to restart SAP if SAP |
| 10765 | * is on unsafe channel. |
| 10766 | * @wiphy: wiphy structure pointer |
| 10767 | * @wdev: Wireless device structure pointer |
| 10768 | * @data: Pointer to the data received |
| 10769 | * @data_len: Length of @data |
| 10770 | * |
| 10771 | * wlan_hdd_cfg80211_avoid_freq do restart the sap if sap is already |
| 10772 | * on any of unsafe channels. |
| 10773 | * If sap is on any of unsafe channel, hdd_unsafe_channel_restart_sap |
| 10774 | * will send WLAN_SVC_LTE_COEX_IND indication to userspace to restart. |
| 10775 | * |
| 10776 | * Return: 0 on success; errno on failure |
| 10777 | */ |
| 10778 | static int wlan_hdd_cfg80211_avoid_freq(struct wiphy *wiphy, |
| 10779 | struct wireless_dev *wdev, |
| 10780 | const void *data, int data_len) |
| 10781 | { |
| 10782 | int ret; |
| 10783 | |
| 10784 | cds_ssr_protect(__func__); |
| 10785 | ret = __wlan_hdd_cfg80211_avoid_freq(wiphy, wdev, data, data_len); |
| 10786 | cds_ssr_unprotect(__func__); |
| 10787 | |
| 10788 | return ret; |
| 10789 | } |
| 10790 | |
| 10791 | #endif |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 10792 | /** |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10793 | * __wlan_hdd_cfg80211_sap_configuration_set() - ask driver to restart SAP if |
| 10794 | * SAP is on unsafe channel. |
| 10795 | * @wiphy: wiphy structure pointer |
| 10796 | * @wdev: Wireless device structure pointer |
| 10797 | * @data: Pointer to the data received |
| 10798 | * @data_len: Length of @data |
| 10799 | * |
| 10800 | * __wlan_hdd_cfg80211_sap_configuration_set function set SAP params to |
| 10801 | * driver. |
| 10802 | * QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHAN will set sap config channel and |
| 10803 | * will initiate restart of sap. |
| 10804 | * |
| 10805 | * Return: 0 on success; errno on failure |
| 10806 | */ |
| 10807 | static int |
| 10808 | __wlan_hdd_cfg80211_sap_configuration_set(struct wiphy *wiphy, |
| 10809 | struct wireless_dev *wdev, |
| 10810 | const void *data, int data_len) |
| 10811 | { |
| 10812 | struct net_device *ndev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 10813 | struct hdd_adapter *hostapd_adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 10814 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10815 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_MAX + 1]; |
| 10816 | uint8_t config_channel = 0; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 10817 | struct hdd_ap_ctx *ap_ctx; |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10818 | int ret; |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 10819 | QDF_STATUS status; |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10820 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10821 | hdd_enter(); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10822 | |
| 10823 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 10824 | hdd_err("Command not allowed in FTM mode"); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10825 | return -EINVAL; |
| 10826 | } |
| 10827 | |
| 10828 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10829 | if (0 != ret) |
| 10830 | return -EINVAL; |
| 10831 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 10832 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_MAX, |
| 10833 | data, data_len, |
| 10834 | wlan_hdd_sap_config_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 10835 | hdd_err("invalid attr"); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10836 | return -EINVAL; |
| 10837 | } |
| 10838 | |
| 10839 | if (tb[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHANNEL]) { |
| 10840 | if (!test_bit(SOFTAP_BSS_STARTED, |
| 10841 | &hostapd_adapter->event_flags)) { |
| 10842 | hdd_err("SAP is not started yet. Restart sap will be invalid"); |
| 10843 | return -EINVAL; |
| 10844 | } |
| 10845 | |
| 10846 | config_channel = |
| 10847 | nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHANNEL]); |
| 10848 | |
| 10849 | if (!((IS_24G_CH(config_channel)) || |
| 10850 | (IS_5G_CH(config_channel)))) { |
| 10851 | hdd_err("Channel %d is not valid to restart SAP", |
| 10852 | config_channel); |
| 10853 | return -ENOTSUPP; |
| 10854 | } |
| 10855 | |
| 10856 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(hostapd_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 10857 | ap_ctx->sap_config.channel = config_channel; |
| 10858 | ap_ctx->sap_config.ch_params.ch_width = |
| 10859 | ap_ctx->sap_config.ch_width_orig; |
hqu | 73bccf2 | 2017-10-28 15:34:17 +0800 | [diff] [blame] | 10860 | ap_ctx->bss_stop_reason = BSS_STOP_DUE_TO_VENDOR_CONFIG_CHAN; |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10861 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 10862 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 10863 | ap_ctx->sap_config.channel, |
| 10864 | ap_ctx->sap_config.sec_ch, |
| 10865 | &ap_ctx->sap_config.ch_params); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10866 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10867 | hdd_restart_sap(hostapd_adapter); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10868 | } |
| 10869 | |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 10870 | if (tb[QCA_WLAN_VENDOR_ATTR_SAP_MANDATORY_FREQUENCY_LIST]) { |
| 10871 | uint32_t freq_len, i; |
| 10872 | uint32_t *freq; |
| 10873 | uint8_t chans[QDF_MAX_NUM_CHAN]; |
| 10874 | |
| 10875 | hdd_debug("setting mandatory freq/chan list"); |
| 10876 | |
| 10877 | freq_len = nla_len( |
| 10878 | tb[QCA_WLAN_VENDOR_ATTR_SAP_MANDATORY_FREQUENCY_LIST])/ |
| 10879 | sizeof(uint32_t); |
| 10880 | |
| 10881 | if (freq_len > QDF_MAX_NUM_CHAN) { |
| 10882 | hdd_err("insufficient space to hold channels"); |
| 10883 | return -ENOMEM; |
| 10884 | } |
| 10885 | |
| 10886 | freq = nla_data( |
| 10887 | tb[QCA_WLAN_VENDOR_ATTR_SAP_MANDATORY_FREQUENCY_LIST]); |
| 10888 | |
| 10889 | hdd_debug("freq_len=%d", freq_len); |
| 10890 | |
| 10891 | for (i = 0; i < freq_len; i++) { |
| 10892 | chans[i] = ieee80211_frequency_to_channel(freq[i]); |
| 10893 | hdd_debug("freq[%d]=%d", i, freq[i]); |
| 10894 | } |
| 10895 | |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 10896 | status = policy_mgr_set_sap_mandatory_channels( |
| 10897 | hdd_ctx->hdd_psoc, chans, freq_len); |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 10898 | if (QDF_IS_STATUS_ERROR(status)) |
| 10899 | return -EINVAL; |
| 10900 | } |
| 10901 | |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 10902 | return 0; |
| 10903 | } |
| 10904 | |
| 10905 | /** |
| 10906 | * wlan_hdd_cfg80211_sap_configuration_set() - sap configuration vendor command |
| 10907 | * @wiphy: wiphy structure pointer |
| 10908 | * @wdev: Wireless device structure pointer |
| 10909 | * @data: Pointer to the data received |
| 10910 | * @data_len: Length of @data |
| 10911 | * |
| 10912 | * __wlan_hdd_cfg80211_sap_configuration_set function set SAP params to |
| 10913 | * driver. |
| 10914 | * QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHAN will set sap config channel and |
| 10915 | * will initiate restart of sap. |
| 10916 | * |
| 10917 | * Return: 0 on success; errno on failure |
| 10918 | */ |
| 10919 | static int wlan_hdd_cfg80211_sap_configuration_set(struct wiphy *wiphy, |
| 10920 | struct wireless_dev *wdev, |
| 10921 | const void *data, int data_len) |
| 10922 | { |
| 10923 | int ret; |
| 10924 | |
| 10925 | cds_ssr_protect(__func__); |
| 10926 | ret = __wlan_hdd_cfg80211_sap_configuration_set(wiphy, |
| 10927 | wdev, data, data_len); |
| 10928 | cds_ssr_unprotect(__func__); |
| 10929 | |
| 10930 | return ret; |
| 10931 | } |
| 10932 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 10933 | #undef BPF_INVALID |
| 10934 | #undef BPF_SET_RESET |
| 10935 | #undef BPF_VERSION |
| 10936 | #undef BPF_ID |
| 10937 | #undef BPF_PACKET_SIZE |
| 10938 | #undef BPF_CURRENT_OFFSET |
| 10939 | #undef BPF_PROGRAM |
| 10940 | #undef BPF_MAX |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 10941 | |
| 10942 | /** |
| 10943 | * define short names for the global vendor params |
| 10944 | * used by wlan_hdd_cfg80211_wakelock_stats_rsp_callback() |
| 10945 | */ |
| 10946 | #define PARAM_TOTAL_CMD_EVENT_WAKE \ |
| 10947 | QCA_WLAN_VENDOR_ATTR_TOTAL_CMD_EVENT_WAKE |
| 10948 | #define PARAM_CMD_EVENT_WAKE_CNT_PTR \ |
| 10949 | QCA_WLAN_VENDOR_ATTR_CMD_EVENT_WAKE_CNT_PTR |
| 10950 | #define PARAM_CMD_EVENT_WAKE_CNT_SZ \ |
| 10951 | QCA_WLAN_VENDOR_ATTR_CMD_EVENT_WAKE_CNT_SZ |
| 10952 | #define PARAM_TOTAL_DRIVER_FW_LOCAL_WAKE \ |
| 10953 | QCA_WLAN_VENDOR_ATTR_TOTAL_DRIVER_FW_LOCAL_WAKE |
| 10954 | #define PARAM_DRIVER_FW_LOCAL_WAKE_CNT_PTR \ |
| 10955 | QCA_WLAN_VENDOR_ATTR_DRIVER_FW_LOCAL_WAKE_CNT_PTR |
| 10956 | #define PARAM_DRIVER_FW_LOCAL_WAKE_CNT_SZ \ |
| 10957 | QCA_WLAN_VENDOR_ATTR_DRIVER_FW_LOCAL_WAKE_CNT_SZ |
| 10958 | #define PARAM_TOTAL_RX_DATA_WAKE \ |
| 10959 | QCA_WLAN_VENDOR_ATTR_TOTAL_RX_DATA_WAKE |
| 10960 | #define PARAM_RX_UNICAST_CNT \ |
| 10961 | QCA_WLAN_VENDOR_ATTR_RX_UNICAST_CNT |
| 10962 | #define PARAM_RX_MULTICAST_CNT \ |
| 10963 | QCA_WLAN_VENDOR_ATTR_RX_MULTICAST_CNT |
| 10964 | #define PARAM_RX_BROADCAST_CNT \ |
| 10965 | QCA_WLAN_VENDOR_ATTR_RX_BROADCAST_CNT |
| 10966 | #define PARAM_ICMP_PKT \ |
| 10967 | QCA_WLAN_VENDOR_ATTR_ICMP_PKT |
| 10968 | #define PARAM_ICMP6_PKT \ |
| 10969 | QCA_WLAN_VENDOR_ATTR_ICMP6_PKT |
| 10970 | #define PARAM_ICMP6_RA \ |
| 10971 | QCA_WLAN_VENDOR_ATTR_ICMP6_RA |
| 10972 | #define PARAM_ICMP6_NA \ |
| 10973 | QCA_WLAN_VENDOR_ATTR_ICMP6_NA |
| 10974 | #define PARAM_ICMP6_NS \ |
| 10975 | QCA_WLAN_VENDOR_ATTR_ICMP6_NS |
| 10976 | #define PARAM_ICMP4_RX_MULTICAST_CNT \ |
| 10977 | QCA_WLAN_VENDOR_ATTR_ICMP4_RX_MULTICAST_CNT |
| 10978 | #define PARAM_ICMP6_RX_MULTICAST_CNT \ |
| 10979 | QCA_WLAN_VENDOR_ATTR_ICMP6_RX_MULTICAST_CNT |
| 10980 | #define PARAM_OTHER_RX_MULTICAST_CNT \ |
| 10981 | QCA_WLAN_VENDOR_ATTR_OTHER_RX_MULTICAST_CNT |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 10982 | #define PARAM_RSSI_BREACH_CNT \ |
| 10983 | QCA_WLAN_VENDOR_ATTR_RSSI_BREACH_CNT |
| 10984 | #define PARAM_LOW_RSSI_CNT \ |
| 10985 | QCA_WLAN_VENDOR_ATTR_LOW_RSSI_CNT |
| 10986 | #define PARAM_GSCAN_CNT \ |
| 10987 | QCA_WLAN_VENDOR_ATTR_GSCAN_CNT |
| 10988 | #define PARAM_PNO_COMPLETE_CNT \ |
| 10989 | QCA_WLAN_VENDOR_ATTR_PNO_COMPLETE_CNT |
| 10990 | #define PARAM_PNO_MATCH_CNT \ |
| 10991 | QCA_WLAN_VENDOR_ATTR_PNO_MATCH_CNT |
| 10992 | |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 10993 | |
| 10994 | |
| 10995 | /** |
| 10996 | * hdd_send_wakelock_stats() - API to send wakelock stats |
| 10997 | * @ctx: context to be passed to callback |
| 10998 | * @data: data passed to callback |
| 10999 | * |
| 11000 | * This function is used to send wake lock stats to HAL layer |
| 11001 | * |
| 11002 | * Return: 0 on success, error number otherwise. |
| 11003 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 11004 | 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] | 11005 | const struct sir_wake_lock_stats *data) |
| 11006 | { |
| 11007 | struct sk_buff *skb; |
| 11008 | uint32_t nl_buf_len; |
| 11009 | uint32_t total_rx_data_wake, rx_multicast_cnt; |
| 11010 | uint32_t ipv6_rx_multicast_addr_cnt; |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 11011 | uint32_t icmpv6_cnt; |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11012 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11013 | hdd_enter(); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11014 | |
| 11015 | nl_buf_len = NLMSG_HDRLEN; |
| 11016 | nl_buf_len += |
| 11017 | QCA_WLAN_VENDOR_GET_WAKE_STATS_MAX * |
| 11018 | (NLMSG_HDRLEN + sizeof(uint32_t)); |
| 11019 | |
| 11020 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 11021 | |
| 11022 | if (!skb) { |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 11023 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11024 | return -ENOMEM; |
| 11025 | } |
| 11026 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11027 | hdd_debug("wow_ucast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11028 | data->wow_ucast_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11029 | hdd_debug("wow_bcast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11030 | data->wow_bcast_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11031 | hdd_debug("wow_ipv4_mcast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11032 | data->wow_ipv4_mcast_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11033 | hdd_debug("wow_ipv6_mcast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11034 | data->wow_ipv6_mcast_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11035 | hdd_debug("wow_ipv6_mcast_ra_stats %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11036 | data->wow_ipv6_mcast_ra_stats); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11037 | hdd_debug("wow_ipv6_mcast_ns_stats %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11038 | data->wow_ipv6_mcast_ns_stats); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11039 | hdd_debug("wow_ipv6_mcast_na_stats %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11040 | data->wow_ipv6_mcast_na_stats); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11041 | hdd_debug("wow_icmpv4_count %d", data->wow_icmpv4_count); |
| 11042 | hdd_debug("wow_icmpv6_count %d", |
Himanshu Agarwal | 4574e28 | 2016-08-10 15:22:45 +0530 | [diff] [blame] | 11043 | data->wow_icmpv6_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11044 | hdd_debug("wow_rssi_breach_wake_up_count %d", |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 11045 | data->wow_rssi_breach_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11046 | hdd_debug("wow_low_rssi_wake_up_count %d", |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 11047 | data->wow_low_rssi_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11048 | hdd_debug("wow_gscan_wake_up_count %d", |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 11049 | data->wow_gscan_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11050 | hdd_debug("wow_pno_complete_wake_up_count %d", |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 11051 | data->wow_pno_complete_wake_up_count); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11052 | hdd_debug("wow_pno_match_wake_up_count %d", |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 11053 | data->wow_pno_match_wake_up_count); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11054 | |
| 11055 | ipv6_rx_multicast_addr_cnt = |
Himanshu Agarwal | 4574e28 | 2016-08-10 15:22:45 +0530 | [diff] [blame] | 11056 | data->wow_ipv6_mcast_wake_up_count; |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11057 | |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 11058 | icmpv6_cnt = |
Himanshu Agarwal | 4574e28 | 2016-08-10 15:22:45 +0530 | [diff] [blame] | 11059 | data->wow_icmpv6_count; |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 11060 | |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11061 | rx_multicast_cnt = |
| 11062 | data->wow_ipv4_mcast_wake_up_count + |
| 11063 | ipv6_rx_multicast_addr_cnt; |
| 11064 | |
| 11065 | total_rx_data_wake = |
| 11066 | data->wow_ucast_wake_up_count + |
| 11067 | data->wow_bcast_wake_up_count + |
| 11068 | rx_multicast_cnt; |
| 11069 | |
| 11070 | if (nla_put_u32(skb, PARAM_TOTAL_CMD_EVENT_WAKE, 0) || |
| 11071 | nla_put_u32(skb, PARAM_CMD_EVENT_WAKE_CNT_PTR, 0) || |
| 11072 | nla_put_u32(skb, PARAM_CMD_EVENT_WAKE_CNT_SZ, 0) || |
| 11073 | nla_put_u32(skb, PARAM_TOTAL_DRIVER_FW_LOCAL_WAKE, 0) || |
| 11074 | nla_put_u32(skb, PARAM_DRIVER_FW_LOCAL_WAKE_CNT_PTR, 0) || |
| 11075 | nla_put_u32(skb, PARAM_DRIVER_FW_LOCAL_WAKE_CNT_SZ, 0) || |
| 11076 | nla_put_u32(skb, PARAM_TOTAL_RX_DATA_WAKE, |
| 11077 | total_rx_data_wake) || |
| 11078 | nla_put_u32(skb, PARAM_RX_UNICAST_CNT, |
| 11079 | data->wow_ucast_wake_up_count) || |
| 11080 | nla_put_u32(skb, PARAM_RX_MULTICAST_CNT, |
| 11081 | rx_multicast_cnt) || |
| 11082 | nla_put_u32(skb, PARAM_RX_BROADCAST_CNT, |
| 11083 | data->wow_bcast_wake_up_count) || |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 11084 | nla_put_u32(skb, PARAM_ICMP_PKT, |
| 11085 | data->wow_icmpv4_count) || |
| 11086 | nla_put_u32(skb, PARAM_ICMP6_PKT, |
| 11087 | icmpv6_cnt) || |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11088 | nla_put_u32(skb, PARAM_ICMP6_RA, |
| 11089 | data->wow_ipv6_mcast_ra_stats) || |
| 11090 | nla_put_u32(skb, PARAM_ICMP6_NA, |
| 11091 | data->wow_ipv6_mcast_na_stats) || |
| 11092 | nla_put_u32(skb, PARAM_ICMP6_NS, |
| 11093 | data->wow_ipv6_mcast_ns_stats) || |
| 11094 | nla_put_u32(skb, PARAM_ICMP4_RX_MULTICAST_CNT, |
| 11095 | data->wow_ipv4_mcast_wake_up_count) || |
| 11096 | nla_put_u32(skb, PARAM_ICMP6_RX_MULTICAST_CNT, |
| 11097 | ipv6_rx_multicast_addr_cnt) || |
Poddar, Siddarth | c01681a | 2016-12-21 18:36:30 +0530 | [diff] [blame] | 11098 | nla_put_u32(skb, PARAM_OTHER_RX_MULTICAST_CNT, 0) || |
| 11099 | nla_put_u32(skb, PARAM_RSSI_BREACH_CNT, |
| 11100 | data->wow_rssi_breach_wake_up_count) || |
| 11101 | nla_put_u32(skb, PARAM_LOW_RSSI_CNT, |
| 11102 | data->wow_low_rssi_wake_up_count) || |
| 11103 | nla_put_u32(skb, PARAM_GSCAN_CNT, |
| 11104 | data->wow_gscan_wake_up_count) || |
| 11105 | nla_put_u32(skb, PARAM_PNO_COMPLETE_CNT, |
| 11106 | data->wow_pno_complete_wake_up_count) || |
| 11107 | nla_put_u32(skb, PARAM_PNO_MATCH_CNT, |
| 11108 | data->wow_pno_match_wake_up_count)) { |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 11109 | hdd_err("nla put fail"); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11110 | goto nla_put_failure; |
| 11111 | } |
| 11112 | |
| 11113 | cfg80211_vendor_cmd_reply(skb); |
| 11114 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11115 | hdd_exit(); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11116 | return 0; |
| 11117 | |
| 11118 | nla_put_failure: |
| 11119 | kfree_skb(skb); |
| 11120 | return -EINVAL; |
| 11121 | } |
| 11122 | |
| 11123 | /** |
| 11124 | * __wlan_hdd_cfg80211_get_wakelock_stats() - gets wake lock stats |
| 11125 | * @wiphy: wiphy pointer |
| 11126 | * @wdev: pointer to struct wireless_dev |
| 11127 | * @data: pointer to incoming NL vendor data |
| 11128 | * @data_len: length of @data |
| 11129 | * |
| 11130 | * This function parses the incoming NL vendor command data attributes and |
| 11131 | * invokes the SME Api and blocks on a completion variable. |
| 11132 | * WMA copies required data and invokes callback |
| 11133 | * wlan_hdd_cfg80211_wakelock_stats_rsp_callback to send wake lock stats. |
| 11134 | * |
| 11135 | * Return: 0 on success; error number otherwise. |
| 11136 | */ |
| 11137 | static int __wlan_hdd_cfg80211_get_wakelock_stats(struct wiphy *wiphy, |
| 11138 | struct wireless_dev *wdev, |
| 11139 | const void *data, |
| 11140 | int data_len) |
| 11141 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 11142 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11143 | int status, ret; |
| 11144 | struct sir_wake_lock_stats wake_lock_stats; |
| 11145 | QDF_STATUS qdf_status; |
| 11146 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11147 | hdd_enter(); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11148 | |
| 11149 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 11150 | hdd_err("Command not allowed in FTM mode"); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11151 | return -EINVAL; |
| 11152 | } |
| 11153 | |
| 11154 | status = wlan_hdd_validate_context(hdd_ctx); |
| 11155 | if (0 != status) |
| 11156 | return -EINVAL; |
| 11157 | |
| 11158 | qdf_status = wma_get_wakelock_stats(&wake_lock_stats); |
| 11159 | if (qdf_status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 11160 | hdd_err("failed to get wakelock stats(err=%d)", qdf_status); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11161 | return -EINVAL; |
| 11162 | } |
| 11163 | |
| 11164 | ret = hdd_send_wakelock_stats(hdd_ctx, |
| 11165 | &wake_lock_stats); |
| 11166 | if (ret) |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 11167 | hdd_err("Failed to post wake lock stats"); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11168 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11169 | hdd_exit(); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11170 | return ret; |
| 11171 | } |
| 11172 | |
| 11173 | /** |
| 11174 | * wlan_hdd_cfg80211_get_wakelock_stats() - gets wake lock stats |
| 11175 | * @wiphy: wiphy pointer |
| 11176 | * @wdev: pointer to struct wireless_dev |
| 11177 | * @data: pointer to incoming NL vendor data |
| 11178 | * @data_len: length of @data |
| 11179 | * |
| 11180 | * This function parses the incoming NL vendor command data attributes and |
| 11181 | * invokes the SME Api and blocks on a completion variable. |
| 11182 | * WMA copies required data and invokes callback |
| 11183 | * wlan_hdd_cfg80211_wakelock_stats_rsp_callback to send wake lock stats. |
| 11184 | * |
| 11185 | * Return: 0 on success; error number otherwise. |
| 11186 | */ |
| 11187 | static int wlan_hdd_cfg80211_get_wakelock_stats(struct wiphy *wiphy, |
| 11188 | struct wireless_dev *wdev, |
| 11189 | const void *data, int data_len) |
| 11190 | { |
| 11191 | int ret; |
| 11192 | |
| 11193 | cds_ssr_protect(__func__); |
| 11194 | ret = __wlan_hdd_cfg80211_get_wakelock_stats(wiphy, wdev, data, |
| 11195 | data_len); |
Jeff Johnson | f3a64e6 | 2016-10-12 17:17:34 -0700 | [diff] [blame] | 11196 | cds_ssr_unprotect(__func__); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 11197 | |
| 11198 | return ret; |
| 11199 | } |
| 11200 | |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 11201 | /** |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 11202 | * __wlan_hdd_cfg80211_get_bus_size() - Get WMI Bus size |
| 11203 | * @wiphy: wiphy structure pointer |
| 11204 | * @wdev: Wireless device structure pointer |
| 11205 | * @data: Pointer to the data received |
| 11206 | * @data_len: Length of @data |
| 11207 | * |
| 11208 | * This function reads wmi max bus size and fill in the skb with |
| 11209 | * NL attributes and send up the NL event. |
| 11210 | * Return: 0 on success; errno on failure |
| 11211 | */ |
| 11212 | static int |
| 11213 | __wlan_hdd_cfg80211_get_bus_size(struct wiphy *wiphy, |
| 11214 | struct wireless_dev *wdev, |
| 11215 | const void *data, int data_len) |
| 11216 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 11217 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 11218 | int ret_val; |
| 11219 | struct sk_buff *skb; |
| 11220 | uint32_t nl_buf_len; |
| 11221 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11222 | hdd_enter(); |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 11223 | |
| 11224 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 11225 | if (ret_val) |
| 11226 | return ret_val; |
| 11227 | |
| 11228 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 11229 | hdd_err("Command not allowed in FTM mode"); |
| 11230 | return -EINVAL; |
| 11231 | } |
| 11232 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 11233 | 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] | 11234 | |
| 11235 | nl_buf_len = NLMSG_HDRLEN; |
| 11236 | nl_buf_len += (sizeof(hdd_ctx->wmi_max_len) + NLA_HDRLEN); |
| 11237 | |
| 11238 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 11239 | if (!skb) { |
| 11240 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
| 11241 | return -ENOMEM; |
| 11242 | } |
| 11243 | |
| 11244 | if (nla_put_u16(skb, QCA_WLAN_VENDOR_ATTR_DRV_INFO_BUS_SIZE, |
| 11245 | hdd_ctx->wmi_max_len)) { |
| 11246 | hdd_err("nla put failure"); |
| 11247 | goto nla_put_failure; |
| 11248 | } |
| 11249 | |
| 11250 | cfg80211_vendor_cmd_reply(skb); |
| 11251 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11252 | hdd_exit(); |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 11253 | |
| 11254 | return 0; |
| 11255 | |
| 11256 | nla_put_failure: |
| 11257 | kfree_skb(skb); |
| 11258 | return -EINVAL; |
| 11259 | } |
| 11260 | |
| 11261 | /** |
| 11262 | * wlan_hdd_cfg80211_get_bus_size() - SSR Wrapper to Get Bus size |
| 11263 | * @wiphy: wiphy structure pointer |
| 11264 | * @wdev: Wireless device structure pointer |
| 11265 | * @data: Pointer to the data received |
| 11266 | * @data_len: Length of @data |
| 11267 | * |
| 11268 | * Return: 0 on success; errno on failure |
| 11269 | */ |
| 11270 | static int wlan_hdd_cfg80211_get_bus_size(struct wiphy *wiphy, |
| 11271 | struct wireless_dev *wdev, |
| 11272 | const void *data, int data_len) |
| 11273 | { |
| 11274 | int ret; |
| 11275 | |
| 11276 | cds_ssr_protect(__func__); |
| 11277 | ret = __wlan_hdd_cfg80211_get_bus_size(wiphy, wdev, data, data_len); |
| 11278 | cds_ssr_unprotect(__func__); |
| 11279 | |
| 11280 | return ret; |
| 11281 | } |
| 11282 | |
| 11283 | /** |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 11284 | *__wlan_hdd_cfg80211_setband() - set band |
| 11285 | * @wiphy: Pointer to wireless phy |
| 11286 | * @wdev: Pointer to wireless device |
| 11287 | * @data: Pointer to data |
| 11288 | * @data_len: Length of @data |
| 11289 | * |
| 11290 | * Return: 0 on success, negative errno on failure |
| 11291 | */ |
| 11292 | static int __wlan_hdd_cfg80211_setband(struct wiphy *wiphy, |
| 11293 | struct wireless_dev *wdev, |
| 11294 | const void *data, int data_len) |
| 11295 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 11296 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 11297 | struct net_device *dev = wdev->netdev; |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 11298 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1]; |
| 11299 | int ret; |
| 11300 | static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1] |
| 11301 | = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 } }; |
| 11302 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11303 | hdd_enter(); |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 11304 | |
| 11305 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 11306 | if (ret) |
| 11307 | return ret; |
| 11308 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 11309 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, |
| 11310 | data, data_len, policy)) { |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 11311 | hdd_err("Invalid ATTR"); |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 11312 | return -EINVAL; |
| 11313 | } |
| 11314 | |
| 11315 | if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) { |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 11316 | hdd_err("attr SETBAND_VALUE failed"); |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 11317 | return -EINVAL; |
| 11318 | } |
| 11319 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 11320 | ret = hdd_reg_set_band(dev, |
| 11321 | nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE])); |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 11322 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11323 | hdd_exit(); |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 11324 | return ret; |
| 11325 | } |
| 11326 | |
| 11327 | /** |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 11328 | *wlan_hdd_validate_acs_channel() - validate channel provided by ACS |
| 11329 | * @adapter: hdd adapter |
| 11330 | * @channel: channel number |
| 11331 | * |
| 11332 | * return: QDF status based on success or failure |
| 11333 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 11334 | static QDF_STATUS wlan_hdd_validate_acs_channel(struct hdd_adapter *adapter, |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 11335 | int channel, int chan_bw) |
| 11336 | { |
| 11337 | if (QDF_STATUS_SUCCESS != |
| 11338 | wlan_hdd_validate_operation_channel(adapter, channel)) |
| 11339 | return QDF_STATUS_E_FAILURE; |
| 11340 | if ((wlansap_is_channel_in_nol_list(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 11341 | channel, |
| 11342 | PHY_SINGLE_CHANNEL_CENTERED))) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11343 | hdd_info("channel %d is in nol", channel); |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 11344 | return -EINVAL; |
| 11345 | } |
| 11346 | |
| 11347 | if ((wlansap_is_channel_leaking_in_nol( |
| 11348 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 11349 | channel, chan_bw))) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11350 | hdd_info("channel %d is leaking in nol", channel); |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 11351 | return -EINVAL; |
| 11352 | } |
| 11353 | |
| 11354 | return 0; |
| 11355 | |
| 11356 | } |
| 11357 | |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 11358 | static void hdd_update_acs_sap_config(struct hdd_context *hdd_ctx, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11359 | tsap_Config_t *sap_config, |
| 11360 | struct hdd_vendor_chan_info *channel_list) |
| 11361 | { |
| 11362 | sap_config->channel = channel_list->pri_ch; |
| 11363 | |
| 11364 | sap_config->ch_params.center_freq_seg0 = |
| 11365 | channel_list->vht_seg0_center_ch; |
| 11366 | sap_config->ch_params.center_freq_seg1 = |
| 11367 | channel_list->vht_seg1_center_ch; |
| 11368 | |
| 11369 | sap_config->ch_params.sec_ch_offset = channel_list->ht_sec_ch; |
| 11370 | sap_config->ch_params.ch_width = channel_list->chan_width; |
| 11371 | if (sap_config->channel >= 36) |
| 11372 | sap_config->ch_width_orig = |
| 11373 | hdd_ctx->config->vhtChannelWidth; |
| 11374 | else |
| 11375 | sap_config->ch_width_orig = |
| 11376 | hdd_ctx->config->nChannelBondingMode24GHz ? |
| 11377 | eHT_CHANNEL_WIDTH_40MHZ : |
| 11378 | eHT_CHANNEL_WIDTH_20MHZ; |
| 11379 | |
| 11380 | sap_config->acs_cfg.pri_ch = channel_list->pri_ch; |
| 11381 | sap_config->acs_cfg.ch_width = channel_list->chan_width; |
| 11382 | sap_config->acs_cfg.vht_seg0_center_ch = |
| 11383 | channel_list->vht_seg0_center_ch; |
| 11384 | sap_config->acs_cfg.vht_seg1_center_ch = |
| 11385 | channel_list->vht_seg1_center_ch; |
| 11386 | sap_config->acs_cfg.ht_sec_ch = channel_list->ht_sec_ch; |
| 11387 | } |
| 11388 | |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 11389 | 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] | 11390 | uint8_t channel_cnt, |
| 11391 | struct hdd_vendor_chan_info *channel_list) |
| 11392 | { |
| 11393 | tsap_Config_t *sap_config; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11394 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 11395 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11396 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 11397 | |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 11398 | if (!channel_list) { |
| 11399 | hdd_err("channel_list is NULL"); |
| 11400 | return -EINVAL; |
| 11401 | } |
| 11402 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11403 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11404 | sap_config = &adapter->session.ap.sap_config; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11405 | |
| 11406 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11407 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11408 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11409 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11410 | } |
| 11411 | |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 11412 | if (channel_list->pri_ch == 0) { |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11413 | /* Check mode, set default channel */ |
| 11414 | channel_list->pri_ch = 6; |
| 11415 | /* |
| 11416 | * sap_select_default_oper_chan(hdd_ctx->hHal, |
| 11417 | * sap_config->acs_cfg.hw_mode); |
| 11418 | */ |
| 11419 | } |
| 11420 | |
| 11421 | switch (reason) { |
| 11422 | /* SAP init case */ |
| 11423 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 11424 | hdd_update_acs_sap_config(hdd_ctx, sap_config, channel_list); |
| 11425 | /* Update Hostapd */ |
| 11426 | wlan_hdd_cfg80211_acs_ch_select_evt(adapter); |
| 11427 | break; |
| 11428 | |
| 11429 | /* DFS detected on current channel */ |
| 11430 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 11431 | wlan_sap_update_next_channel( |
| 11432 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 11433 | channel_list->pri_ch, |
| 11434 | channel_list->chan_width); |
| 11435 | status = sme_update_new_channel_event( |
| 11436 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11437 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11438 | break; |
| 11439 | |
| 11440 | /* LTE coex event on current channel */ |
| 11441 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 11442 | sap_config->acs_cfg.pri_ch = channel_list->pri_ch; |
| 11443 | sap_config->acs_cfg.ch_width = channel_list->chan_width; |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 11444 | hdd_ap_ctx->sap_config.ch_width_orig = |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11445 | channel_list->chan_width; |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 11446 | hdd_switch_sap_channel(adapter, sap_config->acs_cfg.pri_ch, |
| 11447 | true); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11448 | break; |
| 11449 | |
| 11450 | default: |
| 11451 | hdd_info("invalid reason for timer invoke"); |
| 11452 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11453 | hdd_exit(); |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 11454 | return qdf_status_to_os_return(status); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11455 | } |
| 11456 | |
| 11457 | /** |
| 11458 | * Define short name for vendor channel set config |
| 11459 | */ |
| 11460 | #define SET_CHAN_REASON QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_REASON |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11461 | #define SET_CHAN_CHAN_LIST QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_LIST |
| 11462 | #define SET_CHAN_PRIMARY_CHANNEL \ |
| 11463 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_PRIMARY |
| 11464 | #define SET_CHAN_SECONDARY_CHANNEL \ |
| 11465 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_SECONDARY |
| 11466 | #define SET_CHAN_SEG0_CENTER_CHANNEL \ |
| 11467 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_CENTER_SEG0 |
| 11468 | #define SET_CHAN_SEG1_CENTER_CHANNEL \ |
| 11469 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_CENTER_SEG1 |
| 11470 | #define SET_CHAN_CHANNEL_WIDTH \ |
| 11471 | QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_WIDTH |
| 11472 | #define SET_CHAN_MAX QCA_WLAN_VENDOR_ATTR_EXTERNAL_ACS_CHANNEL_MAX |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 11473 | #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] | 11474 | |
| 11475 | /** |
| 11476 | * hdd_parse_vendor_acs_chan_config() - API to parse vendor acs channel config |
| 11477 | * @channel_list: pointer to hdd_vendor_chan_info |
| 11478 | * @reason: channel change reason |
| 11479 | * @channel_cnt: channel count |
| 11480 | * @data: data |
| 11481 | * @data_len: data len |
| 11482 | * |
| 11483 | * Return: 0 on success, negative errno on failure |
| 11484 | */ |
| 11485 | static int hdd_parse_vendor_acs_chan_config(struct hdd_vendor_chan_info |
| 11486 | **chan_list_ptr, uint8_t *reason, uint8_t *channel_cnt, |
| 11487 | const void *data, int data_len) |
| 11488 | { |
| 11489 | int rem, i = 0; |
| 11490 | struct nlattr *tb[SET_CHAN_MAX + 1]; |
| 11491 | struct nlattr *tb2[SET_CHAN_MAX + 1]; |
| 11492 | struct nlattr *curr_attr; |
| 11493 | struct hdd_vendor_chan_info *channel_list; |
| 11494 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 11495 | 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] | 11496 | hdd_err("Invalid ATTR"); |
| 11497 | return -EINVAL; |
| 11498 | } |
| 11499 | |
| 11500 | if (tb[SET_CHAN_REASON]) |
| 11501 | *reason = nla_get_u8(tb[SET_CHAN_REASON]); |
| 11502 | |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 11503 | nla_for_each_nested(curr_attr, tb[SET_CHAN_CHAN_LIST], rem) |
| 11504 | i++; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11505 | |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 11506 | *channel_cnt = i; |
| 11507 | |
| 11508 | if (i == 0) |
| 11509 | hdd_err("incorrect channel count"); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11510 | |
| 11511 | channel_list = qdf_mem_malloc(sizeof(struct hdd_vendor_chan_info) * |
| 11512 | (*channel_cnt)); |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 11513 | if (NULL == channel_list) { |
| 11514 | hdd_err("Could not allocate for channel_list"); |
| 11515 | return -ENOMEM; |
| 11516 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11517 | |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 11518 | i = 0; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11519 | nla_for_each_nested(curr_attr, tb[SET_CHAN_CHAN_LIST], rem) { |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 11520 | if (wlan_cfg80211_nla_parse(tb2, SET_CHAN_MAX, |
| 11521 | nla_data(curr_attr), |
| 11522 | nla_len(curr_attr), NULL)) { |
| 11523 | hdd_err("nla_parse failed"); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11524 | return -EINVAL; |
| 11525 | } |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 11526 | if (tb2[SET_EXT_ACS_BAND]) { |
| 11527 | channel_list[i].band = |
| 11528 | nla_get_u8(tb2[SET_EXT_ACS_BAND]); |
| 11529 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11530 | /* Parse and Fetch allowed SSID list*/ |
| 11531 | if (tb2[SET_CHAN_PRIMARY_CHANNEL]) { |
| 11532 | channel_list[i].pri_ch = |
| 11533 | nla_get_u8( |
| 11534 | tb2[SET_CHAN_PRIMARY_CHANNEL]); |
| 11535 | } |
| 11536 | if (tb2[SET_CHAN_SECONDARY_CHANNEL]) { |
| 11537 | channel_list[i].ht_sec_ch = |
| 11538 | nla_get_u8(tb2[SET_CHAN_SECONDARY_CHANNEL]); |
| 11539 | } |
| 11540 | if (tb2[SET_CHAN_SEG0_CENTER_CHANNEL]) { |
| 11541 | channel_list[i].vht_seg0_center_ch = |
| 11542 | nla_get_u8(tb2[SET_CHAN_SEG0_CENTER_CHANNEL]); |
| 11543 | } |
| 11544 | if (tb2[SET_CHAN_SEG1_CENTER_CHANNEL]) { |
| 11545 | channel_list[i].vht_seg1_center_ch = |
| 11546 | nla_get_u8(tb2[SET_CHAN_SEG1_CENTER_CHANNEL]); |
| 11547 | } |
| 11548 | if (tb2[SET_CHAN_CHANNEL_WIDTH]) { |
| 11549 | channel_list[i].chan_width = |
| 11550 | nla_get_u8(tb2[SET_CHAN_CHANNEL_WIDTH]); |
| 11551 | } |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 11552 | 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] | 11553 | i, channel_list[i].pri_ch, |
| 11554 | channel_list[i].ht_sec_ch, |
| 11555 | channel_list[i].vht_seg0_center_ch, |
| 11556 | channel_list[i].vht_seg1_center_ch, |
| 11557 | channel_list[i].chan_width); |
| 11558 | i++; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11559 | } |
| 11560 | *chan_list_ptr = channel_list; |
| 11561 | |
| 11562 | return 0; |
| 11563 | } |
| 11564 | |
| 11565 | /** |
| 11566 | * Undef short names for vendor set channel configuration |
| 11567 | */ |
| 11568 | #undef SET_CHAN_REASON |
| 11569 | #undef SET_CHAN_CHANNEL_COUNT |
| 11570 | #undef SET_CHAN_CHAN_LIST |
| 11571 | #undef SET_CHAN_PRIMARY_CHANNEL |
| 11572 | #undef SET_CHAN_SECONDARY_CHANNEL |
| 11573 | #undef SET_CHAN_SEG0_CENTER_CHANNEL |
| 11574 | #undef SET_CHAN_SEG1_CENTER_CHANNEL |
| 11575 | #undef SET_CHAN_CHANNEL_WIDTH |
| 11576 | #undef SET_CHAN_MAX |
| 11577 | |
| 11578 | /** |
| 11579 | * __wlan_hdd_cfg80211_update_vendor_channel() - update vendor channel |
| 11580 | * @wiphy: Pointer to wireless phy |
| 11581 | * @wdev: Pointer to wireless device |
| 11582 | * @data: Pointer to data |
| 11583 | * @data_len: Length of @data |
| 11584 | * |
| 11585 | * Return: 0 on success, negative errno on failure |
| 11586 | */ |
| 11587 | static int __wlan_hdd_cfg80211_update_vendor_channel(struct wiphy *wiphy, |
| 11588 | struct wireless_dev *wdev, |
| 11589 | const void *data, int data_len) |
| 11590 | { |
| 11591 | int ret_val; |
| 11592 | QDF_STATUS qdf_status; |
| 11593 | uint8_t channel_cnt = 0, reason = -1; |
| 11594 | struct hdd_vendor_chan_info *channel_list = NULL; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 11595 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(wdev->netdev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 11596 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 11597 | struct hdd_vendor_chan_info *channel_list_ptr; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11598 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11599 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11600 | |
| 11601 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 11602 | if (ret_val) |
| 11603 | return ret_val; |
| 11604 | |
| 11605 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 11606 | hdd_err("Command not allowed in FTM mode"); |
| 11607 | return -EINVAL; |
| 11608 | } |
| 11609 | |
| 11610 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 11611 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 11612 | else { |
| 11613 | hdd_err("already timeout happened for acs"); |
| 11614 | return -EINVAL; |
| 11615 | } |
| 11616 | |
| 11617 | ret_val = hdd_parse_vendor_acs_chan_config(&channel_list, &reason, |
| 11618 | &channel_cnt, data, data_len); |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 11619 | channel_list_ptr = channel_list; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11620 | if (ret_val) |
| 11621 | return ret_val; |
| 11622 | |
| 11623 | /* Validate channel to be set */ |
| 11624 | while (channel_cnt && channel_list) { |
| 11625 | qdf_status = wlan_hdd_validate_acs_channel(adapter, |
| 11626 | channel_list->pri_ch, |
| 11627 | channel_list->chan_width); |
| 11628 | if (qdf_status == QDF_STATUS_SUCCESS) |
| 11629 | break; |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 11630 | else if (channel_cnt == 1) { |
| 11631 | hdd_err("invalid channel %d received from app", |
| 11632 | channel_list->pri_ch); |
| 11633 | channel_list->pri_ch = 0; |
| 11634 | break; |
| 11635 | } |
| 11636 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11637 | channel_cnt--; |
| 11638 | channel_list++; |
| 11639 | } |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 11640 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11641 | if ((channel_cnt <= 0) || !channel_list) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 11642 | hdd_err("no available channel/chanlist %d/%pK", channel_cnt, |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 11643 | channel_list); |
| 11644 | qdf_mem_free(channel_list_ptr); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11645 | return -EINVAL; |
| 11646 | } |
| 11647 | |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 11648 | hdd_debug("received primary channel as %d", channel_list->pri_ch); |
| 11649 | |
| 11650 | ret_val = hdd_update_acs_channel(adapter, reason, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11651 | channel_cnt, channel_list); |
Nachiket Kukade | c3f92f7 | 2017-08-07 17:04:50 +0530 | [diff] [blame] | 11652 | qdf_mem_free(channel_list_ptr); |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 11653 | return ret_val; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 11654 | } |
| 11655 | |
| 11656 | /** |
| 11657 | * wlan_hdd_cfg80211_update_vendor_channel() - update vendor channel |
| 11658 | * @wiphy: Pointer to wireless phy |
| 11659 | * @wdev: Pointer to wireless device |
| 11660 | * @data: Pointer to data |
| 11661 | * @data_len: Length of @data |
| 11662 | * |
| 11663 | * Return: 0 on success, negative errno on failure |
| 11664 | */ |
| 11665 | static int wlan_hdd_cfg80211_update_vendor_channel(struct wiphy *wiphy, |
| 11666 | struct wireless_dev *wdev, |
| 11667 | const void *data, int data_len) |
| 11668 | { |
| 11669 | int ret; |
| 11670 | |
| 11671 | cds_ssr_protect(__func__); |
| 11672 | ret = __wlan_hdd_cfg80211_update_vendor_channel(wiphy, wdev, data, |
| 11673 | data_len); |
| 11674 | cds_ssr_protect(__func__); |
| 11675 | |
| 11676 | return ret; |
| 11677 | } |
Kapil Gupta | 94ca6f6 | 2016-12-11 18:43:12 +0530 | [diff] [blame] | 11678 | |
| 11679 | /** |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 11680 | * wlan_hdd_cfg80211_setband() - Wrapper to setband |
| 11681 | * @wiphy: wiphy structure pointer |
| 11682 | * @wdev: Wireless device structure pointer |
| 11683 | * @data: Pointer to the data received |
| 11684 | * @data_len: Length of @data |
| 11685 | * |
| 11686 | * Return: 0 on success; errno on failure |
| 11687 | */ |
| 11688 | static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy, |
| 11689 | struct wireless_dev *wdev, |
| 11690 | const void *data, int data_len) |
| 11691 | { |
| 11692 | int ret; |
| 11693 | |
| 11694 | cds_ssr_protect(__func__); |
| 11695 | ret = __wlan_hdd_cfg80211_setband(wiphy, wdev, data, data_len); |
| 11696 | cds_ssr_unprotect(__func__); |
| 11697 | |
| 11698 | return ret; |
| 11699 | } |
| 11700 | |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 11701 | /** |
| 11702 | * wlan_hdd_cfg80211_sar_convert_limit_set() - Convert limit set value |
| 11703 | * @nl80211_value: Vendor command attribute value |
| 11704 | * @wmi_value: Pointer to return converted WMI return value |
| 11705 | * |
| 11706 | * Convert NL80211 vendor command value for SAR limit set to WMI value |
| 11707 | * Return: 0 on success, -1 on invalid value |
| 11708 | */ |
| 11709 | static int wlan_hdd_cfg80211_sar_convert_limit_set(u32 nl80211_value, |
| 11710 | u32 *wmi_value) |
| 11711 | { |
| 11712 | int ret = 0; |
| 11713 | |
| 11714 | switch (nl80211_value) { |
| 11715 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_NONE: |
| 11716 | *wmi_value = WMI_SAR_FEATURE_OFF; |
| 11717 | break; |
| 11718 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF0: |
| 11719 | *wmi_value = WMI_SAR_FEATURE_ON_SET_0; |
| 11720 | break; |
| 11721 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF1: |
| 11722 | *wmi_value = WMI_SAR_FEATURE_ON_SET_1; |
| 11723 | break; |
| 11724 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF2: |
| 11725 | *wmi_value = WMI_SAR_FEATURE_ON_SET_2; |
| 11726 | break; |
| 11727 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF3: |
| 11728 | *wmi_value = WMI_SAR_FEATURE_ON_SET_3; |
| 11729 | break; |
| 11730 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF4: |
| 11731 | *wmi_value = WMI_SAR_FEATURE_ON_SET_4; |
| 11732 | break; |
| 11733 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_USER: |
| 11734 | *wmi_value = WMI_SAR_FEATURE_ON_USER_DEFINED; |
| 11735 | break; |
| 11736 | default: |
| 11737 | ret = -1; |
| 11738 | } |
| 11739 | return ret; |
| 11740 | } |
| 11741 | |
| 11742 | /** |
| 11743 | * wlan_hdd_cfg80211_sar_convert_band() - Convert WLAN band value |
| 11744 | * @nl80211_value: Vendor command attribute value |
| 11745 | * @wmi_value: Pointer to return converted WMI return value |
| 11746 | * |
| 11747 | * Convert NL80211 vendor command value for SAR BAND to WMI value |
| 11748 | * Return: 0 on success, -1 on invalid value |
| 11749 | */ |
| 11750 | static int wlan_hdd_cfg80211_sar_convert_band(u32 nl80211_value, u32 *wmi_value) |
| 11751 | { |
| 11752 | int ret = 0; |
| 11753 | |
| 11754 | switch (nl80211_value) { |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 11755 | case HDD_NL80211_BAND_2GHZ: |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 11756 | *wmi_value = WMI_SAR_2G_ID; |
| 11757 | break; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 11758 | case HDD_NL80211_BAND_5GHZ: |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 11759 | *wmi_value = WMI_SAR_5G_ID; |
| 11760 | break; |
| 11761 | default: |
| 11762 | ret = -1; |
| 11763 | } |
| 11764 | return ret; |
| 11765 | } |
| 11766 | |
| 11767 | /** |
| 11768 | * wlan_hdd_cfg80211_sar_convert_modulation() - Convert WLAN modulation value |
| 11769 | * @nl80211_value: Vendor command attribute value |
| 11770 | * @wmi_value: Pointer to return converted WMI return value |
| 11771 | * |
| 11772 | * Convert NL80211 vendor command value for SAR Modulation to WMI value |
| 11773 | * Return: 0 on success, -1 on invalid value |
| 11774 | */ |
| 11775 | static int wlan_hdd_cfg80211_sar_convert_modulation(u32 nl80211_value, |
| 11776 | u32 *wmi_value) |
| 11777 | { |
| 11778 | int ret = 0; |
| 11779 | |
| 11780 | switch (nl80211_value) { |
| 11781 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION_CCK: |
| 11782 | *wmi_value = WMI_SAR_MOD_CCK; |
| 11783 | break; |
| 11784 | case QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION_OFDM: |
| 11785 | *wmi_value = WMI_SAR_MOD_OFDM; |
| 11786 | break; |
| 11787 | default: |
| 11788 | ret = -1; |
| 11789 | } |
| 11790 | return ret; |
| 11791 | } |
| 11792 | |
Jeff Johnson | 8c83f13 | 2017-12-18 16:41:37 -0800 | [diff] [blame] | 11793 | static u32 hdd_sar_wmi_to_nl_enable(uint32_t wmi_value) |
| 11794 | { |
| 11795 | switch (wmi_value) { |
| 11796 | default: |
| 11797 | case WMI_SAR_FEATURE_OFF: |
| 11798 | return QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_NONE; |
| 11799 | case WMI_SAR_FEATURE_ON_SET_0: |
| 11800 | return QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF0; |
| 11801 | case WMI_SAR_FEATURE_ON_SET_1: |
| 11802 | return QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF1; |
| 11803 | case WMI_SAR_FEATURE_ON_SET_2: |
| 11804 | return QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF2; |
| 11805 | case WMI_SAR_FEATURE_ON_SET_3: |
| 11806 | return QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF3; |
| 11807 | case WMI_SAR_FEATURE_ON_SET_4: |
| 11808 | return QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF4; |
| 11809 | case WMI_SAR_FEATURE_ON_USER_DEFINED: |
| 11810 | return QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_USER; |
| 11811 | } |
| 11812 | } |
| 11813 | |
| 11814 | static u32 hdd_sar_wmi_to_nl_band(uint32_t wmi_value) |
| 11815 | { |
| 11816 | switch (wmi_value) { |
| 11817 | default: |
| 11818 | case WMI_SAR_2G_ID: |
| 11819 | return HDD_NL80211_BAND_2GHZ; |
| 11820 | case WMI_SAR_5G_ID: |
| 11821 | return HDD_NL80211_BAND_5GHZ; |
| 11822 | } |
| 11823 | } |
| 11824 | |
| 11825 | static u32 hdd_sar_wmi_to_nl_modulation(uint32_t wmi_value) |
| 11826 | { |
| 11827 | switch (wmi_value) { |
| 11828 | default: |
| 11829 | case WMI_SAR_MOD_CCK: |
| 11830 | return QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION_CCK; |
| 11831 | case WMI_SAR_MOD_OFDM: |
| 11832 | return QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION_OFDM; |
| 11833 | } |
| 11834 | } |
| 11835 | |
Jeff Johnson | b17a93c | 2017-06-02 12:26:55 -0700 | [diff] [blame] | 11836 | static const struct nla_policy |
| 11837 | sar_limits_policy[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX + 1] = { |
| 11838 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SAR_ENABLE] = {.type = NLA_U32}, |
| 11839 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_NUM_SPECS] = {.type = NLA_U32}, |
| 11840 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND] = {.type = NLA_U32}, |
| 11841 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_CHAIN] = {.type = NLA_U32}, |
| 11842 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION] = {.type = NLA_U32}, |
| 11843 | [QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT] = {.type = NLA_U32}, |
| 11844 | }; |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 11845 | |
Jeff Johnson | 8c83f13 | 2017-12-18 16:41:37 -0800 | [diff] [blame] | 11846 | #define WLAN_WAIT_TIME_SAR 5000 |
| 11847 | |
| 11848 | /** |
| 11849 | * hdd_sar_context - hdd sar context |
| 11850 | * @event: sar limit event |
| 11851 | */ |
| 11852 | struct hdd_sar_context { |
| 11853 | struct sar_limit_event event; |
| 11854 | }; |
| 11855 | |
| 11856 | /** |
| 11857 | * hdd_sar_cb () - sar response message handler |
| 11858 | * @cookie: hdd request cookie |
| 11859 | * @event: sar response event |
| 11860 | * |
| 11861 | * Return: none |
| 11862 | */ |
| 11863 | static void hdd_sar_cb(void *cookie, |
| 11864 | struct sar_limit_event *event) |
| 11865 | { |
| 11866 | struct hdd_request *request; |
| 11867 | struct hdd_sar_context *context; |
| 11868 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11869 | hdd_enter(); |
Jeff Johnson | 8c83f13 | 2017-12-18 16:41:37 -0800 | [diff] [blame] | 11870 | |
| 11871 | if (!event) { |
| 11872 | hdd_err("response is NULL"); |
| 11873 | return; |
| 11874 | } |
| 11875 | |
| 11876 | request = hdd_request_get(cookie); |
| 11877 | if (!request) { |
| 11878 | hdd_debug("Obsolete request"); |
| 11879 | return; |
| 11880 | } |
| 11881 | |
| 11882 | context = hdd_request_priv(request); |
| 11883 | context->event = *event; |
| 11884 | hdd_request_complete(request); |
| 11885 | hdd_request_put(request); |
| 11886 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11887 | hdd_exit(); |
Jeff Johnson | 8c83f13 | 2017-12-18 16:41:37 -0800 | [diff] [blame] | 11888 | } |
| 11889 | |
| 11890 | static uint32_t hdd_sar_get_response_len(const struct sar_limit_event *event) |
| 11891 | { |
| 11892 | uint32_t len; |
| 11893 | uint32_t row_len; |
| 11894 | |
| 11895 | len = NLMSG_HDRLEN; |
| 11896 | /* QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SAR_ENABLE */ |
| 11897 | len += NLA_HDRLEN + sizeof(u32); |
| 11898 | /* QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_NUM_SPECS */ |
| 11899 | len += NLA_HDRLEN + sizeof(u32); |
| 11900 | |
| 11901 | /* nest */ |
| 11902 | row_len = NLA_HDRLEN; |
| 11903 | /* QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND */ |
| 11904 | row_len += NLA_HDRLEN + sizeof(u32); |
| 11905 | /* QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_CHAIN */ |
| 11906 | row_len += NLA_HDRLEN + sizeof(u32); |
| 11907 | /* QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION */ |
| 11908 | row_len += NLA_HDRLEN + sizeof(u32); |
| 11909 | /* QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT */ |
| 11910 | row_len += NLA_HDRLEN + sizeof(u32); |
| 11911 | |
| 11912 | /* QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC */ |
| 11913 | len += NLA_HDRLEN + (row_len * event->num_limit_rows); |
| 11914 | |
| 11915 | return len; |
| 11916 | } |
| 11917 | |
| 11918 | static int hdd_sar_fill_response(struct sk_buff *skb, |
| 11919 | const struct sar_limit_event *event) |
| 11920 | { |
| 11921 | int errno; |
| 11922 | u32 value; |
| 11923 | u32 attr; |
| 11924 | struct nlattr *nla_spec_attr; |
| 11925 | struct nlattr *nla_row_attr; |
| 11926 | uint32_t row; |
| 11927 | const struct sar_limit_event_row *event_row; |
| 11928 | |
| 11929 | attr = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SAR_ENABLE; |
| 11930 | value = hdd_sar_wmi_to_nl_enable(event->sar_enable); |
| 11931 | errno = nla_put_u32(skb, attr, value); |
| 11932 | if (errno) |
| 11933 | return errno; |
| 11934 | |
| 11935 | attr = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_NUM_SPECS; |
| 11936 | value = event->num_limit_rows; |
| 11937 | errno = nla_put_u32(skb, attr, value); |
| 11938 | if (errno) |
| 11939 | return errno; |
| 11940 | |
| 11941 | attr = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC; |
| 11942 | nla_spec_attr = nla_nest_start(skb, attr); |
| 11943 | if (!nla_spec_attr) |
| 11944 | return -EINVAL; |
| 11945 | |
| 11946 | for (row = 0, event_row = event->sar_limit_row; |
| 11947 | row < event->num_limit_rows; |
| 11948 | row++, event_row++) { |
| 11949 | nla_row_attr = nla_nest_start(skb, attr); |
| 11950 | if (!nla_row_attr) |
| 11951 | return -EINVAL; |
| 11952 | |
| 11953 | attr = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND; |
| 11954 | value = hdd_sar_wmi_to_nl_band(event_row->band_id); |
| 11955 | errno = nla_put_u32(skb, attr, value); |
| 11956 | if (errno) |
| 11957 | return errno; |
| 11958 | |
| 11959 | attr = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_CHAIN; |
| 11960 | value = event_row->chain_id; |
| 11961 | errno = nla_put_u32(skb, attr, value); |
| 11962 | if (errno) |
| 11963 | return errno; |
| 11964 | |
| 11965 | attr = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION; |
| 11966 | value = hdd_sar_wmi_to_nl_modulation(event_row->mod_id); |
| 11967 | errno = nla_put_u32(skb, attr, value); |
| 11968 | if (errno) |
| 11969 | return errno; |
| 11970 | |
| 11971 | attr = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT; |
| 11972 | value = event_row->limit_value; |
| 11973 | errno = nla_put_u32(skb, attr, value); |
| 11974 | if (errno) |
| 11975 | return errno; |
| 11976 | |
| 11977 | nla_nest_end(skb, nla_row_attr); |
| 11978 | } |
| 11979 | nla_nest_end(skb, nla_spec_attr); |
| 11980 | |
| 11981 | return 0; |
| 11982 | } |
| 11983 | |
| 11984 | static int hdd_sar_send_response(struct wiphy *wiphy, |
| 11985 | const struct sar_limit_event *event) |
| 11986 | { |
| 11987 | uint32_t len; |
| 11988 | struct sk_buff *skb; |
| 11989 | int errno; |
| 11990 | |
| 11991 | len = hdd_sar_get_response_len(event); |
| 11992 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, len); |
| 11993 | if (!skb) { |
| 11994 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
| 11995 | return -ENOMEM; |
| 11996 | } |
| 11997 | |
| 11998 | errno = hdd_sar_fill_response(skb, event); |
| 11999 | if (errno) { |
| 12000 | kfree_skb(skb); |
| 12001 | return errno; |
| 12002 | } |
| 12003 | |
| 12004 | return cfg80211_vendor_cmd_reply(skb); |
| 12005 | } |
| 12006 | |
| 12007 | /** |
| 12008 | * __wlan_hdd_get_sar_power_limits() - Get SAR power limits |
| 12009 | * @wiphy: Pointer to wireless phy |
| 12010 | * @wdev: Pointer to wireless device |
| 12011 | * @data: Pointer to data |
| 12012 | * @data_len: Length of @data |
| 12013 | * |
| 12014 | * This function is used to retrieve Specific Absorption Rate limit specs. |
| 12015 | * |
| 12016 | * Return: 0 on success, negative errno on failure |
| 12017 | */ |
| 12018 | static int __wlan_hdd_get_sar_power_limits(struct wiphy *wiphy, |
| 12019 | struct wireless_dev *wdev, |
| 12020 | const void *data, int data_len) |
| 12021 | { |
| 12022 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 12023 | struct hdd_request *request; |
| 12024 | struct hdd_sar_context *context; |
| 12025 | void *cookie; |
| 12026 | QDF_STATUS status; |
| 12027 | int ret; |
| 12028 | static const struct hdd_request_params params = { |
| 12029 | .priv_size = sizeof(*context), |
| 12030 | .timeout_ms = WLAN_WAIT_TIME_SAR, |
| 12031 | }; |
| 12032 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12033 | hdd_enter(); |
Jeff Johnson | 8c83f13 | 2017-12-18 16:41:37 -0800 | [diff] [blame] | 12034 | |
| 12035 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12036 | hdd_err("Command not allowed in FTM mode"); |
| 12037 | return -EPERM; |
| 12038 | } |
| 12039 | |
| 12040 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 12041 | return -EINVAL; |
| 12042 | |
| 12043 | request = hdd_request_alloc(¶ms); |
| 12044 | if (!request) { |
| 12045 | hdd_err("Request allocation failure"); |
| 12046 | return -ENOMEM; |
| 12047 | } |
| 12048 | |
| 12049 | cookie = hdd_request_cookie(request); |
| 12050 | |
| 12051 | status = sme_get_sar_power_limits(hdd_ctx->hHal, hdd_sar_cb, cookie); |
| 12052 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 12053 | hdd_err("Unable to post sar message"); |
| 12054 | ret = -EINVAL; |
| 12055 | goto cleanup; |
| 12056 | } |
| 12057 | |
| 12058 | ret = hdd_request_wait_for_response(request); |
| 12059 | if (ret) { |
| 12060 | hdd_err("Target response timed out"); |
| 12061 | goto cleanup; |
| 12062 | } |
| 12063 | |
| 12064 | context = hdd_request_priv(request); |
| 12065 | ret = hdd_sar_send_response(wiphy, &context->event); |
| 12066 | |
| 12067 | cleanup: |
| 12068 | hdd_request_put(request); |
| 12069 | |
| 12070 | return ret; |
| 12071 | } |
| 12072 | |
| 12073 | /** |
| 12074 | * wlan_hdd_cfg80211_get_sar_power_limits() - Get SAR power limits |
| 12075 | * @wiphy: Pointer to wireless phy |
| 12076 | * @wdev: Pointer to wireless device |
| 12077 | * @data: Pointer to data |
| 12078 | * @data_len: Length of @data |
| 12079 | * |
| 12080 | * Wrapper function of __wlan_hdd_cfg80211_get_sar_power_limits() |
| 12081 | * |
| 12082 | * Return: 0 on success, negative errno on failure |
| 12083 | */ |
| 12084 | static int wlan_hdd_cfg80211_get_sar_power_limits(struct wiphy *wiphy, |
| 12085 | struct wireless_dev *wdev, |
| 12086 | const void *data, |
| 12087 | int data_len) |
| 12088 | { |
| 12089 | int ret; |
| 12090 | |
| 12091 | cds_ssr_protect(__func__); |
| 12092 | ret = __wlan_hdd_get_sar_power_limits(wiphy, wdev, data, data_len); |
| 12093 | cds_ssr_unprotect(__func__); |
| 12094 | |
| 12095 | return ret; |
| 12096 | } |
| 12097 | |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 12098 | /** |
| 12099 | * __wlan_hdd_set_sar_power_limits() - Set SAR power limits |
| 12100 | * @wiphy: Pointer to wireless phy |
| 12101 | * @wdev: Pointer to wireless device |
| 12102 | * @data: Pointer to data |
| 12103 | * @data_len: Length of @data |
| 12104 | * |
| 12105 | * This function is used to setup Specific Absorption Rate limit specs. |
| 12106 | * |
| 12107 | * Return: 0 on success, negative errno on failure |
| 12108 | */ |
| 12109 | static int __wlan_hdd_set_sar_power_limits(struct wiphy *wiphy, |
| 12110 | struct wireless_dev *wdev, |
| 12111 | const void *data, int data_len) |
| 12112 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 12113 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 12114 | struct nlattr *sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX + 1], |
| 12115 | *tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX + 1], |
| 12116 | *sar_spec_list; |
| 12117 | struct sar_limit_cmd_params sar_limit_cmd = {0}; |
| 12118 | int ret = -EINVAL, i = 0, rem = 0; |
| 12119 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12120 | hdd_enter(); |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 12121 | |
| 12122 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12123 | hdd_err("Command not allowed in FTM mode"); |
| 12124 | return -EPERM; |
| 12125 | } |
| 12126 | |
| 12127 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 12128 | return -EINVAL; |
| 12129 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 12130 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX, |
| 12131 | data, data_len, sar_limits_policy)) { |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 12132 | hdd_err("Invalid SAR attributes"); |
| 12133 | return -EINVAL; |
| 12134 | } |
| 12135 | |
| 12136 | /* Vendor command manadates all SAR Specs in single call */ |
| 12137 | sar_limit_cmd.commit_limits = 1; |
| 12138 | sar_limit_cmd.sar_enable = WMI_SAR_FEATURE_NO_CHANGE; |
| 12139 | if (tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SAR_ENABLE]) { |
| 12140 | if (wlan_hdd_cfg80211_sar_convert_limit_set(nla_get_u32( |
| 12141 | tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SAR_ENABLE]), |
| 12142 | &sar_limit_cmd.sar_enable) < 0) { |
| 12143 | hdd_err("Invalid SAR Enable attr"); |
| 12144 | goto fail; |
| 12145 | } |
| 12146 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 12147 | hdd_debug("attr sar sar_enable %d", sar_limit_cmd.sar_enable); |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 12148 | |
| 12149 | if (tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_NUM_SPECS]) { |
| 12150 | sar_limit_cmd.num_limit_rows = nla_get_u32( |
| 12151 | tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_NUM_SPECS]); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 12152 | hdd_debug("attr sar num_limit_rows %d", |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 12153 | sar_limit_cmd.num_limit_rows); |
| 12154 | } |
| 12155 | if (sar_limit_cmd.num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) { |
| 12156 | hdd_err("SAR Spec list exceed supported size"); |
| 12157 | goto fail; |
| 12158 | } |
| 12159 | if (sar_limit_cmd.num_limit_rows == 0) |
| 12160 | goto send_sar_limits; |
| 12161 | sar_limit_cmd.sar_limit_row_list = qdf_mem_malloc(sizeof( |
| 12162 | struct sar_limit_cmd_row) * |
| 12163 | sar_limit_cmd.num_limit_rows); |
| 12164 | if (!sar_limit_cmd.sar_limit_row_list) { |
| 12165 | ret = -ENOMEM; |
| 12166 | goto fail; |
| 12167 | } |
| 12168 | if (!tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC]) { |
| 12169 | hdd_err("Invalid SAR SPECs list"); |
| 12170 | goto fail; |
| 12171 | } |
| 12172 | |
| 12173 | nla_for_each_nested(sar_spec_list, |
| 12174 | tb[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC], rem) { |
| 12175 | if (i == sar_limit_cmd.num_limit_rows) { |
| 12176 | hdd_warn("SAR Cmd has excess SPECs in list"); |
| 12177 | break; |
| 12178 | } |
| 12179 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 12180 | if (wlan_cfg80211_nla_parse(sar_spec, |
| 12181 | QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_MAX, |
| 12182 | nla_data(sar_spec_list), |
| 12183 | nla_len(sar_spec_list), |
| 12184 | sar_limits_policy)) { |
| 12185 | hdd_err("nla_parse failed for SAR Spec list"); |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 12186 | goto fail; |
| 12187 | } |
| 12188 | sar_limit_cmd.sar_limit_row_list[i].validity_bitmap = 0; |
| 12189 | if (sar_spec[ |
| 12190 | QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT]) { |
| 12191 | sar_limit_cmd.sar_limit_row_list[i].limit_value = |
| 12192 | nla_get_u32(sar_spec[ |
| 12193 | QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT]); |
| 12194 | } else { |
| 12195 | hdd_err("SAR Spec does not have power limit value"); |
| 12196 | goto fail; |
| 12197 | } |
| 12198 | |
| 12199 | if (sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND]) { |
| 12200 | if (wlan_hdd_cfg80211_sar_convert_band(nla_get_u32( |
| 12201 | sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_BAND]), |
| 12202 | &sar_limit_cmd.sar_limit_row_list[i].band_id) |
| 12203 | < 0) { |
| 12204 | hdd_err("Invalid SAR Band attr"); |
| 12205 | goto fail; |
| 12206 | } |
| 12207 | sar_limit_cmd.sar_limit_row_list[i].validity_bitmap |= |
| 12208 | WMI_SAR_BAND_ID_VALID_MASK; |
| 12209 | } |
| 12210 | if (sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_CHAIN]) { |
| 12211 | sar_limit_cmd.sar_limit_row_list[i].chain_id = |
| 12212 | nla_get_u32(sar_spec[ |
| 12213 | QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_CHAIN]); |
| 12214 | sar_limit_cmd.sar_limit_row_list[i].validity_bitmap |= |
| 12215 | WMI_SAR_CHAIN_ID_VALID_MASK; |
| 12216 | } |
| 12217 | if (sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION]) { |
| 12218 | if (wlan_hdd_cfg80211_sar_convert_modulation(nla_get_u32( |
| 12219 | sar_spec[QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_MODULATION]), |
| 12220 | &sar_limit_cmd.sar_limit_row_list[i].mod_id) |
| 12221 | < 0) { |
| 12222 | hdd_err("Invalid SAR Modulation attr"); |
| 12223 | goto fail; |
| 12224 | } |
| 12225 | sar_limit_cmd.sar_limit_row_list[i].validity_bitmap |= |
| 12226 | WMI_SAR_MOD_ID_VALID_MASK; |
| 12227 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 12228 | 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] | 12229 | i, sar_limit_cmd.sar_limit_row_list[i].band_id, |
| 12230 | sar_limit_cmd.sar_limit_row_list[i].chain_id, |
| 12231 | sar_limit_cmd.sar_limit_row_list[i].mod_id, |
| 12232 | sar_limit_cmd.sar_limit_row_list[i].limit_value, |
| 12233 | sar_limit_cmd.sar_limit_row_list[i].validity_bitmap); |
| 12234 | i++; |
| 12235 | } |
| 12236 | |
| 12237 | if (i < sar_limit_cmd.num_limit_rows) { |
| 12238 | hdd_warn("SAR Cmd has less SPECs in list"); |
| 12239 | sar_limit_cmd.num_limit_rows = i; |
| 12240 | } |
| 12241 | |
| 12242 | send_sar_limits: |
| 12243 | if (sme_set_sar_power_limits(hdd_ctx->hHal, &sar_limit_cmd) == |
| 12244 | QDF_STATUS_SUCCESS) |
| 12245 | ret = 0; |
| 12246 | fail: |
| 12247 | qdf_mem_free(sar_limit_cmd.sar_limit_row_list); |
| 12248 | return ret; |
| 12249 | } |
| 12250 | |
| 12251 | /** |
| 12252 | * wlan_hdd_cfg80211_set_sar_power_limits() - Set SAR power limits |
| 12253 | * @wiphy: Pointer to wireless phy |
| 12254 | * @wdev: Pointer to wireless device |
| 12255 | * @data: Pointer to data |
| 12256 | * @data_len: Length of @data |
| 12257 | * |
| 12258 | * Wrapper function of __wlan_hdd_cfg80211_set_sar_power_limits() |
| 12259 | * |
| 12260 | * Return: 0 on success, negative errno on failure |
| 12261 | */ |
| 12262 | static int wlan_hdd_cfg80211_set_sar_power_limits(struct wiphy *wiphy, |
| 12263 | struct wireless_dev *wdev, |
| 12264 | const void *data, |
| 12265 | int data_len) |
| 12266 | { |
| 12267 | int ret; |
| 12268 | |
| 12269 | cds_ssr_protect(__func__); |
| 12270 | ret = __wlan_hdd_set_sar_power_limits(wiphy, wdev, data, |
| 12271 | data_len); |
| 12272 | cds_ssr_unprotect(__func__); |
| 12273 | |
| 12274 | return ret; |
| 12275 | } |
| 12276 | |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 12277 | static const struct |
| 12278 | nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] = { |
| 12279 | [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = {.type = NLA_U32}, |
| 12280 | [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = {.type = NLA_BINARY, |
| 12281 | .len = QDF_MAC_ADDR_SIZE}, |
| 12282 | }; |
| 12283 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 12284 | void wlan_hdd_rso_cmd_status_cb(void *ctx, struct rso_cmd_status *rso_status) |
| 12285 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 12286 | struct hdd_context *hdd_ctx = (struct hdd_context *)ctx; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 12287 | struct hdd_adapter *adapter; |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 12288 | |
| 12289 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rso_status->vdev_id); |
| 12290 | if (!adapter) { |
| 12291 | hdd_err("adapter NULL"); |
| 12292 | return; |
| 12293 | } |
| 12294 | |
| 12295 | adapter->lfr_fw_status.is_disabled = rso_status->status; |
| 12296 | complete(&adapter->lfr_fw_status.disable_lfr_event); |
| 12297 | } |
| 12298 | |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 12299 | /** |
| 12300 | * __wlan_hdd_cfg80211_set_fast_roaming() - enable/disable roaming |
| 12301 | * @wiphy: Pointer to wireless phy |
| 12302 | * @wdev: Pointer to wireless device |
| 12303 | * @data: Pointer to data |
| 12304 | * @data_len: Length of @data |
| 12305 | * |
| 12306 | * This function is used to enable/disable roaming using vendor commands |
| 12307 | * |
| 12308 | * Return: 0 on success, negative errno on failure |
| 12309 | */ |
| 12310 | static int __wlan_hdd_cfg80211_set_fast_roaming(struct wiphy *wiphy, |
| 12311 | struct wireless_dev *wdev, |
| 12312 | const void *data, int data_len) |
| 12313 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 12314 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 12315 | struct net_device *dev = wdev->netdev; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 12316 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 12317 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1]; |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 12318 | uint32_t is_fast_roam_enabled; |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 12319 | int ret; |
Selvaraj, Sridhar | d753e7c | 2017-01-12 20:19:27 +0530 | [diff] [blame] | 12320 | QDF_STATUS qdf_status; |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 12321 | unsigned long rc; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 12322 | struct hdd_station_ctx *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 12323 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 12324 | hdd_enter_dev(dev); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 12325 | |
| 12326 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12327 | if (0 != ret) |
| 12328 | return ret; |
| 12329 | |
| 12330 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12331 | hdd_err("Command not allowed in FTM mode"); |
| 12332 | return -EINVAL; |
| 12333 | } |
| 12334 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 12335 | ret = wlan_cfg80211_nla_parse(tb, |
| 12336 | QCA_WLAN_VENDOR_ATTR_MAX, data, data_len, |
| 12337 | qca_wlan_vendor_attr); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 12338 | if (ret) { |
| 12339 | hdd_err("Invalid ATTR"); |
| 12340 | return -EINVAL; |
| 12341 | } |
| 12342 | |
| 12343 | /* Parse and fetch Enable flag */ |
| 12344 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) { |
| 12345 | hdd_err("attr enable failed"); |
| 12346 | return -EINVAL; |
| 12347 | } |
| 12348 | |
| 12349 | is_fast_roam_enabled = nla_get_u32( |
| 12350 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]); |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 12351 | hdd_debug("isFastRoamEnabled %d", is_fast_roam_enabled); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 12352 | |
| 12353 | /* Update roaming */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12354 | qdf_status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 12355 | is_fast_roam_enabled); |
Selvaraj, Sridhar | d753e7c | 2017-01-12 20:19:27 +0530 | [diff] [blame] | 12356 | if (qdf_status != QDF_STATUS_SUCCESS) |
| 12357 | hdd_err("sme_config_fast_roaming failed with status=%d", |
| 12358 | qdf_status); |
| 12359 | ret = qdf_status_to_os_return(qdf_status); |
| 12360 | |
Selvaraj, Sridhar | 4c7411e | 2017-05-04 12:58:41 +0530 | [diff] [blame] | 12361 | if (eConnectionState_Associated == hdd_sta_ctx->conn_info.connState && |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 12362 | QDF_IS_STATUS_SUCCESS(qdf_status) && !is_fast_roam_enabled) { |
Selvaraj, Sridhar | 4c7411e | 2017-05-04 12:58:41 +0530 | [diff] [blame] | 12363 | |
| 12364 | INIT_COMPLETION(adapter->lfr_fw_status.disable_lfr_event); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 12365 | /* |
| 12366 | * wait only for LFR disable in fw as LFR enable |
| 12367 | * is always success |
| 12368 | */ |
| 12369 | rc = wait_for_completion_timeout( |
| 12370 | &adapter->lfr_fw_status.disable_lfr_event, |
| 12371 | msecs_to_jiffies(WAIT_TIME_RSO_CMD_STATUS)); |
| 12372 | if (!rc) { |
| 12373 | hdd_err("Timed out waiting for RSO CMD status"); |
| 12374 | return -ETIMEDOUT; |
| 12375 | } |
| 12376 | |
| 12377 | if (!adapter->lfr_fw_status.is_disabled) { |
| 12378 | hdd_err("Roam disable attempt in FW fails"); |
| 12379 | return -EBUSY; |
| 12380 | } |
| 12381 | } |
| 12382 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12383 | hdd_exit(); |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 12384 | return ret; |
| 12385 | } |
| 12386 | |
| 12387 | /** |
| 12388 | * wlan_hdd_cfg80211_set_fast_roaming() - enable/disable roaming |
| 12389 | * @wiphy: Pointer to wireless phy |
| 12390 | * @wdev: Pointer to wireless device |
| 12391 | * @data: Pointer to data |
| 12392 | * @data_len: Length of @data |
| 12393 | * |
| 12394 | * Wrapper function of __wlan_hdd_cfg80211_set_fast_roaming() |
| 12395 | * |
| 12396 | * Return: 0 on success, negative errno on failure |
| 12397 | */ |
| 12398 | static int wlan_hdd_cfg80211_set_fast_roaming(struct wiphy *wiphy, |
| 12399 | struct wireless_dev *wdev, |
| 12400 | const void *data, int data_len) |
| 12401 | { |
| 12402 | int ret; |
| 12403 | |
| 12404 | cds_ssr_protect(__func__); |
| 12405 | ret = __wlan_hdd_cfg80211_set_fast_roaming(wiphy, wdev, data, data_len); |
| 12406 | cds_ssr_unprotect(__func__); |
| 12407 | |
| 12408 | return ret; |
| 12409 | } |
| 12410 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12411 | /* |
| 12412 | * define short names for the global vendor params |
| 12413 | * used by wlan_hdd_cfg80211_setarp_stats_cmd() |
| 12414 | */ |
| 12415 | #define STATS_SET_INVALID \ |
| 12416 | QCA_ATTR_NUD_STATS_SET_INVALID |
| 12417 | #define STATS_SET_START \ |
| 12418 | QCA_ATTR_NUD_STATS_SET_START |
| 12419 | #define STATS_GW_IPV4 \ |
| 12420 | QCA_ATTR_NUD_STATS_GW_IPV4 |
| 12421 | #define STATS_SET_DATA_PKT_INFO \ |
| 12422 | QCA_ATTR_NUD_STATS_SET_DATA_PKT_INFO |
| 12423 | #define STATS_SET_MAX \ |
| 12424 | QCA_ATTR_NUD_STATS_SET_MAX |
| 12425 | |
| 12426 | const struct nla_policy |
| 12427 | qca_wlan_vendor_set_nud_stats[STATS_SET_MAX + 1] = { |
| 12428 | [STATS_SET_START] = {.type = NLA_FLAG }, |
| 12429 | [STATS_GW_IPV4] = {.type = NLA_U32 }, |
| 12430 | [STATS_SET_DATA_PKT_INFO] = {.type = NLA_U32 }, |
| 12431 | }; |
| 12432 | |
| 12433 | /* define short names for the global vendor params */ |
| 12434 | #define CONNECTIVITY_STATS_SET_INVALID \ |
| 12435 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_SET_INVALID |
| 12436 | #define STATS_PKT_INFO_TYPE \ |
| 12437 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_STATS_PKT_INFO_TYPE |
| 12438 | #define STATS_DNS_DOMAIN_NAME \ |
| 12439 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_DNS_DOMAIN_NAME |
| 12440 | #define STATS_SRC_PORT \ |
| 12441 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_SRC_PORT |
| 12442 | #define STATS_DEST_PORT \ |
| 12443 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_DEST_PORT |
| 12444 | #define STATS_DEST_IPV4 \ |
| 12445 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_DEST_IPV4 |
| 12446 | #define STATS_DEST_IPV6 \ |
| 12447 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_DEST_IPV6 |
| 12448 | #define CONNECTIVITY_STATS_SET_MAX \ |
| 12449 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_SET_MAX |
| 12450 | |
| 12451 | const struct nla_policy |
| 12452 | qca_wlan_vendor_set_connectivity_check_stats[CONNECTIVITY_STATS_SET_MAX + 1] = { |
| 12453 | [STATS_PKT_INFO_TYPE] = {.type = NLA_U32 }, |
| 12454 | [STATS_DNS_DOMAIN_NAME] = {.type = NLA_BINARY, |
| 12455 | .len = DNS_DOMAIN_NAME_MAX_LEN }, |
| 12456 | [STATS_SRC_PORT] = {.type = NLA_U32 }, |
| 12457 | [STATS_DEST_PORT] = {.type = NLA_U32 }, |
| 12458 | [STATS_DEST_IPV4] = {.type = NLA_U32 }, |
| 12459 | [STATS_DEST_IPV6] = {.type = NLA_BINARY, |
| 12460 | .len = ICMPv6_ADDR_LEN }, |
| 12461 | }; |
| 12462 | |
| 12463 | /** |
| 12464 | * hdd_dns_unmake_name_query() - Convert an uncompressed DNS name to a |
| 12465 | * NUL-terminated string |
| 12466 | * @name: DNS name |
| 12467 | * |
| 12468 | * Return: Produce a printable version of a DNS name. |
| 12469 | */ |
| 12470 | static inline uint8_t *hdd_dns_unmake_name_query(uint8_t *name) |
| 12471 | { |
| 12472 | uint8_t *p; |
| 12473 | unsigned int len; |
| 12474 | |
| 12475 | p = name; |
| 12476 | while ((len = *p)) { |
| 12477 | *(p++) = '.'; |
| 12478 | p += len; |
| 12479 | } |
| 12480 | |
| 12481 | return name + 1; |
| 12482 | } |
| 12483 | |
| 12484 | /** |
| 12485 | * hdd_dns_make_name_query() - Convert a standard NUL-terminated string |
| 12486 | * to DNS name |
| 12487 | * @string: Name as a NUL-terminated string |
| 12488 | * @buf: Buffer in which to place DNS name |
| 12489 | * |
| 12490 | * DNS names consist of "<length>element" pairs. |
| 12491 | * |
| 12492 | * Return: Byte following constructed DNS name |
| 12493 | */ |
| 12494 | static uint8_t *hdd_dns_make_name_query(const uint8_t *string, uint8_t *buf) |
| 12495 | { |
| 12496 | uint8_t *length_byte = buf++; |
| 12497 | uint8_t c; |
| 12498 | |
| 12499 | while ((c = *(string++))) { |
| 12500 | if (c == '.') { |
| 12501 | *length_byte = buf - length_byte - 1; |
| 12502 | length_byte = buf; |
| 12503 | } |
| 12504 | *(buf++) = c; |
| 12505 | } |
| 12506 | *length_byte = buf - length_byte - 1; |
| 12507 | *(buf++) = '\0'; |
| 12508 | return buf; |
| 12509 | } |
| 12510 | |
| 12511 | /** |
| 12512 | * hdd_set_clear_connectivity_check_stats_info() - set/clear stats info |
| 12513 | * @adapter: Pointer to hdd adapter |
| 12514 | * @arp_stats_params: arp stats structure to be sent to FW |
| 12515 | * @tb: nl attribute |
| 12516 | * @is_set_stats: set/clear stats |
| 12517 | * |
| 12518 | * |
| 12519 | * Return: 0 on success, negative errno on failure |
| 12520 | */ |
| 12521 | static int hdd_set_clear_connectivity_check_stats_info( |
| 12522 | struct hdd_adapter *adapter, |
| 12523 | struct set_arp_stats_params *arp_stats_params, |
| 12524 | struct nlattr **tb, bool is_set_stats) |
| 12525 | { |
| 12526 | struct nlattr *tb2[CONNECTIVITY_STATS_SET_MAX + 1]; |
| 12527 | struct nlattr *curr_attr = NULL; |
| 12528 | int err = 0; |
| 12529 | uint32_t pkt_bitmap; |
| 12530 | int rem; |
| 12531 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12532 | /* Set NUD command for start tracking is received. */ |
| 12533 | nla_for_each_nested(curr_attr, |
| 12534 | tb[STATS_SET_DATA_PKT_INFO], |
| 12535 | rem) { |
| 12536 | |
| 12537 | if (wlan_cfg80211_nla_parse(tb2, |
| 12538 | CONNECTIVITY_STATS_SET_MAX, |
| 12539 | nla_data(curr_attr), nla_len(curr_attr), |
| 12540 | qca_wlan_vendor_set_connectivity_check_stats)) { |
| 12541 | hdd_err("nla_parse failed"); |
| 12542 | err = -EINVAL; |
| 12543 | goto end; |
| 12544 | } |
| 12545 | |
| 12546 | if (tb2[STATS_PKT_INFO_TYPE]) { |
| 12547 | pkt_bitmap = nla_get_u32(tb2[STATS_PKT_INFO_TYPE]); |
| 12548 | if (!pkt_bitmap) { |
| 12549 | hdd_err("pkt tracking bitmap is empty"); |
| 12550 | err = -EINVAL; |
| 12551 | goto end; |
| 12552 | } |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 12553 | |
| 12554 | if (is_set_stats) { |
| 12555 | arp_stats_params->pkt_type_bitmap = pkt_bitmap; |
| 12556 | arp_stats_params->flag = true; |
| 12557 | adapter->pkt_type_bitmap |= |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12558 | arp_stats_params->pkt_type_bitmap; |
| 12559 | |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 12560 | if (pkt_bitmap & CONNECTIVITY_CHECK_SET_ARP) { |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12561 | if (!tb[STATS_GW_IPV4]) { |
| 12562 | hdd_err("GW ipv4 address is not present"); |
| 12563 | err = -EINVAL; |
| 12564 | goto end; |
| 12565 | } |
| 12566 | arp_stats_params->ip_addr = |
| 12567 | nla_get_u32(tb[STATS_GW_IPV4]); |
| 12568 | arp_stats_params->pkt_type = |
| 12569 | WLAN_NUD_STATS_ARP_PKT_TYPE; |
| 12570 | adapter->track_arp_ip = |
| 12571 | arp_stats_params->ip_addr; |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12572 | } |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 12573 | |
| 12574 | if (pkt_bitmap & CONNECTIVITY_CHECK_SET_DNS) { |
| 12575 | uint8_t *domain_name; |
| 12576 | |
| 12577 | if (!tb2[STATS_DNS_DOMAIN_NAME]) { |
| 12578 | hdd_err("DNS domain id is not present"); |
| 12579 | err = -EINVAL; |
| 12580 | goto end; |
| 12581 | } |
| 12582 | domain_name = nla_data( |
| 12583 | tb2[STATS_DNS_DOMAIN_NAME]); |
| 12584 | adapter->track_dns_domain_len = |
| 12585 | nla_len(tb2[ |
| 12586 | STATS_DNS_DOMAIN_NAME]); |
| 12587 | hdd_dns_make_name_query(domain_name, |
| 12588 | adapter->dns_payload); |
| 12589 | /* DNStracking isn't supported in FW. */ |
| 12590 | arp_stats_params->pkt_type_bitmap &= |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12591 | ~CONNECTIVITY_CHECK_SET_DNS; |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12592 | } |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 12593 | |
| 12594 | if (pkt_bitmap & |
| 12595 | CONNECTIVITY_CHECK_SET_TCP_HANDSHAKE) { |
| 12596 | if (!tb2[STATS_SRC_PORT] || |
| 12597 | !tb2[STATS_DEST_PORT]) { |
| 12598 | hdd_err("Source/Dest port is not present"); |
| 12599 | err = -EINVAL; |
| 12600 | goto end; |
| 12601 | } |
| 12602 | arp_stats_params->tcp_src_port = |
| 12603 | nla_get_u32( |
| 12604 | tb2[STATS_SRC_PORT]); |
| 12605 | arp_stats_params->tcp_dst_port = |
| 12606 | nla_get_u32( |
| 12607 | tb2[STATS_DEST_PORT]); |
| 12608 | adapter->track_src_port = |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12609 | arp_stats_params->tcp_src_port; |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 12610 | adapter->track_dest_port = |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12611 | arp_stats_params->tcp_dst_port; |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12612 | } |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 12613 | |
| 12614 | if (pkt_bitmap & |
| 12615 | CONNECTIVITY_CHECK_SET_ICMPV4) { |
| 12616 | if (!tb2[STATS_DEST_IPV4]) { |
| 12617 | hdd_err("destination ipv4 address to track ping packets is not present"); |
| 12618 | err = -EINVAL; |
| 12619 | goto end; |
| 12620 | } |
| 12621 | arp_stats_params->icmp_ipv4 = |
| 12622 | nla_get_u32( |
| 12623 | tb2[STATS_DEST_IPV4]); |
| 12624 | adapter->track_dest_ipv4 = |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12625 | arp_stats_params->icmp_ipv4; |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 12626 | } |
| 12627 | } else { |
| 12628 | /* clear stats command received */ |
| 12629 | arp_stats_params->pkt_type_bitmap = pkt_bitmap; |
| 12630 | arp_stats_params->flag = false; |
| 12631 | adapter->pkt_type_bitmap &= |
| 12632 | (~arp_stats_params->pkt_type_bitmap); |
| 12633 | |
| 12634 | if (pkt_bitmap & CONNECTIVITY_CHECK_SET_ARP) { |
| 12635 | arp_stats_params->pkt_type = |
| 12636 | WLAN_NUD_STATS_ARP_PKT_TYPE; |
| 12637 | qdf_mem_zero(&adapter->hdd_stats. |
| 12638 | hdd_arp_stats, |
| 12639 | sizeof(adapter->hdd_stats. |
| 12640 | hdd_arp_stats)); |
| 12641 | adapter->track_arp_ip = 0; |
| 12642 | } |
| 12643 | |
| 12644 | if (pkt_bitmap & CONNECTIVITY_CHECK_SET_DNS) { |
| 12645 | /* DNStracking isn't supported in FW. */ |
| 12646 | arp_stats_params->pkt_type_bitmap &= |
| 12647 | ~CONNECTIVITY_CHECK_SET_DNS; |
| 12648 | qdf_mem_zero(&adapter->hdd_stats. |
| 12649 | hdd_dns_stats, |
| 12650 | sizeof(adapter->hdd_stats. |
| 12651 | hdd_dns_stats)); |
| 12652 | qdf_mem_zero(adapter->dns_payload, |
| 12653 | adapter->track_dns_domain_len); |
| 12654 | adapter->track_dns_domain_len = 0; |
| 12655 | } |
| 12656 | |
| 12657 | if (pkt_bitmap & |
| 12658 | CONNECTIVITY_CHECK_SET_TCP_HANDSHAKE) { |
| 12659 | qdf_mem_zero(&adapter->hdd_stats. |
| 12660 | hdd_tcp_stats, |
| 12661 | sizeof(adapter->hdd_stats. |
| 12662 | hdd_tcp_stats)); |
| 12663 | adapter->track_src_port = 0; |
| 12664 | adapter->track_dest_port = 0; |
| 12665 | } |
| 12666 | |
| 12667 | if (pkt_bitmap & |
| 12668 | CONNECTIVITY_CHECK_SET_ICMPV4) { |
| 12669 | qdf_mem_zero(&adapter->hdd_stats. |
| 12670 | hdd_icmpv4_stats, |
| 12671 | sizeof(adapter->hdd_stats. |
| 12672 | hdd_icmpv4_stats)); |
| 12673 | adapter->track_dest_ipv4 = 0; |
| 12674 | } |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12675 | } |
| 12676 | } else { |
| 12677 | hdd_err("stats list empty"); |
| 12678 | err = -EINVAL; |
| 12679 | goto end; |
| 12680 | } |
| 12681 | } |
| 12682 | |
| 12683 | end: |
| 12684 | return err; |
| 12685 | } |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12686 | |
| 12687 | void hdd_update_cca_info_cb(void *context, uint32_t congestion, |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12688 | uint32_t vdev_id) |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12689 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 12690 | struct hdd_context *hdd_ctx = (struct hdd_context *)context; |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12691 | int status; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 12692 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 12693 | struct hdd_station_ctx *hdd_sta_ctx; |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12694 | |
| 12695 | status = wlan_hdd_validate_context(hdd_ctx); |
| 12696 | if (status != 0) |
| 12697 | return; |
| 12698 | |
| 12699 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 12700 | if (adapter == NULL) { |
| 12701 | hdd_err("vdev_id %d does not exist with host", vdev_id); |
| 12702 | return; |
| 12703 | } |
| 12704 | |
| 12705 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12706 | hdd_sta_ctx->conn_info.cca = congestion; |
| 12707 | hdd_info("congestion:%d", congestion); |
| 12708 | } |
| 12709 | |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 12710 | static const struct nla_policy qca_wlan_vendor_set_trace_level_policy[ |
| 12711 | QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MAX + 1] = { |
| 12712 | [QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_PARAM] = {.type = NLA_NESTED }, |
| 12713 | [QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MODULE_ID] = {.type = NLA_U32 }, |
| 12714 | [QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_TRACE_MASK] = {.type = NLA_U32 }, |
| 12715 | }; |
| 12716 | |
| 12717 | /** |
| 12718 | * __wlan_hdd_cfg80211_set_trace_level() - Set the trace level |
| 12719 | * @wiphy: Pointer to wireless phy |
| 12720 | * @wdev: Pointer to wireless device |
| 12721 | * @data: Pointer to data |
| 12722 | * @data_len: Length of @data |
| 12723 | * |
| 12724 | * Return: 0 on success, negative errno on failure |
| 12725 | */ |
| 12726 | static int |
| 12727 | __wlan_hdd_cfg80211_set_trace_level(struct wiphy *wiphy, |
| 12728 | struct wireless_dev *wdev, |
| 12729 | const void *data, |
| 12730 | int data_len) |
| 12731 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 12732 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 12733 | struct nlattr *tb1[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MAX + 1]; |
| 12734 | struct nlattr *tb2[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MAX + 1]; |
| 12735 | struct nlattr *apth; |
| 12736 | int rem; |
| 12737 | int ret = 1; |
| 12738 | int print_idx = -1; |
| 12739 | int module_id = -1; |
| 12740 | int bit_mask = -1; |
| 12741 | int status; |
| 12742 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12743 | hdd_enter(); |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 12744 | |
| 12745 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 12746 | hdd_err("Command not allowed in FTM mode"); |
| 12747 | return -EINVAL; |
| 12748 | } |
| 12749 | |
| 12750 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12751 | if (ret != 0) |
| 12752 | return -EINVAL; |
| 12753 | |
| 12754 | print_idx = qdf_get_pidx(); |
| 12755 | if (print_idx < 0 || print_idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 12756 | hdd_err("Invalid print controle object index"); |
| 12757 | return -EINVAL; |
| 12758 | } |
| 12759 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 12760 | if (wlan_cfg80211_nla_parse(tb1, |
| 12761 | QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MAX, |
| 12762 | data, data_len, |
| 12763 | qca_wlan_vendor_set_trace_level_policy)) { |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 12764 | hdd_err("Invalid attr"); |
| 12765 | return -EINVAL; |
| 12766 | } |
| 12767 | |
| 12768 | if (!tb1[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_PARAM]) { |
| 12769 | hdd_err("attr trace level param failed"); |
| 12770 | return -EINVAL; |
| 12771 | } |
| 12772 | |
| 12773 | nla_for_each_nested(apth, |
| 12774 | tb1[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_PARAM], rem) { |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 12775 | if (wlan_cfg80211_nla_parse(tb2, |
| 12776 | QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MAX, |
| 12777 | nla_data(apth), nla_len(apth), NULL)) { |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 12778 | hdd_err("Invalid attr"); |
| 12779 | return -EINVAL; |
| 12780 | } |
| 12781 | |
| 12782 | if (!tb2[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MODULE_ID]) { |
| 12783 | hdd_err("attr Module ID failed"); |
| 12784 | return -EINVAL; |
| 12785 | } |
| 12786 | module_id = nla_get_u32 |
| 12787 | (tb2[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_MODULE_ID]); |
| 12788 | |
| 12789 | if (!tb2[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_TRACE_MASK]) { |
| 12790 | hdd_err("attr Verbose mask failed"); |
| 12791 | return -EINVAL; |
| 12792 | } |
| 12793 | bit_mask = nla_get_u32 |
| 12794 | (tb2[QCA_WLAN_VENDOR_ATTR_SET_TRACE_LEVEL_TRACE_MASK]); |
| 12795 | |
| 12796 | status = hdd_qdf_trace_enable(module_id, bit_mask); |
| 12797 | |
| 12798 | if (status != 0) |
| 12799 | hdd_err("can not set verbose mask %d for the category %d", |
| 12800 | bit_mask, module_id); |
| 12801 | } |
| 12802 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12803 | hdd_exit(); |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 12804 | return ret; |
| 12805 | } |
| 12806 | |
| 12807 | /** |
Ashish Kumar Dhanotiya | eb4fe4b | 2017-02-20 16:04:00 +0530 | [diff] [blame] | 12808 | * wlan_hdd_cfg80211_set_trace_level() - Set the trace level |
| 12809 | * @wiphy: Pointer to wireless phy |
| 12810 | * @wdev: Pointer to wireless device |
| 12811 | * @data: Pointer to data |
| 12812 | * @data_len: Length of @data |
| 12813 | * |
| 12814 | * Wrapper function of __wlan_hdd_cfg80211_set_trace_level() |
| 12815 | * |
| 12816 | * Return: 0 on success, negative errno on failure |
| 12817 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 12818 | |
| 12819 | static int wlan_hdd_cfg80211_set_trace_level(struct wiphy *wiphy, |
| 12820 | struct wireless_dev *wdev, |
| 12821 | const void *data, |
| 12822 | int data_len) |
| 12823 | { |
| 12824 | int ret; |
| 12825 | |
| 12826 | cds_ssr_protect(__func__); |
| 12827 | ret = __wlan_hdd_cfg80211_set_trace_level(wiphy, wdev, data, data_len); |
| 12828 | cds_ssr_unprotect(__func__); |
| 12829 | |
| 12830 | return ret; |
| 12831 | } |
| 12832 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12833 | /** |
| 12834 | * __wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware |
| 12835 | * @wiphy: pointer to wireless wiphy structure. |
| 12836 | * @wdev: pointer to wireless_dev structure. |
| 12837 | * @data: pointer to apfind configuration data. |
| 12838 | * @data_len: the length in byte of apfind data. |
| 12839 | * |
| 12840 | * This is called when wlan driver needs to send arp stats to |
| 12841 | * firmware. |
| 12842 | * |
| 12843 | * Return: An error code or 0 on success. |
| 12844 | */ |
| 12845 | static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy, |
| 12846 | struct wireless_dev *wdev, |
| 12847 | const void *data, int data_len) |
| 12848 | { |
| 12849 | struct nlattr *tb[STATS_SET_MAX + 1]; |
| 12850 | struct net_device *dev = wdev->netdev; |
| 12851 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 12852 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12853 | struct set_arp_stats_params arp_stats_params = {0}; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12854 | int err = 0; |
| 12855 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12856 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12857 | |
Anurag Chouhan | 9fb2bd5 | 2018-01-04 12:25:48 +0530 | [diff] [blame] | 12858 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12859 | hdd_err("Command not allowed in FTM mode"); |
| 12860 | return -EINVAL; |
| 12861 | } |
| 12862 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12863 | err = wlan_hdd_validate_context(hdd_ctx); |
| 12864 | if (0 != err) |
| 12865 | return err; |
| 12866 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 12867 | err = wlan_cfg80211_nla_parse(tb, STATS_SET_MAX, data, data_len, |
| 12868 | qca_wlan_vendor_set_nud_stats); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12869 | if (err) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12870 | hdd_err("STATS_SET_START ATTR"); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12871 | return err; |
| 12872 | } |
| 12873 | |
Yeshwanth Sriram Guntuka | d5aae7f | 2017-11-27 14:33:51 +0530 | [diff] [blame] | 12874 | if (adapter->session_id == HDD_SESSION_ID_INVALID) { |
| 12875 | hdd_err("Invalid session id"); |
| 12876 | return -EINVAL; |
| 12877 | } |
| 12878 | |
Poddar, Siddarth | df07667 | 2018-02-26 14:21:45 +0530 | [diff] [blame] | 12879 | if (adapter->device_mode != QDF_STA_MODE) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12880 | hdd_err("STATS supported in only STA mode!"); |
Poddar, Siddarth | df07667 | 2018-02-26 14:21:45 +0530 | [diff] [blame] | 12881 | return -EINVAL; |
| 12882 | } |
| 12883 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12884 | if (tb[STATS_SET_START]) { |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12885 | /* tracking is enabled for stats other than arp. */ |
| 12886 | if (tb[STATS_SET_DATA_PKT_INFO]) { |
| 12887 | err = hdd_set_clear_connectivity_check_stats_info( |
| 12888 | adapter, |
| 12889 | &arp_stats_params, tb, true); |
| 12890 | if (err) |
| 12891 | return -EINVAL; |
| 12892 | |
| 12893 | /* |
| 12894 | * if only tracking dns, then don't send |
| 12895 | * wmi command to FW. |
| 12896 | */ |
| 12897 | if (!arp_stats_params.pkt_type_bitmap) |
| 12898 | return err; |
| 12899 | } else { |
| 12900 | if (!tb[STATS_GW_IPV4]) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12901 | hdd_err("STATS_SET_START CMD"); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12902 | return -EINVAL; |
| 12903 | } |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 12904 | |
| 12905 | arp_stats_params.pkt_type_bitmap = |
| 12906 | CONNECTIVITY_CHECK_SET_ARP; |
| 12907 | adapter->pkt_type_bitmap |= |
| 12908 | arp_stats_params.pkt_type_bitmap; |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12909 | arp_stats_params.flag = true; |
| 12910 | arp_stats_params.ip_addr = |
| 12911 | nla_get_u32(tb[STATS_GW_IPV4]); |
| 12912 | adapter->track_arp_ip = arp_stats_params.ip_addr; |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12913 | arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12914 | } |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12915 | } else { |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 12916 | /* clear stats command received. */ |
| 12917 | if (tb[STATS_SET_DATA_PKT_INFO]) { |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12918 | err = hdd_set_clear_connectivity_check_stats_info( |
| 12919 | adapter, |
| 12920 | &arp_stats_params, tb, false); |
| 12921 | if (err) |
| 12922 | return -EINVAL; |
| 12923 | |
| 12924 | /* |
| 12925 | * if only tracking dns, then don't send |
| 12926 | * wmi command to FW. |
| 12927 | */ |
| 12928 | if (!arp_stats_params.pkt_type_bitmap) |
| 12929 | return err; |
| 12930 | } else { |
Poddar, Siddarth | 9c2cd26 | 2018-01-18 19:03:39 +0530 | [diff] [blame] | 12931 | arp_stats_params.pkt_type_bitmap = |
| 12932 | CONNECTIVITY_CHECK_SET_ARP; |
| 12933 | adapter->pkt_type_bitmap &= |
| 12934 | (~arp_stats_params.pkt_type_bitmap); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12935 | arp_stats_params.flag = false; |
| 12936 | qdf_mem_zero(&adapter->hdd_stats.hdd_arp_stats, |
| 12937 | sizeof(adapter->hdd_stats.hdd_arp_stats)); |
| 12938 | arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE; |
| 12939 | } |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12940 | } |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12941 | |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12942 | hdd_info("STATS_SET_START Received flag %d!", arp_stats_params.flag); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12943 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12944 | arp_stats_params.vdev_id = adapter->session_id; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12945 | |
| 12946 | if (QDF_STATUS_SUCCESS != |
| 12947 | sme_set_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12948 | hdd_err("STATS_SET_START CMD Failed!"); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12949 | return -EINVAL; |
| 12950 | } |
| 12951 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12952 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12953 | |
| 12954 | return err; |
| 12955 | } |
| 12956 | |
| 12957 | /** |
| 12958 | * wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware |
| 12959 | * @wiphy: pointer to wireless wiphy structure. |
| 12960 | * @wdev: pointer to wireless_dev structure. |
| 12961 | * @data: pointer to apfind configuration data. |
| 12962 | * @data_len: the length in byte of apfind data. |
| 12963 | * |
| 12964 | * This is called when wlan driver needs to send arp stats to |
| 12965 | * firmware. |
| 12966 | * |
| 12967 | * Return: An error code or 0 on success. |
| 12968 | */ |
| 12969 | static int wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy, |
| 12970 | struct wireless_dev *wdev, |
| 12971 | const void *data, int data_len) |
| 12972 | { |
| 12973 | int ret; |
| 12974 | |
| 12975 | cds_ssr_protect(__func__); |
| 12976 | ret = __wlan_hdd_cfg80211_set_nud_stats(wiphy, wdev, data, data_len); |
| 12977 | cds_ssr_unprotect(__func__); |
| 12978 | |
| 12979 | return ret; |
| 12980 | } |
| 12981 | |
| 12982 | #undef STATS_SET_INVALID |
| 12983 | #undef STATS_SET_START |
| 12984 | #undef STATS_GW_IPV4 |
| 12985 | #undef STATS_SET_MAX |
| 12986 | |
| 12987 | /* |
| 12988 | * define short names for the global vendor params |
| 12989 | * used by wlan_hdd_cfg80211_setarp_stats_cmd() |
| 12990 | */ |
| 12991 | #define STATS_GET_INVALID \ |
| 12992 | QCA_ATTR_NUD_STATS_SET_INVALID |
| 12993 | #define COUNT_FROM_NETDEV \ |
| 12994 | QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV |
| 12995 | #define COUNT_TO_LOWER_MAC \ |
| 12996 | QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC |
| 12997 | #define RX_COUNT_BY_LOWER_MAC \ |
| 12998 | QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC |
| 12999 | #define COUNT_TX_SUCCESS \ |
| 13000 | QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS |
| 13001 | #define RSP_RX_COUNT_BY_LOWER_MAC \ |
| 13002 | QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC |
| 13003 | #define RSP_RX_COUNT_BY_UPPER_MAC \ |
| 13004 | QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC |
| 13005 | #define RSP_COUNT_TO_NETDEV \ |
| 13006 | QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV |
| 13007 | #define RSP_COUNT_OUT_OF_ORDER_DROP \ |
| 13008 | QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP |
| 13009 | #define AP_LINK_ACTIVE \ |
| 13010 | QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE |
| 13011 | #define AP_LINK_DAD \ |
| 13012 | QCA_ATTR_NUD_STATS_IS_DAD |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 13013 | #define DATA_PKT_STATS \ |
| 13014 | QCA_ATTR_NUD_STATS_DATA_PKT_STATS |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13015 | #define STATS_GET_MAX \ |
| 13016 | QCA_ATTR_NUD_STATS_GET_MAX |
| 13017 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 13018 | #define CHECK_STATS_INVALID \ |
| 13019 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_INVALID |
| 13020 | #define CHECK_STATS_PKT_TYPE \ |
| 13021 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_TYPE |
| 13022 | #define CHECK_STATS_PKT_DNS_DOMAIN_NAME \ |
| 13023 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_DNS_DOMAIN_NAME |
| 13024 | #define CHECK_STATS_PKT_SRC_PORT \ |
| 13025 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_SRC_PORT |
| 13026 | #define CHECK_STATS_PKT_DEST_PORT \ |
| 13027 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_DEST_PORT |
| 13028 | #define CHECK_STATS_PKT_DEST_IPV4 \ |
| 13029 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_DEST_IPV4 |
| 13030 | #define CHECK_STATS_PKT_DEST_IPV6 \ |
| 13031 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_DEST_IPV6 |
| 13032 | #define CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV \ |
| 13033 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV |
| 13034 | #define CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC \ |
| 13035 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC |
| 13036 | #define CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC \ |
| 13037 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC |
| 13038 | #define CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS \ |
| 13039 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS |
| 13040 | #define CHECK_STATS_PKT_RSP_RX_COUNT_BY_LOWER_MAC \ |
| 13041 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_RSP_RX_COUNT_BY_LOWER_MAC |
| 13042 | #define CHECK_STATS_PKT_RSP_RX_COUNT_BY_UPPER_MAC \ |
| 13043 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_RSP_RX_COUNT_BY_UPPER_MAC |
| 13044 | #define CHECK_STATS_PKT_RSP_COUNT_TO_NETDEV \ |
| 13045 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_RSP_COUNT_TO_NETDEV |
| 13046 | #define CHECK_STATS_PKT_RSP_COUNT_OUT_OF_ORDER_DROP \ |
| 13047 | QCA_ATTR_CONNECTIVITY_CHECK_STATS_PKT_RSP_COUNT_OUT_OF_ORDER_DROP |
| 13048 | #define CHECK_DATA_STATS_MAX \ |
| 13049 | QCA_ATTR_CONNECTIVITY_CHECK_DATA_STATS_MAX |
| 13050 | |
| 13051 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13052 | const struct nla_policy |
| 13053 | qca_wlan_vendor_get_nud_stats[STATS_GET_MAX + 1] = { |
| 13054 | [COUNT_FROM_NETDEV] = {.type = NLA_U16 }, |
| 13055 | [COUNT_TO_LOWER_MAC] = {.type = NLA_U16 }, |
| 13056 | [RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 }, |
| 13057 | [COUNT_TX_SUCCESS] = {.type = NLA_U16 }, |
| 13058 | [RSP_RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 }, |
| 13059 | [RSP_RX_COUNT_BY_UPPER_MAC] = {.type = NLA_U16 }, |
| 13060 | [RSP_COUNT_TO_NETDEV] = {.type = NLA_U16 }, |
| 13061 | [RSP_COUNT_OUT_OF_ORDER_DROP] = {.type = NLA_U16 }, |
| 13062 | [AP_LINK_ACTIVE] = {.type = NLA_FLAG }, |
| 13063 | [AP_LINK_DAD] = {.type = NLA_FLAG }, |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 13064 | [DATA_PKT_STATS] = {.type = NLA_U16 }, |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13065 | }; |
| 13066 | |
| 13067 | /** |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 13068 | * hdd_populate_dns_stats_info() - send dns stats info to network stack |
| 13069 | * @adapter: pointer to adapter context |
| 13070 | * @skb: pointer to skb |
| 13071 | * |
| 13072 | * |
| 13073 | * Return: An error code or 0 on success. |
| 13074 | */ |
| 13075 | static int hdd_populate_dns_stats_info(struct hdd_adapter *adapter, |
| 13076 | struct sk_buff *skb) |
| 13077 | { |
| 13078 | uint8_t *dns_query; |
| 13079 | |
| 13080 | dns_query = qdf_mem_malloc(adapter->track_dns_domain_len + 1); |
| 13081 | if (!dns_query) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 13082 | hdd_err("mem alloc fail"); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 13083 | return -EINVAL; |
| 13084 | } |
| 13085 | |
| 13086 | qdf_mem_copy(dns_query, adapter->dns_payload, |
| 13087 | adapter->track_dns_domain_len); |
| 13088 | |
| 13089 | if (nla_put_u16(skb, CHECK_STATS_PKT_TYPE, |
| 13090 | CONNECTIVITY_CHECK_SET_DNS) || |
| 13091 | nla_put(skb, CHECK_STATS_PKT_DNS_DOMAIN_NAME, |
| 13092 | adapter->track_dns_domain_len, |
| 13093 | hdd_dns_unmake_name_query(dns_query)) || |
| 13094 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV, |
| 13095 | adapter->hdd_stats.hdd_dns_stats.tx_dns_req_count) || |
| 13096 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC, |
| 13097 | adapter->hdd_stats.hdd_dns_stats.tx_host_fw_sent) || |
| 13098 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC, |
| 13099 | adapter->hdd_stats.hdd_dns_stats.tx_host_fw_sent) || |
| 13100 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS, |
| 13101 | adapter->hdd_stats.hdd_dns_stats.tx_ack_cnt) || |
| 13102 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_RX_COUNT_BY_UPPER_MAC, |
| 13103 | adapter->hdd_stats.hdd_dns_stats.rx_dns_rsp_count) || |
| 13104 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_COUNT_TO_NETDEV, |
| 13105 | adapter->hdd_stats.hdd_dns_stats.rx_delivered) || |
| 13106 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_COUNT_OUT_OF_ORDER_DROP, |
| 13107 | adapter->hdd_stats.hdd_dns_stats.rx_host_drop)) { |
| 13108 | hdd_err("nla put fail"); |
| 13109 | qdf_mem_free(dns_query); |
| 13110 | kfree_skb(skb); |
| 13111 | return -EINVAL; |
| 13112 | } |
| 13113 | qdf_mem_free(dns_query); |
| 13114 | return 0; |
| 13115 | } |
| 13116 | |
| 13117 | /** |
| 13118 | * hdd_populate_tcp_stats_info() - send tcp stats info to network stack |
| 13119 | * @adapter: pointer to adapter context |
| 13120 | * @skb: pointer to skb |
| 13121 | * @pkt_type: tcp pkt type |
| 13122 | * |
| 13123 | * Return: An error code or 0 on success. |
| 13124 | */ |
| 13125 | static int hdd_populate_tcp_stats_info(struct hdd_adapter *adapter, |
| 13126 | struct sk_buff *skb, |
| 13127 | uint8_t pkt_type) |
| 13128 | { |
| 13129 | switch (pkt_type) { |
| 13130 | case CONNECTIVITY_CHECK_SET_TCP_SYN: |
| 13131 | /* Fill info for tcp syn packets (tx packet) */ |
| 13132 | if (nla_put_u16(skb, CHECK_STATS_PKT_TYPE, |
| 13133 | CONNECTIVITY_CHECK_SET_TCP_SYN) || |
| 13134 | nla_put_u16(skb, CHECK_STATS_PKT_SRC_PORT, |
| 13135 | adapter->track_src_port) || |
| 13136 | nla_put_u16(skb, CHECK_STATS_PKT_DEST_PORT, |
| 13137 | adapter->track_dest_port) || |
| 13138 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV, |
| 13139 | adapter->hdd_stats.hdd_tcp_stats.tx_tcp_syn_count) || |
| 13140 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC, |
| 13141 | adapter->hdd_stats.hdd_tcp_stats. |
| 13142 | tx_tcp_syn_host_fw_sent) || |
| 13143 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC, |
| 13144 | adapter->hdd_stats.hdd_tcp_stats. |
| 13145 | tx_tcp_syn_host_fw_sent) || |
| 13146 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS, |
| 13147 | adapter->hdd_stats.hdd_tcp_stats.tx_tcp_syn_ack_cnt)) { |
| 13148 | hdd_err("nla put fail"); |
| 13149 | kfree_skb(skb); |
| 13150 | return -EINVAL; |
| 13151 | } |
| 13152 | break; |
| 13153 | case CONNECTIVITY_CHECK_SET_TCP_SYN_ACK: |
| 13154 | /* Fill info for tcp syn-ack packets (rx packet) */ |
| 13155 | if (nla_put_u16(skb, CHECK_STATS_PKT_TYPE, |
| 13156 | CONNECTIVITY_CHECK_SET_TCP_SYN_ACK) || |
| 13157 | nla_put_u16(skb, CHECK_STATS_PKT_SRC_PORT, |
| 13158 | adapter->track_src_port) || |
| 13159 | nla_put_u16(skb, CHECK_STATS_PKT_DEST_PORT, |
| 13160 | adapter->track_dest_port) || |
| 13161 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_RX_COUNT_BY_LOWER_MAC, |
| 13162 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt) || |
| 13163 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_RX_COUNT_BY_UPPER_MAC, |
| 13164 | adapter->hdd_stats.hdd_tcp_stats. |
| 13165 | rx_tcp_syn_ack_count) || |
| 13166 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_COUNT_TO_NETDEV, |
| 13167 | adapter->hdd_stats.hdd_tcp_stats.rx_delivered) || |
| 13168 | nla_put_u16(skb, |
| 13169 | CHECK_STATS_PKT_RSP_COUNT_OUT_OF_ORDER_DROP, |
| 13170 | adapter->hdd_stats.hdd_tcp_stats.rx_host_drop)) { |
| 13171 | hdd_err("nla put fail"); |
| 13172 | kfree_skb(skb); |
| 13173 | return -EINVAL; |
| 13174 | } |
| 13175 | break; |
| 13176 | case CONNECTIVITY_CHECK_SET_TCP_ACK: |
| 13177 | /* Fill info for tcp ack packets (tx packet) */ |
| 13178 | if (nla_put_u16(skb, CHECK_STATS_PKT_TYPE, |
| 13179 | CONNECTIVITY_CHECK_SET_TCP_ACK) || |
| 13180 | nla_put_u16(skb, CHECK_STATS_PKT_SRC_PORT, |
| 13181 | adapter->track_src_port) || |
| 13182 | nla_put_u16(skb, CHECK_STATS_PKT_DEST_PORT, |
| 13183 | adapter->track_dest_port) || |
| 13184 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV, |
| 13185 | adapter->hdd_stats.hdd_tcp_stats.tx_tcp_ack_count) || |
| 13186 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC, |
| 13187 | adapter->hdd_stats.hdd_tcp_stats. |
| 13188 | tx_tcp_ack_host_fw_sent) || |
| 13189 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC, |
| 13190 | adapter->hdd_stats.hdd_tcp_stats. |
| 13191 | tx_tcp_ack_host_fw_sent) || |
| 13192 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS, |
| 13193 | adapter->hdd_stats.hdd_tcp_stats.tx_tcp_ack_ack_cnt)) { |
| 13194 | hdd_err("nla put fail"); |
| 13195 | kfree_skb(skb); |
| 13196 | return -EINVAL; |
| 13197 | } |
| 13198 | break; |
| 13199 | default: |
| 13200 | break; |
| 13201 | } |
| 13202 | return 0; |
| 13203 | } |
| 13204 | |
| 13205 | /** |
| 13206 | * hdd_populate_icmpv4_stats_info() - send icmpv4 stats info to network stack |
| 13207 | * @adapter: pointer to adapter context |
| 13208 | * @skb: pointer to skb |
| 13209 | * |
| 13210 | * |
| 13211 | * Return: An error code or 0 on success. |
| 13212 | */ |
| 13213 | static int hdd_populate_icmpv4_stats_info(struct hdd_adapter *adapter, |
| 13214 | struct sk_buff *skb) |
| 13215 | { |
| 13216 | if (nla_put_u16(skb, CHECK_STATS_PKT_TYPE, |
| 13217 | CONNECTIVITY_CHECK_SET_ICMPV4) || |
| 13218 | nla_put_u32(skb, CHECK_STATS_PKT_DEST_IPV4, |
| 13219 | adapter->track_dest_ipv4) || |
| 13220 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_FROM_NETDEV, |
| 13221 | adapter->hdd_stats.hdd_icmpv4_stats.tx_icmpv4_req_count) || |
| 13222 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TO_LOWER_MAC, |
| 13223 | adapter->hdd_stats.hdd_icmpv4_stats.tx_host_fw_sent) || |
| 13224 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_RX_COUNT_BY_LOWER_MAC, |
| 13225 | adapter->hdd_stats.hdd_icmpv4_stats.tx_host_fw_sent) || |
| 13226 | nla_put_u16(skb, CHECK_STATS_PKT_REQ_COUNT_TX_SUCCESS, |
| 13227 | adapter->hdd_stats.hdd_icmpv4_stats.tx_ack_cnt) || |
| 13228 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_RX_COUNT_BY_LOWER_MAC, |
| 13229 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt) || |
| 13230 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_RX_COUNT_BY_UPPER_MAC, |
| 13231 | adapter->hdd_stats.hdd_icmpv4_stats.rx_icmpv4_rsp_count) || |
| 13232 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_COUNT_TO_NETDEV, |
| 13233 | adapter->hdd_stats.hdd_icmpv4_stats.rx_delivered) || |
| 13234 | nla_put_u16(skb, CHECK_STATS_PKT_RSP_COUNT_OUT_OF_ORDER_DROP, |
| 13235 | adapter->hdd_stats.hdd_icmpv4_stats.rx_host_drop)) { |
| 13236 | hdd_err("nla put fail"); |
| 13237 | kfree_skb(skb); |
| 13238 | return -EINVAL; |
| 13239 | } |
| 13240 | return 0; |
| 13241 | } |
| 13242 | |
| 13243 | /** |
| 13244 | * hdd_populate_connectivity_check_stats_info() - send connectivity stats info |
| 13245 | * to network stack |
| 13246 | * @adapter: pointer to adapter context |
| 13247 | * @skb: pointer to skb |
| 13248 | * |
| 13249 | * |
| 13250 | * Return: An error code or 0 on success. |
| 13251 | */ |
| 13252 | |
| 13253 | static int hdd_populate_connectivity_check_stats_info( |
| 13254 | struct hdd_adapter *adapter, struct sk_buff *skb) |
| 13255 | { |
| 13256 | struct nlattr *connect_stats, *connect_info; |
| 13257 | uint32_t count = 0; |
| 13258 | |
| 13259 | connect_stats = nla_nest_start(skb, DATA_PKT_STATS); |
| 13260 | if (connect_stats == NULL) { |
| 13261 | hdd_err("nla_nest_start failed"); |
| 13262 | return -EINVAL; |
| 13263 | } |
| 13264 | |
| 13265 | if (adapter->pkt_type_bitmap & CONNECTIVITY_CHECK_SET_DNS) { |
| 13266 | connect_info = nla_nest_start(skb, count); |
| 13267 | if (connect_info == NULL) { |
| 13268 | hdd_err("nla_nest_start failed count %u", count); |
| 13269 | return -EINVAL; |
| 13270 | } |
| 13271 | |
| 13272 | if (hdd_populate_dns_stats_info(adapter, skb)) |
| 13273 | goto put_attr_fail; |
| 13274 | nla_nest_end(skb, connect_info); |
| 13275 | count++; |
| 13276 | } |
| 13277 | |
| 13278 | if (adapter->pkt_type_bitmap & CONNECTIVITY_CHECK_SET_TCP_HANDSHAKE) { |
| 13279 | connect_info = nla_nest_start(skb, count); |
| 13280 | if (connect_info == NULL) { |
| 13281 | hdd_err("nla_nest_start failed count %u", count); |
| 13282 | return -EINVAL; |
| 13283 | } |
| 13284 | if (hdd_populate_tcp_stats_info(adapter, skb, |
| 13285 | CONNECTIVITY_CHECK_SET_TCP_SYN)) |
| 13286 | goto put_attr_fail; |
| 13287 | nla_nest_end(skb, connect_info); |
| 13288 | count++; |
| 13289 | |
| 13290 | connect_info = nla_nest_start(skb, count); |
| 13291 | if (connect_info == NULL) { |
| 13292 | hdd_err("nla_nest_start failed count %u", count); |
| 13293 | return -EINVAL; |
| 13294 | } |
| 13295 | if (hdd_populate_tcp_stats_info(adapter, skb, |
| 13296 | CONNECTIVITY_CHECK_SET_TCP_SYN_ACK)) |
| 13297 | goto put_attr_fail; |
| 13298 | nla_nest_end(skb, connect_info); |
| 13299 | count++; |
| 13300 | |
| 13301 | connect_info = nla_nest_start(skb, count); |
| 13302 | if (connect_info == NULL) { |
| 13303 | hdd_err("nla_nest_start failed count %u", count); |
| 13304 | return -EINVAL; |
| 13305 | } |
| 13306 | if (hdd_populate_tcp_stats_info(adapter, skb, |
| 13307 | CONNECTIVITY_CHECK_SET_TCP_ACK)) |
| 13308 | goto put_attr_fail; |
| 13309 | nla_nest_end(skb, connect_info); |
| 13310 | count++; |
| 13311 | } |
| 13312 | |
| 13313 | if (adapter->pkt_type_bitmap & CONNECTIVITY_CHECK_SET_ICMPV4) { |
| 13314 | connect_info = nla_nest_start(skb, count); |
| 13315 | if (connect_info == NULL) { |
| 13316 | hdd_err("nla_nest_start failed count %u", count); |
| 13317 | return -EINVAL; |
| 13318 | } |
| 13319 | |
| 13320 | if (hdd_populate_icmpv4_stats_info(adapter, skb)) |
| 13321 | goto put_attr_fail; |
| 13322 | nla_nest_end(skb, connect_info); |
| 13323 | count++; |
| 13324 | } |
| 13325 | |
| 13326 | nla_nest_end(skb, connect_stats); |
| 13327 | return 0; |
| 13328 | |
| 13329 | put_attr_fail: |
| 13330 | hdd_err("QCA_WLAN_VENDOR_ATTR put fail. count %u", count); |
| 13331 | return -EINVAL; |
| 13332 | } |
| 13333 | |
| 13334 | |
| 13335 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13336 | * __wlan_hdd_cfg80211_get_nud_stats() - get arp stats command to firmware |
| 13337 | * @wiphy: pointer to wireless wiphy structure. |
| 13338 | * @wdev: pointer to wireless_dev structure. |
| 13339 | * @data: pointer to apfind configuration data. |
| 13340 | * @data_len: the length in byte of apfind data. |
| 13341 | * |
| 13342 | * This is called when wlan driver needs to get arp stats to |
| 13343 | * firmware. |
| 13344 | * |
| 13345 | * Return: An error code or 0 on success. |
| 13346 | */ |
| 13347 | static int __wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy, |
| 13348 | struct wireless_dev *wdev, |
| 13349 | const void *data, int data_len) |
| 13350 | { |
| 13351 | int err = 0; |
| 13352 | unsigned long rc; |
| 13353 | struct hdd_nud_stats_context *context; |
| 13354 | struct net_device *dev = wdev->netdev; |
| 13355 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13356 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 13357 | struct get_arp_stats_params arp_stats_params; |
Poddar, Siddarth | db56816 | 2017-07-27 18:16:38 +0530 | [diff] [blame] | 13358 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 13359 | uint32_t pkt_type_bitmap; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13360 | struct sk_buff *skb; |
| 13361 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 13362 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13363 | |
Anurag Chouhan | 9fb2bd5 | 2018-01-04 12:25:48 +0530 | [diff] [blame] | 13364 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 13365 | hdd_err("Command not allowed in FTM mode"); |
| 13366 | return -EINVAL; |
| 13367 | } |
| 13368 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13369 | err = wlan_hdd_validate_context(hdd_ctx); |
| 13370 | if (0 != err) |
| 13371 | return err; |
| 13372 | |
Rajeev Kumar | 7f28e8a3 | 2017-08-23 15:41:30 -0700 | [diff] [blame] | 13373 | err = hdd_validate_adapter(adapter); |
| 13374 | if (err) |
| 13375 | return err; |
| 13376 | |
Poddar, Siddarth | df07667 | 2018-02-26 14:21:45 +0530 | [diff] [blame] | 13377 | if (adapter->device_mode != QDF_STA_MODE) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 13378 | hdd_err("STATS supported in only STA mode!"); |
Poddar, Siddarth | df07667 | 2018-02-26 14:21:45 +0530 | [diff] [blame] | 13379 | return -EINVAL; |
| 13380 | } |
| 13381 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13382 | arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13383 | arp_stats_params.vdev_id = adapter->session_id; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13384 | |
| 13385 | spin_lock(&hdd_context_lock); |
| 13386 | context = &hdd_ctx->nud_stats_context; |
| 13387 | INIT_COMPLETION(context->response_event); |
| 13388 | spin_unlock(&hdd_context_lock); |
| 13389 | |
Poddar, Siddarth | 762c547 | 2018-03-20 14:55:35 +0530 | [diff] [blame] | 13390 | pkt_type_bitmap = adapter->pkt_type_bitmap; |
| 13391 | |
| 13392 | /* send NUD failure event only when ARP tracking is enabled. */ |
| 13393 | if (hdd_ctx->config->enable_data_stall_det && |
| 13394 | (pkt_type_bitmap & CONNECTIVITY_CHECK_SET_ARP)) |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 13395 | cdp_post_data_stall_event(soc, |
| 13396 | DATA_STALL_LOG_INDICATOR_FRAMEWORK, |
Poddar, Siddarth | db56816 | 2017-07-27 18:16:38 +0530 | [diff] [blame] | 13397 | DATA_STALL_LOG_NUD_FAILURE, |
| 13398 | 0xFF, 0XFF, |
| 13399 | DATA_STALL_LOG_RECOVERY_TRIGGER_PDR); |
| 13400 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13401 | if (QDF_STATUS_SUCCESS != |
| 13402 | sme_get_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 13403 | hdd_err("STATS_SET_START CMD Failed!"); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13404 | return -EINVAL; |
| 13405 | } |
| 13406 | |
| 13407 | rc = wait_for_completion_timeout(&context->response_event, |
| 13408 | msecs_to_jiffies( |
| 13409 | WLAN_WAIT_TIME_NUD_STATS)); |
| 13410 | if (!rc) { |
| 13411 | hdd_err("Target response timed out request "); |
| 13412 | return -ETIMEDOUT; |
| 13413 | } |
| 13414 | |
| 13415 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 13416 | WLAN_NUD_STATS_LEN); |
| 13417 | if (!skb) { |
| 13418 | hdd_err("%s: cfg80211_vendor_cmd_alloc_reply_skb failed", |
| 13419 | __func__); |
| 13420 | return -ENOMEM; |
| 13421 | } |
| 13422 | |
| 13423 | if (nla_put_u16(skb, COUNT_FROM_NETDEV, |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 13424 | adapter->hdd_stats.hdd_arp_stats.tx_arp_req_count) || |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13425 | nla_put_u16(skb, COUNT_TO_LOWER_MAC, |
| 13426 | adapter->hdd_stats.hdd_arp_stats.tx_host_fw_sent) || |
| 13427 | nla_put_u16(skb, RX_COUNT_BY_LOWER_MAC, |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 13428 | adapter->hdd_stats.hdd_arp_stats.tx_host_fw_sent) || |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13429 | nla_put_u16(skb, COUNT_TX_SUCCESS, |
| 13430 | adapter->hdd_stats.hdd_arp_stats.tx_ack_cnt) || |
| 13431 | nla_put_u16(skb, RSP_RX_COUNT_BY_LOWER_MAC, |
| 13432 | adapter->hdd_stats.hdd_arp_stats.rx_fw_cnt) || |
| 13433 | nla_put_u16(skb, RSP_RX_COUNT_BY_UPPER_MAC, |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 13434 | adapter->hdd_stats.hdd_arp_stats.rx_arp_rsp_count) || |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13435 | nla_put_u16(skb, RSP_COUNT_TO_NETDEV, |
| 13436 | adapter->hdd_stats.hdd_arp_stats.rx_delivered) || |
| 13437 | nla_put_u16(skb, RSP_COUNT_OUT_OF_ORDER_DROP, |
| 13438 | adapter->hdd_stats.hdd_arp_stats. |
| 13439 | rx_host_drop_reorder)) { |
| 13440 | hdd_err("nla put fail"); |
| 13441 | kfree_skb(skb); |
| 13442 | return -EINVAL; |
| 13443 | } |
| 13444 | if (adapter->con_status) |
| 13445 | nla_put_flag(skb, AP_LINK_ACTIVE); |
| 13446 | if (adapter->dad) |
| 13447 | nla_put_flag(skb, AP_LINK_DAD); |
| 13448 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 13449 | /* ARP tracking is done above. */ |
| 13450 | pkt_type_bitmap &= ~CONNECTIVITY_CHECK_SET_ARP; |
| 13451 | |
| 13452 | if (pkt_type_bitmap) { |
| 13453 | if (hdd_populate_connectivity_check_stats_info(adapter, skb)) |
| 13454 | return -EINVAL; |
| 13455 | } |
| 13456 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 13457 | cfg80211_vendor_cmd_reply(skb); |
| 13458 | return err; |
| 13459 | } |
| 13460 | |
| 13461 | /** |
| 13462 | * wlan_hdd_cfg80211_get_nud_stats() - get arp stats command to firmware |
| 13463 | * @wiphy: pointer to wireless wiphy structure. |
| 13464 | * @wdev: pointer to wireless_dev structure. |
| 13465 | * @data: pointer to apfind configuration data. |
| 13466 | * @data_len: the length in byte of apfind data. |
| 13467 | * |
| 13468 | * This is called when wlan driver needs to get arp stats to |
| 13469 | * firmware. |
| 13470 | * |
| 13471 | * Return: An error code or 0 on success. |
| 13472 | */ |
| 13473 | static int wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy, |
| 13474 | struct wireless_dev *wdev, |
| 13475 | const void *data, int data_len) |
| 13476 | { |
| 13477 | int ret; |
| 13478 | |
| 13479 | cds_ssr_protect(__func__); |
| 13480 | ret = __wlan_hdd_cfg80211_get_nud_stats(wiphy, wdev, data, data_len); |
| 13481 | cds_ssr_unprotect(__func__); |
| 13482 | |
| 13483 | return ret; |
| 13484 | } |
| 13485 | |
| 13486 | #undef QCA_ATTR_NUD_STATS_SET_INVALID |
| 13487 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV |
| 13488 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC |
| 13489 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC |
| 13490 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS |
| 13491 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC |
| 13492 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC |
| 13493 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV |
| 13494 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP |
| 13495 | #undef QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE |
| 13496 | #undef QCA_ATTR_NUD_STATS_GET_MAX |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 13497 | |
| 13498 | void hdd_bt_activity_cb(void *context, uint32_t bt_activity) |
| 13499 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 13500 | struct hdd_context *hdd_ctx = (struct hdd_context *)context; |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 13501 | int status; |
| 13502 | |
| 13503 | status = wlan_hdd_validate_context(hdd_ctx); |
| 13504 | if (0 != status) |
| 13505 | return; |
| 13506 | |
| 13507 | if (bt_activity == WLAN_COEX_EVENT_BT_A2DP_PROFILE_ADD) |
| 13508 | hdd_ctx->bt_a2dp_active = 1; |
| 13509 | else if (bt_activity == WLAN_COEX_EVENT_BT_A2DP_PROFILE_REMOVE) |
| 13510 | hdd_ctx->bt_a2dp_active = 0; |
| 13511 | else if (bt_activity == WLAN_COEX_EVENT_BT_VOICE_PROFILE_ADD) |
| 13512 | hdd_ctx->bt_vo_active = 1; |
| 13513 | else if (bt_activity == WLAN_COEX_EVENT_BT_VOICE_PROFILE_REMOVE) |
| 13514 | hdd_ctx->bt_vo_active = 0; |
| 13515 | else |
| 13516 | return; |
| 13517 | |
Yeshwanth Sriram Guntuka | 9b9eb43 | 2017-12-14 18:48:41 +0530 | [diff] [blame] | 13518 | ucfg_scan_set_bt_activity(hdd_ctx->hdd_psoc, hdd_ctx->bt_a2dp_active); |
Srinivas Girigowda | 6598eea | 2017-07-06 19:26:19 -0700 | [diff] [blame] | 13519 | 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] | 13520 | hdd_ctx->bt_vo_active); |
| 13521 | } |
| 13522 | |
| 13523 | |
| 13524 | /** |
| 13525 | * wlan_hdd_is_bt_in_progress() - check if bt activity is in progress |
| 13526 | * @hdd_ctx : HDD context |
| 13527 | * |
| 13528 | * Return: true if BT activity is in progress else false |
| 13529 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 13530 | static inline bool wlan_hdd_is_bt_in_progress(struct hdd_context *hdd_ctx) |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 13531 | { |
| 13532 | if (hdd_ctx->bt_a2dp_active || hdd_ctx->bt_vo_active) |
| 13533 | return true; |
| 13534 | |
| 13535 | return false; |
| 13536 | } |
| 13537 | |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 13538 | struct chain_rssi_priv { |
| 13539 | struct chain_rssi_result chain_rssi; |
| 13540 | }; |
| 13541 | |
| 13542 | /** |
| 13543 | * hdd_get_chain_rssi_cb() - Callback function to get chain rssi |
| 13544 | * @context: opaque context originally passed to SME. HDD always passes |
| 13545 | * a cookie for the request context |
| 13546 | * @data: struct for get chain rssi |
| 13547 | * |
| 13548 | * This function receives the response/data from the lower layer and |
| 13549 | * checks to see if the thread is still waiting then post the results to |
| 13550 | * upper layer, if the request has timed out then ignore. |
| 13551 | * |
| 13552 | * Return: None |
| 13553 | */ |
| 13554 | static void hdd_get_chain_rssi_cb(void *context, |
| 13555 | struct chain_rssi_result *data) |
| 13556 | { |
| 13557 | struct hdd_request *request; |
| 13558 | struct chain_rssi_priv *priv; |
| 13559 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 13560 | hdd_enter(); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 13561 | |
| 13562 | request = hdd_request_get(context); |
| 13563 | if (!request) { |
| 13564 | hdd_err("Obsolete request"); |
| 13565 | return; |
| 13566 | } |
| 13567 | |
| 13568 | priv = hdd_request_priv(request); |
| 13569 | priv->chain_rssi = *data; |
| 13570 | hdd_request_complete(request); |
| 13571 | hdd_request_put(request); |
| 13572 | } |
| 13573 | |
| 13574 | /** |
| 13575 | * hdd_post_get_chain_rssi_rsp - send rsp to user space |
| 13576 | * @hdd_ctx: pointer to hdd context |
| 13577 | * @result: chain rssi result |
| 13578 | * |
| 13579 | * Return: 0 for success, non-zero for failure |
| 13580 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 13581 | static int hdd_post_get_chain_rssi_rsp(struct hdd_context *hdd_ctx, |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 13582 | struct chain_rssi_result *result) |
| 13583 | { |
| 13584 | struct sk_buff *skb; |
| 13585 | int data_len = sizeof(result->chain_rssi); |
| 13586 | |
| 13587 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, |
| 13588 | data_len + NLA_HDRLEN + NLMSG_HDRLEN); |
| 13589 | |
| 13590 | if (!skb) { |
| 13591 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 13592 | return -ENOMEM; |
| 13593 | } |
| 13594 | |
| 13595 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_CHAIN_RSSI, data_len, |
| 13596 | result->chain_rssi)) { |
| 13597 | hdd_err("put fail"); |
| 13598 | goto nla_put_failure; |
| 13599 | } |
| 13600 | |
| 13601 | cfg80211_vendor_cmd_reply(skb); |
| 13602 | return 0; |
| 13603 | |
| 13604 | nla_put_failure: |
| 13605 | kfree_skb(skb); |
| 13606 | return -EINVAL; |
| 13607 | } |
| 13608 | |
| 13609 | /** |
| 13610 | * __wlan_hdd_cfg80211_get_chain_rssi() - get chain rssi |
| 13611 | * @wiphy: wiphy pointer |
| 13612 | * @wdev: pointer to struct wireless_dev |
| 13613 | * @data: pointer to incoming NL vendor data |
| 13614 | * @data_len: length of @data |
| 13615 | * |
| 13616 | * Return: 0 on success; error number otherwise. |
| 13617 | */ |
| 13618 | static int __wlan_hdd_cfg80211_get_chain_rssi(struct wiphy *wiphy, |
| 13619 | struct wireless_dev *wdev, |
| 13620 | const void *data, |
| 13621 | int data_len) |
| 13622 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 13623 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(wdev->netdev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 13624 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 13625 | struct get_chain_rssi_req_params req_msg; |
| 13626 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1]; |
| 13627 | QDF_STATUS status; |
| 13628 | int retval; |
| 13629 | void *cookie; |
| 13630 | struct hdd_request *request; |
| 13631 | struct chain_rssi_priv *priv; |
| 13632 | static const struct hdd_request_params params = { |
| 13633 | .priv_size = sizeof(*priv), |
| 13634 | .timeout_ms = WLAN_WAIT_TIME_STATS, |
| 13635 | }; |
| 13636 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 13637 | hdd_enter(); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 13638 | |
| 13639 | retval = wlan_hdd_validate_context(hdd_ctx); |
| 13640 | if (0 != retval) |
| 13641 | return retval; |
| 13642 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 13643 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, |
| 13644 | data, data_len, NULL)) { |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 13645 | hdd_err("Invalid ATTR"); |
| 13646 | return -EINVAL; |
| 13647 | } |
| 13648 | |
| 13649 | if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) { |
| 13650 | hdd_err("attr mac addr failed"); |
| 13651 | return -EINVAL; |
| 13652 | } |
| 13653 | if (nla_len(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) != |
| 13654 | QDF_MAC_ADDR_SIZE) { |
| 13655 | hdd_err("incorrect mac size"); |
| 13656 | return -EINVAL; |
| 13657 | } |
| 13658 | memcpy(&req_msg.peer_macaddr, |
| 13659 | nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]), |
| 13660 | QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13661 | req_msg.session_id = adapter->session_id; |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 13662 | |
| 13663 | request = hdd_request_alloc(¶ms); |
| 13664 | if (!request) { |
| 13665 | hdd_err("Request allocation failure"); |
| 13666 | return -ENOMEM; |
| 13667 | } |
| 13668 | cookie = hdd_request_cookie(request); |
| 13669 | |
| 13670 | status = sme_get_chain_rssi(hdd_ctx->hHal, |
| 13671 | &req_msg, |
| 13672 | hdd_get_chain_rssi_cb, |
| 13673 | cookie); |
| 13674 | if (QDF_STATUS_SUCCESS != status) { |
| 13675 | hdd_err("Unable to get chain rssi"); |
| 13676 | retval = qdf_status_to_os_return(status); |
| 13677 | } else { |
| 13678 | retval = hdd_request_wait_for_response(request); |
| 13679 | if (retval) { |
| 13680 | hdd_err("Target response timed out"); |
| 13681 | } else { |
| 13682 | priv = hdd_request_priv(request); |
| 13683 | retval = hdd_post_get_chain_rssi_rsp(hdd_ctx, |
| 13684 | &priv->chain_rssi); |
| 13685 | if (retval) |
| 13686 | hdd_err("Failed to post chain rssi"); |
| 13687 | } |
| 13688 | } |
| 13689 | hdd_request_put(request); |
| 13690 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 13691 | hdd_exit(); |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 13692 | return retval; |
| 13693 | } |
| 13694 | |
| 13695 | /** |
| 13696 | * wlan_hdd_cfg80211_get_chain_rssi() - get chain rssi |
| 13697 | * @wiphy: wiphy pointer |
| 13698 | * @wdev: pointer to struct wireless_dev |
| 13699 | * @data: pointer to incoming NL vendor data |
| 13700 | * @data_len: length of @data |
| 13701 | * |
| 13702 | * Return: 0 on success; error number otherwise. |
| 13703 | */ |
| 13704 | static int wlan_hdd_cfg80211_get_chain_rssi(struct wiphy *wiphy, |
| 13705 | struct wireless_dev *wdev, |
| 13706 | const void *data, |
| 13707 | int data_len) |
| 13708 | { |
| 13709 | int ret; |
| 13710 | |
| 13711 | cds_ssr_protect(__func__); |
| 13712 | ret = __wlan_hdd_cfg80211_get_chain_rssi(wiphy, wdev, data, data_len); |
| 13713 | cds_ssr_unprotect(__func__); |
| 13714 | |
| 13715 | return ret; |
| 13716 | } |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 13717 | |
Ganesh Kondabattini | b1960e7 | 2017-09-01 09:09:50 +0530 | [diff] [blame] | 13718 | /** |
| 13719 | * __wlan_hdd_cfg80211_set_limit_offchan_param() - set limit off-channel cmd |
| 13720 | * parameters |
| 13721 | * @wiphy: pointer to wireless wiphy structure. |
| 13722 | * @wdev: pointer to wireless_dev structure. |
| 13723 | * @data: pointer to limit off-channel command parameters. |
| 13724 | * @data_len: the length in byte of limit off-channel command parameters. |
| 13725 | * |
| 13726 | * This is called when application wants to limit the off channel time due to |
| 13727 | * active voip traffic. |
| 13728 | * |
| 13729 | * Return: An error code or 0 on success. |
| 13730 | */ |
| 13731 | static int __wlan_hdd_cfg80211_set_limit_offchan_param(struct wiphy *wiphy, |
| 13732 | struct wireless_dev *wdev, const void *data, int data_len) |
| 13733 | { |
| 13734 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ACTIVE_TOS_MAX + 1]; |
| 13735 | struct net_device *dev = wdev->netdev; |
| 13736 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13737 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 13738 | int ret = 0; |
| 13739 | uint8_t tos; |
| 13740 | uint8_t tos_status; |
| 13741 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 13742 | hdd_enter(); |
Ganesh Kondabattini | b1960e7 | 2017-09-01 09:09:50 +0530 | [diff] [blame] | 13743 | |
| 13744 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13745 | if (ret < 0) |
| 13746 | return ret; |
| 13747 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 13748 | if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_ACTIVE_TOS_MAX, |
| 13749 | data, data_len, |
| 13750 | wlan_hdd_set_limit_off_channel_param_policy)) { |
Ganesh Kondabattini | b1960e7 | 2017-09-01 09:09:50 +0530 | [diff] [blame] | 13751 | hdd_err("Invalid ATTR"); |
| 13752 | return -EINVAL; |
| 13753 | } |
| 13754 | |
| 13755 | if (!tb[QCA_WLAN_VENDOR_ATTR_ACTIVE_TOS]) { |
| 13756 | hdd_err("attr tos failed"); |
| 13757 | goto fail; |
| 13758 | } |
| 13759 | |
| 13760 | tos = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_ACTIVE_TOS]); |
| 13761 | hdd_debug("tos %d", tos); |
| 13762 | |
| 13763 | if (!tb[QCA_WLAN_VENDOR_ATTR_ACTIVE_TOS_START]) { |
| 13764 | hdd_err("attr tos active failed"); |
| 13765 | goto fail; |
| 13766 | } |
| 13767 | tos_status = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_ACTIVE_TOS_START]); |
| 13768 | |
| 13769 | hdd_debug("tos status %d", tos_status); |
| 13770 | ret = hdd_set_limit_off_chan_for_tos(adapter, tos, tos_status); |
| 13771 | |
| 13772 | fail: |
| 13773 | return ret; |
| 13774 | } |
| 13775 | |
| 13776 | /** |
| 13777 | * wlan_hdd_cfg80211_set_limit_offchan_param() - set limit off-channel cmd |
| 13778 | * parameters |
| 13779 | * @wiphy: pointer to wireless wiphy structure. |
| 13780 | * @wdev: pointer to wireless_dev structure. |
| 13781 | * @data: pointer to limit off-channel command parameters. |
| 13782 | * @data_len: the length in byte of limit off-channel command parameters. |
| 13783 | * |
| 13784 | * This is called when application wants to limit the off channel time due to |
| 13785 | * active voip traffic. |
| 13786 | * |
| 13787 | * Return: An error code or 0 on success. |
| 13788 | */ |
| 13789 | static int wlan_hdd_cfg80211_set_limit_offchan_param(struct wiphy *wiphy, |
| 13790 | struct wireless_dev *wdev, |
| 13791 | const void *data, int data_len) |
| 13792 | |
| 13793 | { |
| 13794 | int ret = 0; |
| 13795 | |
| 13796 | cds_ssr_protect(__func__); |
| 13797 | ret = __wlan_hdd_cfg80211_set_limit_offchan_param(wiphy, wdev, data, |
| 13798 | data_len); |
| 13799 | cds_ssr_unprotect(__func__); |
| 13800 | |
| 13801 | return ret; |
| 13802 | } |
| 13803 | |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 13804 | /** |
| 13805 | * wlan_hdd_fill_btm_resp() - Fill bss candidate response buffer |
| 13806 | * @reply_skb : pointer to reply_skb |
| 13807 | * @info : bss candidate information |
| 13808 | * @index : attribute type index for nla_next_start() |
| 13809 | * |
| 13810 | * Return : 0 on success and errno on failure |
| 13811 | */ |
| 13812 | static int wlan_hdd_fill_btm_resp(struct sk_buff *reply_skb, |
| 13813 | struct bss_candidate_info *info, |
| 13814 | int index) |
| 13815 | { |
| 13816 | struct nlattr *attr; |
| 13817 | |
| 13818 | attr = nla_nest_start(reply_skb, index); |
| 13819 | if (!attr) { |
| 13820 | hdd_err("nla_nest_start failed"); |
| 13821 | kfree_skb(reply_skb); |
| 13822 | return -EINVAL; |
| 13823 | } |
| 13824 | |
| 13825 | if (nla_put(reply_skb, |
| 13826 | QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO_BSSID, |
| 13827 | ETH_ALEN, info->bssid.bytes) || |
| 13828 | nla_put_u32(reply_skb, |
| 13829 | QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO_STATUS, |
| 13830 | info->status)) { |
| 13831 | hdd_err("nla_put failed"); |
| 13832 | kfree_skb(reply_skb); |
| 13833 | return -EINVAL; |
| 13834 | } |
| 13835 | |
| 13836 | nla_nest_end(reply_skb, attr); |
| 13837 | |
| 13838 | return 0; |
| 13839 | } |
| 13840 | |
| 13841 | /** |
| 13842 | * __wlan_hdd_cfg80211_fetch_bss_transition_status() - fetch bss transition |
| 13843 | * status |
| 13844 | * @wiphy : WIPHY structure pointer |
| 13845 | * @wdev : Wireless device structure pointer |
| 13846 | * @data : Pointer to the data received |
| 13847 | * @data_len : Length of the data received |
| 13848 | * |
| 13849 | * This fuction is used to fetch transition status for candidate bss. The |
| 13850 | * transition status is either accept or reason for reject. |
| 13851 | * |
| 13852 | * Return : 0 on success and errno on failure |
| 13853 | */ |
| 13854 | static int __wlan_hdd_cfg80211_fetch_bss_transition_status(struct wiphy *wiphy, |
| 13855 | struct wireless_dev *wdev, |
| 13856 | const void *data, int data_len) |
| 13857 | { |
| 13858 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1]; |
| 13859 | struct nlattr *tb_msg[QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO_MAX + 1]; |
| 13860 | uint8_t transition_reason; |
| 13861 | struct nlattr *attr; |
| 13862 | struct sk_buff *reply_skb; |
| 13863 | int rem, j; |
| 13864 | int ret; |
| 13865 | bool is_bt_in_progress; |
| 13866 | struct bss_candidate_info candidate_info[MAX_CANDIDATE_INFO]; |
| 13867 | uint16_t nof_candidates, i = 0; |
| 13868 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 13869 | struct net_device *dev = wdev->netdev; |
| 13870 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13871 | struct hdd_station_ctx *hdd_sta_ctx = |
| 13872 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 13873 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13874 | |
| 13875 | const struct nla_policy |
| 13876 | btm_params_policy[QCA_WLAN_VENDOR_ATTR_MAX + 1] = { |
| 13877 | [QCA_WLAN_VENDOR_ATTR_BTM_MBO_TRANSITION_REASON] = { |
| 13878 | .type = NLA_U8}, |
| 13879 | [QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO] = { |
| 13880 | .type = NLA_NESTED}, |
| 13881 | }; |
| 13882 | const struct nla_policy |
| 13883 | btm_cand_list_policy[QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO_MAX + 1] |
| 13884 | = {[QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO_BSSID] = { |
| 13885 | .len = QDF_MAC_ADDR_SIZE}, |
| 13886 | [QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO_STATUS] = { |
| 13887 | .type = NLA_U32}, |
| 13888 | }; |
| 13889 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 13890 | hdd_enter(); |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 13891 | |
| 13892 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 13893 | hdd_err("Command not allowed in FTM mode"); |
| 13894 | return -EINVAL; |
| 13895 | } |
| 13896 | |
| 13897 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13898 | if (ret) |
| 13899 | return ret; |
| 13900 | |
| 13901 | if (adapter->device_mode != QDF_STA_MODE || |
| 13902 | hdd_sta_ctx->conn_info.connState != eConnectionState_Associated) { |
| 13903 | hdd_err("Command is either not invoked for STA mode (device mode: %d) or STA is not associated (Connection state: %d)", |
| 13904 | adapter->device_mode, hdd_sta_ctx->conn_info.connState); |
| 13905 | return -EINVAL; |
| 13906 | } |
| 13907 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 13908 | ret = wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, |
| 13909 | data_len, btm_params_policy); |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 13910 | if (ret) { |
| 13911 | hdd_err("Attribute parse failed"); |
| 13912 | return -EINVAL; |
| 13913 | } |
| 13914 | |
| 13915 | if (!tb[QCA_WLAN_VENDOR_ATTR_BTM_MBO_TRANSITION_REASON] || |
| 13916 | !tb[QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO]) { |
| 13917 | hdd_err("Missing attributes"); |
| 13918 | return -EINVAL; |
| 13919 | } |
| 13920 | |
| 13921 | transition_reason = nla_get_u8( |
| 13922 | tb[QCA_WLAN_VENDOR_ATTR_BTM_MBO_TRANSITION_REASON]); |
| 13923 | |
| 13924 | nla_for_each_nested(attr, |
| 13925 | tb[QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO], |
| 13926 | rem) { |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 13927 | ret = wlan_cfg80211_nla_parse_nested(tb_msg, |
| 13928 | QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO_MAX, |
| 13929 | attr, btm_cand_list_policy); |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 13930 | if (ret) { |
| 13931 | hdd_err("Attribute parse failed"); |
| 13932 | return -EINVAL; |
| 13933 | } |
| 13934 | |
| 13935 | if (!tb_msg[QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO_BSSID]) { |
| 13936 | hdd_err("Missing BSSID attribute"); |
| 13937 | return -EINVAL; |
| 13938 | } |
| 13939 | |
| 13940 | qdf_mem_copy((void *)candidate_info[i].bssid.bytes, |
| 13941 | nla_data(tb_msg[ |
| 13942 | QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO_BSSID]), |
| 13943 | QDF_MAC_ADDR_SIZE); |
| 13944 | i++; |
| 13945 | if (i == MAX_CANDIDATE_INFO) |
| 13946 | break; |
| 13947 | } |
| 13948 | |
| 13949 | /* |
| 13950 | * Determine status for each candidate and fill in the status field. |
| 13951 | * Also arrange the candidates in the order of preference. |
| 13952 | */ |
| 13953 | nof_candidates = i; |
| 13954 | |
| 13955 | is_bt_in_progress = wlan_hdd_is_bt_in_progress(hdd_ctx); |
| 13956 | |
| 13957 | ret = sme_get_bss_transition_status(hal, transition_reason, |
| 13958 | &hdd_sta_ctx->conn_info.bssId, |
| 13959 | candidate_info, |
| 13960 | nof_candidates, |
| 13961 | is_bt_in_progress); |
| 13962 | if (ret) |
| 13963 | return -EINVAL; |
| 13964 | |
| 13965 | /* Prepare the reply and send it to userspace */ |
| 13966 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 13967 | ((QDF_MAC_ADDR_SIZE + sizeof(uint32_t)) * |
| 13968 | nof_candidates) + NLMSG_HDRLEN); |
| 13969 | if (!reply_skb) { |
| 13970 | hdd_err("reply buffer alloc failed"); |
| 13971 | return -ENOMEM; |
| 13972 | } |
| 13973 | |
| 13974 | attr = nla_nest_start(reply_skb, |
| 13975 | QCA_WLAN_VENDOR_ATTR_BTM_CANDIDATE_INFO); |
| 13976 | if (!attr) { |
| 13977 | hdd_err("nla_nest_start failed"); |
| 13978 | kfree_skb(reply_skb); |
| 13979 | return -EINVAL; |
| 13980 | } |
| 13981 | |
| 13982 | /* |
| 13983 | * Order candidates as - accepted candidate list followed by rejected |
| 13984 | * candidate list |
| 13985 | */ |
| 13986 | for (i = 0, j = 0; i < nof_candidates; i++) { |
| 13987 | /* copy accepted candidate list */ |
| 13988 | if (candidate_info[i].status == QCA_STATUS_ACCEPT) { |
| 13989 | if (wlan_hdd_fill_btm_resp(reply_skb, |
| 13990 | &candidate_info[i], j)) |
| 13991 | return -EINVAL; |
| 13992 | j++; |
| 13993 | } |
| 13994 | } |
| 13995 | for (i = 0; i < nof_candidates; i++) { |
| 13996 | /* copy rejected candidate list */ |
| 13997 | if (candidate_info[i].status != QCA_STATUS_ACCEPT) { |
| 13998 | if (wlan_hdd_fill_btm_resp(reply_skb, |
| 13999 | &candidate_info[i], j)) |
| 14000 | return -EINVAL; |
| 14001 | j++; |
| 14002 | } |
| 14003 | } |
| 14004 | nla_nest_end(reply_skb, attr); |
| 14005 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 14006 | hdd_exit(); |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 14007 | |
| 14008 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 14009 | } |
| 14010 | |
| 14011 | /** |
| 14012 | * wlan_hdd_cfg80211_fetch_bss_transition_status() - fetch bss transition status |
| 14013 | * @wiphy : WIPHY structure pointer |
| 14014 | * @wdev : Wireless device structure pointer |
| 14015 | * @data : Pointer to the data received |
| 14016 | * @data_len : Length of the data received |
| 14017 | * |
| 14018 | * This fuction is used to fetch transition status for candidate bss. The |
| 14019 | * transition status is either accept or reason for reject. |
| 14020 | * |
| 14021 | * Return : 0 on success and errno on failure |
| 14022 | */ |
| 14023 | static int wlan_hdd_cfg80211_fetch_bss_transition_status(struct wiphy *wiphy, |
| 14024 | struct wireless_dev *wdev, |
| 14025 | const void *data, int data_len) |
| 14026 | { |
| 14027 | int ret; |
| 14028 | |
| 14029 | cds_ssr_protect(__func__); |
| 14030 | ret = __wlan_hdd_cfg80211_fetch_bss_transition_status(wiphy, wdev, |
| 14031 | data, data_len); |
| 14032 | cds_ssr_unprotect(__func__); |
| 14033 | |
| 14034 | return ret; |
| 14035 | } |
| 14036 | |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 14037 | /** |
| 14038 | * wlan_hdd_fill_intf_info() - Fill skb buffer with interface info |
| 14039 | * @skb: Pointer to skb |
| 14040 | * @info: mac mode info |
| 14041 | * @index: attribute type index for nla_nest_start() |
| 14042 | * |
| 14043 | * Return : 0 on success and errno on failure |
| 14044 | */ |
| 14045 | static int wlan_hdd_fill_intf_info(struct sk_buff *skb, |
| 14046 | struct connection_info *info, int index) |
| 14047 | { |
| 14048 | struct nlattr *attr; |
| 14049 | uint32_t freq; |
| 14050 | struct hdd_context *hdd_ctx; |
| 14051 | struct hdd_adapter *hdd_adapter; |
| 14052 | |
| 14053 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14054 | if (!hdd_ctx) |
| 14055 | goto error; |
| 14056 | |
| 14057 | hdd_adapter = hdd_get_adapter_by_vdev(hdd_ctx, info->vdev_id); |
| 14058 | if (!hdd_adapter) |
| 14059 | goto error; |
| 14060 | |
| 14061 | attr = nla_nest_start(skb, index); |
| 14062 | if (!attr) |
| 14063 | goto error; |
| 14064 | |
| 14065 | freq = sme_chn_to_freq(info->channel); |
| 14066 | |
| 14067 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_MAC_IFACE_INFO_IFINDEX, |
| 14068 | hdd_adapter->dev->ifindex) || |
| 14069 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_MAC_IFACE_INFO_FREQ, freq)) |
| 14070 | goto error; |
| 14071 | |
| 14072 | nla_nest_end(skb, attr); |
| 14073 | |
| 14074 | return 0; |
| 14075 | error: |
| 14076 | hdd_err("Fill buffer with interface info failed"); |
| 14077 | kfree_skb(skb); |
| 14078 | return -EINVAL; |
| 14079 | } |
| 14080 | |
| 14081 | /** |
| 14082 | * wlan_hdd_fill_mac_info() - Fill skb buffer with mac info |
| 14083 | * @skb: Pointer to skb |
| 14084 | * @info: mac mode info |
| 14085 | * @mac_id: MAC id |
| 14086 | * @conn_count: number of current connections |
| 14087 | * |
| 14088 | * Return : 0 on success and errno on failure |
| 14089 | */ |
| 14090 | static int wlan_hdd_fill_mac_info(struct sk_buff *skb, |
| 14091 | struct connection_info *info, uint32_t mac_id, |
| 14092 | uint32_t conn_count) |
| 14093 | { |
| 14094 | struct nlattr *attr, *intf_attr; |
| 14095 | uint32_t band = 0, i = 0, j = 0; |
| 14096 | bool present = false; |
| 14097 | |
| 14098 | while (i < conn_count) { |
| 14099 | if (info[i].mac_id == mac_id) { |
| 14100 | present = true; |
| 14101 | if (info[i].channel <= SIR_11B_CHANNEL_END) |
| 14102 | band |= 1 << NL80211_BAND_2GHZ; |
| 14103 | else if (info[i].channel <= SIR_11A_CHANNEL_END) |
| 14104 | band |= 1 << NL80211_BAND_5GHZ; |
| 14105 | } |
| 14106 | i++; |
| 14107 | } |
| 14108 | |
| 14109 | if (!present) |
| 14110 | return 0; |
| 14111 | |
| 14112 | i = 0; |
| 14113 | attr = nla_nest_start(skb, mac_id); |
| 14114 | if (!attr) |
| 14115 | goto error; |
| 14116 | |
| 14117 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_MAC_INFO_MAC_ID, mac_id) || |
| 14118 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_MAC_INFO_BAND, band)) |
| 14119 | goto error; |
| 14120 | |
| 14121 | intf_attr = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_MAC_IFACE_INFO); |
| 14122 | if (!intf_attr) |
| 14123 | goto error; |
| 14124 | |
| 14125 | while (i < conn_count) { |
| 14126 | if (info[i].mac_id == mac_id) { |
| 14127 | if (wlan_hdd_fill_intf_info(skb, &info[i], j)) |
| 14128 | return -EINVAL; |
| 14129 | j++; |
| 14130 | } |
| 14131 | i++; |
| 14132 | } |
| 14133 | |
| 14134 | nla_nest_end(skb, intf_attr); |
| 14135 | |
| 14136 | nla_nest_end(skb, attr); |
| 14137 | |
| 14138 | return 0; |
| 14139 | error: |
| 14140 | hdd_err("Fill buffer with mac info failed"); |
| 14141 | kfree_skb(skb); |
| 14142 | return -EINVAL; |
| 14143 | } |
| 14144 | |
| 14145 | |
| 14146 | int wlan_hdd_send_mode_change_event(void) |
| 14147 | { |
| 14148 | int err; |
| 14149 | struct hdd_context *hdd_ctx; |
| 14150 | struct sk_buff *skb; |
| 14151 | struct nlattr *attr; |
| 14152 | struct connection_info info[MAX_NUMBER_OF_CONC_CONNECTIONS]; |
| 14153 | uint32_t conn_count, mac_id; |
| 14154 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 14155 | hdd_enter(); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 14156 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14157 | if (!hdd_ctx) { |
| 14158 | hdd_err("HDD context is NULL"); |
| 14159 | return -EINVAL; |
| 14160 | } |
| 14161 | |
| 14162 | err = wlan_hdd_validate_context(hdd_ctx); |
| 14163 | if (0 != err) |
| 14164 | return err; |
| 14165 | |
| 14166 | conn_count = policy_mgr_get_connection_info(hdd_ctx->hdd_psoc, info); |
| 14167 | if (!conn_count) |
| 14168 | return -EINVAL; |
| 14169 | |
| 14170 | skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, NULL, |
| 14171 | (sizeof(uint32_t) * 4) * |
| 14172 | MAX_NUMBER_OF_CONC_CONNECTIONS + NLMSG_HDRLEN, |
| 14173 | QCA_NL80211_VENDOR_SUBCMD_WLAN_MAC_INFO_INDEX, |
| 14174 | GFP_KERNEL); |
| 14175 | if (!skb) { |
| 14176 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
| 14177 | return -ENOMEM; |
| 14178 | } |
| 14179 | |
| 14180 | attr = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_MAC_INFO); |
| 14181 | if (!attr) { |
| 14182 | hdd_err("nla_nest_start failed"); |
| 14183 | kfree_skb(skb); |
| 14184 | return -EINVAL; |
| 14185 | } |
| 14186 | |
| 14187 | for (mac_id = 0; mac_id < MAX_MAC; mac_id++) { |
| 14188 | if (wlan_hdd_fill_mac_info(skb, info, mac_id, conn_count)) |
| 14189 | return -EINVAL; |
| 14190 | } |
| 14191 | |
| 14192 | nla_nest_end(skb, attr); |
| 14193 | |
| 14194 | cfg80211_vendor_event(skb, GFP_KERNEL); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 14195 | hdd_exit(); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 14196 | |
| 14197 | return err; |
| 14198 | } |
| 14199 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14200 | const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] = { |
| 14201 | { |
| 14202 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14203 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY, |
| 14204 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
Srinivas Dasari | 947abd7 | 2016-09-02 12:11:33 +0530 | [diff] [blame] | 14205 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14206 | .doit = is_driver_dfs_capable |
| 14207 | }, |
| 14208 | |
| 14209 | #ifdef WLAN_FEATURE_NAN |
| 14210 | { |
| 14211 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14212 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN, |
| 14213 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14214 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14215 | .doit = wlan_hdd_cfg80211_nan_request |
| 14216 | }, |
| 14217 | #endif |
| 14218 | |
| 14219 | #ifdef WLAN_FEATURE_STATS_EXT |
| 14220 | { |
| 14221 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14222 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_STATS_EXT, |
| 14223 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14224 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14225 | .doit = wlan_hdd_cfg80211_stats_ext_request |
| 14226 | }, |
| 14227 | #endif |
| 14228 | #ifdef FEATURE_WLAN_EXTSCAN |
| 14229 | { |
| 14230 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14231 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START, |
| 14232 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14233 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14234 | .doit = wlan_hdd_cfg80211_extscan_start |
| 14235 | }, |
| 14236 | { |
| 14237 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14238 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP, |
| 14239 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14240 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14241 | .doit = wlan_hdd_cfg80211_extscan_stop |
| 14242 | }, |
| 14243 | { |
| 14244 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14245 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS, |
Manjeet Singh | 3abd730 | 2017-01-11 16:07:42 +0530 | [diff] [blame] | 14246 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14247 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14248 | .doit = wlan_hdd_cfg80211_extscan_get_valid_channels |
| 14249 | }, |
| 14250 | { |
| 14251 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14252 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES, |
| 14253 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14254 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14255 | .doit = wlan_hdd_cfg80211_extscan_get_capabilities |
| 14256 | }, |
| 14257 | { |
| 14258 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14259 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS, |
| 14260 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14261 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14262 | .doit = wlan_hdd_cfg80211_extscan_get_cached_results |
| 14263 | }, |
| 14264 | { |
| 14265 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14266 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST, |
| 14267 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14268 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14269 | .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist |
| 14270 | }, |
| 14271 | { |
| 14272 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14273 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST, |
| 14274 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14275 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14276 | .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist |
| 14277 | }, |
| 14278 | { |
| 14279 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14280 | .info.subcmd = |
| 14281 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE, |
| 14282 | .flags = |
| 14283 | WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14284 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14285 | .doit = wlan_hdd_cfg80211_extscan_set_significant_change |
| 14286 | }, |
| 14287 | { |
| 14288 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14289 | .info.subcmd = |
| 14290 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE, |
| 14291 | .flags = |
| 14292 | WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14293 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14294 | .doit = wlan_hdd_cfg80211_extscan_reset_significant_change |
| 14295 | }, |
| 14296 | { |
| 14297 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14298 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_LIST, |
| 14299 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14300 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14301 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14302 | .doit = wlan_hdd_cfg80211_set_epno_list |
| 14303 | }, |
| 14304 | #endif /* FEATURE_WLAN_EXTSCAN */ |
| 14305 | |
| 14306 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 14307 | { |
| 14308 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14309 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR, |
| 14310 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14311 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14312 | .doit = wlan_hdd_cfg80211_ll_stats_clear |
| 14313 | }, |
| 14314 | |
| 14315 | { |
| 14316 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14317 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET, |
| 14318 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14319 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14320 | .doit = wlan_hdd_cfg80211_ll_stats_set |
| 14321 | }, |
| 14322 | |
| 14323 | { |
| 14324 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14325 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET, |
| 14326 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14327 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14328 | .doit = wlan_hdd_cfg80211_ll_stats_get |
| 14329 | }, |
| 14330 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 14331 | #ifdef FEATURE_WLAN_TDLS |
| 14332 | { |
| 14333 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14334 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE, |
| 14335 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14336 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14337 | .doit = wlan_hdd_cfg80211_exttdls_enable |
| 14338 | }, |
| 14339 | { |
| 14340 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14341 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE, |
| 14342 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14343 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14344 | .doit = wlan_hdd_cfg80211_exttdls_disable |
| 14345 | }, |
| 14346 | { |
| 14347 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14348 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS, |
| 14349 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 14350 | .doit = wlan_hdd_cfg80211_exttdls_get_status |
| 14351 | }, |
| 14352 | #endif |
| 14353 | { |
| 14354 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14355 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES, |
| 14356 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 14357 | .doit = wlan_hdd_cfg80211_get_supported_features |
| 14358 | }, |
| 14359 | { |
| 14360 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14361 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SCANNING_MAC_OUI, |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 14362 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14363 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14364 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14365 | .doit = wlan_hdd_cfg80211_set_scanning_mac_oui |
| 14366 | }, |
| 14367 | { |
| 14368 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14369 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX, |
| 14370 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 14371 | .doit = wlan_hdd_cfg80211_get_concurrency_matrix |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14372 | }, |
| 14373 | { |
| 14374 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14375 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG, |
| 14376 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 14377 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14378 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14379 | .doit = wlan_hdd_cfg80211_disable_dfs_chan_scan |
| 14380 | }, |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 14381 | { |
| 14382 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14383 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WISA, |
| 14384 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 14385 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14386 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 14387 | .doit = wlan_hdd_cfg80211_handle_wisa_cmd |
| 14388 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14389 | { |
| 14390 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 14391 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_STATION, |
| 14392 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14393 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14394 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14395 | .doit = hdd_cfg80211_get_station_cmd |
| 14396 | }, |
| 14397 | { |
| 14398 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14399 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DO_ACS, |
| 14400 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14401 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14402 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14403 | .doit = wlan_hdd_cfg80211_do_acs |
| 14404 | }, |
| 14405 | |
| 14406 | { |
| 14407 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14408 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES, |
| 14409 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14410 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 14411 | .doit = wlan_hdd_cfg80211_get_features |
| 14412 | }, |
| 14413 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 14414 | { |
| 14415 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14416 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_SET_KEY, |
| 14417 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14418 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14419 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14420 | .doit = wlan_hdd_cfg80211_keymgmt_set_key |
| 14421 | }, |
| 14422 | #endif |
| 14423 | #ifdef FEATURE_WLAN_EXTSCAN |
| 14424 | { |
| 14425 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14426 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST, |
| 14427 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14428 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14429 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14430 | .doit = wlan_hdd_cfg80211_set_passpoint_list |
| 14431 | }, |
| 14432 | { |
| 14433 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14434 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_RESET_PASSPOINT_LIST, |
| 14435 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14436 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14437 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14438 | .doit = wlan_hdd_cfg80211_reset_passpoint_list |
| 14439 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14440 | #endif /* FEATURE_WLAN_EXTSCAN */ |
| 14441 | { |
| 14442 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14443 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO, |
| 14444 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14445 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 14446 | .doit = wlan_hdd_cfg80211_get_wifi_info |
| 14447 | }, |
Paul Zhang | 3a210c5 | 2016-12-08 10:18:12 +0800 | [diff] [blame] | 14448 | #ifndef WLAN_UMAC_CONVERGENCE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14449 | { |
| 14450 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14451 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION, |
| 14452 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14453 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14454 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14455 | .doit = wlan_hdd_cfg80211_wifi_configuration_set |
| 14456 | }, |
Paul Zhang | 3a210c5 | 2016-12-08 10:18:12 +0800 | [diff] [blame] | 14457 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14458 | { |
| 14459 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Kiran Kumar Lokere | 08195ef | 2018-01-17 19:25:15 -0800 | [diff] [blame] | 14460 | .info.subcmd = |
| 14461 | QCA_NL80211_VENDOR_SUBCMD_WIFI_TEST_CONFIGURATION, |
| 14462 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14463 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14464 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14465 | .doit = wlan_hdd_cfg80211_set_wifi_test_config |
| 14466 | }, |
| 14467 | |
| 14468 | { |
| 14469 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14470 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAM, |
| 14471 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 14472 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14473 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14474 | .doit = wlan_hdd_cfg80211_set_ext_roam_params |
| 14475 | }, |
| 14476 | { |
| 14477 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14478 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START, |
| 14479 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 14480 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14481 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14482 | .doit = wlan_hdd_cfg80211_wifi_logger_start |
| 14483 | }, |
| 14484 | { |
| 14485 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14486 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA, |
| 14487 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
SaidiReddy Yenuga | 76047d0 | 2017-04-26 19:17:42 +0530 | [diff] [blame] | 14488 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14489 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14490 | .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data |
| 14491 | }, |
| 14492 | { |
| 14493 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14494 | .info.subcmd = |
| 14495 | QCA_NL80211_VENDOR_SUBCMD_GET_PREFERRED_FREQ_LIST, |
| 14496 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14497 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14498 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14499 | .doit = wlan_hdd_cfg80211_get_preferred_freq_list |
| 14500 | }, |
| 14501 | { |
| 14502 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14503 | .info.subcmd = |
| 14504 | QCA_NL80211_VENDOR_SUBCMD_SET_PROBABLE_OPER_CHANNEL, |
| 14505 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14506 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14507 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14508 | .doit = wlan_hdd_cfg80211_set_probable_oper_channel |
| 14509 | }, |
Manikandan Mohan | 5356c2b | 2016-04-03 15:51:35 -0700 | [diff] [blame] | 14510 | #ifdef WLAN_FEATURE_TSF |
| 14511 | { |
| 14512 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14513 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TSF, |
| 14514 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14515 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14516 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14517 | .doit = wlan_hdd_cfg80211_handle_tsf_cmd |
| 14518 | }, |
| 14519 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14520 | #ifdef FEATURE_WLAN_TDLS |
| 14521 | { |
| 14522 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14523 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_CAPABILITIES, |
| 14524 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14525 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14526 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14527 | .doit = wlan_hdd_cfg80211_get_tdls_capabilities |
| 14528 | }, |
| 14529 | #endif |
| 14530 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 14531 | { |
| 14532 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14533 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS, |
| 14534 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14535 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14536 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14537 | .doit = wlan_hdd_cfg80211_offloaded_packets |
| 14538 | }, |
| 14539 | #endif |
| 14540 | { |
| 14541 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14542 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI, |
| 14543 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14544 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14545 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14546 | .doit = wlan_hdd_cfg80211_monitor_rssi |
| 14547 | }, |
| 14548 | { |
| 14549 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 14550 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ND_OFFLOAD, |
| 14551 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14552 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14553 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14554 | .doit = wlan_hdd_cfg80211_set_ns_offload |
| 14555 | }, |
| 14556 | { |
| 14557 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14558 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_LOGGER_FEATURE_SET, |
| 14559 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
Sourav Mohapatra | 412ceb9 | 2018-03-07 18:41:16 +0530 | [diff] [blame] | 14560 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14561 | .doit = wlan_hdd_cfg80211_get_logger_supp_feature |
| 14562 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14563 | { |
| 14564 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14565 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TRIGGER_SCAN, |
| 14566 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14567 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14568 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14569 | .doit = wlan_hdd_cfg80211_vendor_scan |
| 14570 | }, |
| 14571 | |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 14572 | /* Vendor abort scan */ |
| 14573 | { |
| 14574 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14575 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ABORT_SCAN, |
| 14576 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14577 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14578 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14579 | .doit = wlan_hdd_vendor_abort_scan |
| 14580 | }, |
| 14581 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14582 | /* OCB commands */ |
| 14583 | { |
| 14584 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14585 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_SET_CONFIG, |
| 14586 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14587 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14588 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14589 | .doit = wlan_hdd_cfg80211_ocb_set_config |
| 14590 | }, |
| 14591 | { |
| 14592 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14593 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_SET_UTC_TIME, |
| 14594 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14595 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14596 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14597 | .doit = wlan_hdd_cfg80211_ocb_set_utc_time |
| 14598 | }, |
| 14599 | { |
| 14600 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14601 | .info.subcmd = |
| 14602 | QCA_NL80211_VENDOR_SUBCMD_OCB_START_TIMING_ADVERT, |
| 14603 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14604 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14605 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14606 | .doit = wlan_hdd_cfg80211_ocb_start_timing_advert |
| 14607 | }, |
| 14608 | { |
| 14609 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14610 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_STOP_TIMING_ADVERT, |
| 14611 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14612 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14613 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14614 | .doit = wlan_hdd_cfg80211_ocb_stop_timing_advert |
| 14615 | }, |
| 14616 | { |
| 14617 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14618 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_GET_TSF_TIMER, |
| 14619 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14620 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14621 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14622 | .doit = wlan_hdd_cfg80211_ocb_get_tsf_timer |
| 14623 | }, |
| 14624 | { |
| 14625 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14626 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_GET_STATS, |
| 14627 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14628 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14629 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14630 | .doit = wlan_hdd_cfg80211_dcc_get_stats |
| 14631 | }, |
| 14632 | { |
| 14633 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14634 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_CLEAR_STATS, |
| 14635 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14636 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14637 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14638 | .doit = wlan_hdd_cfg80211_dcc_clear_stats |
| 14639 | }, |
| 14640 | { |
| 14641 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14642 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_UPDATE_NDL, |
| 14643 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14644 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14645 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14646 | .doit = wlan_hdd_cfg80211_dcc_update_ndl |
| 14647 | }, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 14648 | { |
| 14649 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14650 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES, |
| 14651 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14652 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14653 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14654 | .doit = wlan_hdd_cfg80211_get_link_properties |
| 14655 | }, |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 14656 | { |
Peng Xu | d222096 | 2016-07-11 17:59:17 -0700 | [diff] [blame] | 14657 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 14658 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OTA_TEST, |
| 14659 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14660 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14661 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14662 | .doit = wlan_hdd_cfg80211_set_ota_test |
| 14663 | }, |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 14664 | #ifdef FEATURE_LFR_SUBNET_DETECTION |
| 14665 | { |
| 14666 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14667 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GW_PARAM_CONFIG, |
| 14668 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14669 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14670 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14671 | .doit = wlan_hdd_cfg80211_set_gateway_params |
| 14672 | }, |
| 14673 | #endif /* FEATURE_LFR_SUBNET_DETECTION */ |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 14674 | { |
Peng Xu | d222096 | 2016-07-11 17:59:17 -0700 | [diff] [blame] | 14675 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 14676 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_TXPOWER_SCALE, |
| 14677 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14678 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14679 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14680 | .doit = wlan_hdd_cfg80211_txpower_scale |
| 14681 | }, |
| 14682 | { |
| 14683 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14684 | .info.subcmd = |
| 14685 | QCA_NL80211_VENDOR_SUBCMD_SET_TXPOWER_SCALE_DECR_DB, |
| 14686 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14687 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14688 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14689 | .doit = wlan_hdd_cfg80211_txpower_scale_decr_db |
| 14690 | }, |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 14691 | { |
| 14692 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14693 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_PACKET_FILTER, |
| 14694 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14695 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14696 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14697 | .doit = wlan_hdd_cfg80211_bpf_offload |
| 14698 | }, |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 14699 | { |
| 14700 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14701 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ACS_POLICY, |
| 14702 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14703 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14704 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14705 | .doit = wlan_hdd_cfg80211_acs_dfs_mode |
| 14706 | }, |
| 14707 | { |
| 14708 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 14709 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_STA_CONNECT_ROAM_POLICY, |
| 14710 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14711 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14712 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14713 | .doit = wlan_hdd_cfg80211_sta_roam_policy |
| 14714 | }, |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 14715 | #ifdef FEATURE_WLAN_CH_AVOID |
| 14716 | { |
| 14717 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14718 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY, |
| 14719 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14720 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14721 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14722 | .doit = wlan_hdd_cfg80211_avoid_freq |
| 14723 | }, |
| 14724 | #endif |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 14725 | { |
| 14726 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 14727 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_SAP_CONFIG, |
| 14728 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14729 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14730 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14731 | .doit = wlan_hdd_cfg80211_sap_configuration_set |
| 14732 | }, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 14733 | { |
Peng Xu | 4225c15 | 2016-07-14 21:18:14 -0700 | [diff] [blame] | 14734 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 14735 | .info.subcmd = |
| 14736 | QCA_NL80211_VENDOR_SUBCMD_P2P_LISTEN_OFFLOAD_START, |
| 14737 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14738 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14739 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14740 | .doit = wlan_hdd_cfg80211_p2p_lo_start |
| 14741 | }, |
| 14742 | { |
| 14743 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14744 | .info.subcmd = |
| 14745 | QCA_NL80211_VENDOR_SUBCMD_P2P_LISTEN_OFFLOAD_STOP, |
| 14746 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14747 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14748 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14749 | .doit = wlan_hdd_cfg80211_p2p_lo_stop |
| 14750 | }, |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14751 | { |
| 14752 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14753 | .info.subcmd = |
| 14754 | QCA_NL80211_VENDOR_SUBCMD_SAP_CONDITIONAL_CHAN_SWITCH, |
| 14755 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14756 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14757 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14758 | .doit = wlan_hdd_cfg80211_conditional_chan_switch |
| 14759 | }, |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 14760 | #ifdef WLAN_FEATURE_NAN_DATAPATH |
| 14761 | { |
| 14762 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14763 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NDP, |
| 14764 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14765 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14766 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14767 | .doit = wlan_hdd_cfg80211_process_ndp_cmd |
| 14768 | }, |
| 14769 | #endif |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 14770 | { |
| 14771 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14772 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WAKE_REASON_STATS, |
| 14773 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14774 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14775 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14776 | .doit = wlan_hdd_cfg80211_get_wakelock_stats |
| 14777 | }, |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 14778 | { |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 14779 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14780 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_BUS_SIZE, |
| 14781 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14782 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14783 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14784 | .doit = wlan_hdd_cfg80211_get_bus_size |
| 14785 | }, |
| 14786 | { |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 14787 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14788 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTERNAL_ACS, |
| 14789 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14790 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14791 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14792 | .doit = wlan_hdd_cfg80211_update_vendor_channel |
| 14793 | }, |
| 14794 | { |
bings | d09dea3 | 2017-03-17 10:08:26 +0800 | [diff] [blame] | 14795 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 14796 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND, |
| 14797 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14798 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14799 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14800 | .doit = wlan_hdd_cfg80211_setband |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 14801 | }, |
| 14802 | { |
| 14803 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14804 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING, |
| 14805 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14806 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14807 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14808 | .doit = wlan_hdd_cfg80211_set_fast_roaming |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 14809 | }, |
| 14810 | #ifdef WLAN_FEATURE_DISA |
| 14811 | { |
| 14812 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14813 | .info.subcmd = |
| 14814 | QCA_NL80211_VENDOR_SUBCMD_ENCRYPTION_TEST, |
| 14815 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14816 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14817 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14818 | .doit = wlan_hdd_cfg80211_encrypt_decrypt_msg |
| 14819 | }, |
| 14820 | #endif |
Kabilan Kannan | d053aaf | 2016-10-26 02:06:14 -0700 | [diff] [blame] | 14821 | #ifdef FEATURE_WLAN_TDLS |
| 14822 | { |
| 14823 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14824 | .info.subcmd = |
| 14825 | QCA_NL80211_VENDOR_SUBCMD_CONFIGURE_TDLS, |
| 14826 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14827 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14828 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14829 | .doit = wlan_hdd_cfg80211_configure_tdls_mode |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 14830 | }, |
Kabilan Kannan | d053aaf | 2016-10-26 02:06:14 -0700 | [diff] [blame] | 14831 | #endif |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 14832 | { |
| 14833 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Jeff Johnson | 8c83f13 | 2017-12-18 16:41:37 -0800 | [diff] [blame] | 14834 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SAR_LIMITS, |
| 14835 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14836 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14837 | .doit = wlan_hdd_cfg80211_get_sar_power_limits |
| 14838 | }, |
| 14839 | { |
| 14840 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Kabilan Kannan | 3c0a735 | 2016-12-02 18:49:38 -0800 | [diff] [blame] | 14841 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS, |
| 14842 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14843 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14844 | .doit = wlan_hdd_cfg80211_set_sar_power_limits |
| 14845 | }, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 14846 | { |
| 14847 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14848 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_TRACE_LEVEL, |
| 14849 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14850 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14851 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14852 | .doit = wlan_hdd_cfg80211_set_trace_level |
| 14853 | }, |
Zhang Qian | 4ead8f0 | 2017-03-27 14:21:47 +0800 | [diff] [blame] | 14854 | { |
| 14855 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14856 | .info.subcmd = |
| 14857 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_EXT, |
| 14858 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14859 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14860 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14861 | .doit = wlan_hdd_cfg80211_ll_stats_ext_set_param |
| 14862 | }, |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 14863 | { |
| 14864 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14865 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_SET, |
| 14866 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14867 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14868 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14869 | .doit = wlan_hdd_cfg80211_set_nud_stats |
| 14870 | }, |
| 14871 | { |
| 14872 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14873 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET, |
| 14874 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14875 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14876 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14877 | .doit = wlan_hdd_cfg80211_get_nud_stats |
| 14878 | }, |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 14879 | { |
| 14880 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14881 | .info.subcmd = |
| 14882 | QCA_NL80211_VENDOR_SUBCMD_FETCH_BSS_TRANSITION_STATUS, |
| 14883 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14884 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14885 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14886 | .doit = wlan_hdd_cfg80211_fetch_bss_transition_status |
| 14887 | }, |
Sandeep Puligilla | 063a434 | 2018-01-10 02:50:14 -0800 | [diff] [blame] | 14888 | FEATURE_SPECTRAL_SCAN_VENDOR_COMMANDS |
Paul Zhang | 3a210c5 | 2016-12-08 10:18:12 +0800 | [diff] [blame] | 14889 | #ifdef WLAN_UMAC_CONVERGENCE |
| 14890 | COMMON_VENDOR_COMMANDS |
| 14891 | #endif |
Krishna Kumaar Natarajan | f567650 | 2017-03-06 10:28:44 -0800 | [diff] [blame] | 14892 | FEATURE_11AX_VENDOR_COMMANDS |
lifeng | d217d19 | 2017-05-09 19:44:16 +0800 | [diff] [blame] | 14893 | |
| 14894 | { |
| 14895 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14896 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CHAIN_RSSI, |
| 14897 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14898 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14899 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14900 | .doit = wlan_hdd_cfg80211_get_chain_rssi |
| 14901 | }, |
Ganesh Kondabattini | b1960e7 | 2017-09-01 09:09:50 +0530 | [diff] [blame] | 14902 | { |
| 14903 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 14904 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ACTIVE_TOS, |
| 14905 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 14906 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 14907 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 14908 | .doit = wlan_hdd_cfg80211_set_limit_offchan_param |
| 14909 | }, |
| 14910 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14911 | }; |
| 14912 | |
Dustin Brown | 52ba1ce | 2017-08-16 12:10:55 -0700 | [diff] [blame] | 14913 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) |
| 14914 | static inline void |
| 14915 | hdd_wiphy_set_max_sched_scans(struct wiphy *wiphy, uint8_t max_scans) |
| 14916 | { |
| 14917 | if (max_scans == 0) |
| 14918 | wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 14919 | else |
| 14920 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 14921 | } |
| 14922 | #else |
| 14923 | static inline void |
| 14924 | hdd_wiphy_set_max_sched_scans(struct wiphy *wiphy, uint8_t max_scans) |
| 14925 | { |
| 14926 | wiphy->max_sched_scan_reqs = max_scans; |
| 14927 | } |
| 14928 | #endif /* KERNEL_VERSION(4, 12, 0) */ |
| 14929 | |
Padma, Santhosh Kumar | 4b302b6 | 2017-07-21 17:33:27 +0530 | [diff] [blame] | 14930 | /** |
| 14931 | * wlan_hdd_cfg80211_add_connected_pno_support() - Set connected PNO support |
| 14932 | * @wiphy: Pointer to wireless phy |
| 14933 | * |
| 14934 | * This function is used to set connected PNO support to kernel |
| 14935 | * |
| 14936 | * Return: None |
| 14937 | */ |
| 14938 | #if defined(CFG80211_REPORT_BETTER_BSS_IN_SCHED_SCAN) |
| 14939 | static void wlan_hdd_cfg80211_add_connected_pno_support(struct wiphy *wiphy) |
| 14940 | { |
| 14941 | wiphy_ext_feature_set(wiphy, |
| 14942 | NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI); |
| 14943 | } |
| 14944 | #else |
| 14945 | static void wlan_hdd_cfg80211_add_connected_pno_support(struct wiphy *wiphy) |
| 14946 | { |
| 14947 | } |
| 14948 | #endif |
| 14949 | |
Anurag Chouhan | 7c01cc4 | 2016-12-16 21:33:43 +0530 | [diff] [blame] | 14950 | #if ((LINUX_VERSION_CODE > KERNEL_VERSION(4, 4, 0)) || \ |
| 14951 | defined(CFG80211_MULTI_SCAN_PLAN_BACKPORT)) && \ |
| 14952 | defined(FEATURE_WLAN_SCAN_PNO) |
| 14953 | /** |
| 14954 | * hdd_config_sched_scan_plans_to_wiphy() - configure sched scan plans to wiphy |
| 14955 | * @wiphy: pointer to wiphy |
| 14956 | * @config: pointer to config |
| 14957 | * |
| 14958 | * Return: None |
| 14959 | */ |
| 14960 | static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy, |
| 14961 | struct hdd_config *config) |
| 14962 | { |
| 14963 | if (config->configPNOScanSupport) { |
Dustin Brown | 52ba1ce | 2017-08-16 12:10:55 -0700 | [diff] [blame] | 14964 | hdd_wiphy_set_max_sched_scans(wiphy, 1); |
Abhishek Singh | 0481d66 | 2017-04-11 18:20:11 +0530 | [diff] [blame] | 14965 | wiphy->max_sched_scan_ssids = SCAN_PNO_MAX_SUPP_NETWORKS; |
| 14966 | wiphy->max_match_sets = SCAN_PNO_MAX_SUPP_NETWORKS; |
Anurag Chouhan | 7c01cc4 | 2016-12-16 21:33:43 +0530 | [diff] [blame] | 14967 | wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
Abhishek Singh | 0481d66 | 2017-04-11 18:20:11 +0530 | [diff] [blame] | 14968 | wiphy->max_sched_scan_plans = SCAN_PNO_MAX_PLAN_REQUEST; |
Anurag Chouhan | 7c01cc4 | 2016-12-16 21:33:43 +0530 | [diff] [blame] | 14969 | if (config->max_sched_scan_plan_interval) |
| 14970 | wiphy->max_sched_scan_plan_interval = |
| 14971 | config->max_sched_scan_plan_interval; |
| 14972 | if (config->max_sched_scan_plan_iterations) |
| 14973 | wiphy->max_sched_scan_plan_iterations = |
| 14974 | config->max_sched_scan_plan_iterations; |
| 14975 | } |
| 14976 | } |
| 14977 | #else |
| 14978 | static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy, |
| 14979 | struct hdd_config *config) |
| 14980 | { |
| 14981 | } |
| 14982 | #endif |
| 14983 | |
| 14984 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 14985 | /** |
| 14986 | * hdd_cfg80211_wiphy_alloc() - Allocate wiphy context |
| 14987 | * @priv_size: Size of the hdd context. |
| 14988 | * |
| 14989 | * Allocate wiphy context and hdd context. |
| 14990 | * |
| 14991 | * Return: hdd context on success and NULL on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14992 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 14993 | struct hdd_context *hdd_cfg80211_wiphy_alloc(int priv_size) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14994 | { |
| 14995 | struct wiphy *wiphy; |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 14996 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 14997 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 14998 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14999 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15000 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 15001 | |
| 15002 | if (!wiphy) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15003 | hdd_err("wiphy init failed!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15004 | return NULL; |
| 15005 | } |
| 15006 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 15007 | hdd_ctx = wiphy_priv(wiphy); |
| 15008 | |
| 15009 | hdd_ctx->wiphy = wiphy; |
| 15010 | |
| 15011 | return hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15012 | } |
| 15013 | |
| 15014 | /* |
| 15015 | * FUNCTION: wlan_hdd_cfg80211_update_band |
| 15016 | * This function is called from the supplicant through a |
| 15017 | * private ioctl to change the band value |
| 15018 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 15019 | int wlan_hdd_cfg80211_update_band(struct hdd_context *hdd_ctx, struct wiphy *wiphy, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 15020 | enum band_info eBand) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15021 | { |
| 15022 | int i, j; |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 15023 | enum channel_state channelEnabledState; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15024 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15025 | hdd_enter(); |
Srinivas Girigowda | 5da651b | 2017-08-04 11:22:54 -0700 | [diff] [blame] | 15026 | |
| 15027 | for (i = 0; i < HDD_NUM_NL80211_BANDS; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15028 | |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 15029 | if (NULL == wiphy->bands[i]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15030 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15031 | |
| 15032 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) { |
| 15033 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 15034 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 15035 | channelEnabledState = wlan_reg_get_channel_state( |
| 15036 | hdd_ctx->hdd_pdev, |
| 15037 | band->channels[j].hw_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15038 | |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15039 | if (HDD_NL80211_BAND_2GHZ == i && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 15040 | BAND_5G == eBand) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15041 | /* 5G only */ |
| 15042 | #ifdef WLAN_ENABLE_SOCIAL_CHANNELS_5G_ONLY |
| 15043 | /* Enable Social channels for P2P */ |
| 15044 | if (WLAN_HDD_IS_SOCIAL_CHANNEL |
| 15045 | (band->channels[j].center_freq) |
| 15046 | && CHANNEL_STATE_ENABLE == |
| 15047 | channelEnabledState) |
| 15048 | band->channels[j].flags &= |
| 15049 | ~IEEE80211_CHAN_DISABLED; |
| 15050 | else |
| 15051 | #endif |
| 15052 | band->channels[j].flags |= |
| 15053 | IEEE80211_CHAN_DISABLED; |
| 15054 | continue; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15055 | } else if (HDD_NL80211_BAND_5GHZ == i && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 15056 | BAND_2G == eBand) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15057 | /* 2G only */ |
| 15058 | band->channels[j].flags |= |
| 15059 | IEEE80211_CHAN_DISABLED; |
| 15060 | continue; |
| 15061 | } |
| 15062 | |
Amar Singhal | 6842e8f | 2016-02-23 16:30:32 -0800 | [diff] [blame] | 15063 | if (CHANNEL_STATE_DISABLE != channelEnabledState) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15064 | band->channels[j].flags &= |
| 15065 | ~IEEE80211_CHAN_DISABLED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15066 | } |
| 15067 | } |
| 15068 | return 0; |
| 15069 | } |
| 15070 | |
Rajeev Kumar Sirasanagandla | 686abd9 | 2017-06-08 18:09:01 +0530 | [diff] [blame] | 15071 | #if defined(CFG80211_SCAN_RANDOM_MAC_ADDR) || \ |
| 15072 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) |
| 15073 | static void wlan_hdd_cfg80211_scan_randomization_init(struct wiphy *wiphy) |
| 15074 | { |
Paul Zhang | 382248f | 2017-10-17 14:24:45 +0800 | [diff] [blame] | 15075 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e0847ba | 2018-03-01 12:34:50 -0800 | [diff] [blame] | 15076 | |
Paul Zhang | 382248f | 2017-10-17 14:24:45 +0800 | [diff] [blame] | 15077 | hdd_ctx = wiphy_priv(wiphy); |
| 15078 | |
| 15079 | if (false == hdd_ctx->config->enable_mac_spoofing) { |
| 15080 | hdd_warn("MAC address spoofing is not enabled"); |
| 15081 | } else { |
| 15082 | wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR; |
| 15083 | wiphy->features |= NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR; |
| 15084 | } |
Rajeev Kumar Sirasanagandla | 686abd9 | 2017-06-08 18:09:01 +0530 | [diff] [blame] | 15085 | } |
| 15086 | #else |
| 15087 | static void wlan_hdd_cfg80211_scan_randomization_init(struct wiphy *wiphy) |
| 15088 | { |
| 15089 | } |
| 15090 | #endif |
| 15091 | |
Peng Xu | acfdda1 | 2017-02-06 16:15:38 -0800 | [diff] [blame] | 15092 | #define WLAN_HDD_MAX_NUM_CSA_COUNTERS 2 |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 15093 | |
| 15094 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 15095 | (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 15096 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 15097 | static void wlan_hdd_cfg80211_set_wiphy_fils_feature(struct wiphy *wiphy) |
| 15098 | { |
| 15099 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_FILS_SK_OFFLOAD); |
| 15100 | } |
| 15101 | #else |
| 15102 | static void wlan_hdd_cfg80211_set_wiphy_fils_feature(struct wiphy *wiphy) |
| 15103 | { |
| 15104 | } |
| 15105 | #endif |
| 15106 | |
gaurank kathpalia | a398d5f | 2018-02-27 16:42:22 +0530 | [diff] [blame] | 15107 | #if defined (CFG80211_SCAN_DBS_CONTROL_SUPPORT) || \ |
| 15108 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)) |
| 15109 | static void wlan_hdd_cfg80211_set_wiphy_scan_flags(struct wiphy *wiphy) |
| 15110 | { |
| 15111 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_LOW_SPAN_SCAN); |
| 15112 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_LOW_POWER_SCAN); |
| 15113 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_HIGH_ACCURACY_SCAN); |
| 15114 | } |
| 15115 | #else |
| 15116 | static void wlan_hdd_cfg80211_set_wiphy_scan_flags(struct wiphy *wiphy) |
| 15117 | { |
| 15118 | } |
| 15119 | #endif |
| 15120 | |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 15121 | #if defined(WLAN_FEATURE_SAE) && \ |
| 15122 | defined(CFG80211_EXTERNAL_AUTH_SUPPORT) |
Padma, Santhosh Kumar | 3e47c63 | 2017-09-01 20:15:27 +0530 | [diff] [blame] | 15123 | /** |
| 15124 | * wlan_hdd_cfg80211_set_wiphy_sae_feature() - Indicates support of SAE feature |
| 15125 | * @wiphy: Pointer to wiphy |
| 15126 | * @config: pointer to config |
| 15127 | * |
| 15128 | * This function is used to indicate the support of SAE |
| 15129 | * |
| 15130 | * Return: None |
| 15131 | */ |
| 15132 | static void wlan_hdd_cfg80211_set_wiphy_sae_feature(struct wiphy *wiphy, |
| 15133 | struct hdd_config *config) |
| 15134 | { |
| 15135 | if (config->is_sae_enabled) |
| 15136 | wiphy->features |= NL80211_FEATURE_SAE; |
| 15137 | } |
| 15138 | #else |
| 15139 | static void wlan_hdd_cfg80211_set_wiphy_sae_feature(struct wiphy *wiphy, |
| 15140 | struct hdd_config *config) |
| 15141 | { |
| 15142 | } |
| 15143 | #endif |
| 15144 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15145 | /* |
| 15146 | * FUNCTION: wlan_hdd_cfg80211_init |
| 15147 | * This function is called by hdd_wlan_startup() |
| 15148 | * during initialization. |
| 15149 | * This function is used to initialize and register wiphy structure. |
| 15150 | */ |
| 15151 | int wlan_hdd_cfg80211_init(struct device *dev, |
| 15152 | struct wiphy *wiphy, struct hdd_config *pCfg) |
| 15153 | { |
| 15154 | int i, j; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15155 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Ashish Kumar Dhanotiya | cc2e0d3 | 2017-08-24 20:13:08 +0530 | [diff] [blame] | 15156 | int len = 0; |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 15157 | uint32_t *cipher_suites; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15158 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15159 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15160 | |
| 15161 | /* Now bind the underlying wlan device with wiphy */ |
| 15162 | set_wiphy_dev(wiphy, dev); |
| 15163 | |
| 15164 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
| 15165 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15166 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 15167 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 15168 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
| 15169 | #ifdef FEATURE_WLAN_STA_4ADDR_SCHEME |
| 15170 | | WIPHY_FLAG_4ADDR_STATION |
| 15171 | #endif |
| 15172 | | WIPHY_FLAG_OFFCHAN_TX; |
| 15173 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15174 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 15175 | wiphy->wowlan = &wowlan_support_cfg80211_init; |
| 15176 | #else |
| 15177 | wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT; |
| 15178 | wiphy->wowlan.n_patterns = WOWL_MAX_PTRNS_ALLOWED; |
| 15179 | wiphy->wowlan.pattern_min_len = 1; |
| 15180 | wiphy->wowlan.pattern_max_len = WOWL_PTRN_MAX_SIZE; |
| 15181 | #endif |
| 15182 | |
Deepak Dhamdhere | a2df6bb | 2015-10-29 15:11:06 -0700 | [diff] [blame] | 15183 | if (pCfg->isFastTransitionEnabled || pCfg->isFastRoamIniFeatureEnabled |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15184 | #ifdef FEATURE_WLAN_ESE |
| 15185 | || pCfg->isEseIniFeatureEnabled |
| 15186 | #endif |
| 15187 | ) { |
| 15188 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 15189 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15190 | #ifdef FEATURE_WLAN_TDLS |
| 15191 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 15192 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 15193 | #endif |
| 15194 | |
| 15195 | wiphy->features |= NL80211_FEATURE_HT_IBSS; |
| 15196 | |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 15197 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) |
| 15198 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS); |
| 15199 | #endif |
Vignesh Viswanathan | cc7f1b9 | 2017-09-28 13:12:24 +0530 | [diff] [blame] | 15200 | if (pCfg->is_fils_enabled) |
| 15201 | wlan_hdd_cfg80211_set_wiphy_fils_feature(wiphy); |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 15202 | |
gaurank kathpalia | a398d5f | 2018-02-27 16:42:22 +0530 | [diff] [blame] | 15203 | wlan_hdd_cfg80211_set_wiphy_scan_flags(wiphy); |
| 15204 | |
Padma, Santhosh Kumar | 3e47c63 | 2017-09-01 20:15:27 +0530 | [diff] [blame] | 15205 | wlan_hdd_cfg80211_set_wiphy_sae_feature(wiphy, pCfg); |
| 15206 | |
Anurag Chouhan | 7c01cc4 | 2016-12-16 21:33:43 +0530 | [diff] [blame] | 15207 | hdd_config_sched_scan_plans_to_wiphy(wiphy, pCfg); |
Padma, Santhosh Kumar | 4b302b6 | 2017-07-21 17:33:27 +0530 | [diff] [blame] | 15208 | wlan_hdd_cfg80211_add_connected_pno_support(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15209 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15210 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 15211 | |
| 15212 | wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH; |
| 15213 | |
| 15214 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 15215 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 15216 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
| 15217 | | BIT(NL80211_IFTYPE_ADHOC) |
| 15218 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 15219 | | BIT(NL80211_IFTYPE_P2P_GO) |
| 15220 | | BIT(NL80211_IFTYPE_AP) |
| 15221 | | BIT(NL80211_IFTYPE_MONITOR); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15222 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 15223 | if (pCfg->advertiseConcurrentOperation) { |
| 15224 | if (pCfg->enableMCC) { |
| 15225 | int i; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 15226 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 15227 | for (i = 0; |
| 15228 | i < ARRAY_SIZE(wlan_hdd_iface_combination); |
| 15229 | i++) { |
| 15230 | if (!pCfg->allowMCCGODiffBI) |
| 15231 | wlan_hdd_iface_combination[i]. |
| 15232 | beacon_int_infra_match = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15233 | } |
| 15234 | } |
| 15235 | wiphy->n_iface_combinations = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 15236 | ARRAY_SIZE(wlan_hdd_iface_combination); |
| 15237 | wiphy->iface_combinations = wlan_hdd_iface_combination; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15238 | } |
| 15239 | |
| 15240 | /* Before registering we need to update the ht capabilitied based |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 15241 | * on ini values |
| 15242 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15243 | if (!pCfg->ShortGI20MhzEnable) { |
| 15244 | wlan_hdd_band_2_4_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 15245 | wlan_hdd_band_5_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15246 | } |
| 15247 | |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 15248 | if (!pCfg->ShortGI40MhzEnable) |
| 15249 | wlan_hdd_band_5_ghz.ht_cap.cap &= |
| 15250 | ~IEEE80211_HT_CAP_SGI_40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15251 | |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 15252 | if (!pCfg->nChannelBondingMode5GHz) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15253 | wlan_hdd_band_5_ghz.ht_cap.cap &= |
| 15254 | ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15255 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15256 | /* |
| 15257 | * In case of static linked driver at the time of driver unload, |
| 15258 | * module exit doesn't happens. Module cleanup helps in cleaning |
| 15259 | * of static memory. |
| 15260 | * If driver load happens statically, at the time of driver unload, |
| 15261 | * wiphy flags don't get reset because of static memory. |
| 15262 | * It's better not to store channel in static memory. |
| 15263 | */ |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15264 | wiphy->bands[HDD_NL80211_BAND_2GHZ] = &wlan_hdd_band_2_4_ghz; |
| 15265 | wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels = |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15266 | qdf_mem_malloc(sizeof(hdd_channels_2_4_ghz)); |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15267 | if (wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels == NULL) { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15268 | hdd_err("Not enough memory to allocate channels"); |
| 15269 | return -ENOMEM; |
| 15270 | } |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15271 | qdf_mem_copy(wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels, |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15272 | &hdd_channels_2_4_ghz[0], |
| 15273 | sizeof(hdd_channels_2_4_ghz)); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15274 | if ((hdd_is_5g_supported(hdd_ctx)) && |
Selvaraj, Sridhar | cd3cc70 | 2016-07-31 15:37:07 +0530 | [diff] [blame] | 15275 | ((eHDD_DOT11_MODE_11b != pCfg->dot11Mode) && |
| 15276 | (eHDD_DOT11_MODE_11g != pCfg->dot11Mode) && |
| 15277 | (eHDD_DOT11_MODE_11b_ONLY != pCfg->dot11Mode) && |
| 15278 | (eHDD_DOT11_MODE_11g_ONLY != pCfg->dot11Mode))) { |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15279 | wiphy->bands[HDD_NL80211_BAND_5GHZ] = &wlan_hdd_band_5_ghz; |
Ashish Kumar Dhanotiya | cc2e0d3 | 2017-08-24 20:13:08 +0530 | [diff] [blame] | 15280 | |
| 15281 | if (pCfg->dot11p_mode) { |
| 15282 | wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels = |
| 15283 | qdf_mem_malloc(sizeof(hdd_channels_5_ghz) + |
| 15284 | sizeof(hdd_channels_dot11p)); |
| 15285 | if (wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels == |
| 15286 | NULL) { |
| 15287 | goto mem_fail; |
| 15288 | } |
| 15289 | wiphy->bands[HDD_NL80211_BAND_5GHZ]->n_channels = |
| 15290 | QDF_ARRAY_SIZE(hdd_channels_5_ghz) + |
| 15291 | QDF_ARRAY_SIZE(hdd_channels_dot11p); |
| 15292 | |
| 15293 | qdf_mem_copy(wiphy->bands[HDD_NL80211_BAND_5GHZ]-> |
| 15294 | channels, &hdd_channels_5_ghz[0], |
| 15295 | sizeof(hdd_channels_5_ghz)); |
| 15296 | len = sizeof(hdd_channels_5_ghz); |
| 15297 | qdf_mem_copy((char *)wiphy-> |
| 15298 | bands[HDD_NL80211_BAND_5GHZ]->channels |
| 15299 | + len, |
| 15300 | &hdd_channels_dot11p[0], |
| 15301 | sizeof(hdd_channels_dot11p)); |
| 15302 | |
| 15303 | } else { |
| 15304 | wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels = |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15305 | qdf_mem_malloc(sizeof(hdd_channels_5_ghz)); |
Ashish Kumar Dhanotiya | cc2e0d3 | 2017-08-24 20:13:08 +0530 | [diff] [blame] | 15306 | if (wiphy->bands[HDD_NL80211_BAND_5GHZ]->channels == |
| 15307 | NULL) { |
| 15308 | goto mem_fail; |
| 15309 | } |
| 15310 | qdf_mem_copy(wiphy-> |
| 15311 | bands[HDD_NL80211_BAND_5GHZ]->channels, |
| 15312 | &hdd_channels_5_ghz[0], |
| 15313 | sizeof(hdd_channels_5_ghz)); |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15314 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15315 | } |
| 15316 | |
Srinivas Girigowda | 5da651b | 2017-08-04 11:22:54 -0700 | [diff] [blame] | 15317 | for (i = 0; i < HDD_NUM_NL80211_BANDS; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15318 | |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 15319 | if (NULL == wiphy->bands[i]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15320 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15321 | |
| 15322 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) { |
| 15323 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 15324 | |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15325 | if (HDD_NL80211_BAND_2GHZ == i && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 15326 | BAND_5G == pCfg->nBandCapability) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15327 | /* 5G only */ |
| 15328 | #ifdef WLAN_ENABLE_SOCIAL_CHANNELS_5G_ONLY |
| 15329 | /* Enable social channels for P2P */ |
| 15330 | if (WLAN_HDD_IS_SOCIAL_CHANNEL |
| 15331 | (band->channels[j].center_freq)) |
| 15332 | band->channels[j].flags &= |
| 15333 | ~IEEE80211_CHAN_DISABLED; |
| 15334 | else |
| 15335 | #endif |
| 15336 | band->channels[j].flags |= |
| 15337 | IEEE80211_CHAN_DISABLED; |
| 15338 | continue; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15339 | } else if (HDD_NL80211_BAND_5GHZ == i && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 15340 | BAND_2G == pCfg->nBandCapability) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15341 | /* 2G only */ |
| 15342 | band->channels[j].flags |= |
| 15343 | IEEE80211_CHAN_DISABLED; |
| 15344 | continue; |
| 15345 | } |
| 15346 | } |
| 15347 | } |
| 15348 | /*Initialise the supported cipher suite details */ |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 15349 | if (pCfg->gcmp_enabled) { |
| 15350 | cipher_suites = qdf_mem_malloc(sizeof(hdd_cipher_suites) + |
| 15351 | sizeof(hdd_gcmp_cipher_suits)); |
| 15352 | if (cipher_suites == NULL) { |
| 15353 | hdd_err("Not enough memory for cipher suites"); |
| 15354 | return -ENOMEM; |
| 15355 | } |
| 15356 | wiphy->n_cipher_suites = QDF_ARRAY_SIZE(hdd_cipher_suites) + |
| 15357 | QDF_ARRAY_SIZE(hdd_gcmp_cipher_suits); |
| 15358 | qdf_mem_copy(cipher_suites, &hdd_cipher_suites, |
| 15359 | sizeof(hdd_cipher_suites)); |
| 15360 | qdf_mem_copy(cipher_suites + QDF_ARRAY_SIZE(hdd_cipher_suites), |
| 15361 | &hdd_gcmp_cipher_suits, |
| 15362 | sizeof(hdd_gcmp_cipher_suits)); |
| 15363 | } else { |
| 15364 | cipher_suites = qdf_mem_malloc(sizeof(hdd_cipher_suites)); |
| 15365 | if (cipher_suites == NULL) { |
| 15366 | hdd_err("Not enough memory for cipher suites"); |
| 15367 | return -ENOMEM; |
| 15368 | } |
| 15369 | wiphy->n_cipher_suites = QDF_ARRAY_SIZE(hdd_cipher_suites); |
| 15370 | qdf_mem_copy(cipher_suites, &hdd_cipher_suites, |
| 15371 | sizeof(hdd_cipher_suites)); |
| 15372 | } |
| 15373 | wiphy->cipher_suites = cipher_suites; |
| 15374 | cipher_suites = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15375 | /*signal strength in mBm (100*dBm) */ |
| 15376 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 15377 | wiphy->max_remain_on_channel_duration = MAX_REMAIN_ON_CHANNEL_DURATION; |
| 15378 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 15379 | if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15380 | wiphy->n_vendor_commands = |
| 15381 | ARRAY_SIZE(hdd_wiphy_vendor_commands); |
| 15382 | wiphy->vendor_commands = hdd_wiphy_vendor_commands; |
| 15383 | |
| 15384 | wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events; |
| 15385 | wiphy->n_vendor_events = |
| 15386 | ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events); |
| 15387 | } |
| 15388 | |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 15389 | if (pCfg->enableDFSMasterCap) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15390 | wiphy->flags |= WIPHY_FLAG_DFS_OFFLOAD; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15391 | |
| 15392 | wiphy->max_ap_assoc_sta = pCfg->maxNumberOfPeers; |
| 15393 | |
| 15394 | #ifdef QCA_HT_2040_COEX |
| 15395 | wiphy->features |= NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE; |
| 15396 | #endif |
Agrawal, Ashish | 4e5fa1c | 2016-09-21 19:03:43 +0530 | [diff] [blame] | 15397 | wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER; |
wadesong | a75734c | 2017-02-07 16:03:25 +0800 | [diff] [blame] | 15398 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 15399 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) || \ |
wadesong | a75734c | 2017-02-07 16:03:25 +0800 | [diff] [blame] | 15400 | defined(CFG80211_BEACON_TX_RATE_CUSTOM_BACKPORT) |
| 15401 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_LEGACY); |
| 15402 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_HT); |
| 15403 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_VHT); |
| 15404 | #endif |
| 15405 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 15406 | hdd_add_channel_switch_support(&wiphy->flags); |
Peng Xu | acfdda1 | 2017-02-06 16:15:38 -0800 | [diff] [blame] | 15407 | wiphy->max_num_csa_counters = WLAN_HDD_MAX_NUM_CSA_COUNTERS; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 15408 | if (pCfg->enable_mac_spoofing) |
| 15409 | wlan_hdd_cfg80211_scan_randomization_init(wiphy); |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 15410 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 15411 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15412 | return 0; |
Ashish Kumar Dhanotiya | cc2e0d3 | 2017-08-24 20:13:08 +0530 | [diff] [blame] | 15413 | |
| 15414 | mem_fail: |
| 15415 | hdd_err("Not enough memory to allocate channels"); |
| 15416 | if (wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels != NULL) { |
| 15417 | qdf_mem_free(wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels); |
| 15418 | wiphy->bands[HDD_NL80211_BAND_2GHZ]->channels = NULL; |
| 15419 | } |
| 15420 | return -ENOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15421 | } |
| 15422 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15423 | /** |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 15424 | * wlan_hdd_cfg80211_deinit() - Deinit cfg80211 |
| 15425 | * @wiphy: the wiphy to validate against |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15426 | * |
| 15427 | * this function deinit cfg80211 and cleanup the |
Abhishek Singh | 3e6172f | 2016-05-04 16:56:48 +0530 | [diff] [blame] | 15428 | * memory allocated in wlan_hdd_cfg80211_init also |
| 15429 | * reset the global reg params. |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15430 | * |
| 15431 | * Return: void |
| 15432 | */ |
| 15433 | void wlan_hdd_cfg80211_deinit(struct wiphy *wiphy) |
| 15434 | { |
| 15435 | int i; |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 15436 | const uint32_t *cipher_suites; |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15437 | |
Srinivas Girigowda | 5da651b | 2017-08-04 11:22:54 -0700 | [diff] [blame] | 15438 | for (i = 0; i < HDD_NUM_NL80211_BANDS; i++) { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15439 | if (NULL != wiphy->bands[i] && |
| 15440 | (NULL != wiphy->bands[i]->channels)) { |
| 15441 | qdf_mem_free(wiphy->bands[i]->channels); |
| 15442 | wiphy->bands[i]->channels = NULL; |
| 15443 | } |
| 15444 | } |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 15445 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 15446 | cipher_suites = wiphy->cipher_suites; |
| 15447 | wiphy->cipher_suites = NULL; |
| 15448 | wiphy->n_cipher_suites = 0; |
| 15449 | qdf_mem_free((uint32_t *)cipher_suites); |
| 15450 | cipher_suites = NULL; |
Abhishek Singh | 3e6172f | 2016-05-04 16:56:48 +0530 | [diff] [blame] | 15451 | hdd_reset_global_reg_params(); |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 15452 | } |
| 15453 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 15454 | /** |
| 15455 | * wlan_hdd_update_band_cap() - update capabilities for supported bands |
| 15456 | * @hdd_ctx: HDD context |
| 15457 | * |
| 15458 | * this function will update capabilities for supported bands |
| 15459 | * |
| 15460 | * Return: void |
| 15461 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 15462 | static void wlan_hdd_update_band_cap(struct hdd_context *hdd_ctx) |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 15463 | { |
| 15464 | uint32_t val32; |
| 15465 | uint16_t val16; |
| 15466 | tSirMacHTCapabilityInfo *ht_cap_info; |
| 15467 | QDF_STATUS status; |
| 15468 | |
| 15469 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_HT_CAP_INFO, &val32); |
| 15470 | if (QDF_STATUS_SUCCESS != status) { |
| 15471 | hdd_err("could not get HT capability info"); |
| 15472 | val32 = 0; |
| 15473 | } |
| 15474 | val16 = (uint16_t)val32; |
| 15475 | ht_cap_info = (tSirMacHTCapabilityInfo *)&val16; |
| 15476 | |
| 15477 | if (ht_cap_info->txSTBC == true) { |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15478 | if (NULL != hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]) |
| 15479 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]->ht_cap.cap |= |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 15480 | IEEE80211_HT_CAP_TX_STBC; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15481 | if (NULL != hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]) |
| 15482 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]->ht_cap.cap |= |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 15483 | IEEE80211_HT_CAP_TX_STBC; |
| 15484 | } |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 15485 | |
| 15486 | if (!sme_is_feature_supported_by_fw(DOT11AC)) { |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15487 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]-> |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 15488 | vht_cap.vht_supported = 0; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15489 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]->vht_cap.cap = 0; |
| 15490 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]-> |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 15491 | vht_cap.vht_supported = 0; |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 15492 | hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]->vht_cap.cap = 0; |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 15493 | } |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 15494 | } |
| 15495 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15496 | /* |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 15497 | * In this function, wiphy structure is updated after QDF |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15498 | * initialization. In wlan_hdd_cfg80211_init, only the |
| 15499 | * default values will be initialized. The final initialization |
| 15500 | * of all required members can be done here. |
| 15501 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 15502 | void wlan_hdd_update_wiphy(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15503 | { |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 15504 | hdd_ctx->wiphy->max_ap_assoc_sta = hdd_ctx->config->maxNumberOfPeers; |
| 15505 | |
| 15506 | wlan_hdd_update_band_cap(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15507 | } |
| 15508 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 15509 | /** |
| 15510 | * wlan_hdd_update_11n_mode - update 11n mode in hdd cfg |
| 15511 | * @cfg: hdd cfg |
| 15512 | * |
| 15513 | * this function update 11n mode in hdd cfg |
| 15514 | * |
| 15515 | * Return: void |
| 15516 | */ |
| 15517 | void wlan_hdd_update_11n_mode(struct hdd_config *cfg) |
| 15518 | { |
| 15519 | if (sme_is_feature_supported_by_fw(DOT11AC)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15520 | hdd_debug("support 11ac"); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 15521 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15522 | hdd_debug("not support 11ac"); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 15523 | if ((cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) || |
| 15524 | (cfg->dot11Mode == eHDD_DOT11_MODE_11ac)) { |
| 15525 | cfg->dot11Mode = eHDD_DOT11_MODE_11n; |
| 15526 | cfg->sap_p2p_11ac_override = 0; |
| 15527 | } |
| 15528 | } |
| 15529 | } |
| 15530 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15531 | /* In this function we are registering wiphy. */ |
| 15532 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 15533 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15534 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15535 | /* Register our wiphy dev with cfg80211 */ |
| 15536 | if (0 > wiphy_register(wiphy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 15537 | hdd_err("wiphy register failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15538 | return -EIO; |
| 15539 | } |
| 15540 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 15541 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15542 | return 0; |
| 15543 | } |
| 15544 | |
| 15545 | /* |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 15546 | * HDD function to update wiphy capability based on target offload status. |
| 15547 | * |
| 15548 | * wlan_hdd_cfg80211_init() does initialization of all wiphy related |
| 15549 | * capability even before downloading firmware to the target. In discrete |
| 15550 | * case, host will get know certain offload capability (say sched_scan |
| 15551 | * caps) only after downloading firmware to the target and target boots up. |
| 15552 | * This function is used to override setting done in wlan_hdd_cfg80211_init() |
| 15553 | * based on target capability. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15554 | */ |
| 15555 | void wlan_hdd_cfg80211_update_wiphy_caps(struct wiphy *wiphy) |
| 15556 | { |
| 15557 | #ifdef FEATURE_WLAN_SCAN_PNO |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15558 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 15559 | struct hdd_config *pCfg = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15560 | |
| 15561 | /* wlan_hdd_cfg80211_init() sets sched_scan caps already in wiphy before |
| 15562 | * control comes here. Here just we need to clear it if firmware doesn't |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 15563 | * have PNO support. |
| 15564 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15565 | if (!pCfg->PnoOffload) { |
Dustin Brown | 52ba1ce | 2017-08-16 12:10:55 -0700 | [diff] [blame] | 15566 | hdd_wiphy_set_max_sched_scans(wiphy, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15567 | wiphy->max_sched_scan_ssids = 0; |
| 15568 | wiphy->max_match_sets = 0; |
| 15569 | wiphy->max_sched_scan_ie_len = 0; |
| 15570 | } |
| 15571 | #endif |
| 15572 | } |
| 15573 | |
| 15574 | /* This function registers for all frame which supplicant is interested in */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15575 | int wlan_hdd_cfg80211_register_frames(struct hdd_adapter *adapter) |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15576 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15577 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter); |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15578 | /* Register for all P2P action, public action etc frames */ |
| 15579 | 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] | 15580 | QDF_STATUS status; |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15581 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15582 | hdd_enter(); |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15583 | |
| 15584 | /* Register frame indication call back */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15585 | status = sme_register_mgmt_frame_ind_callback(hHal, |
| 15586 | hdd_indicate_mgmt_frame); |
| 15587 | if (status != QDF_STATUS_SUCCESS) { |
| 15588 | hdd_err("Failed to register hdd_indicate_mgmt_frame"); |
| 15589 | goto ret_status; |
| 15590 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15591 | |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15592 | /* Right now we are registering these frame when driver is getting |
| 15593 | * initialized. Once we will move to 2.6.37 kernel, in which we have |
| 15594 | * frame register ops, we will move this code as a part of that |
| 15595 | */ |
| 15596 | |
| 15597 | /* GAS Initial Request */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15598 | status = sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15599 | (uint8_t *) GAS_INITIAL_REQ, |
| 15600 | GAS_INITIAL_REQ_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15601 | if (status != QDF_STATUS_SUCCESS) { |
| 15602 | hdd_err("Failed to register GAS_INITIAL_REQ"); |
| 15603 | goto ret_status; |
| 15604 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15605 | |
| 15606 | /* GAS Initial Response */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15607 | status = sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15608 | (uint8_t *) GAS_INITIAL_RSP, |
| 15609 | GAS_INITIAL_RSP_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15610 | if (status != QDF_STATUS_SUCCESS) { |
| 15611 | hdd_err("Failed to register GAS_INITIAL_RSP"); |
| 15612 | goto dereg_gas_initial_req; |
| 15613 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15614 | |
| 15615 | /* GAS Comeback Request */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15616 | status = sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15617 | (uint8_t *) GAS_COMEBACK_REQ, |
| 15618 | GAS_COMEBACK_REQ_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15619 | if (status != QDF_STATUS_SUCCESS) { |
| 15620 | hdd_err("Failed to register GAS_COMEBACK_REQ"); |
| 15621 | goto dereg_gas_initial_rsp; |
| 15622 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15623 | |
| 15624 | /* GAS Comeback Response */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15625 | status = sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15626 | (uint8_t *) GAS_COMEBACK_RSP, |
| 15627 | GAS_COMEBACK_RSP_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15628 | if (status != QDF_STATUS_SUCCESS) { |
| 15629 | hdd_err("Failed to register GAS_COMEBACK_RSP"); |
| 15630 | goto dereg_gas_comeback_req; |
| 15631 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15632 | |
| 15633 | /* WNM BSS Transition Request frame */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15634 | status = sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15635 | (uint8_t *) WNM_BSS_ACTION_FRAME, |
| 15636 | WNM_BSS_ACTION_FRAME_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15637 | if (status != QDF_STATUS_SUCCESS) { |
| 15638 | hdd_err("Failed to register WNM_BSS_ACTION_FRAME"); |
| 15639 | goto dereg_gas_comeback_rsp; |
| 15640 | } |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15641 | |
| 15642 | /* WNM-Notification */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 15643 | status = sme_register_mgmt_frame(hHal, adapter->session_id, type, |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15644 | (uint8_t *) WNM_NOTIFICATION_FRAME, |
| 15645 | WNM_NOTIFICATION_FRAME_SIZE); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 15646 | if (status != QDF_STATUS_SUCCESS) { |
| 15647 | hdd_err("Failed to register WNM_NOTIFICATION_FRAME"); |
| 15648 | goto dereg_wnm_bss_action_frm; |
| 15649 | } |
| 15650 | |
| 15651 | dereg_wnm_bss_action_frm: |
| 15652 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 15653 | (uint8_t *) WNM_BSS_ACTION_FRAME, |
| 15654 | WNM_BSS_ACTION_FRAME_SIZE); |
| 15655 | dereg_gas_comeback_rsp: |
| 15656 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 15657 | (uint8_t *) GAS_COMEBACK_RSP, |
| 15658 | GAS_COMEBACK_RSP_SIZE); |
| 15659 | dereg_gas_comeback_req: |
| 15660 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 15661 | (uint8_t *) GAS_COMEBACK_REQ, |
| 15662 | GAS_COMEBACK_REQ_SIZE); |
| 15663 | dereg_gas_initial_rsp: |
| 15664 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 15665 | (uint8_t *) GAS_INITIAL_RSP, |
| 15666 | GAS_INITIAL_RSP_SIZE); |
| 15667 | dereg_gas_initial_req: |
| 15668 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 15669 | (uint8_t *) GAS_INITIAL_REQ, |
| 15670 | GAS_INITIAL_REQ_SIZE); |
| 15671 | ret_status: |
| 15672 | return qdf_status_to_os_return(status); |
Wu Gao | 84d120c | 2017-03-24 18:46:00 +0800 | [diff] [blame] | 15673 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15674 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15675 | void wlan_hdd_cfg80211_deregister_frames(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15676 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15677 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15678 | /* Register for all P2P action, public action etc frames */ |
| 15679 | uint16_t type = (SIR_MAC_MGMT_FRAME << 2) | (SIR_MAC_MGMT_ACTION << 4); |
| 15680 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15681 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15682 | |
| 15683 | /* Right now we are registering these frame when driver is getting |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 15684 | * initialized. Once we will move to 2.6.37 kernel, in which we have |
| 15685 | * frame register ops, we will move this code as a part of that |
| 15686 | */ |
| 15687 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15688 | /* GAS Initial Request */ |
| 15689 | |
| 15690 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 15691 | (uint8_t *) GAS_INITIAL_REQ, |
| 15692 | GAS_INITIAL_REQ_SIZE); |
| 15693 | |
| 15694 | /* GAS Initial Response */ |
| 15695 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 15696 | (uint8_t *) GAS_INITIAL_RSP, |
| 15697 | GAS_INITIAL_RSP_SIZE); |
| 15698 | |
| 15699 | /* GAS Comeback Request */ |
| 15700 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 15701 | (uint8_t *) GAS_COMEBACK_REQ, |
| 15702 | GAS_COMEBACK_REQ_SIZE); |
| 15703 | |
| 15704 | /* GAS Comeback Response */ |
| 15705 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 15706 | (uint8_t *) GAS_COMEBACK_RSP, |
| 15707 | GAS_COMEBACK_RSP_SIZE); |
| 15708 | |
| 15709 | /* P2P Public Action */ |
| 15710 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 15711 | (uint8_t *) P2P_PUBLIC_ACTION_FRAME, |
| 15712 | P2P_PUBLIC_ACTION_FRAME_SIZE); |
| 15713 | |
| 15714 | /* P2P Action */ |
| 15715 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 15716 | (uint8_t *) P2P_ACTION_FRAME, |
| 15717 | P2P_ACTION_FRAME_SIZE); |
| 15718 | |
| 15719 | /* WNM-Notification */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 15720 | sme_deregister_mgmt_frame(hHal, adapter->session_id, type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15721 | (uint8_t *) WNM_NOTIFICATION_FRAME, |
| 15722 | WNM_NOTIFICATION_FRAME_SIZE); |
| 15723 | } |
| 15724 | |
| 15725 | #ifdef FEATURE_WLAN_WAPI |
Jeff Johnson | fee20aa | 2017-10-30 21:33:14 -0700 | [diff] [blame] | 15726 | void wlan_hdd_cfg80211_set_key_wapi(struct hdd_adapter *adapter, |
| 15727 | uint8_t key_index, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15728 | const uint8_t *mac_addr, const uint8_t *key, |
| 15729 | int key_Len) |
| 15730 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15731 | tCsrRoamSetKey setKey; |
| 15732 | bool isConnected = true; |
| 15733 | int status = 0; |
Krunal Soni | bfd0549 | 2017-10-03 15:48:37 -0700 | [diff] [blame] | 15734 | uint32_t roamId = INVALID_ROAM_ID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15735 | uint8_t *pKeyPtr = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15736 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15737 | hdd_debug("Device_mode %s(%d)", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15738 | hdd_device_mode_to_string(adapter->device_mode), |
| 15739 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15740 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 15741 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15742 | setKey.keyId = key_index; /* Store Key ID */ |
| 15743 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; /* SET WAPI Encryption */ |
| 15744 | setKey.keyDirection = eSIR_TX_RX; /* Key Directionn both TX and RX */ |
| 15745 | setKey.paeRole = 0; /* the PAE role */ |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 15746 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 15747 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 15748 | else |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 15749 | qdf_mem_copy(setKey.peerMac.bytes, mac_addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 15750 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15751 | setKey.keyLength = key_Len; |
| 15752 | pKeyPtr = setKey.Key; |
| 15753 | memcpy(pKeyPtr, key, key_Len); |
| 15754 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15755 | hdd_debug("WAPI KEY LENGTH:0x%04x", key_Len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15756 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15757 | if (isConnected) { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15758 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 15759 | adapter->session_id, &setKey, &roamId); |
Jeff Johnson | fee20aa | 2017-10-30 21:33:14 -0700 | [diff] [blame] | 15760 | if (status != 0) |
| 15761 | hdd_err("sme_roam_set_key failed status: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15762 | } |
| 15763 | } |
| 15764 | #endif /* FEATURE_WLAN_WAPI */ |
| 15765 | |
Krunal Soni | 364e087 | 2017-05-10 21:24:34 -0700 | [diff] [blame] | 15766 | bool wlan_hdd_is_ap_supports_immediate_power_save(uint8_t *ies, int length) |
| 15767 | { |
Naveen Rawat | 08db88f | 2017-09-08 15:07:48 -0700 | [diff] [blame] | 15768 | const uint8_t *vendor_ie; |
Krunal Soni | 364e087 | 2017-05-10 21:24:34 -0700 | [diff] [blame] | 15769 | |
| 15770 | if (length < 2) { |
| 15771 | hdd_debug("bss size is less than expected"); |
| 15772 | return true; |
| 15773 | } |
| 15774 | if (!ies) { |
| 15775 | hdd_debug("invalid IE pointer"); |
| 15776 | return true; |
| 15777 | } |
Naveen Rawat | 08db88f | 2017-09-08 15:07:48 -0700 | [diff] [blame] | 15778 | 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] | 15779 | VENDOR1_AP_OUI_TYPE_SIZE, ies, length); |
| 15780 | if (vendor_ie) { |
| 15781 | hdd_debug("AP can't support immediate powersave. defer it"); |
| 15782 | return false; |
| 15783 | } |
| 15784 | return true; |
| 15785 | } |
| 15786 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15787 | /* |
| 15788 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 15789 | * called by wlan_hdd_cfg80211_start_bss() and |
| 15790 | * wlan_hdd_set_channel() |
| 15791 | * This function validates whether given channel is part of valid |
| 15792 | * channel list. |
| 15793 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15794 | QDF_STATUS wlan_hdd_validate_operation_channel(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15795 | int channel) |
| 15796 | { |
| 15797 | |
| 15798 | uint32_t num_ch = 0; |
| 15799 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 15800 | u32 indx = 0; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15801 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15802 | uint8_t fValidChannel = false, count = 0; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15803 | struct hdd_config *hdd_pConfig_ini = (WLAN_HDD_GET_CTX(adapter))->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15804 | |
| 15805 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 15806 | |
| 15807 | if (hdd_pConfig_ini->sapAllowAllChannel) { |
| 15808 | /* Validate the channel */ |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 15809 | for (count = CHAN_ENUM_1; count <= CHAN_ENUM_165; count++) { |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 15810 | if (channel == WLAN_REG_CH_NUM(count)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15811 | fValidChannel = true; |
| 15812 | break; |
| 15813 | } |
| 15814 | } |
| 15815 | if (fValidChannel != true) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15816 | hdd_err("Invalid Channel: %d", channel); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15817 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15818 | } |
| 15819 | } else { |
| 15820 | if (0 != sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 15821 | valid_ch, &num_ch)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 15822 | hdd_err("failed to get valid channel list"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15823 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15824 | } |
| 15825 | for (indx = 0; indx < num_ch; indx++) { |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 15826 | if (channel == valid_ch[indx]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15827 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15828 | } |
| 15829 | |
| 15830 | if (indx >= num_ch) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15831 | hdd_err("Invalid Channel: %d", channel); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15832 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15833 | } |
| 15834 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15835 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15836 | |
| 15837 | } |
| 15838 | |
| 15839 | #ifdef DHCP_SERVER_OFFLOAD |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 15840 | static void wlan_hdd_set_dhcp_server_offload(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15841 | { |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 15842 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15843 | tpSirDhcpSrvOffloadInfo pDhcpSrvInfo; |
| 15844 | uint8_t numEntries = 0; |
| 15845 | uint8_t srv_ip[IPADDR_NUM_ENTRIES]; |
| 15846 | uint8_t num; |
| 15847 | uint32_t temp; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 15848 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 15849 | pDhcpSrvInfo = qdf_mem_malloc(sizeof(*pDhcpSrvInfo)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15850 | if (NULL == pDhcpSrvInfo) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 15851 | hdd_err("could not allocate tDhcpSrvOffloadInfo!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15852 | return; |
| 15853 | } |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 15854 | pDhcpSrvInfo->vdev_id = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15855 | pDhcpSrvInfo->dhcpSrvOffloadEnabled = true; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15856 | pDhcpSrvInfo->dhcpClientNum = hdd_ctx->config->dhcpMaxNumClients; |
| 15857 | hdd_string_to_u8_array(hdd_ctx->config->dhcpServerIP, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15858 | srv_ip, &numEntries, IPADDR_NUM_ENTRIES); |
| 15859 | if (numEntries != IPADDR_NUM_ENTRIES) { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15860 | hdd_err("Incorrect IP address (%s) assigned for DHCP server!", hdd_ctx->config->dhcpServerIP); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15861 | goto end; |
| 15862 | } |
| 15863 | if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15864 | hdd_err("Invalid IP address (%s)! It could NOT be multicast IP address!", hdd_ctx->config->dhcpServerIP); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15865 | goto end; |
| 15866 | } |
| 15867 | if (srv_ip[IPADDR_NUM_ENTRIES - 1] >= 100) { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15868 | hdd_err("Invalid IP address (%s)! The last field must be less than 100!", hdd_ctx->config->dhcpServerIP); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15869 | goto end; |
| 15870 | } |
| 15871 | for (num = 0; num < numEntries; num++) { |
| 15872 | temp = srv_ip[num]; |
| 15873 | pDhcpSrvInfo->dhcpSrvIP |= (temp << (8 * num)); |
| 15874 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 15875 | if (QDF_STATUS_SUCCESS != |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15876 | sme_set_dhcp_srv_offload(hdd_ctx->hHal, pDhcpSrvInfo)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 15877 | hdd_err("sme_setDHCPSrvOffload fail!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15878 | goto end; |
| 15879 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15880 | hdd_debug("enable DHCP Server offload successfully!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15881 | end: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 15882 | qdf_mem_free(pDhcpSrvInfo); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15883 | } |
| 15884 | #endif /* DHCP_SERVER_OFFLOAD */ |
| 15885 | |
| 15886 | static int __wlan_hdd_cfg80211_change_bss(struct wiphy *wiphy, |
| 15887 | struct net_device *dev, |
| 15888 | struct bss_parameters *params) |
| 15889 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15890 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 15891 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15892 | int ret = 0; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 15893 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15894 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15895 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15896 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 15897 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 15898 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15899 | return -EINVAL; |
| 15900 | } |
| 15901 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 15902 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 15903 | hdd_err("invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 15904 | return -EINVAL; |
| 15905 | } |
| 15906 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 15907 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15908 | TRACE_CODE_HDD_CFG80211_CHANGE_BSS, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 15909 | adapter->session_id, params->ap_isolate)); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15910 | hdd_debug("Device_mode %s(%d), ap_isolate = %d", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15911 | hdd_device_mode_to_string(adapter->device_mode), |
| 15912 | adapter->device_mode, params->ap_isolate); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15913 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15914 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15915 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 15916 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15917 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15918 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 15919 | if (!(adapter->device_mode == QDF_SAP_MODE || |
| 15920 | adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15921 | return -EOPNOTSUPP; |
| 15922 | } |
| 15923 | |
| 15924 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 15925 | * want to update this parameter |
| 15926 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15927 | if (-1 != params->ap_isolate) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 15928 | adapter->session.ap.disable_intrabss_fwd = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15929 | !!params->ap_isolate; |
| 15930 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 15931 | qdf_ret_status = sme_ap_disable_intra_bss_fwd(hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 15932 | adapter->session_id, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 15933 | adapter->session. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15934 | ap. |
Jeff Johnson | 82ceb08 | 2017-10-27 14:52:42 -0700 | [diff] [blame] | 15935 | disable_intrabss_fwd); |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 15936 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15937 | ret = -EINVAL; |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 15938 | |
| 15939 | ucfg_ipa_set_ap_ibss_fwd(hdd_ctx->hdd_pdev, |
| 15940 | adapter->session.ap. |
| 15941 | disable_intrabss_fwd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15942 | } |
| 15943 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 15944 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15945 | return ret; |
| 15946 | } |
| 15947 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 15948 | /** |
| 15949 | * wlan_hdd_change_client_iface_to_new_mode() - to change iface to provided mode |
| 15950 | * @ndev: pointer to net device provided by supplicant |
| 15951 | * @type: type of the interface, upper layer wanted to change |
| 15952 | * |
| 15953 | * Upper layer provides the new interface mode that needs to be changed |
| 15954 | * for given net device |
| 15955 | * |
| 15956 | * Return: success or failure in terms of integer value |
| 15957 | */ |
| 15958 | static int wlan_hdd_change_client_iface_to_new_mode(struct net_device *ndev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15959 | enum nl80211_iftype type) |
| 15960 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 15961 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 15962 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 15963 | struct hdd_config *config = hdd_ctx->config; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 15964 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15965 | struct wireless_dev *wdev; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 15966 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15967 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 15968 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15969 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 15970 | if (test_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 15971 | hdd_warn("ACS is in progress, don't change iface!"); |
Sandeep Puligilla | 1e6da36 | 2017-04-07 14:16:03 -0700 | [diff] [blame] | 15972 | return -EBUSY; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15973 | } |
| 15974 | |
| 15975 | wdev = ndev->ieee80211_ptr; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 15976 | hdd_stop_adapter(hdd_ctx, adapter); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 15977 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15978 | wdev->iftype = type; |
| 15979 | /*Check for sub-string p2p to confirm its a p2p interface */ |
| 15980 | if (NULL != strnstr(ndev->name, "p2p", 3)) { |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 15981 | adapter->device_mode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15982 | (type == NL80211_IFTYPE_STATION) ? |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 15983 | QDF_P2P_DEVICE_MODE : QDF_P2P_CLIENT_MODE; |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 15984 | } else if (type == NL80211_IFTYPE_ADHOC) { |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 15985 | adapter->device_mode = QDF_IBSS_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15986 | } else { |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 15987 | adapter->device_mode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15988 | (type == NL80211_IFTYPE_STATION) ? |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 15989 | QDF_STA_MODE : QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15990 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 15991 | memset(&adapter->session, 0, sizeof(adapter->session)); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 15992 | hdd_set_station_ops(adapter->dev); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 15993 | |
| 15994 | roam_profile = hdd_roam_profile(adapter); |
| 15995 | roam_profile->pAddIEScan = adapter->scan_info.scan_add_ie.addIEdata; |
| 15996 | roam_profile->nAddIEScanLength = |
Jeff Johnson | 37fa040 | 2017-10-28 12:42:29 -0700 | [diff] [blame] | 15997 | adapter->scan_info.scan_add_ie.length; |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 15998 | if (type == NL80211_IFTYPE_ADHOC) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 15999 | status = hdd_start_station_adapter(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16000 | roam_profile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 16001 | roam_profile->phyMode = |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 16002 | hdd_cfg_xlate_to_csr_phy_mode(config->dot11Mode); |
| 16003 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 16004 | hdd_exit(); |
Sandeep Puligilla | 1e6da36 | 2017-04-07 14:16:03 -0700 | [diff] [blame] | 16005 | |
| 16006 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16007 | } |
| 16008 | |
| 16009 | static int wlan_hdd_cfg80211_change_bss(struct wiphy *wiphy, |
| 16010 | struct net_device *dev, |
| 16011 | struct bss_parameters *params) |
| 16012 | { |
| 16013 | int ret; |
| 16014 | |
| 16015 | cds_ssr_protect(__func__); |
| 16016 | ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params); |
| 16017 | cds_ssr_unprotect(__func__); |
| 16018 | |
| 16019 | return ret; |
| 16020 | } |
| 16021 | |
Rajeev Kumar | 98edb77 | 2016-01-19 12:42:19 -0800 | [diff] [blame] | 16022 | /** |
| 16023 | * __wlan_hdd_cfg80211_change_iface() - change interface cfg80211 op |
| 16024 | * @wiphy: Pointer to the wiphy structure |
| 16025 | * @ndev: Pointer to the net device |
| 16026 | * @type: Interface type |
| 16027 | * @flags: Flags for change interface |
| 16028 | * @params: Pointer to change interface parameters |
| 16029 | * |
| 16030 | * Return: 0 for success, error number on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16031 | */ |
| 16032 | static int __wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy, |
| 16033 | struct net_device *ndev, |
| 16034 | enum nl80211_iftype type, |
| 16035 | u32 *flags, |
| 16036 | struct vif_params *params) |
| 16037 | { |
| 16038 | struct wireless_dev *wdev; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16039 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16040 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 16041 | struct csr_roam_profile *roam_profile = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16042 | eCsrRoamBssType LastBSSType; |
| 16043 | struct hdd_config *pConfig = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16044 | int status; |
| 16045 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 16046 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16047 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 16048 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 16049 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16050 | return -EINVAL; |
| 16051 | } |
| 16052 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16053 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16054 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 16055 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16056 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16057 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 16058 | if (cds_is_fw_down()) { |
| 16059 | hdd_err("Ignore if FW is already down"); |
| 16060 | return -EINVAL; |
| 16061 | } |
| 16062 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 16063 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16064 | TRACE_CODE_HDD_CFG80211_CHANGE_IFACE, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16065 | adapter->session_id, type)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16066 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16067 | hdd_debug("Device_mode = %d, IFTYPE = 0x%x", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16068 | adapter->device_mode, type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16069 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16070 | status = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 16071 | if (status) { |
| 16072 | hdd_err("Failed to start modules"); |
| 16073 | return -EINVAL; |
| 16074 | } |
| 16075 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16076 | if (!policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16077 | wlan_hdd_convert_nl_iftype_to_hdd_type(type), |
| 16078 | 0, HW_MODE_20_MHZ)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 16079 | hdd_debug("This concurrency combination is not allowed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16080 | return -EINVAL; |
| 16081 | } |
| 16082 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16083 | pConfig = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16084 | wdev = ndev->ieee80211_ptr; |
| 16085 | |
| 16086 | /* Reset the current device mode bit mask */ |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16087 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16088 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16089 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16090 | hdd_notify_teardown_tdls_links(adapter->hdd_vdev); |
| 16091 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 16092 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 16093 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 16094 | (adapter->device_mode == QDF_IBSS_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16095 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16096 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16097 | LastBSSType = roam_profile->BSSType; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16098 | |
| 16099 | switch (type) { |
| 16100 | case NL80211_IFTYPE_STATION: |
| 16101 | case NL80211_IFTYPE_P2P_CLIENT: |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 16102 | case NL80211_IFTYPE_ADHOC: |
| 16103 | if (type == NL80211_IFTYPE_ADHOC) { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16104 | hdd_deregister_tx_flow_control(adapter); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16105 | hdd_debug("Setting interface Type to ADHOC"); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 16106 | } |
Sandeep Puligilla | 1e6da36 | 2017-04-07 14:16:03 -0700 | [diff] [blame] | 16107 | status = wlan_hdd_change_client_iface_to_new_mode(ndev, |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 16108 | type); |
Sandeep Puligilla | 1e6da36 | 2017-04-07 14:16:03 -0700 | [diff] [blame] | 16109 | if (status) { |
| 16110 | hdd_err("Failed to change iface to new mode:%d status %d", |
| 16111 | type, status); |
| 16112 | return status; |
| 16113 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16114 | if (hdd_start_adapter(adapter)) { |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 16115 | hdd_err("Failed to start adapter :%d", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16116 | adapter->device_mode); |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 16117 | return -EINVAL; |
| 16118 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16119 | goto done; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16120 | case NL80211_IFTYPE_AP: |
| 16121 | case NL80211_IFTYPE_P2P_GO: |
| 16122 | { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16123 | hdd_debug("Setting interface Type to %s", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16124 | (type == |
| 16125 | NL80211_IFTYPE_AP) ? "SoftAP" : |
| 16126 | "P2pGo"); |
| 16127 | |
| 16128 | /* Cancel any remain on channel for GO mode */ |
| 16129 | if (NL80211_IFTYPE_P2P_GO == type) { |
| 16130 | wlan_hdd_cancel_existing_remain_on_channel |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16131 | (adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16132 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16133 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 16134 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16135 | /* De-init the adapter */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16136 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 16137 | memset(&adapter->session, 0, |
| 16138 | sizeof(adapter->session)); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16139 | adapter->device_mode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16140 | (type == |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 16141 | NL80211_IFTYPE_AP) ? QDF_SAP_MODE : |
| 16142 | QDF_P2P_GO_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16143 | |
| 16144 | /* |
| 16145 | * Fw will take care incase of concurrency |
| 16146 | */ |
| 16147 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16148 | if ((QDF_SAP_MODE == adapter->device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16149 | && (pConfig->apRandomBssidEnabled)) { |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 16150 | /* To meet Android requirements create |
| 16151 | * a randomized MAC address of the |
| 16152 | * form 02:1A:11:Fx:xx:xx |
| 16153 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16154 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 16155 | ndev->dev_addr[0] = 0x02; |
| 16156 | ndev->dev_addr[1] = 0x1A; |
| 16157 | ndev->dev_addr[2] = 0x11; |
| 16158 | ndev->dev_addr[3] |= 0xF0; |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 16159 | memcpy(adapter->mac_addr. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16160 | bytes, ndev->dev_addr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 16161 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16162 | pr_info("wlan: Generated HotSpot BSSID " |
| 16163 | MAC_ADDRESS_STR "\n", |
| 16164 | MAC_ADDR_ARRAY(ndev->dev_addr)); |
| 16165 | } |
| 16166 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16167 | hdd_set_ap_ops(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16168 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16169 | if (hdd_start_adapter(adapter)) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 16170 | hdd_err("Error initializing the ap mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16171 | return -EINVAL; |
| 16172 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16173 | /* Interface type changed update in wiphy structure */ |
| 16174 | if (wdev) { |
| 16175 | wdev->iftype = type; |
| 16176 | } else { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 16177 | hdd_err("Wireless dev is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16178 | return -EINVAL; |
| 16179 | } |
| 16180 | goto done; |
| 16181 | } |
| 16182 | |
| 16183 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16184 | hdd_err("Unsupported interface type: %d", type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16185 | return -EOPNOTSUPP; |
| 16186 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16187 | } else if ((adapter->device_mode == QDF_SAP_MODE) || |
| 16188 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16189 | switch (type) { |
| 16190 | case NL80211_IFTYPE_STATION: |
| 16191 | case NL80211_IFTYPE_P2P_CLIENT: |
| 16192 | case NL80211_IFTYPE_ADHOC: |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 16193 | status = wlan_hdd_change_client_iface_to_new_mode(ndev, |
| 16194 | type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 16195 | if (status != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16196 | return status; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16197 | if (hdd_start_adapter(adapter)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16198 | hdd_err("Failed to start adapter: %d", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16199 | adapter->device_mode); |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 16200 | return -EINVAL; |
| 16201 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16202 | goto done; |
| 16203 | |
| 16204 | case NL80211_IFTYPE_AP: |
| 16205 | case NL80211_IFTYPE_P2P_GO: |
| 16206 | wdev->iftype = type; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16207 | adapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 16208 | QDF_SAP_MODE : QDF_P2P_GO_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16209 | goto done; |
| 16210 | |
| 16211 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16212 | hdd_err("Unsupported interface type: %d", type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16213 | return -EOPNOTSUPP; |
| 16214 | } |
| 16215 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16216 | hdd_err("Unsupported device mode: %d", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16217 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16218 | return -EOPNOTSUPP; |
| 16219 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16220 | done: |
| 16221 | /* Set bitmask based on updated value */ |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16222 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16223 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16224 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16225 | hdd_lpass_notify_mode_change(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16226 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 16227 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16228 | return 0; |
| 16229 | } |
| 16230 | |
Dustin Brown | 9ed30a5 | 2017-08-16 13:59:38 -0700 | [diff] [blame] | 16231 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) |
Rajeev Kumar | 98edb77 | 2016-01-19 12:42:19 -0800 | [diff] [blame] | 16232 | /** |
| 16233 | * wlan_hdd_cfg80211_change_iface() - change interface cfg80211 op |
| 16234 | * @wiphy: Pointer to the wiphy structure |
| 16235 | * @ndev: Pointer to the net device |
| 16236 | * @type: Interface type |
| 16237 | * @flags: Flags for change interface |
| 16238 | * @params: Pointer to change interface parameters |
| 16239 | * |
| 16240 | * Return: 0 for success, error number on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16241 | */ |
| 16242 | static int wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy, |
| 16243 | struct net_device *ndev, |
| 16244 | enum nl80211_iftype type, |
| 16245 | u32 *flags, |
| 16246 | struct vif_params *params) |
| 16247 | { |
| 16248 | int ret; |
| 16249 | |
| 16250 | cds_ssr_protect(__func__); |
| 16251 | ret = |
| 16252 | __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params); |
| 16253 | cds_ssr_unprotect(__func__); |
| 16254 | |
| 16255 | return ret; |
| 16256 | } |
Dustin Brown | 9ed30a5 | 2017-08-16 13:59:38 -0700 | [diff] [blame] | 16257 | #else |
| 16258 | static int wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy, |
| 16259 | struct net_device *ndev, |
| 16260 | enum nl80211_iftype type, |
| 16261 | struct vif_params *params) |
| 16262 | { |
| 16263 | int ret; |
| 16264 | |
| 16265 | cds_ssr_protect(__func__); |
| 16266 | ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, |
| 16267 | ¶ms->flags, params); |
| 16268 | cds_ssr_unprotect(__func__); |
| 16269 | |
| 16270 | return ret; |
| 16271 | } |
| 16272 | #endif /* KERNEL_VERSION(4, 12, 0) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16273 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16274 | /** |
| 16275 | * __wlan_hdd_change_station() - change station |
| 16276 | * @wiphy: Pointer to the wiphy structure |
| 16277 | * @dev: Pointer to the net device. |
| 16278 | * @mac: bssid |
| 16279 | * @params: Pointer to station parameters |
| 16280 | * |
| 16281 | * Return: 0 for success, error number on failure. |
| 16282 | */ |
| 16283 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 16284 | static int __wlan_hdd_change_station(struct wiphy *wiphy, |
| 16285 | struct net_device *dev, |
| 16286 | const uint8_t *mac, |
| 16287 | struct station_parameters *params) |
| 16288 | #else |
| 16289 | static int __wlan_hdd_change_station(struct wiphy *wiphy, |
| 16290 | struct net_device *dev, |
| 16291 | uint8_t *mac, |
| 16292 | struct station_parameters *params) |
| 16293 | #endif |
| 16294 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 16295 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16296 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16297 | struct hdd_context *hdd_ctx; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16298 | struct hdd_station_ctx *sta_ctx; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 16299 | struct qdf_mac_addr STAMacAddress; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16300 | int ret; |
| 16301 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 16302 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16303 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 16304 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16305 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16306 | return -EINVAL; |
| 16307 | } |
| 16308 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 16309 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16310 | TRACE_CODE_HDD_CHANGE_STATION, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16311 | adapter->session_id, params->listen_interval)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16312 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16313 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 16314 | hdd_err("invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 16315 | return -EINVAL; |
| 16316 | } |
| 16317 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16318 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16319 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 16320 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16321 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16322 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16323 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16324 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16325 | qdf_mem_copy(STAMacAddress.bytes, mac, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16326 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16327 | if ((adapter->device_mode == QDF_SAP_MODE) || |
| 16328 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16329 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
| 16330 | status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16331 | hdd_softap_change_sta_state(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16332 | &STAMacAddress, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 16333 | OL_TXRX_PEER_STATE_AUTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16334 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 16335 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16336 | hdd_debug("Not able to change TL state to AUTHENTICATED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16337 | return -EINVAL; |
| 16338 | } |
| 16339 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16340 | } else if ((adapter->device_mode == QDF_STA_MODE) || |
| 16341 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16342 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Frank Liu | d1a2846 | 2017-09-06 22:55:48 +0800 | [diff] [blame] | 16343 | #if defined(FEATURE_WLAN_TDLS) |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16344 | ret = wlan_cfg80211_tdls_update_peer(hdd_ctx->hdd_pdev, |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 16345 | dev, mac, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16346 | #endif |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 16347 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16348 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 16349 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16350 | return ret; |
| 16351 | } |
| 16352 | |
| 16353 | /** |
| 16354 | * wlan_hdd_change_station() - cfg80211 change station handler function |
| 16355 | * @wiphy: Pointer to the wiphy structure |
| 16356 | * @dev: Pointer to the net device. |
| 16357 | * @mac: bssid |
| 16358 | * @params: Pointer to station parameters |
| 16359 | * |
| 16360 | * This is the cfg80211 change station handler function which invokes |
| 16361 | * the internal function @__wlan_hdd_change_station with |
| 16362 | * SSR protection. |
| 16363 | * |
| 16364 | * Return: 0 for success, error number on failure. |
| 16365 | */ |
| 16366 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) || defined(WITH_BACKPORTS) |
| 16367 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 16368 | struct net_device *dev, |
| 16369 | const u8 *mac, |
| 16370 | struct station_parameters *params) |
| 16371 | #else |
| 16372 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 16373 | struct net_device *dev, |
| 16374 | u8 *mac, |
| 16375 | struct station_parameters *params) |
| 16376 | #endif |
| 16377 | { |
| 16378 | int ret; |
| 16379 | |
| 16380 | cds_ssr_protect(__func__); |
| 16381 | ret = __wlan_hdd_change_station(wiphy, dev, mac, params); |
| 16382 | cds_ssr_unprotect(__func__); |
| 16383 | |
| 16384 | return ret; |
| 16385 | } |
| 16386 | |
| 16387 | /* |
| 16388 | * FUNCTION: __wlan_hdd_cfg80211_add_key |
| 16389 | * This function is used to initialize the key information |
| 16390 | */ |
| 16391 | static int __wlan_hdd_cfg80211_add_key(struct wiphy *wiphy, |
| 16392 | struct net_device *ndev, |
| 16393 | u8 key_index, bool pairwise, |
| 16394 | const u8 *mac_addr, |
| 16395 | struct key_params *params) |
| 16396 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16397 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16398 | tCsrRoamSetKey setKey; |
| 16399 | int status; |
Krunal Soni | bfd0549 | 2017-10-03 15:48:37 -0700 | [diff] [blame] | 16400 | uint32_t roamId = INVALID_ROAM_ID; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 16401 | QDF_STATUS qdf_ret_status; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16402 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16403 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 16404 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16405 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 16406 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16407 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16408 | return -EINVAL; |
| 16409 | } |
| 16410 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16411 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 16412 | hdd_err("Invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 16413 | return -EINVAL; |
| 16414 | } |
| 16415 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 16416 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16417 | TRACE_CODE_HDD_CFG80211_ADD_KEY, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16418 | adapter->session_id, params->key_len)); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16419 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16420 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16421 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 16422 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16423 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16424 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16425 | hdd_debug("Device_mode %s(%d)", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16426 | hdd_device_mode_to_string(adapter->device_mode), |
| 16427 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16428 | |
| 16429 | if (CSR_MAX_NUM_KEY <= key_index) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16430 | hdd_err("Invalid key index %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16431 | |
| 16432 | return -EINVAL; |
| 16433 | } |
| 16434 | |
| 16435 | if (CSR_MAX_KEY_LEN < params->key_len) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16436 | hdd_err("Invalid key length %d", params->key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16437 | |
| 16438 | return -EINVAL; |
| 16439 | } |
| 16440 | |
Jeff Johnson | b05f4fd | 2017-10-18 15:08:21 -0700 | [diff] [blame] | 16441 | if (CSR_MAX_RSC_LEN < params->seq_len) { |
| 16442 | hdd_err("Invalid seq length %d", params->seq_len); |
| 16443 | |
| 16444 | return -EINVAL; |
| 16445 | } |
| 16446 | |
| 16447 | hdd_debug("key index %d, key length %d, seq length %d", |
| 16448 | key_index, params->key_len, params->seq_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16449 | |
| 16450 | /*extract key idx, key len and key */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16451 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16452 | setKey.keyId = key_index; |
| 16453 | setKey.keyLength = params->key_len; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16454 | qdf_mem_copy(&setKey.Key[0], params->key, params->key_len); |
Jeff Johnson | b05f4fd | 2017-10-18 15:08:21 -0700 | [diff] [blame] | 16455 | qdf_mem_copy(&setKey.keyRsc[0], params->seq, params->seq_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16456 | |
| 16457 | switch (params->cipher) { |
| 16458 | case WLAN_CIPHER_SUITE_WEP40: |
| 16459 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 16460 | break; |
| 16461 | |
| 16462 | case WLAN_CIPHER_SUITE_WEP104: |
| 16463 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 16464 | break; |
| 16465 | |
| 16466 | case WLAN_CIPHER_SUITE_TKIP: |
| 16467 | { |
| 16468 | u8 *pKey = &setKey.Key[0]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16469 | |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 16470 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16471 | qdf_mem_zero(pKey, CSR_MAX_KEY_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16472 | |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 16473 | /* Supplicant sends the 32bytes key in this order |
| 16474 | * |
| 16475 | * |--------------|----------|----------| |
| 16476 | * | Tk1 |TX-MIC | RX Mic | |
| 16477 | * |--------------|----------|----------| |
| 16478 | * <---16bytes---><--8bytes--><--8bytes--> |
| 16479 | * |
| 16480 | * Sme expects the 32 bytes key to be in the below order |
| 16481 | * |
| 16482 | * |--------------|----------|----------| |
| 16483 | * | Tk1 |RX-MIC | TX Mic | |
| 16484 | * |--------------|----------|----------| |
| 16485 | * <---16bytes---><--8bytes--><--8bytes--> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16486 | */ |
| 16487 | /* Copy the Temporal Key 1 (TK1) */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16488 | qdf_mem_copy(pKey, params->key, 16); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16489 | |
| 16490 | /*Copy the rx mic first */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16491 | qdf_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16492 | |
| 16493 | /*Copy the tx mic */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16494 | qdf_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16495 | |
| 16496 | break; |
| 16497 | } |
| 16498 | |
| 16499 | case WLAN_CIPHER_SUITE_CCMP: |
| 16500 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 16501 | break; |
| 16502 | |
| 16503 | #ifdef FEATURE_WLAN_WAPI |
| 16504 | case WLAN_CIPHER_SUITE_SMS4: |
| 16505 | { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16506 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16507 | wlan_hdd_cfg80211_set_key_wapi(adapter, key_index, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16508 | mac_addr, params->key, |
| 16509 | params->key_len); |
| 16510 | return 0; |
| 16511 | } |
| 16512 | #endif |
| 16513 | |
| 16514 | #ifdef FEATURE_WLAN_ESE |
| 16515 | case WLAN_CIPHER_SUITE_KRK: |
| 16516 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 16517 | break; |
| 16518 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 16519 | case WLAN_CIPHER_SUITE_BTK: |
| 16520 | setKey.encType = eCSR_ENCRYPT_TYPE_BTK; |
| 16521 | break; |
| 16522 | #endif |
| 16523 | #endif |
| 16524 | |
| 16525 | #ifdef WLAN_FEATURE_11W |
| 16526 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 16527 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
| 16528 | break; |
Padma, Santhosh Kumar | 4117d7a | 2017-12-20 17:39:33 +0530 | [diff] [blame] | 16529 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) |
| 16530 | case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
| 16531 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_GMAC_128; |
| 16532 | break; |
| 16533 | case WLAN_CIPHER_SUITE_BIP_GMAC_256: |
| 16534 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_GMAC_256; |
| 16535 | break; |
| 16536 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16537 | #endif |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 16538 | case WLAN_CIPHER_SUITE_GCMP: |
| 16539 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_GCMP; |
| 16540 | break; |
| 16541 | case WLAN_CIPHER_SUITE_GCMP_256: |
| 16542 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_GCMP_256; |
| 16543 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16544 | |
| 16545 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16546 | hdd_err("Unsupported cipher type: %u", params->cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16547 | return -EOPNOTSUPP; |
| 16548 | } |
| 16549 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16550 | hdd_debug("encryption type %d", setKey.encType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16551 | |
| 16552 | if (!pairwise) { |
| 16553 | /* set group key */ |
Jeff Johnson | 96aa2ac | 2017-10-18 15:55:36 -0700 | [diff] [blame] | 16554 | hdd_debug("setting Broadcast key"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16555 | setKey.keyDirection = eSIR_RX_ONLY; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 16556 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16557 | } else { |
| 16558 | /* set pairwise key */ |
Jeff Johnson | 96aa2ac | 2017-10-18 15:55:36 -0700 | [diff] [blame] | 16559 | hdd_debug("setting pairwise key"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16560 | setKey.keyDirection = eSIR_TX_RX; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16561 | qdf_mem_copy(setKey.peerMac.bytes, mac_addr, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16562 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16563 | if ((QDF_IBSS_MODE == adapter->device_mode) && !pairwise) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16564 | /* if a key is already installed, block all subsequent ones */ |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 16565 | if (adapter->session.station.ibss_enc_key_installed) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16566 | hdd_debug("IBSS key installed already"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16567 | return 0; |
| 16568 | } |
| 16569 | |
| 16570 | setKey.keyDirection = eSIR_TX_RX; |
| 16571 | /*Set the group key */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16572 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16573 | adapter->session_id, &setKey, &roamId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16574 | |
| 16575 | if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16576 | hdd_err("sme_roam_set_key failed, status: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16577 | return -EINVAL; |
| 16578 | } |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 16579 | /* Save the keys here and call sme_roam_set_key for setting |
| 16580 | * the PTK after peer joins the IBSS network |
| 16581 | */ |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 16582 | qdf_mem_copy(&adapter->session.station.ibss_enc_key, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16583 | &setKey, sizeof(tCsrRoamSetKey)); |
| 16584 | |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 16585 | adapter->session.station.ibss_enc_key_installed = 1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16586 | return status; |
| 16587 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16588 | if ((adapter->device_mode == QDF_SAP_MODE) || |
| 16589 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 16590 | struct hdd_hostapd_state *hostapd_state = |
| 16591 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
| 16592 | struct hdd_ap_ctx *ap_ctx = |
| 16593 | WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 16594 | |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 16595 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 6ba30a1 | 2016-09-13 13:59:43 -0700 | [diff] [blame] | 16596 | status = wlansap_set_key_sta( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16597 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), &setKey); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 16598 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16599 | hdd_err("wlansap_set_key_sta failed status: %d", |
| 16600 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16601 | } |
| 16602 | } |
| 16603 | |
Jeff Johnson | 413c15f | 2017-10-27 18:56:35 -0700 | [diff] [blame] | 16604 | /* 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] | 16605 | if (pairwise || |
| 16606 | eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 16607 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType) |
Jeff Johnson | 3d73136 | 2017-10-27 19:06:41 -0700 | [diff] [blame] | 16608 | qdf_mem_copy(&ap_ctx->wep_key[key_index], &setKey, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16609 | sizeof(tCsrRoamSetKey)); |
| 16610 | else |
Jeff Johnson | 413c15f | 2017-10-27 18:56:35 -0700 | [diff] [blame] | 16611 | qdf_mem_copy(&ap_ctx->group_key, &setKey, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16612 | sizeof(tCsrRoamSetKey)); |
| 16613 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16614 | } else if ((adapter->device_mode == QDF_STA_MODE) || |
| 16615 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16616 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16617 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16618 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16619 | |
| 16620 | if (!pairwise) { |
| 16621 | /* set group key */ |
Jeff Johnson | af2ae4b | 2017-11-01 11:38:50 -0700 | [diff] [blame] | 16622 | if (sta_ctx->roam_info.defer_key_complete) { |
Jeff Johnson | 96aa2ac | 2017-10-18 15:55:36 -0700 | [diff] [blame] | 16623 | hdd_debug("Perform Set key Complete"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16624 | hdd_perform_roam_set_key_complete(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16625 | } |
| 16626 | } |
| 16627 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16628 | roam_profile = hdd_roam_profile(adapter); |
| 16629 | roam_profile->Keys.KeyLength[key_index] = params->key_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16630 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16631 | roam_profile->Keys.defaultIndex = key_index; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16632 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16633 | qdf_mem_copy(&roam_profile->Keys.KeyMaterial[key_index][0], |
| 16634 | params->key, params->key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16635 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16636 | hdd_debug("Set key for peerMac "MAC_ADDRESS_STR" direction %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16637 | MAC_ADDR_ARRAY(setKey.peerMac.bytes), |
| 16638 | setKey.keyDirection); |
| 16639 | |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 16640 | /* The supplicant may attempt to set the PTK once |
| 16641 | * pre-authentication is done. Save the key in the |
| 16642 | * UMAC and include it in the ADD BSS request |
| 16643 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16644 | qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16645 | adapter->session_id, &setKey); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 16646 | if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16647 | hdd_debug("Update PreAuth Key success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16648 | return 0; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 16649 | } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16650 | hdd_err("Update PreAuth Key failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16651 | return -EINVAL; |
| 16652 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16653 | |
| 16654 | /* issue set key request to SME */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16655 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16656 | adapter->session_id, &setKey, &roamId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16657 | |
| 16658 | if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16659 | hdd_err("sme_roam_set_key failed, status: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16660 | return -EINVAL; |
| 16661 | } |
| 16662 | |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 16663 | /* in case of IBSS as there was no information |
| 16664 | * available about WEP keys during IBSS join, group |
| 16665 | * key intialized with NULL key, so re-initialize |
| 16666 | * group key with correct value |
| 16667 | */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16668 | if ((eCSR_BSS_TYPE_START_IBSS == roam_profile->BSSType) && |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 16669 | !((HDD_AUTH_KEY_MGMT_802_1X == |
| 16670 | (sta_ctx->auth_key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16671 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16672 | sta_ctx->conn_info.authType) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16673 | ) |
| 16674 | && ((WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 16675 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 16676 | ) |
| 16677 | ) { |
| 16678 | setKey.keyDirection = eSIR_RX_ONLY; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 16679 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16680 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16681 | hdd_debug("Set key peerMac "MAC_ADDRESS_STR" direction %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16682 | MAC_ADDR_ARRAY(setKey.peerMac.bytes), |
| 16683 | setKey.keyDirection); |
| 16684 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16685 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16686 | adapter->session_id, &setKey, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16687 | &roamId); |
| 16688 | |
| 16689 | if (0 != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16690 | hdd_err("sme_roam_set_key failed for group key (IBSS), returned %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16691 | return -EINVAL; |
| 16692 | } |
| 16693 | } |
| 16694 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 16695 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16696 | return 0; |
| 16697 | } |
| 16698 | |
| 16699 | static int wlan_hdd_cfg80211_add_key(struct wiphy *wiphy, |
| 16700 | struct net_device *ndev, |
| 16701 | u8 key_index, bool pairwise, |
| 16702 | const u8 *mac_addr, |
| 16703 | struct key_params *params) |
| 16704 | { |
| 16705 | int ret; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 16706 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16707 | cds_ssr_protect(__func__); |
| 16708 | ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise, |
| 16709 | mac_addr, params); |
| 16710 | cds_ssr_unprotect(__func__); |
| 16711 | |
| 16712 | return ret; |
| 16713 | } |
| 16714 | |
| 16715 | /* |
| 16716 | * FUNCTION: __wlan_hdd_cfg80211_get_key |
| 16717 | * This function is used to get the key information |
| 16718 | */ |
| 16719 | static int __wlan_hdd_cfg80211_get_key(struct wiphy *wiphy, |
| 16720 | struct net_device *ndev, |
| 16721 | u8 key_index, bool pairwise, |
| 16722 | const u8 *mac_addr, void *cookie, |
| 16723 | void (*callback)(void *cookie, |
| 16724 | struct key_params *) |
| 16725 | ) |
| 16726 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16727 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 16728 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16729 | struct key_params params; |
| 16730 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 16731 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16732 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 16733 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16734 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16735 | return -EINVAL; |
| 16736 | } |
| 16737 | |
Jiachao Wu | d58cfc9 | 2017-12-27 14:15:23 +0800 | [diff] [blame] | 16738 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 16739 | hdd_err("Invalid session id: %d", adapter->session_id); |
| 16740 | return -EINVAL; |
| 16741 | } |
| 16742 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16743 | hdd_debug("Device_mode %s(%d)", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16744 | hdd_device_mode_to_string(adapter->device_mode), |
| 16745 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16746 | |
| 16747 | memset(¶ms, 0, sizeof(params)); |
| 16748 | |
| 16749 | if (CSR_MAX_NUM_KEY <= key_index) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16750 | hdd_err("Invalid key index: %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16751 | return -EINVAL; |
| 16752 | } |
| 16753 | |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 16754 | if ((adapter->device_mode == QDF_SAP_MODE) || |
| 16755 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
| 16756 | struct hdd_ap_ctx *ap_ctx = |
| 16757 | WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16758 | |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 16759 | roam_profile = |
| 16760 | wlan_sap_get_roam_profile(ap_ctx->sap_context); |
| 16761 | } else { |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16762 | roam_profile = hdd_roam_profile(adapter); |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 16763 | } |
| 16764 | |
Jiachao Wu | d58cfc9 | 2017-12-27 14:15:23 +0800 | [diff] [blame] | 16765 | if (roam_profile == NULL) { |
| 16766 | hdd_err("Get roam profile failed!"); |
| 16767 | return -EINVAL; |
| 16768 | } |
| 16769 | |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16770 | switch (roam_profile->EncryptionType.encryptionType[0]) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16771 | case eCSR_ENCRYPT_TYPE_NONE: |
| 16772 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 16773 | break; |
| 16774 | |
| 16775 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 16776 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 16777 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 16778 | break; |
| 16779 | |
| 16780 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 16781 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 16782 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 16783 | break; |
| 16784 | |
| 16785 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 16786 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 16787 | break; |
| 16788 | |
| 16789 | case eCSR_ENCRYPT_TYPE_AES: |
| 16790 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 16791 | break; |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 16792 | case eCSR_ENCRYPT_TYPE_AES_GCMP: |
| 16793 | params.cipher = WLAN_CIPHER_SUITE_GCMP; |
| 16794 | break; |
| 16795 | case eCSR_ENCRYPT_TYPE_AES_GCMP_256: |
| 16796 | params.cipher = WLAN_CIPHER_SUITE_GCMP_256; |
| 16797 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16798 | default: |
| 16799 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 16800 | break; |
| 16801 | } |
| 16802 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 16803 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16804 | TRACE_CODE_HDD_CFG80211_GET_KEY, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16805 | adapter->session_id, params.cipher)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16806 | |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16807 | params.key_len = roam_profile->Keys.KeyLength[key_index]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16808 | params.seq_len = 0; |
| 16809 | params.seq = NULL; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 16810 | params.key = &roam_profile->Keys.KeyMaterial[key_index][0]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16811 | callback(cookie, ¶ms); |
| 16812 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 16813 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16814 | return 0; |
| 16815 | } |
| 16816 | |
| 16817 | static int wlan_hdd_cfg80211_get_key(struct wiphy *wiphy, |
| 16818 | struct net_device *ndev, |
| 16819 | u8 key_index, bool pairwise, |
| 16820 | const u8 *mac_addr, void *cookie, |
| 16821 | void (*callback)(void *cookie, |
| 16822 | struct key_params *) |
| 16823 | ) |
| 16824 | { |
| 16825 | int ret; |
| 16826 | |
| 16827 | cds_ssr_protect(__func__); |
| 16828 | ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise, |
| 16829 | mac_addr, cookie, callback); |
| 16830 | cds_ssr_unprotect(__func__); |
| 16831 | |
| 16832 | return ret; |
| 16833 | } |
| 16834 | |
| 16835 | /** |
| 16836 | * __wlan_hdd_cfg80211_del_key() - Delete the encryption key for station |
| 16837 | * @wiphy: wiphy interface context |
| 16838 | * @ndev: pointer to net device |
| 16839 | * @key_index: Key index used in 802.11 frames |
| 16840 | * @unicast: true if it is unicast key |
| 16841 | * @multicast: true if it is multicast key |
| 16842 | * |
| 16843 | * This function is required for cfg80211_ops API. |
| 16844 | * It is used to delete the key information |
| 16845 | * Underlying hardware implementation does not have API to delete the |
| 16846 | * encryption key. It is automatically deleted when the peer is |
| 16847 | * removed. Hence this function currently does nothing. |
| 16848 | * Future implementation may interprete delete key operation to |
| 16849 | * replacing the key with a random junk value, effectively making it |
| 16850 | * useless. |
| 16851 | * |
| 16852 | * Return: status code, always 0. |
| 16853 | */ |
| 16854 | |
| 16855 | static int __wlan_hdd_cfg80211_del_key(struct wiphy *wiphy, |
| 16856 | struct net_device *ndev, |
| 16857 | u8 key_index, |
| 16858 | bool pairwise, const u8 *mac_addr) |
| 16859 | { |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 16860 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16861 | return 0; |
| 16862 | } |
| 16863 | |
| 16864 | /** |
| 16865 | * wlan_hdd_cfg80211_del_key() - cfg80211 delete key handler function |
| 16866 | * @wiphy: Pointer to wiphy structure. |
| 16867 | * @dev: Pointer to net_device structure. |
| 16868 | * @key_index: key index |
| 16869 | * @pairwise: pairwise |
| 16870 | * @mac_addr: mac address |
| 16871 | * |
| 16872 | * This is the cfg80211 delete key handler function which invokes |
| 16873 | * the internal function @__wlan_hdd_cfg80211_del_key with |
| 16874 | * SSR protection. |
| 16875 | * |
| 16876 | * Return: 0 for success, error number on failure. |
| 16877 | */ |
| 16878 | static int wlan_hdd_cfg80211_del_key(struct wiphy *wiphy, |
| 16879 | struct net_device *dev, |
| 16880 | u8 key_index, |
| 16881 | bool pairwise, const u8 *mac_addr) |
| 16882 | { |
| 16883 | int ret; |
| 16884 | |
| 16885 | cds_ssr_protect(__func__); |
| 16886 | ret = __wlan_hdd_cfg80211_del_key(wiphy, dev, key_index, |
| 16887 | pairwise, mac_addr); |
| 16888 | cds_ssr_unprotect(__func__); |
| 16889 | |
| 16890 | return ret; |
| 16891 | } |
| 16892 | |
Hu Wang | c314884 | 2017-06-20 19:03:29 +0800 | [diff] [blame] | 16893 | #ifdef FEATURE_WLAN_WAPI |
| 16894 | static bool hdd_is_wapi_enc_type(eCsrEncryptionType ucEncryptionType) |
| 16895 | { |
| 16896 | if (ucEncryptionType == eCSR_ENCRYPT_TYPE_WPI) |
| 16897 | return true; |
| 16898 | |
| 16899 | return false; |
| 16900 | } |
| 16901 | #else |
| 16902 | static bool hdd_is_wapi_enc_type(eCsrEncryptionType ucEncryptionType) |
| 16903 | { |
| 16904 | return false; |
| 16905 | } |
| 16906 | #endif |
| 16907 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16908 | /* |
| 16909 | * FUNCTION: __wlan_hdd_cfg80211_set_default_key |
| 16910 | * This function is used to set the default tx key index |
| 16911 | */ |
| 16912 | static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, |
| 16913 | struct net_device *ndev, |
| 16914 | u8 key_index, |
| 16915 | bool unicast, bool multicast) |
| 16916 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16917 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16918 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16919 | int status; |
| 16920 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 16921 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16922 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 16923 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 16924 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16925 | return -EINVAL; |
| 16926 | } |
| 16927 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16928 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 16929 | hdd_err("Invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 16930 | return -EINVAL; |
| 16931 | } |
| 16932 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 16933 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16934 | TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 16935 | adapter->session_id, key_index)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16936 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16937 | hdd_debug("Device_mode %s(%d) key_index = %d", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16938 | hdd_device_mode_to_string(adapter->device_mode), |
| 16939 | adapter->device_mode, key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16940 | |
| 16941 | if (CSR_MAX_NUM_KEY <= key_index) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16942 | hdd_err("Invalid key index: %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16943 | return -EINVAL; |
| 16944 | } |
| 16945 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16946 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 16947 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16948 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 16949 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16950 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16951 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 16952 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 16953 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 16954 | struct hdd_station_ctx *sta_ctx = |
| 16955 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16956 | struct csr_roam_profile *roam_profile; |
| 16957 | |
| 16958 | roam_profile = hdd_roam_profile(adapter); |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 16959 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16960 | if ((eCSR_ENCRYPT_TYPE_TKIP != |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16961 | sta_ctx->conn_info.ucEncryptionType) && |
Hu Wang | c314884 | 2017-06-20 19:03:29 +0800 | [diff] [blame] | 16962 | !hdd_is_wapi_enc_type( |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16963 | sta_ctx->conn_info.ucEncryptionType) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16964 | (eCSR_ENCRYPT_TYPE_AES != |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16965 | sta_ctx->conn_info.ucEncryptionType) && |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 16966 | (eCSR_ENCRYPT_TYPE_AES_GCMP != |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16967 | sta_ctx->conn_info.ucEncryptionType) && |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 16968 | (eCSR_ENCRYPT_TYPE_AES_GCMP_256 != |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16969 | sta_ctx->conn_info.ucEncryptionType)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16970 | /* If default key index is not same as previous one, |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 16971 | * then update the default key index |
| 16972 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16973 | |
| 16974 | tCsrRoamSetKey setKey; |
Krunal Soni | bfd0549 | 2017-10-03 15:48:37 -0700 | [diff] [blame] | 16975 | uint32_t roamId = INVALID_ROAM_ID; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16976 | tCsrKeys *Keys = &roam_profile->Keys; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16977 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 16978 | hdd_debug("Default tx key index %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16979 | |
| 16980 | Keys->defaultIndex = (u8) key_index; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16981 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16982 | setKey.keyId = key_index; |
| 16983 | setKey.keyLength = Keys->KeyLength[key_index]; |
| 16984 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 16985 | qdf_mem_copy(&setKey.Key[0], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16986 | &Keys->KeyMaterial[key_index][0], |
| 16987 | Keys->KeyLength[key_index]); |
| 16988 | |
| 16989 | setKey.keyDirection = eSIR_TX_RX; |
| 16990 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 16991 | qdf_copy_macaddr(&setKey.peerMac, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 16992 | &sta_ctx->conn_info.bssId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16993 | |
| 16994 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 16995 | roam_profile->EncryptionType. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 16996 | encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP104) { |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 16997 | /* In the case of dynamic wep |
| 16998 | * supplicant hardcodes DWEP type to |
| 16999 | * eCSR_ENCRYPT_TYPE_WEP104 even |
| 17000 | * though ap is configured for WEP-40 |
| 17001 | * encryption. In this canse the key |
| 17002 | * length is 5 but the encryption type |
| 17003 | * is 104 hence checking the key |
| 17004 | * lenght(5) and encryption type(104) |
| 17005 | * and switching encryption type to 40 |
| 17006 | */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17007 | roam_profile->EncryptionType. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17008 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17009 | roam_profile->mcEncryptionType. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17010 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WEP40; |
| 17011 | } |
| 17012 | |
| 17013 | setKey.encType = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17014 | roam_profile->EncryptionType. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17015 | encryptionType[0]; |
| 17016 | |
| 17017 | /* Issue set key request */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17018 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 17019 | adapter->session_id, &setKey, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17020 | &roamId); |
| 17021 | |
| 17022 | if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17023 | hdd_err("sme_roam_set_key failed, status: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17024 | status); |
| 17025 | return -EINVAL; |
| 17026 | } |
| 17027 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17028 | } else if (QDF_SAP_MODE == adapter->device_mode) { |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 17029 | struct hdd_ap_ctx *ap_ctx = |
| 17030 | WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 17031 | struct csr_roam_profile *profile = |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 17032 | wlan_sap_get_roam_profile(ap_ctx->sap_context); |
| 17033 | |
| 17034 | if (!profile) { |
| 17035 | hdd_err("Failed to get SAP Roam Profile"); |
| 17036 | return -EINVAL; |
| 17037 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17038 | /* In SoftAp mode setting key direction for default mode */ |
| 17039 | if ((eCSR_ENCRYPT_TYPE_TKIP != |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 17040 | profile->EncryptionType.encryptionType[0]) && |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 17041 | (eCSR_ENCRYPT_TYPE_AES != |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 17042 | profile->EncryptionType.encryptionType[0]) && |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 17043 | (eCSR_ENCRYPT_TYPE_AES_GCMP != |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 17044 | profile->EncryptionType.encryptionType[0]) && |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 17045 | (eCSR_ENCRYPT_TYPE_AES_GCMP_256 != |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 17046 | profile->EncryptionType.encryptionType[0])) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17047 | /* Saving key direction for default key index to TX default */ |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 17048 | ap_ctx->wep_key[key_index].keyDirection = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17049 | eSIR_TX_DEFAULT; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17050 | hdd_debug("WEP default key index set to SAP context %d", |
Masti, Narayanraddi | ab712a7 | 2016-08-04 11:59:11 +0530 | [diff] [blame] | 17051 | key_index); |
Nachiket Kukade | d915283 | 2017-10-16 16:18:22 +0530 | [diff] [blame] | 17052 | ap_ctx->wep_def_key_idx = key_index; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17053 | } |
| 17054 | } |
| 17055 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 17056 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17057 | return status; |
| 17058 | } |
| 17059 | |
| 17060 | static int wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, |
| 17061 | struct net_device *ndev, |
| 17062 | u8 key_index, |
| 17063 | bool unicast, bool multicast) |
| 17064 | { |
| 17065 | int ret; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 17066 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17067 | cds_ssr_protect(__func__); |
| 17068 | ret = |
| 17069 | __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast, |
| 17070 | multicast); |
| 17071 | cds_ssr_unprotect(__func__); |
| 17072 | |
| 17073 | return ret; |
| 17074 | } |
| 17075 | |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 17076 | /* |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 17077 | * wlan_hdd_cfg80211_update_bss_list :to inform nl80211 |
| 17078 | * interface that BSS might have been lost. |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17079 | * @adapter: adaptor |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 17080 | * @bssid: bssid which might have been lost |
| 17081 | * |
| 17082 | * Return: bss which is unlinked from kernel cache |
| 17083 | */ |
| 17084 | struct cfg80211_bss *wlan_hdd_cfg80211_update_bss_list( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17085 | struct hdd_adapter *adapter, tSirMacAddr bssid) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17086 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17087 | struct net_device *dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17088 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 17089 | struct wiphy *wiphy = wdev->wiphy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17090 | struct cfg80211_bss *bss = NULL; |
| 17091 | |
Abhishek Singh | b5e38ef | 2017-01-02 12:09:34 +0530 | [diff] [blame] | 17092 | bss = hdd_cfg80211_get_bss(wiphy, NULL, bssid, |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 17093 | NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17094 | if (bss == NULL) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 17095 | hdd_err("BSS not present"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17096 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17097 | hdd_debug("cfg80211_unlink_bss called for BSSID " |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 17098 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(bssid)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17099 | cfg80211_unlink_bss(wiphy, bss); |
| 17100 | } |
| 17101 | return bss; |
| 17102 | } |
| 17103 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17104 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17105 | static inline int |
| 17106 | wlan_hdd_get_frame_len(struct bss_description *bss_desc) |
| 17107 | { |
| 17108 | return GET_IE_LEN_IN_BSS(bss_desc->length) + sizeof(qcom_ie_age); |
| 17109 | } |
| 17110 | |
| 17111 | static inline void wlan_hdd_add_age_ie(struct ieee80211_mgmt *mgmt, |
Abhishek Singh | f1c1676 | 2018-03-07 10:48:46 +0530 | [diff] [blame] | 17112 | uint32_t *ie_length, struct bss_description *bss_desc) |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17113 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17114 | qcom_ie_age *qie_age = NULL; |
Nachiket Kukade | 348ede7 | 2017-04-28 16:34:24 +0530 | [diff] [blame] | 17115 | |
| 17116 | /* |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17117 | * GPS Requirement: need age ie per entry. Using vendor specific. |
| 17118 | * Assuming this is the last IE, copy at the end |
Nachiket Kukade | 348ede7 | 2017-04-28 16:34:24 +0530 | [diff] [blame] | 17119 | */ |
Abhishek Singh | f1c1676 | 2018-03-07 10:48:46 +0530 | [diff] [blame] | 17120 | *ie_length -= sizeof(qcom_ie_age); |
| 17121 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + *ie_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17122 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 17123 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 17124 | qie_age->oui_1 = QCOM_OUI1; |
| 17125 | qie_age->oui_2 = QCOM_OUI2; |
| 17126 | qie_age->oui_3 = QCOM_OUI3; |
| 17127 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
Deepthi Gowri | 6acee34 | 2016-10-28 15:00:38 +0530 | [diff] [blame] | 17128 | /* |
| 17129 | * Lowi expects the timestamp of bss in units of 1/10 ms. In driver |
| 17130 | * all bss related timestamp is in units of ms. Due to this when scan |
| 17131 | * results are sent to lowi the scan age is high.To address this, |
| 17132 | * send age in units of 1/10 ms. |
| 17133 | */ |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17134 | qie_age->age = (uint32_t)(qdf_mc_timer_get_system_time() - |
| 17135 | bss_desc->received_time)/10; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17136 | qie_age->tsf_delta = bss_desc->tsf_delta; |
Krishna Kumaar Natarajan | a4e1224 | 2016-04-01 18:44:39 -0700 | [diff] [blame] | 17137 | memcpy(&qie_age->beacon_tsf, bss_desc->timeStamp, |
| 17138 | sizeof(qie_age->beacon_tsf)); |
Krishna Kumaar Natarajan | 89a99d4 | 2016-08-04 15:44:38 -0700 | [diff] [blame] | 17139 | memcpy(&qie_age->seq_ctrl, &bss_desc->seq_ctrl, |
| 17140 | sizeof(qie_age->seq_ctrl)); |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17141 | } |
| 17142 | #else |
| 17143 | static inline int |
| 17144 | wlan_hdd_get_frame_len(struct bss_description *bss_desc) |
| 17145 | { |
| 17146 | return GET_IE_LEN_IN_BSS(bss_desc->length); |
| 17147 | } |
| 17148 | static inline void wlan_hdd_add_age_ie(struct ieee80211_mgmt *mgmt, |
Abhishek Singh | f1c1676 | 2018-03-07 10:48:46 +0530 | [diff] [blame] | 17149 | uint32_t *ie_length, struct bss_description *bss_desc) |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17150 | { |
| 17151 | } |
| 17152 | #endif /* WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17153 | |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17154 | |
| 17155 | struct cfg80211_bss * |
| 17156 | wlan_hdd_inform_bss_frame(struct hdd_adapter *adapter, |
| 17157 | struct bss_description *bss_desc) |
| 17158 | { |
| 17159 | struct wireless_dev *wdev = adapter->dev->ieee80211_ptr; |
| 17160 | struct wiphy *wiphy = wdev->wiphy; |
Abhishek Singh | f1c1676 | 2018-03-07 10:48:46 +0530 | [diff] [blame] | 17161 | uint32_t ie_length = wlan_hdd_get_frame_len(bss_desc); |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17162 | const char *ie = |
| 17163 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields : NULL); |
| 17164 | uint32_t freq, i; |
| 17165 | struct cfg80211_bss *bss_status = NULL; |
| 17166 | struct hdd_context *hdd_ctx; |
| 17167 | struct timespec ts; |
| 17168 | struct hdd_config *cfg_param; |
| 17169 | struct wlan_cfg80211_inform_bss bss_data = {0}; |
| 17170 | |
| 17171 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 17172 | /* |
| 17173 | * wlan_hdd_validate_context should not be used here, In validate ctx |
| 17174 | * start_modules_in_progress or stop_modules_in_progress is validated, |
| 17175 | * If the start_modules_in_progress is set to true means the interface |
| 17176 | * is not UP yet if the stop_modules_in_progress means that interface |
| 17177 | * is already down. So in both the two scenario's driver should not be |
| 17178 | * informing bss to kernel. Hence removing the validate context. |
| 17179 | */ |
| 17180 | |
| 17181 | if (!hdd_ctx || !hdd_ctx->config) { |
| 17182 | hdd_debug("HDD context is Null"); |
| 17183 | return NULL; |
| 17184 | } |
| 17185 | |
| 17186 | if (cds_is_driver_recovering() || |
| 17187 | cds_is_load_or_unload_in_progress()) { |
| 17188 | hdd_debug("Recovery or load/unload in progress. State: 0x%x", |
| 17189 | cds_get_driver_state()); |
| 17190 | return NULL; |
| 17191 | } |
| 17192 | |
| 17193 | cfg_param = hdd_ctx->config; |
| 17194 | bss_data.frame_len = ie_length + offsetof(struct ieee80211_mgmt, |
| 17195 | u.probe_resp.variable); |
| 17196 | bss_data.mgmt = qdf_mem_malloc(bss_data.frame_len); |
| 17197 | if (!bss_data.mgmt) { |
| 17198 | hdd_err("memory allocation failed"); |
| 17199 | return NULL; |
| 17200 | } |
| 17201 | |
| 17202 | memcpy(bss_data.mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
| 17203 | |
| 17204 | /* Android does not want the timestamp from the frame. |
| 17205 | * Instead it wants a monotonic increasing value |
| 17206 | */ |
| 17207 | get_monotonic_boottime(&ts); |
| 17208 | bss_data.mgmt->u.probe_resp.timestamp = |
| 17209 | ((u64) ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 17210 | |
| 17211 | bss_data.mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 17212 | bss_data.mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
| 17213 | |
Abhishek Singh | f1c1676 | 2018-03-07 10:48:46 +0530 | [diff] [blame] | 17214 | wlan_hdd_add_age_ie(bss_data.mgmt, &ie_length, bss_desc); |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17215 | |
| 17216 | memcpy(bss_data.mgmt->u.probe_resp.variable, ie, ie_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17217 | if (bss_desc->fProbeRsp) { |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17218 | bss_data.mgmt->frame_control |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17219 | (u16) (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 17220 | } else { |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17221 | bss_data.mgmt->frame_control |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17222 | (u16) (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 17223 | } |
| 17224 | |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17225 | if (bss_desc->channelId <= ARRAY_SIZE(hdd_channels_2_4_ghz) && |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 17226 | (wiphy->bands[HDD_NL80211_BAND_2GHZ] != NULL)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17227 | freq = |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17228 | ieee80211_channel_to_frequency(bss_desc->channelId, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 17229 | HDD_NL80211_BAND_2GHZ); |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17230 | } else if ((bss_desc->channelId > ARRAY_SIZE(hdd_channels_2_4_ghz)) |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 17231 | && (wiphy->bands[HDD_NL80211_BAND_5GHZ] != NULL)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17232 | freq = |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17233 | ieee80211_channel_to_frequency(bss_desc->channelId, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 17234 | HDD_NL80211_BAND_5GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17235 | } else { |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17236 | hdd_err("Invalid channel: %d", bss_desc->channelId); |
| 17237 | qdf_mem_free(bss_data.mgmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17238 | return NULL; |
| 17239 | } |
| 17240 | |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17241 | bss_data.chan = ieee80211_get_channel(wiphy, freq); |
| 17242 | if (!bss_data.chan) { |
Deepthi Gowri | 084c24d | 2016-09-01 15:55:09 +0530 | [diff] [blame] | 17243 | hdd_err("chan pointer is NULL, chan_no: %d freq: %d", |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17244 | bss_desc->channelId, freq); |
| 17245 | qdf_mem_free(bss_data.mgmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17246 | return NULL; |
| 17247 | } |
| 17248 | |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17249 | /* |
| 17250 | * Based on .ini configuration, raw rssi can be reported for bss. |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 17251 | * Raw rssi is typically used for estimating power. |
| 17252 | */ |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17253 | 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] | 17254 | bss_desc->rssi; |
| 17255 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17256 | /* Supplicant takes the signal strength in terms of mBm(100*dBm) */ |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17257 | bss_data.rssi = QDF_MIN(bss_data.rssi, 0) * 100; |
| 17258 | |
| 17259 | bss_data.boottime_ns = bss_desc->scansystimensec; |
| 17260 | |
| 17261 | /* Set all per chain rssi as invalid */ |
| 17262 | for (i = 0; i < WLAN_MGMT_TXRX_HOST_MAX_ANTENNA; i++) |
| 17263 | bss_data.per_chain_snr[i] = WLAN_INVALID_PER_CHAIN_RSSI; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17264 | |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 17265 | hdd_debug("BSSID: " MAC_ADDRESS_STR " Channel:%d RSSI:%d TSF %u", |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17266 | MAC_ADDR_ARRAY(bss_data.mgmt->bssid), bss_data.chan->center_freq, |
| 17267 | (int)(bss_data.rssi / 100), |
Sandeep Puligilla | 394da5d | 2016-05-06 01:26:29 -0700 | [diff] [blame] | 17268 | bss_desc->timeStamp[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17269 | |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17270 | bss_status = wlan_cfg80211_inform_bss_frame_data(wiphy, &bss_data); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 17271 | hdd_ctx->beacon_probe_rsp_cnt_per_scan++; |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17272 | qdf_mem_free(bss_data.mgmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17273 | return bss_status; |
| 17274 | } |
| 17275 | |
| 17276 | /** |
| 17277 | * wlan_hdd_cfg80211_update_bss_db() - update bss database of CF80211 |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17278 | * @adapter: Pointer to adapter |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 17279 | * @roam_info: Pointer to roam info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17280 | * |
| 17281 | * This function is used to update the BSS data base of CFG8011 |
| 17282 | * |
| 17283 | * Return: struct cfg80211_bss pointer |
| 17284 | */ |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 17285 | struct cfg80211_bss * |
| 17286 | wlan_hdd_cfg80211_update_bss_db(struct hdd_adapter *adapter, |
| 17287 | struct csr_roam_info *roam_info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17288 | { |
| 17289 | tCsrRoamConnectedProfile roamProfile; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17290 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17291 | struct cfg80211_bss *bss = NULL; |
| 17292 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17293 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 17294 | sme_roam_get_connect_profile(hHal, adapter->session_id, &roamProfile); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17295 | |
| 17296 | if (NULL != roamProfile.pBssDesc) { |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17297 | bss = wlan_hdd_inform_bss_frame(adapter, roamProfile.pBssDesc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17298 | |
| 17299 | if (NULL == bss) |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 17300 | hdd_debug("wlan_hdd_inform_bss_frame returned NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17301 | |
Naveen Rawat | df0a7e7 | 2016-01-06 18:35:53 -0800 | [diff] [blame] | 17302 | sme_roam_free_connect_profile(&roamProfile); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17303 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 17304 | hdd_err("roamProfile.pBssDesc is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17305 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17306 | return bss; |
| 17307 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17308 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17309 | /** |
| 17310 | * wlan_hdd_cfg80211_pmksa_candidate_notify() - notify a new PMSKA candidate |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17311 | * @adapter: Pointer to adapter |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 17312 | * @roam_info: Pointer to roam info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17313 | * @index: Index |
| 17314 | * @preauth: Preauth flag |
| 17315 | * |
| 17316 | * 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] | 17317 | * PMK value is notified to supplicant whether PMK caching or OKC is enabled |
| 17318 | * in firmware or not. Supplicant needs this value becaue it uses PMK caching |
| 17319 | * by default. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17320 | * |
| 17321 | * Return: 0 for success, non-zero for failure |
| 17322 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17323 | int wlan_hdd_cfg80211_pmksa_candidate_notify(struct hdd_adapter *adapter, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 17324 | struct csr_roam_info *roam_info, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17325 | int index, bool preauth) |
| 17326 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17327 | struct net_device *dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17328 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 17329 | hdd_enter(); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17330 | hdd_debug("is going to notify supplicant of:"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17331 | |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 17332 | if (NULL == roam_info) { |
| 17333 | hdd_err("roam_info is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17334 | return -EINVAL; |
| 17335 | } |
| 17336 | |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 17337 | hdd_info(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(roam_info->bssid.bytes)); |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 17338 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 17339 | roam_info->bssid.bytes, |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 17340 | preauth, GFP_KERNEL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17341 | return 0; |
| 17342 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17343 | |
| 17344 | #ifdef FEATURE_WLAN_LFR_METRICS |
| 17345 | /** |
| 17346 | * wlan_hdd_cfg80211_roam_metrics_preauth() - roam metrics preauth |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17347 | * @adapter: Pointer to adapter |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 17348 | * @roam_info: Pointer to roam info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17349 | * |
| 17350 | * 802.11r/LFR metrics reporting function to report preauth initiation |
| 17351 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 17352 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17353 | */ |
| 17354 | #define MAX_LFR_METRICS_EVENT_LENGTH 100 |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 17355 | QDF_STATUS |
| 17356 | wlan_hdd_cfg80211_roam_metrics_preauth(struct hdd_adapter *adapter, |
| 17357 | struct csr_roam_info *roam_info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17358 | { |
| 17359 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 17360 | union iwreq_data wrqu; |
| 17361 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 17362 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17363 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17364 | if (NULL == adapter) { |
| 17365 | hdd_err("adapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 17366 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17367 | } |
| 17368 | |
| 17369 | /* create the event */ |
| 17370 | memset(&wrqu, 0, sizeof(wrqu)); |
| 17371 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 17372 | |
| 17373 | wrqu.data.pointer = metrics_notification; |
| 17374 | wrqu.data.length = scnprintf(metrics_notification, |
| 17375 | sizeof(metrics_notification), |
| 17376 | "QCOM: LFR_PREAUTH_INIT " MAC_ADDRESS_STR, |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 17377 | MAC_ADDR_ARRAY(roam_info->bssid.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17378 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17379 | wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17380 | metrics_notification); |
| 17381 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 17382 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17383 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 17384 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17385 | } |
| 17386 | |
| 17387 | /** |
| 17388 | * wlan_hdd_cfg80211_roam_metrics_handover() - roam metrics hand over |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17389 | * @adapter: Pointer to adapter |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 17390 | * @roam_info: Pointer to roam info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17391 | * @preauth_status: Preauth status |
| 17392 | * |
| 17393 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 17394 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 17395 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17396 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 17397 | QDF_STATUS |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17398 | wlan_hdd_cfg80211_roam_metrics_preauth_status(struct hdd_adapter *adapter, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 17399 | struct csr_roam_info *roam_info, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17400 | bool preauth_status) |
| 17401 | { |
| 17402 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 17403 | union iwreq_data wrqu; |
| 17404 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 17405 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17406 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17407 | if (NULL == adapter) { |
| 17408 | hdd_err("adapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 17409 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17410 | } |
| 17411 | |
| 17412 | /* create the event */ |
| 17413 | memset(&wrqu, 0, sizeof(wrqu)); |
| 17414 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 17415 | |
| 17416 | scnprintf(metrics_notification, sizeof(metrics_notification), |
| 17417 | "QCOM: LFR_PREAUTH_STATUS " MAC_ADDRESS_STR, |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 17418 | MAC_ADDR_ARRAY(roam_info->bssid.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17419 | |
| 17420 | if (1 == preauth_status) |
| 17421 | strlcat(metrics_notification, " true", |
| 17422 | sizeof(metrics_notification)); |
| 17423 | else |
| 17424 | strlcat(metrics_notification, " false", |
| 17425 | sizeof(metrics_notification)); |
| 17426 | |
| 17427 | wrqu.data.pointer = metrics_notification; |
| 17428 | wrqu.data.length = strlen(metrics_notification); |
| 17429 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17430 | wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17431 | metrics_notification); |
| 17432 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 17433 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17434 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 17435 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17436 | } |
| 17437 | |
| 17438 | /** |
| 17439 | * wlan_hdd_cfg80211_roam_metrics_handover() - roam metrics hand over |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17440 | * @adapter: Pointer to adapter |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 17441 | * @roam_info: Pointer to roam info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17442 | * |
| 17443 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 17444 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 17445 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17446 | */ |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 17447 | QDF_STATUS |
| 17448 | wlan_hdd_cfg80211_roam_metrics_handover(struct hdd_adapter *adapter, |
| 17449 | struct csr_roam_info *roam_info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17450 | { |
| 17451 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 17452 | union iwreq_data wrqu; |
| 17453 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 17454 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17455 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17456 | if (NULL == adapter) { |
| 17457 | hdd_err("adapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 17458 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17459 | } |
| 17460 | |
| 17461 | /* create the event */ |
| 17462 | memset(&wrqu, 0, sizeof(wrqu)); |
| 17463 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 17464 | |
| 17465 | wrqu.data.pointer = metrics_notification; |
| 17466 | wrqu.data.length = scnprintf(metrics_notification, |
| 17467 | sizeof(metrics_notification), |
| 17468 | "QCOM: LFR_PREAUTH_HANDOVER " |
| 17469 | MAC_ADDRESS_STR, |
Jeff Johnson | fd06085 | 2017-10-04 10:50:51 -0700 | [diff] [blame] | 17470 | MAC_ADDR_ARRAY(roam_info->bssid.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17471 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17472 | wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17473 | metrics_notification); |
| 17474 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 17475 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17476 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 17477 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17478 | } |
| 17479 | #endif |
| 17480 | |
| 17481 | /** |
| 17482 | * hdd_select_cbmode() - select channel bonding mode |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17483 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17484 | * @operatingChannel: Operating channel |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 17485 | * @ch_params: channel info struct to populate |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17486 | * |
| 17487 | * Return: none |
| 17488 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17489 | void hdd_select_cbmode(struct hdd_adapter *adapter, uint8_t operationChannel, |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 17490 | struct ch_params *ch_params) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17491 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17492 | struct hdd_station_ctx *station_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 17493 | struct hdd_mon_set_ch_info *ch_info = &station_ctx->ch_info; |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 17494 | uint8_t sec_ch = 0; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17495 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 17496 | |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 17497 | /* |
| 17498 | * CDS api expects secondary channel for calculating |
| 17499 | * the channel params |
| 17500 | */ |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 17501 | if ((ch_params->ch_width == CH_WIDTH_40MHZ) && |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 17502 | (WLAN_REG_IS_24GHZ_CH(operationChannel))) { |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 17503 | if (operationChannel >= 1 && operationChannel <= 5) |
| 17504 | sec_ch = operationChannel + 4; |
| 17505 | else if (operationChannel >= 6 && operationChannel <= 13) |
| 17506 | sec_ch = operationChannel - 4; |
| 17507 | } |
| 17508 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17509 | /* This call decides required channel bonding mode */ |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 17510 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, operationChannel, |
| 17511 | sec_ch, ch_params); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 17512 | |
| 17513 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) { |
Srinivas Girigowda | 2fb677c | 2017-03-25 15:35:34 -0700 | [diff] [blame] | 17514 | enum hdd_dot11_mode hdd_dot11_mode; |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 17515 | uint8_t iniDot11Mode = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17516 | (WLAN_HDD_GET_CTX(adapter))->config->dot11Mode; |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 17517 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17518 | hdd_debug("Dot11Mode is %u", iniDot11Mode); |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 17519 | switch (iniDot11Mode) { |
| 17520 | case eHDD_DOT11_MODE_AUTO: |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 17521 | case eHDD_DOT11_MODE_11ax: |
| 17522 | case eHDD_DOT11_MODE_11ax_ONLY: |
| 17523 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 17524 | hdd_dot11_mode = eHDD_DOT11_MODE_11ax; |
| 17525 | else if (sme_is_feature_supported_by_fw(DOT11AC)) |
| 17526 | hdd_dot11_mode = eHDD_DOT11_MODE_11ac; |
| 17527 | else |
| 17528 | hdd_dot11_mode = eHDD_DOT11_MODE_11n; |
| 17529 | break; |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 17530 | case eHDD_DOT11_MODE_11ac: |
| 17531 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 17532 | if (sme_is_feature_supported_by_fw(DOT11AC)) |
| 17533 | hdd_dot11_mode = eHDD_DOT11_MODE_11ac; |
| 17534 | else |
| 17535 | hdd_dot11_mode = eHDD_DOT11_MODE_11n; |
| 17536 | break; |
| 17537 | case eHDD_DOT11_MODE_11n: |
| 17538 | case eHDD_DOT11_MODE_11n_ONLY: |
| 17539 | hdd_dot11_mode = eHDD_DOT11_MODE_11n; |
| 17540 | break; |
| 17541 | default: |
| 17542 | hdd_dot11_mode = iniDot11Mode; |
| 17543 | break; |
| 17544 | } |
| 17545 | ch_info->channel_width = ch_params->ch_width; |
| 17546 | ch_info->phy_mode = |
| 17547 | hdd_cfg_xlate_to_csr_phy_mode(hdd_dot11_mode); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 17548 | ch_info->channel = operationChannel; |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 17549 | ch_info->cb_mode = ch_params->ch_width; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17550 | hdd_debug("ch_info width %d, phymode %d channel %d", |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 17551 | ch_info->channel_width, ch_info->phy_mode, |
| 17552 | ch_info->channel); |
| 17553 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17554 | } |
| 17555 | |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17556 | /** |
| 17557 | * wlan_hdd_handle_sap_sta_dfs_conc() - to handle SAP STA DFS conc |
| 17558 | * @adapter: STA adapter |
| 17559 | * @roam_profile: STA roam profile |
| 17560 | * |
| 17561 | * This routine will move SAP from dfs to non-dfs, if sta is coming up. |
| 17562 | * |
| 17563 | * Return: false if sta-sap conc is not allowed, else return true |
| 17564 | */ |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 17565 | static |
| 17566 | bool wlan_hdd_handle_sap_sta_dfs_conc(struct hdd_adapter *adapter, |
| 17567 | struct csr_roam_profile *roam_profile) |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17568 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 17569 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 17570 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 17571 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 17572 | struct hdd_hostapd_state *hostapd_state; |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17573 | uint8_t channel = 0; |
| 17574 | QDF_STATUS status; |
| 17575 | |
| 17576 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 17577 | if (!hdd_ctx) { |
| 17578 | hdd_err("HDD context is NULL"); |
| 17579 | return true; |
| 17580 | } |
| 17581 | |
| 17582 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 17583 | /* probably no sap running, no handling required */ |
| 17584 | if (ap_adapter == NULL) |
| 17585 | return true; |
| 17586 | |
| 17587 | /* |
| 17588 | * sap is not in started state, so it is fine to go ahead with sta. |
| 17589 | * if sap is currently doing CAC then don't allow sta to go further. |
| 17590 | */ |
| 17591 | if (!test_bit(SOFTAP_BSS_STARTED, &(ap_adapter)->event_flags) && |
| 17592 | (hdd_ctx->dev_dfs_cac_status != DFS_CAC_IN_PROGRESS)) |
| 17593 | return true; |
| 17594 | |
| 17595 | if (hdd_ctx->dev_dfs_cac_status == DFS_CAC_IN_PROGRESS) { |
| 17596 | hdd_err("Concurrent SAP is in CAC state, STA is not allowed"); |
| 17597 | return false; |
| 17598 | } |
| 17599 | |
| 17600 | /* |
| 17601 | * log and return error, if we allow STA to go through, we don't |
| 17602 | * know what is going to happen better stop sta connection |
| 17603 | */ |
| 17604 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 17605 | if (NULL == hdd_ap_ctx) { |
| 17606 | hdd_err("AP context not found"); |
| 17607 | return false; |
| 17608 | } |
| 17609 | |
| 17610 | /* sap is on non-dfs channel, nothing to handle */ |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 17611 | if (!wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 17612 | hdd_ap_ctx->operating_channel)) { |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 17613 | hdd_info("sap is on non-dfs channel, sta is allowed"); |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17614 | return true; |
| 17615 | } |
| 17616 | /* |
| 17617 | * 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] | 17618 | * connect by passing its roam_profile. |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17619 | */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 17620 | status = policy_mgr_get_channel_from_scan_result(hdd_ctx->hdd_psoc, |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17621 | roam_profile, &channel); |
| 17622 | |
Nitesh Shah | 5977452 | 2016-09-16 15:14:21 +0530 | [diff] [blame] | 17623 | /* |
| 17624 | * If the STA's channel is 2.4 GHz, then set pcl with only 2.4 GHz |
| 17625 | * channels for roaming case. |
| 17626 | */ |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 17627 | if (WLAN_REG_IS_24GHZ_CH(channel)) { |
| 17628 | 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] | 17629 | return true; |
| 17630 | } |
| 17631 | |
| 17632 | /* |
Jeff Johnson | dcf84ce | 2017-10-05 09:26:24 -0700 | [diff] [blame] | 17633 | * 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] | 17634 | * find out the best channel. If channel is non-dfs 5 GHz then |
| 17635 | * better move SAP to STA's channel to make scc, so we have room |
| 17636 | * for 3port MCC scenario. |
Nitesh Shah | 5977452 | 2016-09-16 15:14:21 +0530 | [diff] [blame] | 17637 | */ |
Tushnim Bhattacharyya | 9a92999 | 2017-06-18 00:59:09 -0700 | [diff] [blame] | 17638 | if ((0 == channel) || wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, channel) || |
| 17639 | !policy_mgr_is_safe_channel(hdd_ctx->hdd_psoc, channel)) |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 17640 | channel = policy_mgr_get_nondfs_preferred_channel( |
| 17641 | hdd_ctx->hdd_psoc, PM_SAP_MODE, true); |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17642 | |
| 17643 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 17644 | qdf_event_reset(&hostapd_state->qdf_event); |
| 17645 | status = wlansap_set_channel_change_with_csa( |
| 17646 | WLAN_HDD_GET_SAP_CTX_PTR(ap_adapter), channel, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 17647 | hdd_ap_ctx->sap_config.ch_width_orig, false); |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17648 | |
| 17649 | if (QDF_STATUS_SUCCESS != status) { |
| 17650 | hdd_err("Set channel with CSA IE failed, can't allow STA"); |
| 17651 | return false; |
| 17652 | } |
| 17653 | |
| 17654 | /* |
| 17655 | * wait here for SAP to finish the channel switch. When channel |
| 17656 | * switch happens, SAP sends few beacons with CSA_IE. After |
| 17657 | * successfully Transmission of those beacons, it will move its |
| 17658 | * state from started to disconnected and move to new channel. |
| 17659 | * once it moves to new channel, sap again moves its state |
| 17660 | * machine from disconnected to started and set this event. |
| 17661 | * wait for 10 secs to finish this. |
| 17662 | */ |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 17663 | status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, 10000); |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17664 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 17665 | hdd_err("wait for qdf_event failed, STA not allowed!!"); |
| 17666 | return false; |
| 17667 | } |
| 17668 | |
| 17669 | return true; |
| 17670 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17671 | |
Abhishek Singh | cfb4448 | 2017-03-10 12:42:37 +0530 | [diff] [blame] | 17672 | #ifdef WLAN_FEATURE_11W |
| 17673 | /** |
| 17674 | * wlan_hdd_cfg80211_check_pmf_valid() - check if pmf status is ok |
| 17675 | * @roam_profile: pointer to roam profile |
| 17676 | * |
| 17677 | * if MFPEnabled is set but the peer AP is non-PMF i.e 80211w=2 |
| 17678 | * or pmf=2 is an explicit configuration in the supplicant |
| 17679 | * configuration, drop the connection request. |
| 17680 | * |
| 17681 | * Return: 0 if check result is valid, otherwise return error code |
| 17682 | */ |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 17683 | static |
| 17684 | 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] | 17685 | { |
| 17686 | if (roam_profile->MFPEnabled && |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17687 | !(roam_profile->MFPRequired || roam_profile->MFPCapable)) { |
Abhishek Singh | cfb4448 | 2017-03-10 12:42:37 +0530 | [diff] [blame] | 17688 | hdd_err("Drop connect req as supplicant has indicated PMF required for the non-PMF peer. MFPEnabled %d MFPRequired %d MFPCapable %d", |
| 17689 | roam_profile->MFPEnabled, |
| 17690 | roam_profile->MFPRequired, |
| 17691 | roam_profile->MFPCapable); |
| 17692 | return -EINVAL; |
| 17693 | } |
| 17694 | return 0; |
| 17695 | } |
| 17696 | #else |
| 17697 | static inline |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 17698 | 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] | 17699 | { |
| 17700 | return 0; |
| 17701 | } |
| 17702 | #endif |
| 17703 | |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 17704 | /** |
| 17705 | * wlan_hdd_cfg80211_connect_start() - to start the association process |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17706 | * @adapter: Pointer to adapter |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 17707 | * @ssid: Pointer to ssid |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17708 | * @ssid_len: Length of ssid |
| 17709 | * @bssid: Pointer to bssid |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 17710 | * @bssid_hint: Pointer to bssid hint |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17711 | * @operatingChannel: Operating channel |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 17712 | * @ch_width: channel width. this is needed only for IBSS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17713 | * |
| 17714 | * This function is used to start the association process |
| 17715 | * |
| 17716 | * Return: 0 for success, non-zero for failure |
| 17717 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17718 | static int wlan_hdd_cfg80211_connect_start(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17719 | const u8 *ssid, size_t ssid_len, |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 17720 | const u8 *bssid, const u8 *bssid_hint, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 17721 | u8 operatingChannel, |
| 17722 | enum nl80211_chan_width ch_width) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17723 | { |
| 17724 | int status = 0; |
Rajeev Kumar | d31e154 | 2017-01-13 14:37:42 -0800 | [diff] [blame] | 17725 | QDF_STATUS qdf_status; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 17726 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 17727 | struct hdd_station_ctx *hdd_sta_ctx; |
Krunal Soni | bfd0549 | 2017-10-03 15:48:37 -0700 | [diff] [blame] | 17728 | uint32_t roamId = INVALID_ROAM_ID; |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 17729 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17730 | eCsrAuthType RSNAuthType; |
| 17731 | tSmeConfigParams *sme_config; |
Nitesh Shah | 044fd67 | 2016-10-13 18:53:25 +0530 | [diff] [blame] | 17732 | uint8_t channel = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17733 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 17734 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17735 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17736 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 17737 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17738 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 17739 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 17740 | if (status) |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 17741 | goto ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17742 | |
| 17743 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 17744 | hdd_err("wrong SSID len"); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 17745 | status = -EINVAL; |
| 17746 | goto ret_status; |
| 17747 | } |
| 17748 | |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 17749 | if (true == hdd_is_connection_in_progress(NULL, NULL)) { |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 17750 | hdd_err("Connection refused: conn in progress"); |
| 17751 | status = -EINVAL; |
| 17752 | goto ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17753 | } |
| 17754 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17755 | hdd_notify_teardown_tdls_links(adapter->hdd_vdev); |
Nitesh Shah | 273e4e5 | 2017-04-03 12:53:36 +0530 | [diff] [blame] | 17756 | |
Anurag Chouhan | d939d3d | 2016-07-20 17:45:48 +0530 | [diff] [blame] | 17757 | qdf_mem_zero(&hdd_sta_ctx->conn_info.conn_flag, |
| 17758 | sizeof(hdd_sta_ctx->conn_info.conn_flag)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17759 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17760 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17761 | if (roam_profile) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 17762 | struct hdd_station_ctx *sta_ctx; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 17763 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 17764 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17765 | |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 17766 | /* Restart the opportunistic timer |
| 17767 | * |
| 17768 | * If hw_mode_change_in_progress is true, then wait |
| 17769 | * till firmware sends the callback for hw_mode change. |
| 17770 | * |
| 17771 | * Else set connect_in_progress as true and proceed. |
| 17772 | */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 17773 | policy_mgr_restart_opportunistic_timer( |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 17774 | hdd_ctx->hdd_psoc, false); |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 17775 | if (policy_mgr_is_hw_mode_change_in_progress( |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 17776 | hdd_ctx->hdd_psoc)) { |
Abhishek Singh | 471652b | 2017-04-14 12:28:32 +0530 | [diff] [blame] | 17777 | qdf_status = policy_mgr_wait_for_connection_update( |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 17778 | hdd_ctx->hdd_psoc); |
Abhishek Singh | 471652b | 2017-04-14 12:28:32 +0530 | [diff] [blame] | 17779 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 17780 | hdd_err("qdf wait for event failed!!"); |
| 17781 | status = -EINVAL; |
| 17782 | goto ret_status; |
| 17783 | } |
| 17784 | } |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 17785 | hdd_set_connection_in_progress(true); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 17786 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17787 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17788 | (WLAN_HDD_GET_CTX(adapter))->config->WmmMode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17789 | /*QoS not enabled in cfg file */ |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17790 | roam_profile->uapsd_mask = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17791 | } else { |
| 17792 | /*QoS enabled, update uapsd mask from cfg file */ |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17793 | roam_profile->uapsd_mask = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17794 | (WLAN_HDD_GET_CTX(adapter))->config->UapsdMask; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17795 | } |
| 17796 | |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17797 | roam_profile->SSIDs.numOfSSIDs = 1; |
| 17798 | roam_profile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 17799 | qdf_mem_zero(roam_profile->SSIDs.SSIDList->SSID.ssId, |
| 17800 | sizeof(roam_profile->SSIDs.SSIDList->SSID.ssId)); |
| 17801 | qdf_mem_copy((void *)(roam_profile->SSIDs.SSIDList->SSID.ssId), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17802 | ssid, ssid_len); |
| 17803 | |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 17804 | roam_profile->supplicant_disabled_roaming = false; |
Varun Reddy Yeturu | e5a35d1 | 2017-10-20 11:26:57 -0700 | [diff] [blame] | 17805 | |
Abhishek Singh | 3c9910e | 2017-01-06 17:56:47 +0530 | [diff] [blame] | 17806 | /* cleanup bssid hint */ |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17807 | qdf_mem_zero(roam_profile->bssid_hint.bytes, |
Abhishek Singh | 3c9910e | 2017-01-06 17:56:47 +0530 | [diff] [blame] | 17808 | QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17809 | qdf_mem_zero((void *)(roam_profile->BSSIDs.bssid), |
Abhishek Singh | 3c9910e | 2017-01-06 17:56:47 +0530 | [diff] [blame] | 17810 | QDF_MAC_ADDR_SIZE); |
| 17811 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17812 | if (bssid) { |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17813 | roam_profile->BSSIDs.numOfBSSIDs = 1; |
Varun Reddy Yeturu | e5a35d1 | 2017-10-20 11:26:57 -0700 | [diff] [blame] | 17814 | roam_profile->supplicant_disabled_roaming = true; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17815 | qdf_mem_copy((void *)(roam_profile->BSSIDs.bssid), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 17816 | bssid, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 17817 | /* |
| 17818 | * Save BSSID in seperate variable as |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17819 | * roam_profile's BSSID is getting zeroed out in the |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 17820 | * association process. In case of join failure |
| 17821 | * we should send valid BSSID to supplicant |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17822 | */ |
Jeff Johnson | 731bc32 | 2017-10-14 19:53:44 -0700 | [diff] [blame] | 17823 | qdf_mem_copy(sta_ctx->requested_bssid.bytes, |
| 17824 | bssid, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17825 | hdd_debug("bssid is given by upper layer %pM", bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17826 | } else if (bssid_hint) { |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17827 | qdf_mem_copy(roam_profile->bssid_hint.bytes, |
Abhishek Singh | 3c9910e | 2017-01-06 17:56:47 +0530 | [diff] [blame] | 17828 | bssid_hint, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 17829 | /* |
| 17830 | * Save BSSID in a separate variable as |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17831 | * roam_profile's BSSID is getting zeroed out in the |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 17832 | * association process. In case of join failure |
| 17833 | * we should send valid BSSID to supplicant |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17834 | */ |
Jeff Johnson | 731bc32 | 2017-10-14 19:53:44 -0700 | [diff] [blame] | 17835 | qdf_mem_copy(sta_ctx->requested_bssid.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 17836 | bssid_hint, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17837 | hdd_debug("bssid_hint is given by upper layer %pM", |
Krunal Soni | 35b404c | 2016-07-14 23:36:00 -0700 | [diff] [blame] | 17838 | bssid_hint); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17839 | } |
| 17840 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17841 | hdd_debug("Connect to SSID: %.*s operating Channel: %u", |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17842 | roam_profile->SSIDs.SSIDList->SSID.length, |
| 17843 | roam_profile->SSIDs.SSIDList->SSID.ssId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17844 | operatingChannel); |
| 17845 | |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 17846 | if (hdd_sta_ctx->wpa_versions) { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17847 | hdd_set_genie_to_csr(adapter, &RSNAuthType); |
| 17848 | hdd_set_csr_auth_type(adapter, RSNAuthType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17849 | } |
| 17850 | #ifdef FEATURE_WLAN_WAPI |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 17851 | if (adapter->wapi_info.wapi_mode) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17852 | hdd_debug("Setting WAPI AUTH Type and Encryption Mode values"); |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 17853 | switch (adapter->wapi_info.wapi_auth_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17854 | case WAPI_AUTH_MODE_PSK: |
| 17855 | { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17856 | hdd_debug("WAPI AUTH TYPE: PSK: %d", |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 17857 | adapter->wapi_info.wapi_auth_mode); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17858 | roam_profile->AuthType.authType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17859 | eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 17860 | break; |
| 17861 | } |
| 17862 | case WAPI_AUTH_MODE_CERT: |
| 17863 | { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17864 | hdd_debug("WAPI AUTH TYPE: CERT: %d", |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 17865 | adapter->wapi_info.wapi_auth_mode); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17866 | roam_profile->AuthType.authType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17867 | eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 17868 | break; |
| 17869 | } |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 17870 | default: |
| 17871 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17872 | } /* End of switch */ |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 17873 | if (adapter->wapi_info.wapi_auth_mode == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17874 | WAPI_AUTH_MODE_PSK |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 17875 | || adapter->wapi_info.wapi_auth_mode == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17876 | WAPI_AUTH_MODE_CERT) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 17877 | hdd_debug("WAPI PAIRWISE/GROUP ENCRYPTION: WPI"); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17878 | roam_profile->AuthType.numEntries = 1; |
| 17879 | roam_profile->EncryptionType.numEntries = 1; |
| 17880 | roam_profile->EncryptionType.encryptionType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17881 | eCSR_ENCRYPT_TYPE_WPI; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17882 | roam_profile->mcEncryptionType.numEntries = 1; |
| 17883 | roam_profile->mcEncryptionType. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17884 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 17885 | } |
| 17886 | } |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 17887 | #endif |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17888 | pmo_ucfg_flush_gtk_offload_req(adapter->hdd_vdev); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17889 | roam_profile->csrPersona = adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17890 | |
| 17891 | if (operatingChannel) { |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17892 | roam_profile->ChannelInfo.ChannelList = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17893 | &operatingChannel; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17894 | roam_profile->ChannelInfo.numOfChannels = 1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17895 | } else { |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17896 | roam_profile->ChannelInfo.ChannelList = NULL; |
| 17897 | roam_profile->ChannelInfo.numOfChannels = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17898 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17899 | if ((QDF_IBSS_MODE == adapter->device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17900 | && operatingChannel) { |
| 17901 | /* |
| 17902 | * Need to post the IBSS power save parameters |
| 17903 | * to WMA. WMA will configure this parameters |
| 17904 | * to firmware if power save is enabled by the |
| 17905 | * firmware. |
| 17906 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17907 | qdf_status = hdd_set_ibss_power_save_params(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17908 | |
Abhishek Singh | 471652b | 2017-04-14 12:28:32 +0530 | [diff] [blame] | 17909 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 17910 | hdd_err("Set IBSS Power Save Params Failed"); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 17911 | status = -EINVAL; |
| 17912 | goto conn_failure; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17913 | } |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17914 | roam_profile->ch_params.ch_width = |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 17915 | hdd_map_nl_chan_width(ch_width); |
Nitesh Shah | 87335a5 | 2016-09-05 15:47:32 +0530 | [diff] [blame] | 17916 | /* |
| 17917 | * In IBSS mode while operating in 2.4 GHz, |
| 17918 | * the device supports only 20 MHz. |
| 17919 | */ |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 17920 | if (WLAN_REG_IS_24GHZ_CH(operatingChannel)) |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17921 | roam_profile->ch_params.ch_width = |
Nitesh Shah | 87335a5 | 2016-09-05 15:47:32 +0530 | [diff] [blame] | 17922 | CH_WIDTH_20MHZ; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17923 | hdd_select_cbmode(adapter, operatingChannel, |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17924 | &roam_profile->ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17925 | } |
| 17926 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 17927 | if (wlan_hdd_cfg80211_check_pmf_valid(roam_profile)) { |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 17928 | status = -EINVAL; |
| 17929 | goto conn_failure; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17930 | } |
| 17931 | |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 17932 | /* |
| 17933 | * After 8-way handshake supplicant should give the scan command |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17934 | * in that it update the additional IEs, But because of scan |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 17935 | * enhancements, the supplicant is not issuing the scan command |
| 17936 | * now. So the unicast frames which are sent from the host are |
| 17937 | * not having the additional IEs. If it is P2P CLIENT and there |
| 17938 | * is no additional IE present in roamProfile, then use the |
| 17939 | * addtional IE form scan_info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17940 | */ |
| 17941 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17942 | if ((adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17943 | (!roam_profile->pAddIEScan)) { |
| 17944 | roam_profile->pAddIEScan = |
Jeff Johnson | 37fa040 | 2017-10-28 12:42:29 -0700 | [diff] [blame] | 17945 | &adapter->scan_info.scan_add_ie.addIEdata[0]; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17946 | roam_profile->nAddIEScanLength = |
Jeff Johnson | 37fa040 | 2017-10-28 12:42:29 -0700 | [diff] [blame] | 17947 | adapter->scan_info.scan_add_ie.length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17948 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17949 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 17950 | if ((policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) == true) |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17951 | && (false == wlan_hdd_handle_sap_sta_dfs_conc(adapter, |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 17952 | roam_profile))) { |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17953 | hdd_err("sap-sta conc will fail, can't allow sta"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17954 | hdd_conn_set_connection_state(adapter, |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17955 | eConnectionState_NotConnected); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 17956 | status = -ENOMEM; |
| 17957 | goto conn_failure; |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17958 | } |
| 17959 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 17960 | sme_config = qdf_mem_malloc(sizeof(*sme_config)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17961 | if (!sme_config) { |
| 17962 | hdd_err("unable to allocate sme_config"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 17963 | hdd_conn_set_connection_state(adapter, |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 17964 | eConnectionState_NotConnected); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 17965 | status = -ENOMEM; |
| 17966 | goto conn_failure; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17967 | } |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 17968 | sme_get_config_param(hdd_ctx->hHal, sme_config); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17969 | /* These values are not sessionized. So, any change in these SME |
| 17970 | * configs on an older or parallel interface will affect the |
| 17971 | * cb mode. So, restoring the default INI params before starting |
| 17972 | * interfaces such as sta, cli etc., |
| 17973 | */ |
| 17974 | sme_config->csrConfig.channelBondingMode5GHz = |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 17975 | hdd_ctx->config->nChannelBondingMode5GHz; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 17976 | sme_config->csrConfig.channelBondingMode24GHz = |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 17977 | hdd_ctx->config->nChannelBondingMode24GHz; |
| 17978 | sme_update_config(hdd_ctx->hHal, sme_config); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 17979 | qdf_mem_free(sme_config); |
Agrawal Ashish | 6b01576 | 2016-05-05 11:22:18 +0530 | [diff] [blame] | 17980 | /* |
| 17981 | * Change conn_state to connecting before sme_roam_connect(), |
| 17982 | * because sme_roam_connect() has a direct path to call |
| 17983 | * hdd_sme_roam_callback(), which will change the conn_state |
| 17984 | * If direct path, conn_state will be accordingly changed to |
| 17985 | * NotConnected or Associated by either |
| 17986 | * hdd_association_completion_handler() or |
| 17987 | * hdd_dis_connect_handler() in sme_RoamCallback()if |
| 17988 | * sme_RomConnect is to be queued, |
| 17989 | * Connecting state will remain until it is completed. |
| 17990 | * |
| 17991 | * If connection state is not changed, connection state will |
| 17992 | * remain in eConnectionState_NotConnected state. |
| 17993 | * In hdd_association_completion_handler, "hddDisconInProgress" |
| 17994 | * is set to true if conn state is |
| 17995 | * eConnectionState_NotConnected. |
| 17996 | * If "hddDisconInProgress" is set to true then cfg80211 layer |
| 17997 | * is not informed of connect result indication which |
| 17998 | * is an issue. |
| 17999 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18000 | if (QDF_STA_MODE == adapter->device_mode || |
| 18001 | QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 18002 | hdd_conn_set_connection_state(adapter, |
Agrawal Ashish | 6b01576 | 2016-05-05 11:22:18 +0530 | [diff] [blame] | 18003 | eConnectionState_Connecting); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18004 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame^] | 18005 | hdd_set_disconnect_status(adapter, false); |
| 18006 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 18007 | qdf_runtime_pm_prevent_suspend( |
| 18008 | &hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 18009 | hdd_prevent_suspend_timeout(HDD_WAKELOCK_TIMEOUT_CONNECT, |
| 18010 | WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18011 | qdf_status = sme_roam_connect(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 18012 | adapter->session_id, roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18013 | &roamId); |
Abhishek Singh | 471652b | 2017-04-14 12:28:32 +0530 | [diff] [blame] | 18014 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 18015 | status = qdf_status_to_os_return(qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18016 | |
Rajeev Kumar | d31e154 | 2017-01-13 14:37:42 -0800 | [diff] [blame] | 18017 | if ((QDF_STATUS_SUCCESS != qdf_status) && |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18018 | (QDF_STA_MODE == adapter->device_mode || |
| 18019 | QDF_P2P_CLIENT_MODE == adapter->device_mode)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 18020 | hdd_err("sme_roam_connect (session %d) failed with " |
Rajeev Kumar | d31e154 | 2017-01-13 14:37:42 -0800 | [diff] [blame] | 18021 | "qdf_status %d. -> NotConnected", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 18022 | adapter->session_id, qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18023 | /* change back to NotAssociated */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18024 | hdd_conn_set_connection_state(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18025 | eConnectionState_NotConnected); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 18026 | qdf_runtime_pm_allow_suspend( |
| 18027 | &hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 18028 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18029 | } |
| 18030 | |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 18031 | /* Reset connect_in_progress */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 18032 | hdd_set_connection_in_progress(false); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 18033 | |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 18034 | roam_profile->ChannelInfo.ChannelList = NULL; |
| 18035 | roam_profile->ChannelInfo.numOfChannels = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18036 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18037 | if ((QDF_STA_MODE == adapter->device_mode) |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18038 | && policy_mgr_is_current_hwmode_dbs(hdd_ctx->hdd_psoc) |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 18039 | && !policy_mgr_is_hw_dbs_2x2_capable( |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18040 | hdd_ctx->hdd_psoc)) { |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 18041 | policy_mgr_get_channel_from_scan_result( |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18042 | hdd_ctx->hdd_psoc, |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 18043 | roam_profile, &channel); |
Archana Ramachandran | cc0ffb1 | 2017-02-17 18:30:43 -0800 | [diff] [blame] | 18044 | hdd_info("Move to single MAC mode(optimization) if applicable"); |
Nitesh Shah | 044fd67 | 2016-10-13 18:53:25 +0530 | [diff] [blame] | 18045 | if (channel) |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 18046 | policy_mgr_checkn_update_hw_mode_single_mac_mode( |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 18047 | hdd_ctx->hdd_psoc, channel); |
Nitesh Shah | 044fd67 | 2016-10-13 18:53:25 +0530 | [diff] [blame] | 18048 | } |
| 18049 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18050 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 18051 | hdd_err("No valid Roam profile"); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 18052 | status = -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18053 | } |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 18054 | goto ret_status; |
| 18055 | |
| 18056 | conn_failure: |
| 18057 | /* Reset connect_in_progress */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 18058 | hdd_set_connection_in_progress(false); |
Nitesh Shah | a3dfea3 | 2017-02-09 19:18:57 +0530 | [diff] [blame] | 18059 | |
| 18060 | ret_status: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 18061 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18062 | return status; |
| 18063 | } |
| 18064 | |
| 18065 | /** |
| 18066 | * wlan_hdd_cfg80211_set_auth_type() - set auth type |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18067 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18068 | * @auth_type: Auth type |
| 18069 | * |
| 18070 | * This function is used to set the authentication type (OPEN/SHARED). |
| 18071 | * |
| 18072 | * Return: 0 for success, non-zero for failure |
| 18073 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18074 | static int wlan_hdd_cfg80211_set_auth_type(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18075 | enum nl80211_auth_type auth_type) |
| 18076 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18077 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18078 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18079 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18080 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18081 | /*set authentication type */ |
| 18082 | switch (auth_type) { |
| 18083 | case NL80211_AUTHTYPE_AUTOMATIC: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18084 | hdd_debug("set authentication type to AUTOSWITCH"); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18085 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18086 | break; |
| 18087 | |
| 18088 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18089 | case NL80211_AUTHTYPE_FT: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18090 | hdd_debug("set authentication type to OPEN"); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18091 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18092 | break; |
| 18093 | |
| 18094 | case NL80211_AUTHTYPE_SHARED_KEY: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18095 | hdd_debug("set authentication type to SHARED"); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18096 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18097 | break; |
| 18098 | #ifdef FEATURE_WLAN_ESE |
| 18099 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18100 | hdd_debug("set authentication type to CCKM WPA"); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18101 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18102 | break; |
| 18103 | #endif |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 18104 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 18105 | (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 18106 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18107 | case NL80211_AUTHTYPE_FILS_SK: |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 18108 | hdd_debug("set authentication type to FILS SHARED"); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18109 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18110 | break; |
| 18111 | #endif |
Padma, Santhosh Kumar | 07eb80b | 2017-07-05 16:10:06 +0530 | [diff] [blame] | 18112 | case NL80211_AUTHTYPE_SAE: |
| 18113 | hdd_debug("set authentication type to SAE"); |
| 18114 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_SAE; |
| 18115 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18116 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18117 | hdd_err("Unsupported authentication type: %d", auth_type); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18118 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18119 | return -EINVAL; |
| 18120 | } |
| 18121 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18122 | roam_profile = hdd_roam_profile(adapter); |
| 18123 | roam_profile->AuthType.authType[0] = sta_ctx->conn_info.authType; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18124 | return 0; |
| 18125 | } |
| 18126 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 18127 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 18128 | (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 18129 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18130 | 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] | 18131 | { |
| 18132 | struct cds_fils_connection_info *fils_con_info; |
| 18133 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18134 | fils_con_info = roam_profile->fils_con_info; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18135 | if (!fils_con_info) { |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 18136 | hdd_err("No valid Roam profile"); |
| 18137 | return false; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18138 | } |
| 18139 | |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 18140 | return true; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18141 | } |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 18142 | |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 18143 | static enum eAniAuthType wlan_hdd_get_fils_auth_type( |
| 18144 | enum nl80211_auth_type auth) |
| 18145 | { |
| 18146 | switch (auth) { |
| 18147 | case NL80211_AUTHTYPE_FILS_SK: |
| 18148 | return SIR_FILS_SK_WITHOUT_PFS; |
| 18149 | case NL80211_AUTHTYPE_FILS_SK_PFS: |
| 18150 | return SIR_FILS_SK_WITH_PFS; |
| 18151 | case NL80211_AUTHTYPE_FILS_PK: |
| 18152 | return SIR_FILS_PK_AUTH; |
| 18153 | default: |
| 18154 | return eSIR_DONOT_USE_AUTH_TYPE; |
| 18155 | } |
| 18156 | } |
| 18157 | |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 18158 | static bool wlan_hdd_fils_data_in_limits(struct cfg80211_connect_params *req) |
| 18159 | { |
| 18160 | hdd_debug("seq=%d auth=%d lengths: user=%zu rrk=%zu realm=%zu", |
| 18161 | req->fils_erp_next_seq_num, req->auth_type, |
| 18162 | req->fils_erp_username_len, req->fils_erp_rrk_len, |
| 18163 | req->fils_erp_realm_len); |
| 18164 | if (!req->fils_erp_rrk_len || !req->fils_erp_realm_len || |
| 18165 | !req->fils_erp_username_len || |
| 18166 | req->fils_erp_rrk_len > FILS_MAX_RRK_LENGTH || |
| 18167 | req->fils_erp_realm_len > FILS_MAX_REALM_LEN || |
| 18168 | req->fils_erp_username_len > FILS_MAX_KEYNAME_NAI_LENGTH) { |
| 18169 | hdd_err("length incorrect, user=%zu rrk=%zu realm=%zu", |
| 18170 | req->fils_erp_username_len, req->fils_erp_rrk_len, |
| 18171 | req->fils_erp_realm_len); |
| 18172 | return false; |
| 18173 | } |
| 18174 | |
| 18175 | return true; |
| 18176 | } |
| 18177 | |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 18178 | /** |
| 18179 | * wlan_hdd_cfg80211_set_fils_config() - set fils config params during connect |
| 18180 | * @adapter: Pointer to adapter |
| 18181 | * @req: Pointer to fils parameters |
| 18182 | * |
| 18183 | * Return: 0 for success, non-zero for failure |
| 18184 | */ |
| 18185 | static int wlan_hdd_cfg80211_set_fils_config(struct hdd_adapter *adapter, |
| 18186 | struct cfg80211_connect_params *req) |
| 18187 | { |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 18188 | struct csr_roam_profile *roam_profile; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 18189 | enum eAniAuthType auth_type; |
| 18190 | uint8_t *buf; |
| 18191 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 18192 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18193 | roam_profile = hdd_roam_profile(adapter); |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 18194 | |
| 18195 | if (!hdd_ctx->config->is_fils_enabled) { |
| 18196 | hdd_err("FILS disabled"); |
| 18197 | return -EINVAL; |
| 18198 | } |
| 18199 | hdd_clear_fils_connection_info(adapter); |
| 18200 | roam_profile->fils_con_info = |
| 18201 | qdf_mem_malloc(sizeof(*roam_profile->fils_con_info)); |
| 18202 | |
| 18203 | if (!roam_profile->fils_con_info) { |
| 18204 | hdd_err("failed to allocate memory"); |
| 18205 | return -EINVAL; |
| 18206 | } |
| 18207 | /* |
| 18208 | * The initial connection for FILS may happen with an OPEN |
| 18209 | * auth type. Hence we need to allow the connection to go |
| 18210 | * through in that case as well. Below is_fils_connection |
| 18211 | * flag is propagated down to CSR and PE sessions through |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 18212 | * the JOIN request. As the flag is used, do not free the |
| 18213 | * memory allocated to fils_con_info and return success. |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 18214 | */ |
| 18215 | if (req->auth_type != NL80211_AUTHTYPE_FILS_SK) { |
| 18216 | roam_profile->fils_con_info->is_fils_connection = false; |
| 18217 | return 0; |
| 18218 | } |
| 18219 | |
| 18220 | /* |
| 18221 | * Once above check is done, then we can check for valid FILS |
| 18222 | * auth types. Currently only NL80211_AUTHTYPE_FILS_SK is |
| 18223 | * supported. Once all auth types are supported, then we can |
| 18224 | * merge these 2 conditions into one. |
| 18225 | */ |
| 18226 | auth_type = wlan_hdd_get_fils_auth_type(req->auth_type); |
| 18227 | if (auth_type == eSIR_DONOT_USE_AUTH_TYPE) { |
| 18228 | hdd_err("invalid auth type for fils %d", req->auth_type); |
Varun Reddy Yeturu | 82e39cd | 2017-10-16 12:04:05 -0700 | [diff] [blame] | 18229 | goto fils_conn_fail; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 18230 | } |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 18231 | if (!wlan_hdd_fils_data_in_limits(req)) |
Jeff Johnson | b8adae4 | 2018-02-27 16:12:00 -0800 | [diff] [blame] | 18232 | goto fils_conn_fail; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 18233 | |
| 18234 | roam_profile->fils_con_info->is_fils_connection = true; |
| 18235 | roam_profile->fils_con_info->sequence_number = |
| 18236 | req->fils_erp_next_seq_num; |
| 18237 | roam_profile->fils_con_info->auth_type = auth_type; |
| 18238 | |
| 18239 | roam_profile->fils_con_info->r_rk_length = |
| 18240 | req->fils_erp_rrk_len; |
| 18241 | if (req->fils_erp_rrk_len) |
| 18242 | qdf_mem_copy(roam_profile->fils_con_info->r_rk, |
| 18243 | req->fils_erp_rrk, |
| 18244 | roam_profile->fils_con_info->r_rk_length); |
| 18245 | |
| 18246 | roam_profile->fils_con_info->realm_len = req->fils_erp_realm_len; |
| 18247 | if (req->fils_erp_realm_len) |
| 18248 | qdf_mem_copy(roam_profile->fils_con_info->realm, |
| 18249 | req->fils_erp_realm, |
| 18250 | roam_profile->fils_con_info->realm_len); |
| 18251 | |
| 18252 | roam_profile->fils_con_info->key_nai_length = |
| 18253 | req->fils_erp_username_len + sizeof(char) + |
| 18254 | req->fils_erp_realm_len; |
| 18255 | hdd_debug("key_nai_length = %d", |
| 18256 | roam_profile->fils_con_info->key_nai_length); |
Varun Reddy Yeturu | 82e39cd | 2017-10-16 12:04:05 -0700 | [diff] [blame] | 18257 | if (roam_profile->fils_con_info->key_nai_length > |
| 18258 | FILS_MAX_KEYNAME_NAI_LENGTH) { |
| 18259 | hdd_err("Do not allow FILS conn due to excess NAI Length %d", |
| 18260 | roam_profile->fils_con_info->key_nai_length); |
| 18261 | goto fils_conn_fail; |
| 18262 | } |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 18263 | buf = roam_profile->fils_con_info->keyname_nai; |
| 18264 | qdf_mem_copy(buf, req->fils_erp_username, req->fils_erp_username_len); |
| 18265 | buf += req->fils_erp_username_len; |
| 18266 | *buf++ = '@'; |
| 18267 | 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] | 18268 | |
| 18269 | return 0; |
Varun Reddy Yeturu | 82e39cd | 2017-10-16 12:04:05 -0700 | [diff] [blame] | 18270 | |
| 18271 | fils_conn_fail: |
| 18272 | if (roam_profile->fils_con_info) { |
| 18273 | qdf_mem_free(roam_profile->fils_con_info); |
| 18274 | roam_profile->fils_con_info = NULL; |
| 18275 | } |
| 18276 | return -EINVAL; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 18277 | } |
| 18278 | |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 18279 | static bool wlan_hdd_is_akm_suite_fils(uint32_t key_mgmt) |
| 18280 | { |
| 18281 | switch (key_mgmt) { |
| 18282 | case WLAN_AKM_SUITE_FILS_SHA256: |
| 18283 | case WLAN_AKM_SUITE_FILS_SHA384: |
| 18284 | case WLAN_AKM_SUITE_FT_FILS_SHA256: |
| 18285 | case WLAN_AKM_SUITE_FT_FILS_SHA384: |
| 18286 | return true; |
| 18287 | default: |
| 18288 | return false; |
| 18289 | } |
| 18290 | } |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 18291 | |
| 18292 | static bool wlan_hdd_is_conn_type_fils(struct cfg80211_connect_params *req) |
| 18293 | { |
| 18294 | enum nl80211_auth_type auth_type = req->auth_type; |
| 18295 | /* |
| 18296 | * Below n_akm_suites is defined as int in the kernel, even though it |
| 18297 | * is supposed to be unsigned. |
| 18298 | */ |
| 18299 | int num_akm_suites = req->crypto.n_akm_suites; |
| 18300 | uint32_t key_mgmt = req->crypto.akm_suites[0]; |
| 18301 | enum eAniAuthType fils_auth_type = |
| 18302 | wlan_hdd_get_fils_auth_type(req->auth_type); |
| 18303 | |
| 18304 | hdd_debug("Num of AKM suites = %d", num_akm_suites); |
| 18305 | if (num_akm_suites <= 0) |
| 18306 | return false; |
| 18307 | |
| 18308 | /* |
| 18309 | * Auth type will be either be OPEN or FILS type for a FILS connection |
| 18310 | */ |
| 18311 | if ((auth_type != NL80211_AUTHTYPE_OPEN_SYSTEM) && |
| 18312 | (fils_auth_type == eSIR_DONOT_USE_AUTH_TYPE)) { |
| 18313 | hdd_debug("Not a FILS auth type, auth = %d, fils auth = %d", |
| 18314 | auth_type, fils_auth_type); |
| 18315 | return false; |
| 18316 | } |
| 18317 | |
| 18318 | if (!wlan_hdd_is_akm_suite_fils(key_mgmt)) { |
| 18319 | hdd_debug("Not a FILS AKM SUITE %d", key_mgmt); |
| 18320 | return false; |
| 18321 | } |
| 18322 | |
| 18323 | return true; |
| 18324 | } |
| 18325 | |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 18326 | #else |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18327 | 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] | 18328 | { |
| 18329 | return true; |
| 18330 | } |
| 18331 | |
| 18332 | static int wlan_hdd_cfg80211_set_fils_config(struct hdd_adapter *adapter, |
| 18333 | struct cfg80211_connect_params *req) |
| 18334 | { |
| 18335 | return 0; |
| 18336 | } |
| 18337 | |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 18338 | static bool wlan_hdd_is_akm_suite_fils(uint32_t key_mgmt) |
| 18339 | { |
| 18340 | return false; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18341 | } |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 18342 | |
| 18343 | static bool wlan_hdd_is_conn_type_fils(struct cfg80211_connect_params *req) |
| 18344 | { |
| 18345 | return false; |
| 18346 | } |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18347 | #endif |
| 18348 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18349 | /** |
| 18350 | * wlan_hdd_set_akm_suite() - set key management type |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18351 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18352 | * @key_mgmt: Key management type |
| 18353 | * |
| 18354 | * This function is used to set the key mgmt type(PSK/8021x). |
| 18355 | * |
| 18356 | * Return: 0 for success, non-zero for failure |
| 18357 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18358 | 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] | 18359 | { |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18360 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 18361 | struct csr_roam_profile *roam_profile; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18362 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18363 | roam_profile = hdd_roam_profile(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18364 | |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 18365 | if (wlan_hdd_is_akm_suite_fils(key_mgmt) && |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18366 | !hdd_validate_fils_info_ptr(roam_profile)) |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 18367 | return -EINVAL; |
Vidyullatha Kanchanapally | 7b5bee0 | 2017-04-13 14:00:56 +0530 | [diff] [blame] | 18368 | #ifndef WLAN_AKM_SUITE_8021X_SHA256 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18369 | #define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05 |
Vidyullatha Kanchanapally | 7b5bee0 | 2017-04-13 14:00:56 +0530 | [diff] [blame] | 18370 | #endif |
| 18371 | #ifndef WLAN_AKM_SUITE_PSK_SHA256 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18372 | #define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06 |
Vidyullatha Kanchanapally | 7b5bee0 | 2017-04-13 14:00:56 +0530 | [diff] [blame] | 18373 | #endif |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18374 | |
| 18375 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 18376 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18377 | /*set key mgmt type */ |
| 18378 | switch (key_mgmt) { |
| 18379 | case WLAN_AKM_SUITE_PSK: |
| 18380 | case WLAN_AKM_SUITE_PSK_SHA256: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18381 | case WLAN_AKM_SUITE_FT_PSK: |
Abhishek Singh | 02cb9e0 | 2017-08-30 17:39:50 +0530 | [diff] [blame] | 18382 | case WLAN_AKM_SUITE_DPP_RSN: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18383 | hdd_debug("setting key mgmt type to PSK"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18384 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_PSK; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18385 | break; |
| 18386 | |
| 18387 | case WLAN_AKM_SUITE_8021X_SHA256: |
| 18388 | case WLAN_AKM_SUITE_8021X: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18389 | case WLAN_AKM_SUITE_FT_8021X: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18390 | hdd_debug("setting key mgmt type to 8021x"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18391 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18392 | break; |
| 18393 | #ifdef FEATURE_WLAN_ESE |
| 18394 | #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] | 18395 | case WLAN_AKM_SUITE_CCKM: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18396 | hdd_debug("setting key mgmt type to CCKM"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18397 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_CCKM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18398 | break; |
| 18399 | #endif |
| 18400 | #ifndef WLAN_AKM_SUITE_OSEN |
| 18401 | #define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */ |
| 18402 | #endif |
| 18403 | case WLAN_AKM_SUITE_OSEN: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18404 | hdd_debug("setting key mgmt type to OSEN"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18405 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18406 | break; |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 18407 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 18408 | (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 18409 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) |
Sridhar Selvaraj | 6cf642f | 2017-08-21 14:28:10 +0530 | [diff] [blame] | 18410 | case WLAN_AKM_SUITE_FILS_SHA256: |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18411 | hdd_debug("setting key mgmt type to FILS SHA256"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18412 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18413 | roam_profile->fils_con_info->akm_type = |
| 18414 | eCSR_AUTH_TYPE_FILS_SHA256; |
| 18415 | break; |
| 18416 | |
| 18417 | case WLAN_AKM_SUITE_FILS_SHA384: |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 18418 | hdd_debug("setting key mgmt type to FILS SHA384"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18419 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18420 | roam_profile->fils_con_info->akm_type = |
| 18421 | eCSR_AUTH_TYPE_FILS_SHA384; |
| 18422 | break; |
| 18423 | |
| 18424 | case WLAN_AKM_SUITE_FT_FILS_SHA256: |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 18425 | hdd_debug("setting key mgmt type to FILS FT SHA256"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18426 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18427 | roam_profile->fils_con_info->akm_type = |
| 18428 | eCSR_AUTH_TYPE_FT_FILS_SHA256; |
| 18429 | break; |
| 18430 | |
| 18431 | case WLAN_AKM_SUITE_FT_FILS_SHA384: |
Varun Reddy Yeturu | 625a641 | 2017-10-23 10:20:01 -0700 | [diff] [blame] | 18432 | hdd_debug("setting key mgmt type to FILS FT SHA384"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18433 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 18434 | roam_profile->fils_con_info->akm_type = |
| 18435 | eCSR_AUTH_TYPE_FT_FILS_SHA384; |
Sridhar Selvaraj | 6cf642f | 2017-08-21 14:28:10 +0530 | [diff] [blame] | 18436 | break; |
| 18437 | #endif |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 18438 | |
| 18439 | case WLAN_AKM_SUITE_OWE: |
| 18440 | hdd_debug("setting key mgmt type to OWE"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18441 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 18442 | break; |
| 18443 | |
Padma, Santhosh Kumar | e587a5c | 2017-12-21 12:44:46 +0530 | [diff] [blame] | 18444 | case WLAN_AKM_SUITE_EAP_SHA256: |
| 18445 | hdd_debug("setting key mgmt type to EAP_SHA256"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18446 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Padma, Santhosh Kumar | e587a5c | 2017-12-21 12:44:46 +0530 | [diff] [blame] | 18447 | break; |
| 18448 | case WLAN_AKM_SUITE_EAP_SHA384: |
| 18449 | hdd_debug("setting key mgmt type to EAP_SHA384"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18450 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Padma, Santhosh Kumar | e587a5c | 2017-12-21 12:44:46 +0530 | [diff] [blame] | 18451 | break; |
| 18452 | |
Padma, Santhosh Kumar | 07eb80b | 2017-07-05 16:10:06 +0530 | [diff] [blame] | 18453 | case WLAN_AKM_SUITE_SAE: |
| 18454 | hdd_debug("setting key mgmt type to SAE"); |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 18455 | sta_ctx->auth_key_mgmt |= HDD_AUTH_KEY_MGMT_802_1X; |
Padma, Santhosh Kumar | 07eb80b | 2017-07-05 16:10:06 +0530 | [diff] [blame] | 18456 | break; |
| 18457 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18458 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18459 | hdd_err("Unsupported key mgmt type: %d", key_mgmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18460 | return -EINVAL; |
| 18461 | |
| 18462 | } |
| 18463 | return 0; |
| 18464 | } |
| 18465 | |
| 18466 | /** |
| 18467 | * wlan_hdd_cfg80211_set_cipher() - set encryption type |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18468 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18469 | * @cipher: Cipher type |
| 18470 | * @ucast: Unicast flag |
| 18471 | * |
| 18472 | * This function is used to set the encryption type |
| 18473 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 18474 | * |
| 18475 | * Return: 0 for success, non-zero for failure |
| 18476 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18477 | static int wlan_hdd_cfg80211_set_cipher(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18478 | u32 cipher, bool ucast) |
| 18479 | { |
| 18480 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18481 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18482 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18483 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18484 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18485 | if (!cipher) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18486 | hdd_debug("received cipher %d - considering none", cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18487 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 18488 | } else { |
| 18489 | |
| 18490 | /*set encryption method */ |
| 18491 | switch (cipher) { |
| 18492 | case IW_AUTH_CIPHER_NONE: |
| 18493 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 18494 | break; |
| 18495 | |
| 18496 | case WLAN_CIPHER_SUITE_WEP40: |
| 18497 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
| 18498 | break; |
| 18499 | |
| 18500 | case WLAN_CIPHER_SUITE_WEP104: |
| 18501 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
| 18502 | break; |
| 18503 | |
| 18504 | case WLAN_CIPHER_SUITE_TKIP: |
| 18505 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 18506 | break; |
| 18507 | |
| 18508 | case WLAN_CIPHER_SUITE_CCMP: |
| 18509 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 18510 | break; |
| 18511 | #ifdef FEATURE_WLAN_WAPI |
| 18512 | case WLAN_CIPHER_SUITE_SMS4: |
| 18513 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 18514 | break; |
| 18515 | #endif |
| 18516 | |
| 18517 | #ifdef FEATURE_WLAN_ESE |
| 18518 | case WLAN_CIPHER_SUITE_KRK: |
| 18519 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 18520 | break; |
| 18521 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 18522 | case WLAN_CIPHER_SUITE_BTK: |
| 18523 | encryptionType = eCSR_ENCRYPT_TYPE_BTK; |
| 18524 | break; |
| 18525 | #endif |
| 18526 | #endif |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 18527 | case WLAN_CIPHER_SUITE_GCMP: |
| 18528 | encryptionType = eCSR_ENCRYPT_TYPE_AES_GCMP; |
| 18529 | break; |
| 18530 | case WLAN_CIPHER_SUITE_GCMP_256: |
| 18531 | encryptionType = eCSR_ENCRYPT_TYPE_AES_GCMP_256; |
| 18532 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18533 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18534 | hdd_err("Unsupported cipher type: %d", cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18535 | return -EOPNOTSUPP; |
| 18536 | } |
| 18537 | } |
| 18538 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18539 | roam_profile = hdd_roam_profile(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18540 | if (ucast) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18541 | hdd_debug("setting unicast cipher type to %d", encryptionType); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18542 | sta_ctx->conn_info.ucEncryptionType = encryptionType; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18543 | roam_profile->EncryptionType.numEntries = 1; |
| 18544 | roam_profile->EncryptionType.encryptionType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18545 | encryptionType; |
| 18546 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18547 | hdd_debug("setting mcast cipher type to %d", encryptionType); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 18548 | sta_ctx->conn_info.mcEncryptionType = encryptionType; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18549 | roam_profile->mcEncryptionType.numEntries = 1; |
| 18550 | roam_profile->mcEncryptionType.encryptionType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18551 | encryptionType; |
| 18552 | } |
| 18553 | |
| 18554 | return 0; |
| 18555 | } |
| 18556 | |
| 18557 | /** |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18558 | * wlan_hdd_add_assoc_ie() - Add Assoc IE to roamProfile |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18559 | * @adapter: Pointer to adapter |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18560 | * @gen_ie: Pointer to IE data |
| 18561 | * @len: length of IE data |
| 18562 | * |
| 18563 | * Return: 0 for success, non-zero for failure |
| 18564 | */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18565 | static int wlan_hdd_add_assoc_ie(struct hdd_adapter *adapter, |
| 18566 | const uint8_t *gen_ie, uint16_t len) |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18567 | { |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18568 | struct csr_roam_profile *roam_profile; |
| 18569 | tSirAddie *assoc_add_ie; |
| 18570 | uint16_t cur_add_ie_len; |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18571 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18572 | assoc_add_ie = hdd_assoc_additional_ie(adapter); |
| 18573 | cur_add_ie_len = assoc_add_ie->length; |
| 18574 | if (SIR_MAC_MAX_ADD_IE_LENGTH < (cur_add_ie_len + len)) { |
| 18575 | hdd_err("current len %u, new ie of len %u will overflow", |
| 18576 | cur_add_ie_len, len); |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18577 | return -ENOMEM; |
| 18578 | } |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18579 | memcpy(assoc_add_ie->addIEdata + cur_add_ie_len, gen_ie, len); |
| 18580 | assoc_add_ie->length += len; |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18581 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18582 | roam_profile = hdd_roam_profile(adapter); |
| 18583 | roam_profile->pAddIEAssoc = assoc_add_ie->addIEdata; |
| 18584 | roam_profile->nAddIEAssocLength = assoc_add_ie->length; |
| 18585 | |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18586 | return 0; |
| 18587 | } |
| 18588 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 18589 | #ifdef WLAN_FEATURE_FILS_SK |
| 18590 | /** |
| 18591 | * wlan_hdd_save_hlp_ie - API to save HLP IE |
| 18592 | * @roam_profile: Pointer to roam profile |
| 18593 | * @gen_ie: IE buffer to store |
| 18594 | * @len: length of the IE buffer @gen_ie |
| 18595 | * @flush: Flush the older saved HLP if any |
| 18596 | * |
| 18597 | * Return: None |
| 18598 | */ |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 18599 | 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] | 18600 | const uint8_t *gen_ie, uint16_t len, |
| 18601 | bool flush) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 18602 | { |
| 18603 | uint8_t *hlp_ie = roam_profile->hlp_ie; |
| 18604 | |
| 18605 | if (flush) { |
| 18606 | roam_profile->hlp_ie_len = 0; |
| 18607 | if (hlp_ie) { |
| 18608 | qdf_mem_free(hlp_ie); |
| 18609 | roam_profile->hlp_ie = NULL; |
| 18610 | } |
| 18611 | } |
| 18612 | |
| 18613 | if ((roam_profile->hlp_ie_len + |
| 18614 | len) > FILS_MAX_HLP_DATA_LEN) { |
| 18615 | hdd_err("HLP len exceeds: hlp_ie_len %d len %d", |
| 18616 | roam_profile->hlp_ie_len, len); |
| 18617 | return; |
| 18618 | } |
| 18619 | |
| 18620 | if (!roam_profile->hlp_ie) { |
| 18621 | roam_profile->hlp_ie = |
| 18622 | qdf_mem_malloc(FILS_MAX_HLP_DATA_LEN); |
| 18623 | hlp_ie = roam_profile->hlp_ie; |
| 18624 | if (!hlp_ie) { |
| 18625 | hdd_err("HLP IE mem alloc fails"); |
| 18626 | return; |
| 18627 | } |
| 18628 | } |
| 18629 | |
| 18630 | qdf_mem_copy(hlp_ie + roam_profile->hlp_ie_len, gen_ie, len); |
| 18631 | roam_profile->hlp_ie_len += len; |
| 18632 | } |
| 18633 | #else |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 18634 | 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] | 18635 | const uint8_t *gen_ie, uint16_t len, |
| 18636 | bool flush) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 18637 | {} |
| 18638 | #endif |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18639 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18640 | * wlan_hdd_cfg80211_set_ie() - set IEs |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18641 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18642 | * @ie: Pointer ot ie |
| 18643 | * @ie: IE length |
| 18644 | * |
| 18645 | * Return: 0 for success, non-zero for failure |
| 18646 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18647 | static int wlan_hdd_cfg80211_set_ie(struct hdd_adapter *adapter, |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 18648 | const uint8_t *ie, |
| 18649 | size_t ie_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18650 | { |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18651 | struct csr_roam_profile *roam_profile; |
| 18652 | tSirAddie *assoc_add_ie; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18653 | const uint8_t *genie = ie; |
| 18654 | uint16_t remLen = ie_len; |
| 18655 | #ifdef FEATURE_WLAN_WAPI |
| 18656 | uint32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 18657 | u16 *tmp; |
| 18658 | uint16_t akmsuiteCount; |
| 18659 | int *akmlist; |
| 18660 | #endif |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18661 | int status; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18662 | uint8_t *security_ie; |
| 18663 | |
| 18664 | roam_profile = hdd_roam_profile(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18665 | |
| 18666 | /* clear previous assocAddIE */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18667 | assoc_add_ie = hdd_assoc_additional_ie(adapter); |
| 18668 | assoc_add_ie->length = 0; |
| 18669 | roam_profile->bWPSAssociation = false; |
| 18670 | roam_profile->bOSENAssociation = false; |
| 18671 | security_ie = hdd_security_ie(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18672 | |
| 18673 | while (remLen >= 2) { |
| 18674 | uint16_t eLen = 0; |
| 18675 | uint8_t elementId; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 18676 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18677 | elementId = *genie++; |
| 18678 | eLen = *genie++; |
| 18679 | remLen -= 2; |
| 18680 | |
Nachiket Kukade | 4bea8b4 | 2017-06-13 11:53:19 +0530 | [diff] [blame] | 18681 | /* Sanity check on eLen */ |
| 18682 | if (eLen > remLen) { |
| 18683 | hdd_err("%s: Invalid IE length[%d] for IE[0x%X]", |
| 18684 | __func__, eLen, elementId); |
| 18685 | QDF_ASSERT(0); |
| 18686 | return -EINVAL; |
| 18687 | } |
| 18688 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18689 | hdd_debug("IE[0x%X], LEN[%d]", elementId, eLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18690 | |
| 18691 | switch (elementId) { |
| 18692 | case DOT11F_EID_WPA: |
| 18693 | 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] | 18694 | hdd_err("Invalid WPA IE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18695 | return -EINVAL; |
| 18696 | } else if (0 == |
| 18697 | memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) { |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18698 | uint16_t curAddIELen = assoc_add_ie->length; |
| 18699 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18700 | hdd_debug("Set WPS IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18701 | |
| 18702 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18703 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 18704 | hdd_err("Cannot accommodate assocAddIE. Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 18705 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18706 | return -ENOMEM; |
| 18707 | } |
| 18708 | /* 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] | 18709 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18710 | curAddIELen, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18711 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18712 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18713 | roam_profile->bWPSAssociation = true; |
| 18714 | roam_profile->pAddIEAssoc = |
| 18715 | assoc_add_ie->addIEdata; |
| 18716 | roam_profile->nAddIEAssocLength = |
| 18717 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18718 | } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) { |
Nachiket Kukade | 2f6509f | 2017-06-13 17:45:46 +0530 | [diff] [blame] | 18719 | if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) { |
| 18720 | hdd_err("%s: Invalid WPA IE length[%d]", |
| 18721 | __func__, eLen); |
| 18722 | QDF_ASSERT(0); |
| 18723 | return -EINVAL; |
| 18724 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18725 | hdd_debug("Set WPA IE (len %d)", eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18726 | memset(security_ie, 0, MAX_WPA_RSN_IE_LEN); |
| 18727 | memcpy(security_ie, genie - 2, (eLen + 2)); |
| 18728 | roam_profile->pWPAReqIE = security_ie; |
| 18729 | roam_profile->nWPAReqIELength = eLen + 2; /* ie_len; */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18730 | } else if ((0 == memcmp(&genie[0], P2P_OUI_TYPE, |
| 18731 | P2P_OUI_TYPE_SIZE))) { |
| 18732 | uint16_t curAddIELen = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18733 | assoc_add_ie->length; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18734 | hdd_debug("Set P2P IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18735 | |
| 18736 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18737 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 18738 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 18739 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18740 | return -ENOMEM; |
| 18741 | } |
| 18742 | /* 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] | 18743 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18744 | curAddIELen, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18745 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18746 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18747 | roam_profile->pAddIEAssoc = |
| 18748 | assoc_add_ie->addIEdata; |
| 18749 | roam_profile->nAddIEAssocLength = |
| 18750 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18751 | } |
| 18752 | #ifdef WLAN_FEATURE_WFD |
| 18753 | else if ((0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 18754 | WFD_OUI_TYPE_SIZE)) && |
| 18755 | /* Consider WFD IE, only for P2P Client */ |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 18756 | (QDF_P2P_CLIENT_MODE == |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 18757 | adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18758 | uint16_t curAddIELen = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18759 | assoc_add_ie->length; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18760 | hdd_debug("Set WFD IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18761 | |
| 18762 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18763 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 18764 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 18765 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18766 | return -ENOMEM; |
| 18767 | } |
| 18768 | /* WFD IE is saved to Additional IE ; it should |
| 18769 | * be accumulated to handle WPS IE + P2P IE + |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 18770 | * WFD IE |
| 18771 | */ |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18772 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18773 | curAddIELen, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18774 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18775 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18776 | roam_profile->pAddIEAssoc = |
| 18777 | assoc_add_ie->addIEdata; |
| 18778 | roam_profile->nAddIEAssocLength = |
| 18779 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18780 | } |
| 18781 | #endif |
| 18782 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
| 18783 | else if ((0 == memcmp(&genie[0], HS20_OUI_TYPE, |
| 18784 | HS20_OUI_TYPE_SIZE))) { |
| 18785 | uint16_t curAddIELen = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18786 | assoc_add_ie->length; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18787 | hdd_debug("Set HS20 IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18788 | |
| 18789 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18790 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 18791 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 18792 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18793 | return -ENOMEM; |
| 18794 | } |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18795 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18796 | curAddIELen, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18797 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18798 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18799 | roam_profile->pAddIEAssoc = |
| 18800 | assoc_add_ie->addIEdata; |
| 18801 | roam_profile->nAddIEAssocLength = |
| 18802 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18803 | } |
| 18804 | /* Appending OSEN Information Element in Assiciation Request */ |
| 18805 | else if ((0 == memcmp(&genie[0], OSEN_OUI_TYPE, |
| 18806 | OSEN_OUI_TYPE_SIZE))) { |
| 18807 | uint16_t curAddIELen = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18808 | assoc_add_ie->length; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18809 | hdd_debug("Set OSEN IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18810 | |
| 18811 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18812 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 18813 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 18814 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18815 | return -ENOMEM; |
| 18816 | } |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18817 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18818 | curAddIELen, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18819 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18820 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18821 | roam_profile->bOSENAssociation = true; |
| 18822 | roam_profile->pAddIEAssoc = |
| 18823 | assoc_add_ie->addIEdata; |
| 18824 | roam_profile->nAddIEAssocLength = |
| 18825 | assoc_add_ie->length; |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18826 | } else if ((0 == memcmp(&genie[0], MBO_OUI_TYPE, |
| 18827 | MBO_OUI_TYPE_SIZE))){ |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18828 | hdd_debug("Set MBO IE(len %d)", eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18829 | status = wlan_hdd_add_assoc_ie(adapter, |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18830 | genie - 2, eLen + 2); |
| 18831 | if (status) |
| 18832 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18833 | } else { |
| 18834 | uint16_t add_ie_len = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18835 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18836 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18837 | hdd_debug("Set OSEN IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18838 | |
| 18839 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18840 | (assoc_add_ie->length + eLen)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18841 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 18842 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18843 | return -ENOMEM; |
| 18844 | } |
| 18845 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18846 | memcpy(assoc_add_ie->addIEdata + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18847 | add_ie_len, genie - 2, eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18848 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18849 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18850 | roam_profile->pAddIEAssoc = |
| 18851 | assoc_add_ie->addIEdata; |
| 18852 | roam_profile->nAddIEAssocLength = |
| 18853 | assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18854 | } |
| 18855 | break; |
| 18856 | case DOT11F_EID_RSN: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18857 | hdd_debug("Set RSN IE(len %d)", eLen + 2); |
Vignesh Viswanathan | 96e0e70 | 2017-12-05 19:42:46 +0530 | [diff] [blame] | 18858 | if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) { |
| 18859 | hdd_err("%s: Invalid WPA RSN IE length[%d]", |
| 18860 | __func__, eLen); |
| 18861 | return -EINVAL; |
| 18862 | } |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18863 | memset(security_ie, 0, MAX_WPA_RSN_IE_LEN); |
| 18864 | memcpy(security_ie, genie - 2, (eLen + 2)); |
| 18865 | roam_profile->pRSNReqIE = security_ie; |
| 18866 | roam_profile->nRSNReqIELength = eLen + 2; /* ie_len; */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18867 | break; |
| 18868 | /* |
| 18869 | * Appending Extended Capabilities with Interworking bit set |
| 18870 | * in Assoc Req. |
| 18871 | * |
| 18872 | * In assoc req this EXT Cap will only be taken into account if |
| 18873 | * interworkingService bit is set to 1. Currently |
| 18874 | * driver is only interested in interworkingService capability |
| 18875 | * from supplicant. If in future any other EXT Cap info is |
| 18876 | * required from supplicat, it needs to be handled while |
| 18877 | * sending Assoc Req in LIM. |
| 18878 | */ |
| 18879 | case DOT11F_EID_EXTCAP: |
| 18880 | { |
| 18881 | uint16_t curAddIELen = |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18882 | assoc_add_ie->length; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18883 | hdd_debug("Set Extended CAPS IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18884 | |
| 18885 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18886 | (assoc_add_ie->length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 18887 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 18888 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18889 | return -ENOMEM; |
| 18890 | } |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18891 | memcpy(assoc_add_ie->addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 18892 | assoc_add_ie->length += eLen + 2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18893 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18894 | roam_profile->pAddIEAssoc = assoc_add_ie->addIEdata; |
| 18895 | roam_profile->nAddIEAssocLength = assoc_add_ie->length; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18896 | break; |
| 18897 | } |
| 18898 | #ifdef FEATURE_WLAN_WAPI |
| 18899 | case WLAN_EID_WAPI: |
| 18900 | /* Setting WAPI Mode to ON=1 */ |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 18901 | adapter->wapi_info.wapi_mode = true; |
| 18902 | hdd_debug("WAPI MODE IS %u", adapter->wapi_info.wapi_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18903 | tmp = (u16 *) ie; |
| 18904 | tmp = tmp + 2; /* Skip element Id and Len, Version */ |
| 18905 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 18906 | tmp = tmp + 1; |
| 18907 | akmlist = (int *)(tmp); |
| 18908 | if (akmsuiteCount <= MAX_NUM_AKM_SUITES) { |
| 18909 | memcpy(akmsuite, akmlist, (4 * akmsuiteCount)); |
| 18910 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18911 | hdd_err("Invalid akmSuite count: %u", |
| 18912 | akmsuiteCount); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 18913 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18914 | return -EINVAL; |
| 18915 | } |
| 18916 | |
| 18917 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18918 | hdd_debug("WAPI AUTH MODE SET TO PSK"); |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 18919 | adapter->wapi_info.wapi_auth_mode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18920 | WAPI_AUTH_MODE_PSK; |
| 18921 | } |
| 18922 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18923 | hdd_debug("WAPI AUTH MODE SET TO CERTIFICATE"); |
Jeff Johnson | 7d2f4c6 | 2017-11-02 09:25:45 -0700 | [diff] [blame] | 18924 | adapter->wapi_info.wapi_auth_mode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18925 | WAPI_AUTH_MODE_CERT; |
| 18926 | } |
| 18927 | break; |
| 18928 | #endif |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18929 | case DOT11F_EID_SUPPOPERATINGCLASSES: |
| 18930 | { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18931 | hdd_debug("Set Supported Operating Classes IE(len %d)", eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18932 | status = wlan_hdd_add_assoc_ie(adapter, |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 18933 | genie - 2, eLen + 2); |
| 18934 | if (status) |
| 18935 | return status; |
| 18936 | break; |
| 18937 | } |
Sridhar Selvaraj | 6d3e0d7 | 2017-08-17 17:32:37 +0530 | [diff] [blame] | 18938 | case SIR_MAC_REQUEST_EID_MAX: |
| 18939 | { |
| 18940 | if (genie[0] == SIR_FILS_HLP_EXT_EID) { |
| 18941 | hdd_debug("Set HLP EXT IE(len %d)", |
| 18942 | eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18943 | wlan_hdd_save_hlp_ie(roam_profile, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 18944 | genie - 2, eLen + 2, |
| 18945 | true); |
Sridhar Selvaraj | 6d3e0d7 | 2017-08-17 17:32:37 +0530 | [diff] [blame] | 18946 | status = wlan_hdd_add_assoc_ie( |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18947 | adapter, genie - 2, |
Sridhar Selvaraj | 6d3e0d7 | 2017-08-17 17:32:37 +0530 | [diff] [blame] | 18948 | eLen + 2); |
| 18949 | if (status) |
| 18950 | return status; |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 18951 | } else if (genie[0] == |
| 18952 | SIR_DH_PARAMETER_ELEMENT_EXT_EID) { |
| 18953 | hdd_debug("Set DH EXT IE(len %d)", |
| 18954 | eLen + 2); |
| 18955 | status = wlan_hdd_add_assoc_ie( |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18956 | adapter, genie - 2, |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 18957 | eLen + 2); |
| 18958 | if (status) |
| 18959 | return status; |
Sridhar Selvaraj | 6d3e0d7 | 2017-08-17 17:32:37 +0530 | [diff] [blame] | 18960 | } else { |
| 18961 | hdd_err("UNKNOWN EID: %X", genie[0]); |
| 18962 | } |
| 18963 | break; |
| 18964 | } |
| 18965 | case DOT11F_EID_FRAGMENT_IE: |
| 18966 | { |
| 18967 | hdd_debug("Set Fragment IE(len %d)", eLen + 2); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18968 | wlan_hdd_save_hlp_ie(roam_profile, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 18969 | genie - 2, eLen + 2, |
| 18970 | false); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 18971 | status = wlan_hdd_add_assoc_ie(adapter, |
Sridhar Selvaraj | 6d3e0d7 | 2017-08-17 17:32:37 +0530 | [diff] [blame] | 18972 | genie - 2, eLen + 2); |
| 18973 | if (status) |
| 18974 | return status; |
| 18975 | break; |
| 18976 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18977 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 18978 | hdd_err("Set UNKNOWN IE: %X", elementId); |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 18979 | /* when Unknown IE is received we break |
| 18980 | * and continue to the next IE in the buffer |
| 18981 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18982 | break; |
| 18983 | } |
| 18984 | genie += eLen; |
| 18985 | remLen -= eLen; |
| 18986 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 18987 | return 0; |
| 18988 | } |
| 18989 | |
| 18990 | /** |
| 18991 | * hdd_is_wpaie_present() - check for WPA ie |
| 18992 | * @ie: Pointer to ie |
| 18993 | * @ie_len: Ie length |
| 18994 | * |
| 18995 | * Parse the received IE to find the WPA IE |
| 18996 | * |
| 18997 | * Return: true if wpa ie is found else false |
| 18998 | */ |
| 18999 | static bool hdd_is_wpaie_present(const uint8_t *ie, uint8_t ie_len) |
| 19000 | { |
| 19001 | uint8_t eLen = 0; |
| 19002 | uint16_t remLen = ie_len; |
| 19003 | uint8_t elementId = 0; |
| 19004 | |
| 19005 | while (remLen >= 2) { |
| 19006 | elementId = *ie++; |
| 19007 | eLen = *ie++; |
| 19008 | remLen -= 2; |
| 19009 | if (eLen > remLen) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19010 | hdd_err("Invalid IE length: %d", eLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19011 | return false; |
| 19012 | } |
| 19013 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) { |
| 19014 | /* OUI - 0x00 0X50 0XF2 |
| 19015 | * WPA Information Element - 0x01 |
| 19016 | * WPA version - 0x01 |
| 19017 | */ |
| 19018 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 19019 | return true; |
| 19020 | } |
| 19021 | ie += eLen; |
| 19022 | remLen -= eLen; |
| 19023 | } |
| 19024 | return false; |
| 19025 | } |
| 19026 | |
| 19027 | /** |
| 19028 | * wlan_hdd_cfg80211_set_privacy() - set security parameters during connection |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19029 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19030 | * @req: Pointer to security parameters |
| 19031 | * |
| 19032 | * Return: 0 for success, non-zero for failure |
| 19033 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19034 | static int wlan_hdd_cfg80211_set_privacy(struct hdd_adapter *adapter, |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 19035 | struct cfg80211_connect_params *req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19036 | { |
| 19037 | int status = 0; |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 19038 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19039 | struct csr_roam_profile *roam_profile; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 19040 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19041 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19042 | |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 19043 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 19044 | sta_ctx->wpa_versions = req->crypto.wpa_versions; |
| 19045 | hdd_debug("set wpa version to %d", sta_ctx->wpa_versions); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19046 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19047 | roam_profile = hdd_roam_profile(adapter); |
| 19048 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19049 | /*set authentication type */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19050 | status = wlan_hdd_cfg80211_set_auth_type(adapter, req->auth_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19051 | |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 19052 | if (wlan_hdd_is_conn_type_fils(req)) { |
| 19053 | status = wlan_hdd_cfg80211_set_fils_config(adapter, req); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 19054 | |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 19055 | if (0 > status) { |
| 19056 | hdd_err("Failed to set fils config"); |
| 19057 | return status; |
| 19058 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19059 | } |
| 19060 | |
| 19061 | /*set key mgmt type */ |
| 19062 | if (req->crypto.n_akm_suites) { |
| 19063 | status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19064 | wlan_hdd_set_akm_suite(adapter, req->crypto.akm_suites[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19065 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19066 | hdd_err("Failed to set akm suite"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19067 | return status; |
| 19068 | } |
| 19069 | } |
| 19070 | |
| 19071 | /*set pairwise cipher type */ |
| 19072 | if (req->crypto.n_ciphers_pairwise) { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19073 | status = wlan_hdd_cfg80211_set_cipher(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19074 | req->crypto. |
| 19075 | ciphers_pairwise[0], |
| 19076 | true); |
| 19077 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19078 | hdd_err("Failed to set unicast cipher type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19079 | return status; |
| 19080 | } |
| 19081 | } else { |
| 19082 | /*Reset previous cipher suite to none */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19083 | status = wlan_hdd_cfg80211_set_cipher(adapter, 0, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19084 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19085 | hdd_err("Failed to set unicast cipher type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19086 | return status; |
| 19087 | } |
| 19088 | } |
| 19089 | |
| 19090 | /*set group cipher type */ |
| 19091 | status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19092 | wlan_hdd_cfg80211_set_cipher(adapter, req->crypto.cipher_group, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19093 | false); |
| 19094 | |
| 19095 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19096 | hdd_err("Failed to set mcast cipher type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19097 | return status; |
| 19098 | } |
| 19099 | #ifdef WLAN_FEATURE_11W |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19100 | roam_profile->MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19101 | #endif |
| 19102 | |
| 19103 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile */ |
| 19104 | if (req->ie_len) { |
| 19105 | status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19106 | wlan_hdd_cfg80211_set_ie(adapter, req->ie, req->ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19107 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19108 | hdd_err("Failed to parse the WPA/RSN IE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19109 | return status; |
| 19110 | } |
| 19111 | } |
| 19112 | |
| 19113 | /*incase of WEP set default key information */ |
| 19114 | if (req->key && req->key_len) { |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 19115 | u8 key_len = req->key_len; |
| 19116 | u8 key_idx = req->key_idx; |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 19117 | u32 cipher = req->crypto.ciphers_pairwise[0]; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 19118 | |
Jeff Johnson | 37ecea4 | 2018-03-18 17:54:40 -0700 | [diff] [blame] | 19119 | if ((WLAN_CIPHER_SUITE_WEP40 == cipher) || |
| 19120 | (WLAN_CIPHER_SUITE_WEP104 == cipher)) { |
| 19121 | enum hdd_auth_key_mgmt key_mgmt = |
| 19122 | sta_ctx->auth_key_mgmt; |
| 19123 | |
| 19124 | if (key_mgmt & HDD_AUTH_KEY_MGMT_802_1X) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19125 | hdd_err("Dynamic WEP not supported"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19126 | return -EOPNOTSUPP; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 19127 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19128 | |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 19129 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
| 19130 | && (CSR_MAX_NUM_KEY > key_idx)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19131 | hdd_debug("setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 19132 | key_idx, key_len); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19133 | qdf_mem_copy(&roam_profile->Keys. |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 19134 | KeyMaterial[key_idx][0], |
| 19135 | req->key, key_len); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19136 | roam_profile->Keys. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19137 | KeyLength[key_idx] = (u8) key_len; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19138 | roam_profile->Keys. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19139 | defaultIndex = (u8) key_idx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19140 | } |
| 19141 | } |
| 19142 | } |
| 19143 | |
| 19144 | return status; |
| 19145 | } |
| 19146 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19147 | int wlan_hdd_try_disconnect(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19148 | { |
| 19149 | unsigned long rc; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19150 | struct hdd_station_ctx *sta_ctx; |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 19151 | int status, result = 0; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 19152 | tHalHandle hal; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19153 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19154 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19155 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 19156 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19157 | sme_indicate_disconnect_inprogress(hal, adapter->session_id); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19158 | hdd_debug("Stop firmware roaming"); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19159 | sme_stop_roaming(hal, adapter->session_id, eCsrForcedDisassoc); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 19160 | |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19161 | /* |
| 19162 | * If firmware has already started roaming process, driver |
| 19163 | * needs to wait for processing of this disconnect request. |
| 19164 | * |
| 19165 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19166 | INIT_COMPLETION(adapter->roaming_comp_var); |
| 19167 | if (hdd_is_roaming_in_progress(adapter)) { |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19168 | rc = wait_for_completion_timeout( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19169 | &adapter->roaming_comp_var, |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19170 | msecs_to_jiffies(WLAN_WAIT_TIME_STOP_ROAM)); |
| 19171 | if (!rc) { |
| 19172 | hdd_err("roaming comp var timed out session Id: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19173 | adapter->session_id); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19174 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19175 | if (adapter->roam_ho_fail) { |
| 19176 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 19177 | hdd_conn_set_connection_state(adapter, |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19178 | eConnectionState_Disconnecting); |
| 19179 | } |
| 19180 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 19181 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19182 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19183 | if ((QDF_IBSS_MODE == adapter->device_mode) || |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19184 | (eConnectionState_Associated == sta_ctx->conn_info.connState) || |
| 19185 | (eConnectionState_Connecting == sta_ctx->conn_info.connState) || |
| 19186 | (eConnectionState_IbssConnected == sta_ctx->conn_info.connState)) { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19187 | hdd_conn_set_connection_state(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19188 | eConnectionState_Disconnecting); |
| 19189 | /* Issue disconnect to CSR */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19190 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 19191 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19192 | status = sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19193 | adapter->session_id, |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 19194 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 19195 | /* |
| 19196 | * Wait here instead of returning directly, this will block the |
| 19197 | * next connect command and allow processing of the scan for |
| 19198 | * ssid and the previous connect command in CSR. Else we might |
| 19199 | * hit some race conditions leading to SME and HDD out of sync. |
| 19200 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 19201 | if (QDF_STATUS_CMD_NOT_QUEUED == status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19202 | 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] | 19203 | } else if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19204 | hdd_err("sme_roam_disconnect failure, status: %d", |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 19205 | (int)status); |
Jeff Johnson | 8380f23 | 2017-10-25 12:39:44 -0700 | [diff] [blame] | 19206 | sta_ctx->sta_debug_state = status; |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 19207 | result = -EINVAL; |
| 19208 | goto disconnected; |
| 19209 | } |
| 19210 | |
| 19211 | rc = wait_for_completion_timeout( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19212 | &adapter->disconnect_comp_var, |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 19213 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 19214 | if (!rc && (QDF_STATUS_CMD_NOT_QUEUED != status)) { |
Jeff Johnson | 8380f23 | 2017-10-25 12:39:44 -0700 | [diff] [blame] | 19215 | hdd_err("Sme disconnect event timed out session Id: %d sta_debug_state: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19216 | adapter->session_id, sta_ctx->sta_debug_state); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 19217 | result = -ETIMEDOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19218 | } |
| 19219 | } else if (eConnectionState_Disconnecting == |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19220 | sta_ctx->conn_info.connState) { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19221 | rc = wait_for_completion_timeout(&adapter->disconnect_comp_var, |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 19222 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19223 | if (!rc) { |
Jeff Johnson | 8380f23 | 2017-10-25 12:39:44 -0700 | [diff] [blame] | 19224 | hdd_err("Disconnect event timed out session Id: %d sta_debug_state: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19225 | adapter->session_id, sta_ctx->sta_debug_state); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 19226 | result = -ETIMEDOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19227 | } |
| 19228 | } |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 19229 | disconnected: |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19230 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 19231 | return result; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19232 | } |
| 19233 | |
| 19234 | /** |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19235 | * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present |
| 19236 | * @adapter: Pointer to the HDD adapter |
| 19237 | * @req: Pointer to the structure cfg_connect_params receieved from user space |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 19238 | * @status: out variable for status of reassoc request |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19239 | * |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 19240 | * This function will start reassociation if prev_bssid is set and bssid/ |
| 19241 | * bssid_hint, channel/channel_hint parameters are present in connect request. |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19242 | * |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 19243 | * Return: true if connect was for ReAssociation, false otherwise |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19244 | */ |
Selvaraj, Sridhar | a11edcb | 2016-09-07 18:49:14 +0530 | [diff] [blame] | 19245 | #if defined(CFG80211_CONNECT_PREV_BSSID) || \ |
| 19246 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 19247 | static bool wlan_hdd_reassoc_bssid_hint(struct hdd_adapter *adapter, |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 19248 | struct cfg80211_connect_params *req, |
| 19249 | int *status) |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19250 | { |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 19251 | bool reassoc = false; |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 19252 | const uint8_t *bssid = NULL; |
| 19253 | uint16_t channel = 0; |
Jeff Johnson | 731bc32 | 2017-10-14 19:53:44 -0700 | [diff] [blame] | 19254 | struct hdd_station_ctx *sta_ctx; |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 19255 | |
| 19256 | if (req->bssid) |
| 19257 | bssid = req->bssid; |
| 19258 | else if (req->bssid_hint) |
| 19259 | bssid = req->bssid_hint; |
| 19260 | |
| 19261 | if (req->channel) |
| 19262 | channel = req->channel->hw_value; |
| 19263 | else if (req->channel_hint) |
| 19264 | channel = req->channel_hint->hw_value; |
| 19265 | |
| 19266 | if (bssid && channel && req->prev_bssid) { |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 19267 | reassoc = true; |
Dustin Brown | bacc48f | 2018-03-14 14:48:44 -0700 | [diff] [blame] | 19268 | hdd_debug("REASSOC Attempt on channel %d to " MAC_ADDRESS_STR, |
| 19269 | channel, MAC_ADDR_ARRAY(bssid)); |
Arif Hussain | 43354e6 | 2017-05-24 11:24:25 -0700 | [diff] [blame] | 19270 | /* |
| 19271 | * Save BSSID in a separate variable as |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 19272 | * roam_profile's BSSID is getting zeroed out in the |
Arif Hussain | 43354e6 | 2017-05-24 11:24:25 -0700 | [diff] [blame] | 19273 | * association process. In case of join failure |
| 19274 | * we should send valid BSSID to supplicant |
| 19275 | */ |
Jeff Johnson | 731bc32 | 2017-10-14 19:53:44 -0700 | [diff] [blame] | 19276 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 19277 | qdf_mem_copy(sta_ctx->requested_bssid.bytes, bssid, |
Arif Hussain | 43354e6 | 2017-05-24 11:24:25 -0700 | [diff] [blame] | 19278 | QDF_MAC_ADDR_SIZE); |
| 19279 | |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 19280 | *status = hdd_reassoc(adapter, bssid, channel, |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19281 | CONNECT_CMD_USERSPACE); |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 19282 | hdd_debug("hdd_reassoc: status: %d", *status); |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19283 | } |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 19284 | return reassoc; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19285 | } |
| 19286 | #else |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 19287 | static bool wlan_hdd_reassoc_bssid_hint(struct hdd_adapter *adapter, |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 19288 | struct cfg80211_connect_params *req, |
| 19289 | int *status) |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19290 | { |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 19291 | return false; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19292 | } |
| 19293 | #endif |
| 19294 | |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 19295 | |
| 19296 | /** |
| 19297 | * wlan_hdd_check_ht20_ht40_ind() - check if Supplicant has indicated to |
| 19298 | * connect in HT20 mode |
| 19299 | * @hdd_ctx: hdd context |
| 19300 | * @adapter: Pointer to the HDD adapter |
| 19301 | * @req: Pointer to the structure cfg_connect_params receieved from user space |
| 19302 | * |
| 19303 | * This function will check if supplicant has indicated to to connect in HT20 |
| 19304 | * mode. this is currently applicable only for 2.4Ghz mode only. |
| 19305 | * if feature is enabled and supplicant indicate HT20 set |
| 19306 | * force_24ghz_in_ht20 to true to force 2.4Ghz in HT20 else set it to false. |
| 19307 | * |
| 19308 | * Return: void |
| 19309 | */ |
| 19310 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19311 | static void |
| 19312 | wlan_hdd_check_ht20_ht40_ind(struct hdd_context *hdd_ctx, |
| 19313 | struct hdd_adapter *adapter, |
| 19314 | struct cfg80211_connect_params *req) |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 19315 | { |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 19316 | struct csr_roam_profile *roam_profile; |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 19317 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19318 | roam_profile = hdd_roam_profile(adapter); |
| 19319 | |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 19320 | roam_profile->force_24ghz_in_ht20 = false; |
| 19321 | |
| 19322 | if (hdd_ctx->config->override_ht20_40_24g && |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19323 | !(req->ht_capa.cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40)) |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 19324 | roam_profile->force_24ghz_in_ht20 = true; |
| 19325 | |
| 19326 | hdd_debug("req->ht_capa.cap_info %x override_ht20_40_24g %d", |
| 19327 | req->ht_capa.cap_info, |
| 19328 | hdd_ctx->config->override_ht20_40_24g); |
| 19329 | } |
| 19330 | #else |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19331 | static inline void |
| 19332 | wlan_hdd_check_ht20_ht40_ind(struct hdd_context *hdd_ctx, |
| 19333 | struct hdd_adapter *adapter, |
| 19334 | struct cfg80211_connect_params *req) |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 19335 | { |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 19336 | struct csr_roam_profile *roam_profile; |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 19337 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19338 | roam_profile = hdd_roam_profile(adapter); |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 19339 | |
| 19340 | roam_profile->force_24ghz_in_ht20 = false; |
| 19341 | } |
| 19342 | #endif |
| 19343 | |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19344 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19345 | * __wlan_hdd_cfg80211_connect() - cfg80211 connect api |
| 19346 | * @wiphy: Pointer to wiphy |
| 19347 | * @dev: Pointer to network device |
| 19348 | * @req: Pointer to cfg80211 connect request |
| 19349 | * |
| 19350 | * This function is used to start the association process |
| 19351 | * |
| 19352 | * Return: 0 for success, non-zero for failure |
| 19353 | */ |
| 19354 | static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy, |
| 19355 | struct net_device *ndev, |
| 19356 | struct cfg80211_connect_params *req) |
| 19357 | { |
| 19358 | int status; |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 19359 | u16 channel; |
Arif Hussain | ee67701 | 2017-01-26 17:50:13 -0800 | [diff] [blame] | 19360 | const u8 *bssid = NULL; |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 19361 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) |
| 19362 | const u8 *bssid_hint = req->bssid_hint; |
| 19363 | #else |
| 19364 | const u8 *bssid_hint = NULL; |
| 19365 | #endif |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19366 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19367 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19368 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19369 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19370 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19371 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19372 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19373 | return -EINVAL; |
| 19374 | } |
| 19375 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19376 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 19377 | hdd_err("invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19378 | return -EINVAL; |
| 19379 | } |
| 19380 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 19381 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19382 | TRACE_CODE_HDD_CFG80211_CONNECT, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19383 | adapter->session_id, adapter->device_mode)); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19384 | hdd_debug("Device_mode %s(%d)", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19385 | hdd_device_mode_to_string(adapter->device_mode), |
| 19386 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19387 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19388 | if (adapter->device_mode != QDF_STA_MODE && |
| 19389 | adapter->device_mode != QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19390 | hdd_err("Device_mode %s(%d) is not supported", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19391 | hdd_device_mode_to_string(adapter->device_mode), |
| 19392 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19393 | return -EINVAL; |
| 19394 | } |
| 19395 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19396 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19397 | if (!hdd_ctx) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19398 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19399 | return -EINVAL; |
| 19400 | } |
| 19401 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19402 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19403 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19404 | return status; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19405 | |
Arif Hussain | ee67701 | 2017-01-26 17:50:13 -0800 | [diff] [blame] | 19406 | if (req->bssid) |
| 19407 | bssid = req->bssid; |
| 19408 | else if (bssid_hint) |
| 19409 | bssid = bssid_hint; |
| 19410 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19411 | if (bssid && hdd_get_adapter_by_macaddr(hdd_ctx, (uint8_t *)bssid)) { |
Arif Hussain | 7631afa | 2017-02-08 14:35:00 -0800 | [diff] [blame] | 19412 | hdd_err("adapter exist with same mac address " MAC_ADDRESS_STR, |
| 19413 | MAC_ADDR_ARRAY(bssid)); |
| 19414 | return -EINVAL; |
Arif Hussain | ee67701 | 2017-01-26 17:50:13 -0800 | [diff] [blame] | 19415 | } |
| 19416 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19417 | if (true == wlan_hdd_reassoc_bssid_hint(adapter, req, &status)) |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19418 | return status; |
| 19419 | |
Agrawal Ashish | f156e94 | 2016-08-04 14:54:47 +0530 | [diff] [blame] | 19420 | /* Try disconnecting if already in connected state */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19421 | status = wlan_hdd_try_disconnect(adapter); |
Agrawal Ashish | f156e94 | 2016-08-04 14:54:47 +0530 | [diff] [blame] | 19422 | if (0 > status) { |
| 19423 | hdd_err("Failed to disconnect the existing connection"); |
| 19424 | return -EALREADY; |
| 19425 | } |
| 19426 | |
| 19427 | /* Check for max concurrent connections after doing disconnect if any */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19428 | if (req->channel) { |
Min Liu | ab6ed4f | 2018-01-09 13:13:57 +0800 | [diff] [blame] | 19429 | bool ok = false; |
Ajit Pal Singh | 90a45a4 | 2017-04-18 18:53:46 +0530 | [diff] [blame] | 19430 | |
| 19431 | if (req->channel->hw_value && policy_mgr_is_chan_ok_for_dnbs( |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19432 | hdd_ctx->hdd_psoc, |
Ajit Pal Singh | 90a45a4 | 2017-04-18 18:53:46 +0530 | [diff] [blame] | 19433 | req->channel->hw_value, |
| 19434 | &ok)) { |
| 19435 | hdd_warn("Unable to get channel:%d eligibility for DNBS", |
| 19436 | req->channel->hw_value); |
| 19437 | return -EINVAL; |
| 19438 | } |
| 19439 | /** |
| 19440 | * Send connection timedout, so that Android framework does not |
| 19441 | * blacklist us. |
| 19442 | */ |
| 19443 | if (!ok) { |
| 19444 | struct ieee80211_channel *chan = |
Dustin Brown | 2eb1e45 | 2017-08-15 12:40:34 -0700 | [diff] [blame] | 19445 | ieee80211_get_channel(wiphy, |
Ajit Pal Singh | 90a45a4 | 2017-04-18 18:53:46 +0530 | [diff] [blame] | 19446 | wlan_chan_to_freq(req->channel->hw_value)); |
| 19447 | struct cfg80211_bss *bss; |
| 19448 | |
| 19449 | hdd_warn("Channel:%d not OK for DNBS", |
| 19450 | req->channel->hw_value); |
| 19451 | if (chan) { |
| 19452 | bss = hdd_cfg80211_get_bss(wiphy, |
| 19453 | chan, |
| 19454 | req->bssid, req->ssid, |
| 19455 | req->ssid_len); |
| 19456 | if (bss) { |
| 19457 | cfg80211_assoc_timeout(ndev, bss); |
| 19458 | return -ETIMEDOUT; |
| 19459 | } |
| 19460 | } |
| 19461 | return -EINVAL; |
| 19462 | } |
| 19463 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19464 | if (!policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc, |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 19465 | policy_mgr_convert_device_mode_to_qdf_type( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19466 | adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19467 | req->channel->hw_value, HW_MODE_20_MHZ)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19468 | hdd_warn("This concurrency combination is not allowed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19469 | return -ECONNREFUSED; |
| 19470 | } |
| 19471 | } else { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19472 | if (!policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc, |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 19473 | policy_mgr_convert_device_mode_to_qdf_type( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19474 | adapter->device_mode), 0, HW_MODE_20_MHZ)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19475 | hdd_warn("This concurrency combination is not allowed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19476 | return -ECONNREFUSED; |
| 19477 | } |
| 19478 | } |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 19479 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19480 | /*initialise security parameters */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19481 | status = wlan_hdd_cfg80211_set_privacy(adapter, req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19482 | |
| 19483 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19484 | hdd_err("Failed to set security params"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19485 | return status; |
| 19486 | } |
| 19487 | |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 19488 | if (req->channel) |
| 19489 | channel = req->channel->hw_value; |
| 19490 | else |
| 19491 | channel = 0; |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 19492 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19493 | wlan_hdd_check_ht20_ht40_ind(hdd_ctx, adapter, req); |
Abhishek Singh | b59f8d4 | 2017-07-31 14:42:47 +0530 | [diff] [blame] | 19494 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19495 | status = wlan_hdd_cfg80211_connect_start(adapter, req->ssid, |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 19496 | req->ssid_len, req->bssid, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 19497 | bssid_hint, channel, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19498 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19499 | hdd_err("connect failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19500 | return status; |
| 19501 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 19502 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19503 | return status; |
| 19504 | } |
| 19505 | |
| 19506 | /** |
| 19507 | * wlan_hdd_cfg80211_connect() - cfg80211 connect api |
| 19508 | * @wiphy: Pointer to wiphy |
| 19509 | * @dev: Pointer to network device |
| 19510 | * @req: Pointer to cfg80211 connect request |
| 19511 | * |
| 19512 | * Return: 0 for success, non-zero for failure |
| 19513 | */ |
| 19514 | static int wlan_hdd_cfg80211_connect(struct wiphy *wiphy, |
| 19515 | struct net_device *ndev, |
| 19516 | struct cfg80211_connect_params *req) |
| 19517 | { |
| 19518 | int ret; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 19519 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19520 | cds_ssr_protect(__func__); |
| 19521 | ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req); |
| 19522 | cds_ssr_unprotect(__func__); |
| 19523 | |
| 19524 | return ret; |
| 19525 | } |
| 19526 | |
Himanshu Agarwal | 6c3607a | 2018-01-12 12:04:19 +0530 | [diff] [blame] | 19527 | int wlan_hdd_disconnect(struct hdd_adapter *adapter, u16 reason) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19528 | { |
| 19529 | int status, result = 0; |
| 19530 | unsigned long rc; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19531 | 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] | 19532 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Padma, Santhosh Kumar | 52456c6 | 2017-01-05 12:14:08 +0530 | [diff] [blame] | 19533 | eConnectionState prev_conn_state; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19534 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Abhishek Singh | e9706cc | 2017-10-12 17:25:06 +0530 | [diff] [blame] | 19535 | uint32_t wait_time = WLAN_WAIT_TIME_DISCONNECT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19536 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19537 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19538 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19539 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19540 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19541 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19542 | return status; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19543 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19544 | sme_indicate_disconnect_inprogress(hal, adapter->session_id); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19545 | hdd_debug("Stop firmware roaming"); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19546 | status = sme_stop_roaming(hal, adapter->session_id, |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19547 | eCsrForcedDisassoc); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 19548 | /* |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19549 | * If firmware has already started roaming process, driver |
| 19550 | * needs to wait for processing of this disconnect request. |
| 19551 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 19552 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19553 | INIT_COMPLETION(adapter->roaming_comp_var); |
| 19554 | if (hdd_is_roaming_in_progress(adapter)) { |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19555 | rc = wait_for_completion_timeout( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19556 | &adapter->roaming_comp_var, |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19557 | msecs_to_jiffies(WLAN_WAIT_TIME_STOP_ROAM)); |
| 19558 | if (!rc) { |
| 19559 | hdd_err("roaming comp var timed out session Id: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19560 | adapter->session_id); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19561 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19562 | if (adapter->roam_ho_fail) { |
| 19563 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 19564 | hdd_debug("Disabling queues"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19565 | wlan_hdd_netif_queue_control(adapter, |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19566 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 19567 | WLAN_CONTROL_PATH); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19568 | hdd_conn_set_connection_state(adapter, |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19569 | eConnectionState_Disconnecting); |
| 19570 | goto wait_for_disconnect; |
| 19571 | } |
| 19572 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 19573 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19574 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19575 | prev_conn_state = sta_ctx->conn_info.connState; |
Srinivas Girigowda | 6598eea | 2017-07-06 19:26:19 -0700 | [diff] [blame] | 19576 | /*stop tx queues */ |
| 19577 | hdd_info("Disabling queues"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19578 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 19579 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, WLAN_CONTROL_PATH); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19580 | hdd_debug("Set HDD connState to eConnectionState_Disconnecting"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19581 | hdd_conn_set_connection_state(adapter, eConnectionState_Disconnecting); |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 19582 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19583 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19584 | |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 19585 | /* issue disconnect */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19586 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19587 | status = sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19588 | adapter->session_id, reason); |
Padma, Santhosh Kumar | 52456c6 | 2017-01-05 12:14:08 +0530 | [diff] [blame] | 19589 | if ((QDF_STATUS_CMD_NOT_QUEUED == status) && |
| 19590 | prev_conn_state != eConnectionState_Connecting) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19591 | hdd_debug("status = %d, already disconnected", status); |
Padma, Santhosh Kumar | 52456c6 | 2017-01-05 12:14:08 +0530 | [diff] [blame] | 19592 | result = 0; |
Abhishek Singh | e9706cc | 2017-10-12 17:25:06 +0530 | [diff] [blame] | 19593 | /* |
| 19594 | * Wait here instead of returning directly. This will block the |
| 19595 | * next connect command and allow processing of the disconnect |
| 19596 | * in SME else we might hit some race conditions leading to SME |
| 19597 | * and HDD out of sync. As disconnect is already in progress, |
| 19598 | * wait here for 1 sec instead of 5 sec. |
| 19599 | */ |
| 19600 | wait_time = WLAN_WAIT_DISCONNECT_ALREADY_IN_PROGRESS; |
Padma, Santhosh Kumar | 52456c6 | 2017-01-05 12:14:08 +0530 | [diff] [blame] | 19601 | } else if (QDF_STATUS_CMD_NOT_QUEUED == status) { |
| 19602 | /* |
| 19603 | * Wait here instead of returning directly, this will block the |
| 19604 | * next connect command and allow processing of the scan for |
| 19605 | * ssid and the previous connect command in CSR. Else we might |
| 19606 | * hit some race conditions leading to SME and HDD out of sync. |
| 19607 | */ |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19608 | 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] | 19609 | } else if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19610 | hdd_err("csr_roam_disconnect failure, status: %d", (int)status); |
Jeff Johnson | 8380f23 | 2017-10-25 12:39:44 -0700 | [diff] [blame] | 19611 | sta_ctx->sta_debug_state = status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19612 | result = -EINVAL; |
| 19613 | goto disconnected; |
| 19614 | } |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 19615 | wait_for_disconnect: |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19616 | rc = wait_for_completion_timeout(&adapter->disconnect_comp_var, |
Abhishek Singh | e9706cc | 2017-10-12 17:25:06 +0530 | [diff] [blame] | 19617 | msecs_to_jiffies(wait_time)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19618 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 19619 | if (!rc && (QDF_STATUS_CMD_NOT_QUEUED != status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19620 | hdd_err("Failed to disconnect, timed out"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19621 | result = -ETIMEDOUT; |
| 19622 | } |
| 19623 | disconnected: |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19624 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19625 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0) |
| 19626 | /* Sending disconnect event to userspace for kernel version < 3.11 |
| 19627 | * is handled by __cfg80211_disconnect call to __cfg80211_disconnected |
| 19628 | */ |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19629 | hdd_debug("Send disconnected event to userspace"); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19630 | wlan_hdd_cfg80211_indicate_disconnect(adapter->dev, true, |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 19631 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19632 | #endif |
| 19633 | |
| 19634 | return result; |
| 19635 | } |
| 19636 | |
| 19637 | /** |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 19638 | * hdd_ieee80211_reason_code_to_str() - return string conversion of reason code |
| 19639 | * @reason: ieee80211 reason code. |
| 19640 | * |
| 19641 | * This utility function helps log string conversion of reason code. |
| 19642 | * |
| 19643 | * Return: string conversion of reason code, if match found; |
| 19644 | * "Unknown" otherwise. |
| 19645 | */ |
| 19646 | static const char *hdd_ieee80211_reason_code_to_str(uint16_t reason) |
| 19647 | { |
| 19648 | switch (reason) { |
| 19649 | CASE_RETURN_STRING(WLAN_REASON_UNSPECIFIED); |
| 19650 | CASE_RETURN_STRING(WLAN_REASON_PREV_AUTH_NOT_VALID); |
| 19651 | CASE_RETURN_STRING(WLAN_REASON_DEAUTH_LEAVING); |
| 19652 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY); |
| 19653 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_AP_BUSY); |
| 19654 | CASE_RETURN_STRING(WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA); |
| 19655 | CASE_RETURN_STRING(WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); |
| 19656 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_STA_HAS_LEFT); |
| 19657 | CASE_RETURN_STRING(WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH); |
| 19658 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_BAD_POWER); |
| 19659 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_BAD_SUPP_CHAN); |
| 19660 | CASE_RETURN_STRING(WLAN_REASON_INVALID_IE); |
| 19661 | CASE_RETURN_STRING(WLAN_REASON_MIC_FAILURE); |
| 19662 | CASE_RETURN_STRING(WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT); |
| 19663 | CASE_RETURN_STRING(WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT); |
| 19664 | CASE_RETURN_STRING(WLAN_REASON_IE_DIFFERENT); |
| 19665 | CASE_RETURN_STRING(WLAN_REASON_INVALID_GROUP_CIPHER); |
| 19666 | CASE_RETURN_STRING(WLAN_REASON_INVALID_PAIRWISE_CIPHER); |
| 19667 | CASE_RETURN_STRING(WLAN_REASON_INVALID_AKMP); |
| 19668 | CASE_RETURN_STRING(WLAN_REASON_UNSUPP_RSN_VERSION); |
| 19669 | CASE_RETURN_STRING(WLAN_REASON_INVALID_RSN_IE_CAP); |
| 19670 | CASE_RETURN_STRING(WLAN_REASON_IEEE8021X_FAILED); |
| 19671 | CASE_RETURN_STRING(WLAN_REASON_CIPHER_SUITE_REJECTED); |
| 19672 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_UNSPECIFIED_QOS); |
| 19673 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH); |
| 19674 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_LOW_ACK); |
| 19675 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP); |
| 19676 | CASE_RETURN_STRING(WLAN_REASON_QSTA_LEAVE_QBSS); |
| 19677 | CASE_RETURN_STRING(WLAN_REASON_QSTA_NOT_USE); |
| 19678 | CASE_RETURN_STRING(WLAN_REASON_QSTA_REQUIRE_SETUP); |
| 19679 | CASE_RETURN_STRING(WLAN_REASON_QSTA_TIMEOUT); |
| 19680 | CASE_RETURN_STRING(WLAN_REASON_QSTA_CIPHER_NOT_SUPP); |
| 19681 | CASE_RETURN_STRING(WLAN_REASON_MESH_PEER_CANCELED); |
| 19682 | CASE_RETURN_STRING(WLAN_REASON_MESH_MAX_PEERS); |
| 19683 | CASE_RETURN_STRING(WLAN_REASON_MESH_CONFIG); |
| 19684 | CASE_RETURN_STRING(WLAN_REASON_MESH_CLOSE); |
| 19685 | CASE_RETURN_STRING(WLAN_REASON_MESH_MAX_RETRIES); |
| 19686 | CASE_RETURN_STRING(WLAN_REASON_MESH_CONFIRM_TIMEOUT); |
| 19687 | CASE_RETURN_STRING(WLAN_REASON_MESH_INVALID_GTK); |
| 19688 | CASE_RETURN_STRING(WLAN_REASON_MESH_INCONSISTENT_PARAM); |
| 19689 | CASE_RETURN_STRING(WLAN_REASON_MESH_INVALID_SECURITY); |
| 19690 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_ERROR); |
| 19691 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_NOFORWARD); |
| 19692 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_DEST_UNREACHABLE); |
| 19693 | CASE_RETURN_STRING(WLAN_REASON_MAC_EXISTS_IN_MBSS); |
| 19694 | CASE_RETURN_STRING(WLAN_REASON_MESH_CHAN_REGULATORY); |
| 19695 | CASE_RETURN_STRING(WLAN_REASON_MESH_CHAN); |
| 19696 | default: |
| 19697 | return "Unknown"; |
| 19698 | } |
| 19699 | } |
| 19700 | |
| 19701 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19702 | * __wlan_hdd_cfg80211_disconnect() - cfg80211 disconnect api |
| 19703 | * @wiphy: Pointer to wiphy |
| 19704 | * @dev: Pointer to network device |
| 19705 | * @reason: Disconnect reason code |
| 19706 | * |
| 19707 | * This function is used to issue a disconnect request to SME |
| 19708 | * |
| 19709 | * Return: 0 for success, non-zero for failure |
| 19710 | */ |
| 19711 | static int __wlan_hdd_cfg80211_disconnect(struct wiphy *wiphy, |
| 19712 | struct net_device *dev, u16 reason) |
| 19713 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19714 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19715 | int status; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19716 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19717 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 19718 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19719 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19720 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19721 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19722 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19723 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19724 | return -EINVAL; |
| 19725 | } |
| 19726 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19727 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 19728 | hdd_err("Invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19729 | return -EINVAL; |
| 19730 | } |
| 19731 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 19732 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19733 | TRACE_CODE_HDD_CFG80211_DISCONNECT, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19734 | adapter->session_id, reason)); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19735 | hdd_debug("Device_mode %s(%d) reason code(%d)", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19736 | hdd_device_mode_to_string(adapter->device_mode), |
| 19737 | adapter->device_mode, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19738 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19739 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19740 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19741 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19742 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19743 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame^] | 19744 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 19745 | if (adapter->disconnection_in_progress) { |
| 19746 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 19747 | hdd_debug("Disconnect is already in progress"); |
| 19748 | return 0; |
| 19749 | } |
| 19750 | adapter->disconnection_in_progress = true; |
| 19751 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 19752 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19753 | /* Issue disconnect request to SME, if station is in connected state */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19754 | if ((sta_ctx->conn_info.connState == eConnectionState_Associated) || |
| 19755 | (sta_ctx->conn_info.connState == eConnectionState_Connecting)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19756 | eCsrRoamDisconnectReason reasonCode = |
| 19757 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19758 | |
| 19759 | switch (reason) { |
| 19760 | case WLAN_REASON_MIC_FAILURE: |
| 19761 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 19762 | break; |
| 19763 | |
| 19764 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 19765 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 19766 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 19767 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 19768 | break; |
| 19769 | |
| 19770 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 19771 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 19772 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 19773 | break; |
| 19774 | |
| 19775 | case WLAN_REASON_DEAUTH_LEAVING: |
| 19776 | reasonCode = |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19777 | hdd_ctx->config-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19778 | gEnableDeauthToDisassocMap ? |
| 19779 | eCSR_DISCONNECT_REASON_STA_HAS_LEFT : |
| 19780 | eCSR_DISCONNECT_REASON_DEAUTH; |
Mohit Khanna | ceb9778 | 2017-04-05 16:27:08 -0700 | [diff] [blame] | 19781 | qdf_dp_trace_dump_all( |
| 19782 | WLAN_DEAUTH_DPTRACE_DUMP_COUNT, |
| 19783 | QDF_TRACE_DEFAULT_PDEV_ID); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19784 | break; |
| 19785 | case WLAN_REASON_DISASSOC_STA_HAS_LEFT: |
| 19786 | reasonCode = eCSR_DISCONNECT_REASON_STA_HAS_LEFT; |
| 19787 | break; |
| 19788 | default: |
| 19789 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 19790 | break; |
| 19791 | } |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 19792 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 19793 | SCAN_NOT_IN_PROGRESS) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19794 | hdd_debug("Disconnect is in progress, Aborting Scan"); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19795 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19796 | adapter->session_id, INVALID_SCAN_ID, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19797 | } |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19798 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19799 | /* First clean up the tdls peers if any */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19800 | hdd_notify_sta_disconnect(adapter->session_id, |
Kabilan Kannan | b6153b1 | 2017-07-13 17:54:02 -0700 | [diff] [blame] | 19801 | false, true, adapter->hdd_vdev); |
| 19802 | |
Srinivas Girigowda | f620d48 | 2017-04-06 19:03:20 -0700 | [diff] [blame] | 19803 | hdd_info("Disconnect request from user space with reason: %d (%s) internal reason code: %d", |
| 19804 | reason, hdd_ieee80211_reason_code_to_str(reason), reasonCode); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19805 | status = wlan_hdd_disconnect(adapter, reasonCode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19806 | if (0 != status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19807 | hdd_err("wlan_hdd_disconnect failed, status: %d", status); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame^] | 19808 | hdd_set_disconnect_status(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19809 | return -EINVAL; |
| 19810 | } |
| 19811 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19812 | hdd_err("Unexpected cfg disconnect called while in state: %d", |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19813 | sta_ctx->conn_info.connState); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame^] | 19814 | hdd_set_disconnect_status(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19815 | } |
| 19816 | |
| 19817 | return status; |
| 19818 | } |
| 19819 | |
| 19820 | /** |
| 19821 | * wlan_hdd_cfg80211_disconnect() - cfg80211 disconnect api |
| 19822 | * @wiphy: Pointer to wiphy |
| 19823 | * @dev: Pointer to network device |
| 19824 | * @reason: Disconnect reason code |
| 19825 | * |
| 19826 | * Return: 0 for success, non-zero for failure |
| 19827 | */ |
| 19828 | static int wlan_hdd_cfg80211_disconnect(struct wiphy *wiphy, |
| 19829 | struct net_device *dev, u16 reason) |
| 19830 | { |
| 19831 | int ret; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 19832 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19833 | cds_ssr_protect(__func__); |
| 19834 | ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason); |
| 19835 | cds_ssr_unprotect(__func__); |
| 19836 | |
| 19837 | return ret; |
| 19838 | } |
| 19839 | |
| 19840 | /** |
| 19841 | * wlan_hdd_cfg80211_set_privacy_ibss() - set ibss privacy |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19842 | * @adapter: Pointer to adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19843 | * @param: Pointer to IBSS parameters |
| 19844 | * |
| 19845 | * This function is used to initialize the security settings in IBSS mode |
| 19846 | * |
| 19847 | * Return: 0 for success, non-zero for failure |
| 19848 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19849 | static int wlan_hdd_cfg80211_set_privacy_ibss(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19850 | struct cfg80211_ibss_params |
| 19851 | *params) |
| 19852 | { |
Naveen Rawat | 72475db | 2017-12-13 18:07:35 -0800 | [diff] [blame] | 19853 | uint32_t ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19854 | int status = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19855 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19856 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19857 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19858 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19859 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19860 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19861 | |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 19862 | sta_ctx->wpa_versions = 0; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19863 | qdf_mem_zero(&sta_ctx->ibss_enc_key, sizeof(tCsrRoamSetKey)); |
| 19864 | sta_ctx->ibss_enc_key_installed = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19865 | |
| 19866 | if (params->ie_len && (NULL != params->ie)) { |
Naveen Rawat | 08db88f | 2017-09-08 15:07:48 -0700 | [diff] [blame] | 19867 | if (wlan_get_ie_ptr_from_eid(WLAN_EID_RSN, params->ie, |
| 19868 | params->ie_len)) { |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 19869 | sta_ctx->wpa_versions = NL80211_WPA_VERSION_2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19870 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 19871 | } else if (hdd_is_wpaie_present(params->ie, params->ie_len)) { |
| 19872 | tDot11fIEWPA dot11WPAIE; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19873 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(adapter); |
Naveen Rawat | 08db88f | 2017-09-08 15:07:48 -0700 | [diff] [blame] | 19874 | const u8 *ie; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19875 | |
| 19876 | memset(&dot11WPAIE, 0, sizeof(dot11WPAIE)); |
Naveen Rawat | 08db88f | 2017-09-08 15:07:48 -0700 | [diff] [blame] | 19877 | ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_WPA, |
| 19878 | params->ie, params->ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19879 | if (NULL != ie) { |
Jeff Johnson | ce4a834 | 2017-10-14 13:12:22 -0700 | [diff] [blame] | 19880 | sta_ctx->wpa_versions = NL80211_WPA_VERSION_1; |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 19881 | /* Unpack the WPA IE |
| 19882 | * Skip past the EID byte and length byte |
| 19883 | * and four byte WiFi OUI |
| 19884 | */ |
Hanumanth Reddy Pothula | f6e3db3 | 2018-01-24 17:54:15 +0530 | [diff] [blame] | 19885 | if (ie[1] < DOT11F_IE_WPA_MIN_LEN || |
| 19886 | ie[1] > DOT11F_IE_WPA_MAX_LEN) { |
| 19887 | hdd_err("invalid ie len:%d", ie[1]); |
| 19888 | return -EINVAL; |
| 19889 | } |
Naveen Rawat | 72475db | 2017-12-13 18:07:35 -0800 | [diff] [blame] | 19890 | ret = dot11f_unpack_ie_wpa( |
| 19891 | (tpAniSirGlobal) halHandle, |
| 19892 | (uint8_t *)&ie[2 + 4], |
| 19893 | ie[1] - 4, &dot11WPAIE, false); |
| 19894 | if (DOT11F_FAILED(ret)) { |
| 19895 | hdd_err("unpack failed ret: 0x%x", ret); |
| 19896 | return -EINVAL; |
| 19897 | } |
Selvaraj, Sridhar | 75afbeb | 2017-04-03 17:08:59 +0530 | [diff] [blame] | 19898 | /* |
| 19899 | * Extract the multicast cipher, the |
Jeff Johnson | f3826e1 | 2017-01-12 09:49:40 -0800 | [diff] [blame] | 19900 | * encType for unicast cipher for |
| 19901 | * wpa-none is none |
| 19902 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19903 | encryptionType = |
| 19904 | hdd_translate_wpa_to_csr_encryption_type |
| 19905 | (dot11WPAIE.multicast_cipher); |
| 19906 | } |
| 19907 | } |
| 19908 | |
| 19909 | status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19910 | wlan_hdd_cfg80211_set_ie(adapter, params->ie, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19911 | params->ie_len); |
| 19912 | |
| 19913 | if (0 > status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19914 | hdd_err("Failed to parse WPA/RSN IE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19915 | return status; |
| 19916 | } |
| 19917 | } |
| 19918 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19919 | roam_profile = hdd_roam_profile(adapter); |
| 19920 | roam_profile->AuthType.authType[0] = |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19921 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19922 | |
| 19923 | if (params->privacy) { |
| 19924 | /* Security enabled IBSS, At this time there is no information |
| 19925 | * available about the security paramters, so initialise the |
| 19926 | * encryption type to eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
| 19927 | * The correct security parameters will be updated later in |
| 19928 | * wlan_hdd_cfg80211_add_key Hal expects encryption type to be |
| 19929 | * set inorder enable privacy bit in beacons |
| 19930 | */ |
| 19931 | |
| 19932 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 19933 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19934 | hdd_debug("encryptionType=%d", encryptionType); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19935 | sta_ctx->conn_info.ucEncryptionType = encryptionType; |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 19936 | roam_profile->EncryptionType.numEntries = 1; |
| 19937 | roam_profile->EncryptionType.encryptionType[0] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19938 | encryptionType; |
| 19939 | return status; |
| 19940 | } |
| 19941 | |
| 19942 | /** |
| 19943 | * __wlan_hdd_cfg80211_join_ibss() - join ibss |
| 19944 | * @wiphy: Pointer to wiphy |
| 19945 | * @dev: Pointer to network device |
| 19946 | * @param: Pointer to IBSS join parameters |
| 19947 | * |
| 19948 | * This function is used to create/join an IBSS network |
| 19949 | * |
| 19950 | * Return: 0 for success, non-zero for failure |
| 19951 | */ |
| 19952 | static int __wlan_hdd_cfg80211_join_ibss(struct wiphy *wiphy, |
| 19953 | struct net_device *dev, |
| 19954 | struct cfg80211_ibss_params *params) |
| 19955 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19956 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 19957 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19958 | int status; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 19959 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19960 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 19961 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19962 | struct qdf_mac_addr bssid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19963 | u8 channelNum = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19964 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 19965 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19966 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 19967 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 19968 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19969 | return -EINVAL; |
| 19970 | } |
| 19971 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19972 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 19973 | hdd_err("Invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 19974 | return -EINVAL; |
| 19975 | } |
| 19976 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 19977 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19978 | TRACE_CODE_HDD_CFG80211_JOIN_IBSS, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 19979 | adapter->session_id, adapter->device_mode)); |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 19980 | hdd_debug("Device_mode %s(%d)", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19981 | hdd_device_mode_to_string(adapter->device_mode), |
| 19982 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19983 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 19984 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19985 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 19986 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19987 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19988 | |
| 19989 | if (NULL != |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 19990 | params->chandef.chan) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19991 | uint32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 19992 | uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 19993 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19994 | int indx; |
| 19995 | |
| 19996 | /* Get channel number */ |
| 19997 | channelNum = ieee80211_frequency_to_channel( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19998 | params-> |
| 19999 | chandef. |
| 20000 | chan-> |
| 20001 | center_freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20002 | |
| 20003 | if (0 != sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 20004 | validChan, &numChans)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20005 | hdd_err("No valid channel list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20006 | return -EOPNOTSUPP; |
| 20007 | } |
| 20008 | |
| 20009 | for (indx = 0; indx < numChans; indx++) { |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 20010 | if (channelNum == validChan[indx]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20011 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20012 | } |
| 20013 | if (indx >= numChans) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20014 | hdd_err("Not valid Channel: %d", channelNum); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20015 | return -EINVAL; |
| 20016 | } |
| 20017 | } |
| 20018 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20019 | if (!policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc, |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 20020 | PM_IBSS_MODE, channelNum, HW_MODE_20_MHZ)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20021 | hdd_err("This concurrency combination is not allowed"); |
| 20022 | return -ECONNREFUSED; |
| 20023 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20024 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20025 | status = policy_mgr_reset_connection_update(hdd_ctx->hdd_psoc); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 20026 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20027 | hdd_err("qdf_reset_connection_update failed status: %d", status); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 20028 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20029 | status = policy_mgr_current_connections_update(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20030 | adapter->session_id, channelNum, |
Tushnim Bhattacharyya | 3b99f4b | 2018-03-26 14:19:24 -0700 | [diff] [blame] | 20031 | POLICY_MGR_UPDATE_REASON_JOIN_IBSS); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 20032 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20033 | hdd_err("connections update failed!!"); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 20034 | return -EINVAL; |
| 20035 | } |
| 20036 | |
| 20037 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 20038 | status = policy_mgr_wait_for_connection_update( |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20039 | hdd_ctx->hdd_psoc); |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 20040 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20041 | hdd_err("qdf wait for event failed!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20042 | return -EINVAL; |
| 20043 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20044 | } |
| 20045 | |
| 20046 | /*Try disconnecting if already in connected state */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20047 | status = wlan_hdd_try_disconnect(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20048 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20049 | hdd_err("Failed to disconnect the existing IBSS connection"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20050 | return -EALREADY; |
| 20051 | } |
| 20052 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 20053 | roam_profile = hdd_roam_profile(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20054 | |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 20055 | if (eCSR_BSS_TYPE_START_IBSS != roam_profile->BSSType) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20056 | hdd_err("Interface type is not set to IBSS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20057 | return -EINVAL; |
| 20058 | } |
| 20059 | |
| 20060 | /* enable selected protection checks in IBSS mode */ |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 20061 | roam_profile->cfg_protection = IBSS_CFG_PROTECTION_ENABLE_MASK; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20062 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20063 | if (QDF_STATUS_E_FAILURE == sme_cfg_set_int(hdd_ctx->hHal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20064 | WNI_CFG_IBSS_ATIM_WIN_SIZE, |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20065 | hdd_ctx->config-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20066 | ibssATIMWinSize)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20067 | hdd_err("Could not pass on WNI_CFG_IBSS_ATIM_WIN_SIZE to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20068 | } |
| 20069 | |
| 20070 | /* BSSID is provided by upper layers hence no need to AUTO generate */ |
| 20071 | if (NULL != params->bssid) { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20072 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20073 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20074 | hdd_err("ccmCfgStInt failed for WNI_CFG_IBSS_AUTO_BSSID"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20075 | return -EIO; |
| 20076 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 20077 | qdf_mem_copy(bssid.bytes, params->bssid, QDF_MAC_ADDR_SIZE); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20078 | } else if (hdd_ctx->config->isCoalesingInIBSSAllowed == 0) { |
| 20079 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20080 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20081 | hdd_err("ccmCfgStInt failed for WNI_CFG_IBSS_AUTO_BSSID"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20082 | return -EIO; |
| 20083 | } |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20084 | qdf_copy_macaddr(&bssid, &hdd_ctx->config->IbssBssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20085 | } |
| 20086 | if ((params->beacon_interval > CFG_BEACON_INTERVAL_MIN) |
| 20087 | && (params->beacon_interval <= CFG_BEACON_INTERVAL_MAX)) |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 20088 | roam_profile->beaconInterval = params->beacon_interval; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20089 | else { |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 20090 | roam_profile->beaconInterval = CFG_BEACON_INTERVAL_DEFAULT; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20091 | hdd_debug("input beacon interval %d TU is invalid, use default %d TU", |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 20092 | params->beacon_interval, roam_profile->beaconInterval); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20093 | } |
| 20094 | |
| 20095 | /* Set Channel */ |
| 20096 | if (channelNum) { |
| 20097 | /* Set the Operational Channel */ |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20098 | hdd_debug("set channel %d", channelNum); |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 20099 | roam_profile->ChannelInfo.numOfChannels = 1; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 20100 | sta_ctx->conn_info.operationChannel = channelNum; |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 20101 | roam_profile->ChannelInfo.ChannelList = |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 20102 | &sta_ctx->conn_info.operationChannel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20103 | } |
| 20104 | |
| 20105 | /* Initialize security parameters */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20106 | status = wlan_hdd_cfg80211_set_privacy_ibss(adapter, params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20107 | if (status < 0) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20108 | hdd_err("failed to set security parameters"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20109 | return status; |
| 20110 | } |
| 20111 | |
| 20112 | /* Issue connect start */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20113 | status = wlan_hdd_cfg80211_connect_start(adapter, params->ssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20114 | params->ssid_len, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 20115 | bssid.bytes, NULL, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 20116 | sta_ctx->conn_info. |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 20117 | operationChannel, |
| 20118 | params->chandef.width); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20119 | |
| 20120 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20121 | hdd_err("connect failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20122 | return status; |
| 20123 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20124 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20125 | return 0; |
| 20126 | } |
| 20127 | |
| 20128 | /** |
| 20129 | * wlan_hdd_cfg80211_join_ibss() - join ibss |
| 20130 | * @wiphy: Pointer to wiphy |
| 20131 | * @dev: Pointer to network device |
| 20132 | * @param: Pointer to IBSS join parameters |
| 20133 | * |
| 20134 | * This function is used to create/join an IBSS network |
| 20135 | * |
| 20136 | * Return: 0 for success, non-zero for failure |
| 20137 | */ |
| 20138 | static int wlan_hdd_cfg80211_join_ibss(struct wiphy *wiphy, |
| 20139 | struct net_device *dev, |
| 20140 | struct cfg80211_ibss_params *params) |
| 20141 | { |
| 20142 | int ret = 0; |
| 20143 | |
| 20144 | cds_ssr_protect(__func__); |
| 20145 | ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params); |
| 20146 | cds_ssr_unprotect(__func__); |
| 20147 | |
| 20148 | return ret; |
| 20149 | } |
| 20150 | |
| 20151 | /** |
| 20152 | * __wlan_hdd_cfg80211_leave_ibss() - leave ibss |
| 20153 | * @wiphy: Pointer to wiphy |
| 20154 | * @dev: Pointer to network device |
| 20155 | * |
| 20156 | * This function is used to leave an IBSS network |
| 20157 | * |
| 20158 | * Return: 0 for success, non-zero for failure |
| 20159 | */ |
| 20160 | static int __wlan_hdd_cfg80211_leave_ibss(struct wiphy *wiphy, |
| 20161 | struct net_device *dev) |
| 20162 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20163 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 20164 | struct csr_roam_profile *roam_profile; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20165 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20166 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20167 | QDF_STATUS hal_status; |
Chandrasekaran, Manishekar | 12a818a | 2015-12-18 11:44:56 +0530 | [diff] [blame] | 20168 | unsigned long rc; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 20169 | tSirUpdateIE updateIE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20170 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20171 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20172 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 20173 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20174 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20175 | return -EINVAL; |
| 20176 | } |
| 20177 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20178 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 20179 | hdd_err("Invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 20180 | return -EINVAL; |
| 20181 | } |
| 20182 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 20183 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20184 | TRACE_CODE_HDD_CFG80211_LEAVE_IBSS, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20185 | adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20186 | eCSR_DISCONNECT_REASON_IBSS_LEAVE)); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20187 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 20188 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20189 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20190 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20191 | hdd_debug("Device_mode %s(%d)", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20192 | hdd_device_mode_to_string(adapter->device_mode), |
| 20193 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20194 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 20195 | roam_profile = hdd_roam_profile(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20196 | |
| 20197 | /* Issue disconnect only if interface type is set to IBSS */ |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 20198 | if (eCSR_BSS_TYPE_START_IBSS != roam_profile->BSSType) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20199 | hdd_err("BSS Type is not set to IBSS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20200 | return -EINVAL; |
| 20201 | } |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 20202 | /* Clearing add IE of beacon */ |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 20203 | qdf_mem_copy(updateIE.bssid.bytes, adapter->mac_addr.bytes, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 20204 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20205 | updateIE.smeSessionId = adapter->session_id; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 20206 | updateIE.ieBufferlength = 0; |
| 20207 | updateIE.pAdditionIEBuffer = NULL; |
| 20208 | updateIE.append = true; |
| 20209 | updateIE.notify = true; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20210 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 20211 | &updateIE, |
| 20212 | eUPDATE_IE_PROBE_BCN) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20213 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 20214 | } |
| 20215 | |
| 20216 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20217 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20218 | |
| 20219 | /* Issue Disconnect request */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20220 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 20221 | hal_status = sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20222 | adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20223 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20224 | if (!QDF_IS_STATUS_SUCCESS(hal_status)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20225 | hdd_err("sme_roam_disconnect failed status: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20226 | hal_status); |
| 20227 | return -EAGAIN; |
| 20228 | } |
Chandrasekaran, Manishekar | 12a818a | 2015-12-18 11:44:56 +0530 | [diff] [blame] | 20229 | |
| 20230 | /* wait for mc thread to cleanup and then return to upper stack |
| 20231 | * so by the time upper layer calls the change interface, we are |
| 20232 | * all set to proceed further |
| 20233 | */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20234 | rc = wait_for_completion_timeout(&adapter->disconnect_comp_var, |
Chandrasekaran, Manishekar | 12a818a | 2015-12-18 11:44:56 +0530 | [diff] [blame] | 20235 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 20236 | if (!rc) { |
| 20237 | hdd_err("Failed to disconnect, timed out"); |
| 20238 | return -ETIMEDOUT; |
| 20239 | } |
| 20240 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20241 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20242 | return 0; |
| 20243 | } |
| 20244 | |
| 20245 | /** |
| 20246 | * wlan_hdd_cfg80211_leave_ibss() - leave ibss |
| 20247 | * @wiphy: Pointer to wiphy |
| 20248 | * @dev: Pointer to network device |
| 20249 | * |
| 20250 | * This function is used to leave an IBSS network |
| 20251 | * |
| 20252 | * Return: 0 for success, non-zero for failure |
| 20253 | */ |
| 20254 | static int wlan_hdd_cfg80211_leave_ibss(struct wiphy *wiphy, |
| 20255 | struct net_device *dev) |
| 20256 | { |
| 20257 | int ret = 0; |
| 20258 | |
| 20259 | cds_ssr_protect(__func__); |
| 20260 | ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev); |
| 20261 | cds_ssr_unprotect(__func__); |
| 20262 | |
| 20263 | return ret; |
| 20264 | } |
| 20265 | |
| 20266 | /** |
| 20267 | * __wlan_hdd_cfg80211_set_wiphy_params() - set wiphy parameters |
| 20268 | * @wiphy: Pointer to wiphy |
| 20269 | * @changed: Parameters changed |
| 20270 | * |
| 20271 | * This function is used to set the phy parameters. RTS Threshold/FRAG |
| 20272 | * Threshold/Retry Count etc. |
| 20273 | * |
| 20274 | * Return: 0 for success, non-zero for failure |
| 20275 | */ |
| 20276 | static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
| 20277 | u32 changed) |
| 20278 | { |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20279 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 20280 | tHalHandle hHal = hdd_ctx->hHal; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20281 | int status; |
| 20282 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20283 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20284 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 20285 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20286 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20287 | return -EINVAL; |
| 20288 | } |
| 20289 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 20290 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20291 | TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS, |
| 20292 | NO_SESSION, wiphy->rts_threshold)); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20293 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20294 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 20295 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20296 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20297 | |
| 20298 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
| 20299 | u32 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 20300 | WNI_CFG_RTS_THRESHOLD_STAMAX : wiphy->rts_threshold; |
| 20301 | |
| 20302 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
| 20303 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20304 | hdd_err("Invalid RTS Threshold value: %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20305 | rts_threshold); |
| 20306 | return -EINVAL; |
| 20307 | } |
| 20308 | |
| 20309 | if (0 != sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, |
| 20310 | rts_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20311 | hdd_err("sme_cfg_set_int failed for rts_threshold value %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20312 | rts_threshold); |
| 20313 | return -EIO; |
| 20314 | } |
| 20315 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20316 | hdd_debug("set rts threshold %u", rts_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20317 | } |
| 20318 | |
| 20319 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
| 20320 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 20321 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 20322 | wiphy->frag_threshold; |
| 20323 | |
| 20324 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold) || |
| 20325 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20326 | hdd_err("Invalid frag_threshold value %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20327 | frag_threshold); |
| 20328 | return -EINVAL; |
| 20329 | } |
| 20330 | |
| 20331 | if (0 != sme_cfg_set_int(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 20332 | frag_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20333 | hdd_err("sme_cfg_set_int failed for frag_threshold value %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20334 | frag_threshold); |
| 20335 | return -EIO; |
| 20336 | } |
| 20337 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20338 | hdd_debug("set frag threshold %hu", frag_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20339 | } |
| 20340 | |
| 20341 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 20342 | || (changed & WIPHY_PARAM_RETRY_LONG)) { |
| 20343 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 20344 | wiphy->retry_short : wiphy->retry_long; |
| 20345 | |
| 20346 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 20347 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20348 | hdd_err("Invalid Retry count: %hu", retry_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20349 | return -EINVAL; |
| 20350 | } |
| 20351 | |
Nachiket Kukade | 142e996 | 2017-06-16 16:33:28 +0530 | [diff] [blame] | 20352 | if (changed & WIPHY_PARAM_RETRY_LONG) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20353 | if (0 != sme_cfg_set_int(hHal, |
| 20354 | WNI_CFG_LONG_RETRY_LIMIT, |
| 20355 | retry_value)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20356 | hdd_err("sme_cfg_set_int failed for long retry count: %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20357 | retry_value); |
| 20358 | return -EIO; |
| 20359 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20360 | hdd_debug("set long retry count %hu", retry_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20361 | } else if (changed & WIPHY_PARAM_RETRY_SHORT) { |
| 20362 | if (0 != sme_cfg_set_int(hHal, |
| 20363 | WNI_CFG_SHORT_RETRY_LIMIT, |
| 20364 | retry_value)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20365 | hdd_err("sme_cfg_set_int failed for short retry count: %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20366 | retry_value); |
| 20367 | return -EIO; |
| 20368 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20369 | hdd_debug("set short retry count %hu", retry_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20370 | } |
| 20371 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20372 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20373 | return 0; |
| 20374 | } |
| 20375 | |
| 20376 | /** |
| 20377 | * wlan_hdd_cfg80211_set_wiphy_params() - set wiphy parameters |
| 20378 | * @wiphy: Pointer to wiphy |
| 20379 | * @changed: Parameters changed |
| 20380 | * |
| 20381 | * Return: 0 for success, non-zero for failure |
| 20382 | */ |
| 20383 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 20384 | { |
| 20385 | int ret; |
| 20386 | |
| 20387 | cds_ssr_protect(__func__); |
| 20388 | ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed); |
| 20389 | cds_ssr_unprotect(__func__); |
| 20390 | |
| 20391 | return ret; |
| 20392 | } |
| 20393 | |
| 20394 | /** |
| 20395 | * __wlan_hdd_set_default_mgmt_key() - dummy implementation of set default mgmt |
| 20396 | * key |
| 20397 | * @wiphy: Pointer to wiphy |
| 20398 | * @dev: Pointer to network device |
| 20399 | * @key_index: Key index |
| 20400 | * |
| 20401 | * Return: 0 |
| 20402 | */ |
| 20403 | static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 20404 | struct net_device *netdev, |
| 20405 | u8 key_index) |
| 20406 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20407 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20408 | return 0; |
| 20409 | } |
| 20410 | |
| 20411 | /** |
| 20412 | * wlan_hdd_set_default_mgmt_key() - SSR wrapper for |
| 20413 | * wlan_hdd_set_default_mgmt_key |
| 20414 | * @wiphy: pointer to wiphy |
| 20415 | * @netdev: pointer to net_device structure |
| 20416 | * @key_index: key index |
| 20417 | * |
| 20418 | * Return: 0 on success, error number on failure |
| 20419 | */ |
| 20420 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 20421 | struct net_device *netdev, |
| 20422 | u8 key_index) |
| 20423 | { |
| 20424 | int ret; |
| 20425 | |
| 20426 | cds_ssr_protect(__func__); |
| 20427 | ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index); |
| 20428 | cds_ssr_unprotect(__func__); |
| 20429 | |
| 20430 | return ret; |
| 20431 | } |
| 20432 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20433 | /** |
| 20434 | * __wlan_hdd_set_txq_params() - dummy implementation of set tx queue params |
| 20435 | * @wiphy: Pointer to wiphy |
| 20436 | * @dev: Pointer to network device |
| 20437 | * @params: Pointer to tx queue parameters |
| 20438 | * |
| 20439 | * Return: 0 |
| 20440 | */ |
| 20441 | static int __wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 20442 | struct net_device *dev, |
| 20443 | struct ieee80211_txq_params *params) |
| 20444 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20445 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20446 | return 0; |
| 20447 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20448 | |
| 20449 | /** |
| 20450 | * wlan_hdd_set_txq_params() - SSR wrapper for wlan_hdd_set_txq_params |
| 20451 | * @wiphy: pointer to wiphy |
| 20452 | * @netdev: pointer to net_device structure |
| 20453 | * @params: pointer to ieee80211_txq_params |
| 20454 | * |
| 20455 | * Return: 0 on success, error number on failure |
| 20456 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20457 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 20458 | struct net_device *dev, |
| 20459 | struct ieee80211_txq_params *params) |
| 20460 | { |
| 20461 | int ret; |
| 20462 | |
| 20463 | cds_ssr_protect(__func__); |
| 20464 | ret = __wlan_hdd_set_txq_params(wiphy, dev, params); |
| 20465 | cds_ssr_unprotect(__func__); |
| 20466 | |
| 20467 | return ret; |
| 20468 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20469 | |
| 20470 | /** |
| 20471 | * __wlan_hdd_cfg80211_del_station() - delete station v2 |
| 20472 | * @wiphy: Pointer to wiphy |
| 20473 | * @param: Pointer to delete station parameter |
| 20474 | * |
| 20475 | * Return: 0 for success, non-zero for failure |
| 20476 | */ |
| 20477 | static |
| 20478 | int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 20479 | struct net_device *dev, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 20480 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20481 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20482 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20483 | struct hdd_context *hdd_ctx; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 20484 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 20485 | struct hdd_hostapd_state *hapd_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20486 | int status; |
| 20487 | uint8_t staId; |
| 20488 | uint8_t *mac; |
| 20489 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20490 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20491 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 20492 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20493 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20494 | return -EINVAL; |
| 20495 | } |
| 20496 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20497 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 20498 | hdd_err("Invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 20499 | return -EINVAL; |
| 20500 | } |
| 20501 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 20502 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20503 | TRACE_CODE_HDD_CFG80211_DEL_STA, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20504 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20505 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20506 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20507 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20508 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 20509 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20510 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20511 | |
| 20512 | mac = (uint8_t *) pDelStaParams->peerMacAddr.bytes; |
| 20513 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20514 | if ((QDF_SAP_MODE == adapter->device_mode) || |
| 20515 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20516 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20517 | hapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20518 | if (!hapd_state) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20519 | hdd_err("Hostapd State is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20520 | return 0; |
| 20521 | } |
| 20522 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 20523 | if (qdf_is_macaddr_broadcast((struct qdf_mac_addr *) mac)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20524 | uint16_t i; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 20525 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20526 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 20527 | if ((adapter->sta_info[i].in_use) && |
| 20528 | (!adapter->sta_info[i]. |
Jeff Johnson | e4f5d93 | 2017-10-21 13:21:15 -0700 | [diff] [blame] | 20529 | is_deauth_in_progress)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 20530 | qdf_mem_copy( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20531 | mac, |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 20532 | adapter->sta_info[i]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 20533 | sta_mac.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 20534 | QDF_MAC_ADDR_SIZE); |
Yun Park | a4bb37c | 2017-12-08 16:14:22 -0800 | [diff] [blame] | 20535 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20536 | hdd_debug("Delete STA with MAC::" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20537 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20538 | MAC_ADDR_ARRAY(mac)); |
| 20539 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20540 | if (hdd_ctx->dev_dfs_cac_status == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20541 | DFS_CAC_IN_PROGRESS) |
| 20542 | goto fn_end; |
| 20543 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 20544 | qdf_event_reset(&hapd_state->qdf_sta_disassoc_event); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20545 | hdd_softap_sta_disassoc(adapter, |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 20546 | pDelStaParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20547 | qdf_status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20548 | hdd_softap_sta_deauth(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20549 | pDelStaParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20550 | if (QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 20551 | adapter->sta_info[i]. |
Jeff Johnson | e4f5d93 | 2017-10-21 13:21:15 -0700 | [diff] [blame] | 20552 | is_deauth_in_progress = true; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 20553 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 20554 | qdf_wait_for_event_completion( |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 20555 | &hapd_state-> |
| 20556 | qdf_sta_disassoc_event, |
| 20557 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 20558 | if (!QDF_IS_STATUS_SUCCESS( |
| 20559 | qdf_status)) |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20560 | hdd_warn("Deauth wait time expired"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20561 | } |
| 20562 | } |
| 20563 | } |
| 20564 | } else { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20565 | qdf_status = |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20566 | hdd_softap_get_sta_id(adapter, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 20567 | (struct qdf_mac_addr *) mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20568 | &staId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20569 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20570 | hdd_debug("Skip DEL STA as this is not used::" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20571 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20572 | MAC_ADDR_ARRAY(mac)); |
| 20573 | return -ENOENT; |
| 20574 | } |
| 20575 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 20576 | if (adapter->sta_info[staId].is_deauth_in_progress == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20577 | true) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20578 | hdd_debug("Skip DEL STA as deauth is in progress::" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20579 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20580 | MAC_ADDR_ARRAY(mac)); |
| 20581 | return -ENOENT; |
| 20582 | } |
| 20583 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 20584 | adapter->sta_info[staId].is_deauth_in_progress = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20585 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20586 | hdd_debug("Delete STA with MAC::" MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20587 | MAC_ADDR_ARRAY(mac)); |
| 20588 | |
| 20589 | /* Case: SAP in ACS selected DFS ch and client connected |
| 20590 | * Now Radar detected. Then if random channel is another |
| 20591 | * DFS ch then new CAC is initiated and no TX allowed. |
| 20592 | * So do not send any mgmt frames as it will timeout |
| 20593 | * during CAC. |
| 20594 | */ |
| 20595 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20596 | if (hdd_ctx->dev_dfs_cac_status == DFS_CAC_IN_PROGRESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20597 | goto fn_end; |
| 20598 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 20599 | qdf_event_reset(&hapd_state->qdf_sta_disassoc_event); |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 20600 | sme_send_disassoc_req_frame(WLAN_HDD_GET_HAL_CTX |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20601 | (adapter), adapter->session_id, |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 20602 | (uint8_t *)&pDelStaParams->peerMacAddr, |
| 20603 | pDelStaParams->reason_code, 0); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20604 | qdf_status = hdd_softap_sta_deauth(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20605 | pDelStaParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20606 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 20607 | adapter->sta_info[staId].is_deauth_in_progress = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20608 | false; |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20609 | hdd_debug("STA removal failed for ::" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20610 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20611 | MAC_ADDR_ARRAY(mac)); |
| 20612 | return -ENOENT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20613 | } |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 20614 | qdf_status = qdf_wait_for_event_completion( |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 20615 | &hapd_state-> |
| 20616 | qdf_sta_disassoc_event, |
| 20617 | SME_CMD_TIMEOUT_VALUE); |
| 20618 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 20619 | hdd_warn("Deauth wait time expired"); |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 20620 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20621 | } |
| 20622 | } |
| 20623 | |
| 20624 | fn_end: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20625 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20626 | return 0; |
| 20627 | } |
| 20628 | |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 20629 | #if defined(USE_CFG80211_DEL_STA_V2) |
| 20630 | /** |
| 20631 | * wlan_hdd_del_station() - delete station wrapper |
| 20632 | * @adapter: pointer to the hdd adapter |
| 20633 | * |
| 20634 | * Return: None |
| 20635 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 20636 | void wlan_hdd_del_station(struct hdd_adapter *adapter) |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 20637 | { |
| 20638 | struct station_del_parameters del_sta; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 20639 | |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 20640 | del_sta.mac = NULL; |
| 20641 | del_sta.subtype = SIR_MAC_MGMT_DEAUTH >> 4; |
| 20642 | del_sta.reason_code = eCsrForcedDeauthSta; |
| 20643 | |
| 20644 | wlan_hdd_cfg80211_del_station(adapter->wdev.wiphy, adapter->dev, |
| 20645 | &del_sta); |
| 20646 | } |
| 20647 | #else |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 20648 | void wlan_hdd_del_station(struct hdd_adapter *adapter) |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 20649 | { |
| 20650 | wlan_hdd_cfg80211_del_station(adapter->wdev.wiphy, adapter->dev, NULL); |
| 20651 | } |
| 20652 | #endif |
| 20653 | |
| 20654 | #if defined(USE_CFG80211_DEL_STA_V2) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20655 | /** |
| 20656 | * wlan_hdd_cfg80211_del_station() - delete station v2 |
| 20657 | * @wiphy: Pointer to wiphy |
| 20658 | * @param: Pointer to delete station parameter |
| 20659 | * |
| 20660 | * Return: 0 for success, non-zero for failure |
| 20661 | */ |
| 20662 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 20663 | struct net_device *dev, |
| 20664 | struct station_del_parameters *param) |
| 20665 | #else |
| 20666 | /** |
| 20667 | * wlan_hdd_cfg80211_del_station() - delete station |
| 20668 | * @wiphy: Pointer to wiphy |
| 20669 | * @mac: Pointer to station mac address |
| 20670 | * |
| 20671 | * Return: 0 for success, non-zero for failure |
| 20672 | */ |
| 20673 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 20674 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 20675 | struct net_device *dev, |
| 20676 | const uint8_t *mac) |
| 20677 | #else |
| 20678 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 20679 | struct net_device *dev, |
| 20680 | uint8_t *mac) |
| 20681 | #endif |
| 20682 | #endif |
| 20683 | { |
| 20684 | int ret; |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 20685 | struct csr_del_sta_params delStaParams; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20686 | |
| 20687 | cds_ssr_protect(__func__); |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 20688 | #if defined(USE_CFG80211_DEL_STA_V2) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20689 | if (NULL == param) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 20690 | hdd_err("Invalid argument passed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20691 | return -EINVAL; |
| 20692 | } |
| 20693 | wlansap_populate_del_sta_params(param->mac, param->reason_code, |
| 20694 | param->subtype, &delStaParams); |
| 20695 | #else |
| 20696 | wlansap_populate_del_sta_params(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, |
| 20697 | (SIR_MAC_MGMT_DEAUTH >> 4), |
| 20698 | &delStaParams); |
| 20699 | #endif |
| 20700 | ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams); |
| 20701 | cds_ssr_unprotect(__func__); |
| 20702 | |
| 20703 | return ret; |
| 20704 | } |
| 20705 | |
| 20706 | /** |
| 20707 | * __wlan_hdd_cfg80211_add_station() - add station |
| 20708 | * @wiphy: Pointer to wiphy |
| 20709 | * @mac: Pointer to station mac address |
| 20710 | * @pmksa: Pointer to add station parameter |
| 20711 | * |
| 20712 | * Return: 0 for success, non-zero for failure |
| 20713 | */ |
| 20714 | static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 20715 | struct net_device *dev, |
| 20716 | const uint8_t *mac, |
| 20717 | struct station_parameters *params) |
| 20718 | { |
| 20719 | int status = -EPERM; |
| 20720 | #ifdef FEATURE_WLAN_TDLS |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20721 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20722 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20723 | u32 mask, set; |
| 20724 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20725 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20726 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 20727 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20728 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20729 | return -EINVAL; |
| 20730 | } |
| 20731 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20732 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 20733 | hdd_err("Invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 20734 | return -EINVAL; |
| 20735 | } |
| 20736 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 20737 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20738 | TRACE_CODE_HDD_CFG80211_ADD_STA, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20739 | adapter->session_id, params->listen_interval)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20740 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20741 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20742 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20743 | |
| 20744 | mask = params->sta_flags_mask; |
| 20745 | |
| 20746 | set = params->sta_flags_set; |
| 20747 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 20748 | 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] | 20749 | MAC_ADDR_ARRAY(mac)); |
| 20750 | |
| 20751 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Frank Liu | d1a2846 | 2017-09-06 22:55:48 +0800 | [diff] [blame] | 20752 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20753 | status = wlan_cfg80211_tdls_add_peer(hdd_ctx->hdd_pdev, |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 20754 | dev, mac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20755 | } |
| 20756 | #endif |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20757 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20758 | return status; |
| 20759 | } |
| 20760 | |
| 20761 | /** |
| 20762 | * wlan_hdd_cfg80211_add_station() - add station |
| 20763 | * @wiphy: Pointer to wiphy |
| 20764 | * @mac: Pointer to station mac address |
| 20765 | * @pmksa: Pointer to add station parameter |
| 20766 | * |
| 20767 | * Return: 0 for success, non-zero for failure |
| 20768 | */ |
| 20769 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 20770 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 20771 | struct net_device *dev, |
| 20772 | const uint8_t *mac, |
| 20773 | struct station_parameters *params) |
| 20774 | #else |
| 20775 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 20776 | struct net_device *dev, uint8_t *mac, |
| 20777 | struct station_parameters *params) |
| 20778 | #endif |
| 20779 | { |
| 20780 | int ret; |
| 20781 | |
| 20782 | cds_ssr_protect(__func__); |
| 20783 | ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params); |
| 20784 | cds_ssr_unprotect(__func__); |
| 20785 | |
| 20786 | return ret; |
| 20787 | } |
| 20788 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 20789 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 20790 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20791 | /* |
| 20792 | * wlan_hdd_is_pmksa_valid: API to validate pmksa |
| 20793 | * @pmksa: pointer to cfg80211_pmksa structure |
| 20794 | * |
| 20795 | * Return: True if valid else false |
| 20796 | */ |
| 20797 | static inline bool wlan_hdd_is_pmksa_valid(struct cfg80211_pmksa *pmksa) |
| 20798 | { |
| 20799 | if (!pmksa->bssid) { |
Vignesh Viswanathan | fa90d62 | 2017-12-22 13:13:26 +0530 | [diff] [blame] | 20800 | hdd_warn("bssid (%pK) is NULL", |
| 20801 | pmksa->bssid); |
| 20802 | if (!pmksa->ssid || !pmksa->cache_id) { |
| 20803 | hdd_err("either ssid (%pK) or cache_id (%pK) are NULL", |
| 20804 | pmksa->ssid, pmksa->cache_id); |
| 20805 | return false; |
| 20806 | } |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20807 | } |
| 20808 | return true; |
| 20809 | } |
| 20810 | |
| 20811 | /* |
| 20812 | * hdd_fill_pmksa_info: API to update tPmkidCacheInfo from cfg80211_pmksa |
| 20813 | * @pmk_cache: pmksa from supplicant |
| 20814 | * @pmk_cache: pmk needs to be updated |
| 20815 | * |
| 20816 | * Return: None |
| 20817 | */ |
| 20818 | static void hdd_fill_pmksa_info(tPmkidCacheInfo *pmk_cache, |
| 20819 | struct cfg80211_pmksa *pmksa, bool is_delete) |
| 20820 | { |
| 20821 | if (pmksa->bssid) { |
| 20822 | hdd_debug("%s PMKSA for " MAC_ADDRESS_STR, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20823 | is_delete ? "Delete" : "Set", |
| 20824 | MAC_ADDR_ARRAY(pmksa->bssid)); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20825 | qdf_mem_copy(pmk_cache->BSSID.bytes, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20826 | pmksa->bssid, QDF_MAC_ADDR_SIZE); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20827 | } else { |
| 20828 | qdf_mem_copy(pmk_cache->ssid, pmksa->ssid, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20829 | SIR_MAC_MAX_SSID_LENGTH); |
| 20830 | qdf_mem_copy(pmk_cache->cache_id, pmksa->cache_id, |
| 20831 | CACHE_ID_LEN); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20832 | pmk_cache->ssid_len = pmksa->ssid_len; |
| 20833 | hdd_debug("%s PMKSA for ssid %*.*s cache_id %x %x", |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20834 | is_delete ? "Delete" : "Set", |
| 20835 | pmk_cache->ssid_len, pmk_cache->ssid_len, |
| 20836 | pmk_cache->ssid, pmk_cache->cache_id[0], |
| 20837 | pmk_cache->cache_id[1]); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20838 | } |
| 20839 | |
| 20840 | if (is_delete) |
| 20841 | return; |
| 20842 | |
| 20843 | qdf_mem_copy(pmk_cache->PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE); |
| 20844 | if (pmksa->pmk_len && (pmksa->pmk_len <= CSR_RSN_MAX_PMK_LEN)) { |
| 20845 | qdf_mem_copy(pmk_cache->pmk, pmksa->pmk, pmksa->pmk_len); |
| 20846 | pmk_cache->pmk_len = pmksa->pmk_len; |
| 20847 | } else |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 20848 | hdd_debug("pmk len is %zu", pmksa->pmk_len); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20849 | } |
| 20850 | #else |
| 20851 | /* |
| 20852 | * wlan_hdd_is_pmksa_valid: API to validate pmksa |
| 20853 | * @pmksa: pointer to cfg80211_pmksa structure |
| 20854 | * |
| 20855 | * Return: True if valid else false |
| 20856 | */ |
| 20857 | static inline bool wlan_hdd_is_pmksa_valid(struct cfg80211_pmksa *pmksa) |
| 20858 | { |
| 20859 | if (!pmksa->bssid) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 20860 | hdd_err("both bssid is NULL %pK", pmksa->bssid); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20861 | return false; |
| 20862 | } |
| 20863 | return true; |
| 20864 | } |
| 20865 | |
| 20866 | /* |
| 20867 | * hdd_fill_pmksa_info: API to update tPmkidCacheInfo from cfg80211_pmksa |
| 20868 | * @pmk_cache: pmksa from supplicant |
| 20869 | * @pmk_cache: pmk needs to be updated |
| 20870 | * |
| 20871 | * Return: None |
| 20872 | */ |
| 20873 | static void hdd_fill_pmksa_info(tPmkidCacheInfo *pmk_cache, |
| 20874 | struct cfg80211_pmksa *pmksa, bool is_delete) |
| 20875 | { |
| 20876 | hdd_debug("%s PMKSA for " MAC_ADDRESS_STR, is_delete ? "Delete" : "Set", |
| 20877 | MAC_ADDR_ARRAY(pmksa->bssid)); |
| 20878 | qdf_mem_copy(pmk_cache->BSSID.bytes, |
| 20879 | pmksa->bssid, QDF_MAC_ADDR_SIZE); |
| 20880 | |
| 20881 | if (is_delete) |
| 20882 | return; |
| 20883 | |
| 20884 | qdf_mem_copy(pmk_cache->PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE); |
| 20885 | } |
| 20886 | #endif |
| 20887 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20888 | /** |
| 20889 | * __wlan_hdd_cfg80211_set_pmksa() - set pmksa |
| 20890 | * @wiphy: Pointer to wiphy |
| 20891 | * @dev: Pointer to network device |
| 20892 | * @pmksa: Pointer to set pmksa parameter |
| 20893 | * |
| 20894 | * Return: 0 for success, non-zero for failure |
| 20895 | */ |
| 20896 | static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, |
| 20897 | struct net_device *dev, |
| 20898 | struct cfg80211_pmksa *pmksa) |
| 20899 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20900 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 20901 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20902 | tHalHandle halHandle; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20903 | QDF_STATUS result = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20904 | int status; |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20905 | tPmkidCacheInfo pmk_cache; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20906 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 20907 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 20908 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 20909 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20910 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20911 | return -EINVAL; |
| 20912 | } |
| 20913 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20914 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 20915 | hdd_err("Invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 20916 | return -EINVAL; |
| 20917 | } |
| 20918 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20919 | if (!pmksa) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 20920 | hdd_err("pmksa is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20921 | return -EINVAL; |
| 20922 | } |
| 20923 | |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20924 | if (!pmksa->pmkid) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 20925 | hdd_err("pmksa->pmkid(%pK) is NULL", |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20926 | pmksa->pmkid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20927 | return -EINVAL; |
| 20928 | } |
| 20929 | |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20930 | if (!wlan_hdd_is_pmksa_valid(pmksa)) |
| 20931 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20932 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 20933 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20934 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 20935 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20936 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20937 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20938 | halHandle = WLAN_HDD_GET_HAL_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20939 | |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20940 | qdf_mem_zero(&pmk_cache, sizeof(pmk_cache)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20941 | |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20942 | hdd_fill_pmksa_info(&pmk_cache, pmksa, false); |
| 20943 | |
| 20944 | /* |
| 20945 | * Add to the PMKSA Cache in CSR |
| 20946 | * PMKSA cache will be having following |
| 20947 | * 1. pmkid id |
| 20948 | * 2. pmk |
| 20949 | * 3. bssid or cache identifier |
| 20950 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20951 | result = sme_roam_set_pmkid_cache(halHandle, adapter->session_id, |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 20952 | &pmk_cache, 1, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20953 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 20954 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20955 | TRACE_CODE_HDD_CFG80211_SET_PMKSA, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20956 | adapter->session_id, result)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20957 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 20958 | sme_set_del_pmkid_cache(halHandle, adapter->session_id, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 20959 | &pmk_cache, true); |
| 20960 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 20961 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 20962 | return QDF_IS_STATUS_SUCCESS(result) ? 0 : -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20963 | } |
| 20964 | |
| 20965 | /** |
| 20966 | * wlan_hdd_cfg80211_set_pmksa() - set pmksa |
| 20967 | * @wiphy: Pointer to wiphy |
| 20968 | * @dev: Pointer to network device |
| 20969 | * @pmksa: Pointer to set pmksa parameter |
| 20970 | * |
| 20971 | * Return: 0 for success, non-zero for failure |
| 20972 | */ |
| 20973 | static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, |
| 20974 | struct net_device *dev, |
| 20975 | struct cfg80211_pmksa *pmksa) |
| 20976 | { |
| 20977 | int ret; |
| 20978 | |
| 20979 | cds_ssr_protect(__func__); |
| 20980 | ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa); |
| 20981 | cds_ssr_unprotect(__func__); |
| 20982 | |
| 20983 | return ret; |
| 20984 | } |
| 20985 | |
| 20986 | /** |
| 20987 | * __wlan_hdd_cfg80211_del_pmksa() - delete pmksa |
| 20988 | * @wiphy: Pointer to wiphy |
| 20989 | * @dev: Pointer to network device |
| 20990 | * @pmksa: Pointer to pmksa parameter |
| 20991 | * |
| 20992 | * Return: 0 for success, non-zero for failure |
| 20993 | */ |
| 20994 | static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, |
| 20995 | struct net_device *dev, |
| 20996 | struct cfg80211_pmksa *pmksa) |
| 20997 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 20998 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 20999 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21000 | tHalHandle halHandle; |
| 21001 | int status = 0; |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 21002 | tPmkidCacheInfo pmk_cache; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21003 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 21004 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 21005 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 21006 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21007 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21008 | return -EINVAL; |
| 21009 | } |
| 21010 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21011 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 21012 | hdd_err("invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 21013 | return -EINVAL; |
| 21014 | } |
| 21015 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21016 | if (!pmksa) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21017 | hdd_err("pmksa is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21018 | return -EINVAL; |
| 21019 | } |
| 21020 | |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 21021 | if (!wlan_hdd_is_pmksa_valid(pmksa)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21022 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21023 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21024 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21025 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 21026 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21027 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21028 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21029 | halHandle = WLAN_HDD_GET_HAL_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21030 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 21031 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 21032 | TRACE_CODE_HDD_CFG80211_DEL_PMKSA, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21033 | adapter->session_id, 0)); |
Sridhar Selvaraj | c3684c7 | 2017-08-21 14:32:47 +0530 | [diff] [blame] | 21034 | |
| 21035 | qdf_mem_zero(&pmk_cache, sizeof(pmk_cache)); |
| 21036 | |
| 21037 | hdd_fill_pmksa_info(&pmk_cache, pmksa, true); |
| 21038 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21039 | /* Delete the PMKID CSR cache */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 21040 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21041 | sme_roam_del_pmkid_from_cache(halHandle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21042 | adapter->session_id, &pmk_cache, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21043 | false)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21044 | hdd_err("Failed to delete PMKSA for " MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21045 | MAC_ADDR_ARRAY(pmksa->bssid)); |
| 21046 | status = -EINVAL; |
| 21047 | } |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21048 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21049 | sme_set_del_pmkid_cache(halHandle, adapter->session_id, &pmk_cache, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21050 | false); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 21051 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21052 | return status; |
| 21053 | } |
| 21054 | |
| 21055 | /** |
| 21056 | * wlan_hdd_cfg80211_del_pmksa() - delete pmksa |
| 21057 | * @wiphy: Pointer to wiphy |
| 21058 | * @dev: Pointer to network device |
| 21059 | * @pmksa: Pointer to pmksa parameter |
| 21060 | * |
| 21061 | * Return: 0 for success, non-zero for failure |
| 21062 | */ |
| 21063 | static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, |
| 21064 | struct net_device *dev, |
| 21065 | struct cfg80211_pmksa *pmksa) |
| 21066 | { |
| 21067 | int ret; |
| 21068 | |
| 21069 | cds_ssr_protect(__func__); |
| 21070 | ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa); |
| 21071 | cds_ssr_unprotect(__func__); |
| 21072 | |
| 21073 | return ret; |
| 21074 | |
| 21075 | } |
| 21076 | |
| 21077 | /** |
| 21078 | * __wlan_hdd_cfg80211_flush_pmksa() - flush pmksa |
| 21079 | * @wiphy: Pointer to wiphy |
| 21080 | * @dev: Pointer to network device |
| 21081 | * |
| 21082 | * Return: 0 for success, non-zero for failure |
| 21083 | */ |
| 21084 | static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, |
| 21085 | struct net_device *dev) |
| 21086 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21087 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 21088 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21089 | tHalHandle halHandle; |
| 21090 | int status = 0; |
| 21091 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 21092 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 21093 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 21094 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21095 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21096 | return -EINVAL; |
| 21097 | } |
| 21098 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21099 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 21100 | hdd_err("invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 21101 | return -EINVAL; |
| 21102 | } |
| 21103 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21104 | hdd_debug("Flushing PMKSA"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21105 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21106 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21107 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21108 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 21109 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21110 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21111 | |
| 21112 | /* Retrieve halHandle */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21113 | halHandle = WLAN_HDD_GET_HAL_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21114 | |
| 21115 | /* Flush the PMKID cache in CSR */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 21116 | if (QDF_STATUS_SUCCESS != |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21117 | sme_roam_del_pmkid_from_cache(halHandle, adapter->session_id, NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21118 | true)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21119 | hdd_err("Cannot flush PMKIDCache"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21120 | status = -EINVAL; |
| 21121 | } |
Vignesh Viswanathan | e8a26b2 | 2017-10-11 20:38:47 +0530 | [diff] [blame] | 21122 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21123 | sme_set_del_pmkid_cache(halHandle, adapter->session_id, NULL, false); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 21124 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21125 | return status; |
| 21126 | } |
| 21127 | |
| 21128 | /** |
| 21129 | * wlan_hdd_cfg80211_flush_pmksa() - flush pmksa |
| 21130 | * @wiphy: Pointer to wiphy |
| 21131 | * @dev: Pointer to network device |
| 21132 | * |
| 21133 | * Return: 0 for success, non-zero for failure |
| 21134 | */ |
| 21135 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, |
| 21136 | struct net_device *dev) |
| 21137 | { |
| 21138 | int ret; |
| 21139 | |
| 21140 | cds_ssr_protect(__func__); |
| 21141 | ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev); |
| 21142 | cds_ssr_unprotect(__func__); |
| 21143 | |
| 21144 | return ret; |
| 21145 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21146 | |
Deepak Dhamdhere | 9f09e75 | 2016-01-09 23:17:25 -0800 | [diff] [blame] | 21147 | #if defined(KERNEL_SUPPORT_11R_CFG80211) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21148 | /** |
| 21149 | * __wlan_hdd_cfg80211_update_ft_ies() - update fast transition ies |
| 21150 | * @wiphy: Pointer to wiphy |
| 21151 | * @dev: Pointer to network device |
| 21152 | * @ftie: Pointer to fast transition ie parameter |
| 21153 | * |
| 21154 | * Return: 0 for success, non-zero for failure |
| 21155 | */ |
| 21156 | static int |
| 21157 | __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 21158 | struct net_device *dev, |
| 21159 | struct cfg80211_update_ft_ies_params *ftie) |
| 21160 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 21161 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21162 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 21163 | 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] | 21164 | int status; |
| 21165 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 21166 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 21167 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21168 | status = wlan_hdd_validate_context(hdd_ctx); |
| 21169 | if (status) |
| 21170 | return status; |
| 21171 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 21172 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21173 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21174 | return -EINVAL; |
| 21175 | } |
| 21176 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21177 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 21178 | hdd_err("invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 21179 | return -EINVAL; |
| 21180 | } |
| 21181 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 21182 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21183 | TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21184 | adapter->session_id, sta_ctx->conn_info.connState)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21185 | /* Added for debug on reception of Re-assoc Req. */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 21186 | if (eConnectionState_Associated != sta_ctx->conn_info.connState) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21187 | hdd_err("Called with Ie of length = %zu when not associated", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21188 | ftie->ie_len); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21189 | hdd_err("Should be Re-assoc Req IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21190 | } |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21191 | hdd_debug("%s called with Ie of length = %zu", __func__, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21192 | ftie->ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21193 | |
| 21194 | /* Pass the received FT IEs to SME */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21195 | sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(adapter), adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21196 | (const u8 *)ftie->ie, ftie->ie_len); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 21197 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21198 | return 0; |
| 21199 | } |
| 21200 | |
| 21201 | /** |
| 21202 | * wlan_hdd_cfg80211_update_ft_ies() - update fast transition ies |
| 21203 | * @wiphy: Pointer to wiphy |
| 21204 | * @dev: Pointer to network device |
| 21205 | * @ftie: Pointer to fast transition ie parameter |
| 21206 | * |
| 21207 | * Return: 0 for success, non-zero for failure |
| 21208 | */ |
| 21209 | static int |
| 21210 | wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 21211 | struct net_device *dev, |
| 21212 | struct cfg80211_update_ft_ies_params *ftie) |
| 21213 | { |
| 21214 | int ret; |
| 21215 | |
| 21216 | cds_ssr_protect(__func__); |
| 21217 | ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie); |
| 21218 | cds_ssr_unprotect(__func__); |
| 21219 | |
| 21220 | return ret; |
| 21221 | } |
| 21222 | #endif |
| 21223 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 21224 | void wlan_hdd_cfg80211_update_replay_counter_cb( |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21225 | void *cb_ctx, struct pmo_gtk_rsp_params *gtk_rsp_param) |
| 21226 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21227 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21228 | struct hdd_adapter *adapter = (struct hdd_adapter *)cb_ctx; |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21229 | uint8_t temp_replay_counter[8]; |
| 21230 | int i; |
| 21231 | uint8_t *p; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21232 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 21233 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21234 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21235 | if (!adapter) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21236 | hdd_err("HDD adapter is Null"); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21237 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21238 | } |
| 21239 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21240 | if (!gtk_rsp_param) { |
| 21241 | hdd_err("gtk_rsp_param is Null"); |
| 21242 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21243 | } |
| 21244 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21245 | if (gtk_rsp_param->status_flag != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21246 | hdd_err("wlan Failed to get replay counter value"); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21247 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21248 | } |
| 21249 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21250 | hdd_debug("updated replay counter: %llu from fwr", |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21251 | gtk_rsp_param->replay_counter); |
| 21252 | /* convert little to big endian since supplicant works on big endian */ |
| 21253 | p = (uint8_t *)>k_rsp_param->replay_counter; |
| 21254 | for (i = 0; i < 8; i++) |
| 21255 | temp_replay_counter[7 - i] = (uint8_t) p[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21256 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21257 | hdd_debug("gtk_rsp_param bssid %pM", gtk_rsp_param->bssid.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21258 | /* Update replay counter to NL */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21259 | cfg80211_gtk_rekey_notify(adapter->dev, |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21260 | gtk_rsp_param->bssid.bytes, |
| 21261 | temp_replay_counter, GFP_KERNEL); |
| 21262 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 21263 | hdd_exit(); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21264 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21265 | } |
| 21266 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21267 | /** |
| 21268 | * wlan_hdd_copy_gtk_kek - Copy the KEK from GTK rekey data to GTK request |
| 21269 | * @gtk_req: Pointer to GTK request |
| 21270 | * @data: Pointer to rekey data |
| 21271 | * |
| 21272 | * Return: none |
| 21273 | */ |
| 21274 | #ifdef CFG80211_REKEY_DATA_KEK_LEN |
| 21275 | static |
| 21276 | void wlan_hdd_copy_gtk_kek(struct pmo_gtk_req *gtk_req, |
| 21277 | struct cfg80211_gtk_rekey_data *data) |
| 21278 | { |
| 21279 | qdf_mem_copy(gtk_req->kek, data->kek, data->kek_len); |
| 21280 | gtk_req->kek_len = data->kek_len; |
| 21281 | } |
| 21282 | #else |
| 21283 | static |
| 21284 | void wlan_hdd_copy_gtk_kek(struct pmo_gtk_req *gtk_req, |
| 21285 | struct cfg80211_gtk_rekey_data *data) |
| 21286 | { |
| 21287 | qdf_mem_copy(gtk_req->kek, data->kek, NL80211_KEK_LEN); |
| 21288 | gtk_req->kek_len = NL80211_KEK_LEN; |
| 21289 | } |
| 21290 | #endif |
| 21291 | |
| 21292 | /** |
| 21293 | * __wlan_hdd_cfg80211_set_rekey_data() - set rekey data |
| 21294 | * @wiphy: Pointer to wiphy |
| 21295 | * @dev: Pointer to network device |
| 21296 | * @data: Pointer to rekey data |
| 21297 | * |
| 21298 | * This function is used to offload GTK rekeying job to the firmware. |
| 21299 | * |
| 21300 | * Return: 0 for success, non-zero for failure |
| 21301 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 21302 | static |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21303 | int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21304 | struct net_device *dev, |
| 21305 | struct cfg80211_gtk_rekey_data *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21306 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21307 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21308 | int result, i; |
| 21309 | struct pmo_gtk_req *gtk_req = NULL; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21310 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21311 | uint8_t *buf; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 21312 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21313 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 21314 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21315 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 21316 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21317 | hdd_err("Command not allowed in FTM mode"); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21318 | result = -EINVAL; |
| 21319 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21320 | } |
| 21321 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21322 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 21323 | hdd_err("invalid session id: %d", adapter->session_id); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21324 | result = -EINVAL; |
| 21325 | goto out; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 21326 | } |
| 21327 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 21328 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21329 | TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21330 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21331 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21332 | result = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 21333 | if (0 != result) |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21334 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21335 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21336 | gtk_req = qdf_mem_malloc(sizeof(*gtk_req)); |
| 21337 | if (!gtk_req) { |
| 21338 | hdd_err("cannot allocate gtk_req"); |
| 21339 | result = -ENOMEM; |
| 21340 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21341 | } |
| 21342 | |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21343 | /* convert big to little endian since driver work on little endian */ |
| 21344 | buf = (uint8_t *)>k_req->replay_counter; |
| 21345 | for (i = 0; i < 8; i++) |
| 21346 | buf[7 - i] = data->replay_ctr[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21347 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21348 | hdd_debug("current replay counter: %llu in user space", |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21349 | gtk_req->replay_counter); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 21350 | |
| 21351 | wlan_hdd_copy_gtk_kek(gtk_req, data); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21352 | qdf_mem_copy(gtk_req->kck, data->kck, NL80211_KCK_LEN); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21353 | status = pmo_ucfg_cache_gtk_offload_req(adapter->hdd_vdev, gtk_req); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21354 | if (status != QDF_STATUS_SUCCESS) { |
| 21355 | hdd_err("Failed to cache GTK Offload"); |
| 21356 | result = qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21357 | } |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21358 | out: |
| 21359 | if (gtk_req) |
| 21360 | qdf_mem_free(gtk_req); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 21361 | hdd_exit(); |
Mukul Sharma | 3d36c39 | 2017-01-18 18:39:12 +0530 | [diff] [blame] | 21362 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21363 | return result; |
| 21364 | } |
| 21365 | |
| 21366 | /** |
| 21367 | * wlan_hdd_cfg80211_set_rekey_data() - set rekey data |
| 21368 | * @wiphy: Pointer to wiphy |
| 21369 | * @dev: Pointer to network device |
| 21370 | * @data: Pointer to rekey data |
| 21371 | * |
| 21372 | * This function is used to offload GTK rekeying job to the firmware. |
| 21373 | * |
| 21374 | * Return: 0 for success, non-zero for failure |
| 21375 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 21376 | static |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21377 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, |
| 21378 | struct net_device *dev, |
| 21379 | struct cfg80211_gtk_rekey_data *data) |
| 21380 | { |
| 21381 | int ret; |
| 21382 | |
| 21383 | cds_ssr_protect(__func__); |
| 21384 | ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data); |
| 21385 | cds_ssr_unprotect(__func__); |
| 21386 | |
| 21387 | return ret; |
| 21388 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21389 | |
| 21390 | /** |
| 21391 | * __wlan_hdd_cfg80211_set_mac_acl() - set access control policy |
| 21392 | * @wiphy: Pointer to wiphy |
| 21393 | * @dev: Pointer to network device |
| 21394 | * @param: Pointer to access control parameter |
| 21395 | * |
| 21396 | * Return: 0 for success, non-zero for failure |
| 21397 | */ |
| 21398 | static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 21399 | struct net_device *dev, |
| 21400 | const struct cfg80211_acl_data *params) |
| 21401 | { |
| 21402 | int i; |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21403 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 5c19ade | 2017-10-04 09:52:12 -0700 | [diff] [blame] | 21404 | struct hdd_hostapd_state *hostapd_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21405 | tsap_Config_t *pConfig; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21406 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21407 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 21408 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21409 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 21410 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21411 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 21412 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21413 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21414 | return -EINVAL; |
| 21415 | } |
| 21416 | |
| 21417 | if (NULL == params) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21418 | hdd_err("params is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21419 | return -EINVAL; |
| 21420 | } |
| 21421 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21422 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21423 | status = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21424 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 21425 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21426 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21427 | |
Jeff Johnson | 5c19ade | 2017-10-04 09:52:12 -0700 | [diff] [blame] | 21428 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21429 | |
Jeff Johnson | 5c19ade | 2017-10-04 09:52:12 -0700 | [diff] [blame] | 21430 | if (NULL == hostapd_state) { |
| 21431 | hdd_err("hostapd_state is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21432 | return -EINVAL; |
| 21433 | } |
| 21434 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21435 | hdd_debug("acl policy: %d num acl entries: %d", params->acl_policy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21436 | params->n_acl_entries); |
| 21437 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 21438 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 21439 | TRACE_CODE_HDD_CFG80211_SET_MAC_ACL, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21440 | adapter->session_id, adapter->device_mode)); |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21441 | if (QDF_SAP_MODE == adapter->device_mode) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 21442 | pConfig = &adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21443 | |
| 21444 | /* default value */ |
| 21445 | pConfig->num_accept_mac = 0; |
| 21446 | pConfig->num_deny_mac = 0; |
| 21447 | |
| 21448 | /** |
| 21449 | * access control policy |
| 21450 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 21451 | * listed in hostapd.deny file. |
| 21452 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 21453 | * listed in hostapd.accept file. |
| 21454 | */ |
| 21455 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) { |
| 21456 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 21457 | } else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == |
| 21458 | params->acl_policy) { |
| 21459 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 21460 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21461 | hdd_warn("Acl Policy : %d is not supported", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21462 | params->acl_policy); |
| 21463 | return -ENOTSUPP; |
| 21464 | } |
| 21465 | |
| 21466 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) { |
| 21467 | pConfig->num_accept_mac = params->n_acl_entries; |
| 21468 | for (i = 0; i < params->n_acl_entries; i++) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21469 | hdd_debug("** Add ACL MAC entry %i in WhiletList :" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21470 | MAC_ADDRESS_STR, i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21471 | MAC_ADDR_ARRAY( |
| 21472 | params->mac_addrs[i].addr)); |
| 21473 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 21474 | qdf_mem_copy(&pConfig->accept_mac[i], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21475 | params->mac_addrs[i].addr, |
| 21476 | sizeof(qcmacaddr)); |
| 21477 | } |
| 21478 | } else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) { |
| 21479 | pConfig->num_deny_mac = params->n_acl_entries; |
| 21480 | for (i = 0; i < params->n_acl_entries; i++) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21481 | hdd_debug("** Add ACL MAC entry %i in BlackList :" |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21482 | MAC_ADDRESS_STR, i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21483 | MAC_ADDR_ARRAY( |
| 21484 | params->mac_addrs[i].addr)); |
| 21485 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 21486 | qdf_mem_copy(&pConfig->deny_mac[i], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21487 | params->mac_addrs[i].addr, |
| 21488 | sizeof(qcmacaddr)); |
| 21489 | } |
| 21490 | } |
Dustin Brown | 6ba30a1 | 2016-09-13 13:59:43 -0700 | [diff] [blame] | 21491 | qdf_status = wlansap_set_mac_acl( |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21492 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), pConfig); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 21493 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21494 | hdd_err("SAP Set Mac Acl fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21495 | return -EINVAL; |
| 21496 | } |
| 21497 | } else { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21498 | hdd_debug("Invalid device_mode %s(%d)", |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21499 | hdd_device_mode_to_string(adapter->device_mode), |
| 21500 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21501 | return -EINVAL; |
| 21502 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 21503 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21504 | return 0; |
| 21505 | } |
| 21506 | |
| 21507 | /** |
| 21508 | * wlan_hdd_cfg80211_set_mac_acl() - SSR wrapper for |
| 21509 | * __wlan_hdd_cfg80211_set_mac_acl |
| 21510 | * @wiphy: pointer to wiphy structure |
| 21511 | * @dev: pointer to net_device |
| 21512 | * @params: pointer to cfg80211_acl_data |
| 21513 | * |
| 21514 | * Return; 0 on success, error number otherwise |
| 21515 | */ |
| 21516 | static int |
| 21517 | wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 21518 | struct net_device *dev, |
| 21519 | const struct cfg80211_acl_data *params) |
| 21520 | { |
| 21521 | int ret; |
| 21522 | |
| 21523 | cds_ssr_protect(__func__); |
| 21524 | ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params); |
| 21525 | cds_ssr_unprotect(__func__); |
| 21526 | |
| 21527 | return ret; |
| 21528 | } |
| 21529 | |
| 21530 | #ifdef WLAN_NL80211_TESTMODE |
| 21531 | #ifdef FEATURE_WLAN_LPHB |
| 21532 | /** |
| 21533 | * wlan_hdd_cfg80211_lphb_ind_handler() - handle low power heart beat indication |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21534 | * @hdd_ctx: Pointer to hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21535 | * @lphbInd: Pointer to low power heart beat indication parameter |
| 21536 | * |
| 21537 | * Return: none |
| 21538 | */ |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21539 | static void wlan_hdd_cfg80211_lphb_ind_handler(void *hdd_ctx, |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 21540 | struct pmo_lphb_rsp *lphb_ind) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21541 | { |
| 21542 | struct sk_buff *skb; |
| 21543 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21544 | hdd_debug("LPHB indication arrived"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21545 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21546 | if (0 != wlan_hdd_validate_context((struct hdd_context *) hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21547 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21548 | |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 21549 | if (!lphb_ind) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21550 | hdd_err("invalid argument lphbInd"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21551 | return; |
| 21552 | } |
| 21553 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21554 | skb = cfg80211_testmode_alloc_event_skb(((struct hdd_context *) hdd_ctx)-> |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 21555 | wiphy, sizeof(*lphb_ind), GFP_ATOMIC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21556 | if (!skb) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21557 | hdd_err("LPHB timeout, NL buffer alloc fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21558 | return; |
| 21559 | } |
| 21560 | |
| 21561 | 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] | 21562 | hdd_err("WLAN_HDD_TM_ATTR_CMD put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21563 | goto nla_put_failure; |
| 21564 | } |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 21565 | 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] | 21566 | hdd_err("WLAN_HDD_TM_ATTR_TYPE put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21567 | goto nla_put_failure; |
| 21568 | } |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 21569 | if (nla_put(skb, WLAN_HDD_TM_ATTR_DATA, sizeof(*lphb_ind), |
| 21570 | lphb_ind)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21571 | hdd_err("WLAN_HDD_TM_ATTR_DATA put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21572 | goto nla_put_failure; |
| 21573 | } |
| 21574 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 21575 | return; |
| 21576 | |
| 21577 | nla_put_failure: |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21578 | hdd_err("NLA Put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21579 | kfree_skb(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21580 | } |
| 21581 | #endif /* FEATURE_WLAN_LPHB */ |
| 21582 | |
| 21583 | /** |
| 21584 | * __wlan_hdd_cfg80211_testmode() - test mode |
| 21585 | * @wiphy: Pointer to wiphy |
| 21586 | * @data: Data pointer |
| 21587 | * @len: Data length |
| 21588 | * |
| 21589 | * Return: 0 for success, non-zero for failure |
| 21590 | */ |
| 21591 | static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, |
| 21592 | void *data, int len) |
| 21593 | { |
| 21594 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 21595 | int err; |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21596 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21597 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 21598 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 21599 | |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21600 | err = wlan_hdd_validate_context(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21601 | if (err) |
| 21602 | return err; |
| 21603 | |
Dustin Brown | 4ea21db | 2018-01-05 14:13:17 -0800 | [diff] [blame] | 21604 | err = wlan_cfg80211_nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, |
| 21605 | len, wlan_hdd_tm_policy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21606 | if (err) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21607 | hdd_err("Testmode INV ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21608 | return err; |
| 21609 | } |
| 21610 | |
| 21611 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21612 | hdd_err("Testmode INV CMD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21613 | return -EINVAL; |
| 21614 | } |
| 21615 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 21616 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 21617 | TRACE_CODE_HDD_CFG80211_TESTMODE, |
| 21618 | NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21619 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) { |
| 21620 | #ifdef FEATURE_WLAN_LPHB |
| 21621 | /* Low Power Heartbeat configuration request */ |
| 21622 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 21623 | { |
| 21624 | int buf_len; |
| 21625 | void *buf; |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 21626 | struct pmo_lphb_req *hb_params = NULL; |
| 21627 | struct pmo_lphb_req *hb_params_temp = NULL; |
| 21628 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21629 | |
| 21630 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21631 | hdd_err("Testmode INV DATA"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21632 | return -EINVAL; |
| 21633 | } |
| 21634 | |
| 21635 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 21636 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 21637 | |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 21638 | hb_params_temp = (struct pmo_lphb_req *) buf; |
| 21639 | if ((hb_params_temp->cmd == pmo_lphb_set_tcp_pararm_indid) |
| 21640 | && (hb_params_temp->params.lphb_tcp_params. |
| 21641 | time_period_sec == 0)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21642 | return -EINVAL; |
| 21643 | |
Manjeet Singh | 00b2a56 | 2017-01-03 12:08:10 +0530 | [diff] [blame] | 21644 | if (buf_len > sizeof(*hb_params)) { |
| 21645 | hdd_err("buf_len=%d exceeded hb_params size limit", |
| 21646 | buf_len); |
| 21647 | return -ERANGE; |
| 21648 | } |
| 21649 | |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 21650 | hb_params = (struct pmo_lphb_req *)qdf_mem_malloc( |
| 21651 | sizeof(*hb_params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21652 | if (NULL == hb_params) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21653 | hdd_err("Request Buffer Alloc Fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21654 | return -ENOMEM; |
| 21655 | } |
| 21656 | |
Ashish Kumar Dhanotiya | 0fa8ee0 | 2017-07-13 14:04:31 +0530 | [diff] [blame] | 21657 | qdf_mem_zero(hb_params, sizeof(*hb_params)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 21658 | qdf_mem_copy(hb_params, buf, buf_len); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21659 | status = pmo_ucfg_lphb_config_req(hdd_ctx->hdd_psoc, |
| 21660 | hb_params, (void *)hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21661 | wlan_hdd_cfg80211_lphb_ind_handler); |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 21662 | if (status != QDF_STATUS_SUCCESS) |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21663 | hdd_err("LPHB Config Fail, disable"); |
Mukul Sharma | fcd57f5 | 2017-03-20 18:18:59 +0530 | [diff] [blame] | 21664 | |
| 21665 | qdf_mem_free(hb_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21666 | return 0; |
| 21667 | } |
| 21668 | #endif /* FEATURE_WLAN_LPHB */ |
| 21669 | |
| 21670 | #if defined(QCA_WIFI_FTM) |
| 21671 | case WLAN_HDD_TM_CMD_WLAN_FTM: |
| 21672 | { |
Ryan Hsu | c8b27a4 | 2018-01-02 13:57:56 -0800 | [diff] [blame] | 21673 | err = wlan_cfg80211_ftm_testmode_cmd(hdd_ctx->hdd_pdev, |
| 21674 | data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21675 | break; |
| 21676 | } |
| 21677 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21678 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21679 | hdd_err("command: %d not supported", |
Ryan Hsu | c8b27a4 | 2018-01-02 13:57:56 -0800 | [diff] [blame] | 21680 | nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21681 | return -EOPNOTSUPP; |
| 21682 | } |
Ryan Hsu | c8b27a4 | 2018-01-02 13:57:56 -0800 | [diff] [blame] | 21683 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 21684 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21685 | return err; |
| 21686 | } |
| 21687 | |
| 21688 | /** |
| 21689 | * wlan_hdd_cfg80211_testmode() - test mode |
| 21690 | * @wiphy: Pointer to wiphy |
| 21691 | * @dev: Pointer to network device |
| 21692 | * @data: Data pointer |
| 21693 | * @len: Data length |
| 21694 | * |
| 21695 | * Return: 0 for success, non-zero for failure |
| 21696 | */ |
| 21697 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, |
| 21698 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) |
| 21699 | struct wireless_dev *wdev, |
| 21700 | #endif |
| 21701 | void *data, int len) |
| 21702 | { |
| 21703 | int ret; |
| 21704 | |
| 21705 | cds_ssr_protect(__func__); |
| 21706 | ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len); |
| 21707 | cds_ssr_unprotect(__func__); |
| 21708 | |
| 21709 | return ret; |
| 21710 | } |
| 21711 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21712 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 21713 | |
| 21714 | #ifdef QCA_HT_2040_COEX |
| 21715 | /** |
| 21716 | * __wlan_hdd_cfg80211_set_ap_channel_width() - set ap channel bandwidth |
| 21717 | * @wiphy: Pointer to wiphy |
| 21718 | * @dev: Pointer to network device |
| 21719 | * @chandef: Pointer to channel definition parameter |
| 21720 | * |
| 21721 | * Return: 0 for success, non-zero for failure |
| 21722 | */ |
| 21723 | static int |
| 21724 | __wlan_hdd_cfg80211_set_ap_channel_width(struct wiphy *wiphy, |
| 21725 | struct net_device *dev, |
| 21726 | struct cfg80211_chan_def *chandef) |
| 21727 | { |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21728 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21729 | struct hdd_context *hdd_ctx; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 21730 | QDF_STATUS status; |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 21731 | int retval = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21732 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 21733 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 21734 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21735 | return -EINVAL; |
| 21736 | } |
| 21737 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21738 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 21739 | hdd_err("invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 21740 | return -EINVAL; |
| 21741 | } |
Abhishek Singh | 9d5f458 | 2017-10-11 17:59:48 +0530 | [diff] [blame] | 21742 | if (!(adapter->device_mode == QDF_SAP_MODE || |
| 21743 | adapter->device_mode == QDF_P2P_GO_MODE)) |
| 21744 | return -EOPNOTSUPP; |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 21745 | |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21746 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | b894472 | 2017-09-03 09:03:19 -0700 | [diff] [blame] | 21747 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 21748 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21749 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21750 | |
Abhishek Singh | 9d5f458 | 2017-10-11 17:59:48 +0530 | [diff] [blame] | 21751 | hdd_debug("Channel width changed to %d ", |
| 21752 | cfg80211_get_chandef_type(chandef)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21753 | |
| 21754 | /* Change SAP ht2040 mode */ |
Jeff Johnson | ce2ba70 | 2017-10-02 13:30:24 -0700 | [diff] [blame] | 21755 | status = hdd_set_sap_ht2040_mode(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21756 | cfg80211_get_chandef_type(chandef)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 21757 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21758 | hdd_err("Cannot set SAP HT20/40 mode!"); |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 21759 | retval = -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21760 | } |
| 21761 | |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 21762 | return retval; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21763 | } |
| 21764 | |
| 21765 | /** |
| 21766 | * wlan_hdd_cfg80211_set_ap_channel_width() - set ap channel bandwidth |
| 21767 | * @wiphy: Pointer to wiphy |
| 21768 | * @dev: Pointer to network device |
| 21769 | * @chandef: Pointer to channel definition parameter |
| 21770 | * |
| 21771 | * Return: 0 for success, non-zero for failure |
| 21772 | */ |
| 21773 | static int |
| 21774 | wlan_hdd_cfg80211_set_ap_channel_width(struct wiphy *wiphy, |
| 21775 | struct net_device *dev, |
| 21776 | struct cfg80211_chan_def *chandef) |
| 21777 | { |
| 21778 | int ret; |
| 21779 | |
| 21780 | cds_ssr_protect(__func__); |
| 21781 | ret = __wlan_hdd_cfg80211_set_ap_channel_width(wiphy, dev, chandef); |
| 21782 | cds_ssr_unprotect(__func__); |
| 21783 | |
| 21784 | return ret; |
| 21785 | } |
| 21786 | #endif |
| 21787 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 21788 | #ifdef CHANNEL_SWITCH_SUPPORTED |
| 21789 | /** |
| 21790 | * __wlan_hdd_cfg80211_channel_switch()- function to switch |
| 21791 | * channel in SAP/GO |
| 21792 | * @wiphy: wiphy pointer |
| 21793 | * @dev: dev pointer. |
| 21794 | * @csa_params: Change channel params |
| 21795 | * |
| 21796 | * This function is called to switch channel in SAP/GO |
| 21797 | * |
| 21798 | * Return: 0 if success else return non zero |
| 21799 | */ |
| 21800 | static int __wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy, |
| 21801 | struct net_device *dev, |
| 21802 | struct cfg80211_csa_settings *csa_params) |
| 21803 | { |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 21804 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 21805 | struct hdd_context *hdd_ctx; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 21806 | uint8_t channel; |
| 21807 | uint16_t freq; |
| 21808 | int ret; |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 21809 | enum phy_ch_width ch_width; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 21810 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21811 | hdd_debug("Set Freq %d", |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 21812 | csa_params->chandef.chan->center_freq); |
| 21813 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 21814 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 21815 | hdd_err("invalid session id: %d", adapter->session_id); |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 21816 | return -EINVAL; |
| 21817 | } |
| 21818 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 21819 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 21820 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 21821 | |
| 21822 | if (0 != ret) |
| 21823 | return ret; |
| 21824 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 21825 | if ((QDF_P2P_GO_MODE != adapter->device_mode) && |
| 21826 | (QDF_SAP_MODE != adapter->device_mode)) |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 21827 | return -ENOTSUPP; |
| 21828 | |
| 21829 | freq = csa_params->chandef.chan->center_freq; |
| 21830 | channel = cds_freq_to_chan(freq); |
| 21831 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 21832 | ch_width = hdd_map_nl_chan_width(csa_params->chandef.width); |
| 21833 | |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 21834 | ret = hdd_softap_set_channel_change(dev, channel, ch_width, false); |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 21835 | return ret; |
| 21836 | } |
| 21837 | |
| 21838 | /** |
| 21839 | * wlan_hdd_cfg80211_channel_switch()- function to switch |
| 21840 | * channel in SAP/GO |
| 21841 | * @wiphy: wiphy pointer |
| 21842 | * @dev: dev pointer. |
| 21843 | * @csa_params: Change channel params |
| 21844 | * |
| 21845 | * This function is called to switch channel in SAP/GO |
| 21846 | * |
| 21847 | * Return: 0 if success else return non zero |
| 21848 | */ |
| 21849 | static int wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy, |
| 21850 | struct net_device *dev, |
| 21851 | struct cfg80211_csa_settings *csa_params) |
| 21852 | { |
| 21853 | int ret; |
| 21854 | |
| 21855 | cds_ssr_protect(__func__); |
| 21856 | ret = __wlan_hdd_cfg80211_channel_switch(wiphy, dev, csa_params); |
| 21857 | cds_ssr_unprotect(__func__); |
| 21858 | return ret; |
| 21859 | } |
| 21860 | #endif |
| 21861 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21862 | /** |
| 21863 | * wlan_hdd_convert_nl_iftype_to_hdd_type() - provides the type |
| 21864 | * translation from NL to policy manager type |
| 21865 | * @type: Generic connection mode type defined in NL |
| 21866 | * |
| 21867 | * |
| 21868 | * This function provides the type translation |
| 21869 | * |
| 21870 | * Return: cds_con_mode enum |
| 21871 | */ |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 21872 | enum policy_mgr_con_mode wlan_hdd_convert_nl_iftype_to_hdd_type( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21873 | enum nl80211_iftype type) |
| 21874 | { |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 21875 | enum policy_mgr_con_mode mode = PM_MAX_NUM_OF_MODE; |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 21876 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21877 | switch (type) { |
| 21878 | case NL80211_IFTYPE_STATION: |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 21879 | mode = PM_STA_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21880 | break; |
| 21881 | case NL80211_IFTYPE_P2P_CLIENT: |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 21882 | mode = PM_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21883 | break; |
| 21884 | case NL80211_IFTYPE_P2P_GO: |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 21885 | mode = PM_P2P_GO_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21886 | break; |
| 21887 | case NL80211_IFTYPE_AP: |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 21888 | mode = PM_SAP_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21889 | break; |
| 21890 | case NL80211_IFTYPE_ADHOC: |
Tushnim Bhattacharyya | 8716158 | 2017-03-09 13:03:31 -0800 | [diff] [blame] | 21891 | mode = PM_IBSS_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21892 | break; |
| 21893 | default: |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21894 | hdd_err("Unsupported interface type: %d", type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21895 | } |
| 21896 | return mode; |
| 21897 | } |
| 21898 | |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 21899 | int wlan_hdd_change_hw_mode_for_given_chnl(struct hdd_adapter *adapter, |
| 21900 | uint8_t channel, |
| 21901 | enum policy_mgr_conn_update_reason reason) |
| 21902 | { |
| 21903 | QDF_STATUS status; |
| 21904 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 21905 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 21906 | hdd_enter(); |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 21907 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 21908 | return -EINVAL; |
| 21909 | |
| 21910 | status = policy_mgr_reset_connection_update(hdd_ctx->hdd_psoc); |
| 21911 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 21912 | hdd_err("clearing event failed"); |
| 21913 | |
| 21914 | status = policy_mgr_current_connections_update(hdd_ctx->hdd_psoc, |
| 21915 | adapter->session_id, channel, reason); |
| 21916 | switch (status) { |
| 21917 | case QDF_STATUS_E_FAILURE: |
| 21918 | /* |
| 21919 | * QDF_STATUS_E_FAILURE indicates that some error has occured |
| 21920 | * while changing the hw mode |
| 21921 | */ |
| 21922 | hdd_err("ERROR: connections update failed!!"); |
| 21923 | return -EINVAL; |
| 21924 | |
| 21925 | case QDF_STATUS_SUCCESS: |
| 21926 | /* |
| 21927 | * QDF_STATUS_SUCCESS indicates that HW mode change has been |
| 21928 | * triggered and wait for it to finish. |
| 21929 | */ |
| 21930 | status = policy_mgr_wait_for_connection_update( |
| 21931 | hdd_ctx->hdd_psoc); |
| 21932 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 21933 | hdd_err("ERROR: qdf wait for event failed!!"); |
| 21934 | return -EINVAL; |
| 21935 | } |
| 21936 | if (QDF_MONITOR_MODE == adapter->device_mode) |
| 21937 | hdd_info("Monitor mode:channel:%d (SMM->DBS)", channel); |
| 21938 | break; |
| 21939 | |
| 21940 | default: |
| 21941 | /* |
| 21942 | * QDF_STATUS_E_NOSUPPORT indicates that no HW mode change is |
| 21943 | * required, so caller can proceed further. |
| 21944 | */ |
| 21945 | break; |
| 21946 | |
| 21947 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 21948 | hdd_exit(); |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 21949 | |
| 21950 | return 0; |
| 21951 | } |
| 21952 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 21953 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 21954 | * wlan_hdd_cfg80211_set_mon_ch() - Set monitor mode capture channel |
| 21955 | * @wiphy: Handle to struct wiphy to get handle to module context. |
| 21956 | * @chandef: Contains information about the capture channel to be set. |
| 21957 | * |
| 21958 | * This interface is called if and only if monitor mode interface alone is |
| 21959 | * active. |
| 21960 | * |
| 21961 | * Return: 0 success or error code on failure. |
| 21962 | */ |
| 21963 | static int __wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy, |
| 21964 | struct cfg80211_chan_def *chandef) |
| 21965 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 21966 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 21967 | struct hdd_adapter *adapter; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 21968 | struct hdd_station_ctx *sta_ctx; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 21969 | struct hdd_mon_set_ch_info *ch_info; |
| 21970 | QDF_STATUS status; |
| 21971 | tHalHandle hal_hdl; |
| 21972 | struct qdf_mac_addr bssid; |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 21973 | struct csr_roam_profile roam_profile; |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 21974 | struct ch_params ch_params; |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 21975 | uint8_t sec_ch = 0; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 21976 | int ret; |
| 21977 | uint16_t chan_num = cds_freq_to_chan(chandef->chan->center_freq); |
| 21978 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 21979 | hdd_enter(); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 21980 | |
| 21981 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 21982 | if (ret) |
| 21983 | return ret; |
| 21984 | |
| 21985 | hal_hdl = hdd_ctx->hHal; |
| 21986 | |
| 21987 | adapter = hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE); |
| 21988 | if (!adapter) |
| 21989 | return -EIO; |
| 21990 | |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 21991 | hdd_debug("%s: set monitor mode Channel %d and freq %d", |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 21992 | adapter->dev->name, chan_num, chandef->chan->center_freq); |
| 21993 | |
| 21994 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 21995 | ch_info = &sta_ctx->ch_info; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 21996 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 21997 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 21998 | roam_profile.phyMode = ch_info->phy_mode; |
Naveen Rawat | 3184dd8 | 2017-07-05 14:58:18 -0700 | [diff] [blame] | 21999 | 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] | 22000 | hdd_select_cbmode(adapter, chan_num, &roam_profile.ch_params); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 22001 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 22002 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 22003 | QDF_MAC_ADDR_SIZE); |
| 22004 | |
Naveen Rawat | 3184dd8 | 2017-07-05 14:58:18 -0700 | [diff] [blame] | 22005 | ch_params.ch_width = hdd_map_nl_chan_width(chandef->width); |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 22006 | /* |
| 22007 | * CDS api expects secondary channel for calculating |
| 22008 | * the channel params |
| 22009 | */ |
| 22010 | if ((ch_params.ch_width == CH_WIDTH_40MHZ) && |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 22011 | (WLAN_REG_IS_24GHZ_CH(chan_num))) { |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 22012 | if (chan_num >= 1 && chan_num <= 5) |
| 22013 | sec_ch = chan_num + 4; |
| 22014 | else if (chan_num >= 6 && chan_num <= 13) |
| 22015 | sec_ch = chan_num - 4; |
| 22016 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 22017 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan_num, |
| 22018 | sec_ch, &ch_params); |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 22019 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan_num, |
| 22020 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 22021 | hdd_err("Failed to change hw mode"); |
| 22022 | return -EINVAL; |
| 22023 | } |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 22024 | status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params, |
| 22025 | &roam_profile); |
| 22026 | if (status) { |
Srinivas Girigowda | 13d3925 | 2017-03-06 16:12:15 -0800 | [diff] [blame] | 22027 | hdd_err("Failed to set sme_RoamChannel for monitor mode status: %d", |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 22028 | status); |
| 22029 | ret = qdf_status_to_os_return(status); |
| 22030 | return ret; |
| 22031 | } |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 22032 | hdd_exit(); |
Krunal Soni | ed3bc8e | 2018-01-26 12:13:34 -0800 | [diff] [blame] | 22033 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 22034 | return 0; |
| 22035 | } |
| 22036 | |
| 22037 | /** |
| 22038 | * wlan_hdd_cfg80211_set_mon_ch() - Set monitor mode capture channel |
| 22039 | * @wiphy: Handle to struct wiphy to get handle to module context. |
| 22040 | * @chandef: Contains information about the capture channel to be set. |
| 22041 | * |
| 22042 | * This interface is called if and only if monitor mode interface alone is |
| 22043 | * active. |
| 22044 | * |
| 22045 | * Return: 0 success or error code on failure. |
| 22046 | */ |
| 22047 | static int wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy, |
| 22048 | struct cfg80211_chan_def *chandef) |
| 22049 | { |
| 22050 | int ret; |
| 22051 | |
| 22052 | cds_ssr_protect(__func__); |
| 22053 | ret = __wlan_hdd_cfg80211_set_mon_ch(wiphy, chandef); |
| 22054 | cds_ssr_unprotect(__func__); |
| 22055 | return ret; |
| 22056 | } |
| 22057 | |
| 22058 | /** |
Mahesh A Saptasagar | 6dda202 | 2016-09-03 12:59:09 +0530 | [diff] [blame] | 22059 | * wlan_hdd_clear_link_layer_stats() - clear link layer stats |
| 22060 | * @adapter: pointer to adapter |
| 22061 | * |
| 22062 | * Wrapper function to clear link layer stats. |
| 22063 | * return - void |
| 22064 | */ |
Jeff Johnson | e500667 | 2017-08-29 14:39:02 -0700 | [diff] [blame] | 22065 | void wlan_hdd_clear_link_layer_stats(struct hdd_adapter *adapter) |
Mahesh A Saptasagar | 6dda202 | 2016-09-03 12:59:09 +0530 | [diff] [blame] | 22066 | { |
| 22067 | tSirLLStatsClearReq link_layer_stats_clear_req; |
| 22068 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 22069 | |
Mukul Sharma | 491021c | 2016-09-29 21:39:19 +0530 | [diff] [blame] | 22070 | link_layer_stats_clear_req.statsClearReqMask = WIFI_STATS_IFACE_AC | |
| 22071 | WIFI_STATS_IFACE_ALL_PEER; |
Mahesh A Saptasagar | 6dda202 | 2016-09-03 12:59:09 +0530 | [diff] [blame] | 22072 | link_layer_stats_clear_req.stopReq = 0; |
| 22073 | link_layer_stats_clear_req.reqId = 1; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 22074 | link_layer_stats_clear_req.staId = adapter->session_id; |
Mahesh A Saptasagar | 6dda202 | 2016-09-03 12:59:09 +0530 | [diff] [blame] | 22075 | sme_ll_stats_clear_req(hal, &link_layer_stats_clear_req); |
Mahesh A Saptasagar | 6dda202 | 2016-09-03 12:59:09 +0530 | [diff] [blame] | 22076 | } |
| 22077 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 22078 | #define CNT_DIFF(cur, prev) \ |
| 22079 | ((cur >= prev) ? (cur - prev) : (cur + (MAX_COUNT - (prev) + 1))) |
| 22080 | #define MAX_COUNT 0xffffffff |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 22081 | static void hdd_update_chan_info(struct hdd_context *hdd_ctx, |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 22082 | struct scan_chan_info *chan, |
| 22083 | struct scan_chan_info *info, uint32_t cmd_flag) |
| 22084 | { |
| 22085 | if ((info->cmd_flag != WMI_CHAN_InFO_START_RESP) && |
| 22086 | (info->cmd_flag != WMI_CHAN_InFO_END_RESP)) |
| 22087 | hdd_err("cmd flag is invalid: %d", info->cmd_flag); |
| 22088 | |
| 22089 | mutex_lock(&hdd_ctx->chan_info_lock); |
| 22090 | |
| 22091 | if (info->cmd_flag == WMI_CHAN_InFO_START_RESP) |
| 22092 | qdf_mem_zero(chan, sizeof(*chan)); |
| 22093 | |
| 22094 | chan->freq = info->freq; |
| 22095 | chan->noise_floor = info->noise_floor; |
| 22096 | chan->clock_freq = info->clock_freq; |
| 22097 | chan->cmd_flag = info->cmd_flag; |
| 22098 | chan->cycle_count = CNT_DIFF(info->cycle_count, chan->cycle_count); |
| 22099 | |
| 22100 | chan->rx_clear_count = |
| 22101 | CNT_DIFF(info->rx_clear_count, chan->rx_clear_count); |
| 22102 | |
| 22103 | chan->tx_frame_count = |
| 22104 | CNT_DIFF(info->tx_frame_count, chan->tx_frame_count); |
| 22105 | |
| 22106 | mutex_unlock(&hdd_ctx->chan_info_lock); |
| 22107 | |
| 22108 | } |
| 22109 | #undef CNT_DIFF |
| 22110 | #undef MAX_COUNT |
| 22111 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22112 | #if defined(WLAN_FEATURE_FILS_SK) &&\ |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 22113 | defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) &&\ |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22114 | (defined(CFG80211_UPDATE_CONNECT_PARAMS) ||\ |
| 22115 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0))) |
| 22116 | |
| 22117 | #ifndef UPDATE_FILS_ERP_INFO |
| 22118 | #define UPDATE_FILS_ERP_INFO BIT(1) |
| 22119 | #endif |
| 22120 | |
| 22121 | #ifndef UPDATE_FILS_AUTH_TYPE |
| 22122 | #define UPDATE_FILS_AUTH_TYPE BIT(2) |
| 22123 | #endif |
| 22124 | |
| 22125 | /** |
| 22126 | * __wlan_hdd_cfg80211_update_connect_params - update connect params |
| 22127 | * @wiphy: Handle to struct wiphy to get handle to module context. |
| 22128 | * @dev: Pointer to network device |
| 22129 | * @req: Pointer to connect params |
| 22130 | * @changed: Bitmap used to indicate the changed params |
| 22131 | * |
| 22132 | * Update the connect parameters while connected to a BSS. The updated |
| 22133 | * parameters can be used by driver/firmware for subsequent BSS selection |
| 22134 | * (roaming) decisions and to form the Authentication/(Re)Association |
| 22135 | * Request frames. This call does not request an immediate disassociation |
| 22136 | * or reassociation with the current BSS, i.e., this impacts only |
| 22137 | * subsequent (re)associations. The bits in changed are defined in enum |
| 22138 | * cfg80211_connect_params_changed |
| 22139 | * |
| 22140 | * Return: zero for success, non-zero for failure |
| 22141 | */ |
| 22142 | static int __wlan_hdd_cfg80211_update_connect_params( |
| 22143 | struct wiphy *wiphy, struct net_device *dev, |
| 22144 | struct cfg80211_connect_params *req, uint32_t changed) |
| 22145 | { |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 22146 | struct csr_roam_profile *roam_profile; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22147 | uint8_t *buf; |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 22148 | int ret; |
| 22149 | enum eAniAuthType auth_type; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22150 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 22151 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 22152 | QDF_STATUS status; |
| 22153 | struct cds_fils_connection_info *fils_info; |
| 22154 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 22155 | hdd_enter_dev(dev); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22156 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 22157 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 22158 | hdd_err("invalid session id: %d", adapter->session_id); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22159 | return -EINVAL; |
| 22160 | } |
| 22161 | |
| 22162 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 22163 | if (ret) |
| 22164 | return -EINVAL; |
| 22165 | |
Jeff Johnson | 20227a9 | 2018-03-13 09:41:05 -0700 | [diff] [blame] | 22166 | roam_profile = hdd_roam_profile(adapter); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22167 | fils_info = roam_profile->fils_con_info; |
| 22168 | |
| 22169 | if (!fils_info) { |
| 22170 | hdd_err("No valid FILS conn info"); |
| 22171 | return -EINVAL; |
| 22172 | } |
| 22173 | |
| 22174 | if (req->ie_len) |
| 22175 | wlan_hdd_cfg80211_set_ie(adapter, req->ie, req->ie_len); |
| 22176 | |
| 22177 | if (changed) |
| 22178 | fils_info->is_fils_connection = true; |
| 22179 | |
| 22180 | if (changed & UPDATE_FILS_ERP_INFO) { |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 22181 | if (!wlan_hdd_fils_data_in_limits(req)) |
Jeff Johnson | b8adae4 | 2018-02-27 16:12:00 -0800 | [diff] [blame] | 22182 | return -EINVAL; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22183 | fils_info->key_nai_length = req->fils_erp_username_len + |
| 22184 | sizeof(char) + |
| 22185 | req->fils_erp_realm_len; |
Dundi Raviteja | 170d287 | 2018-03-23 15:49:54 +0530 | [diff] [blame] | 22186 | if (fils_info->key_nai_length > |
| 22187 | FILS_MAX_KEYNAME_NAI_LENGTH) { |
| 22188 | hdd_err("Key NAI Length %d", |
| 22189 | fils_info->key_nai_length); |
| 22190 | return -EINVAL; |
| 22191 | } |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22192 | if (req->fils_erp_username_len && req->fils_erp_username) { |
| 22193 | buf = fils_info->keyname_nai; |
| 22194 | qdf_mem_copy(buf, req->fils_erp_username, |
| 22195 | req->fils_erp_username_len); |
| 22196 | buf += req->fils_erp_username_len; |
| 22197 | *buf++ = '@'; |
| 22198 | qdf_mem_copy(buf, req->fils_erp_realm, |
| 22199 | req->fils_erp_realm_len); |
| 22200 | } |
| 22201 | |
| 22202 | fils_info->sequence_number = req->fils_erp_next_seq_num; |
| 22203 | fils_info->r_rk_length = req->fils_erp_rrk_len; |
| 22204 | |
| 22205 | if (req->fils_erp_rrk_len && req->fils_erp_rrk) |
| 22206 | qdf_mem_copy(fils_info->r_rk, req->fils_erp_rrk, |
| 22207 | fils_info->r_rk_length); |
| 22208 | |
| 22209 | fils_info->realm_len = req->fils_erp_realm_len; |
| 22210 | if (req->fils_erp_realm_len && req->fils_erp_realm) |
| 22211 | qdf_mem_copy(fils_info->realm, req->fils_erp_realm, |
| 22212 | fils_info->realm_len); |
| 22213 | } |
| 22214 | |
| 22215 | if (changed & UPDATE_FILS_AUTH_TYPE) { |
| 22216 | auth_type = wlan_hdd_get_fils_auth_type(req->auth_type); |
Varun Reddy Yeturu | 5faa177 | 2017-10-23 11:22:01 -0700 | [diff] [blame] | 22217 | if (auth_type == eSIR_DONOT_USE_AUTH_TYPE) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22218 | hdd_err("invalid auth type for fils %d", |
| 22219 | req->auth_type); |
| 22220 | return -EINVAL; |
| 22221 | } |
| 22222 | |
| 22223 | roam_profile->fils_con_info->auth_type = auth_type; |
| 22224 | } |
| 22225 | |
Varun Reddy Yeturu | 448cb9d | 2017-11-20 20:36:31 -0800 | [diff] [blame] | 22226 | hdd_debug("fils conn update: changed %x is_fils %d keyname nai len %d", |
| 22227 | changed, roam_profile->fils_con_info->is_fils_connection, |
| 22228 | roam_profile->fils_con_info->key_nai_length); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22229 | |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 22230 | if (!hdd_ctx->is_fils_roaming_supported) { |
| 22231 | hdd_debug("FILS roaming support %d", |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 22232 | hdd_ctx->is_fils_roaming_supported); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22233 | return 0; |
| 22234 | } |
| 22235 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 22236 | status = sme_update_fils_config(hdd_ctx->hHal, adapter->session_id, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22237 | roam_profile); |
| 22238 | if (QDF_IS_STATUS_ERROR(status)) |
| 22239 | hdd_err("Update FILS connect params to Fw failed %d", status); |
| 22240 | |
| 22241 | return 0; |
| 22242 | } |
| 22243 | |
| 22244 | /** |
| 22245 | * wlan_hdd_cfg80211_update_connect_params - SSR wrapper for |
| 22246 | * __wlan_hdd_cfg80211_update_connect_params |
| 22247 | * @wiphy: Pointer to wiphy structure |
| 22248 | * @dev: Pointer to net_device |
| 22249 | * @req: Pointer to connect params |
| 22250 | * @changed: flags used to indicate the changed params |
| 22251 | * |
| 22252 | * Return: zero for success, non-zero for failure |
| 22253 | */ |
| 22254 | static int wlan_hdd_cfg80211_update_connect_params(struct wiphy *wiphy, |
| 22255 | struct net_device *dev, |
| 22256 | struct cfg80211_connect_params *req, |
| 22257 | uint32_t changed) |
| 22258 | { |
| 22259 | int ret; |
| 22260 | |
| 22261 | cds_ssr_protect(__func__); |
| 22262 | ret = __wlan_hdd_cfg80211_update_connect_params(wiphy, dev, |
| 22263 | req, changed); |
| 22264 | cds_ssr_unprotect(__func__); |
| 22265 | |
| 22266 | return ret; |
| 22267 | } |
| 22268 | #endif |
| 22269 | |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 22270 | #if defined(WLAN_FEATURE_SAE) && \ |
| 22271 | defined(CFG80211_EXTERNAL_AUTH_SUPPORT) |
| 22272 | /** |
| 22273 | * __wlan_hdd_cfg80211_external_auth() - Handle external auth |
| 22274 | * @wiphy: Pointer to wireless phy |
| 22275 | * @dev: net device |
| 22276 | * @params: Pointer to external auth params |
| 22277 | * |
| 22278 | * Return: 0 on success, negative errno on failure |
| 22279 | */ |
| 22280 | static int |
| 22281 | __wlan_hdd_cfg80211_external_auth(struct wiphy *wiphy, |
| 22282 | struct net_device *dev, |
| 22283 | struct cfg80211_external_auth_params *params) |
| 22284 | { |
| 22285 | struct hdd_context *hdd_ctx = wiphy_priv(wiphy); |
| 22286 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 22287 | int ret; |
| 22288 | |
| 22289 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 22290 | hdd_err("Command not allowed in FTM mode"); |
| 22291 | return -EPERM; |
| 22292 | } |
| 22293 | |
| 22294 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
| 22295 | hdd_err("invalid session id: %d", adapter->session_id); |
| 22296 | return -EINVAL; |
| 22297 | } |
| 22298 | |
| 22299 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 22300 | if (ret) |
| 22301 | return ret; |
| 22302 | |
| 22303 | |
| 22304 | hdd_debug("external_auth status: %d", params->status); |
| 22305 | sme_handle_sae_msg(hdd_ctx->hHal, adapter->session_id, params->status); |
| 22306 | |
| 22307 | return ret; |
| 22308 | } |
| 22309 | |
| 22310 | /** |
| 22311 | * wlan_hdd_cfg80211_external_auth() - Handle external auth |
| 22312 | * @wiphy: Pointer to wireless phy |
| 22313 | * @dev: net device |
| 22314 | * @params: Pointer to external auth params |
| 22315 | * |
| 22316 | * Return: 0 on success, negative errno on failure |
| 22317 | */ |
| 22318 | static int |
| 22319 | wlan_hdd_cfg80211_external_auth(struct wiphy *wiphy, |
| 22320 | struct net_device *dev, |
| 22321 | struct cfg80211_external_auth_params *params) |
| 22322 | { |
| 22323 | int ret; |
| 22324 | |
| 22325 | cds_ssr_protect(__func__); |
| 22326 | ret = __wlan_hdd_cfg80211_external_auth(wiphy, dev, params); |
| 22327 | cds_ssr_unprotect(__func__); |
| 22328 | |
| 22329 | return ret; |
| 22330 | } |
| 22331 | #endif |
| 22332 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 22333 | /** |
| 22334 | * wlan_hdd_chan_info_cb() - channel info callback |
| 22335 | * @chan_info: struct scan_chan_info |
| 22336 | * |
| 22337 | * Store channel info into HDD context |
| 22338 | * |
| 22339 | * Return: None. |
| 22340 | */ |
| 22341 | static void wlan_hdd_chan_info_cb(struct scan_chan_info *info) |
| 22342 | { |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 22343 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 22344 | struct scan_chan_info *chan; |
| 22345 | uint8_t idx; |
| 22346 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 22347 | hdd_enter(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 22348 | |
| 22349 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 22350 | if (wlan_hdd_validate_context(hdd_ctx) != 0) { |
| 22351 | hdd_err("hdd_ctx is invalid"); |
| 22352 | return; |
| 22353 | } |
| 22354 | |
| 22355 | if (!hdd_ctx->chan_info) { |
| 22356 | hdd_err("chan_info is NULL"); |
| 22357 | return; |
| 22358 | } |
| 22359 | |
| 22360 | chan = hdd_ctx->chan_info; |
| 22361 | for (idx = 0; idx < SIR_MAX_NUM_CHANNELS; idx++) { |
| 22362 | if (chan[idx].freq == info->freq) { |
| 22363 | hdd_update_chan_info(hdd_ctx, &chan[idx], info, |
| 22364 | info->cmd_flag); |
| 22365 | hdd_info("cmd:%d freq:%u nf:%d cc:%u rcc:%u clk:%u cmd:%d tfc:%d index:%d", |
| 22366 | chan[idx].cmd_flag, chan[idx].freq, |
| 22367 | chan[idx].noise_floor, |
| 22368 | chan[idx].cycle_count, chan[idx].rx_clear_count, |
| 22369 | chan[idx].clock_freq, chan[idx].cmd_flag, |
| 22370 | chan[idx].tx_frame_count, idx); |
| 22371 | if (chan[idx].freq == 0) |
| 22372 | break; |
| 22373 | |
| 22374 | } |
| 22375 | } |
| 22376 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 22377 | hdd_exit(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 22378 | } |
| 22379 | |
| 22380 | /** |
| 22381 | * wlan_hdd_init_chan_info() - init chan info in hdd context |
| 22382 | * @hdd_ctx: HDD context pointer |
| 22383 | * |
| 22384 | * Return: none |
| 22385 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 22386 | void wlan_hdd_init_chan_info(struct hdd_context *hdd_ctx) |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 22387 | { |
| 22388 | uint8_t num_2g, num_5g, index = 0; |
| 22389 | |
Kapil Gupta | 63e7528 | 2017-05-18 20:55:10 +0530 | [diff] [blame] | 22390 | hdd_ctx->chan_info = NULL; |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 22391 | if (!hdd_ctx->config->fEnableSNRMonitoring) { |
| 22392 | hdd_info("SNR monitoring is disabled"); |
| 22393 | return; |
| 22394 | } |
| 22395 | |
| 22396 | hdd_ctx->chan_info = |
| 22397 | qdf_mem_malloc(sizeof(struct scan_chan_info) |
| 22398 | * QDF_MAX_NUM_CHAN); |
| 22399 | if (hdd_ctx->chan_info == NULL) { |
| 22400 | hdd_err("Failed to malloc for chan info"); |
| 22401 | return; |
| 22402 | } |
| 22403 | mutex_init(&hdd_ctx->chan_info_lock); |
| 22404 | |
| 22405 | num_2g = QDF_ARRAY_SIZE(hdd_channels_2_4_ghz); |
| 22406 | for (; index < num_2g; index++) { |
| 22407 | hdd_ctx->chan_info[index].freq = |
| 22408 | hdd_channels_2_4_ghz[index].center_freq; |
| 22409 | } |
| 22410 | |
| 22411 | num_5g = QDF_ARRAY_SIZE(hdd_channels_5_ghz); |
| 22412 | for (; (index - num_2g) < num_5g; index++) { |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 22413 | if (WLAN_REG_IS_11P_CH( |
| 22414 | hdd_channels_5_ghz[index - num_2g].hw_value)) |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 22415 | continue; |
| 22416 | hdd_ctx->chan_info[index].freq = |
| 22417 | hdd_channels_5_ghz[index - num_2g].center_freq; |
| 22418 | } |
| 22419 | sme_set_chan_info_callback(hdd_ctx->hHal, |
| 22420 | &wlan_hdd_chan_info_cb); |
| 22421 | } |
| 22422 | |
| 22423 | /** |
| 22424 | * wlan_hdd_deinit_chan_info() - deinit chan info in hdd context |
| 22425 | * @hdd_ctx: hdd context pointer |
| 22426 | * |
| 22427 | * Return: none |
| 22428 | */ |
Jeff Johnson | 7aeb95b | 2017-08-28 12:06:33 -0700 | [diff] [blame] | 22429 | void wlan_hdd_deinit_chan_info(struct hdd_context *hdd_ctx) |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 22430 | { |
| 22431 | struct scan_chan_info *chan; |
| 22432 | |
| 22433 | chan = hdd_ctx->chan_info; |
| 22434 | hdd_ctx->chan_info = NULL; |
| 22435 | if (chan) |
| 22436 | qdf_mem_free(chan); |
| 22437 | } |
| 22438 | |
Dustin Brown | 32cb479 | 2017-06-15 15:33:42 -0700 | [diff] [blame] | 22439 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || defined(WITH_BACKPORTS) |
| 22440 | static enum rate_info_bw hdd_map_hdd_bw_to_os(enum hdd_rate_info_bw hdd_bw) |
| 22441 | { |
| 22442 | switch (hdd_bw) { |
| 22443 | case HDD_RATE_BW_5: |
| 22444 | return RATE_INFO_BW_5; |
| 22445 | case HDD_RATE_BW_10: |
| 22446 | return RATE_INFO_BW_10; |
| 22447 | case HDD_RATE_BW_20: |
| 22448 | return RATE_INFO_BW_20; |
| 22449 | case HDD_RATE_BW_40: |
| 22450 | return RATE_INFO_BW_40; |
| 22451 | case HDD_RATE_BW_80: |
| 22452 | return RATE_INFO_BW_80; |
| 22453 | case HDD_RATE_BW_160: |
| 22454 | return RATE_INFO_BW_160; |
| 22455 | } |
| 22456 | |
| 22457 | hdd_err("Unhandled HDD_RATE_BW: %d", hdd_bw); |
| 22458 | |
| 22459 | return RATE_INFO_BW_20; |
| 22460 | } |
| 22461 | |
| 22462 | void hdd_set_rate_bw(struct rate_info *info, enum hdd_rate_info_bw hdd_bw) |
| 22463 | { |
| 22464 | info->bw = hdd_map_hdd_bw_to_os(hdd_bw); |
| 22465 | } |
| 22466 | #else |
| 22467 | static enum rate_info_flags hdd_map_hdd_bw_to_os(enum hdd_rate_info_bw hdd_bw) |
| 22468 | { |
| 22469 | switch (hdd_bw) { |
| 22470 | case HDD_RATE_BW_5: |
| 22471 | case HDD_RATE_BW_10: |
| 22472 | case HDD_RATE_BW_20: |
| 22473 | return (enum rate_info_flags)0; |
| 22474 | case HDD_RATE_BW_40: |
| 22475 | return RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 22476 | case HDD_RATE_BW_80: |
| 22477 | return RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 22478 | case HDD_RATE_BW_160: |
| 22479 | return RATE_INFO_FLAGS_160_MHZ_WIDTH; |
| 22480 | } |
| 22481 | |
| 22482 | hdd_err("Unhandled HDD_RATE_BW: %d", hdd_bw); |
| 22483 | |
| 22484 | return (enum rate_info_flags)0; |
| 22485 | } |
| 22486 | |
| 22487 | void hdd_set_rate_bw(struct rate_info *info, enum hdd_rate_info_bw hdd_bw) |
| 22488 | { |
| 22489 | const enum rate_info_flags all_bws = |
| 22490 | RATE_INFO_FLAGS_40_MHZ_WIDTH | |
| 22491 | RATE_INFO_FLAGS_80_MHZ_WIDTH | |
| 22492 | RATE_INFO_FLAGS_80P80_MHZ_WIDTH | |
| 22493 | RATE_INFO_FLAGS_160_MHZ_WIDTH; |
| 22494 | |
| 22495 | info->flags &= ~all_bws; |
| 22496 | info->flags |= hdd_map_hdd_bw_to_os(hdd_bw); |
| 22497 | } |
| 22498 | #endif |
| 22499 | |
Mahesh A Saptasagar | 6dda202 | 2016-09-03 12:59:09 +0530 | [diff] [blame] | 22500 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 22501 | * struct cfg80211_ops - cfg80211_ops |
| 22502 | * |
| 22503 | * @add_virtual_intf: Add virtual interface |
| 22504 | * @del_virtual_intf: Delete virtual interface |
| 22505 | * @change_virtual_intf: Change virtual interface |
| 22506 | * @change_station: Change station |
| 22507 | * @add_beacon: Add beacon in sap mode |
| 22508 | * @del_beacon: Delete beacon in sap mode |
| 22509 | * @set_beacon: Set beacon in sap mode |
| 22510 | * @start_ap: Start ap |
| 22511 | * @change_beacon: Change beacon |
| 22512 | * @stop_ap: Stop ap |
| 22513 | * @change_bss: Change bss |
| 22514 | * @add_key: Add key |
| 22515 | * @get_key: Get key |
| 22516 | * @del_key: Delete key |
| 22517 | * @set_default_key: Set default key |
| 22518 | * @set_channel: Set channel |
| 22519 | * @scan: Scan |
| 22520 | * @connect: Connect |
| 22521 | * @disconnect: Disconnect |
| 22522 | * @join_ibss = Join ibss |
| 22523 | * @leave_ibss = Leave ibss |
| 22524 | * @set_wiphy_params = Set wiphy params |
| 22525 | * @set_tx_power = Set tx power |
| 22526 | * @get_tx_power = get tx power |
| 22527 | * @remain_on_channel = Remain on channel |
| 22528 | * @cancel_remain_on_channel = Cancel remain on channel |
| 22529 | * @mgmt_tx = Tx management frame |
| 22530 | * @mgmt_tx_cancel_wait = Cancel management tx wait |
| 22531 | * @set_default_mgmt_key = Set default management key |
| 22532 | * @set_txq_params = Set tx queue parameters |
| 22533 | * @get_station = Get station |
| 22534 | * @set_power_mgmt = Set power management |
| 22535 | * @del_station = Delete station |
| 22536 | * @add_station = Add station |
| 22537 | * @set_pmksa = Set pmksa |
| 22538 | * @del_pmksa = Delete pmksa |
| 22539 | * @flush_pmksa = Flush pmksa |
| 22540 | * @update_ft_ies = Update FT IEs |
| 22541 | * @tdls_mgmt = Tdls management |
| 22542 | * @tdls_oper = Tdls operation |
| 22543 | * @set_rekey_data = Set rekey data |
| 22544 | * @sched_scan_start = Scheduled scan start |
| 22545 | * @sched_scan_stop = Scheduled scan stop |
| 22546 | * @resume = Resume wlan |
| 22547 | * @suspend = Suspend wlan |
| 22548 | * @set_mac_acl = Set mac acl |
| 22549 | * @testmode_cmd = Test mode command |
| 22550 | * @set_ap_chanwidth = Set AP channel bandwidth |
| 22551 | * @dump_survey = Dump survey |
| 22552 | * @key_mgmt_set_pmk = Set pmk key management |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22553 | * @update_connect_params = Update connect params |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 22554 | */ |
| 22555 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = { |
| 22556 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 22557 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 22558 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 22559 | .change_station = wlan_hdd_change_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 22560 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 22561 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 22562 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 22563 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 22564 | .add_key = wlan_hdd_cfg80211_add_key, |
| 22565 | .get_key = wlan_hdd_cfg80211_get_key, |
| 22566 | .del_key = wlan_hdd_cfg80211_del_key, |
| 22567 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
| 22568 | .scan = wlan_hdd_cfg80211_scan, |
| 22569 | .connect = wlan_hdd_cfg80211_connect, |
| 22570 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 22571 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 22572 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 22573 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 22574 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 22575 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
| 22576 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 22577 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 22578 | .mgmt_tx = wlan_hdd_mgmt_tx, |
| 22579 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 22580 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 22581 | .set_txq_params = wlan_hdd_set_txq_params, |
Himanshu Agarwal | 37e4241 | 2016-07-21 14:35:09 +0530 | [diff] [blame] | 22582 | .dump_station = wlan_hdd_cfg80211_dump_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 22583 | .get_station = wlan_hdd_cfg80211_get_station, |
| 22584 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 22585 | .del_station = wlan_hdd_cfg80211_del_station, |
| 22586 | .add_station = wlan_hdd_cfg80211_add_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 22587 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 22588 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 22589 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
Deepak Dhamdhere | 9f09e75 | 2016-01-09 23:17:25 -0800 | [diff] [blame] | 22590 | #if defined(KERNEL_SUPPORT_11R_CFG80211) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 22591 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 22592 | #endif |
| 22593 | #ifdef FEATURE_WLAN_TDLS |
| 22594 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 22595 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 22596 | #endif |
| 22597 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 22598 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 22599 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
| 22600 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 22601 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 22602 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 22603 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
| 22604 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 22605 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
| 22606 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
| 22607 | #ifdef WLAN_NL80211_TESTMODE |
| 22608 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 22609 | #endif |
| 22610 | #ifdef QCA_HT_2040_COEX |
| 22611 | .set_ap_chanwidth = wlan_hdd_cfg80211_set_ap_channel_width, |
| 22612 | #endif |
| 22613 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 22614 | #ifdef CHANNEL_SWITCH_SUPPORTED |
| 22615 | .channel_switch = wlan_hdd_cfg80211_channel_switch, |
| 22616 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 22617 | .set_monitor_channel = wlan_hdd_cfg80211_set_mon_ch, |
Vidyullatha, Kanchanapally | 528789e | 2016-05-11 20:38:37 +0530 | [diff] [blame] | 22618 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)) || \ |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 22619 | defined(CFG80211_ABORT_SCAN) |
Vidyullatha, Kanchanapally | 528789e | 2016-05-11 20:38:37 +0530 | [diff] [blame] | 22620 | .abort_scan = wlan_hdd_cfg80211_abort_scan, |
| 22621 | #endif |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22622 | #if defined(WLAN_FEATURE_FILS_SK) &&\ |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 22623 | defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) &&\ |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 22624 | (defined(CFG80211_UPDATE_CONNECT_PARAMS) ||\ |
| 22625 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0))) |
| 22626 | .update_connect_params = wlan_hdd_cfg80211_update_connect_params, |
| 22627 | #endif |
Padma, Santhosh Kumar | eb90a55 | 2018-01-16 19:41:58 +0530 | [diff] [blame] | 22628 | #if defined(WLAN_FEATURE_SAE) && \ |
| 22629 | defined(CFG80211_EXTERNAL_AUTH_SUPPORT) |
| 22630 | .external_auth = wlan_hdd_cfg80211_external_auth, |
| 22631 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 22632 | }; |