Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2016 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 | |
Jeff Johnson | 9c50e78 | 2016-06-29 15:28:56 -0700 | [diff] [blame] | 35 | /* denote that this file does not allow legacy hddLog */ |
| 36 | #define HDD_DISALLOW_LEGACY_HDDLOG 1 |
| 37 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 38 | #include <linux/version.h> |
| 39 | #include <linux/module.h> |
| 40 | #include <linux/kernel.h> |
| 41 | #include <linux/init.h> |
| 42 | #include <linux/etherdevice.h> |
| 43 | #include <linux/wireless.h> |
| 44 | #include <wlan_hdd_includes.h> |
| 45 | #include <net/arp.h> |
| 46 | #include <net/cfg80211.h> |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 47 | #include <qdf_trace.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 48 | #include <wlan_hdd_wowl.h> |
| 49 | #include <ani_global.h> |
| 50 | #include "sir_params.h" |
| 51 | #include "dot11f.h" |
| 52 | #include "wlan_hdd_assoc.h" |
| 53 | #include "wlan_hdd_wext.h" |
| 54 | #include "sme_api.h" |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 55 | #include "sme_power_save_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 56 | #include "wlan_hdd_p2p.h" |
| 57 | #include "wlan_hdd_cfg80211.h" |
| 58 | #include "wlan_hdd_hostapd.h" |
| 59 | #include "wlan_hdd_softap_tx_rx.h" |
| 60 | #include "wlan_hdd_main.h" |
| 61 | #include "wlan_hdd_power.h" |
| 62 | #include "wlan_hdd_trace.h" |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 63 | #include "qdf_types.h" |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 64 | #include "qdf_trace.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 65 | #include "cds_utils.h" |
| 66 | #include "cds_sched.h" |
| 67 | #include "wlan_hdd_scan.h" |
| 68 | #include <qc_sap_ioctl.h> |
| 69 | #include "wlan_hdd_tdls.h" |
| 70 | #include "wlan_hdd_wmm.h" |
| 71 | #include "wma_types.h" |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 72 | #include "wma.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 73 | #include "wlan_hdd_misc.h" |
| 74 | #include "wlan_hdd_nan.h" |
| 75 | #include <wlan_hdd_ipa.h> |
| 76 | #include "wlan_logging_sock_svc.h" |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 77 | #include "sap_api.h" |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 78 | #include "csr_api.h" |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 79 | #include "pld_common.h" |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 80 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | |
| 82 | #ifdef FEATURE_WLAN_EXTSCAN |
| 83 | #include "wlan_hdd_ext_scan.h" |
| 84 | #endif |
| 85 | |
| 86 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 87 | #include "wlan_hdd_stats.h" |
| 88 | #endif |
| 89 | #include "cds_concurrency.h" |
| 90 | #include "qwlan_version.h" |
| 91 | #include "wlan_hdd_memdump.h" |
| 92 | |
| 93 | #include "wlan_hdd_ocb.h" |
Manikandan Mohan | 5356c2b | 2016-04-03 15:51:35 -0700 | [diff] [blame] | 94 | #include "wlan_hdd_tsf.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 95 | |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 96 | #include "wlan_hdd_subnet_detect.h" |
Abhishek Singh | 3e6172f | 2016-05-04 16:56:48 +0530 | [diff] [blame] | 97 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 98 | #include "wlan_hdd_lpass.h" |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 99 | #include "wlan_hdd_nan_datapath.h" |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 100 | #include "wlan_hdd_disa.h" |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 101 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 102 | #include <cdp_txrx_cmn.h> |
| 103 | #include <cdp_txrx_misc.h> |
| 104 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 105 | #define g_mode_rates_size (12) |
| 106 | #define a_mode_rates_size (8) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 107 | #define GET_IE_LEN_IN_BSS_DESC(lenInBss) (lenInBss + sizeof(lenInBss) - \ |
| 108 | ((uintptr_t)OFFSET_OF(tSirBssDescription, ieFields))) |
| 109 | |
| 110 | /* |
| 111 | * Android CTS verifier needs atleast this much wait time (in msec) |
| 112 | */ |
| 113 | #define MAX_REMAIN_ON_CHANNEL_DURATION (5000) |
| 114 | |
| 115 | /* |
| 116 | * Refer @tCfgProtection structure for definition of the bit map. |
| 117 | * below value is obtained by setting the following bit-fields. |
| 118 | * enable obss, fromllb, overlapOBSS and overlapFromllb protection. |
| 119 | */ |
| 120 | #define IBSS_CFG_PROTECTION_ENABLE_MASK 0x8282 |
| 121 | |
| 122 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 123 | .band = NL80211_BAND_2GHZ, \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 124 | .center_freq = (freq), \ |
| 125 | .hw_value = (chan), \ |
| 126 | .flags = (flag), \ |
| 127 | .max_antenna_gain = 0, \ |
| 128 | .max_power = 30, \ |
| 129 | } |
| 130 | |
| 131 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 132 | .band = NL80211_BAND_5GHZ, \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 133 | .center_freq = (freq), \ |
| 134 | .hw_value = (chan), \ |
| 135 | .flags = (flag), \ |
| 136 | .max_antenna_gain = 0, \ |
| 137 | .max_power = 30, \ |
| 138 | } |
| 139 | |
| 140 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag) \ |
| 141 | { \ |
| 142 | .bitrate = rate, \ |
| 143 | .hw_value = rate_id, \ |
| 144 | .flags = flag, \ |
| 145 | } |
| 146 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 147 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
| 148 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 149 | |
| 150 | #define HDD_CHANNEL_14 14 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 151 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 152 | #define IS_DFS_MODE_VALID(mode) ((mode >= DFS_MODE_NONE && \ |
| 153 | mode <= DFS_MODE_DEPRIORITIZE)) |
| 154 | #define IS_CHANNEL_VALID(channel) ((channel >= 0 && channel < 15) \ |
| 155 | || (channel >= 36 && channel <= 184)) |
| 156 | |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 157 | #define MAX_TXPOWER_SCALE 4 |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 158 | #define CDS_MAX_FEATURE_SET 8 |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 159 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 160 | static const u32 hdd_cipher_suites[] = { |
| 161 | WLAN_CIPHER_SUITE_WEP40, |
| 162 | WLAN_CIPHER_SUITE_WEP104, |
| 163 | WLAN_CIPHER_SUITE_TKIP, |
| 164 | #ifdef FEATURE_WLAN_ESE |
| 165 | #define WLAN_CIPHER_SUITE_BTK 0x004096fe /* use for BTK */ |
| 166 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 167 | WLAN_CIPHER_SUITE_BTK, |
| 168 | WLAN_CIPHER_SUITE_KRK, |
| 169 | WLAN_CIPHER_SUITE_CCMP, |
| 170 | #else |
| 171 | WLAN_CIPHER_SUITE_CCMP, |
| 172 | #endif |
| 173 | #ifdef FEATURE_WLAN_WAPI |
| 174 | WLAN_CIPHER_SUITE_SMS4, |
| 175 | #endif |
| 176 | #ifdef WLAN_FEATURE_11W |
| 177 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 178 | #endif |
| 179 | }; |
| 180 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 181 | static const struct ieee80211_channel hdd_channels_2_4_ghz[] = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 182 | HDD2GHZCHAN(2412, 1, 0), |
| 183 | HDD2GHZCHAN(2417, 2, 0), |
| 184 | HDD2GHZCHAN(2422, 3, 0), |
| 185 | HDD2GHZCHAN(2427, 4, 0), |
| 186 | HDD2GHZCHAN(2432, 5, 0), |
| 187 | HDD2GHZCHAN(2437, 6, 0), |
| 188 | HDD2GHZCHAN(2442, 7, 0), |
| 189 | HDD2GHZCHAN(2447, 8, 0), |
| 190 | HDD2GHZCHAN(2452, 9, 0), |
| 191 | HDD2GHZCHAN(2457, 10, 0), |
| 192 | HDD2GHZCHAN(2462, 11, 0), |
| 193 | HDD2GHZCHAN(2467, 12, 0), |
| 194 | HDD2GHZCHAN(2472, 13, 0), |
| 195 | HDD2GHZCHAN(2484, 14, 0), |
| 196 | }; |
| 197 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 198 | static const struct ieee80211_channel hdd_channels_5_ghz[] = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 199 | HDD5GHZCHAN(5180, 36, 0), |
| 200 | HDD5GHZCHAN(5200, 40, 0), |
| 201 | HDD5GHZCHAN(5220, 44, 0), |
| 202 | HDD5GHZCHAN(5240, 48, 0), |
| 203 | HDD5GHZCHAN(5260, 52, 0), |
| 204 | HDD5GHZCHAN(5280, 56, 0), |
| 205 | HDD5GHZCHAN(5300, 60, 0), |
| 206 | HDD5GHZCHAN(5320, 64, 0), |
| 207 | HDD5GHZCHAN(5500, 100, 0), |
| 208 | HDD5GHZCHAN(5520, 104, 0), |
| 209 | HDD5GHZCHAN(5540, 108, 0), |
| 210 | HDD5GHZCHAN(5560, 112, 0), |
| 211 | HDD5GHZCHAN(5580, 116, 0), |
| 212 | HDD5GHZCHAN(5600, 120, 0), |
| 213 | HDD5GHZCHAN(5620, 124, 0), |
| 214 | HDD5GHZCHAN(5640, 128, 0), |
| 215 | HDD5GHZCHAN(5660, 132, 0), |
| 216 | HDD5GHZCHAN(5680, 136, 0), |
| 217 | HDD5GHZCHAN(5700, 140, 0), |
| 218 | HDD5GHZCHAN(5720, 144, 0), |
| 219 | HDD5GHZCHAN(5745, 149, 0), |
| 220 | HDD5GHZCHAN(5765, 153, 0), |
| 221 | HDD5GHZCHAN(5785, 157, 0), |
| 222 | HDD5GHZCHAN(5805, 161, 0), |
| 223 | HDD5GHZCHAN(5825, 165, 0), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 224 | HDD5GHZCHAN(5852, 170, 0), |
| 225 | HDD5GHZCHAN(5855, 171, 0), |
| 226 | HDD5GHZCHAN(5860, 172, 0), |
| 227 | HDD5GHZCHAN(5865, 173, 0), |
| 228 | HDD5GHZCHAN(5870, 174, 0), |
| 229 | HDD5GHZCHAN(5875, 175, 0), |
| 230 | HDD5GHZCHAN(5880, 176, 0), |
| 231 | HDD5GHZCHAN(5885, 177, 0), |
| 232 | HDD5GHZCHAN(5890, 178, 0), |
| 233 | HDD5GHZCHAN(5895, 179, 0), |
| 234 | HDD5GHZCHAN(5900, 180, 0), |
| 235 | HDD5GHZCHAN(5905, 181, 0), |
| 236 | HDD5GHZCHAN(5910, 182, 0), |
| 237 | HDD5GHZCHAN(5915, 183, 0), |
| 238 | HDD5GHZCHAN(5920, 184, 0), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | static struct ieee80211_rate g_mode_rates[] = { |
| 242 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 243 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 244 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 245 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 246 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 247 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 248 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 249 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 250 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 251 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 252 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
| 253 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 254 | }; |
| 255 | |
| 256 | static struct ieee80211_rate a_mode_rates[] = { |
| 257 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 258 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 259 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 260 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 261 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 262 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 263 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
| 264 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 265 | }; |
| 266 | |
| 267 | static struct ieee80211_supported_band wlan_hdd_band_2_4_ghz = { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 268 | .channels = NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 269 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_ghz), |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 270 | .band = NL80211_BAND_2GHZ, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 271 | .bitrates = g_mode_rates, |
| 272 | .n_bitrates = g_mode_rates_size, |
| 273 | .ht_cap.ht_supported = 1, |
| 274 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 275 | | IEEE80211_HT_CAP_GRN_FLD |
| 276 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 277 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 278 | | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 279 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 280 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 281 | .ht_cap.mcs.rx_mask = {0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0,}, |
| 282 | .ht_cap.mcs.rx_highest = cpu_to_le16(72), |
| 283 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 284 | }; |
| 285 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 286 | static struct ieee80211_supported_band wlan_hdd_band_5_ghz = { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 287 | .channels = NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 288 | .n_channels = ARRAY_SIZE(hdd_channels_5_ghz), |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 289 | .band = NL80211_BAND_5GHZ, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 290 | .bitrates = a_mode_rates, |
| 291 | .n_bitrates = a_mode_rates_size, |
| 292 | .ht_cap.ht_supported = 1, |
| 293 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 294 | | IEEE80211_HT_CAP_GRN_FLD |
| 295 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 296 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 297 | | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 298 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 299 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 300 | .ht_cap.mcs.rx_mask = {0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0,}, |
| 301 | .ht_cap.mcs.rx_highest = cpu_to_le16(72), |
| 302 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 303 | .vht_cap.vht_supported = 1, |
| 304 | }; |
| 305 | |
| 306 | /* This structure contain information what kind of frame are expected in |
| 307 | TX/RX direction for each kind of interface */ |
| 308 | static const struct ieee80211_txrx_stypes |
| 309 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 310 | [NL80211_IFTYPE_STATION] = { |
| 311 | .tx = 0xffff, |
| 312 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 313 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 314 | }, |
| 315 | [NL80211_IFTYPE_AP] = { |
| 316 | .tx = 0xffff, |
| 317 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 318 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 319 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 320 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 321 | BIT(SIR_MAC_MGMT_AUTH) | |
| 322 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 323 | BIT(SIR_MAC_MGMT_ACTION), |
| 324 | }, |
| 325 | [NL80211_IFTYPE_ADHOC] = { |
| 326 | .tx = 0xffff, |
| 327 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 328 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 329 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 330 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 331 | BIT(SIR_MAC_MGMT_AUTH) | |
| 332 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 333 | BIT(SIR_MAC_MGMT_ACTION), |
| 334 | }, |
| 335 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 336 | .tx = 0xffff, |
| 337 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 338 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 339 | }, |
| 340 | [NL80211_IFTYPE_P2P_GO] = { |
| 341 | /* This is also same as for SoftAP */ |
| 342 | .tx = 0xffff, |
| 343 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 344 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 345 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 346 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 347 | BIT(SIR_MAC_MGMT_AUTH) | |
| 348 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 349 | BIT(SIR_MAC_MGMT_ACTION), |
| 350 | }, |
| 351 | }; |
| 352 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 353 | /* Interface limits and combinations registered by the driver */ |
| 354 | |
| 355 | /* STA ( + STA ) combination */ |
| 356 | static const struct ieee80211_iface_limit |
| 357 | wlan_hdd_sta_iface_limit[] = { |
| 358 | { |
| 359 | .max = 3, /* p2p0 is a STA as well */ |
| 360 | .types = BIT(NL80211_IFTYPE_STATION), |
| 361 | }, |
| 362 | }; |
| 363 | |
| 364 | /* ADHOC (IBSS) limit */ |
| 365 | static const struct ieee80211_iface_limit |
| 366 | wlan_hdd_adhoc_iface_limit[] = { |
| 367 | { |
| 368 | .max = 1, |
| 369 | .types = BIT(NL80211_IFTYPE_STATION), |
| 370 | }, |
| 371 | { |
| 372 | .max = 1, |
| 373 | .types = BIT(NL80211_IFTYPE_ADHOC), |
| 374 | }, |
| 375 | }; |
| 376 | |
| 377 | /* AP ( + AP ) combination */ |
| 378 | static const struct ieee80211_iface_limit |
| 379 | wlan_hdd_ap_iface_limit[] = { |
| 380 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 381 | .max = (QDF_MAX_NO_OF_SAP_MODE + SAP_MAX_OBSS_STA_CNT), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 382 | .types = BIT(NL80211_IFTYPE_AP), |
| 383 | }, |
| 384 | }; |
| 385 | |
| 386 | /* P2P limit */ |
| 387 | static const struct ieee80211_iface_limit |
| 388 | wlan_hdd_p2p_iface_limit[] = { |
| 389 | { |
| 390 | .max = 1, |
| 391 | .types = BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 392 | }, |
| 393 | { |
| 394 | .max = 1, |
| 395 | .types = BIT(NL80211_IFTYPE_P2P_GO), |
| 396 | }, |
| 397 | }; |
| 398 | |
| 399 | static const struct ieee80211_iface_limit |
| 400 | wlan_hdd_sta_ap_iface_limit[] = { |
| 401 | { |
| 402 | /* We need 1 extra STA interface for OBSS scan when SAP starts |
| 403 | * with HT40 in STA+SAP concurrency mode |
| 404 | */ |
| 405 | .max = (1 + SAP_MAX_OBSS_STA_CNT), |
| 406 | .types = BIT(NL80211_IFTYPE_STATION), |
| 407 | }, |
| 408 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 409 | .max = QDF_MAX_NO_OF_SAP_MODE, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 410 | .types = BIT(NL80211_IFTYPE_AP), |
| 411 | }, |
| 412 | }; |
| 413 | |
| 414 | /* STA + P2P combination */ |
| 415 | static const struct ieee80211_iface_limit |
| 416 | wlan_hdd_sta_p2p_iface_limit[] = { |
| 417 | { |
| 418 | /* One reserved for dedicated P2PDEV usage */ |
| 419 | .max = 2, |
| 420 | .types = BIT(NL80211_IFTYPE_STATION) |
| 421 | }, |
| 422 | { |
| 423 | /* Support for two identical (GO + GO or CLI + CLI) |
| 424 | * or dissimilar (GO + CLI) P2P interfaces |
| 425 | */ |
| 426 | .max = 2, |
| 427 | .types = BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 428 | }, |
| 429 | }; |
| 430 | |
| 431 | /* STA + AP + P2PGO combination */ |
| 432 | static const struct ieee80211_iface_limit |
| 433 | wlan_hdd_sta_ap_p2pgo_iface_limit[] = { |
| 434 | /* Support for AP+P2PGO interfaces */ |
| 435 | { |
| 436 | .max = 2, |
| 437 | .types = BIT(NL80211_IFTYPE_STATION) |
| 438 | }, |
| 439 | { |
| 440 | .max = 1, |
| 441 | .types = BIT(NL80211_IFTYPE_P2P_GO) |
| 442 | }, |
| 443 | { |
| 444 | .max = 1, |
| 445 | .types = BIT(NL80211_IFTYPE_AP) |
| 446 | } |
| 447 | }; |
| 448 | |
| 449 | /* SAP + P2P combination */ |
| 450 | static const struct ieee80211_iface_limit |
| 451 | wlan_hdd_sap_p2p_iface_limit[] = { |
| 452 | { |
| 453 | /* 1 dedicated for p2p0 which is a STA type */ |
| 454 | .max = 1, |
| 455 | .types = BIT(NL80211_IFTYPE_STATION) |
| 456 | }, |
| 457 | { |
| 458 | /* The p2p interface in SAP+P2P can be GO/CLI. |
| 459 | * The p2p connection can be formed on p2p0 or p2p-p2p0-x. |
| 460 | */ |
| 461 | .max = 1, |
| 462 | .types = BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 463 | }, |
| 464 | { |
| 465 | /* SAP+GO to support only one SAP interface */ |
| 466 | .max = 1, |
| 467 | .types = BIT(NL80211_IFTYPE_AP) |
| 468 | } |
| 469 | }; |
| 470 | |
| 471 | /* P2P + P2P combination */ |
| 472 | static const struct ieee80211_iface_limit |
| 473 | wlan_hdd_p2p_p2p_iface_limit[] = { |
| 474 | { |
| 475 | /* 1 dedicated for p2p0 which is a STA type */ |
| 476 | .max = 1, |
| 477 | .types = BIT(NL80211_IFTYPE_STATION) |
| 478 | }, |
| 479 | { |
| 480 | /* The p2p interface in P2P+P2P can be GO/CLI. |
| 481 | * For P2P+P2P, the new interfaces are formed on p2p-p2p0-x. |
| 482 | */ |
| 483 | .max = 2, |
| 484 | .types = BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 485 | }, |
| 486 | }; |
| 487 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 488 | static const struct ieee80211_iface_limit |
| 489 | wlan_hdd_mon_iface_limit[] = { |
| 490 | { |
| 491 | .max = 3, /* Monitor interface */ |
| 492 | .types = BIT(NL80211_IFTYPE_MONITOR), |
| 493 | }, |
| 494 | }; |
| 495 | |
| 496 | static struct ieee80211_iface_combination |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 497 | wlan_hdd_iface_combination[] = { |
| 498 | /* STA */ |
| 499 | { |
| 500 | .limits = wlan_hdd_sta_iface_limit, |
| 501 | .num_different_channels = 2, |
| 502 | .max_interfaces = 3, |
| 503 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_iface_limit), |
| 504 | }, |
| 505 | /* ADHOC */ |
| 506 | { |
| 507 | .limits = wlan_hdd_adhoc_iface_limit, |
Krunal Soni | 2c68f23 | 2015-10-26 20:52:51 -0700 | [diff] [blame] | 508 | .num_different_channels = 2, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 509 | .max_interfaces = 2, |
| 510 | .n_limits = ARRAY_SIZE(wlan_hdd_adhoc_iface_limit), |
| 511 | }, |
| 512 | /* AP */ |
| 513 | { |
| 514 | .limits = wlan_hdd_ap_iface_limit, |
| 515 | .num_different_channels = 2, |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 516 | .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] | 517 | .n_limits = ARRAY_SIZE(wlan_hdd_ap_iface_limit), |
| 518 | }, |
| 519 | /* P2P */ |
| 520 | { |
| 521 | .limits = wlan_hdd_p2p_iface_limit, |
| 522 | .num_different_channels = 2, |
| 523 | .max_interfaces = 2, |
| 524 | .n_limits = ARRAY_SIZE(wlan_hdd_p2p_iface_limit), |
| 525 | }, |
| 526 | /* STA + AP */ |
| 527 | { |
| 528 | .limits = wlan_hdd_sta_ap_iface_limit, |
| 529 | .num_different_channels = 2, |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 530 | .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] | 531 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_ap_iface_limit), |
| 532 | .beacon_int_infra_match = true, |
| 533 | }, |
| 534 | /* STA + P2P */ |
| 535 | { |
| 536 | .limits = wlan_hdd_sta_p2p_iface_limit, |
| 537 | .num_different_channels = 2, |
| 538 | /* one interface reserved for P2PDEV dedicated usage */ |
| 539 | .max_interfaces = 4, |
| 540 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_p2p_iface_limit), |
| 541 | .beacon_int_infra_match = true, |
| 542 | }, |
| 543 | /* STA + P2P GO + SAP */ |
| 544 | { |
| 545 | .limits = wlan_hdd_sta_ap_p2pgo_iface_limit, |
| 546 | /* we can allow 3 channels for three different persona |
| 547 | * but due to firmware limitation, allow max 2 concrnt channels. |
| 548 | */ |
| 549 | .num_different_channels = 2, |
| 550 | /* one interface reserved for P2PDEV dedicated usage */ |
| 551 | .max_interfaces = 4, |
| 552 | .n_limits = ARRAY_SIZE(wlan_hdd_sta_ap_p2pgo_iface_limit), |
| 553 | .beacon_int_infra_match = true, |
| 554 | }, |
| 555 | /* SAP + P2P */ |
| 556 | { |
| 557 | .limits = wlan_hdd_sap_p2p_iface_limit, |
| 558 | .num_different_channels = 2, |
| 559 | /* 1-p2p0 + 1-SAP + 1-P2P (on p2p0 or p2p-p2p0-x) */ |
| 560 | .max_interfaces = 3, |
| 561 | .n_limits = ARRAY_SIZE(wlan_hdd_sap_p2p_iface_limit), |
| 562 | .beacon_int_infra_match = true, |
| 563 | }, |
| 564 | /* P2P + P2P */ |
| 565 | { |
| 566 | .limits = wlan_hdd_p2p_p2p_iface_limit, |
| 567 | .num_different_channels = 2, |
| 568 | /* 1-p2p0 + 2-P2P (on p2p-p2p0-x) */ |
| 569 | .max_interfaces = 3, |
| 570 | .n_limits = ARRAY_SIZE(wlan_hdd_p2p_p2p_iface_limit), |
| 571 | .beacon_int_infra_match = true, |
| 572 | }, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 573 | /* Monitor */ |
| 574 | { |
| 575 | .limits = wlan_hdd_mon_iface_limit, |
| 576 | .max_interfaces = 3, |
| 577 | .num_different_channels = 2, |
| 578 | .n_limits = ARRAY_SIZE(wlan_hdd_mon_iface_limit), |
| 579 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 580 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 581 | |
| 582 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 583 | struct hdd_bpf_context bpf_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 584 | |
| 585 | #ifdef WLAN_NL80211_TESTMODE |
| 586 | enum wlan_hdd_tm_attr { |
| 587 | WLAN_HDD_TM_ATTR_INVALID = 0, |
| 588 | WLAN_HDD_TM_ATTR_CMD = 1, |
| 589 | WLAN_HDD_TM_ATTR_DATA = 2, |
| 590 | WLAN_HDD_TM_ATTR_STREAM_ID = 3, |
| 591 | WLAN_HDD_TM_ATTR_TYPE = 4, |
| 592 | /* keep last */ |
| 593 | WLAN_HDD_TM_ATTR_AFTER_LAST, |
| 594 | WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1, |
| 595 | }; |
| 596 | |
| 597 | enum wlan_hdd_tm_cmd { |
| 598 | WLAN_HDD_TM_CMD_WLAN_FTM = 0, |
| 599 | WLAN_HDD_TM_CMD_WLAN_HB = 1, |
| 600 | }; |
| 601 | |
| 602 | #define WLAN_HDD_TM_DATA_MAX_LEN 5000 |
| 603 | |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 604 | enum wlan_hdd_vendor_ie_access_policy { |
| 605 | WLAN_HDD_VENDOR_IE_ACCESS_NONE = 0, |
| 606 | WLAN_HDD_VENDOR_IE_ACCESS_ALLOW_IF_LISTED, |
| 607 | }; |
| 608 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 609 | static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] = { |
| 610 | [WLAN_HDD_TM_ATTR_CMD] = {.type = NLA_U32}, |
| 611 | [WLAN_HDD_TM_ATTR_DATA] = {.type = NLA_BINARY, |
| 612 | .len = WLAN_HDD_TM_DATA_MAX_LEN}, |
| 613 | }; |
| 614 | #endif /* WLAN_NL80211_TESTMODE */ |
| 615 | |
| 616 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 617 | static const struct wiphy_wowlan_support wowlan_support_cfg80211_init = { |
| 618 | .flags = WIPHY_WOWLAN_MAGIC_PKT, |
| 619 | .n_patterns = WOWL_MAX_PTRNS_ALLOWED, |
| 620 | .pattern_min_len = 1, |
| 621 | .pattern_max_len = WOWL_PTRN_MAX_SIZE, |
| 622 | }; |
| 623 | #endif |
| 624 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 625 | /** |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 626 | * hdd_add_channel_switch_support()- Adds Channel Switch flag if supported |
| 627 | * @flags: Pointer to the flags to Add channel switch flag. |
| 628 | * |
| 629 | * This Function adds Channel Switch support flag, if channel switch is |
| 630 | * supported by kernel. |
| 631 | * Return: void. |
| 632 | */ |
| 633 | #ifdef CHANNEL_SWITCH_SUPPORTED |
| 634 | static inline void hdd_add_channel_switch_support(uint32_t *flags) |
| 635 | { |
Krishna Kumaar Natarajan | 8a8df26 | 2015-12-04 11:43:46 -0800 | [diff] [blame] | 636 | *flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 637 | return; |
| 638 | } |
| 639 | #else |
| 640 | static inline void hdd_add_channel_switch_support(uint32_t *flags) |
| 641 | { |
| 642 | return; |
| 643 | } |
| 644 | #endif |
| 645 | |
Manikandan Mohan | 22b8372 | 2015-12-15 15:03:23 -0800 | [diff] [blame] | 646 | #ifdef FEATURE_WLAN_TDLS |
| 647 | |
| 648 | /* TDLS capabilities params */ |
| 649 | #define PARAM_MAX_TDLS_SESSION \ |
| 650 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_CAPS_MAX_CONC_SESSIONS |
| 651 | #define PARAM_TDLS_FEATURE_SUPPORT \ |
| 652 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_CAPS_FEATURES_SUPPORTED |
| 653 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 654 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 655 | * __wlan_hdd_cfg80211_get_tdls_capabilities() - Provide TDLS Capabilites. |
| 656 | * @wiphy: WIPHY structure pointer |
| 657 | * @wdev: Wireless device structure pointer |
| 658 | * @data: Pointer to the data received |
| 659 | * @data_len: Length of the data received |
| 660 | * |
| 661 | * This function provides TDLS capabilities |
| 662 | * |
| 663 | * Return: 0 on success and errno on failure |
| 664 | */ |
| 665 | static int __wlan_hdd_cfg80211_get_tdls_capabilities(struct wiphy *wiphy, |
| 666 | struct wireless_dev *wdev, |
| 667 | const void *data, |
| 668 | int data_len) |
| 669 | { |
| 670 | int status; |
| 671 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 672 | struct sk_buff *skb; |
| 673 | uint32_t set = 0; |
| 674 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 675 | ENTER_DEV(wdev->netdev); |
| 676 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 677 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 678 | hdd_err("Command not allowed in FTM mode"); |
| 679 | return -EPERM; |
| 680 | } |
| 681 | |
| 682 | status = wlan_hdd_validate_context(hdd_ctx); |
| 683 | if (status) |
| 684 | return status; |
| 685 | |
| 686 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, (2 * sizeof(u32)) + |
| 687 | NLMSG_HDRLEN); |
| 688 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 689 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 690 | goto fail; |
| 691 | } |
| 692 | |
| 693 | if (false == hdd_ctx->config->fEnableTDLSSupport) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 694 | hdd_err("TDLS feature not Enabled or Not supported in FW"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 695 | if (nla_put_u32(skb, PARAM_MAX_TDLS_SESSION, 0) || |
| 696 | nla_put_u32(skb, PARAM_TDLS_FEATURE_SUPPORT, 0)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 697 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 698 | goto fail; |
| 699 | } |
| 700 | } else { |
| 701 | set = set | WIFI_TDLS_SUPPORT; |
| 702 | set = set | (hdd_ctx->config->fTDLSExternalControl ? |
| 703 | WIFI_TDLS_EXTERNAL_CONTROL_SUPPORT : 0); |
| 704 | set = set | (hdd_ctx->config->fEnableTDLSOffChannel ? |
| 705 | WIIF_TDLS_OFFCHANNEL_SUPPORT : 0); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 706 | hdd_notice("TDLS Feature supported value %x", set); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 707 | if (nla_put_u32(skb, PARAM_MAX_TDLS_SESSION, |
| 708 | hdd_ctx->max_num_tdls_sta) || |
| 709 | nla_put_u32(skb, PARAM_TDLS_FEATURE_SUPPORT, |
| 710 | set)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 711 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 712 | goto fail; |
| 713 | } |
| 714 | } |
| 715 | return cfg80211_vendor_cmd_reply(skb); |
| 716 | fail: |
| 717 | if (skb) |
| 718 | kfree_skb(skb); |
| 719 | return -EINVAL; |
| 720 | } |
| 721 | |
| 722 | /** |
| 723 | * wlan_hdd_cfg80211_get_tdls_capabilities() - Provide TDLS Capabilites. |
| 724 | * @wiphy: WIPHY structure pointer |
| 725 | * @wdev: Wireless device structure pointer |
| 726 | * @data: Pointer to the data received |
| 727 | * @data_len: Length of the data received |
| 728 | * |
| 729 | * This function provides TDLS capabilities |
| 730 | * |
| 731 | * Return: 0 on success and errno on failure |
| 732 | */ |
| 733 | static int |
| 734 | wlan_hdd_cfg80211_get_tdls_capabilities(struct wiphy *wiphy, |
| 735 | struct wireless_dev *wdev, |
| 736 | const void *data, |
| 737 | int data_len) |
| 738 | { |
| 739 | int ret; |
| 740 | |
| 741 | cds_ssr_protect(__func__); |
| 742 | ret = __wlan_hdd_cfg80211_get_tdls_capabilities(wiphy, wdev, |
| 743 | data, data_len); |
| 744 | cds_ssr_unprotect(__func__); |
| 745 | |
| 746 | return ret; |
| 747 | } |
| 748 | #endif |
| 749 | |
| 750 | #ifdef QCA_HT_2040_COEX |
| 751 | static void wlan_hdd_cfg80211_start_pending_acs(struct work_struct *work); |
| 752 | #endif |
| 753 | |
| 754 | #if defined(FEATURE_WLAN_CH_AVOID) || defined(FEATURE_WLAN_FORCE_SAP_SCC) |
| 755 | /* |
| 756 | * FUNCTION: wlan_hdd_send_avoid_freq_event |
| 757 | * This is called when wlan driver needs to send vendor specific |
| 758 | * avoid frequency range event to userspace |
| 759 | */ |
| 760 | int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx, |
| 761 | tHddAvoidFreqList *pAvoidFreqList) |
| 762 | { |
| 763 | struct sk_buff *vendor_event; |
| 764 | |
| 765 | ENTER(); |
| 766 | |
| 767 | if (!pHddCtx) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 768 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 769 | return -EINVAL; |
| 770 | } |
| 771 | |
| 772 | if (!pAvoidFreqList) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 773 | hdd_err("pAvoidFreqList is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 774 | return -EINVAL; |
| 775 | } |
| 776 | |
| 777 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 778 | NULL, |
| 779 | sizeof(tHddAvoidFreqList), |
| 780 | QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX, |
| 781 | GFP_KERNEL); |
| 782 | if (!vendor_event) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 783 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 784 | return -EINVAL; |
| 785 | } |
| 786 | |
| 787 | memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)), |
| 788 | (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList)); |
| 789 | |
| 790 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 791 | |
| 792 | EXIT(); |
| 793 | return 0; |
| 794 | } |
| 795 | #endif /* FEATURE_WLAN_CH_AVOID || FEATURE_WLAN_FORCE_SAP_SCC */ |
| 796 | |
| 797 | /* vendor specific events */ |
| 798 | static const struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] = { |
| 799 | #ifdef FEATURE_WLAN_CH_AVOID |
| 800 | [QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX] = { |
| 801 | .vendor_id = |
| 802 | QCA_NL80211_VENDOR_ID, |
| 803 | .subcmd = |
| 804 | QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY |
| 805 | }, |
| 806 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 807 | |
| 808 | #ifdef WLAN_FEATURE_NAN |
| 809 | [QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX] = { |
| 810 | .vendor_id = |
| 811 | QCA_NL80211_VENDOR_ID, |
| 812 | .subcmd = |
| 813 | QCA_NL80211_VENDOR_SUBCMD_NAN |
| 814 | }, |
| 815 | #endif |
| 816 | |
| 817 | #ifdef WLAN_FEATURE_STATS_EXT |
| 818 | [QCA_NL80211_VENDOR_SUBCMD_STATS_EXT_INDEX] = { |
| 819 | .vendor_id = |
| 820 | QCA_NL80211_VENDOR_ID, |
| 821 | .subcmd = |
| 822 | QCA_NL80211_VENDOR_SUBCMD_STATS_EXT |
| 823 | }, |
| 824 | #endif /* WLAN_FEATURE_STATS_EXT */ |
| 825 | #ifdef FEATURE_WLAN_EXTSCAN |
| 826 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX] = { |
| 827 | .vendor_id = |
| 828 | QCA_NL80211_VENDOR_ID, |
| 829 | .subcmd = |
| 830 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START |
| 831 | }, |
| 832 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX] = { |
| 833 | .vendor_id = |
| 834 | QCA_NL80211_VENDOR_ID, |
| 835 | .subcmd = |
| 836 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP |
| 837 | }, |
| 838 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX] = { |
| 839 | . |
| 840 | vendor_id |
| 841 | = |
| 842 | QCA_NL80211_VENDOR_ID, |
| 843 | .subcmd = |
| 844 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES |
| 845 | }, |
| 846 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX] = { |
| 847 | . |
| 848 | vendor_id |
| 849 | = |
| 850 | QCA_NL80211_VENDOR_ID, |
| 851 | . |
| 852 | subcmd = |
| 853 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS |
| 854 | }, |
| 855 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX] = { |
| 856 | . |
| 857 | vendor_id |
| 858 | = |
| 859 | QCA_NL80211_VENDOR_ID, |
| 860 | . |
| 861 | subcmd |
| 862 | = |
| 863 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE |
| 864 | }, |
| 865 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX] = { |
| 866 | . |
| 867 | vendor_id |
| 868 | = |
| 869 | QCA_NL80211_VENDOR_ID, |
| 870 | .subcmd = |
| 871 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT |
| 872 | }, |
| 873 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX] = { |
| 874 | .vendor_id = |
| 875 | QCA_NL80211_VENDOR_ID, |
| 876 | .subcmd = |
| 877 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT |
| 878 | }, |
| 879 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX] = { |
| 880 | . |
| 881 | vendor_id |
| 882 | = |
| 883 | QCA_NL80211_VENDOR_ID, |
| 884 | .subcmd = |
| 885 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND |
| 886 | }, |
| 887 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX] = { |
| 888 | . |
| 889 | vendor_id |
| 890 | = |
| 891 | QCA_NL80211_VENDOR_ID, |
| 892 | .subcmd = |
| 893 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST |
| 894 | }, |
| 895 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX] = { |
| 896 | . |
| 897 | vendor_id |
| 898 | = |
| 899 | QCA_NL80211_VENDOR_ID, |
| 900 | . |
| 901 | subcmd |
| 902 | = |
| 903 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST |
| 904 | }, |
| 905 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX] = { |
| 906 | . |
| 907 | vendor_id |
| 908 | = |
| 909 | QCA_NL80211_VENDOR_ID, |
| 910 | . |
| 911 | subcmd = |
| 912 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE |
| 913 | }, |
| 914 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX] = { |
| 915 | . |
| 916 | vendor_id |
| 917 | = |
| 918 | QCA_NL80211_VENDOR_ID, |
| 919 | . |
| 920 | subcmd |
| 921 | = |
| 922 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE |
| 923 | }, |
| 924 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX] = { |
| 925 | . |
| 926 | vendor_id |
| 927 | = |
| 928 | QCA_NL80211_VENDOR_ID, |
| 929 | . |
| 930 | subcmd |
| 931 | = |
| 932 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE |
| 933 | }, |
| 934 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX] = { |
| 935 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 936 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND |
| 937 | }, |
| 938 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX] = { |
| 939 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 940 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST |
| 941 | }, |
| 942 | #endif /* FEATURE_WLAN_EXTSCAN */ |
| 943 | |
| 944 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 945 | [QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET_INDEX] = { |
| 946 | .vendor_id = |
| 947 | QCA_NL80211_VENDOR_ID, |
| 948 | .subcmd = |
| 949 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET |
| 950 | }, |
| 951 | [QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET_INDEX] = { |
| 952 | .vendor_id = |
| 953 | QCA_NL80211_VENDOR_ID, |
| 954 | .subcmd = |
| 955 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET |
| 956 | }, |
| 957 | [QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR_INDEX] = { |
| 958 | .vendor_id = |
| 959 | QCA_NL80211_VENDOR_ID, |
| 960 | .subcmd = |
| 961 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR |
| 962 | }, |
| 963 | [QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX] = { |
| 964 | .vendor_id = |
| 965 | QCA_NL80211_VENDOR_ID, |
| 966 | .subcmd = |
| 967 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS |
| 968 | }, |
| 969 | [QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX] = { |
| 970 | .vendor_id = |
| 971 | QCA_NL80211_VENDOR_ID, |
| 972 | .subcmd = |
| 973 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS |
| 974 | }, |
| 975 | [QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX] = { |
| 976 | .vendor_id = |
| 977 | QCA_NL80211_VENDOR_ID, |
| 978 | .subcmd = |
| 979 | QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS |
| 980 | }, |
| 981 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 982 | [QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX] = { |
| 983 | .vendor_id = |
| 984 | QCA_NL80211_VENDOR_ID, |
| 985 | .subcmd = |
| 986 | QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE |
| 987 | }, |
| 988 | [QCA_NL80211_VENDOR_SUBCMD_DO_ACS_INDEX] = { |
| 989 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 990 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_DO_ACS |
| 991 | }, |
| 992 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 993 | [QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH_INDEX] = { |
| 994 | .vendor_id = |
| 995 | QCA_NL80211_VENDOR_ID, |
| 996 | .subcmd = |
| 997 | QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH |
| 998 | }, |
| 999 | #endif |
| 1000 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_STARTED_INDEX] = { |
| 1001 | .vendor_id = |
| 1002 | QCA_NL80211_VENDOR_ID, |
| 1003 | .subcmd = |
| 1004 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_STARTED |
| 1005 | }, |
| 1006 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_FINISHED_INDEX] = { |
| 1007 | .vendor_id = |
| 1008 | QCA_NL80211_VENDOR_ID, |
| 1009 | .subcmd = |
| 1010 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_FINISHED |
| 1011 | }, |
| 1012 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_ABORTED_INDEX] = { |
| 1013 | .vendor_id = |
| 1014 | QCA_NL80211_VENDOR_ID, |
| 1015 | .subcmd = |
| 1016 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_ABORTED |
| 1017 | }, |
| 1018 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_NOP_FINISHED_INDEX] = { |
| 1019 | .vendor_id = |
| 1020 | QCA_NL80211_VENDOR_ID, |
| 1021 | .subcmd = |
| 1022 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_NOP_FINISHED |
| 1023 | }, |
| 1024 | [QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_RADAR_DETECTED_INDEX] = { |
| 1025 | .vendor_id = |
| 1026 | QCA_NL80211_VENDOR_ID, |
| 1027 | .subcmd = |
| 1028 | QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_RADAR_DETECTED |
| 1029 | }, |
| 1030 | #ifdef FEATURE_WLAN_EXTSCAN |
| 1031 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_NETWORK_FOUND_INDEX] = { |
| 1032 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1033 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_NETWORK_FOUND |
| 1034 | }, |
| 1035 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_PASSPOINT_NETWORK_FOUND_INDEX] = { |
| 1036 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1037 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_PASSPOINT_NETWORK_FOUND |
| 1038 | }, |
| 1039 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST_INDEX] = { |
| 1040 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1041 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST |
| 1042 | }, |
| 1043 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST_INDEX] = { |
| 1044 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1045 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST |
| 1046 | }, |
| 1047 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = { |
| 1048 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1049 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST |
| 1050 | }, |
| 1051 | #endif /* FEATURE_WLAN_EXTSCAN */ |
| 1052 | [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = { |
| 1053 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1054 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI |
| 1055 | }, |
| 1056 | #ifdef WLAN_FEATURE_MEMDUMP |
| 1057 | [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = { |
| 1058 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1059 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP |
| 1060 | }, |
| 1061 | #endif /* WLAN_FEATURE_MEMDUMP */ |
Manikandan Mohan | 5356c2b | 2016-04-03 15:51:35 -0700 | [diff] [blame] | 1062 | #ifdef WLAN_FEATURE_TSF |
| 1063 | [QCA_NL80211_VENDOR_SUBCMD_TSF_INDEX] = { |
| 1064 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1065 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_TSF |
| 1066 | }, |
| 1067 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1068 | [QCA_NL80211_VENDOR_SUBCMD_SCAN_DONE_INDEX] = { |
| 1069 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1070 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_SCAN_DONE |
| 1071 | }, |
| 1072 | [QCA_NL80211_VENDOR_SUBCMD_SCAN_INDEX] = { |
| 1073 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1074 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_TRIGGER_SCAN |
| 1075 | }, |
| 1076 | /* OCB events */ |
| 1077 | [QCA_NL80211_VENDOR_SUBCMD_DCC_STATS_EVENT_INDEX] = { |
| 1078 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1079 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_STATS_EVENT |
| 1080 | }, |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 1081 | #ifdef FEATURE_LFR_SUBNET_DETECTION |
| 1082 | [QCA_NL80211_VENDOR_SUBCMD_GW_PARAM_CONFIG_INDEX] = { |
| 1083 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1084 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_GW_PARAM_CONFIG |
| 1085 | }, |
| 1086 | #endif /*FEATURE_LFR_SUBNET_DETECTION */ |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 1087 | |
| 1088 | #ifdef WLAN_FEATURE_NAN_DATAPATH |
| 1089 | [QCA_NL80211_VENDOR_SUBCMD_NDP_INDEX] = { |
| 1090 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1091 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_NDP |
| 1092 | }, |
| 1093 | #endif /* WLAN_FEATURE_NAN_DATAPATH */ |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 1094 | |
| 1095 | [QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX] = { |
| 1096 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1097 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_P2P_LISTEN_OFFLOAD_STOP |
| 1098 | }, |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 1099 | [QCA_NL80211_VENDOR_SUBCMD_SAP_CONDITIONAL_CHAN_SWITCH_INDEX] = { |
| 1100 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1101 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_SAP_CONDITIONAL_CHAN_SWITCH |
| 1102 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1103 | }; |
| 1104 | |
| 1105 | /** |
| 1106 | * __is_driver_dfs_capable() - get driver DFS capability |
| 1107 | * @wiphy: pointer to wireless wiphy structure. |
| 1108 | * @wdev: pointer to wireless_dev structure. |
| 1109 | * @data: Pointer to the data to be passed via vendor interface |
| 1110 | * @data_len:Length of the data to be passed |
| 1111 | * |
| 1112 | * This function is called by userspace to indicate whether or not |
| 1113 | * the driver supports DFS offload. |
| 1114 | * |
| 1115 | * Return: 0 on success, negative errno on failure |
| 1116 | */ |
| 1117 | static int __is_driver_dfs_capable(struct wiphy *wiphy, |
| 1118 | struct wireless_dev *wdev, |
| 1119 | const void *data, |
| 1120 | int data_len) |
| 1121 | { |
| 1122 | u32 dfs_capability = 0; |
| 1123 | struct sk_buff *temp_skbuff; |
| 1124 | int ret_val; |
| 1125 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 1126 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 1127 | ENTER_DEV(wdev->netdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1128 | |
| 1129 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 1130 | if (ret_val) |
| 1131 | return ret_val; |
| 1132 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1133 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1134 | hdd_err("Command not allowed in FTM mode"); |
| 1135 | return -EPERM; |
| 1136 | } |
| 1137 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1138 | dfs_capability = !!(wiphy->flags & WIPHY_FLAG_DFS_OFFLOAD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1139 | |
| 1140 | temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) + |
| 1141 | NLMSG_HDRLEN); |
| 1142 | |
| 1143 | if (temp_skbuff != NULL) { |
| 1144 | ret_val = nla_put_u32(temp_skbuff, QCA_WLAN_VENDOR_ATTR_DFS, |
| 1145 | dfs_capability); |
| 1146 | if (ret_val) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1147 | hdd_err("QCA_WLAN_VENDOR_ATTR_DFS put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1148 | kfree_skb(temp_skbuff); |
| 1149 | |
| 1150 | return ret_val; |
| 1151 | } |
| 1152 | |
| 1153 | return cfg80211_vendor_cmd_reply(temp_skbuff); |
| 1154 | } |
| 1155 | |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1156 | hdd_err("dfs capability: buffer alloc fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1157 | return -ENOMEM; |
| 1158 | } |
| 1159 | |
| 1160 | /** |
| 1161 | * is_driver_dfs_capable() - get driver DFS capability |
| 1162 | * @wiphy: pointer to wireless wiphy structure. |
| 1163 | * @wdev: pointer to wireless_dev structure. |
| 1164 | * @data: Pointer to the data to be passed via vendor interface |
| 1165 | * @data_len:Length of the data to be passed |
| 1166 | * |
| 1167 | * This function is called by userspace to indicate whether or not |
| 1168 | * the driver supports DFS offload. This is an SSR-protected |
| 1169 | * wrapper function. |
| 1170 | * |
| 1171 | * Return: 0 on success, negative errno on failure |
| 1172 | */ |
| 1173 | static int is_driver_dfs_capable(struct wiphy *wiphy, |
| 1174 | struct wireless_dev *wdev, |
| 1175 | const void *data, |
| 1176 | int data_len) |
| 1177 | { |
| 1178 | int ret; |
| 1179 | |
| 1180 | cds_ssr_protect(__func__); |
| 1181 | ret = __is_driver_dfs_capable(wiphy, wdev, data, data_len); |
| 1182 | cds_ssr_unprotect(__func__); |
| 1183 | |
| 1184 | return ret; |
| 1185 | } |
| 1186 | |
| 1187 | /** |
| 1188 | * wlan_hdd_sap_cfg_dfs_override() - DFS MCC restriction check |
| 1189 | * |
| 1190 | * @adapter: SAP adapter pointer |
| 1191 | * |
| 1192 | * DFS in MCC is not supported for Multi bssid SAP mode due to single physical |
| 1193 | * radio. So in case of DFS MCC scenario override current SAP given config |
| 1194 | * to follow concurrent SAP DFS config |
| 1195 | * |
| 1196 | * Return: 0 - No DFS issue, 1 - Override done and negative error codes |
| 1197 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1198 | int wlan_hdd_sap_cfg_dfs_override(hdd_adapter_t *adapter) |
| 1199 | { |
| 1200 | hdd_adapter_t *con_sap_adapter; |
| 1201 | tsap_Config_t *sap_config, *con_sap_config; |
| 1202 | int con_ch; |
| 1203 | |
| 1204 | /* |
| 1205 | * Check if AP+AP case, once primary AP chooses a DFS |
| 1206 | * channel secondary AP should always follow primary APs channel |
| 1207 | */ |
| 1208 | if (!cds_concurrent_beaconing_sessions_running()) |
| 1209 | return 0; |
| 1210 | |
| 1211 | con_sap_adapter = hdd_get_con_sap_adapter(adapter, true); |
| 1212 | if (!con_sap_adapter) |
| 1213 | return 0; |
| 1214 | |
| 1215 | sap_config = &adapter->sessionCtx.ap.sapConfig; |
| 1216 | con_sap_config = &con_sap_adapter->sessionCtx.ap.sapConfig; |
| 1217 | con_ch = con_sap_adapter->sessionCtx.ap.operatingChannel; |
| 1218 | |
| 1219 | if (!CDS_IS_DFS_CH(con_ch)) |
| 1220 | return 0; |
| 1221 | |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1222 | hdd_err("Only SCC AP-AP DFS Permitted (ch=%d, con_ch=%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1223 | sap_config->channel, con_ch); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1224 | hdd_notice("Overriding guest AP's channel"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1225 | sap_config->channel = con_ch; |
| 1226 | |
| 1227 | if (con_sap_config->acs_cfg.acs_mode == true) { |
| 1228 | if (con_ch != con_sap_config->acs_cfg.pri_ch && |
| 1229 | con_ch != con_sap_config->acs_cfg.ht_sec_ch) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1230 | hdd_err("Primary AP channel config error"); |
| 1231 | hdd_err("Operating ch: %d ACS ch: %d %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1232 | con_ch, con_sap_config->acs_cfg.pri_ch, |
| 1233 | con_sap_config->acs_cfg.ht_sec_ch); |
| 1234 | return -EINVAL; |
| 1235 | } |
| 1236 | /* Sec AP ACS info is overwritten with Pri AP due to DFS |
| 1237 | * MCC restriction. So free ch list allocated in do_acs |
| 1238 | * func for Sec AP and realloc for Pri AP ch list size |
| 1239 | */ |
| 1240 | if (sap_config->acs_cfg.ch_list) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1241 | qdf_mem_free(sap_config->acs_cfg.ch_list); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1242 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1243 | qdf_mem_copy(&sap_config->acs_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1244 | &con_sap_config->acs_cfg, |
| 1245 | sizeof(struct sap_acs_cfg)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1246 | sap_config->acs_cfg.ch_list = qdf_mem_malloc( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1247 | sizeof(uint8_t) * |
| 1248 | con_sap_config->acs_cfg.ch_list_count); |
| 1249 | if (!sap_config->acs_cfg.ch_list) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1250 | hdd_err("ACS config alloc fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1251 | return -ENOMEM; |
| 1252 | } |
| 1253 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1254 | qdf_mem_copy(sap_config->acs_cfg.ch_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1255 | con_sap_config->acs_cfg.ch_list, |
| 1256 | con_sap_config->acs_cfg.ch_list_count); |
| 1257 | |
| 1258 | } else { |
| 1259 | sap_config->acs_cfg.pri_ch = con_ch; |
| 1260 | if (sap_config->acs_cfg.ch_width > eHT_CHANNEL_WIDTH_20MHZ) |
| 1261 | sap_config->acs_cfg.ht_sec_ch = con_sap_config->sec_ch; |
| 1262 | } |
| 1263 | |
| 1264 | return con_ch; |
| 1265 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1266 | |
| 1267 | /** |
| 1268 | * wlan_hdd_set_acs_ch_range : Start ACS channel range values |
| 1269 | * @sap_cfg: pointer to SAP config struct |
| 1270 | * |
| 1271 | * This function sets the default ACS start and end channel for the given band |
| 1272 | * and also parses the given ACS channel list. |
| 1273 | * |
| 1274 | * Return: None |
| 1275 | */ |
| 1276 | |
| 1277 | static void wlan_hdd_set_acs_ch_range(tsap_Config_t *sap_cfg, bool ht_enabled, |
| 1278 | bool vht_enabled) |
| 1279 | { |
| 1280 | int i; |
| 1281 | if (sap_cfg->acs_cfg.hw_mode == QCA_ACS_MODE_IEEE80211B) { |
| 1282 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11b; |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 1283 | sap_cfg->acs_cfg.start_ch = CDS_CHANNEL_NUM(CHAN_ENUM_1); |
| 1284 | sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(CHAN_ENUM_14); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1285 | } else if (sap_cfg->acs_cfg.hw_mode == QCA_ACS_MODE_IEEE80211G) { |
| 1286 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11g; |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 1287 | sap_cfg->acs_cfg.start_ch = CDS_CHANNEL_NUM(CHAN_ENUM_1); |
| 1288 | sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(CHAN_ENUM_13); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1289 | } else if (sap_cfg->acs_cfg.hw_mode == QCA_ACS_MODE_IEEE80211A) { |
| 1290 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11a; |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 1291 | sap_cfg->acs_cfg.start_ch = CDS_CHANNEL_NUM(CHAN_ENUM_36); |
| 1292 | sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(CHAN_ENUM_165); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1293 | } else if (sap_cfg->acs_cfg.hw_mode == QCA_ACS_MODE_IEEE80211ANY) { |
| 1294 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_abg; |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 1295 | sap_cfg->acs_cfg.start_ch = CDS_CHANNEL_NUM(CHAN_ENUM_1); |
| 1296 | sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(CHAN_ENUM_165); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1297 | } |
| 1298 | |
| 1299 | if (ht_enabled) |
| 1300 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11n; |
| 1301 | |
| 1302 | if (vht_enabled) |
| 1303 | sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11ac; |
| 1304 | |
| 1305 | |
| 1306 | /* Parse ACS Chan list from hostapd */ |
| 1307 | if (!sap_cfg->acs_cfg.ch_list) |
| 1308 | return; |
| 1309 | |
| 1310 | sap_cfg->acs_cfg.start_ch = sap_cfg->acs_cfg.ch_list[0]; |
| 1311 | sap_cfg->acs_cfg.end_ch = |
| 1312 | sap_cfg->acs_cfg.ch_list[sap_cfg->acs_cfg.ch_list_count - 1]; |
| 1313 | for (i = 0; i < sap_cfg->acs_cfg.ch_list_count; i++) { |
Manjeet Singh | 2d3b0c5 | 2016-09-02 13:31:48 +0530 | [diff] [blame] | 1314 | /* avoid channel as start channel */ |
| 1315 | if (sap_cfg->acs_cfg.start_ch > sap_cfg->acs_cfg.ch_list[i] && |
| 1316 | sap_cfg->acs_cfg.ch_list[i] != 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1317 | sap_cfg->acs_cfg.start_ch = sap_cfg->acs_cfg.ch_list[i]; |
| 1318 | if (sap_cfg->acs_cfg.end_ch < sap_cfg->acs_cfg.ch_list[i]) |
| 1319 | sap_cfg->acs_cfg.end_ch = sap_cfg->acs_cfg.ch_list[i]; |
| 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | |
| 1324 | static void wlan_hdd_cfg80211_start_pending_acs(struct work_struct *work); |
| 1325 | |
| 1326 | /** |
| 1327 | * wlan_hdd_cfg80211_start_acs : Start ACS Procedure for SAP |
| 1328 | * @adapter: pointer to SAP adapter struct |
| 1329 | * |
| 1330 | * This function starts the ACS procedure if there are no |
| 1331 | * constraints like MBSSID DFS restrictions. |
| 1332 | * |
| 1333 | * Return: Status of ACS Start procedure |
| 1334 | */ |
| 1335 | |
| 1336 | static int wlan_hdd_cfg80211_start_acs(hdd_adapter_t *adapter) |
| 1337 | { |
| 1338 | |
| 1339 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1340 | tsap_Config_t *sap_config; |
| 1341 | tpWLAN_SAPEventCB acs_event_callback; |
| 1342 | int status; |
| 1343 | |
| 1344 | sap_config = &adapter->sessionCtx.ap.sapConfig; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 1345 | if (hdd_ctx->acs_policy.acs_channel) |
| 1346 | sap_config->channel = hdd_ctx->acs_policy.acs_channel; |
| 1347 | else |
| 1348 | sap_config->channel = AUTO_CHANNEL_SELECT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1349 | |
| 1350 | status = wlan_hdd_sap_cfg_dfs_override(adapter); |
| 1351 | if (status < 0) { |
| 1352 | return status; |
| 1353 | } else { |
| 1354 | if (status > 0) { |
| 1355 | /*notify hostapd about channel override */ |
| 1356 | wlan_hdd_cfg80211_acs_ch_select_evt(adapter); |
| 1357 | clear_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags); |
| 1358 | return 0; |
| 1359 | } |
| 1360 | } |
| 1361 | status = wlan_hdd_config_acs(hdd_ctx, adapter); |
| 1362 | if (status) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1363 | hdd_err("ACS config failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1364 | return -EINVAL; |
| 1365 | } |
| 1366 | |
| 1367 | acs_event_callback = hdd_hostapd_sap_event_cb; |
| 1368 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1369 | qdf_mem_copy(sap_config->self_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1370 | adapter->macAddressCurrent.bytes, sizeof(struct qdf_mac_addr)); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1371 | hdd_notice("ACS Started for wlan%d", adapter->dev->ifindex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1372 | status = wlansap_acs_chselect( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1373 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1374 | acs_event_callback, sap_config, adapter->dev); |
| 1375 | |
| 1376 | |
| 1377 | if (status) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1378 | hdd_err("ACS channel select failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1379 | return -EINVAL; |
| 1380 | } |
| 1381 | sap_config->acs_cfg.acs_mode = true; |
| 1382 | set_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags); |
| 1383 | |
| 1384 | return 0; |
| 1385 | } |
| 1386 | |
| 1387 | /** |
| 1388 | * __wlan_hdd_cfg80211_do_acs : CFG80211 handler function for DO_ACS Vendor CMD |
| 1389 | * @wiphy: Linux wiphy struct pointer |
| 1390 | * @wdev: Linux wireless device struct pointer |
| 1391 | * @data: ACS information from hostapd |
| 1392 | * @data_len: ACS information length |
| 1393 | * |
| 1394 | * This function handle DO_ACS Vendor command from hostapd, parses ACS config |
| 1395 | * and starts ACS procedure. |
| 1396 | * |
| 1397 | * Return: ACS procedure start status |
| 1398 | */ |
| 1399 | |
| 1400 | static int __wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy, |
| 1401 | struct wireless_dev *wdev, |
| 1402 | const void *data, int data_len) |
| 1403 | { |
| 1404 | struct net_device *ndev = wdev->netdev; |
| 1405 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 1406 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 1407 | tsap_Config_t *sap_config; |
| 1408 | struct sk_buff *temp_skbuff; |
| 1409 | int status = -EINVAL, i = 0; |
| 1410 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ACS_MAX + 1]; |
| 1411 | bool ht_enabled, ht40_enabled, vht_enabled; |
| 1412 | uint8_t ch_width; |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 1413 | uint8_t weight_list[QDF_MAX_NUM_CHAN]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1414 | |
| 1415 | /* ***Note*** Donot set SME config related to ACS operation here because |
| 1416 | * ACS operation is not synchronouse and ACS for Second AP may come when |
| 1417 | * ACS operation for first AP is going on. So only do_acs is split to |
| 1418 | * seperate start_acs routine. Also SME-PMAC struct that is used to |
| 1419 | * pass paremeters from HDD to SAP is global. Thus All ACS related SME |
| 1420 | * config shall be set only from start_acs. |
| 1421 | */ |
| 1422 | |
| 1423 | /* nla_policy Policy template. Policy not applied as some attributes are |
| 1424 | * optional and QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST has variable length |
| 1425 | * |
| 1426 | * [QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE] = { .type = NLA_U8 }, |
| 1427 | * [QCA_WLAN_VENDOR_ATTR_ACS_HT_ENABLED] = { .type = NLA_FLAG }, |
| 1428 | * [QCA_WLAN_VENDOR_ATTR_ACS_HT40_ENABLED] = { .type = NLA_FLAG }, |
| 1429 | * [QCA_WLAN_VENDOR_ATTR_ACS_VHT_ENABLED] = { .type = NLA_FLAG }, |
| 1430 | * [QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH] = { .type = NLA_U16 }, |
| 1431 | * [QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST] = { .type = NLA_NESTED }, |
| 1432 | */ |
| 1433 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 1434 | ENTER_DEV(ndev); |
| 1435 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1436 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1437 | hdd_err("Command not allowed in FTM mode"); |
| 1438 | return -EPERM; |
| 1439 | } |
| 1440 | |
| 1441 | if (hdd_ctx->config->force_sap_acs) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1442 | hdd_err("Hostapd ACS rejected as Driver ACS enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1443 | return -EPERM; |
| 1444 | } |
| 1445 | |
| 1446 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1447 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1448 | goto out; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1449 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1450 | if (cds_is_sub_20_mhz_enabled()) { |
| 1451 | hdd_err("ACS not supported in sub 20 MHz ch wd."); |
| 1452 | status = -EINVAL; |
| 1453 | goto out; |
| 1454 | } |
| 1455 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1456 | sap_config = &adapter->sessionCtx.ap.sapConfig; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1457 | qdf_mem_zero(&sap_config->acs_cfg, sizeof(struct sap_acs_cfg)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1458 | |
| 1459 | status = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_ACS_MAX, data, data_len, |
| 1460 | NULL); |
| 1461 | if (status) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1462 | hdd_err("Invalid ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1463 | goto out; |
| 1464 | } |
| 1465 | |
| 1466 | if (!tb[QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1467 | hdd_err("Attr hw_mode failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1468 | goto out; |
| 1469 | } |
| 1470 | sap_config->acs_cfg.hw_mode = nla_get_u8( |
| 1471 | tb[QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE]); |
| 1472 | |
| 1473 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_HT_ENABLED]) |
| 1474 | ht_enabled = |
| 1475 | nla_get_flag(tb[QCA_WLAN_VENDOR_ATTR_ACS_HT_ENABLED]); |
| 1476 | else |
| 1477 | ht_enabled = 0; |
| 1478 | |
| 1479 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_HT40_ENABLED]) |
| 1480 | ht40_enabled = |
| 1481 | nla_get_flag(tb[QCA_WLAN_VENDOR_ATTR_ACS_HT40_ENABLED]); |
| 1482 | else |
| 1483 | ht40_enabled = 0; |
| 1484 | |
| 1485 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_VHT_ENABLED]) |
| 1486 | vht_enabled = |
| 1487 | nla_get_flag(tb[QCA_WLAN_VENDOR_ATTR_ACS_VHT_ENABLED]); |
| 1488 | else |
| 1489 | vht_enabled = 0; |
| 1490 | |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 1491 | if (hdd_ctx->config->sap_force_11n_for_11ac) { |
| 1492 | vht_enabled = 0; |
| 1493 | hdd_log(LOG1, FL("VHT is Disabled in ACS")); |
| 1494 | } |
| 1495 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1496 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH]) { |
| 1497 | ch_width = nla_get_u16(tb[QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH]); |
| 1498 | } else { |
| 1499 | if (ht_enabled && ht40_enabled) |
| 1500 | ch_width = 40; |
| 1501 | else |
| 1502 | ch_width = 20; |
| 1503 | } |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 1504 | |
| 1505 | /* this may be possible, when sap_force_11n_for_11ac is set */ |
| 1506 | if ((ch_width == 80 || ch_width == 160) && !vht_enabled) { |
| 1507 | if (ht_enabled && ht40_enabled) |
| 1508 | ch_width = 40; |
| 1509 | else |
| 1510 | ch_width = 20; |
| 1511 | } |
| 1512 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1513 | if (ch_width == 80) |
| 1514 | sap_config->acs_cfg.ch_width = CH_WIDTH_80MHZ; |
| 1515 | else if (ch_width == 40) |
| 1516 | sap_config->acs_cfg.ch_width = CH_WIDTH_40MHZ; |
| 1517 | else |
| 1518 | sap_config->acs_cfg.ch_width = CH_WIDTH_20MHZ; |
| 1519 | |
| 1520 | /* hw_mode = a/b/g: QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST and |
| 1521 | * QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST attrs are present, and |
| 1522 | * QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST is used for obtaining the |
| 1523 | * channel list, QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST is ignored |
| 1524 | * since it contains the frequency values of the channels in |
| 1525 | * the channel list. |
| 1526 | * hw_mode = any: only QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST attr |
| 1527 | * is present |
| 1528 | */ |
| 1529 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST]) { |
| 1530 | char *tmp = nla_data(tb[QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST]); |
| 1531 | sap_config->acs_cfg.ch_list_count = nla_len( |
| 1532 | tb[QCA_WLAN_VENDOR_ATTR_ACS_CH_LIST]); |
| 1533 | if (sap_config->acs_cfg.ch_list_count) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1534 | sap_config->acs_cfg.ch_list = qdf_mem_malloc( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1535 | sizeof(uint8_t) * |
| 1536 | sap_config->acs_cfg.ch_list_count); |
| 1537 | if (sap_config->acs_cfg.ch_list == NULL) |
| 1538 | goto out; |
| 1539 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1540 | qdf_mem_copy(sap_config->acs_cfg.ch_list, tmp, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1541 | sap_config->acs_cfg.ch_list_count); |
| 1542 | } |
| 1543 | } else if (tb[QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST]) { |
| 1544 | uint32_t *freq = |
| 1545 | nla_data(tb[QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST]); |
| 1546 | sap_config->acs_cfg.ch_list_count = nla_len( |
| 1547 | tb[QCA_WLAN_VENDOR_ATTR_ACS_FREQ_LIST]) / |
| 1548 | sizeof(uint32_t); |
| 1549 | if (sap_config->acs_cfg.ch_list_count) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1550 | sap_config->acs_cfg.ch_list = qdf_mem_malloc( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1551 | sap_config->acs_cfg.ch_list_count); |
| 1552 | if (sap_config->acs_cfg.ch_list == NULL) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1553 | hdd_err("ACS config alloc fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1554 | status = -ENOMEM; |
| 1555 | goto out; |
| 1556 | } |
| 1557 | |
| 1558 | /* convert frequency to channel */ |
| 1559 | for (i = 0; i < sap_config->acs_cfg.ch_list_count; i++) |
| 1560 | sap_config->acs_cfg.ch_list[i] = |
| 1561 | ieee80211_frequency_to_channel(freq[i]); |
| 1562 | } |
| 1563 | } |
| 1564 | |
| 1565 | hdd_debug("get pcl for DO_ACS vendor command"); |
| 1566 | |
| 1567 | /* consult policy manager to get PCL */ |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 1568 | status = cds_get_pcl(CDS_SAP_MODE, |
Manishekar Chandrasekaran | 7009f25 | 2016-04-21 19:14:15 +0530 | [diff] [blame] | 1569 | sap_config->acs_cfg.pcl_channels, |
| 1570 | &sap_config->acs_cfg.pcl_ch_count, |
| 1571 | weight_list, QDF_ARRAY_SIZE(weight_list)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1572 | if (QDF_STATUS_SUCCESS != status) |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1573 | hdd_err("Get PCL failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1574 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1575 | /* ACS override for android */ |
Rajeev Kumar Sirasanagandla | b79b546 | 2016-09-06 18:33:17 +0530 | [diff] [blame] | 1576 | if (hdd_ctx->config->sap_p2p_11ac_override && ht_enabled && |
| 1577 | !hdd_ctx->config->sap_force_11n_for_11ac) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1578 | hdd_notice("ACS Config override for 11AC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1579 | vht_enabled = 1; |
| 1580 | sap_config->acs_cfg.hw_mode = eCSR_DOT11_MODE_11ac; |
| 1581 | sap_config->acs_cfg.ch_width = |
| 1582 | hdd_ctx->config->vhtChannelWidth; |
| 1583 | /* No VHT80 in 2.4G so perform ACS accordingly */ |
| 1584 | if (sap_config->acs_cfg.end_ch <= 14 && |
| 1585 | sap_config->acs_cfg.ch_width == eHT_CHANNEL_WIDTH_80MHZ) |
| 1586 | sap_config->acs_cfg.ch_width = eHT_CHANNEL_WIDTH_40MHZ; |
| 1587 | } |
| 1588 | |
Manishekar Chandrasekaran | 44e334f | 2016-05-30 16:42:50 +0530 | [diff] [blame] | 1589 | wlan_hdd_set_acs_ch_range(sap_config, ht_enabled, vht_enabled); |
| 1590 | |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1591 | hdd_notice("ACS Config for wlan%d: HW_MODE: %d ACS_BW: %d HT: %d VHT: %d START_CH: %d END_CH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1592 | adapter->dev->ifindex, sap_config->acs_cfg.hw_mode, |
| 1593 | ch_width, ht_enabled, vht_enabled, |
| 1594 | sap_config->acs_cfg.start_ch, sap_config->acs_cfg.end_ch); |
| 1595 | |
| 1596 | if (sap_config->acs_cfg.ch_list_count) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1597 | hdd_notice("ACS channel list: len: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1598 | sap_config->acs_cfg.ch_list_count); |
| 1599 | for (i = 0; i < sap_config->acs_cfg.ch_list_count; i++) |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1600 | hdd_notice("%d ", sap_config->acs_cfg.ch_list[i]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1601 | } |
| 1602 | sap_config->acs_cfg.acs_mode = true; |
| 1603 | if (test_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1604 | /* ***Note*** Completion variable usage is not allowed |
| 1605 | * here since ACS scan operation may take max 2.2 sec |
| 1606 | * for 5G band: |
| 1607 | * 9 Active channel X 40 ms active scan time + |
| 1608 | * 16 Passive channel X 110ms passive scan time |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1609 | * Since this CFG80211 call lock rtnl mutex, we cannot hold on |
| 1610 | * for this long. So we split up the scanning part. |
| 1611 | */ |
| 1612 | set_bit(ACS_PENDING, &adapter->event_flags); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1613 | hdd_notice("ACS Pending for wlan%d", adapter->dev->ifindex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1614 | status = 0; |
| 1615 | } else { |
| 1616 | status = wlan_hdd_cfg80211_start_acs(adapter); |
| 1617 | } |
| 1618 | |
| 1619 | out: |
| 1620 | if (0 == status) { |
| 1621 | temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 1622 | NLMSG_HDRLEN); |
| 1623 | if (temp_skbuff != NULL) |
| 1624 | return cfg80211_vendor_cmd_reply(temp_skbuff); |
| 1625 | } |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 1626 | wlan_hdd_undo_acs(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1627 | clear_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags); |
| 1628 | |
| 1629 | return status; |
| 1630 | } |
| 1631 | |
| 1632 | /** |
| 1633 | * wlan_hdd_cfg80211_do_acs : CFG80211 handler function for DO_ACS Vendor CMD |
| 1634 | * @wiphy: Linux wiphy struct pointer |
| 1635 | * @wdev: Linux wireless device struct pointer |
| 1636 | * @data: ACS information from hostapd |
| 1637 | * @data_len: ACS information len |
| 1638 | * |
| 1639 | * This function handle DO_ACS Vendor command from hostapd, parses ACS config |
| 1640 | * and starts ACS procedure. |
| 1641 | * |
| 1642 | * Return: ACS procedure start status |
| 1643 | */ |
| 1644 | |
| 1645 | static int wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy, |
| 1646 | struct wireless_dev *wdev, |
| 1647 | const void *data, int data_len) |
| 1648 | { |
| 1649 | int ret; |
| 1650 | |
| 1651 | cds_ssr_protect(__func__); |
| 1652 | ret = __wlan_hdd_cfg80211_do_acs(wiphy, wdev, data, data_len); |
| 1653 | cds_ssr_unprotect(__func__); |
| 1654 | |
| 1655 | return ret; |
| 1656 | } |
| 1657 | |
| 1658 | /** |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 1659 | * wlan_hdd_undo_acs : Do cleanup of DO_ACS |
| 1660 | * @adapter: Pointer to adapter struct |
| 1661 | * |
| 1662 | * This function handle cleanup of what was done in DO_ACS, including free |
| 1663 | * memory. |
| 1664 | * |
| 1665 | * Return: void |
| 1666 | */ |
| 1667 | |
| 1668 | void wlan_hdd_undo_acs(hdd_adapter_t *adapter) |
| 1669 | { |
| 1670 | if (adapter == NULL) |
| 1671 | return; |
| 1672 | if (adapter->sessionCtx.ap.sapConfig.acs_cfg.ch_list) { |
| 1673 | qdf_mem_free(adapter->sessionCtx.ap.sapConfig.acs_cfg.ch_list); |
| 1674 | adapter->sessionCtx.ap.sapConfig.acs_cfg.ch_list = NULL; |
| 1675 | } |
| 1676 | } |
| 1677 | |
| 1678 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1679 | * wlan_hdd_cfg80211_start_pending_acs : Start pending ACS procedure for SAP |
| 1680 | * @work: Linux workqueue struct pointer for ACS work |
| 1681 | * |
| 1682 | * This function starts the ACS procedure which was marked pending when an ACS |
| 1683 | * procedure was in progress for a concurrent SAP interface. |
| 1684 | * |
| 1685 | * Return: None |
| 1686 | */ |
| 1687 | |
| 1688 | static void wlan_hdd_cfg80211_start_pending_acs(struct work_struct *work) |
| 1689 | { |
| 1690 | hdd_adapter_t *adapter = container_of(work, hdd_adapter_t, |
| 1691 | acs_pending_work.work); |
| 1692 | wlan_hdd_cfg80211_start_acs(adapter); |
| 1693 | } |
| 1694 | |
| 1695 | /** |
| 1696 | * wlan_hdd_cfg80211_acs_ch_select_evt: Callback function for ACS evt |
| 1697 | * @adapter: Pointer to SAP adapter struct |
| 1698 | * @pri_channel: SAP ACS procedure selected Primary channel |
| 1699 | * @sec_channel: SAP ACS procedure selected secondary channel |
| 1700 | * |
| 1701 | * This is a callback function from SAP module on ACS procedure is completed. |
| 1702 | * This function send the ACS selected channel information to hostapd |
| 1703 | * |
| 1704 | * Return: None |
| 1705 | */ |
| 1706 | |
| 1707 | void wlan_hdd_cfg80211_acs_ch_select_evt(hdd_adapter_t *adapter) |
| 1708 | { |
| 1709 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1710 | tsap_Config_t *sap_cfg = &(WLAN_HDD_GET_AP_CTX_PTR(adapter))->sapConfig; |
| 1711 | struct sk_buff *vendor_event; |
| 1712 | int ret_val; |
| 1713 | hdd_adapter_t *con_sap_adapter; |
| 1714 | uint16_t ch_width; |
| 1715 | |
| 1716 | vendor_event = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Ryan Hsu | 9206a4e | 2016-01-19 17:23:13 -0800 | [diff] [blame] | 1717 | &(adapter->wdev), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1718 | 4 * sizeof(u8) + 1 * sizeof(u16) + 4 + NLMSG_HDRLEN, |
| 1719 | QCA_NL80211_VENDOR_SUBCMD_DO_ACS_INDEX, |
| 1720 | GFP_KERNEL); |
| 1721 | |
| 1722 | if (!vendor_event) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 1723 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1724 | return; |
| 1725 | } |
| 1726 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1727 | ret_val = nla_put_u8(vendor_event, |
| 1728 | QCA_WLAN_VENDOR_ATTR_ACS_PRIMARY_CHANNEL, |
| 1729 | sap_cfg->acs_cfg.pri_ch); |
| 1730 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 1731 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_PRIMARY_CHANNEL put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1732 | kfree_skb(vendor_event); |
| 1733 | return; |
| 1734 | } |
| 1735 | |
| 1736 | ret_val = nla_put_u8(vendor_event, |
| 1737 | QCA_WLAN_VENDOR_ATTR_ACS_SECONDARY_CHANNEL, |
| 1738 | sap_cfg->acs_cfg.ht_sec_ch); |
| 1739 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 1740 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_SECONDARY_CHANNEL put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1741 | kfree_skb(vendor_event); |
| 1742 | return; |
| 1743 | } |
| 1744 | |
| 1745 | ret_val = nla_put_u8(vendor_event, |
| 1746 | QCA_WLAN_VENDOR_ATTR_ACS_VHT_SEG0_CENTER_CHANNEL, |
| 1747 | sap_cfg->acs_cfg.vht_seg0_center_ch); |
| 1748 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 1749 | 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] | 1750 | kfree_skb(vendor_event); |
| 1751 | return; |
| 1752 | } |
| 1753 | |
| 1754 | ret_val = nla_put_u8(vendor_event, |
| 1755 | QCA_WLAN_VENDOR_ATTR_ACS_VHT_SEG1_CENTER_CHANNEL, |
| 1756 | sap_cfg->acs_cfg.vht_seg1_center_ch); |
| 1757 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 1758 | 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] | 1759 | kfree_skb(vendor_event); |
| 1760 | return; |
| 1761 | } |
| 1762 | |
| 1763 | if (sap_cfg->acs_cfg.ch_width == CH_WIDTH_80MHZ) |
| 1764 | ch_width = 80; |
| 1765 | else if (sap_cfg->acs_cfg.ch_width == CH_WIDTH_40MHZ) |
| 1766 | ch_width = 40; |
| 1767 | else |
| 1768 | ch_width = 20; |
| 1769 | |
| 1770 | ret_val = nla_put_u16(vendor_event, |
| 1771 | QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH, |
| 1772 | ch_width); |
| 1773 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 1774 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_CHWIDTH put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1775 | kfree_skb(vendor_event); |
| 1776 | return; |
| 1777 | } |
| 1778 | if (sap_cfg->acs_cfg.pri_ch > 14) |
| 1779 | ret_val = nla_put_u8(vendor_event, |
| 1780 | QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE, |
| 1781 | QCA_ACS_MODE_IEEE80211A); |
| 1782 | else |
| 1783 | ret_val = nla_put_u8(vendor_event, |
| 1784 | QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE, |
| 1785 | QCA_ACS_MODE_IEEE80211G); |
| 1786 | |
| 1787 | if (ret_val) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 1788 | hdd_err("QCA_WLAN_VENDOR_ATTR_ACS_HW_MODE put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1789 | kfree_skb(vendor_event); |
| 1790 | return; |
| 1791 | } |
| 1792 | |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 1793 | hdd_notice("ACS result for wlan%d: PRI_CH: %d SEC_CH: %d VHT_SEG0: %d VHT_SEG1: %d ACS_BW: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1794 | adapter->dev->ifindex, sap_cfg->acs_cfg.pri_ch, |
| 1795 | sap_cfg->acs_cfg.ht_sec_ch, sap_cfg->acs_cfg.vht_seg0_center_ch, |
| 1796 | sap_cfg->acs_cfg.vht_seg1_center_ch, ch_width); |
| 1797 | |
| 1798 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 1799 | /* ***Note*** As already mentioned Completion variable usage is not |
| 1800 | * allowed here since ACS scan operation may take max 2.2 sec. |
| 1801 | * Further in AP-AP mode pending ACS is resumed here to serailize ACS |
| 1802 | * operation. |
| 1803 | * TODO: Delayed operation is used since SME-PMAC strut is global. Thus |
| 1804 | * when Primary AP ACS is complete and secondary AP ACS is started here |
| 1805 | * immediately, Primary AP start_bss may come inbetween ACS operation |
| 1806 | * and overwrite Sec AP ACS paramters. Thus Sec AP ACS is executed with |
| 1807 | * delay. This path and below constraint will be removed on sessionizing |
| 1808 | * SAP acs parameters and decoupling SAP from PMAC (WIP). |
| 1809 | * As per design constraint user space control application must take |
| 1810 | * care of serailizing hostapd start for each VIF in AP-AP mode to avoid |
| 1811 | * this code path. Sec AP hostapd should be started after Primary AP |
| 1812 | * start beaconing which can be confirmed by getchannel iwpriv command |
| 1813 | */ |
| 1814 | |
| 1815 | con_sap_adapter = hdd_get_con_sap_adapter(adapter, false); |
| 1816 | if (con_sap_adapter && |
| 1817 | test_bit(ACS_PENDING, &con_sap_adapter->event_flags)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1818 | INIT_DELAYED_WORK(&con_sap_adapter->acs_pending_work, |
| 1819 | wlan_hdd_cfg80211_start_pending_acs); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1820 | /* Lets give 500ms for OBSS + START_BSS to complete */ |
| 1821 | schedule_delayed_work(&con_sap_adapter->acs_pending_work, |
| 1822 | msecs_to_jiffies(500)); |
| 1823 | clear_bit(ACS_PENDING, &con_sap_adapter->event_flags); |
| 1824 | } |
| 1825 | |
| 1826 | return; |
| 1827 | } |
| 1828 | |
| 1829 | static int |
| 1830 | __wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy, |
| 1831 | struct wireless_dev *wdev, |
| 1832 | const void *data, |
| 1833 | int data_len) |
| 1834 | { |
| 1835 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 1836 | struct sk_buff *skb = NULL; |
| 1837 | uint32_t fset = 0; |
| 1838 | int ret; |
| 1839 | |
Srinivas Girigowda | dbfb264 | 2016-08-28 21:32:38 -0700 | [diff] [blame] | 1840 | /* ENTER_DEV() intentionally not used in a frequently invoked API */ |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 1841 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1842 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1843 | hdd_err("Command not allowed in FTM mode"); |
| 1844 | return -EPERM; |
| 1845 | } |
| 1846 | |
| 1847 | ret = wlan_hdd_validate_context(pHddCtx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1848 | if (ret) |
| 1849 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1850 | |
| 1851 | if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1852 | hdd_notice("Infra Station mode is supported by driver"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1853 | fset |= WIFI_FEATURE_INFRA; |
| 1854 | } |
| 1855 | if (true == hdd_is_5g_supported(pHddCtx)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1856 | hdd_notice("INFRA_5G is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1857 | fset |= WIFI_FEATURE_INFRA_5G; |
| 1858 | } |
| 1859 | #ifdef WLAN_FEATURE_P2P |
| 1860 | if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) && |
| 1861 | (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1862 | hdd_notice("WiFi-Direct is supported by driver"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1863 | fset |= WIFI_FEATURE_P2P; |
| 1864 | } |
| 1865 | #endif |
| 1866 | fset |= WIFI_FEATURE_SOFT_AP; |
| 1867 | |
| 1868 | /* HOTSPOT is a supplicant feature, enable it by default */ |
| 1869 | fset |= WIFI_FEATURE_HOTSPOT; |
| 1870 | |
| 1871 | #ifdef FEATURE_WLAN_EXTSCAN |
Manjeet Singh | 0f2ce5c | 2016-09-01 12:08:57 +0530 | [diff] [blame] | 1872 | if (pHddCtx->config->extscan_enabled && |
| 1873 | sme_is_feature_supported_by_fw(EXTENDED_SCAN)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1874 | hdd_notice("EXTScan is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1875 | fset |= WIFI_FEATURE_EXTSCAN | WIFI_FEATURE_HAL_EPNO; |
| 1876 | } |
| 1877 | #endif |
| 1878 | if (wlan_hdd_nan_is_supported()) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1879 | hdd_notice("NAN is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1880 | fset |= WIFI_FEATURE_NAN; |
| 1881 | } |
| 1882 | if (sme_is_feature_supported_by_fw(RTT)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1883 | hdd_notice("RTT is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1884 | fset |= WIFI_FEATURE_D2D_RTT; |
| 1885 | fset |= WIFI_FEATURE_D2AP_RTT; |
| 1886 | } |
| 1887 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1888 | if (pHddCtx->config->configPNOScanSupport && |
| 1889 | sme_is_feature_supported_by_fw(PNO)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1890 | hdd_notice("PNO is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1891 | fset |= WIFI_FEATURE_PNO; |
| 1892 | } |
| 1893 | #endif |
| 1894 | fset |= WIFI_FEATURE_ADDITIONAL_STA; |
| 1895 | #ifdef FEATURE_WLAN_TDLS |
| 1896 | if ((true == pHddCtx->config->fEnableTDLSSupport) && |
| 1897 | sme_is_feature_supported_by_fw(TDLS)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1898 | hdd_notice("TDLS is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1899 | fset |= WIFI_FEATURE_TDLS; |
| 1900 | } |
| 1901 | if (sme_is_feature_supported_by_fw(TDLS) && |
| 1902 | (true == pHddCtx->config->fEnableTDLSOffChannel) && |
| 1903 | sme_is_feature_supported_by_fw(TDLS_OFF_CHANNEL)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1904 | hdd_notice("TDLS off-channel is supported by firmware"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1905 | fset |= WIFI_FEATURE_TDLS_OFFCHANNEL; |
| 1906 | } |
| 1907 | #endif |
| 1908 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 1909 | fset |= WIFI_FEATURE_AP_STA; |
| 1910 | #endif |
| 1911 | fset |= WIFI_FEATURE_RSSI_MONITOR; |
Srinivas Girigowda | a2cad3e | 2016-10-25 14:14:23 -0700 | [diff] [blame] | 1912 | fset |= WIFI_FEATURE_TX_TRANSMIT_POWER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1913 | |
| 1914 | if (hdd_link_layer_stats_supported()) |
| 1915 | fset |= WIFI_FEATURE_LINK_LAYER_STATS; |
| 1916 | |
| 1917 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) + |
| 1918 | NLMSG_HDRLEN); |
| 1919 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1920 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1921 | return -EINVAL; |
| 1922 | } |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1923 | hdd_notice("Supported Features : 0x%x", fset); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1924 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1925 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1926 | goto nla_put_failure; |
| 1927 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 1928 | ret = cfg80211_vendor_cmd_reply(skb); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 1929 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1930 | nla_put_failure: |
| 1931 | kfree_skb(skb); |
| 1932 | return -EINVAL; |
| 1933 | } |
| 1934 | |
| 1935 | /** |
| 1936 | * wlan_hdd_cfg80211_get_supported_features() - get supported features |
| 1937 | * @wiphy: pointer to wireless wiphy structure. |
| 1938 | * @wdev: pointer to wireless_dev structure. |
| 1939 | * @data: Pointer to the data to be passed via vendor interface |
| 1940 | * @data_len:Length of the data to be passed |
| 1941 | * |
| 1942 | * Return: Return the Success or Failure code. |
| 1943 | */ |
| 1944 | static int |
| 1945 | wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy, |
| 1946 | struct wireless_dev *wdev, |
| 1947 | const void *data, int data_len) |
| 1948 | { |
| 1949 | int ret = 0; |
| 1950 | |
| 1951 | cds_ssr_protect(__func__); |
| 1952 | ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, |
| 1953 | data, data_len); |
| 1954 | cds_ssr_unprotect(__func__); |
| 1955 | |
| 1956 | return ret; |
| 1957 | } |
| 1958 | |
| 1959 | /** |
| 1960 | * __wlan_hdd_cfg80211_set_scanning_mac_oui() - set scan MAC |
| 1961 | * @wiphy: pointer to wireless wiphy structure. |
| 1962 | * @wdev: pointer to wireless_dev structure. |
| 1963 | * @data: Pointer to the data to be passed via vendor interface |
| 1964 | * @data_len:Length of the data to be passed |
| 1965 | * |
| 1966 | * Set the MAC address that is to be used for scanning. |
| 1967 | * |
| 1968 | * Return: Return the Success or Failure code. |
| 1969 | */ |
| 1970 | static int |
| 1971 | __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy, |
| 1972 | struct wireless_dev *wdev, |
| 1973 | const void *data, |
| 1974 | int data_len) |
| 1975 | { |
| 1976 | tpSirScanMacOui pReqMsg = NULL; |
| 1977 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 1978 | 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] | 1979 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1980 | int ret; |
| 1981 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 1982 | ENTER_DEV(wdev->netdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1983 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1984 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1985 | hdd_err("Command not allowed in FTM mode"); |
| 1986 | return -EPERM; |
| 1987 | } |
| 1988 | |
| 1989 | ret = wlan_hdd_validate_context(pHddCtx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1990 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1991 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1992 | |
| 1993 | if (false == pHddCtx->config->enable_mac_spoofing) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 1994 | hdd_warn("MAC address spoofing is not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1995 | return -ENOTSUPP; |
| 1996 | } |
| 1997 | |
| 1998 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX, |
| 1999 | data, data_len, NULL)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2000 | hdd_err("Invalid ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2001 | return -EINVAL; |
| 2002 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2003 | pReqMsg = qdf_mem_malloc(sizeof(*pReqMsg)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2004 | if (!pReqMsg) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2005 | hdd_err("qdf_mem_malloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2006 | return -ENOMEM; |
| 2007 | } |
| 2008 | if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2009 | hdd_err("attr mac oui failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2010 | goto fail; |
| 2011 | } |
| 2012 | nla_memcpy(&pReqMsg->oui[0], |
| 2013 | tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI], |
| 2014 | sizeof(pReqMsg->oui)); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2015 | hdd_notice("Oui (%02x:%02x:%02x)", pReqMsg->oui[0], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2016 | pReqMsg->oui[1], pReqMsg->oui[2]); |
| 2017 | status = sme_set_scanning_mac_oui(pHddCtx->hHal, pReqMsg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2018 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2019 | hdd_err("sme_set_scanning_mac_oui failed(err=%d)", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2020 | goto fail; |
| 2021 | } |
| 2022 | return 0; |
| 2023 | fail: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2024 | qdf_mem_free(pReqMsg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2025 | return -EINVAL; |
| 2026 | } |
| 2027 | |
| 2028 | /** |
| 2029 | * wlan_hdd_cfg80211_set_scanning_mac_oui() - set scan MAC |
| 2030 | * @wiphy: pointer to wireless wiphy structure. |
| 2031 | * @wdev: pointer to wireless_dev structure. |
| 2032 | * @data: Pointer to the data to be passed via vendor interface |
| 2033 | * @data_len:Length of the data to be passed |
| 2034 | * |
| 2035 | * Set the MAC address that is to be used for scanning. This is an |
| 2036 | * SSR-protecting wrapper function. |
| 2037 | * |
| 2038 | * Return: Return the Success or Failure code. |
| 2039 | */ |
| 2040 | static int |
| 2041 | wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy, |
| 2042 | struct wireless_dev *wdev, |
| 2043 | const void *data, |
| 2044 | int data_len) |
| 2045 | { |
| 2046 | int ret; |
| 2047 | |
| 2048 | cds_ssr_protect(__func__); |
| 2049 | ret = __wlan_hdd_cfg80211_set_scanning_mac_oui(wiphy, wdev, |
| 2050 | data, data_len); |
| 2051 | cds_ssr_unprotect(__func__); |
| 2052 | |
| 2053 | return ret; |
| 2054 | } |
| 2055 | |
| 2056 | /** |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 2057 | * __wlan_hdd_cfg80211_get_concurrency_matrix() - to retrieve concurrency matrix |
| 2058 | * @wiphy: pointer phy adapter |
| 2059 | * @wdev: pointer to wireless device structure |
| 2060 | * @data: pointer to data buffer |
| 2061 | * @data_len: length of data |
| 2062 | * |
| 2063 | * This routine will give concurrency matrix |
| 2064 | * |
| 2065 | * Return: int status code |
| 2066 | */ |
| 2067 | static int __wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy, |
| 2068 | struct wireless_dev *wdev, |
| 2069 | const void *data, |
| 2070 | int data_len) |
| 2071 | { |
| 2072 | uint32_t feature_set_matrix[CDS_MAX_FEATURE_SET] = {0}; |
| 2073 | uint8_t i, feature_sets, max_feature_sets; |
| 2074 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1]; |
| 2075 | struct sk_buff *reply_skb; |
| 2076 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 2077 | int ret; |
| 2078 | |
| 2079 | ENTER_DEV(wdev->netdev); |
| 2080 | |
| 2081 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2082 | hdd_err("Command not allowed in FTM mode"); |
| 2083 | return -EPERM; |
| 2084 | } |
| 2085 | |
| 2086 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2087 | if (ret) |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 2088 | return ret; |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 2089 | |
| 2090 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX, |
| 2091 | data, data_len, NULL)) { |
| 2092 | hdd_err("Invalid ATTR"); |
| 2093 | return -EINVAL; |
| 2094 | } |
| 2095 | |
| 2096 | /* Parse and fetch max feature set */ |
| 2097 | if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) { |
| 2098 | hdd_err("Attr max feature set size failed"); |
| 2099 | return -EINVAL; |
| 2100 | } |
| 2101 | max_feature_sets = nla_get_u32(tb[ |
| 2102 | QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]); |
| 2103 | hdd_info("Max feature set size: %d", max_feature_sets); |
| 2104 | |
| 2105 | /* Fill feature combination matrix */ |
| 2106 | feature_sets = 0; |
| 2107 | feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA | |
Srinivas Girigowda | ca42292 | 2016-08-17 18:29:42 -0700 | [diff] [blame] | 2108 | WIFI_FEATURE_P2P; |
| 2109 | feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA | |
| 2110 | WIFI_FEATURE_NAN; |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 2111 | /* Add more feature combinations here */ |
| 2112 | |
| 2113 | feature_sets = QDF_MIN(feature_sets, max_feature_sets); |
Srinivas Girigowda | ca42292 | 2016-08-17 18:29:42 -0700 | [diff] [blame] | 2114 | hdd_info("Number of feature sets: %d", feature_sets); |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 2115 | hdd_info("Feature set matrix"); |
| 2116 | for (i = 0; i < feature_sets; i++) |
| 2117 | hdd_info("[%d] 0x%02X", i, feature_set_matrix[i]); |
| 2118 | |
| 2119 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) + |
| 2120 | sizeof(u32) * feature_sets + NLMSG_HDRLEN); |
| 2121 | if (!reply_skb) { |
| 2122 | hdd_err("Feature set matrix: buffer alloc fail"); |
| 2123 | return -ENOMEM; |
| 2124 | } |
| 2125 | |
| 2126 | if (nla_put_u32(reply_skb, |
| 2127 | QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE, |
| 2128 | feature_sets) || |
| 2129 | nla_put(reply_skb, |
| 2130 | QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET, |
| 2131 | sizeof(u32) * feature_sets, |
| 2132 | feature_set_matrix)) { |
| 2133 | hdd_err("nla put fail"); |
| 2134 | kfree_skb(reply_skb); |
| 2135 | return -EINVAL; |
| 2136 | } |
| 2137 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 2138 | } |
| 2139 | |
| 2140 | /** |
| 2141 | * wlan_hdd_cfg80211_get_concurrency_matrix() - get concurrency matrix |
| 2142 | * @wiphy: pointer to wireless wiphy structure. |
| 2143 | * @wdev: pointer to wireless_dev structure. |
| 2144 | * @data: Pointer to the data to be passed via vendor interface |
| 2145 | * @data_len:Length of the data to be passed |
| 2146 | * |
| 2147 | * Retrieves the concurrency feature set matrix |
| 2148 | * |
| 2149 | * Return: 0 on success, negative errno on failure |
| 2150 | */ |
| 2151 | static int |
| 2152 | wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy, |
| 2153 | struct wireless_dev *wdev, |
| 2154 | const void *data, |
| 2155 | int data_len) |
| 2156 | { |
| 2157 | int ret; |
| 2158 | |
| 2159 | cds_ssr_protect(__func__); |
| 2160 | ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, |
| 2161 | data, data_len); |
| 2162 | cds_ssr_unprotect(__func__); |
| 2163 | |
| 2164 | return ret; |
| 2165 | } |
| 2166 | |
| 2167 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2168 | * wlan_hdd_cfg80211_set_feature() - Set the bitmask for supported features |
| 2169 | * @feature_flags: pointer to the byte array of features. |
| 2170 | * @feature: Feature to be turned ON in the byte array. |
| 2171 | * |
| 2172 | * Return: None |
| 2173 | * |
| 2174 | * This is called to turn ON or SET the feature flag for the requested feature. |
| 2175 | **/ |
| 2176 | #define NUM_BITS_IN_BYTE 8 |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 2177 | static void wlan_hdd_cfg80211_set_feature(uint8_t *feature_flags, |
| 2178 | uint8_t feature) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2179 | { |
| 2180 | uint32_t index; |
| 2181 | uint8_t bit_mask; |
| 2182 | |
| 2183 | index = feature / NUM_BITS_IN_BYTE; |
| 2184 | bit_mask = 1 << (feature % NUM_BITS_IN_BYTE); |
| 2185 | feature_flags[index] |= bit_mask; |
| 2186 | } |
| 2187 | |
| 2188 | /** |
| 2189 | * __wlan_hdd_cfg80211_get_features() - Get the Driver Supported features |
| 2190 | * @wiphy: pointer to wireless wiphy structure. |
| 2191 | * @wdev: pointer to wireless_dev structure. |
| 2192 | * @data: Pointer to the data to be passed via vendor interface |
| 2193 | * @data_len:Length of the data to be passed |
| 2194 | * |
| 2195 | * This is called when wlan driver needs to send supported feature set to |
| 2196 | * supplicant upon a request/query from the supplicant. |
| 2197 | * |
| 2198 | * Return: Return the Success or Failure code. |
| 2199 | **/ |
| 2200 | #define MAX_CONCURRENT_CHAN_ON_24G 2 |
| 2201 | #define MAX_CONCURRENT_CHAN_ON_5G 2 |
| 2202 | static int |
| 2203 | __wlan_hdd_cfg80211_get_features(struct wiphy *wiphy, |
| 2204 | struct wireless_dev *wdev, |
| 2205 | const void *data, int data_len) |
| 2206 | { |
| 2207 | struct sk_buff *skb = NULL; |
| 2208 | uint32_t dbs_capability = 0; |
| 2209 | bool one_by_one_dbs, two_by_two_dbs; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2210 | QDF_STATUS ret = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2211 | int ret_val; |
| 2212 | |
| 2213 | uint8_t feature_flags[(NUM_QCA_WLAN_VENDOR_FEATURES + 7) / 8] = {0}; |
| 2214 | hdd_context_t *hdd_ctx_ptr = wiphy_priv(wiphy); |
| 2215 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 2216 | ENTER_DEV(wdev->netdev); |
| 2217 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2218 | ret_val = wlan_hdd_validate_context(hdd_ctx_ptr); |
| 2219 | if (ret_val) |
| 2220 | return ret_val; |
| 2221 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2222 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2223 | hdd_err("Command not allowed in FTM mode"); |
| 2224 | return -EPERM; |
| 2225 | } |
| 2226 | |
Varun Reddy Yeturu | d351a6c | 2016-03-16 14:01:00 -0700 | [diff] [blame] | 2227 | if (roaming_offload_enabled(hdd_ctx_ptr)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2228 | hdd_notice("Key Mgmt Offload is supported"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2229 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 2230 | QCA_WLAN_VENDOR_FEATURE_KEY_MGMT_OFFLOAD); |
| 2231 | } |
| 2232 | |
| 2233 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 2234 | QCA_WLAN_VENDOR_FEATURE_SUPPORT_HW_MODE_ANY); |
| 2235 | if (wma_is_scan_simultaneous_capable()) |
| 2236 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 2237 | QCA_WLAN_VENDOR_FEATURE_OFFCHANNEL_SIMULTANEOUS); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 2238 | |
| 2239 | if (wma_is_p2p_lo_capable()) |
| 2240 | wlan_hdd_cfg80211_set_feature(feature_flags, |
| 2241 | QCA_WLAN_VENDOR_FEATURE_P2P_LISTEN_OFFLOAD); |
| 2242 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2243 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(feature_flags) + |
| 2244 | NLMSG_HDRLEN); |
| 2245 | |
| 2246 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2247 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2248 | return -ENOMEM; |
| 2249 | } |
| 2250 | |
| 2251 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_FLAGS, |
| 2252 | sizeof(feature_flags), feature_flags)) |
| 2253 | goto nla_put_failure; |
| 2254 | |
| 2255 | ret = wma_get_dbs_hw_modes(&one_by_one_dbs, &two_by_two_dbs); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2256 | if (QDF_STATUS_SUCCESS == ret) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2257 | if (one_by_one_dbs) |
| 2258 | dbs_capability = DRV_DBS_CAPABILITY_1X1; |
| 2259 | |
| 2260 | if (two_by_two_dbs) |
| 2261 | dbs_capability = DRV_DBS_CAPABILITY_2X2; |
| 2262 | |
| 2263 | if (!one_by_one_dbs && !two_by_two_dbs) |
| 2264 | dbs_capability = DRV_DBS_CAPABILITY_DISABLED; |
| 2265 | } else { |
| 2266 | hdd_err("wma_get_dbs_hw_mode failed"); |
| 2267 | dbs_capability = DRV_DBS_CAPABILITY_DISABLED; |
| 2268 | } |
| 2269 | |
| 2270 | hdd_info("dbs_capability is %d", dbs_capability); |
| 2271 | |
| 2272 | if (nla_put_u32(skb, |
| 2273 | QCA_WLAN_VENDOR_ATTR_MAX_CONCURRENT_CHANNELS_2_4_BAND, |
| 2274 | MAX_CONCURRENT_CHAN_ON_24G)) |
| 2275 | goto nla_put_failure; |
| 2276 | |
| 2277 | if (nla_put_u32(skb, |
| 2278 | QCA_WLAN_VENDOR_ATTR_MAX_CONCURRENT_CHANNELS_5_0_BAND, |
| 2279 | MAX_CONCURRENT_CHAN_ON_5G)) |
| 2280 | goto nla_put_failure; |
| 2281 | |
| 2282 | return cfg80211_vendor_cmd_reply(skb); |
| 2283 | |
| 2284 | nla_put_failure: |
| 2285 | kfree_skb(skb); |
| 2286 | return -EINVAL; |
| 2287 | } |
| 2288 | |
| 2289 | /** |
| 2290 | * wlan_hdd_cfg80211_get_features() - Get the Driver Supported features |
| 2291 | * @wiphy: pointer to wireless wiphy structure. |
| 2292 | * @wdev: pointer to wireless_dev structure. |
| 2293 | * @data: Pointer to the data to be passed via vendor interface |
| 2294 | * @data_len:Length of the data to be passed |
| 2295 | * |
| 2296 | * This is called when wlan driver needs to send supported feature set to |
| 2297 | * supplicant upon a request/query from the supplicant. |
| 2298 | * |
| 2299 | * Return: Return the Success or Failure code. |
| 2300 | */ |
| 2301 | static int |
| 2302 | wlan_hdd_cfg80211_get_features(struct wiphy *wiphy, |
| 2303 | struct wireless_dev *wdev, |
| 2304 | const void *data, int data_len) |
| 2305 | { |
| 2306 | int ret; |
| 2307 | |
| 2308 | cds_ssr_protect(__func__); |
| 2309 | ret = __wlan_hdd_cfg80211_get_features(wiphy, wdev, |
| 2310 | data, data_len); |
| 2311 | cds_ssr_unprotect(__func__); |
| 2312 | |
| 2313 | return ret; |
| 2314 | } |
| 2315 | |
| 2316 | |
| 2317 | /** |
| 2318 | * __wlan_hdd_cfg80211_set_ext_roam_params() - Settings for roaming parameters |
| 2319 | * @wiphy: The wiphy structure |
| 2320 | * @wdev: The wireless device |
| 2321 | * @data: Data passed by framework |
| 2322 | * @data_len: Parameters to be configured passed as data |
| 2323 | * |
| 2324 | * The roaming related parameters are configured by the framework |
| 2325 | * using this interface. |
| 2326 | * |
| 2327 | * Return: Return either success or failure code. |
| 2328 | */ |
| 2329 | static int |
| 2330 | __wlan_hdd_cfg80211_set_ext_roam_params(struct wiphy *wiphy, |
| 2331 | struct wireless_dev *wdev, const void *data, int data_len) |
| 2332 | { |
| 2333 | struct net_device *dev = wdev->netdev; |
| 2334 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2335 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2336 | uint8_t session_id; |
| 2337 | struct roam_ext_params roam_params; |
| 2338 | uint32_t cmd_type, req_id; |
| 2339 | struct nlattr *curr_attr; |
| 2340 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX + 1]; |
| 2341 | struct nlattr *tb2[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX + 1]; |
| 2342 | int rem, i; |
| 2343 | uint32_t buf_len = 0; |
| 2344 | int ret; |
| 2345 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 2346 | ENTER_DEV(dev); |
| 2347 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2348 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2349 | hdd_err("Command not allowed in FTM mode"); |
| 2350 | return -EPERM; |
| 2351 | } |
| 2352 | |
| 2353 | ret = wlan_hdd_validate_context(pHddCtx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2354 | if (ret) |
| 2355 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2356 | |
| 2357 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX, |
| 2358 | data, data_len, |
| 2359 | NULL)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2360 | hdd_err("Invalid ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2361 | return -EINVAL; |
| 2362 | } |
| 2363 | /* Parse and fetch Command Type*/ |
| 2364 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2365 | hdd_err("roam cmd type failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2366 | goto fail; |
| 2367 | } |
| 2368 | session_id = pAdapter->sessionId; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2369 | qdf_mem_set(&roam_params, sizeof(roam_params), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2370 | cmd_type = nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD]); |
| 2371 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2372 | hdd_err("attr request id failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2373 | goto fail; |
| 2374 | } |
| 2375 | req_id = nla_get_u32( |
| 2376 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2377 | hdd_debug("Req Id (%d)", req_id); |
| 2378 | hdd_debug("Cmd Type (%d)", cmd_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2379 | switch (cmd_type) { |
| 2380 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SSID_WHITE_LIST: |
| 2381 | i = 0; |
| 2382 | nla_for_each_nested(curr_attr, |
| 2383 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID_LIST], |
| 2384 | rem) { |
| 2385 | if (nla_parse(tb2, |
| 2386 | QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_MAX, |
| 2387 | nla_data(curr_attr), nla_len(curr_attr), |
| 2388 | NULL)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2389 | hdd_err("nla_parse failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2390 | goto fail; |
| 2391 | } |
| 2392 | /* Parse and Fetch allowed SSID list*/ |
| 2393 | if (!tb2[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2394 | hdd_err("attr allowed ssid failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2395 | goto fail; |
| 2396 | } |
| 2397 | buf_len = nla_len(tb2[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID]); |
| 2398 | /* |
| 2399 | * Upper Layers include a null termination character. |
| 2400 | * Check for the actual permissible length of SSID and |
| 2401 | * also ensure not to copy the NULL termination |
| 2402 | * character to the driver buffer. |
| 2403 | */ |
| 2404 | if (buf_len && (i < MAX_SSID_ALLOWED_LIST) && |
| 2405 | ((buf_len - 1) <= SIR_MAC_MAX_SSID_LENGTH)) { |
| 2406 | nla_memcpy( |
| 2407 | roam_params.ssid_allowed_list[i].ssId, |
| 2408 | tb2[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID], |
| 2409 | buf_len - 1); |
| 2410 | roam_params.ssid_allowed_list[i].length = |
| 2411 | buf_len - 1; |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2412 | hdd_debug("SSID[%d]: %.*s,length = %d", i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2413 | roam_params.ssid_allowed_list[i].length, |
| 2414 | roam_params.ssid_allowed_list[i].ssId, |
| 2415 | roam_params.ssid_allowed_list[i].length); |
| 2416 | i++; |
| 2417 | } else { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2418 | hdd_err("Invalid buffer length"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2419 | } |
| 2420 | } |
| 2421 | roam_params.num_ssid_allowed_list = i; |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2422 | hdd_debug("Num of Allowed SSID %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2423 | roam_params.num_ssid_allowed_list); |
| 2424 | sme_update_roam_params(pHddCtx->hHal, session_id, |
| 2425 | roam_params, REASON_ROAM_SET_SSID_ALLOWED); |
| 2426 | break; |
| 2427 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_EXTSCAN_ROAM_PARAMS: |
| 2428 | /* Parse and fetch 5G Boost Threshold */ |
| 2429 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_THRESHOLD]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2430 | hdd_err("5G boost threshold failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2431 | goto fail; |
| 2432 | } |
| 2433 | roam_params.raise_rssi_thresh_5g = nla_get_s32( |
| 2434 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_THRESHOLD]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2435 | hdd_debug("5G Boost Threshold (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2436 | roam_params.raise_rssi_thresh_5g); |
| 2437 | /* Parse and fetch 5G Penalty Threshold */ |
| 2438 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_THRESHOLD]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2439 | hdd_err("5G penalty threshold failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2440 | goto fail; |
| 2441 | } |
| 2442 | roam_params.drop_rssi_thresh_5g = nla_get_s32( |
| 2443 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_THRESHOLD]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2444 | hdd_debug("5G Penalty Threshold (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2445 | roam_params.drop_rssi_thresh_5g); |
| 2446 | /* Parse and fetch 5G Boost Factor */ |
| 2447 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_FACTOR]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2448 | hdd_err("5G boost Factor failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2449 | goto fail; |
| 2450 | } |
| 2451 | roam_params.raise_factor_5g = nla_get_u32( |
| 2452 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_FACTOR]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2453 | hdd_debug("5G Boost Factor (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2454 | roam_params.raise_factor_5g); |
| 2455 | /* Parse and fetch 5G Penalty factor */ |
| 2456 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_FACTOR]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2457 | hdd_err("5G Penalty Factor failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2458 | goto fail; |
| 2459 | } |
| 2460 | roam_params.drop_factor_5g = nla_get_u32( |
| 2461 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_FACTOR]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2462 | hdd_debug("5G Penalty factor (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2463 | roam_params.drop_factor_5g); |
| 2464 | /* Parse and fetch 5G Max Boost */ |
| 2465 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_MAX_BOOST]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2466 | hdd_err("5G Max Boost failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2467 | goto fail; |
| 2468 | } |
| 2469 | roam_params.max_raise_rssi_5g = nla_get_u32( |
| 2470 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_MAX_BOOST]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2471 | hdd_debug("5G Max Boost (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2472 | roam_params.max_raise_rssi_5g); |
| 2473 | /* Parse and fetch Rssi Diff */ |
| 2474 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_LAZY_ROAM_HISTERESYS]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2475 | hdd_err("Rssi Diff failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2476 | goto fail; |
| 2477 | } |
| 2478 | roam_params.rssi_diff = nla_get_s32( |
| 2479 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_LAZY_ROAM_HISTERESYS]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2480 | hdd_debug("RSSI Diff (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2481 | roam_params.rssi_diff); |
| 2482 | /* Parse and fetch Alert Rssi Threshold */ |
| 2483 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_ALERT_ROAM_RSSI_TRIGGER]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2484 | hdd_err("Alert Rssi Threshold failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2485 | goto fail; |
| 2486 | } |
| 2487 | roam_params.alert_rssi_threshold = nla_get_u32( |
| 2488 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_ALERT_ROAM_RSSI_TRIGGER]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2489 | hdd_debug("Alert RSSI Threshold (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2490 | roam_params.alert_rssi_threshold); |
| 2491 | sme_update_roam_params(pHddCtx->hHal, session_id, |
| 2492 | roam_params, |
| 2493 | REASON_ROAM_EXT_SCAN_PARAMS_CHANGED); |
| 2494 | break; |
| 2495 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_LAZY_ROAM: |
| 2496 | /* Parse and fetch Activate Good Rssi Roam */ |
| 2497 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_ENABLE]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2498 | hdd_err("Activate Good Rssi Roam failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2499 | goto fail; |
| 2500 | } |
| 2501 | roam_params.good_rssi_roam = nla_get_s32( |
| 2502 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_ENABLE]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2503 | hdd_debug("Activate Good Rssi Roam (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2504 | roam_params.good_rssi_roam); |
| 2505 | sme_update_roam_params(pHddCtx->hHal, session_id, |
| 2506 | roam_params, REASON_ROAM_GOOD_RSSI_CHANGED); |
| 2507 | break; |
| 2508 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_BSSID_PREFS: |
| 2509 | /* Parse and fetch number of preferred BSSID */ |
| 2510 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_NUM_BSSID]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2511 | hdd_err("attr num of preferred bssid failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2512 | goto fail; |
| 2513 | } |
| 2514 | roam_params.num_bssid_favored = nla_get_u32( |
| 2515 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_NUM_BSSID]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2516 | hdd_debug("Num of Preferred BSSID (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2517 | roam_params.num_bssid_favored); |
| 2518 | i = 0; |
| 2519 | nla_for_each_nested(curr_attr, |
| 2520 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS], |
| 2521 | rem) { |
| 2522 | if (nla_parse(tb2, |
| 2523 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX, |
| 2524 | nla_data(curr_attr), nla_len(curr_attr), |
| 2525 | NULL)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2526 | hdd_err("nla_parse failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2527 | goto fail; |
| 2528 | } |
| 2529 | /* Parse and fetch MAC address */ |
| 2530 | if (!tb2[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_BSSID]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2531 | hdd_err("attr mac address failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2532 | goto fail; |
| 2533 | } |
Srinivas Girigowda | b053239 | 2015-11-24 11:50:16 -0800 | [diff] [blame] | 2534 | nla_memcpy(roam_params.bssid_favored[i].bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2535 | tb2[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_BSSID], |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2536 | QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | b053239 | 2015-11-24 11:50:16 -0800 | [diff] [blame] | 2537 | hdd_debug(MAC_ADDRESS_STR, |
| 2538 | MAC_ADDR_ARRAY(roam_params.bssid_favored[i].bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2539 | /* Parse and fetch preference factor*/ |
| 2540 | if (!tb2[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_RSSI_MODIFIER]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2541 | hdd_err("BSSID Preference score failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2542 | goto fail; |
| 2543 | } |
| 2544 | roam_params.bssid_favored_factor[i] = nla_get_u32( |
| 2545 | tb2[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_RSSI_MODIFIER]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2546 | hdd_debug("BSSID Preference score (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2547 | roam_params.bssid_favored_factor[i]); |
| 2548 | i++; |
| 2549 | } |
| 2550 | sme_update_roam_params(pHddCtx->hHal, session_id, |
| 2551 | roam_params, REASON_ROAM_SET_FAVORED_BSSID); |
| 2552 | break; |
| 2553 | case QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_BLACKLIST_BSSID: |
| 2554 | /* Parse and fetch number of blacklist BSSID */ |
| 2555 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_NUM_BSSID]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2556 | hdd_err("attr num of blacklist bssid failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2557 | goto fail; |
| 2558 | } |
| 2559 | roam_params.num_bssid_avoid_list = nla_get_u32( |
| 2560 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_NUM_BSSID]); |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2561 | hdd_debug("Num of blacklist BSSID (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2562 | roam_params.num_bssid_avoid_list); |
| 2563 | i = 0; |
| 2564 | nla_for_each_nested(curr_attr, |
| 2565 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS], |
| 2566 | rem) { |
| 2567 | if (nla_parse(tb2, |
| 2568 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX, |
| 2569 | nla_data(curr_attr), nla_len(curr_attr), |
| 2570 | NULL)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2571 | hdd_err("nla_parse failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2572 | goto fail; |
| 2573 | } |
| 2574 | /* Parse and fetch MAC address */ |
| 2575 | if (!tb2[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_BSSID]) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2576 | hdd_err("attr blacklist addr failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2577 | goto fail; |
| 2578 | } |
Srinivas Girigowda | b053239 | 2015-11-24 11:50:16 -0800 | [diff] [blame] | 2579 | nla_memcpy(roam_params.bssid_avoid_list[i].bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2580 | tb2[QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_BSSID], |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2581 | QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | b053239 | 2015-11-24 11:50:16 -0800 | [diff] [blame] | 2582 | hdd_debug(MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2583 | MAC_ADDR_ARRAY( |
Srinivas Girigowda | b053239 | 2015-11-24 11:50:16 -0800 | [diff] [blame] | 2584 | roam_params.bssid_avoid_list[i].bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2585 | i++; |
| 2586 | } |
| 2587 | sme_update_roam_params(pHddCtx->hHal, session_id, |
| 2588 | roam_params, REASON_ROAM_SET_BLACKLIST_BSSID); |
| 2589 | break; |
| 2590 | } |
| 2591 | return 0; |
| 2592 | fail: |
| 2593 | return -EINVAL; |
| 2594 | } |
| 2595 | |
| 2596 | /** |
| 2597 | * wlan_hdd_cfg80211_set_ext_roam_params() - set ext scan roam params |
| 2598 | * @wiphy: pointer to wireless wiphy structure. |
| 2599 | * @wdev: pointer to wireless_dev structure. |
| 2600 | * @data: Pointer to the data to be passed via vendor interface |
| 2601 | * @data_len:Length of the data to be passed |
| 2602 | * |
| 2603 | * Return: Return the Success or Failure code. |
| 2604 | */ |
| 2605 | static int |
| 2606 | wlan_hdd_cfg80211_set_ext_roam_params(struct wiphy *wiphy, |
| 2607 | struct wireless_dev *wdev, |
| 2608 | const void *data, |
| 2609 | int data_len) |
| 2610 | { |
| 2611 | int ret; |
| 2612 | |
| 2613 | cds_ssr_protect(__func__); |
| 2614 | ret = __wlan_hdd_cfg80211_set_ext_roam_params(wiphy, wdev, |
| 2615 | data, data_len); |
| 2616 | cds_ssr_unprotect(__func__); |
| 2617 | |
| 2618 | return ret; |
| 2619 | } |
| 2620 | |
| 2621 | static const struct nla_policy |
| 2622 | wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX |
| 2623 | +1] = { |
| 2624 | [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 }, |
| 2625 | }; |
| 2626 | |
| 2627 | /** |
| 2628 | * wlan_hdd_check_dfs_channel_for_adapter() - check dfs channel in adapter |
| 2629 | * @hdd_ctx: HDD context |
| 2630 | * @device_mode: device mode |
| 2631 | * Return: bool |
| 2632 | */ |
| 2633 | static bool wlan_hdd_check_dfs_channel_for_adapter(hdd_context_t *hdd_ctx, |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 2634 | enum tQDF_ADAPTER_MODE device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2635 | { |
| 2636 | hdd_adapter_t *adapter; |
| 2637 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 2638 | hdd_ap_ctx_t *ap_ctx; |
| 2639 | hdd_station_ctx_t *sta_ctx; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2640 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2641 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2642 | qdf_status = hdd_get_front_adapter(hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2643 | &adapter_node); |
| 2644 | |
| 2645 | while ((NULL != adapter_node) && |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2646 | (QDF_STATUS_SUCCESS == qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2647 | adapter = adapter_node->pAdapter; |
| 2648 | |
| 2649 | if ((device_mode == adapter->device_mode) && |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 2650 | (device_mode == QDF_SAP_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2651 | ap_ctx = |
| 2652 | WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2653 | |
| 2654 | /* |
| 2655 | * if there is SAP already running on DFS channel, |
| 2656 | * do not disable scan on dfs channels. Note that |
| 2657 | * with SAP on DFS, there cannot be conurrency on |
| 2658 | * single radio. But then we can have multiple |
| 2659 | * radios !! |
| 2660 | */ |
| 2661 | if (CHANNEL_STATE_DFS == |
| 2662 | cds_get_channel_state( |
| 2663 | ap_ctx->operatingChannel)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2664 | hdd_err("SAP running on DFS channel"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2665 | return true; |
| 2666 | } |
| 2667 | } |
| 2668 | |
| 2669 | if ((device_mode == adapter->device_mode) && |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 2670 | (device_mode == QDF_STA_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2671 | sta_ctx = |
| 2672 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 2673 | |
| 2674 | /* |
| 2675 | * if STA is already connected on DFS channel, |
| 2676 | * do not disable scan on dfs channels |
| 2677 | */ |
| 2678 | if (hdd_conn_is_connected(sta_ctx) && |
| 2679 | (CHANNEL_STATE_DFS == |
| 2680 | cds_get_channel_state( |
| 2681 | sta_ctx->conn_info.operationChannel))) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2682 | hdd_err("client connected on DFS channel"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2683 | return true; |
| 2684 | } |
| 2685 | } |
| 2686 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2687 | qdf_status = hdd_get_next_adapter(hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2688 | adapter_node, |
| 2689 | &next); |
| 2690 | adapter_node = next; |
| 2691 | } |
| 2692 | |
| 2693 | return false; |
| 2694 | } |
| 2695 | |
| 2696 | /** |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 2697 | * wlan_hdd_disable_dfs_chan_scan() - disable/enable DFS channels |
| 2698 | * @hdd_ctx: HDD context within host driver |
| 2699 | * @adapter: Adapter pointer |
| 2700 | * @no_dfs_flag: If TRUE, DFS channels cannot be used for scanning |
| 2701 | * |
| 2702 | * Loops through devices to see who is operating on DFS channels |
| 2703 | * and then disables/enables DFS channels by calling SME API. |
| 2704 | * Fails the disable request if any device is active on a DFS channel. |
| 2705 | * |
| 2706 | * Return: 0 or other error codes. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2707 | */ |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 2708 | |
| 2709 | int wlan_hdd_disable_dfs_chan_scan(hdd_context_t *hdd_ctx, |
| 2710 | hdd_adapter_t *adapter, |
| 2711 | uint32_t no_dfs_flag) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2712 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2713 | tHalHandle h_hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2714 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2715 | int ret_val = -EPERM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2716 | |
| 2717 | if (no_dfs_flag == hdd_ctx->config->enableDFSChnlScan) { |
| 2718 | if (no_dfs_flag) { |
| 2719 | status = wlan_hdd_check_dfs_channel_for_adapter( |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 2720 | hdd_ctx, QDF_STA_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2721 | |
| 2722 | if (true == status) |
| 2723 | return -EOPNOTSUPP; |
| 2724 | |
| 2725 | status = wlan_hdd_check_dfs_channel_for_adapter( |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 2726 | hdd_ctx, QDF_SAP_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2727 | |
| 2728 | if (true == status) |
| 2729 | return -EOPNOTSUPP; |
| 2730 | } |
| 2731 | |
| 2732 | hdd_ctx->config->enableDFSChnlScan = !no_dfs_flag; |
| 2733 | |
| 2734 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 2735 | |
| 2736 | /* |
| 2737 | * call the SME API to tunnel down the new channel list |
| 2738 | * to the firmware |
| 2739 | */ |
| 2740 | status = sme_handle_dfs_chan_scan( |
| 2741 | h_hal, hdd_ctx->config->enableDFSChnlScan); |
| 2742 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2743 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2744 | ret_val = 0; |
| 2745 | |
| 2746 | /* |
| 2747 | * Clear the SME scan cache also. Note that the |
| 2748 | * clearing of scan results is independent of session; |
| 2749 | * so no need to iterate over |
| 2750 | * all sessions |
| 2751 | */ |
| 2752 | status = sme_scan_flush_result(h_hal); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2753 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2754 | ret_val = -EPERM; |
| 2755 | } |
| 2756 | |
| 2757 | } else { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2758 | hdd_notice(" the DFS flag has not changed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2759 | ret_val = 0; |
| 2760 | } |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 2761 | return ret_val; |
| 2762 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2763 | |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 2764 | /** |
| 2765 | * __wlan_hdd_cfg80211_disable_dfs_chan_scan() - DFS channel configuration |
| 2766 | * @wiphy: corestack handler |
| 2767 | * @wdev: wireless device |
| 2768 | * @data: data |
| 2769 | * @data_len: data length |
| 2770 | * Return: success(0) or reason code for failure |
| 2771 | */ |
| 2772 | static int __wlan_hdd_cfg80211_disable_dfs_chan_scan(struct wiphy *wiphy, |
| 2773 | struct wireless_dev *wdev, |
| 2774 | const void *data, |
| 2775 | int data_len) |
| 2776 | { |
| 2777 | struct net_device *dev = wdev->netdev; |
| 2778 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2779 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 2780 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1]; |
| 2781 | int ret_val; |
| 2782 | uint32_t no_dfs_flag = 0; |
| 2783 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 2784 | ENTER_DEV(dev); |
| 2785 | |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 2786 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2787 | if (ret_val) |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 2788 | return ret_val; |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 2789 | |
| 2790 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX, |
| 2791 | data, data_len, |
| 2792 | wlan_hdd_set_no_dfs_flag_config_policy)) { |
| 2793 | hdd_err("invalid attr"); |
| 2794 | return -EINVAL; |
| 2795 | } |
| 2796 | |
| 2797 | if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) { |
| 2798 | hdd_err("attr dfs flag failed"); |
| 2799 | return -EINVAL; |
| 2800 | } |
| 2801 | |
| 2802 | no_dfs_flag = nla_get_u32( |
| 2803 | tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]); |
| 2804 | |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2805 | hdd_notice(" DFS flag = %d", no_dfs_flag); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 2806 | |
| 2807 | if (no_dfs_flag > 1) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 2808 | hdd_err("invalid value of dfs flag"); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 2809 | return -EINVAL; |
| 2810 | } |
| 2811 | |
| 2812 | ret_val = wlan_hdd_disable_dfs_chan_scan(hdd_ctx, adapter, |
| 2813 | no_dfs_flag); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2814 | return ret_val; |
| 2815 | } |
| 2816 | |
| 2817 | /** |
| 2818 | * wlan_hdd_cfg80211_disable_dfs_chan_scan () - DFS scan vendor command |
| 2819 | * |
| 2820 | * @wiphy: wiphy device pointer |
| 2821 | * @wdev: wireless device pointer |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 2822 | * @data: Vendor command data buffer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2823 | * @data_len: Buffer length |
| 2824 | * |
| 2825 | * Handles QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX. Validate it and |
| 2826 | * call wlan_hdd_disable_dfs_chan_scan to send it to firmware. |
| 2827 | * |
| 2828 | * Return: EOK or other error codes. |
| 2829 | */ |
| 2830 | |
| 2831 | static int wlan_hdd_cfg80211_disable_dfs_chan_scan(struct wiphy *wiphy, |
| 2832 | struct wireless_dev *wdev, |
| 2833 | const void *data, |
| 2834 | int data_len) |
| 2835 | { |
| 2836 | int ret; |
| 2837 | |
| 2838 | cds_ssr_protect(__func__); |
| 2839 | ret = __wlan_hdd_cfg80211_disable_dfs_chan_scan(wiphy, wdev, |
| 2840 | data, data_len); |
| 2841 | cds_ssr_unprotect(__func__); |
| 2842 | |
| 2843 | return ret; |
| 2844 | } |
| 2845 | |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 2846 | static const struct nla_policy |
| 2847 | wlan_hdd_wisa_cmd_policy[QCA_WLAN_VENDOR_ATTR_WISA_MAX + 1] = { |
| 2848 | [QCA_WLAN_VENDOR_ATTR_WISA_MODE] = {.type = NLA_U32 }, |
| 2849 | }; |
| 2850 | |
| 2851 | /** |
| 2852 | * __wlan_hdd_cfg80211_handle_wisa_cmd() - Handle WISA vendor cmd |
| 2853 | * @wiphy: wiphy device pointer |
| 2854 | * @wdev: wireless device pointer |
| 2855 | * @data: Vendor command data buffer |
| 2856 | * @data_len: Buffer length |
| 2857 | * |
| 2858 | * Handles QCA_WLAN_VENDOR_SUBCMD_WISA. Validate cmd attributes and |
| 2859 | * setup WISA Mode features. |
| 2860 | * |
| 2861 | * Return: Success(0) or reason code for failure |
| 2862 | */ |
| 2863 | static int __wlan_hdd_cfg80211_handle_wisa_cmd(struct wiphy *wiphy, |
| 2864 | struct wireless_dev *wdev, const void *data, int data_len) |
| 2865 | { |
| 2866 | struct net_device *dev = wdev->netdev; |
| 2867 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2868 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 2869 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WISA_MAX + 1]; |
| 2870 | struct sir_wisa_params wisa; |
| 2871 | int ret_val; |
| 2872 | QDF_STATUS status; |
| 2873 | bool wisa_mode; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 2874 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 2875 | void *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 2876 | |
| 2877 | ENTER_DEV(dev); |
| 2878 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 2879 | if (ret_val) |
| 2880 | goto err; |
| 2881 | |
| 2882 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2883 | hdd_err("Command not allowed in FTM mode"); |
| 2884 | return -EPERM; |
| 2885 | } |
| 2886 | |
| 2887 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WISA_MAX, data, data_len, |
| 2888 | wlan_hdd_wisa_cmd_policy)) { |
| 2889 | hdd_err("Invalid WISA cmd attributes"); |
| 2890 | ret_val = -EINVAL; |
| 2891 | goto err; |
| 2892 | } |
| 2893 | if (!tb[QCA_WLAN_VENDOR_ATTR_WISA_MODE]) { |
| 2894 | hdd_err("Invalid WISA mode"); |
| 2895 | ret_val = -EINVAL; |
| 2896 | goto err; |
| 2897 | } |
| 2898 | |
| 2899 | wisa_mode = !!nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_WISA_MODE]); |
| 2900 | hdd_info("WISA Mode: %d", wisa_mode); |
| 2901 | wisa.mode = wisa_mode; |
| 2902 | wisa.vdev_id = adapter->sessionId; |
| 2903 | status = sme_set_wisa_params(hdd_ctx->hHal, &wisa); |
Manikandan Mohan | b6315dd | 2016-05-10 16:16:36 -0700 | [diff] [blame] | 2904 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 2905 | hdd_err("Unable to set WISA mode: %d to FW", wisa_mode); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 2906 | ret_val = -EINVAL; |
Manikandan Mohan | b6315dd | 2016-05-10 16:16:36 -0700 | [diff] [blame] | 2907 | } |
| 2908 | if (QDF_IS_STATUS_SUCCESS(status) || wisa_mode == false) |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 2909 | cdp_set_wisa_mode(soc, |
| 2910 | cdp_get_vdev_from_vdev_id(soc, pdev, |
| 2911 | adapter->sessionId), |
| 2912 | wisa_mode); |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 2913 | err: |
| 2914 | EXIT(); |
| 2915 | return ret_val; |
| 2916 | } |
| 2917 | |
| 2918 | /** |
| 2919 | * wlan_hdd_cfg80211_handle_wisa_cmd() - Handle WISA vendor cmd |
| 2920 | * @wiphy: corestack handler |
| 2921 | * @wdev: wireless device |
| 2922 | * @data: data |
| 2923 | * @data_len: data length |
| 2924 | * |
| 2925 | * Handles QCA_WLAN_VENDOR_SUBCMD_WISA. Validate cmd attributes and |
| 2926 | * setup WISA mode features. |
| 2927 | * |
| 2928 | * Return: Success(0) or reason code for failure |
| 2929 | */ |
| 2930 | static int wlan_hdd_cfg80211_handle_wisa_cmd(struct wiphy *wiphy, |
| 2931 | struct wireless_dev *wdev, |
| 2932 | const void *data, |
| 2933 | int data_len) |
| 2934 | { |
| 2935 | int ret; |
| 2936 | |
| 2937 | cds_ssr_protect(__func__); |
| 2938 | ret = __wlan_hdd_cfg80211_handle_wisa_cmd(wiphy, wdev, data, data_len); |
| 2939 | cds_ssr_unprotect(__func__); |
| 2940 | |
| 2941 | return ret; |
| 2942 | } |
| 2943 | |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 2944 | /* |
| 2945 | * define short names for the global vendor params |
| 2946 | * used by __wlan_hdd_cfg80211_get_station_cmd() |
| 2947 | */ |
| 2948 | #define STATION_INVALID \ |
| 2949 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INVALID |
| 2950 | #define STATION_INFO \ |
| 2951 | QCA_WLAN_VENDOR_ATTR_GET_STATION_INFO |
| 2952 | #define STATION_ASSOC_FAIL_REASON \ |
| 2953 | QCA_WLAN_VENDOR_ATTR_GET_STATION_ASSOC_FAIL_REASON |
| 2954 | #define STATION_MAX \ |
| 2955 | QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX |
| 2956 | |
| 2957 | static const struct nla_policy |
| 2958 | hdd_get_station_policy[STATION_MAX + 1] = { |
| 2959 | [STATION_INFO] = {.type = NLA_FLAG}, |
| 2960 | [STATION_ASSOC_FAIL_REASON] = {.type = NLA_FLAG}, |
| 2961 | }; |
| 2962 | |
| 2963 | /** |
| 2964 | * hdd_get_station_assoc_fail() - Handle get station assoc fail |
| 2965 | * @hdd_ctx: HDD context within host driver |
| 2966 | * @wdev: wireless device |
| 2967 | * |
| 2968 | * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION_ASSOC_FAIL. |
| 2969 | * Validate cmd attributes and send the station info to upper layers. |
| 2970 | * |
| 2971 | * Return: Success(0) or reason code for failure |
| 2972 | */ |
| 2973 | static int hdd_get_station_assoc_fail(hdd_context_t *hdd_ctx, |
| 2974 | hdd_adapter_t *adapter) |
| 2975 | { |
| 2976 | struct sk_buff *skb = NULL; |
| 2977 | uint32_t nl_buf_len; |
| 2978 | hdd_station_ctx_t *hdd_sta_ctx; |
| 2979 | |
| 2980 | nl_buf_len = NLMSG_HDRLEN; |
| 2981 | nl_buf_len += sizeof(uint32_t); |
| 2982 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 2983 | |
| 2984 | if (!skb) { |
| 2985 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
| 2986 | return -ENOMEM; |
| 2987 | } |
| 2988 | |
| 2989 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 2990 | |
| 2991 | if (nla_put_u32(skb, INFO_ASSOC_FAIL_REASON, |
| 2992 | hdd_sta_ctx->conn_info.assoc_status_code)) { |
| 2993 | hdd_err("put fail"); |
| 2994 | goto fail; |
| 2995 | } |
| 2996 | return cfg80211_vendor_cmd_reply(skb); |
| 2997 | fail: |
| 2998 | if (skb) |
| 2999 | kfree_skb(skb); |
| 3000 | return -EINVAL; |
| 3001 | } |
| 3002 | |
| 3003 | /** |
| 3004 | * hdd_map_auth_type() - transform auth type specific to |
| 3005 | * vendor command |
| 3006 | * @auth_type: csr auth type |
| 3007 | * |
| 3008 | * Return: Success(0) or reason code for failure |
| 3009 | */ |
| 3010 | static int hdd_convert_auth_type(uint32_t auth_type) |
| 3011 | { |
| 3012 | uint32_t ret_val; |
| 3013 | |
| 3014 | switch (auth_type) { |
| 3015 | case eCSR_AUTH_TYPE_OPEN_SYSTEM: |
| 3016 | ret_val = QCA_WLAN_AUTH_TYPE_OPEN; |
| 3017 | break; |
| 3018 | case eCSR_AUTH_TYPE_SHARED_KEY: |
| 3019 | ret_val = QCA_WLAN_AUTH_TYPE_SHARED; |
| 3020 | break; |
| 3021 | case eCSR_AUTH_TYPE_WPA: |
| 3022 | ret_val = QCA_WLAN_AUTH_TYPE_WPA; |
| 3023 | break; |
| 3024 | case eCSR_AUTH_TYPE_WPA_PSK: |
| 3025 | ret_val = QCA_WLAN_AUTH_TYPE_WPA_PSK; |
| 3026 | break; |
| 3027 | case eCSR_AUTH_TYPE_AUTOSWITCH: |
| 3028 | ret_val = QCA_WLAN_AUTH_TYPE_AUTOSWITCH; |
| 3029 | break; |
| 3030 | case eCSR_AUTH_TYPE_WPA_NONE: |
| 3031 | ret_val = QCA_WLAN_AUTH_TYPE_WPA_NONE; |
| 3032 | break; |
| 3033 | case eCSR_AUTH_TYPE_RSN: |
| 3034 | ret_val = QCA_WLAN_AUTH_TYPE_RSN; |
| 3035 | break; |
| 3036 | case eCSR_AUTH_TYPE_RSN_PSK: |
| 3037 | ret_val = QCA_WLAN_AUTH_TYPE_RSN_PSK; |
| 3038 | break; |
| 3039 | case eCSR_AUTH_TYPE_FT_RSN: |
| 3040 | ret_val = QCA_WLAN_AUTH_TYPE_FT; |
| 3041 | break; |
| 3042 | case eCSR_AUTH_TYPE_FT_RSN_PSK: |
| 3043 | ret_val = QCA_WLAN_AUTH_TYPE_FT_PSK; |
| 3044 | break; |
| 3045 | case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE: |
| 3046 | ret_val = QCA_WLAN_AUTH_TYPE_WAI; |
| 3047 | break; |
| 3048 | case eCSR_AUTH_TYPE_WAPI_WAI_PSK: |
| 3049 | ret_val = QCA_WLAN_AUTH_TYPE_WAI_PSK; |
| 3050 | break; |
| 3051 | case eCSR_AUTH_TYPE_CCKM_WPA: |
| 3052 | ret_val = QCA_WLAN_AUTH_TYPE_CCKM_WPA; |
| 3053 | break; |
| 3054 | case eCSR_AUTH_TYPE_CCKM_RSN: |
| 3055 | ret_val = QCA_WLAN_AUTH_TYPE_CCKM_RSN; |
| 3056 | break; |
| 3057 | case eCSR_AUTH_TYPE_RSN_PSK_SHA256: |
| 3058 | ret_val = QCA_WLAN_AUTH_TYPE_SHA256_PSK; |
| 3059 | break; |
| 3060 | case eCSR_AUTH_TYPE_RSN_8021X_SHA256: |
| 3061 | ret_val = QCA_WLAN_AUTH_TYPE_SHA256; |
| 3062 | break; |
| 3063 | case eCSR_NUM_OF_SUPPORT_AUTH_TYPE: |
| 3064 | case eCSR_AUTH_TYPE_FAILED: |
| 3065 | case eCSR_AUTH_TYPE_NONE: |
| 3066 | default: |
| 3067 | ret_val = QCA_WLAN_AUTH_TYPE_INVALID; |
| 3068 | break; |
| 3069 | } |
| 3070 | return ret_val; |
| 3071 | } |
| 3072 | |
| 3073 | /** |
| 3074 | * hdd_map_dot_11_mode() - transform dot11mode type specific to |
| 3075 | * vendor command |
| 3076 | * @dot11mode: dot11mode |
| 3077 | * |
| 3078 | * Return: Success(0) or reason code for failure |
| 3079 | */ |
| 3080 | static int hdd_convert_dot11mode(uint32_t dot11mode) |
| 3081 | { |
| 3082 | uint32_t ret_val; |
| 3083 | |
| 3084 | switch (dot11mode) { |
| 3085 | case eCSR_CFG_DOT11_MODE_11A: |
| 3086 | ret_val = QCA_WLAN_802_11_MODE_11A; |
| 3087 | break; |
| 3088 | case eCSR_CFG_DOT11_MODE_11B: |
| 3089 | ret_val = QCA_WLAN_802_11_MODE_11B; |
| 3090 | break; |
| 3091 | case eCSR_CFG_DOT11_MODE_11G: |
| 3092 | ret_val = QCA_WLAN_802_11_MODE_11G; |
| 3093 | break; |
| 3094 | case eCSR_CFG_DOT11_MODE_11N: |
| 3095 | ret_val = QCA_WLAN_802_11_MODE_11N; |
| 3096 | break; |
| 3097 | case eCSR_CFG_DOT11_MODE_11AC: |
| 3098 | ret_val = QCA_WLAN_802_11_MODE_11AC; |
| 3099 | break; |
| 3100 | case eCSR_CFG_DOT11_MODE_AUTO: |
| 3101 | case eCSR_CFG_DOT11_MODE_ABG: |
| 3102 | default: |
| 3103 | ret_val = QCA_WLAN_802_11_MODE_INVALID; |
| 3104 | } |
| 3105 | return ret_val; |
| 3106 | } |
| 3107 | |
| 3108 | /** |
| 3109 | * hdd_add_tx_bitrate() - add tx bitrate attribute |
| 3110 | * @skb: pointer to sk buff |
| 3111 | * @hdd_sta_ctx: pointer to hdd station context |
| 3112 | * @idx: attribute index |
| 3113 | * |
| 3114 | * Return: Success(0) or reason code for failure |
| 3115 | */ |
| 3116 | static int32_t hdd_add_tx_bitrate(struct sk_buff *skb, |
| 3117 | hdd_station_ctx_t *hdd_sta_ctx, |
| 3118 | int idx) |
| 3119 | { |
| 3120 | struct nlattr *nla_attr; |
| 3121 | uint32_t bitrate, bitrate_compat; |
| 3122 | |
| 3123 | nla_attr = nla_nest_start(skb, idx); |
| 3124 | if (!nla_attr) |
| 3125 | goto fail; |
| 3126 | /* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */ |
| 3127 | bitrate = cfg80211_calculate_bitrate(&hdd_sta_ctx->conn_info.txrate); |
| 3128 | |
| 3129 | /* report 16-bit bitrate only if we can */ |
| 3130 | bitrate_compat = bitrate < (1UL << 16) ? bitrate : 0; |
| 3131 | if (bitrate > 0 && |
| 3132 | nla_put_u32(skb, NL80211_RATE_INFO_BITRATE32, bitrate)) { |
| 3133 | hdd_err("put fail"); |
| 3134 | goto fail; |
| 3135 | } |
| 3136 | if (bitrate_compat > 0 && |
| 3137 | nla_put_u16(skb, NL80211_RATE_INFO_BITRATE, bitrate_compat)) { |
| 3138 | hdd_err("put fail"); |
| 3139 | goto fail; |
| 3140 | } |
| 3141 | if (nla_put_u8(skb, NL80211_RATE_INFO_VHT_NSS, |
| 3142 | hdd_sta_ctx->conn_info.txrate.nss)) { |
| 3143 | hdd_err("put fail"); |
| 3144 | goto fail; |
| 3145 | } |
| 3146 | nla_nest_end(skb, nla_attr); |
| 3147 | return 0; |
| 3148 | fail: |
| 3149 | return -EINVAL; |
| 3150 | } |
| 3151 | |
| 3152 | /** |
| 3153 | * hdd_add_sta_info() - add station info attribute |
| 3154 | * @skb: pointer to sk buff |
| 3155 | * @hdd_sta_ctx: pointer to hdd station context |
| 3156 | * @idx: attribute index |
| 3157 | * |
| 3158 | * Return: Success(0) or reason code for failure |
| 3159 | */ |
| 3160 | static int32_t hdd_add_sta_info(struct sk_buff *skb, |
| 3161 | hdd_station_ctx_t *hdd_sta_ctx, int idx) |
| 3162 | { |
| 3163 | struct nlattr *nla_attr; |
| 3164 | |
| 3165 | nla_attr = nla_nest_start(skb, idx); |
| 3166 | if (!nla_attr) |
| 3167 | goto fail; |
| 3168 | if (nla_put_u8(skb, NL80211_STA_INFO_SIGNAL, |
| 3169 | (hdd_sta_ctx->conn_info.signal + 100))) { |
| 3170 | hdd_err("put fail"); |
| 3171 | goto fail; |
| 3172 | } |
| 3173 | if (hdd_add_tx_bitrate(skb, hdd_sta_ctx, NL80211_STA_INFO_TX_BITRATE)) |
| 3174 | goto fail; |
| 3175 | nla_nest_end(skb, nla_attr); |
| 3176 | return 0; |
| 3177 | fail: |
| 3178 | return -EINVAL; |
| 3179 | } |
| 3180 | |
| 3181 | /** |
| 3182 | * hdd_add_survey_info() - add survey info attribute |
| 3183 | * @skb: pointer to sk buff |
| 3184 | * @hdd_sta_ctx: pointer to hdd station context |
| 3185 | * @idx: attribute index |
| 3186 | * |
| 3187 | * Return: Success(0) or reason code for failure |
| 3188 | */ |
| 3189 | static int32_t hdd_add_survey_info(struct sk_buff *skb, |
| 3190 | hdd_station_ctx_t *hdd_sta_ctx, |
| 3191 | int idx) |
| 3192 | { |
| 3193 | struct nlattr *nla_attr; |
| 3194 | |
| 3195 | nla_attr = nla_nest_start(skb, idx); |
| 3196 | if (!nla_attr) |
| 3197 | goto fail; |
| 3198 | if (nla_put_u32(skb, NL80211_SURVEY_INFO_FREQUENCY, |
| 3199 | hdd_sta_ctx->conn_info.freq) || |
| 3200 | nla_put_u8(skb, NL80211_SURVEY_INFO_NOISE, |
| 3201 | (hdd_sta_ctx->conn_info.noise + 100))) { |
| 3202 | hdd_err("put fail"); |
| 3203 | goto fail; |
| 3204 | } |
| 3205 | nla_nest_end(skb, nla_attr); |
| 3206 | return 0; |
| 3207 | fail: |
| 3208 | return -EINVAL; |
| 3209 | } |
| 3210 | |
| 3211 | /** |
| 3212 | * hdd_add_link_standard_info() - add link info attribute |
| 3213 | * @skb: pointer to sk buff |
| 3214 | * @hdd_sta_ctx: pointer to hdd station context |
| 3215 | * @idx: attribute index |
| 3216 | * |
| 3217 | * Return: Success(0) or reason code for failure |
| 3218 | */ |
| 3219 | static int32_t |
| 3220 | hdd_add_link_standard_info(struct sk_buff *skb, |
| 3221 | hdd_station_ctx_t *hdd_sta_ctx, int idx) |
| 3222 | { |
| 3223 | struct nlattr *nla_attr; |
| 3224 | |
| 3225 | nla_attr = nla_nest_start(skb, idx); |
| 3226 | if (!nla_attr) |
| 3227 | goto fail; |
| 3228 | if (nla_put(skb, |
| 3229 | NL80211_ATTR_SSID, |
| 3230 | hdd_sta_ctx->conn_info.SSID.SSID.length, |
| 3231 | hdd_sta_ctx->conn_info.SSID.SSID.ssId)) { |
| 3232 | hdd_err("put fail"); |
| 3233 | goto fail; |
| 3234 | } |
| 3235 | if (hdd_add_survey_info(skb, hdd_sta_ctx, NL80211_ATTR_SURVEY_INFO)) |
| 3236 | goto fail; |
| 3237 | if (hdd_add_sta_info(skb, hdd_sta_ctx, NL80211_ATTR_STA_INFO)) |
| 3238 | goto fail; |
| 3239 | nla_nest_end(skb, nla_attr); |
| 3240 | return 0; |
| 3241 | fail: |
| 3242 | return -EINVAL; |
| 3243 | } |
| 3244 | |
| 3245 | /** |
| 3246 | * hdd_add_ap_standard_info() - add ap info attribute |
| 3247 | * @skb: pointer to sk buff |
| 3248 | * @hdd_sta_ctx: pointer to hdd station context |
| 3249 | * @idx: attribute index |
| 3250 | * |
| 3251 | * Return: Success(0) or reason code for failure |
| 3252 | */ |
| 3253 | static int32_t |
| 3254 | hdd_add_ap_standard_info(struct sk_buff *skb, |
| 3255 | hdd_station_ctx_t *hdd_sta_ctx, int idx) |
| 3256 | { |
| 3257 | struct nlattr *nla_attr; |
| 3258 | |
| 3259 | nla_attr = nla_nest_start(skb, idx); |
| 3260 | if (!nla_attr) |
| 3261 | goto fail; |
| 3262 | if (hdd_sta_ctx->conn_info.conn_flag.vht_present) |
| 3263 | if (nla_put(skb, NL80211_ATTR_VHT_CAPABILITY, |
| 3264 | sizeof(hdd_sta_ctx->conn_info.vht_caps), |
| 3265 | &hdd_sta_ctx->conn_info.vht_caps)) { |
| 3266 | hdd_err("put fail"); |
| 3267 | goto fail; |
| 3268 | } |
| 3269 | if (hdd_sta_ctx->conn_info.conn_flag.ht_present) |
| 3270 | if (nla_put(skb, NL80211_ATTR_HT_CAPABILITY, |
| 3271 | sizeof(hdd_sta_ctx->conn_info.ht_caps), |
| 3272 | &hdd_sta_ctx->conn_info.ht_caps)) { |
| 3273 | hdd_err("put fail"); |
| 3274 | goto fail; |
| 3275 | } |
| 3276 | nla_nest_end(skb, nla_attr); |
| 3277 | return 0; |
| 3278 | fail: |
| 3279 | return -EINVAL; |
| 3280 | } |
| 3281 | |
| 3282 | /** |
| 3283 | * hdd_get_station_info() - send BSS information to supplicant |
| 3284 | * @hdd_ctx: pointer to hdd context |
| 3285 | * @adapter: pointer to adapter |
| 3286 | * |
| 3287 | * Return: 0 if success else error status |
| 3288 | */ |
| 3289 | static int hdd_get_station_info(hdd_context_t *hdd_ctx, |
| 3290 | hdd_adapter_t *adapter) |
| 3291 | { |
| 3292 | struct sk_buff *skb = NULL; |
| 3293 | uint8_t *tmp_hs20 = NULL; |
| 3294 | uint32_t nl_buf_len; |
| 3295 | hdd_station_ctx_t *hdd_sta_ctx; |
| 3296 | |
| 3297 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 3298 | |
| 3299 | nl_buf_len = NLMSG_HDRLEN; |
| 3300 | nl_buf_len += sizeof(hdd_sta_ctx->conn_info.SSID.SSID.length) + |
| 3301 | sizeof(hdd_sta_ctx->conn_info.freq) + |
| 3302 | sizeof(hdd_sta_ctx->conn_info.noise) + |
| 3303 | sizeof(hdd_sta_ctx->conn_info.signal) + |
| 3304 | (sizeof(uint32_t) * 2) + |
| 3305 | sizeof(hdd_sta_ctx->conn_info.txrate.nss) + |
| 3306 | sizeof(hdd_sta_ctx->conn_info.roam_count) + |
| 3307 | sizeof(hdd_sta_ctx->conn_info.authType) + |
| 3308 | sizeof(hdd_sta_ctx->conn_info.dot11Mode); |
| 3309 | if (hdd_sta_ctx->conn_info.conn_flag.vht_present) |
| 3310 | nl_buf_len += sizeof(hdd_sta_ctx->conn_info.vht_caps); |
| 3311 | if (hdd_sta_ctx->conn_info.conn_flag.ht_present) |
| 3312 | nl_buf_len += sizeof(hdd_sta_ctx->conn_info.ht_caps); |
| 3313 | if (hdd_sta_ctx->conn_info.conn_flag.hs20_present) { |
| 3314 | tmp_hs20 = (uint8_t *)&(hdd_sta_ctx->conn_info.hs20vendor_ie); |
| 3315 | nl_buf_len += (sizeof(hdd_sta_ctx->conn_info.hs20vendor_ie) - |
| 3316 | 1); |
| 3317 | } |
| 3318 | if (hdd_sta_ctx->conn_info.conn_flag.ht_op_present) |
| 3319 | nl_buf_len += sizeof(hdd_sta_ctx->conn_info.ht_operation); |
| 3320 | if (hdd_sta_ctx->conn_info.conn_flag.vht_op_present) |
| 3321 | nl_buf_len += sizeof(hdd_sta_ctx->conn_info.vht_operation); |
| 3322 | |
| 3323 | |
| 3324 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 3325 | if (!skb) { |
| 3326 | hdd_err(FL("cfg80211_vendor_cmd_alloc_reply_skb failed")); |
| 3327 | return -ENOMEM; |
| 3328 | } |
| 3329 | |
| 3330 | if (hdd_add_link_standard_info(skb, hdd_sta_ctx, |
| 3331 | LINK_INFO_STANDARD_NL80211_ATTR)) { |
| 3332 | hdd_err("put fail"); |
| 3333 | goto fail; |
| 3334 | } |
| 3335 | if (hdd_add_ap_standard_info(skb, hdd_sta_ctx, |
| 3336 | AP_INFO_STANDARD_NL80211_ATTR)) { |
| 3337 | hdd_err("put fail"); |
| 3338 | goto fail; |
| 3339 | } |
| 3340 | if (nla_put_u32(skb, INFO_ROAM_COUNT, |
| 3341 | hdd_sta_ctx->conn_info.roam_count) || |
| 3342 | nla_put_u32(skb, INFO_AKM, |
| 3343 | hdd_convert_auth_type( |
| 3344 | hdd_sta_ctx->conn_info.authType)) || |
| 3345 | nla_put_u32(skb, WLAN802_11_MODE, |
| 3346 | hdd_convert_dot11mode( |
| 3347 | hdd_sta_ctx->conn_info.dot11Mode))) { |
| 3348 | hdd_err("put fail"); |
| 3349 | goto fail; |
| 3350 | } |
| 3351 | if (hdd_sta_ctx->conn_info.conn_flag.ht_op_present) |
| 3352 | if (nla_put(skb, HT_OPERATION, |
| 3353 | (sizeof(hdd_sta_ctx->conn_info.ht_operation)), |
| 3354 | &hdd_sta_ctx->conn_info.ht_operation)) { |
| 3355 | hdd_err("put fail"); |
| 3356 | goto fail; |
| 3357 | } |
| 3358 | if (hdd_sta_ctx->conn_info.conn_flag.vht_op_present) |
| 3359 | if (nla_put(skb, VHT_OPERATION, |
| 3360 | (sizeof(hdd_sta_ctx->conn_info.vht_operation)), |
| 3361 | &hdd_sta_ctx->conn_info.vht_operation)) { |
| 3362 | hdd_err("put fail"); |
| 3363 | goto fail; |
| 3364 | } |
| 3365 | if (hdd_sta_ctx->conn_info.conn_flag.hs20_present) |
| 3366 | if (nla_put(skb, AP_INFO_HS20_INDICATION, |
| 3367 | (sizeof(hdd_sta_ctx->conn_info.hs20vendor_ie) - 1), |
| 3368 | tmp_hs20 + 1)) { |
| 3369 | hdd_err("put fail"); |
| 3370 | goto fail; |
| 3371 | } |
| 3372 | |
| 3373 | return cfg80211_vendor_cmd_reply(skb); |
| 3374 | fail: |
| 3375 | if (skb) |
| 3376 | kfree_skb(skb); |
| 3377 | return -EINVAL; |
| 3378 | } |
| 3379 | |
| 3380 | /** |
| 3381 | * __hdd_cfg80211_get_station_cmd() - Handle get station vendor cmd |
| 3382 | * @wiphy: corestack handler |
| 3383 | * @wdev: wireless device |
| 3384 | * @data: data |
| 3385 | * @data_len: data length |
| 3386 | * |
| 3387 | * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION. |
| 3388 | * Validate cmd attributes and send the station info to upper layers. |
| 3389 | * |
| 3390 | * Return: Success(0) or reason code for failure |
| 3391 | */ |
Anurag Chouhan | d939d3d | 2016-07-20 17:45:48 +0530 | [diff] [blame] | 3392 | static int |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 3393 | __hdd_cfg80211_get_station_cmd(struct wiphy *wiphy, |
| 3394 | struct wireless_dev *wdev, |
| 3395 | const void *data, |
| 3396 | int data_len) |
| 3397 | { |
| 3398 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 3399 | struct net_device *dev = wdev->netdev; |
| 3400 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3401 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX + 1]; |
| 3402 | int32_t status; |
| 3403 | |
| 3404 | ENTER_DEV(dev); |
| 3405 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 3406 | hdd_err("Command not allowed in FTM mode"); |
| 3407 | status = -EPERM; |
| 3408 | goto out; |
| 3409 | } |
| 3410 | |
| 3411 | status = wlan_hdd_validate_context(hdd_ctx); |
| 3412 | if (0 != status) |
| 3413 | goto out; |
| 3414 | |
| 3415 | |
| 3416 | status = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_STATION_MAX, |
| 3417 | data, data_len, NULL); |
| 3418 | if (status) { |
| 3419 | hdd_err("Invalid ATTR"); |
| 3420 | goto out; |
| 3421 | } |
| 3422 | |
| 3423 | /* Parse and fetch Command Type*/ |
| 3424 | if (tb[STATION_INFO]) { |
| 3425 | status = hdd_get_station_info(hdd_ctx, adapter); |
| 3426 | } else if (tb[STATION_ASSOC_FAIL_REASON]) { |
| 3427 | status = hdd_get_station_assoc_fail(hdd_ctx, adapter); |
| 3428 | } else { |
| 3429 | hdd_err("get station info cmd type failed"); |
| 3430 | status = -EINVAL; |
| 3431 | goto out; |
| 3432 | } |
| 3433 | EXIT(); |
| 3434 | out: |
| 3435 | return status; |
| 3436 | } |
| 3437 | |
| 3438 | /** |
| 3439 | * wlan_hdd_cfg80211_get_station_cmd() - Handle get station vendor cmd |
| 3440 | * @wiphy: corestack handler |
| 3441 | * @wdev: wireless device |
| 3442 | * @data: data |
| 3443 | * @data_len: data length |
| 3444 | * |
| 3445 | * Handles QCA_NL80211_VENDOR_SUBCMD_GET_STATION. |
| 3446 | * Validate cmd attributes and send the station info to upper layers. |
| 3447 | * |
| 3448 | * Return: Success(0) or reason code for failure |
| 3449 | */ |
| 3450 | static int32_t |
| 3451 | hdd_cfg80211_get_station_cmd(struct wiphy *wiphy, |
| 3452 | struct wireless_dev *wdev, |
| 3453 | const void *data, |
| 3454 | int data_len) |
| 3455 | { |
| 3456 | int ret; |
| 3457 | |
| 3458 | cds_ssr_protect(__func__); |
| 3459 | ret = __hdd_cfg80211_get_station_cmd(wiphy, wdev, data, data_len); |
| 3460 | cds_ssr_unprotect(__func__); |
| 3461 | |
| 3462 | return ret; |
| 3463 | } |
| 3464 | |
| 3465 | /* |
| 3466 | * undef short names defined for get station command |
| 3467 | * used by __wlan_hdd_cfg80211_get_station_cmd() |
| 3468 | */ |
| 3469 | #undef STATION_INVALID |
| 3470 | #undef STATION_INFO |
| 3471 | #undef STATION_ASSOC_FAIL_REASON |
| 3472 | #undef STATION_MAX |
| 3473 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3474 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 3475 | /** |
| 3476 | * __wlan_hdd_cfg80211_keymgmt_set_key() - Store the Keys in the driver session |
| 3477 | * @wiphy: pointer to wireless wiphy structure. |
| 3478 | * @wdev: pointer to wireless_dev structure. |
| 3479 | * @data: Pointer to the Key data |
| 3480 | * @data_len:Length of the data passed |
| 3481 | * |
| 3482 | * This is called when wlan driver needs to save the keys received via |
| 3483 | * vendor specific command. |
| 3484 | * |
| 3485 | * Return: Return the Success or Failure code. |
| 3486 | */ |
| 3487 | static int __wlan_hdd_cfg80211_keymgmt_set_key(struct wiphy *wiphy, |
| 3488 | struct wireless_dev *wdev, |
| 3489 | const void *data, int data_len) |
| 3490 | { |
| 3491 | uint8_t local_pmk[SIR_ROAM_SCAN_PSK_SIZE]; |
| 3492 | struct net_device *dev = wdev->netdev; |
| 3493 | hdd_adapter_t *hdd_adapter_ptr = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3494 | hdd_context_t *hdd_ctx_ptr; |
| 3495 | int status; |
| 3496 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 3497 | ENTER_DEV(dev); |
| 3498 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3499 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3500 | hdd_err("Command not allowed in FTM mode"); |
| 3501 | return -EPERM; |
| 3502 | } |
| 3503 | |
| 3504 | if ((data == NULL) || (data_len == 0) || |
| 3505 | (data_len > SIR_ROAM_SCAN_PSK_SIZE)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3506 | hdd_err("Invalid data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3507 | return -EINVAL; |
| 3508 | } |
| 3509 | |
| 3510 | hdd_ctx_ptr = WLAN_HDD_GET_CTX(hdd_adapter_ptr); |
| 3511 | if (!hdd_ctx_ptr) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3512 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3513 | return -EINVAL; |
| 3514 | } |
| 3515 | |
| 3516 | status = wlan_hdd_validate_context(hdd_ctx_ptr); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3517 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3518 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3519 | sme_update_roam_key_mgmt_offload_enabled(hdd_ctx_ptr->hHal, |
| 3520 | hdd_adapter_ptr->sessionId, |
Deepak Dhamdhere | f2a7d8b | 2016-08-19 16:17:38 -0700 | [diff] [blame] | 3521 | true, |
| 3522 | hdd_is_okc_mode_enabled(hdd_ctx_ptr)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3523 | qdf_mem_zero(&local_pmk, SIR_ROAM_SCAN_PSK_SIZE); |
| 3524 | qdf_mem_copy(local_pmk, data, data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3525 | sme_roam_set_psk_pmk(WLAN_HDD_GET_HAL_CTX(hdd_adapter_ptr), |
| 3526 | hdd_adapter_ptr->sessionId, local_pmk, data_len); |
| 3527 | return 0; |
| 3528 | } |
| 3529 | |
| 3530 | /** |
| 3531 | * wlan_hdd_cfg80211_keymgmt_set_key() - Store the Keys in the driver session |
| 3532 | * @wiphy: pointer to wireless wiphy structure. |
| 3533 | * @wdev: pointer to wireless_dev structure. |
| 3534 | * @data: Pointer to the Key data |
| 3535 | * @data_len:Length of the data passed |
| 3536 | * |
| 3537 | * This is called when wlan driver needs to save the keys received via |
| 3538 | * vendor specific command. |
| 3539 | * |
| 3540 | * Return: Return the Success or Failure code. |
| 3541 | */ |
| 3542 | static int wlan_hdd_cfg80211_keymgmt_set_key(struct wiphy *wiphy, |
| 3543 | struct wireless_dev *wdev, |
| 3544 | const void *data, int data_len) |
| 3545 | { |
| 3546 | int ret; |
| 3547 | |
| 3548 | cds_ssr_protect(__func__); |
| 3549 | ret = __wlan_hdd_cfg80211_keymgmt_set_key(wiphy, wdev, data, data_len); |
| 3550 | cds_ssr_unprotect(__func__); |
| 3551 | |
| 3552 | return ret; |
| 3553 | } |
Varun Reddy Yeturu | bbbbe23 | 2016-02-29 14:01:57 -0800 | [diff] [blame] | 3554 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3555 | |
| 3556 | static const struct nla_policy qca_wlan_vendor_get_wifi_info_policy[ |
| 3557 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1] = { |
| 3558 | [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 }, |
| 3559 | [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 }, |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 3560 | [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX] = {.type = NLA_U32 }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3561 | }; |
| 3562 | |
| 3563 | /** |
| 3564 | * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info |
| 3565 | * @wiphy: pointer to wireless wiphy structure. |
| 3566 | * @wdev: pointer to wireless_dev structure. |
| 3567 | * @data: Pointer to the data to be passed via vendor interface |
| 3568 | * @data_len:Length of the data to be passed |
| 3569 | * |
| 3570 | * This is called when wlan driver needs to send wifi driver related info |
| 3571 | * (driver/fw version) to the user space application upon request. |
| 3572 | * |
| 3573 | * Return: Return the Success or Failure code. |
| 3574 | */ |
| 3575 | static int |
| 3576 | __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy, |
| 3577 | struct wireless_dev *wdev, |
| 3578 | const void *data, int data_len) |
| 3579 | { |
| 3580 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 3581 | 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] | 3582 | tSirVersionString driver_version; |
| 3583 | tSirVersionString firmware_version; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3584 | uint32_t major_spid = 0, minor_spid = 0, siid = 0, crmid = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3585 | int status; |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 3586 | struct sk_buff *reply_skb; |
| 3587 | uint32_t skb_len = 0, count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3588 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 3589 | ENTER_DEV(wdev->netdev); |
| 3590 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3591 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3592 | hdd_err("Command not allowed in FTM mode"); |
| 3593 | return -EPERM; |
| 3594 | } |
| 3595 | |
| 3596 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3597 | if (status) |
| 3598 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3599 | |
| 3600 | if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data, |
| 3601 | data_len, qca_wlan_vendor_get_wifi_info_policy)) { |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 3602 | hdd_err("WIFI_INFO_GET NL CMD parsing failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3603 | return -EINVAL; |
| 3604 | } |
| 3605 | |
| 3606 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) { |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 3607 | hdd_err("Rcvd req for Driver version"); |
| 3608 | strlcpy(driver_version, QWLAN_VERSIONSTR, |
| 3609 | sizeof(driver_version)); |
| 3610 | skb_len += strlen(driver_version) + 1; |
| 3611 | count++; |
| 3612 | } |
| 3613 | |
| 3614 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) { |
| 3615 | hdd_info("Rcvd req for FW version"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3616 | hdd_get_fw_version(hdd_ctx, &major_spid, &minor_spid, &siid, |
| 3617 | &crmid); |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 3618 | snprintf(firmware_version, sizeof(firmware_version), |
| 3619 | "%d:%d:%d:%d", major_spid, minor_spid, siid, crmid); |
| 3620 | skb_len += strlen(firmware_version) + 1; |
| 3621 | count++; |
| 3622 | } |
| 3623 | |
| 3624 | if (count == 0) { |
| 3625 | hdd_err("unknown attribute in get_wifi_info request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3626 | return -EINVAL; |
| 3627 | } |
| 3628 | |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 3629 | skb_len += (NLA_HDRLEN * count) + NLMSG_HDRLEN; |
| 3630 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, skb_len); |
| 3631 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3632 | if (!reply_skb) { |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 3633 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3634 | return -ENOMEM; |
| 3635 | } |
| 3636 | |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 3637 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) { |
| 3638 | if (nla_put_string(reply_skb, |
| 3639 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION, |
| 3640 | driver_version)) |
| 3641 | goto error_nla_fail; |
| 3642 | } |
| 3643 | |
Hanumanth Reddy Pothula | 1046ccc | 2016-10-14 14:33:44 +0530 | [diff] [blame] | 3644 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) { |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 3645 | if (nla_put_string(reply_skb, |
| 3646 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION, |
| 3647 | firmware_version)) |
| 3648 | goto error_nla_fail; |
| 3649 | } |
| 3650 | |
| 3651 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX]) { |
| 3652 | if (nla_put_u32(reply_skb, |
| 3653 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_RADIO_INDEX, |
| 3654 | hdd_ctx->radio_index)) |
| 3655 | goto error_nla_fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3656 | } |
| 3657 | |
| 3658 | return cfg80211_vendor_cmd_reply(reply_skb); |
Ryan Hsu | 7ac8885 | 2016-04-28 10:20:34 -0700 | [diff] [blame] | 3659 | |
| 3660 | error_nla_fail: |
| 3661 | hdd_err("nla put fail"); |
| 3662 | kfree_skb(reply_skb); |
| 3663 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3664 | } |
| 3665 | |
| 3666 | /** |
| 3667 | * wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info |
| 3668 | * @wiphy: pointer to wireless wiphy structure. |
| 3669 | * @wdev: pointer to wireless_dev structure. |
| 3670 | * @data: Pointer to the data to be passed via vendor interface |
| 3671 | * @data_len:Length of the data to be passed |
| 3672 | * |
| 3673 | * This is called when wlan driver needs to send wifi driver related info |
| 3674 | * (driver/fw version) to the user space application upon request. |
| 3675 | * |
| 3676 | * Return: Return the Success or Failure code. |
| 3677 | */ |
| 3678 | static int |
| 3679 | wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy, |
| 3680 | struct wireless_dev *wdev, |
| 3681 | const void *data, int data_len) |
| 3682 | { |
| 3683 | int ret; |
| 3684 | |
| 3685 | cds_ssr_protect(__func__); |
| 3686 | ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy, wdev, data, data_len); |
| 3687 | cds_ssr_unprotect(__func__); |
| 3688 | |
| 3689 | return ret; |
| 3690 | } |
| 3691 | |
| 3692 | /** |
| 3693 | * __wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features |
| 3694 | * @wiphy: pointer to wireless wiphy structure. |
| 3695 | * @wdev: pointer to wireless_dev structure. |
| 3696 | * @data: Pointer to the data to be passed via vendor interface |
| 3697 | * @data_len:Length of the data to be passed |
| 3698 | * |
| 3699 | * This is called by userspace to know the supported logger features |
| 3700 | * |
| 3701 | * Return: Return the Success or Failure code. |
| 3702 | */ |
| 3703 | static int |
| 3704 | __wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy, |
| 3705 | struct wireless_dev *wdev, |
| 3706 | const void *data, int data_len) |
| 3707 | { |
| 3708 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 3709 | int status; |
| 3710 | uint32_t features; |
| 3711 | struct sk_buff *reply_skb = NULL; |
| 3712 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 3713 | ENTER_DEV(wdev->netdev); |
| 3714 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3715 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3716 | hdd_err("Command not allowed in FTM mode"); |
| 3717 | return -EPERM; |
| 3718 | } |
| 3719 | |
| 3720 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3721 | if (status) |
| 3722 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3723 | |
| 3724 | features = 0; |
| 3725 | |
| 3726 | if (hdd_is_memdump_supported()) |
| 3727 | features |= WIFI_LOGGER_MEMORY_DUMP_SUPPORTED; |
| 3728 | features |= WIFI_LOGGER_PER_PACKET_TX_RX_STATUS_SUPPORTED; |
| 3729 | features |= WIFI_LOGGER_CONNECT_EVENT_SUPPORTED; |
| 3730 | features |= WIFI_LOGGER_WAKE_LOCK_SUPPORTED; |
| 3731 | |
| 3732 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 3733 | sizeof(uint32_t) + NLA_HDRLEN + NLMSG_HDRLEN); |
| 3734 | if (!reply_skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3735 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3736 | return -ENOMEM; |
| 3737 | } |
| 3738 | |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3739 | hdd_notice("Supported logger features: 0x%0x", features); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3740 | if (nla_put_u32(reply_skb, QCA_WLAN_VENDOR_ATTR_LOGGER_SUPPORTED, |
| 3741 | features)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3742 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3743 | kfree_skb(reply_skb); |
| 3744 | return -EINVAL; |
| 3745 | } |
| 3746 | |
| 3747 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 3748 | } |
| 3749 | |
| 3750 | /** |
| 3751 | * wlan_hdd_cfg80211_get_logger_supp_feature() - Get the wifi logger features |
| 3752 | * @wiphy: pointer to wireless wiphy structure. |
| 3753 | * @wdev: pointer to wireless_dev structure. |
| 3754 | * @data: Pointer to the data to be passed via vendor interface |
| 3755 | * @data_len:Length of the data to be passed |
| 3756 | * |
| 3757 | * This is called by userspace to know the supported logger features |
| 3758 | * |
| 3759 | * Return: Return the Success or Failure code. |
| 3760 | */ |
| 3761 | static int |
| 3762 | wlan_hdd_cfg80211_get_logger_supp_feature(struct wiphy *wiphy, |
| 3763 | struct wireless_dev *wdev, |
| 3764 | const void *data, int data_len) |
| 3765 | { |
| 3766 | int ret; |
| 3767 | |
| 3768 | cds_ssr_protect(__func__); |
| 3769 | ret = __wlan_hdd_cfg80211_get_logger_supp_feature(wiphy, wdev, |
| 3770 | data, data_len); |
| 3771 | cds_ssr_unprotect(__func__); |
| 3772 | |
| 3773 | return ret; |
| 3774 | } |
| 3775 | |
Varun Reddy Yeturu | bbbbe23 | 2016-02-29 14:01:57 -0800 | [diff] [blame] | 3776 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3777 | /** |
| 3778 | * wlan_hdd_send_roam_auth_event() - Send the roamed and authorized event |
| 3779 | * @hdd_ctx_ptr: pointer to HDD Context. |
| 3780 | * @bssid: pointer to bssid of roamed AP. |
| 3781 | * @req_rsn_ie: Pointer to request RSN IE |
| 3782 | * @req_rsn_len: Length of the request RSN IE |
| 3783 | * @rsp_rsn_ie: Pointer to response RSN IE |
| 3784 | * @rsp_rsn_len: Length of the response RSN IE |
| 3785 | * @roam_info_ptr: Pointer to the roaming related information |
| 3786 | * |
| 3787 | * This is called when wlan driver needs to send the roaming and |
| 3788 | * authorization information after roaming. |
| 3789 | * |
| 3790 | * The information that would be sent is the request RSN IE, response |
| 3791 | * RSN IE and BSSID of the newly roamed AP. |
| 3792 | * |
| 3793 | * If the Authorized status is authenticated, then additional parameters |
| 3794 | * like PTK's KCK and KEK and Replay Counter would also be passed to the |
| 3795 | * supplicant. |
| 3796 | * |
| 3797 | * The supplicant upon receiving this event would ignore the legacy |
| 3798 | * cfg80211_roamed call and use the entire information from this event. |
| 3799 | * The cfg80211_roamed should still co-exist since the kernel will |
| 3800 | * make use of the parameters even if the supplicant ignores it. |
| 3801 | * |
| 3802 | * Return: Return the Success or Failure code. |
| 3803 | */ |
| 3804 | int wlan_hdd_send_roam_auth_event(hdd_context_t *hdd_ctx_ptr, uint8_t *bssid, |
| 3805 | uint8_t *req_rsn_ie, uint32_t req_rsn_len, uint8_t *rsp_rsn_ie, |
| 3806 | uint32_t rsp_rsn_len, tCsrRoamInfo *roam_info_ptr) |
| 3807 | { |
| 3808 | struct sk_buff *skb = NULL; |
Varun Reddy Yeturu | 16e8f01 | 2016-02-03 17:21:09 -0800 | [diff] [blame] | 3809 | eCsrAuthType auth_type; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3810 | ENTER(); |
| 3811 | |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3812 | if (wlan_hdd_validate_context(hdd_ctx_ptr)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3813 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3814 | |
Varun Reddy Yeturu | d351a6c | 2016-03-16 14:01:00 -0700 | [diff] [blame] | 3815 | if (!roaming_offload_enabled(hdd_ctx_ptr) || |
Prashanth Bhatta | bfc2529 | 2015-11-05 11:16:21 -0800 | [diff] [blame] | 3816 | !roam_info_ptr->roamSynchInProgress) |
| 3817 | return 0; |
| 3818 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3819 | skb = cfg80211_vendor_event_alloc(hdd_ctx_ptr->wiphy, |
| 3820 | NULL, |
| 3821 | ETH_ALEN + req_rsn_len + rsp_rsn_len + |
| 3822 | sizeof(uint8_t) + SIR_REPLAY_CTR_LEN + |
| 3823 | SIR_KCK_KEY_LEN + SIR_KCK_KEY_LEN + |
Ravi Joshi | 277ae9b | 2015-11-13 11:30:43 -0800 | [diff] [blame] | 3824 | sizeof(uint8_t) + (8 * NLMSG_HDRLEN), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3825 | QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH_INDEX, |
| 3826 | GFP_KERNEL); |
| 3827 | |
| 3828 | if (!skb) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3829 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3830 | return -EINVAL; |
| 3831 | } |
| 3832 | |
| 3833 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_BSSID, |
| 3834 | ETH_ALEN, bssid) || |
| 3835 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_REQ_IE, |
| 3836 | req_rsn_len, req_rsn_ie) || |
| 3837 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_RESP_IE, |
| 3838 | rsp_rsn_len, rsp_rsn_ie)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3839 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3840 | goto nla_put_failure; |
| 3841 | } |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3842 | hdd_debug("Auth Status = %d", roam_info_ptr->synchAuthStatus); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3843 | if (roam_info_ptr->synchAuthStatus == |
| 3844 | CSR_ROAM_AUTH_STATUS_AUTHENTICATED) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3845 | hdd_debug("Include Auth Params TLV's"); |
Naveen Rawat | 14298b9 | 2015-11-25 16:27:41 -0800 | [diff] [blame] | 3846 | if (nla_put_u8(skb, |
| 3847 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_AUTHORIZED, true)) { |
| 3848 | hdd_err("nla put fail"); |
| 3849 | goto nla_put_failure; |
| 3850 | } |
Varun Reddy Yeturu | 16e8f01 | 2016-02-03 17:21:09 -0800 | [diff] [blame] | 3851 | auth_type = roam_info_ptr->u.pConnectedProfile->AuthType; |
| 3852 | /* if FT or CCKM connection: dont send replay counter */ |
| 3853 | if (auth_type != eCSR_AUTH_TYPE_FT_RSN && |
| 3854 | auth_type != eCSR_AUTH_TYPE_FT_RSN_PSK && |
| 3855 | auth_type != eCSR_AUTH_TYPE_CCKM_WPA && |
| 3856 | auth_type != eCSR_AUTH_TYPE_CCKM_RSN && |
| 3857 | nla_put(skb, |
| 3858 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_KEY_REPLAY_CTR, |
| 3859 | SIR_REPLAY_CTR_LEN, |
| 3860 | roam_info_ptr->replay_ctr)) { |
| 3861 | hdd_err("non FT/non CCKM connection."); |
Naveen Rawat | 14298b9 | 2015-11-25 16:27:41 -0800 | [diff] [blame] | 3862 | hdd_err("failed to send replay counter."); |
| 3863 | goto nla_put_failure; |
| 3864 | } |
| 3865 | if (nla_put(skb, |
| 3866 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_PTK_KCK, |
| 3867 | SIR_KCK_KEY_LEN, roam_info_ptr->kck) || |
| 3868 | nla_put(skb, |
| 3869 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_PTK_KEK, |
| 3870 | SIR_KEK_KEY_LEN, roam_info_ptr->kek)) { |
| 3871 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3872 | goto nla_put_failure; |
| 3873 | } |
| 3874 | } else { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3875 | hdd_debug("No Auth Params TLV's"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3876 | if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_AUTHORIZED, |
| 3877 | false)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3878 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3879 | goto nla_put_failure; |
| 3880 | } |
| 3881 | } |
| 3882 | |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3883 | hdd_debug("Subnet Change Status = %d", |
Ravi Joshi | 277ae9b | 2015-11-13 11:30:43 -0800 | [diff] [blame] | 3884 | roam_info_ptr->subnet_change_status); |
| 3885 | |
| 3886 | /* |
| 3887 | * Add subnet change status if subnet has changed |
| 3888 | * 0 = unchanged |
| 3889 | * 1 = changed |
| 3890 | * 2 = unknown |
| 3891 | */ |
| 3892 | if (roam_info_ptr->subnet_change_status) { |
| 3893 | if (nla_put_u8(skb, |
| 3894 | QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_SUBNET_STATUS, |
| 3895 | roam_info_ptr->subnet_change_status)) { |
Jeff Johnson | 020db45 | 2016-06-29 14:37:26 -0700 | [diff] [blame] | 3896 | hdd_err("nla put fail"); |
Ravi Joshi | 277ae9b | 2015-11-13 11:30:43 -0800 | [diff] [blame] | 3897 | goto nla_put_failure; |
| 3898 | } |
| 3899 | } |
| 3900 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3901 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 3902 | return 0; |
| 3903 | |
| 3904 | nla_put_failure: |
| 3905 | kfree_skb(skb); |
| 3906 | return -EINVAL; |
| 3907 | } |
Varun Reddy Yeturu | bbbbe23 | 2016-02-29 14:01:57 -0800 | [diff] [blame] | 3908 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3909 | |
| 3910 | static const struct nla_policy |
| 3911 | wlan_hdd_wifi_config_policy[QCA_WLAN_VENDOR_ATTR_CONFIG_MAX + 1] = { |
| 3912 | |
| 3913 | [QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM] = {.type = NLA_U32 }, |
| 3914 | [QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR] = {.type = NLA_U16 }, |
| 3915 | [QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME] = {.type = NLA_U32 }, |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 3916 | [QCA_WLAN_VENDOR_ATTR_CONFIG_CHANNEL_AVOIDANCE_IND] = {.type = NLA_U8 }, |
Padma, Santhosh Kumar | a711967 | 2016-08-16 16:05:14 +0530 | [diff] [blame] | 3917 | [QCA_WLAN_VENDOR_ATTR_CONFIG_TX_MPDU_AGGREGATION] = {.type = NLA_U8 }, |
| 3918 | [QCA_WLAN_VENDOR_ATTR_CONFIG_RX_MPDU_AGGREGATION] = {.type = NLA_U8 }, |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 3919 | [QCA_WLAN_VENDOR_ATTR_CONFIG_NON_AGG_RETRY] = {.type = NLA_U8 }, |
| 3920 | [QCA_WLAN_VENDOR_ATTR_CONFIG_AGG_RETRY] = {.type = NLA_U8 }, |
| 3921 | [QCA_WLAN_VENDOR_ATTR_CONFIG_MGMT_RETRY] = {.type = NLA_U8 }, |
| 3922 | [QCA_WLAN_VENDOR_ATTR_CONFIG_CTRL_RETRY] = {.type = NLA_U8 }, |
| 3923 | [QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_DELAY] = {.type = NLA_U8 }, |
Agrawal, Ashish | b45599a | 2016-10-27 14:55:30 +0530 | [diff] [blame] | 3924 | [QCA_WLAN_VENDOR_ATTR_CONFIG_TX_FAIL_COUNT] = {.type = NLA_U32 }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3925 | }; |
| 3926 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3927 | /** |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 3928 | * wlan_hdd_save_default_scan_ies() - API to store the default scan IEs |
| 3929 | * |
| 3930 | * @adapter: Pointer to HDD adapter |
| 3931 | * @ie_data: Pointer to Scan IEs buffer |
| 3932 | * @ie_len: Length of Scan IEs |
| 3933 | * |
| 3934 | * Return: 0 on success; error number otherwise |
| 3935 | */ |
| 3936 | static int wlan_hdd_save_default_scan_ies(hdd_adapter_t *adapter, |
| 3937 | uint8_t *ie_data, uint8_t ie_len) |
| 3938 | { |
| 3939 | hdd_scaninfo_t *scan_info = NULL; |
| 3940 | scan_info = &adapter->scan_info; |
| 3941 | |
| 3942 | if (scan_info->default_scan_ies) { |
| 3943 | qdf_mem_free(scan_info->default_scan_ies); |
| 3944 | scan_info->default_scan_ies = NULL; |
| 3945 | } |
| 3946 | |
| 3947 | scan_info->default_scan_ies = qdf_mem_malloc(ie_len); |
| 3948 | if (!scan_info->default_scan_ies) |
| 3949 | return -ENOMEM; |
| 3950 | |
| 3951 | memcpy(scan_info->default_scan_ies, ie_data, ie_len); |
| 3952 | scan_info->default_scan_ies_len = ie_len; |
| 3953 | return 0; |
| 3954 | } |
| 3955 | |
| 3956 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3957 | * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration |
| 3958 | * vendor command |
| 3959 | * |
| 3960 | * @wiphy: wiphy device pointer |
| 3961 | * @wdev: wireless device pointer |
| 3962 | * @data: Vendor command data buffer |
| 3963 | * @data_len: Buffer length |
| 3964 | * |
| 3965 | * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX. |
| 3966 | * |
| 3967 | * Return: Error code. |
| 3968 | */ |
| 3969 | static int |
| 3970 | __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, |
| 3971 | struct wireless_dev *wdev, |
| 3972 | const void *data, |
| 3973 | int data_len) |
| 3974 | { |
| 3975 | struct net_device *dev = wdev->netdev; |
| 3976 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3977 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 3978 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_CONFIG_MAX + 1]; |
| 3979 | int ret_val = 0; |
| 3980 | u32 modulated_dtim; |
| 3981 | u16 stats_avg_factor; |
| 3982 | u32 guard_time; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 3983 | uint8_t set_value; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 3984 | u32 ftm_capab; |
Dustin Brown | 10a7b71 | 2016-10-07 10:31:16 -0700 | [diff] [blame] | 3985 | u8 qpower; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3986 | QDF_STATUS status; |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 3987 | int attr_len; |
| 3988 | int access_policy = 0; |
| 3989 | char vendor_ie[SIR_MAC_MAX_IE_LENGTH + 2]; |
| 3990 | bool vendor_ie_present = false, access_policy_present = false; |
Deepak Dhamdhere | b106ae5 | 2016-08-10 20:55:30 +0530 | [diff] [blame] | 3991 | uint16_t scan_ie_len = 0; |
| 3992 | uint8_t *scan_ie; |
Padma, Santhosh Kumar | a711967 | 2016-08-16 16:05:14 +0530 | [diff] [blame] | 3993 | struct sir_set_tx_rx_aggregation_size request; |
| 3994 | QDF_STATUS qdf_status; |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 3995 | uint8_t retry, delay; |
| 3996 | int param_id; |
Agrawal, Ashish | b45599a | 2016-10-27 14:55:30 +0530 | [diff] [blame] | 3997 | uint32_t tx_fail_count; |
Deepak Dhamdhere | b106ae5 | 2016-08-10 20:55:30 +0530 | [diff] [blame] | 3998 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 3999 | ENTER_DEV(dev); |
| 4000 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4001 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4002 | hdd_err("Command not allowed in FTM mode"); |
| 4003 | return -EPERM; |
| 4004 | } |
| 4005 | |
| 4006 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4007 | if (ret_val) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4008 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4009 | |
| 4010 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_CONFIG_MAX, |
| 4011 | data, data_len, |
| 4012 | wlan_hdd_wifi_config_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4013 | hdd_err("invalid attr"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4014 | return -EINVAL; |
| 4015 | } |
| 4016 | |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 4017 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_FINE_TIME_MEASUREMENT]) { |
| 4018 | ftm_capab = nla_get_u32(tb[ |
| 4019 | QCA_WLAN_VENDOR_ATTR_CONFIG_FINE_TIME_MEASUREMENT]); |
| 4020 | hdd_ctx->config->fine_time_meas_cap = |
| 4021 | hdd_ctx->fine_time_meas_cap_target & ftm_capab; |
| 4022 | sme_update_fine_time_measurement_capab(hdd_ctx->hHal, |
Selvaraj, Sridhar | 57bb4d0 | 2016-08-31 16:14:15 +0530 | [diff] [blame] | 4023 | adapter->sessionId, |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 4024 | hdd_ctx->config->fine_time_meas_cap); |
| 4025 | hdd_info("FTM capability: user value: 0x%x, target value: 0x%x, final value: 0x%x", |
| 4026 | ftm_capab, hdd_ctx->fine_time_meas_cap_target, |
| 4027 | hdd_ctx->config->fine_time_meas_cap); |
| 4028 | } |
| 4029 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4030 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM]) { |
| 4031 | modulated_dtim = nla_get_u32( |
| 4032 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM]); |
| 4033 | |
| 4034 | status = sme_configure_modulated_dtim(hdd_ctx->hHal, |
| 4035 | adapter->sessionId, |
| 4036 | modulated_dtim); |
| 4037 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4038 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4039 | ret_val = -EPERM; |
| 4040 | } |
| 4041 | |
Kapil Gupta | 6213c01 | 2016-09-02 19:39:09 +0530 | [diff] [blame] | 4042 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER]) { |
| 4043 | qpower = nla_get_u8( |
| 4044 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER]); |
| 4045 | if (hdd_set_qpower_config(hdd_ctx, adapter, qpower) != 0) |
| 4046 | ret_val = -EINVAL; |
| 4047 | } |
| 4048 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4049 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR]) { |
| 4050 | stats_avg_factor = nla_get_u16( |
| 4051 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR]); |
| 4052 | status = sme_configure_stats_avg_factor(hdd_ctx->hHal, |
| 4053 | adapter->sessionId, |
| 4054 | stats_avg_factor); |
| 4055 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4056 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4057 | ret_val = -EPERM; |
| 4058 | } |
| 4059 | |
| 4060 | |
| 4061 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME]) { |
| 4062 | guard_time = nla_get_u32( |
| 4063 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME]); |
| 4064 | status = sme_configure_guard_time(hdd_ctx->hHal, |
| 4065 | adapter->sessionId, |
| 4066 | guard_time); |
| 4067 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4068 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4069 | ret_val = -EPERM; |
| 4070 | } |
| 4071 | |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 4072 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY_IE_LIST]) { |
| 4073 | qdf_mem_zero(&vendor_ie[0], SIR_MAC_MAX_IE_LENGTH + 2); |
| 4074 | attr_len = nla_len( |
| 4075 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY_IE_LIST]); |
| 4076 | if (attr_len < 0 || attr_len > SIR_MAC_MAX_IE_LENGTH + 2) { |
| 4077 | hdd_info("Invalid value. attr_len %d", |
| 4078 | attr_len); |
| 4079 | return -EINVAL; |
| 4080 | } |
| 4081 | |
| 4082 | nla_memcpy(&vendor_ie, |
| 4083 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY_IE_LIST], |
| 4084 | attr_len); |
| 4085 | vendor_ie_present = true; |
| 4086 | hdd_info("Access policy vendor ie present.attr_len %d", |
| 4087 | attr_len); |
| 4088 | qdf_trace_hex_dump(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO, |
| 4089 | &vendor_ie[0], attr_len); |
| 4090 | } |
| 4091 | |
| 4092 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY]) { |
| 4093 | access_policy = (int) nla_get_u32( |
| 4094 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_ACCESS_POLICY]); |
| 4095 | if ((access_policy < QCA_ACCESS_POLICY_ACCEPT_UNLESS_LISTED) || |
| 4096 | (access_policy > |
| 4097 | QCA_ACCESS_POLICY_DENY_UNLESS_LISTED)) { |
| 4098 | hdd_info("Invalid value. access_policy %d", |
| 4099 | access_policy); |
| 4100 | return -EINVAL; |
| 4101 | } |
| 4102 | access_policy_present = true; |
| 4103 | hdd_info("Access policy present. access_policy %d", |
| 4104 | access_policy); |
| 4105 | } |
| 4106 | |
Zhang Qian | a3bcbe0 | 2016-08-12 16:20:36 +0800 | [diff] [blame] | 4107 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_NON_AGG_RETRY]) { |
| 4108 | retry = nla_get_u8(tb[ |
| 4109 | QCA_WLAN_VENDOR_ATTR_CONFIG_NON_AGG_RETRY]); |
| 4110 | retry = retry > CFG_NON_AGG_RETRY_MAX ? |
| 4111 | CFG_NON_AGG_RETRY_MAX : retry; |
| 4112 | param_id = WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH; |
| 4113 | ret_val = wma_cli_set_command(adapter->sessionId, param_id, |
| 4114 | retry, PDEV_CMD); |
| 4115 | } |
| 4116 | |
| 4117 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_AGG_RETRY]) { |
| 4118 | retry = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_AGG_RETRY]); |
| 4119 | retry = retry > CFG_AGG_RETRY_MAX ? |
| 4120 | CFG_AGG_RETRY_MAX : retry; |
| 4121 | |
| 4122 | /* Value less than CFG_AGG_RETRY_MIN has side effect to t-put */ |
| 4123 | retry = ((retry > 0) && (retry < CFG_AGG_RETRY_MIN)) ? |
| 4124 | CFG_AGG_RETRY_MIN : retry; |
| 4125 | param_id = WMI_PDEV_PARAM_AGG_SW_RETRY_TH; |
| 4126 | ret_val = wma_cli_set_command(adapter->sessionId, param_id, |
| 4127 | retry, PDEV_CMD); |
| 4128 | } |
| 4129 | |
| 4130 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_MGMT_RETRY]) { |
| 4131 | retry = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_MGMT_RETRY]); |
| 4132 | retry = retry > CFG_MGMT_RETRY_MAX ? |
| 4133 | CFG_MGMT_RETRY_MAX : retry; |
| 4134 | param_id = WMI_PDEV_PARAM_MGMT_RETRY_LIMIT; |
| 4135 | ret_val = wma_cli_set_command(adapter->sessionId, param_id, |
| 4136 | retry, PDEV_CMD); |
| 4137 | } |
| 4138 | |
| 4139 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_CTRL_RETRY]) { |
| 4140 | retry = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_CTRL_RETRY]); |
| 4141 | retry = retry > CFG_CTRL_RETRY_MAX ? |
| 4142 | CFG_CTRL_RETRY_MAX : retry; |
| 4143 | param_id = WMI_PDEV_PARAM_CTRL_RETRY_LIMIT; |
| 4144 | ret_val = wma_cli_set_command(adapter->sessionId, param_id, |
| 4145 | retry, PDEV_CMD); |
| 4146 | } |
| 4147 | |
| 4148 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_DELAY]) { |
| 4149 | delay = nla_get_u8(tb[ |
| 4150 | QCA_WLAN_VENDOR_ATTR_CONFIG_PROPAGATION_DELAY]); |
| 4151 | delay = delay > CFG_PROPAGATION_DELAY_MAX ? |
| 4152 | CFG_PROPAGATION_DELAY_MAX : delay; |
| 4153 | param_id = WMI_PDEV_PARAM_PROPAGATION_DELAY; |
| 4154 | ret_val = wma_cli_set_command(adapter->sessionId, param_id, |
| 4155 | delay, PDEV_CMD); |
| 4156 | } |
| 4157 | |
Agrawal, Ashish | b45599a | 2016-10-27 14:55:30 +0530 | [diff] [blame] | 4158 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_FAIL_COUNT]) { |
| 4159 | tx_fail_count = nla_get_u32( |
| 4160 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_FAIL_COUNT]); |
| 4161 | if (tx_fail_count) { |
| 4162 | status = sme_update_tx_fail_cnt_threshold(hdd_ctx->hHal, |
| 4163 | adapter->sessionId, tx_fail_count); |
| 4164 | if (QDF_STATUS_SUCCESS != status) { |
| 4165 | hdd_info("sme_update_tx_fail_cnt_threshold (err=%d)", |
| 4166 | status); |
| 4167 | return -EINVAL; |
| 4168 | } |
| 4169 | } |
| 4170 | } |
| 4171 | |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 4172 | if (vendor_ie_present && access_policy_present) { |
| 4173 | if (access_policy == QCA_ACCESS_POLICY_DENY_UNLESS_LISTED) { |
| 4174 | access_policy = |
| 4175 | WLAN_HDD_VENDOR_IE_ACCESS_ALLOW_IF_LISTED; |
Selvaraj, Sridhar | ac4fcf3 | 2016-09-28 12:57:32 +0530 | [diff] [blame] | 4176 | } else { |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 4177 | access_policy = WLAN_HDD_VENDOR_IE_ACCESS_NONE; |
Selvaraj, Sridhar | ac4fcf3 | 2016-09-28 12:57:32 +0530 | [diff] [blame] | 4178 | } |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 4179 | |
Selvaraj, Sridhar | ac4fcf3 | 2016-09-28 12:57:32 +0530 | [diff] [blame] | 4180 | hdd_info("calling sme_update_access_policy_vendor_ie"); |
| 4181 | status = sme_update_access_policy_vendor_ie(hdd_ctx->hHal, |
| 4182 | adapter->sessionId, &vendor_ie[0], |
| 4183 | access_policy); |
| 4184 | if (QDF_STATUS_SUCCESS != status) { |
| 4185 | hdd_info("Failed to set vendor ie and access policy."); |
Kondabattini, Ganesh | 44f6a21 | 2016-09-05 15:14:25 +0530 | [diff] [blame] | 4186 | return -EINVAL; |
| 4187 | } |
| 4188 | } |
| 4189 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 4190 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_CHANNEL_AVOIDANCE_IND]) { |
| 4191 | set_value = nla_get_u8( |
| 4192 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_CHANNEL_AVOIDANCE_IND]); |
| 4193 | hdd_info("set_value: %d", set_value); |
| 4194 | ret_val = hdd_enable_disable_ca_event(hdd_ctx, set_value); |
| 4195 | } |
| 4196 | |
Deepak Dhamdhere | b106ae5 | 2016-08-10 20:55:30 +0530 | [diff] [blame] | 4197 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_SCAN_DEFAULT_IES]) { |
| 4198 | scan_ie_len = nla_len( |
| 4199 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_SCAN_DEFAULT_IES]); |
| 4200 | hdd_info("Received default scan IE of len %d session %d device mode %d", |
| 4201 | scan_ie_len, adapter->sessionId, |
| 4202 | adapter->device_mode); |
| 4203 | if (scan_ie_len && (scan_ie_len <= MAX_DEFAULT_SCAN_IE_LEN)) { |
| 4204 | scan_ie = (uint8_t *) nla_data(tb |
| 4205 | [QCA_WLAN_VENDOR_ATTR_CONFIG_SCAN_DEFAULT_IES]); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4206 | |
| 4207 | if (wlan_hdd_save_default_scan_ies(adapter, scan_ie, |
| 4208 | scan_ie_len)) |
| 4209 | hdd_err("Failed to save default scan IEs"); |
| 4210 | |
Deepak Dhamdhere | b106ae5 | 2016-08-10 20:55:30 +0530 | [diff] [blame] | 4211 | if (adapter->device_mode == QDF_STA_MODE) { |
| 4212 | status = sme_set_default_scan_ie(hdd_ctx->hHal, |
| 4213 | adapter->sessionId, scan_ie, |
| 4214 | scan_ie_len); |
| 4215 | if (QDF_STATUS_SUCCESS != status) |
| 4216 | ret_val = -EPERM; |
| 4217 | } |
| 4218 | } else |
| 4219 | ret_val = -EPERM; |
| 4220 | } |
Padma, Santhosh Kumar | a711967 | 2016-08-16 16:05:14 +0530 | [diff] [blame] | 4221 | |
| 4222 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_MPDU_AGGREGATION] || |
| 4223 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RX_MPDU_AGGREGATION]) { |
| 4224 | /* if one is specified, both must be specified */ |
| 4225 | if (!tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_MPDU_AGGREGATION] || |
| 4226 | !tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RX_MPDU_AGGREGATION]) { |
| 4227 | hdd_err("Both TX and RX MPDU Aggregation required"); |
| 4228 | return -EINVAL; |
| 4229 | } |
| 4230 | |
| 4231 | request.tx_aggregation_size = nla_get_u8( |
| 4232 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_TX_MPDU_AGGREGATION]); |
| 4233 | request.rx_aggregation_size = nla_get_u8( |
| 4234 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RX_MPDU_AGGREGATION]); |
| 4235 | request.vdev_id = adapter->sessionId; |
| 4236 | |
| 4237 | if (request.tx_aggregation_size >= |
| 4238 | CFG_TX_AGGREGATION_SIZE_MIN && |
| 4239 | request.tx_aggregation_size <= |
| 4240 | CFG_TX_AGGREGATION_SIZE_MAX && |
| 4241 | request.rx_aggregation_size >= |
| 4242 | CFG_RX_AGGREGATION_SIZE_MIN && |
| 4243 | request.rx_aggregation_size <= |
| 4244 | CFG_RX_AGGREGATION_SIZE_MAX) { |
| 4245 | qdf_status = wma_set_tx_rx_aggregation_size(&request); |
| 4246 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 4247 | hdd_err("failed to set aggr sizes err %d", |
| 4248 | qdf_status); |
| 4249 | ret_val = -EPERM; |
| 4250 | } |
| 4251 | } else { |
| 4252 | hdd_err("TX %d RX %d MPDU aggr size not in range", |
| 4253 | request.tx_aggregation_size, |
| 4254 | request.rx_aggregation_size); |
| 4255 | ret_val = -EINVAL; |
| 4256 | } |
| 4257 | } |
| 4258 | |
Selvaraj, Sridhar | ac4fcf3 | 2016-09-28 12:57:32 +0530 | [diff] [blame] | 4259 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_IGNORE_ASSOC_DISALLOWED]) { |
| 4260 | uint8_t ignore_assoc_disallowed; |
| 4261 | |
| 4262 | ignore_assoc_disallowed |
| 4263 | = nla_get_u8(tb[ |
| 4264 | QCA_WLAN_VENDOR_ATTR_CONFIG_IGNORE_ASSOC_DISALLOWED]); |
| 4265 | hdd_info("Set ignore_assoc_disallowed value - %d", |
| 4266 | ignore_assoc_disallowed); |
| 4267 | if ((ignore_assoc_disallowed < |
| 4268 | QCA_IGNORE_ASSOC_DISALLOWED_DISABLE) || |
| 4269 | (ignore_assoc_disallowed > |
| 4270 | QCA_IGNORE_ASSOC_DISALLOWED_ENABLE)) |
| 4271 | return -EPERM; |
| 4272 | |
| 4273 | sme_update_session_param(hdd_ctx->hHal, |
| 4274 | adapter->sessionId, |
| 4275 | SIR_PARAM_IGNORE_ASSOC_DISALLOWED, |
| 4276 | ignore_assoc_disallowed); |
| 4277 | } |
| 4278 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4279 | return ret_val; |
| 4280 | } |
| 4281 | |
| 4282 | /** |
| 4283 | * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration |
| 4284 | * vendor command |
| 4285 | * |
| 4286 | * @wiphy: wiphy device pointer |
| 4287 | * @wdev: wireless device pointer |
| 4288 | * @data: Vendor command data buffer |
| 4289 | * @data_len: Buffer length |
| 4290 | * |
| 4291 | * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX. |
| 4292 | * |
| 4293 | * Return: EOK or other error codes. |
| 4294 | */ |
| 4295 | static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, |
| 4296 | struct wireless_dev *wdev, |
| 4297 | const void *data, |
| 4298 | int data_len) |
| 4299 | { |
| 4300 | int ret; |
| 4301 | |
| 4302 | cds_ssr_protect(__func__); |
| 4303 | ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev, |
| 4304 | data, data_len); |
| 4305 | cds_ssr_unprotect(__func__); |
| 4306 | |
| 4307 | return ret; |
| 4308 | } |
| 4309 | |
| 4310 | static const struct |
| 4311 | nla_policy |
| 4312 | qca_wlan_vendor_wifi_logger_start_policy |
| 4313 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = { |
| 4314 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID] |
| 4315 | = {.type = NLA_U32 }, |
| 4316 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL] |
| 4317 | = {.type = NLA_U32 }, |
| 4318 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS] |
| 4319 | = {.type = NLA_U32 }, |
| 4320 | }; |
| 4321 | |
| 4322 | /** |
| 4323 | * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable |
| 4324 | * or disable the collection of packet statistics from the firmware |
| 4325 | * @wiphy: WIPHY structure pointer |
| 4326 | * @wdev: Wireless device structure pointer |
| 4327 | * @data: Pointer to the data received |
| 4328 | * @data_len: Length of the data received |
| 4329 | * |
| 4330 | * This function enables or disables the collection of packet statistics from |
| 4331 | * the firmware |
| 4332 | * |
| 4333 | * Return: 0 on success and errno on failure |
| 4334 | */ |
| 4335 | static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy, |
| 4336 | struct wireless_dev *wdev, |
| 4337 | const void *data, |
| 4338 | int data_len) |
| 4339 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4340 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4341 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 4342 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1]; |
| 4343 | struct sir_wifi_start_log start_log; |
| 4344 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 4345 | ENTER_DEV(wdev->netdev); |
| 4346 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4347 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4348 | hdd_err("Command not allowed in FTM mode"); |
| 4349 | return -EPERM; |
| 4350 | } |
| 4351 | |
| 4352 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4353 | if (status) |
| 4354 | return status; |
| 4355 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4356 | |
| 4357 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX, |
| 4358 | data, data_len, |
| 4359 | qca_wlan_vendor_wifi_logger_start_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4360 | hdd_err("Invalid attribute"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4361 | return -EINVAL; |
| 4362 | } |
| 4363 | |
| 4364 | /* Parse and fetch ring id */ |
| 4365 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4366 | hdd_err("attr ATTR failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4367 | return -EINVAL; |
| 4368 | } |
| 4369 | start_log.ring_id = nla_get_u32( |
| 4370 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]); |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 4371 | hdd_info("Ring ID=%d", start_log.ring_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4372 | |
| 4373 | /* Parse and fetch verbose level */ |
| 4374 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4375 | hdd_err("attr verbose_level failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4376 | return -EINVAL; |
| 4377 | } |
| 4378 | start_log.verbose_level = nla_get_u32( |
| 4379 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]); |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 4380 | hdd_info("verbose_level=%d", start_log.verbose_level); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4381 | |
| 4382 | /* Parse and fetch flag */ |
| 4383 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4384 | hdd_err("attr flag failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4385 | return -EINVAL; |
| 4386 | } |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 4387 | start_log.is_iwpriv_command = nla_get_u32( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4388 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]); |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 4389 | hdd_info("is_iwpriv_command =%d", start_log.is_iwpriv_command); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4390 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 4391 | /* size is buff size which can be set using iwpriv command*/ |
| 4392 | start_log.size = 0; |
| 4393 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4394 | cds_set_ring_log_level(start_log.ring_id, start_log.verbose_level); |
| 4395 | |
| 4396 | if (start_log.ring_id == RING_ID_WAKELOCK) { |
| 4397 | /* Start/stop wakelock events */ |
| 4398 | if (start_log.verbose_level > WLAN_LOG_LEVEL_OFF) |
| 4399 | cds_set_wakelock_logging(true); |
| 4400 | else |
| 4401 | cds_set_wakelock_logging(false); |
| 4402 | return 0; |
| 4403 | } |
| 4404 | |
| 4405 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4406 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4407 | hdd_err("sme_wifi_start_logger failed(err=%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4408 | status); |
| 4409 | return -EINVAL; |
| 4410 | } |
| 4411 | return 0; |
| 4412 | } |
| 4413 | |
| 4414 | /** |
| 4415 | * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable |
| 4416 | * or disable the collection of packet statistics from the firmware |
| 4417 | * @wiphy: WIPHY structure pointer |
| 4418 | * @wdev: Wireless device structure pointer |
| 4419 | * @data: Pointer to the data received |
| 4420 | * @data_len: Length of the data received |
| 4421 | * |
| 4422 | * This function is used to enable or disable the collection of packet |
| 4423 | * statistics from the firmware |
| 4424 | * |
| 4425 | * Return: 0 on success and errno on failure |
| 4426 | */ |
| 4427 | static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy, |
| 4428 | struct wireless_dev *wdev, |
| 4429 | const void *data, |
| 4430 | int data_len) |
| 4431 | { |
| 4432 | int ret = 0; |
| 4433 | |
| 4434 | cds_ssr_protect(__func__); |
| 4435 | ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy, |
| 4436 | wdev, data, data_len); |
| 4437 | cds_ssr_unprotect(__func__); |
| 4438 | |
| 4439 | return ret; |
| 4440 | } |
| 4441 | |
| 4442 | static const struct |
| 4443 | nla_policy |
| 4444 | qca_wlan_vendor_wifi_logger_get_ring_data_policy |
| 4445 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = { |
| 4446 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID] |
| 4447 | = {.type = NLA_U32 }, |
| 4448 | }; |
| 4449 | |
| 4450 | /** |
| 4451 | * __wlan_hdd_cfg80211_wifi_logger_get_ring_data() - Flush per packet stats |
| 4452 | * @wiphy: WIPHY structure pointer |
| 4453 | * @wdev: Wireless device structure pointer |
| 4454 | * @data: Pointer to the data received |
| 4455 | * @data_len: Length of the data received |
| 4456 | * |
| 4457 | * This function is used to flush or retrieve the per packet statistics from |
| 4458 | * the driver |
| 4459 | * |
| 4460 | * Return: 0 on success and errno on failure |
| 4461 | */ |
| 4462 | static int __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy, |
| 4463 | struct wireless_dev *wdev, |
| 4464 | const void *data, |
| 4465 | int data_len) |
| 4466 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4467 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4468 | uint32_t ring_id; |
| 4469 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 4470 | struct nlattr *tb |
| 4471 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1]; |
| 4472 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 4473 | ENTER_DEV(wdev->netdev); |
| 4474 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4475 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4476 | hdd_err("Command not allowed in FTM mode"); |
| 4477 | return -EPERM; |
| 4478 | } |
| 4479 | |
| 4480 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4481 | if (status) |
| 4482 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4483 | |
| 4484 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX, |
| 4485 | data, data_len, |
| 4486 | qca_wlan_vendor_wifi_logger_get_ring_data_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4487 | hdd_err("Invalid attribute"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4488 | return -EINVAL; |
| 4489 | } |
| 4490 | |
| 4491 | /* Parse and fetch ring id */ |
| 4492 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4493 | hdd_err("attr ATTR failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4494 | return -EINVAL; |
| 4495 | } |
| 4496 | |
| 4497 | ring_id = nla_get_u32( |
| 4498 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]); |
| 4499 | |
| 4500 | if (ring_id == RING_ID_PER_PACKET_STATS) { |
| 4501 | wlan_logging_set_per_pkt_stats(); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4502 | hdd_notice("Flushing/Retrieving packet stats"); |
Sreelakshmi Konamki | c3815ba | 2016-08-18 12:01:57 +0530 | [diff] [blame] | 4503 | } else if (ring_id == RING_ID_DRIVER_DEBUG) { |
| 4504 | /* |
| 4505 | * As part of DRIVER ring ID, flush both driver and fw logs. |
| 4506 | * For other Ring ID's driver doesn't have any rings to flush |
| 4507 | */ |
| 4508 | hdd_notice("Bug report triggered by framework"); |
| 4509 | |
| 4510 | status = cds_flush_logs(WLAN_LOG_TYPE_NON_FATAL, |
| 4511 | WLAN_LOG_INDICATOR_FRAMEWORK, |
| 4512 | WLAN_LOG_REASON_CODE_UNUSED, |
| 4513 | true, false); |
| 4514 | if (QDF_STATUS_SUCCESS != status) { |
| 4515 | hdd_err("Failed to trigger bug report"); |
| 4516 | return -EINVAL; |
| 4517 | } |
| 4518 | } else { |
| 4519 | wlan_report_log_completion(WLAN_LOG_TYPE_NON_FATAL, |
| 4520 | WLAN_LOG_INDICATOR_FRAMEWORK, |
| 4521 | WLAN_LOG_REASON_CODE_UNUSED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4522 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4523 | return 0; |
| 4524 | } |
| 4525 | |
| 4526 | /** |
| 4527 | * wlan_hdd_cfg80211_wifi_logger_get_ring_data() - Wrapper to flush packet stats |
| 4528 | * @wiphy: WIPHY structure pointer |
| 4529 | * @wdev: Wireless device structure pointer |
| 4530 | * @data: Pointer to the data received |
| 4531 | * @data_len: Length of the data received |
| 4532 | * |
| 4533 | * This function is used to flush or retrieve the per packet statistics from |
| 4534 | * the driver |
| 4535 | * |
| 4536 | * Return: 0 on success and errno on failure |
| 4537 | */ |
| 4538 | static int wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy, |
| 4539 | struct wireless_dev *wdev, |
| 4540 | const void *data, |
| 4541 | int data_len) |
| 4542 | { |
| 4543 | int ret = 0; |
| 4544 | |
| 4545 | cds_ssr_protect(__func__); |
| 4546 | ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy, |
| 4547 | wdev, data, data_len); |
| 4548 | cds_ssr_unprotect(__func__); |
| 4549 | |
| 4550 | return ret; |
| 4551 | } |
| 4552 | |
| 4553 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 4554 | /** |
| 4555 | * hdd_map_req_id_to_pattern_id() - map request id to pattern id |
| 4556 | * @hdd_ctx: HDD context |
| 4557 | * @request_id: [input] request id |
| 4558 | * @pattern_id: [output] pattern id |
| 4559 | * |
| 4560 | * This function loops through request id to pattern id array |
| 4561 | * if the slot is available, store the request id and return pattern id |
| 4562 | * if entry exists, return the pattern id |
| 4563 | * |
| 4564 | * Return: 0 on success and errno on failure |
| 4565 | */ |
| 4566 | static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx, |
| 4567 | uint32_t request_id, |
| 4568 | uint8_t *pattern_id) |
| 4569 | { |
| 4570 | uint32_t i; |
| 4571 | |
| 4572 | mutex_lock(&hdd_ctx->op_ctx.op_lock); |
| 4573 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 4574 | if (hdd_ctx->op_ctx.op_table[i].request_id == MAX_REQUEST_ID) { |
| 4575 | hdd_ctx->op_ctx.op_table[i].request_id = request_id; |
| 4576 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 4577 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 4578 | return 0; |
| 4579 | } else if (hdd_ctx->op_ctx.op_table[i].request_id == |
| 4580 | request_id) { |
| 4581 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 4582 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 4583 | return 0; |
| 4584 | } |
| 4585 | } |
| 4586 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 4587 | return -EINVAL; |
| 4588 | } |
| 4589 | |
| 4590 | /** |
| 4591 | * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id |
| 4592 | * @hdd_ctx: HDD context |
| 4593 | * @request_id: [input] request id |
| 4594 | * @pattern_id: [output] pattern id |
| 4595 | * |
| 4596 | * This function loops through request id to pattern id array |
| 4597 | * reset request id to 0 (slot available again) and |
| 4598 | * return pattern id |
| 4599 | * |
| 4600 | * Return: 0 on success and errno on failure |
| 4601 | */ |
| 4602 | static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx, |
| 4603 | uint32_t request_id, |
| 4604 | uint8_t *pattern_id) |
| 4605 | { |
| 4606 | uint32_t i; |
| 4607 | |
| 4608 | mutex_lock(&hdd_ctx->op_ctx.op_lock); |
| 4609 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 4610 | if (hdd_ctx->op_ctx.op_table[i].request_id == request_id) { |
| 4611 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 4612 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 4613 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 4614 | return 0; |
| 4615 | } |
| 4616 | } |
| 4617 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 4618 | return -EINVAL; |
| 4619 | } |
| 4620 | |
| 4621 | |
| 4622 | /* |
| 4623 | * define short names for the global vendor params |
| 4624 | * used by __wlan_hdd_cfg80211_offloaded_packets() |
| 4625 | */ |
| 4626 | #define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX |
| 4627 | #define PARAM_REQUEST_ID \ |
| 4628 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID |
| 4629 | #define PARAM_CONTROL \ |
| 4630 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL |
| 4631 | #define PARAM_IP_PACKET \ |
| 4632 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA |
| 4633 | #define PARAM_SRC_MAC_ADDR \ |
| 4634 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR |
| 4635 | #define PARAM_DST_MAC_ADDR \ |
| 4636 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR |
| 4637 | #define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD |
| 4638 | |
| 4639 | /** |
| 4640 | * wlan_hdd_add_tx_ptrn() - add tx pattern |
| 4641 | * @adapter: adapter pointer |
| 4642 | * @hdd_ctx: hdd context |
| 4643 | * @tb: nl attributes |
| 4644 | * |
| 4645 | * This function reads the NL attributes and forms a AddTxPtrn message |
| 4646 | * posts it to SME. |
| 4647 | * |
| 4648 | */ |
| 4649 | static int |
| 4650 | wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx, |
| 4651 | struct nlattr **tb) |
| 4652 | { |
| 4653 | struct sSirAddPeriodicTxPtrn *add_req; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4654 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4655 | uint32_t request_id, ret, len; |
| 4656 | uint8_t pattern_id = 0; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4657 | struct qdf_mac_addr dst_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4658 | uint16_t eth_type = htons(ETH_P_IP); |
| 4659 | |
| 4660 | if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4661 | hdd_err("Not in Connected state!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4662 | return -ENOTSUPP; |
| 4663 | } |
| 4664 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4665 | add_req = qdf_mem_malloc(sizeof(*add_req)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4666 | if (!add_req) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4667 | hdd_err("memory allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4668 | return -ENOMEM; |
| 4669 | } |
| 4670 | |
| 4671 | /* Parse and fetch request Id */ |
| 4672 | if (!tb[PARAM_REQUEST_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4673 | hdd_err("attr request id failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4674 | goto fail; |
| 4675 | } |
| 4676 | |
| 4677 | request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); |
| 4678 | if (request_id == MAX_REQUEST_ID) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4679 | hdd_err("request_id cannot be MAX"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4680 | return -EINVAL; |
| 4681 | } |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4682 | hdd_notice("Request Id: %u", request_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4683 | |
| 4684 | if (!tb[PARAM_PERIOD]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4685 | hdd_err("attr period failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4686 | goto fail; |
| 4687 | } |
| 4688 | add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4689 | hdd_notice("Period: %u ms", add_req->usPtrnIntervalMs); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4690 | if (add_req->usPtrnIntervalMs == 0) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4691 | hdd_err("Invalid interval zero, return failure"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4692 | goto fail; |
| 4693 | } |
| 4694 | |
| 4695 | if (!tb[PARAM_SRC_MAC_ADDR]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4696 | hdd_err("attr source mac address failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4697 | goto fail; |
| 4698 | } |
Srinivas Girigowda | 3189655 | 2015-11-18 22:59:52 -0800 | [diff] [blame] | 4699 | nla_memcpy(add_req->mac_address.bytes, tb[PARAM_SRC_MAC_ADDR], |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4700 | QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4701 | hdd_notice("input src mac address: "MAC_ADDRESS_STR, |
Srinivas Girigowda | 3189655 | 2015-11-18 22:59:52 -0800 | [diff] [blame] | 4702 | MAC_ADDR_ARRAY(add_req->mac_address.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4703 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4704 | if (!qdf_is_macaddr_equal(&add_req->mac_address, |
Srinivas Girigowda | 3189655 | 2015-11-18 22:59:52 -0800 | [diff] [blame] | 4705 | &adapter->macAddressCurrent)) { |
| 4706 | hdd_err("input src mac address and connected ap bssid are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4707 | goto fail; |
| 4708 | } |
| 4709 | |
| 4710 | if (!tb[PARAM_DST_MAC_ADDR]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4711 | hdd_err("attr dst mac address failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4712 | goto fail; |
| 4713 | } |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4714 | nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4715 | hdd_notice("input dst mac address: "MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4716 | MAC_ADDR_ARRAY(dst_addr.bytes)); |
| 4717 | |
| 4718 | if (!tb[PARAM_IP_PACKET]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4719 | hdd_err("attr ip packet failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4720 | goto fail; |
| 4721 | } |
| 4722 | add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4723 | hdd_notice("IP packet len: %u", add_req->ucPtrnSize); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4724 | |
| 4725 | if (add_req->ucPtrnSize < 0 || |
| 4726 | add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE - |
| 4727 | ETH_HLEN)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4728 | hdd_err("Invalid IP packet len: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4729 | add_req->ucPtrnSize); |
| 4730 | goto fail; |
| 4731 | } |
| 4732 | |
| 4733 | len = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4734 | 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] | 4735 | len += QDF_MAC_ADDR_SIZE; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4736 | qdf_mem_copy(&add_req->ucPattern[len], add_req->mac_address.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4737 | QDF_MAC_ADDR_SIZE); |
| 4738 | len += QDF_MAC_ADDR_SIZE; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4739 | qdf_mem_copy(&add_req->ucPattern[len], ð_type, 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4740 | len += 2; |
| 4741 | |
| 4742 | /* |
| 4743 | * This is the IP packet, add 14 bytes Ethernet (802.3) header |
| 4744 | * ------------------------------------------------------------ |
| 4745 | * | 14 bytes Ethernet (802.3) header | IP header and payload | |
| 4746 | * ------------------------------------------------------------ |
| 4747 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4748 | qdf_mem_copy(&add_req->ucPattern[len], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4749 | nla_data(tb[PARAM_IP_PACKET]), |
| 4750 | add_req->ucPtrnSize); |
| 4751 | add_req->ucPtrnSize += len; |
| 4752 | |
| 4753 | ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id); |
| 4754 | if (ret) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4755 | hdd_warn("req id to pattern id failed (ret=%d)", ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4756 | goto fail; |
| 4757 | } |
| 4758 | add_req->ucPtrnId = pattern_id; |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4759 | hdd_notice("pattern id: %d", add_req->ucPtrnId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4760 | |
| 4761 | status = sme_add_periodic_tx_ptrn(hdd_ctx->hHal, add_req); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4762 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4763 | hdd_err("sme_add_periodic_tx_ptrn failed (err=%d)", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4764 | goto fail; |
| 4765 | } |
| 4766 | |
| 4767 | EXIT(); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4768 | qdf_mem_free(add_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4769 | return 0; |
| 4770 | |
| 4771 | fail: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4772 | qdf_mem_free(add_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4773 | return -EINVAL; |
| 4774 | } |
| 4775 | |
| 4776 | /** |
| 4777 | * wlan_hdd_del_tx_ptrn() - delete tx pattern |
| 4778 | * @adapter: adapter pointer |
| 4779 | * @hdd_ctx: hdd context |
| 4780 | * @tb: nl attributes |
| 4781 | * |
| 4782 | * This function reads the NL attributes and forms a DelTxPtrn message |
| 4783 | * posts it to SME. |
| 4784 | * |
| 4785 | */ |
| 4786 | static int |
| 4787 | wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx, |
| 4788 | struct nlattr **tb) |
| 4789 | { |
| 4790 | struct sSirDelPeriodicTxPtrn *del_req; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4791 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4792 | uint32_t request_id, ret; |
| 4793 | uint8_t pattern_id = 0; |
| 4794 | |
| 4795 | /* Parse and fetch request Id */ |
| 4796 | if (!tb[PARAM_REQUEST_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4797 | hdd_err("attr request id failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4798 | return -EINVAL; |
| 4799 | } |
| 4800 | request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); |
| 4801 | if (request_id == MAX_REQUEST_ID) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4802 | hdd_err("request_id cannot be MAX"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4803 | return -EINVAL; |
| 4804 | } |
| 4805 | |
| 4806 | ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id); |
| 4807 | if (ret) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4808 | hdd_warn("req id to pattern id failed (ret=%d)", ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4809 | return -EINVAL; |
| 4810 | } |
| 4811 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4812 | del_req = qdf_mem_malloc(sizeof(*del_req)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4813 | if (!del_req) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4814 | hdd_err("memory allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4815 | return -ENOMEM; |
| 4816 | } |
| 4817 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4818 | qdf_copy_macaddr(&del_req->mac_address, &adapter->macAddressCurrent); |
Srinivas Girigowda | a5bba7a | 2015-11-18 22:44:36 -0800 | [diff] [blame] | 4819 | hdd_info(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->mac_address.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4820 | del_req->ucPtrnId = pattern_id; |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4821 | hdd_notice("Request Id: %u Pattern id: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4822 | request_id, del_req->ucPtrnId); |
| 4823 | |
| 4824 | status = sme_del_periodic_tx_ptrn(hdd_ctx->hHal, del_req); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4825 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4826 | hdd_err("sme_del_periodic_tx_ptrn failed (err=%d)", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4827 | goto fail; |
| 4828 | } |
| 4829 | |
| 4830 | EXIT(); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4831 | qdf_mem_free(del_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4832 | return 0; |
| 4833 | |
| 4834 | fail: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4835 | qdf_mem_free(del_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4836 | return -EINVAL; |
| 4837 | } |
| 4838 | |
| 4839 | |
| 4840 | /** |
| 4841 | * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets |
| 4842 | * @wiphy: Pointer to wireless phy |
| 4843 | * @wdev: Pointer to wireless device |
| 4844 | * @data: Pointer to data |
| 4845 | * @data_len: Data length |
| 4846 | * |
| 4847 | * Return: 0 on success, negative errno on failure |
| 4848 | */ |
| 4849 | static int |
| 4850 | __wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy, |
| 4851 | struct wireless_dev *wdev, |
| 4852 | const void *data, |
| 4853 | int data_len) |
| 4854 | { |
| 4855 | struct net_device *dev = wdev->netdev; |
| 4856 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4857 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 4858 | struct nlattr *tb[PARAM_MAX + 1]; |
| 4859 | uint8_t control; |
| 4860 | int ret; |
| 4861 | static const struct nla_policy policy[PARAM_MAX + 1] = { |
| 4862 | [PARAM_REQUEST_ID] = { .type = NLA_U32 }, |
| 4863 | [PARAM_CONTROL] = { .type = NLA_U32 }, |
| 4864 | [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4865 | .len = QDF_MAC_ADDR_SIZE }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4866 | [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4867 | .len = QDF_MAC_ADDR_SIZE }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4868 | [PARAM_PERIOD] = { .type = NLA_U32 }, |
| 4869 | }; |
| 4870 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 4871 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4872 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4873 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4874 | hdd_err("Command not allowed in FTM mode"); |
| 4875 | return -EPERM; |
| 4876 | } |
| 4877 | |
| 4878 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4879 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4880 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4881 | |
| 4882 | if (!sme_is_feature_supported_by_fw(WLAN_PERIODIC_TX_PTRN)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4883 | hdd_err("Periodic Tx Pattern Offload feature is not supported in FW!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4884 | return -ENOTSUPP; |
| 4885 | } |
| 4886 | |
| 4887 | if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4888 | hdd_err("Invalid ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4889 | return -EINVAL; |
| 4890 | } |
| 4891 | |
| 4892 | if (!tb[PARAM_CONTROL]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4893 | hdd_err("attr control failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4894 | return -EINVAL; |
| 4895 | } |
| 4896 | control = nla_get_u32(tb[PARAM_CONTROL]); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4897 | hdd_notice("Control: %d", control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4898 | |
| 4899 | if (control == WLAN_START_OFFLOADED_PACKETS) |
| 4900 | return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb); |
| 4901 | else if (control == WLAN_STOP_OFFLOADED_PACKETS) |
| 4902 | return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb); |
| 4903 | else { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4904 | hdd_err("Invalid control: %d", control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4905 | return -EINVAL; |
| 4906 | } |
| 4907 | } |
| 4908 | |
| 4909 | /* |
| 4910 | * done with short names for the global vendor params |
| 4911 | * used by __wlan_hdd_cfg80211_offloaded_packets() |
| 4912 | */ |
| 4913 | #undef PARAM_MAX |
| 4914 | #undef PARAM_REQUEST_ID |
| 4915 | #undef PARAM_CONTROL |
| 4916 | #undef PARAM_IP_PACKET |
| 4917 | #undef PARAM_SRC_MAC_ADDR |
| 4918 | #undef PARAM_DST_MAC_ADDR |
| 4919 | #undef PARAM_PERIOD |
| 4920 | |
| 4921 | /** |
| 4922 | * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets |
| 4923 | * @wiphy: wiphy structure pointer |
| 4924 | * @wdev: Wireless device structure pointer |
| 4925 | * @data: Pointer to the data received |
| 4926 | * @data_len: Length of @data |
| 4927 | * |
| 4928 | * Return: 0 on success; errno on failure |
| 4929 | */ |
| 4930 | static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy, |
| 4931 | struct wireless_dev *wdev, |
| 4932 | const void *data, |
| 4933 | int data_len) |
| 4934 | { |
| 4935 | int ret = 0; |
| 4936 | |
| 4937 | cds_ssr_protect(__func__); |
| 4938 | ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy, |
| 4939 | wdev, data, data_len); |
| 4940 | cds_ssr_unprotect(__func__); |
| 4941 | |
| 4942 | return ret; |
| 4943 | } |
| 4944 | #endif |
| 4945 | |
| 4946 | /* |
| 4947 | * define short names for the global vendor params |
| 4948 | * used by __wlan_hdd_cfg80211_monitor_rssi() |
| 4949 | */ |
| 4950 | #define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX |
| 4951 | #define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID |
| 4952 | #define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL |
| 4953 | #define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI |
| 4954 | #define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI |
| 4955 | |
| 4956 | /** |
| 4957 | * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi |
| 4958 | * @wiphy: Pointer to wireless phy |
| 4959 | * @wdev: Pointer to wireless device |
| 4960 | * @data: Pointer to data |
| 4961 | * @data_len: Data length |
| 4962 | * |
| 4963 | * Return: 0 on success, negative errno on failure |
| 4964 | */ |
| 4965 | static int |
| 4966 | __wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, |
| 4967 | struct wireless_dev *wdev, |
| 4968 | const void *data, |
| 4969 | int data_len) |
| 4970 | { |
| 4971 | struct net_device *dev = wdev->netdev; |
| 4972 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4973 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 4974 | struct nlattr *tb[PARAM_MAX + 1]; |
| 4975 | struct rssi_monitor_req req; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4976 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4977 | int ret; |
| 4978 | uint32_t control; |
| 4979 | static const struct nla_policy policy[PARAM_MAX + 1] = { |
| 4980 | [PARAM_REQUEST_ID] = { .type = NLA_U32 }, |
| 4981 | [PARAM_CONTROL] = { .type = NLA_U32 }, |
| 4982 | [PARAM_MIN_RSSI] = { .type = NLA_S8 }, |
| 4983 | [PARAM_MAX_RSSI] = { .type = NLA_S8 }, |
| 4984 | }; |
| 4985 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 4986 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4987 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 4988 | if (wlan_hdd_validate_session_id(adapter->sessionId)) { |
| 4989 | hdd_err("invalid session id: %d", adapter->sessionId); |
| 4990 | return -EINVAL; |
| 4991 | } |
| 4992 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4993 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4994 | if (ret) |
| 4995 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4996 | |
| 4997 | if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 4998 | hdd_err("Not in Connected state!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4999 | return -ENOTSUPP; |
| 5000 | } |
| 5001 | |
| 5002 | if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5003 | hdd_err("Invalid ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5004 | return -EINVAL; |
| 5005 | } |
| 5006 | |
| 5007 | if (!tb[PARAM_REQUEST_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5008 | hdd_err("attr request id failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5009 | return -EINVAL; |
| 5010 | } |
| 5011 | |
| 5012 | if (!tb[PARAM_CONTROL]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5013 | hdd_err("attr control failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5014 | return -EINVAL; |
| 5015 | } |
| 5016 | |
| 5017 | req.request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); |
| 5018 | req.session_id = adapter->sessionId; |
| 5019 | control = nla_get_u32(tb[PARAM_CONTROL]); |
| 5020 | |
| 5021 | if (control == QCA_WLAN_RSSI_MONITORING_START) { |
| 5022 | req.control = true; |
| 5023 | if (!tb[PARAM_MIN_RSSI]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5024 | hdd_err("attr min rssi failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5025 | return -EINVAL; |
| 5026 | } |
| 5027 | |
| 5028 | if (!tb[PARAM_MAX_RSSI]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5029 | hdd_err("attr max rssi failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5030 | return -EINVAL; |
| 5031 | } |
| 5032 | |
| 5033 | req.min_rssi = nla_get_s8(tb[PARAM_MIN_RSSI]); |
| 5034 | req.max_rssi = nla_get_s8(tb[PARAM_MAX_RSSI]); |
| 5035 | |
| 5036 | if (!(req.min_rssi < req.max_rssi)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5037 | hdd_warn("min_rssi: %d must be less than max_rssi: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5038 | req.min_rssi, req.max_rssi); |
| 5039 | return -EINVAL; |
| 5040 | } |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5041 | hdd_notice("Min_rssi: %d Max_rssi: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5042 | req.min_rssi, req.max_rssi); |
| 5043 | |
| 5044 | } else if (control == QCA_WLAN_RSSI_MONITORING_STOP) |
| 5045 | req.control = false; |
| 5046 | else { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5047 | hdd_err("Invalid control cmd: %d", control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5048 | return -EINVAL; |
| 5049 | } |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5050 | hdd_notice("Request Id: %u Session_id: %d Control: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5051 | req.request_id, req.session_id, req.control); |
| 5052 | |
| 5053 | status = sme_set_rssi_monitoring(hdd_ctx->hHal, &req); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5054 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5055 | hdd_err("sme_set_rssi_monitoring failed(err=%d)", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5056 | return -EINVAL; |
| 5057 | } |
| 5058 | |
| 5059 | return 0; |
| 5060 | } |
| 5061 | |
| 5062 | /* |
| 5063 | * done with short names for the global vendor params |
| 5064 | * used by __wlan_hdd_cfg80211_monitor_rssi() |
| 5065 | */ |
| 5066 | #undef PARAM_MAX |
| 5067 | #undef PARAM_CONTROL |
| 5068 | #undef PARAM_REQUEST_ID |
| 5069 | #undef PARAM_MAX_RSSI |
| 5070 | #undef PARAM_MIN_RSSI |
| 5071 | |
| 5072 | /** |
| 5073 | * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring |
| 5074 | * @wiphy: wiphy structure pointer |
| 5075 | * @wdev: Wireless device structure pointer |
| 5076 | * @data: Pointer to the data received |
| 5077 | * @data_len: Length of @data |
| 5078 | * |
| 5079 | * Return: 0 on success; errno on failure |
| 5080 | */ |
| 5081 | static int |
| 5082 | wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 5083 | const void *data, int data_len) |
| 5084 | { |
| 5085 | int ret; |
| 5086 | |
| 5087 | cds_ssr_protect(__func__); |
| 5088 | ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len); |
| 5089 | cds_ssr_unprotect(__func__); |
| 5090 | |
| 5091 | return ret; |
| 5092 | } |
| 5093 | |
| 5094 | /** |
| 5095 | * hdd_rssi_threshold_breached() - rssi breached NL event |
| 5096 | * @hddctx: HDD context |
| 5097 | * @data: rssi breached event data |
| 5098 | * |
| 5099 | * This function reads the rssi breached event %data and fill in the skb with |
| 5100 | * NL attributes and send up the NL event. |
| 5101 | * |
| 5102 | * Return: none |
| 5103 | */ |
| 5104 | void hdd_rssi_threshold_breached(void *hddctx, |
| 5105 | struct rssi_breach_event *data) |
| 5106 | { |
| 5107 | hdd_context_t *hdd_ctx = hddctx; |
| 5108 | struct sk_buff *skb; |
| 5109 | |
| 5110 | ENTER(); |
| 5111 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 5112 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 5113 | return; |
| 5114 | if (!data) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5115 | hdd_err("data is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5116 | return; |
| 5117 | } |
| 5118 | |
| 5119 | skb = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
| 5120 | NULL, |
| 5121 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 5122 | QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX, |
| 5123 | GFP_KERNEL); |
| 5124 | |
| 5125 | if (!skb) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5126 | hdd_err("cfg80211_vendor_event_alloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5127 | return; |
| 5128 | } |
| 5129 | |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5130 | hdd_notice("Req Id: %u Current rssi: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5131 | data->request_id, data->curr_rssi); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5132 | hdd_notice("Current BSSID: "MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5133 | MAC_ADDR_ARRAY(data->curr_bssid.bytes)); |
| 5134 | |
| 5135 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID, |
| 5136 | data->request_id) || |
| 5137 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID, |
| 5138 | sizeof(data->curr_bssid), data->curr_bssid.bytes) || |
| 5139 | nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI, |
| 5140 | data->curr_rssi)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5141 | hdd_err("nla put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5142 | goto fail; |
| 5143 | } |
| 5144 | |
| 5145 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 5146 | return; |
| 5147 | |
| 5148 | fail: |
| 5149 | kfree_skb(skb); |
| 5150 | return; |
| 5151 | } |
| 5152 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 5153 | static const struct nla_policy |
| 5154 | ns_offload_set_policy[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_MAX + 1] = { |
| 5155 | [QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_FLAG] = {.type = NLA_U8}, |
| 5156 | }; |
| 5157 | |
| 5158 | /** |
| 5159 | * __wlan_hdd_cfg80211_set_ns_offload() - enable/disable NS offload |
| 5160 | * @wiphy: Pointer to wireless phy |
| 5161 | * @wdev: Pointer to wireless device |
| 5162 | * @data: Pointer to data |
| 5163 | * @data_len: Length of @data |
| 5164 | * |
| 5165 | * Return: 0 on success, negative errno on failure |
| 5166 | */ |
| 5167 | static int |
| 5168 | __wlan_hdd_cfg80211_set_ns_offload(struct wiphy *wiphy, |
| 5169 | struct wireless_dev *wdev, |
| 5170 | const void *data, int data_len) |
| 5171 | { |
| 5172 | int status; |
| 5173 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_MAX + 1]; |
| 5174 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Dustin Brown | d8279d2 | 2016-09-07 14:52:57 -0700 | [diff] [blame] | 5175 | struct net_device *dev = wdev->netdev; |
| 5176 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 5177 | |
| 5178 | ENTER_DEV(wdev->netdev); |
| 5179 | |
| 5180 | status = wlan_hdd_validate_context(pHddCtx); |
| 5181 | if (0 != status) |
| 5182 | return status; |
| 5183 | if (!pHddCtx->config->fhostNSOffload) { |
| 5184 | hdd_err("ND Offload not supported"); |
| 5185 | return -EINVAL; |
| 5186 | } |
| 5187 | |
| 5188 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_MAX, |
| 5189 | (struct nlattr *)data, |
| 5190 | data_len, ns_offload_set_policy)) { |
| 5191 | hdd_err("nla_parse failed"); |
| 5192 | return -EINVAL; |
| 5193 | } |
| 5194 | |
| 5195 | if (!tb[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_FLAG]) { |
| 5196 | hdd_err("ND Offload flag attribute not present"); |
| 5197 | return -EINVAL; |
| 5198 | } |
| 5199 | |
| 5200 | pHddCtx->ns_offload_enable = |
| 5201 | nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_ND_OFFLOAD_FLAG]); |
| 5202 | |
Dustin Brown | d8279d2 | 2016-09-07 14:52:57 -0700 | [diff] [blame] | 5203 | /* update ns offload in case it is already enabled/disabled */ |
| 5204 | hdd_conf_ns_offload(adapter, pHddCtx->ns_offload_enable); |
| 5205 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 5206 | return 0; |
| 5207 | } |
| 5208 | |
| 5209 | /** |
| 5210 | * wlan_hdd_cfg80211_set_ns_offload() - enable/disable NS offload |
| 5211 | * @wiphy: pointer to wireless wiphy structure. |
| 5212 | * @wdev: pointer to wireless_dev structure. |
| 5213 | * @data: Pointer to the data to be passed via vendor interface |
| 5214 | * @data_len:Length of the data to be passed |
| 5215 | * |
| 5216 | * Return: Return the Success or Failure code. |
| 5217 | */ |
| 5218 | static int wlan_hdd_cfg80211_set_ns_offload(struct wiphy *wiphy, |
| 5219 | struct wireless_dev *wdev, |
| 5220 | const void *data, int data_len) |
| 5221 | { |
| 5222 | int ret; |
| 5223 | |
| 5224 | cds_ssr_protect(__func__); |
| 5225 | ret = __wlan_hdd_cfg80211_set_ns_offload(wiphy, wdev, data, data_len); |
| 5226 | cds_ssr_unprotect(__func__); |
| 5227 | |
| 5228 | return ret; |
| 5229 | } |
| 5230 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5231 | /** __wlan_hdd_cfg80211_get_preferred_freq_list() - get preferred frequency list |
| 5232 | * @wiphy: Pointer to wireless phy |
| 5233 | * @wdev: Pointer to wireless device |
| 5234 | * @data: Pointer to data |
| 5235 | * @data_len: Data length |
| 5236 | * |
| 5237 | * This function return the preferred frequency list generated by the policy |
| 5238 | * manager. |
| 5239 | * |
| 5240 | * Return: success or failure code |
| 5241 | */ |
| 5242 | static int __wlan_hdd_cfg80211_get_preferred_freq_list(struct wiphy *wiphy, |
| 5243 | struct wireless_dev |
| 5244 | *wdev, const void *data, |
| 5245 | int data_len) |
| 5246 | { |
| 5247 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 5248 | int i, ret = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5249 | QDF_STATUS status; |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 5250 | 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] | 5251 | uint32_t pcl_len = 0; |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 5252 | uint32_t freq_list[QDF_MAX_NUM_CHAN]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5253 | enum cds_con_mode intf_mode; |
| 5254 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_MAX + 1]; |
| 5255 | struct sk_buff *reply_skb; |
| 5256 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 5257 | ENTER_DEV(wdev->netdev); |
| 5258 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5259 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 5260 | if (ret) |
| 5261 | return -EINVAL; |
| 5262 | |
| 5263 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_MAX, |
| 5264 | data, data_len, NULL)) { |
| 5265 | hdd_err("Invalid ATTR"); |
| 5266 | return -EINVAL; |
| 5267 | } |
| 5268 | |
| 5269 | if (!tb[QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_IFACE_TYPE]) { |
| 5270 | hdd_err("attr interface type failed"); |
| 5271 | return -EINVAL; |
| 5272 | } |
| 5273 | |
| 5274 | intf_mode = nla_get_u32(tb |
| 5275 | [QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_IFACE_TYPE]); |
| 5276 | |
| 5277 | if (intf_mode < CDS_STA_MODE || intf_mode >= CDS_MAX_NUM_OF_MODE) { |
| 5278 | hdd_err("Invalid interface type"); |
| 5279 | return -EINVAL; |
| 5280 | } |
| 5281 | |
| 5282 | hdd_debug("Userspace requested pref freq list"); |
| 5283 | |
Manishekar Chandrasekaran | 7009f25 | 2016-04-21 19:14:15 +0530 | [diff] [blame] | 5284 | status = cds_get_pcl(intf_mode, pcl, &pcl_len, |
| 5285 | weight_list, QDF_ARRAY_SIZE(weight_list)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5286 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5287 | hdd_err("Get pcl failed"); |
| 5288 | return -EINVAL; |
| 5289 | } |
| 5290 | |
| 5291 | /* convert channel number to frequency */ |
| 5292 | for (i = 0; i < pcl_len; i++) { |
| 5293 | if (pcl[i] <= ARRAY_SIZE(hdd_channels_2_4_ghz)) |
| 5294 | freq_list[i] = |
| 5295 | ieee80211_channel_to_frequency(pcl[i], |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 5296 | NL80211_BAND_2GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5297 | else |
| 5298 | freq_list[i] = |
| 5299 | ieee80211_channel_to_frequency(pcl[i], |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 5300 | NL80211_BAND_5GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5301 | } |
| 5302 | |
| 5303 | /* send the freq_list back to supplicant */ |
| 5304 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) + |
| 5305 | sizeof(u32) * |
| 5306 | pcl_len + |
| 5307 | NLMSG_HDRLEN); |
| 5308 | |
| 5309 | if (!reply_skb) { |
| 5310 | hdd_err("Allocate reply_skb failed"); |
| 5311 | return -EINVAL; |
| 5312 | } |
| 5313 | |
| 5314 | if (nla_put_u32(reply_skb, |
| 5315 | QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_IFACE_TYPE, |
| 5316 | intf_mode) || |
| 5317 | nla_put(reply_skb, |
| 5318 | QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST, |
| 5319 | sizeof(uint32_t) * pcl_len, |
| 5320 | freq_list)) { |
| 5321 | hdd_err("nla put fail"); |
| 5322 | kfree_skb(reply_skb); |
| 5323 | return -EINVAL; |
| 5324 | } |
| 5325 | |
| 5326 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 5327 | } |
| 5328 | |
| 5329 | /** wlan_hdd_cfg80211_get_preferred_freq_list () - get preferred frequency list |
| 5330 | * @wiphy: Pointer to wireless phy |
| 5331 | * @wdev: Pointer to wireless device |
| 5332 | * @data: Pointer to data |
| 5333 | * @data_len: Data length |
| 5334 | * |
| 5335 | * This function return the preferred frequency list generated by the policy |
| 5336 | * manager. |
| 5337 | * |
| 5338 | * Return: success or failure code |
| 5339 | */ |
| 5340 | static int wlan_hdd_cfg80211_get_preferred_freq_list(struct wiphy *wiphy, |
| 5341 | struct wireless_dev |
| 5342 | *wdev, const void *data, |
| 5343 | int data_len) |
| 5344 | { |
| 5345 | int ret = 0; |
| 5346 | |
| 5347 | cds_ssr_protect(__func__); |
| 5348 | ret = __wlan_hdd_cfg80211_get_preferred_freq_list(wiphy, wdev, |
| 5349 | data, data_len); |
| 5350 | cds_ssr_unprotect(__func__); |
| 5351 | |
| 5352 | return ret; |
| 5353 | } |
| 5354 | |
| 5355 | /** |
| 5356 | * __wlan_hdd_cfg80211_set_probable_oper_channel () - set probable channel |
| 5357 | * @wiphy: Pointer to wireless phy |
| 5358 | * @wdev: Pointer to wireless device |
| 5359 | * @data: Pointer to data |
| 5360 | * @data_len: Data length |
| 5361 | * |
| 5362 | * Return: 0 on success, negative errno on failure |
| 5363 | */ |
| 5364 | static int __wlan_hdd_cfg80211_set_probable_oper_channel(struct wiphy *wiphy, |
| 5365 | struct wireless_dev *wdev, |
| 5366 | const void *data, |
| 5367 | int data_len) |
| 5368 | { |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 5369 | struct net_device *ndev = wdev->netdev; |
| 5370 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5371 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 5372 | int ret = 0; |
| 5373 | enum cds_con_mode intf_mode; |
| 5374 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_PREFERRED_FREQ_LIST_MAX + 1]; |
| 5375 | uint32_t channel_hint; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5376 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 5377 | ENTER_DEV(ndev); |
| 5378 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5379 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 5380 | if (ret) |
| 5381 | return ret; |
| 5382 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5383 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_MAX, |
| 5384 | data, data_len, NULL)) { |
| 5385 | hdd_err("Invalid ATTR"); |
| 5386 | return -EINVAL; |
| 5387 | } |
| 5388 | |
| 5389 | if (!tb[QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_IFACE_TYPE]) { |
| 5390 | hdd_err("attr interface type failed"); |
| 5391 | return -EINVAL; |
| 5392 | } |
| 5393 | |
| 5394 | intf_mode = nla_get_u32(tb |
| 5395 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_IFACE_TYPE]); |
| 5396 | |
| 5397 | if (intf_mode < CDS_STA_MODE || intf_mode >= CDS_MAX_NUM_OF_MODE) { |
| 5398 | hdd_err("Invalid interface type"); |
| 5399 | return -EINVAL; |
| 5400 | } |
| 5401 | |
| 5402 | if (!tb[QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_FREQ]) { |
| 5403 | hdd_err("attr probable freq failed"); |
| 5404 | return -EINVAL; |
| 5405 | } |
| 5406 | |
| 5407 | channel_hint = cds_freq_to_chan(nla_get_u32(tb |
| 5408 | [QCA_WLAN_VENDOR_ATTR_PROBABLE_OPER_CHANNEL_FREQ])); |
| 5409 | |
| 5410 | /* check pcl table */ |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 5411 | if (!cds_allow_concurrency(intf_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5412 | channel_hint, HW_MODE_20_MHZ)) { |
| 5413 | hdd_err("Set channel hint failed due to concurrency check"); |
| 5414 | return -EINVAL; |
| 5415 | } |
| 5416 | |
Krunal Soni | 09e5503 | 2016-06-07 10:06:55 -0700 | [diff] [blame] | 5417 | if (0 != wlan_hdd_check_remain_on_channel(adapter)) |
| 5418 | hdd_warn("Remain On Channel Pending"); |
| 5419 | |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 5420 | ret = qdf_reset_connection_update(); |
| 5421 | if (!QDF_IS_STATUS_SUCCESS(ret)) |
| 5422 | hdd_err("clearing event failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5423 | |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 5424 | ret = cds_current_connections_update(adapter->sessionId, |
| 5425 | channel_hint, |
| 5426 | SIR_UPDATE_REASON_SET_OPER_CHAN); |
| 5427 | if (QDF_STATUS_E_FAILURE == ret) { |
| 5428 | /* return in the failure case */ |
| 5429 | hdd_err("ERROR: connections update failed!!"); |
| 5430 | return -EINVAL; |
| 5431 | } |
| 5432 | |
| 5433 | if (QDF_STATUS_SUCCESS == ret) { |
| 5434 | /* |
| 5435 | * Success is the only case for which we expect hw mode |
| 5436 | * change to take place, hence we need to wait. |
| 5437 | * For any other return value it should be a pass |
| 5438 | * through |
| 5439 | */ |
| 5440 | ret = qdf_wait_for_connection_update(); |
| 5441 | if (!QDF_IS_STATUS_SUCCESS(ret)) { |
| 5442 | hdd_err("ERROR: qdf wait for event failed!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5443 | return -EINVAL; |
| 5444 | } |
| 5445 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5446 | } |
| 5447 | |
| 5448 | return 0; |
| 5449 | } |
| 5450 | |
| 5451 | /** |
| 5452 | * wlan_hdd_cfg80211_set_probable_oper_channel () - set probable channel |
| 5453 | * @wiphy: Pointer to wireless phy |
| 5454 | * @wdev: Pointer to wireless device |
| 5455 | * @data: Pointer to data |
| 5456 | * @data_len: Data length |
| 5457 | * |
| 5458 | * Return: 0 on success, negative errno on failure |
| 5459 | */ |
| 5460 | static int wlan_hdd_cfg80211_set_probable_oper_channel(struct wiphy *wiphy, |
| 5461 | struct wireless_dev *wdev, |
| 5462 | const void *data, |
| 5463 | int data_len) |
| 5464 | { |
| 5465 | int ret = 0; |
| 5466 | |
| 5467 | cds_ssr_protect(__func__); |
| 5468 | ret = __wlan_hdd_cfg80211_set_probable_oper_channel(wiphy, wdev, |
| 5469 | data, data_len); |
| 5470 | cds_ssr_unprotect(__func__); |
| 5471 | |
| 5472 | return ret; |
| 5473 | } |
| 5474 | |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5475 | static const struct |
| 5476 | nla_policy |
| 5477 | qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = { |
| 5478 | [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC }, |
| 5479 | }; |
| 5480 | |
| 5481 | /** |
| 5482 | * __wlan_hdd_cfg80211_get_link_properties() - Get link properties |
| 5483 | * @wiphy: WIPHY structure pointer |
| 5484 | * @wdev: Wireless device structure pointer |
| 5485 | * @data: Pointer to the data received |
| 5486 | * @data_len: Length of the data received |
| 5487 | * |
| 5488 | * This function is used to get link properties like nss, rate flags and |
| 5489 | * operating frequency for the active connection with the given peer. |
| 5490 | * |
| 5491 | * Return: 0 on success and errno on failure |
| 5492 | */ |
| 5493 | static int __wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy, |
| 5494 | struct wireless_dev *wdev, |
| 5495 | const void *data, |
| 5496 | int data_len) |
| 5497 | { |
| 5498 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 5499 | struct net_device *dev = wdev->netdev; |
| 5500 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5501 | hdd_station_ctx_t *hdd_sta_ctx; |
| 5502 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1]; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5503 | uint8_t peer_mac[QDF_MAC_ADDR_SIZE]; |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5504 | uint32_t sta_id; |
| 5505 | struct sk_buff *reply_skb; |
| 5506 | uint32_t rate_flags = 0; |
| 5507 | uint8_t nss; |
| 5508 | uint8_t final_rate_flags = 0; |
| 5509 | uint32_t freq; |
| 5510 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 5511 | ENTER_DEV(dev); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5512 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5513 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5514 | hdd_err("Command not allowed in FTM mode"); |
| 5515 | return -EPERM; |
| 5516 | } |
| 5517 | |
| 5518 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 5519 | return -EINVAL; |
| 5520 | |
| 5521 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len, |
| 5522 | qca_wlan_vendor_attr_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5523 | hdd_err("Invalid attribute"); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5524 | return -EINVAL; |
| 5525 | } |
| 5526 | |
| 5527 | if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5528 | hdd_err("Attribute peerMac not provided for mode=%d", |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5529 | adapter->device_mode); |
| 5530 | return -EINVAL; |
| 5531 | } |
| 5532 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5533 | 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] | 5534 | QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5535 | hdd_notice("peerMac="MAC_ADDRESS_STR" for device_mode:%d", |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5536 | MAC_ADDR_ARRAY(peer_mac), adapter->device_mode); |
| 5537 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 5538 | if (adapter->device_mode == QDF_STA_MODE || |
| 5539 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5540 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5541 | if ((hdd_sta_ctx->conn_info.connState != |
| 5542 | eConnectionState_Associated) || |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5543 | qdf_mem_cmp(hdd_sta_ctx->conn_info.bssId.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5544 | peer_mac, QDF_MAC_ADDR_SIZE)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5545 | hdd_err("Not Associated to mac "MAC_ADDRESS_STR, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5546 | MAC_ADDR_ARRAY(peer_mac)); |
| 5547 | return -EINVAL; |
| 5548 | } |
| 5549 | |
| 5550 | nss = hdd_sta_ctx->conn_info.nss; |
| 5551 | freq = cds_chan_to_freq( |
| 5552 | hdd_sta_ctx->conn_info.operationChannel); |
| 5553 | rate_flags = hdd_sta_ctx->conn_info.rate_flags; |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 5554 | } else if (adapter->device_mode == QDF_P2P_GO_MODE || |
| 5555 | adapter->device_mode == QDF_SAP_MODE) { |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5556 | |
| 5557 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5558 | if (adapter->aStaInfo[sta_id].isUsed && |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5559 | !qdf_is_macaddr_broadcast( |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5560 | &adapter->aStaInfo[sta_id].macAddrSTA) && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5561 | !qdf_mem_cmp( |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5562 | &adapter->aStaInfo[sta_id].macAddrSTA.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5563 | peer_mac, QDF_MAC_ADDR_SIZE)) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5564 | break; |
| 5565 | } |
| 5566 | |
| 5567 | if (WLAN_MAX_STA_COUNT == sta_id) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5568 | hdd_err("No active peer with mac="MAC_ADDRESS_STR, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5569 | MAC_ADDR_ARRAY(peer_mac)); |
| 5570 | return -EINVAL; |
| 5571 | } |
| 5572 | |
| 5573 | nss = adapter->aStaInfo[sta_id].nss; |
| 5574 | freq = cds_chan_to_freq( |
| 5575 | (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel); |
| 5576 | rate_flags = adapter->aStaInfo[sta_id].rate_flags; |
| 5577 | } else { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5578 | hdd_err("Not Associated! with mac "MAC_ADDRESS_STR, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5579 | MAC_ADDR_ARRAY(peer_mac)); |
| 5580 | return -EINVAL; |
| 5581 | } |
| 5582 | |
| 5583 | if (!(rate_flags & eHAL_TX_RATE_LEGACY)) { |
| 5584 | if (rate_flags & eHAL_TX_RATE_VHT80) { |
| 5585 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 5586 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && !defined(WITH_BACKPORTS) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5587 | final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 5588 | #endif |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5589 | } else if (rate_flags & eHAL_TX_RATE_VHT40) { |
| 5590 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 5591 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && !defined(WITH_BACKPORTS) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5592 | final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 5593 | #endif |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5594 | } else if (rate_flags & eHAL_TX_RATE_VHT20) { |
| 5595 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 5596 | } else if (rate_flags & |
| 5597 | (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) { |
| 5598 | final_rate_flags |= RATE_INFO_FLAGS_MCS; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 5599 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && !defined(WITH_BACKPORTS) |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5600 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 5601 | final_rate_flags |= |
| 5602 | RATE_INFO_FLAGS_40_MHZ_WIDTH; |
Ryan Hsu | 3a0f523 | 2016-01-21 14:40:11 -0800 | [diff] [blame] | 5603 | #endif |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5604 | } |
| 5605 | |
| 5606 | if (rate_flags & eHAL_TX_RATE_SGI) { |
| 5607 | if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS)) |
| 5608 | final_rate_flags |= RATE_INFO_FLAGS_MCS; |
| 5609 | final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 5610 | } |
| 5611 | } |
| 5612 | |
| 5613 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 5614 | sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN); |
| 5615 | |
| 5616 | if (NULL == reply_skb) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5617 | hdd_err("getLinkProperties: skb alloc failed"); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5618 | return -EINVAL; |
| 5619 | } |
| 5620 | |
| 5621 | if (nla_put_u8(reply_skb, |
| 5622 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS, |
| 5623 | nss) || |
| 5624 | nla_put_u8(reply_skb, |
| 5625 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS, |
| 5626 | final_rate_flags) || |
| 5627 | nla_put_u32(reply_skb, |
| 5628 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ, |
| 5629 | freq)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 5630 | hdd_err("nla_put failed"); |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 5631 | kfree_skb(reply_skb); |
| 5632 | return -EINVAL; |
| 5633 | } |
| 5634 | |
| 5635 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 5636 | } |
| 5637 | |
| 5638 | /** |
| 5639 | * wlan_hdd_cfg80211_get_link_properties() - Wrapper function to get link |
| 5640 | * properties. |
| 5641 | * @wiphy: WIPHY structure pointer |
| 5642 | * @wdev: Wireless device structure pointer |
| 5643 | * @data: Pointer to the data received |
| 5644 | * @data_len: Length of the data received |
| 5645 | * |
| 5646 | * This function is used to get link properties like nss, rate flags and |
| 5647 | * operating frequency for the active connection with the given peer. |
| 5648 | * |
| 5649 | * Return: 0 on success and errno on failure |
| 5650 | */ |
| 5651 | static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy, |
| 5652 | struct wireless_dev *wdev, |
| 5653 | const void *data, |
| 5654 | int data_len) |
| 5655 | { |
| 5656 | int ret = 0; |
| 5657 | |
| 5658 | cds_ssr_protect(__func__); |
| 5659 | ret = __wlan_hdd_cfg80211_get_link_properties(wiphy, |
| 5660 | wdev, data, data_len); |
| 5661 | cds_ssr_unprotect(__func__); |
| 5662 | |
| 5663 | return ret; |
| 5664 | } |
| 5665 | |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 5666 | static const struct |
| 5667 | nla_policy |
| 5668 | qca_wlan_vendor_ota_test_policy |
| 5669 | [QCA_WLAN_VENDOR_ATTR_OTA_TEST_MAX + 1] = { |
| 5670 | [QCA_WLAN_VENDOR_ATTR_OTA_TEST_ENABLE] = {.type = NLA_U8 }, |
| 5671 | }; |
| 5672 | |
| 5673 | /** |
| 5674 | * __wlan_hdd_cfg80211_set_ota_test () - enable/disable OTA test |
| 5675 | * @wiphy: Pointer to wireless phy |
| 5676 | * @wdev: Pointer to wireless device |
| 5677 | * @data: Pointer to data |
| 5678 | * @data_len: Data length |
| 5679 | * |
| 5680 | * Return: 0 on success, negative errno on failure |
| 5681 | */ |
| 5682 | static int __wlan_hdd_cfg80211_set_ota_test(struct wiphy *wiphy, |
| 5683 | struct wireless_dev *wdev, |
| 5684 | const void *data, |
| 5685 | int data_len) |
| 5686 | { |
| 5687 | struct net_device *dev = wdev->netdev; |
| 5688 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5689 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 5690 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 5691 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_OTA_TEST_MAX + 1]; |
| 5692 | uint8_t ota_enable = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5693 | QDF_STATUS status; |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 5694 | uint32_t current_roam_state; |
| 5695 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 5696 | ENTER_DEV(dev); |
| 5697 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5698 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 5699 | hdd_err("Command not allowed in FTM mode"); |
| 5700 | return -EPERM; |
| 5701 | } |
| 5702 | |
| 5703 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 5704 | return -EINVAL; |
| 5705 | |
| 5706 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_OTA_TEST_MAX, |
| 5707 | data, data_len, |
| 5708 | qca_wlan_vendor_ota_test_policy)) { |
| 5709 | hdd_err("invalid attr"); |
| 5710 | return -EINVAL; |
| 5711 | } |
| 5712 | |
| 5713 | if (!tb[QCA_WLAN_VENDOR_ATTR_OTA_TEST_ENABLE]) { |
| 5714 | hdd_err("attr ota test failed"); |
| 5715 | return -EINVAL; |
| 5716 | } |
| 5717 | |
| 5718 | ota_enable = nla_get_u8( |
| 5719 | tb[QCA_WLAN_VENDOR_ATTR_OTA_TEST_ENABLE]); |
| 5720 | |
| 5721 | hdd_info(" OTA test enable = %d", ota_enable); |
| 5722 | if (ota_enable != 1) { |
| 5723 | hdd_err("Invalid value, only enable test mode is supported!"); |
| 5724 | return -EINVAL; |
| 5725 | } |
| 5726 | |
| 5727 | current_roam_state = |
| 5728 | sme_get_current_roam_state(hal, adapter->sessionId); |
| 5729 | status = sme_stop_roaming(hal, adapter->sessionId, |
| 5730 | eCsrHddIssued); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5731 | if (status != QDF_STATUS_SUCCESS) { |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 5732 | hdd_err("Enable/Disable roaming failed"); |
| 5733 | return -EINVAL; |
| 5734 | } |
| 5735 | |
| 5736 | status = sme_ps_enable_disable(hal, adapter->sessionId, |
| 5737 | SME_PS_DISABLE); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5738 | if (status != QDF_STATUS_SUCCESS) { |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 5739 | hdd_err("Enable/Disable power save failed"); |
| 5740 | /* restore previous roaming setting */ |
| 5741 | if (current_roam_state == eCSR_ROAMING_STATE_JOINING || |
| 5742 | current_roam_state == eCSR_ROAMING_STATE_JOINED) |
| 5743 | status = sme_start_roaming(hal, adapter->sessionId, |
| 5744 | eCsrHddIssued); |
| 5745 | else if (current_roam_state == eCSR_ROAMING_STATE_STOP || |
| 5746 | current_roam_state == eCSR_ROAMING_STATE_IDLE) |
| 5747 | status = sme_stop_roaming(hal, adapter->sessionId, |
| 5748 | eCsrHddIssued); |
| 5749 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5750 | if (status != QDF_STATUS_SUCCESS) |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 5751 | hdd_err("Restoring roaming state failed"); |
| 5752 | |
| 5753 | return -EINVAL; |
| 5754 | } |
| 5755 | |
| 5756 | |
| 5757 | return 0; |
| 5758 | } |
| 5759 | |
| 5760 | /** |
| 5761 | * wlan_hdd_cfg80211_set_ota_test () - Enable or disable OTA test |
| 5762 | * @wiphy: Pointer to wireless phy |
| 5763 | * @wdev: Pointer to wireless device |
| 5764 | * @data: Pointer to data |
| 5765 | * @data_len: Data length |
| 5766 | * |
| 5767 | * Return: 0 on success, negative errno on failure |
| 5768 | */ |
| 5769 | static int wlan_hdd_cfg80211_set_ota_test(struct wiphy *wiphy, |
| 5770 | struct wireless_dev *wdev, |
| 5771 | const void *data, |
| 5772 | int data_len) |
| 5773 | { |
| 5774 | int ret = 0; |
| 5775 | |
| 5776 | cds_ssr_protect(__func__); |
| 5777 | ret = __wlan_hdd_cfg80211_set_ota_test(wiphy, wdev, data, data_len); |
| 5778 | cds_ssr_unprotect(__func__); |
| 5779 | |
| 5780 | return ret; |
| 5781 | } |
| 5782 | |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5783 | /** |
| 5784 | * __wlan_hdd_cfg80211_txpower_scale () - txpower scaling |
| 5785 | * @wiphy: Pointer to wireless phy |
| 5786 | * @wdev: Pointer to wireless device |
| 5787 | * @data: Pointer to data |
| 5788 | * @data_len: Data length |
| 5789 | * |
| 5790 | * Return: 0 on success, negative errno on failure |
| 5791 | */ |
| 5792 | static int __wlan_hdd_cfg80211_txpower_scale(struct wiphy *wiphy, |
| 5793 | struct wireless_dev *wdev, |
| 5794 | const void *data, |
| 5795 | int data_len) |
| 5796 | { |
| 5797 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 5798 | struct net_device *dev = wdev->netdev; |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 5799 | hdd_adapter_t *adapter; |
| 5800 | int ret; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5801 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_MAX + 1]; |
| 5802 | uint8_t scale_value; |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 5803 | QDF_STATUS status; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5804 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 5805 | ENTER_DEV(dev); |
| 5806 | |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5807 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 5808 | if (ret) |
| 5809 | return ret; |
| 5810 | |
| 5811 | adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5812 | |
| 5813 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_MAX, |
| 5814 | data, data_len, NULL)) { |
| 5815 | hdd_err("Invalid ATTR"); |
| 5816 | return -EINVAL; |
| 5817 | } |
| 5818 | |
| 5819 | if (!tb[QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE]) { |
| 5820 | hdd_err("attr tx power scale failed"); |
| 5821 | return -EINVAL; |
| 5822 | } |
| 5823 | |
| 5824 | scale_value = nla_get_u8(tb |
| 5825 | [QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE]); |
| 5826 | |
| 5827 | if (scale_value > MAX_TXPOWER_SCALE) { |
| 5828 | hdd_err("Invalid tx power scale level"); |
| 5829 | return -EINVAL; |
| 5830 | } |
| 5831 | |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 5832 | status = wma_set_tx_power_scale(adapter->sessionId, scale_value); |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5833 | |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 5834 | if (QDF_STATUS_SUCCESS != status) { |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5835 | hdd_err("Set tx power scale failed"); |
| 5836 | return -EINVAL; |
| 5837 | } |
| 5838 | |
| 5839 | return 0; |
| 5840 | } |
| 5841 | |
| 5842 | /** |
| 5843 | * wlan_hdd_cfg80211_txpower_scale () - txpower scaling |
| 5844 | * @wiphy: Pointer to wireless phy |
| 5845 | * @wdev: Pointer to wireless device |
| 5846 | * @data: Pointer to data |
| 5847 | * @data_len: Data length |
| 5848 | * |
| 5849 | * Return: 0 on success, negative errno on failure |
| 5850 | */ |
| 5851 | static int wlan_hdd_cfg80211_txpower_scale(struct wiphy *wiphy, |
| 5852 | struct wireless_dev *wdev, |
| 5853 | const void *data, |
| 5854 | int data_len) |
| 5855 | { |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 5856 | int ret; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5857 | |
| 5858 | cds_ssr_protect(__func__); |
| 5859 | ret = __wlan_hdd_cfg80211_txpower_scale(wiphy, wdev, |
| 5860 | data, data_len); |
| 5861 | cds_ssr_unprotect(__func__); |
| 5862 | |
| 5863 | return ret; |
| 5864 | } |
| 5865 | |
| 5866 | /** |
| 5867 | * __wlan_hdd_cfg80211_txpower_scale_decr_db () - txpower scaling |
| 5868 | * @wiphy: Pointer to wireless phy |
| 5869 | * @wdev: Pointer to wireless device |
| 5870 | * @data: Pointer to data |
| 5871 | * @data_len: Data length |
| 5872 | * |
| 5873 | * Return: 0 on success, negative errno on failure |
| 5874 | */ |
| 5875 | static int __wlan_hdd_cfg80211_txpower_scale_decr_db(struct wiphy *wiphy, |
| 5876 | struct wireless_dev *wdev, |
| 5877 | const void *data, |
| 5878 | int data_len) |
| 5879 | { |
| 5880 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 5881 | struct net_device *dev = wdev->netdev; |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 5882 | hdd_adapter_t *adapter; |
| 5883 | int ret; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5884 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB_MAX + 1]; |
| 5885 | uint8_t scale_value; |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 5886 | QDF_STATUS status; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5887 | |
Jeff Johnson | 1f61b61 | 2016-02-12 16:28:33 -0800 | [diff] [blame] | 5888 | ENTER_DEV(dev); |
| 5889 | |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5890 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 5891 | if (ret) |
| 5892 | return ret; |
| 5893 | |
| 5894 | adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5895 | |
| 5896 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB_MAX, |
| 5897 | data, data_len, NULL)) { |
| 5898 | hdd_err("Invalid ATTR"); |
| 5899 | return -EINVAL; |
| 5900 | } |
| 5901 | |
| 5902 | if (!tb[QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB]) { |
| 5903 | hdd_err("attr tx power decrease db value failed"); |
| 5904 | return -EINVAL; |
| 5905 | } |
| 5906 | |
| 5907 | scale_value = nla_get_u8(tb |
| 5908 | [QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB]); |
| 5909 | |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 5910 | status = wma_set_tx_power_scale_decr_db(adapter->sessionId, |
| 5911 | scale_value); |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5912 | |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 5913 | if (QDF_STATUS_SUCCESS != status) { |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5914 | hdd_err("Set tx power decrease db failed"); |
| 5915 | return -EINVAL; |
| 5916 | } |
| 5917 | |
| 5918 | return 0; |
| 5919 | } |
| 5920 | |
| 5921 | /** |
| 5922 | * wlan_hdd_cfg80211_txpower_scale_decr_db () - txpower scaling |
| 5923 | * @wiphy: Pointer to wireless phy |
| 5924 | * @wdev: Pointer to wireless device |
| 5925 | * @data: Pointer to data |
| 5926 | * @data_len: Data length |
| 5927 | * |
| 5928 | * Return: 0 on success, negative errno on failure |
| 5929 | */ |
| 5930 | static int wlan_hdd_cfg80211_txpower_scale_decr_db(struct wiphy *wiphy, |
| 5931 | struct wireless_dev *wdev, |
| 5932 | const void *data, |
| 5933 | int data_len) |
| 5934 | { |
Peng Xu | 62c8c43 | 2016-05-09 15:23:02 -0700 | [diff] [blame] | 5935 | int ret; |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 5936 | |
| 5937 | cds_ssr_protect(__func__); |
| 5938 | ret = __wlan_hdd_cfg80211_txpower_scale_decr_db(wiphy, wdev, |
| 5939 | data, data_len); |
| 5940 | cds_ssr_unprotect(__func__); |
| 5941 | |
| 5942 | return ret; |
| 5943 | } |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 5944 | |
| 5945 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5946 | * __wlan_hdd_cfg80211_conditional_chan_switch() - Conditional channel switch |
| 5947 | * @wiphy: Pointer to wireless phy |
| 5948 | * @wdev: Pointer to wireless device |
| 5949 | * @data: Pointer to data |
| 5950 | * @data_len: Data length |
| 5951 | * |
| 5952 | * Processes the conditional channel switch request and invokes the helper |
| 5953 | * APIs to process the channel switch request. |
| 5954 | * |
| 5955 | * Return: 0 on success, negative errno on failure |
| 5956 | */ |
| 5957 | static int __wlan_hdd_cfg80211_conditional_chan_switch(struct wiphy *wiphy, |
| 5958 | struct wireless_dev *wdev, |
| 5959 | const void *data, |
| 5960 | int data_len) |
| 5961 | { |
| 5962 | int ret; |
| 5963 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 5964 | struct net_device *dev = wdev->netdev; |
| 5965 | hdd_adapter_t *adapter; |
| 5966 | struct nlattr |
| 5967 | *tb[QCA_WLAN_VENDOR_ATTR_SAP_CONDITIONAL_CHAN_SWITCH_MAX + 1]; |
| 5968 | uint32_t freq_len, i; |
| 5969 | uint32_t *freq; |
| 5970 | uint8_t chans[QDF_MAX_NUM_CHAN]; |
| 5971 | |
| 5972 | ENTER_DEV(dev); |
| 5973 | |
| 5974 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 5975 | if (ret) |
| 5976 | return ret; |
| 5977 | |
| 5978 | if (!hdd_ctx->config->enableDFSMasterCap) { |
| 5979 | hdd_err("DFS master capability is not present in the driver"); |
| 5980 | return -EINVAL; |
| 5981 | } |
| 5982 | |
| 5983 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5984 | hdd_err("Command not allowed in FTM mode"); |
| 5985 | return -EPERM; |
| 5986 | } |
| 5987 | |
| 5988 | adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5989 | if (adapter->device_mode != QDF_SAP_MODE) { |
| 5990 | hdd_err("Invalid device mode %d", adapter->device_mode); |
| 5991 | return -EINVAL; |
| 5992 | } |
| 5993 | |
| 5994 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SAP_CONDITIONAL_CHAN_SWITCH_MAX, |
| 5995 | data, data_len, NULL)) { |
| 5996 | hdd_err("Invalid ATTR"); |
| 5997 | return -EINVAL; |
| 5998 | } |
| 5999 | |
| 6000 | if (!tb[QCA_WLAN_VENDOR_ATTR_SAP_CONDITIONAL_CHAN_SWITCH_FREQ_LIST]) { |
| 6001 | hdd_err("Frequency list is missing"); |
| 6002 | return -EINVAL; |
| 6003 | } |
| 6004 | |
| 6005 | freq_len = nla_len( |
| 6006 | tb[QCA_WLAN_VENDOR_ATTR_SAP_CONDITIONAL_CHAN_SWITCH_FREQ_LIST])/ |
| 6007 | sizeof(uint32_t); |
| 6008 | |
| 6009 | if (freq_len > QDF_MAX_NUM_CHAN) { |
| 6010 | hdd_err("insufficient space to hold channels"); |
| 6011 | return -ENOMEM; |
| 6012 | } |
| 6013 | |
| 6014 | hdd_debug("freq_len=%d", freq_len); |
| 6015 | |
| 6016 | freq = nla_data( |
| 6017 | tb[QCA_WLAN_VENDOR_ATTR_SAP_CONDITIONAL_CHAN_SWITCH_FREQ_LIST]); |
| 6018 | |
| 6019 | |
| 6020 | for (i = 0; i < freq_len; i++) { |
| 6021 | if (freq[i] == 0) |
| 6022 | chans[i] = 0; |
| 6023 | else |
| 6024 | chans[i] = ieee80211_frequency_to_channel(freq[i]); |
| 6025 | |
| 6026 | hdd_debug("freq[%d]=%d", i, freq[i]); |
| 6027 | } |
| 6028 | |
| 6029 | /* |
| 6030 | * The input frequency list from user space is designed to be a |
| 6031 | * priority based frequency list. This is only to accommodate any |
| 6032 | * future request. But, current requirement is only to perform CAC |
| 6033 | * on a single channel. So, the first entry from the list is picked. |
| 6034 | * |
| 6035 | * If channel is zero, any channel in the available outdoor regulatory |
| 6036 | * domain will be selected. |
| 6037 | */ |
| 6038 | ret = wlan_hdd_request_pre_cac(chans[0]); |
| 6039 | if (ret) { |
| 6040 | hdd_err("pre cac request failed with reason:%d", ret); |
| 6041 | return ret; |
| 6042 | } |
| 6043 | |
| 6044 | return 0; |
| 6045 | } |
| 6046 | |
| 6047 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 6048 | * __wlan_hdd_cfg80211_p2p_lo_start () - start P2P Listen Offload |
| 6049 | * @wiphy: Pointer to wireless phy |
| 6050 | * @wdev: Pointer to wireless device |
| 6051 | * @data: Pointer to data |
| 6052 | * @data_len: Data length |
| 6053 | * |
| 6054 | * This function is to process the p2p listen offload start vendor |
| 6055 | * command. It parses the input parameters and invoke WMA API to |
| 6056 | * send the command to firmware. |
| 6057 | * |
| 6058 | * Return: 0 on success, negative errno on failure |
| 6059 | */ |
| 6060 | static int __wlan_hdd_cfg80211_p2p_lo_start(struct wiphy *wiphy, |
| 6061 | struct wireless_dev *wdev, |
| 6062 | const void *data, |
| 6063 | int data_len) |
| 6064 | { |
| 6065 | int ret; |
| 6066 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 6067 | struct net_device *dev = wdev->netdev; |
| 6068 | hdd_adapter_t *adapter; |
| 6069 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_MAX + 1]; |
| 6070 | struct sir_p2p_lo_start params; |
| 6071 | QDF_STATUS status; |
| 6072 | |
| 6073 | ENTER_DEV(dev); |
| 6074 | |
| 6075 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 6076 | if (ret) |
| 6077 | return ret; |
| 6078 | |
| 6079 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 6080 | hdd_err("Command not allowed in FTM mode"); |
| 6081 | return -EPERM; |
| 6082 | } |
| 6083 | |
| 6084 | adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6085 | if ((adapter->device_mode != QDF_P2P_DEVICE_MODE) && |
| 6086 | (adapter->device_mode != QDF_P2P_CLIENT_MODE) && |
| 6087 | (adapter->device_mode != QDF_P2P_GO_MODE)) { |
| 6088 | hdd_err("Invalid device mode %d", adapter->device_mode); |
| 6089 | return -EINVAL; |
| 6090 | } |
| 6091 | |
| 6092 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_MAX, |
| 6093 | data, data_len, NULL)) { |
| 6094 | hdd_err("Invalid ATTR"); |
| 6095 | return -EINVAL; |
| 6096 | } |
| 6097 | |
| 6098 | memset(¶ms, 0, sizeof(params)); |
| 6099 | |
| 6100 | if (!tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_CTRL_FLAG]) |
| 6101 | params.ctl_flags = 1; /* set to default value */ |
| 6102 | else |
| 6103 | params.ctl_flags = nla_get_u32(tb |
| 6104 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_CTRL_FLAG]); |
| 6105 | |
| 6106 | if (!tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_CHANNEL] || |
| 6107 | !tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_PERIOD] || |
| 6108 | !tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_INTERVAL] || |
| 6109 | !tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_COUNT] || |
| 6110 | !tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_DEVICE_TYPES] || |
| 6111 | !tb[QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_VENDOR_IE]) { |
| 6112 | hdd_err("Attribute parsing failed"); |
| 6113 | return -EINVAL; |
| 6114 | } |
| 6115 | |
| 6116 | params.vdev_id = adapter->sessionId; |
| 6117 | params.freq = nla_get_u32(tb |
| 6118 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_CHANNEL]); |
| 6119 | if ((params.freq != 2412) && (params.freq != 2437) && |
| 6120 | (params.freq != 2462)) { |
| 6121 | hdd_err("Invalid listening channel: %d", params.freq); |
| 6122 | return -EINVAL; |
| 6123 | } |
| 6124 | |
| 6125 | params.period = nla_get_u32(tb |
| 6126 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_PERIOD]); |
| 6127 | if (!((params.period > 0) && (params.period < UINT_MAX))) { |
| 6128 | hdd_err("Invalid period: %d", params.period); |
| 6129 | return -EINVAL; |
| 6130 | } |
| 6131 | |
| 6132 | params.interval = nla_get_u32(tb |
| 6133 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_INTERVAL]); |
| 6134 | if (!((params.interval > 0) && (params.interval < UINT_MAX))) { |
| 6135 | hdd_err("Invalid interval: %d", params.interval); |
| 6136 | return -EINVAL; |
| 6137 | } |
| 6138 | |
| 6139 | params.count = nla_get_u32(tb |
| 6140 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_COUNT]); |
| 6141 | if (!((params.count > 0) && (params.count < UINT_MAX))) { |
| 6142 | hdd_err("Invalid count: %d", params.count); |
| 6143 | return -EINVAL; |
| 6144 | } |
| 6145 | |
| 6146 | params.device_types = nla_data(tb |
| 6147 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_DEVICE_TYPES]); |
| 6148 | if (params.device_types == NULL) { |
| 6149 | hdd_err("Invalid device types"); |
| 6150 | return -EINVAL; |
| 6151 | } |
| 6152 | |
| 6153 | params.dev_types_len = nla_len(tb |
| 6154 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_DEVICE_TYPES]); |
| 6155 | if (params.dev_types_len < 8) { |
| 6156 | hdd_err("Invalid device type length: %d", params.dev_types_len); |
| 6157 | return -EINVAL; |
| 6158 | } |
| 6159 | |
| 6160 | params.probe_resp_tmplt = nla_data(tb |
| 6161 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_VENDOR_IE]); |
| 6162 | if (params.probe_resp_tmplt == NULL) { |
| 6163 | hdd_err("Invalid probe response template"); |
| 6164 | return -EINVAL; |
| 6165 | } |
| 6166 | |
| 6167 | params.probe_resp_len = nla_len(tb |
| 6168 | [QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_VENDOR_IE]); |
| 6169 | if (params.probe_resp_len == 0) { |
| 6170 | hdd_err("Invalid probe resp template length: %d", |
| 6171 | params.probe_resp_len); |
| 6172 | return -EINVAL; |
| 6173 | } |
| 6174 | |
| 6175 | hdd_debug("P2P LO params: freq=%d, period=%d, interval=%d, count=%d", |
| 6176 | params.freq, params.period, params.interval, params.count); |
| 6177 | |
| 6178 | status = wma_p2p_lo_start(¶ms); |
| 6179 | |
| 6180 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 6181 | hdd_err("P2P LO start failed"); |
| 6182 | return -EINVAL; |
| 6183 | } |
| 6184 | |
| 6185 | return 0; |
| 6186 | } |
| 6187 | |
| 6188 | |
| 6189 | /** |
| 6190 | * wlan_hdd_cfg80211_p2p_lo_start () - start P2P Listen Offload |
| 6191 | * @wiphy: Pointer to wireless phy |
| 6192 | * @wdev: Pointer to wireless device |
| 6193 | * @data: Pointer to data |
| 6194 | * @data_len: Data length |
| 6195 | * |
| 6196 | * This function inovkes internal __wlan_hdd_cfg80211_p2p_lo_start() |
| 6197 | * to process p2p listen offload start vendor command. |
| 6198 | * |
| 6199 | * Return: 0 on success, negative errno on failure |
| 6200 | */ |
| 6201 | static int wlan_hdd_cfg80211_p2p_lo_start(struct wiphy *wiphy, |
| 6202 | struct wireless_dev *wdev, |
| 6203 | const void *data, |
| 6204 | int data_len) |
| 6205 | { |
| 6206 | int ret = 0; |
| 6207 | |
| 6208 | cds_ssr_protect(__func__); |
| 6209 | ret = __wlan_hdd_cfg80211_p2p_lo_start(wiphy, wdev, |
| 6210 | data, data_len); |
| 6211 | cds_ssr_unprotect(__func__); |
| 6212 | |
| 6213 | return ret; |
| 6214 | } |
| 6215 | |
| 6216 | /** |
| 6217 | * __wlan_hdd_cfg80211_p2p_lo_stop () - stop P2P Listen Offload |
| 6218 | * @wiphy: Pointer to wireless phy |
| 6219 | * @wdev: Pointer to wireless device |
| 6220 | * @data: Pointer to data |
| 6221 | * @data_len: Data length |
| 6222 | * |
| 6223 | * This function is to process the p2p listen offload stop vendor |
| 6224 | * command. It invokes WMA API to send command to firmware. |
| 6225 | * |
| 6226 | * Return: 0 on success, negative errno on failure |
| 6227 | */ |
| 6228 | static int __wlan_hdd_cfg80211_p2p_lo_stop(struct wiphy *wiphy, |
| 6229 | struct wireless_dev *wdev, |
| 6230 | const void *data, |
| 6231 | int data_len) |
| 6232 | { |
| 6233 | QDF_STATUS status; |
| 6234 | hdd_adapter_t *adapter; |
| 6235 | struct net_device *dev = wdev->netdev; |
| 6236 | |
| 6237 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 6238 | hdd_err("Command not allowed in FTM mode"); |
| 6239 | return -EPERM; |
| 6240 | } |
| 6241 | |
| 6242 | adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6243 | if ((adapter->device_mode != QDF_P2P_DEVICE_MODE) && |
| 6244 | (adapter->device_mode != QDF_P2P_CLIENT_MODE) && |
| 6245 | (adapter->device_mode != QDF_P2P_GO_MODE)) { |
| 6246 | hdd_err("Invalid device mode"); |
| 6247 | return -EINVAL; |
| 6248 | } |
| 6249 | |
| 6250 | status = wma_p2p_lo_stop(adapter->sessionId); |
| 6251 | |
| 6252 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 6253 | hdd_err("P2P LO stop failed"); |
| 6254 | return -EINVAL; |
| 6255 | } |
| 6256 | |
| 6257 | return 0; |
| 6258 | } |
| 6259 | |
| 6260 | /** |
| 6261 | * wlan_hdd_cfg80211_p2p_lo_stop () - stop P2P Listen Offload |
| 6262 | * @wiphy: Pointer to wireless phy |
| 6263 | * @wdev: Pointer to wireless device |
| 6264 | * @data: Pointer to data |
| 6265 | * @data_len: Data length |
| 6266 | * |
| 6267 | * This function inovkes internal __wlan_hdd_cfg80211_p2p_lo_stop() |
| 6268 | * to process p2p listen offload stop vendor command. |
| 6269 | * |
| 6270 | * Return: 0 on success, negative errno on failure |
| 6271 | */ |
| 6272 | static int wlan_hdd_cfg80211_p2p_lo_stop(struct wiphy *wiphy, |
| 6273 | struct wireless_dev *wdev, |
| 6274 | const void *data, |
| 6275 | int data_len) |
| 6276 | { |
| 6277 | int ret = 0; |
| 6278 | |
| 6279 | cds_ssr_protect(__func__); |
| 6280 | ret = __wlan_hdd_cfg80211_p2p_lo_stop(wiphy, wdev, |
| 6281 | data, data_len); |
| 6282 | cds_ssr_unprotect(__func__); |
| 6283 | |
| 6284 | return ret; |
| 6285 | } |
| 6286 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 6287 | /** |
| 6288 | * wlan_hdd_cfg80211_conditional_chan_switch() - SAP conditional channel switch |
| 6289 | * @wiphy: Pointer to wireless phy |
| 6290 | * @wdev: Pointer to wireless device |
| 6291 | * @data: Pointer to data |
| 6292 | * @data_len: Data length |
| 6293 | * |
| 6294 | * Inovkes internal API __wlan_hdd_cfg80211_conditional_chan_switch() |
| 6295 | * to process the conditional channel switch request. |
| 6296 | * |
| 6297 | * Return: 0 on success, negative errno on failure |
| 6298 | */ |
| 6299 | static int wlan_hdd_cfg80211_conditional_chan_switch(struct wiphy *wiphy, |
| 6300 | struct wireless_dev *wdev, |
| 6301 | const void *data, |
| 6302 | int data_len) |
| 6303 | { |
| 6304 | int ret; |
| 6305 | |
| 6306 | cds_ssr_protect(__func__); |
| 6307 | ret = __wlan_hdd_cfg80211_conditional_chan_switch(wiphy, wdev, |
| 6308 | data, data_len); |
| 6309 | cds_ssr_unprotect(__func__); |
| 6310 | |
| 6311 | return ret; |
| 6312 | } |
| 6313 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6314 | /* |
| 6315 | * define short names for the global vendor params |
| 6316 | * used by __wlan_hdd_cfg80211_bpf_offload() |
| 6317 | */ |
| 6318 | #define BPF_INVALID \ |
| 6319 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_INVALID |
| 6320 | #define BPF_SET_RESET \ |
| 6321 | QCA_WLAN_VENDOR_ATTR_SET_RESET_PACKET_FILTER |
| 6322 | #define BPF_VERSION \ |
| 6323 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_VERSION |
| 6324 | #define BPF_FILTER_ID \ |
| 6325 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_ID |
| 6326 | #define BPF_PACKET_SIZE \ |
| 6327 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_SIZE |
| 6328 | #define BPF_CURRENT_OFFSET \ |
| 6329 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_CURRENT_OFFSET |
| 6330 | #define BPF_PROGRAM \ |
| 6331 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_PROGRAM |
| 6332 | #define BPF_MAX \ |
| 6333 | QCA_WLAN_VENDOR_ATTR_PACKET_FILTER_MAX |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 6334 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6335 | static const struct nla_policy |
| 6336 | wlan_hdd_bpf_offload_policy[BPF_MAX + 1] = { |
| 6337 | [BPF_SET_RESET] = {.type = NLA_U32}, |
| 6338 | [BPF_VERSION] = {.type = NLA_U32}, |
| 6339 | [BPF_FILTER_ID] = {.type = NLA_U32}, |
| 6340 | [BPF_PACKET_SIZE] = {.type = NLA_U32}, |
| 6341 | [BPF_CURRENT_OFFSET] = {.type = NLA_U32}, |
| 6342 | [BPF_PROGRAM] = {.type = NLA_U8}, |
| 6343 | }; |
| 6344 | |
| 6345 | /** |
| 6346 | * hdd_get_bpf_offload_cb() - Callback function to BPF Offload |
| 6347 | * @hdd_context: hdd_context |
| 6348 | * @bpf_get_offload: struct for get offload |
| 6349 | * |
| 6350 | * This function receives the response/data from the lower layer and |
| 6351 | * checks to see if the thread is still waiting then post the results to |
| 6352 | * upper layer, if the request has timed out then ignore. |
| 6353 | * |
| 6354 | * Return: None |
| 6355 | */ |
| 6356 | void hdd_get_bpf_offload_cb(void *hdd_context, |
| 6357 | struct sir_bpf_get_offload *data) |
| 6358 | { |
| 6359 | hdd_context_t *hdd_ctx = hdd_context; |
| 6360 | struct hdd_bpf_context *context; |
| 6361 | |
| 6362 | ENTER(); |
| 6363 | |
| 6364 | if (wlan_hdd_validate_context(hdd_ctx) || !data) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6365 | hdd_err("HDD context is invalid or data(%p) is null", |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6366 | data); |
| 6367 | return; |
| 6368 | } |
| 6369 | |
| 6370 | spin_lock(&hdd_context_lock); |
| 6371 | |
| 6372 | context = &bpf_context; |
| 6373 | /* The caller presumably timed out so there is nothing we can do */ |
| 6374 | if (context->magic != BPF_CONTEXT_MAGIC) { |
| 6375 | spin_unlock(&hdd_context_lock); |
| 6376 | return; |
| 6377 | } |
| 6378 | |
| 6379 | /* context is valid so caller is still waiting */ |
| 6380 | /* paranoia: invalidate the magic */ |
| 6381 | context->magic = 0; |
| 6382 | |
| 6383 | context->capability_response = *data; |
| 6384 | complete(&context->completion); |
| 6385 | |
| 6386 | spin_unlock(&hdd_context_lock); |
| 6387 | |
| 6388 | return; |
| 6389 | } |
| 6390 | |
| 6391 | /** |
| 6392 | * hdd_post_get_bpf_capabilities_rsp() - Callback function to BPF Offload |
| 6393 | * @hdd_context: hdd_context |
| 6394 | * @bpf_get_offload: struct for get offload |
| 6395 | * |
| 6396 | * Return: 0 on success, error number otherwise. |
| 6397 | */ |
| 6398 | static int hdd_post_get_bpf_capabilities_rsp(hdd_context_t *hdd_ctx, |
| 6399 | struct sir_bpf_get_offload *bpf_get_offload) |
| 6400 | { |
| 6401 | struct sk_buff *skb; |
| 6402 | uint32_t nl_buf_len; |
| 6403 | |
| 6404 | ENTER(); |
| 6405 | |
| 6406 | nl_buf_len = NLMSG_HDRLEN; |
| 6407 | nl_buf_len += |
| 6408 | (sizeof(bpf_get_offload->max_bytes_for_bpf_inst) + NLA_HDRLEN) + |
| 6409 | (sizeof(bpf_get_offload->bpf_version) + NLA_HDRLEN); |
| 6410 | |
| 6411 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 6412 | if (!skb) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6413 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6414 | return -ENOMEM; |
| 6415 | } |
| 6416 | |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6417 | hdd_notice("BPF Version: %u BPF max bytes: %u", |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6418 | bpf_get_offload->bpf_version, |
| 6419 | bpf_get_offload->max_bytes_for_bpf_inst); |
| 6420 | |
| 6421 | if (nla_put_u32(skb, BPF_PACKET_SIZE, |
| 6422 | bpf_get_offload->max_bytes_for_bpf_inst) || |
| 6423 | nla_put_u32(skb, BPF_VERSION, bpf_get_offload->bpf_version)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6424 | hdd_err("nla put failure"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6425 | goto nla_put_failure; |
| 6426 | } |
| 6427 | |
| 6428 | cfg80211_vendor_cmd_reply(skb); |
| 6429 | EXIT(); |
| 6430 | return 0; |
| 6431 | |
| 6432 | nla_put_failure: |
| 6433 | kfree_skb(skb); |
| 6434 | return -EINVAL; |
| 6435 | } |
| 6436 | |
| 6437 | /** |
| 6438 | * hdd_get_bpf_offload - Get BPF offload Capabilities |
| 6439 | * @hdd_ctx: Hdd context |
| 6440 | * |
| 6441 | * Return: 0 on success, errno on failure |
| 6442 | */ |
| 6443 | static int hdd_get_bpf_offload(hdd_context_t *hdd_ctx) |
| 6444 | { |
| 6445 | unsigned long rc; |
Houston Hoffman | 59c097f | 2016-11-09 15:50:25 -0800 | [diff] [blame] | 6446 | static struct hdd_bpf_context *context; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6447 | QDF_STATUS status; |
| 6448 | int ret; |
| 6449 | |
| 6450 | ENTER(); |
| 6451 | |
| 6452 | spin_lock(&hdd_context_lock); |
| 6453 | context = &bpf_context; |
| 6454 | context->magic = BPF_CONTEXT_MAGIC; |
| 6455 | INIT_COMPLETION(context->completion); |
| 6456 | spin_unlock(&hdd_context_lock); |
| 6457 | |
| 6458 | status = sme_get_bpf_offload_capabilities(hdd_ctx->hHal); |
| 6459 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6460 | hdd_err("Unable to retrieve BPF caps"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6461 | return -EINVAL; |
| 6462 | } |
| 6463 | /* request was sent -- wait for the response */ |
| 6464 | rc = wait_for_completion_timeout(&context->completion, |
| 6465 | msecs_to_jiffies(WLAN_WAIT_TIME_BPF)); |
| 6466 | if (!rc) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6467 | hdd_err("Target response timed out"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6468 | spin_lock(&hdd_context_lock); |
| 6469 | context->magic = 0; |
| 6470 | spin_unlock(&hdd_context_lock); |
| 6471 | |
| 6472 | return -ETIMEDOUT; |
| 6473 | } |
| 6474 | ret = hdd_post_get_bpf_capabilities_rsp(hdd_ctx, |
| 6475 | &bpf_context.capability_response); |
| 6476 | if (ret) |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6477 | hdd_err("Failed to post get bpf capabilities"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6478 | |
| 6479 | EXIT(); |
| 6480 | return ret; |
| 6481 | } |
| 6482 | |
| 6483 | /** |
| 6484 | * hdd_set_reset_bpf_offload - Post set/reset bpf to SME |
| 6485 | * @hdd_ctx: Hdd context |
| 6486 | * @tb: Length of @data |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 6487 | * @adapter: pointer to adapter struct |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6488 | * |
| 6489 | * Return: 0 on success; errno on failure |
| 6490 | */ |
| 6491 | static int hdd_set_reset_bpf_offload(hdd_context_t *hdd_ctx, |
| 6492 | struct nlattr **tb, |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 6493 | hdd_adapter_t *adapter) |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6494 | { |
| 6495 | struct sir_bpf_set_offload *bpf_set_offload; |
| 6496 | QDF_STATUS status; |
| 6497 | int prog_len; |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 6498 | int ret = 0; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6499 | |
| 6500 | ENTER(); |
| 6501 | |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 6502 | if (adapter->device_mode == QDF_STA_MODE || |
| 6503 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
| 6504 | if (!hdd_conn_is_connected( |
| 6505 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
| 6506 | hdd_err("Not in Connected state!"); |
| 6507 | return -ENOTSUPP; |
| 6508 | } |
| 6509 | } |
| 6510 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6511 | bpf_set_offload = qdf_mem_malloc(sizeof(*bpf_set_offload)); |
| 6512 | if (bpf_set_offload == NULL) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6513 | hdd_err("qdf_mem_malloc failed for bpf_set_offload"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6514 | return -ENOMEM; |
| 6515 | } |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6516 | |
| 6517 | /* Parse and fetch bpf packet size */ |
| 6518 | if (!tb[BPF_PACKET_SIZE]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6519 | hdd_err("attr bpf packet size failed"); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 6520 | ret = -EINVAL; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6521 | goto fail; |
| 6522 | } |
| 6523 | bpf_set_offload->total_length = nla_get_u32(tb[BPF_PACKET_SIZE]); |
| 6524 | |
| 6525 | if (!bpf_set_offload->total_length) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6526 | hdd_notice("BPF reset packet filter received"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6527 | goto post_sme; |
| 6528 | } |
| 6529 | |
| 6530 | /* Parse and fetch bpf program */ |
| 6531 | if (!tb[BPF_PROGRAM]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6532 | hdd_err("attr bpf program failed"); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 6533 | ret = -EINVAL; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6534 | goto fail; |
| 6535 | } |
| 6536 | |
| 6537 | prog_len = nla_len(tb[BPF_PROGRAM]); |
| 6538 | bpf_set_offload->program = qdf_mem_malloc(sizeof(uint8_t) * prog_len); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 6539 | |
| 6540 | if (bpf_set_offload->program == NULL) { |
| 6541 | hdd_err("qdf_mem_malloc failed for bpf offload program"); |
| 6542 | ret = -ENOMEM; |
| 6543 | goto fail; |
| 6544 | } |
| 6545 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6546 | bpf_set_offload->current_length = prog_len; |
| 6547 | nla_memcpy(bpf_set_offload->program, tb[BPF_PROGRAM], prog_len); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 6548 | bpf_set_offload->session_id = adapter->sessionId; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6549 | |
Rajeev Kumar Sirasanagandla | 62b6303 | 2016-08-22 14:56:57 +0530 | [diff] [blame] | 6550 | hdd_info("BPF set instructions"); |
| 6551 | QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO, |
| 6552 | bpf_set_offload->program, prog_len); |
| 6553 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6554 | /* Parse and fetch filter Id */ |
| 6555 | if (!tb[BPF_FILTER_ID]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6556 | hdd_err("attr filter id failed"); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 6557 | ret = -EINVAL; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6558 | goto fail; |
| 6559 | } |
| 6560 | bpf_set_offload->filter_id = nla_get_u32(tb[BPF_FILTER_ID]); |
| 6561 | |
| 6562 | /* Parse and fetch current offset */ |
| 6563 | if (!tb[BPF_CURRENT_OFFSET]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6564 | hdd_err("attr current offset failed"); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 6565 | ret = -EINVAL; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6566 | goto fail; |
| 6567 | } |
| 6568 | bpf_set_offload->current_offset = nla_get_u32(tb[BPF_CURRENT_OFFSET]); |
| 6569 | |
| 6570 | post_sme: |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6571 | hdd_notice("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] | 6572 | bpf_set_offload->session_id, |
| 6573 | bpf_set_offload->version, |
| 6574 | bpf_set_offload->filter_id, |
| 6575 | bpf_set_offload->total_length, |
| 6576 | bpf_set_offload->current_length, |
| 6577 | bpf_set_offload->current_offset); |
| 6578 | |
| 6579 | status = sme_set_bpf_instructions(hdd_ctx->hHal, bpf_set_offload); |
| 6580 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6581 | hdd_err("sme_set_bpf_instructions failed(err=%d)", status); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 6582 | ret = -EINVAL; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6583 | goto fail; |
| 6584 | } |
| 6585 | EXIT(); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6586 | |
| 6587 | fail: |
| 6588 | if (bpf_set_offload->current_length) |
| 6589 | qdf_mem_free(bpf_set_offload->program); |
| 6590 | qdf_mem_free(bpf_set_offload); |
Arun Khandavalli | 0850081 | 2016-07-25 14:58:42 +0530 | [diff] [blame] | 6591 | return ret; |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6592 | } |
| 6593 | |
| 6594 | /** |
| 6595 | * wlan_hdd_cfg80211_bpf_offload() - Set/Reset to BPF Offload |
| 6596 | * @wiphy: wiphy structure pointer |
| 6597 | * @wdev: Wireless device structure pointer |
| 6598 | * @data: Pointer to the data received |
| 6599 | * @data_len: Length of @data |
| 6600 | * |
| 6601 | * Return: 0 on success; errno on failure |
| 6602 | */ |
| 6603 | static int |
| 6604 | __wlan_hdd_cfg80211_bpf_offload(struct wiphy *wiphy, |
| 6605 | struct wireless_dev *wdev, |
| 6606 | const void *data, int data_len) |
| 6607 | { |
| 6608 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 6609 | struct net_device *dev = wdev->netdev; |
| 6610 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6611 | struct nlattr *tb[BPF_MAX + 1]; |
| 6612 | int ret_val, packet_filter_subcmd; |
| 6613 | |
| 6614 | ENTER(); |
| 6615 | |
| 6616 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 6617 | if (ret_val) |
| 6618 | return ret_val; |
| 6619 | |
| 6620 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6621 | hdd_err("Command not allowed in FTM mode"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6622 | return -EINVAL; |
| 6623 | } |
| 6624 | |
| 6625 | if (!hdd_ctx->bpf_enabled) { |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 6626 | hdd_err("BPF offload is not supported/enabled"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6627 | return -ENOTSUPP; |
| 6628 | } |
| 6629 | |
| 6630 | if (nla_parse(tb, BPF_MAX, data, data_len, |
| 6631 | wlan_hdd_bpf_offload_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6632 | hdd_err("Invalid ATTR"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6633 | return -EINVAL; |
| 6634 | } |
| 6635 | |
| 6636 | if (!tb[BPF_SET_RESET]) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 6637 | hdd_err("attr bpf set reset failed"); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6638 | return -EINVAL; |
| 6639 | } |
| 6640 | |
| 6641 | packet_filter_subcmd = nla_get_u32(tb[BPF_SET_RESET]); |
| 6642 | |
| 6643 | if (packet_filter_subcmd == QCA_WLAN_GET_PACKET_FILTER) |
| 6644 | return hdd_get_bpf_offload(hdd_ctx); |
| 6645 | else |
| 6646 | return hdd_set_reset_bpf_offload(hdd_ctx, tb, |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 6647 | pAdapter); |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 6648 | } |
| 6649 | |
| 6650 | /** |
| 6651 | * wlan_hdd_cfg80211_bpf_offload() - SSR Wrapper to BPF Offload |
| 6652 | * @wiphy: wiphy structure pointer |
| 6653 | * @wdev: Wireless device structure pointer |
| 6654 | * @data: Pointer to the data received |
| 6655 | * @data_len: Length of @data |
| 6656 | * |
| 6657 | * Return: 0 on success; errno on failure |
| 6658 | */ |
| 6659 | |
| 6660 | static int wlan_hdd_cfg80211_bpf_offload(struct wiphy *wiphy, |
| 6661 | struct wireless_dev *wdev, |
| 6662 | const void *data, int data_len) |
| 6663 | { |
| 6664 | int ret; |
| 6665 | |
| 6666 | cds_ssr_protect(__func__); |
| 6667 | ret = __wlan_hdd_cfg80211_bpf_offload(wiphy, wdev, data, data_len); |
| 6668 | cds_ssr_unprotect(__func__); |
| 6669 | |
| 6670 | return ret; |
| 6671 | } |
| 6672 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 6673 | /** |
| 6674 | * wlan_hdd_set_pre_cac_status() - Set the pre cac status |
| 6675 | * @pre_cac_adapter: AP adapter used for pre cac |
| 6676 | * @status: Status (true or false) |
| 6677 | * @handle: Global handle |
| 6678 | * |
| 6679 | * Sets the status of pre cac i.e., whether the pre cac is active or not |
| 6680 | * |
| 6681 | * Return: Zero on success, non-zero on failure |
| 6682 | */ |
| 6683 | static int wlan_hdd_set_pre_cac_status(hdd_adapter_t *pre_cac_adapter, |
| 6684 | bool status, tHalHandle handle) |
| 6685 | { |
| 6686 | QDF_STATUS ret; |
| 6687 | |
| 6688 | ret = wlan_sap_set_pre_cac_status( |
| 6689 | WLAN_HDD_GET_SAP_CTX_PTR(pre_cac_adapter), status, handle); |
| 6690 | if (QDF_IS_STATUS_ERROR(ret)) |
| 6691 | return -EINVAL; |
| 6692 | |
| 6693 | return 0; |
| 6694 | } |
| 6695 | |
| 6696 | /** |
| 6697 | * wlan_hdd_set_chan_before_pre_cac() - Save the channel before pre cac |
| 6698 | * @ap_adapter: AP adapter |
| 6699 | * @chan_before_pre_cac: Channel |
| 6700 | * |
| 6701 | * Saves the channel which the AP was beaconing on before moving to the pre |
| 6702 | * cac channel. If radar is detected on the pre cac channel, this saved |
| 6703 | * channel will be used for AP operations. |
| 6704 | * |
| 6705 | * Return: Zero on success, non-zero on failure |
| 6706 | */ |
| 6707 | static int wlan_hdd_set_chan_before_pre_cac(hdd_adapter_t *ap_adapter, |
| 6708 | uint8_t chan_before_pre_cac) |
| 6709 | { |
| 6710 | QDF_STATUS ret; |
| 6711 | |
| 6712 | ret = wlan_sap_set_chan_before_pre_cac( |
| 6713 | WLAN_HDD_GET_SAP_CTX_PTR(ap_adapter), chan_before_pre_cac); |
| 6714 | if (QDF_IS_STATUS_ERROR(ret)) |
| 6715 | return -EINVAL; |
| 6716 | |
| 6717 | return 0; |
| 6718 | } |
| 6719 | |
| 6720 | /** |
| 6721 | * wlan_hdd_sap_get_nol() - Get SAPs NOL |
| 6722 | * @ap_adapter: AP adapter |
| 6723 | * @nol: Non-occupancy list |
| 6724 | * @nol_len: Length of NOL |
| 6725 | * |
| 6726 | * Get the NOL for SAP |
| 6727 | * |
| 6728 | * Return: Zero on success, non-zero on failure |
| 6729 | */ |
| 6730 | static int wlan_hdd_sap_get_nol(hdd_adapter_t *ap_adapter, uint8_t *nol, |
| 6731 | uint32_t *nol_len) |
| 6732 | { |
| 6733 | QDF_STATUS ret; |
| 6734 | |
| 6735 | ret = wlansap_get_dfs_nol(WLAN_HDD_GET_SAP_CTX_PTR(ap_adapter), |
| 6736 | nol, nol_len); |
| 6737 | if (QDF_IS_STATUS_ERROR(ret)) |
| 6738 | return -EINVAL; |
| 6739 | |
| 6740 | return 0; |
| 6741 | } |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 6742 | |
| 6743 | /** |
| 6744 | * wlan_hdd_validate_and_get_pre_cac_ch() - Validate and get pre cac channel |
| 6745 | * @hdd_ctx: HDD context |
| 6746 | * @ap_adapter: AP adapter |
| 6747 | * @channel: Channel requested by userspace |
| 6748 | * @pre_cac_chan: Pointer to the pre CAC channel |
| 6749 | * |
| 6750 | * Validates the channel provided by userspace. If user provided channel 0, |
| 6751 | * a valid outdoor channel must be selected from the regulatory channel. |
| 6752 | * |
| 6753 | * Return: Zero on success and non zero value on error |
| 6754 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 6755 | static int wlan_hdd_validate_and_get_pre_cac_ch(hdd_context_t *hdd_ctx, |
| 6756 | hdd_adapter_t *ap_adapter, |
| 6757 | uint8_t channel, |
| 6758 | uint8_t *pre_cac_chan) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 6759 | { |
| 6760 | uint32_t i, j; |
| 6761 | QDF_STATUS status; |
| 6762 | int ret; |
| 6763 | uint8_t nol[QDF_MAX_NUM_CHAN]; |
| 6764 | uint32_t nol_len = 0, weight_len = 0; |
| 6765 | bool found; |
| 6766 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 6767 | uint8_t channel_list[QDF_MAX_NUM_CHAN] = {0}; |
| 6768 | uint8_t pcl_weights[QDF_MAX_NUM_CHAN] = {0}; |
| 6769 | |
| 6770 | if (0 == channel) { |
| 6771 | /* Channel is not obtained from PCL because PCL may not have |
| 6772 | * the entire channel list. For example: if SAP is up on |
| 6773 | * channel 6 and PCL is queried for the next SAP interface, |
| 6774 | * if SCC is preferred, the PCL will contain only the channel |
| 6775 | * 6. But, we are in need of a DFS channel. So, going with the |
| 6776 | * first channel from the valid channel list. |
| 6777 | */ |
| 6778 | status = cds_get_valid_chans(channel_list, &len); |
| 6779 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6780 | hdd_err("Failed to get channel list"); |
| 6781 | return -EINVAL; |
| 6782 | } |
| 6783 | cds_update_with_safe_channel_list(channel_list, &len, |
| 6784 | pcl_weights, weight_len); |
| 6785 | ret = wlan_hdd_sap_get_nol(ap_adapter, nol, &nol_len); |
| 6786 | for (i = 0; i < len; i++) { |
| 6787 | found = false; |
| 6788 | for (j = 0; j < nol_len; j++) { |
| 6789 | if (channel_list[i] == nol[j]) { |
| 6790 | found = true; |
| 6791 | break; |
| 6792 | } |
| 6793 | } |
| 6794 | if (found) |
| 6795 | continue; |
| 6796 | if (CDS_IS_DFS_CH(channel_list[i])) { |
| 6797 | *pre_cac_chan = channel_list[i]; |
| 6798 | break; |
| 6799 | } |
| 6800 | } |
| 6801 | if (*pre_cac_chan == 0) { |
| 6802 | hdd_err("unable to find outdoor channel"); |
| 6803 | return -EINVAL; |
| 6804 | } |
| 6805 | } else { |
| 6806 | /* Only when driver selects a channel, check is done for |
| 6807 | * unnsafe and NOL channels. When user provides a fixed channel |
| 6808 | * the user is expected to take care of this. |
| 6809 | */ |
| 6810 | if (!sme_is_channel_valid(hdd_ctx->hHal, channel) || |
| 6811 | !CDS_IS_DFS_CH(channel)) { |
| 6812 | hdd_err("Invalid channel for pre cac:%d", channel); |
| 6813 | return -EINVAL; |
| 6814 | } else { |
| 6815 | *pre_cac_chan = channel; |
| 6816 | } |
| 6817 | } |
| 6818 | hdd_info("selected pre cac channel:%d", *pre_cac_chan); |
| 6819 | return 0; |
| 6820 | } |
| 6821 | |
| 6822 | /** |
| 6823 | * wlan_hdd_request_pre_cac() - Start pre CAC in the driver |
| 6824 | * @channel: Channel option provided by userspace |
| 6825 | * |
| 6826 | * Sets the driver to the required hardware mode and start an adapater for |
| 6827 | * pre CAC which will mimic an AP. |
| 6828 | * |
| 6829 | * Return: Zero on success, non-zero value on error |
| 6830 | */ |
| 6831 | int wlan_hdd_request_pre_cac(uint8_t channel) |
| 6832 | { |
| 6833 | uint8_t pre_cac_chan = 0; |
| 6834 | hdd_context_t *hdd_ctx; |
| 6835 | int ret; |
| 6836 | hdd_adapter_t *ap_adapter, *pre_cac_adapter; |
| 6837 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 6838 | QDF_STATUS status; |
| 6839 | struct wiphy *wiphy; |
| 6840 | struct net_device *dev; |
| 6841 | struct cfg80211_chan_def chandef; |
| 6842 | enum nl80211_channel_type channel_type; |
| 6843 | uint32_t freq; |
| 6844 | struct ieee80211_channel *chan; |
| 6845 | tHalHandle handle; |
| 6846 | bool val; |
| 6847 | |
| 6848 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6849 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 6850 | return -EINVAL; |
| 6851 | |
| 6852 | if (cds_get_connection_count() > 1) { |
| 6853 | hdd_err("pre cac not allowed in concurrency"); |
| 6854 | return -EINVAL; |
| 6855 | } |
| 6856 | |
| 6857 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 6858 | if (!ap_adapter) { |
| 6859 | hdd_err("unable to get SAP adapter"); |
| 6860 | return -EINVAL; |
| 6861 | } |
| 6862 | |
| 6863 | handle = WLAN_HDD_GET_HAL_CTX(ap_adapter); |
| 6864 | if (!handle) { |
| 6865 | hdd_err("Invalid handle"); |
| 6866 | return -EINVAL; |
| 6867 | } |
| 6868 | |
| 6869 | val = wlan_sap_is_pre_cac_active(handle); |
| 6870 | if (val) { |
| 6871 | hdd_err("pre cac is already in progress"); |
| 6872 | return -EINVAL; |
| 6873 | } |
| 6874 | |
| 6875 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 6876 | if (!hdd_ap_ctx) { |
| 6877 | hdd_err("SAP context is NULL"); |
| 6878 | return -EINVAL; |
| 6879 | } |
| 6880 | |
| 6881 | if (CDS_IS_DFS_CH(hdd_ap_ctx->operatingChannel)) { |
| 6882 | hdd_err("SAP is already on DFS channel:%d", |
| 6883 | hdd_ap_ctx->operatingChannel); |
| 6884 | return -EINVAL; |
| 6885 | } |
| 6886 | |
| 6887 | if (!CDS_IS_CHANNEL_24GHZ(hdd_ap_ctx->operatingChannel)) { |
| 6888 | hdd_err("pre CAC alllowed only when SAP is in 2.4GHz:%d", |
| 6889 | hdd_ap_ctx->operatingChannel); |
| 6890 | return -EINVAL; |
| 6891 | } |
| 6892 | |
| 6893 | hdd_info("channel:%d", channel); |
| 6894 | |
| 6895 | ret = wlan_hdd_validate_and_get_pre_cac_ch(hdd_ctx, ap_adapter, channel, |
| 6896 | &pre_cac_chan); |
| 6897 | if (ret != 0) |
| 6898 | return ret; |
| 6899 | |
| 6900 | /* Since current SAP is in 2.4GHz and pre CAC channel is in 5GHz, this |
| 6901 | * connection update should result in DBS mode |
| 6902 | */ |
| 6903 | status = cds_update_and_wait_for_connection_update( |
| 6904 | ap_adapter->sessionId, |
| 6905 | pre_cac_chan, |
| 6906 | SIR_UPDATE_REASON_PRE_CAC); |
| 6907 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6908 | hdd_err("error in moving to DBS mode"); |
| 6909 | return -EINVAL; |
| 6910 | } |
| 6911 | |
| 6912 | hdd_debug("starting pre cac SAP adapter"); |
| 6913 | |
| 6914 | /* Starting a SAP adapter: |
| 6915 | * Instead of opening an adapter, we could just do a SME open session |
| 6916 | * for AP type. But, start BSS would still need an adapter. |
| 6917 | * So, this option is not taken. |
| 6918 | * |
| 6919 | * hdd open adapter is going to register this precac interface with |
| 6920 | * user space. This interface though exposed to user space will be in |
| 6921 | * DOWN state. Consideration was done to avoid this registration to the |
| 6922 | * user space. But, as part of SAP operations multiple events are sent |
| 6923 | * to user space. Some of these events received from unregistered |
| 6924 | * interface was causing crashes. So, retaining the registration. |
| 6925 | * |
| 6926 | * So, this interface would remain registered and will remain in DOWN |
| 6927 | * state for the CAC duration. We will add notes in the feature |
| 6928 | * announcement to not use this temporary interface for any activity |
| 6929 | * from user space. |
| 6930 | */ |
| 6931 | pre_cac_adapter = hdd_open_adapter(hdd_ctx, QDF_SAP_MODE, "precac%d", |
| 6932 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 6933 | NET_NAME_UNKNOWN, true); |
| 6934 | if (!pre_cac_adapter) { |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 6935 | hdd_err("error opening the pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 6936 | return -EINVAL; |
| 6937 | } |
| 6938 | |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 6939 | /* |
| 6940 | * This interface is internally created by the driver. So, no interface |
| 6941 | * up comes for this interface from user space and hence starting |
| 6942 | * the adapter internally. |
| 6943 | */ |
| 6944 | if (hdd_start_adapter(pre_cac_adapter)) { |
| 6945 | hdd_err("error starting the pre cac adapter"); |
| 6946 | goto close_pre_cac_adapter; |
| 6947 | } |
| 6948 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 6949 | hdd_debug("preparing for start ap/bss on the pre cac adapter"); |
| 6950 | |
| 6951 | wiphy = hdd_ctx->wiphy; |
| 6952 | dev = pre_cac_adapter->dev; |
| 6953 | |
| 6954 | /* Since this is only a dummy interface lets us use the IEs from the |
| 6955 | * other active SAP interface. In regular scenarios, these IEs would |
| 6956 | * come from the user space entity |
| 6957 | */ |
| 6958 | pre_cac_adapter->sessionCtx.ap.beacon = qdf_mem_malloc( |
| 6959 | sizeof(*ap_adapter->sessionCtx.ap.beacon)); |
| 6960 | if (!pre_cac_adapter->sessionCtx.ap.beacon) { |
| 6961 | hdd_err("failed to alloc mem for beacon"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 6962 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 6963 | } |
| 6964 | qdf_mem_copy(pre_cac_adapter->sessionCtx.ap.beacon, |
| 6965 | ap_adapter->sessionCtx.ap.beacon, |
| 6966 | sizeof(*pre_cac_adapter->sessionCtx.ap.beacon)); |
| 6967 | pre_cac_adapter->sessionCtx.ap.sapConfig.ch_width_orig = |
| 6968 | ap_adapter->sessionCtx.ap.sapConfig.ch_width_orig; |
| 6969 | pre_cac_adapter->sessionCtx.ap.sapConfig.authType = |
| 6970 | ap_adapter->sessionCtx.ap.sapConfig.authType; |
| 6971 | |
| 6972 | /* Premise is that on moving from 2.4GHz to 5GHz, the SAP will continue |
| 6973 | * to operate on the same bandwidth as that of the 2.4GHz operations. |
| 6974 | * Only bandwidths 20MHz/40MHz are possible on 2.4GHz band. |
| 6975 | */ |
| 6976 | switch (ap_adapter->sessionCtx.ap.sapConfig.ch_width_orig) { |
| 6977 | case CH_WIDTH_20MHZ: |
| 6978 | channel_type = NL80211_CHAN_HT20; |
| 6979 | break; |
| 6980 | case CH_WIDTH_40MHZ: |
| 6981 | if (ap_adapter->sessionCtx.ap.sapConfig.sec_ch > |
| 6982 | ap_adapter->sessionCtx.ap.sapConfig.channel) |
| 6983 | channel_type = NL80211_CHAN_HT40PLUS; |
| 6984 | else |
| 6985 | channel_type = NL80211_CHAN_HT40MINUS; |
| 6986 | break; |
| 6987 | default: |
| 6988 | channel_type = NL80211_CHAN_NO_HT; |
| 6989 | break; |
| 6990 | } |
| 6991 | |
| 6992 | freq = cds_chan_to_freq(pre_cac_chan); |
| 6993 | chan = __ieee80211_get_channel(wiphy, freq); |
| 6994 | if (!chan) { |
| 6995 | hdd_err("channel converion failed"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 6996 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 6997 | } |
| 6998 | |
| 6999 | cfg80211_chandef_create(&chandef, chan, channel_type); |
| 7000 | |
| 7001 | hdd_debug("orig width:%d channel_type:%d freq:%d", |
| 7002 | ap_adapter->sessionCtx.ap.sapConfig.ch_width_orig, |
| 7003 | channel_type, freq); |
| 7004 | |
| 7005 | ret = wlan_hdd_set_channel(wiphy, dev, &chandef, channel_type); |
| 7006 | if (0 != ret) { |
| 7007 | hdd_err("failed to set channel"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 7008 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 7009 | } |
| 7010 | |
| 7011 | status = wlan_hdd_cfg80211_start_bss(pre_cac_adapter, NULL, |
| 7012 | PRE_CAC_SSID, qdf_str_len(PRE_CAC_SSID), |
Archana Ramachandran | 1a5b604 | 2016-11-08 16:36:50 -0800 | [diff] [blame^] | 7013 | eHIDDEN_SSID_NOT_IN_USE, false, false); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 7014 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7015 | hdd_err("start bss failed"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 7016 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 7017 | } |
| 7018 | |
| 7019 | /* |
| 7020 | * The pre cac status is set here. But, it would not be reset explicitly |
| 7021 | * anywhere, since after the pre cac success/failure, the pre cac |
| 7022 | * adapter itself would be removed. |
| 7023 | */ |
| 7024 | ret = wlan_hdd_set_pre_cac_status(pre_cac_adapter, true, handle); |
| 7025 | if (0 != ret) { |
| 7026 | hdd_err("failed to set pre cac status"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 7027 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 7028 | } |
| 7029 | |
| 7030 | ret = wlan_hdd_set_chan_before_pre_cac(ap_adapter, |
| 7031 | hdd_ap_ctx->operatingChannel); |
| 7032 | if (0 != ret) { |
| 7033 | hdd_err("failed to set channel before pre cac"); |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 7034 | goto stop_close_pre_cac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 7035 | } |
| 7036 | |
| 7037 | ap_adapter->pre_cac_chan = pre_cac_chan; |
| 7038 | |
| 7039 | return 0; |
| 7040 | |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 7041 | stop_close_pre_cac_adapter: |
| 7042 | hdd_stop_adapter(hdd_ctx, pre_cac_adapter, true); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 7043 | qdf_mem_free(pre_cac_adapter->sessionCtx.ap.beacon); |
| 7044 | pre_cac_adapter->sessionCtx.ap.beacon = NULL; |
Manishekar Chandrasekaran | dfdf2a8 | 2016-08-24 16:16:16 +0530 | [diff] [blame] | 7045 | close_pre_cac_adapter: |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 7046 | hdd_close_adapter(hdd_ctx, pre_cac_adapter, false); |
| 7047 | return -EINVAL; |
| 7048 | } |
| 7049 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 7050 | /** |
| 7051 | * hdd_init_bpf_completion() - Initialize the completion event for bpf |
| 7052 | * |
| 7053 | * Return: None |
| 7054 | */ |
| 7055 | void hdd_init_bpf_completion(void) |
| 7056 | { |
| 7057 | init_completion(&bpf_context.completion); |
| 7058 | } |
| 7059 | |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 7060 | static const struct nla_policy |
| 7061 | wlan_hdd_sap_config_policy[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_MAX + 1] = { |
| 7062 | [QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHANNEL] = {.type = NLA_U8 }, |
| 7063 | }; |
| 7064 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 7065 | static const struct nla_policy |
| 7066 | wlan_hdd_set_acs_dfs_config_policy[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MAX + 1] = { |
| 7067 | [QCA_WLAN_VENDOR_ATTR_ACS_DFS_MODE] = {.type = NLA_U8 }, |
| 7068 | [QCA_WLAN_VENDOR_ATTR_ACS_CHANNEL_HINT] = {.type = NLA_U8 }, |
| 7069 | }; |
| 7070 | |
| 7071 | /** |
| 7072 | * __wlan_hdd_cfg80211_acs_dfs_mode() - set ACS DFS mode and channel |
| 7073 | * @wiphy: Pointer to wireless phy |
| 7074 | * @wdev: Pointer to wireless device |
| 7075 | * @data: Pointer to data |
| 7076 | * @data_len: Length of @data |
| 7077 | * |
| 7078 | * This function parses the incoming NL vendor command data attributes and |
| 7079 | * updates the SAP context about channel_hint and DFS mode. |
| 7080 | * If channel_hint is set, SAP will choose that channel |
| 7081 | * as operating channel. |
| 7082 | * |
| 7083 | * If DFS mode is enabled, driver will include DFS channels |
| 7084 | * in ACS else driver will skip DFS channels. |
| 7085 | * |
| 7086 | * Return: 0 on success, negative errno on failure |
| 7087 | */ |
| 7088 | static int |
| 7089 | __wlan_hdd_cfg80211_acs_dfs_mode(struct wiphy *wiphy, |
| 7090 | struct wireless_dev *wdev, |
| 7091 | const void *data, int data_len) |
| 7092 | { |
| 7093 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 7094 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MAX + 1]; |
| 7095 | int ret; |
| 7096 | struct acs_dfs_policy *acs_policy; |
| 7097 | int mode = DFS_MODE_NONE; |
| 7098 | int channel_hint = 0; |
| 7099 | |
| 7100 | ENTER_DEV(wdev->netdev); |
| 7101 | |
| 7102 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 7103 | hdd_err("Command not allowed in FTM mode"); |
| 7104 | return -EINVAL; |
| 7105 | } |
| 7106 | |
| 7107 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7108 | if (0 != ret) |
| 7109 | return ret; |
| 7110 | |
| 7111 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_ACS_DFS_MAX, |
| 7112 | data, data_len, |
| 7113 | wlan_hdd_set_acs_dfs_config_policy)) { |
| 7114 | hdd_err("invalid attr"); |
| 7115 | return -EINVAL; |
| 7116 | } |
| 7117 | |
| 7118 | acs_policy = &hdd_ctx->acs_policy; |
| 7119 | /* |
| 7120 | * SCM sends this attribute to restrict SAP from choosing |
| 7121 | * DFS channels from ACS. |
| 7122 | */ |
| 7123 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MODE]) |
| 7124 | mode = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_ACS_DFS_MODE]); |
| 7125 | |
| 7126 | if (!IS_DFS_MODE_VALID(mode)) { |
| 7127 | hdd_err("attr acs dfs mode is not valid"); |
| 7128 | return -EINVAL; |
| 7129 | } |
| 7130 | acs_policy->acs_dfs_mode = mode; |
| 7131 | |
| 7132 | /* |
| 7133 | * SCM sends this attribute to provide an active channel, |
| 7134 | * to skip redundant ACS between drivers, and save driver start up time |
| 7135 | */ |
| 7136 | if (tb[QCA_WLAN_VENDOR_ATTR_ACS_CHANNEL_HINT]) |
| 7137 | channel_hint = nla_get_u8( |
| 7138 | tb[QCA_WLAN_VENDOR_ATTR_ACS_CHANNEL_HINT]); |
| 7139 | |
| 7140 | if (!IS_CHANNEL_VALID(channel_hint)) { |
| 7141 | hdd_err("acs channel is not valid"); |
| 7142 | return -EINVAL; |
| 7143 | } |
| 7144 | acs_policy->acs_channel = channel_hint; |
| 7145 | |
| 7146 | return 0; |
| 7147 | } |
| 7148 | |
| 7149 | /** |
| 7150 | * wlan_hdd_cfg80211_acs_dfs_mode() - Wrapper to set ACS DFS mode |
| 7151 | * @wiphy: wiphy structure pointer |
| 7152 | * @wdev: Wireless device structure pointer |
| 7153 | * @data: Pointer to the data received |
| 7154 | * @data_len: Length of @data |
| 7155 | * |
| 7156 | * This function parses the incoming NL vendor command data attributes and |
| 7157 | * updates the SAP context about channel_hint and DFS mode. |
| 7158 | * |
| 7159 | * Return: 0 on success; errno on failure |
| 7160 | */ |
| 7161 | static int wlan_hdd_cfg80211_acs_dfs_mode(struct wiphy *wiphy, |
| 7162 | struct wireless_dev *wdev, |
| 7163 | const void *data, int data_len) |
| 7164 | { |
| 7165 | int ret; |
| 7166 | |
| 7167 | cds_ssr_protect(__func__); |
| 7168 | ret = __wlan_hdd_cfg80211_acs_dfs_mode(wiphy, wdev, data, data_len); |
| 7169 | cds_ssr_unprotect(__func__); |
| 7170 | |
| 7171 | return ret; |
| 7172 | } |
| 7173 | |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 7174 | /** |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 7175 | * wlan_hdd_get_sta_roam_dfs_mode() - get sta roam dfs mode policy |
| 7176 | * @mode : cfg80211 dfs mode |
| 7177 | * |
| 7178 | * Return: return csr sta roam dfs mode else return NONE |
| 7179 | */ |
| 7180 | static enum sta_roam_policy_dfs_mode wlan_hdd_get_sta_roam_dfs_mode( |
| 7181 | enum dfs_mode mode) |
| 7182 | { |
| 7183 | switch (mode) { |
| 7184 | case DFS_MODE_ENABLE: |
| 7185 | return CSR_STA_ROAM_POLICY_DFS_ENABLED; |
| 7186 | break; |
| 7187 | case DFS_MODE_DISABLE: |
| 7188 | return CSR_STA_ROAM_POLICY_DFS_DISABLED; |
| 7189 | break; |
| 7190 | case DFS_MODE_DEPRIORITIZE: |
| 7191 | return CSR_STA_ROAM_POLICY_DFS_DEPRIORITIZE; |
| 7192 | break; |
| 7193 | default: |
| 7194 | hdd_err("STA Roam policy dfs mode is NONE"); |
| 7195 | return CSR_STA_ROAM_POLICY_NONE; |
| 7196 | } |
| 7197 | } |
| 7198 | |
| 7199 | static const struct nla_policy |
| 7200 | wlan_hdd_set_sta_roam_config_policy[ |
| 7201 | QCA_WLAN_VENDOR_ATTR_STA_CONNECT_ROAM_POLICY_MAX + 1] = { |
| 7202 | [QCA_WLAN_VENDOR_ATTR_STA_DFS_MODE] = {.type = NLA_U8 }, |
| 7203 | [QCA_WLAN_VENDOR_ATTR_STA_SKIP_UNSAFE_CHANNEL] = {.type = NLA_U8 }, |
| 7204 | }; |
| 7205 | |
| 7206 | /** |
| 7207 | * __wlan_hdd_cfg80211_sta_roam_policy() - Set params to restrict scan channels |
| 7208 | * for station connection or roaming. |
| 7209 | * @wiphy: Pointer to wireless phy |
| 7210 | * @wdev: Pointer to wireless device |
| 7211 | * @data: Pointer to data |
| 7212 | * @data_len: Length of @data |
| 7213 | * |
| 7214 | * __wlan_hdd_cfg80211_sta_roam_policy will decide if DFS channels or unsafe |
| 7215 | * channels needs to be skipped in scanning or not. |
| 7216 | * If dfs_mode is disabled, driver will not scan DFS channels. |
| 7217 | * If skip_unsafe_channels is set, driver will skip unsafe channels |
| 7218 | * in Scanning. |
| 7219 | * |
| 7220 | * Return: 0 on success, negative errno on failure |
| 7221 | */ |
| 7222 | static int |
| 7223 | __wlan_hdd_cfg80211_sta_roam_policy(struct wiphy *wiphy, |
| 7224 | struct wireless_dev *wdev, |
| 7225 | const void *data, int data_len) |
| 7226 | { |
| 7227 | struct net_device *dev = wdev->netdev; |
| 7228 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7229 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 7230 | struct nlattr *tb[ |
| 7231 | QCA_WLAN_VENDOR_ATTR_STA_CONNECT_ROAM_POLICY_MAX + 1]; |
| 7232 | int ret; |
| 7233 | enum sta_roam_policy_dfs_mode sta_roam_dfs_mode; |
| 7234 | enum dfs_mode mode = DFS_MODE_NONE; |
| 7235 | bool skip_unsafe_channels = false; |
| 7236 | QDF_STATUS status; |
| 7237 | |
| 7238 | ENTER_DEV(dev); |
| 7239 | |
| 7240 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 7241 | hdd_err("Command not allowed in FTM mode"); |
| 7242 | return -EINVAL; |
| 7243 | } |
| 7244 | |
| 7245 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7246 | if (0 != ret) |
| 7247 | return ret; |
| 7248 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_STA_CONNECT_ROAM_POLICY_MAX, |
| 7249 | data, data_len, |
| 7250 | wlan_hdd_set_sta_roam_config_policy)) { |
| 7251 | hdd_err("invalid attr"); |
| 7252 | return -EINVAL; |
| 7253 | } |
| 7254 | if (tb[QCA_WLAN_VENDOR_ATTR_STA_DFS_MODE]) |
| 7255 | mode = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_STA_DFS_MODE]); |
| 7256 | if (!IS_DFS_MODE_VALID(mode)) { |
| 7257 | hdd_err("attr sta roam dfs mode policy is not valid"); |
| 7258 | return -EINVAL; |
| 7259 | } |
| 7260 | |
| 7261 | sta_roam_dfs_mode = wlan_hdd_get_sta_roam_dfs_mode(mode); |
| 7262 | |
| 7263 | if (tb[QCA_WLAN_VENDOR_ATTR_STA_SKIP_UNSAFE_CHANNEL]) |
| 7264 | skip_unsafe_channels = nla_get_u8( |
| 7265 | tb[QCA_WLAN_VENDOR_ATTR_STA_SKIP_UNSAFE_CHANNEL]); |
| 7266 | |
| 7267 | status = sme_update_sta_roam_policy(hdd_ctx->hHal, sta_roam_dfs_mode, |
| 7268 | skip_unsafe_channels, adapter->sessionId); |
| 7269 | |
| 7270 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 7271 | hdd_err("sme_update_sta_roam_policy (err=%d)", status); |
| 7272 | return -EINVAL; |
| 7273 | } |
| 7274 | return 0; |
| 7275 | } |
| 7276 | |
| 7277 | /** |
| 7278 | * wlan_hdd_cfg80211_sta_roam_policy() - Wrapper to restrict scan channels, |
| 7279 | * connection and roaming for station. |
| 7280 | * @wiphy: wiphy structure pointer |
| 7281 | * @wdev: Wireless device structure pointer |
| 7282 | * @data: Pointer to the data received |
| 7283 | * @data_len: Length of @data |
| 7284 | * |
| 7285 | * __wlan_hdd_cfg80211_sta_roam_policy will decide if DFS channels or unsafe |
| 7286 | * channels needs to be skipped in scanning or not. |
| 7287 | * If dfs_mode is disabled, driver will not scan DFS channels. |
| 7288 | * If skip_unsafe_channels is set, driver will skip unsafe channels |
| 7289 | * in Scanning. |
| 7290 | * Return: 0 on success; errno on failure |
| 7291 | */ |
| 7292 | static int wlan_hdd_cfg80211_sta_roam_policy(struct wiphy *wiphy, |
| 7293 | struct wireless_dev *wdev, |
| 7294 | const void *data, int data_len) |
| 7295 | { |
| 7296 | int ret; |
| 7297 | |
| 7298 | cds_ssr_protect(__func__); |
| 7299 | ret = __wlan_hdd_cfg80211_sta_roam_policy(wiphy, wdev, data, data_len); |
| 7300 | cds_ssr_unprotect(__func__); |
| 7301 | |
| 7302 | return ret; |
| 7303 | } |
| 7304 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7305 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7306 | /** |
| 7307 | * __wlan_hdd_cfg80211_avoid_freq() - ask driver to restart SAP if SAP |
| 7308 | * is on unsafe channel. |
| 7309 | * @wiphy: wiphy structure pointer |
| 7310 | * @wdev: Wireless device structure pointer |
| 7311 | * @data: Pointer to the data received |
| 7312 | * @data_len: Length of @data |
| 7313 | * |
| 7314 | * wlan_hdd_cfg80211_avoid_freq do restart the sap if sap is already |
| 7315 | * on any of unsafe channels. |
| 7316 | * If sap is on any of unsafe channel, hdd_unsafe_channel_restart_sap |
| 7317 | * will send WLAN_SVC_LTE_COEX_IND indication to userspace to restart. |
| 7318 | * |
| 7319 | * Return: 0 on success; errno on failure |
| 7320 | */ |
| 7321 | static int |
| 7322 | __wlan_hdd_cfg80211_avoid_freq(struct wiphy *wiphy, |
| 7323 | struct wireless_dev *wdev, |
| 7324 | const void *data, int data_len) |
| 7325 | { |
| 7326 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 7327 | int ret; |
| 7328 | uint16_t unsafe_channel_count; |
| 7329 | int unsafe_channel_index; |
| 7330 | qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 7331 | |
| 7332 | ENTER_DEV(wdev->netdev); |
| 7333 | |
| 7334 | if (!qdf_ctx) { |
| 7335 | cds_err("qdf_ctx is NULL"); |
| 7336 | return -EINVAL; |
| 7337 | } |
| 7338 | |
| 7339 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 7340 | hdd_err("Command not allowed in FTM mode"); |
| 7341 | return -EINVAL; |
| 7342 | } |
| 7343 | |
| 7344 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7345 | if (0 != ret) |
| 7346 | return ret; |
| 7347 | pld_get_wlan_unsafe_channel(qdf_ctx->dev, hdd_ctx->unsafe_channel_list, |
| 7348 | &(hdd_ctx->unsafe_channel_count), |
| 7349 | sizeof(hdd_ctx->unsafe_channel_list)); |
| 7350 | |
| 7351 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
| 7352 | (uint16_t)NUM_CHANNELS); |
| 7353 | for (unsafe_channel_index = 0; |
| 7354 | unsafe_channel_index < unsafe_channel_count; |
| 7355 | unsafe_channel_index++) { |
| 7356 | hdd_info("Channel %d is not safe", |
| 7357 | hdd_ctx->unsafe_channel_list[unsafe_channel_index]); |
| 7358 | } |
| 7359 | hdd_unsafe_channel_restart_sap(hdd_ctx); |
| 7360 | return 0; |
| 7361 | } |
| 7362 | |
| 7363 | /** |
| 7364 | * wlan_hdd_cfg80211_avoid_freq() - ask driver to restart SAP if SAP |
| 7365 | * is on unsafe channel. |
| 7366 | * @wiphy: wiphy structure pointer |
| 7367 | * @wdev: Wireless device structure pointer |
| 7368 | * @data: Pointer to the data received |
| 7369 | * @data_len: Length of @data |
| 7370 | * |
| 7371 | * wlan_hdd_cfg80211_avoid_freq do restart the sap if sap is already |
| 7372 | * on any of unsafe channels. |
| 7373 | * If sap is on any of unsafe channel, hdd_unsafe_channel_restart_sap |
| 7374 | * will send WLAN_SVC_LTE_COEX_IND indication to userspace to restart. |
| 7375 | * |
| 7376 | * Return: 0 on success; errno on failure |
| 7377 | */ |
| 7378 | static int wlan_hdd_cfg80211_avoid_freq(struct wiphy *wiphy, |
| 7379 | struct wireless_dev *wdev, |
| 7380 | const void *data, int data_len) |
| 7381 | { |
| 7382 | int ret; |
| 7383 | |
| 7384 | cds_ssr_protect(__func__); |
| 7385 | ret = __wlan_hdd_cfg80211_avoid_freq(wiphy, wdev, data, data_len); |
| 7386 | cds_ssr_unprotect(__func__); |
| 7387 | |
| 7388 | return ret; |
| 7389 | } |
| 7390 | |
| 7391 | #endif |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 7392 | /** |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 7393 | * __wlan_hdd_cfg80211_sap_configuration_set() - ask driver to restart SAP if |
| 7394 | * SAP is on unsafe channel. |
| 7395 | * @wiphy: wiphy structure pointer |
| 7396 | * @wdev: Wireless device structure pointer |
| 7397 | * @data: Pointer to the data received |
| 7398 | * @data_len: Length of @data |
| 7399 | * |
| 7400 | * __wlan_hdd_cfg80211_sap_configuration_set function set SAP params to |
| 7401 | * driver. |
| 7402 | * QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHAN will set sap config channel and |
| 7403 | * will initiate restart of sap. |
| 7404 | * |
| 7405 | * Return: 0 on success; errno on failure |
| 7406 | */ |
| 7407 | static int |
| 7408 | __wlan_hdd_cfg80211_sap_configuration_set(struct wiphy *wiphy, |
| 7409 | struct wireless_dev *wdev, |
| 7410 | const void *data, int data_len) |
| 7411 | { |
| 7412 | struct net_device *ndev = wdev->netdev; |
| 7413 | hdd_adapter_t *hostapd_adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 7414 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 7415 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_MAX + 1]; |
| 7416 | uint8_t config_channel = 0; |
| 7417 | hdd_ap_ctx_t *ap_ctx; |
| 7418 | int ret; |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 7419 | QDF_STATUS status; |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 7420 | |
| 7421 | ENTER(); |
| 7422 | |
| 7423 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7424 | hdd_err("Command not allowed in FTM mode"); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 7425 | return -EINVAL; |
| 7426 | } |
| 7427 | |
| 7428 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7429 | if (0 != ret) |
| 7430 | return -EINVAL; |
| 7431 | |
| 7432 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_MAX, |
| 7433 | data, data_len, |
| 7434 | wlan_hdd_sap_config_policy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 7435 | hdd_err("invalid attr"); |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 7436 | return -EINVAL; |
| 7437 | } |
| 7438 | |
| 7439 | if (tb[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHANNEL]) { |
| 7440 | if (!test_bit(SOFTAP_BSS_STARTED, |
| 7441 | &hostapd_adapter->event_flags)) { |
| 7442 | hdd_err("SAP is not started yet. Restart sap will be invalid"); |
| 7443 | return -EINVAL; |
| 7444 | } |
| 7445 | |
| 7446 | config_channel = |
| 7447 | nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHANNEL]); |
| 7448 | |
| 7449 | if (!((IS_24G_CH(config_channel)) || |
| 7450 | (IS_5G_CH(config_channel)))) { |
| 7451 | hdd_err("Channel %d is not valid to restart SAP", |
| 7452 | config_channel); |
| 7453 | return -ENOTSUPP; |
| 7454 | } |
| 7455 | |
| 7456 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(hostapd_adapter); |
| 7457 | ap_ctx->sapConfig.channel = config_channel; |
| 7458 | ap_ctx->sapConfig.ch_params.ch_width = |
| 7459 | ap_ctx->sapConfig.ch_width_orig; |
| 7460 | |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 7461 | cds_set_channel_params(ap_ctx->sapConfig.channel, |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 7462 | ap_ctx->sapConfig.sec_ch, |
| 7463 | &ap_ctx->sapConfig.ch_params); |
| 7464 | |
| 7465 | cds_restart_sap(hostapd_adapter); |
| 7466 | } |
| 7467 | |
Manishekar Chandrasekaran | 1db3abe | 2016-06-24 03:27:07 +0530 | [diff] [blame] | 7468 | if (tb[QCA_WLAN_VENDOR_ATTR_SAP_MANDATORY_FREQUENCY_LIST]) { |
| 7469 | uint32_t freq_len, i; |
| 7470 | uint32_t *freq; |
| 7471 | uint8_t chans[QDF_MAX_NUM_CHAN]; |
| 7472 | |
| 7473 | hdd_debug("setting mandatory freq/chan list"); |
| 7474 | |
| 7475 | freq_len = nla_len( |
| 7476 | tb[QCA_WLAN_VENDOR_ATTR_SAP_MANDATORY_FREQUENCY_LIST])/ |
| 7477 | sizeof(uint32_t); |
| 7478 | |
| 7479 | if (freq_len > QDF_MAX_NUM_CHAN) { |
| 7480 | hdd_err("insufficient space to hold channels"); |
| 7481 | return -ENOMEM; |
| 7482 | } |
| 7483 | |
| 7484 | freq = nla_data( |
| 7485 | tb[QCA_WLAN_VENDOR_ATTR_SAP_MANDATORY_FREQUENCY_LIST]); |
| 7486 | |
| 7487 | hdd_debug("freq_len=%d", freq_len); |
| 7488 | |
| 7489 | for (i = 0; i < freq_len; i++) { |
| 7490 | chans[i] = ieee80211_frequency_to_channel(freq[i]); |
| 7491 | hdd_debug("freq[%d]=%d", i, freq[i]); |
| 7492 | } |
| 7493 | |
| 7494 | status = cds_set_sap_mandatory_channels(chans, freq_len); |
| 7495 | if (QDF_IS_STATUS_ERROR(status)) |
| 7496 | return -EINVAL; |
| 7497 | } |
| 7498 | |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 7499 | return 0; |
| 7500 | } |
| 7501 | |
| 7502 | /** |
| 7503 | * wlan_hdd_cfg80211_sap_configuration_set() - sap configuration vendor command |
| 7504 | * @wiphy: wiphy structure pointer |
| 7505 | * @wdev: Wireless device structure pointer |
| 7506 | * @data: Pointer to the data received |
| 7507 | * @data_len: Length of @data |
| 7508 | * |
| 7509 | * __wlan_hdd_cfg80211_sap_configuration_set function set SAP params to |
| 7510 | * driver. |
| 7511 | * QCA_WLAN_VENDOR_ATTR_SAP_CONFIG_CHAN will set sap config channel and |
| 7512 | * will initiate restart of sap. |
| 7513 | * |
| 7514 | * Return: 0 on success; errno on failure |
| 7515 | */ |
| 7516 | static int wlan_hdd_cfg80211_sap_configuration_set(struct wiphy *wiphy, |
| 7517 | struct wireless_dev *wdev, |
| 7518 | const void *data, int data_len) |
| 7519 | { |
| 7520 | int ret; |
| 7521 | |
| 7522 | cds_ssr_protect(__func__); |
| 7523 | ret = __wlan_hdd_cfg80211_sap_configuration_set(wiphy, |
| 7524 | wdev, data, data_len); |
| 7525 | cds_ssr_unprotect(__func__); |
| 7526 | |
| 7527 | return ret; |
| 7528 | } |
| 7529 | |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 7530 | #undef BPF_INVALID |
| 7531 | #undef BPF_SET_RESET |
| 7532 | #undef BPF_VERSION |
| 7533 | #undef BPF_ID |
| 7534 | #undef BPF_PACKET_SIZE |
| 7535 | #undef BPF_CURRENT_OFFSET |
| 7536 | #undef BPF_PROGRAM |
| 7537 | #undef BPF_MAX |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7538 | |
| 7539 | /** |
| 7540 | * define short names for the global vendor params |
| 7541 | * used by wlan_hdd_cfg80211_wakelock_stats_rsp_callback() |
| 7542 | */ |
| 7543 | #define PARAM_TOTAL_CMD_EVENT_WAKE \ |
| 7544 | QCA_WLAN_VENDOR_ATTR_TOTAL_CMD_EVENT_WAKE |
| 7545 | #define PARAM_CMD_EVENT_WAKE_CNT_PTR \ |
| 7546 | QCA_WLAN_VENDOR_ATTR_CMD_EVENT_WAKE_CNT_PTR |
| 7547 | #define PARAM_CMD_EVENT_WAKE_CNT_SZ \ |
| 7548 | QCA_WLAN_VENDOR_ATTR_CMD_EVENT_WAKE_CNT_SZ |
| 7549 | #define PARAM_TOTAL_DRIVER_FW_LOCAL_WAKE \ |
| 7550 | QCA_WLAN_VENDOR_ATTR_TOTAL_DRIVER_FW_LOCAL_WAKE |
| 7551 | #define PARAM_DRIVER_FW_LOCAL_WAKE_CNT_PTR \ |
| 7552 | QCA_WLAN_VENDOR_ATTR_DRIVER_FW_LOCAL_WAKE_CNT_PTR |
| 7553 | #define PARAM_DRIVER_FW_LOCAL_WAKE_CNT_SZ \ |
| 7554 | QCA_WLAN_VENDOR_ATTR_DRIVER_FW_LOCAL_WAKE_CNT_SZ |
| 7555 | #define PARAM_TOTAL_RX_DATA_WAKE \ |
| 7556 | QCA_WLAN_VENDOR_ATTR_TOTAL_RX_DATA_WAKE |
| 7557 | #define PARAM_RX_UNICAST_CNT \ |
| 7558 | QCA_WLAN_VENDOR_ATTR_RX_UNICAST_CNT |
| 7559 | #define PARAM_RX_MULTICAST_CNT \ |
| 7560 | QCA_WLAN_VENDOR_ATTR_RX_MULTICAST_CNT |
| 7561 | #define PARAM_RX_BROADCAST_CNT \ |
| 7562 | QCA_WLAN_VENDOR_ATTR_RX_BROADCAST_CNT |
| 7563 | #define PARAM_ICMP_PKT \ |
| 7564 | QCA_WLAN_VENDOR_ATTR_ICMP_PKT |
| 7565 | #define PARAM_ICMP6_PKT \ |
| 7566 | QCA_WLAN_VENDOR_ATTR_ICMP6_PKT |
| 7567 | #define PARAM_ICMP6_RA \ |
| 7568 | QCA_WLAN_VENDOR_ATTR_ICMP6_RA |
| 7569 | #define PARAM_ICMP6_NA \ |
| 7570 | QCA_WLAN_VENDOR_ATTR_ICMP6_NA |
| 7571 | #define PARAM_ICMP6_NS \ |
| 7572 | QCA_WLAN_VENDOR_ATTR_ICMP6_NS |
| 7573 | #define PARAM_ICMP4_RX_MULTICAST_CNT \ |
| 7574 | QCA_WLAN_VENDOR_ATTR_ICMP4_RX_MULTICAST_CNT |
| 7575 | #define PARAM_ICMP6_RX_MULTICAST_CNT \ |
| 7576 | QCA_WLAN_VENDOR_ATTR_ICMP6_RX_MULTICAST_CNT |
| 7577 | #define PARAM_OTHER_RX_MULTICAST_CNT \ |
| 7578 | QCA_WLAN_VENDOR_ATTR_OTHER_RX_MULTICAST_CNT |
| 7579 | |
| 7580 | |
| 7581 | /** |
| 7582 | * hdd_send_wakelock_stats() - API to send wakelock stats |
| 7583 | * @ctx: context to be passed to callback |
| 7584 | * @data: data passed to callback |
| 7585 | * |
| 7586 | * This function is used to send wake lock stats to HAL layer |
| 7587 | * |
| 7588 | * Return: 0 on success, error number otherwise. |
| 7589 | */ |
| 7590 | static uint32_t hdd_send_wakelock_stats(hdd_context_t *hdd_ctx, |
| 7591 | const struct sir_wake_lock_stats *data) |
| 7592 | { |
| 7593 | struct sk_buff *skb; |
| 7594 | uint32_t nl_buf_len; |
| 7595 | uint32_t total_rx_data_wake, rx_multicast_cnt; |
| 7596 | uint32_t ipv6_rx_multicast_addr_cnt; |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 7597 | uint32_t icmpv6_cnt; |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7598 | |
| 7599 | ENTER(); |
| 7600 | |
| 7601 | nl_buf_len = NLMSG_HDRLEN; |
| 7602 | nl_buf_len += |
| 7603 | QCA_WLAN_VENDOR_GET_WAKE_STATS_MAX * |
| 7604 | (NLMSG_HDRLEN + sizeof(uint32_t)); |
| 7605 | |
| 7606 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 7607 | |
| 7608 | if (!skb) { |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7609 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7610 | return -ENOMEM; |
| 7611 | } |
| 7612 | |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7613 | hdd_info("wow_ucast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7614 | data->wow_ucast_wake_up_count); |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7615 | hdd_info("wow_bcast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7616 | data->wow_bcast_wake_up_count); |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7617 | hdd_info("wow_ipv4_mcast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7618 | data->wow_ipv4_mcast_wake_up_count); |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7619 | hdd_info("wow_ipv6_mcast_wake_up_count %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7620 | data->wow_ipv6_mcast_wake_up_count); |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7621 | hdd_info("wow_ipv6_mcast_ra_stats %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7622 | data->wow_ipv6_mcast_ra_stats); |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7623 | hdd_info("wow_ipv6_mcast_ns_stats %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7624 | data->wow_ipv6_mcast_ns_stats); |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7625 | hdd_info("wow_ipv6_mcast_na_stats %d", |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7626 | data->wow_ipv6_mcast_na_stats); |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7627 | hdd_info("wow_icmpv4_count %d", data->wow_icmpv4_count); |
| 7628 | hdd_info("wow_icmpv6_count %d", |
Himanshu Agarwal | 4574e28 | 2016-08-10 15:22:45 +0530 | [diff] [blame] | 7629 | data->wow_icmpv6_count); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7630 | |
| 7631 | ipv6_rx_multicast_addr_cnt = |
Himanshu Agarwal | 4574e28 | 2016-08-10 15:22:45 +0530 | [diff] [blame] | 7632 | data->wow_ipv6_mcast_wake_up_count; |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7633 | |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 7634 | icmpv6_cnt = |
Himanshu Agarwal | 4574e28 | 2016-08-10 15:22:45 +0530 | [diff] [blame] | 7635 | data->wow_icmpv6_count; |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 7636 | |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7637 | rx_multicast_cnt = |
| 7638 | data->wow_ipv4_mcast_wake_up_count + |
| 7639 | ipv6_rx_multicast_addr_cnt; |
| 7640 | |
| 7641 | total_rx_data_wake = |
| 7642 | data->wow_ucast_wake_up_count + |
| 7643 | data->wow_bcast_wake_up_count + |
| 7644 | rx_multicast_cnt; |
| 7645 | |
| 7646 | if (nla_put_u32(skb, PARAM_TOTAL_CMD_EVENT_WAKE, 0) || |
| 7647 | nla_put_u32(skb, PARAM_CMD_EVENT_WAKE_CNT_PTR, 0) || |
| 7648 | nla_put_u32(skb, PARAM_CMD_EVENT_WAKE_CNT_SZ, 0) || |
| 7649 | nla_put_u32(skb, PARAM_TOTAL_DRIVER_FW_LOCAL_WAKE, 0) || |
| 7650 | nla_put_u32(skb, PARAM_DRIVER_FW_LOCAL_WAKE_CNT_PTR, 0) || |
| 7651 | nla_put_u32(skb, PARAM_DRIVER_FW_LOCAL_WAKE_CNT_SZ, 0) || |
| 7652 | nla_put_u32(skb, PARAM_TOTAL_RX_DATA_WAKE, |
| 7653 | total_rx_data_wake) || |
| 7654 | nla_put_u32(skb, PARAM_RX_UNICAST_CNT, |
| 7655 | data->wow_ucast_wake_up_count) || |
| 7656 | nla_put_u32(skb, PARAM_RX_MULTICAST_CNT, |
| 7657 | rx_multicast_cnt) || |
| 7658 | nla_put_u32(skb, PARAM_RX_BROADCAST_CNT, |
| 7659 | data->wow_bcast_wake_up_count) || |
Sreelakshmi Konamki | e1cd51f | 2016-08-19 16:58:24 +0530 | [diff] [blame] | 7660 | nla_put_u32(skb, PARAM_ICMP_PKT, |
| 7661 | data->wow_icmpv4_count) || |
| 7662 | nla_put_u32(skb, PARAM_ICMP6_PKT, |
| 7663 | icmpv6_cnt) || |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7664 | nla_put_u32(skb, PARAM_ICMP6_RA, |
| 7665 | data->wow_ipv6_mcast_ra_stats) || |
| 7666 | nla_put_u32(skb, PARAM_ICMP6_NA, |
| 7667 | data->wow_ipv6_mcast_na_stats) || |
| 7668 | nla_put_u32(skb, PARAM_ICMP6_NS, |
| 7669 | data->wow_ipv6_mcast_ns_stats) || |
| 7670 | nla_put_u32(skb, PARAM_ICMP4_RX_MULTICAST_CNT, |
| 7671 | data->wow_ipv4_mcast_wake_up_count) || |
| 7672 | nla_put_u32(skb, PARAM_ICMP6_RX_MULTICAST_CNT, |
| 7673 | ipv6_rx_multicast_addr_cnt) || |
| 7674 | nla_put_u32(skb, PARAM_OTHER_RX_MULTICAST_CNT, 0)) { |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7675 | hdd_err("nla put fail"); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7676 | goto nla_put_failure; |
| 7677 | } |
| 7678 | |
| 7679 | cfg80211_vendor_cmd_reply(skb); |
| 7680 | |
| 7681 | EXIT(); |
| 7682 | return 0; |
| 7683 | |
| 7684 | nla_put_failure: |
| 7685 | kfree_skb(skb); |
| 7686 | return -EINVAL; |
| 7687 | } |
| 7688 | |
| 7689 | /** |
| 7690 | * __wlan_hdd_cfg80211_get_wakelock_stats() - gets wake lock stats |
| 7691 | * @wiphy: wiphy pointer |
| 7692 | * @wdev: pointer to struct wireless_dev |
| 7693 | * @data: pointer to incoming NL vendor data |
| 7694 | * @data_len: length of @data |
| 7695 | * |
| 7696 | * This function parses the incoming NL vendor command data attributes and |
| 7697 | * invokes the SME Api and blocks on a completion variable. |
| 7698 | * WMA copies required data and invokes callback |
| 7699 | * wlan_hdd_cfg80211_wakelock_stats_rsp_callback to send wake lock stats. |
| 7700 | * |
| 7701 | * Return: 0 on success; error number otherwise. |
| 7702 | */ |
| 7703 | static int __wlan_hdd_cfg80211_get_wakelock_stats(struct wiphy *wiphy, |
| 7704 | struct wireless_dev *wdev, |
| 7705 | const void *data, |
| 7706 | int data_len) |
| 7707 | { |
| 7708 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 7709 | int status, ret; |
| 7710 | struct sir_wake_lock_stats wake_lock_stats; |
| 7711 | QDF_STATUS qdf_status; |
| 7712 | |
| 7713 | ENTER(); |
| 7714 | |
| 7715 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7716 | hdd_err("Command not allowed in FTM mode"); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7717 | return -EINVAL; |
| 7718 | } |
| 7719 | |
| 7720 | status = wlan_hdd_validate_context(hdd_ctx); |
| 7721 | if (0 != status) |
| 7722 | return -EINVAL; |
| 7723 | |
| 7724 | qdf_status = wma_get_wakelock_stats(&wake_lock_stats); |
| 7725 | if (qdf_status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7726 | hdd_err("failed to get wakelock stats(err=%d)", qdf_status); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7727 | return -EINVAL; |
| 7728 | } |
| 7729 | |
| 7730 | ret = hdd_send_wakelock_stats(hdd_ctx, |
| 7731 | &wake_lock_stats); |
| 7732 | if (ret) |
Jeff Johnson | 64943bd | 2016-08-23 13:14:06 -0700 | [diff] [blame] | 7733 | hdd_err("Failed to post wake lock stats"); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7734 | |
| 7735 | EXIT(); |
| 7736 | return ret; |
| 7737 | } |
| 7738 | |
| 7739 | /** |
| 7740 | * wlan_hdd_cfg80211_get_wakelock_stats() - gets wake lock stats |
| 7741 | * @wiphy: wiphy pointer |
| 7742 | * @wdev: pointer to struct wireless_dev |
| 7743 | * @data: pointer to incoming NL vendor data |
| 7744 | * @data_len: length of @data |
| 7745 | * |
| 7746 | * This function parses the incoming NL vendor command data attributes and |
| 7747 | * invokes the SME Api and blocks on a completion variable. |
| 7748 | * WMA copies required data and invokes callback |
| 7749 | * wlan_hdd_cfg80211_wakelock_stats_rsp_callback to send wake lock stats. |
| 7750 | * |
| 7751 | * Return: 0 on success; error number otherwise. |
| 7752 | */ |
| 7753 | static int wlan_hdd_cfg80211_get_wakelock_stats(struct wiphy *wiphy, |
| 7754 | struct wireless_dev *wdev, |
| 7755 | const void *data, int data_len) |
| 7756 | { |
| 7757 | int ret; |
| 7758 | |
| 7759 | cds_ssr_protect(__func__); |
| 7760 | ret = __wlan_hdd_cfg80211_get_wakelock_stats(wiphy, wdev, data, |
| 7761 | data_len); |
Jeff Johnson | f3a64e6 | 2016-10-12 17:17:34 -0700 | [diff] [blame] | 7762 | cds_ssr_unprotect(__func__); |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 7763 | |
| 7764 | return ret; |
| 7765 | } |
| 7766 | |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 7767 | /** |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 7768 | * __wlan_hdd_cfg80211_get_bus_size() - Get WMI Bus size |
| 7769 | * @wiphy: wiphy structure pointer |
| 7770 | * @wdev: Wireless device structure pointer |
| 7771 | * @data: Pointer to the data received |
| 7772 | * @data_len: Length of @data |
| 7773 | * |
| 7774 | * This function reads wmi max bus size and fill in the skb with |
| 7775 | * NL attributes and send up the NL event. |
| 7776 | * Return: 0 on success; errno on failure |
| 7777 | */ |
| 7778 | static int |
| 7779 | __wlan_hdd_cfg80211_get_bus_size(struct wiphy *wiphy, |
| 7780 | struct wireless_dev *wdev, |
| 7781 | const void *data, int data_len) |
| 7782 | { |
| 7783 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 7784 | int ret_val; |
| 7785 | struct sk_buff *skb; |
| 7786 | uint32_t nl_buf_len; |
| 7787 | |
| 7788 | ENTER(); |
| 7789 | |
| 7790 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 7791 | if (ret_val) |
| 7792 | return ret_val; |
| 7793 | |
| 7794 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 7795 | hdd_err("Command not allowed in FTM mode"); |
| 7796 | return -EINVAL; |
| 7797 | } |
| 7798 | |
| 7799 | hdd_info("WMI Max Bus size: %d", hdd_ctx->wmi_max_len); |
| 7800 | |
| 7801 | nl_buf_len = NLMSG_HDRLEN; |
| 7802 | nl_buf_len += (sizeof(hdd_ctx->wmi_max_len) + NLA_HDRLEN); |
| 7803 | |
| 7804 | skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); |
| 7805 | if (!skb) { |
| 7806 | hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); |
| 7807 | return -ENOMEM; |
| 7808 | } |
| 7809 | |
| 7810 | if (nla_put_u16(skb, QCA_WLAN_VENDOR_ATTR_DRV_INFO_BUS_SIZE, |
| 7811 | hdd_ctx->wmi_max_len)) { |
| 7812 | hdd_err("nla put failure"); |
| 7813 | goto nla_put_failure; |
| 7814 | } |
| 7815 | |
| 7816 | cfg80211_vendor_cmd_reply(skb); |
| 7817 | |
| 7818 | EXIT(); |
| 7819 | |
| 7820 | return 0; |
| 7821 | |
| 7822 | nla_put_failure: |
| 7823 | kfree_skb(skb); |
| 7824 | return -EINVAL; |
| 7825 | } |
| 7826 | |
| 7827 | /** |
| 7828 | * wlan_hdd_cfg80211_get_bus_size() - SSR Wrapper to Get Bus size |
| 7829 | * @wiphy: wiphy structure pointer |
| 7830 | * @wdev: Wireless device structure pointer |
| 7831 | * @data: Pointer to the data received |
| 7832 | * @data_len: Length of @data |
| 7833 | * |
| 7834 | * Return: 0 on success; errno on failure |
| 7835 | */ |
| 7836 | static int wlan_hdd_cfg80211_get_bus_size(struct wiphy *wiphy, |
| 7837 | struct wireless_dev *wdev, |
| 7838 | const void *data, int data_len) |
| 7839 | { |
| 7840 | int ret; |
| 7841 | |
| 7842 | cds_ssr_protect(__func__); |
| 7843 | ret = __wlan_hdd_cfg80211_get_bus_size(wiphy, wdev, data, data_len); |
| 7844 | cds_ssr_unprotect(__func__); |
| 7845 | |
| 7846 | return ret; |
| 7847 | } |
| 7848 | |
| 7849 | /** |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 7850 | *__wlan_hdd_cfg80211_setband() - set band |
| 7851 | * @wiphy: Pointer to wireless phy |
| 7852 | * @wdev: Pointer to wireless device |
| 7853 | * @data: Pointer to data |
| 7854 | * @data_len: Length of @data |
| 7855 | * |
| 7856 | * Return: 0 on success, negative errno on failure |
| 7857 | */ |
| 7858 | static int __wlan_hdd_cfg80211_setband(struct wiphy *wiphy, |
| 7859 | struct wireless_dev *wdev, |
| 7860 | const void *data, int data_len) |
| 7861 | { |
| 7862 | struct net_device *dev = wdev->netdev; |
| 7863 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 7864 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1]; |
| 7865 | int ret; |
| 7866 | static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1] |
| 7867 | = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 } }; |
| 7868 | |
| 7869 | ENTER(); |
| 7870 | |
| 7871 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7872 | if (ret) |
| 7873 | return ret; |
| 7874 | |
| 7875 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len, policy)) { |
| 7876 | hdd_err(FL("Invalid ATTR")); |
| 7877 | return -EINVAL; |
| 7878 | } |
| 7879 | |
| 7880 | if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) { |
| 7881 | hdd_err(FL("attr SETBAND_VALUE failed")); |
| 7882 | return -EINVAL; |
| 7883 | } |
| 7884 | |
| 7885 | ret = hdd_set_band(dev, |
| 7886 | nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE])); |
| 7887 | |
| 7888 | EXIT(); |
| 7889 | return ret; |
| 7890 | } |
| 7891 | |
| 7892 | /** |
| 7893 | * wlan_hdd_cfg80211_setband() - Wrapper to setband |
| 7894 | * @wiphy: wiphy structure pointer |
| 7895 | * @wdev: Wireless device structure pointer |
| 7896 | * @data: Pointer to the data received |
| 7897 | * @data_len: Length of @data |
| 7898 | * |
| 7899 | * Return: 0 on success; errno on failure |
| 7900 | */ |
| 7901 | static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy, |
| 7902 | struct wireless_dev *wdev, |
| 7903 | const void *data, int data_len) |
| 7904 | { |
| 7905 | int ret; |
| 7906 | |
| 7907 | cds_ssr_protect(__func__); |
| 7908 | ret = __wlan_hdd_cfg80211_setband(wiphy, wdev, data, data_len); |
| 7909 | cds_ssr_unprotect(__func__); |
| 7910 | |
| 7911 | return ret; |
| 7912 | } |
| 7913 | |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 7914 | static const struct |
| 7915 | nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] = { |
| 7916 | [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = {.type = NLA_U32}, |
| 7917 | [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = {.type = NLA_BINARY, |
| 7918 | .len = QDF_MAC_ADDR_SIZE}, |
| 7919 | }; |
| 7920 | |
| 7921 | /** |
| 7922 | * __wlan_hdd_cfg80211_set_fast_roaming() - enable/disable roaming |
| 7923 | * @wiphy: Pointer to wireless phy |
| 7924 | * @wdev: Pointer to wireless device |
| 7925 | * @data: Pointer to data |
| 7926 | * @data_len: Length of @data |
| 7927 | * |
| 7928 | * This function is used to enable/disable roaming using vendor commands |
| 7929 | * |
| 7930 | * Return: 0 on success, negative errno on failure |
| 7931 | */ |
| 7932 | static int __wlan_hdd_cfg80211_set_fast_roaming(struct wiphy *wiphy, |
| 7933 | struct wireless_dev *wdev, |
| 7934 | const void *data, int data_len) |
| 7935 | { |
| 7936 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 7937 | struct net_device *dev = wdev->netdev; |
| 7938 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7939 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1]; |
| 7940 | uint32_t is_fast_roam_enabled; |
| 7941 | int ret; |
| 7942 | |
| 7943 | ENTER_DEV(dev); |
| 7944 | |
| 7945 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7946 | if (0 != ret) |
| 7947 | return ret; |
| 7948 | |
| 7949 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 7950 | hdd_err("Command not allowed in FTM mode"); |
| 7951 | return -EINVAL; |
| 7952 | } |
| 7953 | |
| 7954 | ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len, |
| 7955 | qca_wlan_vendor_attr); |
| 7956 | if (ret) { |
| 7957 | hdd_err("Invalid ATTR"); |
| 7958 | return -EINVAL; |
| 7959 | } |
| 7960 | |
| 7961 | /* Parse and fetch Enable flag */ |
| 7962 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) { |
| 7963 | hdd_err("attr enable failed"); |
| 7964 | return -EINVAL; |
| 7965 | } |
| 7966 | |
| 7967 | is_fast_roam_enabled = nla_get_u32( |
| 7968 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]); |
| 7969 | hdd_notice("isFastRoamEnabled %d", is_fast_roam_enabled); |
| 7970 | |
| 7971 | /* Update roaming */ |
| 7972 | ret = sme_config_fast_roaming(hdd_ctx->hHal, adapter->sessionId, |
| 7973 | is_fast_roam_enabled); |
| 7974 | if (ret) |
| 7975 | hdd_err("sme_config_fast_roaming failed"); |
| 7976 | EXIT(); |
| 7977 | return ret; |
| 7978 | } |
| 7979 | |
| 7980 | /** |
| 7981 | * wlan_hdd_cfg80211_set_fast_roaming() - enable/disable roaming |
| 7982 | * @wiphy: Pointer to wireless phy |
| 7983 | * @wdev: Pointer to wireless device |
| 7984 | * @data: Pointer to data |
| 7985 | * @data_len: Length of @data |
| 7986 | * |
| 7987 | * Wrapper function of __wlan_hdd_cfg80211_set_fast_roaming() |
| 7988 | * |
| 7989 | * Return: 0 on success, negative errno on failure |
| 7990 | */ |
| 7991 | static int wlan_hdd_cfg80211_set_fast_roaming(struct wiphy *wiphy, |
| 7992 | struct wireless_dev *wdev, |
| 7993 | const void *data, int data_len) |
| 7994 | { |
| 7995 | int ret; |
| 7996 | |
| 7997 | cds_ssr_protect(__func__); |
| 7998 | ret = __wlan_hdd_cfg80211_set_fast_roaming(wiphy, wdev, data, data_len); |
| 7999 | cds_ssr_unprotect(__func__); |
| 8000 | |
| 8001 | return ret; |
| 8002 | } |
| 8003 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8004 | const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] = { |
| 8005 | { |
| 8006 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8007 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY, |
| 8008 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
Srinivas Dasari | 947abd7 | 2016-09-02 12:11:33 +0530 | [diff] [blame] | 8009 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8010 | .doit = is_driver_dfs_capable |
| 8011 | }, |
| 8012 | |
| 8013 | #ifdef WLAN_FEATURE_NAN |
| 8014 | { |
| 8015 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8016 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN, |
| 8017 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8018 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8019 | .doit = wlan_hdd_cfg80211_nan_request |
| 8020 | }, |
| 8021 | #endif |
| 8022 | |
| 8023 | #ifdef WLAN_FEATURE_STATS_EXT |
| 8024 | { |
| 8025 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8026 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_STATS_EXT, |
| 8027 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8028 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8029 | .doit = wlan_hdd_cfg80211_stats_ext_request |
| 8030 | }, |
| 8031 | #endif |
| 8032 | #ifdef FEATURE_WLAN_EXTSCAN |
| 8033 | { |
| 8034 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8035 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START, |
| 8036 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8037 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8038 | .doit = wlan_hdd_cfg80211_extscan_start |
| 8039 | }, |
| 8040 | { |
| 8041 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8042 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP, |
| 8043 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8044 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8045 | .doit = wlan_hdd_cfg80211_extscan_stop |
| 8046 | }, |
| 8047 | { |
| 8048 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8049 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS, |
| 8050 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 8051 | .doit = wlan_hdd_cfg80211_extscan_get_valid_channels |
| 8052 | }, |
| 8053 | { |
| 8054 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8055 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES, |
| 8056 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8057 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8058 | .doit = wlan_hdd_cfg80211_extscan_get_capabilities |
| 8059 | }, |
| 8060 | { |
| 8061 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8062 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS, |
| 8063 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8064 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8065 | .doit = wlan_hdd_cfg80211_extscan_get_cached_results |
| 8066 | }, |
| 8067 | { |
| 8068 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8069 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST, |
| 8070 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8071 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8072 | .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist |
| 8073 | }, |
| 8074 | { |
| 8075 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8076 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST, |
| 8077 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8078 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8079 | .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist |
| 8080 | }, |
| 8081 | { |
| 8082 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8083 | .info.subcmd = |
| 8084 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE, |
| 8085 | .flags = |
| 8086 | WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8087 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8088 | .doit = wlan_hdd_cfg80211_extscan_set_significant_change |
| 8089 | }, |
| 8090 | { |
| 8091 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8092 | .info.subcmd = |
| 8093 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE, |
| 8094 | .flags = |
| 8095 | WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8096 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8097 | .doit = wlan_hdd_cfg80211_extscan_reset_significant_change |
| 8098 | }, |
| 8099 | { |
| 8100 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8101 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_LIST, |
| 8102 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8103 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8104 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8105 | .doit = wlan_hdd_cfg80211_set_epno_list |
| 8106 | }, |
| 8107 | #endif /* FEATURE_WLAN_EXTSCAN */ |
| 8108 | |
| 8109 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 8110 | { |
| 8111 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8112 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR, |
| 8113 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8114 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8115 | .doit = wlan_hdd_cfg80211_ll_stats_clear |
| 8116 | }, |
| 8117 | |
| 8118 | { |
| 8119 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8120 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET, |
| 8121 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8122 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8123 | .doit = wlan_hdd_cfg80211_ll_stats_set |
| 8124 | }, |
| 8125 | |
| 8126 | { |
| 8127 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8128 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET, |
| 8129 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8130 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8131 | .doit = wlan_hdd_cfg80211_ll_stats_get |
| 8132 | }, |
| 8133 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 8134 | #ifdef FEATURE_WLAN_TDLS |
| 8135 | { |
| 8136 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8137 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE, |
| 8138 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8139 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8140 | .doit = wlan_hdd_cfg80211_exttdls_enable |
| 8141 | }, |
| 8142 | { |
| 8143 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8144 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE, |
| 8145 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8146 | WIPHY_VENDOR_CMD_NEED_NETDEV | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8147 | .doit = wlan_hdd_cfg80211_exttdls_disable |
| 8148 | }, |
| 8149 | { |
| 8150 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8151 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS, |
| 8152 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 8153 | .doit = wlan_hdd_cfg80211_exttdls_get_status |
| 8154 | }, |
| 8155 | #endif |
| 8156 | { |
| 8157 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8158 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES, |
| 8159 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 8160 | .doit = wlan_hdd_cfg80211_get_supported_features |
| 8161 | }, |
| 8162 | { |
| 8163 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8164 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SCANNING_MAC_OUI, |
| 8165 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 8166 | .doit = wlan_hdd_cfg80211_set_scanning_mac_oui |
| 8167 | }, |
| 8168 | { |
| 8169 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8170 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX, |
| 8171 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Chandrasekaran, Manishekar | 6e9aa1b | 2015-12-02 18:04:00 +0530 | [diff] [blame] | 8172 | .doit = wlan_hdd_cfg80211_get_concurrency_matrix |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8173 | }, |
| 8174 | { |
| 8175 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8176 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG, |
| 8177 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8178 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 8179 | .doit = wlan_hdd_cfg80211_disable_dfs_chan_scan |
| 8180 | }, |
Manikandan Mohan | 80dea79 | 2016-04-28 16:36:48 -0700 | [diff] [blame] | 8181 | { |
| 8182 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8183 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WISA, |
| 8184 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8185 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 8186 | .doit = wlan_hdd_cfg80211_handle_wisa_cmd |
| 8187 | }, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8188 | { |
| 8189 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Anurag Chouhan | 9691948 | 2016-07-13 16:36:57 +0530 | [diff] [blame] | 8190 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_STATION, |
| 8191 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8192 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8193 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8194 | .doit = hdd_cfg80211_get_station_cmd |
| 8195 | }, |
| 8196 | { |
| 8197 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8198 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DO_ACS, |
| 8199 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8200 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8201 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8202 | .doit = wlan_hdd_cfg80211_do_acs |
| 8203 | }, |
| 8204 | |
| 8205 | { |
| 8206 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8207 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES, |
| 8208 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8209 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 8210 | .doit = wlan_hdd_cfg80211_get_features |
| 8211 | }, |
| 8212 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 8213 | { |
| 8214 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8215 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_SET_KEY, |
| 8216 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8217 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8218 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8219 | .doit = wlan_hdd_cfg80211_keymgmt_set_key |
| 8220 | }, |
| 8221 | #endif |
| 8222 | #ifdef FEATURE_WLAN_EXTSCAN |
| 8223 | { |
| 8224 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8225 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST, |
| 8226 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8227 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8228 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8229 | .doit = wlan_hdd_cfg80211_set_passpoint_list |
| 8230 | }, |
| 8231 | { |
| 8232 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8233 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_RESET_PASSPOINT_LIST, |
| 8234 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8235 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8236 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8237 | .doit = wlan_hdd_cfg80211_reset_passpoint_list |
| 8238 | }, |
| 8239 | { |
| 8240 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8241 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST, |
| 8242 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8243 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8244 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8245 | .doit = wlan_hdd_cfg80211_extscan_set_ssid_hotlist |
| 8246 | }, |
| 8247 | { |
| 8248 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8249 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST, |
| 8250 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8251 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8252 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8253 | .doit = wlan_hdd_cfg80211_extscan_reset_ssid_hotlist |
| 8254 | }, |
| 8255 | #endif /* FEATURE_WLAN_EXTSCAN */ |
| 8256 | { |
| 8257 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8258 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO, |
| 8259 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8260 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 8261 | .doit = wlan_hdd_cfg80211_get_wifi_info |
| 8262 | }, |
| 8263 | { |
| 8264 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8265 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION, |
| 8266 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8267 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8268 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8269 | .doit = wlan_hdd_cfg80211_wifi_configuration_set |
| 8270 | }, |
| 8271 | { |
| 8272 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8273 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAM, |
| 8274 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8275 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 8276 | .doit = wlan_hdd_cfg80211_set_ext_roam_params |
| 8277 | }, |
| 8278 | { |
| 8279 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8280 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START, |
| 8281 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8282 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 8283 | .doit = wlan_hdd_cfg80211_wifi_logger_start |
| 8284 | }, |
| 8285 | { |
| 8286 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8287 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA, |
| 8288 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8289 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 8290 | .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data |
| 8291 | }, |
| 8292 | { |
| 8293 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8294 | .info.subcmd = |
| 8295 | QCA_NL80211_VENDOR_SUBCMD_GET_PREFERRED_FREQ_LIST, |
| 8296 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8297 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8298 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8299 | .doit = wlan_hdd_cfg80211_get_preferred_freq_list |
| 8300 | }, |
| 8301 | { |
| 8302 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8303 | .info.subcmd = |
| 8304 | QCA_NL80211_VENDOR_SUBCMD_SET_PROBABLE_OPER_CHANNEL, |
| 8305 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8306 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8307 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8308 | .doit = wlan_hdd_cfg80211_set_probable_oper_channel |
| 8309 | }, |
Manikandan Mohan | 5356c2b | 2016-04-03 15:51:35 -0700 | [diff] [blame] | 8310 | #ifdef WLAN_FEATURE_TSF |
| 8311 | { |
| 8312 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8313 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TSF, |
| 8314 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8315 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8316 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8317 | .doit = wlan_hdd_cfg80211_handle_tsf_cmd |
| 8318 | }, |
| 8319 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8320 | #ifdef FEATURE_WLAN_TDLS |
| 8321 | { |
| 8322 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8323 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_CAPABILITIES, |
| 8324 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8325 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8326 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8327 | .doit = wlan_hdd_cfg80211_get_tdls_capabilities |
| 8328 | }, |
| 8329 | #endif |
| 8330 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8331 | { |
| 8332 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8333 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS, |
| 8334 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8335 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8336 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8337 | .doit = wlan_hdd_cfg80211_offloaded_packets |
| 8338 | }, |
| 8339 | #endif |
| 8340 | { |
| 8341 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8342 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI, |
| 8343 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8344 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8345 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8346 | .doit = wlan_hdd_cfg80211_monitor_rssi |
| 8347 | }, |
| 8348 | { |
| 8349 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8350 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ND_OFFLOAD, |
| 8351 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8352 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8353 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8354 | .doit = wlan_hdd_cfg80211_set_ns_offload |
| 8355 | }, |
| 8356 | { |
| 8357 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8358 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_LOGGER_FEATURE_SET, |
| 8359 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8360 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8361 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8362 | .doit = wlan_hdd_cfg80211_get_logger_supp_feature |
| 8363 | }, |
| 8364 | #ifdef WLAN_FEATURE_MEMDUMP |
| 8365 | { |
| 8366 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8367 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP, |
| 8368 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8369 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8370 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8371 | .doit = wlan_hdd_cfg80211_get_fw_mem_dump |
| 8372 | }, |
| 8373 | #endif /* WLAN_FEATURE_MEMDUMP */ |
| 8374 | { |
| 8375 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8376 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TRIGGER_SCAN, |
| 8377 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8378 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8379 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8380 | .doit = wlan_hdd_cfg80211_vendor_scan |
| 8381 | }, |
| 8382 | |
| 8383 | /* OCB commands */ |
| 8384 | { |
| 8385 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8386 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_SET_CONFIG, |
| 8387 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8388 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8389 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8390 | .doit = wlan_hdd_cfg80211_ocb_set_config |
| 8391 | }, |
| 8392 | { |
| 8393 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8394 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_SET_UTC_TIME, |
| 8395 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8396 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8397 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8398 | .doit = wlan_hdd_cfg80211_ocb_set_utc_time |
| 8399 | }, |
| 8400 | { |
| 8401 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8402 | .info.subcmd = |
| 8403 | QCA_NL80211_VENDOR_SUBCMD_OCB_START_TIMING_ADVERT, |
| 8404 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8405 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8406 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8407 | .doit = wlan_hdd_cfg80211_ocb_start_timing_advert |
| 8408 | }, |
| 8409 | { |
| 8410 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8411 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_STOP_TIMING_ADVERT, |
| 8412 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8413 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8414 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8415 | .doit = wlan_hdd_cfg80211_ocb_stop_timing_advert |
| 8416 | }, |
| 8417 | { |
| 8418 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8419 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OCB_GET_TSF_TIMER, |
| 8420 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8421 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8422 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8423 | .doit = wlan_hdd_cfg80211_ocb_get_tsf_timer |
| 8424 | }, |
| 8425 | { |
| 8426 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8427 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_GET_STATS, |
| 8428 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8429 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8430 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8431 | .doit = wlan_hdd_cfg80211_dcc_get_stats |
| 8432 | }, |
| 8433 | { |
| 8434 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8435 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_CLEAR_STATS, |
| 8436 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8437 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8438 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8439 | .doit = wlan_hdd_cfg80211_dcc_clear_stats |
| 8440 | }, |
| 8441 | { |
| 8442 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8443 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_DCC_UPDATE_NDL, |
| 8444 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8445 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8446 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8447 | .doit = wlan_hdd_cfg80211_dcc_update_ndl |
| 8448 | }, |
Kanchanapally, Vidyullatha | e306281 | 2015-05-22 17:28:57 +0530 | [diff] [blame] | 8449 | { |
| 8450 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8451 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES, |
| 8452 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8453 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8454 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8455 | .doit = wlan_hdd_cfg80211_get_link_properties |
| 8456 | }, |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8457 | { |
Peng Xu | d222096 | 2016-07-11 17:59:17 -0700 | [diff] [blame] | 8458 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Peng Xu | 278d012 | 2015-09-24 16:34:17 -0700 | [diff] [blame] | 8459 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OTA_TEST, |
| 8460 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8461 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8462 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8463 | .doit = wlan_hdd_cfg80211_set_ota_test |
| 8464 | }, |
Ravi Joshi | deb5a8d | 2015-11-09 19:11:43 -0800 | [diff] [blame] | 8465 | #ifdef FEATURE_LFR_SUBNET_DETECTION |
| 8466 | { |
| 8467 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8468 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GW_PARAM_CONFIG, |
| 8469 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8470 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8471 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8472 | .doit = wlan_hdd_cfg80211_set_gateway_params |
| 8473 | }, |
| 8474 | #endif /* FEATURE_LFR_SUBNET_DETECTION */ |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 8475 | { |
Peng Xu | d222096 | 2016-07-11 17:59:17 -0700 | [diff] [blame] | 8476 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Peng Xu | 4d67c8f | 2015-10-16 16:02:26 -0700 | [diff] [blame] | 8477 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_TXPOWER_SCALE, |
| 8478 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8479 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8480 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8481 | .doit = wlan_hdd_cfg80211_txpower_scale |
| 8482 | }, |
| 8483 | { |
| 8484 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8485 | .info.subcmd = |
| 8486 | QCA_NL80211_VENDOR_SUBCMD_SET_TXPOWER_SCALE_DECR_DB, |
| 8487 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8488 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8489 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8490 | .doit = wlan_hdd_cfg80211_txpower_scale_decr_db |
| 8491 | }, |
Arun Khandavalli | 2476ef5 | 2016-04-26 20:19:43 +0530 | [diff] [blame] | 8492 | { |
| 8493 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8494 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_PACKET_FILTER, |
| 8495 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8496 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8497 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8498 | .doit = wlan_hdd_cfg80211_bpf_offload |
| 8499 | }, |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 8500 | { |
| 8501 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 8502 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ACS_POLICY, |
| 8503 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8504 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8505 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8506 | .doit = wlan_hdd_cfg80211_acs_dfs_mode |
| 8507 | }, |
| 8508 | { |
| 8509 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8510 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_STA_CONNECT_ROAM_POLICY, |
| 8511 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8512 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8513 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8514 | .doit = wlan_hdd_cfg80211_sta_roam_policy |
| 8515 | }, |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8516 | #ifdef FEATURE_WLAN_CH_AVOID |
| 8517 | { |
| 8518 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8519 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY, |
| 8520 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8521 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8522 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8523 | .doit = wlan_hdd_cfg80211_avoid_freq |
| 8524 | }, |
| 8525 | #endif |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 8526 | { |
| 8527 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Agrawal Ashish | c9ddbab | 2016-05-25 12:04:47 +0530 | [diff] [blame] | 8528 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_SAP_CONFIG, |
| 8529 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8530 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8531 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8532 | .doit = wlan_hdd_cfg80211_sap_configuration_set |
| 8533 | }, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8534 | { |
Peng Xu | 4225c15 | 2016-07-14 21:18:14 -0700 | [diff] [blame] | 8535 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8536 | .info.subcmd = |
| 8537 | QCA_NL80211_VENDOR_SUBCMD_P2P_LISTEN_OFFLOAD_START, |
| 8538 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8539 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8540 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8541 | .doit = wlan_hdd_cfg80211_p2p_lo_start |
| 8542 | }, |
| 8543 | { |
| 8544 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8545 | .info.subcmd = |
| 8546 | QCA_NL80211_VENDOR_SUBCMD_P2P_LISTEN_OFFLOAD_STOP, |
| 8547 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8548 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8549 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8550 | .doit = wlan_hdd_cfg80211_p2p_lo_stop |
| 8551 | }, |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 8552 | { |
| 8553 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8554 | .info.subcmd = |
| 8555 | QCA_NL80211_VENDOR_SUBCMD_SAP_CONDITIONAL_CHAN_SWITCH, |
| 8556 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8557 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8558 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8559 | .doit = wlan_hdd_cfg80211_conditional_chan_switch |
| 8560 | }, |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 8561 | #ifdef WLAN_FEATURE_NAN_DATAPATH |
| 8562 | { |
| 8563 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8564 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NDP, |
| 8565 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8566 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8567 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8568 | .doit = wlan_hdd_cfg80211_process_ndp_cmd |
| 8569 | }, |
| 8570 | #endif |
Padma, Santhosh Kumar | 5e33beb | 2016-08-08 19:07:06 +0530 | [diff] [blame] | 8571 | { |
| 8572 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8573 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WAKE_REASON_STATS, |
| 8574 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8575 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8576 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8577 | .doit = wlan_hdd_cfg80211_get_wakelock_stats |
| 8578 | }, |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 8579 | { |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 8580 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8581 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_BUS_SIZE, |
| 8582 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8583 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8584 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8585 | .doit = wlan_hdd_cfg80211_get_bus_size |
| 8586 | }, |
| 8587 | { |
Srinivas Dasari | 510e7fe | 2016-04-28 11:51:30 +0530 | [diff] [blame] | 8588 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND, |
| 8589 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8590 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8591 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8592 | .doit = wlan_hdd_cfg80211_setband |
Mukul Sharma | 69c44cd | 2016-09-12 18:33:57 +0530 | [diff] [blame] | 8593 | }, |
| 8594 | { |
| 8595 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8596 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING, |
| 8597 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8598 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8599 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8600 | .doit = wlan_hdd_cfg80211_set_fast_roaming |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 8601 | }, |
| 8602 | #ifdef WLAN_FEATURE_DISA |
| 8603 | { |
| 8604 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8605 | .info.subcmd = |
| 8606 | QCA_NL80211_VENDOR_SUBCMD_ENCRYPTION_TEST, |
| 8607 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8608 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8609 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8610 | .doit = wlan_hdd_cfg80211_encrypt_decrypt_msg |
| 8611 | }, |
| 8612 | #endif |
Kabilan Kannan | d053aaf | 2016-10-26 02:06:14 -0700 | [diff] [blame] | 8613 | #ifdef FEATURE_WLAN_TDLS |
| 8614 | { |
| 8615 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 8616 | .info.subcmd = |
| 8617 | QCA_NL80211_VENDOR_SUBCMD_CONFIGURE_TDLS, |
| 8618 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 8619 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 8620 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 8621 | .doit = wlan_hdd_cfg80211_configure_tdls_mode |
| 8622 | } |
| 8623 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8624 | }; |
| 8625 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8626 | /** |
| 8627 | * hdd_cfg80211_wiphy_alloc() - Allocate wiphy context |
| 8628 | * @priv_size: Size of the hdd context. |
| 8629 | * |
| 8630 | * Allocate wiphy context and hdd context. |
| 8631 | * |
| 8632 | * Return: hdd context on success and NULL on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8633 | */ |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8634 | hdd_context_t *hdd_cfg80211_wiphy_alloc(int priv_size) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8635 | { |
| 8636 | struct wiphy *wiphy; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8637 | hdd_context_t *hdd_ctx; |
| 8638 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8639 | ENTER(); |
| 8640 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8641 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 8642 | |
| 8643 | if (!wiphy) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8644 | hdd_err("wiphy init failed!\n"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8645 | return NULL; |
| 8646 | } |
| 8647 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8648 | hdd_ctx = wiphy_priv(wiphy); |
| 8649 | |
| 8650 | hdd_ctx->wiphy = wiphy; |
| 8651 | |
| 8652 | return hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8653 | } |
| 8654 | |
| 8655 | /* |
| 8656 | * FUNCTION: wlan_hdd_cfg80211_update_band |
| 8657 | * This function is called from the supplicant through a |
| 8658 | * private ioctl to change the band value |
| 8659 | */ |
| 8660 | int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand) |
| 8661 | { |
| 8662 | int i, j; |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 8663 | enum channel_state channelEnabledState; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8664 | |
| 8665 | ENTER(); |
| 8666 | |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8667 | for (i = 0; i < NUM_NL80211_BANDS; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8668 | |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 8669 | if (NULL == wiphy->bands[i]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8670 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8671 | |
| 8672 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) { |
| 8673 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 8674 | |
| 8675 | channelEnabledState = |
| 8676 | cds_get_channel_state(band->channels[j]. |
| 8677 | hw_value); |
| 8678 | |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8679 | if (NL80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8680 | /* 5G only */ |
| 8681 | #ifdef WLAN_ENABLE_SOCIAL_CHANNELS_5G_ONLY |
| 8682 | /* Enable Social channels for P2P */ |
| 8683 | if (WLAN_HDD_IS_SOCIAL_CHANNEL |
| 8684 | (band->channels[j].center_freq) |
| 8685 | && CHANNEL_STATE_ENABLE == |
| 8686 | channelEnabledState) |
| 8687 | band->channels[j].flags &= |
| 8688 | ~IEEE80211_CHAN_DISABLED; |
| 8689 | else |
| 8690 | #endif |
| 8691 | band->channels[j].flags |= |
| 8692 | IEEE80211_CHAN_DISABLED; |
| 8693 | continue; |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8694 | } else if (NL80211_BAND_5GHZ == i && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8695 | eCSR_BAND_24 == eBand) { |
| 8696 | /* 2G only */ |
| 8697 | band->channels[j].flags |= |
| 8698 | IEEE80211_CHAN_DISABLED; |
| 8699 | continue; |
| 8700 | } |
| 8701 | |
Amar Singhal | 6842e8f | 2016-02-23 16:30:32 -0800 | [diff] [blame] | 8702 | if (CHANNEL_STATE_DISABLE != channelEnabledState) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8703 | band->channels[j].flags &= |
| 8704 | ~IEEE80211_CHAN_DISABLED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8705 | } |
| 8706 | } |
| 8707 | return 0; |
| 8708 | } |
| 8709 | |
| 8710 | /* |
| 8711 | * FUNCTION: wlan_hdd_cfg80211_init |
| 8712 | * This function is called by hdd_wlan_startup() |
| 8713 | * during initialization. |
| 8714 | * This function is used to initialize and register wiphy structure. |
| 8715 | */ |
| 8716 | int wlan_hdd_cfg80211_init(struct device *dev, |
| 8717 | struct wiphy *wiphy, struct hdd_config *pCfg) |
| 8718 | { |
| 8719 | int i, j; |
| 8720 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8721 | |
| 8722 | ENTER(); |
| 8723 | |
| 8724 | /* Now bind the underlying wlan device with wiphy */ |
| 8725 | set_wiphy_dev(wiphy, dev); |
| 8726 | |
| 8727 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
| 8728 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8729 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 8730 | wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS; |
Amar Singhal | 01098f7 | 2015-10-08 11:55:32 -0700 | [diff] [blame] | 8731 | wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8732 | #else |
| 8733 | wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS; |
Amar Singhal | 01098f7 | 2015-10-08 11:55:32 -0700 | [diff] [blame] | 8734 | wiphy->country_ie_pref |= NL80211_COUNTRY_IE_IGNORE_CORE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8735 | #endif |
| 8736 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8737 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 8738 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 8739 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
| 8740 | #ifdef FEATURE_WLAN_STA_4ADDR_SCHEME |
| 8741 | | WIPHY_FLAG_4ADDR_STATION |
| 8742 | #endif |
| 8743 | | WIPHY_FLAG_OFFCHAN_TX; |
| 8744 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8745 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 8746 | wiphy->wowlan = &wowlan_support_cfg80211_init; |
| 8747 | #else |
| 8748 | wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT; |
| 8749 | wiphy->wowlan.n_patterns = WOWL_MAX_PTRNS_ALLOWED; |
| 8750 | wiphy->wowlan.pattern_min_len = 1; |
| 8751 | wiphy->wowlan.pattern_max_len = WOWL_PTRN_MAX_SIZE; |
| 8752 | #endif |
| 8753 | |
Deepak Dhamdhere | a2df6bb | 2015-10-29 15:11:06 -0700 | [diff] [blame] | 8754 | if (pCfg->isFastTransitionEnabled || pCfg->isFastRoamIniFeatureEnabled |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8755 | #ifdef FEATURE_WLAN_ESE |
| 8756 | || pCfg->isEseIniFeatureEnabled |
| 8757 | #endif |
| 8758 | ) { |
| 8759 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 8760 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8761 | #ifdef FEATURE_WLAN_TDLS |
| 8762 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 8763 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 8764 | #endif |
| 8765 | |
| 8766 | wiphy->features |= NL80211_FEATURE_HT_IBSS; |
| 8767 | |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 8768 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) |
| 8769 | wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS); |
| 8770 | #endif |
| 8771 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8772 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 8773 | if (pCfg->configPNOScanSupport) { |
| 8774 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 8775 | wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS; |
| 8776 | wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS; |
| 8777 | wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
Ryan Hsu | b736bc5 | 2016-06-15 16:58:24 -0700 | [diff] [blame] | 8778 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) || defined(WITH_BACKPORTS) |
| 8779 | wiphy->max_sched_scan_plans = SIR_PNO_MAX_PLAN_REQUEST; |
| 8780 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8781 | } |
| 8782 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
| 8783 | |
| 8784 | #if defined QCA_WIFI_FTM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8785 | if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8786 | #endif |
| 8787 | |
| 8788 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 8789 | driver can still register regulatory callback and |
| 8790 | it will get regulatory settings in wiphy->band[], but |
| 8791 | driver need to determine what to do with both |
| 8792 | regulatory settings */ |
| 8793 | |
| 8794 | wiphy->reg_notifier = hdd_reg_notifier; |
| 8795 | |
| 8796 | #if defined QCA_WIFI_FTM |
| 8797 | } |
| 8798 | #endif |
| 8799 | |
| 8800 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 8801 | |
| 8802 | wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH; |
| 8803 | |
| 8804 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 8805 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8806 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
| 8807 | | BIT(NL80211_IFTYPE_ADHOC) |
| 8808 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 8809 | | BIT(NL80211_IFTYPE_P2P_GO) |
| 8810 | | BIT(NL80211_IFTYPE_AP) |
| 8811 | | BIT(NL80211_IFTYPE_MONITOR); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8812 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8813 | if (pCfg->advertiseConcurrentOperation) { |
| 8814 | if (pCfg->enableMCC) { |
| 8815 | int i; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 8816 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8817 | for (i = 0; |
| 8818 | i < ARRAY_SIZE(wlan_hdd_iface_combination); |
| 8819 | i++) { |
| 8820 | if (!pCfg->allowMCCGODiffBI) |
| 8821 | wlan_hdd_iface_combination[i]. |
| 8822 | beacon_int_infra_match = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8823 | } |
| 8824 | } |
| 8825 | wiphy->n_iface_combinations = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8826 | ARRAY_SIZE(wlan_hdd_iface_combination); |
| 8827 | wiphy->iface_combinations = wlan_hdd_iface_combination; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8828 | } |
| 8829 | |
| 8830 | /* Before registering we need to update the ht capabilitied based |
| 8831 | * on ini values*/ |
| 8832 | if (!pCfg->ShortGI20MhzEnable) { |
| 8833 | wlan_hdd_band_2_4_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 8834 | 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] | 8835 | } |
| 8836 | |
| 8837 | if (!pCfg->ShortGI40MhzEnable) { |
| 8838 | wlan_hdd_band_5_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 8839 | } |
| 8840 | |
| 8841 | if (!pCfg->nChannelBondingMode5GHz) { |
| 8842 | wlan_hdd_band_5_ghz.ht_cap.cap &= |
| 8843 | ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 8844 | } |
| 8845 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8846 | /* |
| 8847 | * In case of static linked driver at the time of driver unload, |
| 8848 | * module exit doesn't happens. Module cleanup helps in cleaning |
| 8849 | * of static memory. |
| 8850 | * If driver load happens statically, at the time of driver unload, |
| 8851 | * wiphy flags don't get reset because of static memory. |
| 8852 | * It's better not to store channel in static memory. |
| 8853 | */ |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8854 | wiphy->bands[NL80211_BAND_2GHZ] = &wlan_hdd_band_2_4_ghz; |
| 8855 | wiphy->bands[NL80211_BAND_2GHZ]->channels = |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8856 | qdf_mem_malloc(sizeof(hdd_channels_2_4_ghz)); |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8857 | if (wiphy->bands[NL80211_BAND_2GHZ]->channels == NULL) { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8858 | hdd_err("Not enough memory to allocate channels"); |
| 8859 | return -ENOMEM; |
| 8860 | } |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8861 | qdf_mem_copy(wiphy->bands[NL80211_BAND_2GHZ]->channels, |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8862 | &hdd_channels_2_4_ghz[0], |
| 8863 | sizeof(hdd_channels_2_4_ghz)); |
Selvaraj, Sridhar | cd3cc70 | 2016-07-31 15:37:07 +0530 | [diff] [blame] | 8864 | if ((hdd_is_5g_supported(pHddCtx)) && |
| 8865 | ((eHDD_DOT11_MODE_11b != pCfg->dot11Mode) && |
| 8866 | (eHDD_DOT11_MODE_11g != pCfg->dot11Mode) && |
| 8867 | (eHDD_DOT11_MODE_11b_ONLY != pCfg->dot11Mode) && |
| 8868 | (eHDD_DOT11_MODE_11g_ONLY != pCfg->dot11Mode))) { |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8869 | wiphy->bands[NL80211_BAND_5GHZ] = &wlan_hdd_band_5_ghz; |
| 8870 | wiphy->bands[NL80211_BAND_5GHZ]->channels = |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8871 | qdf_mem_malloc(sizeof(hdd_channels_5_ghz)); |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8872 | if (wiphy->bands[NL80211_BAND_5GHZ]->channels == NULL) { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8873 | hdd_err("Not enough memory to allocate channels"); |
| 8874 | qdf_mem_free(wiphy-> |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8875 | bands[NL80211_BAND_2GHZ]->channels); |
| 8876 | wiphy->bands[NL80211_BAND_2GHZ]->channels = NULL; |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8877 | return -ENOMEM; |
| 8878 | } |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8879 | qdf_mem_copy(wiphy->bands[NL80211_BAND_5GHZ]->channels, |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8880 | &hdd_channels_5_ghz[0], |
| 8881 | sizeof(hdd_channels_5_ghz)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8882 | } |
| 8883 | |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8884 | for (i = 0; i < NUM_NL80211_BANDS; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8885 | |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 8886 | if (NULL == wiphy->bands[i]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8887 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8888 | |
| 8889 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) { |
| 8890 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 8891 | |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8892 | if (NL80211_BAND_2GHZ == i && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8893 | eCSR_BAND_5G == pCfg->nBandCapability) { |
| 8894 | /* 5G only */ |
| 8895 | #ifdef WLAN_ENABLE_SOCIAL_CHANNELS_5G_ONLY |
| 8896 | /* Enable social channels for P2P */ |
| 8897 | if (WLAN_HDD_IS_SOCIAL_CHANNEL |
| 8898 | (band->channels[j].center_freq)) |
| 8899 | band->channels[j].flags &= |
| 8900 | ~IEEE80211_CHAN_DISABLED; |
| 8901 | else |
| 8902 | #endif |
| 8903 | band->channels[j].flags |= |
| 8904 | IEEE80211_CHAN_DISABLED; |
| 8905 | continue; |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8906 | } else if (NL80211_BAND_5GHZ == i && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8907 | eCSR_BAND_24 == pCfg->nBandCapability) { |
| 8908 | /* 2G only */ |
| 8909 | band->channels[j].flags |= |
| 8910 | IEEE80211_CHAN_DISABLED; |
| 8911 | continue; |
| 8912 | } |
| 8913 | } |
| 8914 | } |
| 8915 | /*Initialise the supported cipher suite details */ |
| 8916 | wiphy->cipher_suites = hdd_cipher_suites; |
| 8917 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 8918 | |
| 8919 | /*signal strength in mBm (100*dBm) */ |
| 8920 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 8921 | wiphy->max_remain_on_channel_duration = MAX_REMAIN_ON_CHANNEL_DURATION; |
| 8922 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8923 | if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8924 | wiphy->n_vendor_commands = |
| 8925 | ARRAY_SIZE(hdd_wiphy_vendor_commands); |
| 8926 | wiphy->vendor_commands = hdd_wiphy_vendor_commands; |
| 8927 | |
| 8928 | wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events; |
| 8929 | wiphy->n_vendor_events = |
| 8930 | ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events); |
| 8931 | } |
| 8932 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8933 | if (pCfg->enableDFSMasterCap) { |
| 8934 | wiphy->flags |= WIPHY_FLAG_DFS_OFFLOAD; |
| 8935 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8936 | |
| 8937 | wiphy->max_ap_assoc_sta = pCfg->maxNumberOfPeers; |
| 8938 | |
| 8939 | #ifdef QCA_HT_2040_COEX |
| 8940 | wiphy->features |= NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE; |
| 8941 | #endif |
Agrawal, Ashish | 4e5fa1c | 2016-09-21 19:03:43 +0530 | [diff] [blame] | 8942 | wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 8943 | hdd_add_channel_switch_support(&wiphy->flags); |
| 8944 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8945 | EXIT(); |
| 8946 | return 0; |
| 8947 | } |
| 8948 | |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8949 | /** |
| 8950 | * wlan_hdd_cfg80211_deinit - Deinit cfg80211 |
| 8951 | * @ wiphy: the wiphy to validate against |
| 8952 | * |
| 8953 | * this function deinit cfg80211 and cleanup the |
Abhishek Singh | 3e6172f | 2016-05-04 16:56:48 +0530 | [diff] [blame] | 8954 | * memory allocated in wlan_hdd_cfg80211_init also |
| 8955 | * reset the global reg params. |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8956 | * |
| 8957 | * Return: void |
| 8958 | */ |
| 8959 | void wlan_hdd_cfg80211_deinit(struct wiphy *wiphy) |
| 8960 | { |
| 8961 | int i; |
| 8962 | |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 8963 | for (i = 0; i < NUM_NL80211_BANDS; i++) { |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8964 | if (NULL != wiphy->bands[i] && |
| 8965 | (NULL != wiphy->bands[i]->channels)) { |
| 8966 | qdf_mem_free(wiphy->bands[i]->channels); |
| 8967 | wiphy->bands[i]->channels = NULL; |
| 8968 | } |
| 8969 | } |
Abhishek Singh | 3e6172f | 2016-05-04 16:56:48 +0530 | [diff] [blame] | 8970 | hdd_reset_global_reg_params(); |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 8971 | } |
| 8972 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8973 | /* |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8974 | * In this function, wiphy structure is updated after QDF |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8975 | * initialization. In wlan_hdd_cfg80211_init, only the |
| 8976 | * default values will be initialized. The final initialization |
| 8977 | * of all required members can be done here. |
| 8978 | */ |
| 8979 | void wlan_hdd_update_wiphy(struct wiphy *wiphy, struct hdd_config *pCfg) |
| 8980 | { |
| 8981 | wiphy->max_ap_assoc_sta = pCfg->maxNumberOfPeers; |
| 8982 | } |
| 8983 | |
| 8984 | /* In this function we are registering wiphy. */ |
| 8985 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 8986 | { |
| 8987 | ENTER(); |
| 8988 | /* Register our wiphy dev with cfg80211 */ |
| 8989 | if (0 > wiphy_register(wiphy)) { |
| 8990 | /* print error */ |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 8991 | hdd_err("wiphy register failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8992 | return -EIO; |
| 8993 | } |
| 8994 | |
| 8995 | EXIT(); |
| 8996 | return 0; |
| 8997 | } |
| 8998 | |
| 8999 | /* |
| 9000 | HDD function to update wiphy capability based on target offload status. |
| 9001 | |
| 9002 | wlan_hdd_cfg80211_init() does initialization of all wiphy related |
| 9003 | capability even before downloading firmware to the target. In discrete |
| 9004 | case, host will get know certain offload capability (say sched_scan |
| 9005 | caps) only after downloading firmware to the target and target boots up. |
| 9006 | This function is used to override setting done in wlan_hdd_cfg80211_init() |
| 9007 | based on target capability. |
| 9008 | */ |
| 9009 | void wlan_hdd_cfg80211_update_wiphy_caps(struct wiphy *wiphy) |
| 9010 | { |
| 9011 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 9012 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 9013 | struct hdd_config *pCfg = pHddCtx->config; |
| 9014 | |
| 9015 | /* wlan_hdd_cfg80211_init() sets sched_scan caps already in wiphy before |
| 9016 | * control comes here. Here just we need to clear it if firmware doesn't |
| 9017 | * have PNO support. */ |
| 9018 | if (!pCfg->PnoOffload) { |
| 9019 | wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 9020 | wiphy->max_sched_scan_ssids = 0; |
| 9021 | wiphy->max_match_sets = 0; |
| 9022 | wiphy->max_sched_scan_ie_len = 0; |
| 9023 | } |
| 9024 | #endif |
| 9025 | } |
| 9026 | |
| 9027 | /* This function registers for all frame which supplicant is interested in */ |
| 9028 | void wlan_hdd_cfg80211_register_frames(hdd_adapter_t *pAdapter) |
| 9029 | { |
| 9030 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 9031 | /* Register for all P2P action, public action etc frames */ |
| 9032 | uint16_t type = (SIR_MAC_MGMT_FRAME << 2) | (SIR_MAC_MGMT_ACTION << 4); |
| 9033 | |
| 9034 | ENTER(); |
| 9035 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 9036 | /* Register frame indication call back */ |
| 9037 | sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame); |
| 9038 | |
Selvaraj, Sridhar | 4577a9b | 2016-09-04 15:17:07 +0530 | [diff] [blame] | 9039 | /* Register for p2p ack indication */ |
| 9040 | sme_register_p2p_ack_ind_callback(hHal, hdd_send_action_cnf_cb); |
| 9041 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9042 | /* Right now we are registering these frame when driver is getting |
| 9043 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 9044 | frame register ops, we will move this code as a part of that */ |
| 9045 | /* GAS Initial Request */ |
| 9046 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9047 | (uint8_t *) GAS_INITIAL_REQ, |
| 9048 | GAS_INITIAL_REQ_SIZE); |
| 9049 | |
| 9050 | /* GAS Initial Response */ |
| 9051 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9052 | (uint8_t *) GAS_INITIAL_RSP, |
| 9053 | GAS_INITIAL_RSP_SIZE); |
| 9054 | |
| 9055 | /* GAS Comeback Request */ |
| 9056 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9057 | (uint8_t *) GAS_COMEBACK_REQ, |
| 9058 | GAS_COMEBACK_REQ_SIZE); |
| 9059 | |
| 9060 | /* GAS Comeback Response */ |
| 9061 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9062 | (uint8_t *) GAS_COMEBACK_RSP, |
| 9063 | GAS_COMEBACK_RSP_SIZE); |
| 9064 | |
| 9065 | /* P2P Public Action */ |
| 9066 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9067 | (uint8_t *) P2P_PUBLIC_ACTION_FRAME, |
| 9068 | P2P_PUBLIC_ACTION_FRAME_SIZE); |
| 9069 | |
| 9070 | /* P2P Action */ |
| 9071 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9072 | (uint8_t *) P2P_ACTION_FRAME, |
| 9073 | P2P_ACTION_FRAME_SIZE); |
| 9074 | |
| 9075 | /* WNM BSS Transition Request frame */ |
| 9076 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9077 | (uint8_t *) WNM_BSS_ACTION_FRAME, |
| 9078 | WNM_BSS_ACTION_FRAME_SIZE); |
| 9079 | |
| 9080 | /* WNM-Notification */ |
| 9081 | sme_register_mgmt_frame(hHal, pAdapter->sessionId, type, |
| 9082 | (uint8_t *) WNM_NOTIFICATION_FRAME, |
| 9083 | WNM_NOTIFICATION_FRAME_SIZE); |
| 9084 | } |
| 9085 | |
| 9086 | void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t *pAdapter) |
| 9087 | { |
| 9088 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 9089 | /* Register for all P2P action, public action etc frames */ |
| 9090 | uint16_t type = (SIR_MAC_MGMT_FRAME << 2) | (SIR_MAC_MGMT_ACTION << 4); |
| 9091 | |
| 9092 | ENTER(); |
| 9093 | |
| 9094 | /* Right now we are registering these frame when driver is getting |
| 9095 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 9096 | frame register ops, we will move this code as a part of that */ |
| 9097 | /* GAS Initial Request */ |
| 9098 | |
| 9099 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9100 | (uint8_t *) GAS_INITIAL_REQ, |
| 9101 | GAS_INITIAL_REQ_SIZE); |
| 9102 | |
| 9103 | /* GAS Initial Response */ |
| 9104 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9105 | (uint8_t *) GAS_INITIAL_RSP, |
| 9106 | GAS_INITIAL_RSP_SIZE); |
| 9107 | |
| 9108 | /* GAS Comeback Request */ |
| 9109 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9110 | (uint8_t *) GAS_COMEBACK_REQ, |
| 9111 | GAS_COMEBACK_REQ_SIZE); |
| 9112 | |
| 9113 | /* GAS Comeback Response */ |
| 9114 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9115 | (uint8_t *) GAS_COMEBACK_RSP, |
| 9116 | GAS_COMEBACK_RSP_SIZE); |
| 9117 | |
| 9118 | /* P2P Public Action */ |
| 9119 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9120 | (uint8_t *) P2P_PUBLIC_ACTION_FRAME, |
| 9121 | P2P_PUBLIC_ACTION_FRAME_SIZE); |
| 9122 | |
| 9123 | /* P2P Action */ |
| 9124 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9125 | (uint8_t *) P2P_ACTION_FRAME, |
| 9126 | P2P_ACTION_FRAME_SIZE); |
| 9127 | |
| 9128 | /* WNM-Notification */ |
| 9129 | sme_deregister_mgmt_frame(hHal, pAdapter->sessionId, type, |
| 9130 | (uint8_t *) WNM_NOTIFICATION_FRAME, |
| 9131 | WNM_NOTIFICATION_FRAME_SIZE); |
| 9132 | } |
| 9133 | |
| 9134 | #ifdef FEATURE_WLAN_WAPI |
| 9135 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t *pAdapter, uint8_t key_index, |
| 9136 | const uint8_t *mac_addr, const uint8_t *key, |
| 9137 | int key_Len) |
| 9138 | { |
| 9139 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9140 | tCsrRoamSetKey setKey; |
| 9141 | bool isConnected = true; |
| 9142 | int status = 0; |
| 9143 | uint32_t roamId = 0xFF; |
| 9144 | uint8_t *pKeyPtr = NULL; |
| 9145 | int n = 0; |
| 9146 | |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 9147 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9148 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 9149 | pAdapter->device_mode); |
| 9150 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9151 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9152 | setKey.keyId = key_index; /* Store Key ID */ |
| 9153 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; /* SET WAPI Encryption */ |
| 9154 | setKey.keyDirection = eSIR_TX_RX; /* Key Directionn both TX and RX */ |
| 9155 | setKey.paeRole = 0; /* the PAE role */ |
| 9156 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) { |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9157 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9158 | } else { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9159 | qdf_mem_copy(setKey.peerMac.bytes, mac_addr, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9160 | } |
| 9161 | setKey.keyLength = key_Len; |
| 9162 | pKeyPtr = setKey.Key; |
| 9163 | memcpy(pKeyPtr, key, key_Len); |
| 9164 | |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 9165 | hdd_notice("WAPI KEY LENGTH:0x%04x", key_Len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9166 | for (n = 0; n < key_Len; n++) |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 9167 | hdd_notice("WAPI KEY Data[%d]:%02x ", |
| 9168 | n, setKey.Key[n]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9169 | |
| 9170 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 9171 | if (isConnected) { |
| 9172 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 9173 | pAdapter->sessionId, &setKey, &roamId); |
| 9174 | } |
| 9175 | if (status != 0) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 9176 | hdd_err("sme_roam_set_key returned ERROR status= %d", |
| 9177 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9178 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 9179 | } |
| 9180 | } |
| 9181 | #endif /* FEATURE_WLAN_WAPI */ |
| 9182 | |
| 9183 | uint8_t *wlan_hdd_cfg80211_get_ie_ptr(const uint8_t *ies_ptr, int length, |
| 9184 | uint8_t eid) |
| 9185 | { |
| 9186 | int left = length; |
| 9187 | uint8_t *ptr = (uint8_t *)ies_ptr; |
| 9188 | uint8_t elem_id, elem_len; |
| 9189 | |
| 9190 | while (left >= 2) { |
| 9191 | elem_id = ptr[0]; |
| 9192 | elem_len = ptr[1]; |
| 9193 | left -= 2; |
| 9194 | if (elem_len > left) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9195 | hdd_alert("Invalid IEs eid = %d elem_len=%d left=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9196 | eid, elem_len, left); |
| 9197 | return NULL; |
| 9198 | } |
| 9199 | if (elem_id == eid) { |
| 9200 | return ptr; |
| 9201 | } |
| 9202 | |
| 9203 | left -= elem_len; |
| 9204 | ptr += (elem_len + 2); |
| 9205 | } |
| 9206 | return NULL; |
| 9207 | } |
| 9208 | |
| 9209 | /* |
| 9210 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 9211 | * called by wlan_hdd_cfg80211_start_bss() and |
| 9212 | * wlan_hdd_set_channel() |
| 9213 | * This function validates whether given channel is part of valid |
| 9214 | * channel list. |
| 9215 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9216 | QDF_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9217 | int channel) |
| 9218 | { |
| 9219 | |
| 9220 | uint32_t num_ch = 0; |
| 9221 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 9222 | u32 indx = 0; |
| 9223 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 9224 | uint8_t fValidChannel = false, count = 0; |
| 9225 | struct hdd_config *hdd_pConfig_ini = (WLAN_HDD_GET_CTX(pAdapter))->config; |
| 9226 | |
| 9227 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 9228 | |
| 9229 | if (hdd_pConfig_ini->sapAllowAllChannel) { |
| 9230 | /* Validate the channel */ |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 9231 | for (count = CHAN_ENUM_1; count <= CHAN_ENUM_165; count++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 9232 | if (channel == CDS_CHANNEL_NUM(count)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9233 | fValidChannel = true; |
| 9234 | break; |
| 9235 | } |
| 9236 | } |
| 9237 | if (fValidChannel != true) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9238 | hdd_err("Invalid Channel [%d]", channel); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9239 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9240 | } |
| 9241 | } else { |
| 9242 | if (0 != sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 9243 | valid_ch, &num_ch)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9244 | hdd_err("failed to get valid channel list"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9245 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9246 | } |
| 9247 | for (indx = 0; indx < num_ch; indx++) { |
| 9248 | if (channel == valid_ch[indx]) { |
| 9249 | break; |
| 9250 | } |
| 9251 | } |
| 9252 | |
| 9253 | if (indx >= num_ch) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9254 | hdd_err("Invalid Channel [%d]", channel); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9255 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9256 | } |
| 9257 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9258 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9259 | |
| 9260 | } |
| 9261 | |
| 9262 | #ifdef DHCP_SERVER_OFFLOAD |
| 9263 | static void wlan_hdd_set_dhcp_server_offload(hdd_adapter_t *pHostapdAdapter) |
| 9264 | { |
| 9265 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 9266 | tpSirDhcpSrvOffloadInfo pDhcpSrvInfo; |
| 9267 | uint8_t numEntries = 0; |
| 9268 | uint8_t srv_ip[IPADDR_NUM_ENTRIES]; |
| 9269 | uint8_t num; |
| 9270 | uint32_t temp; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9271 | pDhcpSrvInfo = qdf_mem_malloc(sizeof(*pDhcpSrvInfo)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9272 | if (NULL == pDhcpSrvInfo) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9273 | hdd_err("could not allocate tDhcpSrvOffloadInfo!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9274 | return; |
| 9275 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9276 | pDhcpSrvInfo->vdev_id = pHostapdAdapter->sessionId; |
| 9277 | pDhcpSrvInfo->dhcpSrvOffloadEnabled = true; |
| 9278 | pDhcpSrvInfo->dhcpClientNum = pHddCtx->config->dhcpMaxNumClients; |
| 9279 | hdd_string_to_u8_array(pHddCtx->config->dhcpServerIP, |
| 9280 | srv_ip, &numEntries, IPADDR_NUM_ENTRIES); |
| 9281 | if (numEntries != IPADDR_NUM_ENTRIES) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9282 | hdd_err("incorrect IP address (%s) assigned for DHCP server!", pHddCtx->config->dhcpServerIP); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9283 | goto end; |
| 9284 | } |
| 9285 | if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9286 | hdd_err("invalid IP address (%s)! It could NOT be multicast IP address!", pHddCtx->config->dhcpServerIP); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9287 | goto end; |
| 9288 | } |
| 9289 | if (srv_ip[IPADDR_NUM_ENTRIES - 1] >= 100) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9290 | hdd_err("invalid IP address (%s)! The last field must be less than 100!", pHddCtx->config->dhcpServerIP); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9291 | goto end; |
| 9292 | } |
| 9293 | for (num = 0; num < numEntries; num++) { |
| 9294 | temp = srv_ip[num]; |
| 9295 | pDhcpSrvInfo->dhcpSrvIP |= (temp << (8 * num)); |
| 9296 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9297 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9298 | sme_set_dhcp_srv_offload(pHddCtx->hHal, pDhcpSrvInfo)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9299 | hdd_err("sme_setDHCPSrvOffload fail!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9300 | goto end; |
| 9301 | } |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9302 | hdd_info("enable DHCP Server offload successfully!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9303 | end: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9304 | qdf_mem_free(pDhcpSrvInfo); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9305 | return; |
| 9306 | } |
| 9307 | #endif /* DHCP_SERVER_OFFLOAD */ |
| 9308 | |
| 9309 | static int __wlan_hdd_cfg80211_change_bss(struct wiphy *wiphy, |
| 9310 | struct net_device *dev, |
| 9311 | struct bss_parameters *params) |
| 9312 | { |
| 9313 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9314 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9315 | int ret = 0; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9316 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9317 | |
| 9318 | ENTER(); |
| 9319 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9320 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9321 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9322 | return -EINVAL; |
| 9323 | } |
| 9324 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 9325 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 9326 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 9327 | return -EINVAL; |
| 9328 | } |
| 9329 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 9330 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9331 | TRACE_CODE_HDD_CFG80211_CHANGE_BSS, |
| 9332 | pAdapter->sessionId, params->ap_isolate)); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9333 | hdd_notice("Device_mode %s(%d), ap_isolate = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9334 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 9335 | pAdapter->device_mode, params->ap_isolate); |
| 9336 | |
| 9337 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9338 | ret = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 9339 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9340 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9341 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9342 | if (!(pAdapter->device_mode == QDF_SAP_MODE || |
| 9343 | pAdapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9344 | return -EOPNOTSUPP; |
| 9345 | } |
| 9346 | |
| 9347 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 9348 | * want to update this parameter */ |
| 9349 | if (-1 != params->ap_isolate) { |
| 9350 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = |
| 9351 | !!params->ap_isolate; |
| 9352 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9353 | qdf_ret_status = sme_ap_disable_intra_bss_fwd(pHddCtx->hHal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9354 | pAdapter->sessionId, |
| 9355 | pAdapter->sessionCtx. |
| 9356 | ap. |
| 9357 | apDisableIntraBssFwd); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9358 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9359 | ret = -EINVAL; |
| 9360 | } |
| 9361 | } |
| 9362 | |
| 9363 | EXIT(); |
| 9364 | return ret; |
| 9365 | } |
| 9366 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9367 | /** |
| 9368 | * wlan_hdd_change_client_iface_to_new_mode() - to change iface to provided mode |
| 9369 | * @ndev: pointer to net device provided by supplicant |
| 9370 | * @type: type of the interface, upper layer wanted to change |
| 9371 | * |
| 9372 | * Upper layer provides the new interface mode that needs to be changed |
| 9373 | * for given net device |
| 9374 | * |
| 9375 | * Return: success or failure in terms of integer value |
| 9376 | */ |
| 9377 | 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] | 9378 | enum nl80211_iftype type) |
| 9379 | { |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9380 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 9381 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9382 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9383 | hdd_wext_state_t *wext; |
| 9384 | struct wireless_dev *wdev; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 9385 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9386 | |
| 9387 | ENTER(); |
| 9388 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9389 | if (test_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9390 | hdd_notice("ACS is in progress, don't change iface!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9391 | return 0; |
| 9392 | } |
| 9393 | |
| 9394 | wdev = ndev->ieee80211_ptr; |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9395 | hdd_stop_adapter(hdd_ctx, adapter, true); |
| 9396 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9397 | wdev->iftype = type; |
| 9398 | /*Check for sub-string p2p to confirm its a p2p interface */ |
| 9399 | if (NULL != strnstr(ndev->name, "p2p", 3)) { |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9400 | adapter->device_mode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9401 | (type == NL80211_IFTYPE_STATION) ? |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9402 | QDF_P2P_DEVICE_MODE : QDF_P2P_CLIENT_MODE; |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9403 | } else if (type == NL80211_IFTYPE_ADHOC) { |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9404 | adapter->device_mode = QDF_IBSS_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9405 | } else { |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9406 | adapter->device_mode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9407 | (type == NL80211_IFTYPE_STATION) ? |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9408 | QDF_STA_MODE : QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9409 | } |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9410 | memset(&adapter->sessionCtx, 0, sizeof(adapter->sessionCtx)); |
| 9411 | hdd_set_station_ops(adapter->dev); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9412 | wext = WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
| 9413 | wext->roamProfile.pAddIEScan = adapter->scan_info.scanAddIE.addIEdata; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9414 | wext->roamProfile.nAddIEScanLength = |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9415 | adapter->scan_info.scanAddIE.length; |
| 9416 | if (type == NL80211_IFTYPE_ADHOC) { |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 9417 | status = hdd_init_station_mode(adapter); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9418 | wext->roamProfile.BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 9419 | wext->roamProfile.phyMode = |
| 9420 | hdd_cfg_xlate_to_csr_phy_mode(config->dot11Mode); |
| 9421 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9422 | EXIT(); |
| 9423 | return status; |
| 9424 | } |
| 9425 | |
| 9426 | static int wlan_hdd_cfg80211_change_bss(struct wiphy *wiphy, |
| 9427 | struct net_device *dev, |
| 9428 | struct bss_parameters *params) |
| 9429 | { |
| 9430 | int ret; |
| 9431 | |
| 9432 | cds_ssr_protect(__func__); |
| 9433 | ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params); |
| 9434 | cds_ssr_unprotect(__func__); |
| 9435 | |
| 9436 | return ret; |
| 9437 | } |
| 9438 | |
| 9439 | /* FUNCTION: wlan_hdd_change_country_code_cd |
| 9440 | * to wait for contry code completion |
| 9441 | */ |
| 9442 | void *wlan_hdd_change_country_code_cb(void *pAdapter) |
| 9443 | { |
| 9444 | hdd_adapter_t *call_back_pAdapter = pAdapter; |
| 9445 | complete(&call_back_pAdapter->change_country_code); |
| 9446 | return NULL; |
| 9447 | } |
| 9448 | |
Rajeev Kumar | 98edb77 | 2016-01-19 12:42:19 -0800 | [diff] [blame] | 9449 | /** |
| 9450 | * __wlan_hdd_cfg80211_change_iface() - change interface cfg80211 op |
| 9451 | * @wiphy: Pointer to the wiphy structure |
| 9452 | * @ndev: Pointer to the net device |
| 9453 | * @type: Interface type |
| 9454 | * @flags: Flags for change interface |
| 9455 | * @params: Pointer to change interface parameters |
| 9456 | * |
| 9457 | * Return: 0 for success, error number on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9458 | */ |
| 9459 | static int __wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy, |
| 9460 | struct net_device *ndev, |
| 9461 | enum nl80211_iftype type, |
| 9462 | u32 *flags, |
| 9463 | struct vif_params *params) |
| 9464 | { |
| 9465 | struct wireless_dev *wdev; |
| 9466 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 9467 | hdd_context_t *pHddCtx; |
| 9468 | tCsrRoamProfile *pRoamProfile = NULL; |
| 9469 | eCsrRoamBssType LastBSSType; |
| 9470 | struct hdd_config *pConfig = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9471 | QDF_STATUS vstatus; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9472 | int status; |
| 9473 | |
| 9474 | ENTER(); |
| 9475 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9476 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9477 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9478 | return -EINVAL; |
| 9479 | } |
| 9480 | |
| 9481 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9482 | status = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 9483 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9484 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9485 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 9486 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9487 | TRACE_CODE_HDD_CFG80211_CHANGE_IFACE, |
| 9488 | pAdapter->sessionId, type)); |
| 9489 | |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9490 | hdd_notice("Device_mode = %d, IFTYPE = 0x%x", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9491 | pAdapter->device_mode, type); |
| 9492 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9493 | status = hdd_wlan_start_modules(pHddCtx, pAdapter, false); |
| 9494 | if (status) { |
| 9495 | hdd_err("Failed to start modules"); |
| 9496 | return -EINVAL; |
| 9497 | } |
| 9498 | |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 9499 | if (!cds_allow_concurrency( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9500 | wlan_hdd_convert_nl_iftype_to_hdd_type(type), |
| 9501 | 0, HW_MODE_20_MHZ)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9502 | hdd_debug("This concurrency combination is not allowed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9503 | return -EINVAL; |
| 9504 | } |
| 9505 | |
| 9506 | pConfig = pHddCtx->config; |
| 9507 | wdev = ndev->ieee80211_ptr; |
| 9508 | |
| 9509 | /* Reset the current device mode bit mask */ |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 9510 | cds_clear_concurrency_mode(pAdapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9511 | |
| 9512 | hdd_tdls_notify_mode_change(pAdapter, pHddCtx); |
| 9513 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9514 | if ((pAdapter->device_mode == QDF_STA_MODE) || |
| 9515 | (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 9516 | (pAdapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 9517 | (pAdapter->device_mode == QDF_IBSS_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9518 | hdd_wext_state_t *pWextState = |
| 9519 | WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 9520 | |
| 9521 | pRoamProfile = &pWextState->roamProfile; |
| 9522 | LastBSSType = pRoamProfile->BSSType; |
| 9523 | |
| 9524 | switch (type) { |
| 9525 | case NL80211_IFTYPE_STATION: |
| 9526 | case NL80211_IFTYPE_P2P_CLIENT: |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9527 | case NL80211_IFTYPE_ADHOC: |
| 9528 | if (type == NL80211_IFTYPE_ADHOC) { |
| 9529 | wlan_hdd_tdls_exit(pAdapter); |
| 9530 | hdd_deregister_tx_flow_control(pAdapter); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9531 | hdd_notice("Setting interface Type to ADHOC"); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9532 | } |
| 9533 | vstatus = wlan_hdd_change_client_iface_to_new_mode(ndev, |
| 9534 | type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9535 | if (vstatus != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9536 | return -EINVAL; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 9537 | if (hdd_start_adapter(pAdapter)) { |
| 9538 | hdd_err("Failed to start adapter :%d", |
| 9539 | pAdapter->device_mode); |
| 9540 | return -EINVAL; |
| 9541 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9542 | goto done; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9543 | case NL80211_IFTYPE_AP: |
| 9544 | case NL80211_IFTYPE_P2P_GO: |
| 9545 | { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9546 | hdd_info("Setting interface Type to %s", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9547 | (type == |
| 9548 | NL80211_IFTYPE_AP) ? "SoftAP" : |
| 9549 | "P2pGo"); |
| 9550 | |
| 9551 | /* Cancel any remain on channel for GO mode */ |
| 9552 | if (NL80211_IFTYPE_P2P_GO == type) { |
| 9553 | wlan_hdd_cancel_existing_remain_on_channel |
| 9554 | (pAdapter); |
| 9555 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9556 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9557 | hdd_stop_adapter(pHddCtx, pAdapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9558 | /* De-init the adapter */ |
| 9559 | hdd_deinit_adapter(pHddCtx, pAdapter, true); |
| 9560 | memset(&pAdapter->sessionCtx, 0, |
| 9561 | sizeof(pAdapter->sessionCtx)); |
| 9562 | pAdapter->device_mode = |
| 9563 | (type == |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9564 | NL80211_IFTYPE_AP) ? QDF_SAP_MODE : |
| 9565 | QDF_P2P_GO_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9566 | |
| 9567 | /* |
| 9568 | * Fw will take care incase of concurrency |
| 9569 | */ |
| 9570 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9571 | if ((QDF_SAP_MODE == pAdapter->device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9572 | && (pConfig->apRandomBssidEnabled)) { |
| 9573 | /* To meet Android requirements create a randomized |
| 9574 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 9575 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 9576 | ndev->dev_addr[0] = 0x02; |
| 9577 | ndev->dev_addr[1] = 0x1A; |
| 9578 | ndev->dev_addr[2] = 0x11; |
| 9579 | ndev->dev_addr[3] |= 0xF0; |
| 9580 | memcpy(pAdapter->macAddressCurrent. |
| 9581 | bytes, ndev->dev_addr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9582 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9583 | pr_info("wlan: Generated HotSpot BSSID " |
| 9584 | MAC_ADDRESS_STR "\n", |
| 9585 | MAC_ADDR_ARRAY(ndev->dev_addr)); |
| 9586 | } |
| 9587 | |
| 9588 | hdd_set_ap_ops(pAdapter->dev); |
| 9589 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9590 | if (hdd_start_adapter(pAdapter)) { |
| 9591 | hdd_err("Error initializing the ap mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9592 | return -EINVAL; |
| 9593 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9594 | /* Interface type changed update in wiphy structure */ |
| 9595 | if (wdev) { |
| 9596 | wdev->iftype = type; |
| 9597 | } else { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9598 | hdd_err("Wireless dev is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9599 | return -EINVAL; |
| 9600 | } |
| 9601 | goto done; |
| 9602 | } |
| 9603 | |
| 9604 | default: |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9605 | hdd_err("Unsupported interface type (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9606 | type); |
| 9607 | return -EOPNOTSUPP; |
| 9608 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9609 | } else if ((pAdapter->device_mode == QDF_SAP_MODE) || |
| 9610 | (pAdapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9611 | switch (type) { |
| 9612 | case NL80211_IFTYPE_STATION: |
| 9613 | case NL80211_IFTYPE_P2P_CLIENT: |
| 9614 | case NL80211_IFTYPE_ADHOC: |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9615 | status = wlan_hdd_change_client_iface_to_new_mode(ndev, |
| 9616 | type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9617 | if (status != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9618 | return status; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 9619 | if (hdd_start_adapter(pAdapter)) { |
| 9620 | hdd_err("Failed to start adapter :%d", |
| 9621 | pAdapter->device_mode); |
| 9622 | return -EINVAL; |
| 9623 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9624 | goto done; |
| 9625 | |
| 9626 | case NL80211_IFTYPE_AP: |
| 9627 | case NL80211_IFTYPE_P2P_GO: |
| 9628 | wdev->iftype = type; |
| 9629 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9630 | QDF_SAP_MODE : QDF_P2P_GO_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9631 | goto done; |
| 9632 | |
| 9633 | default: |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9634 | hdd_err("Unsupported interface type(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9635 | type); |
| 9636 | return -EOPNOTSUPP; |
| 9637 | } |
| 9638 | } else { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9639 | hdd_err("Unsupported device mode(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9640 | pAdapter->device_mode); |
| 9641 | return -EOPNOTSUPP; |
| 9642 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9643 | done: |
| 9644 | /* Set bitmask based on updated value */ |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 9645 | cds_set_concurrency_mode(pAdapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9646 | |
Jeff Johnson | 2ae6f71 | 2016-09-23 15:08:48 -0700 | [diff] [blame] | 9647 | hdd_lpass_notify_mode_change(pAdapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9648 | |
| 9649 | EXIT(); |
| 9650 | return 0; |
| 9651 | } |
| 9652 | |
Rajeev Kumar | 98edb77 | 2016-01-19 12:42:19 -0800 | [diff] [blame] | 9653 | /** |
| 9654 | * wlan_hdd_cfg80211_change_iface() - change interface cfg80211 op |
| 9655 | * @wiphy: Pointer to the wiphy structure |
| 9656 | * @ndev: Pointer to the net device |
| 9657 | * @type: Interface type |
| 9658 | * @flags: Flags for change interface |
| 9659 | * @params: Pointer to change interface parameters |
| 9660 | * |
| 9661 | * Return: 0 for success, error number on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9662 | */ |
| 9663 | static int wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy, |
| 9664 | struct net_device *ndev, |
| 9665 | enum nl80211_iftype type, |
| 9666 | u32 *flags, |
| 9667 | struct vif_params *params) |
| 9668 | { |
| 9669 | int ret; |
| 9670 | |
| 9671 | cds_ssr_protect(__func__); |
| 9672 | ret = |
| 9673 | __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params); |
| 9674 | cds_ssr_unprotect(__func__); |
| 9675 | |
| 9676 | return ret; |
| 9677 | } |
| 9678 | |
| 9679 | #ifdef FEATURE_WLAN_TDLS |
| 9680 | static bool wlan_hdd_is_duplicate_channel(uint8_t *arr, |
| 9681 | int index, uint8_t match) |
| 9682 | { |
| 9683 | int i; |
| 9684 | for (i = 0; i < index; i++) { |
| 9685 | if (arr[i] == match) |
| 9686 | return true; |
| 9687 | } |
| 9688 | return false; |
| 9689 | } |
| 9690 | #endif |
| 9691 | |
| 9692 | /** |
| 9693 | * __wlan_hdd_change_station() - change station |
| 9694 | * @wiphy: Pointer to the wiphy structure |
| 9695 | * @dev: Pointer to the net device. |
| 9696 | * @mac: bssid |
| 9697 | * @params: Pointer to station parameters |
| 9698 | * |
| 9699 | * Return: 0 for success, error number on failure. |
| 9700 | */ |
| 9701 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 9702 | static int __wlan_hdd_change_station(struct wiphy *wiphy, |
| 9703 | struct net_device *dev, |
| 9704 | const uint8_t *mac, |
| 9705 | struct station_parameters *params) |
| 9706 | #else |
| 9707 | static int __wlan_hdd_change_station(struct wiphy *wiphy, |
| 9708 | struct net_device *dev, |
| 9709 | uint8_t *mac, |
| 9710 | struct station_parameters *params) |
| 9711 | #endif |
| 9712 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9713 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9714 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9715 | hdd_context_t *pHddCtx; |
| 9716 | hdd_station_ctx_t *pHddStaCtx; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9717 | struct qdf_mac_addr STAMacAddress; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9718 | #ifdef FEATURE_WLAN_TDLS |
| 9719 | tCsrStaParams StaParams = { 0 }; |
| 9720 | uint8_t isBufSta = 0; |
| 9721 | uint8_t isOffChannelSupported = 0; |
Nitesh Shah | 99934ac | 2016-09-05 15:54:08 +0530 | [diff] [blame] | 9722 | bool is_qos_wmm_sta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9723 | #endif |
| 9724 | int ret; |
| 9725 | |
| 9726 | ENTER(); |
| 9727 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9728 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9729 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9730 | return -EINVAL; |
| 9731 | } |
| 9732 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 9733 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9734 | TRACE_CODE_HDD_CHANGE_STATION, |
| 9735 | pAdapter->sessionId, params->listen_interval)); |
| 9736 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 9737 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 9738 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 9739 | return -EINVAL; |
| 9740 | } |
| 9741 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9742 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9743 | ret = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 9744 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9745 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9746 | |
| 9747 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9748 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9749 | qdf_mem_copy(STAMacAddress.bytes, mac, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9750 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9751 | if ((pAdapter->device_mode == QDF_SAP_MODE) || |
| 9752 | (pAdapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9753 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
| 9754 | status = |
| 9755 | hdd_softap_change_sta_state(pAdapter, |
| 9756 | &STAMacAddress, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 9757 | OL_TXRX_PEER_STATE_AUTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9758 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9759 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9760 | hdd_notice("Not able to change TL state to AUTHENTICATED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9761 | return -EINVAL; |
| 9762 | } |
| 9763 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9764 | } else if ((pAdapter->device_mode == QDF_STA_MODE) || |
| 9765 | (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9766 | #ifdef FEATURE_WLAN_TDLS |
| 9767 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9768 | |
| 9769 | if (cds_is_sub_20_mhz_enabled()) { |
| 9770 | hdd_err("TDLS not allowed with sub 20 MHz"); |
| 9771 | return -EINVAL; |
| 9772 | } |
| 9773 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9774 | StaParams.capability = params->capability; |
| 9775 | StaParams.uapsd_queues = params->uapsd_queues; |
| 9776 | StaParams.max_sp = params->max_sp; |
| 9777 | |
| 9778 | /* Convert (first channel , number of channels) tuple to |
| 9779 | * the total list of channels. This goes with the assumption |
| 9780 | * that if the first channel is < 14, then the next channels |
| 9781 | * are an incremental of 1 else an incremental of 4 till the number |
| 9782 | * of channels. |
| 9783 | */ |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9784 | hdd_notice("params->supported_channels_len: %d", params->supported_channels_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9785 | if (0 != params->supported_channels_len) { |
| 9786 | int i = 0, j = 0, k = 0, no_of_channels = 0; |
| 9787 | int num_unique_channels; |
| 9788 | int next; |
| 9789 | for (i = 0; |
| 9790 | i < params->supported_channels_len |
| 9791 | && j < SIR_MAC_MAX_SUPP_CHANNELS; i += 2) { |
| 9792 | int wifi_chan_index; |
| 9793 | if (!wlan_hdd_is_duplicate_channel |
| 9794 | (StaParams.supported_channels, j, |
| 9795 | params->supported_channels[i])) { |
| 9796 | StaParams. |
| 9797 | supported_channels[j] = |
| 9798 | params-> |
| 9799 | supported_channels[i]; |
| 9800 | } else { |
| 9801 | continue; |
| 9802 | } |
| 9803 | wifi_chan_index = |
| 9804 | ((StaParams.supported_channels[j] <= |
| 9805 | HDD_CHANNEL_14) ? 1 : 4); |
| 9806 | no_of_channels = |
| 9807 | params->supported_channels[i + 1]; |
| 9808 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9809 | hdd_notice("i: %d, j: %d, k: %d, StaParams.supported_channels[%d]: %d, wifi_chan_index: %d, no_of_channels: %d", i, j, k, j, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9810 | StaParams. |
| 9811 | supported_channels[j], |
| 9812 | wifi_chan_index, |
| 9813 | no_of_channels); |
| 9814 | for (k = 1; k <= no_of_channels && |
| 9815 | j < SIR_MAC_MAX_SUPP_CHANNELS - 1; |
| 9816 | k++) { |
| 9817 | next = |
| 9818 | StaParams. |
| 9819 | supported_channels[j] + |
| 9820 | wifi_chan_index; |
| 9821 | if (!wlan_hdd_is_duplicate_channel(StaParams.supported_channels, j + 1, next)) { |
| 9822 | StaParams. |
| 9823 | supported_channels[j |
| 9824 | + |
| 9825 | 1] |
| 9826 | = next; |
| 9827 | } else { |
| 9828 | continue; |
| 9829 | } |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9830 | hdd_notice("i: %d, j: %d, k: %d, StaParams.supported_channels[%d]: %d", i, j, k, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9831 | j + 1, |
| 9832 | StaParams. |
| 9833 | supported_channels[j + |
| 9834 | 1]); |
| 9835 | j += 1; |
| 9836 | } |
| 9837 | } |
| 9838 | num_unique_channels = j + 1; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9839 | hdd_notice("Unique Channel List"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9840 | for (i = 0; i < num_unique_channels; i++) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9841 | hdd_notice("StaParams.supported_channels[%d]: %d,", i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9842 | StaParams. |
| 9843 | supported_channels[i]); |
| 9844 | } |
| 9845 | if (MAX_CHANNEL < num_unique_channels) |
| 9846 | num_unique_channels = MAX_CHANNEL; |
| 9847 | StaParams.supported_channels_len = |
| 9848 | num_unique_channels; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9849 | hdd_notice("After removing duplcates StaParams.supported_channels_len: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9850 | StaParams.supported_channels_len); |
| 9851 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9852 | qdf_mem_copy(StaParams.supported_oper_classes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9853 | params->supported_oper_classes, |
| 9854 | params->supported_oper_classes_len); |
| 9855 | StaParams.supported_oper_classes_len = |
| 9856 | params->supported_oper_classes_len; |
| 9857 | |
| 9858 | if (0 != params->ext_capab_len) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9859 | qdf_mem_copy(StaParams.extn_capability, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9860 | params->ext_capab, |
| 9861 | sizeof(StaParams.extn_capability)); |
| 9862 | |
| 9863 | if (NULL != params->ht_capa) { |
| 9864 | StaParams.htcap_present = 1; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9865 | qdf_mem_copy(&StaParams.HTCap, params->ht_capa, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9866 | sizeof(tSirHTCap)); |
| 9867 | } |
| 9868 | |
| 9869 | StaParams.supported_rates_len = |
| 9870 | params->supported_rates_len; |
| 9871 | |
| 9872 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 9873 | * The supported_rates array , for all the structures propogating till Add Sta |
| 9874 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 9875 | * modified to send more rates. |
| 9876 | */ |
| 9877 | |
| 9878 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 9879 | */ |
| 9880 | if (StaParams.supported_rates_len > |
| 9881 | SIR_MAC_MAX_SUPP_RATES) |
| 9882 | StaParams.supported_rates_len = |
| 9883 | SIR_MAC_MAX_SUPP_RATES; |
| 9884 | |
| 9885 | if (0 != StaParams.supported_rates_len) { |
| 9886 | int i = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9887 | qdf_mem_copy(StaParams.supported_rates, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9888 | params->supported_rates, |
| 9889 | StaParams.supported_rates_len); |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9890 | hdd_notice("Supported Rates with Length %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9891 | StaParams.supported_rates_len); |
| 9892 | for (i = 0; i < StaParams.supported_rates_len; |
| 9893 | i++) |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9894 | hdd_notice("[%d]: %0x", i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9895 | StaParams.supported_rates[i]); |
| 9896 | } |
| 9897 | |
| 9898 | if (NULL != params->vht_capa) { |
| 9899 | StaParams.vhtcap_present = 1; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9900 | qdf_mem_copy(&StaParams.VHTCap, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9901 | params->vht_capa, |
| 9902 | sizeof(tSirVHTCap)); |
| 9903 | } |
| 9904 | |
| 9905 | if (0 != params->ext_capab_len) { |
| 9906 | /*Define A Macro : TODO Sunil */ |
| 9907 | if ((1 << 4) & StaParams.extn_capability[3]) { |
| 9908 | isBufSta = 1; |
| 9909 | } |
| 9910 | /* TDLS Channel Switching Support */ |
| 9911 | if ((1 << 6) & StaParams.extn_capability[3]) { |
| 9912 | isOffChannelSupported = 1; |
| 9913 | } |
| 9914 | } |
| 9915 | |
Nitesh Shah | 99934ac | 2016-09-05 15:54:08 +0530 | [diff] [blame] | 9916 | if (pHddCtx->config->fEnableTDLSWmmMode && |
Nitesh Shah | d8ff632 | 2016-09-05 15:55:21 +0530 | [diff] [blame] | 9917 | (params->ht_capa || params->vht_capa || |
| 9918 | (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME)))) |
Nitesh Shah | 99934ac | 2016-09-05 15:54:08 +0530 | [diff] [blame] | 9919 | is_qos_wmm_sta = true; |
| 9920 | |
| 9921 | hdd_notice("%s: TDLS Peer is QOS capable" |
| 9922 | " is_qos_wmm_sta= %d HTcapPresent = %d", |
| 9923 | __func__, is_qos_wmm_sta, |
| 9924 | StaParams.htcap_present); |
| 9925 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9926 | status = wlan_hdd_tdls_set_peer_caps(pAdapter, mac, |
Nitesh Shah | 99934ac | 2016-09-05 15:54:08 +0530 | [diff] [blame] | 9927 | &StaParams, |
| 9928 | isBufSta, |
| 9929 | isOffChannelSupported, |
| 9930 | is_qos_wmm_sta); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9931 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9932 | hdd_err("wlan_hdd_tdls_set_peer_caps failed!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9933 | return -EINVAL; |
| 9934 | } |
| 9935 | |
| 9936 | status = |
| 9937 | wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, |
| 9938 | &StaParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9939 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9940 | hdd_err("wlan_hdd_tdls_add_station failed!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9941 | return -EINVAL; |
| 9942 | } |
| 9943 | } |
| 9944 | #endif |
| 9945 | } |
| 9946 | EXIT(); |
| 9947 | return ret; |
| 9948 | } |
| 9949 | |
| 9950 | /** |
| 9951 | * wlan_hdd_change_station() - cfg80211 change station handler function |
| 9952 | * @wiphy: Pointer to the wiphy structure |
| 9953 | * @dev: Pointer to the net device. |
| 9954 | * @mac: bssid |
| 9955 | * @params: Pointer to station parameters |
| 9956 | * |
| 9957 | * This is the cfg80211 change station handler function which invokes |
| 9958 | * the internal function @__wlan_hdd_change_station with |
| 9959 | * SSR protection. |
| 9960 | * |
| 9961 | * Return: 0 for success, error number on failure. |
| 9962 | */ |
| 9963 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) || defined(WITH_BACKPORTS) |
| 9964 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 9965 | struct net_device *dev, |
| 9966 | const u8 *mac, |
| 9967 | struct station_parameters *params) |
| 9968 | #else |
| 9969 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 9970 | struct net_device *dev, |
| 9971 | u8 *mac, |
| 9972 | struct station_parameters *params) |
| 9973 | #endif |
| 9974 | { |
| 9975 | int ret; |
| 9976 | |
| 9977 | cds_ssr_protect(__func__); |
| 9978 | ret = __wlan_hdd_change_station(wiphy, dev, mac, params); |
| 9979 | cds_ssr_unprotect(__func__); |
| 9980 | |
| 9981 | return ret; |
| 9982 | } |
| 9983 | |
| 9984 | /* |
| 9985 | * FUNCTION: __wlan_hdd_cfg80211_add_key |
| 9986 | * This function is used to initialize the key information |
| 9987 | */ |
| 9988 | static int __wlan_hdd_cfg80211_add_key(struct wiphy *wiphy, |
| 9989 | struct net_device *ndev, |
| 9990 | u8 key_index, bool pairwise, |
| 9991 | const u8 *mac_addr, |
| 9992 | struct key_params *params) |
| 9993 | { |
| 9994 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 9995 | tCsrRoamSetKey setKey; |
| 9996 | int status; |
| 9997 | uint32_t roamId = 0xFF; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9998 | hdd_hostapd_state_t *pHostapdState; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9999 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10000 | hdd_context_t *pHddCtx; |
| 10001 | hdd_ap_ctx_t *ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 10002 | |
| 10003 | ENTER(); |
| 10004 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10005 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10006 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10007 | return -EINVAL; |
| 10008 | } |
| 10009 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 10010 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 10011 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 10012 | return -EINVAL; |
| 10013 | } |
| 10014 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 10015 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10016 | TRACE_CODE_HDD_CFG80211_ADD_KEY, |
| 10017 | pAdapter->sessionId, params->key_len)); |
| 10018 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10019 | status = wlan_hdd_validate_context(pHddCtx); |
| 10020 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 10021 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10022 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10023 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10024 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10025 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 10026 | pAdapter->device_mode); |
| 10027 | |
| 10028 | if (CSR_MAX_NUM_KEY <= key_index) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10029 | hdd_err("Invalid key index %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10030 | |
| 10031 | return -EINVAL; |
| 10032 | } |
| 10033 | |
| 10034 | if (CSR_MAX_KEY_LEN < params->key_len) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10035 | hdd_err("Invalid key length %d", params->key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10036 | |
| 10037 | return -EINVAL; |
| 10038 | } |
| 10039 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10040 | hdd_notice("called with key index = %d & key length %d", key_index, params->key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10041 | |
| 10042 | /*extract key idx, key len and key */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10043 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10044 | setKey.keyId = key_index; |
| 10045 | setKey.keyLength = params->key_len; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10046 | qdf_mem_copy(&setKey.Key[0], params->key, params->key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10047 | |
| 10048 | switch (params->cipher) { |
| 10049 | case WLAN_CIPHER_SUITE_WEP40: |
| 10050 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 10051 | break; |
| 10052 | |
| 10053 | case WLAN_CIPHER_SUITE_WEP104: |
| 10054 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 10055 | break; |
| 10056 | |
| 10057 | case WLAN_CIPHER_SUITE_TKIP: |
| 10058 | { |
| 10059 | u8 *pKey = &setKey.Key[0]; |
| 10060 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 10061 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10062 | qdf_mem_zero(pKey, CSR_MAX_KEY_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10063 | |
| 10064 | /*Supplicant sends the 32bytes key in this order |
| 10065 | |
| 10066 | |--------------|----------|----------| |
| 10067 | | Tk1 |TX-MIC | RX Mic | |
| 10068 | |||--------------|----------|----------| |
| 10069 | <---16bytes---><--8bytes--><--8bytes--> |
| 10070 | |
| 10071 | */ |
| 10072 | /*Sme expects the 32 bytes key to be in the below order |
| 10073 | |
| 10074 | |--------------|----------|----------| |
| 10075 | | Tk1 |RX-MIC | TX Mic | |
| 10076 | |||--------------|----------|----------| |
| 10077 | <---16bytes---><--8bytes--><--8bytes--> |
| 10078 | */ |
| 10079 | /* Copy the Temporal Key 1 (TK1) */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10080 | qdf_mem_copy(pKey, params->key, 16); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10081 | |
| 10082 | /*Copy the rx mic first */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10083 | qdf_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10084 | |
| 10085 | /*Copy the tx mic */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10086 | qdf_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10087 | |
| 10088 | break; |
| 10089 | } |
| 10090 | |
| 10091 | case WLAN_CIPHER_SUITE_CCMP: |
| 10092 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 10093 | break; |
| 10094 | |
| 10095 | #ifdef FEATURE_WLAN_WAPI |
| 10096 | case WLAN_CIPHER_SUITE_SMS4: |
| 10097 | { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10098 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10099 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, |
| 10100 | mac_addr, params->key, |
| 10101 | params->key_len); |
| 10102 | return 0; |
| 10103 | } |
| 10104 | #endif |
| 10105 | |
| 10106 | #ifdef FEATURE_WLAN_ESE |
| 10107 | case WLAN_CIPHER_SUITE_KRK: |
| 10108 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 10109 | break; |
| 10110 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 10111 | case WLAN_CIPHER_SUITE_BTK: |
| 10112 | setKey.encType = eCSR_ENCRYPT_TYPE_BTK; |
| 10113 | break; |
| 10114 | #endif |
| 10115 | #endif |
| 10116 | |
| 10117 | #ifdef WLAN_FEATURE_11W |
| 10118 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 10119 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
| 10120 | break; |
| 10121 | #endif |
| 10122 | |
| 10123 | default: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10124 | hdd_err("unsupported cipher type %u", params->cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10125 | return -EOPNOTSUPP; |
| 10126 | } |
| 10127 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10128 | hdd_info("encryption type %d", setKey.encType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10129 | |
| 10130 | if (!pairwise) { |
| 10131 | /* set group key */ |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10132 | hdd_notice("%s- %d: setting Broadcast key", __func__, __LINE__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10133 | setKey.keyDirection = eSIR_RX_ONLY; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 10134 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10135 | } else { |
| 10136 | /* set pairwise key */ |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10137 | hdd_notice("%s- %d: setting pairwise key", __func__, __LINE__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10138 | setKey.keyDirection = eSIR_TX_RX; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10139 | qdf_mem_copy(setKey.peerMac.bytes, mac_addr, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10140 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 10141 | if ((QDF_IBSS_MODE == pAdapter->device_mode) && !pairwise) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10142 | /* if a key is already installed, block all subsequent ones */ |
| 10143 | if (pAdapter->sessionCtx.station.ibss_enc_key_installed) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10144 | hdd_info("IBSS key installed already"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10145 | return 0; |
| 10146 | } |
| 10147 | |
| 10148 | setKey.keyDirection = eSIR_TX_RX; |
| 10149 | /*Set the group key */ |
| 10150 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10151 | pAdapter->sessionId, &setKey, &roamId); |
| 10152 | |
| 10153 | if (0 != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10154 | hdd_err("sme_roam_set_key failed, returned %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10155 | return -EINVAL; |
| 10156 | } |
| 10157 | /*Save the keys here and call sme_roam_set_key for setting |
| 10158 | the PTK after peer joins the IBSS network */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10159 | qdf_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10160 | &setKey, sizeof(tCsrRoamSetKey)); |
| 10161 | |
| 10162 | pAdapter->sessionCtx.station.ibss_enc_key_installed = 1; |
| 10163 | return status; |
| 10164 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 10165 | if ((pAdapter->device_mode == QDF_SAP_MODE) || |
| 10166 | (pAdapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10167 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 10168 | if (pHostapdState->bssState == BSS_START) { |
Dustin Brown | 6ba30a1 | 2016-09-13 13:59:43 -0700 | [diff] [blame] | 10169 | status = wlansap_set_key_sta( |
| 10170 | WLAN_HDD_GET_SAP_CTX_PTR(pAdapter), &setKey); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10171 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10172 | hdd_err("[%4d] wlansap_set_key_sta returned ERROR status= %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10173 | __LINE__, status); |
| 10174 | } |
| 10175 | } |
| 10176 | |
| 10177 | /* Save the key in ap ctx for use on START_BASS and restart */ |
| 10178 | if (pairwise || |
| 10179 | eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 10180 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10181 | qdf_mem_copy(&ap_ctx->wepKey[key_index], &setKey, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10182 | sizeof(tCsrRoamSetKey)); |
| 10183 | else |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10184 | qdf_mem_copy(&ap_ctx->groupKey, &setKey, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10185 | sizeof(tCsrRoamSetKey)); |
| 10186 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 10187 | } else if ((pAdapter->device_mode == QDF_STA_MODE) || |
| 10188 | (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10189 | hdd_wext_state_t *pWextState = |
| 10190 | WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 10191 | hdd_station_ctx_t *pHddStaCtx = |
| 10192 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10193 | |
| 10194 | if (!pairwise) { |
| 10195 | /* set group key */ |
| 10196 | if (pHddStaCtx->roam_info.deferKeyComplete) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10197 | hdd_notice("%s- %d: Perform Set key Complete", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10198 | __func__, __LINE__); |
| 10199 | hdd_perform_roam_set_key_complete(pAdapter); |
| 10200 | } |
| 10201 | } |
| 10202 | |
| 10203 | pWextState->roamProfile.Keys.KeyLength[key_index] = |
| 10204 | (u8) params->key_len; |
| 10205 | |
| 10206 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 10207 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10208 | qdf_mem_copy(&pWextState->roamProfile.Keys. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10209 | KeyMaterial[key_index][0], params->key, |
| 10210 | params->key_len); |
| 10211 | |
| 10212 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 10213 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10214 | hdd_info("Set key for peerMac "MAC_ADDRESS_STR" direction %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10215 | MAC_ADDR_ARRAY(setKey.peerMac.bytes), |
| 10216 | setKey.keyDirection); |
| 10217 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10218 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 10219 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 10220 | request */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10221 | qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10222 | pAdapter->sessionId, &setKey); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10223 | if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10224 | hdd_info("Update PreAuth Key success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10225 | return 0; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10226 | } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10227 | hdd_err("Update PreAuth Key failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10228 | return -EINVAL; |
| 10229 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10230 | |
| 10231 | /* issue set key request to SME */ |
| 10232 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10233 | pAdapter->sessionId, &setKey, &roamId); |
| 10234 | |
| 10235 | if (0 != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10236 | hdd_err("sme_roam_set_key failed, returned %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10237 | pHddStaCtx->roam_info.roamingState = |
| 10238 | HDD_ROAM_STATE_NONE; |
| 10239 | return -EINVAL; |
| 10240 | } |
| 10241 | |
| 10242 | /* in case of IBSS as there was no information available about WEP keys during |
| 10243 | * IBSS join, group key intialized with NULL key, so re-initialize group key |
| 10244 | * with correct value*/ |
| 10245 | if ((eCSR_BSS_TYPE_START_IBSS == |
| 10246 | pWextState->roamProfile.BSSType) |
| 10247 | && |
| 10248 | !((IW_AUTH_KEY_MGMT_802_1X == |
| 10249 | (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
| 10250 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == |
| 10251 | pHddStaCtx->conn_info.authType) |
| 10252 | ) |
| 10253 | && ((WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 10254 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 10255 | ) |
| 10256 | ) { |
| 10257 | setKey.keyDirection = eSIR_RX_ONLY; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 10258 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10259 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10260 | hdd_info("Set key peerMac "MAC_ADDRESS_STR" direction %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10261 | MAC_ADDR_ARRAY(setKey.peerMac.bytes), |
| 10262 | setKey.keyDirection); |
| 10263 | |
| 10264 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10265 | pAdapter->sessionId, &setKey, |
| 10266 | &roamId); |
| 10267 | |
| 10268 | if (0 != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10269 | 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] | 10270 | pHddStaCtx->roam_info.roamingState = |
| 10271 | HDD_ROAM_STATE_NONE; |
| 10272 | return -EINVAL; |
| 10273 | } |
| 10274 | } |
| 10275 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 10276 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10277 | return 0; |
| 10278 | } |
| 10279 | |
| 10280 | static int wlan_hdd_cfg80211_add_key(struct wiphy *wiphy, |
| 10281 | struct net_device *ndev, |
| 10282 | u8 key_index, bool pairwise, |
| 10283 | const u8 *mac_addr, |
| 10284 | struct key_params *params) |
| 10285 | { |
| 10286 | int ret; |
| 10287 | cds_ssr_protect(__func__); |
| 10288 | ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise, |
| 10289 | mac_addr, params); |
| 10290 | cds_ssr_unprotect(__func__); |
| 10291 | |
| 10292 | return ret; |
| 10293 | } |
| 10294 | |
| 10295 | /* |
| 10296 | * FUNCTION: __wlan_hdd_cfg80211_get_key |
| 10297 | * This function is used to get the key information |
| 10298 | */ |
| 10299 | static int __wlan_hdd_cfg80211_get_key(struct wiphy *wiphy, |
| 10300 | struct net_device *ndev, |
| 10301 | u8 key_index, bool pairwise, |
| 10302 | const u8 *mac_addr, void *cookie, |
| 10303 | void (*callback)(void *cookie, |
| 10304 | struct key_params *) |
| 10305 | ) |
| 10306 | { |
| 10307 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 10308 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 10309 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 10310 | struct key_params params; |
| 10311 | |
| 10312 | ENTER(); |
| 10313 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10314 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10315 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10316 | return -EINVAL; |
| 10317 | } |
| 10318 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10319 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10320 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 10321 | pAdapter->device_mode); |
| 10322 | |
| 10323 | memset(¶ms, 0, sizeof(params)); |
| 10324 | |
| 10325 | if (CSR_MAX_NUM_KEY <= key_index) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10326 | hdd_err("invalid key index %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10327 | key_index); |
| 10328 | return -EINVAL; |
| 10329 | } |
| 10330 | |
| 10331 | switch (pRoamProfile->EncryptionType.encryptionType[0]) { |
| 10332 | case eCSR_ENCRYPT_TYPE_NONE: |
| 10333 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 10334 | break; |
| 10335 | |
| 10336 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 10337 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 10338 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 10339 | break; |
| 10340 | |
| 10341 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 10342 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 10343 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 10344 | break; |
| 10345 | |
| 10346 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 10347 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 10348 | break; |
| 10349 | |
| 10350 | case eCSR_ENCRYPT_TYPE_AES: |
| 10351 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 10352 | break; |
| 10353 | |
| 10354 | default: |
| 10355 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 10356 | break; |
| 10357 | } |
| 10358 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 10359 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10360 | TRACE_CODE_HDD_CFG80211_GET_KEY, |
| 10361 | pAdapter->sessionId, params.cipher)); |
| 10362 | |
| 10363 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 10364 | params.seq_len = 0; |
| 10365 | params.seq = NULL; |
| 10366 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 10367 | callback(cookie, ¶ms); |
| 10368 | |
| 10369 | EXIT(); |
| 10370 | return 0; |
| 10371 | } |
| 10372 | |
| 10373 | static int wlan_hdd_cfg80211_get_key(struct wiphy *wiphy, |
| 10374 | struct net_device *ndev, |
| 10375 | u8 key_index, bool pairwise, |
| 10376 | const u8 *mac_addr, void *cookie, |
| 10377 | void (*callback)(void *cookie, |
| 10378 | struct key_params *) |
| 10379 | ) |
| 10380 | { |
| 10381 | int ret; |
| 10382 | |
| 10383 | cds_ssr_protect(__func__); |
| 10384 | ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise, |
| 10385 | mac_addr, cookie, callback); |
| 10386 | cds_ssr_unprotect(__func__); |
| 10387 | |
| 10388 | return ret; |
| 10389 | } |
| 10390 | |
| 10391 | /** |
| 10392 | * __wlan_hdd_cfg80211_del_key() - Delete the encryption key for station |
| 10393 | * @wiphy: wiphy interface context |
| 10394 | * @ndev: pointer to net device |
| 10395 | * @key_index: Key index used in 802.11 frames |
| 10396 | * @unicast: true if it is unicast key |
| 10397 | * @multicast: true if it is multicast key |
| 10398 | * |
| 10399 | * This function is required for cfg80211_ops API. |
| 10400 | * It is used to delete the key information |
| 10401 | * Underlying hardware implementation does not have API to delete the |
| 10402 | * encryption key. It is automatically deleted when the peer is |
| 10403 | * removed. Hence this function currently does nothing. |
| 10404 | * Future implementation may interprete delete key operation to |
| 10405 | * replacing the key with a random junk value, effectively making it |
| 10406 | * useless. |
| 10407 | * |
| 10408 | * Return: status code, always 0. |
| 10409 | */ |
| 10410 | |
| 10411 | static int __wlan_hdd_cfg80211_del_key(struct wiphy *wiphy, |
| 10412 | struct net_device *ndev, |
| 10413 | u8 key_index, |
| 10414 | bool pairwise, const u8 *mac_addr) |
| 10415 | { |
| 10416 | EXIT(); |
| 10417 | return 0; |
| 10418 | } |
| 10419 | |
| 10420 | /** |
| 10421 | * wlan_hdd_cfg80211_del_key() - cfg80211 delete key handler function |
| 10422 | * @wiphy: Pointer to wiphy structure. |
| 10423 | * @dev: Pointer to net_device structure. |
| 10424 | * @key_index: key index |
| 10425 | * @pairwise: pairwise |
| 10426 | * @mac_addr: mac address |
| 10427 | * |
| 10428 | * This is the cfg80211 delete key handler function which invokes |
| 10429 | * the internal function @__wlan_hdd_cfg80211_del_key with |
| 10430 | * SSR protection. |
| 10431 | * |
| 10432 | * Return: 0 for success, error number on failure. |
| 10433 | */ |
| 10434 | static int wlan_hdd_cfg80211_del_key(struct wiphy *wiphy, |
| 10435 | struct net_device *dev, |
| 10436 | u8 key_index, |
| 10437 | bool pairwise, const u8 *mac_addr) |
| 10438 | { |
| 10439 | int ret; |
| 10440 | |
| 10441 | cds_ssr_protect(__func__); |
| 10442 | ret = __wlan_hdd_cfg80211_del_key(wiphy, dev, key_index, |
| 10443 | pairwise, mac_addr); |
| 10444 | cds_ssr_unprotect(__func__); |
| 10445 | |
| 10446 | return ret; |
| 10447 | } |
| 10448 | |
| 10449 | /* |
| 10450 | * FUNCTION: __wlan_hdd_cfg80211_set_default_key |
| 10451 | * This function is used to set the default tx key index |
| 10452 | */ |
| 10453 | static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, |
| 10454 | struct net_device *ndev, |
| 10455 | u8 key_index, |
| 10456 | bool unicast, bool multicast) |
| 10457 | { |
| 10458 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 10459 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 10460 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10461 | hdd_context_t *pHddCtx; |
| 10462 | int status; |
| 10463 | |
| 10464 | ENTER(); |
| 10465 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10466 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10467 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10468 | return -EINVAL; |
| 10469 | } |
| 10470 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 10471 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 10472 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 10473 | return -EINVAL; |
| 10474 | } |
| 10475 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 10476 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10477 | TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY, |
| 10478 | pAdapter->sessionId, key_index)); |
| 10479 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10480 | hdd_notice("Device_mode %s(%d) key_index = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10481 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 10482 | pAdapter->device_mode, key_index); |
| 10483 | |
| 10484 | if (CSR_MAX_NUM_KEY <= key_index) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10485 | hdd_err("Invalid key index %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10486 | return -EINVAL; |
| 10487 | } |
| 10488 | |
| 10489 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10490 | status = wlan_hdd_validate_context(pHddCtx); |
| 10491 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 10492 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10493 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10494 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 10495 | if ((pAdapter->device_mode == QDF_STA_MODE) || |
| 10496 | (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10497 | if ((eCSR_ENCRYPT_TYPE_TKIP != |
| 10498 | pHddStaCtx->conn_info.ucEncryptionType) && |
| 10499 | (eCSR_ENCRYPT_TYPE_AES != |
| 10500 | pHddStaCtx->conn_info.ucEncryptionType)) { |
| 10501 | /* If default key index is not same as previous one, |
| 10502 | * then update the default key index */ |
| 10503 | |
| 10504 | tCsrRoamSetKey setKey; |
| 10505 | uint32_t roamId = 0xFF; |
| 10506 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
| 10507 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10508 | hdd_info("Default tx key index %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10509 | |
| 10510 | Keys->defaultIndex = (u8) key_index; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10511 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10512 | setKey.keyId = key_index; |
| 10513 | setKey.keyLength = Keys->KeyLength[key_index]; |
| 10514 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10515 | qdf_mem_copy(&setKey.Key[0], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10516 | &Keys->KeyMaterial[key_index][0], |
| 10517 | Keys->KeyLength[key_index]); |
| 10518 | |
| 10519 | setKey.keyDirection = eSIR_TX_RX; |
| 10520 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 10521 | qdf_copy_macaddr(&setKey.peerMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10522 | &pHddStaCtx->conn_info.bssId); |
| 10523 | |
| 10524 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 10525 | pWextState->roamProfile.EncryptionType. |
| 10526 | encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP104) { |
| 10527 | /* In the case of dynamic wep supplicant hardcodes DWEP type |
| 10528 | * to eCSR_ENCRYPT_TYPE_WEP104 even though ap is configured for |
| 10529 | * WEP-40 encryption. In this canse the key length is 5 but the |
| 10530 | * encryption type is 104 hence checking the key langht(5) and |
| 10531 | * encryption type(104) and switching encryption type to 40*/ |
| 10532 | pWextState->roamProfile.EncryptionType. |
| 10533 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WEP40; |
| 10534 | pWextState->roamProfile.mcEncryptionType. |
| 10535 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WEP40; |
| 10536 | } |
| 10537 | |
| 10538 | setKey.encType = |
| 10539 | pWextState->roamProfile.EncryptionType. |
| 10540 | encryptionType[0]; |
| 10541 | |
| 10542 | /* Issue set key request */ |
| 10543 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10544 | pAdapter->sessionId, &setKey, |
| 10545 | &roamId); |
| 10546 | |
| 10547 | if (0 != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10548 | hdd_err("sme_roam_set_key failed, returned %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10549 | status); |
| 10550 | return -EINVAL; |
| 10551 | } |
| 10552 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 10553 | } else if (QDF_SAP_MODE == pAdapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10554 | /* In SoftAp mode setting key direction for default mode */ |
| 10555 | if ((eCSR_ENCRYPT_TYPE_TKIP != |
| 10556 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 10557 | && (eCSR_ENCRYPT_TYPE_AES != |
| 10558 | pWextState->roamProfile.EncryptionType. |
| 10559 | encryptionType[0])) { |
| 10560 | /* Saving key direction for default key index to TX default */ |
| 10561 | hdd_ap_ctx_t *pAPCtx = |
| 10562 | WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 10563 | pAPCtx->wepKey[key_index].keyDirection = |
| 10564 | eSIR_TX_DEFAULT; |
Kondabattini, Ganesh | 702d90e | 2016-09-03 01:54:22 +0530 | [diff] [blame] | 10565 | hdd_info("WEP default key index set to SAP context %d", |
Masti, Narayanraddi | ab712a7 | 2016-08-04 11:59:11 +0530 | [diff] [blame] | 10566 | key_index); |
Kondabattini, Ganesh | 702d90e | 2016-09-03 01:54:22 +0530 | [diff] [blame] | 10567 | pAPCtx->wep_def_key_idx = key_index; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10568 | } |
| 10569 | } |
| 10570 | |
| 10571 | EXIT(); |
| 10572 | return status; |
| 10573 | } |
| 10574 | |
| 10575 | static int wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, |
| 10576 | struct net_device *ndev, |
| 10577 | u8 key_index, |
| 10578 | bool unicast, bool multicast) |
| 10579 | { |
| 10580 | int ret; |
| 10581 | cds_ssr_protect(__func__); |
| 10582 | ret = |
| 10583 | __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast, |
| 10584 | multicast); |
| 10585 | cds_ssr_unprotect(__func__); |
| 10586 | |
| 10587 | return ret; |
| 10588 | } |
| 10589 | |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10590 | /* |
| 10591 | * wlan_hdd_cfg80211_get_bss :to get the bss from kernel cache. |
| 10592 | * @wiphy: wiphy pointer |
| 10593 | * @channel: channel of the BSS |
| 10594 | * @bssid: Bssid of BSS |
| 10595 | * @ssid: Ssid of the BSS |
| 10596 | * @ssid_len: ssid length |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10597 | * |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10598 | * Return: bss found in kernel cache |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10599 | */ |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10600 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && !defined(WITH_BACKPORTS) |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 10601 | static |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10602 | struct cfg80211_bss *wlan_hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 10603 | struct ieee80211_channel *channel, const u8 *bssid, |
| 10604 | const u8 *ssid, size_t ssid_len) |
| 10605 | { |
| 10606 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 10607 | ssid, |
| 10608 | ssid_len, |
| 10609 | WLAN_CAPABILITY_ESS, |
| 10610 | WLAN_CAPABILITY_ESS); |
| 10611 | } |
| 10612 | #else |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 10613 | static |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10614 | struct cfg80211_bss *wlan_hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 10615 | struct ieee80211_channel *channel, const u8 *bssid, |
| 10616 | const u8 *ssid, size_t ssid_len) |
| 10617 | { |
| 10618 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 10619 | ssid, |
| 10620 | ssid_len, |
| 10621 | IEEE80211_BSS_TYPE_ESS, |
| 10622 | IEEE80211_PRIVACY_ANY); |
| 10623 | } |
| 10624 | #endif |
| 10625 | |
| 10626 | |
| 10627 | /* |
| 10628 | * wlan_hdd_cfg80211_update_bss_list :to inform nl80211 |
| 10629 | * interface that BSS might have been lost. |
| 10630 | * @pAdapter: adaptor |
| 10631 | * @bssid: bssid which might have been lost |
| 10632 | * |
| 10633 | * Return: bss which is unlinked from kernel cache |
| 10634 | */ |
| 10635 | struct cfg80211_bss *wlan_hdd_cfg80211_update_bss_list( |
| 10636 | hdd_adapter_t *pAdapter, tSirMacAddr bssid) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10637 | { |
| 10638 | struct net_device *dev = pAdapter->dev; |
| 10639 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 10640 | struct wiphy *wiphy = wdev->wiphy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10641 | struct cfg80211_bss *bss = NULL; |
| 10642 | |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10643 | bss = wlan_hdd_cfg80211_get_bss(wiphy, NULL, bssid, |
| 10644 | NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10645 | if (bss == NULL) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10646 | hdd_err("BSS not present"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10647 | } else { |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10648 | hdd_info("cfg80211_unlink_bss called for BSSID " |
| 10649 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(bssid)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10650 | cfg80211_unlink_bss(wiphy, bss); |
| 10651 | } |
| 10652 | return bss; |
| 10653 | } |
| 10654 | |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10655 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10656 | /** |
| 10657 | * wlan_hdd_cfg80211_inform_bss_frame() - inform bss details to NL80211 |
| 10658 | * @pAdapter: Pointer to adapter |
| 10659 | * @bss_desc: Pointer to bss descriptor |
| 10660 | * |
| 10661 | * This function is used to inform the BSS details to nl80211 interface. |
| 10662 | * |
| 10663 | * Return: struct cfg80211_bss pointer |
| 10664 | */ |
Selvaraj, Sridhar | fe696d2 | 2016-08-03 21:34:51 +0530 | [diff] [blame] | 10665 | struct cfg80211_bss *wlan_hdd_cfg80211_inform_bss_frame(hdd_adapter_t *pAdapter, |
| 10666 | tSirBssDescription *bss_desc) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10667 | { |
| 10668 | /* |
| 10669 | * cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 10670 | * already exists in bss data base of cfg80211 for that particular BSS |
| 10671 | * ID. Using cfg80211_inform_bss_frame to update the bss entry instead |
| 10672 | * of cfg80211_inform_bss, But this call expects mgmt packet as input. |
| 10673 | * As of now there is no possibility to get the mgmt(probe response) |
| 10674 | * frame from PE, converting bss_desc to ieee80211_mgmt(probe response) |
| 10675 | * and passing to cfg80211_inform_bss_frame. |
| 10676 | */ |
| 10677 | struct net_device *dev = pAdapter->dev; |
| 10678 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 10679 | struct wiphy *wiphy = wdev->wiphy; |
| 10680 | int chan_no = bss_desc->channelId; |
| 10681 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 10682 | qcom_ie_age *qie_age = NULL; |
| 10683 | int ie_length = |
| 10684 | GET_IE_LEN_IN_BSS_DESC(bss_desc->length) + sizeof(qcom_ie_age); |
| 10685 | #else |
| 10686 | int ie_length = GET_IE_LEN_IN_BSS_DESC(bss_desc->length); |
| 10687 | #endif |
| 10688 | const char *ie = |
| 10689 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields : NULL); |
| 10690 | unsigned int freq; |
| 10691 | struct ieee80211_channel *chan; |
| 10692 | struct ieee80211_mgmt *mgmt = NULL; |
| 10693 | struct cfg80211_bss *bss_status = NULL; |
| 10694 | size_t frame_len = sizeof(struct ieee80211_mgmt) + ie_length; |
| 10695 | int rssi = 0; |
| 10696 | hdd_context_t *pHddCtx; |
| 10697 | int status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10698 | struct timespec ts; |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 10699 | struct hdd_config *cfg_param; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10700 | |
| 10701 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10702 | status = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 10703 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10704 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10705 | |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 10706 | cfg_param = pHddCtx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10707 | mgmt = kzalloc((sizeof(struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
| 10708 | if (!mgmt) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10709 | hdd_err("memory allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10710 | return NULL; |
| 10711 | } |
| 10712 | |
| 10713 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
| 10714 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10715 | /* Android does not want the timestamp from the frame. |
| 10716 | Instead it wants a monotonic increasing value */ |
Yuanyuan Liu | 2e03b41 | 2016-04-06 14:36:15 -0700 | [diff] [blame] | 10717 | get_monotonic_boottime(&ts); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10718 | mgmt->u.probe_resp.timestamp = |
| 10719 | ((u64) ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10720 | |
| 10721 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 10722 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
| 10723 | |
| 10724 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 10725 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 10726 | /* Assuming this is the last IE, copy at the end */ |
| 10727 | ie_length -= sizeof(qcom_ie_age); |
| 10728 | qie_age = (qcom_ie_age *) (mgmt->u.probe_resp.variable + ie_length); |
| 10729 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 10730 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 10731 | qie_age->oui_1 = QCOM_OUI1; |
| 10732 | qie_age->oui_2 = QCOM_OUI2; |
| 10733 | qie_age->oui_3 = QCOM_OUI3; |
| 10734 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
Deepthi Gowri | 6acee34 | 2016-10-28 15:00:38 +0530 | [diff] [blame] | 10735 | /* |
| 10736 | * Lowi expects the timestamp of bss in units of 1/10 ms. In driver |
| 10737 | * all bss related timestamp is in units of ms. Due to this when scan |
| 10738 | * results are sent to lowi the scan age is high.To address this, |
| 10739 | * send age in units of 1/10 ms. |
| 10740 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10741 | qie_age->age = |
Sarada Prasanna Garnayak | b3e06a6 | 2016-11-14 20:48:39 +0530 | [diff] [blame] | 10742 | (uint32_t)(qdf_mc_timer_get_system_time() - bss_desc->received_time)/10; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10743 | qie_age->tsf_delta = bss_desc->tsf_delta; |
Krishna Kumaar Natarajan | a4e1224 | 2016-04-01 18:44:39 -0700 | [diff] [blame] | 10744 | memcpy(&qie_age->beacon_tsf, bss_desc->timeStamp, |
| 10745 | sizeof(qie_age->beacon_tsf)); |
Krishna Kumaar Natarajan | 89a99d4 | 2016-08-04 15:44:38 -0700 | [diff] [blame] | 10746 | memcpy(&qie_age->seq_ctrl, &bss_desc->seq_ctrl, |
| 10747 | sizeof(qie_age->seq_ctrl)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10748 | #endif |
| 10749 | |
| 10750 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
| 10751 | if (bss_desc->fProbeRsp) { |
| 10752 | mgmt->frame_control |= |
| 10753 | (u16) (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 10754 | } else { |
| 10755 | mgmt->frame_control |= |
| 10756 | (u16) (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 10757 | } |
| 10758 | |
| 10759 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_ghz) && |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 10760 | (wiphy->bands[NL80211_BAND_2GHZ] != NULL)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10761 | freq = |
| 10762 | ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 10763 | NL80211_BAND_2GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10764 | } else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_ghz)) |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 10765 | && (wiphy->bands[NL80211_BAND_5GHZ] != NULL)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10766 | freq = |
| 10767 | ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 10768 | NL80211_BAND_5GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10769 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10770 | hdd_err("Invalid chan_no %d", chan_no); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10771 | kfree(mgmt); |
| 10772 | return NULL; |
| 10773 | } |
| 10774 | |
| 10775 | chan = __ieee80211_get_channel(wiphy, freq); |
| 10776 | /* When the band is changed on the fly using the GUI, three things are done |
| 10777 | * 1. scan abort |
| 10778 | * 2. flush scan results from cache |
| 10779 | * 3. update the band with the new band user specified (refer to the |
| 10780 | * hdd_set_band_helper function) as part of the scan abort, message will be |
| 10781 | * queued to PE and we proceed with flushing and changinh the band. |
| 10782 | * PE will stop the scanning further and report back the results what ever |
| 10783 | * it had till now by calling the call back function. |
| 10784 | * if the time between update band and scandone call back is sufficient |
| 10785 | * enough the band change reflects in SME, SME validates the channels |
| 10786 | * and discards the channels correponding to previous band and calls back |
| 10787 | * with zero bss results. but if the time between band update and scan done |
| 10788 | * callback is very small then band change will not reflect in SME and SME |
| 10789 | * reports to HDD all the channels correponding to previous band.this is due |
| 10790 | * to race condition.but those channels are invalid to the new band and so |
| 10791 | * this function __ieee80211_get_channel will return NULL.Each time we |
| 10792 | * report scan result with this pointer null warning kernel trace is printed. |
| 10793 | * if the scan results contain large number of APs continuosly kernel |
| 10794 | * warning trace is printed and it will lead to apps watch dog bark. |
| 10795 | * So drop the bss and continue to next bss. |
| 10796 | */ |
| 10797 | if (chan == NULL) { |
Deepthi Gowri | 084c24d | 2016-09-01 15:55:09 +0530 | [diff] [blame] | 10798 | hdd_err("chan pointer is NULL, chan_no: %d freq: %d", |
| 10799 | chan_no, freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10800 | kfree(mgmt); |
| 10801 | return NULL; |
| 10802 | } |
| 10803 | |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 10804 | /* Based on .ini configuration, raw rssi can be reported for bss. |
| 10805 | * Raw rssi is typically used for estimating power. |
| 10806 | */ |
| 10807 | |
| 10808 | rssi = (cfg_param->inform_bss_rssi_raw) ? bss_desc->rssi_raw : |
| 10809 | bss_desc->rssi; |
| 10810 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10811 | /* Supplicant takes the signal strength in terms of mBm(100*dBm) */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10812 | rssi = QDF_MIN(rssi, 0) * 100; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10813 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10814 | hdd_notice("BSSID: " MAC_ADDRESS_STR " Channel:%d RSSI:%d TSF %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10815 | MAC_ADDR_ARRAY(mgmt->bssid), chan->center_freq, |
Sandeep Puligilla | 394da5d | 2016-05-06 01:26:29 -0700 | [diff] [blame] | 10816 | (int)(rssi / 100), |
| 10817 | bss_desc->timeStamp[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10818 | |
| 10819 | bss_status = |
| 10820 | cfg80211_inform_bss_frame(wiphy, chan, mgmt, frame_len, rssi, |
| 10821 | GFP_KERNEL); |
| 10822 | kfree(mgmt); |
| 10823 | return bss_status; |
| 10824 | } |
| 10825 | |
| 10826 | /** |
| 10827 | * wlan_hdd_cfg80211_update_bss_db() - update bss database of CF80211 |
| 10828 | * @pAdapter: Pointer to adapter |
| 10829 | * @pRoamInfo: Pointer to roam info |
| 10830 | * |
| 10831 | * This function is used to update the BSS data base of CFG8011 |
| 10832 | * |
| 10833 | * Return: struct cfg80211_bss pointer |
| 10834 | */ |
| 10835 | struct cfg80211_bss *wlan_hdd_cfg80211_update_bss_db(hdd_adapter_t *pAdapter, |
| 10836 | tCsrRoamInfo *pRoamInfo) |
| 10837 | { |
| 10838 | tCsrRoamConnectedProfile roamProfile; |
| 10839 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 10840 | struct cfg80211_bss *bss = NULL; |
| 10841 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10842 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 10843 | sme_roam_get_connect_profile(hHal, pAdapter->sessionId, &roamProfile); |
| 10844 | |
| 10845 | if (NULL != roamProfile.pBssDesc) { |
| 10846 | bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 10847 | roamProfile.pBssDesc); |
| 10848 | |
| 10849 | if (NULL == bss) |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10850 | hdd_notice("wlan_hdd_cfg80211_inform_bss_frame returned NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10851 | |
Naveen Rawat | df0a7e7 | 2016-01-06 18:35:53 -0800 | [diff] [blame] | 10852 | sme_roam_free_connect_profile(&roamProfile); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10853 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10854 | hdd_err("roamProfile.pBssDesc is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10855 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10856 | return bss; |
| 10857 | } |
| 10858 | /** |
| 10859 | * wlan_hdd_cfg80211_update_bss() - update bss |
| 10860 | * @wiphy: Pointer to wiphy |
| 10861 | * @pAdapter: Pointer to adapter |
| 10862 | * @scan_time: scan request timestamp |
| 10863 | * |
| 10864 | * Return: zero if success, non-zero otherwise |
| 10865 | */ |
| 10866 | int wlan_hdd_cfg80211_update_bss(struct wiphy *wiphy, |
| 10867 | hdd_adapter_t *pAdapter, |
| 10868 | uint32_t scan_time) |
| 10869 | { |
| 10870 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 10871 | tCsrScanResultInfo *pScanResult; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10872 | QDF_STATUS status = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10873 | tScanResultHandle pResult; |
| 10874 | struct cfg80211_bss *bss_status = NULL; |
| 10875 | hdd_context_t *pHddCtx; |
| 10876 | int ret; |
| 10877 | |
| 10878 | ENTER(); |
| 10879 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 10880 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 10881 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 10882 | return -EINVAL; |
| 10883 | } |
| 10884 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 10885 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10886 | TRACE_CODE_HDD_CFG80211_UPDATE_BSS, |
| 10887 | NO_SESSION, pAdapter->sessionId)); |
| 10888 | |
| 10889 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10890 | ret = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 10891 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10892 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10893 | |
| 10894 | /* start getting scan results and populate cgf80211 BSS database */ |
| 10895 | status = sme_scan_get_result(hHal, pAdapter->sessionId, NULL, &pResult); |
| 10896 | |
| 10897 | /* no scan results */ |
| 10898 | if (NULL == pResult) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10899 | hdd_err("No scan result Status %d", status); |
Kapil Gupta | 0ed58dc | 2016-04-22 15:35:26 +0530 | [diff] [blame] | 10900 | return -EAGAIN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10901 | } |
| 10902 | |
| 10903 | pScanResult = sme_scan_result_get_first(hHal, pResult); |
| 10904 | |
| 10905 | while (pScanResult) { |
| 10906 | /* |
| 10907 | * - cfg80211_inform_bss() is not updating ie field of bss |
| 10908 | * entry if entry already exists in bss data base of cfg80211 |
| 10909 | * for that particular BSS ID. Using cfg80211_inform_bss_frame |
| 10910 | * to update thebss entry instead of cfg80211_inform_bss, |
| 10911 | * But this call expects mgmt packet as input. As of now |
| 10912 | * there is no possibility to get the mgmt(probe response) |
| 10913 | * frame from PE, converting bss_desc to |
| 10914 | * ieee80211_mgmt(probe response) and passing to c |
| 10915 | * fg80211_inform_bss_frame. |
| 10916 | * - Update BSS only if beacon timestamp is later than |
| 10917 | * scan request timestamp. |
| 10918 | */ |
| 10919 | if ((scan_time == 0) || |
| 10920 | (scan_time < |
Deepthi Gowri | 6acee34 | 2016-10-28 15:00:38 +0530 | [diff] [blame] | 10921 | pScanResult->BssDescriptor.received_time)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10922 | bss_status = |
| 10923 | wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 10924 | &pScanResult->BssDescriptor); |
| 10925 | |
| 10926 | if (NULL == bss_status) { |
| 10927 | hdd_info("NULL returned by cfg80211_inform_bss_frame"); |
| 10928 | } else { |
| 10929 | cfg80211_put_bss( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10930 | wiphy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10931 | bss_status); |
| 10932 | } |
| 10933 | } else { |
| 10934 | hdd_info("BSSID: " MAC_ADDRESS_STR " Skipped", |
| 10935 | MAC_ADDR_ARRAY(pScanResult->BssDescriptor.bssId)); |
| 10936 | } |
| 10937 | pScanResult = sme_scan_result_get_next(hHal, pResult); |
| 10938 | } |
| 10939 | |
| 10940 | sme_scan_result_purge(hHal, pResult); |
| 10941 | /* |
| 10942 | * For SAP mode, scan is invoked by hostapd during SAP start |
| 10943 | * if hostapd is restarted, we need to flush previous scan |
| 10944 | * result so that it will reflect environment change |
| 10945 | */ |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 10946 | if (pAdapter->device_mode == QDF_SAP_MODE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10947 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 10948 | && pHddCtx->skip_acs_scan_status != eSAP_SKIP_ACS_SCAN |
| 10949 | #endif |
| 10950 | ) |
| 10951 | sme_scan_flush_result(hHal); |
| 10952 | |
| 10953 | EXIT(); |
| 10954 | return 0; |
| 10955 | } |
| 10956 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10957 | /** |
| 10958 | * wlan_hdd_cfg80211_pmksa_candidate_notify() - notify a new PMSKA candidate |
| 10959 | * @pAdapter: Pointer to adapter |
| 10960 | * @pRoamInfo: Pointer to roam info |
| 10961 | * @index: Index |
| 10962 | * @preauth: Preauth flag |
| 10963 | * |
| 10964 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 10965 | * |
| 10966 | * Return: 0 for success, non-zero for failure |
| 10967 | */ |
| 10968 | int wlan_hdd_cfg80211_pmksa_candidate_notify(hdd_adapter_t *pAdapter, |
| 10969 | tCsrRoamInfo *pRoamInfo, |
| 10970 | int index, bool preauth) |
| 10971 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10972 | struct net_device *dev = pAdapter->dev; |
| 10973 | hdd_context_t *pHddCtx = (hdd_context_t *) pAdapter->pHddCtx; |
| 10974 | |
| 10975 | ENTER(); |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10976 | hdd_notice("is going to notify supplicant of:"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10977 | |
| 10978 | if (NULL == pRoamInfo) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10979 | hdd_alert("pRoamInfo is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10980 | return -EINVAL; |
| 10981 | } |
| 10982 | |
| 10983 | if (true == hdd_is_okc_mode_enabled(pHddCtx)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10984 | hdd_notice(MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10985 | MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes)); |
| 10986 | cfg80211_pmksa_candidate_notify(dev, index, |
| 10987 | pRoamInfo->bssid.bytes, |
| 10988 | preauth, GFP_KERNEL); |
| 10989 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10990 | return 0; |
| 10991 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10992 | |
| 10993 | #ifdef FEATURE_WLAN_LFR_METRICS |
| 10994 | /** |
| 10995 | * wlan_hdd_cfg80211_roam_metrics_preauth() - roam metrics preauth |
| 10996 | * @pAdapter: Pointer to adapter |
| 10997 | * @pRoamInfo: Pointer to roam info |
| 10998 | * |
| 10999 | * 802.11r/LFR metrics reporting function to report preauth initiation |
| 11000 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11001 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11002 | */ |
| 11003 | #define MAX_LFR_METRICS_EVENT_LENGTH 100 |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11004 | QDF_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11005 | tCsrRoamInfo *pRoamInfo) |
| 11006 | { |
| 11007 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 11008 | union iwreq_data wrqu; |
| 11009 | |
| 11010 | ENTER(); |
| 11011 | |
| 11012 | if (NULL == pAdapter) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11013 | hdd_err("pAdapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11014 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11015 | } |
| 11016 | |
| 11017 | /* create the event */ |
| 11018 | memset(&wrqu, 0, sizeof(wrqu)); |
| 11019 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 11020 | |
| 11021 | wrqu.data.pointer = metrics_notification; |
| 11022 | wrqu.data.length = scnprintf(metrics_notification, |
| 11023 | sizeof(metrics_notification), |
| 11024 | "QCOM: LFR_PREAUTH_INIT " MAC_ADDRESS_STR, |
| 11025 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 11026 | |
| 11027 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, |
| 11028 | metrics_notification); |
| 11029 | |
| 11030 | EXIT(); |
| 11031 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11032 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11033 | } |
| 11034 | |
| 11035 | /** |
| 11036 | * wlan_hdd_cfg80211_roam_metrics_handover() - roam metrics hand over |
| 11037 | * @pAdapter: Pointer to adapter |
| 11038 | * @pRoamInfo: Pointer to roam info |
| 11039 | * @preauth_status: Preauth status |
| 11040 | * |
| 11041 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 11042 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11043 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11044 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11045 | QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11046 | wlan_hdd_cfg80211_roam_metrics_preauth_status(hdd_adapter_t *pAdapter, |
| 11047 | tCsrRoamInfo *pRoamInfo, |
| 11048 | bool preauth_status) |
| 11049 | { |
| 11050 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 11051 | union iwreq_data wrqu; |
| 11052 | |
| 11053 | ENTER(); |
| 11054 | |
| 11055 | if (NULL == pAdapter) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11056 | hdd_err("pAdapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11057 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11058 | } |
| 11059 | |
| 11060 | /* create the event */ |
| 11061 | memset(&wrqu, 0, sizeof(wrqu)); |
| 11062 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 11063 | |
| 11064 | scnprintf(metrics_notification, sizeof(metrics_notification), |
| 11065 | "QCOM: LFR_PREAUTH_STATUS " MAC_ADDRESS_STR, |
| 11066 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 11067 | |
| 11068 | if (1 == preauth_status) |
| 11069 | strlcat(metrics_notification, " true", |
| 11070 | sizeof(metrics_notification)); |
| 11071 | else |
| 11072 | strlcat(metrics_notification, " false", |
| 11073 | sizeof(metrics_notification)); |
| 11074 | |
| 11075 | wrqu.data.pointer = metrics_notification; |
| 11076 | wrqu.data.length = strlen(metrics_notification); |
| 11077 | |
| 11078 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, |
| 11079 | metrics_notification); |
| 11080 | |
| 11081 | EXIT(); |
| 11082 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11083 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11084 | } |
| 11085 | |
| 11086 | /** |
| 11087 | * wlan_hdd_cfg80211_roam_metrics_handover() - roam metrics hand over |
| 11088 | * @pAdapter: Pointer to adapter |
| 11089 | * @pRoamInfo: Pointer to roam info |
| 11090 | * |
| 11091 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 11092 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11093 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11094 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11095 | QDF_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t *pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11096 | tCsrRoamInfo *pRoamInfo) |
| 11097 | { |
| 11098 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 11099 | union iwreq_data wrqu; |
| 11100 | |
| 11101 | ENTER(); |
| 11102 | |
| 11103 | if (NULL == pAdapter) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11104 | hdd_err("pAdapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11105 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11106 | } |
| 11107 | |
| 11108 | /* create the event */ |
| 11109 | memset(&wrqu, 0, sizeof(wrqu)); |
| 11110 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 11111 | |
| 11112 | wrqu.data.pointer = metrics_notification; |
| 11113 | wrqu.data.length = scnprintf(metrics_notification, |
| 11114 | sizeof(metrics_notification), |
| 11115 | "QCOM: LFR_PREAUTH_HANDOVER " |
| 11116 | MAC_ADDRESS_STR, |
| 11117 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 11118 | |
| 11119 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, |
| 11120 | metrics_notification); |
| 11121 | |
| 11122 | EXIT(); |
| 11123 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11124 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11125 | } |
| 11126 | #endif |
| 11127 | |
| 11128 | /** |
| 11129 | * hdd_select_cbmode() - select channel bonding mode |
| 11130 | * @pAdapter: Pointer to adapter |
| 11131 | * @operatingChannel: Operating channel |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11132 | * @ch_params: channel info struct to populate |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11133 | * |
| 11134 | * Return: none |
| 11135 | */ |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11136 | void hdd_select_cbmode(hdd_adapter_t *pAdapter, uint8_t operationChannel, |
| 11137 | struct ch_params_s *ch_params) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11138 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 11139 | hdd_station_ctx_t *station_ctx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 11140 | struct hdd_mon_set_ch_info *ch_info = &station_ctx->ch_info; |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 11141 | uint8_t sec_ch = 0; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 11142 | |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 11143 | /* |
| 11144 | * CDS api expects secondary channel for calculating |
| 11145 | * the channel params |
| 11146 | */ |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11147 | if ((ch_params->ch_width == CH_WIDTH_40MHZ) && |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 11148 | (CDS_IS_CHANNEL_24GHZ(operationChannel))) { |
| 11149 | if (operationChannel >= 1 && operationChannel <= 5) |
| 11150 | sec_ch = operationChannel + 4; |
| 11151 | else if (operationChannel >= 6 && operationChannel <= 13) |
| 11152 | sec_ch = operationChannel - 4; |
| 11153 | } |
| 11154 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11155 | /* This call decides required channel bonding mode */ |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11156 | cds_set_channel_params(operationChannel, sec_ch, ch_params); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 11157 | |
| 11158 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) { |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11159 | eHddDot11Mode hdd_dot11_mode; |
| 11160 | uint8_t iniDot11Mode = |
| 11161 | (WLAN_HDD_GET_CTX(pAdapter))->config->dot11Mode; |
| 11162 | |
| 11163 | hdd_notice("Dot11Mode is %u", iniDot11Mode); |
| 11164 | switch (iniDot11Mode) { |
| 11165 | case eHDD_DOT11_MODE_AUTO: |
| 11166 | case eHDD_DOT11_MODE_11ac: |
| 11167 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 11168 | if (sme_is_feature_supported_by_fw(DOT11AC)) |
| 11169 | hdd_dot11_mode = eHDD_DOT11_MODE_11ac; |
| 11170 | else |
| 11171 | hdd_dot11_mode = eHDD_DOT11_MODE_11n; |
| 11172 | break; |
| 11173 | case eHDD_DOT11_MODE_11n: |
| 11174 | case eHDD_DOT11_MODE_11n_ONLY: |
| 11175 | hdd_dot11_mode = eHDD_DOT11_MODE_11n; |
| 11176 | break; |
| 11177 | default: |
| 11178 | hdd_dot11_mode = iniDot11Mode; |
| 11179 | break; |
| 11180 | } |
| 11181 | ch_info->channel_width = ch_params->ch_width; |
| 11182 | ch_info->phy_mode = |
| 11183 | hdd_cfg_xlate_to_csr_phy_mode(hdd_dot11_mode); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 11184 | ch_info->channel = operationChannel; |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11185 | ch_info->cb_mode = ch_params->ch_width; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 11186 | hdd_info("ch_info width %d, phymode %d channel %d", |
| 11187 | ch_info->channel_width, ch_info->phy_mode, |
| 11188 | ch_info->channel); |
| 11189 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11190 | } |
| 11191 | |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 11192 | /** |
| 11193 | * wlan_hdd_handle_sap_sta_dfs_conc() - to handle SAP STA DFS conc |
| 11194 | * @adapter: STA adapter |
| 11195 | * @roam_profile: STA roam profile |
| 11196 | * |
| 11197 | * This routine will move SAP from dfs to non-dfs, if sta is coming up. |
| 11198 | * |
| 11199 | * Return: false if sta-sap conc is not allowed, else return true |
| 11200 | */ |
| 11201 | static bool wlan_hdd_handle_sap_sta_dfs_conc(hdd_adapter_t *adapter, |
| 11202 | tCsrRoamProfile *roam_profile) |
| 11203 | { |
| 11204 | hdd_context_t *hdd_ctx; |
| 11205 | hdd_adapter_t *ap_adapter; |
| 11206 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 11207 | hdd_hostapd_state_t *hostapd_state; |
| 11208 | uint8_t channel = 0; |
| 11209 | QDF_STATUS status; |
| 11210 | |
| 11211 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11212 | if (!hdd_ctx) { |
| 11213 | hdd_err("HDD context is NULL"); |
| 11214 | return true; |
| 11215 | } |
| 11216 | |
| 11217 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 11218 | /* probably no sap running, no handling required */ |
| 11219 | if (ap_adapter == NULL) |
| 11220 | return true; |
| 11221 | |
| 11222 | /* |
| 11223 | * sap is not in started state, so it is fine to go ahead with sta. |
| 11224 | * if sap is currently doing CAC then don't allow sta to go further. |
| 11225 | */ |
| 11226 | if (!test_bit(SOFTAP_BSS_STARTED, &(ap_adapter)->event_flags) && |
| 11227 | (hdd_ctx->dev_dfs_cac_status != DFS_CAC_IN_PROGRESS)) |
| 11228 | return true; |
| 11229 | |
| 11230 | if (hdd_ctx->dev_dfs_cac_status == DFS_CAC_IN_PROGRESS) { |
| 11231 | hdd_err("Concurrent SAP is in CAC state, STA is not allowed"); |
| 11232 | return false; |
| 11233 | } |
| 11234 | |
| 11235 | /* |
| 11236 | * log and return error, if we allow STA to go through, we don't |
| 11237 | * know what is going to happen better stop sta connection |
| 11238 | */ |
| 11239 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11240 | if (NULL == hdd_ap_ctx) { |
| 11241 | hdd_err("AP context not found"); |
| 11242 | return false; |
| 11243 | } |
| 11244 | |
| 11245 | /* sap is on non-dfs channel, nothing to handle */ |
| 11246 | if (!CDS_IS_DFS_CH(hdd_ap_ctx->operatingChannel)) { |
| 11247 | hdd_info("sap is on non-dfs channel, sta is allowed"); |
| 11248 | return true; |
| 11249 | } |
| 11250 | /* |
| 11251 | * 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] | 11252 | * connect by passing its roam_profile. |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 11253 | */ |
| 11254 | status = cds_get_channel_from_scan_result(adapter, |
| 11255 | roam_profile, &channel); |
| 11256 | |
Nitesh Shah | 5977452 | 2016-09-16 15:14:21 +0530 | [diff] [blame] | 11257 | /* |
| 11258 | * If the STA's channel is 2.4 GHz, then set pcl with only 2.4 GHz |
| 11259 | * channels for roaming case. |
| 11260 | */ |
| 11261 | if (CDS_IS_CHANNEL_24GHZ(channel)) { |
| 11262 | hdd_info("sap is on dfs, new sta conn on 2.4 is allowed"); |
| 11263 | return true; |
| 11264 | } |
| 11265 | |
| 11266 | /* |
| 11267 | * If channel is 0 or DFS then better to call pcl and find out the |
| 11268 | * best channel. If channel is non-dfs 5 GHz then better move SAP |
| 11269 | * to STA's channel to make scc, so we have room for 3port MCC |
| 11270 | * scenario. |
| 11271 | */ |
| 11272 | if ((0 == channel) || CDS_IS_DFS_CH(channel)) |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 11273 | channel = cds_get_nondfs_preferred_channel(CDS_SAP_MODE, |
| 11274 | true); |
| 11275 | |
| 11276 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 11277 | qdf_event_reset(&hostapd_state->qdf_event); |
| 11278 | status = wlansap_set_channel_change_with_csa( |
| 11279 | WLAN_HDD_GET_SAP_CTX_PTR(ap_adapter), channel, |
| 11280 | hdd_ap_ctx->sapConfig.ch_width_orig); |
| 11281 | |
| 11282 | if (QDF_STATUS_SUCCESS != status) { |
| 11283 | hdd_err("Set channel with CSA IE failed, can't allow STA"); |
| 11284 | return false; |
| 11285 | } |
| 11286 | |
| 11287 | /* |
| 11288 | * wait here for SAP to finish the channel switch. When channel |
| 11289 | * switch happens, SAP sends few beacons with CSA_IE. After |
| 11290 | * successfully Transmission of those beacons, it will move its |
| 11291 | * state from started to disconnected and move to new channel. |
| 11292 | * once it moves to new channel, sap again moves its state |
| 11293 | * machine from disconnected to started and set this event. |
| 11294 | * wait for 10 secs to finish this. |
| 11295 | */ |
| 11296 | status = qdf_wait_single_event(&hostapd_state->qdf_event, 10000); |
| 11297 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 11298 | hdd_err("wait for qdf_event failed, STA not allowed!!"); |
| 11299 | return false; |
| 11300 | } |
| 11301 | |
| 11302 | return true; |
| 11303 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11304 | |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11305 | /** |
| 11306 | * wlan_hdd_cfg80211_connect_start() - to start the association process |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11307 | * @pAdapter: Pointer to adapter |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11308 | * @ssid: Pointer to ssid |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11309 | * @ssid_len: Length of ssid |
| 11310 | * @bssid: Pointer to bssid |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11311 | * @bssid_hint: Pointer to bssid hint |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11312 | * @operatingChannel: Operating channel |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11313 | * @ch_width: channel width. this is needed only for IBSS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11314 | * |
| 11315 | * This function is used to start the association process |
| 11316 | * |
| 11317 | * Return: 0 for success, non-zero for failure |
| 11318 | */ |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11319 | static int wlan_hdd_cfg80211_connect_start(hdd_adapter_t *pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11320 | const u8 *ssid, size_t ssid_len, |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11321 | const u8 *bssid, const u8 *bssid_hint, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11322 | u8 operatingChannel, |
| 11323 | enum nl80211_chan_width ch_width) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11324 | { |
| 11325 | int status = 0; |
| 11326 | hdd_wext_state_t *pWextState; |
| 11327 | hdd_context_t *pHddCtx; |
Anurag Chouhan | 5de8d17 | 2016-07-13 14:44:28 +0530 | [diff] [blame] | 11328 | hdd_station_ctx_t *hdd_sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11329 | uint32_t roamId; |
| 11330 | tCsrRoamProfile *pRoamProfile; |
| 11331 | eCsrAuthType RSNAuthType; |
| 11332 | tSmeConfigParams *sme_config; |
Nitesh Shah | 044fd67 | 2016-10-13 18:53:25 +0530 | [diff] [blame] | 11333 | uint8_t channel = 0; |
| 11334 | struct sir_hw_mode_params hw_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11335 | |
| 11336 | ENTER(); |
| 11337 | |
| 11338 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11339 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Anurag Chouhan | 5de8d17 | 2016-07-13 14:44:28 +0530 | [diff] [blame] | 11340 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11341 | |
| 11342 | status = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 11343 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11344 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11345 | |
| 11346 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11347 | hdd_err("wrong SSID len"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11348 | return -EINVAL; |
| 11349 | } |
| 11350 | |
| 11351 | pRoamProfile = &pWextState->roamProfile; |
Anurag Chouhan | d939d3d | 2016-07-20 17:45:48 +0530 | [diff] [blame] | 11352 | qdf_mem_zero(&hdd_sta_ctx->conn_info.conn_flag, |
| 11353 | sizeof(hdd_sta_ctx->conn_info.conn_flag)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11354 | |
| 11355 | if (pRoamProfile) { |
| 11356 | hdd_station_ctx_t *pHddStaCtx; |
| 11357 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11358 | |
| 11359 | if (HDD_WMM_USER_MODE_NO_QOS == |
| 11360 | (WLAN_HDD_GET_CTX(pAdapter))->config->WmmMode) { |
| 11361 | /*QoS not enabled in cfg file */ |
| 11362 | pRoamProfile->uapsd_mask = 0; |
| 11363 | } else { |
| 11364 | /*QoS enabled, update uapsd mask from cfg file */ |
| 11365 | pRoamProfile->uapsd_mask = |
| 11366 | (WLAN_HDD_GET_CTX(pAdapter))->config->UapsdMask; |
| 11367 | } |
| 11368 | |
| 11369 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 11370 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11371 | qdf_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11372 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11373 | qdf_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11374 | ssid, ssid_len); |
| 11375 | |
Sreelakshmi Konamki | bda5bbf | 2016-09-12 18:38:10 +0530 | [diff] [blame] | 11376 | pRoamProfile->do_not_roam = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11377 | if (bssid) { |
| 11378 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
Sreelakshmi Konamki | bda5bbf | 2016-09-12 18:38:10 +0530 | [diff] [blame] | 11379 | pRoamProfile->do_not_roam = true; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11380 | qdf_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11381 | bssid, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11382 | /* |
| 11383 | * Save BSSID in seperate variable as |
| 11384 | * pRoamProfile's BSSID is getting zeroed out in the |
| 11385 | * association process. In case of join failure |
| 11386 | * we should send valid BSSID to supplicant |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11387 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11388 | qdf_mem_copy((void *)(pWextState->req_bssId.bytes), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11389 | bssid, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 35b404c | 2016-07-14 23:36:00 -0700 | [diff] [blame] | 11390 | hdd_info("bssid is given by upper layer %pM", bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11391 | } else if (bssid_hint) { |
| 11392 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11393 | qdf_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11394 | bssid_hint, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11395 | /* |
| 11396 | * Save BSSID in a separate variable as |
| 11397 | * pRoamProfile's BSSID is getting zeroed out in the |
| 11398 | * association process. In case of join failure |
| 11399 | * we should send valid BSSID to supplicant |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11400 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11401 | qdf_mem_copy((void *)(pWextState->req_bssId.bytes), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11402 | bssid_hint, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 35b404c | 2016-07-14 23:36:00 -0700 | [diff] [blame] | 11403 | hdd_info("bssid_hint is given by upper layer %pM", |
| 11404 | bssid_hint); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11405 | } else { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11406 | qdf_mem_zero((void *)(pRoamProfile->BSSIDs.bssid), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11407 | QDF_MAC_ADDR_SIZE); |
Krunal Soni | 35b404c | 2016-07-14 23:36:00 -0700 | [diff] [blame] | 11408 | hdd_info("no bssid given by upper layer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11409 | } |
| 11410 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11411 | hdd_notice("Connect to SSID: %.*s operating Channel: %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11412 | pRoamProfile->SSIDs.SSIDList->SSID.length, |
| 11413 | pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
| 11414 | operatingChannel); |
| 11415 | |
| 11416 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 11417 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11418 | hdd_set_genie_to_csr(pAdapter, &RSNAuthType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11419 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 11420 | } |
| 11421 | #ifdef FEATURE_WLAN_WAPI |
| 11422 | if (pAdapter->wapi_info.nWapiMode) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11423 | hdd_notice("Setting WAPI AUTH Type and Encryption Mode values"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11424 | switch (pAdapter->wapi_info.wapiAuthMode) { |
| 11425 | case WAPI_AUTH_MODE_PSK: |
| 11426 | { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11427 | hdd_notice("WAPI AUTH TYPE: PSK: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11428 | pAdapter->wapi_info.wapiAuthMode); |
| 11429 | pRoamProfile->AuthType.authType[0] = |
| 11430 | eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 11431 | break; |
| 11432 | } |
| 11433 | case WAPI_AUTH_MODE_CERT: |
| 11434 | { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11435 | hdd_notice("WAPI AUTH TYPE: CERT: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11436 | pAdapter->wapi_info.wapiAuthMode); |
| 11437 | pRoamProfile->AuthType.authType[0] = |
| 11438 | eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 11439 | break; |
| 11440 | } |
| 11441 | } /* End of switch */ |
| 11442 | if (pAdapter->wapi_info.wapiAuthMode == |
| 11443 | WAPI_AUTH_MODE_PSK |
| 11444 | || pAdapter->wapi_info.wapiAuthMode == |
| 11445 | WAPI_AUTH_MODE_CERT) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11446 | hdd_notice("WAPI PAIRWISE/GROUP ENCRYPTION: WPI"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11447 | pRoamProfile->AuthType.numEntries = 1; |
| 11448 | pRoamProfile->EncryptionType.numEntries = 1; |
| 11449 | pRoamProfile->EncryptionType.encryptionType[0] = |
| 11450 | eCSR_ENCRYPT_TYPE_WPI; |
| 11451 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 11452 | pRoamProfile->mcEncryptionType. |
| 11453 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 11454 | } |
| 11455 | } |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11456 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11457 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 11458 | /* Initializing gtkOffloadReqParams */ |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 11459 | if ((QDF_STA_MODE == pAdapter->device_mode) || |
| 11460 | (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11461 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 11462 | sizeof(tSirGtkOffloadParams)); |
| 11463 | pHddStaCtx->gtkOffloadReqParams.ulFlags = |
| 11464 | GTK_OFFLOAD_DISABLE; |
| 11465 | } |
| 11466 | #endif |
| 11467 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 11468 | |
| 11469 | if (operatingChannel) { |
| 11470 | pRoamProfile->ChannelInfo.ChannelList = |
| 11471 | &operatingChannel; |
| 11472 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 11473 | } else { |
| 11474 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 11475 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 11476 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 11477 | if ((QDF_IBSS_MODE == pAdapter->device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11478 | && operatingChannel) { |
| 11479 | /* |
| 11480 | * Need to post the IBSS power save parameters |
| 11481 | * to WMA. WMA will configure this parameters |
| 11482 | * to firmware if power save is enabled by the |
| 11483 | * firmware. |
| 11484 | */ |
| 11485 | status = hdd_set_ibss_power_save_params(pAdapter); |
| 11486 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11487 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11488 | hdd_err("Set IBSS Power Save Params Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11489 | return -EINVAL; |
| 11490 | } |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11491 | pRoamProfile->ch_params.ch_width = |
| 11492 | hdd_map_nl_chan_width(ch_width); |
Nitesh Shah | 87335a5 | 2016-09-05 15:47:32 +0530 | [diff] [blame] | 11493 | /* |
| 11494 | * In IBSS mode while operating in 2.4 GHz, |
| 11495 | * the device supports only 20 MHz. |
| 11496 | */ |
| 11497 | if (CDS_IS_CHANNEL_24GHZ(operatingChannel)) |
| 11498 | pRoamProfile->ch_params.ch_width = |
| 11499 | CH_WIDTH_20MHZ; |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11500 | hdd_select_cbmode(pAdapter, operatingChannel, |
| 11501 | &pRoamProfile->ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11502 | } |
Abhishek Singh | 99bce86 | 2016-06-20 15:10:51 +0530 | [diff] [blame] | 11503 | /* |
| 11504 | * if MFPEnabled is set but the peer AP is non-PMF i.e 80211w=2 |
| 11505 | * or pmf=2 is an explicit configuration in the supplicant |
| 11506 | * configuration, drop the connection request. |
| 11507 | */ |
| 11508 | if (pWextState->roamProfile.MFPEnabled && |
| 11509 | !(pWextState->roamProfile.MFPRequired || |
| 11510 | pWextState->roamProfile.MFPCapable)) { |
| 11511 | hdd_err("Drop connect req as supplicant has indicated PMF req for a non-PMF peer. MFPEnabled %d MFPRequired %d MFPCapable %d", |
| 11512 | pWextState->roamProfile.MFPEnabled, |
| 11513 | pWextState->roamProfile.MFPRequired, |
| 11514 | pWextState->roamProfile.MFPCapable); |
| 11515 | return -EINVAL; |
| 11516 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11517 | |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 11518 | if (true == cds_is_connection_in_progress()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11519 | hdd_err("Connection refused: conn in progress"); |
| 11520 | return -EINVAL; |
| 11521 | } |
| 11522 | |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11523 | /* |
| 11524 | * After 8-way handshake supplicant should give the scan command |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11525 | * in that it update the additional IEs, But because of scan |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11526 | * enhancements, the supplicant is not issuing the scan command |
| 11527 | * now. So the unicast frames which are sent from the host are |
| 11528 | * not having the additional IEs. If it is P2P CLIENT and there |
| 11529 | * is no additional IE present in roamProfile, then use the |
| 11530 | * addtional IE form scan_info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11531 | */ |
| 11532 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 11533 | if ((pAdapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11534 | (!pRoamProfile->pAddIEScan)) { |
| 11535 | pRoamProfile->pAddIEScan = |
| 11536 | &pAdapter->scan_info.scanAddIE.addIEdata[0]; |
| 11537 | pRoamProfile->nAddIEScanLength = |
| 11538 | pAdapter->scan_info.scanAddIE.length; |
| 11539 | } |
| 11540 | /* |
| 11541 | * When policy manager is enabled from ini file, we shouldn't |
| 11542 | * check for other concurrency rules. |
| 11543 | */ |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 11544 | if (wma_is_hw_dbs_capable() == false) { |
Tushnim Bhattacharyya | 4adb368 | 2016-01-07 15:07:12 -0800 | [diff] [blame] | 11545 | cds_handle_conc_rule1(pAdapter, pRoamProfile); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 11546 | if (true != cds_handle_conc_rule2( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11547 | pAdapter, pRoamProfile, &roamId)) |
| 11548 | return 0; |
| 11549 | } |
| 11550 | |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 11551 | if ((wma_is_hw_dbs_capable() == true) && |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 11552 | (false == wlan_hdd_handle_sap_sta_dfs_conc(pAdapter, |
| 11553 | pRoamProfile))) { |
| 11554 | hdd_err("sap-sta conc will fail, can't allow sta"); |
| 11555 | hdd_conn_set_connection_state(pAdapter, |
| 11556 | eConnectionState_NotConnected); |
| 11557 | return -ENOMEM; |
| 11558 | } |
| 11559 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11560 | sme_config = qdf_mem_malloc(sizeof(*sme_config)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11561 | if (!sme_config) { |
| 11562 | hdd_err("unable to allocate sme_config"); |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 11563 | hdd_conn_set_connection_state(pAdapter, |
| 11564 | eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11565 | return -ENOMEM; |
| 11566 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11567 | sme_get_config_param(pHddCtx->hHal, sme_config); |
| 11568 | /* These values are not sessionized. So, any change in these SME |
| 11569 | * configs on an older or parallel interface will affect the |
| 11570 | * cb mode. So, restoring the default INI params before starting |
| 11571 | * interfaces such as sta, cli etc., |
| 11572 | */ |
| 11573 | sme_config->csrConfig.channelBondingMode5GHz = |
| 11574 | pHddCtx->config->nChannelBondingMode5GHz; |
| 11575 | sme_config->csrConfig.channelBondingMode24GHz = |
| 11576 | pHddCtx->config->nChannelBondingMode24GHz; |
| 11577 | sme_update_config(pHddCtx->hHal, sme_config); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11578 | qdf_mem_free(sme_config); |
Agrawal Ashish | 6b01576 | 2016-05-05 11:22:18 +0530 | [diff] [blame] | 11579 | /* |
| 11580 | * Change conn_state to connecting before sme_roam_connect(), |
| 11581 | * because sme_roam_connect() has a direct path to call |
| 11582 | * hdd_sme_roam_callback(), which will change the conn_state |
| 11583 | * If direct path, conn_state will be accordingly changed to |
| 11584 | * NotConnected or Associated by either |
| 11585 | * hdd_association_completion_handler() or |
| 11586 | * hdd_dis_connect_handler() in sme_RoamCallback()if |
| 11587 | * sme_RomConnect is to be queued, |
| 11588 | * Connecting state will remain until it is completed. |
| 11589 | * |
| 11590 | * If connection state is not changed, connection state will |
| 11591 | * remain in eConnectionState_NotConnected state. |
| 11592 | * In hdd_association_completion_handler, "hddDisconInProgress" |
| 11593 | * is set to true if conn state is |
| 11594 | * eConnectionState_NotConnected. |
| 11595 | * If "hddDisconInProgress" is set to true then cfg80211 layer |
| 11596 | * is not informed of connect result indication which |
| 11597 | * is an issue. |
| 11598 | */ |
| 11599 | if (QDF_STA_MODE == pAdapter->device_mode || |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11600 | QDF_P2P_CLIENT_MODE == pAdapter->device_mode) |
Agrawal Ashish | 6b01576 | 2016-05-05 11:22:18 +0530 | [diff] [blame] | 11601 | hdd_conn_set_connection_state(pAdapter, |
| 11602 | eConnectionState_Connecting); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11603 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 11604 | qdf_runtime_pm_prevent_suspend(pAdapter->connect_rpm_ctx. |
| 11605 | connect); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11606 | status = sme_roam_connect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 11607 | pAdapter->sessionId, pRoamProfile, |
| 11608 | &roamId); |
| 11609 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11610 | if ((QDF_STATUS_SUCCESS != status) && |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 11611 | (QDF_STA_MODE == pAdapter->device_mode || |
| 11612 | QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11613 | hdd_err("sme_roam_connect (session %d) failed with " |
| 11614 | "status %d. -> NotConnected", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11615 | pAdapter->sessionId, status); |
| 11616 | /* change back to NotAssociated */ |
| 11617 | hdd_conn_set_connection_state(pAdapter, |
| 11618 | eConnectionState_NotConnected); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 11619 | qdf_runtime_pm_allow_suspend(pAdapter->connect_rpm_ctx. |
| 11620 | connect); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11621 | } |
| 11622 | |
| 11623 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 11624 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 11625 | |
Nitesh Shah | 044fd67 | 2016-10-13 18:53:25 +0530 | [diff] [blame] | 11626 | if (!QDF_IS_STATUS_SUCCESS( |
| 11627 | wma_get_current_hw_mode(&hw_mode))) { |
| 11628 | hdd_err("wma_get_current_hw_mode failed"); |
| 11629 | return status; |
| 11630 | } |
| 11631 | |
| 11632 | if ((QDF_STA_MODE == pAdapter->device_mode) |
| 11633 | && hw_mode.dbs_cap) { |
| 11634 | cds_get_channel_from_scan_result(pAdapter, |
| 11635 | pRoamProfile, &channel); |
| 11636 | if (channel) |
| 11637 | cds_checkn_update_hw_mode_single_mac_mode |
| 11638 | (channel); |
| 11639 | } |
| 11640 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11641 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11642 | hdd_err("No valid Roam profile"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11643 | return -EINVAL; |
| 11644 | } |
| 11645 | EXIT(); |
| 11646 | return status; |
| 11647 | } |
| 11648 | |
| 11649 | /** |
| 11650 | * wlan_hdd_cfg80211_set_auth_type() - set auth type |
| 11651 | * @pAdapter: Pointer to adapter |
| 11652 | * @auth_type: Auth type |
| 11653 | * |
| 11654 | * This function is used to set the authentication type (OPEN/SHARED). |
| 11655 | * |
| 11656 | * Return: 0 for success, non-zero for failure |
| 11657 | */ |
| 11658 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 11659 | enum nl80211_auth_type auth_type) |
| 11660 | { |
| 11661 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11662 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11663 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11664 | /*set authentication type */ |
| 11665 | switch (auth_type) { |
| 11666 | case NL80211_AUTHTYPE_AUTOMATIC: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11667 | hdd_notice("set authentication type to AUTOSWITCH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11668 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 11669 | break; |
| 11670 | |
| 11671 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11672 | case NL80211_AUTHTYPE_FT: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11673 | hdd_notice("set authentication type to OPEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11674 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 11675 | break; |
| 11676 | |
| 11677 | case NL80211_AUTHTYPE_SHARED_KEY: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11678 | hdd_notice("set authentication type to SHARED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11679 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 11680 | break; |
| 11681 | #ifdef FEATURE_WLAN_ESE |
| 11682 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11683 | hdd_notice("set authentication type to CCKM WPA"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11684 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA; |
| 11685 | break; |
| 11686 | #endif |
| 11687 | |
| 11688 | default: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11689 | hdd_err("Unsupported authentication type %d", auth_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11690 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 11691 | return -EINVAL; |
| 11692 | } |
| 11693 | |
| 11694 | pWextState->roamProfile.AuthType.authType[0] = |
| 11695 | pHddStaCtx->conn_info.authType; |
| 11696 | return 0; |
| 11697 | } |
| 11698 | |
| 11699 | /** |
| 11700 | * wlan_hdd_set_akm_suite() - set key management type |
| 11701 | * @pAdapter: Pointer to adapter |
| 11702 | * @key_mgmt: Key management type |
| 11703 | * |
| 11704 | * This function is used to set the key mgmt type(PSK/8021x). |
| 11705 | * |
| 11706 | * Return: 0 for success, non-zero for failure |
| 11707 | */ |
| 11708 | static int wlan_hdd_set_akm_suite(hdd_adapter_t *pAdapter, u32 key_mgmt) |
| 11709 | { |
| 11710 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11711 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11712 | #define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05 |
| 11713 | #define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06 |
| 11714 | /*set key mgmt type */ |
| 11715 | switch (key_mgmt) { |
| 11716 | case WLAN_AKM_SUITE_PSK: |
| 11717 | case WLAN_AKM_SUITE_PSK_SHA256: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11718 | case WLAN_AKM_SUITE_FT_PSK: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11719 | hdd_notice("setting key mgmt type to PSK"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11720 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 11721 | break; |
| 11722 | |
| 11723 | case WLAN_AKM_SUITE_8021X_SHA256: |
| 11724 | case WLAN_AKM_SUITE_8021X: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11725 | case WLAN_AKM_SUITE_FT_8021X: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11726 | hdd_notice("setting key mgmt type to 8021x"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11727 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 11728 | break; |
| 11729 | #ifdef FEATURE_WLAN_ESE |
| 11730 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 11731 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 11732 | case WLAN_AKM_SUITE_CCKM: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11733 | hdd_notice("setting key mgmt type to CCKM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11734 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 11735 | break; |
| 11736 | #endif |
| 11737 | #ifndef WLAN_AKM_SUITE_OSEN |
| 11738 | #define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */ |
| 11739 | #endif |
| 11740 | case WLAN_AKM_SUITE_OSEN: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11741 | hdd_notice("setting key mgmt type to OSEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11742 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 11743 | break; |
| 11744 | |
| 11745 | default: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11746 | hdd_err("Unsupported key mgmt type %d", key_mgmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11747 | return -EINVAL; |
| 11748 | |
| 11749 | } |
| 11750 | return 0; |
| 11751 | } |
| 11752 | |
| 11753 | /** |
| 11754 | * wlan_hdd_cfg80211_set_cipher() - set encryption type |
| 11755 | * @pAdapter: Pointer to adapter |
| 11756 | * @cipher: Cipher type |
| 11757 | * @ucast: Unicast flag |
| 11758 | * |
| 11759 | * This function is used to set the encryption type |
| 11760 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 11761 | * |
| 11762 | * Return: 0 for success, non-zero for failure |
| 11763 | */ |
| 11764 | static int wlan_hdd_cfg80211_set_cipher(hdd_adapter_t *pAdapter, |
| 11765 | u32 cipher, bool ucast) |
| 11766 | { |
| 11767 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 11768 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11769 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11770 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11771 | if (!cipher) { |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 11772 | hdd_info("received cipher %d - considering none", cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11773 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 11774 | } else { |
| 11775 | |
| 11776 | /*set encryption method */ |
| 11777 | switch (cipher) { |
| 11778 | case IW_AUTH_CIPHER_NONE: |
| 11779 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 11780 | break; |
| 11781 | |
| 11782 | case WLAN_CIPHER_SUITE_WEP40: |
| 11783 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
| 11784 | break; |
| 11785 | |
| 11786 | case WLAN_CIPHER_SUITE_WEP104: |
| 11787 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
| 11788 | break; |
| 11789 | |
| 11790 | case WLAN_CIPHER_SUITE_TKIP: |
| 11791 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 11792 | break; |
| 11793 | |
| 11794 | case WLAN_CIPHER_SUITE_CCMP: |
| 11795 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 11796 | break; |
| 11797 | #ifdef FEATURE_WLAN_WAPI |
| 11798 | case WLAN_CIPHER_SUITE_SMS4: |
| 11799 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 11800 | break; |
| 11801 | #endif |
| 11802 | |
| 11803 | #ifdef FEATURE_WLAN_ESE |
| 11804 | case WLAN_CIPHER_SUITE_KRK: |
| 11805 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 11806 | break; |
| 11807 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 11808 | case WLAN_CIPHER_SUITE_BTK: |
| 11809 | encryptionType = eCSR_ENCRYPT_TYPE_BTK; |
| 11810 | break; |
| 11811 | #endif |
| 11812 | #endif |
| 11813 | default: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11814 | hdd_err("Unsupported cipher type %d", cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11815 | return -EOPNOTSUPP; |
| 11816 | } |
| 11817 | } |
| 11818 | |
| 11819 | if (ucast) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11820 | hdd_notice("setting unicast cipher type to %d", encryptionType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11821 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 11822 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 11823 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 11824 | encryptionType; |
| 11825 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11826 | hdd_notice("setting mcast cipher type to %d", encryptionType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11827 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 11828 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 11829 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 11830 | encryptionType; |
| 11831 | } |
| 11832 | |
| 11833 | return 0; |
| 11834 | } |
| 11835 | |
| 11836 | /** |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 11837 | * wlan_hdd_add_assoc_ie() - Add Assoc IE to roamProfile |
| 11838 | * @wext_state: Pointer to wext state |
| 11839 | * @gen_ie: Pointer to IE data |
| 11840 | * @len: length of IE data |
| 11841 | * |
| 11842 | * Return: 0 for success, non-zero for failure |
| 11843 | */ |
| 11844 | static int wlan_hdd_add_assoc_ie(hdd_wext_state_t *wext_state, |
| 11845 | const uint8_t *gen_ie, uint16_t len) |
| 11846 | { |
| 11847 | uint16_t cur_add_ie_len = |
| 11848 | wext_state->assocAddIE.length; |
| 11849 | |
| 11850 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 11851 | (wext_state->assocAddIE.length + len)) { |
| 11852 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
| 11853 | QDF_ASSERT(0); |
| 11854 | return -ENOMEM; |
| 11855 | } |
| 11856 | memcpy(wext_state->assocAddIE.addIEdata + |
| 11857 | cur_add_ie_len, gen_ie, len); |
| 11858 | wext_state->assocAddIE.length += len; |
| 11859 | |
| 11860 | wext_state->roamProfile.pAddIEAssoc = |
| 11861 | wext_state->assocAddIE.addIEdata; |
| 11862 | wext_state->roamProfile.nAddIEAssocLength = |
| 11863 | wext_state->assocAddIE.length; |
| 11864 | return 0; |
| 11865 | } |
| 11866 | |
| 11867 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11868 | * wlan_hdd_cfg80211_set_ie() - set IEs |
| 11869 | * @pAdapter: Pointer to adapter |
| 11870 | * @ie: Pointer ot ie |
| 11871 | * @ie: IE length |
| 11872 | * |
| 11873 | * Return: 0 for success, non-zero for failure |
| 11874 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 11875 | static int wlan_hdd_cfg80211_set_ie(hdd_adapter_t *pAdapter, const uint8_t *ie, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11876 | size_t ie_len) |
| 11877 | { |
| 11878 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11879 | const uint8_t *genie = ie; |
| 11880 | uint16_t remLen = ie_len; |
| 11881 | #ifdef FEATURE_WLAN_WAPI |
| 11882 | uint32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 11883 | u16 *tmp; |
| 11884 | uint16_t akmsuiteCount; |
| 11885 | int *akmlist; |
| 11886 | #endif |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 11887 | int status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11888 | |
| 11889 | /* clear previous assocAddIE */ |
| 11890 | pWextState->assocAddIE.length = 0; |
| 11891 | pWextState->roamProfile.bWPSAssociation = false; |
| 11892 | pWextState->roamProfile.bOSENAssociation = false; |
| 11893 | |
| 11894 | while (remLen >= 2) { |
| 11895 | uint16_t eLen = 0; |
| 11896 | uint8_t elementId; |
| 11897 | elementId = *genie++; |
| 11898 | eLen = *genie++; |
| 11899 | remLen -= 2; |
| 11900 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11901 | hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11902 | |
| 11903 | switch (elementId) { |
| 11904 | case DOT11F_EID_WPA: |
| 11905 | 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] | 11906 | hdd_err("Invalid WPA IE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11907 | return -EINVAL; |
| 11908 | } else if (0 == |
| 11909 | memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) { |
| 11910 | uint16_t curAddIELen = |
| 11911 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11912 | hdd_notice("Set WPS IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11913 | |
| 11914 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 11915 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11916 | hdd_err("Cannot accommodate assocAddIE. Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 11917 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11918 | return -ENOMEM; |
| 11919 | } |
| 11920 | /* WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE */ |
| 11921 | memcpy(pWextState->assocAddIE.addIEdata + |
| 11922 | curAddIELen, genie - 2, eLen + 2); |
| 11923 | pWextState->assocAddIE.length += eLen + 2; |
| 11924 | |
| 11925 | pWextState->roamProfile.bWPSAssociation = true; |
| 11926 | pWextState->roamProfile.pAddIEAssoc = |
| 11927 | pWextState->assocAddIE.addIEdata; |
| 11928 | pWextState->roamProfile.nAddIEAssocLength = |
| 11929 | pWextState->assocAddIE.length; |
| 11930 | } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11931 | hdd_notice("Set WPA IE (len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11932 | memset(pWextState->WPARSNIE, 0, |
| 11933 | MAX_WPA_RSN_IE_LEN); |
| 11934 | memcpy(pWextState->WPARSNIE, genie - 2, |
| 11935 | (eLen + 2)); |
| 11936 | pWextState->roamProfile.pWPAReqIE = |
| 11937 | pWextState->WPARSNIE; |
| 11938 | pWextState->roamProfile.nWPAReqIELength = eLen + 2; /* ie_len; */ |
| 11939 | } else if ((0 == memcmp(&genie[0], P2P_OUI_TYPE, |
| 11940 | P2P_OUI_TYPE_SIZE))) { |
| 11941 | uint16_t curAddIELen = |
| 11942 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11943 | hdd_notice("Set P2P IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11944 | |
| 11945 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 11946 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11947 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 11948 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11949 | return -ENOMEM; |
| 11950 | } |
| 11951 | /* P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE */ |
| 11952 | memcpy(pWextState->assocAddIE.addIEdata + |
| 11953 | curAddIELen, genie - 2, eLen + 2); |
| 11954 | pWextState->assocAddIE.length += eLen + 2; |
| 11955 | |
| 11956 | pWextState->roamProfile.pAddIEAssoc = |
| 11957 | pWextState->assocAddIE.addIEdata; |
| 11958 | pWextState->roamProfile.nAddIEAssocLength = |
| 11959 | pWextState->assocAddIE.length; |
| 11960 | } |
| 11961 | #ifdef WLAN_FEATURE_WFD |
| 11962 | else if ((0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 11963 | WFD_OUI_TYPE_SIZE)) && |
| 11964 | /* Consider WFD IE, only for P2P Client */ |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 11965 | (QDF_P2P_CLIENT_MODE == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11966 | pAdapter->device_mode)) { |
| 11967 | uint16_t curAddIELen = |
| 11968 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11969 | hdd_notice("Set WFD IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11970 | |
| 11971 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 11972 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11973 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 11974 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11975 | return -ENOMEM; |
| 11976 | } |
| 11977 | /* WFD IE is saved to Additional IE ; it should |
| 11978 | * be accumulated to handle WPS IE + P2P IE + |
| 11979 | * WFD IE */ |
| 11980 | memcpy(pWextState->assocAddIE.addIEdata + |
| 11981 | curAddIELen, genie - 2, eLen + 2); |
| 11982 | pWextState->assocAddIE.length += eLen + 2; |
| 11983 | |
| 11984 | pWextState->roamProfile.pAddIEAssoc = |
| 11985 | pWextState->assocAddIE.addIEdata; |
| 11986 | pWextState->roamProfile.nAddIEAssocLength = |
| 11987 | pWextState->assocAddIE.length; |
| 11988 | } |
| 11989 | #endif |
| 11990 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
| 11991 | else if ((0 == memcmp(&genie[0], HS20_OUI_TYPE, |
| 11992 | HS20_OUI_TYPE_SIZE))) { |
| 11993 | uint16_t curAddIELen = |
| 11994 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11995 | hdd_notice("Set HS20 IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11996 | |
| 11997 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 11998 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11999 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12000 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12001 | return -ENOMEM; |
| 12002 | } |
| 12003 | memcpy(pWextState->assocAddIE.addIEdata + |
| 12004 | curAddIELen, genie - 2, eLen + 2); |
| 12005 | pWextState->assocAddIE.length += eLen + 2; |
| 12006 | |
| 12007 | pWextState->roamProfile.pAddIEAssoc = |
| 12008 | pWextState->assocAddIE.addIEdata; |
| 12009 | pWextState->roamProfile.nAddIEAssocLength = |
| 12010 | pWextState->assocAddIE.length; |
| 12011 | } |
| 12012 | /* Appending OSEN Information Element in Assiciation Request */ |
| 12013 | else if ((0 == memcmp(&genie[0], OSEN_OUI_TYPE, |
| 12014 | OSEN_OUI_TYPE_SIZE))) { |
| 12015 | uint16_t curAddIELen = |
| 12016 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12017 | hdd_notice("Set OSEN IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12018 | |
| 12019 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 12020 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12021 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12022 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12023 | return -ENOMEM; |
| 12024 | } |
| 12025 | memcpy(pWextState->assocAddIE.addIEdata + |
| 12026 | curAddIELen, genie - 2, eLen + 2); |
| 12027 | pWextState->assocAddIE.length += eLen + 2; |
| 12028 | |
| 12029 | pWextState->roamProfile.bOSENAssociation = true; |
| 12030 | pWextState->roamProfile.pAddIEAssoc = |
| 12031 | pWextState->assocAddIE.addIEdata; |
| 12032 | pWextState->roamProfile.nAddIEAssocLength = |
| 12033 | pWextState->assocAddIE.length; |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 12034 | } else if ((0 == memcmp(&genie[0], MBO_OUI_TYPE, |
| 12035 | MBO_OUI_TYPE_SIZE))){ |
| 12036 | hdd_info("Set MBO IE(len %d)", eLen + 2); |
| 12037 | status = wlan_hdd_add_assoc_ie(pWextState, |
| 12038 | genie - 2, eLen + 2); |
| 12039 | if (status) |
| 12040 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12041 | } else { |
| 12042 | uint16_t add_ie_len = |
| 12043 | pWextState->assocAddIE.length; |
| 12044 | |
| 12045 | hdd_info("Set OSEN IE(len %d)", eLen + 2); |
| 12046 | |
| 12047 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 12048 | (pWextState->assocAddIE.length + eLen)) { |
| 12049 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12050 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12051 | return -ENOMEM; |
| 12052 | } |
| 12053 | |
| 12054 | memcpy(pWextState->assocAddIE.addIEdata + |
| 12055 | add_ie_len, genie - 2, eLen + 2); |
| 12056 | pWextState->assocAddIE.length += eLen + 2; |
| 12057 | |
| 12058 | pWextState->roamProfile.pAddIEAssoc = |
| 12059 | pWextState->assocAddIE.addIEdata; |
| 12060 | pWextState->roamProfile.nAddIEAssocLength = |
| 12061 | pWextState->assocAddIE.length; |
| 12062 | } |
| 12063 | break; |
| 12064 | case DOT11F_EID_RSN: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12065 | hdd_notice("Set RSN IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12066 | memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN); |
| 12067 | memcpy(pWextState->WPARSNIE, genie - 2, |
| 12068 | (eLen + 2)); |
| 12069 | pWextState->roamProfile.pRSNReqIE = |
| 12070 | pWextState->WPARSNIE; |
| 12071 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; /* ie_len; */ |
| 12072 | break; |
| 12073 | /* |
| 12074 | * Appending Extended Capabilities with Interworking bit set |
| 12075 | * in Assoc Req. |
| 12076 | * |
| 12077 | * In assoc req this EXT Cap will only be taken into account if |
| 12078 | * interworkingService bit is set to 1. Currently |
| 12079 | * driver is only interested in interworkingService capability |
| 12080 | * from supplicant. If in future any other EXT Cap info is |
| 12081 | * required from supplicat, it needs to be handled while |
| 12082 | * sending Assoc Req in LIM. |
| 12083 | */ |
| 12084 | case DOT11F_EID_EXTCAP: |
| 12085 | { |
| 12086 | uint16_t curAddIELen = |
| 12087 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12088 | hdd_notice("Set Extended CAPS IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12089 | |
| 12090 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 12091 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12092 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12093 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12094 | return -ENOMEM; |
| 12095 | } |
| 12096 | memcpy(pWextState->assocAddIE.addIEdata + |
| 12097 | curAddIELen, genie - 2, eLen + 2); |
| 12098 | pWextState->assocAddIE.length += eLen + 2; |
| 12099 | |
| 12100 | pWextState->roamProfile.pAddIEAssoc = |
| 12101 | pWextState->assocAddIE.addIEdata; |
| 12102 | pWextState->roamProfile.nAddIEAssocLength = |
| 12103 | pWextState->assocAddIE.length; |
| 12104 | break; |
| 12105 | } |
| 12106 | #ifdef FEATURE_WLAN_WAPI |
| 12107 | case WLAN_EID_WAPI: |
| 12108 | /* Setting WAPI Mode to ON=1 */ |
| 12109 | pAdapter->wapi_info.nWapiMode = 1; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12110 | hdd_notice("WAPI MODE IS %u", pAdapter->wapi_info.nWapiMode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12111 | tmp = (u16 *) ie; |
| 12112 | tmp = tmp + 2; /* Skip element Id and Len, Version */ |
| 12113 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 12114 | tmp = tmp + 1; |
| 12115 | akmlist = (int *)(tmp); |
| 12116 | if (akmsuiteCount <= MAX_NUM_AKM_SUITES) { |
| 12117 | memcpy(akmsuite, akmlist, (4 * akmsuiteCount)); |
| 12118 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12119 | hdd_err("Invalid akmSuite count"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12120 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12121 | return -EINVAL; |
| 12122 | } |
| 12123 | |
| 12124 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12125 | hdd_notice("WAPI AUTH MODE SET TO PSK"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12126 | pAdapter->wapi_info.wapiAuthMode = |
| 12127 | WAPI_AUTH_MODE_PSK; |
| 12128 | } |
| 12129 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12130 | hdd_notice("WAPI AUTH MODE SET TO CERTIFICATE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12131 | pAdapter->wapi_info.wapiAuthMode = |
| 12132 | WAPI_AUTH_MODE_CERT; |
| 12133 | } |
| 12134 | break; |
| 12135 | #endif |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 12136 | case DOT11F_EID_SUPPOPERATINGCLASSES: |
| 12137 | { |
| 12138 | hdd_info("Set Supported Operating Classes IE(len %d)", eLen + 2); |
| 12139 | status = wlan_hdd_add_assoc_ie(pWextState, |
| 12140 | genie - 2, eLen + 2); |
| 12141 | if (status) |
| 12142 | return status; |
| 12143 | break; |
| 12144 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12145 | default: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12146 | hdd_err("Set UNKNOWN IE %X", elementId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12147 | /* when Unknown IE is received we should break and continue |
| 12148 | * to the next IE in the buffer instead we were returning |
| 12149 | * so changing this to break */ |
| 12150 | break; |
| 12151 | } |
| 12152 | genie += eLen; |
| 12153 | remLen -= eLen; |
| 12154 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12155 | return 0; |
| 12156 | } |
| 12157 | |
| 12158 | /** |
| 12159 | * hdd_is_wpaie_present() - check for WPA ie |
| 12160 | * @ie: Pointer to ie |
| 12161 | * @ie_len: Ie length |
| 12162 | * |
| 12163 | * Parse the received IE to find the WPA IE |
| 12164 | * |
| 12165 | * Return: true if wpa ie is found else false |
| 12166 | */ |
| 12167 | static bool hdd_is_wpaie_present(const uint8_t *ie, uint8_t ie_len) |
| 12168 | { |
| 12169 | uint8_t eLen = 0; |
| 12170 | uint16_t remLen = ie_len; |
| 12171 | uint8_t elementId = 0; |
| 12172 | |
| 12173 | while (remLen >= 2) { |
| 12174 | elementId = *ie++; |
| 12175 | eLen = *ie++; |
| 12176 | remLen -= 2; |
| 12177 | if (eLen > remLen) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12178 | hdd_err("IE length is wrong %d", eLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12179 | return false; |
| 12180 | } |
| 12181 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) { |
| 12182 | /* OUI - 0x00 0X50 0XF2 |
| 12183 | * WPA Information Element - 0x01 |
| 12184 | * WPA version - 0x01 |
| 12185 | */ |
| 12186 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 12187 | return true; |
| 12188 | } |
| 12189 | ie += eLen; |
| 12190 | remLen -= eLen; |
| 12191 | } |
| 12192 | return false; |
| 12193 | } |
| 12194 | |
| 12195 | /** |
| 12196 | * wlan_hdd_cfg80211_set_privacy() - set security parameters during connection |
| 12197 | * @pAdapter: Pointer to adapter |
| 12198 | * @req: Pointer to security parameters |
| 12199 | * |
| 12200 | * Return: 0 for success, non-zero for failure |
| 12201 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 12202 | static int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter, |
| 12203 | struct cfg80211_connect_params *req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12204 | { |
| 12205 | int status = 0; |
| 12206 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 12207 | ENTER(); |
| 12208 | |
| 12209 | /*set wpa version */ |
| 12210 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 12211 | |
| 12212 | if (req->crypto.wpa_versions) { |
| 12213 | if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) { |
| 12214 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 12215 | } else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) { |
| 12216 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 12217 | } |
| 12218 | } |
| 12219 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12220 | hdd_notice("set wpa version to %d", pWextState->wpaVersion); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12221 | |
| 12222 | /*set authentication type */ |
| 12223 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 12224 | |
| 12225 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12226 | hdd_err("failed to set authentication type "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12227 | return status; |
| 12228 | } |
| 12229 | |
| 12230 | /*set key mgmt type */ |
| 12231 | if (req->crypto.n_akm_suites) { |
| 12232 | status = |
| 12233 | wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 12234 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12235 | hdd_err("failed to set akm suite"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12236 | return status; |
| 12237 | } |
| 12238 | } |
| 12239 | |
| 12240 | /*set pairwise cipher type */ |
| 12241 | if (req->crypto.n_ciphers_pairwise) { |
| 12242 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 12243 | req->crypto. |
| 12244 | ciphers_pairwise[0], |
| 12245 | true); |
| 12246 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12247 | hdd_err("failed to set unicast cipher type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12248 | return status; |
| 12249 | } |
| 12250 | } else { |
| 12251 | /*Reset previous cipher suite to none */ |
| 12252 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 12253 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12254 | hdd_err("failed to set unicast cipher type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12255 | return status; |
| 12256 | } |
| 12257 | } |
| 12258 | |
| 12259 | /*set group cipher type */ |
| 12260 | status = |
| 12261 | wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 12262 | false); |
| 12263 | |
| 12264 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12265 | hdd_err("failed to set mcast cipher type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12266 | return status; |
| 12267 | } |
| 12268 | #ifdef WLAN_FEATURE_11W |
| 12269 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 12270 | #endif |
| 12271 | |
| 12272 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile */ |
| 12273 | if (req->ie_len) { |
| 12274 | status = |
| 12275 | wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 12276 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12277 | hdd_err("failed to parse the WPA/RSN IE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12278 | return status; |
| 12279 | } |
| 12280 | } |
| 12281 | |
| 12282 | /*incase of WEP set default key information */ |
| 12283 | if (req->key && req->key_len) { |
| 12284 | if ((WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 12285 | || (WLAN_CIPHER_SUITE_WEP104 == |
| 12286 | req->crypto.ciphers_pairwise[0]) |
| 12287 | ) { |
| 12288 | if (IW_AUTH_KEY_MGMT_802_1X |
| 12289 | == |
| 12290 | (pWextState-> |
| 12291 | authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12292 | hdd_err("Dynamic WEP not supported"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12293 | return -EOPNOTSUPP; |
| 12294 | } else { |
| 12295 | u8 key_len = req->key_len; |
| 12296 | u8 key_idx = req->key_idx; |
| 12297 | |
| 12298 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= |
| 12299 | key_len) |
| 12300 | && (CSR_MAX_NUM_KEY > key_idx) |
| 12301 | ) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12302 | hdd_notice("setting default wep key, key_idx = %hu key_len %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12303 | key_idx, key_len); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 12304 | qdf_mem_copy(&pWextState->roamProfile. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12305 | Keys. |
| 12306 | KeyMaterial[key_idx][0], |
| 12307 | req->key, key_len); |
| 12308 | pWextState->roamProfile.Keys. |
| 12309 | KeyLength[key_idx] = (u8) key_len; |
| 12310 | pWextState->roamProfile.Keys. |
| 12311 | defaultIndex = (u8) key_idx; |
| 12312 | } |
| 12313 | } |
| 12314 | } |
| 12315 | } |
| 12316 | |
| 12317 | return status; |
| 12318 | } |
| 12319 | |
| 12320 | /** |
| 12321 | * wlan_hdd_try_disconnect() - try disconnnect from previous connection |
| 12322 | * @pAdapter: Pointer to adapter |
| 12323 | * |
| 12324 | * This function is used to disconnect from previous connection |
| 12325 | * |
| 12326 | * Return: 0 for success, non-zero for failure |
| 12327 | */ |
| 12328 | static int wlan_hdd_try_disconnect(hdd_adapter_t *pAdapter) |
| 12329 | { |
| 12330 | unsigned long rc; |
| 12331 | hdd_station_ctx_t *pHddStaCtx; |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12332 | int status, result = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12333 | |
| 12334 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12335 | |
Jeff Johnson | 9edf957 | 2016-10-03 15:24:49 -0700 | [diff] [blame] | 12336 | if ((QDF_IBSS_MODE == pAdapter->device_mode) || |
Abhishek Singh | 03f992e | 2016-01-07 18:07:06 +0530 | [diff] [blame] | 12337 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 12338 | (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) || |
| 12339 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12340 | hdd_conn_set_connection_state(pAdapter, |
| 12341 | eConnectionState_Disconnecting); |
| 12342 | /* Issue disconnect to CSR */ |
| 12343 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12344 | |
| 12345 | status = sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 12346 | pAdapter->sessionId, |
| 12347 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 12348 | /* |
| 12349 | * Wait here instead of returning directly, this will block the |
| 12350 | * next connect command and allow processing of the scan for |
| 12351 | * ssid and the previous connect command in CSR. Else we might |
| 12352 | * hit some race conditions leading to SME and HDD out of sync. |
| 12353 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12354 | if (QDF_STATUS_CMD_NOT_QUEUED == status) { |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12355 | hdd_info("Already disconnected or connect was in sme/roam pending list and removed by disconnect"); |
| 12356 | } else if (0 != status) { |
| 12357 | hdd_err("csrRoamDisconnect failure, returned %d", |
| 12358 | (int)status); |
| 12359 | pHddStaCtx->staDebugState = status; |
| 12360 | result = -EINVAL; |
| 12361 | goto disconnected; |
| 12362 | } |
| 12363 | |
| 12364 | rc = wait_for_completion_timeout( |
| 12365 | &pAdapter->disconnect_comp_var, |
| 12366 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12367 | if (!rc && (QDF_STATUS_CMD_NOT_QUEUED != status)) { |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12368 | hdd_err("Sme disconnect event timed out session Id %d staDebugState %d", |
| 12369 | pAdapter->sessionId, pHddStaCtx->staDebugState); |
| 12370 | result = -ETIMEDOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12371 | } |
| 12372 | } else if (eConnectionState_Disconnecting == |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12373 | pHddStaCtx->conn_info.connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12374 | rc = wait_for_completion_timeout(&pAdapter->disconnect_comp_var, |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12375 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12376 | if (!rc) { |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12377 | hdd_err("Disconnect event timed out session Id %d staDebugState %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12378 | pAdapter->sessionId, pHddStaCtx->staDebugState); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12379 | result = -ETIMEDOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12380 | } |
| 12381 | } |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12382 | disconnected: |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12383 | hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected); |
| 12384 | return result; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12385 | } |
| 12386 | |
| 12387 | /** |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12388 | * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present |
| 12389 | * @adapter: Pointer to the HDD adapter |
| 12390 | * @req: Pointer to the structure cfg_connect_params receieved from user space |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12391 | * @status: out variable for status of reassoc request |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12392 | * |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 12393 | * This function will start reassociation if prev_bssid is set and bssid/ |
| 12394 | * bssid_hint, channel/channel_hint parameters are present in connect request. |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12395 | * |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12396 | * Return: true if connect was for ReAssociation, false otherwise |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12397 | */ |
Selvaraj, Sridhar | a11edcb | 2016-09-07 18:49:14 +0530 | [diff] [blame] | 12398 | #if defined(CFG80211_CONNECT_PREV_BSSID) || \ |
| 12399 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12400 | static bool wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter, |
| 12401 | struct cfg80211_connect_params *req, |
| 12402 | int *status) |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12403 | { |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12404 | bool reassoc = false; |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 12405 | const uint8_t *bssid = NULL; |
| 12406 | uint16_t channel = 0; |
| 12407 | |
| 12408 | if (req->bssid) |
| 12409 | bssid = req->bssid; |
| 12410 | else if (req->bssid_hint) |
| 12411 | bssid = req->bssid_hint; |
| 12412 | |
| 12413 | if (req->channel) |
| 12414 | channel = req->channel->hw_value; |
| 12415 | else if (req->channel_hint) |
| 12416 | channel = req->channel_hint->hw_value; |
| 12417 | |
| 12418 | if (bssid && channel && req->prev_bssid) { |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12419 | reassoc = true; |
| 12420 | hdd_info(FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR), |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 12421 | channel, MAC_ADDR_ARRAY(bssid)); |
| 12422 | *status = hdd_reassoc(adapter, bssid, channel, |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12423 | CONNECT_CMD_USERSPACE); |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12424 | hdd_debug("hdd_reassoc: status: %d", *status); |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12425 | } |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12426 | return reassoc; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12427 | } |
| 12428 | #else |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12429 | static bool wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter, |
| 12430 | struct cfg80211_connect_params *req, |
| 12431 | int *status) |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12432 | { |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12433 | return false; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12434 | } |
| 12435 | #endif |
| 12436 | |
| 12437 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12438 | * __wlan_hdd_cfg80211_connect() - cfg80211 connect api |
| 12439 | * @wiphy: Pointer to wiphy |
| 12440 | * @dev: Pointer to network device |
| 12441 | * @req: Pointer to cfg80211 connect request |
| 12442 | * |
| 12443 | * This function is used to start the association process |
| 12444 | * |
| 12445 | * Return: 0 for success, non-zero for failure |
| 12446 | */ |
| 12447 | static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy, |
| 12448 | struct net_device *ndev, |
| 12449 | struct cfg80211_connect_params *req) |
| 12450 | { |
| 12451 | int status; |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 12452 | u16 channel; |
| 12453 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) |
| 12454 | const u8 *bssid_hint = req->bssid_hint; |
| 12455 | #else |
| 12456 | const u8 *bssid_hint = NULL; |
| 12457 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12458 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 12459 | hdd_context_t *pHddCtx; |
| 12460 | |
| 12461 | ENTER(); |
| 12462 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 12463 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12464 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12465 | return -EINVAL; |
| 12466 | } |
| 12467 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 12468 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 12469 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 12470 | return -EINVAL; |
| 12471 | } |
| 12472 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12473 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12474 | TRACE_CODE_HDD_CFG80211_CONNECT, |
| 12475 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12476 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12477 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 12478 | pAdapter->device_mode); |
| 12479 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 12480 | if (pAdapter->device_mode != QDF_STA_MODE && |
| 12481 | pAdapter->device_mode != QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12482 | hdd_err("Device_mode %s(%d) is not supported", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12483 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 12484 | pAdapter->device_mode); |
| 12485 | return -EINVAL; |
| 12486 | } |
| 12487 | |
| 12488 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12489 | if (!pHddCtx) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12490 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12491 | return -EINVAL; |
| 12492 | } |
| 12493 | |
| 12494 | status = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 12495 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12496 | return status; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12497 | |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12498 | if (true == wlan_hdd_reassoc_bssid_hint(pAdapter, req, &status)) |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12499 | return status; |
| 12500 | |
Agrawal Ashish | f156e94 | 2016-08-04 14:54:47 +0530 | [diff] [blame] | 12501 | wlan_hdd_disable_roaming(pAdapter); |
| 12502 | |
| 12503 | /* Try disconnecting if already in connected state */ |
| 12504 | status = wlan_hdd_try_disconnect(pAdapter); |
| 12505 | if (0 > status) { |
| 12506 | hdd_err("Failed to disconnect the existing connection"); |
| 12507 | return -EALREADY; |
| 12508 | } |
| 12509 | |
| 12510 | /* Check for max concurrent connections after doing disconnect if any */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12511 | if (req->channel) { |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 12512 | if (!cds_allow_concurrency( |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 12513 | cds_convert_device_mode_to_qdf_type( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12514 | pAdapter->device_mode), |
| 12515 | req->channel->hw_value, HW_MODE_20_MHZ)) { |
| 12516 | hdd_err("This concurrency combination is not allowed"); |
| 12517 | return -ECONNREFUSED; |
| 12518 | } |
| 12519 | } else { |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 12520 | if (!cds_allow_concurrency( |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 12521 | cds_convert_device_mode_to_qdf_type( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12522 | pAdapter->device_mode), 0, HW_MODE_20_MHZ)) { |
| 12523 | hdd_err("This concurrency combination is not allowed"); |
| 12524 | return -ECONNREFUSED; |
| 12525 | } |
| 12526 | } |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12527 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12528 | /*initialise security parameters */ |
| 12529 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
| 12530 | |
| 12531 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12532 | hdd_err("failed to set security params"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12533 | return status; |
| 12534 | } |
| 12535 | |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 12536 | if (req->channel) |
| 12537 | channel = req->channel->hw_value; |
| 12538 | else |
| 12539 | channel = 0; |
| 12540 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 12541 | req->ssid_len, req->bssid, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 12542 | bssid_hint, channel, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12543 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12544 | hdd_err("connect failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12545 | return status; |
| 12546 | } |
| 12547 | EXIT(); |
| 12548 | return status; |
| 12549 | } |
| 12550 | |
| 12551 | /** |
| 12552 | * wlan_hdd_cfg80211_connect() - cfg80211 connect api |
| 12553 | * @wiphy: Pointer to wiphy |
| 12554 | * @dev: Pointer to network device |
| 12555 | * @req: Pointer to cfg80211 connect request |
| 12556 | * |
| 12557 | * Return: 0 for success, non-zero for failure |
| 12558 | */ |
| 12559 | static int wlan_hdd_cfg80211_connect(struct wiphy *wiphy, |
| 12560 | struct net_device *ndev, |
| 12561 | struct cfg80211_connect_params *req) |
| 12562 | { |
| 12563 | int ret; |
| 12564 | cds_ssr_protect(__func__); |
| 12565 | ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req); |
| 12566 | cds_ssr_unprotect(__func__); |
| 12567 | |
| 12568 | return ret; |
| 12569 | } |
| 12570 | |
| 12571 | /** |
| 12572 | * wlan_hdd_disconnect() - hdd disconnect api |
| 12573 | * @pAdapter: Pointer to adapter |
| 12574 | * @reason: Disconnect reason code |
| 12575 | * |
| 12576 | * This function is used to issue a disconnect request to SME |
| 12577 | * |
| 12578 | * Return: 0 for success, non-zero for failure |
| 12579 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 12580 | static int wlan_hdd_disconnect(hdd_adapter_t *pAdapter, u16 reason) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12581 | { |
| 12582 | int status, result = 0; |
| 12583 | unsigned long rc; |
| 12584 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12585 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12586 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 12587 | ENTER(); |
| 12588 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12589 | status = wlan_hdd_validate_context(pHddCtx); |
| 12590 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 12591 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12592 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12593 | |
| 12594 | /*stop tx queues */ |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12595 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12596 | wlan_hdd_netif_queue_control(pAdapter, WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 12597 | WLAN_CONTROL_PATH); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12598 | hdd_notice("Set HDD connState to eConnectionState_Disconnecting"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12599 | pHddStaCtx->conn_info.connState = eConnectionState_Disconnecting; |
| 12600 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 12601 | |
| 12602 | /*issue disconnect */ |
| 12603 | |
| 12604 | status = sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 12605 | pAdapter->sessionId, reason); |
Abhishek Singh | acfdc92 | 2015-12-30 17:31:21 +0530 | [diff] [blame] | 12606 | /* |
| 12607 | * Wait here instead of returning directly, this will block the next |
| 12608 | * connect command and allow processing of the scan for ssid and |
| 12609 | * the previous connect command in CSR. Else we might hit some |
| 12610 | * race conditions leading to SME and HDD out of sync. |
| 12611 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12612 | if (QDF_STATUS_CMD_NOT_QUEUED == status) { |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12613 | hdd_info("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] | 12614 | } else if (0 != status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12615 | hdd_err("csr_roam_disconnect failure, returned %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12616 | (int)status); |
| 12617 | pHddStaCtx->staDebugState = status; |
| 12618 | result = -EINVAL; |
| 12619 | goto disconnected; |
| 12620 | } |
| 12621 | rc = wait_for_completion_timeout(&pAdapter->disconnect_comp_var, |
| 12622 | msecs_to_jiffies |
| 12623 | (WLAN_WAIT_TIME_DISCONNECT)); |
| 12624 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12625 | if (!rc && (QDF_STATUS_CMD_NOT_QUEUED != status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12626 | hdd_err("Failed to disconnect, timed out"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12627 | result = -ETIMEDOUT; |
| 12628 | } |
| 12629 | disconnected: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12630 | hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected); |
| 12631 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0) |
| 12632 | /* Sending disconnect event to userspace for kernel version < 3.11 |
| 12633 | * is handled by __cfg80211_disconnect call to __cfg80211_disconnected |
| 12634 | */ |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12635 | hdd_notice("Send disconnected event to userspace"); |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 12636 | wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true, |
| 12637 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12638 | #endif |
| 12639 | |
| 12640 | return result; |
| 12641 | } |
| 12642 | |
| 12643 | /** |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 12644 | * hdd_ieee80211_reason_code_to_str() - return string conversion of reason code |
| 12645 | * @reason: ieee80211 reason code. |
| 12646 | * |
| 12647 | * This utility function helps log string conversion of reason code. |
| 12648 | * |
| 12649 | * Return: string conversion of reason code, if match found; |
| 12650 | * "Unknown" otherwise. |
| 12651 | */ |
| 12652 | static const char *hdd_ieee80211_reason_code_to_str(uint16_t reason) |
| 12653 | { |
| 12654 | switch (reason) { |
| 12655 | CASE_RETURN_STRING(WLAN_REASON_UNSPECIFIED); |
| 12656 | CASE_RETURN_STRING(WLAN_REASON_PREV_AUTH_NOT_VALID); |
| 12657 | CASE_RETURN_STRING(WLAN_REASON_DEAUTH_LEAVING); |
| 12658 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY); |
| 12659 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_AP_BUSY); |
| 12660 | CASE_RETURN_STRING(WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA); |
| 12661 | CASE_RETURN_STRING(WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); |
| 12662 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_STA_HAS_LEFT); |
| 12663 | CASE_RETURN_STRING(WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH); |
| 12664 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_BAD_POWER); |
| 12665 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_BAD_SUPP_CHAN); |
| 12666 | CASE_RETURN_STRING(WLAN_REASON_INVALID_IE); |
| 12667 | CASE_RETURN_STRING(WLAN_REASON_MIC_FAILURE); |
| 12668 | CASE_RETURN_STRING(WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT); |
| 12669 | CASE_RETURN_STRING(WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT); |
| 12670 | CASE_RETURN_STRING(WLAN_REASON_IE_DIFFERENT); |
| 12671 | CASE_RETURN_STRING(WLAN_REASON_INVALID_GROUP_CIPHER); |
| 12672 | CASE_RETURN_STRING(WLAN_REASON_INVALID_PAIRWISE_CIPHER); |
| 12673 | CASE_RETURN_STRING(WLAN_REASON_INVALID_AKMP); |
| 12674 | CASE_RETURN_STRING(WLAN_REASON_UNSUPP_RSN_VERSION); |
| 12675 | CASE_RETURN_STRING(WLAN_REASON_INVALID_RSN_IE_CAP); |
| 12676 | CASE_RETURN_STRING(WLAN_REASON_IEEE8021X_FAILED); |
| 12677 | CASE_RETURN_STRING(WLAN_REASON_CIPHER_SUITE_REJECTED); |
| 12678 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_UNSPECIFIED_QOS); |
| 12679 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH); |
| 12680 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_LOW_ACK); |
| 12681 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP); |
| 12682 | CASE_RETURN_STRING(WLAN_REASON_QSTA_LEAVE_QBSS); |
| 12683 | CASE_RETURN_STRING(WLAN_REASON_QSTA_NOT_USE); |
| 12684 | CASE_RETURN_STRING(WLAN_REASON_QSTA_REQUIRE_SETUP); |
| 12685 | CASE_RETURN_STRING(WLAN_REASON_QSTA_TIMEOUT); |
| 12686 | CASE_RETURN_STRING(WLAN_REASON_QSTA_CIPHER_NOT_SUPP); |
| 12687 | CASE_RETURN_STRING(WLAN_REASON_MESH_PEER_CANCELED); |
| 12688 | CASE_RETURN_STRING(WLAN_REASON_MESH_MAX_PEERS); |
| 12689 | CASE_RETURN_STRING(WLAN_REASON_MESH_CONFIG); |
| 12690 | CASE_RETURN_STRING(WLAN_REASON_MESH_CLOSE); |
| 12691 | CASE_RETURN_STRING(WLAN_REASON_MESH_MAX_RETRIES); |
| 12692 | CASE_RETURN_STRING(WLAN_REASON_MESH_CONFIRM_TIMEOUT); |
| 12693 | CASE_RETURN_STRING(WLAN_REASON_MESH_INVALID_GTK); |
| 12694 | CASE_RETURN_STRING(WLAN_REASON_MESH_INCONSISTENT_PARAM); |
| 12695 | CASE_RETURN_STRING(WLAN_REASON_MESH_INVALID_SECURITY); |
| 12696 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_ERROR); |
| 12697 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_NOFORWARD); |
| 12698 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_DEST_UNREACHABLE); |
| 12699 | CASE_RETURN_STRING(WLAN_REASON_MAC_EXISTS_IN_MBSS); |
| 12700 | CASE_RETURN_STRING(WLAN_REASON_MESH_CHAN_REGULATORY); |
| 12701 | CASE_RETURN_STRING(WLAN_REASON_MESH_CHAN); |
| 12702 | default: |
| 12703 | return "Unknown"; |
| 12704 | } |
| 12705 | } |
| 12706 | |
| 12707 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12708 | * __wlan_hdd_cfg80211_disconnect() - cfg80211 disconnect api |
| 12709 | * @wiphy: Pointer to wiphy |
| 12710 | * @dev: Pointer to network device |
| 12711 | * @reason: Disconnect reason code |
| 12712 | * |
| 12713 | * This function is used to issue a disconnect request to SME |
| 12714 | * |
| 12715 | * Return: 0 for success, non-zero for failure |
| 12716 | */ |
| 12717 | static int __wlan_hdd_cfg80211_disconnect(struct wiphy *wiphy, |
| 12718 | struct net_device *dev, u16 reason) |
| 12719 | { |
| 12720 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 12721 | int status; |
| 12722 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12723 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12724 | #ifdef FEATURE_WLAN_TDLS |
| 12725 | uint8_t staIdx; |
| 12726 | #endif |
| 12727 | |
| 12728 | ENTER(); |
| 12729 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 12730 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12731 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12732 | return -EINVAL; |
| 12733 | } |
| 12734 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 12735 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 12736 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 12737 | return -EINVAL; |
| 12738 | } |
| 12739 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12740 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12741 | TRACE_CODE_HDD_CFG80211_DISCONNECT, |
| 12742 | pAdapter->sessionId, reason)); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12743 | hdd_notice("Device_mode %s(%d) reason code(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12744 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 12745 | pAdapter->device_mode, reason); |
| 12746 | |
| 12747 | status = wlan_hdd_validate_context(pHddCtx); |
| 12748 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 12749 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12750 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12751 | |
| 12752 | /* Issue disconnect request to SME, if station is in connected state */ |
| 12753 | if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) || |
| 12754 | (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)) { |
| 12755 | eCsrRoamDisconnectReason reasonCode = |
| 12756 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 12757 | hdd_scaninfo_t *pScanInfo; |
| 12758 | |
| 12759 | switch (reason) { |
| 12760 | case WLAN_REASON_MIC_FAILURE: |
| 12761 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 12762 | break; |
| 12763 | |
| 12764 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 12765 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 12766 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 12767 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 12768 | break; |
| 12769 | |
| 12770 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 12771 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 12772 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 12773 | break; |
| 12774 | |
| 12775 | case WLAN_REASON_DEAUTH_LEAVING: |
| 12776 | reasonCode = |
| 12777 | pHddCtx->config-> |
| 12778 | gEnableDeauthToDisassocMap ? |
| 12779 | eCSR_DISCONNECT_REASON_STA_HAS_LEFT : |
| 12780 | eCSR_DISCONNECT_REASON_DEAUTH; |
| 12781 | break; |
| 12782 | case WLAN_REASON_DISASSOC_STA_HAS_LEFT: |
| 12783 | reasonCode = eCSR_DISCONNECT_REASON_STA_HAS_LEFT; |
| 12784 | break; |
| 12785 | default: |
| 12786 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 12787 | break; |
| 12788 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12789 | hdd_notice("convert to internal reason %d to reasonCode %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12790 | reason, reasonCode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12791 | pScanInfo = &pAdapter->scan_info; |
| 12792 | if (pScanInfo->mScanPending) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12793 | hdd_notice("Disconnect is in progress, Aborting Scan"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12794 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId, |
| 12795 | eCSR_SCAN_ABORT_DEFAULT); |
| 12796 | } |
Edhar, Mahesh Kumar | 732f698 | 2016-07-01 11:23:06 +0530 | [diff] [blame] | 12797 | wlan_hdd_cleanup_remain_on_channel_ctx(pAdapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12798 | #ifdef FEATURE_WLAN_TDLS |
| 12799 | /* First clean up the tdls peers if any */ |
| 12800 | for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta; staIdx++) { |
| 12801 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == |
| 12802 | pAdapter->sessionId) |
| 12803 | && (pHddCtx->tdlsConnInfo[staIdx].staId)) { |
| 12804 | uint8_t *mac; |
| 12805 | mac = |
| 12806 | pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12807 | hdd_notice("call sme_delete_tdls_peer_sta staId %d sessionId %d " |
| 12808 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12809 | pHddCtx->tdlsConnInfo[staIdx].staId, |
| 12810 | pAdapter->sessionId, |
| 12811 | MAC_ADDR_ARRAY(mac)); |
| 12812 | sme_delete_tdls_peer_sta(WLAN_HDD_GET_HAL_CTX |
| 12813 | (pAdapter), |
| 12814 | pAdapter->sessionId, mac); |
| 12815 | } |
| 12816 | } |
| 12817 | #endif |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12818 | hdd_notice("Disconnecting with reasoncode:%u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12819 | reasonCode); |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 12820 | hdd_info("Disconnect request from user space with reason: %s", |
| 12821 | hdd_ieee80211_reason_code_to_str(reason)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12822 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 12823 | if (0 != status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12824 | hdd_err("failure, returned %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12825 | return -EINVAL; |
| 12826 | } |
| 12827 | } else { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12828 | hdd_err("unexpected cfg disconnect called while in state (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12829 | pHddStaCtx->conn_info.connState); |
| 12830 | } |
| 12831 | |
| 12832 | return status; |
| 12833 | } |
| 12834 | |
| 12835 | /** |
| 12836 | * wlan_hdd_cfg80211_disconnect() - cfg80211 disconnect api |
| 12837 | * @wiphy: Pointer to wiphy |
| 12838 | * @dev: Pointer to network device |
| 12839 | * @reason: Disconnect reason code |
| 12840 | * |
| 12841 | * Return: 0 for success, non-zero for failure |
| 12842 | */ |
| 12843 | static int wlan_hdd_cfg80211_disconnect(struct wiphy *wiphy, |
| 12844 | struct net_device *dev, u16 reason) |
| 12845 | { |
| 12846 | int ret; |
| 12847 | cds_ssr_protect(__func__); |
| 12848 | ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason); |
| 12849 | cds_ssr_unprotect(__func__); |
| 12850 | |
| 12851 | return ret; |
| 12852 | } |
| 12853 | |
| 12854 | /** |
| 12855 | * wlan_hdd_cfg80211_set_privacy_ibss() - set ibss privacy |
| 12856 | * @pAdapter: Pointer to adapter |
| 12857 | * @param: Pointer to IBSS parameters |
| 12858 | * |
| 12859 | * This function is used to initialize the security settings in IBSS mode |
| 12860 | * |
| 12861 | * Return: 0 for success, non-zero for failure |
| 12862 | */ |
| 12863 | static int wlan_hdd_cfg80211_set_privacy_ibss(hdd_adapter_t *pAdapter, |
| 12864 | struct cfg80211_ibss_params |
| 12865 | *params) |
| 12866 | { |
| 12867 | int status = 0; |
| 12868 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 12869 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 12870 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12871 | |
| 12872 | ENTER(); |
| 12873 | |
| 12874 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 12875 | qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12876 | pHddStaCtx->ibss_enc_key_installed = 0; |
| 12877 | |
| 12878 | if (params->ie_len && (NULL != params->ie)) { |
| 12879 | if (wlan_hdd_cfg80211_get_ie_ptr(params->ie, |
| 12880 | params->ie_len, WLAN_EID_RSN)) { |
| 12881 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 12882 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 12883 | } else if (hdd_is_wpaie_present(params->ie, params->ie_len)) { |
| 12884 | tDot11fIEWPA dot11WPAIE; |
| 12885 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 12886 | u8 *ie; |
| 12887 | |
| 12888 | memset(&dot11WPAIE, 0, sizeof(dot11WPAIE)); |
| 12889 | ie = wlan_hdd_cfg80211_get_ie_ptr(params->ie, |
| 12890 | params->ie_len, |
| 12891 | DOT11F_EID_WPA); |
| 12892 | if (NULL != ie) { |
| 12893 | pWextState->wpaVersion = |
| 12894 | IW_AUTH_WPA_VERSION_WPA; |
| 12895 | /* Unpack the WPA IE */ |
| 12896 | /* Skip past the EID byte and length byte - and four byte WiFi OUI */ |
| 12897 | dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle, |
| 12898 | &ie[2 + 4], |
| 12899 | ie[1] - 4, &dot11WPAIE); |
| 12900 | /*Extract the multicast cipher, the encType for unicast |
| 12901 | cipher for wpa-none is none */ |
| 12902 | encryptionType = |
| 12903 | hdd_translate_wpa_to_csr_encryption_type |
| 12904 | (dot11WPAIE.multicast_cipher); |
| 12905 | } |
| 12906 | } |
| 12907 | |
| 12908 | status = |
| 12909 | wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, |
| 12910 | params->ie_len); |
| 12911 | |
| 12912 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12913 | hdd_err("failed to parse WPA/RSN IE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12914 | return status; |
| 12915 | } |
| 12916 | } |
| 12917 | |
| 12918 | pWextState->roamProfile.AuthType.authType[0] = |
| 12919 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 12920 | |
| 12921 | if (params->privacy) { |
| 12922 | /* Security enabled IBSS, At this time there is no information |
| 12923 | * available about the security paramters, so initialise the |
| 12924 | * encryption type to eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
| 12925 | * The correct security parameters will be updated later in |
| 12926 | * wlan_hdd_cfg80211_add_key Hal expects encryption type to be |
| 12927 | * set inorder enable privacy bit in beacons |
| 12928 | */ |
| 12929 | |
| 12930 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 12931 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12932 | hdd_info("encryptionType=%d", encryptionType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12933 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 12934 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 12935 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 12936 | encryptionType; |
| 12937 | return status; |
| 12938 | } |
| 12939 | |
| 12940 | /** |
| 12941 | * __wlan_hdd_cfg80211_join_ibss() - join ibss |
| 12942 | * @wiphy: Pointer to wiphy |
| 12943 | * @dev: Pointer to network device |
| 12944 | * @param: Pointer to IBSS join parameters |
| 12945 | * |
| 12946 | * This function is used to create/join an IBSS network |
| 12947 | * |
| 12948 | * Return: 0 for success, non-zero for failure |
| 12949 | */ |
| 12950 | static int __wlan_hdd_cfg80211_join_ibss(struct wiphy *wiphy, |
| 12951 | struct net_device *dev, |
| 12952 | struct cfg80211_ibss_params *params) |
| 12953 | { |
| 12954 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 12955 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 12956 | tCsrRoamProfile *pRoamProfile; |
| 12957 | int status; |
| 12958 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12959 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 12960 | struct qdf_mac_addr bssid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12961 | u8 channelNum = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12962 | |
| 12963 | ENTER(); |
| 12964 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 12965 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12966 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12967 | return -EINVAL; |
| 12968 | } |
| 12969 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 12970 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 12971 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 12972 | return -EINVAL; |
| 12973 | } |
| 12974 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12975 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12976 | TRACE_CODE_HDD_CFG80211_JOIN_IBSS, |
| 12977 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12978 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12979 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 12980 | pAdapter->device_mode); |
| 12981 | |
| 12982 | status = wlan_hdd_validate_context(pHddCtx); |
| 12983 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 12984 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12985 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12986 | |
| 12987 | if (NULL != |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12988 | params->chandef.chan) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12989 | uint32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 12990 | uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 12991 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 12992 | int indx; |
| 12993 | |
| 12994 | /* Get channel number */ |
| 12995 | channelNum = ieee80211_frequency_to_channel( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12996 | params-> |
| 12997 | chandef. |
| 12998 | chan-> |
| 12999 | center_freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13000 | |
| 13001 | if (0 != sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 13002 | validChan, &numChans)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13003 | hdd_err("No valid channel list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13004 | return -EOPNOTSUPP; |
| 13005 | } |
| 13006 | |
| 13007 | for (indx = 0; indx < numChans; indx++) { |
| 13008 | if (channelNum == validChan[indx]) { |
| 13009 | break; |
| 13010 | } |
| 13011 | } |
| 13012 | if (indx >= numChans) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13013 | hdd_err("Not valid Channel %d", channelNum); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13014 | return -EINVAL; |
| 13015 | } |
| 13016 | } |
| 13017 | |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 13018 | if (!cds_allow_concurrency(CDS_IBSS_MODE, channelNum, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13019 | HW_MODE_20_MHZ)) { |
| 13020 | hdd_err("This concurrency combination is not allowed"); |
| 13021 | return -ECONNREFUSED; |
| 13022 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13023 | |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 13024 | status = qdf_reset_connection_update(); |
| 13025 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 13026 | hdd_err("ERR: clear event failed"); |
| 13027 | |
| 13028 | status = cds_current_connections_update(pAdapter->sessionId, |
| 13029 | channelNum, |
| 13030 | SIR_UPDATE_REASON_JOIN_IBSS); |
| 13031 | if (QDF_STATUS_E_FAILURE == status) { |
| 13032 | hdd_err("ERROR: connections update failed!!"); |
| 13033 | return -EINVAL; |
| 13034 | } |
| 13035 | |
| 13036 | if (QDF_STATUS_SUCCESS == status) { |
| 13037 | status = qdf_wait_for_connection_update(); |
| 13038 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13039 | hdd_err("ERROR: qdf wait for event failed!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13040 | return -EINVAL; |
| 13041 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13042 | } |
| 13043 | |
| 13044 | /*Try disconnecting if already in connected state */ |
| 13045 | status = wlan_hdd_try_disconnect(pAdapter); |
| 13046 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13047 | hdd_err("Failed to disconnect the existing IBSS connection"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13048 | return -EALREADY; |
| 13049 | } |
| 13050 | |
| 13051 | pRoamProfile = &pWextState->roamProfile; |
| 13052 | |
| 13053 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13054 | hdd_err("Interface type is not set to IBSS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13055 | return -EINVAL; |
| 13056 | } |
| 13057 | |
| 13058 | /* enable selected protection checks in IBSS mode */ |
| 13059 | pRoamProfile->cfg_protection = IBSS_CFG_PROTECTION_ENABLE_MASK; |
| 13060 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13061 | if (QDF_STATUS_E_FAILURE == sme_cfg_set_int(pHddCtx->hHal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13062 | WNI_CFG_IBSS_ATIM_WIN_SIZE, |
| 13063 | pHddCtx->config-> |
| 13064 | ibssATIMWinSize)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13065 | 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] | 13066 | } |
| 13067 | |
| 13068 | /* BSSID is provided by upper layers hence no need to AUTO generate */ |
| 13069 | if (NULL != params->bssid) { |
| 13070 | if (sme_cfg_set_int(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13071 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13072 | hdd_err("ccmCfgStInt failed for WNI_CFG_IBSS_AUTO_BSSID"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13073 | return -EIO; |
| 13074 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 13075 | qdf_mem_copy(bssid.bytes, params->bssid, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13076 | } else if (pHddCtx->config->isCoalesingInIBSSAllowed == 0) { |
| 13077 | if (sme_cfg_set_int(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13078 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13079 | hdd_err("ccmCfgStInt failed for WNI_CFG_IBSS_AUTO_BSSID"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13080 | return -EIO; |
| 13081 | } |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 13082 | qdf_copy_macaddr(&bssid, &pHddCtx->config->IbssBssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13083 | } |
| 13084 | if ((params->beacon_interval > CFG_BEACON_INTERVAL_MIN) |
| 13085 | && (params->beacon_interval <= CFG_BEACON_INTERVAL_MAX)) |
| 13086 | pRoamProfile->beaconInterval = params->beacon_interval; |
| 13087 | else { |
| 13088 | pRoamProfile->beaconInterval = CFG_BEACON_INTERVAL_DEFAULT; |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13089 | hdd_info("input beacon interval %d TU is invalid, use default %d TU", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13090 | params->beacon_interval, pRoamProfile->beaconInterval); |
| 13091 | } |
| 13092 | |
| 13093 | /* Set Channel */ |
| 13094 | if (channelNum) { |
| 13095 | /* Set the Operational Channel */ |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13096 | hdd_info("set channel %d", channelNum); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13097 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 13098 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 13099 | pRoamProfile->ChannelInfo.ChannelList = |
| 13100 | &pHddStaCtx->conn_info.operationChannel; |
| 13101 | } |
| 13102 | |
| 13103 | /* Initialize security parameters */ |
| 13104 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
| 13105 | if (status < 0) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13106 | hdd_err("failed to set security parameters"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13107 | return status; |
| 13108 | } |
| 13109 | |
| 13110 | /* Issue connect start */ |
| 13111 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
| 13112 | params->ssid_len, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 13113 | bssid.bytes, NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13114 | pHddStaCtx->conn_info. |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 13115 | operationChannel, |
| 13116 | params->chandef.width); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13117 | |
| 13118 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13119 | hdd_err("connect failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13120 | return status; |
| 13121 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13122 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13123 | return 0; |
| 13124 | } |
| 13125 | |
| 13126 | /** |
| 13127 | * wlan_hdd_cfg80211_join_ibss() - join ibss |
| 13128 | * @wiphy: Pointer to wiphy |
| 13129 | * @dev: Pointer to network device |
| 13130 | * @param: Pointer to IBSS join parameters |
| 13131 | * |
| 13132 | * This function is used to create/join an IBSS network |
| 13133 | * |
| 13134 | * Return: 0 for success, non-zero for failure |
| 13135 | */ |
| 13136 | static int wlan_hdd_cfg80211_join_ibss(struct wiphy *wiphy, |
| 13137 | struct net_device *dev, |
| 13138 | struct cfg80211_ibss_params *params) |
| 13139 | { |
| 13140 | int ret = 0; |
| 13141 | |
| 13142 | cds_ssr_protect(__func__); |
| 13143 | ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params); |
| 13144 | cds_ssr_unprotect(__func__); |
| 13145 | |
| 13146 | return ret; |
| 13147 | } |
| 13148 | |
| 13149 | /** |
| 13150 | * __wlan_hdd_cfg80211_leave_ibss() - leave ibss |
| 13151 | * @wiphy: Pointer to wiphy |
| 13152 | * @dev: Pointer to network device |
| 13153 | * |
| 13154 | * This function is used to leave an IBSS network |
| 13155 | * |
| 13156 | * Return: 0 for success, non-zero for failure |
| 13157 | */ |
| 13158 | static int __wlan_hdd_cfg80211_leave_ibss(struct wiphy *wiphy, |
| 13159 | struct net_device *dev) |
| 13160 | { |
| 13161 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13162 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 13163 | tCsrRoamProfile *pRoamProfile; |
| 13164 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13165 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13166 | QDF_STATUS hal_status; |
Chandrasekaran, Manishekar | 12a818a | 2015-12-18 11:44:56 +0530 | [diff] [blame] | 13167 | unsigned long rc; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 13168 | tSirUpdateIE updateIE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13169 | |
| 13170 | ENTER(); |
| 13171 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13172 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13173 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13174 | return -EINVAL; |
| 13175 | } |
| 13176 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13177 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13178 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 13179 | return -EINVAL; |
| 13180 | } |
| 13181 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13182 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13183 | TRACE_CODE_HDD_CFG80211_LEAVE_IBSS, |
| 13184 | pAdapter->sessionId, |
| 13185 | eCSR_DISCONNECT_REASON_IBSS_LEAVE)); |
| 13186 | status = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13187 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13188 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13189 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13190 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13191 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 13192 | pAdapter->device_mode); |
| 13193 | if (NULL == pWextState) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13194 | hdd_err("Data Storage Corruption"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13195 | return -EIO; |
| 13196 | } |
| 13197 | |
| 13198 | pRoamProfile = &pWextState->roamProfile; |
| 13199 | |
| 13200 | /* Issue disconnect only if interface type is set to IBSS */ |
| 13201 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13202 | hdd_err("BSS Type is not set to IBSS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13203 | return -EINVAL; |
| 13204 | } |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 13205 | /* Clearing add IE of beacon */ |
| 13206 | qdf_mem_copy(updateIE.bssid.bytes, pAdapter->macAddressCurrent.bytes, |
| 13207 | sizeof(tSirMacAddr)); |
| 13208 | updateIE.smeSessionId = pAdapter->sessionId; |
| 13209 | updateIE.ieBufferlength = 0; |
| 13210 | updateIE.pAdditionIEBuffer = NULL; |
| 13211 | updateIE.append = true; |
| 13212 | updateIE.notify = true; |
| 13213 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 13214 | &updateIE, |
| 13215 | eUPDATE_IE_PROBE_BCN) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13216 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 13217 | } |
| 13218 | |
| 13219 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 13220 | wlan_hdd_reset_prob_rspies(pAdapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13221 | |
| 13222 | /* Issue Disconnect request */ |
| 13223 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 13224 | hal_status = sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 13225 | pAdapter->sessionId, |
| 13226 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13227 | if (!QDF_IS_STATUS_SUCCESS(hal_status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13228 | hdd_err("sme_roam_disconnect failed hal_status(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13229 | hal_status); |
| 13230 | return -EAGAIN; |
| 13231 | } |
Chandrasekaran, Manishekar | 12a818a | 2015-12-18 11:44:56 +0530 | [diff] [blame] | 13232 | |
| 13233 | /* wait for mc thread to cleanup and then return to upper stack |
| 13234 | * so by the time upper layer calls the change interface, we are |
| 13235 | * all set to proceed further |
| 13236 | */ |
| 13237 | rc = wait_for_completion_timeout(&pAdapter->disconnect_comp_var, |
| 13238 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 13239 | if (!rc) { |
| 13240 | hdd_err("Failed to disconnect, timed out"); |
| 13241 | return -ETIMEDOUT; |
| 13242 | } |
| 13243 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13244 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13245 | return 0; |
| 13246 | } |
| 13247 | |
| 13248 | /** |
| 13249 | * wlan_hdd_cfg80211_leave_ibss() - leave ibss |
| 13250 | * @wiphy: Pointer to wiphy |
| 13251 | * @dev: Pointer to network device |
| 13252 | * |
| 13253 | * This function is used to leave an IBSS network |
| 13254 | * |
| 13255 | * Return: 0 for success, non-zero for failure |
| 13256 | */ |
| 13257 | static int wlan_hdd_cfg80211_leave_ibss(struct wiphy *wiphy, |
| 13258 | struct net_device *dev) |
| 13259 | { |
| 13260 | int ret = 0; |
| 13261 | |
| 13262 | cds_ssr_protect(__func__); |
| 13263 | ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev); |
| 13264 | cds_ssr_unprotect(__func__); |
| 13265 | |
| 13266 | return ret; |
| 13267 | } |
| 13268 | |
| 13269 | /** |
| 13270 | * __wlan_hdd_cfg80211_set_wiphy_params() - set wiphy parameters |
| 13271 | * @wiphy: Pointer to wiphy |
| 13272 | * @changed: Parameters changed |
| 13273 | * |
| 13274 | * This function is used to set the phy parameters. RTS Threshold/FRAG |
| 13275 | * Threshold/Retry Count etc. |
| 13276 | * |
| 13277 | * Return: 0 for success, non-zero for failure |
| 13278 | */ |
| 13279 | static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
| 13280 | u32 changed) |
| 13281 | { |
| 13282 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 13283 | tHalHandle hHal = pHddCtx->hHal; |
| 13284 | int status; |
| 13285 | |
| 13286 | ENTER(); |
| 13287 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13288 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13289 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13290 | return -EINVAL; |
| 13291 | } |
| 13292 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13293 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13294 | TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS, |
| 13295 | NO_SESSION, wiphy->rts_threshold)); |
| 13296 | status = wlan_hdd_validate_context(pHddCtx); |
| 13297 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13298 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13299 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13300 | |
| 13301 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
| 13302 | u32 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 13303 | WNI_CFG_RTS_THRESHOLD_STAMAX : wiphy->rts_threshold; |
| 13304 | |
| 13305 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
| 13306 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13307 | hdd_err("Invalid RTS Threshold value %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13308 | rts_threshold); |
| 13309 | return -EINVAL; |
| 13310 | } |
| 13311 | |
| 13312 | if (0 != sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, |
| 13313 | rts_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13314 | hdd_err("sme_cfg_set_int failed for rts_threshold value %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13315 | rts_threshold); |
| 13316 | return -EIO; |
| 13317 | } |
| 13318 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13319 | hdd_info("set rts threshold %u", rts_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13320 | } |
| 13321 | |
| 13322 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
| 13323 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 13324 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 13325 | wiphy->frag_threshold; |
| 13326 | |
| 13327 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold) || |
| 13328 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13329 | hdd_err("Invalid frag_threshold value %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13330 | frag_threshold); |
| 13331 | return -EINVAL; |
| 13332 | } |
| 13333 | |
| 13334 | if (0 != sme_cfg_set_int(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 13335 | frag_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13336 | hdd_err("sme_cfg_set_int failed for frag_threshold value %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13337 | frag_threshold); |
| 13338 | return -EIO; |
| 13339 | } |
| 13340 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13341 | hdd_info("set frag threshold %hu", frag_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13342 | } |
| 13343 | |
| 13344 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 13345 | || (changed & WIPHY_PARAM_RETRY_LONG)) { |
| 13346 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 13347 | wiphy->retry_short : wiphy->retry_long; |
| 13348 | |
| 13349 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 13350 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13351 | hdd_err("Invalid Retry count %hu", retry_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13352 | return -EINVAL; |
| 13353 | } |
| 13354 | |
| 13355 | if (changed & WIPHY_PARAM_RETRY_SHORT) { |
| 13356 | if (0 != sme_cfg_set_int(hHal, |
| 13357 | WNI_CFG_LONG_RETRY_LIMIT, |
| 13358 | retry_value)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13359 | hdd_err("sme_cfg_set_int failed for long retry count %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13360 | retry_value); |
| 13361 | return -EIO; |
| 13362 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13363 | hdd_info("set long retry count %hu", retry_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13364 | } else if (changed & WIPHY_PARAM_RETRY_SHORT) { |
| 13365 | if (0 != sme_cfg_set_int(hHal, |
| 13366 | WNI_CFG_SHORT_RETRY_LIMIT, |
| 13367 | retry_value)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13368 | hdd_err("sme_cfg_set_int failed for short retry count %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13369 | retry_value); |
| 13370 | return -EIO; |
| 13371 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13372 | hdd_info("set short retry count %hu", retry_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13373 | } |
| 13374 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13375 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13376 | return 0; |
| 13377 | } |
| 13378 | |
| 13379 | /** |
| 13380 | * wlan_hdd_cfg80211_set_wiphy_params() - set wiphy parameters |
| 13381 | * @wiphy: Pointer to wiphy |
| 13382 | * @changed: Parameters changed |
| 13383 | * |
| 13384 | * Return: 0 for success, non-zero for failure |
| 13385 | */ |
| 13386 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 13387 | { |
| 13388 | int ret; |
| 13389 | |
| 13390 | cds_ssr_protect(__func__); |
| 13391 | ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed); |
| 13392 | cds_ssr_unprotect(__func__); |
| 13393 | |
| 13394 | return ret; |
| 13395 | } |
| 13396 | |
| 13397 | /** |
| 13398 | * __wlan_hdd_set_default_mgmt_key() - dummy implementation of set default mgmt |
| 13399 | * key |
| 13400 | * @wiphy: Pointer to wiphy |
| 13401 | * @dev: Pointer to network device |
| 13402 | * @key_index: Key index |
| 13403 | * |
| 13404 | * Return: 0 |
| 13405 | */ |
| 13406 | static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 13407 | struct net_device *netdev, |
| 13408 | u8 key_index) |
| 13409 | { |
| 13410 | ENTER(); |
| 13411 | return 0; |
| 13412 | } |
| 13413 | |
| 13414 | /** |
| 13415 | * wlan_hdd_set_default_mgmt_key() - SSR wrapper for |
| 13416 | * wlan_hdd_set_default_mgmt_key |
| 13417 | * @wiphy: pointer to wiphy |
| 13418 | * @netdev: pointer to net_device structure |
| 13419 | * @key_index: key index |
| 13420 | * |
| 13421 | * Return: 0 on success, error number on failure |
| 13422 | */ |
| 13423 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 13424 | struct net_device *netdev, |
| 13425 | u8 key_index) |
| 13426 | { |
| 13427 | int ret; |
| 13428 | |
| 13429 | cds_ssr_protect(__func__); |
| 13430 | ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index); |
| 13431 | cds_ssr_unprotect(__func__); |
| 13432 | |
| 13433 | return ret; |
| 13434 | } |
| 13435 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13436 | /** |
| 13437 | * __wlan_hdd_set_txq_params() - dummy implementation of set tx queue params |
| 13438 | * @wiphy: Pointer to wiphy |
| 13439 | * @dev: Pointer to network device |
| 13440 | * @params: Pointer to tx queue parameters |
| 13441 | * |
| 13442 | * Return: 0 |
| 13443 | */ |
| 13444 | static int __wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 13445 | struct net_device *dev, |
| 13446 | struct ieee80211_txq_params *params) |
| 13447 | { |
| 13448 | ENTER(); |
| 13449 | return 0; |
| 13450 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13451 | |
| 13452 | /** |
| 13453 | * wlan_hdd_set_txq_params() - SSR wrapper for wlan_hdd_set_txq_params |
| 13454 | * @wiphy: pointer to wiphy |
| 13455 | * @netdev: pointer to net_device structure |
| 13456 | * @params: pointer to ieee80211_txq_params |
| 13457 | * |
| 13458 | * Return: 0 on success, error number on failure |
| 13459 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13460 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 13461 | struct net_device *dev, |
| 13462 | struct ieee80211_txq_params *params) |
| 13463 | { |
| 13464 | int ret; |
| 13465 | |
| 13466 | cds_ssr_protect(__func__); |
| 13467 | ret = __wlan_hdd_set_txq_params(wiphy, dev, params); |
| 13468 | cds_ssr_unprotect(__func__); |
| 13469 | |
| 13470 | return ret; |
| 13471 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13472 | |
| 13473 | /** |
| 13474 | * __wlan_hdd_cfg80211_del_station() - delete station v2 |
| 13475 | * @wiphy: Pointer to wiphy |
| 13476 | * @param: Pointer to delete station parameter |
| 13477 | * |
| 13478 | * Return: 0 for success, non-zero for failure |
| 13479 | */ |
| 13480 | static |
| 13481 | int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 13482 | struct net_device *dev, |
| 13483 | struct tagCsrDelStaParams *pDelStaParams) |
| 13484 | { |
| 13485 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13486 | hdd_context_t *pHddCtx; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 13487 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13488 | hdd_hostapd_state_t *hapd_state; |
| 13489 | int status; |
| 13490 | uint8_t staId; |
| 13491 | uint8_t *mac; |
| 13492 | |
| 13493 | ENTER(); |
| 13494 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13495 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13496 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13497 | return -EINVAL; |
| 13498 | } |
| 13499 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13500 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13501 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 13502 | return -EINVAL; |
| 13503 | } |
| 13504 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13505 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13506 | TRACE_CODE_HDD_CFG80211_DEL_STA, |
| 13507 | pAdapter->sessionId, pAdapter->device_mode)); |
| 13508 | |
| 13509 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13510 | status = wlan_hdd_validate_context(pHddCtx); |
| 13511 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13512 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13513 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13514 | |
| 13515 | mac = (uint8_t *) pDelStaParams->peerMacAddr.bytes; |
| 13516 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 13517 | if ((QDF_SAP_MODE == pAdapter->device_mode) || |
| 13518 | (QDF_P2P_GO_MODE == pAdapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13519 | |
| 13520 | hapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 13521 | if (!hapd_state) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13522 | hdd_err("Hostapd State is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13523 | return 0; |
| 13524 | } |
| 13525 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 13526 | if (qdf_is_macaddr_broadcast((struct qdf_mac_addr *) mac)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13527 | uint16_t i; |
| 13528 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
| 13529 | if ((pAdapter->aStaInfo[i].isUsed) && |
| 13530 | (!pAdapter->aStaInfo[i]. |
| 13531 | isDeauthInProgress)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 13532 | qdf_mem_copy( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13533 | mac, |
| 13534 | pAdapter->aStaInfo[i]. |
| 13535 | macAddrSTA.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13536 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13537 | if (hdd_ipa_uc_is_enabled(pHddCtx)) { |
| 13538 | hdd_ipa_wlan_evt(pAdapter, |
| 13539 | pAdapter-> |
| 13540 | aStaInfo[i]. |
| 13541 | ucSTAId, |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 13542 | HDD_IPA_CLIENT_DISCONNECT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13543 | mac); |
| 13544 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13545 | hdd_notice("Delete STA with MAC::" |
| 13546 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13547 | MAC_ADDR_ARRAY(mac)); |
| 13548 | |
| 13549 | if (pHddCtx->dev_dfs_cac_status == |
| 13550 | DFS_CAC_IN_PROGRESS) |
| 13551 | goto fn_end; |
| 13552 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 13553 | qdf_event_reset(&hapd_state->qdf_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13554 | hdd_softap_sta_disassoc(pAdapter, |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 13555 | pDelStaParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13556 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13557 | hdd_softap_sta_deauth(pAdapter, |
| 13558 | pDelStaParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13559 | if (QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13560 | pAdapter->aStaInfo[i]. |
| 13561 | isDeauthInProgress = true; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 13562 | qdf_status = |
| 13563 | qdf_wait_single_event( |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 13564 | &hapd_state->qdf_event, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13565 | 1000); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 13566 | if (!QDF_IS_STATUS_SUCCESS( |
| 13567 | qdf_status)) |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13568 | hdd_err("Deauth wait time expired"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13569 | } |
| 13570 | } |
| 13571 | } |
| 13572 | } else { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13573 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13574 | hdd_softap_get_sta_id(pAdapter, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13575 | (struct qdf_mac_addr *) mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13576 | &staId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13577 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13578 | hdd_notice("Skip DEL STA as this is not used::" |
| 13579 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13580 | MAC_ADDR_ARRAY(mac)); |
| 13581 | return -ENOENT; |
| 13582 | } |
| 13583 | |
| 13584 | if (hdd_ipa_uc_is_enabled(pHddCtx)) { |
| 13585 | hdd_ipa_wlan_evt(pAdapter, staId, |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 13586 | HDD_IPA_CLIENT_DISCONNECT, mac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13587 | } |
| 13588 | |
| 13589 | if (pAdapter->aStaInfo[staId].isDeauthInProgress == |
| 13590 | true) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13591 | hdd_notice("Skip DEL STA as deauth is in progress::" |
| 13592 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13593 | MAC_ADDR_ARRAY(mac)); |
| 13594 | return -ENOENT; |
| 13595 | } |
| 13596 | |
| 13597 | pAdapter->aStaInfo[staId].isDeauthInProgress = true; |
| 13598 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13599 | hdd_notice("Delete STA with MAC::" MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13600 | MAC_ADDR_ARRAY(mac)); |
| 13601 | |
| 13602 | /* Case: SAP in ACS selected DFS ch and client connected |
| 13603 | * Now Radar detected. Then if random channel is another |
| 13604 | * DFS ch then new CAC is initiated and no TX allowed. |
| 13605 | * So do not send any mgmt frames as it will timeout |
| 13606 | * during CAC. |
| 13607 | */ |
| 13608 | |
| 13609 | if (pHddCtx->dev_dfs_cac_status == DFS_CAC_IN_PROGRESS) |
| 13610 | goto fn_end; |
| 13611 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 13612 | qdf_event_reset(&hapd_state->qdf_event); |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 13613 | sme_send_disassoc_req_frame(WLAN_HDD_GET_HAL_CTX |
| 13614 | (pAdapter), pAdapter->sessionId, |
| 13615 | (uint8_t *)&pDelStaParams->peerMacAddr, |
| 13616 | pDelStaParams->reason_code, 0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13617 | qdf_status = hdd_softap_sta_deauth(pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13618 | pDelStaParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13619 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13620 | pAdapter->aStaInfo[staId].isDeauthInProgress = |
| 13621 | false; |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13622 | hdd_notice("STA removal failed for ::" |
| 13623 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13624 | MAC_ADDR_ARRAY(mac)); |
| 13625 | return -ENOENT; |
| 13626 | } else { |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 13627 | qdf_status = qdf_wait_single_event( |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 13628 | &hapd_state->qdf_event, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13629 | 1000); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 13630 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13631 | hdd_err("Deauth wait time expired"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13632 | } |
| 13633 | } |
| 13634 | } |
| 13635 | |
| 13636 | fn_end: |
| 13637 | EXIT(); |
| 13638 | return 0; |
| 13639 | } |
| 13640 | |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 13641 | #if defined(USE_CFG80211_DEL_STA_V2) |
| 13642 | /** |
| 13643 | * wlan_hdd_del_station() - delete station wrapper |
| 13644 | * @adapter: pointer to the hdd adapter |
| 13645 | * |
| 13646 | * Return: None |
| 13647 | */ |
| 13648 | void wlan_hdd_del_station(hdd_adapter_t *adapter) |
| 13649 | { |
| 13650 | struct station_del_parameters del_sta; |
| 13651 | del_sta.mac = NULL; |
| 13652 | del_sta.subtype = SIR_MAC_MGMT_DEAUTH >> 4; |
| 13653 | del_sta.reason_code = eCsrForcedDeauthSta; |
| 13654 | |
| 13655 | wlan_hdd_cfg80211_del_station(adapter->wdev.wiphy, adapter->dev, |
| 13656 | &del_sta); |
| 13657 | } |
| 13658 | #else |
| 13659 | void wlan_hdd_del_station(hdd_adapter_t *adapter) |
| 13660 | { |
| 13661 | wlan_hdd_cfg80211_del_station(adapter->wdev.wiphy, adapter->dev, NULL); |
| 13662 | } |
| 13663 | #endif |
| 13664 | |
| 13665 | #if defined(USE_CFG80211_DEL_STA_V2) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13666 | /** |
| 13667 | * wlan_hdd_cfg80211_del_station() - delete station v2 |
| 13668 | * @wiphy: Pointer to wiphy |
| 13669 | * @param: Pointer to delete station parameter |
| 13670 | * |
| 13671 | * Return: 0 for success, non-zero for failure |
| 13672 | */ |
| 13673 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 13674 | struct net_device *dev, |
| 13675 | struct station_del_parameters *param) |
| 13676 | #else |
| 13677 | /** |
| 13678 | * wlan_hdd_cfg80211_del_station() - delete station |
| 13679 | * @wiphy: Pointer to wiphy |
| 13680 | * @mac: Pointer to station mac address |
| 13681 | * |
| 13682 | * Return: 0 for success, non-zero for failure |
| 13683 | */ |
| 13684 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 13685 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 13686 | struct net_device *dev, |
| 13687 | const uint8_t *mac) |
| 13688 | #else |
| 13689 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 13690 | struct net_device *dev, |
| 13691 | uint8_t *mac) |
| 13692 | #endif |
| 13693 | #endif |
| 13694 | { |
| 13695 | int ret; |
| 13696 | struct tagCsrDelStaParams delStaParams; |
| 13697 | |
| 13698 | cds_ssr_protect(__func__); |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 13699 | #if defined(USE_CFG80211_DEL_STA_V2) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13700 | if (NULL == param) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 13701 | hdd_err("Invalid argument passed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13702 | return -EINVAL; |
| 13703 | } |
| 13704 | wlansap_populate_del_sta_params(param->mac, param->reason_code, |
| 13705 | param->subtype, &delStaParams); |
| 13706 | #else |
| 13707 | wlansap_populate_del_sta_params(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, |
| 13708 | (SIR_MAC_MGMT_DEAUTH >> 4), |
| 13709 | &delStaParams); |
| 13710 | #endif |
| 13711 | ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams); |
| 13712 | cds_ssr_unprotect(__func__); |
| 13713 | |
| 13714 | return ret; |
| 13715 | } |
| 13716 | |
| 13717 | /** |
| 13718 | * __wlan_hdd_cfg80211_add_station() - add station |
| 13719 | * @wiphy: Pointer to wiphy |
| 13720 | * @mac: Pointer to station mac address |
| 13721 | * @pmksa: Pointer to add station parameter |
| 13722 | * |
| 13723 | * Return: 0 for success, non-zero for failure |
| 13724 | */ |
| 13725 | static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 13726 | struct net_device *dev, |
| 13727 | const uint8_t *mac, |
| 13728 | struct station_parameters *params) |
| 13729 | { |
| 13730 | int status = -EPERM; |
| 13731 | #ifdef FEATURE_WLAN_TDLS |
| 13732 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13733 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 13734 | u32 mask, set; |
| 13735 | |
| 13736 | ENTER(); |
| 13737 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13738 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13739 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13740 | return -EINVAL; |
| 13741 | } |
| 13742 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13743 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13744 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 13745 | return -EINVAL; |
| 13746 | } |
| 13747 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13748 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13749 | TRACE_CODE_HDD_CFG80211_ADD_STA, |
| 13750 | pAdapter->sessionId, params->listen_interval)); |
| 13751 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13752 | if (0 != wlan_hdd_validate_context(pHddCtx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13753 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13754 | |
| 13755 | mask = params->sta_flags_mask; |
| 13756 | |
| 13757 | set = params->sta_flags_set; |
| 13758 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13759 | hdd_notice("mask 0x%x set 0x%x " MAC_ADDRESS_STR, mask, set, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13760 | MAC_ADDR_ARRAY(mac)); |
| 13761 | |
| 13762 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 13763 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 13764 | status = |
| 13765 | wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
| 13766 | } |
| 13767 | } |
| 13768 | #endif |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13769 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13770 | return status; |
| 13771 | } |
| 13772 | |
| 13773 | /** |
| 13774 | * wlan_hdd_cfg80211_add_station() - add station |
| 13775 | * @wiphy: Pointer to wiphy |
| 13776 | * @mac: Pointer to station mac address |
| 13777 | * @pmksa: Pointer to add station parameter |
| 13778 | * |
| 13779 | * Return: 0 for success, non-zero for failure |
| 13780 | */ |
| 13781 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 13782 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 13783 | struct net_device *dev, |
| 13784 | const uint8_t *mac, |
| 13785 | struct station_parameters *params) |
| 13786 | #else |
| 13787 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 13788 | struct net_device *dev, uint8_t *mac, |
| 13789 | struct station_parameters *params) |
| 13790 | #endif |
| 13791 | { |
| 13792 | int ret; |
| 13793 | |
| 13794 | cds_ssr_protect(__func__); |
| 13795 | ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params); |
| 13796 | cds_ssr_unprotect(__func__); |
| 13797 | |
| 13798 | return ret; |
| 13799 | } |
| 13800 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13801 | /** |
| 13802 | * __wlan_hdd_cfg80211_set_pmksa() - set pmksa |
| 13803 | * @wiphy: Pointer to wiphy |
| 13804 | * @dev: Pointer to network device |
| 13805 | * @pmksa: Pointer to set pmksa parameter |
| 13806 | * |
| 13807 | * Return: 0 for success, non-zero for failure |
| 13808 | */ |
| 13809 | static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, |
| 13810 | struct net_device *dev, |
| 13811 | struct cfg80211_pmksa *pmksa) |
| 13812 | { |
| 13813 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13814 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13815 | tHalHandle halHandle; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13816 | QDF_STATUS result = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13817 | int status; |
| 13818 | tPmkidCacheInfo pmk_id; |
| 13819 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13820 | ENTER(); |
| 13821 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13822 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13823 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13824 | return -EINVAL; |
| 13825 | } |
| 13826 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13827 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13828 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 13829 | return -EINVAL; |
| 13830 | } |
| 13831 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13832 | if (!pmksa) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13833 | hdd_err("pmksa is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13834 | return -EINVAL; |
| 13835 | } |
| 13836 | |
| 13837 | if (!pmksa->bssid || !pmksa->pmkid) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13838 | hdd_err("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13839 | pmksa->bssid, pmksa->pmkid); |
| 13840 | return -EINVAL; |
| 13841 | } |
| 13842 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13843 | hdd_warn("set PMKSA for " MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13844 | MAC_ADDR_ARRAY(pmksa->bssid)); |
| 13845 | |
| 13846 | status = wlan_hdd_validate_context(pHddCtx); |
| 13847 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13848 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13849 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13850 | |
| 13851 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 13852 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 13853 | qdf_mem_copy(pmk_id.BSSID.bytes, pmksa->bssid, QDF_MAC_ADDR_SIZE); |
| 13854 | qdf_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13855 | |
| 13856 | /* Add to the PMKSA ID Cache in CSR */ |
| 13857 | result = sme_roam_set_pmkid_cache(halHandle, pAdapter->sessionId, |
| 13858 | &pmk_id, 1, false); |
| 13859 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13860 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13861 | TRACE_CODE_HDD_CFG80211_SET_PMKSA, |
| 13862 | pAdapter->sessionId, result)); |
| 13863 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13864 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13865 | return QDF_IS_STATUS_SUCCESS(result) ? 0 : -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13866 | } |
| 13867 | |
| 13868 | /** |
| 13869 | * wlan_hdd_cfg80211_set_pmksa() - set pmksa |
| 13870 | * @wiphy: Pointer to wiphy |
| 13871 | * @dev: Pointer to network device |
| 13872 | * @pmksa: Pointer to set pmksa parameter |
| 13873 | * |
| 13874 | * Return: 0 for success, non-zero for failure |
| 13875 | */ |
| 13876 | static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, |
| 13877 | struct net_device *dev, |
| 13878 | struct cfg80211_pmksa *pmksa) |
| 13879 | { |
| 13880 | int ret; |
| 13881 | |
| 13882 | cds_ssr_protect(__func__); |
| 13883 | ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa); |
| 13884 | cds_ssr_unprotect(__func__); |
| 13885 | |
| 13886 | return ret; |
| 13887 | } |
| 13888 | |
| 13889 | /** |
| 13890 | * __wlan_hdd_cfg80211_del_pmksa() - delete pmksa |
| 13891 | * @wiphy: Pointer to wiphy |
| 13892 | * @dev: Pointer to network device |
| 13893 | * @pmksa: Pointer to pmksa parameter |
| 13894 | * |
| 13895 | * Return: 0 for success, non-zero for failure |
| 13896 | */ |
| 13897 | static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, |
| 13898 | struct net_device *dev, |
| 13899 | struct cfg80211_pmksa *pmksa) |
| 13900 | { |
| 13901 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13902 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13903 | tHalHandle halHandle; |
| 13904 | int status = 0; |
| 13905 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13906 | ENTER(); |
| 13907 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13908 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13909 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13910 | return -EINVAL; |
| 13911 | } |
| 13912 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13913 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13914 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 13915 | return -EINVAL; |
| 13916 | } |
| 13917 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13918 | if (!pmksa) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13919 | hdd_err("pmksa is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13920 | return -EINVAL; |
| 13921 | } |
| 13922 | |
| 13923 | if (!pmksa->bssid) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13924 | hdd_err("pmksa->bssid is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13925 | return -EINVAL; |
| 13926 | } |
| 13927 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13928 | hdd_debug("Deleting PMKSA for " MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13929 | MAC_ADDR_ARRAY(pmksa->bssid)); |
| 13930 | |
| 13931 | status = wlan_hdd_validate_context(pHddCtx); |
| 13932 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13933 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13934 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13935 | |
| 13936 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 13937 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13938 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 13939 | TRACE_CODE_HDD_CFG80211_DEL_PMKSA, |
| 13940 | pAdapter->sessionId, 0)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13941 | /* Delete the PMKID CSR cache */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13942 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13943 | sme_roam_del_pmkid_from_cache(halHandle, |
| 13944 | pAdapter->sessionId, pmksa->bssid, |
| 13945 | false)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13946 | hdd_err("Failed to delete PMKSA for " MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13947 | MAC_ADDR_ARRAY(pmksa->bssid)); |
| 13948 | status = -EINVAL; |
| 13949 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13950 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13951 | return status; |
| 13952 | } |
| 13953 | |
| 13954 | /** |
| 13955 | * wlan_hdd_cfg80211_del_pmksa() - delete pmksa |
| 13956 | * @wiphy: Pointer to wiphy |
| 13957 | * @dev: Pointer to network device |
| 13958 | * @pmksa: Pointer to pmksa parameter |
| 13959 | * |
| 13960 | * Return: 0 for success, non-zero for failure |
| 13961 | */ |
| 13962 | static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, |
| 13963 | struct net_device *dev, |
| 13964 | struct cfg80211_pmksa *pmksa) |
| 13965 | { |
| 13966 | int ret; |
| 13967 | |
| 13968 | cds_ssr_protect(__func__); |
| 13969 | ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa); |
| 13970 | cds_ssr_unprotect(__func__); |
| 13971 | |
| 13972 | return ret; |
| 13973 | |
| 13974 | } |
| 13975 | |
| 13976 | /** |
| 13977 | * __wlan_hdd_cfg80211_flush_pmksa() - flush pmksa |
| 13978 | * @wiphy: Pointer to wiphy |
| 13979 | * @dev: Pointer to network device |
| 13980 | * |
| 13981 | * Return: 0 for success, non-zero for failure |
| 13982 | */ |
| 13983 | static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, |
| 13984 | struct net_device *dev) |
| 13985 | { |
| 13986 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13987 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13988 | tHalHandle halHandle; |
| 13989 | int status = 0; |
| 13990 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13991 | ENTER(); |
| 13992 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13993 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13994 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13995 | return -EINVAL; |
| 13996 | } |
| 13997 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13998 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13999 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 14000 | return -EINVAL; |
| 14001 | } |
| 14002 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14003 | hdd_warn("Flushing PMKSA"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14004 | |
| 14005 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 14006 | status = wlan_hdd_validate_context(pHddCtx); |
| 14007 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14008 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14009 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14010 | |
| 14011 | /* Retrieve halHandle */ |
| 14012 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 14013 | |
| 14014 | /* Flush the PMKID cache in CSR */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14015 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14016 | sme_roam_del_pmkid_from_cache(halHandle, pAdapter->sessionId, NULL, |
| 14017 | true)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14018 | hdd_err("Cannot flush PMKIDCache"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14019 | status = -EINVAL; |
| 14020 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14021 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14022 | return status; |
| 14023 | } |
| 14024 | |
| 14025 | /** |
| 14026 | * wlan_hdd_cfg80211_flush_pmksa() - flush pmksa |
| 14027 | * @wiphy: Pointer to wiphy |
| 14028 | * @dev: Pointer to network device |
| 14029 | * |
| 14030 | * Return: 0 for success, non-zero for failure |
| 14031 | */ |
| 14032 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, |
| 14033 | struct net_device *dev) |
| 14034 | { |
| 14035 | int ret; |
| 14036 | |
| 14037 | cds_ssr_protect(__func__); |
| 14038 | ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev); |
| 14039 | cds_ssr_unprotect(__func__); |
| 14040 | |
| 14041 | return ret; |
| 14042 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14043 | |
Deepak Dhamdhere | 9f09e75 | 2016-01-09 23:17:25 -0800 | [diff] [blame] | 14044 | #if defined(KERNEL_SUPPORT_11R_CFG80211) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14045 | /** |
| 14046 | * __wlan_hdd_cfg80211_update_ft_ies() - update fast transition ies |
| 14047 | * @wiphy: Pointer to wiphy |
| 14048 | * @dev: Pointer to network device |
| 14049 | * @ftie: Pointer to fast transition ie parameter |
| 14050 | * |
| 14051 | * Return: 0 for success, non-zero for failure |
| 14052 | */ |
| 14053 | static int |
| 14054 | __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 14055 | struct net_device *dev, |
| 14056 | struct cfg80211_update_ft_ies_params *ftie) |
| 14057 | { |
| 14058 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 14059 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14060 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 14061 | int status; |
| 14062 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14063 | ENTER(); |
| 14064 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14065 | status = wlan_hdd_validate_context(hdd_ctx); |
| 14066 | if (status) |
| 14067 | return status; |
| 14068 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14069 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14070 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14071 | return -EINVAL; |
| 14072 | } |
| 14073 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14074 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 14075 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 14076 | return -EINVAL; |
| 14077 | } |
| 14078 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 14079 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14080 | TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES, |
| 14081 | pAdapter->sessionId, pHddStaCtx->conn_info.connState)); |
| 14082 | /* Added for debug on reception of Re-assoc Req. */ |
| 14083 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14084 | hdd_err("Called with Ie of length = %zu when not associated", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14085 | ftie->ie_len); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14086 | hdd_err("Should be Re-assoc Req IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14087 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14088 | hdd_notice("%s called with Ie of length = %zu", __func__, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14089 | ftie->ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14090 | |
| 14091 | /* Pass the received FT IEs to SME */ |
| 14092 | sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 14093 | (const u8 *)ftie->ie, ftie->ie_len); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14094 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14095 | return 0; |
| 14096 | } |
| 14097 | |
| 14098 | /** |
| 14099 | * wlan_hdd_cfg80211_update_ft_ies() - update fast transition ies |
| 14100 | * @wiphy: Pointer to wiphy |
| 14101 | * @dev: Pointer to network device |
| 14102 | * @ftie: Pointer to fast transition ie parameter |
| 14103 | * |
| 14104 | * Return: 0 for success, non-zero for failure |
| 14105 | */ |
| 14106 | static int |
| 14107 | wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 14108 | struct net_device *dev, |
| 14109 | struct cfg80211_update_ft_ies_params *ftie) |
| 14110 | { |
| 14111 | int ret; |
| 14112 | |
| 14113 | cds_ssr_protect(__func__); |
| 14114 | ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie); |
| 14115 | cds_ssr_unprotect(__func__); |
| 14116 | |
| 14117 | return ret; |
| 14118 | } |
| 14119 | #endif |
| 14120 | |
| 14121 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 14122 | /** |
| 14123 | * wlan_hdd_cfg80211_update_replay_counter_callback() - replay counter callback |
| 14124 | * @callbackContext: Callback context |
| 14125 | * @pGtkOffloadGetInfoRsp: Pointer to gtk offload response parameter |
| 14126 | * |
| 14127 | * Callback rountine called upon receiving response for get offload info |
| 14128 | * |
| 14129 | * Return: none |
| 14130 | */ |
| 14131 | void wlan_hdd_cfg80211_update_replay_counter_callback(void *callbackContext, |
| 14132 | tpSirGtkOffloadGetInfoRspParams |
| 14133 | pGtkOffloadGetInfoRsp) |
| 14134 | { |
| 14135 | hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext; |
| 14136 | uint8_t tempReplayCounter[8]; |
| 14137 | hdd_station_ctx_t *pHddStaCtx; |
| 14138 | |
| 14139 | ENTER(); |
| 14140 | |
| 14141 | if (NULL == pAdapter) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14142 | hdd_err("HDD adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14143 | return; |
| 14144 | } |
| 14145 | |
| 14146 | if (NULL == pGtkOffloadGetInfoRsp) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14147 | hdd_err("pGtkOffloadGetInfoRsp is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14148 | return; |
| 14149 | } |
| 14150 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14151 | if (QDF_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14152 | hdd_err("wlan Failed to get replay counter value"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14153 | return; |
| 14154 | } |
| 14155 | |
| 14156 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 14157 | /* Update replay counter */ |
| 14158 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 14159 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 14160 | |
| 14161 | { |
| 14162 | /* changing from little to big endian since supplicant |
| 14163 | * works on big endian format |
| 14164 | */ |
| 14165 | int i; |
| 14166 | uint8_t *p = |
| 14167 | (uint8_t *) &pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 14168 | |
| 14169 | for (i = 0; i < 8; i++) { |
| 14170 | tempReplayCounter[7 - i] = (uint8_t) p[i]; |
| 14171 | } |
| 14172 | } |
| 14173 | |
| 14174 | /* Update replay counter to NL */ |
Srinivas Girigowda | 2213b1d | 2015-11-20 17:10:11 -0800 | [diff] [blame] | 14175 | cfg80211_gtk_rekey_notify(pAdapter->dev, |
| 14176 | pGtkOffloadGetInfoRsp->bssid.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14177 | tempReplayCounter, GFP_KERNEL); |
| 14178 | } |
| 14179 | |
| 14180 | /** |
| 14181 | * __wlan_hdd_cfg80211_set_rekey_data() - set rekey data |
| 14182 | * @wiphy: Pointer to wiphy |
| 14183 | * @dev: Pointer to network device |
| 14184 | * @data: Pointer to rekey data |
| 14185 | * |
| 14186 | * This function is used to offload GTK rekeying job to the firmware. |
| 14187 | * |
| 14188 | * Return: 0 for success, non-zero for failure |
| 14189 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 14190 | static |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14191 | int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, |
| 14192 | struct net_device *dev, |
| 14193 | struct cfg80211_gtk_rekey_data *data) |
| 14194 | { |
| 14195 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14196 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 14197 | hdd_station_ctx_t *pHddStaCtx; |
| 14198 | tHalHandle hHal; |
| 14199 | int result; |
| 14200 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14201 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14202 | |
| 14203 | ENTER(); |
| 14204 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14205 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14206 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14207 | return -EINVAL; |
| 14208 | } |
| 14209 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14210 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 14211 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 14212 | return -EINVAL; |
| 14213 | } |
| 14214 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 14215 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14216 | TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA, |
| 14217 | pAdapter->sessionId, pAdapter->device_mode)); |
| 14218 | |
| 14219 | result = wlan_hdd_validate_context(pHddCtx); |
| 14220 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14221 | if (0 != result) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14222 | return result; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14223 | |
| 14224 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 14225 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 14226 | if (NULL == hHal) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14227 | hdd_err("HAL context is Null!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14228 | return -EAGAIN; |
| 14229 | } |
| 14230 | |
| 14231 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 14232 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, |
| 14233 | NL80211_KCK_LEN); |
| 14234 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, |
| 14235 | NL80211_KEK_LEN); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 14236 | qdf_copy_macaddr(&pHddStaCtx->gtkOffloadReqParams.bssid, |
Srinivas Girigowda | 2213b1d | 2015-11-20 17:10:11 -0800 | [diff] [blame] | 14237 | &pHddStaCtx->conn_info.bssId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14238 | { |
| 14239 | /* changing from big to little endian since driver |
| 14240 | * works on little endian format |
| 14241 | */ |
| 14242 | uint8_t *p = |
| 14243 | (uint8_t *) &pHddStaCtx->gtkOffloadReqParams. |
| 14244 | ullKeyReplayCounter; |
| 14245 | int i; |
| 14246 | |
| 14247 | for (i = 0; i < 8; i++) { |
| 14248 | p[7 - i] = data->replay_ctr[i]; |
| 14249 | } |
| 14250 | } |
| 14251 | |
| 14252 | if (true == pHddCtx->hdd_wlan_suspended) { |
| 14253 | /* if wlan is suspended, enable GTK offload directly from here */ |
| 14254 | memcpy(&hddGtkOffloadReqParams, |
| 14255 | &pHddStaCtx->gtkOffloadReqParams, |
| 14256 | sizeof(tSirGtkOffloadParams)); |
| 14257 | status = |
| 14258 | sme_set_gtk_offload(hHal, &hddGtkOffloadReqParams, |
| 14259 | pAdapter->sessionId); |
| 14260 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14261 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14262 | hdd_err("sme_set_gtk_offload failed, status(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14263 | status); |
| 14264 | return -EINVAL; |
| 14265 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14266 | hdd_notice("sme_set_gtk_offload successful"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14267 | } else { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14268 | hdd_notice("wlan not suspended GTKOffload request is stored"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14269 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14270 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14271 | return result; |
| 14272 | } |
| 14273 | |
| 14274 | /** |
| 14275 | * wlan_hdd_cfg80211_set_rekey_data() - set rekey data |
| 14276 | * @wiphy: Pointer to wiphy |
| 14277 | * @dev: Pointer to network device |
| 14278 | * @data: Pointer to rekey data |
| 14279 | * |
| 14280 | * This function is used to offload GTK rekeying job to the firmware. |
| 14281 | * |
| 14282 | * Return: 0 for success, non-zero for failure |
| 14283 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 14284 | static |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14285 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, |
| 14286 | struct net_device *dev, |
| 14287 | struct cfg80211_gtk_rekey_data *data) |
| 14288 | { |
| 14289 | int ret; |
| 14290 | |
| 14291 | cds_ssr_protect(__func__); |
| 14292 | ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data); |
| 14293 | cds_ssr_unprotect(__func__); |
| 14294 | |
| 14295 | return ret; |
| 14296 | } |
| 14297 | #endif /*WLAN_FEATURE_GTK_OFFLOAD */ |
| 14298 | |
| 14299 | /** |
| 14300 | * __wlan_hdd_cfg80211_set_mac_acl() - set access control policy |
| 14301 | * @wiphy: Pointer to wiphy |
| 14302 | * @dev: Pointer to network device |
| 14303 | * @param: Pointer to access control parameter |
| 14304 | * |
| 14305 | * Return: 0 for success, non-zero for failure |
| 14306 | */ |
| 14307 | static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 14308 | struct net_device *dev, |
| 14309 | const struct cfg80211_acl_data *params) |
| 14310 | { |
| 14311 | int i; |
| 14312 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14313 | hdd_hostapd_state_t *pHostapdState; |
| 14314 | tsap_Config_t *pConfig; |
| 14315 | v_CONTEXT_t p_cds_context = NULL; |
| 14316 | hdd_context_t *pHddCtx; |
| 14317 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14318 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14319 | |
| 14320 | ENTER(); |
| 14321 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14322 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14323 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14324 | return -EINVAL; |
| 14325 | } |
| 14326 | |
| 14327 | if (NULL == params) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14328 | hdd_err("params is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14329 | return -EINVAL; |
| 14330 | } |
| 14331 | |
| 14332 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 14333 | status = wlan_hdd_validate_context(pHddCtx); |
| 14334 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14335 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14336 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14337 | |
| 14338 | p_cds_context = pHddCtx->pcds_context; |
| 14339 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 14340 | |
| 14341 | if (NULL == pHostapdState) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14342 | hdd_err("pHostapdState is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14343 | return -EINVAL; |
| 14344 | } |
| 14345 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14346 | hdd_err("acl policy: = %d no acl entries = %d", params->acl_policy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14347 | params->n_acl_entries); |
| 14348 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 14349 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 14350 | TRACE_CODE_HDD_CFG80211_SET_MAC_ACL, |
| 14351 | pAdapter->sessionId, pAdapter->device_mode)); |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 14352 | if (QDF_SAP_MODE == pAdapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14353 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 14354 | |
| 14355 | /* default value */ |
| 14356 | pConfig->num_accept_mac = 0; |
| 14357 | pConfig->num_deny_mac = 0; |
| 14358 | |
| 14359 | /** |
| 14360 | * access control policy |
| 14361 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 14362 | * listed in hostapd.deny file. |
| 14363 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 14364 | * listed in hostapd.accept file. |
| 14365 | */ |
| 14366 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) { |
| 14367 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 14368 | } else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == |
| 14369 | params->acl_policy) { |
| 14370 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 14371 | } else { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14372 | hdd_err("Acl Policy : %d is not supported", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14373 | params->acl_policy); |
| 14374 | return -ENOTSUPP; |
| 14375 | } |
| 14376 | |
| 14377 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) { |
| 14378 | pConfig->num_accept_mac = params->n_acl_entries; |
| 14379 | for (i = 0; i < params->n_acl_entries; i++) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14380 | hdd_notice("** Add ACL MAC entry %i in WhiletList :" |
| 14381 | MAC_ADDRESS_STR, i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14382 | MAC_ADDR_ARRAY( |
| 14383 | params->mac_addrs[i].addr)); |
| 14384 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14385 | qdf_mem_copy(&pConfig->accept_mac[i], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14386 | params->mac_addrs[i].addr, |
| 14387 | sizeof(qcmacaddr)); |
| 14388 | } |
| 14389 | } else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) { |
| 14390 | pConfig->num_deny_mac = params->n_acl_entries; |
| 14391 | for (i = 0; i < params->n_acl_entries; i++) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14392 | hdd_notice("** Add ACL MAC entry %i in BlackList :" |
| 14393 | MAC_ADDRESS_STR, i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14394 | MAC_ADDR_ARRAY( |
| 14395 | params->mac_addrs[i].addr)); |
| 14396 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14397 | qdf_mem_copy(&pConfig->deny_mac[i], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14398 | params->mac_addrs[i].addr, |
| 14399 | sizeof(qcmacaddr)); |
| 14400 | } |
| 14401 | } |
Dustin Brown | 6ba30a1 | 2016-09-13 13:59:43 -0700 | [diff] [blame] | 14402 | qdf_status = wlansap_set_mac_acl( |
| 14403 | WLAN_HDD_GET_SAP_CTX_PTR(pAdapter), pConfig); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14404 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14405 | hdd_err("SAP Set Mac Acl fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14406 | return -EINVAL; |
| 14407 | } |
| 14408 | } else { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14409 | hdd_notice("Invalid device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14410 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 14411 | pAdapter->device_mode); |
| 14412 | return -EINVAL; |
| 14413 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14414 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14415 | return 0; |
| 14416 | } |
| 14417 | |
| 14418 | /** |
| 14419 | * wlan_hdd_cfg80211_set_mac_acl() - SSR wrapper for |
| 14420 | * __wlan_hdd_cfg80211_set_mac_acl |
| 14421 | * @wiphy: pointer to wiphy structure |
| 14422 | * @dev: pointer to net_device |
| 14423 | * @params: pointer to cfg80211_acl_data |
| 14424 | * |
| 14425 | * Return; 0 on success, error number otherwise |
| 14426 | */ |
| 14427 | static int |
| 14428 | wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 14429 | struct net_device *dev, |
| 14430 | const struct cfg80211_acl_data *params) |
| 14431 | { |
| 14432 | int ret; |
| 14433 | |
| 14434 | cds_ssr_protect(__func__); |
| 14435 | ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params); |
| 14436 | cds_ssr_unprotect(__func__); |
| 14437 | |
| 14438 | return ret; |
| 14439 | } |
| 14440 | |
| 14441 | #ifdef WLAN_NL80211_TESTMODE |
| 14442 | #ifdef FEATURE_WLAN_LPHB |
| 14443 | /** |
| 14444 | * wlan_hdd_cfg80211_lphb_ind_handler() - handle low power heart beat indication |
| 14445 | * @pHddCtx: Pointer to hdd context |
| 14446 | * @lphbInd: Pointer to low power heart beat indication parameter |
| 14447 | * |
| 14448 | * Return: none |
| 14449 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 14450 | static void wlan_hdd_cfg80211_lphb_ind_handler(void *pHddCtx, |
| 14451 | tSirLPHBInd *lphbInd) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14452 | { |
| 14453 | struct sk_buff *skb; |
| 14454 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14455 | hdd_err("LPHB indication arrived"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14456 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14457 | if (0 != wlan_hdd_validate_context((hdd_context_t *) pHddCtx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14458 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14459 | |
| 14460 | if (NULL == lphbInd) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14461 | hdd_err("invalid argument lphbInd"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14462 | return; |
| 14463 | } |
| 14464 | |
| 14465 | skb = cfg80211_testmode_alloc_event_skb(((hdd_context_t *) pHddCtx)-> |
| 14466 | wiphy, sizeof(tSirLPHBInd), |
| 14467 | GFP_ATOMIC); |
| 14468 | if (!skb) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14469 | hdd_err("LPHB timeout, NL buffer alloc fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14470 | return; |
| 14471 | } |
| 14472 | |
| 14473 | 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] | 14474 | hdd_err("WLAN_HDD_TM_ATTR_CMD put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14475 | goto nla_put_failure; |
| 14476 | } |
| 14477 | if (nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14478 | hdd_err("WLAN_HDD_TM_ATTR_TYPE put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14479 | goto nla_put_failure; |
| 14480 | } |
| 14481 | if (nla_put(skb, WLAN_HDD_TM_ATTR_DATA, sizeof(tSirLPHBInd), lphbInd)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14482 | hdd_err("WLAN_HDD_TM_ATTR_DATA put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14483 | goto nla_put_failure; |
| 14484 | } |
| 14485 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 14486 | return; |
| 14487 | |
| 14488 | nla_put_failure: |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14489 | hdd_err("NLA Put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14490 | kfree_skb(skb); |
| 14491 | |
| 14492 | return; |
| 14493 | } |
| 14494 | #endif /* FEATURE_WLAN_LPHB */ |
| 14495 | |
| 14496 | /** |
| 14497 | * __wlan_hdd_cfg80211_testmode() - test mode |
| 14498 | * @wiphy: Pointer to wiphy |
| 14499 | * @data: Data pointer |
| 14500 | * @len: Data length |
| 14501 | * |
| 14502 | * Return: 0 for success, non-zero for failure |
| 14503 | */ |
| 14504 | static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, |
| 14505 | void *data, int len) |
| 14506 | { |
| 14507 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 14508 | int err; |
| 14509 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 14510 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14511 | ENTER(); |
| 14512 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14513 | err = wlan_hdd_validate_context(pHddCtx); |
| 14514 | if (err) |
| 14515 | return err; |
| 14516 | |
| 14517 | err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, |
| 14518 | len, wlan_hdd_tm_policy); |
| 14519 | if (err) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14520 | hdd_err("Testmode INV ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14521 | return err; |
| 14522 | } |
| 14523 | |
| 14524 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14525 | hdd_err("Testmode INV CMD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14526 | return -EINVAL; |
| 14527 | } |
| 14528 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 14529 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 14530 | TRACE_CODE_HDD_CFG80211_TESTMODE, |
| 14531 | NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14532 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) { |
| 14533 | #ifdef FEATURE_WLAN_LPHB |
| 14534 | /* Low Power Heartbeat configuration request */ |
| 14535 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 14536 | { |
| 14537 | int buf_len; |
| 14538 | void *buf; |
| 14539 | tSirLPHBReq *hb_params = NULL; |
| 14540 | tSirLPHBReq *hb_params_temp = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14541 | QDF_STATUS smeStatus; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14542 | |
| 14543 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14544 | hdd_err("Testmode INV DATA"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14545 | return -EINVAL; |
| 14546 | } |
| 14547 | |
| 14548 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 14549 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 14550 | |
| 14551 | hb_params_temp = (tSirLPHBReq *) buf; |
| 14552 | if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) |
| 14553 | && (hb_params_temp->params.lphbTcpParamReq. |
| 14554 | timePeriodSec == 0)) |
| 14555 | return -EINVAL; |
| 14556 | |
| 14557 | hb_params = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14558 | (tSirLPHBReq *) qdf_mem_malloc(sizeof(tSirLPHBReq)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14559 | if (NULL == hb_params) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14560 | hdd_err("Request Buffer Alloc Fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14561 | return -ENOMEM; |
| 14562 | } |
| 14563 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14564 | qdf_mem_copy(hb_params, buf, buf_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14565 | smeStatus = |
| 14566 | sme_lphb_config_req((tHalHandle) (pHddCtx->hHal), |
| 14567 | hb_params, |
| 14568 | wlan_hdd_cfg80211_lphb_ind_handler); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14569 | if (QDF_STATUS_SUCCESS != smeStatus) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14570 | hdd_err("LPHB Config Fail, disable"); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14571 | qdf_mem_free(hb_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14572 | } |
| 14573 | return 0; |
| 14574 | } |
| 14575 | #endif /* FEATURE_WLAN_LPHB */ |
| 14576 | |
| 14577 | #if defined(QCA_WIFI_FTM) |
| 14578 | case WLAN_HDD_TM_CMD_WLAN_FTM: |
| 14579 | { |
| 14580 | int buf_len; |
| 14581 | void *buf; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14582 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14583 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) { |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 14584 | hdd_err("WLAN_HDD_TM_ATTR_DATA attribute is invalid"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14585 | return -EINVAL; |
| 14586 | } |
| 14587 | |
| 14588 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 14589 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 14590 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 14591 | hdd_info("****FTM Tx cmd len = %d*****", buf_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14592 | |
| 14593 | status = wlan_hdd_ftm_testmode_cmd(buf, buf_len); |
| 14594 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14595 | if (status != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14596 | err = -EBUSY; |
| 14597 | break; |
| 14598 | } |
| 14599 | #endif |
| 14600 | |
| 14601 | default: |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14602 | hdd_err("command %d not supported", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14603 | nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])); |
| 14604 | return -EOPNOTSUPP; |
| 14605 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14606 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14607 | return err; |
| 14608 | } |
| 14609 | |
| 14610 | /** |
| 14611 | * wlan_hdd_cfg80211_testmode() - test mode |
| 14612 | * @wiphy: Pointer to wiphy |
| 14613 | * @dev: Pointer to network device |
| 14614 | * @data: Data pointer |
| 14615 | * @len: Data length |
| 14616 | * |
| 14617 | * Return: 0 for success, non-zero for failure |
| 14618 | */ |
| 14619 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, |
| 14620 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) |
| 14621 | struct wireless_dev *wdev, |
| 14622 | #endif |
| 14623 | void *data, int len) |
| 14624 | { |
| 14625 | int ret; |
| 14626 | |
| 14627 | cds_ssr_protect(__func__); |
| 14628 | ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len); |
| 14629 | cds_ssr_unprotect(__func__); |
| 14630 | |
| 14631 | return ret; |
| 14632 | } |
| 14633 | |
| 14634 | #if defined(QCA_WIFI_FTM) |
| 14635 | /** |
| 14636 | * wlan_hdd_testmode_rx_event() - test mode rx event handler |
| 14637 | * @buf: Pointer to buffer |
| 14638 | * @buf_len: Buffer length |
| 14639 | * |
| 14640 | * Return: none |
| 14641 | */ |
| 14642 | void wlan_hdd_testmode_rx_event(void *buf, size_t buf_len) |
| 14643 | { |
| 14644 | struct sk_buff *skb; |
| 14645 | hdd_context_t *hdd_ctx; |
| 14646 | |
| 14647 | if (!buf || !buf_len) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14648 | hdd_err("buf or buf_len invalid, buf = %p buf_len = %zu", buf, buf_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14649 | return; |
| 14650 | } |
| 14651 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14652 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14653 | if (!hdd_ctx) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14654 | hdd_err("hdd context invalid"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14655 | return; |
| 14656 | } |
| 14657 | |
| 14658 | skb = cfg80211_testmode_alloc_event_skb(hdd_ctx->wiphy, |
| 14659 | buf_len, GFP_KERNEL); |
| 14660 | if (!skb) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14661 | hdd_err("failed to allocate testmode rx skb!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14662 | return; |
| 14663 | } |
| 14664 | |
| 14665 | if (nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_FTM) || |
| 14666 | nla_put(skb, WLAN_HDD_TM_ATTR_DATA, buf_len, buf)) |
| 14667 | goto nla_put_failure; |
| 14668 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 14669 | hdd_info("****FTM Rx cmd len = %zu*****", buf_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14670 | |
| 14671 | cfg80211_testmode_event(skb, GFP_KERNEL); |
| 14672 | return; |
| 14673 | |
| 14674 | nla_put_failure: |
| 14675 | kfree_skb(skb); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14676 | hdd_err("nla_put failed on testmode rx skb!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14677 | } |
| 14678 | #endif |
| 14679 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 14680 | |
| 14681 | #ifdef QCA_HT_2040_COEX |
| 14682 | /** |
| 14683 | * __wlan_hdd_cfg80211_set_ap_channel_width() - set ap channel bandwidth |
| 14684 | * @wiphy: Pointer to wiphy |
| 14685 | * @dev: Pointer to network device |
| 14686 | * @chandef: Pointer to channel definition parameter |
| 14687 | * |
| 14688 | * Return: 0 for success, non-zero for failure |
| 14689 | */ |
| 14690 | static int |
| 14691 | __wlan_hdd_cfg80211_set_ap_channel_width(struct wiphy *wiphy, |
| 14692 | struct net_device *dev, |
| 14693 | struct cfg80211_chan_def *chandef) |
| 14694 | { |
| 14695 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14696 | hdd_context_t *pHddCtx; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14697 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14698 | tSmeConfigParams sme_config; |
Anurag Chouhan | 00ed527 | 2016-10-17 17:22:55 +0530 | [diff] [blame] | 14699 | bool cbModeChange = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14700 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14701 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14702 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14703 | return -EINVAL; |
| 14704 | } |
| 14705 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14706 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 14707 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 14708 | return -EINVAL; |
| 14709 | } |
| 14710 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14711 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 14712 | status = wlan_hdd_validate_context(pHddCtx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 14713 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14714 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14715 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14716 | qdf_mem_zero(&sme_config, sizeof(tSmeConfigParams)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14717 | sme_get_config_param(pHddCtx->hHal, &sme_config); |
| 14718 | switch (chandef->width) { |
| 14719 | case NL80211_CHAN_WIDTH_20: |
| 14720 | if (sme_config.csrConfig.channelBondingMode24GHz != |
| 14721 | eCSR_INI_SINGLE_CHANNEL_CENTERED) { |
| 14722 | sme_config.csrConfig.channelBondingMode24GHz = |
| 14723 | eCSR_INI_SINGLE_CHANNEL_CENTERED; |
| 14724 | sme_update_config(pHddCtx->hHal, &sme_config); |
| 14725 | cbModeChange = true; |
| 14726 | } |
| 14727 | break; |
| 14728 | |
| 14729 | case NL80211_CHAN_WIDTH_40: |
| 14730 | if (sme_config.csrConfig.channelBondingMode24GHz == |
| 14731 | eCSR_INI_SINGLE_CHANNEL_CENTERED) { |
| 14732 | if (NL80211_CHAN_HT40MINUS == |
| 14733 | cfg80211_get_chandef_type(chandef)) |
| 14734 | sme_config.csrConfig.channelBondingMode24GHz = |
| 14735 | eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY; |
| 14736 | else |
| 14737 | sme_config.csrConfig.channelBondingMode24GHz = |
| 14738 | eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY; |
| 14739 | sme_update_config(pHddCtx->hHal, &sme_config); |
| 14740 | cbModeChange = true; |
| 14741 | } |
| 14742 | break; |
| 14743 | |
| 14744 | default: |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14745 | hdd_err("Error!!! Invalid HT20/40 mode !"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14746 | return -EINVAL; |
| 14747 | } |
| 14748 | |
| 14749 | if (!cbModeChange) |
| 14750 | return 0; |
| 14751 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 14752 | if (QDF_SAP_MODE != pAdapter->device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14753 | return 0; |
| 14754 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14755 | hdd_notice("Channel bonding changed to %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14756 | sme_config.csrConfig.channelBondingMode24GHz); |
| 14757 | |
| 14758 | /* Change SAP ht2040 mode */ |
| 14759 | status = hdd_set_sap_ht2040_mode(pAdapter, |
| 14760 | cfg80211_get_chandef_type(chandef)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14761 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14762 | hdd_err("Error!!! Cannot set SAP HT20/40 mode!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14763 | return -EINVAL; |
| 14764 | } |
| 14765 | |
| 14766 | return 0; |
| 14767 | } |
| 14768 | |
| 14769 | /** |
| 14770 | * wlan_hdd_cfg80211_set_ap_channel_width() - set ap channel bandwidth |
| 14771 | * @wiphy: Pointer to wiphy |
| 14772 | * @dev: Pointer to network device |
| 14773 | * @chandef: Pointer to channel definition parameter |
| 14774 | * |
| 14775 | * Return: 0 for success, non-zero for failure |
| 14776 | */ |
| 14777 | static int |
| 14778 | wlan_hdd_cfg80211_set_ap_channel_width(struct wiphy *wiphy, |
| 14779 | struct net_device *dev, |
| 14780 | struct cfg80211_chan_def *chandef) |
| 14781 | { |
| 14782 | int ret; |
| 14783 | |
| 14784 | cds_ssr_protect(__func__); |
| 14785 | ret = __wlan_hdd_cfg80211_set_ap_channel_width(wiphy, dev, chandef); |
| 14786 | cds_ssr_unprotect(__func__); |
| 14787 | |
| 14788 | return ret; |
| 14789 | } |
| 14790 | #endif |
| 14791 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14792 | #ifdef CHANNEL_SWITCH_SUPPORTED |
| 14793 | /** |
| 14794 | * __wlan_hdd_cfg80211_channel_switch()- function to switch |
| 14795 | * channel in SAP/GO |
| 14796 | * @wiphy: wiphy pointer |
| 14797 | * @dev: dev pointer. |
| 14798 | * @csa_params: Change channel params |
| 14799 | * |
| 14800 | * This function is called to switch channel in SAP/GO |
| 14801 | * |
| 14802 | * Return: 0 if success else return non zero |
| 14803 | */ |
| 14804 | static int __wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy, |
| 14805 | struct net_device *dev, |
| 14806 | struct cfg80211_csa_settings *csa_params) |
| 14807 | { |
| 14808 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14809 | hdd_context_t *hdd_ctx; |
| 14810 | uint8_t channel; |
| 14811 | uint16_t freq; |
| 14812 | int ret; |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 14813 | enum phy_ch_width ch_width; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14814 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14815 | hdd_notice("Set Freq %d", |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14816 | csa_params->chandef.chan->center_freq); |
| 14817 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14818 | if (wlan_hdd_validate_session_id(adapter->sessionId)) { |
| 14819 | hdd_err("invalid session id: %d", adapter->sessionId); |
| 14820 | return -EINVAL; |
| 14821 | } |
| 14822 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14823 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14824 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14825 | |
| 14826 | if (0 != ret) |
| 14827 | return ret; |
| 14828 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 14829 | if ((QDF_P2P_GO_MODE != adapter->device_mode) && |
| 14830 | (QDF_SAP_MODE != adapter->device_mode)) |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14831 | return -ENOTSUPP; |
| 14832 | |
| 14833 | freq = csa_params->chandef.chan->center_freq; |
| 14834 | channel = cds_freq_to_chan(freq); |
| 14835 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 14836 | ch_width = hdd_map_nl_chan_width(csa_params->chandef.width); |
| 14837 | |
| 14838 | ret = hdd_softap_set_channel_change(dev, channel, ch_width); |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14839 | return ret; |
| 14840 | } |
| 14841 | |
| 14842 | /** |
| 14843 | * wlan_hdd_cfg80211_channel_switch()- function to switch |
| 14844 | * channel in SAP/GO |
| 14845 | * @wiphy: wiphy pointer |
| 14846 | * @dev: dev pointer. |
| 14847 | * @csa_params: Change channel params |
| 14848 | * |
| 14849 | * This function is called to switch channel in SAP/GO |
| 14850 | * |
| 14851 | * Return: 0 if success else return non zero |
| 14852 | */ |
| 14853 | static int wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy, |
| 14854 | struct net_device *dev, |
| 14855 | struct cfg80211_csa_settings *csa_params) |
| 14856 | { |
| 14857 | int ret; |
| 14858 | |
| 14859 | cds_ssr_protect(__func__); |
| 14860 | ret = __wlan_hdd_cfg80211_channel_switch(wiphy, dev, csa_params); |
| 14861 | cds_ssr_unprotect(__func__); |
| 14862 | return ret; |
| 14863 | } |
| 14864 | #endif |
| 14865 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14866 | /** |
| 14867 | * wlan_hdd_convert_nl_iftype_to_hdd_type() - provides the type |
| 14868 | * translation from NL to policy manager type |
| 14869 | * @type: Generic connection mode type defined in NL |
| 14870 | * |
| 14871 | * |
| 14872 | * This function provides the type translation |
| 14873 | * |
| 14874 | * Return: cds_con_mode enum |
| 14875 | */ |
| 14876 | enum cds_con_mode wlan_hdd_convert_nl_iftype_to_hdd_type( |
| 14877 | enum nl80211_iftype type) |
| 14878 | { |
| 14879 | enum cds_con_mode mode = CDS_MAX_NUM_OF_MODE; |
| 14880 | switch (type) { |
| 14881 | case NL80211_IFTYPE_STATION: |
| 14882 | mode = CDS_STA_MODE; |
| 14883 | break; |
| 14884 | case NL80211_IFTYPE_P2P_CLIENT: |
| 14885 | mode = CDS_P2P_CLIENT_MODE; |
| 14886 | break; |
| 14887 | case NL80211_IFTYPE_P2P_GO: |
| 14888 | mode = CDS_P2P_GO_MODE; |
| 14889 | break; |
| 14890 | case NL80211_IFTYPE_AP: |
| 14891 | mode = CDS_SAP_MODE; |
| 14892 | break; |
| 14893 | case NL80211_IFTYPE_ADHOC: |
| 14894 | mode = CDS_IBSS_MODE; |
| 14895 | break; |
| 14896 | default: |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14897 | hdd_err("Unsupported interface type (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14898 | type); |
| 14899 | } |
| 14900 | return mode; |
| 14901 | } |
| 14902 | |
| 14903 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 14904 | * wlan_hdd_cfg80211_set_mon_ch() - Set monitor mode capture channel |
| 14905 | * @wiphy: Handle to struct wiphy to get handle to module context. |
| 14906 | * @chandef: Contains information about the capture channel to be set. |
| 14907 | * |
| 14908 | * This interface is called if and only if monitor mode interface alone is |
| 14909 | * active. |
| 14910 | * |
| 14911 | * Return: 0 success or error code on failure. |
| 14912 | */ |
| 14913 | static int __wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy, |
| 14914 | struct cfg80211_chan_def *chandef) |
| 14915 | { |
| 14916 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 14917 | hdd_adapter_t *adapter; |
| 14918 | hdd_station_ctx_t *sta_ctx; |
| 14919 | struct hdd_mon_set_ch_info *ch_info; |
| 14920 | QDF_STATUS status; |
| 14921 | tHalHandle hal_hdl; |
| 14922 | struct qdf_mac_addr bssid; |
| 14923 | tCsrRoamProfile roam_profile; |
| 14924 | struct ch_params_s ch_params; |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 14925 | uint8_t sec_ch = 0; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 14926 | int ret; |
| 14927 | uint16_t chan_num = cds_freq_to_chan(chandef->chan->center_freq); |
| 14928 | |
| 14929 | ENTER(); |
| 14930 | |
| 14931 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14932 | if (ret) |
| 14933 | return ret; |
| 14934 | |
| 14935 | hal_hdl = hdd_ctx->hHal; |
| 14936 | |
| 14937 | adapter = hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE); |
| 14938 | if (!adapter) |
| 14939 | return -EIO; |
| 14940 | |
| 14941 | hdd_info("%s: set monitor mode Channel %d and freq %d", |
| 14942 | adapter->dev->name, chan_num, chandef->chan->center_freq); |
| 14943 | |
| 14944 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 14945 | ch_info = &sta_ctx->ch_info; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 14946 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 14947 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 14948 | roam_profile.phyMode = ch_info->phy_mode; |
| 14949 | roam_profile.ch_params.ch_width = chandef->width; |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 14950 | hdd_select_cbmode(adapter, chan_num, &roam_profile.ch_params); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 14951 | |
| 14952 | qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes, |
| 14953 | QDF_MAC_ADDR_SIZE); |
| 14954 | |
| 14955 | ch_params.ch_width = chandef->width; |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 14956 | /* |
| 14957 | * CDS api expects secondary channel for calculating |
| 14958 | * the channel params |
| 14959 | */ |
| 14960 | if ((ch_params.ch_width == CH_WIDTH_40MHZ) && |
| 14961 | (CDS_IS_CHANNEL_24GHZ(chan_num))) { |
| 14962 | if (chan_num >= 1 && chan_num <= 5) |
| 14963 | sec_ch = chan_num + 4; |
| 14964 | else if (chan_num >= 6 && chan_num <= 13) |
| 14965 | sec_ch = chan_num - 4; |
| 14966 | } |
| 14967 | cds_set_channel_params(chan_num, sec_ch, &ch_params); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 14968 | status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params, |
| 14969 | &roam_profile); |
| 14970 | if (status) { |
| 14971 | hdd_err("Status: %d Failed to set sme_RoamChannel for monitor mode", |
| 14972 | status); |
| 14973 | ret = qdf_status_to_os_return(status); |
| 14974 | return ret; |
| 14975 | } |
| 14976 | EXIT(); |
| 14977 | return 0; |
| 14978 | } |
| 14979 | |
| 14980 | /** |
| 14981 | * wlan_hdd_cfg80211_set_mon_ch() - Set monitor mode capture channel |
| 14982 | * @wiphy: Handle to struct wiphy to get handle to module context. |
| 14983 | * @chandef: Contains information about the capture channel to be set. |
| 14984 | * |
| 14985 | * This interface is called if and only if monitor mode interface alone is |
| 14986 | * active. |
| 14987 | * |
| 14988 | * Return: 0 success or error code on failure. |
| 14989 | */ |
| 14990 | static int wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy, |
| 14991 | struct cfg80211_chan_def *chandef) |
| 14992 | { |
| 14993 | int ret; |
| 14994 | |
| 14995 | cds_ssr_protect(__func__); |
| 14996 | ret = __wlan_hdd_cfg80211_set_mon_ch(wiphy, chandef); |
| 14997 | cds_ssr_unprotect(__func__); |
| 14998 | return ret; |
| 14999 | } |
| 15000 | |
| 15001 | /** |
Mahesh A Saptasagar | 6dda202 | 2016-09-03 12:59:09 +0530 | [diff] [blame] | 15002 | * wlan_hdd_clear_link_layer_stats() - clear link layer stats |
| 15003 | * @adapter: pointer to adapter |
| 15004 | * |
| 15005 | * Wrapper function to clear link layer stats. |
| 15006 | * return - void |
| 15007 | */ |
| 15008 | void wlan_hdd_clear_link_layer_stats(hdd_adapter_t *adapter) |
| 15009 | { |
| 15010 | tSirLLStatsClearReq link_layer_stats_clear_req; |
| 15011 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 15012 | |
Mukul Sharma | 491021c | 2016-09-29 21:39:19 +0530 | [diff] [blame] | 15013 | link_layer_stats_clear_req.statsClearReqMask = WIFI_STATS_IFACE_AC | |
| 15014 | WIFI_STATS_IFACE_ALL_PEER; |
Mahesh A Saptasagar | 6dda202 | 2016-09-03 12:59:09 +0530 | [diff] [blame] | 15015 | link_layer_stats_clear_req.stopReq = 0; |
| 15016 | link_layer_stats_clear_req.reqId = 1; |
| 15017 | link_layer_stats_clear_req.staId = adapter->sessionId; |
| 15018 | sme_ll_stats_clear_req(hal, &link_layer_stats_clear_req); |
| 15019 | |
| 15020 | return; |
| 15021 | } |
| 15022 | |
| 15023 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15024 | * struct cfg80211_ops - cfg80211_ops |
| 15025 | * |
| 15026 | * @add_virtual_intf: Add virtual interface |
| 15027 | * @del_virtual_intf: Delete virtual interface |
| 15028 | * @change_virtual_intf: Change virtual interface |
| 15029 | * @change_station: Change station |
| 15030 | * @add_beacon: Add beacon in sap mode |
| 15031 | * @del_beacon: Delete beacon in sap mode |
| 15032 | * @set_beacon: Set beacon in sap mode |
| 15033 | * @start_ap: Start ap |
| 15034 | * @change_beacon: Change beacon |
| 15035 | * @stop_ap: Stop ap |
| 15036 | * @change_bss: Change bss |
| 15037 | * @add_key: Add key |
| 15038 | * @get_key: Get key |
| 15039 | * @del_key: Delete key |
| 15040 | * @set_default_key: Set default key |
| 15041 | * @set_channel: Set channel |
| 15042 | * @scan: Scan |
| 15043 | * @connect: Connect |
| 15044 | * @disconnect: Disconnect |
| 15045 | * @join_ibss = Join ibss |
| 15046 | * @leave_ibss = Leave ibss |
| 15047 | * @set_wiphy_params = Set wiphy params |
| 15048 | * @set_tx_power = Set tx power |
| 15049 | * @get_tx_power = get tx power |
| 15050 | * @remain_on_channel = Remain on channel |
| 15051 | * @cancel_remain_on_channel = Cancel remain on channel |
| 15052 | * @mgmt_tx = Tx management frame |
| 15053 | * @mgmt_tx_cancel_wait = Cancel management tx wait |
| 15054 | * @set_default_mgmt_key = Set default management key |
| 15055 | * @set_txq_params = Set tx queue parameters |
| 15056 | * @get_station = Get station |
| 15057 | * @set_power_mgmt = Set power management |
| 15058 | * @del_station = Delete station |
| 15059 | * @add_station = Add station |
| 15060 | * @set_pmksa = Set pmksa |
| 15061 | * @del_pmksa = Delete pmksa |
| 15062 | * @flush_pmksa = Flush pmksa |
| 15063 | * @update_ft_ies = Update FT IEs |
| 15064 | * @tdls_mgmt = Tdls management |
| 15065 | * @tdls_oper = Tdls operation |
| 15066 | * @set_rekey_data = Set rekey data |
| 15067 | * @sched_scan_start = Scheduled scan start |
| 15068 | * @sched_scan_stop = Scheduled scan stop |
| 15069 | * @resume = Resume wlan |
| 15070 | * @suspend = Suspend wlan |
| 15071 | * @set_mac_acl = Set mac acl |
| 15072 | * @testmode_cmd = Test mode command |
| 15073 | * @set_ap_chanwidth = Set AP channel bandwidth |
| 15074 | * @dump_survey = Dump survey |
| 15075 | * @key_mgmt_set_pmk = Set pmk key management |
| 15076 | */ |
| 15077 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = { |
| 15078 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 15079 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 15080 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 15081 | .change_station = wlan_hdd_change_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15082 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 15083 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 15084 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15085 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 15086 | .add_key = wlan_hdd_cfg80211_add_key, |
| 15087 | .get_key = wlan_hdd_cfg80211_get_key, |
| 15088 | .del_key = wlan_hdd_cfg80211_del_key, |
| 15089 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
| 15090 | .scan = wlan_hdd_cfg80211_scan, |
| 15091 | .connect = wlan_hdd_cfg80211_connect, |
| 15092 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 15093 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 15094 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 15095 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 15096 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 15097 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
| 15098 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 15099 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 15100 | .mgmt_tx = wlan_hdd_mgmt_tx, |
| 15101 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 15102 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 15103 | .set_txq_params = wlan_hdd_set_txq_params, |
Himanshu Agarwal | 37e4241 | 2016-07-21 14:35:09 +0530 | [diff] [blame] | 15104 | .dump_station = wlan_hdd_cfg80211_dump_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15105 | .get_station = wlan_hdd_cfg80211_get_station, |
| 15106 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 15107 | .del_station = wlan_hdd_cfg80211_del_station, |
| 15108 | .add_station = wlan_hdd_cfg80211_add_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15109 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 15110 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 15111 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
Deepak Dhamdhere | 9f09e75 | 2016-01-09 23:17:25 -0800 | [diff] [blame] | 15112 | #if defined(KERNEL_SUPPORT_11R_CFG80211) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15113 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 15114 | #endif |
| 15115 | #ifdef FEATURE_WLAN_TDLS |
| 15116 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 15117 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 15118 | #endif |
| 15119 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 15120 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 15121 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
| 15122 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 15123 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 15124 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 15125 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
| 15126 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 15127 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
| 15128 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
| 15129 | #ifdef WLAN_NL80211_TESTMODE |
| 15130 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 15131 | #endif |
| 15132 | #ifdef QCA_HT_2040_COEX |
| 15133 | .set_ap_chanwidth = wlan_hdd_cfg80211_set_ap_channel_width, |
| 15134 | #endif |
| 15135 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 15136 | #ifdef CHANNEL_SWITCH_SUPPORTED |
| 15137 | .channel_switch = wlan_hdd_cfg80211_channel_switch, |
| 15138 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 15139 | .set_monitor_channel = wlan_hdd_cfg80211_set_mon_ch, |
Vidyullatha, Kanchanapally | 528789e | 2016-05-11 20:38:37 +0530 | [diff] [blame] | 15140 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)) || \ |
| 15141 | defined(CFG80211_ABORT_SCAN) |
| 15142 | .abort_scan = wlan_hdd_cfg80211_abort_scan, |
| 15143 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15144 | }; |